@devries-cameron20 / t3code Mirror · read-only / commits / 56c4e20fff
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 19:45 UTC

fix(cursor): user-invoked skills hidden from the model reach the Cursor prompt (#34999)

Julius Marminge committed Nov 12, 2026 at 02:28 UTC 56c4e20fffd143b6be1a77a4ed6a76b8fa87843c
3 files changed +64 -8
packages/provider-cursor/src/server/adapter.test.ts
+22 -1
@@ -2064,6 +2064,12 @@ describe("CursorAdapterV2", () => {
2064 path.join(skill, "SKILL.md"),
2065 "# Review\nReview the code.",
2066 );
2067 + const userOnlySkill = path.join(workspace, ".cursor", "skills", "grill-me");
2068 + yield* fileSystem.makeDirectory(userOnlySkill, { recursive: true });
2069 + yield* fileSystem.writeFileString(
2070 + path.join(userOnlySkill, "SKILL.md"),
2071 + "---\nname: grill-me\ndescription: Grill the plan.\ndisable-model-invocation: true\n---\nAsk one question at a time.",
2072 + );
2073 const steered: string[] = [];
2074 let cancelled = 0;
2075 let outcome: "complete_delivered" | "revert_to_followup" = "complete_delivered";
@@ -2198,6 +2204,21 @@ describe("CursorAdapterV2", () => {
2204 });
2205 assert.deepEqual(steered, ["/review Look at the tests instead."]);
2206 assert.equal(cancelled, 0);
2207 + yield* runtime.steerTurn({
2208 + threadId,
2209 + runId: turn.runId,
2210 + providerThread,
2211 + providerTurnId,
2212 + message: {
2213 + messageId: MessageId.make("cursor-steer-user-only-skill"),
2214 + createdBy: "user",
2215 + creationSource: "web",
2216 + text: "$grill-me My plan.",
2217 + attachments: [],
2218 + },
2219 + });
2220 + // Cursor hides `disable-model-invocation` skills from the model, so the SDK prompt must carry them.
2221 + assert.include(steered.at(-1), "Ask one question at a time.");
2222
2223 outcome = "revert_to_followup";
2224 const declined = yield* runtime
@@ -2216,7 +2237,7 @@ describe("CursorAdapterV2", () => {
2237 })
2238 .pipe(Effect.exit);
2239 if (!Exit.isFailure(declined)) return yield* Effect.die("Expected a declined steer");
2219 - assert.deepEqual(steered, ["/review Look at the tests instead.", "Stop and do this."]);
2240 + assert.equal(steered.at(-1), "Stop and do this.");
2241 assert.equal(cancelled, 0);
2242 const declinedError = Cause.squash(declined.cause);
2243 assert.instanceOf(declinedError, ProviderAdapter.ProviderAdapterSteerDeclinedError);
packages/provider-cursor/src/server/adapter.ts
+23 -7
@@ -28,6 +28,7 @@ import {
28 type OrchestrationV2TurnItem,
29 type ProviderInstanceId,
30 type ServerProviderModel,
31 + type ServerProviderSkill,
32 type ThreadId,
33 } from "@t3tools/contracts";
34 import * as DateTime from "effect/DateTime";
@@ -48,6 +49,8 @@ import * as McpProviderSession from "@t3tools/provider-core/server/mcpSession";
49 import { CursorTransportFailure } from "./transportFailure.ts";
50 import { cursorContextWindowTokens, cursorSdkModelSelection } from "./sdkModel.ts";
51 import {
52 + appendCursorInvokedSkills,
53 + cursorSlashSkillNames,
54 discoverCursorSkills,
55 hasCursorSkillMention,
56 rewriteCursorSkillMentions,
@@ -2309,23 +2312,36 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
2312 return next;
2313 });
2314
2312 - let cursorSkillNames: ReadonlySet<string> | undefined;
2315 + let cursorSkills: ReadonlyMap<string, ServerProviderSkill> | undefined;
2316 const resolveCursorSkillText = Effect.fn("CursorAdapterV2.resolveCursorSkillText")(
2317 function* (rawText: string, cwd: string | undefined) {
2315 - if (hasCursorSkillMention(rawText) && cursorSkillNames === undefined) {
2318 + if (
2319 + cursorSkills === undefined &&
2320 + (hasCursorSkillMention(rawText) || cursorSlashSkillNames(rawText).size > 0)
2321 + ) {
2322 const skills = yield* discoverCursorSkills(cwd, adapterOptions.environment).pipe(
2323 Effect.provideService(FileSystem.FileSystem, fileSystem),
2324 Effect.provideService(Path.Path, path),
2325 );
2320 - cursorSkillNames = new Set(
2326 + cursorSkills = new Map(
2327 skills
2328 .filter((skill) => skill.enabled && skill.userInvocable !== false)
2323 - .map((skill) => skill.name),
2329 + .map((skill) => [skill.name, skill]),
2330 );
2331 }
2326 - return cursorSkillNames === undefined
2327 - ? rawText
2328 - : rewriteCursorSkillMentions(rawText, cursorSkillNames);
2332 + if (cursorSkills === undefined) return rawText;
2333 + const skillsByName = cursorSkills;
2334 + const text = rewriteCursorSkillMentions(rawText, new Set(skillsByName.keys()));
2335 + const invoked = yield* Effect.forEach(cursorSlashSkillNames(text), (name) => {
2336 + const skill = skillsByName.get(name);
2337 + return skill?.userInvocationOnly === true
2338 + ? fileSystem.readFileString(skill.path).pipe(
2339 + Effect.map((contents) => [{ name, contents }]),
2340 + Effect.orElseSucceed(() => []),
2341 + )
2342 + : Effect.succeed([]);
2343 + });
2344 + return appendCursorInvokedSkills(text, invoked.flat());
2345 },
2346 );
2347 const resolveUserMessage = Effect.fnUntraced(function* (
packages/provider-cursor/src/server/skills.ts
+19
@@ -14,6 +14,7 @@ const FRONTMATTER_PATTERN = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/;
14 const SKILL_MENTION_PATTERN =
15 /(^|\s)\p{Sc}(?![0-9][0-9_]*(?:[kKmMbBtT]|[eE][0-9]+)?(?:\s|$))(?=[a-zA-Z0-9:_-]*[a-zA-Z])([a-zA-Z0-9][a-zA-Z0-9:_-]*)(?=\s|$)/gu;
16 const HAS_SKILL_MENTION_PATTERN = new RegExp(SKILL_MENTION_PATTERN.source, "u");
17 +const SLASH_SKILL_PATTERN = /(?:^|\s)\/([a-zA-Z0-9][a-zA-Z0-9:_-]*)(?=\s|$)/gu;
18 const MAX_SKILL_DEPTH = 10;
19 const MAX_SKILL_BYTES = ByteSize.bytes(1_000_000);
20 const MAX_SKILL_SCAN_ENTRIES = 10_000;
@@ -305,3 +306,21 @@ export function rewriteCursorSkillMentions(
306 skillNames.has(name) ? `${prefix}/${name}` : match,
307 );
308 }
309 +
310 +/** Names invoked as `/name`, the form Cursor uses and `rewriteCursorSkillMentions` produces. */
311 +export function cursorSlashSkillNames(prompt: string): ReadonlySet<string> {
312 + return new Set(Array.from(prompt.matchAll(SLASH_SKILL_PATTERN), (match) => match[1] ?? ""));
313 +}
314 +
315 +/** Cursor hides `disable-model-invocation` skills from the model, so the prompt carries them. */
316 +export function appendCursorInvokedSkills(
317 + prompt: string,
318 + skills: ReadonlyArray<{ readonly name: string; readonly contents: string }>,
319 +): string {
320 + if (skills.length === 0) return prompt;
321 + const blocks = skills.map(
322 + (skill) =>
323 + `<skill name="${skill.name}">\n${skill.contents.replace(FRONTMATTER_PATTERN, "").trim()}\n</skill>`,
324 + );
325 + return `${prompt}\n\nThe user invoked these skills. Follow their instructions:\n\n${blocks.join("\n\n")}`;
326 +}