@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,470 @@
1
+ # Code Walkthrough Mode Reference
2
+
3
+ > Extracted from `SKILL.md`. This file contains ALL content specific to the `code-walkthrough` mode of Delphi Review.
4
+
5
+ ---
6
+
7
+ ## Overview
8
+
9
+ 代码走查模式,用于 git push 前对代码变更进行多专家 Delphi 评审。
10
+
11
+ **触发命令**: `/code-walkthrough` (等价于 `/delphi-review --mode code-walkthrough`)
12
+
13
+ ---
14
+
15
+ ## Five Core Properties
16
+
17
+ 1. **匿名性** — Expert A/B/C 在 Round 1 互不知道对方意见
18
+ 2. **迭代共识** — 多轮直到 APPROVED
19
+ 3. **零容忍** — Critical Issues 必须修复
20
+ 4. **零降级** — 环境/资源问题必须阻断,通知用户解决
21
+ 5. **强制覆盖** — 变更必须完整评审;大型变更由用户选择完整评审或在评审前拆分
22
+
23
+ ---
24
+
25
+ ## 触发条件
26
+
27
+ - **自动触发**:`git push` 前(通过 pre-push hook 验证结果文件)
28
+ - **手动触发**:`/code-walkthrough` 命令(等价于 `/delphi-review --mode code-walkthrough`)
29
+
30
+ **⚠️ 重要调用方式说明**:
31
+
32
+ - ✅ **正确**: 在 Agent session 中执行 `/code-walkthrough`
33
+ - ❌ **错误**: Shell 脚本调用 `opencode code-walkthrough` (OpenCode CLI 不支持 skill 子命令)
34
+ - ❌ **错误**: CLI 子命令 `opencode run --skill code-walkthrough --diff` (不支持)
35
+
36
+ **设计决策**: code-walkthrough 是 **强制但手动触发** 的质量门禁:
37
+ - **强制**: push 必须有有效的 `.code-walkthrough-result.json` 文件
38
+ - **手动**: Skill 执行由用户在 Agent session 内触发
39
+ - **理由**: 避免 OpenCode CLI 架构限制,保持正常工作模式
40
+
41
+ **⚠️ 门禁零容忍声明**:
42
+
43
+ code-walkthrough 是强制性质控门禁,以下行为严格禁止:
44
+ - ❌ 使用 `git push --no-verify` 绕过 pre-push hook 验证
45
+ - ❌ 伪造 `.code-walkthrough-result.json` 文件
46
+ - ❌ 因为"时间紧急"或"变更很小"而跳过评审
47
+ - ❌ 修改门禁阈值让告警消失
48
+
49
+ **门禁工具检测出的问题 = 必须修复,不允许绕过。**
50
+
51
+ 详见: [质量门禁行为准则](../../githooks/QUALITY-GATES-CODE-OF-CONDUCT.md)
52
+
53
+ ---
54
+
55
+ ## 流程概览
56
+
57
+ ```
58
+ git push
59
+ │
60
+ ▼
61
+ pre-push hook
62
+ │
63
+ ├─→ 获取 git diff main...HEAD
64
+ │
65
+ ├─→ 提取变更摘要
66
+ │
67
+ ├─→ 运行 Principles Checker (Clean Code + SOLID)
68
+ │
69
+ ├─→ 触发 Delphi 评审 (code-walkthrough mode)
70
+ │ │
71
+ │ ├─→ Expert A (架构 + 设计) 匿名评审 (含 principles_findings)
72
+ │ │
73
+ │ ├─→ Expert B (实现 + 代码质量) 匿名评审 (含 principles_findings)
74
+ │ │
75
+ │ ├─→ Expert C (可行性) 匿名评审 (含 principles_findings)
76
+ │ │
77
+ │ ├─→ 共识检查
78
+ │ │ │
79
+ │ │ ├─→ 三份成功结果、三个 distinct requested_model、≥90% → 允许推送
80
+ │ │ │
81
+ │ │ ├─→ 分歧 → 继续下一轮(最多 5 轮)
82
+ │ │ │
83
+ │ │ └─→ REQUEST_CHANGES → 阻塞推送
84
+ │ │
85
+ │ └─→ 写入 .code-walkthrough-result.json
86
+ │
87
+ └─→ 允许/阻塞推送
88
+ ```
89
+
90
+ ---
91
+
92
+ ## 专家角色
93
+
94
+ | 专家 | 视角 | 配置 |
95
+ |------|------|------|
96
+ | Expert A | 架构 + 设计评审 | `.delphi-config.json` → `experts.architecture` |
97
+ | Expert B | 实现 + 代码质量 | `.delphi-config.json` → `experts.technical` |
98
+ | Expert C | 可行性评审 | `.delphi-config.json` → `experts.feasibility` |
99
+
100
+ > 必须成功执行三个专家角色,并验证三个 distinct trimmed requested_model。Provider、vendor、gateway 和模型国籍均不受限制。`provider: local` fallback 不能计数,local hosted endpoint 可作为普通 callable provider。
101
+
102
+ ---
103
+
104
+ ## 评审维度
105
+
106
+ **必检项**:
107
+
108
+ | 维度 | 检查内容 |
109
+ |------|---------|
110
+ | **正确性** | 逻辑是否正确,边界条件是否处理 |
111
+ | **安全性** | 是否有注入、泄露、越权风险 |
112
+ | **可维护性** | 命名、结构、注释是否清晰 |
113
+ | **测试覆盖** | 是否有足够的测试 |
114
+
115
+ **选检项**(根据变更类型):
116
+
117
+ | 变更类型 | 额外检查 |
118
+ |---------|---------|
119
+ | API 变更 | 接口兼容性、文档更新 |
120
+ | 数据库变更 | 迁移脚本、回滚方案 |
121
+ | 性能敏感 | 性能测试、基准对比 |
122
+
123
+ ---
124
+
125
+ ## Principles Module Integration
126
+
127
+ 作为代码走查的一部分,自动运行 principles checker 分析:
128
+
129
+ ```yaml
130
+ principles_module:
131
+ enabled: true
132
+ trigger: pre-push
133
+ rules:
134
+ - clean-code.all # 9 rules
135
+ - solid.all # 5 rules
136
+ integration_point: expert_prompt
137
+ output_format: principles_findings section
138
+ ```
139
+
140
+ **Principles 检查流程**:
141
+
142
+ ```
143
+ git push
144
+ │
145
+ ▼
146
+ pre-push hook
147
+ │
148
+ ├─→ Step 1: Principles Checker
149
+ │ │
150
+ │ ├─→ 检测变更文件语言
151
+ │ ├─→ 选择对应 Adapter
152
+ │ ├─→ 运行 14 个规则
153
+ │ │ │
154
+ │ │ ├─→ Clean Code (9 rules)
155
+ │ │ │ - long-function (>50 lines)
156
+ │ │ │ - large-file (>500 lines)
157
+ │ │ │ - magic-numbers (非语义数字)
158
+ │ │ │ - god-class (>15 methods)
159
+ │ │ │ - deep-nesting (>4 levels)
160
+ │ │ │ - too-many-params (>7)
161
+ │ │ │ - missing-error-handling (IO 无 try-catch)
162
+ │ │ │ - unused-imports (未使用的导入)
163
+ │ │ │ - code-duplication (>15% 相似度)
164
+ │ │ │
165
+ │ │ ├─→ SOLID (5 rules)
166
+ │ │ │ - srp (单一职责)
167
+ │ │ │ - ocp (开闭原则)
168
+ │ │ │ - lsp (里氏替换)
169
+ │ │ │ - isp (接口隔离)
170
+ │ │ │ - dip (依赖倒置)
171
+ │ │ │
172
+ │ │ └─→ 输出 violations
173
+ │ │
174
+ │ └─→ Step 2: Delphi Code Walkthrough
175
+ │ │
176
+ │ ├─→ Expert A / architecture 评审 (含 principles_findings)
177
+ │ ├─→ Expert B / technical 评审 (含 principles_findings)
178
+ │ ├─→ Expert C / feasibility 评审 (含 principles_findings)
179
+ │ └─→ 共识检查
180
+ │
181
+ └─→ 允许/阻塞推送
182
+ ```
183
+
184
+ **Principles Findings 输出格式**(在 Expert 评审报告中添加):
185
+
186
+ ```markdown
187
+ ## Principles Findings
188
+
189
+ ### Clean Code Violations
190
+
191
+ | Rule | Severity | File | Line | Description |
192
+ |------|----------|------|------|-------------|
193
+ | clean-code.long-function | warning | src/api.ts | 45 | Function "processData" exceeds 50 lines |
194
+ | clean-code.deep-nesting | warning | src/utils.ts | 12 | Nesting depth 5 > threshold 4 |
195
+
196
+ ### SOLID Violations
197
+
198
+ | Rule | Severity | File | Line | Description |
199
+ |------|----------|------|------|-------------|
200
+ | solid.srp | warning | src/user.ts | 1 | Class has 18 methods (>15 threshold) |
201
+ | solid.dip | warning | src/service.ts | 23 | Direct instantiation of UserRepository |
202
+
203
+ ### Summary
204
+ - Total violations: [N]
205
+ - Errors: [N]
206
+ - Warnings: [N]
207
+ - Infos: [N]
208
+ ```
209
+
210
+ **Principles 检查与 Delphi 评审的关系**:
211
+
212
+ | Principles 结果 | Delphi 评审行为 |
213
+ |-----------------|-----------------|
214
+ | 无 violations | Expert 正常评审,无额外关注点 |
215
+ | 有 info 级别 | Expert 评审时参考,不阻塞 |
216
+ | 有 warning 级别 | Expert 必须在评审中提及并给出意见 |
217
+ | 有 error 级别 | **自动阻塞推送**,无需 Delphi 评审 |
218
+
219
+ **阈值配置**:项目级配置文件 `.principlesrc` 可覆盖默认阈值:
220
+
221
+ ```json
222
+ {
223
+ "rules": {
224
+ "clean-code": {
225
+ "long-function": { "threshold": 50 },
226
+ "god-class": { "threshold": 15 },
227
+ "deep-nesting": { "threshold": 4 }
228
+ },
229
+ "solid": {
230
+ "srp": { "methodThreshold": 15 },
231
+ "isp": { "methodThreshold": 10 }
232
+ }
233
+ }
234
+ }
235
+ ```
236
+
237
+ ---
238
+
239
+ ## 共识标准
240
+
241
+ | 条件 | 结果 |
242
+ |------|------|
243
+ | 三份成功结果、三个 distinct requested_model、≥90% 且无 Critical Issues | ✅ 允许推送 |
244
+ | 三份成功结果、≥90% 且有 Minor Issues | ✅ 允许推送(记录问题) |
245
+ | 任一专家失败、缺失或模型重复 | ❌ 阻塞推送 |
246
+ | 共识不足或有 Critical Issues | ❌ 阻塞推送 |
247
+ | 有 Critical Issues | ❌ 阻塞推送 |
248
+ | 有 Major Issues 且未处理 | ❌ 阻塞推送 |
249
+
250
+ ---
251
+
252
+ ## 成本控制 (零降级原则)
253
+
254
+ | 指标 | 阈值 | 处理 |
255
+ |------|------|------|
256
+ | 单次走查成本 | ~$0.03 | 正常执行 |
257
+ | 变更规模 | 无硬性文件数或行数上限 | 大型变更必须完整评审或由用户选择拆分 |
258
+
259
+ 大型变更没有自动跳过或绕过路径。用户可以选择完整评审,或在评审前主动拆分变更;每个变更仍须通过完整的走查和证据验证。
260
+
261
+ ---
262
+
263
+ ## Agent 可用性检查 (MANDATORY)
264
+
265
+ **启动前检查**:
266
+
267
+ ```
268
+ BEFORE code walkthrough:
269
+ ├─ 检查 Expert A 模型可用性
270
+ ├─ 检查 Expert B 模型可用性
271
+ ├─ 检查 Expert C 模型可用性
272
+ └─ 检查 OpenCode CLI 可用性
273
+
274
+ IF 任何检查失败:
275
+ → BLOCK 推送
276
+ → 通知用户具体缺失项
277
+ → 提供修复指引
278
+ → ❌ 禁止跳过走查直接推送
279
+ ```
280
+
281
+ **模型不可用处理**:
282
+
283
+ | 情况 | 处理 |
284
+ |------|------|
285
+ | 任一专家 API 错误 | BLOCK + 提示用户检查 provider/API key |
286
+ | OpenCode CLI 缺失 | BLOCK + 提示用户安装 OpenCode |
287
+
288
+ ---
289
+
290
+ ## Expert 评审输出格式
291
+
292
+ ```markdown
293
+ ## Code Walkthrough - Expert [A/B/C]
294
+
295
+ ### 变更摘要
296
+ [变更的主要内容]
297
+
298
+ ### 发现问题
299
+
300
+ | ID | 严重程度 | 问题描述 | 代码位置 | 修复建议 |
301
+ |----|----------|----------|---------|---------|
302
+ | ... | ... | ... | ... | ... |
303
+
304
+ ### 裁决
305
+ [APPROVED / REQUEST_CHANGES]
306
+
307
+ ### 置信度
308
+ [X/10]
309
+ ```
310
+
311
+ ---
312
+
313
+ ## 共识报告格式
314
+
315
+ ```markdown
316
+ ## Code Walkthrough 共识报告
317
+
318
+ ### 变更信息
319
+ - 分支: [branch name]
320
+ - 提交数: [N]
321
+ - 文件数: [N]
322
+ - 新增行数: +[N]
323
+ - 删除行数: -[N]
324
+
325
+ ### 专家意见汇总
326
+ - Expert A: [APPROVED / REQUEST_CHANGES]
327
+ - Expert B: [APPROVED / REQUEST_CHANGES]
328
+ - Expert C: [APPROVED / REQUEST_CHANGES]
329
+
330
+ ### 共识结果
331
+ [CONSENSUS / DISAGREEMENT]
332
+
333
+ ### 最终裁决
334
+ [APPROVED / REQUEST_CHANGES / NEED_ARBITRATION]
335
+
336
+ ### 问题清单(如有)
337
+ [需要修复的问题]
338
+ ```
339
+
340
+ ---
341
+
342
+ ## 结果输出文件 (MANDATORY)
343
+
344
+ 完成评审后,Skill 必须写入结果文件以供 Hook 验证:
345
+
346
+ **输出文件位置**:`.code-walkthrough-result.json`
347
+
348
+ **输出文件格式**:
349
+
350
+ ```json
351
+ {
352
+ "commit": "abc123def456",
353
+ "branch": "feature/xp-rewrite",
354
+ "timestamp": "2026-04-14T10:30:00Z",
355
+ "expires": "2026-04-14T11:30:00Z",
356
+ "verdict": "APPROVED",
357
+ "confidence": 9,
358
+ "experts": [
359
+ { "id": "Expert A", "role": "architecture", "verdict": "APPROVED", "confidence": 9, "result_type": "delphi_expert_result", "requested_model": "provider/model-a", "resolved_model": "provider/model-a" },
360
+ { "id": "Expert B", "role": "technical", "verdict": "APPROVED", "confidence": 8, "result_type": "delphi_expert_result", "requested_model": "provider/model-b", "resolved_model": null },
361
+ { "id": "Expert C", "role": "feasibility", "verdict": "APPROVED", "confidence": 8, "result_type": "delphi_expert_result", "requested_model": "provider/model-c", "resolved_model": "provider/model-c" }
362
+ ],
363
+ "issues": [],
364
+ "consensus_ratio": 1.0,
365
+ "files_reviewed": 5,
366
+ "lines_added": 120,
367
+ "lines_deleted": 45
368
+ }
369
+ ```
370
+
371
+ **字段说明**:
372
+
373
+ | 字段 | 类型 | 说明 |
374
+ |------|------|------|
375
+ | `commit` | string | 当前 HEAD commit hash (git rev-parse HEAD) |
376
+ | `branch` | string | 当前分支名 |
377
+ | `timestamp` | string | 评审完成时间 (ISO 8601 UTC) |
378
+ | `expires` | string | 过期时间 (timestamp + 1小时) |
379
+ | `verdict` | string | 最终裁决: APPROVED / REQUEST_CHANGES |
380
+ | `confidence` | number | 整体置信度 (1-10) |
381
+ | `experts` | array | 专家评审结果 |
382
+ | `issues` | array | 未解决的问题(如有) |
383
+ | `consensus_ratio` | number | 问题共识比例 (≥0.90 为共识) |
384
+
385
+ **有效期机制**:
386
+
387
+ - **有效期**: 1小时
388
+ - **过期后**: Hook 将提示重新执行 `/code-walkthrough`
389
+ - **commit 必须匹配**: 文件中的 commit 必须等于当前 HEAD
390
+
391
+ **Hook 验证逻辑**:
392
+
393
+ Hook 验证以下条件(全部满足才允许 push):
394
+
395
+ 1. 文件存在
396
+ 2. JSON 格式有效
397
+ 3. commit hash 匹配当前 HEAD
398
+ 4. verdict = APPROVED
399
+ 5. timestamp 未过期
400
+ 6. expires 必须是 timestamp 之后恰好 1 小时
401
+
402
+ ---
403
+
404
+ ## 与现有系统集成
405
+
406
+ | 集成点 | 说明 |
407
+ |--------|------|
408
+ | `pre-push` hook | 验证 `.code-walkthrough-result.json` 文件(不调用 Skill) |
409
+ | `gstack-ship` | 推送后进入发布流程 |
410
+ | `verification-loop` | 走查通过后运行验证 |
411
+
412
+ ---
413
+
414
+ ## Anti-Patterns
415
+
416
+ **只在 `--mode code-walkthrough` 时适用:**
417
+
418
+ | 错误 | 正确 |
419
+ |------|------|
420
+ | Expert 不可用时跳过走查 | BLOCK + 提示用户修复环境 |
421
+ | 大型变更 | 完整评审或由用户在评审前拆分 |
422
+ | OpenCode CLI 缺失时允许推送 | BLOCK + 提示用户安装 OpenCode |
423
+ | 模型 API 错误时降级单模型 | BLOCK + 提示用户检查 API 配置 |
424
+ | 未写入 `.code-walkthrough-result.json` 就声明完成 | MUST 写入结果文件后才能完成 |
425
+ | 结果文件 commit hash 不匹配 | MUST 重新执行走查 |
426
+
427
+ ---
428
+
429
+ ## Terminal State Checklist (code-walkthrough mode)
430
+
431
+ **Pre-requisites (MANDATORY - BLOCK if missing):**
432
+ - [ ] OpenCode CLI 已安装且可用
433
+ - [ ] 三个专家模型 API 均可用
434
+ - [ ] 变更已由用户选择完整评审或拆分为可审阅的变更
435
+ - [ ] Expert A 完成匿名评审
436
+ - [ ] Expert B 完成匿名评审
437
+ - [ ] Expert C 完成匿名评审
438
+ - [ ] 共识检查完成
439
+
440
+ **CRITICAL - 共识验证 (code-walkthrough):**
441
+ - [ ] 三个成功结果均为 `result_type=delphi_expert_result`
442
+ - [ ] 三个 `requested_model` trimmed 后 distinct
443
+ - [ ] 聚合共识 >=90%,并在 exact HEAD 上写入结果
444
+ - [ ] 无 Critical Issues 未解决
445
+ - [ ] 无 Major Issues 未处理(或有处理计划)
446
+
447
+ **Final Requirements (code-walkthrough):**
448
+ - [ ] 共识报告已生成
449
+ - [ ] 问题已记录(如有)
450
+ - [ ] `.code-walkthrough-result.json` 已写入项目根目录
451
+ - [ ] 结果文件 commit hash 匹配当前 HEAD
452
+ - [ ] 结果文件未过期 (< 1小时)
453
+
454
+ **IF 任何 Pre-requisite 缺失:**
455
+ - **CANNOT 允许推送**
456
+ - **MUST BLOCK 并通知用户**
457
+ - **用户必须修复环境问题后重试**
458
+
459
+ **IF 有 Critical Issues:**
460
+ - **CANNOT 允许推送**
461
+ - **MUST 修复后重新走查**
462
+
463
+ **⭐ APPROVED 后必做 (code-walkthrough mode):写入结果文件**
464
+
465
+ IF mode == `code-walkthrough` AND 最终裁决是 APPROVED,评审完成后必须:
466
+
467
+ 1. 写入 `.code-walkthrough-result.json` 到项目根目录
468
+ 2. 验证 JSON 格式有效
469
+ 3. 验证 commit hash 匹配当前 HEAD
470
+ 4. 验证 expires 字段 = timestamp + 1小时
@@ -0,0 +1,64 @@
1
+ # Orchestrator Dispatch Rules(#218 自动多轮调度)
2
+
3
+ ## 背景
4
+
5
+ Delphi review 在 sprint-flow 中通过 subagent 调用时,Round 1→Round 2→Round 3 的调度**必须在 subagent 内部自动完成**,不能每轮暂停等待 orchestrator 或用户干预。只有在以下情况才需要 orchestrator 暂停:
6
+
7
+ ## 自动调度规则
8
+
9
+ | 场景 | 自动处理 | 需暂停 |
10
+ |------|---------|--------|
11
+ | Round 1 完成,需 Round 2 | ✅ subagent 自动继续 | ❌ |
12
+ | Round 2 完成,需 Round 3 | ✅ subagent 自动继续 | ❌ |
13
+ | Round 3+ 完成,仍需更多轮 | ✅ subagent 自动继续,直到 max_rounds | ❌ |
14
+ | 最终 APPROVED (>=90%) | ✅ subagent 输出结果后退出 | ❌ |
15
+ | 最终 REQUEST_CHANGES(可自动修复) | ✅ subagent 尝试修复措辞、AC 缺失等常见问题后自动重评审 | ❌ |
16
+ | 最终 REQUEST_CHANGES(无法自动修复) | ✅ subagent 输出详细失败报告 | **✅ orchestrator 暂停等用户** |
17
+ | 超过 max_rounds (5) 仍无共识 | ✅ subagent 输出"未达成共识报告" | **✅ orchestrator 暂停等用户决策** |
18
+
19
+ ## Subagent 内部 Round 循环
20
+
21
+ 当 delphi-review 以 subagent 启动时(非交互式),应执行以下自动循环:
22
+
23
+ ```python
24
+ round = 1
25
+ while round <= max_review_rounds:
26
+ results = execute_round(round)
27
+ consensus = check_consensus(results)
28
+
29
+ if consensus.verdict == "APPROVED" and consensus.ratio >= 0.9:
30
+ emit_verdict("APPROVED", consensus)
31
+ break
32
+
33
+ if round == max_review_rounds:
34
+ emit_verdict("NO_CONSENSUS", consensus)
35
+ break
36
+
37
+ round += 1
38
+
39
+ if verdict == "REQUEST_CHANGES":
40
+ auto_fix_result = attempt_auto_fix(issues)
41
+ if auto_fix_result.success:
42
+ round = 2
43
+ continue
44
+ else:
45
+ emit_verdict("REQUEST_CHANGES", auto_fix_result.failed_issues)
46
+ ```
47
+
48
+ ## 终止结果输出
49
+
50
+ 当 subagent 因终态退出时,必须输出清晰的裁决:
51
+
52
+ - **APPROVED**: 共识报告 + specification.yaml
53
+ - **REQUEST_CHANGES(可自动修复)**: 自动修复后再次评审
54
+ - **REQUEST_CHANGES(不可自动修复)**: 失败报告 + 建议修复方向
55
+ - **NO_CONSENSUS**: 分歧详情报告
56
+
57
+ ## 与 orchestrator 的交互约定
58
+
59
+ | 状态 | Subagent 输出 | Orchestrator 动作 |
60
+ |------|--------------|------------------|
61
+ | APPROVED | `{verdict:"APPROVED", consensus_ratio: N, ...}` | 自动进入下一 Phase |
62
+ | REQUEST_CHANGES (auto-fixed) | `{verdict:"APPROVED", auto_fixed: ["..."]}` | 自动进入下一 Phase |
63
+ | REQUEST_CHANGES (unfixable) | `{verdict:"REQUEST_CHANGES", failed_issues: [...]}` | ⚠️ 暂停等用户修复后,通过 task_id 重新 dispatch |
64
+ | NO_CONSENSUS | `{verdict:"NO_CONSENSUS", disagreements: [...]}` | ⚠️ 暂停等用户决策(可继续/中止/强制通过) |