Skip to content
Source
Sign inSign up
pingdotgg/t3code

Fix/project scoped provider skills #6661

ClosedGenKerensky(GitHub profile, opens in a new tab)wants to merge 11 commits intomain fromrefs/pull/6661/headopened View on GitHub

What Changed

Project skills in the $ picker were effectively environment-global. This PR makes skill discovery multi-workspace on the server, tags each project skill with where it came from, and filters the picker to the active chat checkout on web and mobile.

Server

  • Shared SkillDiscovery walks project skill roots (git-root → cwd ancestors, compatibility dirs, collision precedence) instead of only the process cwd.
  • SkillWorkspaceCwds / ProjectionSnapshotQuery.getActiveWorkspaceCwds collect every registered project root and active worktree so status probes discover across the environment.
  • Claude, Codex, Cursor, Grok, and OpenCode drivers/providers all use that multi-cwd discovery and stamp project skills with sourceCwd.
  • ServerProviderSkill gains optional sourceCwd (user/global skills omit it).

Shared / contracts

  • @t3tools/shared/providerSkills: path normalization + filterProviderSkillsForWorkspace so server stamps and client paths compare cleanly (trailing separators, ./.., mixed slashes, Windows forms).
  • Clients filter with worktreePath ?? project.workspaceRoot, and may pass projectRoot so worktree chats still see project-root-tagged skills before a re-probe re-tags under the worktree.

Clients

  • Web ChatComposer and mobile ThreadComposer / new-task flow scope the $ picker to the active checkout.
  • Timeline / historical skill labels can keep the full inventory so mentions still resolve when switching projects.
  • Minor Android composer theme-color parsing / skill chip color alignment (fuchsia parity with desktop).

Docs

  • Internals note in docs/internals/providers.md and docs/internals/project-scoped-skills.html describing the model and the accepted interim payload cost (full multi-workspace skill union on provider snapshots until a scoped listSkills(cwd) RPC might land later).

Why

With multiple projects or worktrees open, the $ skill picker showed every project skill from every open workspace. That is wrong for isolation: skills from project A should not appear when chatting in project B (or a different worktree), while user/global skills should still be available everywhere.

Discovery had to expand first (probes only saw one cwd), then the wire format needed a stable workspace tag (sourceCwd), then clients needed a shared filter so web and mobile stay consistent. Filtering only on the client without multi-cwd discovery would still miss skills that were never scanned; tagging without filtering would still dump the full union into the picker.

Payload growth with open workspaces is accepted as an interim cost documented in internals; do not collapse by skill name across workspaces.

UI Changes

Behavior change only in the composer $ skill picker (and mobile new-task flow using the same filter):

  • Before: picker listed the full provider skill inventory (all open projects/worktrees + user skills).
  • After: picker lists user/global skills plus project skills whose sourceCwd matches the active chat checkout (worktreePath ?? project.workspaceRoot, with optional project-root fallback).

No layout or animation redesign. Screenshots not attached; happy to add if useful for review.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

High Risk Touches every provider probe, the provider snapshot contract, projection reads, and composer pickers. Wrong tagging or filtering would leak or hide skills/commands across projects.

Overview Scopes $ skills and / slash commands to the active chat checkout instead of dumping every open workspace’s inventory into the picker.

Server: probes now scan all active project roots and worktrees via getActiveWorkspaceCwds, then stamp project entries with sourceCwd. Shared SkillDiscovery walks git-root → cwd ancestors with harness-specific roots. Claude/Codex/Cursor/Grok/OpenCode all use this; Grok prefers inspect + ACP menus, OpenCode queries debug config / SDK command.list. User/global/bundled items stay untagged.

Clients: web ChatComposer and mobile ThreadComposer / new-task flow filter with filterProviderSkillsForWorkspace / filterProviderSlashCommandsForWorkspace (worktreePath ?? project root, with a project-root fallback for worktree chats). Timeline labels still use the full inventory.

Also fixes Android skill-chip colors by parsing #RRGGBBAA (uniwind) instead of Android #AARRGGBB. Snapshots still ship the full multi-workspace union until a scoped list RPC exists.

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

Note

Add project-scoped provider skill and slash command discovery across workspaces

  • Introduces filesystem skill discovery across user and project directories for Claude, Codex, Cursor, Grok, and OpenCode providers, walking ancestors from git root to each workspace cwd and tagging entries with sourceCwd
  • Adds getActiveWorkspaceCwds to ProjectionSnapshotQuery to supply active project roots and thread worktrees; all provider drivers now require this service and pass resolved skillCwds into their status checks
  • Refactors checkClaudeProviderStatus, checkCodexProviderStatus, checkCursorProviderStatus, checkGrokProviderStatus, and checkOpenCodeProviderStatus to accept an options object with skillCwds and environment
  • Adds shared workspace filtering utilities (filterProviderSkillsForWorkspace, filterProviderSlashCommandsForWorkspace) and applies them in web ChatComposer, mobile ThreadComposer, and NewTaskFlowProvider so $ and / pickers show only skills/commands for the current checkout
  • Adds ACP available_commands_update capture in AcpSessionRuntime (via getAvailableCommands) and routes recognized /name args submissions to session.command in OpenCodeAdapter
  • Behavioral Change: ClaudeDriverEnv, CodexDriverEnv, CursorDriverEnv, GrokDriverEnv, and OpenCodeDriverEnv now require ProjectionSnapshotQuery; all test layers updated with stubs. ServerProviderSkill and ServerProviderSlashCommand schemas gain optional sourceCwd. flattenOpenCodeSkills is removed. packages/client-runtime export path changes from ./providerSkills to ./providerSkillDisplay.
Macroscope summarized 536153c.
    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: 68c342b9-9201-41c1-b4e5-0334b1654663

      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

      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. Effect Service Conventions review: one finding — a new service capability is declared as an optional interface member and feature-detected at runtime, with a production fallback that exists only for partial test doubles. Everything else (namespace imports from effect/* subpaths, environment-based dependency acquisition in the drivers, no ManagedRuntime/runPromise in service code, Layer.succeed limited to test seams, error mapping reusing the existing typed persistence errors) matches the conventions.

      Posted via Macroscope — Effect Service Conventions
    4. Effect Service Conventions review: one finding — a new service capability is declared as an optional interface member and feature-detected at runtime, with a production fallback that exists only for partial test doubles. Everything else (namespace imports from effect/* subpaths, environment-based dependency acquisition in the drivers, no ManagedRuntime/runPromise in service code, Layer.succeed limited to test seams, error mapping reusing the existing typed persistence errors) matches the conventions.

      Posted via Macroscope — Effect Service Conventions
    5. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Skipped

      Macroscope did not run approvability analysis for this PR. Macroscope could not determine whether this PR modifies its approvability configuration, so the PR was not approved automatically. A PR that may change the rules that govern approval is never approved automatically.

      Not approved because:

      • 1 blocking correctness issue found at or above your repo's Minimum Blocking Severity
    6. One finding: two ProjectionSnapshotQuery test doubles added for skill workspace resolution still implement only getShellSnapshot, which is no longer the method the production path calls.

      Posted via Macroscope — Effect Service Conventions
    7. One finding: the new Grok inspect helper puts bare Error values in an Effect failure channel instead of a Schema.TaggedErrorClass with structured attributes. Everything else in scope (new SkillDiscovery / SkillWorkspaceCwds / OpenCodeCommands modules, driver wiring, contract additions, and the updated ProjectionSnapshotQuery shape/test doubles) follows the service, import, and dependency-acquisition conventions.

      Posted via Macroscope — Effect Service Conventions
    8. One finding: the / composer menu still builds its skill: entries from the unfiltered provider inventory, so the cross-workspace leak this PR fixes for $ remains on the slash path (and that read is no longer covered by the memo deps).

      Posted via Macroscope — UI Consistency
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      chat/ChatComposer.tsx:1143

      The slash-command branch is only half-scoped: providerSlashCommandItems now uses selectedProviderSlashCommands, but the skillItems list a few lines below still reads selectedProviderStatus?.skills ?? [], so typing / still offers skill:<name> entries from every open project/worktree — the same leak $ was just fixed for. It is also no longer covered by this memo's dependency list (selectedProviderStatus was replaced by the two filtered arrays), so those entries can go stale.

      Consider sourcing it from the scoped list so both trigger paths agree:

             const query = composerTrigger.query.trim().toLowerCase();
      -      const skillItems = (selectedProviderStatus?.skills ?? [])
      +      const skillItems = selectedProviderSkills
               .filter((skill) => skill.enabled)

      No longer relevant as of 74a51cb0f33593b087e1988e5ebcfc82362bef58

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

      🟡 Medium Drivers/GrokSkills.ts:235

      Project-scoped slash commands lose their workspace identity, so merging per-workspace inspect catalogs treats them as global and lets same-named commands overwrite one another across workspaces. Include skillSourceCwd in the slash command object, as is already done for the corresponding skill.

      ✅ Resolved in 74a51cb0f33593b087e1988e5ebcfc82362bef58

    10. Fixed in 08cc1d167. This duplicates the earlier slash-skill scoping finding; the current head sources skillItems from selectedProviderSkills in both clients.

    11. Fixed in 74a51cb0f. Inspect-derived project commands now carry sourceCwd, and the Grok catalog merge keys slash commands by both workspace and name. Regression coverage keeps same-named commands from two workspaces separate.

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

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

    14. @@ -365,3 +380,6 @@
      365380 }),
      366381 ).pipe(Effect.provideService(Scope.Scope, runtimeScope));
      367382
      383+ const adoptPendingAvailableCommands = (sessionId: string) =>
      384+ Effect.gen(function* () {
      385+ const pending = yield* Ref.getAndSet(pendingAvailableCommandsRef, new Map());
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium acp/AcpSessionRuntime.ts:385

      getAvailableCommands can remain stale after startup: an available_commands_update received between Ref.getAndSet(pendingAvailableCommandsRef, new Map()) and setting startStateRef to Started is buffered after the drain and is never adopted. Coordinate the pending-map drain with the startup-state transition atomically, or perform a second drain after transitioning to Started.

      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/server/src/provider/acp/AcpSessionRuntime.ts around line 385:
      
      `getAvailableCommands` can remain stale after startup: an `available_commands_update` received between `Ref.getAndSet(pendingAvailableCommandsRef, new Map())` and setting `startStateRef` to `Started` is buffered after the drain and is never adopted. Coordinate the pending-map drain with the startup-state transition atomically, or perform a second drain after transitioning to `Started`.
    15. 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 536153cf2e47377907744ba70cdc8b2a1022ad10. Configure [here](https://www.cursor.com/dashboard/bugbot).
      @@ -371,0 +399,21 @@
      399+ const startState = yield* Ref.get(startStateRef);
      400+ if (startState._tag === "Started") {
      401+ // Live session menu; child/foreign session updates are ignored.
      402+ if (notification.sessionId === startState.result.sessionId) {
      403+ yield* Ref.set(availableCommandsRef, commands);
      404+ }
      405+ } else if (
      406+ options.resumeSessionId !== undefined &&
      407+ notification.sessionId === options.resumeSessionId
      408+ ) {
      409+ // Resuming: the target session id is known up front.
      410+ yield* Ref.set(availableCommandsRef, commands);
      411+ } else if (options.resumeSessionId === undefined) {
      412+ // Fresh startup: Grok advertises before session/new returns, but
      413+ // the runtime's session id is not knowable yet. Buffer per
      414+ // advertised id; start() adopts the matching entry.
      415+ yield* Ref.update(pendingAvailableCommandsRef, (pending) => {
      416+ const next = new Map(pending);
      417+ next.set(notification.sessionId, commands);
      418+ return next;
      419+ });

      ACP command adopt race window

      Medium Severity

      Fresh-start available_commands_update handling buffers into pendingAvailableCommandsRef while status is still Starting, and start() drains that map once via getAndSet before flipping to Started. A matching update that lands after the drain but before Started is written goes back into the pending map and is never adopted, so availableCommandsRef can keep a stale or empty menu. That regresses the old path, which wrote straight into availableCommandsRef during startup.

      Additional Locations (1)
      Fix in Cursor Fix in Web
      Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 536153cf2e47377907744ba70cdc8b2a1022ad10. Configure [here](https://www.cursor.com/dashboard/bugbot).
    16. Note

      🤖 GPT-5.6 Sol responding on behalf of Theo

      Closing this PR after an automated pass over open pull requests. Broad project-skills rewrite duplicates trusted implementations #7909 and #5335.

Sign in to join this conversation.