Skip to content

Commit 167f5ec

Browse files
authored
fix(provider-cursor): installed node_modules no longer exhaust skill discovery (pingdotgg#19806)
1 parent 871c7b7 commit 167f5ec

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

‎packages/provider-cursor/src/server/skills.test.ts‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,51 @@ describe("Cursor skills", () => {
162162
}),
163163
));
164164

165+
it("discovers skills across roots without scanning installed node_modules", async () =>
166+
await runNode(
167+
Effect.gen(function* () {
168+
const fileSystem = yield* FileSystem.FileSystem;
169+
const path = yield* Path.Path;
170+
const userHome = yield* fileSystem
171+
.makeTempDirectoryScoped({
172+
directory: NodeOS.tmpdir(),
173+
prefix: "cursor-skills-home-",
174+
})
175+
.pipe(Effect.flatMap((directory) => fileSystem.realPath(directory)));
176+
const root = path.join(userHome, ".agents", "skills");
177+
const dependencies = path.join(root, "review", "tests", "node_modules");
178+
yield* fileSystem.makeDirectory(dependencies, { recursive: true });
179+
yield* Effect.forEach(
180+
Array.from({ length: 10_001 }, (_, index) => path.join(dependencies, `entry-${index}`)),
181+
(file) => fileSystem.writeFileString(file, ""),
182+
{ concurrency: 64, discard: true },
183+
);
184+
const skillDirectories = [
185+
path.join(root, "review"),
186+
path.join(root, "sibling"),
187+
path.join(userHome, ".claude", "skills", "later"),
188+
];
189+
for (const directory of skillDirectories) {
190+
yield* fileSystem.makeDirectory(directory, { recursive: true });
191+
yield* fileSystem.writeFileString(path.join(directory, "SKILL.md"), "---\n---\n");
192+
}
193+
194+
const result = yield* probeCursorSkills(undefined, { HOME: userHome }).pipe(Effect.result);
195+
expect(result._tag).toBe("Success");
196+
if (result._tag !== "Success") return;
197+
expect(result.success).toEqual(
198+
skillDirectories
199+
.map((directory) => ({
200+
name: path.basename(directory),
201+
path: path.join(directory, "SKILL.md"),
202+
scope: "user",
203+
enabled: true,
204+
}))
205+
.sort((left, right) => left.name.localeCompare(right.name)),
206+
);
207+
}),
208+
));
209+
165210
it("still fails discovery when a root holds more entries than the scan allows", async () =>
166211
await runNode(
167212
Effect.gen(function* () {

‎packages/provider-cursor/src/server/skills.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ const discoverSkillsInRoot = Effect.fn("discoverCursorSkillsInRoot")(function* (
197197
return;
198198
}
199199
input.budget.remainingEntries -= 1;
200+
// Installed dependencies can exhaust the shared budget and hide unrelated skills.
201+
if (entry === "node_modules") continue;
200202
const child = path.join(directory, entry);
201203
const info = yield* orUndefined(fileSystem.stat(child), input.budget);
202204
if (info?.type !== "Directory") continue;

0 commit comments

Comments
 (0)