xp-gate 0.5.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.
- package/adapter-common.sh +192 -0
- package/adapters/cpp.sh +76 -0
- package/adapters/dart.sh +41 -0
- package/adapters/flutter.sh +41 -0
- package/adapters/go.sh +59 -0
- package/adapters/iac.sh +189 -0
- package/adapters/java.sh +191 -0
- package/adapters/kotlin.sh +77 -0
- package/adapters/objectivec.sh +38 -0
- package/adapters/powershell.sh +138 -0
- package/adapters/python.sh +104 -0
- package/adapters/shell.sh +55 -0
- package/adapters/swift.sh +44 -0
- package/adapters/typescript.sh +61 -0
- package/bin/xp-gate.js +157 -0
- package/hooks/adapter-common.sh +192 -0
- package/hooks/pre-commit +1667 -0
- package/hooks/pre-push +395 -0
- package/lib/__tests__/detect-deps.test.js +209 -0
- package/lib/__tests__/doctor.test.js +448 -0
- package/lib/__tests__/download-skill.test.js +281 -0
- package/lib/__tests__/init.test.js +327 -0
- package/lib/__tests__/install-skill.test.js +326 -0
- package/lib/__tests__/migrate.test.js +212 -0
- package/lib/__tests__/rollback.test.js +183 -0
- package/lib/__tests__/ui-detector.test.ts +200 -0
- package/lib/__tests__/uninstall-skill.test.js +189 -0
- package/lib/__tests__/uninstall.test.js +589 -0
- package/lib/__tests__/update-skill.test.js +276 -0
- package/lib/detect-deps.js +157 -0
- package/lib/doctor.js +370 -0
- package/lib/download-skill.js +96 -0
- package/lib/init.js +367 -0
- package/lib/install-skill.js +184 -0
- package/lib/migrate.js +120 -0
- package/lib/rollback.js +78 -0
- package/lib/ui-detector.ts +99 -0
- package/lib/uninstall-skill.js +69 -0
- package/lib/uninstall.js +401 -0
- package/lib/update-skill.js +90 -0
- package/package.json +39 -0
- package/plugins/claude-code/.claude-plugin/plugin.json +21 -0
- package/plugins/claude-code/bin/delphi-review-guard.sh +68 -0
- package/plugins/claude-code/bin/xp-gate-check +47 -0
- package/plugins/claude-code/hooks/hooks.json +37 -0
- package/skills/delphi-review/.delphi-config.json.example +45 -0
- package/skills/delphi-review/AGENTS.md +54 -0
- package/skills/delphi-review/INSTALL.md +152 -0
- package/skills/delphi-review/SKILL.md +371 -0
- package/skills/delphi-review/evals/evals.json +82 -0
- package/skills/delphi-review/opencode.json.delphi.example +56 -0
- package/skills/delphi-review/references/code-walkthrough.md +486 -0
- package/skills/ralph-loop/SKILL.md +330 -0
- package/skills/ralph-loop/evals/evals.json +311 -0
- package/skills/ralph-loop/evolution-history.json +59 -0
- package/skills/ralph-loop/evolution-log.md +16 -0
- package/skills/ralph-loop/references/components/memory.md +55 -0
- package/skills/ralph-loop/references/components/middleware.md +54 -0
- package/skills/ralph-loop/references/components/skill-invocations.md +39 -0
- package/skills/ralph-loop/references/components/system-prompt.md +24 -0
- package/skills/ralph-loop/references/components/tool-descriptions.md +32 -0
- package/skills/ralph-loop/references/phase-2-build-ralph.md +89 -0
- package/skills/ralph-loop/templates/progress-log.md +36 -0
- package/skills/sprint-flow/SKILL.md +600 -0
- package/skills/sprint-flow/evals/evals.json +78 -0
- package/skills/sprint-flow/evolution-history.json +39 -0
- package/skills/sprint-flow/evolution-log.md +23 -0
- package/skills/sprint-flow/references/components/memory.md +87 -0
- package/skills/sprint-flow/references/components/middleware.md +72 -0
- package/skills/sprint-flow/references/components/skill-invocations.md +104 -0
- package/skills/sprint-flow/references/components/system-prompt.md +27 -0
- package/skills/sprint-flow/references/components/tool-descriptions.md +96 -0
- package/skills/sprint-flow/references/phase-0-think.md +115 -0
- package/skills/sprint-flow/references/phase-1-plan.md +178 -0
- package/skills/sprint-flow/references/phase-2-build.md +198 -0
- package/skills/sprint-flow/references/phase-3-review.md +213 -0
- package/skills/sprint-flow/references/phase-4-uat.md +125 -0
- package/skills/sprint-flow/references/phase-5-feedback.md +100 -0
- package/skills/sprint-flow/references/phase-6-ship.md +193 -0
- package/skills/sprint-flow/references/phase-7-land.md +140 -0
- package/skills/sprint-flow/references/phase-8-cleanup.md +192 -0
- package/skills/sprint-flow/templates/emergent-issues-template.md +120 -0
- package/skills/sprint-flow/templates/pain-document-template.md +115 -0
- package/skills/sprint-flow/templates/sprint-summary-template.md +120 -0
- package/skills/test-specification-alignment/AGENTS.md +59 -0
- package/skills/test-specification-alignment/SKILL.md +605 -0
- package/skills/test-specification-alignment/evals/evals.json +75 -0
- package/skills/test-specification-alignment/references/alignment-verification-algorithm.md +493 -0
- package/skills/test-specification-alignment/references/phase2-constraint-enforcement.md +431 -0
- package/skills/test-specification-alignment/references/specification-format.md +348 -0
|
@@ -0,0 +1,486 @@
|
|
|
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 互不知道对方意见
|
|
18
|
+
2. **迭代共识** — 多轮直到 APPROVED
|
|
19
|
+
3. **零容忍** — Critical Issues 必须修复
|
|
20
|
+
4. **零降级** — 环境/资源问题必须阻断,通知用户解决
|
|
21
|
+
5. **强制覆盖** — 超过阈值必须 BLOCK,不能跳过
|
|
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
|
+
│ ├─→ 共识检查
|
|
76
|
+
│ │ │
|
|
77
|
+
│ │ ├─→ 2/2 APPROVED → 允许推送
|
|
78
|
+
│ │ │
|
|
79
|
+
│ │ ├─→ 分歧 → Expert C 仲裁
|
|
80
|
+
│ │ │
|
|
81
|
+
│ │ └─→ REQUEST_CHANGES → 阻塞推送
|
|
82
|
+
│ │
|
|
83
|
+
│ └─→ 写入 .code-walkthrough-result.json
|
|
84
|
+
│
|
|
85
|
+
└─→ 允许/阻塞推送
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## 专家角色
|
|
91
|
+
|
|
92
|
+
| 专家 | 视角 | 配置 |
|
|
93
|
+
|------|------|------|
|
|
94
|
+
| Expert A | 架构 + 设计评审 | `.delphi-config.json` → `experts.architecture` |
|
|
95
|
+
| Expert B | 实现 + 代码质量 | `.delphi-config.json` → `experts.technical` |
|
|
96
|
+
| Expert C (仲裁) | 冲突裁决 | `.delphi-config.json` → `experts.feasibility` |
|
|
97
|
+
|
|
98
|
+
> ⚠️ **注意**: 至少配置 **两个不同 provider** 的模型。详见 [INSTALL.md](./INSTALL.md)。
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## 评审维度
|
|
103
|
+
|
|
104
|
+
**必检项**:
|
|
105
|
+
|
|
106
|
+
| 维度 | 检查内容 |
|
|
107
|
+
|------|---------|
|
|
108
|
+
| **正确性** | 逻辑是否正确,边界条件是否处理 |
|
|
109
|
+
| **安全性** | 是否有注入、泄露、越权风险 |
|
|
110
|
+
| **可维护性** | 命名、结构、注释是否清晰 |
|
|
111
|
+
| **测试覆盖** | 是否有足够的测试 |
|
|
112
|
+
|
|
113
|
+
**选检项**(根据变更类型):
|
|
114
|
+
|
|
115
|
+
| 变更类型 | 额外检查 |
|
|
116
|
+
|---------|---------|
|
|
117
|
+
| API 变更 | 接口兼容性、文档更新 |
|
|
118
|
+
| 数据库变更 | 迁移脚本、回滚方案 |
|
|
119
|
+
| 性能敏感 | 性能测试、基准对比 |
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## Principles Module Integration
|
|
124
|
+
|
|
125
|
+
作为代码走查的一部分,自动运行 principles checker 分析:
|
|
126
|
+
|
|
127
|
+
```yaml
|
|
128
|
+
principles_module:
|
|
129
|
+
enabled: true
|
|
130
|
+
trigger: pre-push
|
|
131
|
+
rules:
|
|
132
|
+
- clean-code.all # 9 rules
|
|
133
|
+
- solid.all # 5 rules
|
|
134
|
+
integration_point: expert_prompt
|
|
135
|
+
output_format: principles_findings section
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**Principles 检查流程**:
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
git push
|
|
142
|
+
│
|
|
143
|
+
▼
|
|
144
|
+
pre-push hook
|
|
145
|
+
│
|
|
146
|
+
├─→ Step 1: Principles Checker
|
|
147
|
+
│ │
|
|
148
|
+
│ ├─→ 检测变更文件语言
|
|
149
|
+
│ ├─→ 选择对应 Adapter
|
|
150
|
+
│ ├─→ 运行 14 个规则
|
|
151
|
+
│ │ │
|
|
152
|
+
│ │ ├─→ Clean Code (9 rules)
|
|
153
|
+
│ │ │ - long-function (>50 lines)
|
|
154
|
+
│ │ │ - large-file (>500 lines)
|
|
155
|
+
│ │ │ - magic-numbers (非语义数字)
|
|
156
|
+
│ │ │ - god-class (>15 methods)
|
|
157
|
+
│ │ │ - deep-nesting (>4 levels)
|
|
158
|
+
│ │ │ - too-many-params (>7)
|
|
159
|
+
│ │ │ - missing-error-handling (IO 无 try-catch)
|
|
160
|
+
│ │ │ - unused-imports (未使用的导入)
|
|
161
|
+
│ │ │ - code-duplication (>15% 相似度)
|
|
162
|
+
│ │ │
|
|
163
|
+
│ │ ├─→ SOLID (5 rules)
|
|
164
|
+
│ │ │ - srp (单一职责)
|
|
165
|
+
│ │ │ - ocp (开闭原则)
|
|
166
|
+
│ │ │ - lsp (里氏替换)
|
|
167
|
+
│ │ │ - isp (接口隔离)
|
|
168
|
+
│ │ │ - dip (依赖倒置)
|
|
169
|
+
│ │ │
|
|
170
|
+
│ │ └─→ 输出 violations
|
|
171
|
+
│ │
|
|
172
|
+
│ └─→ Step 2: Delphi Code Walkthrough
|
|
173
|
+
│ │
|
|
174
|
+
│ ├─→ Expert A 评审 (含 principles_findings)
|
|
175
|
+
│ ├─→ Expert B 评审 (含 principles_findings)
|
|
176
|
+
│ └─→ 共识检查
|
|
177
|
+
│
|
|
178
|
+
└─→ 允许/阻塞推送
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
**Principles Findings 输出格式**(在 Expert 评审报告中添加):
|
|
182
|
+
|
|
183
|
+
```markdown
|
|
184
|
+
## Principles Findings
|
|
185
|
+
|
|
186
|
+
### Clean Code Violations
|
|
187
|
+
|
|
188
|
+
| Rule | Severity | File | Line | Description |
|
|
189
|
+
|------|----------|------|------|-------------|
|
|
190
|
+
| clean-code.long-function | warning | src/api.ts | 45 | Function "processData" exceeds 50 lines |
|
|
191
|
+
| clean-code.deep-nesting | warning | src/utils.ts | 12 | Nesting depth 5 > threshold 4 |
|
|
192
|
+
|
|
193
|
+
### SOLID Violations
|
|
194
|
+
|
|
195
|
+
| Rule | Severity | File | Line | Description |
|
|
196
|
+
|------|----------|------|------|-------------|
|
|
197
|
+
| solid.srp | warning | src/user.ts | 1 | Class has 18 methods (>15 threshold) |
|
|
198
|
+
| solid.dip | warning | src/service.ts | 23 | Direct instantiation of UserRepository |
|
|
199
|
+
|
|
200
|
+
### Summary
|
|
201
|
+
- Total violations: [N]
|
|
202
|
+
- Errors: [N]
|
|
203
|
+
- Warnings: [N]
|
|
204
|
+
- Infos: [N]
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
**Principles 检查与 Delphi 评审的关系**:
|
|
208
|
+
|
|
209
|
+
| Principles 结果 | Delphi 评审行为 |
|
|
210
|
+
|-----------------|-----------------|
|
|
211
|
+
| 无 violations | Expert 正常评审,无额外关注点 |
|
|
212
|
+
| 有 info 级别 | Expert 评审时参考,不阻塞 |
|
|
213
|
+
| 有 warning 级别 | Expert 必须在评审中提及并给出意见 |
|
|
214
|
+
| 有 error 级别 | **自动阻塞推送**,无需 Delphi 评审 |
|
|
215
|
+
|
|
216
|
+
**阈值配置**:项目级配置文件 `.principlesrc` 可覆盖默认阈值:
|
|
217
|
+
|
|
218
|
+
```json
|
|
219
|
+
{
|
|
220
|
+
"rules": {
|
|
221
|
+
"clean-code": {
|
|
222
|
+
"long-function": { "threshold": 50 },
|
|
223
|
+
"god-class": { "threshold": 15 },
|
|
224
|
+
"deep-nesting": { "threshold": 4 }
|
|
225
|
+
},
|
|
226
|
+
"solid": {
|
|
227
|
+
"srp": { "methodThreshold": 15 },
|
|
228
|
+
"isp": { "methodThreshold": 10 }
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## 共识标准
|
|
237
|
+
|
|
238
|
+
| 条件 | 结果 |
|
|
239
|
+
|------|------|
|
|
240
|
+
| 2/2 APPROVED + 无 Critical Issues | ✅ 允许推送 |
|
|
241
|
+
| 2/2 APPROVED + 有 Minor Issues | ✅ 允许推送(记录问题) |
|
|
242
|
+
| 1/2 APPROVED | ⚠️ 需要 Expert C 仲裁 |
|
|
243
|
+
| 0/2 APPROVED | ❌ 阻塞推送 |
|
|
244
|
+
| 有 Critical Issues | ❌ 阻塞推送 |
|
|
245
|
+
| 有 Major Issues 且未处理 | ❌ 阻塞推送 |
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
## 成本控制 (零降级原则)
|
|
250
|
+
|
|
251
|
+
| 指标 | 阈值 | 处理 |
|
|
252
|
+
|------|------|------|
|
|
253
|
+
| 单次走查成本 | ~$0.03 | 正常执行 |
|
|
254
|
+
| 最大评审文件数 | 20 个文件 | 超过 → **BLOCK** |
|
|
255
|
+
| 最大 diff 行数 | 500 行 | 超过 → **BLOCK** |
|
|
256
|
+
|
|
257
|
+
**超过阈值处理 (零降级)**:
|
|
258
|
+
|
|
259
|
+
```
|
|
260
|
+
IF 超过阈值:
|
|
261
|
+
→ BLOCK 推送
|
|
262
|
+
→ 通知用户:变更过大,无法有效评审
|
|
263
|
+
→ 用户选项:
|
|
264
|
+
A. 拆分变更(推荐)
|
|
265
|
+
B. 用户明确授权跳过走查(需书面确认风险)
|
|
266
|
+
|
|
267
|
+
❌ 禁止自动跳过走查
|
|
268
|
+
❌ 禁止自动分批并批准
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
**设计原则**:
|
|
272
|
+
- 大变更跳过评审 = 质量风险泄露到生产环境
|
|
273
|
+
- 用户有权决定是否接受风险,AI 不能自动跳过
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## Agent 可用性检查 (MANDATORY)
|
|
278
|
+
|
|
279
|
+
**启动前检查**:
|
|
280
|
+
|
|
281
|
+
```
|
|
282
|
+
BEFORE code walkthrough:
|
|
283
|
+
├─ 检查 Expert A 模型可用性
|
|
284
|
+
├─ 检查 Expert B 模型可用性
|
|
285
|
+
├─ 检查 Expert C 模型可用性(仲裁时需要)
|
|
286
|
+
└─ 检查 OpenCode CLI 可用性
|
|
287
|
+
|
|
288
|
+
IF 任何检查失败:
|
|
289
|
+
→ BLOCK 推送
|
|
290
|
+
→ 通知用户具体缺失项
|
|
291
|
+
→ 提供修复指引
|
|
292
|
+
→ ❌ 禁止跳过走查直接推送
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
**模型不可用处理**:
|
|
296
|
+
|
|
297
|
+
| 情况 | 处理 |
|
|
298
|
+
|------|------|
|
|
299
|
+
| Expert A API 错误 | BLOCK + 提示用户检查 API key |
|
|
300
|
+
| Expert B API 错误 | BLOCK + 提示用户检查 API key |
|
|
301
|
+
| OpenCode CLI 缺失 | BLOCK + 提示用户安装 OpenCode |
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## Expert 评审输出格式
|
|
306
|
+
|
|
307
|
+
```markdown
|
|
308
|
+
## Code Walkthrough - Expert [A/B]
|
|
309
|
+
|
|
310
|
+
### 变更摘要
|
|
311
|
+
[变更的主要内容]
|
|
312
|
+
|
|
313
|
+
### 发现问题
|
|
314
|
+
|
|
315
|
+
| ID | 严重程度 | 问题描述 | 代码位置 | 修复建议 |
|
|
316
|
+
|----|----------|----------|---------|---------|
|
|
317
|
+
| ... | ... | ... | ... | ... |
|
|
318
|
+
|
|
319
|
+
### 裁决
|
|
320
|
+
[APPROVED / REQUEST_CHANGES]
|
|
321
|
+
|
|
322
|
+
### 置信度
|
|
323
|
+
[X/10]
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
|
|
328
|
+
## 共识报告格式
|
|
329
|
+
|
|
330
|
+
```markdown
|
|
331
|
+
## Code Walkthrough 共识报告
|
|
332
|
+
|
|
333
|
+
### 变更信息
|
|
334
|
+
- 分支: [branch name]
|
|
335
|
+
- 提交数: [N]
|
|
336
|
+
- 文件数: [N]
|
|
337
|
+
- 新增行数: +[N]
|
|
338
|
+
- 删除行数: -[N]
|
|
339
|
+
|
|
340
|
+
### 专家意见汇总
|
|
341
|
+
- Expert A: [APPROVED / REQUEST_CHANGES]
|
|
342
|
+
- Expert B: [APPROVED / REQUEST_CHANGES]
|
|
343
|
+
|
|
344
|
+
### 共识结果
|
|
345
|
+
[CONSENSUS / DISAGREEMENT]
|
|
346
|
+
|
|
347
|
+
### 最终裁决
|
|
348
|
+
[APPROVED / REQUEST_CHANGES / NEED_ARBITRATION]
|
|
349
|
+
|
|
350
|
+
### 问题清单(如有)
|
|
351
|
+
[需要修复的问题]
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
---
|
|
355
|
+
|
|
356
|
+
## 结果输出文件 (MANDATORY)
|
|
357
|
+
|
|
358
|
+
完成评审后,Skill 必须写入结果文件以供 Hook 验证:
|
|
359
|
+
|
|
360
|
+
**输出文件位置**:`.code-walkthrough-result.json`
|
|
361
|
+
|
|
362
|
+
**输出文件格式**:
|
|
363
|
+
|
|
364
|
+
```json
|
|
365
|
+
{
|
|
366
|
+
"commit": "abc123def456",
|
|
367
|
+
"branch": "feature/xp-rewrite",
|
|
368
|
+
"timestamp": "2026-04-14T10:30:00Z",
|
|
369
|
+
"expires": "2026-04-14T11:30:00Z",
|
|
370
|
+
"verdict": "APPROVED",
|
|
371
|
+
"confidence": 9,
|
|
372
|
+
"experts": [
|
|
373
|
+
{ "id": "Expert A", "verdict": "APPROVED", "confidence": 9 },
|
|
374
|
+
{ "id": "Expert B", "verdict": "APPROVED", "confidence": 8 }
|
|
375
|
+
],
|
|
376
|
+
"issues": [],
|
|
377
|
+
"consensus_ratio": 1.0,
|
|
378
|
+
"files_reviewed": 5,
|
|
379
|
+
"lines_added": 120,
|
|
380
|
+
"lines_deleted": 45
|
|
381
|
+
}
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
**字段说明**:
|
|
385
|
+
|
|
386
|
+
| 字段 | 类型 | 说明 |
|
|
387
|
+
|------|------|------|
|
|
388
|
+
| `commit` | string | 当前 HEAD commit hash (git rev-parse HEAD) |
|
|
389
|
+
| `branch` | string | 当前分支名 |
|
|
390
|
+
| `timestamp` | string | 评审完成时间 (ISO 8601 UTC) |
|
|
391
|
+
| `expires` | string | 过期时间 (timestamp + 1小时) |
|
|
392
|
+
| `verdict` | string | 最终裁决: APPROVED / REQUEST_CHANGES |
|
|
393
|
+
| `confidence` | number | 整体置信度 (1-10) |
|
|
394
|
+
| `experts` | array | 专家评审结果 |
|
|
395
|
+
| `issues` | array | 未解决的问题(如有) |
|
|
396
|
+
| `consensus_ratio` | number | 问题共识比例 (≥0.95 为共识) |
|
|
397
|
+
|
|
398
|
+
**有效期机制**:
|
|
399
|
+
|
|
400
|
+
- **有效期**: 1小时
|
|
401
|
+
- **过期后**: Hook 将提示重新执行 `/code-walkthrough`
|
|
402
|
+
- **commit 必须匹配**: 文件中的 commit 必须等于当前 HEAD
|
|
403
|
+
|
|
404
|
+
**Hook 验证逻辑**:
|
|
405
|
+
|
|
406
|
+
Hook 验证以下条件(全部满足才允许 push):
|
|
407
|
+
|
|
408
|
+
1. 文件存在
|
|
409
|
+
2. JSON 格式有效
|
|
410
|
+
3. commit hash 匹配当前 HEAD
|
|
411
|
+
4. verdict = APPROVED
|
|
412
|
+
5. timestamp 未过期 (< 1小时)
|
|
413
|
+
|
|
414
|
+
---
|
|
415
|
+
|
|
416
|
+
## 与现有系统集成
|
|
417
|
+
|
|
418
|
+
| 集成点 | 说明 |
|
|
419
|
+
|--------|------|
|
|
420
|
+
| `pre-push` hook | 验证 `.code-walkthrough-result.json` 文件(不调用 Skill) |
|
|
421
|
+
| `gstack-ship` | 推送后进入发布流程 |
|
|
422
|
+
| `verification-loop` | 走查通过后运行验证 |
|
|
423
|
+
|
|
424
|
+
---
|
|
425
|
+
|
|
426
|
+
## Anti-Patterns
|
|
427
|
+
|
|
428
|
+
**只在 `--mode code-walkthrough` 时适用:**
|
|
429
|
+
|
|
430
|
+
| 错误 | 正确 |
|
|
431
|
+
|------|------|
|
|
432
|
+
| Expert 不可用时跳过走查 | BLOCK + 提示用户修复环境 |
|
|
433
|
+
| 超过阈值自动跳过走查 | BLOCK + 提示用户拆分变更 |
|
|
434
|
+
| 超过阈值自动分批评审 | BLOCK + 用户决定是否拆分或授权跳过 |
|
|
435
|
+
| OpenCode CLI 缺失时允许推送 | BLOCK + 提示用户安装 OpenCode |
|
|
436
|
+
| 模型 API 错误时降级单模型 | BLOCK + 提示用户检查 API 配置 |
|
|
437
|
+
| 未写入 `.code-walkthrough-result.json` 就声明完成 | MUST 写入结果文件后才能完成 |
|
|
438
|
+
| 结果文件 commit hash 不匹配 | MUST 重新执行走查 |
|
|
439
|
+
|
|
440
|
+
---
|
|
441
|
+
|
|
442
|
+
## Terminal State Checklist (code-walkthrough mode)
|
|
443
|
+
|
|
444
|
+
**Pre-requisites (MANDATORY - BLOCK if missing):**
|
|
445
|
+
- [ ] OpenCode CLI 已安装且可用
|
|
446
|
+
- [ ] Expert A 模型 API 可用
|
|
447
|
+
- [ ] Expert B 模型 API 可用
|
|
448
|
+
- [ ] 变更大小在阈值内(文件 ≤20,行数 ≤500)
|
|
449
|
+
- [ ] Expert A 完成匿名评审
|
|
450
|
+
- [ ] Expert B 完成匿名评审
|
|
451
|
+
- [ ] 共识检查完成
|
|
452
|
+
|
|
453
|
+
**CRITICAL - 共识验证 (code-walkthrough):**
|
|
454
|
+
- [ ] 至少 2/2 或 2/3 专家 APPROVED
|
|
455
|
+
- [ ] 无 Critical Issues 未解决
|
|
456
|
+
- [ ] 无 Major Issues 未处理(或有处理计划)
|
|
457
|
+
|
|
458
|
+
**Final Requirements (code-walkthrough):**
|
|
459
|
+
- [ ] 共识报告已生成
|
|
460
|
+
- [ ] 问题已记录(如有)
|
|
461
|
+
- [ ] `.code-walkthrough-result.json` 已写入项目根目录
|
|
462
|
+
- [ ] 结果文件 commit hash 匹配当前 HEAD
|
|
463
|
+
- [ ] 结果文件未过期 (< 1小时)
|
|
464
|
+
|
|
465
|
+
**IF 任何 Pre-requisite 缺失:**
|
|
466
|
+
- **CANNOT 允许推送**
|
|
467
|
+
- **MUST BLOCK 并通知用户**
|
|
468
|
+
- **用户必须修复环境问题后重试**
|
|
469
|
+
|
|
470
|
+
**IF 有 Critical Issues:**
|
|
471
|
+
- **CANNOT 允许推送**
|
|
472
|
+
- **MUST 修复后重新走查**
|
|
473
|
+
|
|
474
|
+
**IF 超过大小阈值:**
|
|
475
|
+
- **CANNOT 允许推送**
|
|
476
|
+
- **MUST BLOCK 并提示拆分变更**
|
|
477
|
+
- **用户可明确授权跳过(需确认风险)**
|
|
478
|
+
|
|
479
|
+
**⭐ APPROVED 后必做 (code-walkthrough mode):写入结果文件**
|
|
480
|
+
|
|
481
|
+
IF mode == `code-walkthrough` AND 最终裁决是 APPROVED,评审完成后必须:
|
|
482
|
+
|
|
483
|
+
1. 写入 `.code-walkthrough-result.json` 到项目根目录
|
|
484
|
+
2. 验证 JSON 格式有效
|
|
485
|
+
3. 验证 commit hash 匹配当前 HEAD
|
|
486
|
+
4. 验证 expires 字段 = timestamp + 1小时
|