@boyingliu01/xp-gate 0.19.2 → 0.20.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 (223) hide show
  1. package/adapters/gate-4.sh +83 -18
  2. package/adapters/gate-8.sh +49 -5
  3. package/adapters/iac.sh +1 -1
  4. package/adapters/typescript.sh +15 -60
  5. package/bin/xp-gate.js +15 -16
  6. package/gate-10.sh +35 -2
  7. package/gate-4.sh +110 -21
  8. package/gate-8.sh +49 -5
  9. package/hooks/gate-10.sh +35 -2
  10. package/hooks/gate-4.sh +110 -21
  11. package/hooks/gate-8.sh +49 -5
  12. package/hooks/lib/jscpd-run.sh +63 -0
  13. package/hooks/lib/sprint-gate-report.sh +58 -0
  14. package/hooks/lib/test-failure.sh +152 -0
  15. package/hooks/lib/typecheck.sh +141 -0
  16. package/hooks/lib/validate-code-walkthrough.cjs +43 -5
  17. package/hooks/post-merge +100 -0
  18. package/hooks/pre-commit +401 -155
  19. package/hooks/pre-push +75 -19
  20. package/lib/__tests__/bootstrap.test.js +23 -41
  21. package/lib/__tests__/check-version.test.js +8 -1
  22. package/lib/__tests__/detect-deps.test.js +16 -0
  23. package/lib/__tests__/doctor-drift-round2.test.js +212 -0
  24. package/lib/__tests__/doctor-executed-surface.test.js +209 -0
  25. package/lib/__tests__/doctor-hook-drift.test.js +329 -0
  26. package/lib/__tests__/doctor-machine-mutation.test.js +116 -0
  27. package/lib/__tests__/doctor-module-drift.test.js +206 -0
  28. package/lib/__tests__/doctor-module-resolution-parity.test.js +314 -0
  29. package/lib/__tests__/doctor-path-equivalence.test.js +59 -0
  30. package/lib/__tests__/doctor-repair-boundary.test.js +52 -0
  31. package/lib/__tests__/doctor-tui-skill-freshness.test.js +105 -0
  32. package/lib/__tests__/doctor.test.js +155 -0
  33. package/lib/__tests__/gate-runner.test.js +19 -3
  34. package/lib/__tests__/helpers/lib-sandbox.cjs +55 -0
  35. package/lib/__tests__/init.test.js +44 -17
  36. package/lib/__tests__/install-skill-full-dir.test.js +151 -0
  37. package/lib/__tests__/install-skill.test.js +51 -132
  38. package/lib/__tests__/language-tools-detect.test.js +158 -0
  39. package/lib/__tests__/phase-transition.test.js +15 -1
  40. package/lib/__tests__/qoder-delphi-agents.test.js +285 -0
  41. package/lib/__tests__/shared-paths.test.js +20 -0
  42. package/lib/__tests__/shared-utils.test.js +69 -0
  43. package/lib/__tests__/skill-flags.test.js +48 -0
  44. package/lib/__tests__/ui-detector.test.ts +6 -2
  45. package/lib/__tests__/uninstall.test.js +20 -0
  46. package/lib/__tests__/update-hooks.test.js +12 -0
  47. package/lib/__tests__/update-skill.test.js +7 -4
  48. package/lib/detect-deps.js +3 -20
  49. package/lib/doctor-tui.js +22 -5
  50. package/lib/doctor.js +1178 -31
  51. package/lib/init.js +184 -33
  52. package/lib/install-cmd.js +7 -4
  53. package/lib/install-skill.js +38 -95
  54. package/lib/language-tools.js +83 -4
  55. package/lib/mattpocock-license-verdict.json +1 -1
  56. package/lib/shared-paths.js +5 -2
  57. package/lib/shared-utils.js +47 -3
  58. package/lib/uninstall.js +12 -0
  59. package/lib/update-hooks.js +4 -4
  60. package/lib/update-skill.js +6 -7
  61. package/mock-policy/AGENTS.md +4 -4
  62. package/mutation/AGENTS.md +4 -4
  63. package/mutation/__tests__/gate-m.test.ts +66 -14
  64. package/mutation/__tests__/mutmut-runner.test.ts +91 -42
  65. package/mutation/__tests__/test-filter-parity.test.ts +37 -0
  66. package/mutation/gate-m.ts +21 -8
  67. package/package.json +1 -1
  68. package/plugins/claude-code/.claude-plugin/plugin.json +2 -2
  69. package/plugins/claude-code/skills/clipboard-vision/__tests__/clipboard-vision-distribution.test.cjs +0 -1
  70. package/plugins/claude-code/skills/delphi-review/AGENTS.md +4 -4
  71. package/plugins/claude-code/skills/delphi-review/SKILL.md +98 -14
  72. package/plugins/claude-code/skills/delphi-review/references/code-walkthrough.md +36 -3
  73. package/plugins/claude-code/skills/delphi-review/references/requirements.md +6 -6
  74. package/plugins/claude-code/skills/sprint-flow/AGENTS.md +4 -4
  75. package/plugins/claude-code/skills/sprint-flow/references/phase-2-design.md +3 -3
  76. package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +4 -4
  77. package/plugins/dsh/README.md +169 -4
  78. package/plugins/dsh/dsh-overlay.patch.yml +67 -0
  79. package/plugins/dsh/package.json +1 -1
  80. package/plugins/dsh/scripts/prepack.cjs +24 -19
  81. package/plugins/dsh/setup-dsh.ps1 +160 -0
  82. package/plugins/dsh/skills/clipboard-vision/__tests__/clipboard-vision-distribution.test.cjs +0 -1
  83. package/plugins/dsh/skills/delphi-review/AGENTS.md +4 -4
  84. package/plugins/dsh/skills/delphi-review/SKILL.md +98 -14
  85. package/plugins/dsh/skills/delphi-review/references/code-walkthrough.md +36 -3
  86. package/plugins/dsh/skills/delphi-review/references/requirements.md +6 -6
  87. package/plugins/dsh/skills/sprint-flow/AGENTS.md +4 -4
  88. package/plugins/dsh/skills/sprint-flow/references/phase-2-design.md +3 -3
  89. package/plugins/dsh/skills/test-specification-alignment/AGENTS.md +4 -4
  90. package/plugins/dsh/src/command.test.ts +66 -2
  91. package/plugins/dsh/src/command.ts +36 -14
  92. package/plugins/dsh/src/contract.test.ts +31 -1
  93. package/plugins/dsh/src/delphi-config.test.ts +190 -0
  94. package/plugins/dsh/src/delphi-config.ts +223 -0
  95. package/plugins/dsh/src/delphi-run.test.ts +181 -0
  96. package/plugins/dsh/src/delphi-run.ts +129 -0
  97. package/plugins/dsh/src/delphi.test.ts +222 -0
  98. package/plugins/dsh/src/delphi.ts +247 -0
  99. package/plugins/dsh/src/dialect.test.ts +59 -0
  100. package/plugins/dsh/src/dialect.ts +40 -0
  101. package/plugins/dsh/src/index.ts +70 -4
  102. package/plugins/dsh/src/skills.test.ts +26 -19
  103. package/plugins/opencode/package.json +1 -1
  104. package/plugins/opencode/skills/clipboard-vision/__tests__/clipboard-vision-distribution.test.cjs +0 -1
  105. package/plugins/opencode/skills/delphi-review/AGENTS.md +4 -4
  106. package/plugins/opencode/skills/delphi-review/SKILL.md +98 -14
  107. package/plugins/opencode/skills/delphi-review/references/code-walkthrough.md +36 -3
  108. package/plugins/opencode/skills/delphi-review/references/requirements.md +6 -6
  109. package/plugins/opencode/skills/sprint-flow/AGENTS.md +4 -4
  110. package/plugins/opencode/skills/sprint-flow/references/phase-2-design.md +3 -3
  111. package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +4 -4
  112. package/plugins/qoder/agents/delphi-architecture.md +1 -1
  113. package/plugins/qoder/agents/delphi-feasibility.md +1 -1
  114. package/plugins/qoder/agents/delphi-technical.md +1 -1
  115. package/plugins/qoder/plugin.json +2 -2
  116. package/plugins/qoder/skills/admin-template-guidelines/SKILL.md +6 -797
  117. package/plugins/qoder/skills/admin-template-guidelines/references/rule-1.md +91 -0
  118. package/plugins/qoder/skills/admin-template-guidelines/references/rule-2.md +155 -0
  119. package/plugins/qoder/skills/admin-template-guidelines/references/rule-3.md +70 -0
  120. package/plugins/qoder/skills/admin-template-guidelines/references/rule-4.md +154 -0
  121. package/plugins/qoder/skills/admin-template-guidelines/references/rule-5.md +126 -0
  122. package/plugins/qoder/skills/admin-template-guidelines/references/rule-6.md +180 -0
  123. package/plugins/qoder/skills/batch-grill-me/SKILL.md +15 -0
  124. package/plugins/qoder/skills/clipboard-vision/__tests__/clipboard-vision-distribution.test.cjs +0 -1
  125. package/plugins/qoder/skills/clipboard-vision/describe-clipboard.ps1 +115 -0
  126. package/plugins/qoder/skills/clipboard-vision/describe-clipboard.sh +161 -0
  127. package/plugins/qoder/skills/delphi-review/.delphi-config.json.example +61 -28
  128. package/plugins/qoder/skills/delphi-review/AGENTS.md +4 -4
  129. package/plugins/qoder/skills/delphi-review/INSTALL.md +97 -98
  130. package/plugins/qoder/skills/delphi-review/SKILL.md +170 -63
  131. package/plugins/qoder/skills/delphi-review/hooks.md +19 -0
  132. package/plugins/qoder/skills/delphi-review/opencode.json.delphi.example +6 -10
  133. package/plugins/qoder/skills/delphi-review/references/code-walkthrough.md +36 -3
  134. package/plugins/qoder/skills/delphi-review/references/orchestrator-dispatch.md +64 -0
  135. package/plugins/qoder/skills/delphi-review/references/requirements.md +402 -0
  136. package/plugins/qoder/skills/delphi-review/references/round-templates.md +134 -0
  137. package/plugins/qoder/skills/delphi-review/scripts/verify-consensus.sh +43 -0
  138. package/plugins/qoder/skills/delphi-review/tools.md +29 -0
  139. package/plugins/qoder/skills/domain-modeling/ADR-FORMAT.md +64 -0
  140. package/plugins/qoder/skills/domain-modeling/CONTEXT-FORMAT.md +60 -0
  141. package/plugins/qoder/skills/domain-modeling/SKILL.md +74 -0
  142. package/plugins/qoder/skills/grill-with-docs/SKILL.md +7 -0
  143. package/plugins/qoder/skills/grilling/SKILL.md +12 -0
  144. package/plugins/qoder/skills/ralph-loop/SKILL.md +87 -428
  145. package/plugins/qoder/skills/ralph-loop/references/components.md +113 -0
  146. package/plugins/qoder/skills/ralph-loop/references/workflow-details.md +99 -0
  147. package/plugins/qoder/skills/sprint-flow/AGENTS.md +5 -5
  148. package/plugins/qoder/skills/sprint-flow/SKILL.md +255 -454
  149. package/plugins/qoder/skills/sprint-flow/__tests__/sprint-flow.test.cjs +457 -0
  150. package/plugins/qoder/skills/sprint-flow/hooks.md +18 -0
  151. package/plugins/qoder/skills/sprint-flow/references/components/memory.md +1 -1
  152. package/plugins/qoder/skills/sprint-flow/references/components/middleware.md +1 -1
  153. package/plugins/qoder/skills/sprint-flow/references/components/skill-invocations.md +21 -20
  154. package/plugins/qoder/skills/sprint-flow/references/components/tool-descriptions.md +22 -23
  155. package/plugins/qoder/skills/sprint-flow/references/force-levels.md +0 -1
  156. package/plugins/qoder/skills/sprint-flow/references/orchestration-rules.md +34 -27
  157. package/plugins/qoder/skills/sprint-flow/references/phase-1-prep.md +1 -1
  158. package/plugins/qoder/skills/sprint-flow/references/phase-2-design.md +160 -123
  159. package/plugins/qoder/skills/sprint-flow/references/phase-3-build.md +203 -2
  160. package/plugins/qoder/skills/sprint-flow/references/phase-4-verify.md +107 -34
  161. package/plugins/qoder/skills/sprint-flow/references/phase-5-ship.md +194 -12
  162. package/plugins/qoder/skills/sprint-flow/references/phase-6-close.md +139 -7
  163. package/plugins/qoder/skills/sprint-flow/references/phase-overview.md +486 -0
  164. package/plugins/qoder/skills/sprint-flow/scripts/verify-sprint-state.sh +38 -0
  165. package/plugins/qoder/skills/sprint-flow/tools.md +29 -0
  166. package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +4 -4
  167. package/plugins/qoder/skills/test-specification-alignment/SKILL.md +104 -601
  168. package/plugins/qoder/skills/to-issues/SKILL.md +1 -1
  169. package/principles/AGENTS.md +9 -8
  170. package/principles/__tests__/adapter-metrics.test.ts +292 -0
  171. package/principles/__tests__/analyzer.test.ts +29 -6
  172. package/principles/__tests__/baseline-prune-timeout.test.ts +71 -0
  173. package/principles/__tests__/baseline-prune.test.ts +338 -0
  174. package/principles/__tests__/boy-scout-init-baseline.test.ts +167 -0
  175. package/principles/__tests__/boy-scout-integration.test.ts +97 -6
  176. package/principles/__tests__/boy-scout.test.ts +253 -7
  177. package/principles/__tests__/config-enforcement.test.ts +469 -0
  178. package/principles/__tests__/config-git-timeout.test.ts +66 -0
  179. package/principles/__tests__/direct-execution.test.ts +187 -0
  180. package/principles/__tests__/index.test.ts +16 -3
  181. package/principles/__tests__/warnings-baseline-budgets.test.ts +74 -0
  182. package/principles/adapters/typescript.ts +613 -13
  183. package/principles/analyzer.ts +22 -0
  184. package/principles/baseline-prune.ts +217 -0
  185. package/principles/boy-scout.ts +481 -51
  186. package/principles/config.ts +362 -54
  187. package/principles/direct-execution.ts +60 -0
  188. package/principles/index.ts +40 -17
  189. package/principles/rules/__tests__/clean-code/many-exports.test.ts +16 -10
  190. package/principles/rules/clean-code/code-duplication.ts +8 -8
  191. package/principles/rules/clean-code/deep-nesting.ts +8 -8
  192. package/principles/rules/clean-code/god-class.ts +8 -8
  193. package/principles/rules/clean-code/large-file.ts +15 -11
  194. package/principles/rules/clean-code/long-function.ts +8 -8
  195. package/principles/rules/clean-code/magic-numbers.ts +10 -7
  196. package/principles/rules/clean-code/many-exports.ts +7 -7
  197. package/principles/rules/clean-code/missing-error-handling.ts +5 -5
  198. package/principles/rules/clean-code/too-many-params.ts +8 -8
  199. package/principles/rules/clean-code/unused-imports.ts +5 -5
  200. package/principles/rules/solid/dip.ts +18 -8
  201. package/principles/rules/solid/isp.ts +9 -8
  202. package/principles/rules/solid/lsp.ts +6 -6
  203. package/principles/rules/solid/ocp.ts +6 -5
  204. package/principles/rules/solid/srp.ts +7 -8
  205. package/principles/types.ts +15 -0
  206. package/scripts/__tests__/sync-package-content.test.js +28 -0
  207. package/scripts/delphi-external-review.cjs +193 -10
  208. package/scripts/sync-package-content.js +7 -4
  209. package/skills/clipboard-vision/__tests__/clipboard-vision-distribution.test.cjs +0 -1
  210. package/skills/delphi-review/AGENTS.md +4 -4
  211. package/skills/delphi-review/SKILL.md +98 -14
  212. package/skills/delphi-review/references/code-walkthrough.md +36 -3
  213. package/skills/delphi-review/references/requirements.md +6 -6
  214. package/skills/sprint-flow/AGENTS.md +4 -4
  215. package/skills/sprint-flow/references/phase-2-design.md +3 -3
  216. package/skills/test-specification-alignment/AGENTS.md +4 -4
  217. package/lib/__tests__/download-skill.test.js +0 -281
  218. package/lib/download-skill.js +0 -96
  219. package/plugins/qoder/skills/ralph-loop/references/components/memory.md +0 -55
  220. package/plugins/qoder/skills/ralph-loop/references/components/middleware.md +0 -54
  221. package/plugins/qoder/skills/ralph-loop/references/components/skill-invocations.md +0 -39
  222. package/plugins/qoder/skills/ralph-loop/references/components/system-prompt.md +0 -24
  223. package/plugins/qoder/skills/ralph-loop/references/components/tool-descriptions.md +0 -32
@@ -0,0 +1,486 @@
1
+ # Sprint Flow — Phase Overview & Detailed Instructions
2
+
3
+ > **This file**: detailed phase descriptions, skill integration, parameter docs, output contract, templates, research evidence, and orchestration rules.
4
+ > **Router file**: `../SKILL.md` — description, triggers, workflow steps, constraints, anti-patterns only.
5
+
6
+ ---
7
+
8
+ ## 核心原则
9
+
10
+ | 原则 | 说明 |
11
+ |------|------|
12
+ | **单一入口** | 用户只需调用 `/sprint-flow`,自动串联全流程 |
13
+ | **自动流水线** | 自动执行多个阶段,原生步骤 + 内置 Matt Pocock skill |
14
+ | **关键节点暂停** | APPROVED 确认、DELPHI-GATE 通过、Ship 确认、⚠️ Phase 6 CLOSE 必须人工 |
15
+ | **承认 Emergent** | 用户验收环节必须人工,无法自动化(78% 失败不可见) |
16
+ | **复用现有 Skills** | 不重新发明,整合调用现有体系 |
17
+
18
+ ---
19
+
20
+ ## Unique Value Proposition
21
+
22
+ Sprint Flow is NOT just a sequential launcher of existing skills. Here's what makes it different from manually running each skill:
23
+
24
+ ### Why Sprint Flow vs Manual Skill Execution
25
+
26
+ | Dimension | Manual Execution | Sprint Flow |
27
+ |-----------|-----------------|-------------|
28
+ | **Context Continuity** | Each skill starts fresh; lost design decisions between phases | Phase summaries + sprint-state.json maintain full traceability across 6 phases |
29
+ | **Gate Enforcement** | No enforcement — easy to skip Delphi, skip TDD, skip UAT | HARD-GATE: design must be APPROVED (≥90% Delphi consensus) before coding; UAT is mandatory (no bypass) |
30
+ | **Token Efficiency** | Linear context accumulation across phases — ~150K+ tokens | Ralph-loop default: 40-67% token savings via clean REQ-level contexts |
31
+ | **Emergent Requirements** | Discovered late, silently ignored or merged | Phase 6 CLOSE explicitly captures emergent issues via template; triggers Sprint 2 for critical issues |
32
+ | **Quality Ecosystem** | No integration with quality gates | Integrated with xp-gate's full quality ecosystem: Gate 5 (coverage), Gate M2 (mock density), Delphi code-walkthrough |
33
+ | **Progress Tracking** | Ad-hoc, memory-based | `.sprint-state/` persistence with phase history, timing, and metrics — `--status` renders progress dashboard |
34
+
35
+ ### Key Differentiators
36
+
37
+ 1. **40-67% Token Savings via Ralph Loop**: Phase 3 BUILD default (`ralph-loop`) processes one REQ at a time with clean context, avoiding the linear context accumulation that costs 150K+ tokens in parallel mode.
38
+
39
+ 2. **HARD-GATE Discipline**: Design must pass Delphi review with all three expert roles executed successfully, three distinct requested model IDs verified, and ≥90% aggregate consensus within five rounds before Phase 3 BUILD can start. This is enforced both in SKILL.md instructions and via the Claude Code plugin's PreToolUse hook.
40
+
41
+ 3. **Emergent Requirements Acknowledgment**: Based on research showing 78% of failures are invisible to AI (arXiv study), Phase 6 CLOSE includes mandatory manual UAT verification — cannot be automated, skipped, or bypassed.
42
+
43
+ 4. **XP-Gate Quality Ecosystem Integration**: Sprint Flow is part of the broader xp-gate ecosystem. Phase 3 BUILD integrates with Gate 5 (test coverage ≥80%), Gate M2 (mock density ≤30%), and Gate MW (code-walkthrough validation). Phase 4 VERIFY runs Delphi code-walkthrough that generates `.code-walkthrough-result.json` for pre-push enforcement.
44
+
45
+ 5. **Full Lifecycle Coverage**: From worktree isolation (PREP) to cleanup (CLOSE), sprint-flow covers the entire development lifecycle — not just the "write code" part. PREP (Phase 1/6) prevents over-engineering by routing lightweight changes through simplified workflows.
46
+
47
+ ---
48
+
49
+ ## 完整流程(默认无参数)
50
+
51
+ 调用 `/sprint-flow "[需求描述]"` 后,自动执行以下流程:
52
+
53
+ ```
54
+ Phase 1/6: PREP → worktree隔离 + 规模评估 + 流程路由
55
+ Phase 2/6: DESIGN → grill-with-docs → R1 需求评审 → 设计文档+APPROVAL → batch-grill-me → R2 delphi-review → to-issues → specification.yaml
56
+ Phase 3/6: BUILD → BUILD-ENTRY-CONTRACT → GITHOOKS-GATE → DELPHI-GATE → ralph-loop/TDD → blind-review (read-only subagent) → verification
57
+ Phase 4/6: VERIFY → delphi-review --mode code-walkthrough → test-alignment (#367 HARD-GATE) → xp-gate check --all → browser (Layer 4) → learnings + retro
58
+ Phase 5/6: SHIP → VERSION-GATE → 分支完成决策(4选项) → native ship (PR) → native land (merge+CI+canary)
59
+ Phase 6/6: CLOSE → USER ACCEPTANCE (⚠️ 人工) → #369 返工指标 → emergent issues → cleanup
60
+ ```
61
+
62
+ **v2.0 Compact Redesign** (Issue #290): Merged from 11 phases to 6. PREP = old ISOLATE + AUTO-ESTIMATE. DESIGN = old THINK + PLAN. BUILD = old BUILD (unchanged). VERIFY = old REVIEW + FEEDBACK. SHIP = old SHIP + LAND. CLOSE = old USER ACCEPTANCE + CLEANUP.
63
+
64
+ ---
65
+
66
+ ## 暂停点设计(不是随时停,而是设计明确的暂停点)
67
+
68
+ - **Phase 1/6 PREP**: 保护分支强制隔离 → 输出警告或自动创建 worktree → 自动恢复;AUTO-ESTIMATE 结果展示 → 用户确认 → 按路由继续
69
+ - **Phase 2/6 DESIGN**: grill-with-docs 访谈 → R1 需求评审 GAPS_FOUND → 补充访谈(最多 2 轮);设计文档未 APPROVED (HARD-GATE) → 用户修改 → APPROVED 后继续;batch-grill-me 批量决策 → 用户确认;R2 delphi-review 未 APPROVED → 修复 → APPROVED → specification.yaml
70
+ - **Phase 3/6 BUILD**: BUILD-ENTRY-CONTRACT 未通过 → BLOCK;DELPHI-GATE 未通过 → BLOCK;验证失败 > max3 → 用户决策修复/放弃;成本超阈值 → 用户确认
71
+ - **Phase 4/6 VERIFY**: delphi code-walkthrough REQUEST_CHANGES → 用户处理 → 重新评审;test-alignment 失败 (#367) → 回退 Phase 3(不暂停);浏览器验证发现问题 → 回退 Phase 3(不暂停)
72
+ - **Phase 5/6 SHIP**: 分支完成决策 (4选项) → 确认;native ship PR → 用户确认合并;native land 完成/失败 → 用户确认;⚠️ SHIP must complete merge to main + release before Phase 6
73
+ - **Phase 6/6 CLOSE**: SHIP→CLOSE GATE (校验 merge 已完成 + git status clean + 当前在 main) → Backup sprint-state → #369 返工指标写入 → USER ACCEPTANCE ⚠️ 必须人工验收 → 用户确认后继续;cleanup 完成/失败 → 用户确认 → 结束流程
74
+
75
+ ---
76
+
77
+ ## Workflow Steps Detail
78
+
79
+ | Step | Phase | Name | Key Actions | Output |
80
+ |------|-------|------|-------------|--------|
81
+ | 1 | **1/6** | **PREP** | Detect protected branch → Create git worktree → AUTO-ESTIMATE sizing → Classify (lightweight/standard/complex) | Worktree path + impact assessment |
82
+ | 2 | **2/6** | **DESIGN** | grill-with-docs → R1 需求评审 → 设计文档+APPROVAL (HARD-GATE) → batch-grill-me → R2 delphi-review (≥90% consensus) → to-issues → specification.yaml | specification.yaml + slices-manifest.json + requirements-reviewed.json |
83
+ | 3 | **3/6** | **BUILD** | BUILD-ENTRY-CONTRACT → GITHOOKS-GATE → DELPHI-GATE → ralph-loop (default) or parallel → TDD → blind-review (read-only subagent) → verification | MVP code |
84
+ | 4 | **4/6** | **VERIFY** | delphi-review --mode code-walkthrough → test-specification-alignment (#367 HARD-GATE) → xp-gate check --all → browser (Layer 4 optional) → learnings + xp-gate retro | Review report + feedback-log.md + test-alignment-report.json |
85
+ | 5 | **5/6** | **SHIP** | VERSION-GATE → 分支完成决策 (4选项) → native ship (create PR) → native land (merge + CI + canary) → release | PR URL + deploy status + merge confirmation |
86
+ | 6 | **6/6** | **CLOSE** | SHIP→CLOSE GATE (merge + release verified) → Backup sprint-state → #369 返工指标 → USER ACCEPTANCE (⚠️ mandatory manual) → Capture emergent issues → Cleanup worktree + branch → Sprint summary | Emergent issues list + cleanup report + metrics |
87
+
88
+ **Phase Flow**:
89
+ ```
90
+ PREP → DESIGN → BUILD → VERIFY → SHIP (merge to main + release) → CLOSE
91
+ ↑
92
+ SHIP→CLOSE GATE
93
+ (merge verified + main clean)
94
+ ```
95
+
96
+ **Hard Gates**:
97
+ - **Phase 2/6 → 3/6 (DESIGN → BUILD)**: R1 需求评审 APPROVED + 设计文档用户 APPROVED + R2 delphi-review APPROVED (≥90% consensus) + GITHOOKS-GATE (hooks installed) + DELPHI-GATE (spec APPROVED) + BUILD-ENTRY-CONTRACT (manifest schema + slice↔REQ 一致性)
98
+ - **Phase 4/6 → 5/6 (VERIFY → SHIP)**: feedback-log.md must exist + test-alignment-report.json PASS (#367 程序化 HARD-GATE)
99
+ - **Phase 5/6 → 6/6 (SHIP → CLOSE)**: PR must be merged to main + release completed (HARD-GATE). See `references/phase-6-close.md#ship--close-gate`.
100
+
101
+ ---
102
+
103
+ ## 各 Phase 调用的 Skills
104
+
105
+ ### ⚠️ 强制输出格式规范(Mandatory Output Format)
106
+
107
+ **执行每个 Phase 时,必须以以下固定格式输出阶段标题**,不可省略、不可合并、不可替换:
108
+
109
+ ```markdown
110
+ ## Phase 1/6: PREP (准备工作)
111
+ ## Phase 2/6: DESIGN (设计)
112
+ ## Phase 3/6: BUILD (构建)
113
+ ## Phase 4/6: VERIFY (验证)
114
+ ## Phase 5/6: SHIP (发布)
115
+ ## Phase 6/6: CLOSE (收尾)
116
+ ```
117
+
118
+ **规则**:
119
+ 1. 每个 Phase **开始执行时必须首先输出**对应的 `## Phase X/6: NAME` 标题行(作为该 Phase 输出的第一行)
120
+ 2. **禁止省略** "Phase" 关键词(如不能只写 "PREP" 或 "## 1/6")
121
+ 3. **禁止合并**多个 Phase 的输出(每个 Phase 必须有独立标题)
122
+ 4. **格式必须精确匹配**:`## Phase X/6:` + 大写英文名 + ` (中文名)`
123
+ 5. 跳过某个 Phase(如 `--resume-from build` 跳过了 PREP, DESIGN)时,不输出被跳过 Phase 的标题
124
+ 6. 触发 `/sprint-flow` 后,**第一行输出应包含工作流阶段概览**:
125
+
126
+ ```
127
+ Sprint Flow: PREP → DESIGN → BUILD → VERIFY → SHIP → CLOSE
128
+ ```
129
+
130
+ ### Phase 1/6: PREP (准备工作 — worktree 隔离 + 规模评估)
131
+
132
+ **执行时机**: `/sprint-flow` 启动后 → Phase 2/6 DESIGN 前。**自动执行**。
133
+
134
+ **对应旧模型**: Phase -1 ISOLATE + Phase -0.5 AUTO-ESTIMATE
135
+
136
+ **详细指令**: 参见 `references/phase-1-prep.md` — 包含步骤表、参数处理、错误回退、sprint-state 格式、AUTO-ESTIMATE 指标计算、路由决策。
137
+
138
+ **快速参考**:
139
+ 1. 检测保护分支 (main/master/develop) → 自动创建 worktree `.worktrees/sprint/sprint-YYYY-MM-DD-NN`
140
+ 2. Sprint Lock 检测(Issue #144)— stale 锁自动覆盖,非 stale 阻断
141
+ 3. 项目 setup (`npm install`/`go mod download`/`pip install`)
142
+ 4. `.gitignore` 校验 + Sprint State 记录 + 基线测试
143
+ 5. 识别需求类型 → 收集指标(引用计数、跨模块依赖、循环依赖)→ **轻量** / **标准** / **复杂**
144
+ 6. 输出评估结果 → 用户确认后按路由继续
145
+ 7. **参数**: `--no-isolate` (跳过), `--branch-name <name>`, `--force` (绕过保护分支)
146
+
147
+ ### Phase 2/6: DESIGN (设计 — 需求探索 + 双点评审)
148
+
149
+ **对应旧模型**: Phase 0 THINK + Phase 1 PLAN
150
+
151
+ **执行者**: orchestrator 直接执行全部步骤(交互式 skill)。
152
+
153
+ **详细指令**: 参见 `references/phase-2-design.md` — 完整流程、条件分支、HARD-GATE。
154
+
155
+ **快速参考**:
156
+ - **Step 0: CONTEXT.md 预检 (#322)**: 存在则 SKIP grill 访谈,但 R1 需求评审仍执行(CONTEXT.md 可能陈旧)
157
+ - **Step 1: grill-with-docs** — `skill(name="grill-with-docs")` — 逐个追问 + CONTEXT.md/ADR 沉淀。**HARD-GATE**: 设计未批准 → 不可进入实现
158
+ - **Step 2: R1 需求评审 (#368)** — `/delphi-review --mode requirements` Agent skill — 所有路径都由三专家独立执行,验证 distinct model IDs 后聚合 ≥90% 共识,输出 requirements-reviewed.json(含可重新计算的 requirements_hash 与 exact-HEAD 防陈旧绑定)
159
+ - **Step 3: 原生设计文档生成** — `docs/plans/YYYY-MM-DD-<topic>-design.md`(需求摘要、2-3 方案、推荐、成功标准)
160
+ - **Step 4: HARD-GATE APPROVAL** — 用户审批设计文档
161
+ - **Step 5: 路由分叉** — `change_type == "修改已存在代码"` → SKIP batch-grill-me, lightweight R2
162
+ - **Step 6: batch-grill-me** — `skill(name="batch-grill-me")` — 批量前置决策(替代 autoplan taste_decisions)
163
+ - **Step 7: R2 delphi-review** — `skill(name="delphi-review")` — 等待 APPROVED(≥90% 共识)
164
+ - **Step 8: to-issues** — `skill(name="to-issues")` — 垂直切片 Issue 拆分 → slices-manifest.json
165
+ - **Step 9: specification.yaml** — 从 APPROVED 设计文档自动提取(每 REQ 含验收标准 — #368)
166
+ - **Web 前端额外注入**: OPTIONAL design-shotgun(如已安装)
167
+
168
+ ### Phase 2/6→3/6: GITHOOKS-GATE(质量门禁安装检查)
169
+
170
+ **执行时机**: Phase 2/6 DESIGN 完全通过、准备进入 Phase 3/6 BUILD 之前。
171
+
172
+ **必须执行**: 运行 `githooks/verify.sh` 检查当前项目的 hooks 是否安装。
173
+
174
+ **检查结果处理**:
175
+ - ✅ 全部存在 → 进入 Phase 3/6 BUILD 入口(仍必须先执行 DELPHI-GATE)
176
+ - ❌ 部分/全部缺失 → 运行 `githooks/install.sh` 安装(包括 `.git/hooks/pre-commit`、`.git/hooks/pre-push`、`githooks/adapter-common.sh`、`githooks/adapters/`)
177
+ - 如果 githooks/ 目录不存在于项目根目录(即当前项目不是 xp-gate) → 从 xp-gate 仓库拉取 `githooks/` 目录结构
178
+ - 安装完成后再次 `verify.sh` 确认
179
+
180
+ **核心原则**: 没有质量门禁的代码不可进入 BUILD 阶段。**GITHOOKS-GATE 失败 → 不可编码。**
181
+
182
+ ### Phase 3/6: BUILD (构建 — ralph-loop 默认 + TDD + 盲评 + 验证)
183
+
184
+ **对应旧模型**: Phase 2 BUILD(功能不变)
185
+
186
+ **详细指令**: 参见 `references/phase-3-build.md`。
187
+
188
+ **快速参考**:
189
+ 1. **BUILD-ENTRY-CONTRACT (MANDATORY — v0.18.0+)**: `phase-transition 3 in_progress` 校验 slices-manifest.json schema + slice↔REQ 一致性 → 不合法 BLOCK
190
+ 2. **DELPHI-GATE**: 验证 `.sprint-state/delphi-reviewed.json` 存在且 `verdict = "APPROVED"` → 否则 BLOCK
191
+ 3. **TDD-GATE (MANDATORY — v0.14.0+)**: 在 delegation 前验证每个 REQ 存在 failing test。无 test → mark `[TDD-RED]`(ralph-loop 创建)。有 test 且 GREEN 且无实现 → BLOCK(TDD bypass)。详见 `references/phase-3-build.md#tdd-gate-pre-implementation-tdd-check-mandatory`。
192
+ 4. **输入**: `slices-manifest.json`(Phase 2/6 生成),按 `execution_order` 逐个执行
193
+ 5. **模式**: 默认 `ralph-loop`(逐 REQ 迭代,token 节约 40-67%),可选 `--mode parallel`
194
+ 6. **Skill 步骤**: BUILD-ENTRY-CONTRACT → hooks-install → TDD-GATE → TDD (RED/GREEN/REFACTOR) → blind-review (read-only subagent, tools: [Read, Grep, Glob]) → verification-before-completion → 成本监控 → learnings.md 写入
195
+ 7. **Mock Minimization**: integration-first, mock 仅限 external services, 密度 > 30% 需 `@mock-justified`
196
+
197
+ ### Phase 4/6: VERIFY (验证 — 代码走查 + QA + 反馈获取)
198
+
199
+ **对应旧模型**: Phase 3 REVIEW + Phase 4 FEEDBACK
200
+
201
+ **详细指令**: 参见 `references/phase-4-verify.md`。
202
+
203
+ **快速参考**:
204
+ - **Orchestrator 直接执行**: delphi-review code-walkthrough 需要用户确认 verdict(Issue #249),**必须由 orchestrator 直接调用** `skill(name="delphi-review")`
205
+ - **执行顺序**: `delphi-review --mode code-walkthrough` → 等待 APPROVED → `test-specification-alignment` (#367 程序化 HARD-GATE: test-alignment-report.json + head_commit + spec_hash) → `xp-gate check --all` → 浏览器验证 (Layer 4: gstack browse > browser-use MCP > SKIP)
206
+ - **Web 前端**: `xp-gate ui-review`(原生)+ OPTIONAL gstack qa/design-review/benchmark(如已安装)
207
+ - **Feedback 子阶段**: learnings.md 写入(原生)+ `xp-gate retro`(原生,含 #369 返工率区块)+ OPTIONAL systematic-debugging(Layer 4,保留"无根因不修复"纪律)
208
+ - 输出: 评审报告 + feedback-log.md + test-alignment-report.json
209
+ - **HARD-GATE**: feedback-log.md must exist + test-alignment-report.json PASS before Phase 5/6
210
+
211
+ ### 负载/压力测试(可选)
212
+
213
+ - **适用项目**:主要用于后端服务的压力测试 (k6/Locust/Gatling),Web 前端已有 `benchmark` 技能覆盖 Core Web Vitals、加载时间和资源大小等性能指标
214
+ - **Phase 4/6 技能注入**:可根据项目类型自动选择合适的负载测试工具 (`k6` for Go-based services, `locust` for Python services, `gatling` for JVM-based services)
215
+ - **集成方式**:可作为 Phase 4/6 的可选扩展,在 code-walkthrough 之后执行,与基准测试形成完整性能验证链条
216
+ - **配置文件**:通过 `.sprint-load-test.yaml` 进行配置(待实现),包含并发用户数、持续时间、SLA 指标等参数
217
+ - **触发条件**:后端项目可通过 `--type backend-*` 自动启用,或通过 `--with-performance` 标志手动启用
218
+ - **Web 项目补充说明**:对于 Web 前端项目,现有的 `benchmark` 技能已处理页面加载性能、Core Web Vitals 等前端性能指标;负载/压力测试主要针对服务器端承载能力
219
+
220
+ ### Phase 5/6: SHIP (发布 — 发布准备 + 合并部署)
221
+
222
+ **对应旧模型**: Phase 5 SHIP + Phase 6 LAND
223
+
224
+ **详细指令**: 参见 `references/phase-5-ship.md` — VERSION-GATE (MANDATORY) / finishing-a-development-branch / VERSION CHANGESET (Issue #142) / changeset schema。
225
+
226
+ **快速参考**:
227
+ - **Step 0: VERSION-GATE (MANDATORY — 必须在分支完成决策之前)**: bump VERSION → update CHANGELOG.md → run sync-version.sh → commit + push → verify PR updated。详见 `references/phase-5-ship.md#step-0-version-gate`
228
+ - **Step 1: 分支完成决策(原生 4 选项)**: AskUserQuestion 菜单 (merge/PR/keep/discard),默认推荐 Option 2 (Push and create a Pull Request)
229
+ - **Step 2: 原生 Ship 步骤**: test → VERSION-GATE → commit → push → `gh pr create`
230
+ - 输入: phase-4-summary.md + feedback-log.md → 输出: PR URL (含版本变更 commit)
231
+ - **HARD-GATE**: Phase 4/6 未完成 → BLOCK。验证 `feedback-log.md` 存在 + test-alignment-report.json PASS。
232
+ - **GITHOOKS-GATE**: 验证 hooks 完整性,缺失则 `githooks/install.sh`
233
+ - **LAND(原生步骤)**: merge 确认 → `gh run list` 等 CI (10min) → 等 Deploy (10min) → Canary Health Check (5min)
234
+ - **回滚**: `git revert` 最后一次 merge commit
235
+ - ⚠️ **SHIP COMPLETION**: Phase 5/6 结束前必须确认 PR 已 merge 到 main + release 已创建。未完成 merge 不得进入 Phase 6/6。详见 `references/phase-5-ship.md#ship-completion-gate`。
236
+
237
+ **⚠️ VERSION-GATE 必须在分支完成决策之前执行。顺序反了会导致 PR 不含版本变更 → CI release workflow 不触发 → 无新版本发布。**
238
+
239
+ ### Phase 6/6: CLOSE (收尾 — ⚠️ 人工验收 + 清理)
240
+
241
+ **对应旧模型**: Phase 7 USER ACCEPTANCE + Phase 8 CLEANUP
242
+
243
+ **详细指令**: 参见 `references/phase-6-close.md` — UAT checklist, emergent issues capture, cleanup procedure.
244
+
245
+ **快速参考**:
246
+ - **SHIP→CLOSE GATE (MANDATORY — v0.14.3+)**: 校验 PR 已 merge、当前在 main 分支、`git status --porcelain` 为空。详见 `references/phase-6-close.md#ship--close-gate`。
247
+ - **Backup sprint-state**(MANDATORY): Phase 6 开始前将 `.sprint-state/` 备份到 repo 追踪路径,防止 worktree 清理后状态丢失。详见 `references/phase-6-close.md#backup-sprint-state`。
248
+ - **#369 返工追踪 (v0.18.0+)**: CLOSE 写入 `metrics.completed_at` + `metrics.total_sprint_commits`(merge-base 到合并点提交数)+ `metrics.merge_base_sha`。`xp-gate sprint-status --rework-check [--window-days N]` 仓库范围扫描 fix 提交,`rework_rate > 30%` 告警。"重新打开的 issue 数"指标已删除。
249
+ - **USER ACCEPTANCE**: ⚠️ **MUST NOT be automated, skipped, or bypassed.** 即使用户说"赶时间"、"跳过验收"、"直接发布",也必须暂停等待用户确认。使用 `@templates/emergent-issues-template.md` 检查清单
250
+ - **CLEANUP**: 保存分支信息 → `git worktree remove <worktree_path>`(精确路径,禁止通配符)→ 删除本地分支 + 远程分支 → 关闭遗留 OPEN PR → 更新 sprint-state.json(含 #369 metrics)→ learnings.md 写入 → 释放 Sprint Lock
251
+ - 输出 Cleanup Report + Sprint Summary
252
+ - **IF emergent issues → Sprint 2**
253
+
254
+ ---
255
+
256
+ ## 编排层规则(Orchestration Rules)
257
+
258
+ 全部内容: 参见 `references/orchestration-rules.md`。包含:
259
+ - Agent Dispatch (4 types), Phase Subagent Matrix, CONTEXT INHERITANCE
260
+ - Phase Transition Rules, Phase Summary schema, Phase Transition Gate, RESUME GATE
261
+ - WORKTREE ENFORCEMENT, Eval assertions
262
+
263
+ ## 参数说明
264
+
265
+ | 参数 | 作用 | 示例 |
266
+ |------|------|------|
267
+ | (无参数) | 全流程 PREP → DESIGN → BUILD → VERIFY → SHIP → CLOSE | `/sprint-flow "开发访谈机器人"` |
268
+ | `--stop-at <phase>` | 执行到指定 Phase 后停止 | `--stop-at design` |
269
+ | `--resume-from <phase>` | 从指定 Phase 恢复(需先执行 RESUME GATE) | `--resume-from build --spec specification.yaml` |
270
+ | `--phase <name>` | 只执行单个 Phase | `--phase build-only` |
271
+ | `--status` | 查看 Sprint 进度(只读,不执行 Phase) | `--status` |
272
+ | `--lang <lang>` | 指定项目语言 | `--lang springboot` / `django` / `golang` |
273
+ | `--type <type>` | 指定项目类型 | `--type web-nextjs` / `backend-django` |
274
+ | `--spec <file>` | 使用已有的 specification.yaml | `--spec path/to/spec.yaml` |
275
+ | `--no-isolate` | 跳过 git worktree 隔离 | `--no-isolate` |
276
+ | `--branch-name <name>` | 自定义分支名 | `--branch-name feat/my-feature` |
277
+ | `--force` | 强制在当前分支继续 | `--force` |
278
+ | `--with-performance` | 启用负载/压力测试 | `--with-performance` |
279
+ | `--mode <mode>` | 构建模式(ralph-loop / parallel) | `--mode ralph-loop` |
280
+
281
+ **Backward Compatible Parameter Mapping** (`--stop-at` / `--resume-from` / `--phase`):
282
+
283
+ | Legacy Value | Maps To |
284
+ |-------------|---------|
285
+ | `isolate`, `isolate-only` | `prep`, `prep-only` |
286
+ | `think`, `think-only` | `design`, `design-only` |
287
+ | `plan`, `plan-only` | `design`, `design-only` |
288
+ | `build`, `build-only` | `build`, `build-only` |
289
+ | `review`, `review-only` | `verify`, `verify-only` |
290
+ | `ship`, `ship-only` | `ship`, `ship-only` |
291
+ | `land`, `land-only` | `ship`, `ship-only` |
292
+ | `cleanup`, `cleanup-only` | `close`, `close-only` |
293
+
294
+ **`--status` 行为规则**:
295
+ - 执行 `node scripts/render-sprint-progress.cjs`,读取 `.sprint-state/sprint-state.json` 并渲染 ASCII 进度看板
296
+ - 如果 `sprint-state.json` 不存在 → `[INFO] 未找到活跃的 Sprint`
297
+ - 如果 `status == "completed"` → 输出完整看板 + `[INFO] Sprint 已完成。`
298
+ - `--status` 可与其他参数组合:`--status --resume-from build` → 先展示状态,再提示 "将从 Phase 3/6 BUILD 继续"
299
+
300
+ **`--resume-from` 限制**:校验为**尽力而为**(git commit 可被 GC 回收、文件 mtime 可被 `git checkout` 修改)。校验失败时输出完整诊断日志,建议启动新 Sprint。
301
+
302
+ **项目类型自动检测**(按顺序检查):
303
+
304
+ | 检测条件 | 类型 |
305
+ |---------|------|
306
+ | `package.json` + `next.config.js` | `web-nextjs` |
307
+ | `package.json` + `vite.config.ts` + react 依赖 | `web-react` |
308
+ | `package.json` + vue 依赖 | `web-vue` |
309
+ | `pubspec.yaml` + `flutter:` | `mobile-flutter` |
310
+ | `package.json` + react-native 依赖 or `ios/` + `android/` | `mobile-react-native` |
311
+ | `go.mod` | `backend-go` (可选 k6) |
312
+ | `pom.xml` | `backend-springboot` (可选 gatling) |
313
+ | `manage.py` 或 `pyproject.toml` (django) | `backend-django` (可选 locust) |
314
+ | 无匹配 | `backend-cli` |
315
+
316
+ **项目类型 → Skill 注入映射**:
317
+
318
+ | Phase | Backend (default) | Web Frontend | Mobile | Load Test |
319
+ |-------|------------------|-------------|--------|-----------|
320
+ | 2/6 DESIGN | `grill-with-docs` + R1 `delphi-review --mode requirements` + `batch-grill-me` + R2 `delphi-review` | + OPTIONAL `design-shotgun` | (同 web) | (通用) |
321
+ | 3/6 BUILD | TDD + blind-review (read-only subagent) | (同 backend) | + `vercel-react-native-skills` / `flutter-review` | (同) |
322
+ | 4/6 VERIFY | `delphi-review --mode code-walkthrough` + `test-specification-alignment` + `xp-gate check --all` + k6/locust/gatling | + `xp-gate ui-review` + OPTIONAL qa/design-review/benchmark | Flutter: `flutter-test` / RN: `detox E2E` | k6/locust/gatling |
323
+ | 4/6 VERIFY (Feedback) | learnings.md + `xp-gate retro` | (同) | (同) | (同) |
324
+ | 5/6 SHIP | VERSION-GATE + 原生 4 选项 + native ship + native land | (同) | + platform deploy | (同) |
325
+ | 6/6 CLOSE | — 人工验收 → #369 返工指标 → cleanup | (同) | (同) | (同) |
326
+ | Browse | Layer 4 可选链 (gstack browse > browser-use MCP > SKIP) | 部署 URL + 表单/交互 | Flutter Web / RN Web | (专用) |
327
+
328
+ **Mobile 工具链**: Flutter — `flutter analyze/test/build/pub publish`; RN — `metro/detox/jest/react-native run-ios/android`
329
+
330
+ ---
331
+
332
+ ## 状态管理
333
+
334
+ **Sprint State**: 存储于 `<project-root>/.sprint-state/` — `sprint-state.yaml`/`.json` + `phase-outputs/` (pain-document.md / specification.yaml / mvp-v1 / review-report.md / emergent-issues.md / feedback-log.md / sprint-summary.md)
335
+
336
+ **Sprint 2 自动触发**: Phase 6/6 CLOSE 完成时 — `emergent_issues_count == 0` → 结束; `> 0` → Critical 自动启动 Sprint 2, Major/Minor 询问用户
337
+
338
+ ---
339
+
340
+ ### ⭐ Phase State Persistence(阶段状态持久化 — MANDATORY)
341
+
342
+ **编排器必须在每个 Phase 完成后更新 `.sprint-state/sprint-state.json`**:
343
+
344
+ 1. **Phase 完成后立即更新**(每个 Phase 结束前):
345
+ - `phase`: 更新为当前 Phase 编号(如 `1`, `2`, `3`...)
346
+ - `status`: 更新为 `"completed"`(已完成 Phase)
347
+ - `phase_history`: 追加新条目
348
+
349
+ 2. **`phase_history` 数组条目 schema**:
350
+ ```json
351
+ {
352
+ "phase": 1,
353
+ "phase_name": "PREP",
354
+ "status": "completed",
355
+ "timestamp": "2026-07-08T10:30:00Z"
356
+ }
357
+ ```
358
+
359
+ 3. **检查点**:
360
+ - `--status` 参数读取 `sprint-state.json` 并渲染进度看板
361
+ - TUI panel 显示当前 Phase 和历史
362
+ - `--resume-from` 校验 `phase_history` 中的最后完成 Phase
363
+
364
+ 4. **完整 sprint-state.json 示例**:
365
+ ```json
366
+ {
367
+ "id": "sprint-2026-07-08-01",
368
+ "phase": 3,
369
+ "status": "in_progress",
370
+ "phase_history": [
371
+ {"phase": 1, "phase_name": "PREP", "status": "completed", "timestamp": "2026-07-08T10:00:00Z"},
372
+ {"phase": 2, "phase_name": "DESIGN", "status": "completed", "timestamp": "2026-07-08T10:30:00Z"}
373
+ ],
374
+ "isolation": {
375
+ "worktree_path": "/home/boyingliu01/projects/xp-gate/.worktrees/sprint/sprint-2026-07-08-01",
376
+ "branch": "sprint/2026-07-08-01"
377
+ },
378
+ "outputs": {
379
+ "pain_document": "phase-outputs/phase-2-summary.md",
380
+ "specification": "phase-outputs/specification.yaml"
381
+ },
382
+ "metrics": {
383
+ "coverage_pct": 85.5
384
+ }
385
+ }
386
+ ```
387
+
388
+ **Backward compat**: Old sprint-state.json files using negative/legacy phase numbers (`-1`, `-0.5`, `0`..`8`) remain readable. Dashboard renders them as-is. New sprints use phase numbers 1-6.
389
+
390
+ ---
391
+
392
+ ## 使用示例
393
+
394
+ | 场景 | 命令 | 说明 |
395
+ |------|------|------|
396
+ | 完整流水线 | `/sprint-flow "开发访谈机器人"` | 自动执行 6 阶段 → specification.yaml + PR URL |
397
+ | 设计后停止 | `/sprint-flow "开发认证模块" --stop-at design` | 输出 specification.yaml 后停止,供评审 |
398
+ | 仅构建阶段 | `/sprint-flow "开发 API" --lang django --phase build-only` | 跳过准备/设计,直接 Build |
399
+
400
+ ## 底层 Skills 保持独立
401
+
402
+ 所有被调用的 Skills 独立可用:`delphi-review` (单独评审), `test-driven-development` (TDD),sprint-flow 仅自动串联
403
+
404
+ ---
405
+
406
+ ## Output Contract
407
+
408
+ **Phase Summary** (每个 Phase 必须输出 YAML frontmatter): `phase/N`, `phase_name`, `status`, `outputs[]`, `decisions[]`, `next_phase_context` + markdown body (≤50 lines)
409
+
410
+ **Sprint State JSON**: `{id, phase, status, phase_history[], isolation {worktree_path, branch}, outputs, metrics}` — 存储于 `.sprint-state/sprint-state.json`
411
+
412
+ **Final User-Facing Output**: Phase/status, file paths, validation results, next user decision, PR URL or cleanup report
413
+
414
+ ### Eval Assertions
415
+ - `phase`, `phase_name`, `status`, `outputs`, `decisions`, `next_phase_context`
416
+ - `id`, `isolation.worktree_path`, `isolation.branch`, `metrics.coverage_pct`
417
+
418
+ ## References
419
+
420
+ 详细指令文件位于 `@references/`:
421
+
422
+ | File | Phase | Phase Name | Maps From (Old) |
423
+ |------|-------|------------|-----------------|
424
+ | `@references/phase-1-prep.md` | 1/6 | PREP | Phase -1 ISOLATE + Phase -0.5 AUTO-ESTIMATE |
425
+ | `@references/phase-2-design.md` | 2/6 | DESIGN | Phase 0 THINK + Phase 1 PLAN |
426
+ | `@references/phase-3-build.md` | 3/6 | BUILD | Phase 2 BUILD |
427
+ | `@references/phase-4-verify.md` | 4/6 | VERIFY | Phase 3 REVIEW + Phase 4 FEEDBACK |
428
+ | `@references/phase-5-ship.md` | 5/6 | SHIP | Phase 5 SHIP + Phase 6 LAND |
429
+ | `@references/phase-6-close.md` | 6/6 | CLOSE | Phase 7 USER ACCEPTANCE + Phase 8 CLEANUP |
430
+
431
+ Additional reference files:
432
+ - `@references/force-levels.md` — Phase forcing rules
433
+ - `@references/orchestration-rules.md` — Orchestration layer rules
434
+
435
+ - `@references/components/` — Reusable phase building blocks
436
+
437
+ ---
438
+
439
+ ## Templates
440
+
441
+ 模板文件位于 `@templates/`:
442
+ - `@templates/pain-document-template.md` — Pain Document 模板 (Phase 2/6 DESIGN)
443
+ - `@templates/emergent-issues-template.md` — Emergent Issues 检查清单 (Phase 6/6 CLOSE)
444
+ - `@templates/sprint-summary-template.md` — Sprint Summary 模板 (Phase 6/6 CLOSE)
445
+ - `@templates/sprint-progress-template.md` — Sprint 进度看板(每个 Phase 完成后 + `--status` 查询时渲染)
446
+ - `@templates/auto-estimate-output-template.md` — AUTO-ESTIMATE 输出格式 (Phase 1/6 PREP)
447
+
448
+ ---
449
+
450
+ ## 研究证据
451
+
452
+ | 证据 | 来源 | 应用 |
453
+ |------|------|------|
454
+ | One-shot = 单次迭代执行 | Boris Cherny interview | Phase 3/6 BUILD 设计 |
455
+ | 80% session 从 Plan Mode 开始 | Boris skill | Phase 2/6 DESIGN 设计 |
456
+ | Verification improves 2-3x | Boris #1 tip | Phase 4/6 VERIFY 设计 |
457
+ | Emergent requirements 无法消除 | Mike Cohn, Rafael Santos | Phase 6/6 CLOSE 人工设计 |
458
+ | 78% failures invisible | arXiv research | Phase 6/6 必要性证明 |
459
+ | Think → Plan → Build → Ship | 行业通用流程 | 整体流程设计 |
460
+
461
+ ---
462
+
463
+ ## Phase Flow Consistency
464
+
465
+ This section documents the canonical 6-phase order to ensure all future edits keep the phase sequence synchronized across all locations in this document and its reference files.
466
+
467
+ **Canonical Phase Order** (Phase 1/6..6/6):
468
+
469
+ | Phase # | Name | Phase # | Name |
470
+ |---------|------|---------|------|
471
+ | 1/6 | PREP | 4/6 | VERIFY |
472
+ | 2/6 | DESIGN | 5/6 | SHIP |
473
+ | 3/6 | BUILD | 6/6 | CLOSE |
474
+
475
+ **Locations that MUST keep this order synchronized**:
476
+ 1. **Frontmatter `workflow_steps`** — Phase list
477
+ 2. **Frontmatter `description` trigger text** — Flow string
478
+ 3. **Body "完整流程" section** — Phase descriptions in order
479
+ 4. **Body "Phase Flow" diagram** — ASCII flow diagram
480
+ 5. **Body "强制输出格式规范" section** — Output format
481
+ 6. **Body "Workflow Steps" table** — Step/Phase table
482
+ 7. **Body "References" section** — Reference file list
483
+ 8. **`references/orchestration-rules.md` Phase Subagent Dispatch Matrix** — Phase/Name order
484
+ 9. **`references/force-levels.md`** — Phase references
485
+
486
+ **⚠️ Migration from old 11-phase model (v2.0)**: The 6-phase model was introduced in Issue #290 to reduce cognitive load. Old sprint-state.json files with negative/legacy phase numbers remain backward-compatible.
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env bash
2
+ # sprint-flow: Verify sprint state integrity
3
+ # Checks that sprint-state.json is valid JSON and all expected keys exist.
4
+ #
5
+ # Usage: bash verify-sprint-state.sh [sprint-state-dir]
6
+
7
+ set -euo pipefail
8
+
9
+ STATE_DIR="${1:-.sprint-state}"
10
+ STATE_FILE="$STATE_DIR/sprint-state.json"
11
+
12
+ if [ ! -f "$STATE_FILE" ]; then
13
+ echo "SKIP: No sprint-state.json found at $STATE_FILE"
14
+ exit 0
15
+ fi
16
+
17
+ # Validate JSON
18
+ if ! command -v node &>/dev/null; then
19
+ echo "WARN: node not available, skipping JSON validation"
20
+ exit 0
21
+ fi
22
+
23
+ node -e "
24
+ const fs = require('fs');
25
+ try {
26
+ const data = JSON.parse(fs.readFileSync('$STATE_FILE', 'utf8'));
27
+ const requiredKeys = ['sprint_id', 'status', 'current_phase', 'phases'];
28
+ const missing = requiredKeys.filter(k => !(k in data));
29
+ if (missing.length > 0) {
30
+ console.error('ERROR: Missing required keys in sprint-state.json:', missing.join(', '));
31
+ process.exit(1);
32
+ }
33
+ console.log('OK: sprint-state.json is valid with all required keys');
34
+ } catch (e) {
35
+ console.error('ERROR: sprint-state.json is not valid JSON:', e.message);
36
+ process.exit(1);
37
+ }
38
+ "
@@ -0,0 +1,29 @@
1
+ # Tools Whitelist — Sprint Flow
2
+
3
+ Sprint Flow is an **orchestration skill** that coordinates subagents and system commands.
4
+ It does NOT implement code directly — it delegates implementation to subagents.
5
+
6
+ ## Allowed Tools
7
+
8
+ | Tool | Usage | Rationale |
9
+ |------|-------|-----------|
10
+ | `Bash(git, gh, npm, node)` | git worktree/branch/commit, gh PR/release, npm/node CLI | Required for sprint infrastructure management |
11
+ | `Read` | Read project files, configs, docs | Required for context gathering |
12
+ | `Write` | Write sprint-state, specification.yaml, phase summaries | Required for sprint state persistence |
13
+ | `Edit` | Edit sprint-state, CHANGELOG, VERSION | Required for version management |
14
+ | `Glob` | Find project files by pattern | Required for project discovery |
15
+ | `Grep` | Search file contents | Required for codebase understanding |
16
+ | `Task` | Delegate to subagents (quick, deep, unspecified-high) | Core orchestration mechanism |
17
+ | `Skill` | Invoke integrated skills (brainstorming, autoplan, delphi-review, etc.) | Required for skill chain execution |
18
+ | `TodoWrite` | Track sprint progress | Required for progress visibility |
19
+ | `Question` | Ask user at decision gates | Required for user decision points |
20
+
21
+ ## Denied Tools
22
+
23
+ | Tool | Rationale |
24
+ |------|-----------|
25
+ | `rm -rf (any recursive force remove)` | Destructive — sprint flow only cleans up via `git worktree remove` |
26
+ | `git push --force` | Destructive — never force push during sprint |
27
+ | `DROP TABLE or destructive DB operations` | Destructive — sprint flow orchestrates, does not manage databases |
28
+ | `Write(source code)` | Sprint flow NEVER writes implementation code directly — delegates to subagents via `Task` |
29
+ | `Edit(source code)` | Sprint flow NEVER edits implementation code — delegates to subagents via `Task` |
@@ -1,9 +1,9 @@
1
1
  # SKILLS/TEST-SPECIFICATION-ALIGNMENT KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-09-22
4
- **Commit:** 3d1d1bf
5
- **Branch:** main
6
- **Version:** 0.19.2.0
3
+ **Generated:** 2026-10-07
4
+ **Commit:** ff55f35b
5
+ **Branch:** fix/batch-defects-20261007
6
+ **Version:** 0.20.0.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.