prizmkit 1.1.162 → 1.1.165

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 (75) 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/app-planner/SKILL.md +18 -9
  36. package/bundled/skills/app-planner/references/app-design-guide.md +7 -5
  37. package/bundled/skills/app-planner/references/brainstorm-guide.md +13 -21
  38. package/bundled/skills/app-planner/references/generated-plan-review.md +6 -2
  39. package/bundled/skills/bug-planner/SKILL.md +13 -5
  40. package/bundled/skills/bug-planner/assets/bug-confirmation-template.md +11 -7
  41. package/bundled/skills/bug-planner/references/generated-plan-review.md +7 -3
  42. package/bundled/skills/bug-planner/references/verification.md +0 -2
  43. package/bundled/skills/bug-planner/scripts/validate-bug-list.py +37 -7
  44. package/bundled/skills/feature-planner/SKILL.md +17 -11
  45. package/bundled/skills/feature-planner/assets/planning-guide.md +13 -13
  46. package/bundled/skills/feature-planner/references/completeness-review.md +8 -4
  47. package/bundled/skills/feature-planner/references/generated-plan-review.md +6 -2
  48. package/bundled/skills/feature-planner/scripts/validate-and-generate.py +43 -19
  49. package/bundled/skills/prizmkit-init/SKILL.md +1 -1
  50. package/bundled/skills/prizmkit-init/references/config-schema.md +2 -2
  51. package/bundled/skills/prizmkit-plan/SKILL.md +15 -4
  52. package/bundled/skills/prizmkit-plan/assets/plan-template.md +18 -3
  53. package/bundled/skills/prizmkit-plan/assets/spec-template.md +17 -5
  54. package/bundled/skills/prizmkit-plan/references/clarify-guide.md +26 -24
  55. package/bundled/skills/prizmkit-plan/references/review-plan-spec-loop.md +7 -5
  56. package/bundled/skills/prizmkit-plan/references/verification-checklist.md +15 -6
  57. package/bundled/skills/prizmkit-prizm-docs/assets/prizm-docs-format.md +1 -1
  58. package/bundled/skills/prizmkit-prizm-docs/references/op-init.md +1 -1
  59. package/bundled/skills/refactor-planner/SKILL.md +18 -11
  60. package/bundled/skills/refactor-planner/references/generated-plan-review.md +6 -2
  61. package/bundled/skills/refactor-planner/references/planning-phases.md +14 -9
  62. package/bundled/skills/refactor-planner/references/refactor-scoping-guide.md +8 -2
  63. package/bundled/skills/refactor-planner/scripts/validate-and-generate-refactor.py +38 -9
  64. package/package.json +4 -2
  65. package/src/ai-cli-launch.js +9 -2
  66. package/src/clean.js +42 -6
  67. package/src/config.js +51 -10
  68. package/src/detect-platform.js +30 -8
  69. package/src/external-skills.js +33 -99
  70. package/src/index.js +5 -0
  71. package/src/manifest.js +30 -4
  72. package/src/platforms.js +11 -4
  73. package/src/prompts.js +12 -4
  74. package/src/scaffold.js +75 -4
  75. package/src/upgrade.js +15 -14
@@ -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 || ''));
package/src/scaffold.js CHANGED
@@ -97,7 +97,7 @@ async function removeEmptyDirectory(dirPath) {
97
97
  }
98
98
 
99
99
  export async function removeRetiredAgentTeamArtifacts(platform, projectRoot, dryRun) {
100
- if (platform === 'pi') return;
100
+ if (platform === 'pi' || platform === 'cursor') return;
101
101
  const agentDir = platform === 'claude'
102
102
  ? path.join(projectRoot, '.claude', 'agents')
103
103
  : platform === 'codex'
@@ -234,6 +234,7 @@ export async function installSkills(platform, skills, projectRoot, dryRun, runti
234
234
  let convertSkillToCommand;
235
235
  let convertSkillToCodex;
236
236
  let convertSkillToPi;
237
+ let convertSkillToCursor;
237
238
  if (platform === 'claude') {
238
239
  const commandAdapter = await loadAdapter('claude', 'command-adapter.js');
239
240
  convertSkillToCommand = commandAdapter.convertSkillToCommand;
@@ -243,6 +244,9 @@ export async function installSkills(platform, skills, projectRoot, dryRun, runti
243
244
  } else if (platform === 'pi') {
244
245
  const piSkillAdapter = await loadAdapter('pi', 'skill-adapter.js');
245
246
  convertSkillToPi = piSkillAdapter.convertSkill;
247
+ } else if (platform === 'cursor') {
248
+ const cursorSkillAdapter = await loadAdapter('cursor', 'skill-adapter.js');
249
+ convertSkillToCursor = cursorSkillAdapter.convertSkill;
246
250
  }
247
251
 
248
252
  for (const skillName of skills) {
@@ -372,6 +376,25 @@ export async function installSkills(platform, skills, projectRoot, dryRun, runti
372
376
  }
373
377
  }
374
378
  console.log(chalk.green(` ✓ .pi/skills/${skillName}/`));
379
+ } else if (platform === 'cursor') {
380
+ const content = await fs.readFile(skillMdPath, 'utf8');
381
+ const converted = convertSkillToCursor(content, skillName);
382
+ const targetDir = path.join(projectRoot, '.cursor', 'skills', skillName);
383
+
384
+ if (dryRun) {
385
+ console.log(chalk.gray(` [dry-run] .cursor/skills/${skillName}/`));
386
+ continue;
387
+ }
388
+
389
+ await fs.remove(targetDir);
390
+ await fs.ensureDir(targetDir);
391
+ await fs.writeFile(path.join(targetDir, 'SKILL.md'), converted);
392
+ for (const entry of await fs.readdir(corePath, { withFileTypes: true })) {
393
+ if (entry.isDirectory()) {
394
+ await fs.copy(path.join(corePath, entry.name), path.join(targetDir, entry.name));
395
+ }
396
+ }
397
+ console.log(chalk.green(` ✓ .cursor/skills/${skillName}/`));
375
398
  }
376
399
  }
377
400
  }
@@ -607,6 +630,20 @@ job_max_runtime_seconds = 3300
607
630
  await installRules(projectRoot, ruleFiles);
608
631
  console.log(chalk.green(' ✓ .pi/settings.json'));
609
632
  console.log(chalk.green(` ✓ .pi/rules/ (${ruleFiles.length} 条规则)`));
633
+ } else if (platform === 'cursor') {
634
+ if (dryRun) {
635
+ console.log(chalk.gray(' [dry-run] .cursor/hooks.json'));
636
+ console.log(chalk.gray(' [dry-run] .cursor/hooks/prizmkit-hook.cjs'));
637
+ console.log(chalk.gray(` [dry-run] .cursor/rules/ (${ruleFiles.length} 条规则)`));
638
+ return;
639
+ }
640
+ const { installHooks } = await loadAdapter('cursor', 'hooks-adapter.js');
641
+ const { installRules } = await loadAdapter('cursor', 'rules-adapter.js');
642
+ await installHooks(projectRoot);
643
+ await installRules(projectRoot, ruleFiles);
644
+ console.log(chalk.green(' ✓ .cursor/hooks.json'));
645
+ console.log(chalk.green(' ✓ .cursor/hooks/prizmkit-hook.cjs'));
646
+ console.log(chalk.green(` ✓ .cursor/rules/ (${ruleFiles.length} 条规则)`));
610
647
  }
611
648
  }
612
649
 
@@ -1012,6 +1049,23 @@ export async function installProjectMemory(platform, projectRoot, dryRun) {
1012
1049
  const templateName = 'project-memory-template.md';
1013
1050
  const mainName = projectMemoryFile(platform);
1014
1051
  const privateName = privateProjectMemoryFile(platform);
1052
+
1053
+ if (platform === 'cursor') {
1054
+ const templatePath = path.join(templatesDir, templateName);
1055
+ if (!await fs.pathExists(templatePath)) {
1056
+ console.log(chalk.yellow(` ⚠ 模板文件不存在: ${templateName},跳过`));
1057
+ return;
1058
+ }
1059
+ if (dryRun) {
1060
+ console.log(chalk.gray(' [dry-run] .cursor/rules/prizmkit-framework.mdc'));
1061
+ return;
1062
+ }
1063
+ const { installFrameworkGuidance } = await loadAdapter('cursor', 'rules-adapter.js');
1064
+ await installFrameworkGuidance(projectRoot, (await fs.readFile(templatePath, 'utf8')).trimEnd());
1065
+ console.log(chalk.green(' ✓ .cursor/rules/prizmkit-framework.mdc'));
1066
+ return;
1067
+ }
1068
+
1015
1069
  if (!privateName) return;
1016
1070
 
1017
1071
  const mainPath = mainName ? path.join(projectRoot, mainName) : null;
@@ -1589,10 +1643,16 @@ export const EXTRAS_REGISTRY = {
1589
1643
  // 主安装函数
1590
1644
  // ============================================================
1591
1645
 
1646
+ const SCAFFOLD_CONFIG_FIELDS = new Set([
1647
+ 'platform', 'runtime', 'skills', 'pipeline', 'rules', 'aiCli', 'aiCliLaunch',
1648
+ 'externalSkills', 'playwrightCli', 'openCli', 'openCliAutoDownload',
1649
+ 'projectRoot', 'dryRun',
1650
+ ]);
1651
+
1592
1652
  /**
1593
1653
  * 执行纯净安装
1594
1654
  * @param {Object} config
1595
- * @param {string} config.platform - 'codebuddy' | 'claude' | 'codex' | 'pi' | 'all'
1655
+ * @param {string} config.platform - 'codebuddy' | 'claude' | 'codex' | 'pi' | 'cursor' | 'all'
1596
1656
  * @param {string} [config.runtime] - 'python' (legacy aliases accepted: 'unix' | 'windows')
1597
1657
  * @param {string} config.skills - 'core' | 'minimal' | 'recommended:<type>'
1598
1658
  * @param {boolean} config.pipeline - 是否安装 dev-pipeline
@@ -1606,6 +1666,15 @@ export const EXTRAS_REGISTRY = {
1606
1666
  * @param {boolean} config.dryRun - 是否为预览模式
1607
1667
  */
1608
1668
  export async function scaffold(config) {
1669
+ if (config === null || Array.isArray(config) || typeof config !== 'object') {
1670
+ throw new TypeError('scaffold config must be an object');
1671
+ }
1672
+ const unknownFields = Object.keys(config)
1673
+ .filter(key => !SCAFFOLD_CONFIG_FIELDS.has(key))
1674
+ .sort();
1675
+ if (unknownFields.length) {
1676
+ throw new TypeError(`scaffold config has unknown fields: ${unknownFields.join(', ')}`);
1677
+ }
1609
1678
  const { platform, skills, pipeline, rules, aiCli, aiCliLaunch, externalSkills, playwrightCli, openCli, openCliAutoDownload, projectRoot, dryRun } = config;
1610
1679
  const runtime = normalizeRuntime(config.runtime);
1611
1680
  const launchSelection = resolveAiCliLaunchSelection(aiCli || '', {
@@ -1614,7 +1683,7 @@ export async function scaffold(config) {
1614
1683
  });
1615
1684
  const resolvedAiCli = launchSelection.aiCli;
1616
1685
  if (!isKnownPlatform(platform)) {
1617
- throw new Error(`Unknown platform "${platform}". Expected codebuddy, claude, codex, pi, or all.`);
1686
+ throw new Error(`Unknown platform "${platform}". Expected codebuddy, claude, codex, pi, cursor, or all.`);
1618
1687
  }
1619
1688
  const platforms = expandPlatforms(platform);
1620
1689
  const payloadPlatforms = resolvePayloadPlatforms(platform, resolvedAiCli);
@@ -1796,7 +1865,9 @@ export async function scaffold(config) {
1796
1865
  ? '说 "运行 prizmkit-init"'
1797
1866
  : mainPlatform === 'pi'
1798
1867
  ? '输入 "/skill:prizmkit-init"'
1799
- : '说 "/prizmkit-init"';
1868
+ : mainPlatform === 'cursor'
1869
+ ? '输入 "/prizmkit-init"'
1870
+ : '说 "/prizmkit-init"';
1800
1871
  console.log(` 3. ${chalk.cyan(initInstruction)} ${chalk.gray('# 初始化项目上下文')}`);
1801
1872
 
1802
1873
  if (pipeline) {
package/src/upgrade.js CHANGED
@@ -73,10 +73,12 @@ export async function removeSkillFiles(platform, projectRoot, skillNames, dryRun
73
73
  console.log(chalk.red(` ✗ removed .codebuddy/skills/${skillName}/`));
74
74
  }
75
75
  }
76
- } else if (platform === 'codex' || platform === 'pi') {
76
+ } else if (platform === 'codex' || platform === 'pi' || platform === 'cursor') {
77
77
  const skillDir = platform === 'pi'
78
78
  ? path.join(projectRoot, '.pi', 'skills', skillName)
79
- : path.join(projectRoot, '.agents', 'skills', skillName);
79
+ : platform === 'cursor'
80
+ ? path.join(projectRoot, '.cursor', 'skills', skillName)
81
+ : path.join(projectRoot, '.agents', 'skills', skillName);
80
82
  if (await fs.pathExists(skillDir)) {
81
83
  if (dryRun) {
82
84
  console.log(chalk.gray(` [dry-run] remove ${path.relative(projectRoot, skillDir)}/`));
@@ -93,7 +95,7 @@ export async function removeSkillFiles(platform, projectRoot, skillNames, dryRun
93
95
  * Remove agent files for a specific platform.
94
96
  */
95
97
  export async function removeAgentFiles(platform, projectRoot, agentFileNames, dryRun) {
96
- if (platform === 'pi') return;
98
+ if (platform === 'pi' || platform === 'cursor') return;
97
99
  for (const fileName of agentFileNames) {
98
100
  const dir = platform === 'claude'
99
101
  ? path.join(projectRoot, '.claude', 'agents')
@@ -129,9 +131,11 @@ export async function removeRuleFiles(platform, projectRoot, ruleFileNames, dryR
129
131
  ? path.join(projectRoot, '.agents', 'rules')
130
132
  : platform === 'pi'
131
133
  ? path.join(projectRoot, '.pi', 'rules')
132
- : path.join(projectRoot, '.codebuddy', 'rules');
133
- // Rules are stored as .md for claude, .mdc for codebuddy
134
- const targetName = platform === 'codebuddy'
134
+ : platform === 'cursor'
135
+ ? path.join(projectRoot, '.cursor', 'rules')
136
+ : path.join(projectRoot, '.codebuddy', 'rules');
137
+ // Cursor and CodeBuddy use .mdc; Claude/Codex/Pi use Markdown.
138
+ const targetName = platform === 'codebuddy' || platform === 'cursor'
135
139
  ? baseName.replace(/\.md$/, '.mdc')
136
140
  : baseName;
137
141
  const filePaths = platform === 'codex'
@@ -249,12 +253,14 @@ export async function runUpgrade(directory, options = {}) {
249
253
  const hasCodeBuddy = await hasPlatformFiles(path.join(projectRoot, '.codebuddy', 'skills'));
250
254
  const hasCodex = await hasPlatformFiles(path.join(projectRoot, '.agents', 'skills'));
251
255
  const hasPi = await hasPlatformFiles(path.join(projectRoot, '.pi', 'skills'));
256
+ const hasCursor = await hasPlatformFiles(path.join(projectRoot, '.cursor', 'skills'));
252
257
 
253
258
  const detectedPlatforms = [
254
259
  hasCodeBuddy && 'codebuddy',
255
260
  hasClaude && 'claude',
256
261
  hasCodex && 'codex',
257
262
  hasPi && 'pi',
263
+ hasCursor && 'cursor',
258
264
  ].filter(Boolean);
259
265
 
260
266
  if (detectedPlatforms.length > 1) platform = 'all';
@@ -298,7 +304,7 @@ export async function runUpgrade(directory, options = {}) {
298
304
  newManifest.installedAt = oldManifest.installedAt;
299
305
  }
300
306
 
301
- const diff = oldManifest ? diffManifest(oldManifest, newManifest) : { skills: { added: [], removed: [] }, rules: { added: [], removed: [] }, pipeline: { added: [], removed: [] }, extras: { added: [], removed: [] }, legacyAgents: { added: [], removed: [] } };
307
+ const diff = oldManifest ? diffManifest(oldManifest, newManifest) : { skills: { added: [], removed: [] }, rules: { added: [], removed: [] }, pipeline: { added: [], removed: [] }, extras: { added: [], removed: [] } };
302
308
  const removedPipelineSet = new Set(diff.pipeline.removed);
303
309
  const staleManagedPipelineFiles = pipeline
304
310
  ? (await findStaleManagedPipelineFiles(projectRoot, runtime))
@@ -315,12 +321,11 @@ export async function runUpgrade(directory, options = {}) {
315
321
  console.log('');
316
322
 
317
323
  const totalAdded = diff.skills.added.length + diff.rules.added.length + diff.pipeline.added.length + diff.extras.added.length;
318
- const totalRemoved = diff.skills.removed.length + diff.rules.removed.length + diff.pipeline.removed.length + diff.extras.removed.length + diff.legacyAgents.removed.length + staleManagedPipelineFiles.length;
324
+ const totalRemoved = diff.skills.removed.length + diff.rules.removed.length + diff.pipeline.removed.length + diff.extras.removed.length + staleManagedPipelineFiles.length;
319
325
  const totalUpdated = newSkillList.length + newRuleFiles.length;
320
326
 
321
327
  if (diff.skills.added.length) console.log(chalk.green(` + Skills added: ${diff.skills.added.join(', ')}`));
322
328
  if (diff.skills.removed.length) console.log(chalk.red(` - Skills removed: ${diff.skills.removed.join(', ')}`));
323
- if (diff.legacyAgents.removed.length) console.log(chalk.red(` - Legacy agents removed: ${diff.legacyAgents.removed.join(', ')}`));
324
329
  if (diff.rules.added.length) console.log(chalk.green(` + Rules added: ${diff.rules.added.join(', ')}`));
325
330
  if (diff.rules.removed.length) console.log(chalk.red(` - Rules removed: ${diff.rules.removed.join(', ')}`));
326
331
  if (diff.pipeline.added.length) console.log(chalk.green(` + Pipeline files added: ${diff.pipeline.added.length} file(s)`));
@@ -352,17 +357,13 @@ export async function runUpgrade(directory, options = {}) {
352
357
  const platforms = payloadPlatforms;
353
358
 
354
359
  // 7a. Remove orphaned files
355
- if (diff.skills.removed.length || diff.legacyAgents.removed.length || diff.rules.removed.length || diff.pipeline.removed.length || staleManagedPipelineFiles.length) {
360
+ if (diff.skills.removed.length || diff.rules.removed.length || diff.pipeline.removed.length || staleManagedPipelineFiles.length) {
356
361
  console.log(chalk.bold('\n Removing orphaned files...'));
357
362
  for (const p of platforms) {
358
363
  if (diff.skills.removed.length) {
359
364
  console.log(chalk.blue(`\n Removed skills (${p}):`));
360
365
  await removeSkillFiles(p, projectRoot, diff.skills.removed, dryRun);
361
366
  }
362
- if (diff.legacyAgents.removed.length) {
363
- console.log(chalk.blue(`\n Removed legacy agents (${p}):`));
364
- await removeAgentFiles(p, projectRoot, diff.legacyAgents.removed, dryRun);
365
- }
366
367
  console.log(chalk.blue(`\n Removed retired agent/team artifacts (${p}):`));
367
368
  await removeRetiredAgentTeamArtifacts(p, projectRoot, dryRun);
368
369
  if (diff.rules.removed.length) {