sillyspec 3.20.2 → 3.20.3

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 (208) hide show
  1. package/.claude/skills/sillyspec-archive/SKILL.md +1 -5
  2. package/.claude/skills/sillyspec-auto/SKILL.md +2 -8
  3. package/.claude/skills/sillyspec-brainstorm/SKILL.md +1 -28
  4. package/.claude/skills/sillyspec-commit/SKILL.md +3 -4
  5. package/.claude/skills/sillyspec-continue/SKILL.md +4 -5
  6. package/.claude/skills/sillyspec-doctor/SKILL.md +3 -12
  7. package/.claude/skills/sillyspec-execute/SKILL.md +2 -15
  8. package/.claude/skills/sillyspec-explore/SKILL.md +1 -14
  9. package/.claude/skills/sillyspec-plan/SKILL.md +36 -5
  10. package/.claude/skills/sillyspec-propose/SKILL.md +0 -4
  11. package/.claude/skills/sillyspec-quick/SKILL.md +1 -5
  12. package/.claude/skills/sillyspec-resume/SKILL.md +66 -23
  13. package/.claude/skills/sillyspec-scan/SKILL.md +1 -5
  14. package/.claude/skills/sillyspec-state/SKILL.md +8 -8
  15. package/.claude/skills/sillyspec-status/SKILL.md +1 -5
  16. package/.claude/skills/sillyspec-verify/SKILL.md +1 -5
  17. package/.claude/skills/sillyspec-workspace/SKILL.md +3 -11
  18. package/.sillyspec/changes/archive/2026-04-08-derive-state/design.md +97 -0
  19. package/.sillyspec/changes/archive/2026-04-08-derive-state/plan.md +51 -0
  20. package/.sillyspec/changes/archive/2026-04-08-derive-state/proposal.md +29 -0
  21. package/.sillyspec/changes/archive/2026-04-08-derive-state/requirements.md +34 -0
  22. package/.sillyspec/changes/archive/2026-04-08-derive-state/tasks.md +13 -0
  23. package/.sillyspec/changes/archive/2026-04-08-derive-state/verify-result.md +43 -0
  24. package/.sillyspec/changes/auto-mode/design.md +50 -0
  25. package/.sillyspec/changes/auto-mode/proposal.md +19 -0
  26. package/.sillyspec/changes/auto-mode/requirements.md +21 -0
  27. package/.sillyspec/changes/auto-mode/tasks.md +7 -0
  28. package/.sillyspec/changes/brainstorm-archive/2026-04-05-dashboard-design.md +206 -0
  29. package/.sillyspec/changes/brainstorm-archive/2026-04-05-unified-docs-design.md +199 -0
  30. package/.sillyspec/changes/dashboard/design.md +219 -0
  31. package/.sillyspec/changes/dashboard/design.md.braindraft +206 -0
  32. package/.sillyspec/changes/run-command-design/design.md +1230 -0
  33. package/.sillyspec/changes/unified-docs-design/design.md +199 -0
  34. package/.sillyspec/docs/sillyspec/scan/.gitkeep +0 -0
  35. package/.sillyspec/knowledge/INDEX.md +8 -0
  36. package/.sillyspec/knowledge/uncategorized.md +3 -0
  37. package/.sillyspec/plans/2026-04-05-dashboard.md +737 -0
  38. package/.sillyspec/projects/sillyspec.yaml +3 -0
  39. package/README.md +11 -13
  40. package/SKILL.md +40 -44
  41. package/dist/steps/brainstorm/01-load-context.md +30 -0
  42. package/dist/steps/brainstorm/02-reuse-check.md +6 -0
  43. package/dist/steps/brainstorm/03-prototype-analysis.md +11 -0
  44. package/dist/steps/brainstorm/04-module-split.md +23 -0
  45. package/dist/steps/brainstorm/05-dialog-explore.md +8 -0
  46. package/dist/steps/brainstorm/06-propose-approaches.md +3 -0
  47. package/dist/steps/brainstorm/07-present-design.md +3 -0
  48. package/dist/steps/brainstorm/08-write-design.md +21 -0
  49. package/dist/steps/brainstorm/09-self-review.md +15 -0
  50. package/dist/steps/brainstorm/10-user-confirm.md +3 -0
  51. package/dist/steps/brainstorm/11-output-spec.md +7 -0
  52. package/dist/steps/brainstorm/manifest.yaml +26 -0
  53. package/dist/steps/execute/01-load-context.md +41 -0
  54. package/dist/steps/execute/02-scan-conventions.md +47 -0
  55. package/dist/steps/execute/03-skill-mcp.md +19 -0
  56. package/dist/steps/execute/04-assign-task.md +22 -0
  57. package/dist/steps/execute/04b-prompt-template.md +54 -0
  58. package/dist/steps/execute/05-write-test.md +7 -0
  59. package/dist/steps/execute/06-write-code.md +8 -0
  60. package/dist/steps/execute/07-run-test.md +26 -0
  61. package/dist/steps/execute/08-fix-issues.md +28 -0
  62. package/dist/steps/execute/09-next-task.md +33 -0
  63. package/dist/steps/execute/manifest.yaml +28 -0
  64. package/dist/steps/plan/01-load-context.md +22 -0
  65. package/dist/steps/plan/02-anchor-confirm.md +1 -0
  66. package/dist/steps/plan/03-expand-tasks.md +33 -0
  67. package/dist/steps/plan/04-mark-order.md +15 -0
  68. package/dist/steps/plan/05-e2e-planning.md +17 -0
  69. package/dist/steps/plan/06-self-check.md +16 -0
  70. package/dist/steps/plan/07-save.md +1 -0
  71. package/dist/steps/plan/manifest.yaml +18 -0
  72. package/dist/steps/scan/01-env-detect.md +51 -0
  73. package/dist/steps/scan/02-tech-stack.md +16 -0
  74. package/dist/steps/scan/03-conventions.md +16 -0
  75. package/dist/steps/scan/04-structure.md +19 -0
  76. package/dist/steps/scan/05-quality.md +18 -0
  77. package/dist/steps/scan/06-complete.md +49 -0
  78. package/dist/steps/scan/manifest.yaml +16 -0
  79. package/dist/steps/verify/01-load-specs.md +28 -0
  80. package/dist/steps/verify/02-check-tasks.md +1 -0
  81. package/dist/steps/verify/03-check-design.md +6 -0
  82. package/dist/steps/verify/04-run-tests.md +7 -0
  83. package/dist/steps/verify/05-e2e-tests.md +27 -0
  84. package/dist/steps/verify/05b-e2e-fix.md +33 -0
  85. package/dist/steps/verify/06-code-quality.md +25 -0
  86. package/dist/steps/verify/07-lint-check.md +27 -0
  87. package/dist/steps/verify/08-output-report.md +14 -0
  88. package/dist/steps/verify/manifest.yaml +22 -0
  89. package/package.json +1 -7
  90. package/packages/dashboard/dist/assets/{index-Bq_Z2hne.js → index-D1EVTLmc.js} +1264 -1264
  91. package/packages/dashboard/dist/assets/index-DGe8CqeP.css +1 -0
  92. package/packages/dashboard/dist/index.html +2 -2
  93. package/packages/dashboard/package-lock.json +6 -6
  94. package/packages/dashboard/server/executor.js +1 -1
  95. package/packages/dashboard/server/index.js +18 -98
  96. package/packages/dashboard/server/parser.js +71 -139
  97. package/packages/dashboard/server/watcher.js +6 -14
  98. package/packages/dashboard/src/App.vue +185 -418
  99. package/packages/dashboard/src/components/ActionBar.vue +1 -10
  100. package/packages/dashboard/src/components/CommandPalette.vue +1 -5
  101. package/packages/dashboard/src/components/DocPreview.vue +8 -105
  102. package/packages/dashboard/src/components/DocTree.vue +19 -75
  103. package/packages/dashboard/src/components/PipelineStage.vue +2 -22
  104. package/packages/dashboard/src/components/PipelineView.vue +5 -32
  105. package/packages/dashboard/src/components/ProjectOverview.vue +139 -113
  106. package/packages/dashboard/src/components/StageBadge.vue +3 -17
  107. package/packages/dashboard/src/components/StepCard.vue +2 -7
  108. package/packages/dashboard/src/composables/useDashboard.js +0 -28
  109. package/src/derive.js +147 -0
  110. package/src/index.js +40 -688
  111. package/src/init.js +63 -119
  112. package/src/migrate.js +7 -7
  113. package/src/progress.js +248 -1474
  114. package/src/run.js +302 -3008
  115. package/src/setup.js +64 -2
  116. package/src/stages/archive.js +17 -123
  117. package/src/stages/brainstorm.js +48 -454
  118. package/src/stages/doctor.js +46 -99
  119. package/src/stages/execute.js +59 -420
  120. package/src/stages/index.js +18 -12
  121. package/src/stages/plan.js +189 -492
  122. package/src/stages/propose.js +11 -70
  123. package/src/stages/quick.js +13 -52
  124. package/src/stages/scan.js +68 -485
  125. package/src/stages/status.js +1 -1
  126. package/src/stages/verify.js +16 -203
  127. package/src/step.js +543 -0
  128. package/.claude/skills/sillyspec-knowledge/SKILL.md +0 -270
  129. package/.husky/pre-push +0 -13
  130. package/CLAUDE.md +0 -18
  131. package/docs/brainstorm-plan-contract.md +0 -64
  132. package/docs/plan-execute-contract.md +0 -123
  133. package/docs/platform-scan-protocol.md +0 -298
  134. package/docs/revision-mode.md +0 -115
  135. package/docs/sillyspec/file-lifecycle/known-implementation-gaps.md +0 -99
  136. package/docs/sillyspec/file-lifecycle/platform-workflows-sync.md +0 -218
  137. package/docs/sillyspec/file-lifecycle/stage-artifacts.md +0 -167
  138. package/docs/sillyspec/file-lifecycle/storage-and-state.md +0 -148
  139. package/docs/sillyspec/file-lifecycle/worktree-and-guard.md +0 -193
  140. package/docs/sillyspec/file-lifecycle.md +0 -125
  141. package/docs/workflow-contract-regression.md +0 -106
  142. package/docs/worktree-isolation.md +0 -252
  143. package/packages/dashboard/dist/assets/index-O2W5RV4z.css +0 -1
  144. package/packages/dashboard/dist/prototype-dashboard.html +0 -836
  145. package/packages/dashboard/dist/prototype-overview.html +0 -256
  146. package/packages/dashboard/public/prototype-dashboard.html +0 -836
  147. package/packages/dashboard/public/prototype-overview.html +0 -256
  148. package/packages/dashboard/src/components/HResizeHandle.vue +0 -48
  149. package/packages/dashboard/src/components/ProjectCard.vue +0 -187
  150. package/packages/dashboard/src/components/VResizeHandle.vue +0 -61
  151. package/packages/dashboard/src/composables/useLayout.js +0 -131
  152. package/src/brainstorm-postcheck.js +0 -158
  153. package/src/change-list.js +0 -52
  154. package/src/change-risk-profile.js +0 -352
  155. package/src/classify-change.js +0 -73
  156. package/src/constants.js +0 -70
  157. package/src/contract-matrix.js +0 -278
  158. package/src/db.js +0 -201
  159. package/src/endpoint-extractor.js +0 -315
  160. package/src/hooks/claude-pre-tool-use.cjs +0 -125
  161. package/src/hooks/worktree-guard.js +0 -761
  162. package/src/knowledge-match.js +0 -130
  163. package/src/modules.js +0 -482
  164. package/src/scan-postcheck.js +0 -383
  165. package/src/stage-contract.js +0 -700
  166. package/src/stages/brainstorm-auto.js +0 -229
  167. package/src/stages/explore.js +0 -34
  168. package/src/stages/knowledge.js +0 -498
  169. package/src/stages/plan-postcheck.js +0 -513
  170. package/src/sync.js +0 -497
  171. package/src/task-review.js +0 -346
  172. package/src/workflow.js +0 -785
  173. package/src/worktree-apply.js +0 -549
  174. package/src/worktree.js +0 -932
  175. package/templates/workflows/archive-impact.yaml +0 -79
  176. package/templates/workflows/scan-docs.yaml +0 -132
  177. package/test/brainstorm-plan-contract.test.mjs +0 -273
  178. package/test/check-syntax.mjs +0 -26
  179. package/test/cli-top-level-aliases.test.mjs +0 -174
  180. package/test/contract-artifacts.test.mjs +0 -323
  181. package/test/decision-supersede.test.mjs +0 -277
  182. package/test/knowledge-match.test.mjs +0 -231
  183. package/test/plan-execute-contract.test.mjs +0 -330
  184. package/test/plan-optimization.test.mjs +0 -572
  185. package/test/platform-artifacts.test.mjs +0 -190
  186. package/test/platform-failure-samples.test.mjs +0 -199
  187. package/test/platform-recovery-chain.test.mjs +0 -179
  188. package/test/platform-recovery.test.mjs +0 -167
  189. package/test/platform-scan-p0.test.mjs +0 -175
  190. package/test/revision-v1.test.mjs +0 -1145
  191. package/test/run-sanitize-project-name.test.mjs +0 -51
  192. package/test/run-scan-postcheck-fail.test.mjs +0 -64
  193. package/test/run-scan-project-parse.test.mjs +0 -200
  194. package/test/run-tests.mjs +0 -48
  195. package/test/scan-docs-yaml-placeholders.test.mjs +0 -84
  196. package/test/scan-knowledge.test.mjs +0 -175
  197. package/test/scan-paths.test.mjs +0 -68
  198. package/test/scan-postcheck-project-priority.test.mjs +0 -85
  199. package/test/scan-postcheck.test.mjs +0 -197
  200. package/test/scan-workflow-anyfailed-block.test.mjs +0 -52
  201. package/test/spec-dir.test.mjs +0 -206
  202. package/test/stage-contract-failed-post-check.test.mjs +0 -102
  203. package/test/stage-contract.test.mjs +0 -299
  204. package/test/stage-definitions.test.mjs +0 -39
  205. package/test/wait-gates.test.mjs +0 -501
  206. package/test/workflow-spec-base.test.mjs +0 -142
  207. package/test/worktree-guard.test.mjs +0 -136
  208. package/test/worktree-native-overlay.test.mjs +0 -188
@@ -1,102 +0,0 @@
1
- /**
2
- * task-07: checkTransition failed_post_check 门控
3
- *
4
- * 覆盖:
5
- * - AC-1: scan → brainstorm (failed_post_check) → allowed=false, reason 含"scan post-check 未通过"
6
- * - AC-2: scan → scan (重跑修复) → allowed=true
7
- * - AC-3: scan → doctor/status (辅助阶段) → allowed=true
8
- * - AC-4: 旧数据无 status 字段 → 行为同旧版(按 allowedFrom)
9
- * - AC-5: status='completed' 不被拦
10
- */
11
- import { checkTransition } from '../src/stage-contract.js'
12
-
13
- let passed = 0
14
- let failed = 0
15
- function assertEqual (actual, expected, msg) {
16
- const ok = actual === expected
17
- if (ok) { console.log(`✅ PASS: ${msg}`); passed++ }
18
- else { console.error(`❌ FAIL: ${msg}\n expected: ${JSON.stringify(expected)}\n actual: ${JSON.stringify(actual)}`); failed++ }
19
- }
20
- function assertMatch (actual, regex, msg) {
21
- if (regex.test(actual)) { console.log(`✅ PASS: ${msg}`); passed++ }
22
- else { console.error(`❌ FAIL: ${msg}\n actual: ${JSON.stringify(actual)} 不匹配 ${regex}`); failed++ }
23
- }
24
- function assert (cond, msg) {
25
- if (cond) { console.log(`✅ PASS: ${msg}`); passed++ }
26
- else { console.error(`❌ FAIL: ${msg}`); failed++ }
27
- }
28
-
29
- console.log('=== AC-1: failed_post_check 状态下进 brainstorm/plan/execute 被拦 ===')
30
-
31
- // scan → brainstorm, failed_post_check
32
- {
33
- const r = checkTransition('scan', 'brainstorm', { fromStageData: { status: 'failed_post_check' } })
34
- assertEqual(r.allowed, false, "scan→brainstorm failed_post_check: allowed=false")
35
- assertMatch(r.reason || '', /scan post-check 未通过/, 'reason 含 "scan post-check 未通过"')
36
- assertMatch(r.reason || '', /重跑\s*scan|重跑\s*scan/, 'reason 含 "重跑 scan" 提示')
37
- }
38
-
39
- // scan → plan / execute 同样被拦
40
- {
41
- const r1 = checkTransition('scan', 'plan', { fromStageData: { status: 'failed_post_check' } })
42
- assertEqual(r1.allowed, false, "scan→plan failed_post_check: allowed=false")
43
- const r2 = checkTransition('scan', 'execute', { fromStageData: { status: 'failed_post_check' } })
44
- assertEqual(r2.allowed, false, "scan→execute failed_post_check: allowed=false")
45
- }
46
-
47
- console.log('\n=== AC-2: 允许 scan → scan 重跑修复(fromStage===toStage) ===')
48
- {
49
- const r = checkTransition('scan', 'scan', { fromStageData: { status: 'failed_post_check' } })
50
- assertEqual(r.allowed, true, "scan→scan failed_post_check: allowed=true(允许重跑修复)")
51
- }
52
-
53
- console.log('\n=== AC-3: failed_post_check 下辅助阶段(doctor/status)仍可执行 ===')
54
- {
55
- const r1 = checkTransition('scan', 'doctor', { fromStageData: { status: 'failed_post_check' } })
56
- assertEqual(r1.allowed, true, "scan→doctor failed_post_check: allowed=true(辅助阶段)")
57
- const r2 = checkTransition('scan', 'status', { fromStageData: { status: 'failed_post_check' } })
58
- assertEqual(r2.allowed, true, "scan→status failed_post_check: allowed=true(辅助阶段)")
59
- const r3 = checkTransition('scan', 'quick', { fromStageData: { status: 'failed_post_check' } })
60
- assertEqual(r3.allowed, true, "scan→quick failed_post_check: allowed=true(辅助阶段)")
61
- const r4 = checkTransition('scan', 'explore', { fromStageData: { status: 'failed_post_check' } })
62
- assertEqual(r4.allowed, true, "scan→explore failed_post_check: allowed=true(辅助阶段)")
63
- }
64
-
65
- console.log('\n=== AC-4: 旧数据兼容(无 options 或 status 缺失,行为同旧版) ===')
66
- {
67
- // 无 options(旧调用)— scan→brainstorm 按 allowedFrom 规则允许(scan 是辅助阶段,可进主流程)
68
- const r1 = checkTransition('scan', 'brainstorm')
69
- assertEqual(r1.allowed, true, "scan→brainstorm 无 options: 行为同旧版(allowed=true)")
70
-
71
- // options 提供 fromStageData 但 status 为 undefined
72
- const r2 = checkTransition('scan', 'brainstorm', { fromStageData: { /* 无 status */ } })
73
- assertEqual(r2.allowed, true, "scan→brainstorm status=undefined: 行为同旧版(allowed=true)")
74
-
75
- // options 为空对象
76
- const r3 = checkTransition('scan', 'brainstorm', {})
77
- assertEqual(r3.allowed, true, "scan→brainstorm options={}: 行为同旧版(allowed=true)")
78
- }
79
-
80
- console.log('\n=== AC-5: status="completed" 不被门控拦截 ===')
81
- {
82
- const r = checkTransition('scan', 'brainstorm', { fromStageData: { status: 'completed' } })
83
- assertEqual(r.allowed, true, "scan→brainstorm status=completed: allowed=true")
84
- }
85
-
86
- console.log('\n=== AC-6: fromStage 非 scan 时门控不触发(门控只针对 scan 源) ===')
87
- {
88
- const r = checkTransition('brainstorm', 'plan', { fromStageData: { status: 'failed_post_check' } })
89
- assertEqual(r.allowed, true, "brainstorm→plan failed_post_check: 门控不触发(非 scan 源)")
90
- }
91
-
92
- console.log('\n=== 接口向后兼容:options 第 3 位可选 ===')
93
- {
94
- // 仅 2 参调用(最常见旧用法)
95
- const r = checkTransition('brainstorm', 'plan')
96
- assert(r && typeof r.allowed === 'boolean', '2 参调用返回 { allowed: boolean }')
97
- }
98
-
99
- console.log(`\n${'='.repeat(50)}`)
100
- console.log(`✅ 通过: ${passed} ❌ 失败: ${failed}`)
101
- console.log(`${'='.repeat(50)}`)
102
- if (failed > 0) process.exit(1)
@@ -1,299 +0,0 @@
1
- /**
2
- * StageContract 状态转换 + validator 测试
3
- */
4
- import { checkTransition, runValidators, getContract } from '../src/stage-contract.js'
5
-
6
- let failed = 0
7
-
8
- // === 状态转换测试 ===
9
- const transitionTests = [
10
- // [from, to, expectedAllowed]
11
- // 主流程正常顺序
12
- ['', 'brainstorm', true],
13
- ['brainstorm', 'plan', true],
14
- ['plan', 'execute', true],
15
- ['execute', 'verify', true],
16
- ['verify', 'archive', true],
17
-
18
- // 跳步应被拦截
19
- ['', 'plan', false],
20
- ['', 'execute', false],
21
- ['brainstorm', 'execute', false],
22
- ['plan', 'verify', false],
23
- ['execute', 'archive', false],
24
-
25
- // 回退应被拦截
26
- ['plan', 'brainstorm', false],
27
- ['execute', 'plan', false],
28
- ['verify', 'execute', false],
29
-
30
- // 辅助阶段随时可执行
31
- ['', 'scan', true],
32
- ['', 'quick', true],
33
- ['', 'explore', true],
34
- ['', 'doctor', true],
35
- ['', 'archive', true],
36
- ['brainstorm', 'scan', true],
37
- ['plan', 'quick', true],
38
- ['execute', 'doctor', true],
39
-
40
- // 从辅助阶段进入主流程允许
41
- ['scan', 'plan', true],
42
- ['scan', 'brainstorm', true],
43
- ['quick', 'plan', true],
44
- ['doctor', 'brainstorm', true],
45
-
46
- // archive 特殊:verify 后允许,其他主流程不允许直接跳
47
- ['verify', 'archive', true],
48
- ['execute', 'archive', false],
49
- ['plan', 'archive', false],
50
- ]
51
-
52
- console.log('=== 状态转换测试 ===')
53
- for (const [from, to, expected] of transitionTests) {
54
- const r = checkTransition(from, to)
55
- const ok = r.allowed === expected
56
- if (!ok) failed++
57
- console.log(ok ? '✅' : '❌', `${from || '(起始)'} → ${to}: allowed=${r.allowed} (exp ${expected})${ok ? '' : ' reason: ' + r.reason}`)
58
- }
59
-
60
- // === Validator 测试 ===
61
- console.log('\n=== Validator 测试 ===')
62
-
63
- // plan validator:plan.md 不存在应报错
64
- const planResult = runValidators('plan', '.', 'nonexistent-change')
65
- if (planResult.ok === false && planResult.errors.length > 0) {
66
- console.log('✅ plan validator 检测到缺失 plan.md')
67
- } else {
68
- console.log('❌ plan validator 未检测到缺失 plan.md')
69
- failed++
70
- }
71
-
72
- // verify validator:变更目录不存在应报错
73
- const verifyResult = runValidators('verify', '.', 'nonexistent-change')
74
- if (verifyResult.ok === false && verifyResult.errors.length > 0) {
75
- console.log('✅ verify validator 检测到缺失变更目录')
76
- } else {
77
- console.log('❌ verify validator 未检测到缺失变更目录')
78
- failed++
79
- }
80
-
81
- // scan validator:文档目录不存在应报错
82
- const scanResult = runValidators('scan', join(tmpdir(), 'nonexistent-project'), 'test', { projectName: 'test' })
83
- if (scanResult.ok === false && scanResult.errors.length > 0) {
84
- console.log('✅ scan validator 检测到缺失 scan 文档')
85
- } else {
86
- console.log('❌ scan validator 未检测到缺失 scan 文档')
87
- failed++
88
- }
89
-
90
- // brainstorm 有 validator,但变更目录不存在时应该报错(因为产物不存在)
91
- const brainstormResult = runValidators('brainstorm', '.', 'test')
92
- if (brainstormResult.ok === false && brainstormResult.errors.length > 0) {
93
- console.log('✅ brainstorm validator 检测到缺失产物文件')
94
- } else {
95
- console.log('❌ brainstorm validator 未检测到缺失产物')
96
- failed++
97
- }
98
-
99
- // === scan validator 平台模式 specRoot 测试 ===
100
- console.log('\n=== scan validator specRoot 测试 ===')
101
-
102
- import { mkdtempSync, mkdirSync, writeFileSync, rmSync } from 'fs'
103
- import { join } from 'path'
104
- import { tmpdir } from 'os'
105
-
106
- // 创建临时 specRoot 结构
107
- const specRoot = mkdtempSync(join(tmpdir(), 'sillyspec-test-'))
108
- const sourceRoot = mkdtempSync(join(tmpdir(), 'sillyspec-source-'))
109
- const projectName = 'myaaa'
110
-
111
- // specRoot 在实际代码中等价于 .sillyspec 目录本身(run.js: join(specRoot, 'docs', ...))
112
- // 所以 scan 文档路径为 specRoot/docs/<project>/scan/,不需要额外的 .sillyspec/ 前缀
113
- const specDocsDir = join(specRoot, 'docs', projectName, 'scan')
114
- mkdirSync(specDocsDir, { recursive: true })
115
- for (const doc of ['ARCHITECTURE.md', 'CONVENTIONS.md', 'STRUCTURE.md', 'INTEGRATIONS.md', 'TESTING.md', 'CONCERNS.md', 'PROJECT.md']) {
116
- writeFileSync(join(specDocsDir, doc), '# ' + doc)
117
- }
118
- mkdirSync(join(specRoot, 'docs', projectName, 'modules'), { recursive: true })
119
- writeFileSync(join(specRoot, 'docs', projectName, 'modules', 'app.md'), '# app')
120
-
121
- // 测试1:使用 specRoot 校验成功
122
- const specResult = runValidators('scan', sourceRoot, 'test', { projectName, specRoot })
123
- if (specResult.ok === true) {
124
- console.log('✅ scan validator 使用 specRoot 校验通过')
125
- } else {
126
- console.log('❌ scan validator specRoot 校验失败:', specResult.errors)
127
- failed++
128
- }
129
-
130
- // 测试2:使用 sourceRoot 校验(不传 specRoot)应失败
131
- const localResult = runValidators('scan', sourceRoot, 'test', { projectName })
132
- if (localResult.ok === false && localResult.errors.length > 0) {
133
- console.log('✅ scan validator 使用 sourceRoot 校验正确失败(文档不在 source_root 下)')
134
- } else {
135
- console.log('❌ scan validator sourceRoot 校验未正确失败')
136
- failed++
137
- }
138
-
139
- // 测试3:校验路径指向 specRoot 而非 sourceRoot
140
- const errors1 = localResult.errors.join(' ')
141
- const errors2 = specResult.errors.join(' ')
142
- if (errors1.includes(sourceRoot) || errors1.includes(join(sourceRoot, '.sillyspec'))) {
143
- console.log('✅ 未传 specRoot 时校验路径指向 source_root')
144
- } else {
145
- console.log('✅ 未传 specRoot 时校验失败(文档确实不在 source_root 下)')
146
- }
147
- if (!errors2.includes(specRoot)) {
148
- console.log('✅ 传 specRoot 时校验路径指向 specRoot(无错误=不包含路径)')
149
- } else {
150
- console.log('✅ 传 specRoot 时校验路径正确')
151
- }
152
-
153
- // 清理临时目录
154
- rmSync(specRoot, { recursive: true })
155
- rmSync(sourceRoot, { recursive: true })
156
-
157
- // === decisions.md traceability validator 测试 ===
158
- console.log('\n=== decisions traceability validator 测试 ===')
159
-
160
- const traceRoot = mkdtempSync(join(tmpdir(), 'sillyspec-trace-'))
161
- const traceDir = join(traceRoot, '.sillyspec', 'changes', 'trace')
162
- mkdirSync(traceDir, { recursive: true })
163
- writeFileSync(join(traceDir, 'proposal.md'), '# Proposal\n\n## 不在范围内\n- none\n')
164
- writeFileSync(join(traceDir, 'design.md'), '# Design\n\n## 文件变更清单\n\n## 风险登记\n\n## 自审\n\nD-001@v1\n')
165
- writeFileSync(join(traceDir, 'decisions.md'), '# Decisions\n\n## D-001@v1: Choose canonical account term\n- priority: P1\n- status: accepted\n')
166
- writeFileSync(join(traceDir, 'requirements.md'), '# Requirements\n\n### FR-01: Account naming\nGiven x\nWhen y\nThen z\n')
167
- writeFileSync(join(traceDir, 'tasks.md'), '- [ ] task-01: implement naming (D-001@v1)\n')
168
-
169
- const brainstormTrace = runValidators('brainstorm', traceRoot, 'trace')
170
- if (brainstormTrace.ok === true && brainstormTrace.warnings.some(w => w.includes('requirements.md 未引用') && w.includes('D-001@V1'))) {
171
- console.log('✅ brainstorm validator 检测到 requirements.md 缺少 D-001@v1 引用')
172
- } else {
173
- console.log('❌ brainstorm validator 未检测到 requirements.md 缺少 D-001@v1 引用', brainstormTrace)
174
- failed++
175
- }
176
-
177
- writeFileSync(join(traceDir, 'requirements.md'), '# Requirements\n\n### FR-01: Account naming\n覆盖决策:D-001@v1\nGiven x\nWhen y\nThen z\n')
178
- writeFileSync(join(traceDir, 'plan.md'), '# Plan\n\n- [ ] task-01: implement naming\n')
179
-
180
- const planTrace = runValidators('plan', traceRoot, 'trace')
181
- if (planTrace.ok === true
182
- && planTrace.warnings.some(w => w.includes('plan.md 未引用') && w.includes('FR-01'))
183
- && planTrace.warnings.some(w => w.includes('plan.md 未引用') && w.includes('D-001@V1'))) {
184
- console.log('✅ plan validator 检测到 plan.md 缺少 FR-01/D-001@v1 引用')
185
- } else {
186
- console.log('❌ plan validator 未检测到 plan.md 缺少追踪 ID', planTrace)
187
- failed++
188
- }
189
-
190
- writeFileSync(join(traceDir, 'plan.md'), '# Plan\n\n- [ ] task-01: implement naming(覆盖:FR-01, D-001@v1)\n')
191
- writeFileSync(join(traceDir, 'verify-result.md'), '# Verify\n\nPASS\n')
192
-
193
- const verifyTrace = runValidators('verify', traceRoot, 'trace')
194
- if (verifyTrace.ok === true && verifyTrace.warnings.some(w => w.includes('verify-result.md 未引用') && w.includes('D-001@V1'))) {
195
- console.log('✅ verify validator 检测到 verify-result.md 缺少 D-001@v1 引用')
196
- } else {
197
- console.log('❌ verify validator 未检测到 verify-result.md 缺少 D-001@v1 引用', verifyTrace)
198
- failed++
199
- }
200
-
201
- writeFileSync(join(traceDir, 'verify-result.md'), '# Verify\n\n## 决策追踪矩阵\n| D-001@v1 | FR-01 | task-01 | evidence | PASS |\n')
202
- const verifyTraceOk = runValidators('verify', traceRoot, 'trace')
203
- if (verifyTraceOk.ok === true && !verifyTraceOk.warnings.some(w => w.includes('D-001@V1'))) {
204
- console.log('✅ verify validator 在 D-001@v1 已覆盖时不再报警')
205
- } else {
206
- console.log('❌ verify validator 覆盖后仍报警', verifyTraceOk)
207
- failed++
208
- }
209
-
210
- writeFileSync(join(traceDir, 'decisions.md'), '# Decisions\n\n## D-002@v1: Unresolved schema conflict\n- priority: P0\n- status: unresolved\n')
211
- const blockerTrace = runValidators('plan', traceRoot, 'trace')
212
- if (blockerTrace.ok === false && blockerTrace.errors.some(e => e.includes('P0/P1 未决阻塞') && e.includes('D-002@V1'))) {
213
- console.log('✅ plan validator 阻止 P0 unresolved decision 进入 plan')
214
- } else {
215
- console.log('❌ plan validator 未阻止 P0 unresolved decision', blockerTrace)
216
- failed++
217
- }
218
-
219
- writeFileSync(join(traceDir, 'decisions.md'), '# Decisions\n\n- id: D-003@v1\n priority: P1\n status: blocking\n type: boundary\n')
220
- const yamlBlockerTrace = runValidators('plan', traceRoot, 'trace')
221
- if (yamlBlockerTrace.ok === false && yamlBlockerTrace.errors.some(e => e.includes('P0/P1 未决阻塞') && e.includes('D-003@V1'))) {
222
- console.log('✅ plan validator 支持 list/YAML 风格 decision record')
223
- } else {
224
- console.log('❌ plan validator 未识别 list/YAML 风格 decision record', yamlBlockerTrace)
225
- failed++
226
- }
227
-
228
- writeFileSync(join(traceDir, 'decisions.md'), '# Decisions\n\n- id: D-004@v1\n status: blocking\n type: boundary\n')
229
- const missingPriorityTrace = runValidators('plan', traceRoot, 'trace')
230
- if (missingPriorityTrace.ok === false
231
- && missingPriorityTrace.errors.some(e => e.includes('P0/P1 未决阻塞') && e.includes('D-004@V1') && e.includes('priority=missing->P1'))) {
232
- console.log('✅ plan validator 将缺 priority 的 blocking decision 按 P1 阻断')
233
- } else {
234
- console.log('❌ plan validator 未阻断缺 priority 的 blocking decision', missingPriorityTrace)
235
- failed++
236
- }
237
-
238
- writeFileSync(join(traceDir, 'decisions.md'), '# Decisions\n\n- id: D-005@v1\n status: accepted\n type: term\n')
239
- writeFileSync(join(traceDir, 'plan.md'), '# Plan\n\n- [ ] task-01: implement naming(覆盖:FR-01)\n')
240
- const yamlAcceptedTrace = runValidators('plan', traceRoot, 'trace')
241
- if (yamlAcceptedTrace.ok === true && yamlAcceptedTrace.warnings.some(w => w.includes('plan.md 未引用') && w.includes('D-005@V1'))) {
242
- console.log('✅ plan validator 将 YAML accepted decision 纳入追踪')
243
- } else {
244
- console.log('❌ plan validator 未追踪 YAML accepted decision', yamlAcceptedTrace)
245
- failed++
246
- }
247
-
248
- writeFileSync(join(traceDir, 'decisions.md'), '# Decisions\n')
249
- writeFileSync(join(traceDir, 'requirements.md'), '# Requirements\n\n普通说明提到 https://example.test/spec/FR-404 和注释里的 FR-405,但它们不是结构化需求 ID。\n')
250
- writeFileSync(join(traceDir, 'plan.md'), '# Plan\n\nNo structured requirement IDs here.\n')
251
- const looseIdTrace = runValidators('plan', traceRoot, 'trace')
252
- if (!looseIdTrace.warnings.some(w => w.includes('FR-404') || w.includes('FR-405'))) {
253
- console.log('✅ plan validator 忽略普通正文/URL 中的 FR ID')
254
- } else {
255
- console.log('❌ plan validator 误提取普通正文/URL 中的 FR ID', looseIdTrace)
256
- failed++
257
- }
258
-
259
- writeFileSync(join(traceDir, 'decisions.md'), '# Decisions\n\n普通说明提到 https://example.test/spec/D-404@v1 和注释里的 D-405@v1,但它们不是结构化决策 ID。\n')
260
- const looseBrainstormTrace = runValidators('brainstorm', traceRoot, 'trace')
261
- if (!looseBrainstormTrace.warnings.some(w => w.includes('D-404@V1') || w.includes('D-405@V1'))) {
262
- console.log('✅ brainstorm validator 忽略普通正文/URL 中的 D ID')
263
- } else {
264
- console.log('❌ brainstorm validator 误提取普通正文/URL 中的 D ID', looseBrainstormTrace)
265
- failed++
266
- }
267
-
268
- rmSync(traceRoot, { recursive: true })
269
-
270
- // === StageContract 结构测试 ===
271
- console.log('\n=== Contract 结构测试 ===')
272
-
273
- const plan = getContract('plan')
274
- if (plan.allowedFrom.includes('brainstorm') && plan.allowedTo.includes('execute') && plan.validators.length === 1) {
275
- console.log('✅ plan contract 结构正确')
276
- } else {
277
- console.log('❌ plan contract 结构异常:', JSON.stringify(plan))
278
- failed++
279
- }
280
-
281
- const verify = getContract('verify')
282
- if (verify.allowedFrom.includes('execute') && verify.allowedTo.includes('archive')) {
283
- console.log('✅ verify contract 结构正确')
284
- } else {
285
- console.log('❌ verify contract 结构异常')
286
- failed++
287
- }
288
-
289
- const unknown = getContract('nonexistent')
290
- if (unknown === null) {
291
- console.log('✅ 未知阶段返回 null')
292
- } else {
293
- console.log('❌ 未知阶段应返回 null')
294
- failed++
295
- }
296
-
297
- // === 结果 ===
298
- console.log(`\n${failed === 0 ? '✅ 全部通过' : `❌ ${failed} 项失败`}`)
299
- if (failed > 0) throw new Error(`${failed} test(s) failed`)
@@ -1,39 +0,0 @@
1
- import assert from 'node:assert/strict'
2
- import { stageRegistry } from '../src/stages/index.js'
3
- import { buildPlanSteps } from '../src/stages/plan.js'
4
- import { buildExecuteSteps } from '../src/stages/execute.js'
5
-
6
- const stageSteps = {
7
- brainstorm: stageRegistry.brainstorm.steps,
8
- scan: stageRegistry.scan.steps,
9
- quick: stageRegistry.quick.steps,
10
- archive: stageRegistry.archive.steps,
11
- verify: stageRegistry.verify.steps,
12
- plan: buildPlanSteps(null),
13
- execute: buildExecuteSteps(null),
14
- }
15
-
16
- function names(stage) {
17
- return stageSteps[stage].map(step => step.name)
18
- }
19
-
20
- function assertContains(stage, expectedNames) {
21
- const actual = names(stage)
22
- for (const name of expectedNames) {
23
- assert.ok(actual.includes(name), `${stage} should include step "${name}". Actual: ${actual.join(', ')}`)
24
- }
25
- }
26
-
27
- assert.equal(stageSteps.brainstorm.length, 13, 'brainstorm should include optional demand clarification and default Design Grill gates')
28
- assertContains('brainstorm', ['需求澄清 Grill', '写设计文档并自审', 'Design Grill 交叉审查', '用户确认并生成规范文件'])
29
-
30
- assert.equal(stageSteps.scan.length, 11, 'scan base definition should be 11 steps (with Extract Project Knowledge) before per-project expansion')
31
- assertContains('scan', ['构建扫描项目列表', '生成本地配置', '生成模块映射'])
32
-
33
- assert.equal(stageSteps.quick.length, 3, 'quick should remain a short auxiliary workflow')
34
- assertContains('quick', ['理解任务', '实现并验证', '暂存和更新记录'])
35
-
36
- assert.equal(stageSteps.archive.length, 5, 'archive should keep its five-step lifecycle')
37
- assertContains('archive', ['extract-module-impact', 'sync-module-docs', '确认归档'])
38
-
39
- console.log('✅ stage definition regression checks passed')