Skip to content

Commit b528fd6

Browse files
fix(cursor): count skill file checks toward scan limit
1 parent f88c140 commit b528fd6

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,9 @@ describe("Cursor skills", () => {
217217
? Effect.succeed(Array.from({ length: 200_000 }, (_, index) => `file-${index}`))
218218
: Effect.succeed([]),
219219
stat: (path) => {
220+
stats += 1;
220221
if (path === root) return Effect.succeed({ type: "Directory" } as FileSystem.File.Info);
221222
if (path.startsWith(`${root}/file-`)) {
222-
stats += 1;
223223
return Effect.succeed({ type: "File" } as FileSystem.File.Info);
224224
}
225225
return Effect.fail(
@@ -234,7 +234,11 @@ describe("Cursor skills", () => {
234234
Effect.runPromise,
235235
);
236236

237-
expect(result._tag).toBe("Failure");
237+
expect(result).toMatchObject({
238+
_tag: "Failure",
239+
failure: { reason: "scan-budget-exhausted" },
240+
});
241+
expect(stats).toBeGreaterThanOrEqual(100_000);
238242
expect(stats).toBeLessThanOrEqual(100_000);
239243
});
240244

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,11 @@ const discoverSkillsInRoot = Effect.fn("discoverCursorSkillsInRoot")(function* (
164164
resolvedDirectory === rootDirectory ||
165165
resolvedDirectory.startsWith(`${rootDirectory}${path.sep}`);
166166

167+
if (input.budget.remainingStats === 0) {
168+
input.budget.exhausted = true;
169+
return;
170+
}
171+
input.budget.remainingStats -= 1;
167172
const skillPath = path.join(directory, "SKILL.md");
168173
const skillInfo = yield* orUndefined(fileSystem.stat(skillPath), input.budget);
169174
if (skillInfo?.type === "File") {

0 commit comments

Comments
 (0)