@devries-cameron20 / t3code Mirror · read-only / commits / 30767c22b5
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 22, 05:45 UTC

fix(cursor): supporting files no longer hide sibling skills (#23326)

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>

Julius Marminge committed Nov 2, 2026 at 18:52 UTC 30767c22b5df71f05c573c77620243b9b934e6dd
2 files changed +100 -4
packages/provider-cursor/src/server/skills.test.ts
+80
@@ -3,7 +3,9 @@ import * as NodeServices from "@effect/platform-node/NodeServices";
3 import { describe, expect, it } from "vite-plus/test";
4 import * as Effect from "effect/Effect";
5 import * as FileSystem from "effect/FileSystem";
6 +import * as Layer from "effect/Layer";
7 import * as Path from "effect/Path";
8 +import * as PlatformError from "effect/PlatformError";
9 import type * as Scope from "effect/Scope";
10 import { symlinksSupported } from "@t3tools/shared/testing/symlinks";
11
@@ -173,6 +175,84 @@ describe("Cursor skills", () => {
175 }),
176 ));
177
178 + it("finds sibling skills when one skill ships more files than the scan budget", async () =>
179 + await runNode(
180 + Effect.gen(function* () {
181 + const fileSystem = yield* FileSystem.FileSystem;
182 + const path = yield* Path.Path;
183 + const tempDirectory = (prefix: string) =>
184 + fileSystem
185 + .makeTempDirectoryScoped({ directory: NodeOS.tmpdir(), prefix })
186 + .pipe(Effect.flatMap((directory) => fileSystem.realPath(directory)));
187 + const userHome = yield* tempDirectory("cursor-skills-home-");
188 + const workspace = yield* tempDirectory("cursor-skills-workspace-");
189 + const root = path.join(workspace, ".cursor", "skills");
190 + const artifacts = path.join(root, "a-large", "artifacts");
191 + yield* fileSystem.makeDirectory(artifacts, { recursive: true });
192 + yield* fileSystem.writeFileString(path.join(root, "a-large", "SKILL.md"), "---\n---\n");
193 + yield* fileSystem.makeDirectory(path.join(root, "b-small"), { recursive: true });
194 + yield* fileSystem.writeFileString(path.join(root, "b-small", "SKILL.md"), "---\n---\n");
195 + // More ordinary files than the whole-scan entry budget of 10,000.
196 + yield* Effect.forEach(
197 + Array.from({ length: 11_000 }, (_, index) => path.join(artifacts, `file-${index}.txt`)),
198 + (file) => fileSystem.writeFileString(file, ""),
199 + { concurrency: 64, discard: true },
200 + );
201 +
202 + const expected = [
203 + {
204 + name: "a-large",
205 + path: path.join(root, "a-large", "SKILL.md"),
206 + scope: "project",
207 + enabled: true,
208 + },
209 + {
210 + name: "b-small",
211 + path: path.join(root, "b-small", "SKILL.md"),
212 + scope: "project",
213 + enabled: true,
214 + },
215 + ];
216 + expect(yield* discoverCursorSkills(workspace, { HOME: userHome })).toEqual(expected);
217 + expect(yield* probeCursorSkills(workspace, { HOME: userHome })).toEqual(expected);
218 + }),
219 + ));
220 +
221 + it("stops a scan of a huge file tree instead of statting every file", async () => {
222 + const root = "/workspace/.cursor/skills";
223 + let stats = 0;
224 + const fileSystem = FileSystem.layerNoop({
225 + realPath: (path) => Effect.succeed(path),
226 + readDirectory: (path) =>
227 + path === root
228 + ? Effect.succeed(Array.from({ length: 200_000 }, (_, index) => `file-${index}`))
229 + : Effect.succeed([]),
230 + stat: (path) => {
231 + stats += 1;
232 + if (path === root) return Effect.succeed({ type: "Directory" } as FileSystem.File.Info);
233 + if (path.startsWith(`${root}/file-`)) {
234 + return Effect.succeed({ type: "File" } as FileSystem.File.Info);
235 + }
236 + return Effect.fail(
237 + PlatformError.systemError({ _tag: "NotFound", module: "FileSystem", method: "stat" }),
238 + );
239 + },
240 + });
241 +
242 + const result = await probeCursorSkills("/workspace", { HOME: "/home" }).pipe(
243 + Effect.result,
244 + Effect.provide(Layer.mergeAll(fileSystem, Path.layer)),
245 + Effect.runPromise,
246 + );
247 +
248 + expect(result).toMatchObject({
249 + _tag: "Failure",
250 + failure: { reason: "scan-budget-exhausted" },
251 + });
252 + expect(stats).toBeGreaterThanOrEqual(100_000);
253 + expect(stats).toBeLessThanOrEqual(100_000);
254 + });
255 +
256 it.skipIf(!symlinksSupported)(
257 "treats a symlinked skill outside the root as a package boundary",
258 async () =>
packages/provider-cursor/src/server/skills.ts
+20 -4
@@ -17,6 +17,7 @@ const HAS_SKILL_MENTION_PATTERN = new RegExp(SKILL_MENTION_PATTERN.source, "u");
17 const MAX_SKILL_DEPTH = 10;
18 const MAX_SKILL_BYTES = ByteSize.bytes(1_000_000);
19 const MAX_SKILL_SCAN_ENTRIES = 10_000;
20 +const MAX_SKILL_SCAN_STATS = 100_000;
21 const MAX_SKILL_SCAN_BYTES = ByteSize.bytes(8_000_000);
22
23 interface CursorSkillFrontmatter {
@@ -29,6 +30,7 @@ interface CursorSkillFrontmatter {
30
31 interface CursorSkillScanBudget {
32 remainingEntries: number;
33 + remainingStats: number;
34 remainingBytes: bigint;
35 exhausted: boolean;
36 incomplete: boolean;
@@ -153,6 +155,11 @@ const discoverSkillsInRoot = Effect.fn("discoverCursorSkillsInRoot")(function* (
155 resolvedDirectory === rootDirectory ||
156 resolvedDirectory.startsWith(`${rootDirectory}${path.sep}`);
157
158 + if (input.budget.remainingStats === 0) {
159 + input.budget.exhausted = true;
160 + return;
161 + }
162 + input.budget.remainingStats -= 1;
163 const skillPath = path.join(directory, "SKILL.md");
164 const skillInfo = yield* orUndefined(fileSystem.stat(skillPath), input.budget);
165 if (skillInfo?.type === "File") {
@@ -189,17 +196,25 @@ const discoverSkillsInRoot = Effect.fn("discoverCursorSkillsInRoot")(function* (
196 return;
197 }
198 for (const entry of [...entries].sort()) {
192 - if (input.budget.remainingEntries === 0) {
199 + // Installed dependencies can exhaust the shared budget and hide unrelated skills.
200 + if (entry === "node_modules") continue;
201 + // Files spend no directory budget, so a separate cap keeps a huge file tree bounded.
202 + if (input.budget.remainingStats === 0) {
203 input.budget.exhausted = true;
204 return;
205 }
196 - input.budget.remainingEntries -= 1;
197 - // Installed dependencies can exhaust the shared budget and hide unrelated skills.
198 - if (entry === "node_modules") continue;
206 + input.budget.remainingStats -= 1;
207 const child = path.join(directory, entry);
208 const info = yield* orUndefined(fileSystem.stat(child), input.budget);
209 + // Only directories can hold skills, so only they spend the budget: a skill
210 + // shipping many ordinary files must not hide its siblings.
211 if (info?.type !== "Directory") continue;
212 if (depth >= MAX_SKILL_DEPTH) continue;
213 + if (input.budget.remainingEntries === 0) {
214 + input.budget.exhausted = true;
215 + return;
216 + }
217 + input.budget.remainingEntries -= 1;
218 yield* visit(child, depth + 1);
219 }
220 });
@@ -233,6 +248,7 @@ const inspectCursorSkills = Effect.fn("inspectCursorSkills")(function* (
248 const skillsByName = new Map<string, ServerProviderSkill>();
249 const budget: CursorSkillScanBudget = {
250 remainingEntries: MAX_SKILL_SCAN_ENTRIES,
251 + remainingStats: MAX_SKILL_SCAN_STATS,
252 remainingBytes: MAX_SKILL_SCAN_BYTES,
253 exhausted: false,
254 incomplete: false,