fix(server): include Cursor plugin skills in the composer picker #16430
ClosedMelv1C(GitHub profile, opens in a new tab)wants to merge 4 commits into
main fromrefs/pull/16430/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/server/src/provider/Drivers/CursorSkills.ts line 280OutdatedResolvedby Melv1C(GitHub profile, opens in a new tab)@@ -216,3 +271,10 @@216271 return skills;217272 });218273274+const decodePluginJson = Schema.decodeUnknownEffect(Schema.fromJsonString(Schema.Unknown));275+276+const readJsonObject = Effect.fn("readCursorPluginJson")(function* (277+ file: string,278+): Effect.fn.Return<Record<string, unknown> | undefined, never, FileSystem.FileSystem> {279+ const fileSystem = yield* FileSystem.FileSystem;280+ const contents = yield* orUndefined(fileSystem.readFileString(file));apps/server/src/provider/Drivers/CursorSkills.ts line 436Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -218,0 +398,21 @@398+ const skill = yield* readContainedSkill(resolved);399+ if (skill) skills.push(skill);400+ return;401+ }402+ }403+ skills.push(404+ ...(yield* discoverPluginSkillDirectory({405+ directory: resolved,406+ pluginRoot: input.directory,407+ scope: input.scope,408+ budget: input.budget,409+ })),410+ );411+ });412+413+ if (manifest && "skills" in manifest) {414+ const declared = manifest.skills;415+ if (typeof declared === "string") {416+ yield* readDeclaredSkills(declared, true);417+ } else if (Array.isArray(declared)) {418+ for (const entry of declared) {
- apps/server/src/provider/Drivers/CursorSkills.ts lines 445 to 458Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -218,0 +420,21 @@420+ if (typeof entry !== "string") continue;421+ yield* readDeclaredSkills(entry, false);422+ }423+ }424+ return skills;425+ }426+427+ const skillsDirectory = path.join(input.directory, "skills");428+ const skillsInfo = yield* orUndefined(fileSystem.stat(skillsDirectory), input.budget);429+ if (skillsInfo?.type === "Directory") {430+ skills.push(431+ ...(yield* discoverPluginSkillDirectory({432+ directory: skillsDirectory,433+ pluginRoot: input.directory,434+ scope: input.scope,435+ budget: input.budget,436+ })),437+ );438+ }439+ const rootSkill = yield* readContainedSkill(input.directory);440+ if (rootSkill) skills.push(rootSkill);
- apps/server/src/provider/Drivers/CursorSkills.ts lines 512 to 526Resolvedby Melv1C(GitHub profile, opens in a new tab)@@ -218,0 +519,21 @@519+ readonly addInstall: (directory: string) => void;520+}): Effect.fn.Return<void, never, FileSystem.FileSystem | Path.Path> {521+ const fileSystem = yield* FileSystem.FileSystem;522+ const path = yield* Path.Path;523+ // The SDK marks a finished cache install with .cache-complete and leaves old524+ // SHAs on disk. Several completed versions are ambiguous, so only one is used.525+ const marketplaces = yield* listDirectoryNames(input.cacheRoot, input.budget);526+ if (!marketplaces) return;527+ for (const marketplace of marketplaces) {528+ if (!takeScanEntry(input.budget)) return;529+ if (marketplace.startsWith(".")) continue;530+ const marketplaceDirectory = path.join(input.cacheRoot, marketplace);531+ const marketplaceInfo = yield* orUndefined(fileSystem.stat(marketplaceDirectory), input.budget);532+ if (marketplaceInfo?.type !== "Directory") continue;533+ const plugins = yield* listDirectoryNames(marketplaceDirectory, input.budget);534+ if (!plugins) continue;535+ for (const plugin of plugins) {536+ if (!takeScanEntry(input.budget)) return;537+ if (plugin.startsWith(".")) continue;538+ const pluginDirectory = path.join(marketplaceDirectory, plugin);539+ const pluginInfo = yield* orUndefined(fileSystem.stat(pluginDirectory), input.budget);apps/server/src/provider/Drivers/CursorSkills.ts line 515Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -218,0 +508,21 @@508+ yield* addCompletedCachePlugins({509+ cacheRoot: path.join(input.userHome, ".cursor", "plugins", "cache"),510+ budget: input.budget,511+ addInstall,512+ });513+ return installs;514+});515+516+const addCompletedCachePlugins = Effect.fn("addCompletedCursorCachePlugins")(function* (input: {517+ readonly cacheRoot: string;518+ readonly budget: CursorSkillScanBudget;519+ readonly addInstall: (directory: string) => void;520+}): Effect.fn.Return<void, never, FileSystem.FileSystem | Path.Path> {521+ const fileSystem = yield* FileSystem.FileSystem;522+ const path = yield* Path.Path;523+ // The SDK marks a finished cache install with .cache-complete and leaves old524+ // SHAs on disk. Several completed versions are ambiguous, so only one is used.525+ const marketplaces = yield* listDirectoryNames(input.cacheRoot, input.budget);526+ if (!marketplaces) return;527+ for (const marketplace of marketplaces) {528+ if (!takeScanEntry(input.budget)) return;
- apps/server/src/provider/Drivers/CursorSkills.ts lines 587 to 590OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -237,9 +574,17 @@237574 exhausted: false,238575 incomplete: false,239576 };240- for (const root of roots) {241- if (budget.exhausted) break;242- const skills = yield* discoverSkillsInRoot({ ...root, budget });577+ const remember = (skills: ReadonlyArray<ServerProviderSkill>) => {243578 for (const skill of skills) {244579 if (!skillsByName.has(skill.name)) skillsByName.set(skill.name, skill);245580 }581+ };582+ for (const root of roots) {583+ if (budget.exhausted) break;584+ remember(yield* discoverSkillsInRoot({ ...root, budget }));585+ }586+ if (!budget.exhausted) {587+ const localInstalls = yield* cursorLocalPluginInstalls({ userHome, budget });588+ for (const install of localInstalls) {589+ if (budget.exhausted) break;590+ remember(yield* discoverSkillsInPlugin({ ...install, budget }));
juliusmarminge added labelsmacroscope-review
- @@ -218,0 +336,21 @@336+ budget: input.budget,337+ containmentRoot: input.pluginRoot,338+ });339+ if (skill) skills.push(skill);340+ }341+ return skills;342+ },343+);344+345+const resolvePluginRelativePath = Effect.fn("resolveCursorPluginRelativePath")(function* (346+ pluginRoot: string,347+ relativePath: string,348+): Effect.fn.Return<string | undefined, never, FileSystem.FileSystem | Path.Path> {349+ const fileSystem = yield* FileSystem.FileSystem;350+ const path = yield* Path.Path;351+ const safePath = safePluginRelativePath(relativePath);352+ if (!safePath) return undefined;353+ const candidate = path.resolve(pluginRoot, safePath);354+ if (!isPathInside(path.resolve(pluginRoot), candidate, path)) return undefined;355+ const [resolvedRoot, resolvedCandidate] = yield* Effect.all([356+ orUndefined(fileSystem.realPath(pluginRoot)),
maria-rcks closed this
Sign in to join this conversation.
copilot-pull-request-reviewer[bot](GitHub profile, opens in a new tab) reviewed
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.