Skip to content
Source
Sign inSign up
pingdotgg/t3code

Expose project provider skills in chat #3982

Closedjakeleventhal(GitHub profile, opens in a new tab)wants to merge 7 commits intomain fromrefs/pull/3982/headopened View on GitHub

Summary

Screenshot 2026-07-14 at 10 40 42 PM Screenshot 2026-07-14 at 10 40 47 PM Screenshot 2026-07-14 at 10 41 18 PM Screenshot 2026-07-14 at 10 41 23 PM
  • add a provider-neutral, cwd-aware listSkills capability, RPC, client query, and composer pipeline
  • preserve snapshot fallback, disabled-provider handling, bounded probes, structured causes, keyed caching, and focus-safe chip metadata refreshes from #3901
  • discover Grok skills through its source of truth: grok --cwd <cwd> inspect --json
  • translate recognized enabled $skill references to Grok native /skill syntax only at the ACP boundary while retaining $skill in stored and rendered messages

This supersedes #3901. The replacement generalizes the project-skill feature across Codex and Grok without adding a second filesystem scanner or provider-specific web/RPC paths.

Validation

  • pnpm exec vp check
  • pnpm exec vp run typecheck
  • 89 focused provider, adapter, registry, composer-token, and skill-search tests
  • 104 contract and server tests
  • real-app Grok acceptance with a temporary project sentinel: cwd-aware menu discovery, cross-project invalidation, stable $skill chip storage, and successful native skill execution through ACP
  • real-app Codex $skill regression check

Note

Medium Risk Touches provider drivers, WebSocket RPC, and Grok prompt rewriting at the ACP layer; behavior is bounded by probes, caching, and tests, but incorrect skill resolution or rewrite logic could affect turn submission for Grok/Codex/Claude.

Overview Adds cwd-aware provider skill discovery so the $ skill menu and chips reflect the current project/worktree, not only static provider snapshot skills.

Server & contracts: New read-scoped WebSocket RPC server.listProviderSkills (instanceId + cwd) routes through ProviderRegistry.listSkills. Drivers that support it return discovered skills; others surface ServerProviderSkillsUnsupportedError. Claude, Codex, and Grok each implement listSkills(cwd) via their native discovery paths (Codex app-server probe can skip model listing for skill-only calls).

Grok runtime: Discovers skills via grok inspect --json. On send, enabled $skill tokens in prompts are rewritten to /skill only at the ACP boundary; stored/rendered composer text stays $skill. Discovery is skipped for prompts with no skill tokens and for all-caps tokens treated as env vars (e.g. $PATH).

Clients (web + mobile): useProviderSkills runs when the composer skill trigger is active. Results merge with a keyed cache (resolveComposerProviderSkills / getComposerProviderSkillsCacheEntry) so snapshot skills are used only when discovery is unsupported—not while cwd-aware fetches are pending. Skill popovers show loading states; EnvironmentQueryView exposes typed failure for unsupported detection.

Composer UX: Skill chip labels/descriptions can refresh when the skills list updates without resetting Lexical state or selection on web.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 09b0e54442ef910e0cfb7c7a6e341504a7e5e93f. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Expose provider skills in the chat composer via live cwd-aware discovery

  • Adds a server.listProviderSkills WebSocket RPC that queries the active provider instance's listSkills effect (Claude, Codex, Grok) for a given cwd, returning structured skills or typed errors (ServerProviderSkillsUnsupportedError / ServerProviderSkillsError).
  • Implements listGrokSkills (runs grok inspect --json), discoverClaudeSkills, and a Codex skills probe via probeCodexAppServerProvider with includeModels=false as the per-driver discovery backends.
  • The Grok adapter rewrites $skill tokens to /skill path-style references in the prompt when live discovery confirms the skill is enabled; shell-style env-var tokens (e.g. $MY_VAR) are excluded from rewriting.
  • Web and mobile composers use the new useProviderSkills hook to fetch skills, cache results per (environmentId, instanceId, cwd) target key, and fall back to snapshot skills when discovery is unsupported or pending.
  • Skill chip labels/descriptions in ComposerPromptEditor now refresh in-place without resetting editor state or cursor position when the skills list changes.
  • Risk: Grok skill discovery runs an external subprocess (grok inspect) per turn when $-prefixed tokens are present; it times out after 10 s and surfaces as a ProviderAdapterRequestError.
📊 Macroscope summarized 09b0e54. 25 files reviewed, 0 issues evaluated, 0 issues filtered, 0 comments posted

🗂️ Filtered Issues

No issues evaluated.

    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: c01af707-168f-42d8-b9cf-61ac153356ca

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 High

      https://github.com/pingdotgg/t3code/blob/887c71854c9f9fc64b8eb6a72eb82b577726650b/apps/server/src/provider/Layers/GrokAdapter.ts#L1046

      When a turn requests a new model and contains a skill token, a listSkills failure after applyGrokAcpModelSelection has already switched the ACP session leaves the session on the new model while ctx.currentModelId still records the old model. A subsequent turn without an explicit model selection skips setSessionModel and runs on the unintended model while reporting the stale one. The model switch happens at line 977, but ctx.currentModelId is only updated at line 1047 — after the listSkills call at line 988 that can fail and abort the turn. Consider updating ctx.currentModelId immediately after the model switch succeeds, before the skill-lookup call.

      ✅ Resolved in 1982e2fefd205f13c94fbc4893f221b80e3a0967

    4. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Needs human review

      5 blocking correctness issues found. New feature introducing project-aware provider skill discovery with new RPC endpoints, subprocess spawning, and UI integration across mobile and web. Multiple unresolved review comments identify potential bugs (stale caching, missing config, authorization scope concerns) that warrant human review before merge.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    5. Fixed in 764cb4040. The adapter now synchronizes its internal and public model state immediately after session/set_model succeeds, before skill discovery can fail. Regression coverage verifies a model-less follow-up does not repeat or revert the switch.

    6. Sorry, I'm unable to act on this request because you do not have permissions within this repository.

    7. 💡 Codex Review

      Here are some automated review suggestions for this pull request.

      Reviewed commit: 917ea83630

      ℹ️ About Codex in GitHub

      Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

      • Open a pull request for review
      • Mark a draft as ready
      • Comment "@codex review".

      If Codex has suggestions, it will comment; otherwise it will react with 👍.

      Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

      @@ -0,0 +114,21 @@
      114+ ["--cwd", input.cwd, "inspect", "--json"],
      115+ input.environment ? { env: input.environment } : {},
      116+ ).pipe(
      117+ Effect.mapError(
      118+ (cause) =>
      119+ new GrokSkillDiscoveryError({
      120+ operation: "run",
      121+ detail: "The Grok executable could not be resolved.",
      122+ cause,
      123+ }),
      124+ ),
      125+ );
      126+
      127+ const commandResult = yield* spawnAndCollect(
      128+ binaryPath,
      129+ ChildProcess.make(spawnCommand.command, spawnCommand.args, {
      130+ cwd: input.cwd,
      131+ ...(input.environment ? { env: input.environment } : {}),
      132+ shell: spawnCommand.shell,
      133+ }),
      134+ ).pipe(

      P2 Badge Scope each Grok inspect probe

      When grok inspect hangs or is interrupted, this spawn is only attached to whatever ambient Scope happens to be running the RPC/adapter call; GrokDriver.listSkills exposes it as a normal service method and does not create a per-call scope. In that case the 10s timeout can return an error while the child process remains tied to a longer-lived provider/server scope, so repeated $ menu opens or sends with $skill tokens can accumulate stuck grok inspect processes until shutdown. Wrap the spawned spawnAndCollect probe in its own Effect.scoped before applying the timeout.

      Useful? React with 👍 / 👎.

      @@ -0,0 +20,21 @@
      20+ return {
      21+ targetKey: input.targetKey,
      22+ skills: input.snapshotSkills ?? EMPTY_PROVIDER_SKILLS,
      23+ };
      24+ }
      25+ return null;
      26+}
      27+
      28+export function resolveComposerProviderSkills(input: {
      29+ readonly targetKey: string;
      30+ readonly discoveredSkills: ReadonlyArray<ServerProviderSkill> | null;
      31+ readonly cachedSkills: CachedComposerProviderSkills | null;
      32+ readonly snapshotSkills: ReadonlyArray<ServerProviderSkill> | undefined;
      33+ readonly discoveryUnsupported: boolean;
      34+}): ReadonlyArray<ServerProviderSkill> {
      35+ if (input.discoveredSkills !== null) {
      36+ return input.discoveredSkills;
      37+ }
      38+
      39+ if (input.cachedSkills?.targetKey === input.targetKey) {
      40+ return input.cachedSkills.skills;

      P2 Badge Avoid serving cached skills after discovery failures

      When the current cwd-aware skill query fails (for example, grok inspect exits non-zero), discoveredSkills is null and discoveryUnsupported is false, so this branch still returns the previous successful cache for the same target. That makes the menu offer stale skills while the provider is currently unable to rediscover them; selecting one then sends a $skill token that Grok re-checks at send time and fails, blocking the turn instead of surfacing the discovery failure in the composer.

      Useful? React with 👍 / 👎.

      @@ -951,3 +957,8 @@
      951957 cwd: isPathTrigger ? gitCwd : null,
      952958 query: isPathTrigger ? pathTriggerQuery : null,
      953959 });
      960+ const providerSkills = useProviderSkills({
      961+ environmentId,
      962+ instanceId: selectedProviderStatus?.instanceId ?? null,
      963+ cwd: gitCwd,
      964+ enabled: composerTriggerKind === "skill",

      P2 Badge Do not probe skills for env-var tokens

      When the user types a shell/env-var token such as $PATH or $NODE_ENV, detectComposerTrigger still marks the token as a skill, so this enables server.listProviderSkills and spawns provider CLI probes even though the Grok send path explicitly filters uppercase env-var-style tokens. In prompts or docs involving env vars, merely placing the cursor after $PATH opens the skill menu and can run grok inspect; gate this query with the same env-var-style check or wait until the token can plausibly be a skill.

      Useful? React with 👍 / 👎.

    8. @@ -161,3 +165,16 @@
      161165 ...(eventLoggers.native ? { nativeEventLogger: eventLoggers.native } : {}),
      162166 });
      163167 const textGeneration = yield* makeCodexTextGeneration(effectiveConfig, processEnv);
      168+ const listSkills = Effect.fn("CodexDriver.listSkills")(function* (cwd: string) {
      169+ if (!effectiveConfig.enabled) {
      170+ return [];
      171+ }
      172+
      173+ return yield* probeCodexAppServerProvider({
      174+ binaryPath: effectiveConfig.binaryPath,
      175+ homePath: effectiveConfig.homePath,
      176+ cwd,
      177+ customModels: [],
      178+ environment: processEnv,
      179+ includeModels: false,
      180+ }).pipe(
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium Drivers/CodexDriver.ts:173

      listSkills calls probeCodexAppServerProvider without passing effectiveConfig.launchArgs, so instances that require custom Codex launch arguments (e.g. --config flags) are probed with a different app-server configuration than their normal snapshot and sessions. Skill discovery can return the wrong skill set or fail even though the provider itself works. Pass launchArgs: resolveCodexLaunchArgs(effectiveConfig.launchArgs, processEnv) as the status probe already does.

      Suggested change
      174+ return yield* probeCodexAppServerProvider({
      175+ binaryPath: effectiveConfig.binaryPath,
      176+ homePath: effectiveConfig.homePath,
      177+ launchArgs: resolveCodexLaunchArgs(effectiveConfig.launchArgs, processEnv),
      178+ cwd,
      179+ customModels: [],
      180+ environment: processEnv,
      181+ includeModels: false,
      182+ }).pipe(
      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/server/src/provider/Drivers/CodexDriver.ts around lines 173-180:
      
      `listSkills` calls `probeCodexAppServerProvider` without passing `effectiveConfig.launchArgs`, so instances that require custom Codex launch arguments (e.g. `--config` flags) are probed with a different app-server configuration than their normal snapshot and sessions. Skill discovery can return the wrong skill set or fail even though the provider itself works. Pass `launchArgs: resolveCodexLaunchArgs(effectiveConfig.launchArgs, processEnv)` as the status probe already does.
    9. 💡 Codex Review

      Here are some automated review suggestions for this pull request.

      Reviewed commit: ecda6483c4

      ℹ️ About Codex in GitHub

      Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

      • Open a pull request for review
      • Mark a draft as ready
      • Comment "@codex review".

      If Codex has suggestions, it will comment; otherwise it will react with 👍.

      Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

      @@ -161,3 +165,15 @@
      161165 ...(eventLoggers.native ? { nativeEventLogger: eventLoggers.native } : {}),
      162166 });
      163167 const textGeneration = yield* makeCodexTextGeneration(effectiveConfig, processEnv);
      168+ const listSkills = Effect.fn("CodexDriver.listSkills")(function* (cwd: string) {
      169+ if (!effectiveConfig.enabled) {
      170+ return [];
      171+ }
      172+
      173+ return yield* probeCodexAppServerProvider({
      174+ binaryPath: effectiveConfig.binaryPath,
      175+ homePath: effectiveConfig.homePath,
      176+ cwd,
      177+ customModels: [],
      178+ environment: processEnv,
      179+ includeModels: false,

      P2 Badge Pass Codex launch args to skill probes

      When a Codex instance is configured with launchArgs or T3CODE_CODEX_LAUNCH_ARGS (for example --strict-config, --config, or feature flags), status checks and real sessions resolve and pass those args, but this new server.listProviderSkills path starts a plain app-server without them. In that configuration the $ menu can discover a different skill set or fail even though the provider itself works with the configured app-server; pass the resolved launch args into probeCodexAppServerProvider here as the other Codex app-server callers do.

      Useful? React with 👍 / 👎.

      @@ -295,3 +297,4 @@
      295297 [WS_METHODS.serverProbe, AuthOrchestrationReadScope],
      296298 [WS_METHODS.serverGetConfig, AuthOrchestrationReadScope],
      297299 [WS_METHODS.serverRefreshProviders, AuthOrchestrationOperateScope],
      300+ [WS_METHODS.serverListProviderSkills, AuthOrchestrationReadScope],

      P2 Badge Gate skill discovery behind operate scope

      For sessions that only have orchestration:read, this new RPC still reaches the handler that calls providerRegistry.listSkills, and the new driver implementations start provider subprocesses (codex app-server or grok inspect) in the requested cwd. Comparable provider probing via serverRefreshProviders is already orchestration:operate, so leaving this as read-only lets restricted clients launch local provider processes through the skill menu; require the operate scope here as well.

      Useful? React with 👍 / 👎.

    10. @@ -111,3 +119,14 @@
      111119 };
      112120 }
      113121
      122+export function useProviderSkills(target: {
      123+ readonly environmentId: EnvironmentId | null;
      124+ readonly instanceId: ProviderInstanceId | null;
      125+ readonly cwd: string | null;
      126+ readonly enabled: boolean;
      127+}) {
      128+ const result = useEnvironmentQuery(
      129+ target.enabled &&
      130+ target.environmentId !== null &&
      131+ target.instanceId !== null &&
      132+ target.cwd !== null
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium state/queries.ts:129

      useProviderSkills treats an empty cwd string as a valid target — it only checks target.cwd !== null — so when the new-task flow passes workspaceRoot: "" for a pending task and the user types a $ trigger, the hook sends a provider-skills RPC with cwd: "" instead of disabling the query. The contract requires a non-empty cwd, so discovery fails as a normal error rather than being skipped or falling back as unsupported, leaving skills unavailable for that pending-task case. Use the same empty-string-to-null coercion that useBranches applies.

      -    target.enabled &&
      -      target.environmentId !== null &&
      -      target.instanceId !== null &&
      -      target.cwd !== null
      +    target.enabled &&
      +      target.environmentId !== null &&
      +      target.instanceId !== null &&
      +      target.cwd !== null &&
      +      target.cwd !== ""
      Also found in 1 other location(s)

      apps/mobile/src/features/threads/new-task-flow-provider.tsx:407

      providerSkillsCwd preserves the empty string from an editing placeholder project&#39;s workspaceRoot. When a queued task has no snapshotted projectCwd, its shell is unavailable, and the user types a skill trigger, useProviderSkills therefore sends discovery with cwd: &#34;&#34; instead of disabling the query. This contradicts the placeholder&#39;s explicit no-cwd sentinel and can discover against an unintended process-relative directory or fail, leaving the skill menu incorrect; use the same empty-string-to-null handling as branchTarget.

      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/mobile/src/state/queries.ts around lines 129-132:
      
      `useProviderSkills` treats an empty `cwd` string as a valid target — it only checks `target.cwd !== null` — so when the new-task flow passes `workspaceRoot: ""` for a pending task and the user types a `$` trigger, the hook sends a provider-skills RPC with `cwd: ""` instead of disabling the query. The contract requires a non-empty `cwd`, so discovery fails as a normal error rather than being skipped or falling back as unsupported, leaving skills unavailable for that pending-task case. Use the same empty-string-to-`null` coercion that `useBranches` applies.
      
      Also found in 1 other location(s):
      - apps/mobile/src/features/threads/new-task-flow-provider.tsx:407 -- `providerSkillsCwd` preserves the empty string from an editing placeholder project's `workspaceRoot`. When a queued task has no snapshotted `projectCwd`, its shell is unavailable, and the user types a skill trigger, `useProviderSkills` therefore sends discovery with `cwd: ""` instead of disabling the query. This contradicts the placeholder's explicit no-cwd sentinel and can discover against an unintended process-relative directory or fail, leaving the skill menu incorrect; use the same empty-string-to-`null` handling as `branchTarget`.
      
      @@ -86 +89,21 @@
      8689 readonly instanceId?: ProviderInstanceId;
      90+ readonly listSkills?: (
      91+ cwd: string,
      92+ ) => Effect.Effect<ReadonlyArray<ServerProviderSkill>, ProviderDriverError>;
      93+}
      94+
      95+// Provider requests contain only flattened prompt text, so an inserted skill
      96+// chip cannot be distinguished from manually typed shell syntax here. Grok's
      97+// normal skill names are lowercase or qualified; reserve conventional
      98+// all-uppercase identifiers for environment variables so `$PATH` does not run
      99+// (or fail on) `grok inspect`. An all-uppercase skill can still be rewritten
      100+// when discovery is triggered by another normal skill token in the prompt.
      101+const ENVIRONMENT_VARIABLE_STYLE_TOKEN = /^[A-Z][A-Z0-9_]*$/;
      102+
      103+function submittedSkillTokens(input: string) {
      104+ return collectComposerInlineTokens(input, { includeTrailingSkillToken: true }).filter(
      105+ (token) => token.type === "skill",
      106+ );
      107+}
      108+
      109+function potentialGrokSkillTokens(input: string) {
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium Layers/GrokAdapter.ts:109

      potentialGrokSkillTokens filters out only all-uppercase tokens, so a lowercase shell variable like $foo in a prompt such as echo $foo is treated as a skill token and triggers listSkills. When grok inspect fails, sendTurn rejects the entire prompt with ProviderAdapterRequestError instead of sending the literal text. This breaks otherwise-valid prompts that happen to contain ordinary shell syntax. Consider tightening the token classification so common shell variables are not mistaken for skill names, or make discovery failures non-fatal so the prompt is still sent as literal text.

      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/server/src/provider/Layers/GrokAdapter.ts around line 109:
      
      `potentialGrokSkillTokens` filters out only all-uppercase tokens, so a lowercase shell variable like `$foo` in a prompt such as `echo $foo` is treated as a skill token and triggers `listSkills`. When `grok inspect` fails, `sendTurn` rejects the entire prompt with `ProviderAdapterRequestError` instead of sending the literal text. This breaks otherwise-valid prompts that happen to contain ordinary shell syntax. Consider tightening the token classification so common shell variables are not mistaken for skill names, or make discovery failures non-fatal so the prompt is still sent as literal text.
      @@ -508,3 +508,4 @@
      508508 );
      509509 });
      510510
      511+ const listSkills = Effect.fn("ProviderRegistry.listSkills")(function* (input: {
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium Layers/ProviderRegistry.ts:511

      listSkills reads instances from liveSubsRef, which is only updated asynchronously by syncLiveSources. During a settings reconcile, ProviderInstanceRegistryLive closes the old instance and publishes the replacement before syncLiveSources mirrors it into liveSubsRef, so a skills RPC arriving in that window invokes listSkills on an already-closed instance (or finds no instance at all), causing a transient probe failure or stale result. The instance registry is the authoritative source; resolve the instance directly through it as other instance-routed operations do.

      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/server/src/provider/Layers/ProviderRegistry.ts around line 511:
      
      `listSkills` reads instances from `liveSubsRef`, which is only updated asynchronously by `syncLiveSources`. During a settings reconcile, `ProviderInstanceRegistryLive` closes the old instance and publishes the replacement before `syncLiveSources` mirrors it into `liveSubsRef`, so a skills RPC arriving in that window invokes `listSkills` on an already-closed instance (or finds no instance at all), causing a transient probe failure or stale result. The instance registry is the authoritative source; resolve the instance directly through it as other instance-routed operations do.
    11. 💡 Codex Review

      Here are some automated review suggestions for this pull request.

      Reviewed commit: 0ab50441ed

      ℹ️ About Codex in GitHub

      Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

      • Open a pull request for review
      • Mark a draft as ready
      • Comment "@codex review".

      If Codex has suggestions, it will comment; otherwise it will react with 👍.

      Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

      @@ -1018,0 +1032,21 @@
      1032+ const [cachedProviderSkills, setCachedProviderSkills] =
      1033+ useState<CachedComposerProviderSkills | null>(null);
      1034+ useEffect(() => {
      1035+ const cacheEntry = getComposerProviderSkillsCacheEntry({
      1036+ targetKey: providerSkillsTargetKey,
      1037+ discoveredSkills: providerSkills.data?.skills ?? null,
      1038+ snapshotSkills: selectedProviderStatus?.skills,
      1039+ discoveryUnsupported: providerSkills.isUnsupported,
      1040+ });
      1041+ if (cacheEntry !== null) {
      1042+ setCachedProviderSkills(cacheEntry);
      1043+ }
      1044+ }, [
      1045+ providerSkills.data,
      1046+ providerSkills.isUnsupported,
      1047+ providerSkillsTargetKey,
      1048+ selectedProviderStatus?.skills,
      1049+ ]);
      1050+ const composerProviderSkills = resolveComposerProviderSkills({
      1051+ targetKey: providerSkillsTargetKey,
      1052+ discoveredSkills: providerSkills.data?.skills ?? null,

      P2 Badge Share discovered skills with message timelines

      When a skill exists only in the cwd-aware result—especially for Grok, whose provider snapshots contain no skills—this list remains local to ChatComposer and is only passed to the editor. After sending, ChatView still passes activeProviderStatus?.skills to MessagesTimeline, so SkillInlineText cannot recognize the selected $skill and the chip immediately becomes plain text; mobile has the same snapshot-only feed wiring in ThreadDetailScreen. Preserve the target's discovered skills for timeline rendering as well.

      Useful? React with 👍 / 👎.

      @@ -365,3 +371,7 @@
      365371 cwd: composerTrigger?.kind === "path" ? props.projectCwd : null,
      366372 query: composerTrigger?.kind === "path" ? composerTrigger.query : null,
      367373 });
      374+ const providerSkills = useProviderSkills({
      375+ environmentId: props.environmentId,
      376+ instanceId: selectedProviderStatus?.instanceId ?? null,
      377+ cwd: props.projectCwd,

      P2 Badge Discover skills from the active mobile worktree

      For a thread running in a worktree, ThreadDetailScreen already receives the resolved threadCwd but passes the base projectWorkspaceRoot as this component's projectCwd. Consequently this query and its cache inspect the base checkout while the provider session executes in the worktree, so branch-specific additions or removals produce an incorrect skill menu and selected entries may not invoke anything. Use the active thread cwd for provider-skill discovery, falling back to the project root only when needed.

      Useful? React with 👍 / 👎.

    12. @@ -391,10 +397,11 @@
      391397 option.selection.instanceId === selectedModel.instanceId &&
      392398 option.selection.model === selectedModel.model,
      393399 ) ?? null;
      394- const selectedProviderSkills = useMemo(
      400+ const selectedProviderSnapshotSkills = useMemo(
      395401 () =>
      396402 selectedEnvironmentServerConfig?.providers.find(
      397403 (provider) => provider.instanceId === selectedModel?.instanceId,
      398404 )?.skills ?? [],
      399405 [selectedEnvironmentServerConfig, selectedModel?.instanceId],
      400406 );
      407+ const providerSkillsCwd = selectedWorktreePath ?? selectedProject?.workspaceRoot ?? null;
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium threads/new-task-flow-provider.tsx:407

      Skill discovery uses selectedWorktreePath as the query cwd even in local mode, so after selecting a worktree and switching back to local, skills are fetched from the stale worktree path while the task runs from the project's workspace root. The composer can offer project-specific skills from the wrong checkout. setWorkspaceMode intentionally preserves the previous worktreePath when switching modes, so the cached value leaks into the query. Consider deriving the query cwd from workspaceMode — use selectedWorktreePath only in worktree mode and selectedProject?.workspaceRoot in local mode.

      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/mobile/src/features/threads/new-task-flow-provider.tsx around line 407:
      
      Skill discovery uses `selectedWorktreePath` as the query cwd even in `local` mode, so after selecting a worktree and switching back to local, skills are fetched from the stale worktree path while the task runs from the project's workspace root. The composer can offer project-specific skills from the wrong checkout. `setWorkspaceMode` intentionally preserves the previous `worktreePath` when switching modes, so the cached value leaks into the query. Consider deriving the query cwd from `workspaceMode` — use `selectedWorktreePath` only in worktree mode and `selectedProject?.workspaceRoot` in local mode.
    13. Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot). Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 09b0e54442ef910e0cfb7c7a6e341504a7e5e93f. Configure [here](https://www.cursor.com/dashboard/bugbot).
      @@ -391,10 +397,18 @@
      391397 option.selection.instanceId === selectedModel.instanceId &&
      392398 option.selection.model === selectedModel.model,
      393399 ) ?? null;
      394- const selectedProviderSkills = useMemo(
      400+ const selectedProviderSnapshotSkills = useMemo(
      395401 () =>
      396402 selectedEnvironmentServerConfig?.providers.find(
      397403 (provider) => provider.instanceId === selectedModel?.instanceId,
      398404 )?.skills ?? [],
      399405 [selectedEnvironmentServerConfig, selectedModel?.instanceId],
      400406 );
      407+ const providerSkillsCwd = selectedWorktreePath ?? selectedProject?.workspaceRoot ?? null;
      408+ const providerSkillsEnvironmentId = selectedProject?.environmentId ?? selectedEnvironmentId;
      409+ const providerSkills = useProviderSkills({
      410+ environmentId: providerSkillsEnvironmentId,
      411+ instanceId: selectedModel?.instanceId ?? null,
      412+ cwd: providerSkillsCwd,
      413+ enabled: detectComposerTrigger(prompt, prompt.length)?.kind === "skill",
      414+ });

      New task skill probe ignores cursor

      Medium Severity

      The new-task flow's skill discovery only activates when a $ token is at the end of the prompt. This happens because detectComposerTrigger uses prompt.length instead of the actual cursor position. Consequently, mid-sentence $ skill tokens don't trigger useProviderSkills, leaving skill chip metadata stale or empty, unlike the ThreadComposer.

      Fix in Cursor Fix in Web
      Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 09b0e54442ef910e0cfb7c7a6e341504a7e5e93f. Configure [here](https://www.cursor.com/dashboard/bugbot).
    14. Reviewed the new Effect service/error code (GrokSkillDiscovery.ts, driver listSkills closures, ProviderRegistry.listSkills, the new contract errors, and the client query hooks) against the Effect service conventions.

      Findings are limited to the error-wrapping boundaries added by this PR: two ProviderDriverError wrappers derive their detail (and therefore their message) from cause.message, and the new RPC handler re-inspects its own error channel with an inline _tag comparison instead of wrapping only the lower-level registry failure.

      Other areas look consistent with the conventions: GrokSkillDiscoveryError uses Schema.TaggedErrorClass with a multi-value operation discriminator and a message derived from its own attributes, listGrokSkills acquires ChildProcessSpawner from the environment, no ManagedRuntime/runPromise or fake Layer.succeed dependencies were introduced, and the new client-runtime helpers are pure functions with focused tests.

      Posted via Macroscope — Effect Service Conventions
      @@ -106,3 +107,20 @@
      106107 env: processEnv,
      107108 });
      108109
      110+ const listSkills = Effect.fn("GrokDriver.listSkills")(function* (cwd: string) {
      111+ if (!effectiveConfig.enabled) {
      112+ return [];
      113+ }
      114+
      115+ return yield* listGrokSkills({
      116+ settings: effectiveConfig,
      117+ cwd,
      118+ environment: processEnv,
      119+ }).pipe(
      120+ Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
      121+ Effect.mapError(
      122+ (cause) =>
      123+ new ProviderDriverError({
      124+ driver: DRIVER_KIND,
      125+ instanceId,
      126+ detail: cause.message,
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      detail only copies cause.message, and ProviderDriverError.message interpolates detail, so the wrapper message is derived from the cause rather than from its own stable attributes. Consider a fixed detail that keeps the context known here (cwd) and leave the underlying failure available solely as cause.

      Suggested change
      126- detail: cause.message,
      126+ detail: `Failed to list Grok skills for cwd '${cwd}'`,
      Posted via Macroscope — Effect Service Conventions
      @@ -163,0 +169,21 @@
      169+ const listSkills = Effect.fn("CodexDriver.listSkills")(function* (cwd: string) {
      170+ if (!effectiveConfig.enabled) {
      171+ return [];
      172+ }
      173+
      174+ return yield* probeCodexAppServerProvider({
      175+ binaryPath: effectiveConfig.binaryPath,
      176+ homePath: effectiveConfig.homePath,
      177+ cwd,
      178+ customModels: [],
      179+ environment: processEnv,
      180+ includeModels: false,
      181+ }).pipe(
      182+ Effect.scoped,
      183+ Effect.map((result) => result.skills),
      184+ Effect.mapError(
      185+ (cause) =>
      186+ new ProviderDriverError({
      187+ driver: DRIVER_KIND,
      188+ instanceId,
      189+ detail: `Failed to list Codex skills: ${cause.message}`,
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Same issue as the Grok wrapper: detail interpolates cause.message, which then flows into ProviderDriverError.message. Interpolating an arbitrary defect message can also pull spawn command/output text into the caller-visible detail. Prefer structural context and keep the original error only as cause.

      Suggested change
      189- detail: `Failed to list Codex skills: ${cause.message}`,
      189+ detail: `Failed to list Codex skills for cwd '${cwd}'`,
      Posted via Macroscope — Effect Service Conventions
      @@ -1352,3 +1354,17 @@
      13521354 ).pipe(Effect.map((providers) => ({ providers }))),
      13531355 { "rpc.aggregate": "server" },
      13541356 ),
      1357+ [WS_METHODS.serverListProviderSkills]: (input) =>
      1358+ observeRpcEffect(
      1359+ WS_METHODS.serverListProviderSkills,
      1360+ Effect.gen(function* () {
      1361+ const skills = yield* providerRegistry.listSkills(input);
      1362+ if (!skills) {
      1363+ return yield* new ServerProviderSkillsUnsupportedError({
      1364+ instanceId: input.instanceId,
      1365+ cwd: input.cwd,
      1366+ });
      1367+ }
      1368+ return { skills };
      1369+ }).pipe(
      1370+ Effect.mapError((cause) =>
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      This mapError has to re-inspect an error the same block just raised (_tag === "ServerProviderSkillsUnsupportedError"). Wrapping only the lower-level registry failure removes the hand-rolled tag check and keeps the already-structured domain error passing through by construction.

                   Effect.gen(function* () {
      -              const skills = yield* providerRegistry.listSkills(input);
      +              const skills = yield* providerRegistry.listSkills(input).pipe(
      +                Effect.mapError(
      +                  (cause) =>
      +                    new ServerProviderSkillsError({
      +                      instanceId: input.instanceId,
      +                      cwd: input.cwd,
      +                      cause,
      +                    }),
      +                ),
      +              );
                     if (!skills) {
                       return yield* new ServerProviderSkillsUnsupportedError({
                         instanceId: input.instanceId,
                         cwd: input.cwd,
                       });
                     }
                     return { skills };
      -            }).pipe(
      -              Effect.mapError((cause) =>
      -                cause._tag === "ServerProviderSkillsUnsupportedError"
      -                  ? cause
      -                  : new ServerProviderSkillsError({
      -                      instanceId: input.instanceId,
      -                      cwd: input.cwd,
      -                      cause,
      -                    }),
      -              ),
      -            ),
      +            }),
      Posted via Macroscope — Effect Service Conventions
    15. Reviewed the new Effect service/error code (GrokSkillDiscovery.ts, driver listSkills closures, ProviderRegistry.listSkills, the new contract errors, and the client query hooks) against the Effect service conventions.

      Findings are limited to the error-wrapping boundaries added by this PR: two ProviderDriverError wrappers derive their detail (and therefore their message) from cause.message, and the new RPC handler re-inspects its own error channel with an inline _tag comparison instead of wrapping only the lower-level registry failure.

      Other areas look consistent with the conventions: GrokSkillDiscoveryError uses Schema.TaggedErrorClass with a multi-value operation discriminator and a message derived from its own attributes, listGrokSkills acquires ChildProcessSpawner from the environment, no ManagedRuntime/runPromise or fake Layer.succeed dependencies were introduced, and the new client-runtime helpers are pure functions with focused tests.

      Posted via Macroscope — Effect Service Conventions
      @@ -106,3 +107,20 @@
      106107 env: processEnv,
      107108 });
      108109
      110+ const listSkills = Effect.fn("GrokDriver.listSkills")(function* (cwd: string) {
      111+ if (!effectiveConfig.enabled) {
      112+ return [];
      113+ }
      114+
      115+ return yield* listGrokSkills({
      116+ settings: effectiveConfig,
      117+ cwd,
      118+ environment: processEnv,
      119+ }).pipe(
      120+ Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
      121+ Effect.mapError(
      122+ (cause) =>
      123+ new ProviderDriverError({
      124+ driver: DRIVER_KIND,
      125+ instanceId,
      126+ detail: cause.message,
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      detail only copies cause.message, and ProviderDriverError.message interpolates detail, so the wrapper message is derived from the cause rather than from its own stable attributes. Consider a fixed detail that keeps the context known here (cwd) and leave the underlying failure available solely as cause.

      Suggested change
      126- detail: cause.message,
      126+ detail: `Failed to list Grok skills for cwd '${cwd}'`,
      Posted via Macroscope — Effect Service Conventions
      @@ -163,0 +169,21 @@
      169+ const listSkills = Effect.fn("CodexDriver.listSkills")(function* (cwd: string) {
      170+ if (!effectiveConfig.enabled) {
      171+ return [];
      172+ }
      173+
      174+ return yield* probeCodexAppServerProvider({
      175+ binaryPath: effectiveConfig.binaryPath,
      176+ homePath: effectiveConfig.homePath,
      177+ cwd,
      178+ customModels: [],
      179+ environment: processEnv,
      180+ includeModels: false,
      181+ }).pipe(
      182+ Effect.scoped,
      183+ Effect.map((result) => result.skills),
      184+ Effect.mapError(
      185+ (cause) =>
      186+ new ProviderDriverError({
      187+ driver: DRIVER_KIND,
      188+ instanceId,
      189+ detail: `Failed to list Codex skills: ${cause.message}`,
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Same issue as the Grok wrapper: detail interpolates cause.message, which then flows into ProviderDriverError.message. Interpolating an arbitrary defect message can also pull spawn command/output text into the caller-visible detail. Prefer structural context and keep the original error only as cause.

      Suggested change
      189- detail: `Failed to list Codex skills: ${cause.message}`,
      189+ detail: `Failed to list Codex skills for cwd '${cwd}'`,
      Posted via Macroscope — Effect Service Conventions
      @@ -1352,3 +1354,17 @@
      13521354 ).pipe(Effect.map((providers) => ({ providers }))),
      13531355 { "rpc.aggregate": "server" },
      13541356 ),
      1357+ [WS_METHODS.serverListProviderSkills]: (input) =>
      1358+ observeRpcEffect(
      1359+ WS_METHODS.serverListProviderSkills,
      1360+ Effect.gen(function* () {
      1361+ const skills = yield* providerRegistry.listSkills(input);
      1362+ if (!skills) {
      1363+ return yield* new ServerProviderSkillsUnsupportedError({
      1364+ instanceId: input.instanceId,
      1365+ cwd: input.cwd,
      1366+ });
      1367+ }
      1368+ return { skills };
      1369+ }).pipe(
      1370+ Effect.mapError((cause) =>
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      This mapError has to re-inspect an error the same block just raised (_tag === "ServerProviderSkillsUnsupportedError"). Wrapping only the lower-level registry failure removes the hand-rolled tag check and keeps the already-structured domain error passing through by construction.

                   Effect.gen(function* () {
      -              const skills = yield* providerRegistry.listSkills(input);
      +              const skills = yield* providerRegistry.listSkills(input).pipe(
      +                Effect.mapError(
      +                  (cause) =>
      +                    new ServerProviderSkillsError({
      +                      instanceId: input.instanceId,
      +                      cwd: input.cwd,
      +                      cause,
      +                    }),
      +                ),
      +              );
                     if (!skills) {
                       return yield* new ServerProviderSkillsUnsupportedError({
                         instanceId: input.instanceId,
                         cwd: input.cwd,
                       });
                     }
                     return { skills };
      -            }).pipe(
      -              Effect.mapError((cause) =>
      -                cause._tag === "ServerProviderSkillsUnsupportedError"
      -                  ? cause
      -                  : new ServerProviderSkillsError({
      -                      instanceId: input.instanceId,
      -                      cwd: input.cwd,
      -                      cause,
      -                    }),
      -              ),
      -            ),
      +            }),
      Posted via Macroscope — Effect Service Conventions
    16. 💡 Codex Review

      Here are some automated review suggestions for this pull request.

      Reviewed commit: 09b0e54442

      ℹ️ About Codex in GitHub

      Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

      • Open a pull request for review
      • Mark a draft as ready
      • Comment "@codex review".

      If Codex has suggestions, it will comment; otherwise it will react with 👍.

      Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

      @@ -949,5 +996,19 @@
      949996 mapError: (cause) =>
      950997 mapAcpToAdapterError(PROVIDER, input.threadId, "session/set_model", cause),
      951998 });
      999+ // ACP has already committed the model switch at this point. Keep
      1000+ // both the internal comparison state and the public snapshot in
      1001+ // sync even if later prompt preparation (for example, skill
      1002+ // discovery) fails.
      1003+ ctx.currentModelId = currentModelId;
      1004+ const displayModel = currentModelId
      1005+ ? resolveGrokAcpBaseModelId(currentModelId)
      1006+ : undefined;
      1007+ if (displayModel) {
      1008+ ctx.session = { ...ctx.session, model: displayModel };
      1009+ }
      9521010
      953- const text = input.input?.trim();
      1011+ const rawText = input.input?.trim();
      1012+ const text =
      1013+ rawText && options?.listSkills && potentialGrokSkillTokens(rawText).length > 0
      1014+ ? yield* options.listSkills(ctx.session.cwd ?? "").pipe(

      P1 Badge Avoid probing lowercase shell variables as Grok skills

      When a Grok prompt contains an ordinary lowercase shell variable such as $branch or $file, this condition treats it as a potential skill and makes grok inspect part of turn submission. If inspection is unsupported, fails, or reaches its 10-second timeout, the adapter rejects the turn even though the token was not intended as a skill and the ACP session could otherwise process the prompt; the uppercase-only exception does not cover common lowercase shell variables, so discovery failures should not block ambiguous raw-text tokens.

      Useful? React with 👍 / 👎.

      @@ -1097,16 +1135,4 @@
      10971135 return searchSlashCommandItems(slashCommandItems, query);
      10981136 }
      10991137 if (composerTrigger.kind === "skill") {
      1100- return searchProviderSkills(selectedProviderStatus?.skills ?? [], composerTrigger.query).map(
      1101- (skill) => ({
      1102- id: `skill:${selectedProvider}:${skill.name}`,
      1103- type: "skill" as const,
      1104- provider: selectedProvider,
      1105- skill,
      1106- label: formatProviderSkillDisplayName(skill),
      1107- description:
      1108- skill.shortDescription ??
      1109- skill.description ??
      1110- (skill.scope ? `${skill.scope} skill` : "Run provider skill"),
      1111- }),
      1112- );
      1138+ return searchProviderSkills(composerProviderSkills, composerTrigger.query).map((skill) => ({

      P1 Badge Document the new project-scoped skill flow

      This adds a user-visible, provider-dependent $ skill discovery flow across web and mobile, including cwd-specific behavior and new failure/fallback semantics, but the commit contains no corresponding docs/user/ update. Add user documentation explaining supported providers and how project/worktree discovery behaves, as required for noticeable behavior changes.

      AGENTS.md reference: AGENTS.md:L75-L75

      Useful? React with 👍 / 👎.

    17. Closing in favor of #2829 (orchestration V2).

      #2829 deletes the V1 orchestration layer this PR builds on — apps/server/src/orchestration/**, provider/Layers/*Adapter.ts and provider/Services/** are removed and replaced by apps/server/src/orchestration-v2/**, with the IPC surface renamed to ORCHESTRATION_V2_WS_METHODS. The files this PR touches either no longer exist or are rewritten, so it can't be rebased — it would need reimplementing against the V2 adapters.

      This is not a judgement on the change itself. Several of these are real gaps we still want fixed; the base just moved out from under them.

      Once #2829 merges, please rebase onto main, port the change to the V2 equivalent, and reopen (or open a fresh PR). Ping me and I'll prioritise the review.

    18. juliusmarminge closed this

Sign in to join this conversation.