sillyspec 3.20.2 → 3.20.4

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 (133) hide show
  1. package/.claude/skills/sillyspec-archive/SKILL.md +21 -21
  2. package/.claude/skills/sillyspec-auto/SKILL.md +83 -83
  3. package/.claude/skills/sillyspec-brainstorm/SKILL.md +44 -44
  4. package/.claude/skills/sillyspec-commit/SKILL.md +106 -106
  5. package/.claude/skills/sillyspec-continue/SKILL.md +45 -45
  6. package/.claude/skills/sillyspec-doctor/SKILL.md +31 -31
  7. package/.claude/skills/sillyspec-execute/SKILL.md +30 -30
  8. package/.claude/skills/sillyspec-explore/SKILL.md +109 -109
  9. package/.claude/skills/sillyspec-knowledge/SKILL.md +269 -269
  10. package/.claude/skills/sillyspec-plan/SKILL.md +21 -21
  11. package/.claude/skills/sillyspec-propose/SKILL.md +21 -21
  12. package/.claude/skills/sillyspec-quick/SKILL.md +21 -21
  13. package/.claude/skills/sillyspec-resume/SKILL.md +68 -68
  14. package/.claude/skills/sillyspec-scan/SKILL.md +21 -21
  15. package/.claude/skills/sillyspec-state/SKILL.md +54 -54
  16. package/.claude/skills/sillyspec-status/SKILL.md +21 -21
  17. package/.claude/skills/sillyspec-verify/SKILL.md +21 -21
  18. package/.claude/skills/sillyspec-workspace/SKILL.md +157 -157
  19. package/.husky/pre-push +13 -13
  20. package/CLAUDE.md +18 -18
  21. package/README.md +198 -188
  22. package/SKILL.md +90 -91
  23. package/bin/sillyspec.js +2 -2
  24. package/docs/brainstorm-plan-contract.md +64 -64
  25. package/docs/plan-execute-contract.md +123 -123
  26. package/docs/platform-scan-protocol.md +298 -298
  27. package/docs/revision-mode.md +115 -115
  28. package/docs/sillyspec/file-lifecycle/known-implementation-gaps.md +99 -99
  29. package/docs/sillyspec/file-lifecycle/platform-workflows-sync.md +218 -218
  30. package/docs/sillyspec/file-lifecycle/stage-artifacts.md +167 -167
  31. package/docs/sillyspec/file-lifecycle/storage-and-state.md +148 -148
  32. package/docs/sillyspec/file-lifecycle/worktree-and-guard.md +211 -193
  33. package/docs/sillyspec/file-lifecycle.md +125 -125
  34. package/docs/workflow-contract-regression.md +106 -106
  35. package/docs/worktree-isolation.md +252 -252
  36. package/package.json +40 -40
  37. package/packages/dashboard/dist/assets/index-Bq_Z2hne.js +7446 -7446
  38. package/packages/dashboard/dist/assets/index-O2W5RV4z.css +1 -1
  39. package/packages/dashboard/dist/index.html +16 -16
  40. package/packages/dashboard/index.html +15 -15
  41. package/packages/dashboard/package-lock.json +2384 -2384
  42. package/packages/dashboard/package.json +25 -25
  43. package/packages/dashboard/server/executor.js +86 -86
  44. package/packages/dashboard/server/index.js +588 -588
  45. package/packages/dashboard/server/parser.js +526 -526
  46. package/packages/dashboard/server/watcher.js +344 -344
  47. package/packages/dashboard/src/App.vue +558 -558
  48. package/packages/dashboard/src/components/ActionBar.vue +93 -93
  49. package/packages/dashboard/src/components/CommandPalette.vue +96 -96
  50. package/packages/dashboard/src/components/DetailPanel.vue +137 -137
  51. package/packages/dashboard/src/components/LogStream.vue +65 -65
  52. package/packages/dashboard/src/components/PipelineStage.vue +95 -95
  53. package/packages/dashboard/src/components/PipelineView.vue +156 -156
  54. package/packages/dashboard/src/components/ProjectList.vue +210 -210
  55. package/packages/dashboard/src/components/StageBadge.vue +67 -67
  56. package/packages/dashboard/src/components/StepCard.vue +94 -94
  57. package/packages/dashboard/src/components/detail/DocsDetail.vue +48 -48
  58. package/packages/dashboard/src/components/detail/GitDetail.vue +61 -61
  59. package/packages/dashboard/src/components/detail/TechDetail.vue +43 -43
  60. package/packages/dashboard/src/composables/useDashboard.js +170 -170
  61. package/packages/dashboard/src/composables/useKeyboard.js +119 -119
  62. package/packages/dashboard/src/composables/useWebSocket.js +129 -129
  63. package/packages/dashboard/src/main.js +8 -8
  64. package/packages/dashboard/src/style.css +132 -132
  65. package/packages/dashboard/vite.config.js +18 -18
  66. package/src/brainstorm-postcheck.js +158 -158
  67. package/src/change-list.js +52 -52
  68. package/src/change-risk-profile.js +352 -352
  69. package/src/classify-change.js +73 -73
  70. package/src/constants.js +70 -70
  71. package/src/contract-matrix.js +278 -278
  72. package/src/db.js +201 -201
  73. package/src/endpoint-extractor.js +315 -315
  74. package/src/hooks/claude-pre-tool-use.cjs +125 -125
  75. package/src/hooks/worktree-guard.js +653 -653
  76. package/src/index.js +922 -900
  77. package/src/init.js +431 -431
  78. package/src/knowledge-match.js +130 -130
  79. package/src/migrate.js +117 -117
  80. package/src/modules.js +482 -482
  81. package/src/progress.js +1734 -1734
  82. package/src/run.js +3465 -3358
  83. package/src/scan-postcheck.js +387 -383
  84. package/src/setup.js +398 -398
  85. package/src/stage-contract.js +700 -700
  86. package/src/stages/archive.js +160 -160
  87. package/src/stages/brainstorm-auto.js +229 -229
  88. package/src/stages/brainstorm.js +645 -645
  89. package/src/stages/doctor.js +365 -365
  90. package/src/stages/execute.js +625 -625
  91. package/src/stages/explore.js +34 -34
  92. package/src/stages/index.js +29 -29
  93. package/src/stages/knowledge.js +498 -498
  94. package/src/stages/plan-postcheck.js +511 -513
  95. package/src/stages/plan.js +582 -582
  96. package/src/stages/propose.js +174 -174
  97. package/src/stages/quick.js +82 -82
  98. package/src/stages/scan.js +558 -558
  99. package/src/stages/status.js +65 -65
  100. package/src/stages/verify.js +322 -322
  101. package/src/sync.js +497 -497
  102. package/src/task-review.js +346 -346
  103. package/src/workflow.js +785 -785
  104. package/src/worktree-apply.js +549 -549
  105. package/src/worktree-deps.js +185 -0
  106. package/src/worktree.js +982 -932
  107. package/templates/workflows/archive-impact.yaml +79 -79
  108. package/templates/workflows/scan-docs.yaml +132 -132
  109. package/test/brainstorm-plan-contract.test.mjs +273 -273
  110. package/test/check-syntax.mjs +26 -26
  111. package/test/contract-artifacts.test.mjs +323 -323
  112. package/test/decision-supersede.test.mjs +277 -277
  113. package/test/knowledge-match.test.mjs +231 -231
  114. package/test/plan-execute-contract.test.mjs +330 -330
  115. package/test/plan-optimization.test.mjs +572 -572
  116. package/test/platform-artifacts.test.mjs +166 -166
  117. package/test/platform-failure-samples.test.mjs +199 -199
  118. package/test/platform-recovery-chain.test.mjs +167 -167
  119. package/test/platform-recovery.test.mjs +136 -136
  120. package/test/platform-scan-p0.test.mjs +168 -168
  121. package/test/revision-v1.test.mjs +1145 -1145
  122. package/test/run-scan-project-parse.test.mjs +200 -200
  123. package/test/run-tests.mjs +48 -48
  124. package/test/scan-knowledge.test.mjs +175 -175
  125. package/test/scan-paths.test.mjs +68 -68
  126. package/test/scan-postcheck.test.mjs +197 -197
  127. package/test/spec-dir.test.mjs +206 -206
  128. package/test/stage-contract.test.mjs +299 -299
  129. package/test/stage-definitions.test.mjs +39 -39
  130. package/test/wait-gates.test.mjs +496 -496
  131. package/test/worktree-deps-provision.test.mjs +148 -0
  132. package/test/worktree-guard.test.mjs +71 -71
  133. package/test/worktree-native-overlay.test.mjs +188 -188
package/src/init.js CHANGED
@@ -1,431 +1,431 @@
1
- import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'fs';
2
- import { join, resolve, dirname, basename } from 'path';
3
- import { fileURLToPath } from 'url';
4
- import { checkbox, confirm, input } from '@inquirer/prompts';
5
- import { ProgressManager } from './progress.js';
6
- import chalk from 'chalk';
7
-
8
- const __filename = fileURLToPath(import.meta.url);
9
- const __dirname = dirname(__filename);
10
-
11
- // ── 递归复制目录 ──
12
- function copyDirSync(src, dst) {
13
- mkdirSync(dst, { recursive: true });
14
- for (const entry of readdirSync(src, { withFileTypes: true })) {
15
- if (entry.name === 'node_modules' || entry.name === '.git') continue;
16
- const srcPath = join(src, entry.name);
17
- const dstPath = join(dst, entry.name);
18
- if (entry.isDirectory()) {
19
- copyDirSync(srcPath, dstPath);
20
- } else if (entry.name.endsWith('.md')) {
21
- writeFileSync(dstPath, readFileSync(srcPath));
22
- }
23
- }
24
- }
25
-
26
- // ── 元数据映射 ──
27
-
28
-
29
-
30
- const VALID_TOOLS = ['claude', 'cursor', 'openclaw', 'codex', 'gemini', 'opencode'];
31
-
32
- const TOOL_LABELS = {
33
- claude: 'Claude Code',
34
- cursor: 'Cursor',
35
- openclaw: 'OpenClaw',
36
- codex: 'OpenAI Codex (通过 AGENTS.md)',
37
- gemini: 'Gemini CLI (通过 GEMINI.md)',
38
- opencode: 'OpenCode (通过 INSTRUCTIONS.md)',
39
- };
40
-
41
- const INSTRUCTION_TOOLS = ['codex', 'gemini', 'opencode'];
42
-
43
- const INSTRUCTION_FILE_MAP = {
44
- codex: 'AGENTS.md',
45
- gemini: 'GEMINI.md',
46
- opencode: 'INSTRUCTIONS.md',
47
- };
48
-
49
- const INJECTION_CONTENT = `## SillySpec — 规范驱动开发
50
-
51
- 在执行开发任务时,遵循以下规范:
52
-
53
- ### 代码规范
54
- - 写代码前先读取 \`.sillyspec/docs/<project>/scan/CONVENTIONS.md\`(代码风格)和 \`.sillyspec/docs/<project>/scan/ARCHITECTURE.md\`(架构)
55
- - 调用已有方法前,用 grep 确认方法存在,不许编造
56
- - 遵循 \`.sillyspec/docs/<project>/scan/CONVENTIONS.md\` 中的代码风格
57
-
58
- ### 工作流程
59
- - 读取 sillyspec.db 确认当前阶段(使用 \`sillyspec progress show\`)
60
- - 各阶段产出文件位于 \`.sillyspec/changes/<变更名>/\` 下
61
- `;
62
-
63
- // ── 注入指令文件 ──
64
-
65
- function injectInstructions(tool, projectDir) {
66
- const fileName = INSTRUCTION_FILE_MAP[tool];
67
- if (!fileName) return;
68
- const filePath = join(projectDir, fileName);
69
-
70
- // 文件不存在则创建
71
- if (!existsSync(filePath)) {
72
- writeFileSync(filePath, INJECTION_CONTENT);
73
- return;
74
- }
75
-
76
- // 已存在 SillySpec 标记则跳过
77
- const content = readFileSync(filePath, 'utf8');
78
- if (content.includes('## SillySpec')) return;
79
-
80
- // 追加到末尾
81
- writeFileSync(filePath, content.trimEnd() + '\n\n' + INJECTION_CONTENT);
82
- }
83
-
84
- // ── 检测工具 ──
85
-
86
- function detectTools(projectDir) {
87
- const found = [];
88
- if (existsSync(join(projectDir, '.claude'))) found.push('claude');
89
- if (existsSync(join(projectDir, '.cursor'))) found.push('cursor');
90
- if (existsSync(join(projectDir, '.openclaw'))) found.push('openclaw');
91
- if (existsSync(join(projectDir, 'AGENTS.md'))) found.push('codex');
92
- if (existsSync(join(projectDir, 'GEMINI.md'))) found.push('gemini');
93
- if (existsSync(join(projectDir, 'INSTRUCTIONS.md'))) found.push('opencode');
94
- if (found.length === 0) found.push('claude');
95
- return found;
96
- }
97
-
98
- // ── TTY 工具函数 ──
99
-
100
- function isTTY() {
101
- return process.stdin.isTTY && process.stdout.isTTY;
102
- }
103
-
104
- // ── 核心安装逻辑 ──
105
-
106
- async function doInstall(projectDir, tools, subprojects = [], specDir = null) {
107
- // specDir: 规范目录(默认 projectDir/.sillyspec)
108
- // projectDir: 源码项目根目录(用于工具检测、指令注入、.gitignore)
109
- const spec = specDir || join(projectDir, '.sillyspec');
110
-
111
- // 外部 specDir 时清理旧版本残留的 cwd/.sillyspec/(防止源码污染)。
112
- // ⚠️ 必须保护真实资产:若本地 .sillyspec 含 changes/(非空)、projects/(非空)
113
- // 或 sillyspec.db(进度库),说明该项目本身就用 SillySpec 管理,整体删除会丢资产。
114
- // 此时只清运行时残留,拒绝整删;确无资产时才视为旧残留清理。
115
- const legacyDir = join(projectDir, '.sillyspec');
116
- if (specDir && existsSync(legacyDir)) {
117
- let hasChanges = false;
118
- try {
119
- const changesDir = join(legacyDir, 'changes');
120
- if (existsSync(changesDir)) hasChanges = readdirSync(changesDir).length > 0;
121
- } catch {}
122
- let hasProjects = false;
123
- try {
124
- const projectsDir = join(legacyDir, 'projects');
125
- if (existsSync(projectsDir)) hasProjects = readdirSync(projectsDir).length > 0;
126
- } catch {}
127
- const hasDb = existsSync(join(legacyDir, 'sillyspec.db'));
128
-
129
- if (hasChanges || hasProjects || hasDb) {
130
- // 真实资产存在:拒绝整体删除,仅清理运行时残留
131
- console.error('❌ [sillyspec] 拒绝删除源码目录的 .sillyspec/:检测到真实资产(changes/、projects/ 或 sillyspec.db)。');
132
- console.error(' 该项目似乎本身就用 SillySpec 管理。如需改用外部 spec 目录,请先手动迁移/备份。');
133
- console.error(' 本次仅清理运行时残留(.runtime/、local.yaml、codebase/)。');
134
- for (const residue of ['.runtime', 'local.yaml', 'codebase']) {
135
- const p = join(legacyDir, residue);
136
- if (existsSync(p)) { try { rmSync(p, { recursive: true, force: true }) } catch {} }
137
- }
138
- } else {
139
- // 无真实资产:确属旧版本残留,安全删除
140
- try { rmSync(legacyDir, { recursive: true, force: true }) } catch {}
141
- if (!existsSync(legacyDir)) console.log('🧹 已清理旧版本残留的源码 .sillyspec/ 目录');
142
- else console.error('⚠️ 清理残留 .sillyspec/ 失败');
143
- }
144
- }
145
-
146
- // 创建基础目录
147
- // spec/projects/ → 项目注册表
148
- // spec/docs/<name>/ → 统一文档中心
149
- // spec/knowledge/ → 跨项目共享知识库
150
- // spec/.runtime/ → progress (gitignored)
151
-
152
- // 注册当前项目到 projects/
153
- const projectName = basename(projectDir) || 'project';
154
- const projectsDir = join(spec, 'projects');
155
- mkdirSync(projectsDir, { recursive: true });
156
- const projectYamlPath = join(projectsDir, `${projectName}.yaml`);
157
- if (!existsSync(projectYamlPath)) {
158
- // path 相对于 specDir,跨平台可寻址
159
- writeFileSync(projectYamlPath, `name: ${projectName}\npath: ${projectDir}\nstatus: active\n`);
160
- }
161
-
162
- // 创建 docs/<projectName>/scan/ 子目录(代码扫描结果)
163
- const scanDir = join(spec, 'docs', projectName, 'scan');
164
- mkdirSync(scanDir, { recursive: true });
165
- const gitkeepPath = join(scanDir, '.gitkeep');
166
- if (!existsSync(gitkeepPath)) writeFileSync(gitkeepPath, '');
167
-
168
- // 复制 workflow 模板到 workflows/
169
- const workflowsDir = join(spec, 'workflows');
170
- const templatesDir = join(__dirname, '..', 'templates', 'workflows');
171
- if (existsSync(templatesDir)) {
172
- mkdirSync(workflowsDir, { recursive: true });
173
- for (const file of readdirSync(templatesDir)) {
174
- if (file.endsWith('.yaml')) {
175
- const srcPath = join(templatesDir, file);
176
- const dstPath = join(workflowsDir, file);
177
- if (!existsSync(dstPath)) {
178
- writeFileSync(dstPath, readFileSync(srcPath));
179
- }
180
- }
181
- }
182
- }
183
-
184
- // 创建 shared/workspace 目录
185
- mkdirSync(join(spec, 'shared'), { recursive: true });
186
- mkdirSync(join(spec, 'workspace'), { recursive: true });
187
-
188
- // 创建知识库骨架
189
- const knowledgeDir = join(spec, 'knowledge');
190
- mkdirSync(knowledgeDir, { recursive: true });
191
- const indexPath = join(knowledgeDir, 'INDEX.md');
192
- if (!existsSync(indexPath)) {
193
- writeFileSync(indexPath, `# Knowledge Index\n\n> 子代理任务开始前查询此文件,按关键词匹配,只读命中的知识文件。\n> execute/quick 执行中发现的坑自动追加到 uncategorized.md,经用户确认后归类到对应文件。\n\n<!-- 格式:关键词1|关键词2|关键词3 → 文件路径 -->\n<!-- 示例:mybatis-plus|分页|Page → pagination.md -->\n<!-- 示例:跨域|CORS|preflight → cors.md -->\n`);
194
- }
195
- const uncatPath = join(knowledgeDir, 'uncategorized.md');
196
- if (!existsSync(uncatPath)) {
197
- writeFileSync(uncatPath, `# 未分类知识\n\n> execute/quick 执行中发现的坑暂存于此,用户审阅后归类到对应文件并更新 INDEX.md。\n`);
198
- }
199
-
200
- // 创建 .runtime/ 目录结构(全局状态)
201
- const runtimeDir = join(spec, '.runtime');
202
- for (const sub of ['artifacts', 'history', 'logs', 'templates']) {
203
- mkdirSync(join(runtimeDir, sub), { recursive: true });
204
- }
205
-
206
- // 初始化 SQLite 数据库
207
- const pm = new ProgressManager({ specDir: spec });
208
- await pm.init(projectDir);
209
-
210
- // .gitignore 只在 specDir 在项目内时才修改
211
- const isExternalSpec = specDir && resolve(spec) !== resolve(projectDir, '.sillyspec');
212
- if (!isExternalSpec) {
213
- const gitignorePath = join(projectDir, '.gitignore');
214
- const ignoreRules = ['.sillyspec/codebase/SCAN-RAW.md', '.sillyspec/local.yaml', '.sillyspec/.runtime/'];
215
- if (existsSync(gitignorePath)) {
216
- const content = readFileSync(gitignorePath, 'utf8');
217
- let updated = content.trimEnd();
218
- for (const rule of ignoreRules) {
219
- if (!updated.includes(rule)) {
220
- updated += '\n' + rule;
221
- }
222
- }
223
- writeFileSync(gitignorePath, updated + '\n');
224
- } else {
225
- writeFileSync(gitignorePath, ignoreRules.join('\n') + '\n');
226
- }
227
- }
228
-
229
- // 注入指令文件(codex/gemini/opencode)
230
- for (let i = 0; i < tools.length; i++) {
231
- const toolName = tools[i];
232
- if (INSTRUCTION_TOOLS.includes(toolName)) {
233
- injectInstructions(toolName, projectDir);
234
- }
235
- }
236
-
237
- // 复制 skills 到各工具目录
238
- const skillToolDirs = {
239
- claude: '.claude/skills',
240
- codex: '.codex/skills',
241
- openclaw: '.openclaw/skills',
242
- opencode: '.opencode/skills',
243
- }
244
- const skillsSource = join(__dirname, '..', '.claude', 'skills');
245
- if (existsSync(skillsSource)) {
246
- const sillyspecSkills = readdirSync(skillsSource).filter(f => f.startsWith('sillyspec-') && statSync(join(skillsSource, f)).isDirectory());
247
- if (sillyspecSkills.length > 0) {
248
- for (const [tool, dir] of Object.entries(skillToolDirs)) {
249
- if (!tools.includes(tool)) continue
250
- const targetDir = join(projectDir, dir)
251
- mkdirSync(targetDir, { recursive: true })
252
- for (const skill of sillyspecSkills) {
253
- copyDirSync(join(skillsSource, skill), join(targetDir, skill))
254
- }
255
- console.log(chalk.green(` ✓ ${TOOL_LABELS[tool]} skills 已同步 (${sillyspecSkills.length} 个)`))
256
- }
257
- }
258
- } else {
259
- console.log(chalk.yellow(' ⚠ 未找到 skills 目录(npm 包内无 .claude/skills/),跳过同步'));
260
- }
261
- }
262
-
263
- // ── 安装完成总结 ──
264
-
265
- function showSummary(version, tools, specDir) {
266
- const toolLabels = tools.map(t => TOOL_LABELS[t] || t);
267
-
268
- console.log('');
269
- console.log(chalk.green(' ═══════════════════════════════════════'));
270
- console.log(chalk.green(` ✅ SillySpec v${version} 安装完成!`));
271
- console.log(chalk.green(' ═══════════════════════════════════════'));
272
- console.log('');
273
- console.log(` 已安装工具: ${chalk.cyan(toolLabels.join(', '))}`);
274
- console.log(` 📁 规范目录: ${chalk.cyan(specDir || '.sillyspec')}`);
275
- console.log('');
276
- console.log(' 下一步:使用 AI 技能开始工作');
277
- console.log(' OpenClaw: ' + chalk.bold('/sillyspec:brainstorm'));
278
- console.log(' Claude Code: ' + chalk.bold('/sillyspec:brainstorm'));
279
- console.log('');
280
- console.log(chalk.dim(' 💡 推荐安装 MCP 工具增强 AI 能力:sillyspec setup'));
281
- console.log('');
282
- }
283
-
284
- // ── 读取版本号 ──
285
-
286
- export function getVersion() {
287
- try {
288
- const pkg = JSON.parse(readFileSync(resolve(__dirname, '..', 'package.json'), 'utf8'));
289
- return pkg.version;
290
- } catch {
291
- return '?.?.?';
292
- }
293
- }
294
-
295
- // ── 主命令 ──
296
-
297
- export async function cmdInit(projectDir, options = {}) {
298
- const { tool, interactive, specDir } = options;
299
- const version = getVersion();
300
- const resolvedSpecDir = specDir ? resolve(specDir) : null;
301
-
302
- // ── 交互式模式(--interactive 或 -i)──
303
- if (interactive && isTTY()) {
304
- // 欢迎画面
305
- console.log('');
306
- console.log(chalk.cyan('🤪 SillySpec v' + version + ' — 规范驱动开发'));
307
- console.log(chalk.cyan(' ===================================='));
308
- console.log('');
309
- console.log(' 让 AI 像高级工程师一样工作:');
310
- console.log(' 先思考、先规划、先验证,再写代码。');
311
- console.log('');
312
- console.log(chalk.gray(' 支持的 AI 工具:'));
313
- console.log(chalk.gray(' Claude Code · Claude Skills · Cursor · Codex CLI · OpenCode · OpenClaw'));
314
- console.log('');
315
-
316
- // 工具多选
317
- const detected = detectTools(projectDir);
318
-
319
- const toolChoices = VALID_TOOLS.map(v => ({
320
- name: `${TOOL_LABELS[v]}${v === 'claude' ? ' (推荐)' : ''}`,
321
- value: v,
322
- checked: detected.includes(v),
323
- }));
324
-
325
- const selectedTools = await checkbox({
326
- message: '选择要安装的 AI 工具(空格选择,回车确认)',
327
- choices: toolChoices,
328
- validate: (answer) => answer.length > 0 || '至少选择一个工具',
329
- });
330
-
331
- // 子项目引导(仅交互模式)
332
- let subprojects = [];
333
- {
334
- console.log('');
335
- console.log(chalk.yellow('📋 添加子项目'));
336
- console.log(chalk.dim(' 子项目是工作区中的独立项目目录(如 frontend/、backend/)'));
337
- console.log('');
338
-
339
- const addMore = await confirm({ message: '现在添加子项目?', default: true });
340
- if (addMore) {
341
- let suggestions = [];
342
- try {
343
- const entries = readdirSync(projectDir, { withFileTypes: true });
344
- suggestions = entries
345
- .filter(e => e.isDirectory() && !e.name.startsWith('.') && e.name !== 'node_modules')
346
- .map(e => e.name)
347
- .sort();
348
- } catch {}
349
-
350
- if (suggestions.length > 0) {
351
- console.log('');
352
- console.log(chalk.dim(` 检测到以下目录:${suggestions.join(', ')}`));
353
- console.log('');
354
- }
355
-
356
- let adding = true;
357
- while (adding) {
358
- const name = await input({
359
- message: '子项目名称(如 frontend,留空结束)',
360
- default: suggestions.find(s => !subprojects.find(p => p.name === s)) || '',
361
- });
362
-
363
- if (!name.trim()) {
364
- adding = false;
365
- break;
366
- }
367
-
368
- const pathHint = suggestions.includes(name.trim()) ? `./${name.trim()}` : '';
369
- const subPath = await input({
370
- message: '子项目目录路径',
371
- default: pathHint,
372
- });
373
-
374
- const role = await input({
375
- message: '子项目描述(如 前端 - Vue3 + TypeScript)',
376
- default: '',
377
- });
378
-
379
- let repo = '';
380
- try {
381
- const { execSync } = await import('child_process');
382
- const absPath = resolve(projectDir, subPath.trim() || `./${name.trim()}`);
383
- repo = execSync('git remote get-url origin', { cwd: absPath, encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'] }).trim();
384
- } catch {}
385
-
386
- subprojects.push({ name: name.trim(), path: subPath.trim() || `./${name.trim()}`, role: role.trim(), repo });
387
-
388
- const idx = suggestions.indexOf(name.trim());
389
- if (idx >= 0) suggestions.splice(idx, 1);
390
-
391
- const again = await confirm({ message: '继续添加子项目?', default: subprojects.length < suggestions.length });
392
- if (!again) adding = false;
393
- }
394
- }
395
- }
396
-
397
- console.log('');
398
- await doInstall(projectDir, selectedTools, subprojects, resolvedSpecDir);
399
- showSummary(version, selectedTools, resolvedSpecDir);
400
- return;
401
- }
402
-
403
- // ── 默认快速模式:检测 → 安装 → 结束 ──
404
-
405
- let tools = [];
406
- if (tool) {
407
- if (!VALID_TOOLS.includes(tool)) {
408
- console.error(`❌ 未知工具: ${tool}`);
409
- console.error(`支持的工具: ${VALID_TOOLS.join(', ')}`);
410
- process.exit(1);
411
- }
412
- tools = [tool];
413
- } else {
414
- tools = detectTools(projectDir);
415
- }
416
-
417
- await doInstall(projectDir, tools, [], resolvedSpecDir);
418
-
419
- console.log('');
420
- console.log(chalk.green(` ✅ SillySpec v${version} 安装完成!`));
421
- console.log('');
422
- const specDisplay = resolvedSpecDir || '.sillyspec';
423
- console.log(` 📁 规范目录: ${chalk.cyan(specDisplay)}`);
424
- console.log('');
425
- console.log(' 下一步:使用 AI 技能开始工作');
426
- console.log(` OpenClaw: ${chalk.bold('/sillyspec:brainstorm')}`);
427
- console.log(` Claude Code: ${chalk.bold('/sillyspec:brainstorm')}`);
428
- console.log('');
429
- console.log(chalk.dim(' 💡 增强能力:sillyspec setup(安装 MCP 工具)'));
430
- console.log('');
431
- }
1
+ import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'fs';
2
+ import { join, resolve, dirname, basename } from 'path';
3
+ import { fileURLToPath } from 'url';
4
+ import { checkbox, confirm, input } from '@inquirer/prompts';
5
+ import { ProgressManager } from './progress.js';
6
+ import chalk from 'chalk';
7
+
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = dirname(__filename);
10
+
11
+ // ── 递归复制目录 ──
12
+ function copyDirSync(src, dst) {
13
+ mkdirSync(dst, { recursive: true });
14
+ for (const entry of readdirSync(src, { withFileTypes: true })) {
15
+ if (entry.name === 'node_modules' || entry.name === '.git') continue;
16
+ const srcPath = join(src, entry.name);
17
+ const dstPath = join(dst, entry.name);
18
+ if (entry.isDirectory()) {
19
+ copyDirSync(srcPath, dstPath);
20
+ } else if (entry.name.endsWith('.md')) {
21
+ writeFileSync(dstPath, readFileSync(srcPath));
22
+ }
23
+ }
24
+ }
25
+
26
+ // ── 元数据映射 ──
27
+
28
+
29
+
30
+ const VALID_TOOLS = ['claude', 'cursor', 'openclaw', 'codex', 'gemini', 'opencode'];
31
+
32
+ const TOOL_LABELS = {
33
+ claude: 'Claude Code',
34
+ cursor: 'Cursor',
35
+ openclaw: 'OpenClaw',
36
+ codex: 'OpenAI Codex (通过 AGENTS.md)',
37
+ gemini: 'Gemini CLI (通过 GEMINI.md)',
38
+ opencode: 'OpenCode (通过 INSTRUCTIONS.md)',
39
+ };
40
+
41
+ const INSTRUCTION_TOOLS = ['codex', 'gemini', 'opencode'];
42
+
43
+ const INSTRUCTION_FILE_MAP = {
44
+ codex: 'AGENTS.md',
45
+ gemini: 'GEMINI.md',
46
+ opencode: 'INSTRUCTIONS.md',
47
+ };
48
+
49
+ const INJECTION_CONTENT = `## SillySpec — 规范驱动开发
50
+
51
+ 在执行开发任务时,遵循以下规范:
52
+
53
+ ### 代码规范
54
+ - 写代码前先读取 \`.sillyspec/docs/<project>/scan/CONVENTIONS.md\`(代码风格)和 \`.sillyspec/docs/<project>/scan/ARCHITECTURE.md\`(架构)
55
+ - 调用已有方法前,用 grep 确认方法存在,不许编造
56
+ - 遵循 \`.sillyspec/docs/<project>/scan/CONVENTIONS.md\` 中的代码风格
57
+
58
+ ### 工作流程
59
+ - 读取 sillyspec.db 确认当前阶段(使用 \`sillyspec progress show\`)
60
+ - 各阶段产出文件位于 \`.sillyspec/changes/<变更名>/\` 下
61
+ `;
62
+
63
+ // ── 注入指令文件 ──
64
+
65
+ function injectInstructions(tool, projectDir) {
66
+ const fileName = INSTRUCTION_FILE_MAP[tool];
67
+ if (!fileName) return;
68
+ const filePath = join(projectDir, fileName);
69
+
70
+ // 文件不存在则创建
71
+ if (!existsSync(filePath)) {
72
+ writeFileSync(filePath, INJECTION_CONTENT);
73
+ return;
74
+ }
75
+
76
+ // 已存在 SillySpec 标记则跳过
77
+ const content = readFileSync(filePath, 'utf8');
78
+ if (content.includes('## SillySpec')) return;
79
+
80
+ // 追加到末尾
81
+ writeFileSync(filePath, content.trimEnd() + '\n\n' + INJECTION_CONTENT);
82
+ }
83
+
84
+ // ── 检测工具 ──
85
+
86
+ function detectTools(projectDir) {
87
+ const found = [];
88
+ if (existsSync(join(projectDir, '.claude'))) found.push('claude');
89
+ if (existsSync(join(projectDir, '.cursor'))) found.push('cursor');
90
+ if (existsSync(join(projectDir, '.openclaw'))) found.push('openclaw');
91
+ if (existsSync(join(projectDir, 'AGENTS.md'))) found.push('codex');
92
+ if (existsSync(join(projectDir, 'GEMINI.md'))) found.push('gemini');
93
+ if (existsSync(join(projectDir, 'INSTRUCTIONS.md'))) found.push('opencode');
94
+ if (found.length === 0) found.push('claude');
95
+ return found;
96
+ }
97
+
98
+ // ── TTY 工具函数 ──
99
+
100
+ function isTTY() {
101
+ return process.stdin.isTTY && process.stdout.isTTY;
102
+ }
103
+
104
+ // ── 核心安装逻辑 ──
105
+
106
+ async function doInstall(projectDir, tools, subprojects = [], specDir = null) {
107
+ // specDir: 规范目录(默认 projectDir/.sillyspec)
108
+ // projectDir: 源码项目根目录(用于工具检测、指令注入、.gitignore)
109
+ const spec = specDir || join(projectDir, '.sillyspec');
110
+
111
+ // 外部 specDir 时清理旧版本残留的 cwd/.sillyspec/(防止源码污染)。
112
+ // ⚠️ 必须保护真实资产:若本地 .sillyspec 含 changes/(非空)、projects/(非空)
113
+ // 或 sillyspec.db(进度库),说明该项目本身就用 SillySpec 管理,整体删除会丢资产。
114
+ // 此时只清运行时残留,拒绝整删;确无资产时才视为旧残留清理。
115
+ const legacyDir = join(projectDir, '.sillyspec');
116
+ if (specDir && existsSync(legacyDir)) {
117
+ let hasChanges = false;
118
+ try {
119
+ const changesDir = join(legacyDir, 'changes');
120
+ if (existsSync(changesDir)) hasChanges = readdirSync(changesDir).length > 0;
121
+ } catch {}
122
+ let hasProjects = false;
123
+ try {
124
+ const projectsDir = join(legacyDir, 'projects');
125
+ if (existsSync(projectsDir)) hasProjects = readdirSync(projectsDir).length > 0;
126
+ } catch {}
127
+ const hasDb = existsSync(join(legacyDir, 'sillyspec.db'));
128
+
129
+ if (hasChanges || hasProjects || hasDb) {
130
+ // 真实资产存在:拒绝整体删除,仅清理运行时残留
131
+ console.error('❌ [sillyspec] 拒绝删除源码目录的 .sillyspec/:检测到真实资产(changes/、projects/ 或 sillyspec.db)。');
132
+ console.error(' 该项目似乎本身就用 SillySpec 管理。如需改用外部 spec 目录,请先手动迁移/备份。');
133
+ console.error(' 本次仅清理运行时残留(.runtime/、local.yaml、codebase/)。');
134
+ for (const residue of ['.runtime', 'local.yaml', 'codebase']) {
135
+ const p = join(legacyDir, residue);
136
+ if (existsSync(p)) { try { rmSync(p, { recursive: true, force: true }) } catch {} }
137
+ }
138
+ } else {
139
+ // 无真实资产:确属旧版本残留,安全删除
140
+ try { rmSync(legacyDir, { recursive: true, force: true }) } catch {}
141
+ if (!existsSync(legacyDir)) console.log('🧹 已清理旧版本残留的源码 .sillyspec/ 目录');
142
+ else console.error('⚠️ 清理残留 .sillyspec/ 失败');
143
+ }
144
+ }
145
+
146
+ // 创建基础目录
147
+ // spec/projects/ → 项目注册表
148
+ // spec/docs/<name>/ → 统一文档中心
149
+ // spec/knowledge/ → 跨项目共享知识库
150
+ // spec/.runtime/ → progress (gitignored)
151
+
152
+ // 注册当前项目到 projects/
153
+ const projectName = basename(projectDir) || 'project';
154
+ const projectsDir = join(spec, 'projects');
155
+ mkdirSync(projectsDir, { recursive: true });
156
+ const projectYamlPath = join(projectsDir, `${projectName}.yaml`);
157
+ if (!existsSync(projectYamlPath)) {
158
+ // path 相对于 specDir,跨平台可寻址
159
+ writeFileSync(projectYamlPath, `name: ${projectName}\npath: ${projectDir}\nstatus: active\n`);
160
+ }
161
+
162
+ // 创建 docs/<projectName>/scan/ 子目录(代码扫描结果)
163
+ const scanDir = join(spec, 'docs', projectName, 'scan');
164
+ mkdirSync(scanDir, { recursive: true });
165
+ const gitkeepPath = join(scanDir, '.gitkeep');
166
+ if (!existsSync(gitkeepPath)) writeFileSync(gitkeepPath, '');
167
+
168
+ // 复制 workflow 模板到 workflows/
169
+ const workflowsDir = join(spec, 'workflows');
170
+ const templatesDir = join(__dirname, '..', 'templates', 'workflows');
171
+ if (existsSync(templatesDir)) {
172
+ mkdirSync(workflowsDir, { recursive: true });
173
+ for (const file of readdirSync(templatesDir)) {
174
+ if (file.endsWith('.yaml')) {
175
+ const srcPath = join(templatesDir, file);
176
+ const dstPath = join(workflowsDir, file);
177
+ if (!existsSync(dstPath)) {
178
+ writeFileSync(dstPath, readFileSync(srcPath));
179
+ }
180
+ }
181
+ }
182
+ }
183
+
184
+ // 创建 shared/workspace 目录
185
+ mkdirSync(join(spec, 'shared'), { recursive: true });
186
+ mkdirSync(join(spec, 'workspace'), { recursive: true });
187
+
188
+ // 创建知识库骨架
189
+ const knowledgeDir = join(spec, 'knowledge');
190
+ mkdirSync(knowledgeDir, { recursive: true });
191
+ const indexPath = join(knowledgeDir, 'INDEX.md');
192
+ if (!existsSync(indexPath)) {
193
+ writeFileSync(indexPath, `# Knowledge Index\n\n> 子代理任务开始前查询此文件,按关键词匹配,只读命中的知识文件。\n> execute/quick 执行中发现的坑自动追加到 uncategorized.md,经用户确认后归类到对应文件。\n\n<!-- 格式:关键词1|关键词2|关键词3 → 文件路径 -->\n<!-- 示例:mybatis-plus|分页|Page → pagination.md -->\n<!-- 示例:跨域|CORS|preflight → cors.md -->\n`);
194
+ }
195
+ const uncatPath = join(knowledgeDir, 'uncategorized.md');
196
+ if (!existsSync(uncatPath)) {
197
+ writeFileSync(uncatPath, `# 未分类知识\n\n> execute/quick 执行中发现的坑暂存于此,用户审阅后归类到对应文件并更新 INDEX.md。\n`);
198
+ }
199
+
200
+ // 创建 .runtime/ 目录结构(全局状态)
201
+ const runtimeDir = join(spec, '.runtime');
202
+ for (const sub of ['artifacts', 'history', 'logs', 'templates']) {
203
+ mkdirSync(join(runtimeDir, sub), { recursive: true });
204
+ }
205
+
206
+ // 初始化 SQLite 数据库
207
+ const pm = new ProgressManager({ specDir: spec });
208
+ await pm.init(projectDir);
209
+
210
+ // .gitignore 只在 specDir 在项目内时才修改
211
+ const isExternalSpec = specDir && resolve(spec) !== resolve(projectDir, '.sillyspec');
212
+ if (!isExternalSpec) {
213
+ const gitignorePath = join(projectDir, '.gitignore');
214
+ const ignoreRules = ['.sillyspec/codebase/SCAN-RAW.md', '.sillyspec/local.yaml', '.sillyspec/.runtime/'];
215
+ if (existsSync(gitignorePath)) {
216
+ const content = readFileSync(gitignorePath, 'utf8');
217
+ let updated = content.trimEnd();
218
+ for (const rule of ignoreRules) {
219
+ if (!updated.includes(rule)) {
220
+ updated += '\n' + rule;
221
+ }
222
+ }
223
+ writeFileSync(gitignorePath, updated + '\n');
224
+ } else {
225
+ writeFileSync(gitignorePath, ignoreRules.join('\n') + '\n');
226
+ }
227
+ }
228
+
229
+ // 注入指令文件(codex/gemini/opencode)
230
+ for (let i = 0; i < tools.length; i++) {
231
+ const toolName = tools[i];
232
+ if (INSTRUCTION_TOOLS.includes(toolName)) {
233
+ injectInstructions(toolName, projectDir);
234
+ }
235
+ }
236
+
237
+ // 复制 skills 到各工具目录
238
+ const skillToolDirs = {
239
+ claude: '.claude/skills',
240
+ codex: '.codex/skills',
241
+ openclaw: '.openclaw/skills',
242
+ opencode: '.opencode/skills',
243
+ }
244
+ const skillsSource = join(__dirname, '..', '.claude', 'skills');
245
+ if (existsSync(skillsSource)) {
246
+ const sillyspecSkills = readdirSync(skillsSource).filter(f => f.startsWith('sillyspec-') && statSync(join(skillsSource, f)).isDirectory());
247
+ if (sillyspecSkills.length > 0) {
248
+ for (const [tool, dir] of Object.entries(skillToolDirs)) {
249
+ if (!tools.includes(tool)) continue
250
+ const targetDir = join(projectDir, dir)
251
+ mkdirSync(targetDir, { recursive: true })
252
+ for (const skill of sillyspecSkills) {
253
+ copyDirSync(join(skillsSource, skill), join(targetDir, skill))
254
+ }
255
+ console.log(chalk.green(` ✓ ${TOOL_LABELS[tool]} skills 已同步 (${sillyspecSkills.length} 个)`))
256
+ }
257
+ }
258
+ } else {
259
+ console.log(chalk.yellow(' ⚠ 未找到 skills 目录(npm 包内无 .claude/skills/),跳过同步'));
260
+ }
261
+ }
262
+
263
+ // ── 安装完成总结 ──
264
+
265
+ function showSummary(version, tools, specDir) {
266
+ const toolLabels = tools.map(t => TOOL_LABELS[t] || t);
267
+
268
+ console.log('');
269
+ console.log(chalk.green(' ═══════════════════════════════════════'));
270
+ console.log(chalk.green(` ✅ SillySpec v${version} 安装完成!`));
271
+ console.log(chalk.green(' ═══════════════════════════════════════'));
272
+ console.log('');
273
+ console.log(` 已安装工具: ${chalk.cyan(toolLabels.join(', '))}`);
274
+ console.log(` 📁 规范目录: ${chalk.cyan(specDir || '.sillyspec')}`);
275
+ console.log('');
276
+ console.log(' 下一步:使用 AI 技能开始工作');
277
+ console.log(' OpenClaw: ' + chalk.bold('/sillyspec:brainstorm'));
278
+ console.log(' Claude Code: ' + chalk.bold('/sillyspec:brainstorm'));
279
+ console.log('');
280
+ console.log(chalk.dim(' 💡 推荐安装 MCP 工具增强 AI 能力:sillyspec setup'));
281
+ console.log('');
282
+ }
283
+
284
+ // ── 读取版本号 ──
285
+
286
+ export function getVersion() {
287
+ try {
288
+ const pkg = JSON.parse(readFileSync(resolve(__dirname, '..', 'package.json'), 'utf8'));
289
+ return pkg.version;
290
+ } catch {
291
+ return '?.?.?';
292
+ }
293
+ }
294
+
295
+ // ── 主命令 ──
296
+
297
+ export async function cmdInit(projectDir, options = {}) {
298
+ const { tool, interactive, specDir } = options;
299
+ const version = getVersion();
300
+ const resolvedSpecDir = specDir ? resolve(specDir) : null;
301
+
302
+ // ── 交互式模式(--interactive 或 -i)──
303
+ if (interactive && isTTY()) {
304
+ // 欢迎画面
305
+ console.log('');
306
+ console.log(chalk.cyan('🤪 SillySpec v' + version + ' — 规范驱动开发'));
307
+ console.log(chalk.cyan(' ===================================='));
308
+ console.log('');
309
+ console.log(' 让 AI 像高级工程师一样工作:');
310
+ console.log(' 先思考、先规划、先验证,再写代码。');
311
+ console.log('');
312
+ console.log(chalk.gray(' 支持的 AI 工具:'));
313
+ console.log(chalk.gray(' Claude Code · Claude Skills · Cursor · Codex CLI · OpenCode · OpenClaw'));
314
+ console.log('');
315
+
316
+ // 工具多选
317
+ const detected = detectTools(projectDir);
318
+
319
+ const toolChoices = VALID_TOOLS.map(v => ({
320
+ name: `${TOOL_LABELS[v]}${v === 'claude' ? ' (推荐)' : ''}`,
321
+ value: v,
322
+ checked: detected.includes(v),
323
+ }));
324
+
325
+ const selectedTools = await checkbox({
326
+ message: '选择要安装的 AI 工具(空格选择,回车确认)',
327
+ choices: toolChoices,
328
+ validate: (answer) => answer.length > 0 || '至少选择一个工具',
329
+ });
330
+
331
+ // 子项目引导(仅交互模式)
332
+ let subprojects = [];
333
+ {
334
+ console.log('');
335
+ console.log(chalk.yellow('📋 添加子项目'));
336
+ console.log(chalk.dim(' 子项目是工作区中的独立项目目录(如 frontend/、backend/)'));
337
+ console.log('');
338
+
339
+ const addMore = await confirm({ message: '现在添加子项目?', default: true });
340
+ if (addMore) {
341
+ let suggestions = [];
342
+ try {
343
+ const entries = readdirSync(projectDir, { withFileTypes: true });
344
+ suggestions = entries
345
+ .filter(e => e.isDirectory() && !e.name.startsWith('.') && e.name !== 'node_modules')
346
+ .map(e => e.name)
347
+ .sort();
348
+ } catch {}
349
+
350
+ if (suggestions.length > 0) {
351
+ console.log('');
352
+ console.log(chalk.dim(` 检测到以下目录:${suggestions.join(', ')}`));
353
+ console.log('');
354
+ }
355
+
356
+ let adding = true;
357
+ while (adding) {
358
+ const name = await input({
359
+ message: '子项目名称(如 frontend,留空结束)',
360
+ default: suggestions.find(s => !subprojects.find(p => p.name === s)) || '',
361
+ });
362
+
363
+ if (!name.trim()) {
364
+ adding = false;
365
+ break;
366
+ }
367
+
368
+ const pathHint = suggestions.includes(name.trim()) ? `./${name.trim()}` : '';
369
+ const subPath = await input({
370
+ message: '子项目目录路径',
371
+ default: pathHint,
372
+ });
373
+
374
+ const role = await input({
375
+ message: '子项目描述(如 前端 - Vue3 + TypeScript)',
376
+ default: '',
377
+ });
378
+
379
+ let repo = '';
380
+ try {
381
+ const { execSync } = await import('child_process');
382
+ const absPath = resolve(projectDir, subPath.trim() || `./${name.trim()}`);
383
+ repo = execSync('git remote get-url origin', { cwd: absPath, encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'] }).trim();
384
+ } catch {}
385
+
386
+ subprojects.push({ name: name.trim(), path: subPath.trim() || `./${name.trim()}`, role: role.trim(), repo });
387
+
388
+ const idx = suggestions.indexOf(name.trim());
389
+ if (idx >= 0) suggestions.splice(idx, 1);
390
+
391
+ const again = await confirm({ message: '继续添加子项目?', default: subprojects.length < suggestions.length });
392
+ if (!again) adding = false;
393
+ }
394
+ }
395
+ }
396
+
397
+ console.log('');
398
+ await doInstall(projectDir, selectedTools, subprojects, resolvedSpecDir);
399
+ showSummary(version, selectedTools, resolvedSpecDir);
400
+ return;
401
+ }
402
+
403
+ // ── 默认快速模式:检测 → 安装 → 结束 ──
404
+
405
+ let tools = [];
406
+ if (tool) {
407
+ if (!VALID_TOOLS.includes(tool)) {
408
+ console.error(`❌ 未知工具: ${tool}`);
409
+ console.error(`支持的工具: ${VALID_TOOLS.join(', ')}`);
410
+ process.exit(1);
411
+ }
412
+ tools = [tool];
413
+ } else {
414
+ tools = detectTools(projectDir);
415
+ }
416
+
417
+ await doInstall(projectDir, tools, [], resolvedSpecDir);
418
+
419
+ console.log('');
420
+ console.log(chalk.green(` ✅ SillySpec v${version} 安装完成!`));
421
+ console.log('');
422
+ const specDisplay = resolvedSpecDir || '.sillyspec';
423
+ console.log(` 📁 规范目录: ${chalk.cyan(specDisplay)}`);
424
+ console.log('');
425
+ console.log(' 下一步:使用 AI 技能开始工作');
426
+ console.log(` OpenClaw: ${chalk.bold('/sillyspec:brainstorm')}`);
427
+ console.log(` Claude Code: ${chalk.bold('/sillyspec:brainstorm')}`);
428
+ console.log('');
429
+ console.log(chalk.dim(' 💡 增强能力:sillyspec setup(安装 MCP 工具)'));
430
+ console.log('');
431
+ }