@cursor/july 0.1.73 → 0.1.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +13 -8
- package/dist/bin/agent-serve.js +7 -5
- package/dist/docs/404.html +2 -2
- package/dist/docs/ab.html +3 -3
- package/dist/docs/assets/{app.CdbcFD8T.js → app.BETd-WqU.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.DM5INS71.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.D_NKImM7.js → VPLocalSearchBox.wEaGEmV9.js} +1 -1
- package/dist/docs/assets/chunks/{theme.CMvz7cu9.js → theme.DNDicFOP.js} +2 -2
- package/dist/docs/assets/{reference_cli.md.Cl14Jfo3.js → reference_cli.md.TAaYU8br.js} +3 -3
- package/dist/docs/assets/{reference_cli.md.Cl14Jfo3.lean.js → reference_cli.md.TAaYU8br.lean.js} +1 -1
- package/dist/docs/assets/scaffolding-agents.md.CiGsJ1aw.js +1 -0
- package/dist/docs/assets/{scaffolding-agents.md.CrWSA0Ko.lean.js → scaffolding-agents.md.CiGsJ1aw.lean.js} +1 -1
- package/dist/docs/building-with-agents.html +3 -3
- package/dist/docs/concepts.html +3 -3
- package/dist/docs/deployment.html +3 -3
- package/dist/docs/evals.html +3 -3
- package/dist/docs/example-agents/approval-buddy.html +3 -3
- package/dist/docs/example-agents/benny.html +3 -3
- package/dist/docs/example-agents/bugbot.html +3 -3
- package/dist/docs/example-agents/codebase-wiki.html +3 -3
- package/dist/docs/example-agents/codeowners-review.html +3 -3
- package/dist/docs/example-agents/concierge.html +3 -3
- package/dist/docs/example-agents/fsd.html +3 -3
- package/dist/docs/example-agents/index.html +3 -3
- package/dist/docs/example-agents/knowledge-base.html +3 -3
- package/dist/docs/example-agents/oncall.html +3 -3
- package/dist/docs/example-agents/security-reviewer.html +3 -3
- package/dist/docs/example-agents/slack-agent.html +3 -3
- package/dist/docs/example-agents/weather-agent.html +3 -3
- package/dist/docs/guides/agent-to-agent.html +3 -3
- package/dist/docs/guides/cloud-runtime.html +3 -3
- package/dist/docs/guides/convert-automation.html +3 -3
- package/dist/docs/guides/github.html +3 -3
- package/dist/docs/guides/human-in-the-loop.html +3 -3
- package/dist/docs/guides/mcp-oauth.html +3 -3
- package/dist/docs/guides/opentelemetry.html +3 -3
- package/dist/docs/guides/slack.html +3 -3
- package/dist/docs/guides/webhooks.html +3 -3
- package/dist/docs/hashmap.json +1 -1
- package/dist/docs/hillclimbing.html +3 -3
- package/dist/docs/index.html +3 -3
- package/dist/docs/quickstart.html +3 -3
- package/dist/docs/reference/agent-config.html +3 -3
- package/dist/docs/reference/artifacts.html +3 -3
- package/dist/docs/reference/channels.html +3 -3
- package/dist/docs/reference/cli.html +6 -6
- package/dist/docs/reference/connections.html +3 -3
- package/dist/docs/reference/hooks.html +3 -3
- package/dist/docs/reference/http-api.html +3 -3
- package/dist/docs/reference/instructions.html +3 -3
- package/dist/docs/reference/playground.html +3 -3
- package/dist/docs/reference/project-layout.html +3 -3
- package/dist/docs/reference/prompt.html +3 -3
- package/dist/docs/reference/schedules.html +3 -3
- package/dist/docs/reference/sessions.html +3 -3
- package/dist/docs/reference/skills.html +3 -3
- package/dist/docs/reference/subagents.html +3 -3
- package/dist/docs/reference/tools.html +3 -3
- package/dist/docs/scaffolding-agents.html +5 -5
- package/dist/docs/storage.html +3 -3
- package/dist/docs/templates/agentic-owners.html +3 -3
- package/dist/docs/templates/demo.html +3 -3
- package/dist/docs/templates/pr-autofixer.html +3 -3
- package/dist/docs/templates/security-reviewer.html +3 -3
- package/dist/docs/templates/triage.html +3 -3
- package/dist/docs/troubleshooting.html +3 -3
- package/dist/internal/cli-skills.d.ts +4 -2
- package/dist/internal/cli-skills.d.ts.map +1 -1
- package/dist/internal/cli-skills.js +8 -3
- package/dist/internal/install-cursor-skills.d.ts +71 -16
- package/dist/internal/install-cursor-skills.d.ts.map +1 -1
- package/dist/internal/install-cursor-skills.js +160 -48
- package/dist/internal/sdk-runner.d.ts.map +1 -1
- package/dist/internal/sdk-runner.js +6 -2
- package/dist/playground/assets/index-D_8I9TM0.js +85 -0
- package/dist/playground/assets/index-M3nSMc6_.css +1 -0
- package/dist/playground/index.html +2 -2
- package/docs/reference/cli.md +16 -8
- package/docs/scaffolding-agents.md +14 -6
- package/package.json +3 -1
- package/scripts/install-cursor-skills.mjs +36 -0
- package/skills/ab/SKILL.md +1 -1
- package/skills/create-agent/SKILL.md +1 -1
- package/skills/debug/SKILL.md +1 -1
- package/skills/evals/SKILL.md +1 -1
- package/skills/framework-map/SKILL.md +1 -1
- package/skills/github/SKILL.md +1 -1
- package/skills/hillclimb/SKILL.md +1 -1
- package/skills/mcp-auth/SKILL.md +1 -1
- package/skills/otel/SKILL.md +1 -1
- package/skills/setup-slack/SKILL.md +1 -1
- package/src/bin/agent-serve.ts +7 -5
- package/src/internal/cli-skills.ts +10 -2
- package/src/internal/install-cursor-skills.ts +204 -49
- package/src/internal/sdk-runner.ts +6 -3
- package/dist/docs/assets/chunks/@localSearchIndexroot.DQad--_z.js +0 -1
- package/dist/docs/assets/scaffolding-agents.md.CrWSA0Ko.js +0 -1
- package/dist/playground/assets/index-77uhu5Kr.css +0 -1
- package/dist/playground/assets/index-D4buox4m.js +0 -85
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Offer to install the package's coding-agent skills into the user's
|
|
3
|
-
* personal Cursor skills dir under `~/.cursor/skills/
|
|
3
|
+
* personal Cursor skills dir under `~/.cursor/skills/agentsdk/<skill>/`.
|
|
4
4
|
*
|
|
5
|
-
* Cursor walks `~/.cursor/skills` recursively, so the `
|
|
5
|
+
* Cursor walks `~/.cursor/skills` recursively, so the `agentsdk/` folder is
|
|
6
6
|
* only organizational — identity comes from the leaf folder that holds
|
|
7
|
-
* SKILL.md.
|
|
7
|
+
* SKILL.md. Installed copies get `alwaysApply: true` so Cursor injects the
|
|
8
|
+
* skill body as a global rule instead of leaving it as an on-demand catalog
|
|
9
|
+
* entry. Skipped for `--json` / non-TTY hosts.
|
|
10
|
+
*
|
|
11
|
+
* Consumer installs (`npm install` / `npx` of `@cursor/july`) also copy
|
|
12
|
+
* these skills from a postinstall hook. That path never prompts and never
|
|
13
|
+
* fails the package install. The monorepo source checkout is not a consumer
|
|
14
|
+
* install, so `pnpm install` in everysphere does not overwrite `~/.cursor`.
|
|
8
15
|
*/
|
|
9
16
|
|
|
10
17
|
import {
|
|
@@ -21,51 +28,86 @@ import {
|
|
|
21
28
|
import { homedir } from "node:os";
|
|
22
29
|
import { join } from "node:path";
|
|
23
30
|
import { CLI_COMMAND_NAME, packageRootDir } from "./distribution.js";
|
|
31
|
+
import { parseFrontmatter } from "./frontmatter.js";
|
|
24
32
|
import { stdoutPalette } from "./terminal-style.js";
|
|
25
33
|
|
|
26
34
|
/** Monorepo-only skill; excluded from the published package. */
|
|
27
35
|
const SKIP_SKILL_DIRS = new Set(["operate"]);
|
|
28
36
|
|
|
29
37
|
/** Category folder under ~/.cursor/skills (Cursor discovers nested skills). */
|
|
30
|
-
export const CURSOR_SKILLS_NAMESPACE = "
|
|
38
|
+
export const CURSOR_SKILLS_NAMESPACE = "agentsdk";
|
|
39
|
+
|
|
40
|
+
/** Pre-rename install folder. Install deletes this so `/agentkit-*` rows disappear. */
|
|
41
|
+
export const LEGACY_CURSOR_SKILLS_NAMESPACE = "agentkit";
|
|
31
42
|
|
|
32
43
|
/** How long the `init` offer waits for an answer before skipping the install. */
|
|
33
44
|
export const SKILL_PROMPT_TIMEOUT_MS = 45_000;
|
|
34
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Override the resolved `~/.cursor/skills` directory (not the user home).
|
|
48
|
+
* Used by the postinstall hook in tests and publish smoke.
|
|
49
|
+
*/
|
|
50
|
+
export const CURSOR_JULY_SKILLS_HOME_ENV = "CURSOR_JULY_SKILLS_HOME";
|
|
51
|
+
|
|
52
|
+
/** Set to `1` to skip the postinstall skill copy. */
|
|
53
|
+
export const CURSOR_JULY_SKIP_SKILL_INSTALL_ENV =
|
|
54
|
+
"CURSOR_JULY_SKIP_SKILL_INSTALL";
|
|
55
|
+
|
|
35
56
|
export interface PackageSkill {
|
|
36
|
-
/** Frontmatter `name` (e.g.
|
|
57
|
+
/** Frontmatter `name` (e.g. agentsdk-create-agent). */
|
|
37
58
|
name: string;
|
|
38
|
-
/** Leaf install directory under
|
|
59
|
+
/** Leaf install directory under agentsdk/ (e.g. create-agent). */
|
|
39
60
|
leafDir: string;
|
|
40
61
|
/** Absolute path to the source skill directory in the package. */
|
|
41
62
|
sourceDir: string;
|
|
42
63
|
}
|
|
43
64
|
|
|
44
|
-
export function cursorSkillsHome(
|
|
45
|
-
home
|
|
46
|
-
):
|
|
47
|
-
|
|
48
|
-
|
|
65
|
+
export function cursorSkillsHome(home?: string): string {
|
|
66
|
+
if (home !== undefined) {
|
|
67
|
+
return join(home.trim() === "" ? homedir() : home, ".cursor", "skills");
|
|
68
|
+
}
|
|
69
|
+
const override = process.env[CURSOR_JULY_SKILLS_HOME_ENV]?.trim();
|
|
70
|
+
if (override !== undefined && override !== "") {
|
|
71
|
+
return override;
|
|
72
|
+
}
|
|
73
|
+
return join(homedir(), ".cursor", "skills");
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* True when this package root is an installed copy under `node_modules`
|
|
78
|
+
* (npm, pnpm, yarn, npx, global), not the everysphere source checkout.
|
|
79
|
+
*/
|
|
80
|
+
export function isConsumerPackageInstall(packageRoot: string): boolean {
|
|
81
|
+
// Segment check only — split on both separators so a Windows path still
|
|
82
|
+
// matches when this runs (or is tested) on POSIX. Do not rewrite the path.
|
|
83
|
+
return packageRoot.split(/[\\/]/).includes("node_modules");
|
|
49
84
|
}
|
|
50
85
|
|
|
51
|
-
/** `~/.cursor/skills/
|
|
52
|
-
export function
|
|
86
|
+
/** `~/.cursor/skills/agentsdk` — where package skills are installed. */
|
|
87
|
+
export function agentsdkCursorSkillsDir(
|
|
53
88
|
skillsHome: string = cursorSkillsHome()
|
|
54
89
|
): string {
|
|
55
90
|
return join(skillsHome, CURSOR_SKILLS_NAMESPACE);
|
|
56
91
|
}
|
|
57
92
|
|
|
58
|
-
/**
|
|
93
|
+
/** Pre-rename `~/.cursor/skills/agentkit`. */
|
|
94
|
+
export function legacyAgentkitCursorSkillsDir(
|
|
95
|
+
skillsHome: string = cursorSkillsHome()
|
|
96
|
+
): string {
|
|
97
|
+
return join(skillsHome, LEGACY_CURSOR_SKILLS_NAMESPACE);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Absolute install path for one skill: `…/agentsdk/<leafDir>`. */
|
|
59
101
|
export function skillInstallPath(
|
|
60
102
|
skill: Pick<PackageSkill, "leafDir">,
|
|
61
103
|
skillsHome: string = cursorSkillsHome()
|
|
62
104
|
): string {
|
|
63
|
-
return join(
|
|
105
|
+
return join(agentsdkCursorSkillsDir(skillsHome), skill.leafDir);
|
|
64
106
|
}
|
|
65
107
|
|
|
66
108
|
/**
|
|
67
109
|
* Skills shipped next to the running package. Uses the frontmatter `name`
|
|
68
|
-
* when present, otherwise `
|
|
110
|
+
* when present, otherwise `agentsdk-<dir>`.
|
|
69
111
|
*/
|
|
70
112
|
export async function listShippedPackageSkills(
|
|
71
113
|
packageRoot: string = packageRootDir()
|
|
@@ -91,7 +133,9 @@ export async function listShippedPackageSkills(
|
|
|
91
133
|
continue;
|
|
92
134
|
}
|
|
93
135
|
const raw = await readFile(skillMd, "utf8");
|
|
94
|
-
const name =
|
|
136
|
+
const name =
|
|
137
|
+
parseFrontmatter(raw).data.name ||
|
|
138
|
+
`${CURSOR_SKILLS_NAMESPACE}-${entry.name}`;
|
|
95
139
|
skills.push({ name, leafDir: entry.name, sourceDir });
|
|
96
140
|
}
|
|
97
141
|
skills.sort((a, b) => a.leafDir.localeCompare(b.leafDir));
|
|
@@ -99,7 +143,7 @@ export async function listShippedPackageSkills(
|
|
|
99
143
|
}
|
|
100
144
|
|
|
101
145
|
/**
|
|
102
|
-
* Skills that do not yet have a SKILL.md under ~/.cursor/skills/
|
|
146
|
+
* Skills that do not yet have a SKILL.md under ~/.cursor/skills/agentsdk/.
|
|
103
147
|
* Install still overwrites every shipped skill when the user confirms — this
|
|
104
148
|
* helper is for messaging (fresh install vs update).
|
|
105
149
|
*/
|
|
@@ -125,18 +169,22 @@ export interface SkillInstallResult {
|
|
|
125
169
|
installed: string[];
|
|
126
170
|
/** Leaf dirs deleted because the package no longer ships them. */
|
|
127
171
|
removed: string[];
|
|
172
|
+
/** True when leftover `~/.cursor/skills/agentkit` was deleted. */
|
|
173
|
+
removedLegacyNamespace: boolean;
|
|
128
174
|
}
|
|
129
175
|
|
|
130
176
|
/**
|
|
131
|
-
* Copy each skill directory into `skillsHome/
|
|
177
|
+
* Copy each skill directory into `skillsHome/agentsdk/<leafDir>/`.
|
|
132
178
|
* Always overwrites so a package upgrade refreshes local Cursor skills.
|
|
133
|
-
* Strips monorepo-only frontmatter
|
|
179
|
+
* Strips monorepo-only frontmatter, sets `alwaysApply: true` so Cursor
|
|
180
|
+
* loads the body into context, and removes leaf dirs no longer shipped.
|
|
181
|
+
* Also deletes leftover `skillsHome/agentkit/` from the previous namespace.
|
|
134
182
|
*/
|
|
135
183
|
export async function installCursorSkills(
|
|
136
184
|
skills: readonly PackageSkill[],
|
|
137
185
|
skillsHome: string = cursorSkillsHome()
|
|
138
186
|
): Promise<SkillInstallResult> {
|
|
139
|
-
const namespaceDir =
|
|
187
|
+
const namespaceDir = agentsdkCursorSkillsDir(skillsHome);
|
|
140
188
|
await mkdir(namespaceDir, { recursive: true });
|
|
141
189
|
|
|
142
190
|
const removed = await orphanLeaves(namespaceDir, skills);
|
|
@@ -161,7 +209,9 @@ export async function installCursorSkills(
|
|
|
161
209
|
}
|
|
162
210
|
installed.push(skill.leafDir);
|
|
163
211
|
}
|
|
164
|
-
|
|
212
|
+
const removedLegacyNamespace =
|
|
213
|
+
await removeLegacyCursorSkillsNamespace(skillsHome);
|
|
214
|
+
return { installed, removed, removedLegacyNamespace };
|
|
165
215
|
}
|
|
166
216
|
|
|
167
217
|
async function makeTreeWritable(root: string): Promise<void> {
|
|
@@ -202,13 +252,43 @@ async function orphanLeaves(
|
|
|
202
252
|
.map((entry) => entry.name);
|
|
203
253
|
}
|
|
204
254
|
|
|
205
|
-
/** Drop
|
|
255
|
+
/** Drop leftover `skillsHome/agentkit` from the previous install namespace. */
|
|
256
|
+
async function removeLegacyCursorSkillsNamespace(
|
|
257
|
+
skillsHome: string
|
|
258
|
+
): Promise<boolean> {
|
|
259
|
+
const legacyDir = legacyAgentkitCursorSkillsDir(skillsHome);
|
|
260
|
+
try {
|
|
261
|
+
await stat(legacyDir);
|
|
262
|
+
} catch {
|
|
263
|
+
return false;
|
|
264
|
+
}
|
|
265
|
+
await rm(legacyDir, { recursive: true, force: true });
|
|
266
|
+
return true;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
async function hasLegacyCursorSkillsNamespace(
|
|
270
|
+
skillsHome: string
|
|
271
|
+
): Promise<boolean> {
|
|
272
|
+
try {
|
|
273
|
+
await stat(legacyAgentkitCursorSkillsDir(skillsHome));
|
|
274
|
+
return true;
|
|
275
|
+
} catch {
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Drop monorepo `paths` globs, set `alwaysApply: true` so Cursor injects the
|
|
282
|
+
* body as a global rule, and fix package doc links for ~/.cursor installs.
|
|
283
|
+
*/
|
|
206
284
|
export function prepareSkillMarkdownForCursorInstall(content: string): string {
|
|
207
285
|
const match = /^---\r?\n([\s\S]*?)\r?\n---/.exec(content);
|
|
208
286
|
if (match === null) {
|
|
209
287
|
return content;
|
|
210
288
|
}
|
|
211
|
-
const frontmatter =
|
|
289
|
+
const frontmatter = withAlwaysApply(
|
|
290
|
+
stripPathsFromFrontmatter(match[1] ?? "")
|
|
291
|
+
);
|
|
212
292
|
const body = content.slice(match[0].length);
|
|
213
293
|
const adjustedBody = body.replace(
|
|
214
294
|
/\[`docs\/([^`]+)`\]\(\.\.\/\.\.\/docs\/[^)]+\)/g,
|
|
@@ -235,11 +315,24 @@ function stripPathsFromFrontmatter(frontmatter: string): string {
|
|
|
235
315
|
return out.join("\n");
|
|
236
316
|
}
|
|
237
317
|
|
|
318
|
+
/** Cursor loads `alwaysApply: true` skills as global rules, not catalog rows. */
|
|
319
|
+
function withAlwaysApply(frontmatter: string): string {
|
|
320
|
+
const without = frontmatter
|
|
321
|
+
.split(/\r?\n/)
|
|
322
|
+
.filter((line) => !/^\s*alwaysApply\s*:/.test(line))
|
|
323
|
+
.join("\n")
|
|
324
|
+
.replace(/\n+$/, "");
|
|
325
|
+
if (without === "") {
|
|
326
|
+
return "alwaysApply: true";
|
|
327
|
+
}
|
|
328
|
+
return `${without}\nalwaysApply: true`;
|
|
329
|
+
}
|
|
330
|
+
|
|
238
331
|
export interface SkillInstallPlan {
|
|
239
332
|
shipped: PackageSkill[];
|
|
240
333
|
/** Resolved `~/.cursor/skills`, to install into. */
|
|
241
334
|
skillsHome: string;
|
|
242
|
-
/** Install target: `<skillsHome>/
|
|
335
|
+
/** Install target: `<skillsHome>/agentsdk`. */
|
|
243
336
|
directory: string;
|
|
244
337
|
/** Leaf dirs the package ships. */
|
|
245
338
|
leaves: string[];
|
|
@@ -247,6 +340,8 @@ export interface SkillInstallPlan {
|
|
|
247
340
|
firstInstall: boolean;
|
|
248
341
|
/** Installed leaf dirs the package dropped; installing deletes them. */
|
|
249
342
|
orphans: string[];
|
|
343
|
+
/** True when leftover `skillsHome/agentkit` still exists. */
|
|
344
|
+
hasLegacyNamespace: boolean;
|
|
250
345
|
}
|
|
251
346
|
|
|
252
347
|
/** What an install would do, for the offer and for `install-skills`. */
|
|
@@ -255,19 +350,26 @@ export async function planSkillInstall(options?: {
|
|
|
255
350
|
skillsHome?: string;
|
|
256
351
|
}): Promise<SkillInstallPlan> {
|
|
257
352
|
const skillsHome = options?.skillsHome ?? cursorSkillsHome();
|
|
258
|
-
const directory =
|
|
353
|
+
const directory = agentsdkCursorSkillsDir(skillsHome);
|
|
259
354
|
const shipped = await listShippedPackageSkills(options?.packageRoot);
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
355
|
+
const present = await Promise.all(
|
|
356
|
+
shipped.map(async (skill) => {
|
|
357
|
+
try {
|
|
358
|
+
await access(join(skillInstallPath(skill, skillsHome), "SKILL.md"));
|
|
359
|
+
return true;
|
|
360
|
+
} catch {
|
|
361
|
+
return false;
|
|
362
|
+
}
|
|
363
|
+
})
|
|
364
|
+
);
|
|
264
365
|
return {
|
|
265
366
|
shipped,
|
|
266
367
|
skillsHome,
|
|
267
368
|
directory,
|
|
268
369
|
leaves: shipped.map((skill) => skill.leafDir),
|
|
269
|
-
firstInstall:
|
|
370
|
+
firstInstall: present.every((isPresent) => !isPresent),
|
|
270
371
|
orphans: await orphanLeaves(directory, shipped),
|
|
372
|
+
hasLegacyNamespace: await hasLegacyCursorSkillsNamespace(skillsHome),
|
|
271
373
|
};
|
|
272
374
|
}
|
|
273
375
|
|
|
@@ -282,10 +384,73 @@ export function formatSkillInstall(
|
|
|
282
384
|
if (result.removed.length > 0) {
|
|
283
385
|
lines.push(` removed: ${result.removed.join(", ")}`);
|
|
284
386
|
}
|
|
387
|
+
if (result.removedLegacyNamespace) {
|
|
388
|
+
lines.push(
|
|
389
|
+
` removed: ${legacyAgentkitCursorSkillsDir(plan.skillsHome)} (legacy namespace)`
|
|
390
|
+
);
|
|
391
|
+
}
|
|
285
392
|
lines.push(` location: ${plan.directory}`);
|
|
286
393
|
return `${lines.join("\n")}\n`;
|
|
287
394
|
}
|
|
288
395
|
|
|
396
|
+
export type PackageInstallSkillSyncResult =
|
|
397
|
+
| { status: "installed"; installed: string[]; removed: string[] }
|
|
398
|
+
| {
|
|
399
|
+
status: "skipped";
|
|
400
|
+
reason: "opt-out" | "not-consumer" | "no-skills" | "error";
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
export interface SyncCursorSkillsOnPackageInstallOptions {
|
|
404
|
+
packageRoot?: string;
|
|
405
|
+
skillsHome?: string;
|
|
406
|
+
env?: NodeJS.ProcessEnv;
|
|
407
|
+
/** Override the node_modules consumer check. */
|
|
408
|
+
consumer?: boolean;
|
|
409
|
+
out?: (text: string) => void;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* Copy shipped coding-agent skills into ~/.cursor/skills/agentsdk during a
|
|
414
|
+
* consumer `npm install` / `npx`. Never throws: a failed copy must not fail
|
|
415
|
+
* the package install. No-op in the monorepo source tree and when
|
|
416
|
+
* `CURSOR_JULY_SKIP_SKILL_INSTALL=1`.
|
|
417
|
+
*/
|
|
418
|
+
export async function syncCursorSkillsOnPackageInstall(
|
|
419
|
+
options: SyncCursorSkillsOnPackageInstallOptions = {}
|
|
420
|
+
): Promise<PackageInstallSkillSyncResult> {
|
|
421
|
+
try {
|
|
422
|
+
const env = options.env ?? process.env;
|
|
423
|
+
if (env[CURSOR_JULY_SKIP_SKILL_INSTALL_ENV] === "1") {
|
|
424
|
+
return { status: "skipped", reason: "opt-out" };
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
const packageRoot = options.packageRoot ?? packageRootDir();
|
|
428
|
+
const consumer = options.consumer ?? isConsumerPackageInstall(packageRoot);
|
|
429
|
+
if (!consumer) {
|
|
430
|
+
return { status: "skipped", reason: "not-consumer" };
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
const plan = await planSkillInstall({
|
|
434
|
+
packageRoot,
|
|
435
|
+
skillsHome: options.skillsHome,
|
|
436
|
+
});
|
|
437
|
+
if (plan.shipped.length === 0) {
|
|
438
|
+
return { status: "skipped", reason: "no-skills" };
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
const result = await installCursorSkills(plan.shipped, plan.skillsHome);
|
|
442
|
+
const out = options.out ?? ((text) => process.stderr.write(text));
|
|
443
|
+
out(formatSkillInstall(plan, result));
|
|
444
|
+
return {
|
|
445
|
+
status: "installed",
|
|
446
|
+
installed: result.installed,
|
|
447
|
+
removed: result.removed,
|
|
448
|
+
};
|
|
449
|
+
} catch {
|
|
450
|
+
return { status: "skipped", reason: "error" };
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
289
454
|
export interface OfferInstallCursorSkillsOptions {
|
|
290
455
|
/** Skip when false (non-TTY / `--json`). */
|
|
291
456
|
interactive?: boolean;
|
|
@@ -298,7 +463,7 @@ export interface OfferInstallCursorSkillsOptions {
|
|
|
298
463
|
|
|
299
464
|
/**
|
|
300
465
|
* On a TTY, offer to install/update every shipped package skill into
|
|
301
|
-
* ~/.cursor/skills/
|
|
466
|
+
* ~/.cursor/skills/agentsdk (always overwriting). No-op when non-interactive
|
|
302
467
|
* or the package ships no skills. An unanswered prompt skips the install
|
|
303
468
|
* rather than blocking the caller — see `SKILL_PROMPT_TIMEOUT_MS`.
|
|
304
469
|
*/
|
|
@@ -334,6 +499,13 @@ export async function offerInstallCursorSkills(
|
|
|
334
499
|
if (plan.orphans.length > 0) {
|
|
335
500
|
out(c.dim(` (deletes ${plan.orphans.join(", ")})\n`));
|
|
336
501
|
}
|
|
502
|
+
if (plan.hasLegacyNamespace) {
|
|
503
|
+
out(
|
|
504
|
+
c.dim(
|
|
505
|
+
` (deletes leftover ${legacyAgentkitCursorSkillsDir(plan.skillsHome)})\n`
|
|
506
|
+
)
|
|
507
|
+
);
|
|
508
|
+
}
|
|
337
509
|
|
|
338
510
|
const confirm =
|
|
339
511
|
options.confirm ??
|
|
@@ -365,23 +537,6 @@ export async function offerInstallCursorSkills(
|
|
|
365
537
|
return { installed: result.installed, skipped: false };
|
|
366
538
|
}
|
|
367
539
|
|
|
368
|
-
function parseSkillName(skillMd: string): string | undefined {
|
|
369
|
-
const match = /^---\r?\n([\s\S]*?)\r?\n---/.exec(skillMd);
|
|
370
|
-
if (match === null) {
|
|
371
|
-
return undefined;
|
|
372
|
-
}
|
|
373
|
-
const nameLine = /^name:\s*(.+)\s*$/m.exec(match[1] ?? "");
|
|
374
|
-
if (nameLine === null) {
|
|
375
|
-
return undefined;
|
|
376
|
-
}
|
|
377
|
-
const raw = nameLine[1]?.trim();
|
|
378
|
-
if (raw === undefined || raw === "") {
|
|
379
|
-
return undefined;
|
|
380
|
-
}
|
|
381
|
-
// Strip optional quotes around the YAML scalar.
|
|
382
|
-
return raw.replace(/^["']|["']$/g, "");
|
|
383
|
-
}
|
|
384
|
-
|
|
385
540
|
export interface PromptYesNoOptions {
|
|
386
541
|
defaultYes: boolean;
|
|
387
542
|
out: (text: string) => void;
|
|
@@ -14,12 +14,12 @@ import {
|
|
|
14
14
|
type CloudAgentOptions,
|
|
15
15
|
Cursor,
|
|
16
16
|
createAgentPlatform,
|
|
17
|
-
JsonlLocalAgentStore,
|
|
18
17
|
type LocalAgentStore,
|
|
19
18
|
type ModelSelection,
|
|
20
19
|
type RunResult,
|
|
21
20
|
type SDKAgent,
|
|
22
21
|
} from "@cursor/sdk";
|
|
22
|
+
import { SqliteLocalAgentStore } from "@cursor/sdk/sqlite";
|
|
23
23
|
import {
|
|
24
24
|
DEFAULT_MODEL,
|
|
25
25
|
type ModelSetting,
|
|
@@ -558,8 +558,11 @@ export class CursorSdkRunner implements AgentRunner {
|
|
|
558
558
|
private getStore(stateDir: string): Promise<LocalAgentStore> {
|
|
559
559
|
let storePromise = this.stores.get(stateDir);
|
|
560
560
|
if (storePromise === undefined) {
|
|
561
|
-
storePromise = mkdir(stateDir, { recursive: true }).then(
|
|
562
|
-
(
|
|
561
|
+
storePromise = mkdir(stateDir, { recursive: true }).then(() =>
|
|
562
|
+
SqliteLocalAgentStore.open({
|
|
563
|
+
stateRoot: stateDir,
|
|
564
|
+
workspaceRef: stateDir,
|
|
565
|
+
})
|
|
563
566
|
);
|
|
564
567
|
this.stores.set(stateDir, storePromise);
|
|
565
568
|
}
|