@boyingliu01/xp-gate 0.15.5 → 0.18.1

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 (165) hide show
  1. package/adapter-common.sh +0 -0
  2. package/adapters/cpp.sh +0 -0
  3. package/adapters/dart.sh +0 -0
  4. package/adapters/flutter.sh +0 -0
  5. package/adapters/go.sh +0 -0
  6. package/adapters/iac.sh +0 -0
  7. package/adapters/java.sh +0 -0
  8. package/adapters/kotlin.sh +0 -0
  9. package/adapters/objectivec.sh +0 -0
  10. package/adapters/plugins/book299-20132-python/scripts/install-gradle.sh +0 -0
  11. package/adapters/plugins/book299-20132-python/scripts/install-maven.sh +0 -0
  12. package/adapters/plugins/book299-4081-c/scripts/install-gradle.sh +0 -0
  13. package/adapters/plugins/book299-4081-c/scripts/install-maven.sh +0 -0
  14. package/adapters/plugins/book299-4083-javascriptes5/scripts/install-gradle.sh +0 -0
  15. package/adapters/plugins/book299-4083-javascriptes5/scripts/install-maven.sh +0 -0
  16. package/adapters/powershell.sh +0 -0
  17. package/adapters/python.sh +0 -0
  18. package/adapters/shell.sh +0 -0
  19. package/adapters/swift.sh +0 -0
  20. package/adapters/typescript.sh +0 -0
  21. package/bin/xp-gate.js +29 -1
  22. package/gate-3.sh +0 -0
  23. package/gate-4.sh +0 -0
  24. package/gate-7.sh +0 -0
  25. package/gate-8.sh +0 -0
  26. package/gate-9.sh +0 -0
  27. package/hooks/adapter-common.sh +0 -0
  28. package/hooks/gate-3.sh +0 -0
  29. package/hooks/gate-4.sh +0 -0
  30. package/hooks/gate-7.sh +0 -0
  31. package/hooks/gate-8.sh +0 -0
  32. package/hooks/gate-9.sh +0 -0
  33. package/hooks/lib/now-ms.sh +33 -0
  34. package/hooks/pre-commit +63 -47
  35. package/hooks/pre-push +0 -0
  36. package/hooks/sprint-gate.sh +291 -0
  37. package/lib/__tests__/check-version.test.js +122 -0
  38. package/lib/__tests__/doctor.test.js +13 -15
  39. package/lib/__tests__/gate-audit.test.ts +38 -0
  40. package/lib/__tests__/phase-transition.test.js +512 -272
  41. package/lib/__tests__/retro.test.js +131 -0
  42. package/lib/__tests__/sprint-audit.test.js +207 -207
  43. package/lib/__tests__/sprint-status-rework.test.js +184 -0
  44. package/lib/check-version.js +9 -0
  45. package/lib/doctor-tui.js +268 -198
  46. package/lib/doctor.js +15 -3
  47. package/lib/gate-audit.ts +18 -7
  48. package/lib/gate-runner.js +77 -30
  49. package/lib/init.js +10 -0
  50. package/lib/language-tools.js +833 -833
  51. package/lib/mattpocock-license-verdict.json +7 -0
  52. package/lib/phase-transition.js +499 -249
  53. package/lib/retro.js +222 -0
  54. package/lib/shared-utils.js +7 -0
  55. package/lib/sprint-audit.js +235 -235
  56. package/lib/sprint-init.js +207 -0
  57. package/lib/sprint-state-migrator.js +1 -0
  58. package/lib/sprint-status.js +111 -0
  59. package/mock-policy/AGENTS.md +3 -3
  60. package/mutation/AGENTS.md +3 -3
  61. package/package.json +3 -2
  62. package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
  63. package/plugins/claude-code/bin/delphi-review-guard.sh +0 -0
  64. package/plugins/claude-code/bin/xp-gate-check +0 -0
  65. package/plugins/claude-code/skills/batch-grill-me/SKILL.md +15 -0
  66. package/plugins/claude-code/skills/delphi-review/AGENTS.md +3 -3
  67. package/plugins/claude-code/skills/delphi-review/SKILL.md +59 -4
  68. package/plugins/claude-code/skills/delphi-review/references/requirements.md +390 -0
  69. package/plugins/claude-code/skills/delphi-review/references/round-templates.md +67 -0
  70. package/plugins/claude-code/skills/domain-modeling/ADR-FORMAT.md +64 -0
  71. package/plugins/claude-code/skills/domain-modeling/CONTEXT-FORMAT.md +60 -0
  72. package/plugins/claude-code/skills/domain-modeling/SKILL.md +74 -0
  73. package/plugins/claude-code/skills/grill-with-docs/SKILL.md +7 -0
  74. package/plugins/claude-code/skills/grilling/SKILL.md +12 -0
  75. package/plugins/claude-code/skills/sprint-flow/AGENTS.md +3 -3
  76. package/plugins/claude-code/skills/sprint-flow/SKILL.md +168 -43
  77. package/plugins/claude-code/skills/sprint-flow/references/components/memory.md +1 -1
  78. package/plugins/claude-code/skills/sprint-flow/references/components/middleware.md +1 -1
  79. package/plugins/claude-code/skills/sprint-flow/references/components/skill-invocations.md +21 -20
  80. package/plugins/claude-code/skills/sprint-flow/references/components/tool-descriptions.md +22 -23
  81. package/plugins/claude-code/skills/sprint-flow/references/orchestration-rules.md +14 -12
  82. package/plugins/claude-code/skills/sprint-flow/references/phase-2-design.md +145 -133
  83. package/plugins/claude-code/skills/sprint-flow/references/phase-3-build.md +69 -2
  84. package/plugins/claude-code/skills/sprint-flow/references/phase-4-verify.md +93 -31
  85. package/plugins/claude-code/skills/sprint-flow/references/phase-5-ship.md +99 -14
  86. package/plugins/claude-code/skills/sprint-flow/references/phase-6-close.md +37 -5
  87. package/plugins/claude-code/skills/sprint-flow/references/phase-overview.md +58 -53
  88. package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +3 -3
  89. package/plugins/claude-code/skills/test-specification-alignment/SKILL.md +8 -3
  90. package/plugins/claude-code/skills/to-issues/SKILL.md +1 -1
  91. package/plugins/opencode/index.ts +1 -0
  92. package/plugins/opencode/package.json +1 -1
  93. package/plugins/opencode/skills/batch-grill-me/SKILL.md +15 -0
  94. package/plugins/opencode/skills/delphi-review/AGENTS.md +3 -3
  95. package/plugins/opencode/skills/delphi-review/SKILL.md +59 -4
  96. package/plugins/opencode/skills/delphi-review/references/requirements.md +390 -0
  97. package/plugins/opencode/skills/delphi-review/references/round-templates.md +67 -0
  98. package/plugins/opencode/skills/domain-modeling/ADR-FORMAT.md +64 -0
  99. package/plugins/opencode/skills/domain-modeling/CONTEXT-FORMAT.md +60 -0
  100. package/plugins/opencode/skills/domain-modeling/SKILL.md +74 -0
  101. package/plugins/opencode/skills/grill-with-docs/SKILL.md +7 -0
  102. package/plugins/opencode/skills/grilling/SKILL.md +12 -0
  103. package/plugins/opencode/skills/sprint-flow/AGENTS.md +3 -3
  104. package/plugins/opencode/skills/sprint-flow/SKILL.md +168 -43
  105. package/plugins/opencode/skills/sprint-flow/references/components/memory.md +1 -1
  106. package/plugins/opencode/skills/sprint-flow/references/components/middleware.md +1 -1
  107. package/plugins/opencode/skills/sprint-flow/references/components/skill-invocations.md +21 -20
  108. package/plugins/opencode/skills/sprint-flow/references/components/tool-descriptions.md +22 -23
  109. package/plugins/opencode/skills/sprint-flow/references/orchestration-rules.md +14 -12
  110. package/plugins/opencode/skills/sprint-flow/references/phase-2-design.md +145 -133
  111. package/plugins/opencode/skills/sprint-flow/references/phase-3-build.md +69 -2
  112. package/plugins/opencode/skills/sprint-flow/references/phase-4-verify.md +93 -31
  113. package/plugins/opencode/skills/sprint-flow/references/phase-5-ship.md +99 -14
  114. package/plugins/opencode/skills/sprint-flow/references/phase-6-close.md +37 -5
  115. package/plugins/opencode/skills/sprint-flow/references/phase-overview.md +58 -53
  116. package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +3 -3
  117. package/plugins/opencode/skills/test-specification-alignment/SKILL.md +8 -3
  118. package/plugins/opencode/skills/to-issues/SKILL.md +1 -1
  119. package/plugins/qoder/agents/delphi-architecture.md +48 -48
  120. package/plugins/qoder/agents/delphi-feasibility.md +48 -48
  121. package/plugins/qoder/agents/delphi-technical.md +48 -48
  122. package/plugins/qoder/bin/sprint-flow-guard.sh +0 -0
  123. package/plugins/qoder/bin/xp-gate-check +0 -0
  124. package/plugins/qoder/plugin.json +1 -1
  125. package/plugins/qoder/skills/delphi-review/AGENTS.md +3 -3
  126. package/plugins/qoder/skills/sprint-flow/AGENTS.md +3 -3
  127. package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +3 -3
  128. package/principles/AGENTS.md +3 -3
  129. package/scripts/__tests__/check-mattpocock-license.test.js +229 -0
  130. package/scripts/__tests__/sync-package-content.test.js +50 -0
  131. package/scripts/check-mattpocock-license.cjs +302 -0
  132. package/scripts/delphi-external-review.cjs +432 -432
  133. package/scripts/migrate-audit-anomalies.mjs +78 -0
  134. package/scripts/sync-package-content.js +52 -5
  135. package/skills/batch-grill-me/SKILL.md +15 -0
  136. package/skills/delphi-review/AGENTS.md +3 -3
  137. package/skills/delphi-review/SKILL.md +59 -4
  138. package/skills/delphi-review/references/requirements.md +390 -0
  139. package/skills/delphi-review/references/round-templates.md +67 -0
  140. package/skills/domain-modeling/ADR-FORMAT.md +64 -0
  141. package/skills/domain-modeling/CONTEXT-FORMAT.md +60 -0
  142. package/skills/domain-modeling/SKILL.md +74 -0
  143. package/skills/grill-with-docs/SKILL.md +7 -0
  144. package/skills/grilling/SKILL.md +12 -0
  145. package/skills/sprint-flow/AGENTS.md +3 -3
  146. package/skills/sprint-flow/SKILL.md +168 -43
  147. package/skills/sprint-flow/references/components/memory.md +1 -1
  148. package/skills/sprint-flow/references/components/middleware.md +1 -1
  149. package/skills/sprint-flow/references/components/skill-invocations.md +21 -20
  150. package/skills/sprint-flow/references/components/tool-descriptions.md +22 -23
  151. package/skills/sprint-flow/references/orchestration-rules.md +14 -12
  152. package/skills/sprint-flow/references/phase-2-design.md +145 -133
  153. package/skills/sprint-flow/references/phase-3-build.md +69 -2
  154. package/skills/sprint-flow/references/phase-4-verify.md +93 -31
  155. package/skills/sprint-flow/references/phase-5-ship.md +99 -14
  156. package/skills/sprint-flow/references/phase-6-close.md +37 -5
  157. package/skills/sprint-flow/references/phase-overview.md +58 -53
  158. package/skills/test-specification-alignment/AGENTS.md +3 -3
  159. package/skills/test-specification-alignment/SKILL.md +8 -3
  160. package/skills/to-issues/SKILL.md +1 -1
  161. package/adapters/gate-3.sh +0 -68
  162. package/adapters/gate-4.sh +0 -80
  163. package/adapters/gate-7.sh +0 -45
  164. package/adapters/gate-8.sh +0 -56
  165. package/adapters/gate-9.sh +0 -104
@@ -10,7 +10,7 @@
10
10
  | 原则 | 说明 |
11
11
  |------|------|
12
12
  | **单一入口** | 用户只需调用 `/sprint-flow`,自动串联全流程 |
13
- | **自动流水线** | 类似 autoplan,自动执行多个阶段 |
13
+ | **自动流水线** | 自动执行多个阶段,原生步骤 + 内置 Matt Pocock skill |
14
14
  | **关键节点暂停** | APPROVED 确认、DELPHI-GATE 通过、Ship 确认、⚠️ Phase 6 CLOSE 必须人工 |
15
15
  | **承认 Emergent** | 用户验收环节必须人工,无法自动化(78% 失败不可见) |
16
16
  | **复用现有 Skills** | 不重新发明,整合调用现有体系 |
@@ -52,11 +52,11 @@ Sprint Flow is NOT just a sequential launcher of existing skills. Here's what ma
52
52
 
53
53
  ```
54
54
  Phase 1/6: PREP → worktree隔离 + 规模评估 + 流程路由
55
- Phase 2/6: DESIGN → brainstorming → autoplan → delphi-review → specification.yaml
56
- Phase 3/6: BUILD → GITHOOKS-GATE → DELPHI-GATE → ralph-loop/TDD → freeze/盲评 → verification
57
- Phase 4/6: VERIFY → delphi-review --mode code-walkthrough → test-alignment → browse → learn + retro
58
- Phase 5/6: SHIP → finishing-a-development-branch → ship → land-and-deploy → canary
59
- Phase 6/6: CLOSE → USER ACCEPTANCE (⚠️ 人工) → emergent issues → cleanup
55
+ Phase 2/6: DESIGN → grill-with-docs → R1 需求评审 → 设计文档+APPROVAL → batch-grill-me → R2 delphi-review → to-issues → specification.yaml
56
+ Phase 3/6: BUILD → BUILD-ENTRY-CONTRACT → GITHOOKS-GATE → DELPHI-GATE → ralph-loop/TDD → blind-review (read-only subagent) → verification
57
+ Phase 4/6: VERIFY → delphi-review --mode code-walkthrough → test-alignment (#367 HARD-GATE) → xp-gate check --all → browser (Layer 4) → learnings + retro
58
+ Phase 5/6: SHIP → VERSION-GATE → 分支完成决策(4选项) → native ship (PR) → native land (merge+CI+canary)
59
+ Phase 6/6: CLOSE → USER ACCEPTANCE (⚠️ 人工) → #369 返工指标 → emergent issues → cleanup
60
60
  ```
61
61
 
62
62
  **v2.0 Compact Redesign** (Issue #290): Merged from 11 phases to 6. PREP = old ISOLATE + AUTO-ESTIMATE. DESIGN = old THINK + PLAN. BUILD = old BUILD (unchanged). VERIFY = old REVIEW + FEEDBACK. SHIP = old SHIP + LAND. CLOSE = old USER ACCEPTANCE + CLEANUP.
@@ -66,11 +66,11 @@ Phase 6/6: CLOSE → USER ACCEPTANCE (⚠️ 人工) → emergent issues → cle
66
66
  ## 暂停点设计(不是随时停,而是设计明确的暂停点)
67
67
 
68
68
  - **Phase 1/6 PREP**: 保护分支强制隔离 → 输出警告或自动创建 worktree → 自动恢复;AUTO-ESTIMATE 结果展示 → 用户确认 → 按路由继续
69
- - **Phase 2/6 DESIGN**: brainstorming 设计未 APPROVED (HARD-GATE) → 用户修改 → APPROVED 后继续;autoplan taste_decisions → 用户确认;delphi-review 未 APPROVED → 修复 → APPROVED → specification.yaml
70
- - **Phase 3/6 BUILD**: DELPHI-GATE 未通过 → BLOCK;验证失败 > max3 → 用户决策修复/放弃;成本超阈值 → 用户确认
71
- - **Phase 4/6 VERIFY**: delphi code-walkthrough REQUEST_CHANGES → 用户处理 → 重新评审;browse 发现问题 → 回退 Phase 3(不暂停)
72
- - **Phase 5/6 SHIP**: finishing-a-development-branch (4选项) → 确认;ship PR → 用户确认合并;land-and-deploy 完成/失败 → 用户确认;⚠️ SHIP must complete merge to main + release before Phase 6
73
- - **Phase 6/6 CLOSE**: SHIP→CLOSE GATE (校验 merge 已完成 + git status clean + 当前在 main) → Backup sprint-state → USER ACCEPTANCE ⚠️ 必须人工验收 → 用户确认后继续;cleanup 完成/失败 → 用户确认 → 结束流程
69
+ - **Phase 2/6 DESIGN**: grill-with-docs 访谈 → R1 需求评审 GAPS_FOUND → 补充访谈(最多 2 轮);设计文档未 APPROVED (HARD-GATE) → 用户修改 → APPROVED 后继续;batch-grill-me 批量决策 → 用户确认;R2 delphi-review 未 APPROVED → 修复 → APPROVED → specification.yaml
70
+ - **Phase 3/6 BUILD**: BUILD-ENTRY-CONTRACT 未通过 → BLOCK;DELPHI-GATE 未通过 → BLOCK;验证失败 > max3 → 用户决策修复/放弃;成本超阈值 → 用户确认
71
+ - **Phase 4/6 VERIFY**: delphi code-walkthrough REQUEST_CHANGES → 用户处理 → 重新评审;test-alignment 失败 (#367) → 回退 Phase 3(不暂停);浏览器验证发现问题 → 回退 Phase 3(不暂停)
72
+ - **Phase 5/6 SHIP**: 分支完成决策 (4选项) → 确认;native ship PR → 用户确认合并;native land 完成/失败 → 用户确认;⚠️ SHIP must complete merge to main + release before Phase 6
73
+ - **Phase 6/6 CLOSE**: SHIP→CLOSE GATE (校验 merge 已完成 + git status clean + 当前在 main) → Backup sprint-state → #369 返工指标写入 → USER ACCEPTANCE ⚠️ 必须人工验收 → 用户确认后继续;cleanup 完成/失败 → 用户确认 → 结束流程
74
74
 
75
75
  ---
76
76
 
@@ -79,11 +79,11 @@ Phase 6/6: CLOSE → USER ACCEPTANCE (⚠️ 人工) → emergent issues → cle
79
79
  | Step | Phase | Name | Key Actions | Output |
80
80
  |------|-------|------|-------------|--------|
81
81
  | 1 | **1/6** | **PREP** | Detect protected branch → Create git worktree → AUTO-ESTIMATE sizing → Classify (lightweight/standard/complex) | Worktree path + impact assessment |
82
- | 2 | **2/6** | **DESIGN** | brainstorming → autoplan → delphi-review (HARD-GATE ≥90% consensus) → to-issues → specification.yaml | specification.yaml + slices-manifest.json |
83
- | 3 | **3/6** | **BUILD** | GITHOOKS-GATE → DELPHI-GATE → ralph-loop (default) or parallel → TDD → freeze → blind review → verification | MVP code |
84
- | 4 | **4/6** | **VERIFY** | delphi-review --mode code-walkthrough → test-specification-alignment → browse QA → benchmark (optional) → learn + retro | Review report + feedback-log.md |
85
- | 5 | **5/6** | **SHIP** | VERSION-GATE → finishing-a-development-branch → ship (create PR) → land-and-deploy → merge to main + CI + canary → release | PR URL + deploy status + merge confirmation |
86
- | 6 | **6/6** | **CLOSE** | SHIP→CLOSE GATE (merge + release verified) → Backup sprint-state → USER ACCEPTANCE (⚠️ mandatory manual) → Capture emergent issues → Cleanup worktree + branch → Sprint summary | Emergent issues list + cleanup report |
82
+ | 2 | **2/6** | **DESIGN** | grill-with-docs → R1 需求评审 → 设计文档+APPROVAL (HARD-GATE) → batch-grill-me → R2 delphi-review (≥90% consensus) → to-issues → specification.yaml | specification.yaml + slices-manifest.json + requirements-reviewed.json |
83
+ | 3 | **3/6** | **BUILD** | BUILD-ENTRY-CONTRACT → GITHOOKS-GATE → DELPHI-GATE → ralph-loop (default) or parallel → TDD → blind-review (read-only subagent) → verification | MVP code |
84
+ | 4 | **4/6** | **VERIFY** | delphi-review --mode code-walkthrough → test-specification-alignment (#367 HARD-GATE) → xp-gate check --all → browser (Layer 4 optional) → learnings + xp-gate retro | Review report + feedback-log.md + test-alignment-report.json |
85
+ | 5 | **5/6** | **SHIP** | VERSION-GATE → 分支完成决策 (4选项) → native ship (create PR) → native land (merge + CI + canary) → release | PR URL + deploy status + merge confirmation |
86
+ | 6 | **6/6** | **CLOSE** | SHIP→CLOSE GATE (merge + release verified) → Backup sprint-state → #369 返工指标 → USER ACCEPTANCE (⚠️ mandatory manual) → Capture emergent issues → Cleanup worktree + branch → Sprint summary | Emergent issues list + cleanup report + metrics |
87
87
 
88
88
  **Phase Flow**:
89
89
  ```
@@ -94,8 +94,8 @@ PREP → DESIGN → BUILD → VERIFY → SHIP (merge to main + release) → CLOS
94
94
  ```
95
95
 
96
96
  **Hard Gates**:
97
- - **Phase 2/6 → 3/6 (DESIGN → BUILD)**: Design must be APPROVED by delphi-review (≥90% consensus) + GITHOOKS-GATE (hooks installed) + DELPHI-GATE (spec APPROVED)
98
- - **Phase 4/6 → 5/6 (VERIFY → SHIP)**: feedback-log.md must exist (HARD-GATE)
97
+ - **Phase 2/6 → 3/6 (DESIGN → BUILD)**: R1 需求评审 APPROVED + 设计文档用户 APPROVED + R2 delphi-review APPROVED (≥90% consensus) + GITHOOKS-GATE (hooks installed) + DELPHI-GATE (spec APPROVED) + BUILD-ENTRY-CONTRACT (manifest schema + slice↔REQ 一致性)
98
+ - **Phase 4/6 → 5/6 (VERIFY → SHIP)**: feedback-log.md must exist + test-alignment-report.json PASS (#367 程序化 HARD-GATE)
99
99
  - **Phase 5/6 → 6/6 (SHIP → CLOSE)**: PR must be merged to main + release completed (HARD-GATE). See `references/phase-6-close.md#ship--close-gate`.
100
100
 
101
101
  ---
@@ -144,7 +144,7 @@ Sprint Flow: PREP → DESIGN → BUILD → VERIFY → SHIP → CLOSE
144
144
  6. 输出评估结果 → 用户确认后按路由继续
145
145
  7. **参数**: `--no-isolate` (跳过), `--branch-name <name>`, `--force` (绕过保护分支)
146
146
 
147
- ### Phase 2/6: DESIGN (设计 — 需求探索 + 共识评审)
147
+ ### Phase 2/6: DESIGN (设计 — 需求探索 + 双点评审)
148
148
 
149
149
  **对应旧模型**: Phase 0 THINK + Phase 1 PLAN
150
150
 
@@ -153,14 +153,17 @@ Sprint Flow: PREP → DESIGN → BUILD → VERIFY → SHIP → CLOSE
153
153
  **详细指令**: 参见 `references/phase-2-design.md` — 完整流程、条件分支、HARD-GATE。
154
154
 
155
155
  **快速参考**:
156
- - **Step 0.5: DESIGN 路由分叉 (v0.14.0+)**: 根据 PREP 的 `change_type` 决定路径。`修改已存在代码` → SKIP autoplan, 直接 lightweight delphi-review (2 专家, 1 轮)。`新增功能` 或 undefined → 标准 autoplan 路径。详见 `references/phase-2-design.md#step-05-design-路由分叉`。
157
- - **Step 1: brainstorming** — `skill(name="brainstorming")` — 输出设计文档 + CONTEXT.md + ADR。**HARD-GATE**: 设计未批准 → 不可进入实现
158
- - **Step 2: autoplan** — `skill(name="autoplan")` — CEO/设计/工程自动评审 → 用户确认 taste_decisions(仅标准路径)
159
- - **Step 3: delphi-review** — `skill(name="delphi-review")` — 等待 APPROVED(非 APPROVED 暂停等待用户确认)
160
- - **Step 4: to-issues** — `skill(name="to-issues")` — 垂直切片 Issue 拆分 → slices-manifest.json
161
- - **Step 5: specification.yaml** — 从 APPROVED 设计文档自动提取
162
- - **Web 前端额外注入**: `design-shotgun`
163
- - **条件分支**: IF autoplan AUTO_APPROVED → lightweight delphi-review (2 专家、1 轮); ELSE → 标准 delphi-review (3 专家)
156
+ - **Step 0: CONTEXT.md 预检 (#322)**: 存在则 SKIP grill 访谈,但 R1 需求评审仍执行(CONTEXT.md 可能陈旧)
157
+ - **Step 1: grill-with-docs** — `skill(name="grill-with-docs")` — 逐个追问 + CONTEXT.md/ADR 沉淀。**HARD-GATE**: 设计未批准 → 不可进入实现
158
+ - **Step 2: R1 需求评审 (#368)** — `npx xp-gate delphi-review --mode requirements` — 轻量 2 专家 1 轮,输出 requirements-reviewed.json(含 requirements_hash 防陈旧绑定)。lightweight sprint 跳过 R1 合并入 R2
159
+ - **Step 3: 原生设计文档生成** — `docs/plans/YYYY-MM-DD-<topic>-design.md`(需求摘要、2-3 方案、推荐、成功标准)
160
+ - **Step 4: HARD-GATE APPROVAL** — 用户审批设计文档
161
+ - **Step 5: 路由分叉** — `change_type == "修改已存在代码"` → SKIP batch-grill-me, lightweight R2
162
+ - **Step 6: batch-grill-me** — `skill(name="batch-grill-me")` — 批量前置决策(替代 autoplan taste_decisions)
163
+ - **Step 7: R2 delphi-review** — `skill(name="delphi-review")` — 等待 APPROVED(≥90% 共识)
164
+ - **Step 8: to-issues** — `skill(name="to-issues")` — 垂直切片 Issue 拆分 → slices-manifest.json
165
+ - **Step 9: specification.yaml** — 从 APPROVED 设计文档自动提取(每 REQ 含验收标准 — #368)
166
+ - **Web 前端额外注入**: OPTIONAL design-shotgun(如已安装)
164
167
 
165
168
  ### Phase 2/6→3/6: GITHOOKS-GATE(质量门禁安装检查)
166
169
 
@@ -183,12 +186,13 @@ Sprint Flow: PREP → DESIGN → BUILD → VERIFY → SHIP → CLOSE
183
186
  **详细指令**: 参见 `references/phase-3-build.md`。
184
187
 
185
188
  **快速参考**:
186
- 1. **DELPHI-GATE**: 验证 `.sprint-state/delphi-reviewed.json` 存在且 `verdict = "APPROVED"` → 否则 BLOCK
187
- 2. **TDD-GATE (MANDATORY — v0.14.0+)**: 在 delegation 前验证每个 REQ 存在 failing test。无 test → mark `[TDD-RED]`(ralph-loop 创建)。有 test 且 GREEN 且无实现 → BLOCK(TDD bypass)。详见 `references/phase-3-build.md#tdd-gate-pre-implementation-tdd-check-mandatory`。
188
- 3. **输入**: `slices-manifest.json`(Phase 2/6 生成),按 `execution_order` 逐个执行
189
- 4. **模式**: 默认 `ralph-loop`(逐 REQ 迭代,token 节约 40-67%),可选 `--mode parallel`
190
- 5. **Skill 步骤**: hooks-install → TDD-GATE → dispatching-parallel-agents → TDD (RED/GREEN/REFACTOR) → freeze → blind-review → unfreeze → verification-before-completion → 成本监控
191
- 6. **Mock Minimization**: integration-first, mock 仅限 external services, 密度 > 30% 需 `@mock-justified`
189
+ 1. **BUILD-ENTRY-CONTRACT (MANDATORY — v0.18.0+)**: `phase-transition 3 in_progress` 校验 slices-manifest.json schema + slice↔REQ 一致性 → 不合法 BLOCK
190
+ 2. **DELPHI-GATE**: 验证 `.sprint-state/delphi-reviewed.json` 存在且 `verdict = "APPROVED"` → 否则 BLOCK
191
+ 3. **TDD-GATE (MANDATORY — v0.14.0+)**: 在 delegation 前验证每个 REQ 存在 failing test。无 test → mark `[TDD-RED]`(ralph-loop 创建)。有 test 且 GREEN 且无实现 → BLOCK(TDD bypass)。详见 `references/phase-3-build.md#tdd-gate-pre-implementation-tdd-check-mandatory`。
192
+ 4. **输入**: `slices-manifest.json`(Phase 2/6 生成),按 `execution_order` 逐个执行
193
+ 5. **模式**: 默认 `ralph-loop`(逐 REQ 迭代,token 节约 40-67%),可选 `--mode parallel`
194
+ 6. **Skill 步骤**: BUILD-ENTRY-CONTRACT → hooks-install → TDD-GATE → TDD (RED/GREEN/REFACTOR) → blind-review (read-only subagent, tools: [Read, Grep, Glob]) → verification-before-completion → 成本监控 → learnings.md 写入
195
+ 7. **Mock Minimization**: integration-first, mock 仅限 external services, 密度 > 30% 需 `@mock-justified`
192
196
 
193
197
  ### Phase 4/6: VERIFY (验证 — 代码走查 + QA + 反馈获取)
194
198
 
@@ -198,11 +202,11 @@ Sprint Flow: PREP → DESIGN → BUILD → VERIFY → SHIP → CLOSE
198
202
 
199
203
  **快速参考**:
200
204
  - **Orchestrator 直接执行**: delphi-review code-walkthrough 需要用户确认 verdict(Issue #249),**必须由 orchestrator 直接调用** `skill(name="delphi-review")`
201
- - **执行顺序**: `delphi-review --mode code-walkthrough` → 等待 APPROVED → `test-specification-alignment` → `browse` (gstack) → 可选 `qa`/`design-review`/`benchmark` (gstack)
202
- - **Feedback 子阶段**: `learn` (Sprint 级复盘) + `retro` (工程回顾) + 可选 `systematic-debugging` (根因调试)
203
- - **Subagent**: `task(category="quick", load_skills=["learn", "retro", "systematic-debugging"])`
204
- - 输出: 评审报告 + feedback-log.md
205
- - **HARD-GATE**: feedback-log.md must exist before Phase 5/6
205
+ - **执行顺序**: `delphi-review --mode code-walkthrough` → 等待 APPROVED → `test-specification-alignment` (#367 程序化 HARD-GATE: test-alignment-report.json + head_commit + spec_hash) → `xp-gate check --all` → 浏览器验证 (Layer 4: gstack browse > browser-use MCP > SKIP)
206
+ - **Web 前端**: `xp-gate ui-review`(原生)+ OPTIONAL gstack qa/design-review/benchmark(如已安装)
207
+ - **Feedback 子阶段**: learnings.md 写入(原生)+ `xp-gate retro`(原生,含 #369 返工率区块)+ OPTIONAL systematic-debugging(Layer 4,保留"无根因不修复"纪律)
208
+ - 输出: 评审报告 + feedback-log.md + test-alignment-report.json
209
+ - **HARD-GATE**: feedback-log.md must exist + test-alignment-report.json PASS before Phase 5/6
206
210
 
207
211
  ### 负载/压力测试(可选)
208
212
 
@@ -220,17 +224,17 @@ Sprint Flow: PREP → DESIGN → BUILD → VERIFY → SHIP → CLOSE
220
224
  **详细指令**: 参见 `references/phase-5-ship.md` — VERSION-GATE (MANDATORY) / finishing-a-development-branch / VERSION CHANGESET (Issue #142) / changeset schema。
221
225
 
222
226
  **快速参考**:
223
- - **Step 0: VERSION-GATE (MANDATORY — 必须在 finishing-a-development-branch 之前)**: bump VERSION → update CHANGELOG.md → run sync-version.sh → commit + push → verify PR updated。详见 `references/phase-5-ship.md#step-0-version-gate`
224
- - **Step 1: finishing-a-development-branch**: 4 选项菜单,选择 "Push and create a Pull Request"
225
- - **Orchestrator 直接执行**: `finishing-a-development-branch` 和 `ship` 均为交互式 skill,**必须由 orchestrator 直接调用** `skill(name="finishing-a-development-branch")` 和 `skill(name="ship")`
227
+ - **Step 0: VERSION-GATE (MANDATORY — 必须在分支完成决策之前)**: bump VERSION → update CHANGELOG.md → run sync-version.sh → commit + push → verify PR updated。详见 `references/phase-5-ship.md#step-0-version-gate`
228
+ - **Step 1: 分支完成决策(原生 4 选项)**: AskUserQuestion 菜单 (merge/PR/keep/discard),默认推荐 Option 2 (Push and create a Pull Request)
229
+ - **Step 2: 原生 Ship 步骤**: test → VERSION-GATE → commit → push → `gh pr create`
226
230
  - 输入: phase-4-summary.md + feedback-log.md → 输出: PR URL (含版本变更 commit)
227
- - **HARD-GATE**: Phase 4/6 未完成 → BLOCK。验证 `feedback-log.md` 存在。
231
+ - **HARD-GATE**: Phase 4/6 未完成 → BLOCK。验证 `feedback-log.md` 存在 + test-alignment-report.json PASS。
228
232
  - **GITHOOKS-GATE**: 验证 hooks 完整性,缺失则 `githooks/install.sh`
229
- - **LAND**: `land-and-deploy` — merge PR → 等待 CI (10min) → 等待 Deploy (10min) → Canary Health Check (5min)
233
+ - **LAND(原生步骤)**: merge 确认 → `gh run list` 等 CI (10min) → 等 Deploy (10min) → Canary Health Check (5min)
230
234
  - **回滚**: `git revert` 最后一次 merge commit
231
235
  - ⚠️ **SHIP COMPLETION**: Phase 5/6 结束前必须确认 PR 已 merge 到 main + release 已创建。未完成 merge 不得进入 Phase 6/6。详见 `references/phase-5-ship.md#ship-completion-gate`。
232
236
 
233
- **⚠️ VERSION-GATE 必须在 finishing-a-development-branch 之前执行。顺序反了会导致 PR 不含版本变更 → CI release workflow 不触发 → 无新版本发布。**
237
+ **⚠️ VERSION-GATE 必须在分支完成决策之前执行。顺序反了会导致 PR 不含版本变更 → CI release workflow 不触发 → 无新版本发布。**
234
238
 
235
239
  ### Phase 6/6: CLOSE (收尾 — ⚠️ 人工验收 + 清理)
236
240
 
@@ -241,8 +245,9 @@ Sprint Flow: PREP → DESIGN → BUILD → VERIFY → SHIP → CLOSE
241
245
  **快速参考**:
242
246
  - **SHIP→CLOSE GATE (MANDATORY — v0.14.3+)**: 校验 PR 已 merge、当前在 main 分支、`git status --porcelain` 为空。详见 `references/phase-6-close.md#ship--close-gate`。
243
247
  - **Backup sprint-state**(MANDATORY): Phase 6 开始前将 `.sprint-state/` 备份到 repo 追踪路径,防止 worktree 清理后状态丢失。详见 `references/phase-6-close.md#backup-sprint-state`。
248
+ - **#369 返工追踪 (v0.18.0+)**: CLOSE 写入 `metrics.completed_at` + `metrics.total_sprint_commits`(merge-base 到合并点提交数)+ `metrics.merge_base_sha`。`xp-gate sprint-status --rework-check [--window-days N]` 仓库范围扫描 fix 提交,`rework_rate > 30%` 告警。"重新打开的 issue 数"指标已删除。
244
249
  - **USER ACCEPTANCE**: ⚠️ **MUST NOT be automated, skipped, or bypassed.** 即使用户说"赶时间"、"跳过验收"、"直接发布",也必须暂停等待用户确认。使用 `@templates/emergent-issues-template.md` 检查清单
245
- - **CLEANUP**: 保存分支信息 → `git worktree remove <worktree_path>`(精确路径,禁止通配符)→ 删除本地分支 + 远程分支 → 关闭遗留 OPEN PR → 更新 sprint-state.json → 释放 Sprint Lock
250
+ - **CLEANUP**: 保存分支信息 → `git worktree remove <worktree_path>`(精确路径,禁止通配符)→ 删除本地分支 + 远程分支 → 关闭遗留 OPEN PR → 更新 sprint-state.json(含 #369 metrics)→ learnings.md 写入 → 释放 Sprint Lock
246
251
  - 输出 Cleanup Report + Sprint Summary
247
252
  - **IF emergent issues → Sprint 2**
248
253
 
@@ -312,13 +317,13 @@ Sprint Flow: PREP → DESIGN → BUILD → VERIFY → SHIP → CLOSE
312
317
 
313
318
  | Phase | Backend (default) | Web Frontend | Mobile | Load Test |
314
319
  |-------|------------------|-------------|--------|-----------|
315
- | 2/6 DESIGN | `brainstorming` + `autoplan` + `delphi-review` | + `design-shotgun` | (同 web) | (通用) |
316
- | 3/6 BUILD | TDD + blind-review | (同 backend) | + `vercel-react-native-skills` / `flutter-review` | (同) |
317
- | 4/6 VERIFY | `delphi-review --mode code-walkthrough` + `test-specification-alignment` + k6/locust/gatling | + `qa` + `design-review` + `benchmark` | Flutter: `flutter-test` / RN: `detox E2E` | k6/locust/gatling |
318
- | 4/6 VERIFY (Feedback) | `learn` + `retro` | (同) | (同) | (同) |
319
- | 5/6 SHIP | `finishing-a-development-branch` + `ship` + `land-and-deploy` | (同) | + platform deploy | (同) |
320
- | 6/6 CLOSE | — 人工验收 → cleanup | (同) | (同) | (同) |
321
- | Browse | `localhost:3000` | 部署 URL + 表单/交互 | Flutter Web / RN Web | (专用) |
320
+ | 2/6 DESIGN | `grill-with-docs` + R1 `delphi-review --mode requirements` + `batch-grill-me` + R2 `delphi-review` | + OPTIONAL `design-shotgun` | (同 web) | (通用) |
321
+ | 3/6 BUILD | TDD + blind-review (read-only subagent) | (同 backend) | + `vercel-react-native-skills` / `flutter-review` | (同) |
322
+ | 4/6 VERIFY | `delphi-review --mode code-walkthrough` + `test-specification-alignment` + `xp-gate check --all` + k6/locust/gatling | + `xp-gate ui-review` + OPTIONAL qa/design-review/benchmark | Flutter: `flutter-test` / RN: `detox E2E` | k6/locust/gatling |
323
+ | 4/6 VERIFY (Feedback) | learnings.md + `xp-gate retro` | (同) | (同) | (同) |
324
+ | 5/6 SHIP | VERSION-GATE + 原生 4 选项 + native ship + native land | (同) | + platform deploy | (同) |
325
+ | 6/6 CLOSE | — 人工验收 → #369 返工指标 → cleanup | (同) | (同) | (同) |
326
+ | Browse | Layer 4 可选链 (gstack browse > browser-use MCP > SKIP) | 部署 URL + 表单/交互 | Flutter Web / RN Web | (专用) |
322
327
 
323
328
  **Mobile 工具链**: Flutter — `flutter analyze/test/build/pub publish`; RN — `metro/detox/jest/react-native run-ios/android`
324
329
 
@@ -451,7 +456,7 @@ Additional reference files:
451
456
  | Verification improves 2-3x | Boris #1 tip | Phase 4/6 VERIFY 设计 |
452
457
  | Emergent requirements 无法消除 | Mike Cohn, Rafael Santos | Phase 6/6 CLOSE 人工设计 |
453
458
  | 78% failures invisible | arXiv research | Phase 6/6 必要性证明 |
454
- | Think → Plan → Build → Ship | gstack ETHOS | 整体流程设计 |
459
+ | Think → Plan → Build → Ship | 行业通用流程 | 整体流程设计 |
455
460
 
456
461
  ---
457
462
 
@@ -1,9 +1,9 @@
1
1
  # SKILLS/TEST-SPECIFICATION-ALIGNMENT KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-07-23
4
- **Commit:** 766602e
3
+ **Generated:** 2026-07-25
4
+ **Commit:** 3150b22
5
5
  **Branch:** main
6
- **Version:** 0.15.5.0
6
+ **Version:** 0.18.0.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
@@ -10,7 +10,7 @@ description: "Use when asked to run tests, verify tests, align tests with specif
10
10
  1. **Load Phase 0** — Verify `specification.yaml` and `tests/` directory exist; BLOCK if missing with guidance to complete brainstorming → delphi-review → specification-generator flow first
11
11
  2. **Phase 1 Alignment (Modify Allowed)** — Parse specification.yaml + test files (AST); validate alignment rules; generate alignment report; optionally fix tests to align with requirements; require score ≥80% to proceed
12
12
  3. **Coverage Mapping** — Map each REQ-* to at least one test with `@test` annotation; map each AC-* to at least one assertion; verify `@test`, `@intent`, `@covers` tags
13
- 4. **Pre-Phase 2 Freeze** — Invoke `/freeze` skill to lock test directories; return confirmation before proceeding
13
+ 4. **Pre-Phase 2 Freeze** — Lock test directories via read-only subagent convention (reviewer tools restricted to `[Read, Grep, Glob]`, no Write/Edit/Bash); return confirmation before proceeding
14
14
  5. **Phase 2 Execution (Frozen)** — Run all tests; Agent BLOCKED from modifying/deleting/skipping tests; analyze failures into 4 categories
15
15
  6. **Failure Classification** — For each failing test, output with Type, Test, Root Cause, Action fields; SPECIFICATION_ERROR requires ESCALATE_TO_HUMAN with user options (A: fix spec → re-Phase 1, B: confirm spec → modify code, C: clarify ambiguity)
16
16
  7. **JSON Report Output** — Generate alignment report as valid JSON
@@ -31,11 +31,16 @@ description: "Use when asked to run tests, verify tests, align tests with specif
31
31
 
32
32
  ## Output Format (MANDATORY)
33
33
 
34
+ > **MANDATORY FILE OUTPUT**: When invoked, you MUST write this report as valid JSON to the file `.sprint-state/phase-outputs/test-alignment-report.json` in the project root. Stdout output alone is not sufficient — `xp-gate phase-transition 4 completed` validates the file, not the stdout.
35
+
34
36
  ```json
35
37
  {
36
38
  "alignment_status": "PASS|FAIL|BLOCKED",
37
39
  "phase": "1|2",
38
40
  "score": 85.5,
41
+ "head_commit": "<git rev-parse HEAD output>",
42
+ "spec_hash": "<SHA-256 of specification.yaml if exists, else null>",
43
+ "timestamp": "<ISO 8601>",
39
44
  "misaligned_tests": [
40
45
  {"test_name": "test_checkout", "spec_requirement": "REQ-003", "gap": "Missing @test annotation"}
41
46
  ],
@@ -44,7 +49,7 @@ description: "Use when asked to run tests, verify tests, align tests with specif
44
49
  }
45
50
  ```
46
51
 
47
- **Eval assertions check for:** `alignment_status`, `phase`, `score`, `anti_pattern_detected`.
52
+ **Eval assertions check for:** `alignment_status`, `phase`, `score`, `head_commit`, `spec_hash`, `anti_pattern_detected`.
48
53
 
49
54
  ---
50
55
 
@@ -53,7 +58,7 @@ description: "Use when asked to run tests, verify tests, align tests with specif
53
58
  ### Automatic
54
59
  - BUILD (TDD + review) Round 1 after Driver outputs tests
55
60
  - Gate 1 verification before proceeding
56
- - gstack-ship release before deployment
61
+ - Phase 5 SHIP release before deployment (native phase-5 steps)
57
62
 
58
63
  ### Manual
59
64
  - `/test-specification-alignment`, `/verify-tests`, "run tests", "verify tests"
@@ -242,7 +242,7 @@ Phase 1: PLAN → autoplan → delphi-review → specification.yaml
242
242
  → **/to-issues** → slices-manifest.json + Issue 列表
243
243
  Phase 2: BUILD → 按 execution_order 逐个切片执行
244
244
  → 每个切片 = 一个 REQ(ralph-loop 模式)
245
- → 或通过 dispatching-parallel-agents 并行(无依赖的 AFK 切片)
245
+ → 或通过原生 Task 并行派发(无依赖的 AFK 切片)
246
246
  Phase 3: REVIEW → **整体 review**(全部切片完成后统一 code-walkthrough)
247
247
  → browse / QA 验证端到端行为
248
248
  Phase 4: USER ACC → 人工验收(全部切片集成后的完整功能)
@@ -1,68 +0,0 @@
1
- # ============================================================================
2
- # GATE 3: Cyclomatic Complexity Check
3
- # Uses lizard - checks cyclomatic complexity of changed source files
4
- # ============================================================================
5
-
6
- 2>&1 echo ""
7
- 2>&1 echo "→ Gate 3: Cyclomatic complexity..."
8
- GATE_3_START=$(gate_start_ms)
9
-
10
- if [ "$PROJECT_LANG" = "documentation-only" ]; then
11
- echo "⏭️ SKIPPED - Complexity (documentation project)."
12
- GATE_3_STATUS="SKIP"
13
-
14
- elif [ "$PROJECT_LANG" = "powershell" ]; then
15
- echo "ℹ️ No PowerShell Clean Code / SOLID tool available"
16
- echo "⏭️ SKIPPED - Complexity (no PowerShell tool)"
17
- GATE_3_STATUS="SKIP"
18
-
19
- else
20
- CCN_THRESHOLD=5
21
-
22
- # Check lizard availability
23
- LIZARD_CMD=""
24
- if command -v lizard > /dev/null 2>&1; then
25
- LIZARD_CMD=lizard
26
- elif [ -f ~/.local/bin/lizard ]; then
27
- LIZARD_CMD=~/.local/bin/lizard
28
- fi
29
-
30
- if [ -n "$LIZARD_CMD" ]; then
31
- LIZARD_PATH=$(eval echo "$LIZARD_CMD")
32
-
33
- # Get changed source files for complexity check (includes test files)
34
- CC_FILES=$(echo "$CHANGED_FILES" | grep -E '\.(ts|tsx|js|jsx|py|go|java|swift|cpp|c|hpp|h|m|mm|kt)$' || true)
35
-
36
- if [ -n "$CC_FILES" ]; then
37
- echo "Checking complexity for source files..."
38
-
39
- # Run lizard with CCN threshold
40
- CC_OUTPUT=$($LIZARD_PATH -C $CCN_THRESHOLD $CC_FILES 2>&1 || true)
41
-
42
- # Parse warning count from the summary table: "Warning cnt 8"
43
- # Use anchored grep to avoid matching lizard table headers (e.g. "Rt" column)
44
- CC_WARNINGS=$(echo "$CC_OUTPUT" | grep "^Warning cnt" | awk '{print $NF}' | tr -d '[:space:]' | sed 's/[^0-9]//g' || true)
45
- CC_WARNINGS=${CC_WARNINGS:-0}
46
-
47
- if [ "$CC_WARNINGS" -gt 0 ]; then
48
- echo "$CC_OUTPUT"
49
- echo ""
50
- echo "❌ BLOCKED - $CC_WARNINGS functions with CCN > $CCN_THRESHOLD found."
51
- echo "Refactor high-complexity functions to keep below $CCN_THRESHOLD complexity."
52
- exit 1
53
- else
54
- echo "✅ PASSED - All functions within complexity threshold ($CCN_THRESHOLD)."
55
- GATE_3_STATUS="PASS"
56
- fi
57
- else
58
- echo "⏭️ SKIPPED - Complexity (no source files to check)."
59
- GATE_3_STATUS="SKIP"
60
- fi
61
- else
62
- echo "⚠️ WARN - lizard not installed, complexity check not performed"
63
- echo " Install with: pip install --user lizard"
64
- echo " Gate 3: Complexity check (WARN, tool not available)"
65
- GATE_3_STATUS="WARN"
66
- fi
67
- fi
68
- record_gate_audit "gate-3" "complexity" "$GATE_3_STATUS" "${CC_WARNINGS:-0}" "$GATE_3_START"
@@ -1,80 +0,0 @@
1
- # ============================================================================
2
- # GATE 4: Principles Checker (Clean Code + SOLID)
3
- # Reuses existing principles checker logic
4
- # ============================================================================
5
-
6
- 2>&1 echo ""
7
- 2>&1 echo "→ Gate 4: Principles checker (Clean Code + SOLID)..."
8
- GATE_4_START=$(gate_start_ms)
9
-
10
- GATE_4_STATUS=""
11
-
12
- if [ "$PROJECT_LANG" = "documentation-only" ]; then
13
- echo "⏭️ SKIPPED - Principles check (documentation project)."
14
- GATE_4_STATUS="SKIP"
15
-
16
- else
17
- # Get source files to check against principles
18
- PRINCIPLES_FILES=$(echo "$CHANGED_FILES" | grep -E '\.(ts|tsx|js|jsx|py|go|java|kt|dart|swift|cpp|c|hpp|h|m|mm)$' || true)
19
-
20
- if [ -n "$PRINCIPLES_FILES" ]; then
21
- # Check for principles checker in installed modules first, then project src/
22
- PRINCIPLES_DIR=""
23
- if [ -d ".xp-gate/modules/principles" ]; then
24
- PRINCIPLES_DIR=".xp-gate/modules/principles"
25
- elif [ -f "src/principles/index.ts" ]; then
26
- PRINCIPLES_DIR="src/principles"
27
- elif [ -d "$HOME/.config/xp-gate/modules/principles" ]; then
28
- PRINCIPLES_DIR="$HOME/.config/xp-gate/modules/principles"
29
- fi
30
-
31
- if [ -n "$PRINCIPLES_DIR" ]; then
32
- echo "Checking Clean Code + SOLID principles..."
33
-
34
- if command -v npx > /dev/null 2>&1; then
35
- # Run principles checker and store results
36
- if npx tsx $PRINCIPLES_DIR/index.ts --files $PRINCIPLES_FILES --format json > /tmp/principles-output.json 2>/dev/null; then
37
- # Check severity levels
38
- ERROR_COUNT=$(grep -c '"severity":"error"' /tmp/principles-output.json 2>/dev/null || true)
39
- ERROR_COUNT=${ERROR_COUNT:-0}
40
- WARNING_COUNT=$(grep -c '"severity":"warning"' /tmp/principles-output.json 2>/dev/null || true)
41
- WARNING_COUNT=${WARNING_COUNT:-0}
42
-
43
- if [ "$ERROR_COUNT" -gt 0 ]; then
44
- echo ""
45
- echo "❌ BLOCKED - $ERROR_COUNT principle ERROR(S) found"
46
- echo "Critical violations must be fixed before commit:"
47
- echo " - error-handling violations"
48
- echo " - SOLID principle violations"
49
- echo " - architectural violations"
50
- npx tsx $PRINCIPLES_DIR/index.ts --files $PRINCIPLES_FILES --format console
51
- GATE_4_STATUS="FAIL"
52
- exit 1
53
- fi
54
-
55
- echo "✅ PASSED - Principles checker (no errors found)."
56
- GATE_4_STATUS="PASS"
57
- if [ "$WARNING_COUNT" -gt 0 ]; then
58
- echo "ℹ️ $WARNING_COUNT warnings found (will be handled by Boy Scout Rule)."
59
- fi
60
- else
61
- echo "⚠️ Warning: Principles checker execution failed"
62
- echo "⏭️ SKIPPED - Principles check (execution issue)"
63
- GATE_4_STATUS="SKIP"
64
- fi
65
- else
66
- echo "ℹ️ npx not available - skipping principles check"
67
- echo "⏭️ SKIPPED - Principles check (no Node.js/npx)"
68
- GATE_4_STATUS="SKIP"
69
- fi
70
- else
71
- echo "ℹ️ Principles checker not found in project - skipping"
72
- echo "⏭️ SKIPPED - Principles check (checker not in project)"
73
- GATE_4_STATUS="SKIP"
74
- fi
75
- else
76
- echo "⏭️ SKIPPED - Principles check (no matching source files changed)"
77
- GATE_4_STATUS="SKIP"
78
- fi
79
- fi
80
- record_gate_audit "gate-4" "principles" "$GATE_4_STATUS" "${WARNING_COUNT:-0}" "$GATE_4_START"
@@ -1,45 +0,0 @@
1
- # ============================================================================
2
- # GATE 7: IaC Security Scanning (Terraform, Kubernetes, Docker)
3
- # Detects security issues in Infrastructure as Code files
4
- # Tools: checkov (recommended), hadolint, kube-score, tflint
5
- # ============================================================================
6
-
7
- 2>&1 echo ""
8
- 2>&1 echo "→ Gate 7: IaC Security Scanning (Terraform, Kubernetes, Docker)..."
9
- GATE_7_START=$(gate_start_ms)
10
-
11
- # Check if any IaC files are changed
12
- IAC_FILES=$(git diff --cached --name-only --diff-filter=ACM 2>/dev/null | grep -E "\.(tf|yaml|yml)$|Dockerfile" || true)
13
- if [ -z "$IAC_FILES" ]; then
14
- echo "✅ PASSED - No IaC files detected in changes."
15
- GATE_7_STATUS="PASS"
16
- else
17
- # Run IaC adapter
18
- if [ -f "githooks/adapters/iac.sh" ]; then
19
- # shellcheck source=githooks/adapters/iac.sh
20
- source "githooks/adapters/iac.sh"
21
-
22
- # Run static analysis for IaC files
23
- IAC_OUTPUT=$(run_static_analysis "$IAC_FILES" 2>&1)
24
- IAC_EXIT=$?
25
-
26
- echo "$IAC_OUTPUT"
27
-
28
- if [ $IAC_EXIT -eq 0 ]; then
29
- echo "✅ PASSED - IaC security scan."
30
- GATE_7_STATUS="PASS"
31
- else
32
- echo ""
33
- echo "❌ BLOCKED - IaC security issues detected"
34
- echo "Fix the security issues above before committing."
35
- echo "Tip: Install checkov for comprehensive IaC scanning: pip install checkov"
36
- GATE_7_STATUS="FAIL"
37
- exit 1
38
- fi
39
- else
40
- echo "ℹ️ SKIP - IaC adapter not found"
41
- echo "⏭️ SKIPPED - IaC security (no IaC adapter found)"
42
- GATE_7_STATUS="SKIP"
43
- fi
44
- fi
45
- record_gate_audit "gate-7" "iac-security" "$GATE_7_STATUS" "0" "$GATE_7_START"
@@ -1,56 +0,0 @@
1
- # ============================================================================
2
- # GATE 8: Secret Scanning (gitleaks)
3
- # Detects secrets (API keys, passwords, tokens) in staged files
4
- # Tool: gitleaks -- https://github.com/gitleaks/gitleaks
5
- # ============================================================================
6
-
7
- 2>&1 echo ""
8
- 2>&1 echo "→ Gate 8: Secret scanning (gitleaks)..."
9
- GATE_8_START=$(gate_start_ms)
10
-
11
- # Gitleaks availability check
12
- GITLEAKS_CMD=""
13
- if command -v gitleaks >/dev/null 2>&1; then
14
- GITLEAKS_CMD="gitleaks"
15
- elif [ -f "$HOME/.local/bin/gitleaks" ]; then
16
- GITLEAKS_CMD="$HOME/.local/bin/gitleaks"
17
- fi
18
-
19
- if [ -n "$GITLEAKS_CMD" ]; then
20
- GITLEAKS_CONFIG=""
21
- if [ -f ".gitleaks.toml" ]; then
22
- GITLEAKS_CONFIG="--config=.gitleaks.toml"
23
- fi
24
-
25
- # Run gitleaks on staged changes only (pre-commit mode for speed)
26
- GITLEAKS_OUTPUT=$($GITLEAKS_CMD git --pre-commit --redact --no-banner $GITLEAKS_CONFIG --report-format=json --report-path=/tmp/gitleaks-report.json 2>&1)
27
- GITLEAKS_EXIT=$?
28
-
29
- if [ "$GITLEAKS_EXIT" -eq 0 ]; then
30
- echo " ✅ PASSED - No secrets detected."
31
- GATE_8_STATUS="PASS"
32
- elif [ "$GITLEAKS_EXIT" -eq 1 ]; then
33
- # Secrets found — output details
34
- echo "$GITLEAKS_OUTPUT"
35
- echo ""
36
- echo "❌ BLOCKED - Secrets detected in staged files."
37
- echo ""
38
- echo "Remediation options:"
39
- echo " 1. Remove the secret and use environment variables instead"
40
- echo " 2. Add a false positive to .gitleaks.toml allowlist"
41
- echo " 3. Use git secret or vault for sensitive data"
42
- echo ""
43
- echo "See: https://github.com/gitleaks/gitleaks"
44
- exit 1
45
- else
46
- echo " ⚠️ gitleaks exited with code $GITLEAKS_EXIT - skipping gate"
47
- echo " ✅ Secret Scanning (SKIP, gitleaks error)"
48
- GATE_8_STATUS="SKIP"
49
- fi
50
- else
51
- echo " ℹ️ gitleaks not installed — secret scanning unavailable"
52
- echo " Install: brew install gitleaks (macOS) | winget install gitleaks (Windows) | scripts/install-gitleaks.sh (Linux)"
53
- echo " ⏭️ SKIPPED - Secret scanning (gitleaks not installed)"
54
- GATE_8_STATUS="SKIP"
55
- fi
56
- record_gate_audit "gate-8" "secret-scanning" "$GATE_8_STATUS" "0" "$GATE_8_START"