@boyingliu01/xp-gate 0.7.0 → 0.8.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 (197) hide show
  1. package/bin/xp-gate.js +4 -9
  2. package/lib/__tests__/audit-log.test.ts +107 -0
  3. package/lib/__tests__/detect-deps.test.js +212 -42
  4. package/lib/__tests__/doctor.test.js +1 -0
  5. package/lib/__tests__/gate-audit.test.ts +59 -0
  6. package/lib/__tests__/init.test.js +47 -1
  7. package/lib/__tests__/install-skill.test.js +1 -45
  8. package/lib/__tests__/ui-detector.test.ts +186 -26
  9. package/lib/__tests__/ui-review.test.ts +119 -0
  10. package/lib/__tests__/uninstall.test.js +1 -0
  11. package/lib/detect-deps.js +180 -37
  12. package/lib/doctor.js +7 -9
  13. package/lib/gate-audit.ts +26 -42
  14. package/lib/init.js +42 -13
  15. package/lib/install-skill.js +20 -48
  16. package/lib/rollback.js +1 -16
  17. package/lib/shared-paths.js +30 -0
  18. package/lib/shared-utils.js +25 -0
  19. package/lib/ui-detector.ts +20 -14
  20. package/lib/ui-review.ts +58 -53
  21. package/lib/uninstall.js +8 -9
  22. package/package.json +1 -1
  23. package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
  24. package/plugins/claude-code/skills/admin-template-guidelines/SKILL.md +904 -0
  25. package/plugins/claude-code/skills/delphi-review/.delphi-config.json.example +45 -0
  26. package/plugins/claude-code/skills/delphi-review/AGENTS.md +66 -0
  27. package/plugins/claude-code/skills/delphi-review/INSTALL.md +152 -0
  28. package/plugins/claude-code/skills/delphi-review/SKILL.md +454 -0
  29. package/plugins/claude-code/skills/delphi-review/opencode.json.delphi.example +56 -0
  30. package/plugins/claude-code/skills/delphi-review/references/code-walkthrough.md +486 -0
  31. package/plugins/claude-code/skills/improve-codebase-architecture/SKILL.md +156 -0
  32. package/plugins/claude-code/skills/ralph-loop/SKILL.md +501 -0
  33. package/plugins/claude-code/skills/ralph-loop/references/components/memory.md +55 -0
  34. package/plugins/claude-code/skills/ralph-loop/references/components/middleware.md +54 -0
  35. package/plugins/claude-code/skills/ralph-loop/references/components/skill-invocations.md +39 -0
  36. package/plugins/claude-code/skills/ralph-loop/references/components/system-prompt.md +24 -0
  37. package/plugins/claude-code/skills/ralph-loop/references/components/tool-descriptions.md +32 -0
  38. package/plugins/claude-code/skills/ralph-loop/references/phase-2-build-ralph.md +89 -0
  39. package/plugins/claude-code/skills/ralph-loop/templates/progress-log.md +36 -0
  40. package/plugins/claude-code/skills/sprint-flow/AGENTS.md +68 -0
  41. package/plugins/claude-code/skills/sprint-flow/SKILL.md +1248 -0
  42. package/plugins/claude-code/skills/sprint-flow/references/components/memory.md +87 -0
  43. package/plugins/claude-code/skills/sprint-flow/references/components/middleware.md +72 -0
  44. package/plugins/claude-code/skills/sprint-flow/references/components/skill-invocations.md +104 -0
  45. package/plugins/claude-code/skills/sprint-flow/references/components/system-prompt.md +27 -0
  46. package/plugins/claude-code/skills/sprint-flow/references/components/tool-descriptions.md +96 -0
  47. package/plugins/claude-code/skills/sprint-flow/references/force-levels.md +203 -0
  48. package/plugins/claude-code/skills/sprint-flow/references/phase-0-think.md +115 -0
  49. package/plugins/claude-code/skills/sprint-flow/references/phase-1-plan.md +178 -0
  50. package/plugins/claude-code/skills/sprint-flow/references/phase-2-build.md +198 -0
  51. package/plugins/claude-code/skills/sprint-flow/references/phase-3-review.md +213 -0
  52. package/plugins/claude-code/skills/sprint-flow/references/phase-4-uat.md +125 -0
  53. package/plugins/claude-code/skills/sprint-flow/references/phase-5-feedback.md +100 -0
  54. package/plugins/claude-code/skills/sprint-flow/references/phase-6-ship.md +193 -0
  55. package/plugins/claude-code/skills/sprint-flow/references/phase-7-land.md +140 -0
  56. package/plugins/claude-code/skills/sprint-flow/references/phase-8-cleanup.md +192 -0
  57. package/plugins/claude-code/skills/sprint-flow/references/phase-minus-0-5-auto-estimate.md +257 -0
  58. package/plugins/claude-code/skills/sprint-flow/templates/auto-estimate-learning-log.md +136 -0
  59. package/plugins/claude-code/skills/sprint-flow/templates/auto-estimate-output-template.md +132 -0
  60. package/plugins/claude-code/skills/sprint-flow/templates/emergent-issues-template.md +120 -0
  61. package/plugins/claude-code/skills/sprint-flow/templates/pain-document-template.md +115 -0
  62. package/plugins/claude-code/skills/sprint-flow/templates/sprint-progress-template.md +151 -0
  63. package/plugins/claude-code/skills/sprint-flow/templates/sprint-summary-template.md +120 -0
  64. package/plugins/claude-code/skills/test-driven-development/SKILL.md +71 -0
  65. package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +56 -0
  66. package/plugins/claude-code/skills/test-specification-alignment/SKILL.md +702 -0
  67. package/plugins/claude-code/skills/test-specification-alignment/references/alignment-verification-algorithm.md +493 -0
  68. package/plugins/claude-code/skills/test-specification-alignment/references/phase2-constraint-enforcement.md +431 -0
  69. package/plugins/claude-code/skills/test-specification-alignment/references/specification-format.md +348 -0
  70. package/plugins/claude-code/skills/to-issues/SKILL.md +277 -0
  71. package/plugins/opencode/README.md +38 -0
  72. package/plugins/opencode/index.ts +85 -0
  73. package/plugins/opencode/package.json +18 -0
  74. package/plugins/opencode/skills/admin-template-guidelines/SKILL.md +904 -0
  75. package/plugins/opencode/skills/delphi-review/.delphi-config.json.example +45 -0
  76. package/plugins/opencode/skills/delphi-review/AGENTS.md +66 -0
  77. package/plugins/opencode/skills/delphi-review/INSTALL.md +152 -0
  78. package/plugins/opencode/skills/delphi-review/SKILL.md +454 -0
  79. package/plugins/opencode/skills/delphi-review/opencode.json.delphi.example +56 -0
  80. package/plugins/opencode/skills/delphi-review/references/code-walkthrough.md +486 -0
  81. package/plugins/opencode/skills/improve-codebase-architecture/SKILL.md +156 -0
  82. package/plugins/opencode/skills/ralph-loop/SKILL.md +501 -0
  83. package/plugins/opencode/skills/ralph-loop/references/components/memory.md +55 -0
  84. package/plugins/opencode/skills/ralph-loop/references/components/middleware.md +54 -0
  85. package/plugins/opencode/skills/ralph-loop/references/components/skill-invocations.md +39 -0
  86. package/plugins/opencode/skills/ralph-loop/references/components/system-prompt.md +24 -0
  87. package/plugins/opencode/skills/ralph-loop/references/components/tool-descriptions.md +32 -0
  88. package/plugins/opencode/skills/ralph-loop/references/phase-2-build-ralph.md +89 -0
  89. package/plugins/opencode/skills/ralph-loop/templates/progress-log.md +36 -0
  90. package/plugins/opencode/skills/sprint-flow/AGENTS.md +68 -0
  91. package/plugins/opencode/skills/sprint-flow/SKILL.md +1248 -0
  92. package/plugins/opencode/skills/sprint-flow/references/components/memory.md +87 -0
  93. package/plugins/opencode/skills/sprint-flow/references/components/middleware.md +72 -0
  94. package/plugins/opencode/skills/sprint-flow/references/components/skill-invocations.md +104 -0
  95. package/plugins/opencode/skills/sprint-flow/references/components/system-prompt.md +27 -0
  96. package/plugins/opencode/skills/sprint-flow/references/components/tool-descriptions.md +96 -0
  97. package/plugins/opencode/skills/sprint-flow/references/force-levels.md +203 -0
  98. package/plugins/opencode/skills/sprint-flow/references/phase-0-think.md +115 -0
  99. package/plugins/opencode/skills/sprint-flow/references/phase-1-plan.md +178 -0
  100. package/plugins/opencode/skills/sprint-flow/references/phase-2-build.md +198 -0
  101. package/plugins/opencode/skills/sprint-flow/references/phase-3-review.md +213 -0
  102. package/plugins/opencode/skills/sprint-flow/references/phase-4-uat.md +125 -0
  103. package/plugins/opencode/skills/sprint-flow/references/phase-5-feedback.md +100 -0
  104. package/plugins/opencode/skills/sprint-flow/references/phase-6-ship.md +193 -0
  105. package/plugins/opencode/skills/sprint-flow/references/phase-7-land.md +140 -0
  106. package/plugins/opencode/skills/sprint-flow/references/phase-8-cleanup.md +192 -0
  107. package/plugins/opencode/skills/sprint-flow/references/phase-minus-0-5-auto-estimate.md +257 -0
  108. package/plugins/opencode/skills/sprint-flow/templates/auto-estimate-learning-log.md +136 -0
  109. package/plugins/opencode/skills/sprint-flow/templates/auto-estimate-output-template.md +132 -0
  110. package/plugins/opencode/skills/sprint-flow/templates/emergent-issues-template.md +120 -0
  111. package/plugins/opencode/skills/sprint-flow/templates/pain-document-template.md +115 -0
  112. package/plugins/opencode/skills/sprint-flow/templates/sprint-progress-template.md +151 -0
  113. package/plugins/opencode/skills/sprint-flow/templates/sprint-summary-template.md +120 -0
  114. package/plugins/opencode/skills/test-driven-development/SKILL.md +71 -0
  115. package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +56 -0
  116. package/plugins/opencode/skills/test-specification-alignment/SKILL.md +702 -0
  117. package/plugins/opencode/skills/test-specification-alignment/references/alignment-verification-algorithm.md +493 -0
  118. package/plugins/opencode/skills/test-specification-alignment/references/phase2-constraint-enforcement.md +431 -0
  119. package/plugins/opencode/skills/test-specification-alignment/references/specification-format.md +348 -0
  120. package/plugins/opencode/skills/to-issues/SKILL.md +277 -0
  121. package/plugins/opencode/tsconfig.json +15 -0
  122. package/plugins/qoder/skills/admin-template-guidelines/SKILL.md +904 -0
  123. package/plugins/qoder/skills/delphi-review/.delphi-config.json.example +45 -0
  124. package/plugins/qoder/skills/delphi-review/AGENTS.md +66 -0
  125. package/plugins/qoder/skills/delphi-review/INSTALL.md +152 -0
  126. package/plugins/qoder/skills/delphi-review/SKILL.md +454 -0
  127. package/plugins/qoder/skills/delphi-review/opencode.json.delphi.example +56 -0
  128. package/plugins/qoder/skills/delphi-review/references/code-walkthrough.md +486 -0
  129. package/plugins/qoder/skills/improve-codebase-architecture/SKILL.md +156 -0
  130. package/plugins/qoder/skills/ralph-loop/SKILL.md +501 -0
  131. package/plugins/qoder/skills/ralph-loop/references/components/memory.md +55 -0
  132. package/plugins/qoder/skills/ralph-loop/references/components/middleware.md +54 -0
  133. package/plugins/qoder/skills/ralph-loop/references/components/skill-invocations.md +39 -0
  134. package/plugins/qoder/skills/ralph-loop/references/components/system-prompt.md +24 -0
  135. package/plugins/qoder/skills/ralph-loop/references/components/tool-descriptions.md +32 -0
  136. package/plugins/qoder/skills/ralph-loop/references/phase-2-build-ralph.md +89 -0
  137. package/plugins/qoder/skills/ralph-loop/templates/progress-log.md +36 -0
  138. package/plugins/qoder/skills/sprint-flow/AGENTS.md +68 -0
  139. package/plugins/qoder/skills/sprint-flow/SKILL.md +1248 -0
  140. package/plugins/qoder/skills/sprint-flow/references/components/memory.md +87 -0
  141. package/plugins/qoder/skills/sprint-flow/references/components/middleware.md +72 -0
  142. package/plugins/qoder/skills/sprint-flow/references/components/skill-invocations.md +104 -0
  143. package/plugins/qoder/skills/sprint-flow/references/components/system-prompt.md +27 -0
  144. package/plugins/qoder/skills/sprint-flow/references/components/tool-descriptions.md +96 -0
  145. package/plugins/qoder/skills/sprint-flow/references/force-levels.md +203 -0
  146. package/plugins/qoder/skills/sprint-flow/references/phase-0-think.md +115 -0
  147. package/plugins/qoder/skills/sprint-flow/references/phase-1-plan.md +178 -0
  148. package/plugins/qoder/skills/sprint-flow/references/phase-2-build.md +198 -0
  149. package/plugins/qoder/skills/sprint-flow/references/phase-3-review.md +213 -0
  150. package/plugins/qoder/skills/sprint-flow/references/phase-4-uat.md +125 -0
  151. package/plugins/qoder/skills/sprint-flow/references/phase-5-feedback.md +100 -0
  152. package/plugins/qoder/skills/sprint-flow/references/phase-6-ship.md +193 -0
  153. package/plugins/qoder/skills/sprint-flow/references/phase-7-land.md +140 -0
  154. package/plugins/qoder/skills/sprint-flow/references/phase-8-cleanup.md +192 -0
  155. package/plugins/qoder/skills/sprint-flow/references/phase-minus-0-5-auto-estimate.md +257 -0
  156. package/plugins/qoder/skills/sprint-flow/templates/auto-estimate-learning-log.md +136 -0
  157. package/plugins/qoder/skills/sprint-flow/templates/auto-estimate-output-template.md +132 -0
  158. package/plugins/qoder/skills/sprint-flow/templates/emergent-issues-template.md +120 -0
  159. package/plugins/qoder/skills/sprint-flow/templates/pain-document-template.md +115 -0
  160. package/plugins/qoder/skills/sprint-flow/templates/sprint-progress-template.md +151 -0
  161. package/plugins/qoder/skills/sprint-flow/templates/sprint-summary-template.md +120 -0
  162. package/plugins/qoder/skills/test-driven-development/SKILL.md +71 -0
  163. package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +56 -0
  164. package/plugins/qoder/skills/test-specification-alignment/SKILL.md +702 -0
  165. package/plugins/qoder/skills/test-specification-alignment/references/alignment-verification-algorithm.md +493 -0
  166. package/plugins/qoder/skills/test-specification-alignment/references/phase2-constraint-enforcement.md +431 -0
  167. package/plugins/qoder/skills/test-specification-alignment/references/specification-format.md +348 -0
  168. package/plugins/qoder/skills/to-issues/SKILL.md +277 -0
  169. package/skills/admin-template-guidelines/SKILL.md +904 -0
  170. package/skills/delphi-review/SKILL.md +112 -77
  171. package/skills/improve-codebase-architecture/SKILL.md +156 -0
  172. package/skills/ralph-loop/SKILL.md +165 -34
  173. package/skills/sprint-flow/SKILL.md +448 -107
  174. package/skills/sprint-flow/references/components/skill-invocations.md +1 -1
  175. package/skills/sprint-flow/references/components/tool-descriptions.md +1 -1
  176. package/skills/sprint-flow/references/force-levels.md +203 -0
  177. package/skills/sprint-flow/references/phase-1-plan.md +4 -4
  178. package/skills/sprint-flow/references/phase-minus-0-5-auto-estimate.md +20 -1
  179. package/skills/sprint-flow/templates/auto-estimate-output-template.md +7 -5
  180. package/skills/sprint-flow/templates/sprint-progress-template.md +151 -0
  181. package/skills/test-driven-development/SKILL.md +71 -0
  182. package/skills/test-specification-alignment/SKILL.md +98 -24
  183. package/skills/to-issues/SKILL.md +277 -0
  184. package/plugins/qoder/AGENTS.md +0 -93
  185. package/plugins/qoder/README.md +0 -87
  186. package/plugins/qoder/widgets/quality-report.html +0 -163
  187. package/plugins/qoder/widgets/sprint-dashboard.html +0 -172
  188. package/skills/delphi-review/evals/evals.json +0 -82
  189. package/skills/delphi-review/references/qoder-multi-model.md +0 -191
  190. package/skills/ralph-loop/evals/evals.json +0 -311
  191. package/skills/ralph-loop/evolution-history.json +0 -59
  192. package/skills/ralph-loop/evolution-log.md +0 -16
  193. package/skills/sprint-flow/evals/evals.json +0 -130
  194. package/skills/sprint-flow/evolution-history.json +0 -39
  195. package/skills/sprint-flow/evolution-log.md +0 -23
  196. package/skills/sprint-flow/references/qoder-adaptation.md +0 -173
  197. package/skills/test-specification-alignment/evals/evals.json +0 -75
@@ -0,0 +1,1248 @@
1
+ ---
2
+ name: sprint-flow
3
+ description: >
4
+ One-Shot Sprint 自动流水线。单一入口,自动串联 Think → Plan → Build →
5
+ Review → Ship 流程。整合 brainstorming + autoplan + delphi-review + TDD +
6
+ delphi-review --mode code-walkthrough + ship 等现有 Skills。关键节点暂停等待用户决策。
7
+ 承认 Emergent Requirements 限制,设计用户验收环节。
8
+
9
+ TRIGGER:
10
+ - "开发新功能"
11
+ - "实现 X"
12
+ - "start sprint"
13
+ - "一键开发"
14
+ - "/sprint-flow"
15
+ 用法: /sprint-flow "[需求描述]"
16
+ 示例: /sprint-flow "开发访谈机器人,支持多轮对话"
17
+ 可选参数:
18
+ --no-isolate: 跳过自动 worktree 隔离(⚠️ 在保护分支上有污染风险)
19
+ --branch-name <name>: 自定义分支名(默认自动生成 sprint/YYYY-MM-DD-NN)
20
+ --force: 强制在当前分支继续(即使已是保护分支,⚠️ 输出警告)
21
+ --stop-at <phase>: 执行到指定阶段后停止 (isolate/think/plan/build/review/ship/land/cleanup)
22
+ --resume-from <phase>: 从指定阶段继续,跳过前面阶段
23
+ --phase <phase>: 只执行单个阶段 (isolate-only/think-only/plan-only/build-only/review-only/ship-only/land-only/cleanup-only)
24
+ --lang <language>: 指定项目语言 (springboot/django/golang)
25
+ --type <project_type>: 指定项目类型 (web-nextjs/web-react/web-vue/mobile-flutter/mobile-react-native/backend-django/backend-go/backend-springboot)
26
+ --spec <file>: 使用已有的 specification.yaml 文件
27
+ --with-performance: 启用负载/压力测试(后端项目)
28
+ --mode <build_mode>: 指定 Phase 2 构建模式。默认 = ralph-loop(逐 REQ 迭代,token 节约)。parallel = 旧有并行模式(一次性 dispatch 所有需求)
29
+ --status: 查看当前 Sprint 进度看板(不执行任何阶段,仅读取 sprint-state.json 并渲染进度)
30
+ Use when asked to "开发新功能", "实现 X", "start sprint", "一键开发", or "/sprint-flow" for end-to-end feature development.
31
+ maturity: beta
32
+ ---
33
+
34
+ ## Triggers
35
+
36
+ | Trigger Type | Phrases |
37
+ |--------------|---------|
38
+ | **中文** | "开发新功能", "实现 X", "start sprint", "一键开发", "/sprint-flow", "开发用户登录", "创建 XXX 模块" |
39
+ | **English** | "implement feature", "build X", "start sprint", "one-shot development", "create XXX", "develop new functionality" |
40
+
41
+ **Usage**: `/sprint-flow "[需求描述]"`
42
+
43
+ **Examples**:
44
+ - `/sprint-flow "开发访谈机器人,支持多轮对话"`
45
+ - `/sprint-flow "实现用户认证模块,支持 OAuth2"`
46
+ - `/sprint-flow "开发 REST API 端点"`
47
+
48
+ **Optional Parameters**:
49
+ - `--no-isolate`: Skip auto worktree isolation (⚠️ risk of polluting protected branches)
50
+ - `--branch-name <name>`: Custom branch name (default: `sprint/YYYY-MM-DD-NN`)
51
+ - `--force`: Force continue on current branch even if protected (⚠️ requires explicit confirmation)
52
+ - `--stop-at <phase>`: Stop after specified phase (isolate/think/plan/build/review/ship/land/cleanup)
53
+ - `--resume-from <phase>`: Resume from specified phase, skipping earlier phases
54
+ - `--phase <phase>`: Execute only single phase (isolate-only/think-only/plan-only/build-only/review-only/ship-only/land-only/cleanup-only)
55
+ - `--lang <language>`: Specify project language (springboot/django/golang)
56
+ - `--type <project_type>`: Specify project type (web-nextjs/web-react/web-vue/mobile-flutter/mobile-react-native/backend-django/backend-go/backend-springboot)
57
+ - `--spec <file>`: Use existing specification.yaml file
58
+ - `--with-performance`: Enable load/stress testing (backend projects)
59
+ - `--mode <build_mode>`: Phase 2 build mode. Default = ralph-loop (REQ-level iteration, token-efficient). parallel = legacy all-at-once mode
60
+
61
+ ---
62
+
63
+ ## Scope
64
+
65
+ **What this skill does**:
66
+ - Automates the full 7-phase development pipeline from requirement to production
67
+ - Integrates existing skills (brainstorming, autoplan, delphi-review, TDD, ship, etc.)
68
+ - Enforces quality gates and hard transitions between phases
69
+ - Captures emergent requirements and feedback for continuous improvement
70
+
71
+ **What this skill does NOT do**:
72
+ - Replace individual skills — users can still call `delphi-review`, `test-driven-development`, etc. directly
73
+ - Bypass quality gates or user confirmations at critical checkpoints
74
+ - Automatically merge to main without explicit user approval (Phase 6/7)
75
+ - Handle non-development tasks (bug reports, code review requests without implementation, questions)
76
+
77
+ **Applicable scenarios**:
78
+ - New feature development
79
+ - Module creation
80
+ - End-to-end implementation of user stories
81
+ - Sprint-level planning and execution
82
+
83
+ **Not applicable**:
84
+ - Single bug fixes (use `/investigate` or direct TDD)
85
+ - Code review requests (use `/review` or `delphi-review --mode code-walkthrough`)
86
+ - Architecture questions (use `/plan-eng-review`)
87
+ - Simple explanations or documentation requests
88
+
89
+ ## Examples
90
+
91
+ ### Example 1: Full feature sprint
92
+ User: `/sprint-flow "开发用户认证模块,支持登录、登出、权限检查"`
93
+ Expected behavior: create/verify isolated worktree, run estimate, produce design/spec, build with TDD, review, wait for manual acceptance, then prepare ship path.
94
+ Expected output: phase summaries, `specification.yaml`, verification evidence, and PR URL if the user chooses PR shipping.
95
+
96
+ ### Example 2: Stop after planning
97
+ User: `/sprint-flow "开发 REST API" --stop-at plan`
98
+ Expected behavior: complete isolate/estimate/think/plan, produce specification and slices, then stop without implementation.
99
+ Expected output: phase-1 summary and clear next command to resume from build.
100
+
101
+ ### Example 3: Should not trigger
102
+ User: "解释一下这个函数为什么报错"
103
+ Expected behavior: do not run sprint-flow; route to investigation/explanation instead.
104
+
105
+ # Sprint Flow Skill
106
+
107
+ ## Scope
108
+
109
+ **In Scope:**
110
+ - Sprint 全流程编排(Phase -1 ISOLATE 到 Phase 8 CLEANUP)
111
+ - Git worktree 隔离与环境准备
112
+ - 自动规模评估与流程路由(轻量/标准/复杂)
113
+ - 多 Skill 串联调用(brainstorming, autoplan, delphi-review, TDD, ralph-loop 等)
114
+ - 关键节点暂停与用户决策
115
+ - 状态持久化(sprint-state.json)
116
+ - 多平台适配(Claude Code, OpenCode, Qoder)
117
+
118
+ **Out of Scope:**
119
+ - Does NOT handle internal Skill implementation (each Skill remains independent)
120
+ - Does NOT write business code
121
+ - Does NOT configure CI/CD pipelines (project's own responsibility)
122
+ - Does NOT deploy to production (only up to PR creation + merge)
123
+
124
+ ## Security Notes
125
+
126
+ - sprint-flow **不执行任何破坏性命令**(no `rm -rf`, `git push --force`, `DROP TABLE` 等)
127
+ - `git worktree remove` 仅删除 sprint 创建的临时 worktree 目录,不影响主仓库
128
+ - Phase 6 SHIP 仅创建 PR(`gh pr create`),不自动 merge(除非用户显式确认)
129
+ - Phase 7 LAND 使用 `gh pr merge --squash`(非 force push),merge 前等待 CI 通过
130
+ - 文档中 `+ platform deploy` 等描述仅表示可选的部署步骤映射,**不是可执行命令**
131
+ - sprint-flow 不下载、安装或执行任何外部二进制文件
132
+
133
+ ## Permissions
134
+
135
+ - `git`: read/write (worktree, branch, commit)
136
+ - `gh` (GitHub CLI): read/write (PR create, merge, CI query)
137
+ - `filesystem`: read/write (project dir + `.worktrees/` only)
138
+ - `network`: read-only (CI status, canary health)
139
+
140
+ ## 核心原则
141
+
142
+ | 原则 | 说明 |
143
+ |------|------|
144
+ | **单一入口** | 用户只需调用 `/sprint-flow`,自动串联全流程 |
145
+ | **自动流水线** | 类似 autoplan,自动执行多个阶段 |
146
+ | **关键节点暂停** | APPROVED 确认、Gate 1 通过、Ship 确认、⚠️ Phase 4 必须人工 |
147
+ | **承认 Emergent** | 用户验收环节必须人工,无法自动化(78% 失败不可见) |
148
+ | **复用现有 Skills** | 不重新发明,整合调用现有体系 |
149
+
150
+ ---
151
+
152
+ ## 完整流程(默认无参数)
153
+
154
+ 调用 `/sprint-flow "[需求描述]"` 后,自动执行以下流程:
155
+
156
+ ```
157
+ Phase -1: ISOLATE → ⚠️ 检测保护分支(main/master/develop/trunk/mainline) → 强制创建 git worktree
158
+ → 已在 worktree 中 → 跳过 → 项目 setup → .gitignore 校验 → sprint-state isolation 记录
159
+ Phase -0.5: AUTO-ESTIMATE → 自动评估需求规模 → ⚠️ 展示评估结果,用户确认
160
+ → 轻量:Phase 0-3 以 reduced intensity 执行 THINK/PLAN/review(不跳过 delphi-review)
161
+ → 标准:正常流程 Phase 0-4
162
+ → 复杂:完整流程 Phase 0-8 + 风险警告
163
+ Phase 0: THINK → brainstorming → ⚠️ HARD-GATE: 设计未批准 → 不可进入实现 → Design Document (AI编辑行为约束: 原则3 Surgical Changes, 验证循环要求: 原则4 Goal-Driven Execution - 见 AGENTS.md "## AI CODING DISCIPLINE (Karpathy Principles)")
164
+ Phase 1: PLAN → autoplan → ⚠️ (如有taste_decisions,暂停等用户确认)
165
+ → delphi-review → ⚠️ (等待 APPROVED)
166
+ → 自动生成 specification.yaml(无需独立 skill)
167
+ Phase 2: BUILD → ⚠️ GITHOOKS-GATE: 检查并安装 Git Hooks(缺失→阻断)
168
+ → dispatching-parallel-agents (并行检测) + executing-plans (隔离执行)
169
+ → test-driven-development (RED→GREEN→REFACTOR)
170
+ → freeze (盲评隔离) → requesting-code-review → unfreeze
171
+ → verification-before-completion → ⚠️ (验证失败超过 max 3)
172
+ → MVP v1
173
+ Phase 3: REVIEW → delphi-review --mode code-walkthrough → test-specification-alignment
174
+ → browse → ⚠️ (验证失败)
175
+ Phase 4: ⚠️ ⚠️ USER ACCEPTANCE → 必须人工验收 → Emergent Issues List
176
+ Phase 5: FEEDBACK → learn + retro(工程回顾)+ systematic-debugging(根因调试)
177
+ Phase 6: SHIP → finishing-a-development-branch (4 选项) → ship (PR 路径)
178
+ → PR 创建完成
179
+ Phase 7: ⚠️ LAND → land-and-deploy → merge PR + wait CI + canary health check
180
+ → deploy verification + auto-rollback on failure
181
+ Phase 8: CLEANUP → git worktree remove + branch delete + sprint-state.json update → status: merged
182
+ → Sprint Summary → IF emergent issues → Sprint 2
183
+ ```
184
+
185
+ ---
186
+
187
+ ## 暂停点设计(不是随时停,而是设计明确的暂停点)
188
+
189
+ | 暂停点位置 | 触发条件 | 用户操作 | 自动恢复条件 |
190
+ |-----------|---------|---------|-------------|
191
+ | **Phase -1** | ⚠️ **保护分支强制隔离 / --no-isolate 跳过** | 输出 ⚠️ 警告或自动创建 worktree | 自动创建或用户确认后继续 |
192
+ | **Phase -0.5** | **AUTO-ESTIMATE 结果展示** | 接受建议 / 修改流程 / 取消 | 用户确认后按路由继续 |
193
+ | **Phase 0** | ⚠️ **设计未 APPROVED (HARD-GATE)** | 根据反馈修改设计 | 设计 APPROVED 后继续 |
194
+ | Phase 1 | autoplan surfacing taste_decisions | 用户确认每个决策 | 确认后自动继续 |
195
+ | Phase 1 | delphi-review 未 APPROVED | 修复并重新评审 | APPROVED 后自动继续 |
196
+ | Phase 2 | 验证失败超过 max 3 | 用户决定修复或放弃 | 验证通过后自动继续 |
197
+ | Phase 2 | 成本超阈值 | 用户决定继续或暂停 | 用户确认后自动继续 |
198
+ | Phase 3 | browse 发现问题 | 回退 Phase 2(不暂停) | 验证通过后自动继续 |
199
+ | **Phase 4** | ⚠️ **必须人工验收** | 用户实际使用后确认 | 用户确认后继续 |
200
+ | **Phase 5** | ⚠️ **必须执行,不可跳过 (HARD-GATE)** | Phase 5 完成后进入 Phase 6 | `feedback-log.md` 生成后自动继续 |
201
+ | Phase 6 | finishing-a-development-branch | 用户选择 4 选项 (merge/PR/discard/keep) | 确认后自动继续 |
202
+ | Phase 6 | ship PR 创建(PR 路径)| 用户确认合并 | 合并后自动继续 |
203
+ | **Phase 7** | **land-and-deploy 完成/失败** | **用户确认合并结果 / 处理部署失败** | **确认/修复后继续** |
204
+ | **Phase 8** | **worktree 清理完成/失败** | **用户确认清理 / 手动处理残留** | **确认后结束流程** |
205
+
206
+ ---
207
+
208
+ ## Workflow Steps
209
+
210
+ | Step | Phase | Name | Key Actions | Output |
211
+ |------|-------|------|-------------|--------|
212
+ | 1 | **-1** | **ISOLATE** | Detect protected branch → Create git worktree → Setup project → Validate .gitignore → Record sprint state | Worktree path |
213
+ | 2 | **-0.5** | **AUTO-ESTIMATE** | Analyze code structure → Count references → Assess cross-module impact → Classify (lightweight/standard/complex) | Impact assessment + flow recommendation |
214
+ | 3 | **0** | **THINK** | brainstorming → Generate design doc + CONTEXT.md + ADR | Design document |
215
+ | 4 | **1** | **PLAN** | autoplan → delphi-review (mandatory; lightweight allowed) → Generate specification.yaml + slices-manifest.json | specification.yaml |
216
+ | 5 | **2** | **BUILD** | GITHOOKS-GATE → ralph-loop (default) or parallel → TDD → freeze → blind review → verification | MVP code |
217
+ | 6 | **3** | **REVIEW** | delphi-review --mode code-walkthrough → test-specification-alignment → browse QA → benchmark (optional) | Review report |
218
+ | 7 | **4** | **USER ACCEPT** | **Manual verification** → Capture emergent issues | Emergent issues list |
219
+ | 8 | **5** | **FEEDBACK** | learn → retro → systematic-debugging | feedback-log.md |
220
+ | 9 | **6** | **SHIP** | finishing-a-development-branch → ship (create PR) | PR URL |
221
+ | 10 | **7** | **LAND** | land-and-deploy → merge PR → wait CI → canary health check → rollback on failure | Deploy status |
222
+ | 11 | **8** | **CLEANUP** | Safe worktree removal → Update sprint state → Sprint summary | Cleanup report |
223
+
224
+ **Phase Flow**:
225
+ ```
226
+ ISOLATE → AUTO-ESTIMATE → THINK → PLAN → [GITHOOKS-GATE] → BUILD → REVIEW → USER ACCEPT → FEEDBACK → SHIP → LAND → CLEANUP
227
+ ```
228
+
229
+ **Hard Gates**:
230
+ - **Phase 0→1**: Design must be APPROVED by delphi-review (≥91% consensus)
231
+ - **Phase 1→2**: GITHOOKS-GATE (hooks must be installed) + DELPHI-GATE (spec must be APPROVED)
232
+ - **Phase 4→5**: User acceptance must be completed (mandatory manual step)
233
+ - **Phase 5→6**: feedback-log.md must exist (HARD-GATE)
234
+
235
+ ---
236
+
237
+ ## 各 Phase 调用的 Skills
238
+
239
+ ### Phase -1: ISOLATE(git worktree 隔离)
240
+
241
+ **执行时机**: `/sprint-flow` 启动后、Phase 0 THINK 之前。**自动执行**。
242
+
243
+ **目的**: 默认在 git worktree 中隔离 sprint 工作,防止在保护分支上直接运行导致代码污染。
244
+
245
+ **AI agent 直接执行 bash 命令**(不需要调用外部 skill),步骤如下:
246
+
247
+ | 步骤 | 动作 | 说明 |
248
+ |------|------|------|
249
+ | 0 | **检测当前环境** | 运行 `git rev-parse --git-dir` 和 `git rev-parse --git-common-dir`。如果 `GIT_DIR != GIT_COMMON`:已在 worktree 中 → 输出 "Already in isolated worktree" → 进入 Phase 0 |
250
+ | 1 | **检查保护分支** | 获取当前分支名 `git branch --show-current`。保护分支列表: `main, master, develop, trunk, mainline`。保护分支 → 强制创建 worktree。非保护分支 → 依然创建 worktree(推荐,不阻断) |
251
+ | 2 | **创建 worktree** | 创建目录: `mkdir -p .worktrees/sprint`。检测已有 NN 编号: `ls .worktrees/sprint/ 2>/dev/null | grep -oE '[0-9]{2}$' | sort -n | tail -1`(取最后两位数字,数值排序,取最大),NN = 结果 + 1(无结果则从 01 开始)。运行 `git worktree add .worktrees/sprint/sprint-YYYY-MM-DD-NN -b sprint/YYYY-MM-DD-NN`。**注意**: `cd` 在 AI agent 单次工具调用中不保持状态,步骤 3-6 必须通过 `workdir` 参数或 `&&` 链式命令在新 worktree 目录下执行 |
252
+ | 3 | **项目 setup** | 在 worktree 目录下: 检测项目类型: `package.json` → `npm install`, `go.mod` → `go mod download`, `pyproject.toml` → `pip/poetry install` |
253
+ | 4 | **.gitignore 校验** | 在**仓库根目录**(非 worktree)执行: `git check-ignore -q .worktrees`。如果未忽略 → 将 `.worktrees/` 添加到 `.gitignore` → `git add .gitignore` → `git commit -m 'chore: ignore .worktrees directory'` |
254
+ | 5 | **Sprint State 记录** | `mkdir -p .sprint-state` 在 worktree 目录下。写入 `.sprint-state/sprint-state.json`(如已存在则合并,保留原有字段),新增/更新 `isolation` 对象,设置 `phase: -1`,`status: "running"` |
255
+ | 6 | **基线验证** | 在 worktree 目录下: 检测测试方式(package.json 有 "test" script → `npm test`, go.mod → `go test ./...`, pyproject.toml → `pytest`)。测试失败 → 输出失败信息 → 询问用户是否继续 |
256
+
257
+ **参数处理**:
258
+
259
+ - `--no-isolate`: 跳过自动创建,输出 ⚠️ 警告 `'[WARN] 未创建 worktree 隔离,在 {branch} 分支上直接运行 sprint 有污染风险'` → 进入 Phase 0
260
+ - `--branch-name <name>`: 使用自定义分支名(默认自动生成 `sprint/YYYY-MM-DD-NN`),分支名中的 `/` 在 worktree 路径中自动替换为 `-`(如 `feat/user-login` → 分支名 `feat/user-login`,路径 `.worktrees/sprint/feat-user-login`)
261
+ - `--force`: 强制在当前分支继续(即使已是保护分支),**要求用户显式确认**: 输出 ⚠️ 警告 `'[WARN] 使用 --force 在 {branch} 分支上直接运行 sprint。此操作绕过隔离保护,请确认风险。'` → 等待用户确认("继续" / "取消") → 确认后进入 Phase 0
262
+
263
+ **参数交互规则**:
264
+
265
+ | 参数组合 | 行为 |
266
+ |---------|------|
267
+ | `--no-isolate` 单独 | 跳过隔离,输出警告 → Phase 0 |
268
+ | `--force` 单独 | 跳过隔离,要求确认 → Phase 0 |
269
+ | `--no-isolate` + `--branch-name` | `--branch-name` 忽略,仅 `--no-isolate` 生效 |
270
+ | `--force` + `--branch-name` | `--branch-name` 忽略,仅 `--force` 生效 |
271
+ | `--no-isolate` + `--force` | 等效,输出 `--no-isolate` 警告 → Phase 0 |
272
+ | `--resume-from build` + `--no-isolate` | `--resume-from` 优先,直接跳过 Phase -1 |
273
+
274
+ **错误处理和回退**:
275
+ | 错误场景 | 回退行为 |
276
+ |---------|---------|
277
+ | `git worktree add` 失败(沙箱/权限问题) | 输出 `[ERROR] git worktree add 失败: {error}` → `[WARN] 无法创建 worktree 隔离,将在当前目录继续。请手动设置隔离分支。` → 在当前目录继续 |
278
+ | `.gitignore` 自动添加失败 | 输出 `[WARN] 无法自动添加 .gitignore,请手动将 .worktrees/ 添加到 .gitignore` → 继续 |
279
+ | 基线测试失败 | 输出 `[FAIL] 基线测试未通过:` + 失败详情 → 询问用户 `'基线测试失败,是否继续 sprint?(y/N)'` |
280
+
281
+ **sprint-state.json isolation 对象格式**:
282
+ ```json
283
+ {
284
+ "isolation": {
285
+ "worktree_path": ".worktrees/sprint/sprint-2026-05-24-01",
286
+ "branch": "sprint/2026-05-24-01",
287
+ "created_from": "main",
288
+ "created_from_commit": "abc123def..."
289
+ }
290
+ }
291
+ ```
292
+
293
+ > **清理提示**: Sprint 完成(Phase 6 SHIP)后,执行 `git worktree remove <worktree_path>` 清理 worktree 目录,同时保留 `.sprint-state/` 中的历史记录。
294
+
295
+ ### Phase -0.5: AUTO-ESTIMATE(自动化规模评估与流程路由)
296
+
297
+ **执行时机**: Phase -1 ISOLATE 完成后、Phase 0 THINK 之前。**自动执行**。
298
+
299
+ **目的**: 自动评估需求规模,匹配适度流程,避免小需求走重量级流程造成资源浪费。不依赖人/AI 主观判断,而是通过代码结构分析提供客观指标。
300
+
301
+ **详细指令**: 参见 `references/phase-minus-0-5-auto-estimate.md`
302
+
303
+ #### 快速参考
304
+
305
+ **步骤**:
306
+ 1. **识别需求类型** — 删除/修改已存在代码 → 立即分析;新增功能 → brainstorming 后分析
307
+ 2. **收集指标** — 引用计数 (`grep -rn`)、跨模块依赖 (目录分布)、循环依赖、Public API 暴露、测试文件数
308
+ 3. **汇总评估** — 综合打分 → 轻量 / 标准 / 复杂
309
+ 4. **输出结果** — 使用 `templates/auto-estimate-output-template.md` 标准格式
310
+ 5. **用户确认** — 接受建议 / 修改流程 / 取消
311
+ 6. **路由执行** — 按最终级别进入对应 Phase
312
+
313
+ **路由决策表**:
314
+
315
+ | 评估结果 | 路由 | 说明 |
316
+ |---------|------|------|
317
+ | **轻量** (引用 ≤3, 同模块,无循环依赖) | Phase 0-3 以 reduced intensity 执行(THINK/PLAN/review 强度降低,不跳过 delphi-review) | 轻量仍需要评审,但强度可调整 |
318
+ | **标准** (引用 4-10, 跨 1-2 模块) | 正常流程 Phase 0-4 | 标准 sprint |
319
+ | **复杂** (引用 >10 或 循环依赖 或 跨 3+ 模块) | 完整 Phase 0-8 + 风险警告 | 高风险需求 |
320
+
321
+ **输出模板**: `templates/auto-estimate-output-template.md`
322
+ **学习日志**: `templates/auto-estimate-learning-log.md`(记录用户 override,用于阈值优化)
323
+
324
+ **输出格式**:
325
+ ```
326
+ +-------------------------------------------------------------+
327
+ | AUTO-ESTIMATE 评估结果 |
328
+ +-------------------------------------------------------------+
329
+ | 需求:{task_description} |
330
+ | 类型:{change_type} |
331
+ | |
332
+ | [{impact_level}] Impact: {impact_label} |
333
+ | |
334
+ | 引用:{ref_count} 处 |
335
+ | 跨模块:{cross_module_count} 个 ({module_list}) |
336
+ | 循环依赖:{circular_dep_status} |
337
+ | Public API:{public_api_count} 个 |
338
+ | |
339
+ | 建议流程:{recommended_flow} |
340
+ | |
341
+ | {risk_warning} |
342
+ | |
343
+ | [接受建议] [修改流程] [取消] |
344
+ +-------------------------------------------------------------+
345
+ ```
346
+
347
+ **纠偏机制**:
348
+ - **接受建议**: 按推荐流程执行,记录 `user_decision: "accepted"`
349
+ - **修改流程**: 用户选择其他级别,记录 `override_reason` 到 `.sprint-state/auto-estimate-learning.json`
350
+ - **取消**: 停止本次 sprint
351
+
352
+ **⚠️ 轻量路由的特殊处理**:
353
+ - 轻量路由 Phase 0-3 以 reduced intensity 执行(THINK/PLAN/review 强度降低)
354
+ - **所有路由必须产生** `.sprint-state/delphi-reviewed.json` 且 `verdict = "APPROVED"` 才能进入 BUILD
355
+ - Phase 2 BUILD 仍然执行完整 TDD + 盲评 + 验证
356
+
357
+ ### Phase 0: THINK(需求探索与设计)
358
+ - **Subagent dispatch**: orchestrator 通过 `task(category="deep", load_skills=["brainstorming"])` 启动独立 session
359
+ - 输入: Phase -1 summary(worktree 路径)+ 用户原始需求
360
+ - 输出: 结构化设计文档 → 直接作为 Phase 1 PLAN 的输入
361
+ - **HARD-GATE**: 设计未批准 → 不可进入实现
362
+
363
+ ### Phase 1: PLAN(共识评审)
364
+ - **Subagent dispatch**: orchestrator 通过 `task(category="deep", load_skills=["autoplan", "delphi-review", "to-issues"])` 启动独立 session
365
+ - 输入: phase-0-summary.md + 设计文档
366
+ - 输出: `specification.yaml`(含 user_stories[])+ `slices-manifest.json`
367
+
368
+ **条件分支逻辑**:
369
+ - IF autoplan AUTO_APPROVED + 无 taste_decisions → 可执行 **lightweight delphi-review**(2 专家、1 轮、2/2 APPROVED,参考 `references/force-levels.md`)
370
+ - IF autoplan NEEDS_REVIEW OR taste_decisions > 0 → 调用标准 delphi-review(3 专家)
371
+ - **delphi-review 必须产生** `.sprint-state/delphi-reviewed.json` 且 `verdict = "APPROVED"` → 生成 specification.yaml(含 user_stories[]) → **调用 /to-issues** 拆解为垂直切片 → slices-manifest.json → Phase 2 按 execution_order 执行
372
+
373
+ ### Phase 1→2: GITHOOKS-GATE(质量门禁安装检查)
374
+
375
+ **执行时机**: Phase 1 完全通过、准备进入 Phase 2 BUILD 之前.
376
+
377
+ **必须执行**: 运行 `githooks/verify.sh` 检查当前项目的 hooks 是否安装。
378
+
379
+ **检查结果处理**:
380
+ - ✅ 全部存在 → 进入 Phase 2 BUILD 入口(仍必须先执行 DELPHI-GATE)
381
+ - ❌ 部分/全部缺失 → 运行 `githooks/install.sh` 安装(包括 `.git/hooks/pre-commit`、`.git/hooks/pre-push`、`githooks/adapter-common.sh`、`githooks/adapters/`)
382
+ - 如果 githooks/ 目录不存在于项目根目录(即当前项目不是 xp-gate) → 从 xp-gate 仓库拉取 `githooks/` 目录结构
383
+ - 安装完成后再次 `verify.sh` 确认
384
+
385
+ **核心原则**: 没有质量门禁的代码不可进入 BUILD 阶段。**GITHOOKS-GATE 失败 → 不可编码。**
386
+
387
+ ### Phase 2: BUILD(DELPHI-GATE → ralph-loop 默认 + TDD + 盲评 + 验证)
388
+
389
+ **⚠️ DELPHI-GATE(BUILD 入口门禁)**:
390
+ Phase 2 第一步必须执行 DELPHI-GATE 检查。没有 delphi-review APPROVED → 不可编码。
391
+
392
+ 检查步骤:
393
+ 1. 读取 `.sprint-state/delphi-reviewed.json`
394
+ 2. 验证文件存在 → 不存在 → 输出 `[BLOCKED] delphi-review not APPROVED. 必须先完成 Phase 1 的 delphi-review。` → 返回 Phase 1
395
+ 3. 验证 `verdict` 字段 == `"APPROVED"` → 不等于 → 同上 BLOCK
396
+ 4. ✅ 通过 → 进入 BUILD 编码
397
+
398
+ **输入**: `slices-manifest.json`(由 Phase 1 `/to-issues` 生成),按 `execution_order` 逐个执行。
399
+
400
+ **默认模式**: `ralph-loop` — 逐 REQ/切片 迭代构建。每个切片(REQ)dispatch 独立 subagent,干净上下文,全量回归测试。Token 节约 40-67%。参见 `skills/ralph-loop/SKILL.md`。
401
+
402
+ **并行模式**: 通过 `--mode parallel` 启用 `dispatching-parallel-agents`。仅分发无依赖的 AFK 切片(通过 `dependency_graph` 判定)。HITL 切片需人工确认后才可分发。
403
+
404
+ **替代原 xp-consensus**:使用 superpowers 成熟 skill 组合,保留关键行为(freeze 隔离、熔断回退、成本监控)。
405
+
406
+ | 步骤 | Skill | 说明 |
407
+ |------|-------|------|
408
+ | -1 | **`hooks-install`** _(githooks/scripts)_ | `githooks/verify.sh` → 缺失则 `githooks/install.sh` |
409
+ | 0 | **`dispatching-parallel-agents`** _(superpowers)_ | 检测可并行任务,并行分发独立子任务 |
410
+ | 1 | `test-driven-development` (superpowers) | RED → GREEN → REFACTOR 铁律执行 |
411
+ | 2 | **`executing-plans`** _(superpowers)_ | 在隔离 session 中执行计划,有 review checkpoint |
412
+ | 3 | `freeze` (gstack) | 锁定业务代码,盲评 agent 只能访问测试 |
413
+ | 4 | `requesting-code-review` (superpowers) | 独立 agent 盲评业务代码(隔离状态) |
414
+ | 5 | `unfreeze` (gstack) | 解锁业务代码 |
415
+ | 6 | `verification-before-completion` (superpowers) | 运行测试 + lint,证据优先 |
416
+ | 7 | 成本监控(sprint-flow 编排层) | 超阈值 BLOCK + 用户决策 |
417
+
418
+ **关键行为保留**(原 xp-consensus 17 状态机中的真实边缘情况):
419
+
420
+ | 原状态 | 新处理方案 |
421
+ |--------|-----------|
422
+ | `CIRCUIT_BREAKER_TRIGGERED` | sprint-flow 编排层监控成本,超阈值 BLOCK + 用户决策 |
423
+ | `ROLLBACK_TO_ROUND1` | verification-before-completion 失败 → 修复 max 3 次 → 仍失败 BLOCK |
424
+ | `GATE1_FAILED`/`GATE1_COMPLETE` | verification-before-completion 内置此区分 |
425
+ | `GATE2_RUNNING` | `cso` (gstack) — Phase 1-6 安全审计替代 |
426
+ | `SEALED_CODE_ISOLATION` | 保留 freeze skill 调用 |
427
+
428
+ **语言特定 TDD**:通过 `--lang` 参数选择:
429
+ - `springboot-tdd` / `django-tdd` / `golang-testing`
430
+
431
+ **Mock Minimization**(Phase 2 强制):
432
+ - 默认使用 integration-first:real DB (sqlite-in-memory), real collaborators
433
+ - Mock 仅用于:external services, network calls, I/O boundaries
434
+ - Mock 密度 > 30% 时必须添加 `// @mock-justified: <reason>` 注解(理由最少 10 字符)
435
+ - Phase 3 Gate M 会在 push 时验证 mock 密度
436
+
437
+ ### Phase 3: REVIEW + TEST(验证)
438
+ - **Subagent dispatch**: orchestrator 通过 `task(category="deep", load_skills=["delphi-review", "test-specification-alignment"])` 启动独立 session
439
+ - 输入: phase-2-summary.md + MVP 代码
440
+ - 输出: 评审报告 + 测试对齐结果
441
+ - `delphi-review --mode code-walkthrough` — 多专家匿名代码走查
442
+ - `test-specification-alignment` — 测试与 Spec 对齐验证
443
+ - `browse` (gstack) — 浏览器自动化测试
444
+ - `k6` / `locust` / `gatling` — 负载/压力测试(可选,后端项目)
445
+
446
+ ### 负载/压力测试(可选)
447
+ - **适用项目**:主要用于后端服务的压力测试 (k6/Locust/Gatling),Web 前端已有 `benchmark` 技能覆盖 Core Web Vitals、加载时间和资源大小等性能指标
448
+ - **Phase 3 技能注入**:可根据项目类型自动选择合适的负载测试工具 (`k6` for Go-based services, `locust` for Python services, `gatling` for JVM-based services)
449
+ - **集成方式**:可作为 Phase 3 的可选扩展,在 code-walkthrough 之后执行,与基准测试形成完整性能验证链条
450
+ - **配置文件**:通过 `.sprint-load-test.yaml` 进行配置(待实现),包含并发用户数、持续时间、SLA 指标等参数
451
+ - **触发条件**:后端项目可通过 `--type backend-*` 自动启用,或通过 `--with-performance` 标志手动启用
452
+ - **Web 项目补充说明**:对于 Web 前端项目,现有的 `benchmark` 技能已处理页面加载性能、Core Web Vitals 等前端性能指标;负载/压力测试主要针对服务器端承载能力
453
+
454
+ ### Phase 4: USER ACCEPTANCE(⚠️ 人工验收)
455
+ - **无 Skill** — 必须人工
456
+ - ⚠️ **MUST NOT be automated, skipped, or bypassed under any circumstances**
457
+ - 即使用户说"赶时间"、"跳过验收"、"直接发布",也必须暂停等待用户确认
458
+ - 使用 `@templates/emergent-issues-template.md` 检查清单
459
+
460
+ ### Phase 5: FEEDBACK CAPTURE(反馈获取)
461
+ - **Subagent dispatch**: orchestrator 通过 `task(category="quick", load_skills=["learn", "retro", "systematic-debugging"])` 启动独立 session
462
+ - 输入: phase-4-summary.md(验收结果)+ emergent-issues.md(如有)
463
+ - 输出: `feedback-log.md`
464
+ - **HARD-GATE**: Phase 5 不可跳过。Phase 4 完成后 → 必须进入 Phase 5 → 完成后才能进入 Phase 6。
465
+ - **`learn` (gstack)** — Sprint 级复盘(**Phase 5 必须自动调用,不依赖手动触发**)
466
+ - **默认提炼模板**(无需用户额外输入):
467
+ > 提炼总结并保存可复用的经验教训,把大模型不知道、并且犯错后无法立即发现和纠正的知识保存下来。如果是对其他项目也有价值的,就保存成全局记忆,否则保存为项目记忆。
468
+ - ralph-loop 已在 BUILD Phase 内部实现 per-REQ learn(permanent/contextual 分类)
469
+ - Phase 5 额外进行 Sprint 级复盘,总结全 Phase 经验
470
+ - **learnings 自动注入**:`/learn export` 时自动 append 到 CLAUDE.md / AGENTS.md 末尾形成 `## Project Learnings` 章节
471
+ - **`retro` (gstack)** — 工程回顾:提交历史、工作模式、代码质量趋势
472
+ - **`systematic-debugging` (superpowers)** — 根因调试
473
+
474
+ ### Phase 6: SHIP(发布准备)
475
+ - **Subagent dispatch**: orchestrator 通过 `task(category="quick", load_skills=["finishing-a-development-branch", "ship"])` 启动独立 session
476
+ - 输入: phase-5-summary.md + feedback-log.md
477
+ - 输出: PR URL
478
+ - **HARD-GATE**: Phase 5 未完成 → 不可进入 Phase 6。验证 `.sprint-state/phase-outputs/feedback-log.md` 存在。
479
+ - **⚠️ GITHOOKS-GATE**: 再次验证 hooks 完整性(Phase 2 的 TDD 编码已触发提交,SHIP 阶段还会再次提交)
480
+ - 运行 `githooks/verify.sh` → 缺失 → `githooks/install.sh` → 阻断直至修复
481
+ - **⚠️ VERSION-GATE**: Phase 6 提交前必须 bump VERSION 文件(与变更类型无关)
482
+ - 默认 bump PATCH 位(如 `0.6.0.0` → `0.6.1.0`,MICRO 重置为 0)
483
+ - 重大新功能 bump MINOR 位(如 `0.6.0.0` → `0.7.0.0`),Breaking change bump MAJOR 位
484
+ - 运行 `bash scripts/sync-version.sh` 同步到所有 package.json(root、npm-package、claude-plugin、opencode)
485
+ - 更新 `CHANGELOG.md` 添加本次变更记录(含变更类型说明:skill-only / code / mixed)
486
+ - 验证:`git diff VERSION` 确认版本号已变更,未变更 → 阻断
487
+ - **此规则与变更类型无关** — 纯 skill 变更(仅 .md 文件)也必须 bump PATCH,确保每次 sprint 都触发 npm 发布
488
+ - **`finishing-a-development-branch`** (superpowers) — 结构化完成流:4 选项(merge / PR / discard / keep)
489
+ - `ship` (gstack) — 创建 PR(PR 路径时使用)
490
+ - Phase 6 输出:PR URL(用于 Phase 7 输入)
491
+
492
+ ### Phase 7: LAND(合并 + 部署)
493
+ - **Subagent dispatch**: orchestrator 通过 `task(category="deep", load_skills=["land-and-deploy"])` 启动独立 session
494
+ - 输入: phase-6-summary.md + PR URL
495
+ - 输出: 部署状态 + Canary 报告
496
+ - 输入:Phase 6 输出的 PR URL
497
+ - 调用:`land-and-deploy` skill
498
+ - 流程:
499
+ 1. Merge PR(`gh pr merge --squash`)
500
+ 2. 等待 CI 完成(poll `gh pr checks` 直到 success 或 10min timeout)
501
+ 3. 等待 Deploy 完成(如已配置,10min timeout)
502
+ 4. **Canary Health Check**(如已配置部署平台):
503
+ - 健康检查端点:项目根路径 `/` 或自定义 `/.well-known/health`
504
+ - SLA 指标:HTTP 200 响应 + 错误率 <1% + p99 响应 <2s
505
+ - 超时策略:最长 5 分钟,每 10s polling 一次
506
+ - 部署**失败**时的回滚:`git revert` 最后一次 merge commit + 输出 `[ERROR] Deploy failed, auto-rolled back merge`
507
+ - 条件跳过:无部署配置时,仅执行 merge + CI checks,跳过 deploy/canary
508
+ - 输出:部署状态 + Canary 报告(成功/失败/跳过)
509
+
510
+ ### Phase 8: CLEANUP(安全清理 + 总结)
511
+
512
+ **执行时机**: Phase 7 LAND 成功后(或 Phase 6 Option 1 本地 Merge 后)
513
+
514
+ **动作**:
515
+ 0. **保存分支信息**(必须在 worktree remove 之前执行):
516
+ - `sprint_branch=$(git branch --show-current)`
517
+ - 如果 sprint_branch 为空或与 `isolation.branch` 不匹配: 使用 `isolation.branch`
518
+ 1. **检测 worktree 是否存在**: `[ -d <worktree_path> ]`
519
+ 2. **安全清理**:
520
+ - **⚠️ 禁止使用通配符或递归 shell 删除命令** — 必须先列出 `isolation.worktree_path` 并确认只清理本 sprint worktree
521
+ - 首选 git worktree 管理命令清理该精确路径;失败时重试最多 3 次,间隔 1s
522
+ - 如果仍失败:输出 `[WARN] Worktree cleanup failed; list the target path and ask the user to clean it manually`
523
+ - ** NEVER delete arbitrary directories** — 只删除本 sprint 创建的 `isolation.worktree_path`
524
+ 3. **残留检测**: `[ -d <worktree_path> ]` → 如果仍有残留,输出警告 `[WARN] 检测到残留目录,请手动检查:<worktree_path>`
525
+ 4. **删除本地和远程分支**(⚠️ 必须在步骤 2 worktree remove 成功后执行):
526
+ - 切回主分支: `cd <repo_root> && git checkout main && git pull origin main`
527
+ - 删除本地分支: `git branch -D <sprint_branch>`
528
+ - 使用 `-D` 因为 squash merge 后 git 不认为已合并
529
+ - 如果分支不存在(已被其他流程删除): 静默跳过
530
+ - 删除远程分支: `git push origin --delete <sprint_branch>`
531
+ - 如果远程分支删除失败: 输出 `[WARN] Remote branch cleanup failed, please manually run: git push origin --delete <sprint_branch>`
532
+ 5. **关闭遗留 OPEN PR**:
533
+ - `gh pr list --head <sprint_branch> --state open`
534
+ - 如果存在 OPEN PR: 关闭并评论说明该 sprint 已通过其他 PR 完成
535
+ 6. **更新 `.sprint-state/sprint-state.json`**:
536
+ - `phase: 8`
537
+ - `status: "merged"` 或 `"completed"`
538
+ 7. **输出 Cleanup Report + Sprint Summary**
539
+
540
+ **执行顺序依赖**:
541
+ ```
542
+ 步骤 0 (保存分支名) → 步骤 2 (worktree remove 解除分支文件占用) → 步骤 4 (branch -D 删分支引用 → push --delete 删远程)
543
+ ```
544
+
545
+ **条件跳过**: `--no-isolate` 路径(无 worktree/分支可清理)
546
+
547
+ **输出**: `[CLEANUP] Worktree removed + Branch deleted:` + 残留检测(✅ clean / ⚠️ residual)
548
+
549
+ **IF emergent issues → Sprint 2**
550
+
551
+ ---
552
+
553
+ ## 编排层规则(Orchestration Rules)
554
+
555
+ ### Agent Dispatch Rules
556
+
557
+ | Agent Type | 适用场景 | 不适用场景 | 超时处理 |
558
+ |-----------|---------|-----------|---------|
559
+ | `explore` (bare) | **窄搜索**:单个关键词/pattern,已知文件位置 | 多角度宽泛搜索,读取大文件,3+ search angles | >5min → cancel + 用 `deep` 重试 |
560
+ | `librarian` (bare) | **外部参考**:API 文档、OSS 示例 | 内部代码库宽泛探索 | >5min → cancel + 用 `deep` 重试 |
561
+ | `task(category="deep")` | **复杂研究**:多模块分析,架构决策 | 单文件 trivial fix | 无限制 |
562
+ | `task(category="unspecified-high")` | **高 effort 实现**:新模块、重构 | 单行修改 | 无限制 |
563
+
564
+ **关键规则**:
565
+
566
+ 1. Bare `explore` agent 本质是 contextual grep,**不是研究 agent**。如果任务涉及:
567
+ - 3+ 个独立搜索角度
568
+ - 读取多个大文件(>200 行)
569
+ - 需要跨层分析(如"查 ralph-loop + .sprint-state/ + token 阈值 + phase transition")
570
+
571
+ → **必须用 `task(category="deep", load_skills=[...])` 替代**
572
+
573
+ 2. 如果 `explore` agent >5 分钟未返回 → cancel 并立即用 `task(category="deep")` 重试。不要等待。
574
+
575
+ 3. **并行 explore 仍然是正确模式**。2-4 个窄搜索 explore agent 并行执行是高效且推荐的。问题在于给单一 explore agent 分配宽泛任务。
576
+
577
+ **issue #83 根因**:`bg_1abf2ed9` 被分配了 4 个独立搜索角度的宽泛任务(ralph-loop context + .sprint-state/ + token threshold + phase transition),bare explore agent 超时丢失 session。同批的 `bg_5ecf590d`(窄搜索 OpenCode compaction API)3m35s 正常完成。
578
+
579
+ ### Phase Subagent Dispatch Matrix
580
+
581
+ | Phase | 名称 | Subagent? | Category | load_skills | 执行者 |
582
+ |-------|------|:---------:|----------|-------------|--------|
583
+ | -1 | ISOLATE | ❌ | Bash(直接执行) | 无 | orchestrator |
584
+ | -0.5 | AUTO-ESTIMATE | ❌ | Bash(直接执行) | 无 | orchestrator |
585
+ | 0 | THINK | ✅ | `deep` | `["brainstorming"]` | subagent |
586
+ | 1 | PLAN | ✅ | `deep` | `["autoplan", "delphi-review", "to-issues"]` | subagent |
587
+ | 2 | BUILD | ✅(已有) | ralph-loop | `["test-driven-development"]` | subagent |
588
+ | 3 | REVIEW | ✅ | `deep` | `["delphi-review", "test-specification-alignment"]` | subagent |
589
+ | 4 | USER ACCEPT | ❌ | **强制人工** | 无 | 用户 |
590
+ | 5 | FEEDBACK | ✅ | `quick` | `["learn", "retro", "systematic-debugging"]` | subagent |
591
+ | 6 | SHIP | ✅ | `quick` | `["finishing-a-development-branch", "ship"]` | subagent |
592
+ | 7 | LAND | ✅ | `deep` | `["land-and-deploy"]` | subagent |
593
+ | 8 | CLEANUP | ❌ | Bash(直接执行) | 无 | orchestrator |
594
+
595
+ **上下文隔离原则**:
596
+ - 每个 Subagent 在**独立 session** 中启动,不继承 orchestrator 的对话历史
597
+ - orchestrator session 仅接收 subagent 的最终结果摘要(~13,000 tokens/sprint)
598
+ - 现代模型百万 token 上下文 + 缓存命中 → 单 sprint 不会触发 overflow
599
+
600
+ ### CONTEXT INHERITANCE
601
+
602
+ 每个 Phase subagent 启动时,上下文仅通过以下路径继承:
603
+
604
+ | Phase | 加载来源 | 内容 |
605
+ |-------|---------|------|
606
+ | Phase -1 | 无前置(Bash 操作) | 用户原始需求 + 当前分支状态 |
607
+ | Phase 0 | phase--1-summary(仅路径) | 隔离环境信息(worktree 路径) |
608
+ | Phase 1 | phase-0-summary.md + design-doc | 设计决策 + 结构化规格 |
609
+ | Phase 2 | phase-1-summary.md + specification.yaml | 评审结论 + REQ 列表 |
610
+ | Phase 3 | phase-2-summary.md + MVP 代码 | 构建结果 |
611
+ | Phase 4 | — | **人工验收**。Phase 4 不产生 subagent summary,但用户验收结果记录在 `.sprint-state/phase-outputs/emergent-issues.md`(如有 emergent issues)。Phase 5 加载此文件。 |
612
+ | Phase 5 | phase-4-summary.md + emergent-issues.md | 验收结论 |
613
+ | Phase 6 | phase-5-summary.md + feedback-log.md | 复盘结论 |
614
+ | Phase 7 | phase-6-summary.md + PR URL | 发布准备 |
615
+ | Phase 8 | phase-7-summary(Bash 操作) | 部署结果 |
616
+
617
+ **隔离原则**:每个 Phase subagent 在干净上下文中启动。
618
+ 输入仅限上表对应的摘要文件和一级产出物。
619
+ 不包含前一 Phase 的完整对话、中间文件、失败尝试。
620
+
621
+ **特殊场景**:
622
+ - `--resume-from <phase>`:跳过前置 Phase,直接从指定 Phase 启动。此时要求该 Phase 的前置摘要文件已存在。例如 `--resume-from build` 要求 `phase-1-summary.md` 和 `specification.yaml` 已存在。orchestrator 仍执行 Phase Transition Gate 验证。
623
+ - `--no-isolate`:跳过 Phase -1 ISOLATE,直接在当前分支执行。Phase 0 无 `phase--1-summary` 可用,上下文继承来源为用户原始需求 + 当前 git 状态。所有后续 Phase 的 worktree enforcement 不适用(无 worktree),但仍需保持代码隔离。
624
+ - `next_phase_context` 中的 `{path}` 等变量占位符在实际写入时被替换为具体值。示例中的 `{path}` 应替换为实际 worktree 路径(如 `.worktrees/sprint/sprint-2026-06-01-01`)。
625
+
626
+ ### PHASE TRANSITION RULES
627
+
628
+ 每个 Phase subagent 完成后,必须按顺序执行以下步骤:
629
+
630
+ 1. **写入 Phase 摘要**:创建 `.sprint-state/phase-outputs/phase-{N}-summary.md`
631
+ - 格式:YAML frontmatter + Markdown body(body ≤ 50 行)
632
+ - 大小限制:≤ 40,000 字符(≈ 10,000 tokens)
633
+
634
+ 2. **更新 sprint-state.json**:
635
+ - `phase`: 当前阶段编号
636
+ - `outputs`: 新增当前阶段输出文件路径
637
+ - `phase_history`: 追加或更新当前阶段的记录
638
+ - Phase 开始时:追加 `{ "phase": N, "phase_name": "NAME", "status": "running", "started_at": "<ISO 8601>", "completed_at": null, "duration_seconds": null }`
639
+ - Phase 完成时:更新对应条目,填充 `completed_at`(ISO 8601)和 `duration_seconds`(`completed_at - started_at` 的秒数)
640
+ - Phase 跳过时(如轻量路由跳过 Phase 0 brainstorming):设置 `status: "skipped"`
641
+
642
+ 3. **等待用户确认 checkpoint**(如适用)
643
+
644
+ 4. **展示进度看板**:执行 `node scripts/render-sprint-progress.cjs` 渲染进度看板
645
+ - 脚本自动读取 `.sprint-state/sprint-state.json` 并输出 ASCII 进度看板
646
+ - 渲染规则:已完成阶段显示 ✅ + 耗时,当前阶段 🔄,待做 ⬜,跳过 ⏭️,失败 ❌
647
+ - 进度条:`[████▓░░░░░░] {pct}%`(已完成数/总阶段数 11)
648
+ - 下一步行动:根据当前阶段 + 状态,自动查找对应提示
649
+ - 输出物路径:列出 `outputs` 中已有的文件路径
650
+ - 时机:每个 Phase 完成后的 transition 阶段自动展示,用户无需请求
651
+ - 向后兼容:旧版 `sprint-state.json` 缺少 `phase_history` 时,从 `phase` 字段推断状态
652
+
653
+ ### Phase Summary 格式(YAML Frontmatter Schema)
654
+
655
+ 每个 `phase-N-summary.md` 必须包含以下 YAML frontmatter:
656
+
657
+ ```markdown
658
+ ---
659
+ phase: -1
660
+ phase_name: ISOLATE
661
+ status: completed
662
+ outputs:
663
+ - path: ".worktrees/sprint/sprint-YYYY-MM-DD-NN"
664
+ type: directory
665
+ decisions:
666
+ - title: "Worktree isolation enabled"
667
+ rationale: "Prevent main branch pollution"
668
+ unresolved_issues: []
669
+ next_phase_context: "Worktree created at {path}. All subsequent edits MUST use this workdir."
670
+ ---
671
+
672
+ ## Phase Summary
673
+ {简明摘要,不超过 50 行}
674
+ ```
675
+
676
+ **必填字段**: `phase`, `phase_name`, `status`, `outputs`, `decisions`, `next_phase_context`
677
+ **可选字段**: `unresolved_issues`
678
+
679
+ ### Phase Transition Gate
680
+
681
+ Orchestrator dispatch 下一 Phase 前必须执行验证:
682
+
683
+ ```bash
684
+ SUMMARY=".sprint-state/phase-outputs/phase-${N}-summary.md"
685
+ [ -f "$SUMMARY" ] || { echo "[BLOCK] phase-${N}-summary 不存在"; exit 1; }
686
+ FRONTMARKERS=$(grep -c "^---" "$SUMMARY" 2>/dev/null || echo 0)
687
+ [ "$FRONTMARKERS" -ge 2 ] || { echo "[BLOCK] YAML frontmatter 格式不完整"; exit 1; }
688
+ grep -q "^phase:" "$SUMMARY" || { echo "[BLOCK] 缺少 phase 字段"; exit 1; }
689
+ grep -q "^phase_name:" "$SUMMARY" || { echo "[BLOCK] 缺少 phase_name 字段"; exit 1; }
690
+ grep -q "^status:" "$SUMMARY" || { echo "[BLOCK] 缺少 status 字段"; exit 1; }
691
+ grep -q "^decisions:" "$SUMMARY" || { echo "[BLOCK] 缺少 decisions 字段"; exit 1; }
692
+ grep -q "^outputs:" "$SUMMARY" || { echo "[BLOCK] 缺少 outputs 字段"; exit 1; }
693
+ grep -q "^next_phase_context:" "$SUMMARY" || { echo "[BLOCK] 缺少 next_phase_context"; exit 1; }
694
+ CHARS=$(wc -c < "$SUMMARY" | tr -d ' ')
695
+ [ "$CHARS" -le 40000 ] || { echo "[BLOCK] 摘要超出大小限制 (${CHARS}/40000 chars)"; exit 1; }
696
+ ```
697
+
698
+ **由 orchestrator 强制执行**,不依赖 subagent 自觉遵守。
699
+ 验证失败 → BLOCK,不可 dispatch 下一 Phase。
700
+
701
+ ### WORKTREE ENFORCEMENT(Issue #84)
702
+
703
+ Phase -1 执行完毕后,**所有后续操作(Phase 0 到 Phase 8)的文件编辑、命令执行 MUST 在 worktree 目录下执行**:
704
+
705
+ - **工作目录**:所有 Bash 命令必须通过 `workdir` 参数或 `&&` 链式命令在 worktree 路径下执行
706
+ - **文件写入**:所有 `write`、`edit` 工具的 `filePath` 必须位于 `isolation.worktree_path` 下
707
+ - **验证步骤**:Phase 0 开始前,输出 `[WORKTREE] 后续所有操作将在 {worktree_path} 中进行`
708
+ - **例外**:`.gitignore` 校验(Phase -1 表步 4)和 `git worktree remove`(Phase 8 清理)在仓库根目录执行
709
+ Sprint state is persisted as JSON in `.sprint-state/sprint-state.json`:
710
+ ```json
711
+ {
712
+ "id": "sprint-2026-04-26-01",
713
+ "task_description": "开发访谈机器人,支持多轮对话",
714
+ "phase": -1,
715
+ "status": "running|paused|completed",
716
+ "started_at": "2026-04-26T10:00:00Z",
717
+ "isolation": {
718
+ "worktree_path": ".worktrees/sprint/sprint-2026-04-26-01",
719
+ "branch": "sprint/2026-04-26-01",
720
+ "created_from": "main",
721
+ "created_from_commit": "abc123def..."
722
+ },
723
+ "auto_estimate": {
724
+ "change_type": "删除已存在代码|修改已存在代码|新增功能|Bug修复",
725
+ "metrics": {
726
+ "ref_count": 12,
727
+ "cross_module_count": 3,
728
+ "modules": ["auth", "user", "admin"],
729
+ "circular_dep": true,
730
+ "public_api_count": 5,
731
+ "test_file_count": 4
732
+ },
733
+ "estimated_level": "轻量|标准|复杂",
734
+ "recommended_flow": "轻量流程 (Phase 0-3, reduced-intensity Delphi)|标准流程 (Phase 0-4)|完整 Sprint Flow (Phase 0-8)",
735
+ "risk_warnings": ["循环依赖: user ↔ plane"],
736
+ "user_decision": "accepted|overridden|cancelled",
737
+ "override_reason": null
738
+ },
739
+ "phase_history": [
740
+ {
741
+ "phase": -1,
742
+ "phase_name": "ISOLATE",
743
+ "status": "completed",
744
+ "started_at": "2026-04-26T10:00:00Z",
745
+ "completed_at": "2026-04-26T10:03:00Z",
746
+ "duration_seconds": 180
747
+ }
748
+ ],
749
+ "outputs": {
750
+ "pain_document": "docs/pain-document.md",
751
+ "specification": "specification.yaml",
752
+ "mvp": "mvp-v1/",
753
+ "review_report": "review-report.md"
754
+ },
755
+ "metrics": {
756
+ "tests_passed": 15,
757
+ "tests_failed": 0,
758
+ "coverage_pct": 85
759
+ }
760
+ }
761
+ ```
762
+
763
+ **新增字段说明**:
764
+ - `task_description`: Sprint 需求描述(Phase -1 启动时写入)
765
+ - `started_at`: Sprint 启动时间戳(Phase -1 启动时写入,ISO 8601 格式)
766
+ - `phase_history`: 阶段历史数组,每个元素记录阶段的执行信息:
767
+ - `phase`: 阶段编号
768
+ - `phase_name`: 阶段名称
769
+ - `status`: completed / running / failed / skipped
770
+ - `started_at`: 阶段开始时间(ISO 8601)
771
+ - `completed_at`: 阶段完成时间(null 表示未完成)
772
+ - `duration_seconds`: 耗时秒数(null 表示未完成)
773
+
774
+ **Eval assertions check for:** `phase`, `status`, `isolation.branch`, `outputs.specification`, `metrics.coverage_pct`, `phase_history`, `task_description`.
775
+
776
+ ---
777
+
778
+ ## 参数说明
779
+
780
+ ### 默认用法(无参数)
781
+
782
+ ```bash
783
+ /sprint-flow "开发访谈机器人,支持多轮对话"
784
+
785
+ # 自动执行 Think → Plan → Build → Review → Ship 全流程
786
+ # 关键节点暂停等待用户确认
787
+ ```
788
+
789
+ ### --stop-at(执行到某阶段后停止)
790
+
791
+ ```bash
792
+ /sprint-flow "开发访谈机器人" --stop-at plan
793
+ # → Think → Plan → 输出 specification.yaml → 停止
794
+ # 适用场景:先评审方案,后续手动决定是否继续
795
+ ```
796
+
797
+ ### --resume-from(从某阶段继续)
798
+
799
+ ```bash
800
+ /sprint-flow "继续 Sprint" --resume-from build --spec specification.yaml
801
+ # → 从 Build 恢复,但必须已有 specification.yaml + .sprint-state/delphi-reviewed.json (verdict: APPROVED)
802
+ # 适用场景:中断恢复,使用已通过 delphi-review 的 specification.yaml
803
+ ```
804
+
805
+ ### --phase(只执行单个阶段)
806
+
807
+ ```bash
808
+ /sprint-flow "评审代码" --phase review-only
809
+ # → 只执行 Phase 3 的评审
810
+ # 适用场景:单独验证某个阶段
811
+ ```
812
+
813
+ ### --status(查看 Sprint 进度)
814
+
815
+ ```bash
816
+ /sprint-flow --status
817
+ # → 执行 node scripts/render-sprint-progress.cjs
818
+ # → 读取 .sprint-state/sprint-state.json 并渲染 ASCII 进度看板
819
+ # → 不执行任何 Phase,仅展示当前状态
820
+ # 适用场景:碎片时间恢复时快速查看进度、中断后确认当前阶段和下一步操作
821
+ ```
822
+
823
+ **行为规则**:
824
+ - 执行 `node scripts/render-sprint-progress.cjs`(脚本自动处理所有渲染逻辑)
825
+ - 如果 `sprint-state.json` 不存在 → 脚本输出 `[INFO] 未找到活跃的 Sprint。请先运行 /sprint-flow "[需求描述]" 启动新 Sprint。`
826
+ - 如果 `status == "completed"` → 脚本输出完整看板 + `[INFO] Sprint 已完成。`
827
+ - `--status` 可与其他参数组合:`--status --resume-from build` → 先展示状态,再提示 "将从 Phase 2 BUILD 继续"
828
+ - 向后兼容:旧版 `sprint-state.json` 缺少 `phase_history`/`task_description` 时,按模板"向后兼容"规则渲染
829
+
830
+ ### --lang(指定项目语言)
831
+
832
+ ```bash
833
+ /sprint-flow "开发用户认证模块" --lang springboot
834
+ # Phase 2 自动调用 springboot-tdd + springboot-verification
835
+
836
+ /sprint-flow "开发 REST API" --lang django
837
+ # Phase 2 自动调用 django-tdd + django-verification
838
+
839
+ /sprint-flow "开发并发任务调度器" --lang golang
840
+ # Phase 2 自动调用 golang-testing
841
+ ```
842
+
843
+ ### --type(指定项目类型)
844
+
845
+ ```bash
846
+ /sprint-flow "开发用户登录页面" --type web-nextjs
847
+ /sprint-flow "开发 REST API" --type backend-django
848
+ # 默认: 从项目文件自动检测
849
+ ```
850
+
851
+ 自动检测逻辑(按顺序检查):
852
+
853
+ | 检测条件 | 类型 |
854
+ |---------|------|
855
+ | `package.json` + `next.config.js` | `web-nextjs` |
856
+ | `package.json` + `vite.config.ts` + `react` 依赖 | `web-react` |
857
+ | `package.json` + `vue` 依赖 | `web-vue` |
858
+ | `pubspec.yaml` + `flutter:` | `mobile-flutter` |
859
+ | `package.json` + `react-native` 依赖 or `ios/` + `android/` | `mobile-react-native` |
860
+ | `go.mod` | `backend-go` (可选 k6 负载测试)|
861
+ | `pom.xml` | `backend-springboot` (可选 gatling 负载测试)|
862
+ | `manage.py` 或 `pyproject.toml` (django) | `backend-django` (可选 locust 负载测试)|
863
+ | 无匹配 | `backend-cli` |
864
+
865
+ ### 项目类型到 Skill 注入映射
866
+
867
+ | Phase | Backend (default) | Web Frontend | Mobile | Load/Performance Testing |
868
+ |-------|------------------|-------------|--------|--------------------------|
869
+ | Phase 0 (THINK) | `brainstorming` | (同) | (同) | (通用) |
870
+ | Phase 1 (PLAN) | `autoplan` + `delphi-review` | + `design-shotgun` | (同 web) | (同) |
871
+ | Phase 2 (BUILD) | TDD + blind-review | (同 backend) | + `vercel-react-native-skills` (RN) / `flutter-review` (Flutter) | (同) |
872
+ | Phase 3 (REVIEW) | `delphi-review --mode code-walkthrough` + `test-specification-alignment` + `k6` / `locust` / `gatling` | + `qa` + `design-review` + `benchmark` | Flutter: `flutter-test` / RN: `detox E2E` | k6/locust/gatling (补充 API 测试后的负载测试验证) |
873
+ | Phase 5 (FEEDBACK) | `learn` + `retro` | (同) | (同) | (同) |
874
+ | Phase 6 (SHIP) | `finishing-a-development-branch` + `ship` | (同) | + platform deploy (可选) | (同) |
875
+ | Phase 7 (LAND) | `land-and-deploy` + canary | (同) | (同) | (同) |
876
+ | Phase 8 (CLEANUP) | worktree remove + branch delete + state update | (同) | (同) | (同) |
877
+ | Browse | `localhost:3000` | 部署 URL + 表单/交互 | Flutter Web / RN Web 测试 | (专用负载测试) |
878
+
879
+ **Mobile 专属工具链**:
880
+ - **Flutter**: `flutter analyze`, `flutter test`, `flutter build`, `pub publish`
881
+ - **React Native**: `metro`, `detox`, `jest`, `react-native run-ios/android`
882
+
883
+ ---
884
+
885
+ ## 状态管理
886
+
887
+ ### Sprint State
888
+
889
+ ```yaml
890
+ Sprint State:
891
+ id: sprint-YYYY-MM-DD-NN
892
+ phase: [-1, 0-6] # -1=ISOLATE, 0-6=各阶段
893
+ status: [pending, running, paused, completed, failed] # 统一状态
894
+ pause_reason: [none, wait_isolation, wait_approved, wait_gate1, wait_uat, wait_ship, wait_user_confirm]
895
+ isolation: # Phase -1 隔离信息
896
+ worktree_path: .worktrees/sprint/sprint-YYYY-MM-DD-NN
897
+ branch: sprint/YYYY-MM-DD-NN
898
+ created_from: main
899
+ created_from_commit: abc123def...
900
+
901
+ 存储位置: <project-root>/.sprint-state/
902
+ ├─ sprint-state.yaml # 当前 Sprint 状态
903
+ ├─ sprint-state.json # 当前 Sprint 状态 (JSON 格式,同上)
904
+ └─ phase-outputs/
905
+ ├─ pain-document.md # Phase 0 输出
906
+ ├─ specification.yaml # Phase 1 输出
907
+ ├─ mvp-v1/ # Phase 2 输出
908
+ ├─ review-report.md # Phase 3 输出
909
+ ├─ emergent-issues.md # Phase 4 输出
910
+ ├─ feedback-log.md # Phase 5 输出
911
+ └─ sprint-summary.md # Phase 6 输出
912
+ ```
913
+
914
+ ### Sprint 2 自动触发机制
915
+
916
+ ```yaml
917
+ Sprint 结束时 (Phase 6 完成):
918
+ IF emergent_issues_count == 0 → sprint_completed,结束流程
919
+ IF emergent_issues_count > 0 → sprint_2_needed:
920
+ ├─ IF emergent_issues 有 Critical → 自动启动 Sprint 2
921
+ ├─ IF emergent_issues 仅 Major/Minor → 询问用户
922
+ └─ Sprint 2 Pain Document 自动从 emergent-issues.md 转化
923
+ ```
924
+
925
+ ---
926
+
927
+ ## 使用示例
928
+
929
+ ### 示例 1:完整流程
930
+
931
+ ```bash
932
+ /sprint-flow "开发访谈机器人,支持多轮对话"
933
+
934
+ # 输出:
935
+ # Phase 0: brainstorming 需求探索 → 设计文档 → ⚠️ HARD-GATE: 等待用户 APPROVED
936
+ # 用户 APPROVED → 自动进入 Phase 1
937
+ # Phase 1: autoplan 发现 2 个 taste_decisions → ⚠️ 暂停
938
+ # 用户确认决策后 → delphi-review → Round 1 REQUEST_CHANGES
939
+ # 修复 → Round 2 APPROVED → specification.yaml
940
+ # Phase 2: TDD + freeze + review → verification → MVP v1
941
+ # Phase 3: cross-model-review APPROVED → browse QA 通过
942
+ # Phase 4: ⚠️ 用户验收 → 发现 1 个 Major emergent issue
943
+ # Phase 5: learn → 记录 → Sprint 2 Pain Document
944
+ # Phase 6: ship → PR → 用户确认合并 → canary 监控
945
+ # → Sprint Summary → 发现 emergent issue → 提示是否开始 Sprint 2
946
+ ```
947
+
948
+ ### 示例 2:中断恢复
949
+
950
+ ```bash
951
+ # 第一次:执行到 Plan 后停止
952
+ /sprint-flow "开发用户认证模块" --stop-at plan
953
+ # → 输出 specification.yaml
954
+
955
+ # 第二次:三天后继续
956
+ /sprint-flow "继续开发" --resume-from build --spec docs/specification.yaml
957
+ # → 从 Build 入口恢复,但必须已有 specification.yaml + .sprint-state/delphi-reviewed.json (verdict: APPROVED)
958
+ ```
959
+
960
+ ### 示例 3:语言特定
961
+
962
+ ```bash
963
+ /sprint-flow "开发 REST API" --lang django
964
+ # Phase 2 自动调用 django-tdd + django-verification
965
+ # Gate 1 包含 Django 特定的验证(migrations, linting, coverage)
966
+ ```
967
+
968
+ ### 示例 4:使用 --mode parallel(旧有并行模式)
969
+
970
+ ```bash
971
+ /sprint-flow "修改单行配置" --mode parallel
972
+ # 小改动可使用旧有并行模式,一次 dispatch 完成
973
+ # 注意:默认 ralph-loop 模式已覆盖绝大多数场景
974
+ ```
975
+
976
+ ### 示例 4b:仅验证隔离(--stop-at isolate)
977
+
978
+ ```bash
979
+ /sprint-flow "开发用户登录" --stop-at isolate
980
+ # → 仅执行 Phase -1 ISOLATE
981
+ # → 检测 main 分支 → 创建 worktree → setup → .gitignore → baseline
982
+ # → 输出 worktree 路径 → 停止
983
+ # 适用场景:手动验证隔离是否正常创建,后续手动决定是否继续
984
+ ```
985
+
986
+ ### 示例 5:Worktree 隔离(默认行为)
987
+
988
+ ```bash
989
+ /sprint-flow "开发用户登录"
990
+ # Phase -1 ISOLATE:
991
+ # → 检测当前在 main 分支(保护分支)→ 强制创建 worktree
992
+ # → mkdir -p .worktrees/sprint
993
+ # → 检测已有 NN 编号(.worktrees/sprint/ | grep -oE '[0-9]{2}$' | sort -n | tail -1)
994
+ # → git worktree add .worktrees/sprint/sprint-2026-05-24-01 -b sprint/2026-05-24-01
995
+ # → 在 worktree 目录下:npm install → 基线测试 → .sprint-state/ 记录
996
+ # → 进入 Phase 0 THINK...
997
+
998
+ # 跳过隔离(⚠️ 有污染风险)
999
+ /sprint-flow "开发用户登录" --no-isolate
1000
+ # → [WARN] 未创建 worktree 隔离,在 main 分支上直接运行 sprint 有污染风险
1001
+ # → 直接进入 Phase 0
1002
+
1003
+ # 强制跳过(需用户确认)
1004
+ /sprint-flow "开发用户登录" --force
1005
+ # → [WARN] 使用 --force 在 main 分支上直接运行 sprint → 等待用户确认 → 确认后进入 Phase 0
1006
+
1007
+ # 自定义分支名
1008
+ /sprint-flow "开发用户登录" --branch-name feat/user-login
1009
+ # → 分支名:feat/user-login(保留 /)
1010
+ # → worktree 路径:.worktrees/sprint/feat-user-login(/ 替换为 -)
1011
+
1012
+ # Sprint 完成后安全清理:先列出本 sprint 的 isolation.worktree_path
1013
+ # 仅清理 sprint-state 中记录的精确 worktree 路径
1014
+ # 禁止使用通配符或递归 shell 删除命令
1015
+ # 如果自动清理失败,输出目标路径并要求用户手动处理
1016
+ ```
1017
+
1018
+ ---
1019
+
1020
+ ## 底层 Skills 保持独立
1021
+
1022
+ 所有被调用的 Skills 保持独立可用:
1023
+ - 用户可以直接调用 `delphi-review` 单独评审
1024
+ - 用户可以直接调用 `test-driven-development` 单独执行 TDD
1025
+ - sprint-flow 只是自动串联调用,不替代底层 Skills
1026
+
1027
+ ---
1028
+
1029
+ ## Anti-Patterns
1030
+
1031
+ | 错误 | 正确 |
1032
+ |------|------|
1033
+ | 把普通问答、解释、代码检索请求路由到 sprint-flow | 仅在用户明确要求开发/实现/一键开发完整需求时触发 sprint-flow |
1034
+ | 跳过 Phase -1 隔离,直接在 main/master/develop 上改代码 | 默认创建 worktree;除非用户显式使用 `--no-isolate` 或 `--force` 并确认风险 |
1035
+ | 未完成 Phase -0.5 AUTO-ESTIMATE 就套用完整重流程 | 先评估轻量/标准/复杂,再按推荐流程或用户确认后的流程执行 |
1036
+ | Plan 阶段跳过 Delphi 评审直接 Build | 所有需求级别(轻量/标准/复杂)必须经过 autoplan + delphi-review;未 APPROVED 禁止编码 |
1037
+ | 跳过 TDD 直接实现代码 | Phase 2 必须遵循 RED → GREEN → REFACTOR,测试与实现一起交付 |
1038
+ | 跳过用户验收直接 Ship | Phase 4 USER ACCEPTANCE 必须人工完成;不得自动化、跳过或伪造 |
1039
+ | 验证失败后继续追加随机修改 | 最多 3 次修复循环;仍失败则 BLOCK 并请求用户决策 |
1040
+ | 未生成 Phase Summary 就进入下一阶段 | 每个 Phase 必须写入 `.sprint-state/phase-outputs/phase-{N}-summary.md` 并通过 transition gate |
1041
+
1042
+ ## Output Format
1043
+
1044
+ See [Output Contract](#output-contract) below for the canonical machine-readable output schema.
1045
+
1046
+ ### Eval Assertions
1047
+ - `phase`, `phase_name`, `status`, `outputs`, `decisions`, `next_phase_context`
1048
+ - `id`, `isolation.worktree_path`, `isolation.branch`, `metrics.coverage_pct`
1049
+
1050
+ ## Output Contract
1051
+
1052
+ ### Machine-Readable Outputs
1053
+
1054
+ **Phase Summary** (all automated Phases must output):
1055
+ ```markdown
1056
+ ---
1057
+ phase: <N>
1058
+ phase_name: <NAME>
1059
+ status: completed|paused|failed
1060
+ outputs:
1061
+ - path: "path/to/output"
1062
+ type: file|directory
1063
+ decisions:
1064
+ - title: "Decision title"
1065
+ rationale: "Rationale for decision"
1066
+ unresolved_issues: []
1067
+ next_phase_context: "Context needed by next phase"
1068
+ ---
1069
+
1070
+ ## Phase Summary
1071
+ Concise summary, <= 50 lines.
1072
+ ```
1073
+
1074
+ **Sprint State JSON** (all Phases must maintain):
1075
+ ```json
1076
+ {
1077
+ "id": "sprint-YYYY-MM-DD-NN",
1078
+ "phase": <N>,
1079
+ "status": "running|paused|completed|failed",
1080
+ "isolation": {
1081
+ "worktree_path": ".worktrees/sprint/sprint-YYYY-MM-DD-NN",
1082
+ "branch": "sprint/YYYY-MM-DD-NN"
1083
+ },
1084
+ "outputs": {},
1085
+ "metrics": {}
1086
+ }
1087
+ ```
1088
+
1089
+ ### Final User-Facing Output
1090
+
1091
+ When ending or pausing, output:
1092
+ - Current Phase and status
1093
+ - Generated file paths
1094
+ - Passed/failed validation commands
1095
+ - Next user decision required (if applicable)
1096
+ - PR URL (Phase 6 success) or cleanup report (Phase 8 success)
1097
+
1098
+ ## Security Notes
1099
+
1100
+ - Sprint Flow 会执行 git 操作(worktree、branch、commit、PR、merge),在受保护分支上默认必须隔离。
1101
+ - 不得使用 `--no-verify` 绕过 quality gates;hook 失败必须修复根因。
1102
+ - 不得自动推送、创建 PR、merge 或 deploy,除非用户请求的流程明确进入 Ship/Land 阶段并已通过前置 gate。
1103
+ - 不得修改、打印或提交 `.delphi-config.json`、API keys、tokens、cookies、SSH keys 等敏感信息。
1104
+ - Phase 7 deploy/canary 失败时必须报告失败并按配置回滚;不可静默忽略部署失败。
1105
+ - Phase 4 用户验收不可由模型代替;人工验收是发布安全边界。
1106
+ - worktree 清理只允许删除本 sprint 创建的 `isolation.worktree_path`,不得删除任意用户目录。
1107
+
1108
+ ---
1109
+
1110
+ ## References
1111
+
1112
+ 详细指令文件位于 `@references/`:
1113
+ - `@references/phase-minus-1-isolate.md` — Phase -1 详细指令
1114
+ - `@references/phase-0-think.md` — Phase 0 详细指令
1115
+ - `@references/phase-1-plan.md` — Phase 1 详细指令
1116
+ - `@references/phase-2-build.md` — Phase 2 详细指令
1117
+ - `@references/phase-3-review.md` — Phase 3 详细指令
1118
+ - `@references/phase-4-uat.md` — Phase 4 详细指令(人工)
1119
+ - `@references/phase-5-feedback.md` — Phase 5 详细指令
1120
+ - `@references/phase-6-ship.md` — Phase 6 详细指令
1121
+
1122
+ ---
1123
+
1124
+ ## Templates
1125
+
1126
+ 模板文件位于 `@templates/`:
1127
+ - `@templates/pain-document-template.md` — Pain Document 模板
1128
+ - `@templates/emergent-issues-template.md` — Emergent Issues 检查清单
1129
+ - `@templates/sprint-summary-template.md` — Sprint Summary 模板
1130
+ - `@templates/sprint-progress-template.md` — Sprint 进度看板(每个 Phase 完成后 + `--status` 查询时渲染)
1131
+
1132
+ ---
1133
+
1134
+ ## Anti-Patterns
1135
+
1136
+ | ❌ 错误 | ✅ 正确 |
1137
+ |---|---|
1138
+ | 在保护分支 (main/master) 上直接执行 sprint | Phase -1 自动创建 worktree 隔离 |
1139
+ | 跳过 Phase 4 用户验收("赶时间") | Phase 4 是 HARD-GATE,必须人工验收 |
1140
+ | Phase 2 不安装 Git Hooks 就开始编码 | GITHOOKS-GATE 检查必须先于 BUILD |
1141
+ | 单个 subagent 处理所有 REQ | ralph-loop 逐 REQ 迭代,每个 REQ 独立上下文 |
1142
+ | 验证失败仍 commit | 验证不通过的代码不 commit |
1143
+ | 跳过 Phase 5 FEEDBACK 直接 SHIP | Phase 5 是 HARD-GATE,不可跳过 |
1144
+ | --force 在生产分支上运行不确认 | --force 必须等待用户显式确认风险 |
1145
+ | Phase 6 SHIP 后不清理 worktree/分支 | Phase 8 CLEANUP 必须执行 worktree remove + branch delete |
1146
+
1147
+ ---
1148
+
1149
+ ## Output Format (MANDATORY)
1150
+
1151
+ Sprint-flow orchestrator MUST output phase transition status as valid JSON:
1152
+
1153
+ ```json
1154
+ {
1155
+ "skill_name": "sprint-flow",
1156
+ "sprint_id": "sprint-YYYY-MM-DD-NN",
1157
+ "current_phase": 2,
1158
+ "phase_name": "BUILD",
1159
+ "status": "running|paused|completed|failed",
1160
+ "isolation": {
1161
+ "worktree_path": ".worktrees/sprint/sprint-YYYY-MM-DD-NN",
1162
+ "branch": "sprint/YYYY-MM-DD-NN"
1163
+ },
1164
+ "progress": {
1165
+ "total_phases": 11,
1166
+ "completed_phases": 4,
1167
+ "percentage": 36,
1168
+ "phase_history": [
1169
+ { "phase": -1, "phase_name": "ISOLATE", "status": "completed", "started_at": "2026-06-02T14:30:00Z", "completed_at": "2026-06-02T14:33:00Z", "duration_seconds": 180 },
1170
+ { "phase": -0.5, "phase_name": "AUTO-ESTIMATE", "status": "completed", "started_at": "2026-06-02T14:33:00Z", "completed_at": "2026-06-02T14:34:00Z", "duration_seconds": 60 },
1171
+ { "phase": 0, "phase_name": "THINK", "status": "completed", "started_at": "2026-06-02T14:34:00Z", "completed_at": "2026-06-02T14:59:00Z", "duration_seconds": 1500 },
1172
+ { "phase": 1, "phase_name": "PLAN", "status": "completed", "started_at": "2026-06-02T14:59:00Z", "completed_at": "2026-06-02T15:17:00Z", "duration_seconds": 1080 },
1173
+ { "phase": 2, "phase_name": "BUILD", "status": "running", "started_at": "2026-06-02T15:17:00Z", "completed_at": null, "duration_seconds": null }
1174
+ ]
1175
+ },
1176
+ "outputs": {
1177
+ "specification": "specification.yaml",
1178
+ "mvp": "mvp-v1/"
1179
+ },
1180
+ "metrics": {
1181
+ "tests_passed": 15,
1182
+ "tests_failed": 0,
1183
+ "coverage_pct": 85
1184
+ }
1185
+ }
1186
+ ```
1187
+
1188
+ **Eval assertions check for:** `phase`, `status`, `isolation.branch`, `outputs.specification`, `metrics.coverage_pct`, `progress.phase_history`.
1189
+
1190
+ ---
1191
+
1192
+ ## Anti-Patterns
1193
+
1194
+ | ❌ 错误 | ✅ 正确 |
1195
+ |---|---|
1196
+ | 在保护分支 (main/master) 上直接执行 sprint | Phase -1 自动创建 worktree 隔离 |
1197
+ | 跳过 Phase 4 用户验收("赶时间") | Phase 4 是 HARD-GATE,必须人工验收 |
1198
+ | Phase 2 不安装 Git Hooks 就开始编码 | GITHOOKS-GATE 检查必须先于 BUILD |
1199
+ | 单个 subagent 处理所有 REQ | ralph-loop 逐 REQ 迭代,每个 REQ 独立上下文 |
1200
+ | 验证失败仍 commit | 验证不通过的代码不 commit |
1201
+ | 跳过 Phase 5 FEEDBACK 直接 SHIP | Phase 5 是 HARD-GATE,不可跳过 |
1202
+ | --force 在生产分支上运行不确认 | --force 必须等待用户显式确认风险 |
1203
+ | Phase 6 SHIP 后不清理 worktree/分支 | Phase 8 CLEANUP 必须执行 worktree remove + branch delete |
1204
+
1205
+ ---
1206
+
1207
+ ## Output Format (MANDATORY)
1208
+
1209
+ Sprint-flow orchestrator MUST output phase transition status as valid JSON:
1210
+
1211
+ ```json
1212
+ {
1213
+ "skill_name": "sprint-flow",
1214
+ "sprint_id": "sprint-YYYY-MM-DD-NN",
1215
+ "current_phase": 2,
1216
+ "phase_name": "BUILD",
1217
+ "status": "running|paused|completed|failed",
1218
+ "isolation": {
1219
+ "worktree_path": ".worktrees/sprint/sprint-YYYY-MM-DD-NN",
1220
+ "branch": "sprint/YYYY-MM-DD-NN"
1221
+ },
1222
+ "outputs": {
1223
+ "specification": "specification.yaml",
1224
+ "mvp": "mvp-v1/"
1225
+ },
1226
+ "metrics": {
1227
+ "tests_passed": 15,
1228
+ "tests_failed": 0,
1229
+ "coverage_pct": 85
1230
+ }
1231
+ }
1232
+ ```
1233
+
1234
+ **Eval assertions check for:** `phase`, `status`, `isolation.branch`, `outputs.specification`, `metrics.coverage_pct`.
1235
+
1236
+ ---
1237
+
1238
+ ## 研究证据
1239
+
1240
+ | 证据 | 来源 | 应用 |
1241
+ |------|------|------|
1242
+ | One-shot = 单次迭代执行 | Boris Cherny interview | Phase 2 设计 |
1243
+ | 80% session 从 Plan Mode 开始 | Boris skill | Phase 1 设计 |
1244
+ | Verification improves 2-3x | Boris #1 tip | Phase 3 设计 |
1245
+ | Emergent requirements 无法消除 | Mike Cohn, Rafael Santos | Phase 4 人工设计 |
1246
+ | 78% failures invisible | arXiv research | Phase 4 必要性证明 |
1247
+ | Think → Plan → Build → Ship | gstack ETHOS | 整体流程设计 |
1248
+