@boyingliu01/xp-gate 0.18.5 → 0.19.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 (254) hide show
  1. package/adapter-common.sh +27 -0
  2. package/adapters/gate-3.sh +0 -0
  3. package/adapters/gate-4.sh +0 -0
  4. package/adapters/gate-7.sh +0 -0
  5. package/adapters/gate-8.sh +0 -0
  6. package/adapters/gate-9.sh +0 -0
  7. package/adapters/powershell.sh +85 -33
  8. package/adapters/typescript.sh +8 -8
  9. package/build-integrity/__tests__/import-resolver.test.ts +22 -0
  10. package/build-integrity/__tests__/orchestrator.test.ts +1 -2
  11. package/build-integrity/gate-10.ts +7 -0
  12. package/gate-12-file-hygiene.sh +230 -0
  13. package/hooks/adapter-common.sh +27 -0
  14. package/hooks/gate-10.sh +105 -0
  15. package/hooks/gate-12-file-hygiene.sh +0 -0
  16. package/hooks/lib/validate-code-walkthrough.cjs +125 -0
  17. package/hooks/pre-commit +130 -33
  18. package/hooks/pre-push +15 -91
  19. package/lib/__tests__/check-version.test.js +67 -46
  20. package/lib/__tests__/doctor.test.js +7 -6
  21. package/lib/__tests__/gate-runner.test.js +267 -0
  22. package/lib/__tests__/init.test.js +32 -0
  23. package/lib/__tests__/npm-package.test.js +13 -0
  24. package/lib/__tests__/phase-transition.test.js +604 -12
  25. package/lib/__tests__/sprint-discovery.test.ts +0 -1
  26. package/lib/__tests__/sprint-status-rework.test.js +100 -1
  27. package/lib/__tests__/update-hooks.test.js +143 -10
  28. package/lib/__tests__/upgrade-exec.test.js +73 -45
  29. package/lib/__tests__/upgrade-skill-sync.test.js +1 -1
  30. package/lib/__tests__/upgrade.test.js +12 -11
  31. package/lib/doctor.js +2 -1
  32. package/lib/gate-runner.js +68 -23
  33. package/lib/init.js +34 -5
  34. package/lib/install-skill.js +1 -0
  35. package/lib/mattpocock-license-verdict.json +1 -1
  36. package/lib/phase-transition.js +203 -23
  37. package/lib/shared-paths.js +2 -0
  38. package/lib/sprint-status.js +15 -4
  39. package/lib/test-alignment.ts +3 -13
  40. package/lib/update-hooks.js +129 -15
  41. package/mock-policy/AGENTS.md +5 -5
  42. package/mock-policy/__tests__/gate-m3.test.ts +0 -5
  43. package/mock-policy/__tests__/scope-scanner.test.ts +8 -2
  44. package/mutation/AGENTS.md +4 -4
  45. package/mutation/__tests__/mutmut-runner.test.ts +443 -2
  46. package/mutation/__tests__/update-baseline.test.ts +0 -2
  47. package/mutation/runners/mutmut-runner.ts +67 -17
  48. package/package.json +9 -3
  49. package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
  50. package/plugins/claude-code/skills/clipboard-vision/SKILL.md +47 -0
  51. package/plugins/claude-code/skills/clipboard-vision/__tests__/clipboard-vision-distribution.test.cjs +65 -0
  52. package/plugins/claude-code/skills/clipboard-vision/__tests__/clipboard-vision-security.test.cjs +185 -0
  53. package/plugins/claude-code/skills/clipboard-vision/__tests__/clipboard-vision.Tests.ps1 +138 -0
  54. package/plugins/claude-code/skills/clipboard-vision/__tests__/clipboard-vision.test.cjs +273 -0
  55. package/plugins/claude-code/skills/clipboard-vision/describe-clipboard.ps1 +115 -0
  56. package/plugins/claude-code/skills/clipboard-vision/describe-clipboard.sh +161 -0
  57. package/plugins/claude-code/skills/clipboard-vision/scripts/clipboard-vision.ps1 +86 -0
  58. package/plugins/claude-code/skills/clipboard-vision/scripts/clipboard-vision.sh +137 -0
  59. package/plugins/claude-code/skills/delphi-review/.delphi-config.json.example +24 -27
  60. package/plugins/claude-code/skills/delphi-review/AGENTS.md +13 -12
  61. package/plugins/claude-code/skills/delphi-review/INSTALL.md +15 -17
  62. package/plugins/claude-code/skills/delphi-review/SKILL.md +30 -29
  63. package/plugins/claude-code/skills/delphi-review/opencode.json.delphi.example +6 -10
  64. package/plugins/claude-code/skills/delphi-review/references/code-walkthrough.md +33 -49
  65. package/plugins/claude-code/skills/delphi-review/references/requirements.md +66 -54
  66. package/plugins/claude-code/skills/delphi-review/references/round-templates.md +7 -7
  67. package/plugins/claude-code/skills/sprint-flow/AGENTS.md +5 -5
  68. package/plugins/claude-code/skills/sprint-flow/SKILL.md +4 -4
  69. package/plugins/claude-code/skills/sprint-flow/references/components/skill-invocations.md +2 -2
  70. package/plugins/claude-code/skills/sprint-flow/references/force-levels.md +37 -35
  71. package/plugins/claude-code/skills/sprint-flow/references/orchestration-rules.md +1 -1
  72. package/plugins/claude-code/skills/sprint-flow/references/phase-1-prep.md +1 -1
  73. package/plugins/claude-code/skills/sprint-flow/references/phase-2-design.md +24 -14
  74. package/plugins/claude-code/skills/sprint-flow/references/phase-4-verify.md +6 -6
  75. package/plugins/claude-code/skills/sprint-flow/references/phase-overview.md +2 -2
  76. package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +4 -4
  77. package/plugins/dsh/README.md +25 -0
  78. package/plugins/dsh/cordis.patch.yml +7 -0
  79. package/plugins/dsh/package.json +70 -0
  80. package/plugins/dsh/scripts/prepack.cjs +82 -0
  81. package/plugins/dsh/skills/admin-template-guidelines/SKILL.md +113 -0
  82. package/plugins/dsh/skills/admin-template-guidelines/references/rule-1.md +91 -0
  83. package/plugins/dsh/skills/admin-template-guidelines/references/rule-2.md +155 -0
  84. package/plugins/dsh/skills/admin-template-guidelines/references/rule-3.md +70 -0
  85. package/plugins/dsh/skills/admin-template-guidelines/references/rule-4.md +154 -0
  86. package/plugins/dsh/skills/admin-template-guidelines/references/rule-5.md +126 -0
  87. package/plugins/dsh/skills/admin-template-guidelines/references/rule-6.md +180 -0
  88. package/plugins/dsh/skills/batch-grill-me/SKILL.md +15 -0
  89. package/plugins/dsh/skills/clipboard-vision/SKILL.md +47 -0
  90. package/plugins/dsh/skills/clipboard-vision/__tests__/clipboard-vision-distribution.test.cjs +65 -0
  91. package/plugins/dsh/skills/clipboard-vision/__tests__/clipboard-vision-security.test.cjs +185 -0
  92. package/plugins/dsh/skills/clipboard-vision/__tests__/clipboard-vision.Tests.ps1 +138 -0
  93. package/plugins/dsh/skills/clipboard-vision/__tests__/clipboard-vision.test.cjs +273 -0
  94. package/plugins/dsh/skills/clipboard-vision/describe-clipboard.ps1 +115 -0
  95. package/plugins/dsh/skills/clipboard-vision/describe-clipboard.sh +161 -0
  96. package/plugins/dsh/skills/clipboard-vision/scripts/clipboard-vision.ps1 +86 -0
  97. package/plugins/dsh/skills/clipboard-vision/scripts/clipboard-vision.sh +137 -0
  98. package/plugins/dsh/skills/delphi-review/.delphi-config.json.example +70 -0
  99. package/plugins/dsh/skills/delphi-review/AGENTS.md +67 -0
  100. package/plugins/dsh/skills/delphi-review/INSTALL.md +150 -0
  101. package/plugins/dsh/skills/delphi-review/SKILL.md +559 -0
  102. package/plugins/dsh/skills/delphi-review/hooks.md +19 -0
  103. package/plugins/dsh/skills/delphi-review/opencode.json.delphi.example +52 -0
  104. package/plugins/dsh/skills/delphi-review/references/code-walkthrough.md +470 -0
  105. package/plugins/dsh/skills/delphi-review/references/orchestrator-dispatch.md +64 -0
  106. package/plugins/dsh/skills/delphi-review/references/requirements.md +402 -0
  107. package/plugins/dsh/skills/delphi-review/references/round-templates.md +134 -0
  108. package/plugins/dsh/skills/delphi-review/scripts/verify-consensus.sh +43 -0
  109. package/plugins/dsh/skills/delphi-review/tools.md +29 -0
  110. package/plugins/dsh/skills/domain-modeling/ADR-FORMAT.md +64 -0
  111. package/plugins/dsh/skills/domain-modeling/CONTEXT-FORMAT.md +60 -0
  112. package/plugins/dsh/skills/domain-modeling/SKILL.md +74 -0
  113. package/plugins/dsh/skills/grill-with-docs/SKILL.md +7 -0
  114. package/plugins/dsh/skills/grilling/SKILL.md +12 -0
  115. package/plugins/dsh/skills/improve-codebase-architecture/SKILL.md +156 -0
  116. package/plugins/dsh/skills/ralph-loop/SKILL.md +198 -0
  117. package/plugins/dsh/skills/ralph-loop/references/components.md +113 -0
  118. package/plugins/dsh/skills/ralph-loop/references/phase-2-build-ralph.md +89 -0
  119. package/plugins/dsh/skills/ralph-loop/references/workflow-details.md +99 -0
  120. package/plugins/dsh/skills/ralph-loop/templates/progress-log.md +36 -0
  121. package/plugins/dsh/skills/sprint-flow/AGENTS.md +103 -0
  122. package/plugins/dsh/skills/sprint-flow/SKILL.md +411 -0
  123. package/plugins/dsh/skills/sprint-flow/__tests__/sprint-flow.test.cjs +457 -0
  124. package/plugins/dsh/skills/sprint-flow/hooks.md +18 -0
  125. package/plugins/dsh/skills/sprint-flow/references/components/memory.md +87 -0
  126. package/plugins/dsh/skills/sprint-flow/references/components/middleware.md +75 -0
  127. package/plugins/dsh/skills/sprint-flow/references/components/skill-invocations.md +105 -0
  128. package/plugins/dsh/skills/sprint-flow/references/components/system-prompt.md +27 -0
  129. package/plugins/dsh/skills/sprint-flow/references/components/tool-descriptions.md +95 -0
  130. package/plugins/dsh/skills/sprint-flow/references/force-levels.md +204 -0
  131. package/plugins/dsh/skills/sprint-flow/references/orchestration-rules.md +236 -0
  132. package/plugins/dsh/skills/sprint-flow/references/phase-1-prep.md +294 -0
  133. package/plugins/dsh/skills/sprint-flow/references/phase-2-design.md +273 -0
  134. package/plugins/dsh/skills/sprint-flow/references/phase-3-build.md +348 -0
  135. package/plugins/dsh/skills/sprint-flow/references/phase-4-verify.md +225 -0
  136. package/plugins/dsh/skills/sprint-flow/references/phase-5-ship.md +222 -0
  137. package/plugins/dsh/skills/sprint-flow/references/phase-6-close.md +266 -0
  138. package/plugins/dsh/skills/sprint-flow/references/phase-overview.md +486 -0
  139. package/plugins/dsh/skills/sprint-flow/scripts/verify-sprint-state.sh +38 -0
  140. package/plugins/dsh/skills/sprint-flow/templates/auto-estimate-learning-log.md +136 -0
  141. package/plugins/dsh/skills/sprint-flow/templates/auto-estimate-output-template.md +110 -0
  142. package/plugins/dsh/skills/sprint-flow/templates/emergent-issues-template.md +120 -0
  143. package/plugins/dsh/skills/sprint-flow/templates/pain-document-template.md +115 -0
  144. package/plugins/dsh/skills/sprint-flow/templates/sprint-progress-template.md +140 -0
  145. package/plugins/dsh/skills/sprint-flow/templates/sprint-summary-template.md +121 -0
  146. package/plugins/dsh/skills/sprint-flow/tools.md +29 -0
  147. package/plugins/dsh/skills/test-driven-development/SKILL.md +371 -0
  148. package/plugins/dsh/skills/test-driven-development/testing-anti-patterns.md +299 -0
  149. package/plugins/dsh/skills/test-specification-alignment/AGENTS.md +56 -0
  150. package/plugins/dsh/skills/test-specification-alignment/SKILL.md +205 -0
  151. package/plugins/dsh/skills/test-specification-alignment/references/alignment-verification-algorithm.md +493 -0
  152. package/plugins/dsh/skills/test-specification-alignment/references/phase2-constraint-enforcement.md +431 -0
  153. package/plugins/dsh/skills/test-specification-alignment/references/specification-format.md +348 -0
  154. package/plugins/dsh/skills/to-issues/SKILL.md +277 -0
  155. package/plugins/dsh/src/command.test.ts +102 -0
  156. package/plugins/dsh/src/command.ts +75 -0
  157. package/plugins/dsh/src/contract.test.ts +62 -0
  158. package/plugins/dsh/src/gate-runner.test.ts +100 -0
  159. package/plugins/dsh/src/gate-runner.ts +58 -0
  160. package/plugins/dsh/src/index.test.ts +97 -0
  161. package/plugins/dsh/src/index.ts +94 -0
  162. package/plugins/dsh/src/skills.test.ts +58 -0
  163. package/plugins/dsh/tsconfig.build.json +13 -0
  164. package/plugins/dsh/tsconfig.json +19 -0
  165. package/plugins/dsh/vitest.config.ts +8 -0
  166. package/plugins/opencode/package.json +1 -1
  167. package/plugins/opencode/scripts/prepack.cjs +1 -0
  168. package/plugins/opencode/skills/clipboard-vision/SKILL.md +47 -0
  169. package/plugins/opencode/skills/clipboard-vision/__tests__/clipboard-vision-distribution.test.cjs +65 -0
  170. package/plugins/opencode/skills/clipboard-vision/__tests__/clipboard-vision-security.test.cjs +185 -0
  171. package/plugins/opencode/skills/clipboard-vision/__tests__/clipboard-vision.Tests.ps1 +138 -0
  172. package/plugins/opencode/skills/clipboard-vision/__tests__/clipboard-vision.test.cjs +273 -0
  173. package/plugins/opencode/skills/clipboard-vision/describe-clipboard.ps1 +115 -0
  174. package/plugins/opencode/skills/clipboard-vision/describe-clipboard.sh +161 -0
  175. package/plugins/opencode/skills/clipboard-vision/scripts/clipboard-vision.ps1 +86 -0
  176. package/plugins/opencode/skills/clipboard-vision/scripts/clipboard-vision.sh +137 -0
  177. package/plugins/opencode/skills/delphi-review/.delphi-config.json.example +24 -27
  178. package/plugins/opencode/skills/delphi-review/AGENTS.md +13 -12
  179. package/plugins/opencode/skills/delphi-review/INSTALL.md +15 -17
  180. package/plugins/opencode/skills/delphi-review/SKILL.md +30 -29
  181. package/plugins/opencode/skills/delphi-review/opencode.json.delphi.example +6 -10
  182. package/plugins/opencode/skills/delphi-review/references/code-walkthrough.md +33 -49
  183. package/plugins/opencode/skills/delphi-review/references/requirements.md +66 -54
  184. package/plugins/opencode/skills/delphi-review/references/round-templates.md +7 -7
  185. package/plugins/opencode/skills/sprint-flow/AGENTS.md +5 -5
  186. package/plugins/opencode/skills/sprint-flow/SKILL.md +4 -4
  187. package/plugins/opencode/skills/sprint-flow/references/components/skill-invocations.md +2 -2
  188. package/plugins/opencode/skills/sprint-flow/references/force-levels.md +37 -35
  189. package/plugins/opencode/skills/sprint-flow/references/orchestration-rules.md +1 -1
  190. package/plugins/opencode/skills/sprint-flow/references/phase-1-prep.md +1 -1
  191. package/plugins/opencode/skills/sprint-flow/references/phase-2-design.md +24 -14
  192. package/plugins/opencode/skills/sprint-flow/references/phase-4-verify.md +6 -6
  193. package/plugins/opencode/skills/sprint-flow/references/phase-overview.md +2 -2
  194. package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +4 -4
  195. package/plugins/qoder/plugin.json +1 -1
  196. package/plugins/qoder/skills/clipboard-vision/SKILL.md +47 -0
  197. package/plugins/qoder/skills/clipboard-vision/__tests__/clipboard-vision-distribution.test.cjs +65 -0
  198. package/plugins/qoder/skills/clipboard-vision/__tests__/clipboard-vision-security.test.cjs +185 -0
  199. package/plugins/qoder/skills/clipboard-vision/__tests__/clipboard-vision.Tests.ps1 +138 -0
  200. package/plugins/qoder/skills/clipboard-vision/__tests__/clipboard-vision.test.cjs +273 -0
  201. package/plugins/qoder/skills/clipboard-vision/clipboard-vision/SKILL.md +47 -0
  202. package/plugins/qoder/skills/clipboard-vision/clipboard-vision/__tests__/clipboard-vision-distribution.test.cjs +65 -0
  203. package/plugins/qoder/skills/clipboard-vision/clipboard-vision/__tests__/clipboard-vision-security.test.cjs +185 -0
  204. package/plugins/qoder/skills/clipboard-vision/clipboard-vision/__tests__/clipboard-vision.Tests.ps1 +138 -0
  205. package/plugins/qoder/skills/clipboard-vision/clipboard-vision/__tests__/clipboard-vision.test.cjs +273 -0
  206. package/plugins/qoder/skills/clipboard-vision/clipboard-vision/scripts/clipboard-vision.ps1 +86 -0
  207. package/plugins/qoder/skills/clipboard-vision/clipboard-vision/scripts/clipboard-vision.sh +137 -0
  208. package/plugins/qoder/skills/clipboard-vision/scripts/clipboard-vision.ps1 +86 -0
  209. package/plugins/qoder/skills/clipboard-vision/scripts/clipboard-vision.sh +137 -0
  210. package/plugins/qoder/skills/delphi-review/.delphi-config.json.example +3 -11
  211. package/plugins/qoder/skills/delphi-review/AGENTS.md +15 -17
  212. package/plugins/qoder/skills/delphi-review/INSTALL.md +12 -12
  213. package/plugins/qoder/skills/delphi-review/SKILL.md +58 -25
  214. package/plugins/qoder/skills/delphi-review/opencode.json.delphi.example +1 -1
  215. package/plugins/qoder/skills/delphi-review/references/code-walkthrough.md +33 -49
  216. package/plugins/qoder/skills/sprint-flow/AGENTS.md +5 -5
  217. package/plugins/qoder/skills/sprint-flow/SKILL.md +2 -2
  218. package/plugins/qoder/skills/sprint-flow/references/force-levels.md +38 -35
  219. package/plugins/qoder/skills/sprint-flow/references/phase-1-prep.md +1 -1
  220. package/plugins/qoder/skills/sprint-flow/references/phase-2-design.md +48 -6
  221. package/plugins/qoder/skills/sprint-flow/references/phase-4-verify.md +5 -6
  222. package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +4 -4
  223. package/principles/AGENTS.md +4 -4
  224. package/scripts/__tests__/sync-package-content.test.js +30 -0
  225. package/scripts/delphi-external-review.cjs +194 -63
  226. package/scripts/sync-package-content.js +9 -2
  227. package/skills/clipboard-vision/SKILL.md +47 -0
  228. package/skills/clipboard-vision/__tests__/clipboard-vision-distribution.test.cjs +65 -0
  229. package/skills/clipboard-vision/__tests__/clipboard-vision-security.test.cjs +185 -0
  230. package/skills/clipboard-vision/__tests__/clipboard-vision.Tests.ps1 +138 -0
  231. package/skills/clipboard-vision/__tests__/clipboard-vision.test.cjs +273 -0
  232. package/skills/clipboard-vision/describe-clipboard.ps1 +115 -0
  233. package/skills/clipboard-vision/describe-clipboard.sh +161 -0
  234. package/skills/clipboard-vision/scripts/clipboard-vision.ps1 +86 -0
  235. package/skills/clipboard-vision/scripts/clipboard-vision.sh +137 -0
  236. package/skills/delphi-review/.delphi-config.json.example +24 -27
  237. package/skills/delphi-review/AGENTS.md +13 -12
  238. package/skills/delphi-review/INSTALL.md +15 -17
  239. package/skills/delphi-review/SKILL.md +30 -29
  240. package/skills/delphi-review/opencode.json.delphi.example +6 -10
  241. package/skills/delphi-review/references/code-walkthrough.md +33 -49
  242. package/skills/delphi-review/references/requirements.md +66 -54
  243. package/skills/delphi-review/references/round-templates.md +7 -7
  244. package/skills/sprint-flow/AGENTS.md +5 -5
  245. package/skills/sprint-flow/SKILL.md +4 -4
  246. package/skills/sprint-flow/references/components/skill-invocations.md +2 -2
  247. package/skills/sprint-flow/references/force-levels.md +37 -35
  248. package/skills/sprint-flow/references/orchestration-rules.md +1 -1
  249. package/skills/sprint-flow/references/phase-1-prep.md +1 -1
  250. package/skills/sprint-flow/references/phase-2-design.md +24 -14
  251. package/skills/sprint-flow/references/phase-4-verify.md +6 -6
  252. package/skills/sprint-flow/references/phase-overview.md +2 -2
  253. package/skills/test-specification-alignment/AGENTS.md +4 -4
  254. package/sprint-gate.sh +291 -0
@@ -0,0 +1,222 @@
1
+ # Phase 5/6: SHIP(发布 — 发布准备 + 合并部署)
2
+
3
+ **执行时机**: Phase 4/6 VERIFY 完成后、Phase 6/6 CLOSE 之前。
4
+ **对应旧模型**: Phase 5 SHIP + Phase 6 LAND
5
+
6
+ **摘要**: 结构化分支完成决策(原生 4 选项), 创建 PR(原生步骤), 合并部署(原生步骤), 监控. 生成 Sprint Summary.
7
+
8
+ ---
9
+
10
+ ## Part A: SHIP(发布准备)
11
+
12
+ **Orchestrator 直接执行**: 分支完成决策和 PR 创建均为交互式步骤(4 选项菜单 + PR 确认),**必须由 orchestrator 直接执行**。
13
+
14
+ **关键链**: VERSION-GATE(MANDATORY) → 分支完成决策(4选项) → push PR
15
+
16
+ **HARD-GATE**: Phase 4/6 VERIFY 未完成 → BLOCK。验证 `feedback-log.md` 存在。
17
+
18
+ **GITHOOKS-GATE**: 验证 hooks 完整性,缺失则 `githooks/install.sh`
19
+
20
+ **NETWORK-RESILIENCE**: GitHub API 在大中华区存在间歇性 TLS/超时问题。所有 `gh` CLI 调用应容忍偶尔失败:
21
+ - `gh` 命令失败时等待 2-5 秒后重试(最多 3 次)
22
+ - 优先使用 REST API (`gh api /repos/...`) 而非 GraphQL (`gh pr view --json ...`),REST 更轻量更可靠
23
+ - 验证 CI 状态时使用 `gh run list --branch ... --limit 1 --json status,conclusion` 代替 `gh pr view --json statusCheckRollup`
24
+ - 如果 `gh` 持续超时,fallback 到 `curl + token`:
25
+ ```
26
+ curl -s -H "Authorization: token $(gh auth token)" \
27
+ "https://api.github.com/repos/OWNER/REPO/commits/HEAD/status"
28
+ ```
29
+
30
+ ### Step 0: VERSION-GATE(MANDATORY — 在分支完成决策之前执行)
31
+
32
+ **Purpose**: Ensure version bump, changelog update, and sync before creating PR. This MUST run BEFORE the branch completion decision — the "Create PR" option creates the PR immediately, so version changes must be committed first.
33
+
34
+ **Execution**:
35
+
36
+ ```
37
+ 1. 根据变更类型决定 bump 级别:
38
+ - PATCH (0.14.0 → 0.14.1): bug fixes, docs, minor enhancements
39
+ - MINOR (0.14.0 → 0.15.0): new features, significant enhancements
40
+ - MAJOR (0.14.0 → 1.0.0): breaking changes
41
+
42
+ 2. 更新 VERSION 文件 (MAJOR.MINOR.PATCH.MICRO 格式)
43
+
44
+ 3. 更新 CHANGELOG.md:
45
+ - 添加新版本条目 (## [X.Y.Z.W] - YYYY-MM-DD)
46
+ - 按 ### Added / ### Fixed / ### Changed 分类
47
+
48
+ 4. 运行 sync-version.sh:
49
+ bash scripts/sync-version.sh
50
+
51
+ 5. 验证:
52
+ git diff VERSION # 确认版本号变更
53
+ git diff CHANGELOG.md # 确认 changelog 变更
54
+ git diff --stat # 确认 package.json 版本同步
55
+
56
+ 6. 提交版本变更:
57
+ git add VERSION CHANGELOG.md && git commit -m "release: bump version to X.Y.Z.W"
58
+
59
+ 7. 推送到远程分支:
60
+ git push
61
+
62
+ 8. 验证 CI 流程触发:
63
+ gh pr view <PR_NUMBER> --json state # 确认 CI 已开始
64
+ ```
65
+
66
+ **GATE CHECK** (BEFORE proceeding to branch completion decision):
67
+ ```
68
+ [VERSION-GATE] VERSION bump ✓ # VERSION 文件已更新
69
+ [VERSION-GATE] CHANGELOG ✓ # 新版本条目已添加
70
+ [VERSION-GATE] sync-version ✓ # 所有 package.json 已同步
71
+ [VERSION-GATE] committed ✓ # 版本变更已提交并推送
72
+ [VERSION-GATE] PR updated ✓ # PR 已包含版本变更 commit
73
+ ```
74
+
75
+ **⚠️ ANTI-PATTERN**: 先创建 PR 再 bump VERSION 会导致 PR 不含版本变更 → CI 不触发 release workflow → 无新版本发布。
76
+
77
+ **输出**: 版本变更 commit 包含在 PR 中
78
+
79
+ ### Step 1: 分支完成决策(原生 4 选项 — AskUserQuestion)
80
+
81
+ VERSION-GATE 通过后,orchestrator 向用户展示 4 选项菜单:
82
+
83
+ ```
84
+ ⚠️ Phase 5/6 SHIP: 分支完成决策
85
+
86
+ Sprint 分支已准备就绪。请选择操作:
87
+
88
+ 1. **Merge to main** — 直接合并到主分支(适用于个人项目或已确认无需 PR 审查)
89
+ 2. **Push and create a Pull Request** — 推送并创建 PR(推荐,含 CI 验证)
90
+ 3. **Keep branch** — 保留分支,稍后处理
91
+ 4. **Discard** — 丢弃分支(⚠️ 需要输入确认)
92
+
93
+ 请选择 (1-4):
94
+ ```
95
+
96
+ **Option 4 (Discard) 安全确认**: 要求用户输入分支名确认,防止误删。
97
+
98
+ **默认推荐**: Option 2(Push and create a Pull Request)。
99
+
100
+ ### Step 2: 原生 Ship 步骤序列(选择 Option 2 时执行)
101
+
102
+ ```
103
+ 1. 运行测试:
104
+ npm test # 或项目特定测试命令
105
+
106
+ 2. VERSION-GATE 已通过(Step 0)
107
+
108
+ 3. 提交所有变更:
109
+ git add -A && git commit -m "feat: <sprint-description>"
110
+
111
+ 4. 推送到远程:
112
+ git push -u origin <sprint-branch>
113
+
114
+ 5. 创建 PR:
115
+ gh pr create --title "feat: <description>" --body "<sprint-summary>"
116
+
117
+ 6. 输出 PR URL
118
+ ```
119
+
120
+ **输出**: PR URL (含版本变更 commit)
121
+
122
+ ---
123
+
124
+ ## Part B: LAND(合并 + 部署 — 原生步骤)
125
+
126
+ **Orchestrator 直接执行**: 合并确认和 rollback 决策均为用户交互点,**必须由 orchestrator 直接执行**。
127
+
128
+ **输入**: PR URL → 输出: 部署状态 + Canary 报告
129
+
130
+ ### Step 1: Merge 确认
131
+
132
+ ```
133
+ ⚠️ 确认合并 PR #<number> 到 main?
134
+
135
+ PR: <PR URL>
136
+ 变更: <files changed> 个文件, +<additions>/-<deletions>
137
+
138
+ 确认合并? (yes/no):
139
+ ```
140
+
141
+ ### Step 2: 等待 CI
142
+
143
+ ```
144
+ # 等待 CI 完成(最多 10 分钟)
145
+ gh run list --branch main --limit 1 --json status,conclusion
146
+
147
+ # 轮询直到完成
148
+ WHILE status != "completed":
149
+ 等待 30 秒
150
+ 重新查询
151
+ ```
152
+
153
+ ### Step 3: 等待 Deploy(如适用)
154
+
155
+ ```
156
+ # 等待部署完成(最多 10 分钟)
157
+ # 检测部署平台(Fly.io/Render/Vercel/Netlify/Heroku/GitHub Actions)
158
+ # 查询部署状态
159
+ ```
160
+
161
+ **条件跳过**: 无部署配置时仅 merge + CI。
162
+
163
+ ### Step 4: Canary Health Check(如适用,最多 5 分钟)
164
+
165
+ ```
166
+ # 健康检查端点
167
+ curl -s <health-check-url>
168
+ # 验证返回 200 + 预期响应
169
+ ```
170
+
171
+ ### Step 5: 失败回滚
172
+
173
+ ```
174
+ IF CI 失败 OR 部署失败 OR canary 异常:
175
+ git revert <merge-commit-sha>
176
+ git push
177
+ 输出 "[ROLLBACK] 已回滚 merge commit"
178
+ ```
179
+
180
+ **输出**: 部署状态 (success/failure/skipped), Canary 报告
181
+
182
+ ---
183
+
184
+ ## SHIP COMPLETION GATE (MANDATORY — v0.14.3+)
185
+
186
+ **Purpose**: Ensure merge to main + release is complete before Phase 6/6 CLOSE. Without this gate, worktree cleanup fails (uncommitted changes + unmerged branch) and UAT happens on the wrong version (PR branch, not main).
187
+
188
+ **Execution** (BEFORE transitioning to Phase 6/6):
189
+
190
+ ```
191
+ 1. Verify PR is merged:
192
+ gh pr list --head <sprint-branch> --state merged --json number
193
+ → If no merged PR: BLOCK. Do NOT proceed to Phase 6/6.
194
+
195
+ 2. Verify current branch is main:
196
+ CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
197
+ → If not main/master: BLOCK. Switch to main first.
198
+
199
+ 3. Verify git status is clean:
200
+ git status --porcelain
201
+ → If not empty: BLOCK. Stash or commit changes first.
202
+
203
+ 4. Verify release exists:
204
+ gh release view v<X.Y.Z> --json tagName
205
+ → If not found: WARNING (manual release may have failed). Ask user.
206
+
207
+ 5. Pull latest main:
208
+ git checkout main && git pull
209
+ ```
210
+
211
+ **GATE CHECK** (BEFORE Phase 6/6 CLOSE):
212
+ ```
213
+ [SHIP→CLOSE GATE] PR merged ✓ # PR is in merged state
214
+ [SHIP→CLOSE GATE] on main branch ✓ # Current branch is main/master
215
+ [SHIP→CLOSE GATE] clean status ✓ # No uncommitted changes
216
+ [SHIP→CLOSE GATE] release exists ✓ # GitHub Release created
217
+ [SHIP→CLOSE GATE] main up-to-date ✓ # Pulled latest
218
+ ```
219
+
220
+ **IF GATE FAILS**: Orchestrator MUST complete the merge/release steps BEFORE proceeding to Phase 6/6. Do NOT skip to CLOSE.
221
+
222
+ **Output**: SHIP completion confirmation, ready for Phase 6/6.
@@ -0,0 +1,266 @@
1
+ # Phase 6/6: CLOSE(收尾 — ⚠️ 人工验收 + 清理)
2
+
3
+ **执行时机**: Phase 5/6 SHIP 完成后(merge to main + release 已完成)。
4
+ **对应旧模型**: Phase 7 USER ACCEPTANCE + Phase 8 CLEANUP
5
+
6
+ **NETWORK-RESILIENCE**: 与 Phase 5/6 相同,GitHub API 在大中华区存在间歇性超时。CLEANUP 中的 `gh pr list` 和 `git push --delete` 需容忍重试。详见 `phase-5-ship.md` NETWORK-RESILIENCE 指南。
7
+
8
+ ---
9
+
10
+ ## ⚠️ HARD-GATE: SHIP→CLOSE GATE (MANDATORY — v0.14.3+)
11
+
12
+ **Purpose**: Verify that Phase 5/6 SHIP fully completed (merge to main + release) before entering Phase 6/6 CLOSE. This gate prevents:
13
+ - Worktree cleanup failure (uncommitted changes prevent `git worktree remove`)
14
+ - UAT on wrong version (PR branch instead of merged main)
15
+
16
+ **Execution**: Before ANY Phase 6/6 step, run the SHIP→CLOSE GATE checks defined in `phase-5-ship.md#ship-completion-gate`.
17
+
18
+ **If gate fails**: Return to Phase 5/6 SHIP to complete merge/release. Do NOT proceed with CLOSE.
19
+
20
+ ---
21
+
22
+ ## Backup Sprint State (MANDATORY — v0.14.3+)
23
+
24
+ **Purpose**: `.sprint-state/` is gitignored and lives inside the worktree. When the worktree is removed during CLEANUP, all sprint state is lost. This step copies it into the main repository before cleanup.
25
+
26
+ **Execution** (immediately after SHIP→CLOSE GATE passes):
27
+
28
+ ```bash
29
+ # 1. Read sprint ID
30
+ SPRINT_ID=$(cat .sprint-state/sprint-state.json | grep '"id"' | head -1 | sed 's/.*"id": *"\([^"]*\)".*/\1/')
31
+
32
+ # 2. Backup to repo-tracked path (.sprint-history is NOT in .gitignore)
33
+ BACKUP_DIR=".sprint-history/${SPRINT_ID}"
34
+ mkdir -p "$BACKUP_DIR"
35
+ cp -r .sprint-state/* "$BACKUP_DIR/"
36
+
37
+ # 3. Verify backup
38
+ ls "$BACKUP_DIR/sprint-state.json" && echo "✅ Sprint state backed up to $BACKUP_DIR"
39
+ ```
40
+
41
+ **GATE CHECK**:
42
+ ```
43
+ [BACKUP] sprint-state.json copied ✓
44
+ [BACKUP] phase-outputs/ preserved ✓
45
+ ```
46
+
47
+ **Output**: `.sprint-history/<sprint-id>/` contains full sprint state, safely outside the worktree.
48
+
49
+ ---
50
+
51
+ ## Part A: USER ACCEPTANCE(⚠️ 人工验收)
52
+
53
+ ### 目标
54
+
55
+ 用户实际使用 MVP,发现 Emergent 问题。这是 AI 无法预测的环节。
56
+
57
+ ### ⚠️ 关键说明
58
+
59
+ **这是 Emergent Requirements 发现环节。**
60
+
61
+ - AI 无法预测用户看到产品后才发现的问题
62
+ - 78% 的软件失败是用户使用时发现的,不是开发阶段发现的
63
+ - 必须由用户实际使用验收
64
+
65
+ ### 调用 Skills
66
+
67
+ **无** — 必须人工
68
+
69
+ ### 执行步骤
70
+
71
+ #### Step 1: 提示用户开始验收
72
+
73
+ ```
74
+ ⚠️ Phase 6/6 CLOSE: USER ACCEPTANCE
75
+
76
+ MVP 已通过自动化验证,现在需要您实际使用验收。
77
+
78
+ 请按照以下步骤:
79
+ 1. 启动应用(或访问部署地址)
80
+ 2. 使用 Emergent Issues 检查清单进行验收
81
+ 3. 记录发现的问题
82
+ 4. 完成后确认是否继续
83
+
84
+ 验收完成后,请回复:
85
+ - "验收通过" → 进入 Part B CLEANUP
86
+ - "发现问题" → 填写 emergent-issues.md
87
+ ```
88
+
89
+ #### Step 2: 用户实际使用 MVP
90
+
91
+ 用户按照 Emergent Issues 检查清单验收,使用模板:`@templates/emergent-issues-template.md`
92
+
93
+ 检查维度:
94
+ 1. **核心功能体验** (Core Functionality UX)
95
+ 2. **多轮交互体验** (Multi-turn Interaction UX)
96
+ 3. **视觉/交互体验** (Visual/Interaction UX)
97
+ 4. **用户认知负担** (Cognitive Load)
98
+ 5. **意外发现** (Unexpected Observations)
99
+
100
+ #### Step 3: 记录 Emergent Issues
101
+
102
+ 用户填写 `emergent-issues.md`:
103
+
104
+ ```markdown
105
+ # Emergent Issues - [需求名称]
106
+
107
+ ## 验收日期: YYYY-MM-DD
108
+
109
+ ## 发现的问题
110
+
111
+ ### Critical
112
+ ### Major
113
+ ### Minor
114
+
115
+ ## 验收结论
116
+ - [ ] ✅ 验收通过,进入 CLEANUP
117
+ - [ ] ⚠️ 发现问题需 Sprint 2 迭代
118
+ ```
119
+
120
+ #### Step 4: 保存 Emergent Issues
121
+
122
+ 保存到 `<project-root>/.sprint-state/phase-outputs/emergent-issues.md`
123
+
124
+ ### 暂停点
125
+
126
+ **⚠️ 必须等待用户验收完成**
127
+
128
+ - 用户确认验收结果后才能继续
129
+ - 如果发现重大问题 → Sprint 2 回到 Phase 2/6 DESIGN
130
+
131
+ ### Sprint 2 触发逻辑
132
+
133
+ ```
134
+ Phase 6/6 CLOSE 完成时:
135
+ IF emergent_issues_count == 0 → sprint_completed,结束流程
136
+
137
+ IF emergent_issues_count > 0:
138
+ ├─ IF emergent_issues 有 Critical → 自动启动 Sprint 2
139
+ ├─ IF emergent_issues 仅 Major/Minor → 询问用户
140
+ └─ Sprint 2 Pain Document 从 emergent-issues.md 转化
141
+ ```
142
+
143
+ ### 输出
144
+
145
+ - Emergent Issues List (`emergent-issues.md`)
146
+ - 进入 Part A.5 ARCHIVE 自动执行(如果用户确认验收)
147
+
148
+ ---
149
+
150
+ ## Part A.5: ARCHIVE(归档 — v0.14.0+ Issue #308)
151
+
152
+ **Purpose**: Preserve sprint decision records before cleanup. `.sprint-state/` is gitignored and deleted during CLEANUP; this step copies structured outputs to `.sprint-history/` which is tracked by git.
153
+
154
+ **Execution**: After USER ACCEPTANCE (Part A) confirms continuation, BEFORE CLEANUP (Part B).
155
+
156
+ ### Step 1: Read Sprint ID
157
+
158
+ Read `sprint-state.json` → `id` field (e.g., `sprint-2026-07-09-01`).
159
+
160
+ ### Step 2: Check for Conflicts
161
+
162
+ ```
163
+ IF .sprint-history/<sprint-id>/ already exists:
164
+ → Append timestamp suffix: <sprint-id>-20260709T120000
165
+ → Log warning: "Sprint archive conflict, using timestamp suffix"
166
+ ```
167
+
168
+ ### Step 3: Archive Files
169
+
170
+ Copy from `.sprint-state/` to `.sprint-history/<sprint-id>/`:
171
+
172
+ **Included** (all `.yaml`, `.json`, `.md` files under `.sprint-state/`):
173
+ - `specification.yaml` (if in phase-outputs/)
174
+ - `delphi-reviewed.json`
175
+ - `sprint-state.json`
176
+ - `phase-outputs/*.yaml`, `phase-outputs/*.json`, `phase-outputs/*.md`
177
+ - `tdd-gate-log.json`, `uncommitted-gate-log.json`
178
+
179
+ **Excluded** (temporary/cache):
180
+ - `*.tmp`, `*.cache` files
181
+ - `sprint.lock` (session lock file)
182
+
183
+ ### Step 4: Verify Git Tracking
184
+
185
+ ```bash
186
+ # .sprint-history/ is NOT in .gitignore (verified — no change needed)
187
+ # Verify files are trackable:
188
+ git status .sprint-history/
189
+ ```
190
+
191
+ **No `.gitignore` change needed**: `.sprint-history/` is NOT currently listed in `.gitignore`. The `.sprint-state/` ignore (line 59) only matches `.sprint-state/` exactly — it does NOT match `.sprint-history/`.
192
+
193
+ ### Step 5: Commit Archive (Optional)
194
+
195
+ The orchestrator MAY commit the archive:
196
+ ```
197
+ git add .sprint-history/<sprint-id>/ && git commit -m "archive: sprint <sprint-id>"
198
+ ```
199
+
200
+ ### Output
201
+
202
+ - `.sprint-history/<sprint-id>/` directory with archived sprint state
203
+ - Git-tracked sprint decision records for future retro/review
204
+
205
+ ---
206
+
207
+ ## Part B: CLEANUP(清理 + 总结 + 返工追踪)
208
+
209
+ **摘要**: 写入 #369 返工指标, 自动清理 worktree, 更新 sprint-state.json, 输出 Sprint Summary, 处理 emergent issues.
210
+
211
+ ### Step 0: #369 返工追踪指标写入(v0.18.0+)
212
+
213
+ **Purpose**: Sprint 完成后追踪返工率,暴露"门禁全过但仍返工"的质量问题。
214
+
215
+ **Execution** (CLEANUP 开始时,worktree 清理前):
216
+
217
+ ```
218
+ 1. 写入 metrics.completed_at:
219
+ ISO 8601 时间戳 → sprint-state.json metrics.completed_at
220
+
221
+ 2. 计算 metrics.total_sprint_commits:
222
+ 精确定义: sprint 分支 base(merge-base)到 sprint 合并点的提交数
223
+ CLOSE 时由 CLI 计算写入:
224
+ npx xp-gate sprint-status --rework-check
225
+
226
+ 3. 写入 metrics.merge_base_sha:
227
+ merge-base SHA → sprint-state.json metrics.merge_base_sha
228
+ (SHIP 阶段存入,供删分支后 rework-check 使用 — C5 澄清)
229
+ ```
230
+
231
+ **返工率计算** (`xp-gate sprint-status --rework-check [--window-days N]`):
232
+ - 默认窗口: 7 天(可配置)
233
+ - 扫描范围: **仓库范围**(不限同一分支 — 主工作流"合并 PR + 删除分支"下同分支判定恒为 0)
234
+ - fix 提交匹配: conventional commits 优先 `^fix(\(.+\))?:`,辅以词边界关键词 `\b(fix|bugfix|hotfix|patch|修复)\b`
235
+ - 计算: `rework_rate = fix_commits_in_window / total_sprint_commits`
236
+ - 写回 `metrics.rework_rate`
237
+
238
+ **告警**: `rework_rate > 30%` → 告警输出(并纳入 `xp-gate retro` 报告区块)
239
+
240
+ **注意**: "重新打开的 issue 数"指标已删除(Round 1 修订:零依赖原则下无可靠数据源)。
241
+
242
+ ### 执行步骤
243
+
244
+ 1. **保存分支信息** → 记录清理前的分支和工作树信息
245
+ 2. **清理 worktree**: `git worktree remove <worktree_path>`(精确路径,禁止通配符)
246
+ - 重试机制: 失败后重试最多 3 次,每次间隔 3 秒
247
+ - 仍失败: 输出 `[ERROR]` + 手动清理命令
248
+ 3. **删除本地分支**: `git branch -D sprint/YYYY-MM-DD-NN`
249
+ 4. **删除远程分支**: `git push origin --delete sprint/YYYY-MM-DD-NN`
250
+ 5. **关闭遗留 OPEN PR**: `gh pr list --head sprint/YYYY-MM-DD-NN --state open`
251
+ 6. **更新 sprint-state.json**: 设置 `phase: 6`, `status: "completed"`, 写入 `metrics.completed_at` + `metrics.total_sprint_commits`(#369)
252
+ 7. **释放 Sprint Lock** (Issue #144): 删除 `.sprint-state/sprint.lock`
253
+ 8. **Learnings 写入**(原生): 将 Sprint 中发现的模式/教训追加到 `.sprint-history/learnings.md`
254
+ 9. **Sprint Summary**: 使用 `templates/sprint-summary-template.md` 生成总结
255
+ 10. **处理 Emergent Issues**: 如 Part A 发现 emergent issues → 触发 Sprint 2 逻辑
256
+
257
+ ### 输出
258
+
259
+ - Cleanup Report
260
+ - Sprint Summary
261
+ - 条件跳过: `--no-isolate` 路径下跳过 worktree 清理(无 worktree 可清理)
262
+
263
+ ### 暂停点
264
+
265
+ - **清理失败**: 输出 `[ERROR]` 日志 + 建议手动清理命令 → 用户确认后继续
266
+ - **Sprint Summary**: 展示完整 Sprint 总结 → 用户确认 → 结束流程