@boyingliu01/xp-gate 0.14.23 → 0.14.25

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 (38) hide show
  1. package/bin/xp-gate.js +8 -0
  2. package/lib/__tests__/init.test.js +77 -0
  3. package/lib/__tests__/phase-transition.test.js +174 -0
  4. package/lib/init.js +48 -0
  5. package/lib/phase-transition.js +211 -0
  6. package/mock-policy/AGENTS.md +3 -3
  7. package/mutation/AGENTS.md +3 -3
  8. package/package.json +2 -2
  9. package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
  10. package/plugins/claude-code/skills/delphi-review/AGENTS.md +3 -3
  11. package/plugins/claude-code/skills/delphi-review/SKILL.md +24 -4
  12. package/plugins/claude-code/skills/sprint-flow/AGENTS.md +3 -3
  13. package/plugins/claude-code/skills/sprint-flow/SKILL.md +20 -5
  14. package/plugins/claude-code/skills/sprint-flow/references/orchestration-rules.md +11 -16
  15. package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +3 -3
  16. package/plugins/opencode/package.json +1 -1
  17. package/plugins/opencode/skills/delphi-review/AGENTS.md +3 -3
  18. package/plugins/opencode/skills/delphi-review/SKILL.md +24 -4
  19. package/plugins/opencode/skills/sprint-flow/AGENTS.md +3 -3
  20. package/plugins/opencode/skills/sprint-flow/SKILL.md +20 -5
  21. package/plugins/opencode/skills/sprint-flow/references/orchestration-rules.md +11 -16
  22. package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +3 -3
  23. package/plugins/qoder/agents/delphi-architecture.md +48 -0
  24. package/plugins/qoder/agents/delphi-feasibility.md +48 -0
  25. package/plugins/qoder/agents/delphi-technical.md +48 -0
  26. package/plugins/qoder/plugin.json +1 -1
  27. package/plugins/qoder/skills/delphi-review/AGENTS.md +3 -3
  28. package/plugins/qoder/skills/delphi-review/SKILL.md +276 -167
  29. package/plugins/qoder/skills/sprint-flow/AGENTS.md +3 -3
  30. package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +3 -3
  31. package/principles/AGENTS.md +3 -3
  32. package/scripts/delphi-external-review.cjs +15 -1
  33. package/skills/delphi-review/AGENTS.md +3 -3
  34. package/skills/delphi-review/SKILL.md +24 -4
  35. package/skills/sprint-flow/AGENTS.md +3 -3
  36. package/skills/sprint-flow/SKILL.md +20 -5
  37. package/skills/sprint-flow/references/orchestration-rules.md +11 -16
  38. package/skills/test-specification-alignment/AGENTS.md +3 -3
@@ -1,7 +1,167 @@
1
1
  ---
2
2
  name: delphi-review
3
- description: "Use when asked to review a design, plan, or architecture; before implementation starts; or when multi-expert consensus is needed. See ## Triggers for trigger phrases."
3
+ version: 1.1.0
4
+ description: >
5
+ Performs multi-round anonymous expert consensus review using the Delphi method. Supports
6
+ design review (default) and code-walkthrough (--mode code-walkthrough) modes. Uses 2-3 experts
7
+ from at least 2 different domestic model providers with a >=90% statistical consensus threshold.
8
+ Outputs structured verdict (APPROVED/PASS_WITH_CAVEATS/REQUEST_CHANGES/BLOCKED).
9
+
10
+ WHAT: Anonymous multi-expert review with iterative consensus building for designs, plans,
11
+ architecture, code changes, and PRs. NOT a single-reviewer pass, NOT a linter, NOT a test runner.
12
+ WHEN: User explicitly requests a review, design validation, multi-expert consensus, code walkthrough
13
+ before push, architecture evaluation, or "/delphi-review".
14
+ NOT WHEN: Asking HOW to review something (educational), mentioning "review" in passing without intent,
15
+ requesting a simple code check or lint, asking about the Delphi process itself, or mentioning
16
+ "review" as part of a different workflow (e.g., "code review" without multi-expert intent),
17
+ asking for review guidelines/checklists/formats, individual peer review, or casual review requests.
18
+
19
+ TRIGGERS: "/delphi-review", "review this design", "评审这个需求", "评审这个设计", "design review",
20
+ "多专家评审", "consensus review", "code walkthrough", "push review", "architecture review",
21
+ "delphi review", "run delphi", "start delphi", "评审这个架构", "review this architecture",
22
+ "评审PR", "review this PR with delphi", "delphi评审", "delphi 评审", "run delphi review",
23
+ "执行delphi", "启动delphi评审".
24
+ NEGATIVE TRIGGERS: "how does delphi work", "what is delphi review", "code review checklist",
25
+ "review my code quickly", "can you review this", "peer review", "I need a review",
26
+ "explain the review process", "review guidelines", "how to review a design",
27
+ "code review template", "review format", "PR review", "帮我review一下",
28
+ "just review this", "quick review", "review steps".
29
+ maturity: beta
4
30
  auto_continue: true
31
+ triggers:
32
+ - "/delphi-review"
33
+ - "review this design"
34
+ - "评审这个需求"
35
+ - "评审这个设计"
36
+ - "design review"
37
+ - "多专家评审"
38
+ - "consensus review"
39
+ - "code walkthrough"
40
+ - "push review"
41
+ - "architecture review"
42
+ - "delphi review"
43
+ - "run delphi"
44
+ - "start delphi"
45
+ - "评审这个架构"
46
+ - "review this architecture"
47
+ - "评审PR"
48
+ - "review this PR with delphi"
49
+ - "delphi评审"
50
+ - "delphi 评审"
51
+ - "run delphi review"
52
+ - "执行delphi"
53
+ - "启动delphi评审"
54
+ triggers_negative_examples:
55
+ - "how does delphi work" # educational question about the process
56
+ - "what is delphi review" # asking for explanation, not execution
57
+ - "code review checklist" # asking for a checklist, not running review
58
+ - "review my code quickly" # single-pass quick review, not Delphi multi-round
59
+ - "can you review this" # ambiguous — could be casual peer review
60
+ - "peer review" # different process from Delphi
61
+ - "I need a review" # too vague, casual request
62
+ - "explain the review process" # educational, not executional
63
+ - "review guidelines" # asking about guidelines, not executing
64
+ - "how to review a design" # educational
65
+ - "PR review" # single-reviewer PR check, not multi-expert Delphi
66
+ - "review my PR" # informal PR review request, not Delphi
67
+ - "帮我review一下" # casual Chinese review request, no multi-expert intent
68
+ - "just review this" # casual, single-pass review request
69
+ - "quick review" # explicitly contradicts multi-round Delphi process
70
+ - "review steps" # asking for review instructions, not running review
71
+ - "code review template" # asking for a template, not executing review
72
+ - "review format" # asking about format, not executing
73
+ - "show me how to review" # educational request about reviewing
74
+ - "review checklist example" # asking for examples, not running review
75
+ triggers_negative_test_cases:
76
+ - input: "how does delphi work"
77
+ expect: "NOT triggered"
78
+ - input: "code review checklist"
79
+ expect: "NOT triggered"
80
+ - input: "review my code quickly"
81
+ expect: "NOT triggered"
82
+ - input: "can you review this"
83
+ expect: "NOT triggered"
84
+ - input: "peer review"
85
+ expect: "NOT triggered"
86
+ - input: "I need a review"
87
+ expect: "NOT triggered"
88
+ - input: "explain the review process"
89
+ expect: "NOT triggered"
90
+ - input: "review guidelines"
91
+ expect: "NOT triggered"
92
+ - input: "/delphi-review"
93
+ expect: "triggered"
94
+ - input: "review this design"
95
+ expect: "triggered"
96
+ - input: "评审这个需求"
97
+ expect: "triggered"
98
+ - input: "评审这个设计"
99
+ expect: "triggered"
100
+ - input: "design review"
101
+ expect: "triggered"
102
+ - input: "多专家评审"
103
+ expect: "triggered"
104
+ - input: "consensus review"
105
+ expect: "triggered"
106
+ - input: "code walkthrough"
107
+ expect: "triggered"
108
+ - input: "architecture review"
109
+ expect: "triggered"
110
+ - input: "delphi review"
111
+ expect: "triggered"
112
+ - input: "评审这个架构"
113
+ expect: "triggered"
114
+ - input: "delphi 评审"
115
+ expect: "triggered"
116
+ - input: "run delphi review"
117
+ expect: "triggered"
118
+ - input: "review my PR"
119
+ expect: "NOT triggered"
120
+ - input: "帮我review一下"
121
+ expect: "NOT triggered"
122
+ - input: "just review this"
123
+ expect: "NOT triggered"
124
+ - input: "quick review"
125
+ expect: "NOT triggered"
126
+ - input: "review steps"
127
+ expect: "NOT triggered"
128
+ - input: "code review template"
129
+ expect: "NOT triggered"
130
+ - input: "run delphi"
131
+ expect: "triggered"
132
+ workflow_steps:
133
+ - "Step 0: Input Validation → Output: [DelphiReview] or [DelphiReview:BLOCKED]"
134
+ - "Round 1: Anonymous Independent Review → Output: [DelphiReview Round 1] expert JSON verdicts"
135
+ - "Consensus Check → Output: consensus_ratio, verdict summary"
136
+ - "Round 2: Exchange Opinions (if needed) → Output: [DelphiReview Round 2] revised verdicts"
137
+ - "Round 3: Final Positions (if needed) → Output: [DelphiReview Round 3] final verdicts"
138
+ - "Fix & Re-Review (if REQUEST_CHANGES) → restart from Round 2"
139
+ - "Generate Output: consensus report + specification.yaml (design) or .code-walkthrough-result.json (walkthrough)"
140
+ hooks:
141
+ security:
142
+ - "/careful": "Safety guardrails for destructive commands — ensure review is read-only"
143
+ - "/freeze": "Restrict edits to review scope — prevent accidental changes during review"
144
+ - "/guard": "Full safety mode combining careful + freeze for maximum protection"
145
+ operational:
146
+ - "/context-save": "Save review context before pause or handoff"
147
+ - "/context-restore": "Restore review context on resume"
148
+ tools_allowed:
149
+ - "Read" # read design docs, code, configs, specification.yaml
150
+ - "Glob" # find files by pattern
151
+ - "Grep" # search code content
152
+ - "Bash" # read-only: git diff, git log, file stats
153
+ - "Task(subagent_type=oracle)" # dispatch oracle for deep analysis
154
+ - "Task(subagent_type=delphi-reviewer-architecture)" # dispatch architecture expert
155
+ - "Task(subagent_type=delphi-reviewer-technical)" # dispatch technical expert
156
+ - "Task(subagent_type=delphi-reviewer-feasibility)" # dispatch feasibility expert
157
+ - "Write(specification.yaml, .code-walkthrough-result.json, delphi-reviewed.json)" # write output artifacts only
158
+ - "Skill" # invoke related skills for context
159
+ - "Question" # ask user at decision points
160
+ tools_denied:
161
+ - "Edit(source code)" # NEVER edit implementation code during review
162
+ - "Write(source code)" # NEVER write implementation code
163
+ - "Bash(git commit, git push)" # NEVER commit or push during review
164
+ - "Task(category=*, subagent_type=build)" # NEVER delegate build/implementation
5
165
  ---
6
166
 
7
167
  # Delphi Consensus Review
@@ -31,27 +191,73 @@ auto_continue: true
31
191
  - code walkthrough
32
192
  - push review
33
193
  - architecture review
34
- - PR review
194
+ - delphi review
195
+ - run delphi
196
+ - start delphi
197
+ - 评审这个架构
198
+ - review this architecture
199
+ - 评审PR
200
+ - review this PR with delphi
201
+ - delphi评审
202
+ - delphi 评审
203
+ - run delphi review
204
+ - 执行delphi
205
+ - 启动delphi评审
206
+
207
+ **NOT triggered by:**
208
+ - "how does delphi work" (educational)
209
+ - "code review checklist" (asking for a list)
210
+ - "review my code quickly" (single-pass, not multi-expert)
211
+ - "can you review this" (ambiguous casual review)
212
+ - "peer review" (different process)
213
+ - "I need a review" (too vague)
214
+ - "explain the review process" (educational)
215
+ - "review guidelines" (asking about guidelines)
216
+ - "PR review" (single-reviewer PR check)
217
+ - "review my PR" (informal PR review)
218
+ - "帮我review一下" (casual Chinese request)
219
+ - "just review this" (casual single-pass)
220
+ - "quick review" (contradicts multi-round process)
221
+ - "review steps" (asking for instructions)
222
+ - "code review template" (asking for template)
223
+ - "review format" (asking about format)
224
+ - "show me how to review" (educational)
225
+
226
+ ## Workflow
227
+
228
+ 1. **Step 0: Input Validation** — Check input contains reviewable content (design doc/code/spec/diff). Empty input → `[DelphiReview:BLOCKED]`.
229
+ 2. **Round 1: Anonymous Independent Review** — Experts review without seeing each other's opinions. Output individual verdict JSON.
230
+ 3. **Consensus Check** — Consensus >=90% AND all APPROVED → complete.
231
+ 4. **Round 2: Exchange Opinions** — Experts see others' opinions, re-evaluate.
232
+ 5. **Round 3: Final Positions** — Final stance, output disagreements if any.
233
+ 6. **Fix & Re-Review** — REQUEST_CHANGES → fix Critical+Major → restart from Round 2.
234
+ 7. **Generate Output** — Consensus report + specification.yaml (design) or `.code-walkthrough-result.json` (walkthrough) + `delphi-reviewed.json`.
235
+
236
+ ## Activation (MANDATORY for L1 Trigger Detection)
237
+
238
+ Every delphi-review response MUST begin with an activation marker as the first line:
239
+
240
+ | Marker | Meaning |
241
+ |--------|---------|
242
+ | `[DelphiReview]` | Standard entry — review proceeding |
243
+ | `[DelphiReview:BLOCKED]` | Step 0 input validation failure |
244
+ | `[DelphiReview:WARNING]` | Red flag detected (reserved) |
245
+
246
+ ## Round Markers (MANDATORY for L3 Step Adherence)
247
+
248
+ Each round MUST output a structured round marker:
35
249
 
36
- ## 工作流程
37
-
38
- 1. Input Validation: 检查输入是否包含可评审内容(设计文档/代码/spec),空输入阻断
39
- 2. Expert Assignment: 分配 2-3 位专家,至少来自 2 家不同厂商(国产模型)
40
- 3. Round 1: 匿名独立评审 — 各专家互不知对方意见,独立输出 verdict JSON
41
- 4. Consensus Check: 共识检查 — 共识 ≥90% 且全部 APPROVED 则完成
42
- 5. Round 2: 交换意见 — 未达成共识时,专家查看他人意见后重新评审
43
- 6. Round 3: 最终立场 — 仍未达成共识时,输出最终立场和分歧点
44
- 7. Fix & Re-Review: REQUEST_CHANGES → 修复 Critical+Major → 从 Round 2 重新评审
45
- 8. Generate Output: 生成共识报告 + specification.yaml + delphi-reviewed.json
46
-
47
- ## Activation
48
- **MANDATORY**: Every delphi-review response MUST begin with `[DelphiReview]` as the first line.
49
- This marker is required for skill-cert L1 trigger detection.
250
+ ```
251
+ [DelphiReview Round 1] Anonymous Independent Review
252
+ [DelphiReview Round 2] Exchange Opinions
253
+ [DelphiReview Round 3] Final Positions
254
+ ```
50
255
 
51
- Permitted variants (all satisfy L1 trigger):
52
- - `[DelphiReview]` — standard entry
53
- - `[DelphiReview:BLOCKED]` — Step 0 input validation failure
54
- - `[DelphiReview:WARNING]` — red flag detected (reserved)
256
+ **Rules**:
257
+ - Every round marker MUST appear as a separate, identifiable line
258
+ - Round numbering MUST be sequential (1, 2, 3)
259
+ - After each round, output consensus summary: `consensus_ratio=N/N`, `verdict_status: converging | stable | diverging`
260
+ - Final round MUST output verdict: `APPROVED | PASS_WITH_CAVEATS | REQUEST_CHANGES | PROCESS_BLOCK`
55
261
 
56
262
  ## 核心原则
57
263
 
@@ -88,44 +294,34 @@ Permitted variants (all satisfy L1 trigger):
88
294
  | 2 专家(默认) | A(架构) + B(实现) | 代码变更、小型设计 |
89
295
  | 3 专家 | A(架构) + B(实现) + C(可行性) | 架构决策、需求文档 |
90
296
 
91
- ### 模型选择策略(Qoder — 从 .delphi-config.json 读取 + 外部 API 调用)
297
+ ### 模型选择策略(强制 — 平台适配)
92
298
 
93
- **MUST 从 `.delphi-config.json` 读取 API 配置**,通过 Bash 工具调用 `delphi-external-review.cjs` 脚本实现真正的跨模型评审。
299
+ **关键原则**:
300
+ - ✅ 三个专家必须来自 **至少 2 家不同 provider**
301
+ - ❌ 禁止 hardcode 模型名称
302
+ - ❌ 禁止三个专家全部使用同一 provider 的模型
303
+ - ❌ 禁止使用 Anthropic/OpenAI/Google 等国外模型
94
304
 
95
- **配置定位优先级**:
96
- 1. 当前项目 `skills/delphi-review/.delphi-config.json`(Qoder 已安装 skill)
97
- 2. `~/.qoder/skills/delphi-review/.delphi-config.json`(全局安装)
305
+ #### Qoder 平台(推荐 — Custom Agent 模式)
98
306
 
99
- **脚本定位优先级**:
100
- 1. `node_modules/@boyingliu01/xp-gate/scripts/delphi-external-review.cjs`(npm 安装后)
101
- 2. `$(npm root -g)/@boyingliu01/xp-gate/scripts/delphi-external-review.cjs`(全局安装)
102
- 3. xp-gate 仓库中的 `scripts/delphi-external-review.cjs`(开发环境)
307
+ Qoder 环境下使用 **Custom Agent** 机制,每个专家是一个独立的 custom agent,配置不同的 Qoder 内置模型:
103
308
 
104
- **关键原则**:
105
- - ✅ 三个专家必须来自 **至少 2 家不同 provider**(按 `base_url` 判断)
106
- - ✅ 支持混合模式:`provider: "local"` 表示由 Orchestrator 自身模型扮演
107
- - ❌ 禁止三个专家全部使用同一 provider 的模型(除非使用混合模式)
309
+ | 专家 | Agent 文件 | 模型 | Credits 费率 |
310
+ |------|-----------|------|-------------|
311
+ | Architecture (A) | `.qoder/agents/delphi-architecture.md` | Qwen3.7-Max | 0.5× |
312
+ | Technical (B) | `.qoder/agents/delphi-technical.md` | GLM-5.2 | 0.6× |
313
+ | Feasibility (C) | `.qoder/agents/delphi-feasibility.md` | DeepSeek-V4-Pro | 0.5× |
108
314
 
109
- **配置示例**(参考 `.delphi-config.json.example`):
110
- ```json
111
- {
112
- "active_profile": "default",
113
- "profiles": {
114
- "default": {
115
- "providers": {
116
- "deepseek": { "base_url": "https://api.deepseek.com/v1", "api_key": "sk-xxx" },
117
- "zhipu": { "base_url": "https://open.bigmodel.cn/api/paas/v4", "api_key": "yyy" }
118
- },
119
- "experts": {
120
- "architecture": { "provider": "deepseek", "model": "deepseek-chat" },
121
- "technical": { "provider": "zhipu", "model": "glm-5.2" },
122
- "feasibility": { "provider": "local" }
123
- }
124
- }
125
- }
126
- }
127
- ```
128
- > 上例中 2 个外部 provider(deepseek + zhipu)+ 1 个 local fallback,满足跨 provider 要求。
315
+ **执行方式**:通过 Agent tool 并行启动 3 个 subagent(type=GeneralPurpose),每个 agent 使用自己配置的模型独立评审,主 orchestrator 收集结果后计算共识。
316
+
317
+ **优势**:无需外部 API key,直接使用 Qoder Credits,模型由平台统一管理。
318
+
319
+ #### OpenCode 平台(External API 模式)
320
+
321
+ OpenCode 环境下通过 `opencode.json` 的 agent 配置 + `.delphi-config.json` 调用外部 API:
322
+ - **MUST 从 `opencode.json` 的 agent 配置中读取模型**
323
+ - 通过 `scripts/delphi-external-review.cjs` 调用各 provider 的 OpenAI 兼容 API
324
+ - 需要用户自行配置 API key(环境变量注入)
129
325
 
130
326
  ### 共识阈值
131
327
 
@@ -166,84 +362,14 @@ Phase 0: 准备 → Round 1: 匿名独立评审 → 共识检查
166
362
 
167
363
  1. **有完整输入** → 直接进入 Phase 0(准备阶段),开始 Round 1
168
364
  2. **有部分输入**(占位符、描述性文本)→ 按输入内容执行评审,标注 `[INPUT: PARTIAL]`,但继续执行
169
- 3. **无输入**(仅触发词,无文档/代码)→ 输出以下阻断响应,记入步骤完成:
170
-
171
- **Detection heuristics for Step 0**:
172
- - **Complete**: Contains ≥1 structural element (e.g., `##`, `requirement`, `AC-`, `function`, `class`, `interface`, YAML frontmatter, code block with language tag) AND ≥50 non-whitespace characters of actual content (not placeholder brackets like `[...]`, `{...}`, `<insert here>`).
173
- - **Partial**: Contains descriptive text referencing a design/code artifact BUT lacks substantive structure (e.g., "I need to review my login module" with no actual code/design attached), OR contains obvious placeholders like `[...]`, `(content)`, `<insert here>`, `TODO`.
174
- - **None**: Only trigger words (`/delphi-review`, "review this") with zero additional content, OR content that is exclusively questions about the review process itself ("how does delphi work?").
175
-
176
- **Partial input constraint**: When input is PARTIAL, cap review to 1 round with `confidence=low` annotation. Do NOT proceed with full multi-round review on insufficient input.
177
-
178
- **File path validation**: If user provides a file path (e.g., `--spec specification.yaml`):
179
- - Verify the file exists and is non-empty
180
- - If path is invalid → output: `[DelphiReview:BLOCKED] File not found: [path]. Please verify the path.`
181
- - If file is empty → output: `[DelphiReview:BLOCKED] File is empty: [path]. Please provide valid content.`
182
-
183
- ```
184
- [DelphiReview:BLOCKED] 需要设计文档或代码内容才能启动评审。
185
-
186
- 请提供以下之一:
187
- - 设计文档(design doc / specification)
188
- - 代码变更(code diff / PR link)
189
- - specification.yaml 文件路径
190
- - 架构设计说明
191
-
192
- 评审输入示例:
193
- /delphi-review "Design Doc: [your content here]"
194
- /delphi-review --spec specification.yaml
195
- /delphi-review --mode code-walkthrough
196
- REMAINING STEPS: N/A (input validation failed)
197
- ```
198
-
199
- 在此状态下,BLOCKED 视为步骤已完成(后续步骤标记为 N/A)。
200
-
201
- **重要**: 内嵌在 prompt 中的文档内容(如 "Design Doc: [content]"或代码片段)应视为"有完整输入",直接进入评审。
365
+ 3. **无输入**(仅触发词,无文档/代码)→ 输出阻断响应
202
366
 
203
- **执行方式(Qoder)**:
204
- 1. 将评审内容写入临时文件(使用 `os.tmpdir()` 确保跨平台)
205
- 2. 通过 Bash 工具并行调用 3 个 `delphi-external-review.cjs` 脚本
206
- 3. 对 `fallback: true` 的专家,Orchestrator 自身模型扮演该角色
207
- 4. 收集 verdict JSON,计算共识度,决定是否需要下一轮
367
+ **Detection heuristics**:
368
+ - **Complete**: >=1 structural element (##, requirement, AC-, function, class, interface, YAML frontmatter, code block) AND >=50 non-whitespace chars.
369
+ - **Partial**: Descriptive text referencing a design/code artifact BUT lacks structure, OR contains placeholders.
370
+ - **None**: Only trigger words with zero additional content, OR questions about the review process itself.
208
371
 
209
- **Round 模板**(匿名评审/交换意见/最终立场/修复报告格式)→ 详见 `references/round-templates.md`
210
-
211
- **Orchestrator 自动调度规则**(#218 subagent 内部自动多轮循环)→ 详见 `references/orchestrator-dispatch.md`
212
-
213
- **Automatic re-review**: 对于常见可控问题(措辞模糊、AC 缺失、格式问题),应自行修复后自动重评审,无需等待用户。
214
-
215
- ### ⭐ 自动延续规则(MANDATORY — 防止流程卡住)
216
-
217
- 当 Delphi Review 启动多轮评审(Round 2+)时,**orchestrator 必须自动延续流程,不得等待用户输入**。
218
-
219
- **触发条件**:
220
- - Round N 完成,但未达到终止条件(100% approved + ≥90% consensus + 所有 Critical/Major 已处理)
221
- - 存在待处理的背景任务(subagent dispatched tasks)
222
-
223
- **自动延续动作**:
224
- 1. **收集背景任务结果**:等待 `<system-reminder>` 通知后,立即调用 `background_output(task_id="bg_...")` 获取所有 subagent 输出
225
- 2. **合成 Round N 总结**:汇总专家意见、共识度、待处理问题
226
- 3. **自动启动 Round N+1**:立即 dispatch 新一轮 subagent 任务,携带上一轮总结作为上下文
227
- 4. **循环直至终止**:重复步骤 1-3,直到达到终止条件
228
-
229
- **终止条件**(满足全部):
230
- - ✅ 所有专家状态 = APPROVED
231
- - ✅ 共识度 ≥ 90%
232
- - ✅ 所有 Critical 级别问题已解决
233
- - ✅ 所有 Major 级别问题已处理(或已记录为已知问题)
234
-
235
- **例外情况**(直接输出,不进入下一轮):
236
- - Round 1 即达到 100% approved + 100% consensus → 直接输出最终报告
237
- - 已达最大轮数(5 轮)→ 输出"未达成共识"报告,标记为 PROCESS_BLOCK
238
-
239
- **禁止行为**:
240
- - ❌ 询问用户"要继续吗?"
241
- - ❌ 等待用户手动触发 Round N+1
242
- - ❌ 在未达到终止条件时停止流程
243
-
244
- **错误处理**:
245
- - 背景任务超时(>10min)→ 标记为 TIMEOUT,输出部分结果并终止
246
- - 背景任务失败(subagent 错误)→ 重试 1 次,仍失败则输出错误报告并终止
372
+ **Partial input constraint**: Cap review to 1 round with `confidence=low` annotation.
247
373
 
248
374
  ---
249
375
 
@@ -265,24 +391,12 @@ REMAINING STEPS: N/A (input validation failed)
265
391
 
266
392
  ---
267
393
 
268
- ## Output Format (MANDATORY)
269
-
270
- **Single 模式简化输出**: 当 single reviewer 模式(非 Multi-Expert)时,可使用简化输出格式:
271
- - verdict + confidence + issues_list(合并 critical/major/minor)+ summary
272
- - 完整 JSON 格式保留用于 multi-expert 多轮评审场景
273
-
274
- **Single 模式简化模板**:
275
- ```
276
- [DelphiReview] verdict=APPROVED | REQUEST_CHANGES | BLOCKED
277
- confidence=N/10
278
- issues=[critical: N, major: N, minor: N]
279
- summary: [1-2 sentence verdict summary]
280
- ```
394
+ ## Output Format (MANDATORY for L3)
281
395
 
282
396
  **⚠️ Single vs Multi-Expert Output**:
283
- - **Multi-Expert Mode (default)**: MUST use the full JSON schema below. Each expert outputs independently; the orchestrator aggregates into `consensus_report`. DO NOT use the simplified template.
284
- - **Single Reviewer Mode** (explicitly invoked with `--single`): MAY use the simplified text template above.
285
- - **Never mix formats**. If you are one of multiple experts in the same round, output JSON only.
397
+ - **Multi-Expert Mode (default)**: MUST use the full JSON schema below. Each expert outputs independently; the orchestrator aggregates into `consensus_report`.
398
+ - **Single Reviewer Mode** (explicit `--single`): MAY use simplified text template: `[DelphiReview] verdict=APPROVED|REQUEST_CHANGES|BLOCKED confidence=N/10 issues=[critical:N, major:N, minor:N] summary: [1-2 sentences]`.
399
+ - **Never mix formats**.
286
400
 
287
401
  ```json
288
402
  {
@@ -321,12 +435,10 @@ summary: [1-2 sentence verdict summary]
321
435
  - [ ] 最终裁决是 **APPROVED** 或 **APPROVED_WITH_MINOR**
322
436
  - [ ] 共识报告生成并保存
323
437
  - [ ] IF REQUEST_CHANGES → 已修复 → 已重新评审 → APPROVED
324
- - [ ] ⭐ **IF APPROVED (design mode): 生成 specification.yaml**(自动或用户确认后)
325
- - [ ] ⭐ **状态文件**: 写入 `.sprint-state/delphi-reviewed.json`(`verdict`, `consensus_ratio`, `timestamp`)
326
- - [ ] **Code-walkthrough mode**: 写入 `.code-walkthrough-result.json`(commit hash 匹配 HEAD)
438
+ - [ ] ⭐ **IF APPROVED (design mode): 生成 specification.yaml**
439
+ - [ ] ⭐ **状态文件**: 写入 `.sprint-state/delphi-reviewed.json`
327
440
 
328
441
  **IF REQUEST_CHANGES/REJECTED → CANNOT claim complete**
329
- **IF 任何条件未满足 → MUST BLOCK**
330
442
 
331
443
  ### 状态文件格式
332
444
 
@@ -340,8 +452,6 @@ summary: [1-2 sentence verdict summary]
340
452
  {"mode":"code-walkthrough","commit":"abc123...","timestamp":"...","verdict":"APPROVED","consensus_ratio":1.0}
341
453
  ```
342
454
 
343
- > Phase 2 BUILD 入口检查 (DELPHI-GATE) 读取此文件。`verdict != "APPROVED"` → 禁止编码。
344
-
345
455
  ---
346
456
 
347
457
  ## Anti-Patterns
@@ -362,24 +472,13 @@ summary: [1-2 sentence verdict summary]
362
472
 
363
473
  ## Red Flags
364
474
 
365
- ### 检测触发器(模型可执行检测)
366
-
367
475
  | 用户输入模式 | 触发词 | 响应动作 |
368
476
  |-------------|--------|---------|
369
- | 要求跳过评审 | "skip review", "不用评审", "跳过评审", "直接提交", "不评审" | → 提醒: `[DelphiReview] 评审是投资而非开销。Delphi 设计要求多轮共识(>=90%),不可快速跳过。` |
370
- | 时间压力 | "来不及", "时间紧", "emergency", "赶时间", "deadline" | → 提醒: `[DelphiReview] 时间紧迫正是需要评审的时刻。跳过评审省 30 分钟,后期修复可能花 3 天。` |
371
- | 提前终止 | Round 1 后用户说 "可以了", "够了", "enough" | → BLOCK: `[DelphiReview:BLOCKED] 评审未达终止条件。仍需 [共识>=90% + 所有 Critical/Major 已处理]。` |
372
- | 单专家自评 | 用户仅指定 1 个专家 或 说 "我自己看了" | → 提醒: `[DelphiReview] 至少需要 2 位不同 provider 的专家参与评审。` |
373
- | 无文档输入 | 仅触发词,无设计/代码内容 | → 输出 `[DelphiReview:BLOCKED]` 阻断响应(见 Step 0) |
374
-
375
- ### 原则性声明
376
-
377
- | 借口 | 现实 |
378
- |------|------|
379
- | "这只是小变更" | 所有变更都需要评审 |
380
- | "Round 1 就够了" | 不够,必须多轮直到共识 |
381
- | "生成报告就完成了" | APPROVED 才算完成 |
382
- | "2/3 同意就是共识" | 还要检查问题共识比例 >=90% |
477
+ | 要求跳过评审 | "skip review", "不用评审", "跳过评审" | → 提醒评审是投资而非开销 |
478
+ | 时间压力 | "来不及", "时间紧", "emergency" | → 提醒时间紧迫正是需要评审的时刻 |
479
+ | 提前终止 | Round 1 后用户说 "可以了", "够了" | → BLOCK: 评审未达终止条件 |
480
+ | 单专家自评 | 用户仅指定 1 个专家 | → 提醒至少需要 2 位专家 |
481
+ | 无文档输入 | 仅触发词,无设计/代码内容 | → `[DelphiReview:BLOCKED]` |
383
482
 
384
483
  ---
385
484
 
@@ -392,3 +491,13 @@ summary: [1-2 sentence verdict summary]
392
491
  5. ✅ 状态文件已写入
393
492
 
394
493
  **缺少任何一项 = 未完成**
494
+
495
+ ## References
496
+
497
+ > **Path convention**: `@references/` resolves relative to the skill directory (`skills/delphi-review/`).
498
+
499
+ | File | Content |
500
+ |------|---------|
501
+ | `@references/code-walkthrough.md` | Code-walkthrough mode specification |
502
+ | `@references/orchestrator-dispatch.md` | Orchestrator auto-dispatch rules (#218 subagent multi-round loop) |
503
+ | `@references/round-templates.md` | Round templates (anonymous/exchange/final/fix report formats) |
@@ -1,9 +1,9 @@
1
1
  # SKILLS/SPRINT-FLOW KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-07-21
4
- **Commit:** 03e9223
3
+ **Generated:** 2026-07-22
4
+ **Commit:** 97dd89a
5
5
  **Branch:** main
6
- **Version:** 0.14.23.0
6
+ **Version:** 0.14.25.0
7
7
 
8
8
  ## OVERVIEW
9
9
  **6-phase** development pipeline (v2.0 compact redesign, Issue #290): PREP → DESIGN → BUILD → VERIFY → SHIP → CLOSE. Phase 3/6 BUILD default build mode is **ralph-loop** (REQ-level iteration, 40-67% token savings vs parallel). HARD-GATE between DESIGN (2/6) and BUILD (3/6): design must pass Delphi review (≥90% consensus) before any coding.
@@ -1,9 +1,9 @@
1
1
  # SKILLS/TEST-SPECIFICATION-ALIGNMENT KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-07-21
4
- **Commit:** 03e9223
3
+ **Generated:** 2026-07-22
4
+ **Commit:** 97dd89a
5
5
  **Branch:** main
6
- **Version:** 0.14.23.0
6
+ **Version:** 0.14.25.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
@@ -1,9 +1,9 @@
1
1
  # PRINCIPLES CHECKER MODULE
2
2
 
3
- **Generated:** 2026-07-21
4
- **Commit:** 03e9223
3
+ **Generated:** 2026-07-22
4
+ **Commit:** 97dd89a
5
5
  **Branch:** main
6
- **Version:** 0.14.23.0
6
+ **Version:** 0.14.25.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Clean Code & SOLID principles checker — **Gate 4** of pre-commit. 14 rules × 9 language adapters, SARIF 2.1.0 output. Houses the **Boy Scout Rule** enforcement engine (Gate 6) and warning-baseline storage.
@@ -95,9 +95,23 @@ function readConfig(configPath, profileOverride) {
95
95
  process.exit(1);
96
96
  }
97
97
 
98
+ // Resolve ${ENV_VAR} references in provider api_key fields
99
+ const providers = profile.providers || {};
100
+ for (const [name, prov] of Object.entries(providers)) {
101
+ if (prov.api_key && prov.api_key.startsWith('${') && prov.api_key.endsWith('}')) {
102
+ const envName = prov.api_key.slice(2, -1);
103
+ const envVal = process.env[envName];
104
+ if (envVal) {
105
+ prov.api_key = envVal;
106
+ } else {
107
+ console.error(`[delphi-review] WARNING: Environment variable ${envName} not set (provider: ${name}). API calls will fail.`);
108
+ }
109
+ }
110
+ }
111
+
98
112
  return {
99
113
  active_profile: profileName,
100
- providers: profile.providers || {},
114
+ providers,
101
115
  experts: profile.experts || {},
102
116
  consensus: raw.consensus || { threshold_percent: 90, max_review_rounds: 5 },
103
117
  };
@@ -1,9 +1,9 @@
1
1
  # SKILLS/DELPHI-REVIEW KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-07-21
4
- **Commit:** 03e9223
3
+ **Generated:** 2026-07-22
4
+ **Commit:** 97dd89a
5
5
  **Branch:** main
6
- **Version:** 0.14.23.0
6
+ **Version:** 0.14.25.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Delphi Consensus Review — multi-round anonymous expert review (≥90% threshold, 3 experts from ≥2 providers, domestic models only). Supports design + code-walkthrough modes.
@@ -294,14 +294,34 @@ Each round MUST output a structured round marker:
294
294
  | 2 专家(默认) | A(架构) + B(实现) | 代码变更、小型设计 |
295
295
  | 3 专家 | A(架构) + B(实现) + C(可行性) | 架构决策、需求文档 |
296
296
 
297
- ### 模型选择策略(强制 — 从 opencode.json 读取)
298
-
299
- **MUST 从 `opencode.json` 的 agent 配置中读取模型**,**严禁** hardcode 模型名称。
297
+ ### 模型选择策略(强制 — 平台适配)
300
298
 
301
299
  **关键原则**:
302
300
  - ✅ 三个专家必须来自 **至少 2 家不同 provider**
303
- - ❌ 禁止 hardcode 模型名称(模型列表以 `opencode.json` 为准)
301
+ - ❌ 禁止 hardcode 模型名称
304
302
  - ❌ 禁止三个专家全部使用同一 provider 的模型
303
+ - ❌ 禁止使用 Anthropic/OpenAI/Google 等国外模型
304
+
305
+ #### Qoder 平台(推荐 — Custom Agent 模式)
306
+
307
+ Qoder 环境下使用 **Custom Agent** 机制,每个专家是一个独立的 custom agent,配置不同的 Qoder 内置模型:
308
+
309
+ | 专家 | Agent 文件 | 模型 | Credits 费率 |
310
+ |------|-----------|------|-------------|
311
+ | Architecture (A) | `.qoder/agents/delphi-architecture.md` | Qwen3.7-Max | 0.5× |
312
+ | Technical (B) | `.qoder/agents/delphi-technical.md` | GLM-5.2 | 0.6× |
313
+ | Feasibility (C) | `.qoder/agents/delphi-feasibility.md` | DeepSeek-V4-Pro | 0.5× |
314
+
315
+ **执行方式**:通过 Agent tool 并行启动 3 个 subagent(type=GeneralPurpose),每个 agent 使用自己配置的模型独立评审,主 orchestrator 收集结果后计算共识。
316
+
317
+ **优势**:无需外部 API key,直接使用 Qoder Credits,模型由平台统一管理。
318
+
319
+ #### OpenCode 平台(External API 模式)
320
+
321
+ OpenCode 环境下通过 `opencode.json` 的 agent 配置 + `.delphi-config.json` 调用外部 API:
322
+ - **MUST 从 `opencode.json` 的 agent 配置中读取模型**
323
+ - 通过 `scripts/delphi-external-review.cjs` 调用各 provider 的 OpenAI 兼容 API
324
+ - 需要用户自行配置 API key(环境变量注入)
305
325
 
306
326
  ### 共识阈值
307
327
 
@@ -1,9 +1,9 @@
1
1
  # SKILLS/SPRINT-FLOW KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-07-21
4
- **Commit:** 03e9223
3
+ **Generated:** 2026-07-22
4
+ **Commit:** 97dd89a
5
5
  **Branch:** main
6
- **Version:** 0.14.23.0
6
+ **Version:** 0.14.25.0
7
7
 
8
8
  ## OVERVIEW
9
9
  **6-phase** development pipeline (v2.0 compact redesign, Issue #290): PREP → DESIGN → BUILD → VERIFY → SHIP → CLOSE. Phase 3/6 BUILD default build mode is **ralph-loop** (REQ-level iteration, 40-67% token savings vs parallel). HARD-GATE between DESIGN (2/6) and BUILD (3/6): design must pass Delphi review (≥90% consensus) before any coding.