prizmkit 1.1.162 → 1.1.164

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.
Files changed (58) hide show
  1. package/bin/create-prizmkit.js +4 -4
  2. package/bundled/VERSION.json +3 -3
  3. package/bundled/adapters/cursor/assets/prizmkit-hook.cjs +65 -0
  4. package/bundled/adapters/cursor/hooks-adapter.js +139 -0
  5. package/bundled/adapters/cursor/paths.js +11 -0
  6. package/bundled/adapters/cursor/rules-adapter.js +49 -0
  7. package/bundled/adapters/cursor/skill-adapter.js +27 -0
  8. package/bundled/dev-pipeline/README.md +18 -5
  9. package/bundled/dev-pipeline/prizmkit_runtime/checkpoint_state.py +3 -25
  10. package/bundled/dev-pipeline/prizmkit_runtime/config.py +71 -14
  11. package/bundled/dev-pipeline/prizmkit_runtime/gitops.py +28 -4
  12. package/bundled/dev-pipeline/prizmkit_runtime/heartbeat.py +5 -2
  13. package/bundled/dev-pipeline/prizmkit_runtime/platform_detection.py +21 -3
  14. package/bundled/dev-pipeline/prizmkit_runtime/runners.py +19 -5
  15. package/bundled/dev-pipeline/prizmkit_runtime/sessions.py +123 -28
  16. package/bundled/dev-pipeline/prizmkit_runtime/status.py +2 -0
  17. package/bundled/dev-pipeline/prizmkit_runtime/test_result.py +1 -42
  18. package/bundled/dev-pipeline/scripts/init-bugfix-pipeline.py +43 -6
  19. package/bundled/dev-pipeline/scripts/init-pipeline.py +46 -8
  20. package/bundled/dev-pipeline/scripts/init-refactor-pipeline.py +41 -6
  21. package/bundled/dev-pipeline/scripts/parse-stream-progress.py +143 -27
  22. package/bundled/dev-pipeline/scripts/update-feature-status.py +2 -2
  23. package/bundled/dev-pipeline/scripts/utils.py +3 -12
  24. package/bundled/dev-pipeline/templates/bug-fix-list-schema.json +4 -2
  25. package/bundled/dev-pipeline/templates/feature-list-schema.json +4 -2
  26. package/bundled/dev-pipeline/templates/refactor-list-schema.json +4 -2
  27. package/bundled/dev-pipeline/tests/live_ai_cli_log_smoke.py +2 -1
  28. package/bundled/dev-pipeline/tests/test_checkpoint_state.py +5 -23
  29. package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +2 -2
  30. package/bundled/dev-pipeline/tests/test_python_runner_parity.py +231 -0
  31. package/bundled/dev-pipeline/tests/test_unified_cli.py +406 -30
  32. package/bundled/dev-pipeline/tests/test_utils.py +23 -0
  33. package/bundled/rules/USAGE.md +3 -0
  34. package/bundled/skills/_metadata.json +1 -1
  35. package/bundled/skills/bug-planner/SKILL.md +0 -1
  36. package/bundled/skills/bug-planner/references/verification.md +0 -2
  37. package/bundled/skills/bug-planner/scripts/validate-bug-list.py +37 -7
  38. package/bundled/skills/feature-planner/SKILL.md +5 -8
  39. package/bundled/skills/feature-planner/scripts/validate-and-generate.py +43 -19
  40. package/bundled/skills/prizmkit-init/SKILL.md +1 -1
  41. package/bundled/skills/prizmkit-init/references/config-schema.md +2 -2
  42. package/bundled/skills/prizmkit-plan/references/review-plan-spec-loop.md +2 -3
  43. package/bundled/skills/prizmkit-prizm-docs/assets/prizm-docs-format.md +1 -1
  44. package/bundled/skills/prizmkit-prizm-docs/references/op-init.md +1 -1
  45. package/bundled/skills/refactor-planner/SKILL.md +1 -3
  46. package/bundled/skills/refactor-planner/scripts/validate-and-generate-refactor.py +38 -9
  47. package/package.json +4 -2
  48. package/src/ai-cli-launch.js +9 -2
  49. package/src/clean.js +42 -6
  50. package/src/config.js +51 -10
  51. package/src/detect-platform.js +30 -8
  52. package/src/external-skills.js +33 -99
  53. package/src/index.js +5 -0
  54. package/src/manifest.js +30 -4
  55. package/src/platforms.js +11 -4
  56. package/src/prompts.js +12 -4
  57. package/src/scaffold.js +75 -4
  58. package/src/upgrade.js +15 -14
package/src/config.js CHANGED
@@ -14,13 +14,14 @@ import fs from 'fs-extra';
14
14
  import path from 'path';
15
15
  import { readFileSync } from 'fs';
16
16
  import { dirname, join } from 'path';
17
- import { fileURLToPath } from 'url';
17
+ import { fileURLToPath, pathToFileURL } from 'url';
18
18
  import { confirm } from '@inquirer/prompts';
19
19
 
20
20
  import { readManifest, writeManifest, buildManifest, diffManifest } from './manifest.js';
21
21
  import {
22
22
  loadMetadata,
23
23
  loadRulesMetadata,
24
+ getAdaptersDir,
24
25
  } from './metadata.js';
25
26
  import {
26
27
  installSkills,
@@ -83,6 +84,35 @@ async function removeGeneratedCodexConfig(projectRoot, dryRun) {
83
84
  }
84
85
  }
85
86
 
87
+ async function removeCursorManagedFiles(projectRoot, dryRun) {
88
+ const adapterPath = path.join(getAdaptersDir(), 'cursor', 'hooks-adapter.js');
89
+ const { removeHooks } = await import(pathToFileURL(adapterPath).href);
90
+ for (const change of await removeHooks(projectRoot, dryRun)) {
91
+ const verb = change.action === 'updated' ? 'update' : 'remove';
92
+ console.log(dryRun
93
+ ? chalk.gray(` [dry-run] ${verb} ${change.path}`)
94
+ : change.action === 'updated'
95
+ ? chalk.green(` ✓ updated ${change.path} (removed PrizmKit hooks)`)
96
+ : chalk.red(` ✗ removed ${change.path}`));
97
+ }
98
+
99
+ const guidancePath = path.join(projectRoot, '.cursor', 'rules', 'prizmkit-framework.mdc');
100
+ if (await fs.pathExists(guidancePath)) {
101
+ if (dryRun) console.log(chalk.gray(' [dry-run] remove .cursor/rules/prizmkit-framework.mdc'));
102
+ else {
103
+ await fs.remove(guidancePath);
104
+ console.log(chalk.red(' ✗ removed .cursor/rules/prizmkit-framework.mdc'));
105
+ }
106
+ }
107
+
108
+ if (!dryRun) {
109
+ for (const relativeDir of ['.cursor/hooks', '.cursor/rules', '.cursor']) {
110
+ const dir = path.join(projectRoot, relativeDir);
111
+ if (await fs.pathExists(dir) && (await fs.readdir(dir)).length === 0) await fs.remove(dir);
112
+ }
113
+ }
114
+ }
115
+
86
116
  /**
87
117
  * Detect which platforms are actually installed on filesystem.
88
118
  */
@@ -100,9 +130,11 @@ async function detectInstalledPlatforms(projectRoot) {
100
130
  const hasCodeBuddy = await hasPlatformFiles(path.join(projectRoot, '.codebuddy', 'skills'));
101
131
  const hasCodex = await hasPlatformFiles(path.join(projectRoot, '.agents', 'skills'));
102
132
  const hasPi = await hasPlatformFiles(path.join(projectRoot, '.pi', 'skills'));
103
- const detected = [hasClaude && 'claude', hasCodeBuddy && 'codebuddy', hasCodex && 'codex', hasPi && 'pi'].filter(Boolean);
133
+ const hasCursor = await hasPlatformFiles(path.join(projectRoot, '.cursor', 'skills'));
134
+ const detected = [hasClaude && 'claude', hasCodeBuddy && 'codebuddy', hasCodex && 'codex', hasPi && 'pi', hasCursor && 'cursor'].filter(Boolean);
104
135
 
105
136
  if (detected.length > 1) return detected.length === 2 && hasClaude && hasCodeBuddy ? 'both' : 'all';
137
+ if (hasCursor) return 'cursor';
106
138
  if (hasPi) return 'pi';
107
139
  if (hasCodex) return 'codex';
108
140
  if (hasCodeBuddy) return 'codebuddy';
@@ -221,14 +253,14 @@ async function migrateProjectMemoryOnPlatformDrop(droppedPlatform, newPlatforms,
221
253
  * Selective removal — only removes known PrizmKit files, leaves user-created files intact.
222
254
  */
223
255
  async function removePlatformFiles(platform, projectRoot, manifest, dryRun) {
256
+ // Validate and remove merge-sensitive Cursor hooks before any other platform mutation.
257
+ if (platform === 'cursor') await removeCursorManagedFiles(projectRoot, dryRun);
258
+
224
259
  const skillNames = manifest?.files?.skills || [];
225
260
  const ruleFileNames = manifest?.files?.rules || [];
226
261
  const agentFileNames = [
227
- ...new Set([
228
- ...(manifest?.files?.agents || []),
229
- LEGACY_DEV_AGENT_FILE,
230
- LEGACY_REVIEWER_AGENT_FILE,
231
- ]),
262
+ LEGACY_DEV_AGENT_FILE,
263
+ LEGACY_REVIEWER_AGENT_FILE,
232
264
  ];
233
265
 
234
266
  if (skillNames.length) {
@@ -247,7 +279,9 @@ async function removePlatformFiles(platform, projectRoot, manifest, dryRun) {
247
279
  }
248
280
 
249
281
  // Settings
250
- if (platform === 'codex') {
282
+ if (platform === 'cursor') {
283
+ // Merge-sensitive Cursor hooks and managed framework guidance were handled first.
284
+ } else if (platform === 'codex') {
251
285
  await removeGeneratedCodexConfig(projectRoot, dryRun);
252
286
  const legacySettingsFile = path.join(projectRoot, '.codex', 'prizmkit-settings.json');
253
287
  if (await fs.pathExists(legacySettingsFile)) {
@@ -380,6 +414,13 @@ async function removePlatformFiles(platform, projectRoot, manifest, dryRun) {
380
414
  await fs.remove(dir);
381
415
  }
382
416
  }
417
+ } else if (platform === 'cursor') {
418
+ for (const relativeDir of ['.cursor/skills', '.cursor/rules', '.cursor/hooks', '.cursor']) {
419
+ const dir = path.join(projectRoot, relativeDir);
420
+ if (await fs.pathExists(dir) && !dryRun && (await fs.readdir(dir)).length === 0) {
421
+ await fs.remove(dir);
422
+ }
423
+ }
383
424
  }
384
425
  }
385
426
 
@@ -441,7 +482,7 @@ export async function runConfig(directory, options = {}) {
441
482
  };
442
483
 
443
484
  if (options.platform !== undefined && !isKnownPlatform(options.platform)) {
444
- throw new Error(`Unknown platform "${options.platform}". Expected codebuddy, claude, codex, or all.`);
485
+ throw new Error(`Unknown platform "${options.platform}". Expected codebuddy, claude, codex, pi, cursor, or all.`);
445
486
  }
446
487
 
447
488
  // Display current config
@@ -519,7 +560,7 @@ export async function runConfig(directory, options = {}) {
519
560
  }
520
561
 
521
562
  if (!isKnownPlatform(newConfig.platform)) {
522
- throw new Error(`Unknown platform "${newConfig.platform}". Expected codebuddy, claude, codex, or all.`);
563
+ throw new Error(`Unknown platform "${newConfig.platform}". Expected codebuddy, claude, codex, pi, cursor, or all.`);
523
564
  }
524
565
 
525
566
  // ── Phase 3: COMPUTE DIFF ────────────────────────────────────────────────
@@ -9,7 +9,7 @@ import os from 'os';
9
9
  /**
10
10
  * 允许检测的命令白名单(仅用于 which 检测)
11
11
  */
12
- const ALLOWED_COMMANDS = ['cbc', 'claude', 'codex', 'pi'];
12
+ const ALLOWED_COMMANDS = ['cbc', 'claude', 'codex', 'pi', 'agent'];
13
13
 
14
14
  /**
15
15
  * 检查命令是否存在于 PATH 中
@@ -27,23 +27,44 @@ function commandExists(cmd) {
27
27
  }
28
28
  }
29
29
 
30
+ function cursorAgentExists() {
31
+ if (!commandExists('agent')) return false;
32
+ try {
33
+ const options = {
34
+ encoding: 'utf8',
35
+ stdio: ['ignore', 'pipe', 'pipe'],
36
+ timeout: 5000,
37
+ };
38
+ const version = String(execFileSync('agent', ['--version'], options) || '');
39
+ const help = String(execFileSync('agent', ['--help'], options) || '');
40
+ const identity = `${version}\n${help}`.toLowerCase();
41
+ const requiredFlags = ['--print', '--force', '--trust', '--output-format'];
42
+ return identity.includes('cursor') && requiredFlags.every(flag => help.includes(flag));
43
+ } catch {
44
+ return false;
45
+ }
46
+ }
47
+
30
48
  /**
31
49
  * 检测已安装的 AI CLI 工具,并返回推荐的默认平台和 CLI 命令。
32
50
  *
33
- * 注意:platform 控制目录结构(.codebuddy/ 或 .claude/),
34
- * suggestedCli 是实际运行的可执行命令,二者相互独立。
51
+ * 注意:platform 控制目录结构,suggestedCli 是实际运行的可执行命令。
52
+ * Cursor 的 `agent` 名称通用,只有安全的 version/help 身份探测通过才自动选择。
35
53
  *
36
- * @returns {{ cbc: boolean, claude: boolean, codex: boolean, pi: boolean, suggested: string, suggestedCli: string }}
54
+ * @returns {{ cbc: boolean, claude: boolean, codex: boolean, pi: boolean, cursor: boolean, suggested: string, suggestedCli: string }}
37
55
  */
38
56
  export function detectPlatform() {
39
57
  const cbc = commandExists('cbc');
40
58
  const claude = commandExists('claude');
41
59
  const codex = commandExists('codex');
42
60
  const pi = commandExists('pi');
61
+ const cursor = cursorAgentExists();
43
62
 
44
- // Preserve historical recommendations when Pi is absent.
63
+ // Preserve historical recommendations when Cursor and Pi are absent.
45
64
  let suggested = 'codebuddy';
46
- if (pi) {
65
+ if (cursor) {
66
+ suggested = (cbc || claude || codex || pi) ? 'all' : 'cursor';
67
+ } else if (pi) {
47
68
  suggested = (cbc || claude || codex) ? 'all' : 'pi';
48
69
  } else if (cbc && claude && codex) {
49
70
  suggested = 'all';
@@ -55,12 +76,13 @@ export function detectPlatform() {
55
76
  suggested = 'codebuddy';
56
77
  }
57
78
 
58
- // Preserve historical precedence and use Pi when it is the first available CLI.
79
+ // Preserve historical precedence and use Cursor only when it is the first available CLI.
59
80
  let suggestedCli = '';
60
81
  if (cbc) suggestedCli = 'cbc';
61
82
  else if (claude) suggestedCli = 'claude';
62
83
  else if (codex) suggestedCli = 'codex';
63
84
  else if (pi) suggestedCli = 'pi';
85
+ else if (cursor) suggestedCli = 'agent';
64
86
 
65
- return { cbc, claude, codex, pi, suggested, suggestedCli };
87
+ return { cbc, claude, codex, pi, cursor, suggested, suggestedCli };
66
88
  }
@@ -13,6 +13,7 @@
13
13
 
14
14
  import { execSync } from 'node:child_process';
15
15
  import path from 'path';
16
+ import os from 'node:os';
16
17
  import fs from 'fs-extra';
17
18
  import { resolvePayloadPlatforms } from './platforms.js';
18
19
 
@@ -21,7 +22,7 @@ import { resolvePayloadPlatforms } from './platforms.js';
21
22
  * skill.repo {string} - GitHub short ref (e.g. "pbakaus/impeccable") or full URL
22
23
  * skill.name {string} - Skill name (used for display / single-skill mode)
23
24
  * skill.installAll {boolean} - If true, install all skills from the repo
24
- * @param {string} platform - 'claude' | 'codebuddy' | 'codex' | 'all' ('both' supported only for legacy manifests)
25
+ * @param {string} platform - 'claude' | 'codebuddy' | 'codex' | 'pi' | 'cursor' | 'all' ('both' supported only for legacy manifests)
25
26
  * @param {string} projectRoot - Target project root
26
27
  * @param {string} [aiCli] - optional AI CLI command that may require an additional payload platform
27
28
  */
@@ -47,56 +48,38 @@ export async function installExternalSkill(skill, platform, projectRoot, dryRun,
47
48
  return;
48
49
  }
49
50
 
50
- // stdio: 'pipe' → npx skills runs non-interactively
51
- execSync(cmd, { cwd: projectRoot, stdio: 'pipe', timeout: 120000 });
51
+ // Fetch into an isolated staging root. Running `npx skills` in the target
52
+ // project would let its universal `.agents/skills` output overwrite or delete
53
+ // user-owned Codex resources when Cursor is the selected destination.
54
+ const stagingRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'prizmkit-external-skill-'));
55
+ try {
56
+ execSync(cmd, { cwd: stagingRoot, stdio: 'pipe', timeout: 120000 });
57
+ const agentsSkillsDir = path.join(stagingRoot, '.agents', 'skills');
52
58
 
53
- const agentsSkillsDir = path.join(projectRoot, '.agents', 'skills');
54
-
55
- if (skill.installAll) {
56
- // Repo-level install: copy ALL skill dirs from .agents/skills/ to platform dirs
57
59
  if (!await fs.pathExists(agentsSkillsDir)) {
58
- throw new Error(`npx skills did not produce .agents/skills/ for repo ${skill.repo}`);
60
+ throw new Error(`npx skills did not produce .agents/skills/ for ${skill.repo}`);
59
61
  }
60
- const skillDirs = (await fs.readdir(agentsSkillsDir, { withFileTypes: true }))
61
- .filter(d => d.isDirectory())
62
- .map(d => d.name);
63
-
64
- for (const targetDir of getTargetDirs(platform, projectRoot, aiCli)) {
65
- for (const skillName of skillDirs) {
66
- const srcDir = path.join(agentsSkillsDir, skillName);
67
- const destDir = path.join(targetDir, skillName);
68
- if (path.resolve(srcDir) === path.resolve(destDir)) {
69
- continue;
70
- }
71
- await fs.remove(destDir).catch(() => {});
72
- await fs.copy(srcDir, destDir);
62
+ const skillNames = skill.installAll
63
+ ? (await fs.readdir(agentsSkillsDir, { withFileTypes: true }))
64
+ .filter(entry => entry.isDirectory())
65
+ .map(entry => entry.name)
66
+ : [skill.name];
67
+
68
+ for (const skillName of skillNames) {
69
+ const sourceDir = path.join(agentsSkillsDir, skillName);
70
+ if (!await fs.pathExists(path.join(sourceDir, 'SKILL.md'))) {
71
+ throw new Error(`npx skills did not produce .agents/skills/${skillName}/SKILL.md`);
73
72
  }
74
- }
75
- } else {
76
- // Single-skill install
77
- const canonicalSkillMd = path.join(agentsSkillsDir, skill.name, 'SKILL.md');
78
- if (!await fs.pathExists(canonicalSkillMd)) {
79
- throw new Error(`npx skills did not produce .agents/skills/${skill.name}/SKILL.md`);
80
- }
81
-
82
- const content = await fs.readFile(canonicalSkillMd, 'utf8');
83
-
84
- for (const targetDir of getTargetDirs(platform, projectRoot, aiCli)) {
85
- const skillDir = path.join(targetDir, skill.name);
86
- if (path.resolve(skillDir) === path.resolve(path.dirname(canonicalSkillMd))) {
87
- continue;
73
+ for (const targetDir of getTargetDirs(platform, projectRoot, aiCli)) {
74
+ const destination = path.join(targetDir, skillName);
75
+ await fs.remove(destination).catch(() => {});
76
+ await fs.copy(sourceDir, destination);
88
77
  }
89
- await fs.remove(skillDir).catch(() => {});
90
- await fs.ensureDir(skillDir);
91
- await fs.writeFile(path.join(skillDir, 'SKILL.md'), content);
92
78
  }
79
+ } finally {
80
+ await fs.remove(stagingRoot).catch(() => {});
93
81
  }
94
82
 
95
- // Clean up npx skills artifacts after copying. Preserve .agents/skills when
96
- // Codex is selected because it is the official repository skill location.
97
- if (!resolvePayloadPlatforms(platform, aiCli).includes('codex')) {
98
- await fs.remove(path.join(projectRoot, '.agents')).catch(() => {});
99
- }
100
83
  await fs.remove(path.join(projectRoot, 'skills-lock.json')).catch(() => {});
101
84
  }
102
85
 
@@ -104,65 +87,14 @@ export async function installExternalSkill(skill, platform, projectRoot, dryRun,
104
87
  * Remove all artifacts created by `npx skills` that are not needed by PrizmKit.
105
88
  * Call this once after all external skills have been installed.
106
89
  *
107
- * @param {string} platform - 'claude' | 'codebuddy' | 'codex' | 'all' ('both' supported only for legacy manifests)
90
+ * @param {string} platform - 'claude' | 'codebuddy' | 'codex' | 'pi' | 'cursor' | 'all' ('both' supported only for legacy manifests)
108
91
  * @param {string} [aiCli] - optional AI CLI command that may require an additional payload platform
109
92
  */
110
93
  export async function cleanExternalSkillArtifacts(projectRoot, platform, aiCli = '') {
111
- const keepDirs = new Set(
112
- getTargetDirs(platform, projectRoot, aiCli).map(d => path.resolve(d))
113
- );
114
-
115
- const selectedPlatforms = resolvePayloadPlatforms(platform, aiCli);
116
- const dirsToCheck = [
117
- selectedPlatforms.includes('codex') ? null : '.agents',
118
- '.agent',
119
- '.trae',
120
- 'skills',
121
- '.claude/skills',
122
- '.codebuddy/skills',
123
- '.codex/skills',
124
- ].filter(Boolean);
125
-
126
- for (const dir of dirsToCheck) {
127
- const abs = path.join(projectRoot, dir);
128
- if (keepDirs.has(path.resolve(abs))) continue;
129
- await fs.remove(abs).catch(() => {});
130
- }
131
-
132
- // Remove any dangling symlinks inside kept platform skill dirs
133
- // (npx skills creates symlinks like .claude/skills/<name> -> ../../.agents/skills/<name>)
134
- for (const keepDir of keepDirs) {
135
- if (!await fs.pathExists(keepDir)) continue;
136
- let entries;
137
- try { entries = await fs.readdir(keepDir); } catch { continue; }
138
- for (const entry of entries) {
139
- const entryPath = path.join(keepDir, entry);
140
- try {
141
- const stat = await fs.lstat(entryPath);
142
- if (stat.isSymbolicLink()) {
143
- await fs.remove(entryPath);
144
- }
145
- } catch { /* ignore */ }
146
- }
147
- }
148
-
149
- // Remove empty parent dirs left behind (e.g. .codebuddy/ after removing .codebuddy/skills)
150
- const parentDirs = ['.claude', '.codebuddy', '.codex', '.trae', '.agent'];
151
- for (const dir of parentDirs) {
152
- const abs = path.join(projectRoot, dir);
153
- if (!await fs.pathExists(abs)) continue;
154
- // Only remove if this platform dir is entirely unneeded
155
- const isKept = getTargetDirs(platform, projectRoot, aiCli)
156
- .some(d => path.resolve(d).startsWith(path.resolve(abs) + path.sep));
157
- if (isKept) continue;
158
- try {
159
- const entries = await fs.readdir(abs);
160
- if (entries.length === 0) {
161
- await fs.remove(abs);
162
- }
163
- } catch { /* ignore */ }
164
- }
165
-
94
+ // External Skills are fetched in an isolated staging root, so target cleanup
95
+ // must not scan or delete platform directories or user-owned Skill symlinks.
96
+ // Resolve targets here to retain validation of the caller's platform inputs.
97
+ getTargetDirs(platform, projectRoot, aiCli);
166
98
  await fs.remove(path.join(projectRoot, 'skills-lock.json')).catch(() => {});
167
99
  }
168
100
 
@@ -170,6 +102,8 @@ function getTargetDirs(platform, projectRoot, aiCli = '') {
170
102
  return resolvePayloadPlatforms(platform, aiCli).map(p => {
171
103
  if (p === 'codebuddy') return path.join(projectRoot, '.codebuddy', 'skills');
172
104
  if (p === 'codex') return path.join(projectRoot, '.agents', 'skills');
105
+ if (p === 'pi') return path.join(projectRoot, '.pi', 'skills');
106
+ if (p === 'cursor') return path.join(projectRoot, '.cursor', 'skills');
173
107
  return path.join(projectRoot, '.claude', 'skills');
174
108
  });
175
109
  }
package/src/index.js CHANGED
@@ -53,6 +53,7 @@ export async function runScaffold(directory, options) {
53
53
  detected.claude ? chalk.green('claude ✓') : chalk.gray('claude ✗'),
54
54
  detected.codex ? chalk.green('codex ✓') : chalk.gray('codex ✗'),
55
55
  detected.pi ? chalk.green('pi ✓') : chalk.gray('pi ✗'),
56
+ detected.cursor ? chalk.green('agent(Cursor) ✓') : chalk.gray('agent(Cursor) ✗'),
56
57
  ].join(' ');
57
58
  console.log(` 检测到的 CLI 工具: ${cliStatus}`);
58
59
  console.log(` 目标目录: ${projectRoot}`);
@@ -113,6 +114,10 @@ export async function runScaffold(directory, options) {
113
114
  name: `Pi (.pi/skills + .pi/APPEND_SYSTEM.md)${detected.pi ? chalk.green(' ← 已检测到 pi') : ''}`,
114
115
  value: 'pi',
115
116
  },
117
+ {
118
+ name: `Cursor (.cursor/skills + .cursor/rules + .cursor/hooks.json)${detected.cursor ? chalk.green(' ← 已验证 agent') : ''}`,
119
+ value: 'cursor',
120
+ },
116
121
  {
117
122
  name: '同时安装全部平台',
118
123
  value: 'all',
package/src/manifest.js CHANGED
@@ -14,6 +14,33 @@ import { normalizeRuntime } from './runtimes.js';
14
14
 
15
15
  const MANIFEST_FILE = 'manifest.json';
16
16
  const MANIFEST_DIR = '.prizmkit';
17
+ const MANIFEST_FIELDS = new Set([
18
+ 'version', 'installedAt', 'updatedAt', 'platform', 'runtime', 'suite',
19
+ 'options', 'files',
20
+ ]);
21
+ const MANIFEST_OPTION_FIELDS = new Set(['pipeline', 'rules', 'aiCli']);
22
+ const MANIFEST_FILE_FIELDS = new Set([
23
+ 'skills', 'rules', 'pipeline', 'extras', 'payloadPlatforms', 'memory',
24
+ ]);
25
+ const MANIFEST_MEMORY_FIELDS = new Set(['main', 'private']);
26
+
27
+ function assertKnownFields(value, allowed, label) {
28
+ if (value === undefined) return;
29
+ if (value === null || Array.isArray(value) || typeof value !== 'object') {
30
+ throw new TypeError(`${label} must be a JSON object`);
31
+ }
32
+ const unknown = Object.keys(value).filter(key => !allowed.has(key)).sort();
33
+ if (unknown.length) {
34
+ throw new TypeError(`${label} has unknown fields: ${unknown.join(', ')}`);
35
+ }
36
+ }
37
+
38
+ function validateManifestFields(manifest) {
39
+ assertKnownFields(manifest, MANIFEST_FIELDS, 'manifest');
40
+ assertKnownFields(manifest.options, MANIFEST_OPTION_FIELDS, 'manifest.options');
41
+ assertKnownFields(manifest.files, MANIFEST_FILE_FIELDS, 'manifest.files');
42
+ assertKnownFields(manifest.files?.memory, MANIFEST_MEMORY_FIELDS, 'manifest.files.memory');
43
+ }
17
44
 
18
45
  /**
19
46
  * Read the manifest from a project directory.
@@ -31,6 +58,7 @@ export async function readManifest(projectRoot) {
31
58
  if (manifest === null || Array.isArray(manifest) || typeof manifest !== 'object') {
32
59
  throw new TypeError('manifest root must be a JSON object');
33
60
  }
61
+ validateManifestFields(manifest);
34
62
  return manifest;
35
63
  } catch (error) {
36
64
  throw new Error(`Failed to read PrizmKit manifest at ${manifestPath}: ${error.message}`, { cause: error });
@@ -53,7 +81,7 @@ export async function writeManifest(projectRoot, data) {
53
81
  * Build a manifest object from installation config.
54
82
  * @param {Object} params
55
83
  * @param {string} params.version - PrizmKit version
56
- * @param {string} params.platform - 'codebuddy' | 'claude' | 'codex' | 'all' ('both' supported only for legacy manifests)
84
+ * @param {string} params.platform - 'codebuddy' | 'claude' | 'codex' | 'pi' | 'cursor' | 'all' ('both' supported only for legacy manifests)
57
85
  * @param {string} [params.runtime] - canonical Python runtime id or compatibility alias
58
86
  * @param {string} params.suite - skill suite name
59
87
  * @param {string[]} params.skills - resolved skill name list
@@ -103,7 +131,6 @@ export function buildManifest({
103
131
  main: [...new Set(installedPayloadPlatforms.map(projectMemoryFile).filter(Boolean))],
104
132
  private: [...new Set(installedPayloadPlatforms.map(privateProjectMemoryFile).filter(Boolean))],
105
133
  },
106
- other: [...new Set(installedPayloadPlatforms.map(privateProjectMemoryFile).filter(Boolean))],
107
134
  },
108
135
  };
109
136
  }
@@ -112,7 +139,7 @@ export function buildManifest({
112
139
  * Diff two manifests and return added/removed items.
113
140
  * @param {Object} oldManifest - previous manifest
114
141
  * @param {Object} newManifest - new manifest to compare against
115
- * @returns {Object} { skills: {added, removed}, rules: {added, removed}, pipeline: {added, removed}, extras: {added, removed}, legacyAgents: {added, removed} }
142
+ * @returns {Object} changed managed skills, rules, pipeline files, and extras
116
143
  */
117
144
  export function diffManifest(oldManifest, newManifest) {
118
145
  function diffArrays(oldArr, newArr) {
@@ -132,6 +159,5 @@ export function diffManifest(oldManifest, newManifest) {
132
159
  Array.isArray(newManifest?.files?.pipeline) ? newManifest.files.pipeline : [],
133
160
  ),
134
161
  extras: diffArrays(oldManifest?.files?.extras, newManifest?.files?.extras),
135
- legacyAgents: diffArrays(oldManifest?.files?.agents, []),
136
162
  };
137
163
  }
package/src/platforms.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { isBuiltInAiCli } from './ai-cli-launch.js';
2
2
 
3
- export const PLATFORM_IDS = ['codebuddy', 'claude', 'codex', 'pi'];
3
+ export const PLATFORM_IDS = ['codebuddy', 'claude', 'codex', 'pi', 'cursor'];
4
4
  export const PLATFORM_GROUPS = {
5
5
  all: PLATFORM_IDS,
6
6
  };
@@ -19,11 +19,16 @@ export function platformFromAiCli(aiCli) {
19
19
  } catch {
20
20
  return null;
21
21
  }
22
- const token = aiCli.trim().split(/\s+/)[0]?.replace(/^['"]|['"]$/g, '');
23
- const name = token.split(/[\\/]/).pop()?.toLowerCase() || '';
22
+ const raw = aiCli.trim();
23
+ const unquoted = raw.replace(/^(['"])(.*)\1$/, '$2');
24
+ const token = /^[A-Za-z]:\\/.test(unquoted)
25
+ ? unquoted
26
+ : raw.split(/\s+/)[0]?.replace(/^['"]|['"]$/g, '');
27
+ const name = (token.split(/[\\/]/).pop()?.toLowerCase() || '').replace(/\.(exe|cmd|bat)$/i, '');
24
28
  if (name === 'claude') return 'claude';
25
29
  if (name === 'codex') return 'codex';
26
30
  if (name === 'pi') return 'pi';
31
+ if (name === 'agent') return 'cursor';
27
32
  if (name === 'cbc' || name === 'codebuddy') return 'codebuddy';
28
33
  return null;
29
34
  }
@@ -49,11 +54,12 @@ export function isKnownPlatform(platform) {
49
54
 
50
55
  export function platformLabel(platform) {
51
56
  if (platform === 'both') return 'legacy codebuddy/claude group';
52
- if (platform === 'all') return 'All platforms (CodeBuddy, Claude Code, Codex, Pi)';
57
+ if (platform === 'all') return 'All platforms (CodeBuddy, Claude Code, Codex, Pi, Cursor)';
53
58
  if (platform === 'codebuddy') return 'CodeBuddy';
54
59
  if (platform === 'claude') return 'Claude Code';
55
60
  if (platform === 'codex') return 'Codex';
56
61
  if (platform === 'pi') return 'Pi';
62
+ if (platform === 'cursor') return 'Cursor';
57
63
  return platform;
58
64
  }
59
65
 
@@ -84,5 +90,6 @@ export function defaultCliForPlatform(platform) {
84
90
  if (platform === 'codebuddy') return 'cbc';
85
91
  if (platform === 'codex') return 'codex';
86
92
  if (platform === 'pi') return 'pi';
93
+ if (platform === 'cursor') return 'agent';
87
94
  return '';
88
95
  }
package/src/prompts.js CHANGED
@@ -37,13 +37,13 @@ export function __resetAiCliPromptsForTests() {
37
37
  }
38
38
 
39
39
  /**
40
- * Select target platform (codebuddy, claude, codex, pi, or all).
40
+ * Select target platform (codebuddy, claude, codex, pi, cursor, or all).
41
41
  * @param {string} currentPlatform - current platform value
42
42
  * @param {Object} detected - detected environment info (e.g., { cbc: true, claude: false })
43
43
  * @returns {Promise<string>}
44
44
  */
45
45
  export async function selectPlatform(currentPlatform, detected = {}) {
46
- const selectablePlatforms = ['codebuddy', 'claude', 'codex', 'pi', 'all'];
46
+ const selectablePlatforms = ['codebuddy', 'claude', 'codex', 'pi', 'cursor', 'all'];
47
47
  const detectedDefault = selectablePlatforms.includes(detected.suggested)
48
48
  ? detected.suggested
49
49
  : 'claude';
@@ -72,6 +72,10 @@ export async function selectPlatform(currentPlatform, detected = {}) {
72
72
  name: `Pi (.pi/skills + .pi/APPEND_SYSTEM.md)${detected.pi ? chalk.green(' ← 已检测到 pi') : ''}`,
73
73
  value: 'pi',
74
74
  },
75
+ {
76
+ name: `Cursor (.cursor/skills + .cursor/rules + .cursor/hooks.json)${detected.cursor ? chalk.green(' ← 已检测到 agent') : ''}`,
77
+ value: 'cursor',
78
+ },
75
79
  {
76
80
  name: `同时安装全部平台 (${platformLabel('all')})`,
77
81
  value: 'all',
@@ -83,7 +87,7 @@ export async function selectPlatform(currentPlatform, detected = {}) {
83
87
  }
84
88
 
85
89
  /**
86
- * Select AI CLI command (cbc, claude, codex, pi, custom, or skip).
90
+ * Select AI CLI command (cbc, claude, codex, pi, agent, custom, or skip).
87
91
  * @param {string} currentCommand - current AI CLI command
88
92
  * @param {Object} detected - detected environment info
89
93
  * @returns {Promise<string>} - known command, custom string, or ''
@@ -106,6 +110,10 @@ export async function selectAiCli(currentCommand, detected = {}) {
106
110
  name: `pi — Pi Coding Agent${detected.pi ? chalk.green(' ✓ 已安装') : chalk.gray(' (未检测到)')}`,
107
111
  value: 'pi',
108
112
  },
113
+ {
114
+ name: `agent — Cursor Agent CLI${detected.cursor ? chalk.green(' ✓ 已验证') : chalk.gray(' (未检测到或身份未验证)')}`,
115
+ value: 'agent',
116
+ },
109
117
  {
110
118
  name: '自定义 — 输入其他命令',
111
119
  value: '__custom__',
@@ -116,7 +124,7 @@ export async function selectAiCli(currentCommand, detected = {}) {
116
124
  },
117
125
  ];
118
126
 
119
- const knownCliValues = ['cbc', 'claude', 'codex', 'pi'];
127
+ const knownCliValues = ['cbc', 'claude', 'codex', 'pi', 'agent'];
120
128
  const cliDefault = knownCliValues.includes(currentCommand)
121
129
  ? currentCommand
122
130
  : (currentCommand ? '__custom__' : (detected.suggestedCli || ''));