t3code icon indicating copy to clipboard operation
t3code copied to clipboard

fix(cursor): cursor skills discovery

Open nemesiscodex opened this issue 4 months ago • 3 comments

What Changed

Cursor skills now show up in the $ picker, scoped to the project or worktree where the thread actually runs.

  • Server: a new CursorSkills scanner reads .cursor/skills and .agents/skills at user and project scope for a given working directory, applying Cursor's precedence and naming rules (directory name wins over frontmatter name, .cursor beats .agents, and project beats user). Discovery is bounded and best-effort, rejects roots and symlinks that escape their canonical boundaries, reads at most 64 KiB of metadata per SKILL.md, and never sends skill bodies over the wire.
  • Contracts / RPC: providers.skillInventory takes a thread or project id—never a raw path—and ServerProvider optionally advertises skillInventoryMode: "project"; absence means snapshot mode. ProviderSkillInventory resolves the id to a cwd with the same helper provider sessions use, so a worktree thread lists that worktree's skills.
  • Clients: web and mobile composer and message surfaces request thread-scoped inventories for durable threads and project-scoped inventories for local drafts, only for project-mode providers. Codex, Claude, and other snapshot-mode providers retain the existing zero-round-trip path.
  • Docs: a skill-inventory section in docs/internals/providers.md documents inventory modes, cwd resolution, typed request failures, best-effort discovery, canonical containment, and traversal budgets.

Why

This addresses the Cursor portion of pingdotgg/t3code#2736, which reports that Cursor and OpenCode skills exist on disk but remain absent from T3 Code's provider inventory. OpenCode discovery remains outside this PR's scope.

The $ picker rendered ServerProvider.skills, an environment-wide snapshot computed once from wherever the server started. That is wrong for every project but one, and empty for Cursor: its ACP surface only exposes slash-command metadata mixed with built-ins, with no paths and no scope, so there was nothing reliable to snapshot.

Cursor's inventory depends on the directory where the agent will run, so the lookup must be per thread or project rather than per environment. Passing an id instead of a path, together with canonical containment of skill roots and symlinks, keeps the picker from becoming a filesystem probe.

UI Changes

The $ picker with Cursor selected: empty before, populated with the project's skills after.

Before

Cursor skill picker before this change

After

https://github.com/user-attachments/assets/7b6a84f1-9546-44d0-b485-a6efbe32ba3d

Checklist

  • [ ] This PR is small (is not, sorry about that)
  • [x] This PR is focused
  • [x] I explained what changed and why
  • [x] I included before/after screenshots for any UI changes
  • [x] I included a video for animation/interaction changes

[!NOTE] Medium Risk Introduces a new read-scoped RPC that performs filesystem discovery on the server; scope is id-based and traversal is bounded, but worktree/cwd resolution bugs could show the wrong skill set for a thread.

Overview Cursor’s $ picker now loads skills from the workspace the agent will actually use, instead of the empty or environment-wide ServerProvider.skills snapshot.

On the server, Cursor gets a skillInventory capability backed by discoverCursorSkills, which scans the eight user/project roots (.claude, .codex, .agents, .cursor), merges by Cursor’s precedence rules, and returns bounded metadata only. Providers that expose this capability publish skillInventoryMode: "project" on snapshots. A new providers.skillInventory RPC accepts a thread or project id (not a path), resolves cwd via getThreadWorkspaceContextById and the same worktree logic as provider sessions, then lists skills or falls back to snapshot skills for other drivers.

Web and mobile share useProviderSkills / client-runtime helpers: project-mode providers fetch inventory once per environment+scope+instance; snapshot providers keep zero extra round trips. Composers, timelines, and message rendering consume the resolved list rather than selectedProviderStatus?.skills.

Reviewed by Cursor Bugbot for commit 66a1ecd799b77f994cc40ba3ce794b0eccb88f7b. Bugbot is set up for automated code reviews on this repo. Configure here.

[!NOTE]

Add Cursor skill discovery and per-scope provider skill inventory RPC

  • Adds discoverCursorSkills in CursorSkills.ts to scan eight filesystem roots (user and project, across .claude, .codex, .agents, .cursor) in precedence order, merging results by skill name with bounded traversal and cycle detection.
  • Introduces ProviderSkillInventory as an optional ProviderInstance capability; providers implementing it expose skillInventory.list(cwd) and have skillInventoryMode: "project" added to their snapshots by buildSnapshotSource.
  • Adds a providers.skillInventory WebSocket RPC (with AuthOrchestrationReadScope) backed by resolveProviderSkillInventory, which resolves project or thread scope to a concrete working directory via getThreadWorkspaceContextById before calling the provider capability.
  • Adds useProviderSkills hooks on web and mobile that transparently select between snapshot skills and server-fetched inventories based on skillInventoryMode.
  • Behavioral Change: ChatComposer and ThreadComposer now require callers to pass provider skills explicitly; ChatComposer gains a required activeProjectId prop.

Macroscope summarized 66a1ecd.

nemesiscodex avatar Aug 01 '26 05:08 nemesiscodex

Review Change Stack

📝 Walkthrough

Walkthrough

Provider skill handling now supports project- and thread-scoped inventories. The change adds contracts, Cursor discovery, workspace resolution, RPC access, cached client state, and web/mobile integration.

Changes

Provider skill inventory

Layer / File(s) Summary
Inventory contracts and shared state
packages/contracts/src/server.ts, packages/contracts/src/rpc.ts, packages/client-runtime/src/state/providerSkillInventory.ts, packages/client-runtime/src/state/server.ts
Defines inventory modes, scopes, results, typed failures, provider capabilities, target resolution, skill selection, and cached RPC queries.
Workspace context and inventory resolution
apps/server/src/orchestration/Services/ProjectionSnapshotQuery.ts, apps/server/src/orchestration/Layers/ProjectionSnapshotQuery.ts, apps/server/src/provider/ProviderSkillInventory.ts, apps/server/src/.../*test.ts
Resolves project and thread workspaces, including archived threads and deleted projects, then maps inventory failures to typed errors.
Cursor skill discovery
apps/server/src/provider/Drivers/CursorSkills.ts, apps/server/src/provider/Drivers/CursorDriver.ts, apps/server/src/provider/Layers/ProviderRegistry.ts, apps/server/src/provider/Drivers/CursorSkills.test.ts
Discovers Cursor skills across user and project roots with metadata parsing, precedence, symlink containment, traversal limits, and deterministic sorting.
Inventory RPC integration
apps/server/src/ws.ts, apps/server/src/auth/RpcAuthorization.ts, apps/server/src/server.test.ts
Adds the authorized providersSkillInventory RPC and supplies provider-instance and workspace-query services.
Web and mobile skill consumption
apps/web/src/components/..., apps/web/src/state/queries.ts, apps/web/src/composer-logic.ts, apps/mobile/src/features/threads/..., apps/mobile/src/state/queries.ts
Uses resolved skills in timelines, command menus, and editors. Composer loading now reflects pending skill inventory requests.

Estimated code review effort: 5 (Critical) | ~120 minutes

Merge Risk: 🔵 Low · up to 43055

The PR adds project- and thread-scoped filesystem skill discovery, but the mobile picker can appear empty during its initial inventory load, and the new authenticated lookup does not clearly define resource ownership or revocation for retained worktrees. The change is mergeable with explicit owner awareness and follow-up on these bounded issues.

Sequence Diagram(s)

sequenceDiagram
  participant ChatComposer
  participant useProviderSkills
  participant providersSkillInventory
  participant resolveProviderSkillInventory
  ChatComposer->>useProviderSkills: Request skills for active scope
  useProviderSkills->>providersSkillInventory: Send scope and instanceId
  providersSkillInventory->>resolveProviderSkillInventory: Resolve workspace and inventory
  resolveProviderSkillInventory-->>providersSkillInventory: Return skills
  providersSkillInventory-->>useProviderSkills: Return skill result
  useProviderSkills-->>ChatComposer: Provide selected skills

Suggested reviewers: juliusmarminge, t3dotgg

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 47.37% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 35 files. (2 skipped: 2 unsupported.) Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the primary change: Cursor skill discovery.
Description check ✅ Passed The description explains the changes and rationale, documents UI impact, and includes the required checklist and visual evidence.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • [ ] Create stacked PR
  • [ ] Commit on current branch
🧪 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.

coderabbitai[bot] avatar Aug 01 '26 05:08 coderabbitai[bot]

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This PR introduces a new feature for Cursor skills discovery, adding ~2600 lines including a new RPC endpoint, filesystem scanning logic, new contracts, and client-side query hooks. New features with significant user-facing behavior changes warrant human review.

You can add or adjust custom eligibility rules. Learn more.

macroscopeapp[bot] avatar Aug 01 '26 05:08 macroscopeapp[bot]

This would help a lot — Cursor provider currently shows no skills in the picker. Hoping this can land.

Shuuren avatar Aug 05 '26 07:08 Shuuren

@t3dotgg @juliusmarminge Can we please get this out, Not using t3code because of this at the moment

HarrisonRogers avatar Aug 10 '26 03:08 HarrisonRogers

@coderabbitai full review

nemesiscodex avatar Aug 20 '26 21:08 nemesiscodex

✅ Action performed

Full review finished.

coderabbitai[bot] avatar Aug 20 '26 21:08 coderabbitai[bot]

[!NOTE] 🤖 GPT-5.6 Sol responding on behalf of Theo

Closing this PR after an automated pass over open pull requests. Empty-description Cursor skill proposal changes 39 files. Smaller alternative: #7764.

t3dotgg avatar Aug 23 '26 11:08 t3dotgg