sillyspec 3.20.6 → 3.21.0

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 (80) hide show
  1. package/.claude/CLAUDE.md +23 -0
  2. package/.claude/skills/sillyspec-archive/SKILL.md +86 -21
  3. package/.claude/skills/sillyspec-auto/SKILL.md +98 -83
  4. package/.claude/skills/sillyspec-brainstorm/SKILL.md +78 -44
  5. package/.claude/skills/sillyspec-doctor/SKILL.md +61 -31
  6. package/.claude/skills/sillyspec-execute/SKILL.md +90 -30
  7. package/.claude/skills/sillyspec-explore/SKILL.md +96 -109
  8. package/.claude/skills/sillyspec-export/SKILL.md +4 -0
  9. package/.claude/skills/sillyspec-init/SKILL.md +7 -0
  10. package/.claude/skills/sillyspec-plan/SKILL.md +74 -21
  11. package/.claude/skills/sillyspec-propose/SKILL.md +61 -21
  12. package/.claude/skills/sillyspec-quick/SKILL.md +84 -21
  13. package/.claude/skills/sillyspec-scan/SKILL.md +74 -21
  14. package/.claude/skills/sillyspec-state/SKILL.md +11 -1
  15. package/.claude/skills/sillyspec-status/SKILL.md +55 -21
  16. package/.claude/skills/sillyspec-verify/SKILL.md +82 -21
  17. package/.claude/skills/sillyspec-workspace/SKILL.md +12 -0
  18. package/CLAUDE.md +4 -0
  19. package/package.json +2 -2
  20. package/src/change-list.js +51 -16
  21. package/src/contract-matrix.js +67 -0
  22. package/src/doctor-diagnostics.js +575 -0
  23. package/src/hooks/worktree-guard.js +111 -111
  24. package/src/index.js +154 -82
  25. package/src/progress.js +59 -9
  26. package/src/run.js +139 -38
  27. package/src/stage-contract.js +14 -2
  28. package/src/stages/execute.js +37 -18
  29. package/src/stages/plan-postcheck.js +234 -0
  30. package/src/stages/plan.js +13 -0
  31. package/src/sync.js +13 -3
  32. package/src/worktree.js +69 -28
  33. package/docs/brainstorm-plan-contract.md +0 -64
  34. package/docs/plan-execute-contract.md +0 -123
  35. package/docs/platform-scan-protocol.md +0 -298
  36. package/docs/revision-mode.md +0 -115
  37. package/docs/sillyspec/file-lifecycle/known-implementation-gaps.md +0 -99
  38. package/docs/sillyspec/file-lifecycle/platform-workflows-sync.md +0 -223
  39. package/docs/sillyspec/file-lifecycle/stage-artifacts.md +0 -167
  40. package/docs/sillyspec/file-lifecycle/storage-and-state.md +0 -148
  41. package/docs/sillyspec/file-lifecycle/worktree-and-guard.md +0 -211
  42. package/docs/sillyspec/file-lifecycle.md +0 -132
  43. package/docs/workflow-contract-regression.md +0 -106
  44. package/docs/worktree-isolation.md +0 -252
  45. package/test/brainstorm-plan-contract.test.mjs +0 -273
  46. package/test/check-syntax.mjs +0 -26
  47. package/test/cli-top-level-aliases.test.mjs +0 -174
  48. package/test/contract-artifacts.test.mjs +0 -323
  49. package/test/decision-ref-version.mjs +0 -85
  50. package/test/decision-supersede.test.mjs +0 -277
  51. package/test/knowledge-match.test.mjs +0 -231
  52. package/test/plan-execute-contract.test.mjs +0 -357
  53. package/test/plan-optimization.test.mjs +0 -572
  54. package/test/platform-artifacts.test.mjs +0 -190
  55. package/test/platform-failure-samples.test.mjs +0 -199
  56. package/test/platform-recovery-chain.test.mjs +0 -179
  57. package/test/platform-recovery.test.mjs +0 -167
  58. package/test/platform-scan-p0.test.mjs +0 -186
  59. package/test/quick-recommend.test.mjs +0 -146
  60. package/test/revision-v1.test.mjs +0 -1145
  61. package/test/run-sanitize-project-name.test.mjs +0 -51
  62. package/test/run-scan-postcheck-fail.test.mjs +0 -64
  63. package/test/run-scan-project-parse.test.mjs +0 -200
  64. package/test/run-tests.mjs +0 -48
  65. package/test/runtime-cleanup-keeps-worktree.test.mjs +0 -107
  66. package/test/scan-docs-yaml-placeholders.test.mjs +0 -84
  67. package/test/scan-knowledge.test.mjs +0 -175
  68. package/test/scan-paths.test.mjs +0 -68
  69. package/test/scan-postcheck-project-priority.test.mjs +0 -85
  70. package/test/scan-postcheck.test.mjs +0 -197
  71. package/test/scan-workflow-anyfailed-block.test.mjs +0 -52
  72. package/test/spec-dir.test.mjs +0 -206
  73. package/test/stage-contract-failed-post-check.test.mjs +0 -102
  74. package/test/stage-contract.test.mjs +0 -301
  75. package/test/stage-definitions.test.mjs +0 -39
  76. package/test/wait-gates.test.mjs +0 -501
  77. package/test/workflow-spec-base.test.mjs +0 -142
  78. package/test/worktree-deps-provision.test.mjs +0 -148
  79. package/test/worktree-guard.test.mjs +0 -136
  80. package/test/worktree-native-overlay.test.mjs +0 -188
@@ -1,252 +0,0 @@
1
- # Worktree 隔离
2
-
3
- SillySpec 在 `execute` 和 `quick` 阶段使用 **git worktree** 隔离 AI 子代理的代码修改,确保主工作区始终干净。
4
-
5
- ## 概述
6
-
7
- AI 子代理在执行任务时会在 worktree 中修改源码,而非直接在主工作区操作。任务完成后通过 `worktree apply` 将变更合入主工作区。这带来几个好处:
8
-
9
- - **安全性** — 主工作区不受意外修改影响
10
- - **可审计** — 变更集中在一个 diff 中,便于 review
11
- - **可回退** — 不满意直接 cleanup,主工作区零影响
12
- - **多 Agent 并行** — 多个子代理可以同时工作在不同的 worktree 中
13
-
14
- ### 架构示意
15
-
16
- ```
17
- 主工作区 worktree 隔离区
18
- ┌──────────────────────┐ ┌──────────────────────────┐
19
- │ src/ │ │ .sillyspec/.runtime/ │
20
- │ (hook 禁止写入) │ │ worktrees/ │
21
- │ .sillyspec/ │ │ <change-name>/ │
22
- │ changes/ │ │ src/ (完整副本) │
23
- │ <change-name>/ │ │ node_modules/ │
24
- │ design.md │ │ ... │
25
- │ tasks.md │ │ │
26
- │ .sillyspec/.runtime/ │ │ 分支: sillyspec/<name> │
27
- │ gate-status.json │ └──────────────────────────┘
28
- │ worktrees/ │ │
29
- │ <change-name>/ │ │ sillyspec worktree apply
30
- │ meta.json │────────────────────┘
31
- └──────────────────────┘
32
- ```
33
-
34
- ## 命令参考
35
-
36
- ### `sillyspec worktree create <change-name> [--base <branch>]`
37
-
38
- 创建一个隔离的 worktree。
39
-
40
- - 基于 `--base` 分支(默认当前 HEAD)创建新分支 `sillyspec/<change-name>`
41
- - worktree 目录位于 `.sillyspec/.runtime/worktrees/<change-name>/`
42
- - 在目录内生成 `meta.json` 记录元数据(分支名、base hash、创建时间等)
43
- - 如果 worktree 已存在则报错,提示先执行 cleanup
44
-
45
- ### `sillyspec worktree apply <change-name> [--check-only]`
46
-
47
- 将 worktree 中的变更合入主工作区。
48
-
49
- - 读取 `meta.json` 中的 base hash,与主工作区比对
50
- - 从 `design.md` 解析文件变更清单,校验变更范围
51
- - `--check-only` 只输出检查结果,不实际 apply
52
- - 校验通过后生成 patch 并 3-way apply 到主工作区
53
- - apply 成功后自动清理 worktree
54
-
55
- **文件变更清单解析:** 从 `.sillyspec/changes/<change-name>/design.md` 中的 `## 文件变更清单` 表格提取。
56
-
57
- ### `sillyspec worktree list`
58
-
59
- 列出所有活跃的 worktree。
60
-
61
- 输出表格包含变更名、分支名和创建时间。
62
-
63
- ### `sillyspec worktree cleanup <change-name>`
64
-
65
- 清理指定的 worktree。
66
-
67
- - 强制移除 worktree 目录
68
- - 删除 `sillyspec/<change-name>` 分支
69
- - 删除 `meta.json`
70
-
71
- > ⚠️ cleanup 会丢弃所有未 apply 的变更,请确认后再执行。
72
-
73
- ## Hook 拦截机制
74
-
75
- SillySpec 通过 hook 在 AI 工具调用(Write/Edit/MultiEdit/Bash)前拦截非法写入。判断逻辑采用 **三重门禁**:
76
-
77
- ```
78
- allowWrite = stageGate && locationGate && fileGate
79
- ```
80
-
81
- ### 阶段门禁(stageGate)
82
-
83
- - 读取 `.sillyspec/.runtime/gate-status.json`(由 CLI 维护)
84
- - 只有 `execute` 和 `quick` 阶段允许源码写入
85
- - 其他阶段(brainstorm/plan/verify/archive/explore)→ 禁止
86
- - 无 `gate-status.json` → 禁止(默认安全)
87
-
88
- ### 位置门禁(locationGate)
89
-
90
- - 目标路径必须在 `.sillyspec/.runtime/worktrees/` 下才允许源码写入
91
- - 主工作区的源码目录一律禁止
92
-
93
- ### 文件门禁(fileGate)
94
-
95
- 文档类、配置类文件在所有阶段放行,不受阶段和位置限制:
96
-
97
- - `.sillyspec/` 开头的路径
98
- - `.md` 文件
99
- - `package.json`、`tsconfig.json`、`local.yaml` 等配置文件
100
- - `.git/` 下的文件
101
-
102
- ### Bash 命令拦截
103
-
104
- | 类型 | 示例 |
105
- |------|------|
106
- | **只读放行** | `grep`、`cat`、`git diff`、`git status`、`ls`、`find`、`sillyspec worktree apply/create/list/cleanup` |
107
- | **禁止** | `git add`、`git commit`、`git push`、`git checkout`、`rm -rf`、`sudo` 等 |
108
- | **不确定** | 启发式判断,放行但警告 |
109
-
110
- > 在 worktree 目录下执行 Bash 命令时全部放行,不做拦截。
111
-
112
- ## 降级方案和逃生开关
113
-
114
- | 场景 | 处理方式 |
115
- |------|---------|
116
- | **git < 2.15** | 不支持 worktree,报错停止 |
117
- | **`--no-worktree` 标志** | 跳过隔离创建,但 hook 仍然拦截源码写入 |
118
- | **`SILLYSPEC_DISABLE_HOOKS=1`** | 紧急禁用所有 hook,全部放行 |
119
- | **无 gate-status.json** | stageGate=false,默认禁止源码写入 |
120
- | **worktree 创建失败** | 自动降级为 in-place + baseline protection(mode: in-place-fallback) |
121
- | **已在 linked worktree** | 复用当前目录(mode: native-worktree) |
122
- | **worktree 目录未 ignore** | 阻断创建,提示修复 |
123
-
124
- > ⚠️ in-place 降级模式仍会记录 baseline(baselineFiles + baselineHash + baselineCommit),hook 拦截继续生效,不会无保护地直接写源码。
125
-
126
- ## 多 Agent 并行使用
127
-
128
- 不同的 AI 子代理可以同时创建各自的 worktree:
129
-
130
- ```bash
131
- # Agent A 处理 task-01
132
- sillyspec worktree create feature-auth
133
- # worktree: .sillyspec/.runtime/worktrees/feature-auth/
134
-
135
- # Agent B 处理 task-02
136
- sillyspec worktree create feature-ui
137
- # worktree: .sillyspec/.runtime/worktrees/feature-ui/
138
- ```
139
-
140
- 两个 Agent 在各自的 worktree 中独立工作,互不干扰。各自完成后分别 apply 合入主工作区。
141
-
142
- > 💡 如果两个 Agent 修改了相同的文件,后 apply 的一方可能遇到冲突。建议在 `plan` 阶段通过 Wave 分组避免同一文件被多个 Agent 修改。
143
-
144
- ## 环境变量
145
-
146
- | 变量 | 说明 |
147
- |------|------|
148
- | `SILLYSPEC_DISABLE_HOOKS` | 设为 `1` 时禁用所有 hook(紧急逃生) |
149
- | `SILLYSPEC_WORKTREE_DIR` | 自定义 worktree 存储目录(默认 `.sillyspec/.runtime/worktrees/`) |
150
-
151
- ## 环境隔离检测
152
-
153
- SillySpec 在创建 worktree 前会自动检测当前环境的隔离状态:
154
-
155
- ### submodule 防护
156
-
157
- 使用 `git rev-parse --git-dir` 和 `--git-common-dir` 判断是否在 linked worktree 中。
158
- 同时用 `--show-superproject-working-tree` 排除 git submodule 的误判:
159
-
160
- ```
161
- if GIT_DIR != GIT_COMMON && 无 superproject:
162
- → 已在 linked worktree,复用当前隔离环境
163
- if 无 superproject 为空:
164
- → 在 git submodule 内,阻断创建并提示
165
- else:
166
- → 在主仓库中,正常创建 worktree
167
- ```
168
-
169
- ### .gitignore 强制校验
170
-
171
- worktree 存储目录 `.sillyspec/.runtime/worktrees/` 必须被 `.gitignore` 忽略:
172
-
173
- - **init / doctor 阶段:** 预检查并提示修复
174
- - **execute 阶段:** 未 ignore 则直接阻断 worktree 创建,抛出明确错误
175
- - **不会自动修改 .gitignore:** 避免污染 baseline
176
-
177
- 修复方式:在项目 `.gitignore` 中添加:
178
- ```
179
- .sillyspec/.runtime/worktrees/
180
- ```
181
-
182
- ### isolation 状态
183
-
184
- worktree create 后,isolation 状态写入 `sillyspec.db` 的 `changes` 表(权威状态源):
185
-
186
- | 字段 | 说明 |
187
- |------|------|
188
- | `isolation_status` | pending / verified / degraded / blocked |
189
- | `isolation_mode` | worktree / native-worktree / in-place-fallback / null |
190
- | `isolation_reason` | blocked 或 degraded 时的原因说明 |
191
-
192
- 状态映射:
193
-
194
- | status | mode | 触发条件 |
195
- |--------|------|----------|
196
- | verified | worktree | `git worktree add` 成功 |
197
- | verified | native-worktree | 已在 linked worktree,复用 |
198
- | degraded | in-place-fallback | `git worktree add` 失败,降级 in-place |
199
- | blocked | null | submodule 内 / gitignore 未配置 |
200
- | null | null | 尚未执行隔离检查 |
201
-
202
- > ⚠️ isolation 的权威来源是 sillyspec.db。meta.json 中的 mode 仅作为 worktree 目录的运行时元信息。gate-status.json 不存储 isolation。
203
-
204
- ## 常见问题和故障排除
205
-
206
- ### worktree 残留无法清理
207
-
208
- ```bash
209
- # 查看所有活跃 worktree
210
- sillyspec worktree list
211
-
212
- # 强制清理指定 worktree
213
- sillyspec worktree cleanup <change-name>
214
-
215
- # 如果 worktree 目录被手动删除但分支残留
216
- git worktree prune
217
- git branch -D sillyspec/<change-name>
218
- ```
219
-
220
- ### apply 失败:base hash 不一致
221
-
222
- 说明主工作区在 worktree 创建后又被修改过。处理方式:
223
-
224
- 1. 检查主工作区的变更:`git diff`
225
- 2. 如果主工作区变更不重要 → `git stash` 后重试 apply
226
- 3. 如果重要 → 手动解决冲突
227
-
228
- ### apply 失败:文件清单校验不通过
229
-
230
- 说明 worktree 中修改了 `design.md` 清单之外的文件。处理方式:
231
-
232
- 1. 查看清单外文件:apply 的输出会列出
233
- 2. 确认是否是合理的新增(如测试文件)
234
- 3. 更新 `design.md` 中的文件变更清单后重试
235
- 4. 或用 `--check-only` 排查后再 apply
236
-
237
- ### Hook 误拦截了合法操作
238
-
239
- - 临时方案:设置 `SILLYSPEC_DISABLE_HOOKS=1` 环境变量
240
- - 检查目标文件是否应加入文件白名单(fileGate)
241
- - 检查当前阶段是否正确(gate-status.json)
242
-
243
- ### worktree 内 node_modules 问题
244
-
245
- worktree 创建后需要安装依赖:
246
-
247
- ```bash
248
- cd .sillyspec/.runtime/worktrees/<change-name>/
249
- npm install
250
- ```
251
-
252
- 如果项目使用 pnpm 且有 monorepo,可能需要额外配置。
@@ -1,273 +0,0 @@
1
- /**
2
- * Brainstorm → Plan Contract v1 测试
3
- *
4
- * 验证 design.md 到 plan 的输入契约:
5
- * 1. 合法 design 通过
6
- * 2. 缺关键章节失败
7
- * 3. warning 不阻断
8
- */
9
- import { validateDesignForPlan } from '../src/stages/plan.js'
10
-
11
- let failed = 0
12
- const failures = []
13
-
14
- function assert(condition, msg) {
15
- if (!condition) {
16
- failed++
17
- failures.push(msg)
18
- console.log(` ❌ FAIL: ${msg}`)
19
- } else {
20
- console.log(` ✅ PASS: ${msg}`)
21
- }
22
- }
23
-
24
- console.log('=== Brainstorm → Plan Contract v1 测试 ===\n')
25
-
26
- // ─────────────────────────────────────────
27
- // Case 1: valid design 通过
28
- // ─────────────────────────────────────────
29
- console.log('--- Case 1: valid design 通过 ---')
30
- {
31
- const design = `# Design: 用户认证系统
32
-
33
- ## 背景
34
- 需要实现用户认证。
35
-
36
- ## 设计目标
37
- - 支持 OAuth2
38
- - 支持手机号登录
39
-
40
- ## 非目标
41
- - 不做 SSO
42
-
43
- ## 总体方案
44
- 使用 JWT + Refresh Token。
45
-
46
- ## 决策
47
- - D-001@v1: 选择 JWT 而非 Session
48
-
49
- ## 约束
50
- - 必须兼容现有 API
51
-
52
- ## 文件变更清单
53
- | 操作 | 文件路径 | 说明 |
54
- |------|---------|------|
55
- | 新增 | src/auth.js | 认证模块 |
56
- `
57
- const result = validateDesignForPlan(design)
58
- assert(result.ok, '完整 design 应校验通过')
59
- assert(result.errors.length === 0, '不应有 errors')
60
- assert(result.warnings.length === 0, '不应有 warnings')
61
- }
62
-
63
- // ─────────────────────────────────────────
64
- // Case 2: empty design 失败
65
- // ─────────────────────────────────────────
66
- console.log('\n--- Case 2: empty design 失败 ---')
67
- {
68
- assert(!validateDesignForPlan('').ok, '空字符串应失败')
69
- assert(!validateDesignForPlan(null).ok, 'null 应失败')
70
- assert(!validateDesignForPlan(' ').ok, '纯空格应失败')
71
- }
72
-
73
- // ─────────────────────────────────────────
74
- // Case 3: missing goal 失败
75
- // ─────────────────────────────────────────
76
- console.log('\n--- Case 3: missing goal/背景 失败 ---')
77
- {
78
- const design = `# Design
79
-
80
- ## 总体方案
81
- 用 JWT。
82
-
83
- ## 决策
84
- D-001@v1: 选 JWT
85
- `
86
- const result = validateDesignForPlan(design)
87
- assert(!result.ok, '缺目标/背景应失败')
88
- assert(result.errors.some(e => e.includes('目标') || e.includes('背景')), '错误应提到目标/背景')
89
- }
90
-
91
- // ─────────────────────────────────────────
92
- // Case 4: missing scope/方案 失败
93
- // ─────────────────────────────────────────
94
- console.log('\n--- Case 4: missing scope/方案 失败 ---')
95
- {
96
- const design = `# Design
97
-
98
- ## 背景
99
- 需要认证。
100
-
101
- ## 决策
102
- D-001@v1: 选 JWT
103
- `
104
- const result = validateDesignForPlan(design)
105
- assert(!result.ok, '缺范围/方案应失败')
106
- assert(result.errors.some(e => e.includes('范围') || e.includes('方案')), '错误应提到范围/方案')
107
- }
108
-
109
- // ─────────────────────────────────────────
110
- // Case 5: missing decisions 失败
111
- // ─────────────────────────────────────────
112
- console.log('\n--- Case 5: missing decisions 失败 ---')
113
- {
114
- const design = `# Design
115
-
116
- ## 背景
117
- 需要认证。
118
-
119
- ## 总体方案
120
- 用 JWT。
121
- `
122
- const result = validateDesignForPlan(design)
123
- assert(!result.ok, '缺决策应失败')
124
- assert(result.errors.some(e => e.includes('决策')), '错误应提到决策')
125
- }
126
-
127
- // ─────────────────────────────────────────
128
- // Case 6: decisions.md 引用也算决策
129
- // ─────────────────────────────────────────
130
- console.log('\n--- Case 6: decisions.md 引用算决策 ---')
131
- {
132
- const design = `# Design
133
-
134
- ## 背景
135
- 需要认证。
136
-
137
- ## 总体方案
138
- 用 JWT。详见 decisions.md。
139
-
140
- ## 文件变更清单
141
- | 操作 | 文件 | 说明 |
142
- `
143
- const result = validateDesignForPlan(design)
144
- assert(result.ok, 'decisions.md 引用应满足决策检查')
145
- }
146
-
147
- // ─────────────────────────────────────────
148
- // Case 7: missing non-goals 只有 warning
149
- // ─────────────────────────────────────────
150
- console.log('\n--- Case 7: missing non-goals warning ---')
151
- {
152
- const design = `# Design
153
-
154
- ## 背景
155
- 需要认证。
156
-
157
- ## 总体方案
158
- 用 JWT。
159
-
160
- ## 决策
161
- D-001@v1: 选 JWT
162
-
163
- ## 约束
164
- 必须兼容现有 API。
165
- `
166
- const result = validateDesignForPlan(design)
167
- assert(result.ok, '缺非目标不应阻断')
168
- assert(result.warnings.some(w => w.includes('非目标') || w.includes('Non-goals')), '应有非目标 warning')
169
- }
170
-
171
- // ─────────────────────────────────────────
172
- // Case 8: missing constraints 只有 warning
173
- // ─────────────────────────────────────────
174
- console.log('\n--- Case 8: missing constraints warning ---')
175
- {
176
- const design = `# Design
177
-
178
- ## 目标
179
- 实现认证。
180
-
181
- ## 设计方案
182
- 用 JWT。
183
-
184
- ## 决策
185
- 选择 JWT。
186
-
187
- ## 非目标
188
- 不做 SSO。
189
- `
190
- const result = validateDesignForPlan(design)
191
- assert(result.ok, '缺约束不应阻断')
192
- assert(result.warnings.some(w => w.includes('约束') || w.includes('风险') || w.includes('Trade-off')), '应有约束/风险 warning')
193
- }
194
-
195
- // ─────────────────────────────────────────
196
- // Case 9: missing 文件变更清单 warning
197
- // ─────────────────────────────────────────
198
- console.log('\n--- Case 9: missing 文件变更清单 warning ---')
199
- {
200
- const design = `# Design
201
-
202
- ## 背景
203
- 需要认证。
204
-
205
- ## 总体方案
206
- 用 JWT。
207
-
208
- ## 决策
209
- D-001@v1: 选 JWT
210
- `
211
- const result = validateDesignForPlan(design)
212
- assert(result.ok, '缺文件变更清单不应阻断')
213
- assert(result.warnings.some(w => w.includes('文件变更')), '应有文件变更 warning')
214
- }
215
-
216
- // ─────────────────────────────────────────
217
- // Case 10: 英文 design 通过
218
- // ─────────────────────────────────────────
219
- console.log('\n--- Case 10: 英文 design 通过 ---')
220
- {
221
- const design = `# Design: Auth System
222
-
223
- ## Background
224
- We need authentication.
225
-
226
- ## Solution
227
- Use JWT + Refresh Token.
228
-
229
- ## Decision
230
- D-001@v1: Choose JWT over Session
231
-
232
- ## Non-goals
233
- No SSO.
234
-
235
- ## Constraints
236
- Must be backwards compatible.
237
- `
238
- const result = validateDesignForPlan(design)
239
- assert(result.ok, '英文 design 应校验通过')
240
- assert(result.errors.length === 0, '不应有 errors')
241
- }
242
-
243
- // ─────────────────────────────────────────
244
- // Case 11: 最小合法 design
245
- // ─────────────────────────────────────────
246
- console.log('\n--- Case 11: 最小合法 design ---')
247
- {
248
- const design = `# Design
249
-
250
- ## 目标
251
- 修 bug。
252
-
253
- ## 方案
254
- 改代码。
255
-
256
- ## 决策
257
- D-001@v1: 直接改。
258
- `
259
- const result = validateDesignForPlan(design)
260
- assert(result.ok, '最小合法 design 应通过')
261
- // 可能有 warning 但 ok
262
- }
263
-
264
- // ── 结果 ──
265
- console.log(`\n${'='.repeat(50)}`)
266
- console.log(`✅ 通过: ${11 - failed} ❌ 失败: ${failed}`)
267
- if (failures.length > 0) {
268
- console.log(`失败项:`)
269
- failures.forEach(f => console.log(` - ${f}`))
270
- }
271
- console.log(`${'='.repeat(50)}`)
272
-
273
- if (failed > 0) process.exit(1)
@@ -1,26 +0,0 @@
1
- import { execFileSync } from 'node:child_process'
2
- import { readdirSync, statSync } from 'node:fs'
3
- import { join } from 'node:path'
4
-
5
- const roots = ['src']
6
- const files = []
7
-
8
- function walk(dir) {
9
- for (const entry of readdirSync(dir)) {
10
- const full = join(dir, entry)
11
- const st = statSync(full)
12
- if (st.isDirectory()) {
13
- walk(full)
14
- continue
15
- }
16
- if (/\.(js|cjs|mjs)$/.test(entry)) files.push(full)
17
- }
18
- }
19
-
20
- for (const root of roots) walk(root)
21
-
22
- for (const file of files.sort()) {
23
- execFileSync(process.execPath, ['--check', file], { stdio: 'inherit' })
24
- }
25
-
26
- console.log(`Checked ${files.length} JavaScript files`)