@boyingliu01/xp-gate 0.15.4 → 0.18.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 (117) hide show
  1. package/bin/xp-gate.js +29 -1
  2. package/hooks/lib/now-ms.sh +33 -0
  3. package/hooks/pre-commit +63 -47
  4. package/hooks/sprint-gate.sh +291 -0
  5. package/lib/__tests__/check-version.test.js +122 -0
  6. package/lib/__tests__/doctor.test.js +13 -15
  7. package/lib/__tests__/gate-audit.test.ts +38 -0
  8. package/lib/__tests__/phase-transition.test.js +241 -1
  9. package/lib/__tests__/retro.test.js +131 -0
  10. package/lib/__tests__/sprint-status-rework.test.js +184 -0
  11. package/lib/check-version.js +9 -0
  12. package/lib/doctor-tui.js +79 -9
  13. package/lib/doctor.js +15 -3
  14. package/lib/gate-audit.ts +18 -7
  15. package/lib/gate-runner.js +77 -30
  16. package/lib/init.js +10 -0
  17. package/lib/mattpocock-license-verdict.json +7 -0
  18. package/lib/phase-transition.js +251 -1
  19. package/lib/retro.js +222 -0
  20. package/lib/shared-utils.js +7 -0
  21. package/lib/sprint-init.js +207 -0
  22. package/lib/sprint-state-migrator.js +1 -0
  23. package/lib/sprint-status.js +111 -0
  24. package/mock-policy/AGENTS.md +3 -3
  25. package/mutation/AGENTS.md +3 -3
  26. package/package.json +3 -2
  27. package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
  28. package/plugins/claude-code/skills/batch-grill-me/SKILL.md +15 -0
  29. package/plugins/claude-code/skills/delphi-review/AGENTS.md +3 -3
  30. package/plugins/claude-code/skills/delphi-review/SKILL.md +59 -4
  31. package/plugins/claude-code/skills/delphi-review/references/requirements.md +390 -0
  32. package/plugins/claude-code/skills/delphi-review/references/round-templates.md +67 -0
  33. package/plugins/claude-code/skills/domain-modeling/ADR-FORMAT.md +64 -0
  34. package/plugins/claude-code/skills/domain-modeling/CONTEXT-FORMAT.md +60 -0
  35. package/plugins/claude-code/skills/domain-modeling/SKILL.md +74 -0
  36. package/plugins/claude-code/skills/grill-with-docs/SKILL.md +7 -0
  37. package/plugins/claude-code/skills/grilling/SKILL.md +12 -0
  38. package/plugins/claude-code/skills/sprint-flow/AGENTS.md +3 -3
  39. package/plugins/claude-code/skills/sprint-flow/SKILL.md +168 -43
  40. package/plugins/claude-code/skills/sprint-flow/references/components/memory.md +1 -1
  41. package/plugins/claude-code/skills/sprint-flow/references/components/middleware.md +1 -1
  42. package/plugins/claude-code/skills/sprint-flow/references/components/skill-invocations.md +21 -20
  43. package/plugins/claude-code/skills/sprint-flow/references/components/tool-descriptions.md +22 -23
  44. package/plugins/claude-code/skills/sprint-flow/references/orchestration-rules.md +14 -12
  45. package/plugins/claude-code/skills/sprint-flow/references/phase-2-design.md +145 -133
  46. package/plugins/claude-code/skills/sprint-flow/references/phase-3-build.md +69 -2
  47. package/plugins/claude-code/skills/sprint-flow/references/phase-4-verify.md +93 -31
  48. package/plugins/claude-code/skills/sprint-flow/references/phase-5-ship.md +99 -14
  49. package/plugins/claude-code/skills/sprint-flow/references/phase-6-close.md +37 -5
  50. package/plugins/claude-code/skills/sprint-flow/references/phase-overview.md +58 -53
  51. package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +3 -3
  52. package/plugins/claude-code/skills/test-specification-alignment/SKILL.md +8 -3
  53. package/plugins/claude-code/skills/to-issues/SKILL.md +1 -1
  54. package/plugins/opencode/index.ts +1 -0
  55. package/plugins/opencode/package.json +1 -1
  56. package/plugins/opencode/skills/batch-grill-me/SKILL.md +15 -0
  57. package/plugins/opencode/skills/delphi-review/AGENTS.md +3 -3
  58. package/plugins/opencode/skills/delphi-review/SKILL.md +59 -4
  59. package/plugins/opencode/skills/delphi-review/references/requirements.md +390 -0
  60. package/plugins/opencode/skills/delphi-review/references/round-templates.md +67 -0
  61. package/plugins/opencode/skills/domain-modeling/ADR-FORMAT.md +64 -0
  62. package/plugins/opencode/skills/domain-modeling/CONTEXT-FORMAT.md +60 -0
  63. package/plugins/opencode/skills/domain-modeling/SKILL.md +74 -0
  64. package/plugins/opencode/skills/grill-with-docs/SKILL.md +7 -0
  65. package/plugins/opencode/skills/grilling/SKILL.md +12 -0
  66. package/plugins/opencode/skills/sprint-flow/AGENTS.md +3 -3
  67. package/plugins/opencode/skills/sprint-flow/SKILL.md +168 -43
  68. package/plugins/opencode/skills/sprint-flow/references/components/memory.md +1 -1
  69. package/plugins/opencode/skills/sprint-flow/references/components/middleware.md +1 -1
  70. package/plugins/opencode/skills/sprint-flow/references/components/skill-invocations.md +21 -20
  71. package/plugins/opencode/skills/sprint-flow/references/components/tool-descriptions.md +22 -23
  72. package/plugins/opencode/skills/sprint-flow/references/orchestration-rules.md +14 -12
  73. package/plugins/opencode/skills/sprint-flow/references/phase-2-design.md +145 -133
  74. package/plugins/opencode/skills/sprint-flow/references/phase-3-build.md +69 -2
  75. package/plugins/opencode/skills/sprint-flow/references/phase-4-verify.md +93 -31
  76. package/plugins/opencode/skills/sprint-flow/references/phase-5-ship.md +99 -14
  77. package/plugins/opencode/skills/sprint-flow/references/phase-6-close.md +37 -5
  78. package/plugins/opencode/skills/sprint-flow/references/phase-overview.md +58 -53
  79. package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +3 -3
  80. package/plugins/opencode/skills/test-specification-alignment/SKILL.md +8 -3
  81. package/plugins/opencode/skills/to-issues/SKILL.md +1 -1
  82. package/plugins/qoder/plugin.json +1 -1
  83. package/plugins/qoder/skills/delphi-review/AGENTS.md +3 -3
  84. package/plugins/qoder/skills/sprint-flow/AGENTS.md +3 -3
  85. package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +3 -3
  86. package/principles/AGENTS.md +3 -3
  87. package/scripts/__tests__/check-mattpocock-license.test.js +229 -0
  88. package/scripts/__tests__/sync-package-content.test.js +50 -0
  89. package/scripts/check-mattpocock-license.cjs +302 -0
  90. package/scripts/migrate-audit-anomalies.mjs +78 -0
  91. package/scripts/sync-package-content.js +52 -5
  92. package/skills/batch-grill-me/SKILL.md +15 -0
  93. package/skills/delphi-review/AGENTS.md +3 -3
  94. package/skills/delphi-review/SKILL.md +59 -4
  95. package/skills/delphi-review/references/requirements.md +390 -0
  96. package/skills/delphi-review/references/round-templates.md +67 -0
  97. package/skills/domain-modeling/ADR-FORMAT.md +64 -0
  98. package/skills/domain-modeling/CONTEXT-FORMAT.md +60 -0
  99. package/skills/domain-modeling/SKILL.md +74 -0
  100. package/skills/grill-with-docs/SKILL.md +7 -0
  101. package/skills/grilling/SKILL.md +12 -0
  102. package/skills/sprint-flow/AGENTS.md +3 -3
  103. package/skills/sprint-flow/SKILL.md +168 -43
  104. package/skills/sprint-flow/references/components/memory.md +1 -1
  105. package/skills/sprint-flow/references/components/middleware.md +1 -1
  106. package/skills/sprint-flow/references/components/skill-invocations.md +21 -20
  107. package/skills/sprint-flow/references/components/tool-descriptions.md +22 -23
  108. package/skills/sprint-flow/references/orchestration-rules.md +14 -12
  109. package/skills/sprint-flow/references/phase-2-design.md +145 -133
  110. package/skills/sprint-flow/references/phase-3-build.md +69 -2
  111. package/skills/sprint-flow/references/phase-4-verify.md +93 -31
  112. package/skills/sprint-flow/references/phase-5-ship.md +99 -14
  113. package/skills/sprint-flow/references/phase-6-close.md +37 -5
  114. package/skills/sprint-flow/references/phase-overview.md +58 -53
  115. package/skills/test-specification-alignment/AGENTS.md +3 -3
  116. package/skills/test-specification-alignment/SKILL.md +8 -3
  117. package/skills/to-issues/SKILL.md +1 -1
@@ -1,15 +1,15 @@
1
- # Phase 4/6: VERIFY(验证 — 代码走查 + QA + 反馈获取)
1
+ # Phase 4/6: VERIFY(验证 — 代码走查 + 测试对齐 + 反馈获取)
2
2
 
3
3
  **执行时机**: Phase 3/6 BUILD 完成后、Phase 5/6 SHIP 之前。
4
4
  **对应旧模型**: Phase 3 REVIEW + Phase 4 FEEDBACK
5
5
 
6
6
  ## 目标
7
7
 
8
- 多专家代码走查、测试对齐、浏览器测试、反馈捕获。确保 MVP 符合 specification 并记录经验教训。
8
+ 多专家代码走查、测试对齐(#367 程序化 HARD-GATE)、浏览器验证(Layer 4 可选链)、反馈捕获。确保 MVP 符合 specification 并记录经验教训。
9
9
 
10
10
  **执行者**: orchestrator 直接执行 Part A(非 subagent dispatch — Issue #249)。
11
11
 
12
- Web 前端项目额外增加:系统化 QA、视觉审计、性能基线。
12
+ Web 前端项目额外增加:原生 UI 审查 + 可选增强。
13
13
 
14
14
  ---
15
15
 
@@ -17,20 +17,27 @@ Web 前端项目额外增加:系统化 QA、视觉审计、性能基线。
17
17
 
18
18
  ### 调用 Skills
19
19
 
20
- **所有项目**:
20
+ **所有项目(原生 HARD-GATE 链)**:
21
21
  - `delphi-review --mode code-walkthrough` — 多专家匿名代码走查(2-3 domestic models, ≥90% consensus)
22
- - `test-specification-alignment` — 测试与 Spec 对齐验证
23
- - `browse` (gstack) — 浏览器自动化测试
22
+ - `test-specification-alignment` — 测试与 Spec 对齐验证(#367 程序化 HARD-GATE)
23
+ - `xp-gate check --all` — 全量质量门禁(Gate 0–9,含安全审计)
24
+
25
+ **浏览器验证 — Layer 4 可选链**:
26
+ ```
27
+ OPTIONAL: 若检测到 gstack browse 已安装 → 使用 gstack browse 进行浏览器自动化测试
28
+ ELSE IF 平台支持 browser-use MCP → 使用 browser-use MCP
29
+ ELSE → SKIP 并记录 "[sprint-flow] 浏览器验证 SKIP(无可用浏览器工具)"
30
+ ```
24
31
 
25
32
  **Web 前端项目额外注入** (`--type web-nextjs` / `web-react` / `web-vue`):
26
- - `qa` (gstack) — 三层 QA(Quick/Standard/Exhaustive)系统化测试
27
- - `design-review` (gstack) — 线上 UI 视觉审计(间距、层级、AI slop 检测)
28
- - `benchmark` (gstack) — Core Web Vitals 性能基线
33
+ - `xp-gate ui-review`(原生)— UI 视觉审查(间距、层级、一致性)
34
+ - OPTIONAL: 若检测到 gstack `qa` 已安装 → 三层 QA 系统化测试;未安装则 SKIP
35
+ - OPTIONAL: 若检测到 gstack `design-review` 已安装 → 视觉审计增强;未安装则 SKIP
36
+ - OPTIONAL: 若检测到 gstack `benchmark` 已安装 → Core Web Vitals 基线;未安装则 SKIP
29
37
 
30
38
  **Mobile 项目额外注入** (`--type mobile-flutter` / `mobile-react-native`):
31
39
  - `flutter-test` — Flutter 单元测试 + widget 测试 (Flutter only)
32
40
  - Detox E2E — React Native 端到端测试 (RN only)
33
- - `flutter-review` (user) — Flutter 代码审查 (Flutter only)
34
41
 
35
42
  **Backend 项目额外注入** (`--type backend-go` / `backend-springboot` / `backend-django`):
36
43
  - API Testing — 后端 API 自动化测试
@@ -51,7 +58,7 @@ skill(name="delphi-review", user_message="--mode code-walkthrough")
51
58
 
52
59
  **如果 REQUEST_CHANGES**: 暂停等待用户处理 → 修复后重新评审。**如果 APPROVED**: 写入 `.code-walkthrough-result.json`(1 小时有效期)→ 进入 Step 2。
53
60
 
54
- #### Step 2: 调用 test-specification-alignment
61
+ #### Step 2: 调用 test-specification-alignment(#367 程序化 HARD-GATE)
55
62
 
56
63
  ```
57
64
  skill(name="test-specification-alignment", user_message="--spec specification.yaml --tests mvp-v1/tests")
@@ -59,28 +66,61 @@ skill(name="test-specification-alignment", user_message="--spec specification.ya
59
66
 
60
67
  Phase 1: 验证对齐(可修改测试) → Phase 2: 执行测试(禁止修改测试)
61
68
 
69
+ **#367 修复 — 程序化 HARD-GATE**:
70
+
71
+ test-specification-alignment 执行后**必须**输出 `.sprint-state/phase-outputs/test-alignment-report.json`:
72
+
73
+ ```json
74
+ {
75
+ "alignment_status": "PASS | FAIL",
76
+ "head_commit": "<git rev-parse HEAD>",
77
+ "spec_hash": "<SHA-256 of specification.yaml>",
78
+ "req_test_mapping": {},
79
+ "ac_assertion_mapping": {},
80
+ "timestamp": "<ISO 8601>"
81
+ }
82
+ ```
83
+
84
+ **`phase-transition 4 completed` 程序化校验**:
85
+ - 文件缺失 → BLOCK
86
+ - `alignment_status` 非 PASS → BLOCK
87
+ - `head_commit` 与当前 HEAD 不符 → BLOCK(防陈旧绑定)
88
+ - `spec_hash` 与当前 specification.yaml 不符 → BLOCK(防陈旧绑定)
89
+
90
+ **--skip-evidence 逃生口护栏**:
91
+ - `--skip-evidence` 必须同时提供 `--reason "<text>"`
92
+ - 每次使用写入 audit.jsonl(`event: evidence_skipped, reason, phase`)
93
+ - `xp-gate retro` 报告设曝光区块
94
+ - 单 sprint 使用 >2 次 → 告警
95
+
62
96
  #### Step 2.5: 质量门禁全量验证
63
97
 
64
98
  ```
65
99
  npx xp-gate check --all
66
100
  ```
67
101
 
68
- 运行所有可用的质量门禁(Gate 0–9)并输出汇总报告。任何 BLOCK 状态 → 回退 Phase 3/6 修复。
102
+ 运行所有可用的质量门禁(Gate 0–9,含安全审计 Gate 7/8/9)并输出汇总报告。任何 BLOCK 状态 → 回退 Phase 3/6 修复。
69
103
 
70
- > 此步骤自动调用各独立门禁(lint、复杂度、principles、架构、安全扫描等),无需手动逐个执行。
104
+ > 此步骤自动调用各独立门禁(lint、复杂度、principles、架构、安全扫描等),无需手动逐个执行。替代原 `cso` 外部 skill 调用。
71
105
 
72
106
  #### Step 2.5-2.10: 项目类型特定验证(Web/Mobile/Backend)
73
107
 
74
- - **Web**: qa → design-review → benchmark
108
+ - **Web**: `xp-gate ui-review`(原生)→ OPTIONAL gstack qa/design-review/benchmark(如已安装)
75
109
  - **Mobile**: flutter-test / detox E2E
76
110
  - **Backend**: API automation tests
77
111
 
78
- #### Step 3: 调用 browse skill
112
+ #### Step 3: 浏览器验证(Layer 4 可选链)
79
113
 
80
114
  ```
81
- skill(name="browse", user_message="--url [URL] --test-ui")
115
+ OPTIONAL: 若检测到 gstack browse 已安装:
116
+ skill(name="browse", user_message="--url [URL] --test-ui")
117
+ ELSE IF 平台支持 browser-use MCP:
118
+ 使用 browser-use MCP 进行浏览器验证
119
+ ELSE:
120
+ SKIP 并记录 "[sprint-flow] 浏览器验证 SKIP(无可用浏览器工具)"
82
121
  ```
83
- 默认: `localhost:3000`。发现问题 → 回退 Phase 3/6 修复。
122
+
123
+ 默认 URL: `localhost:3000`。发现问题 → 回退 Phase 3/6 修复。
84
124
 
85
125
  #### Step 4: 保存 Review Report
86
126
 
@@ -92,13 +132,14 @@ skill(name="browse", user_message="--url [URL] --test-ui")
92
132
  |--------|---------|---------|
93
133
  | delphi code-walkthrough REQUEST_CHANGES | Critical Issues 未修复 | 用户修复 → 重新评审 |
94
134
  | test-alignment 失败 | 自动回退 Phase 3/6(不暂停) | 自动迭代 |
95
- | browse 发现问题 | 自动回退 Phase 3/6(不暂停) | 自动迭代 |
135
+ | 浏览器验证发现问题 | 自动回退 Phase 3/6(不暂停) | 自动迭代 |
96
136
 
97
137
  ### 输出
98
138
 
99
139
  - `.code-walkthrough-result.json`(pre-push hook 验证)
140
+ - `.sprint-state/phase-outputs/test-alignment-report.json`(#367 程序化 HARD-GATE 证据)
100
141
  - Review Report (`review-report.md`)
101
- - Web 前端附加: QA report + design-review report + benchmark baseline
142
+ - Web 前端附加: ui-review report + OPTIONAL QA/design-review/benchmark reports
102
143
  - 验证通过的 MVP
103
144
 
104
145
  ---
@@ -107,28 +148,49 @@ skill(name="browse", user_message="--url [URL] --test-ui")
107
148
 
108
149
  ### 调用 Skills
109
150
 
110
- - `learn` (gstack) — 模式记录(个人级)
111
- - `retro` (gstack) — 周工程回顾:提交历史、工作模式、代码质量趋势(团队级)
112
- - `systematic-debugging` (superpowers) _(可选)_ — 根因调试:反馈中的 bug 做根因分析
151
+ **原生**:
152
+ - `learnings.md` 写入 — 模式记录(替代原 gstack `learn`)
153
+ - `xp-gate retro` — 工程回顾:提交历史、工作模式、代码质量趋势、返工率区块
154
+
155
+ **可选(Layer 4)**:
156
+ - OPTIONAL: 若检测到 `systematic-debugging` skill 已安装 → 根因调试(保留"无根因不修复"纪律);未安装则使用"根因分析后方可修复"文本纪律
113
157
 
114
158
  ### 执行步骤
115
159
 
116
- #### Step 1: 调用 learn skill
117
- ```
118
- skill(name="learn", user_message="[Emergent Issues 内容 + Sprint 总结]")
160
+ #### Step 1: Learnings 写入(原生)
161
+
162
+ 将 Sprint 中发现的模式/教训写入 `.sprint-history/learnings.md`:
163
+
164
+ ```markdown
165
+ ## [YYYY-MM-DD] Sprint <id> — VERIFY Learnings
166
+
167
+ ### Pattern: <title>
168
+ - **Context**: <when this applies>
169
+ - **Insight**: <what was learned>
170
+ - **Action**: <how to apply in future>
119
171
  ```
120
172
 
121
- #### Step 2: 工程回顾 — 调用 retro
173
+ #### Step 2: 工程回顾 — xp-gate retro(原生)
174
+
122
175
  ```
123
- skill(name="retro")
176
+ npx xp-gate retro
124
177
  ```
125
- - 提交历史分析、代码质量趋势、团队贡献分解、改进建议
126
178
 
127
- #### Step 3: 根因调试(可选)
179
+ - 提交历史分析、代码质量趋势、改进建议
180
+ - 含 #369 返工率趋势区块
181
+ - 含 --skip-evidence 使用曝光区块
182
+
183
+ #### Step 3: 根因调试(可选 — Layer 4)
184
+
128
185
  **IF Phase 6/6 CLOSE 发现 bug 或 Part A 验证失败**:
186
+
129
187
  ```
130
- skill(name="systematic-debugging", user_message="[具体 bug 描述]")
188
+ OPTIONAL: 若检测到 systematic-debugging skill 已安装:
189
+ skill(name="systematic-debugging", user_message="[具体 bug 描述]")
190
+ ELSE:
191
+ 遵循"无根因不修复"文本纪律 — 先分析根因,确认后再修复
131
192
  ```
193
+
132
194
  Iron Law: 无调查 → 不修复
133
195
 
134
196
  #### Step 4: 转化 Emergent Issues 为 Sprint 2 Pain Document
@@ -158,6 +220,6 @@ Iron Law: 无调查 → 不修复
158
220
  ### 输出
159
221
 
160
222
  - Feedback Log (`feedback-log.md`)
161
- - Retro Report(retro 输出)
223
+ - Retro Report(`xp-gate retro` 输出)
162
224
  - Sprint 2 Pain Document (`sprint2-pain.md`) — 如果有 emergent issues
163
225
  - 进入 Phase 5/6 SHIP 自动执行
@@ -3,17 +3,15 @@
3
3
  **执行时机**: Phase 4/6 VERIFY 完成后、Phase 6/6 CLOSE 之前。
4
4
  **对应旧模型**: Phase 5 SHIP + Phase 6 LAND
5
5
 
6
- **摘要**: 结构化分支完成决策, 创建 PR, 合并部署, 监控. 生成 Sprint Summary.
6
+ **摘要**: 结构化分支完成决策(原生 4 选项), 创建 PR(原生步骤), 合并部署(原生步骤), 监控. 生成 Sprint Summary.
7
7
 
8
8
  ---
9
9
 
10
10
  ## Part A: SHIP(发布准备)
11
11
 
12
- **完整指令**: @see SKILL.md Phase 5/6 SHIP section.
12
+ **Orchestrator 直接执行**: 分支完成决策和 PR 创建均为交互式步骤(4 选项菜单 + PR 确认),**必须由 orchestrator 直接执行**。
13
13
 
14
- **Orchestrator 直接执行**: `finishing-a-development-branch` 和 `ship` 均为交互式 skill(4 选项菜单 + PR 确认),**必须由 orchestrator 直接调用**。
15
-
16
- **关键链**: VERSION-GATE(MANDATORY) → finishing-a-development-branch(4选项) → push PR
14
+ **关键链**: VERSION-GATE(MANDATORY) → 分支完成决策(4选项) → push PR
17
15
 
18
16
  **HARD-GATE**: Phase 4/6 VERIFY 未完成 → BLOCK。验证 `feedback-log.md` 存在。
19
17
 
@@ -29,9 +27,9 @@
29
27
  "https://api.github.com/repos/OWNER/REPO/commits/HEAD/status"
30
28
  ```
31
29
 
32
- ### Step 0: VERSION-GATE(MANDATORY — 在 finishing-a-development-branch 之前执行)
30
+ ### Step 0: VERSION-GATE(MANDATORY — 在分支完成决策之前执行)
33
31
 
34
- **Purpose**: Ensure version bump, changelog update, and sync before creating PR. This MUST run BEFORE calling `finishing-a-development-branch` — the skill's "Create PR" option creates the PR immediately, so version changes must be committed first.
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.
35
33
 
36
34
  **Execution**:
37
35
 
@@ -65,7 +63,7 @@
65
63
  gh pr view <PR_NUMBER> --json state # 确认 CI 已开始
66
64
  ```
67
65
 
68
- **GATE CHECK** (BEFORE proceeding to finishing-a-development-branch):
66
+ **GATE CHECK** (BEFORE proceeding to branch completion decision):
69
67
  ```
70
68
  [VERSION-GATE] VERSION bump ✓ # VERSION 文件已更新
71
69
  [VERSION-GATE] CHANGELOG ✓ # 新版本条目已添加
@@ -74,23 +72,110 @@
74
72
  [VERSION-GATE] PR updated ✓ # PR 已包含版本变更 commit
75
73
  ```
76
74
 
77
- **⚠️ ANTI-PATTERN**: 先调用 finishing-a-development-branch 创建 PR,再 bump VERSION 会导致 PR 不含版本变更 → CI 不触发 release workflow → 无新版本发布。
75
+ **⚠️ ANTI-PATTERN**: 先创建 PR 再 bump VERSION 会导致 PR 不含版本变更 → CI 不触发 release workflow → 无新版本发布。
78
76
 
79
77
  **输出**: 版本变更 commit 包含在 PR 中
80
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
+
81
122
  ---
82
123
 
83
- ## Part B: LAND(合并 + 部署)
124
+ ## Part B: LAND(合并 + 部署 — 原生步骤)
84
125
 
85
- **Orchestrator 直接执行**: `land-and-deploy` 包含 merge 确认和 rollback 决策,**必须由 orchestrator 直接调用** `skill(name="land-and-deploy")`
126
+ **Orchestrator 直接执行**: 合并确认和 rollback 决策均为用户交互点,**必须由 orchestrator 直接执行**。
86
127
 
87
128
  **输入**: PR URL → 输出: 部署状态 + Canary 报告
88
129
 
89
- **流程**: Merge PR → 等待 CI (10min) → 等待 Deploy (10min) → Canary Health Check (5min)
130
+ ### Step 1: Merge 确认
90
131
 
91
- **回滚**: `git revert` 最后一次 merge commit
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
92
142
 
93
- **条件跳过**: 无部署配置时仅 merge + CI
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
+ ```
94
179
 
95
180
  **输出**: 部署状态 (success/failure/skipped), Canary 报告
96
181
 
@@ -204,9 +204,40 @@ git add .sprint-history/<sprint-id>/ && git commit -m "archive: sprint <sprint-i
204
204
 
205
205
  ---
206
206
 
207
- ## Part B: CLEANUP(清理 + 总结)
207
+ ## Part B: CLEANUP(清理 + 总结 + 返工追踪)
208
208
 
209
- **摘要**: 自动清理 worktree, 更新 sprint-state.json, 输出 Sprint Summary, 处理 emergent issues.
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 修订:零依赖原则下无可靠数据源)。
210
241
 
211
242
  ### 执行步骤
212
243
 
@@ -217,10 +248,11 @@ git add .sprint-history/<sprint-id>/ && git commit -m "archive: sprint <sprint-i
217
248
  3. **删除本地分支**: `git branch -D sprint/YYYY-MM-DD-NN`
218
249
  4. **删除远程分支**: `git push origin --delete sprint/YYYY-MM-DD-NN`
219
250
  5. **关闭遗留 OPEN PR**: `gh pr list --head sprint/YYYY-MM-DD-NN --state open`
220
- 6. **更新 sprint-state.json**: 设置 `phase: 6`, `status: "completed"`
251
+ 6. **更新 sprint-state.json**: 设置 `phase: 6`, `status: "completed"`, 写入 `metrics.completed_at` + `metrics.total_sprint_commits`(#369)
221
252
  7. **释放 Sprint Lock** (Issue #144): 删除 `.sprint-state/sprint.lock`
222
- 8. **Sprint Summary**: 使用 `templates/sprint-summary-template.md` 生成总结
223
- 9. **处理 Emergent Issues**: 如 Part A 发现 emergent issues → 触发 Sprint 2 逻辑
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 逻辑
224
256
 
225
257
  ### 输出
226
258