@boyingliu01/xp-gate 0.15.4 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/bin/xp-gate.js +29 -1
  2. package/hooks/lib/now-ms.sh +33 -0
  3. package/hooks/pre-commit +63 -47
  4. package/hooks/sprint-gate.sh +291 -0
  5. package/lib/__tests__/check-version.test.js +122 -0
  6. package/lib/__tests__/doctor.test.js +13 -15
  7. package/lib/__tests__/gate-audit.test.ts +38 -0
  8. package/lib/__tests__/phase-transition.test.js +241 -1
  9. package/lib/__tests__/retro.test.js +131 -0
  10. package/lib/__tests__/sprint-status-rework.test.js +184 -0
  11. package/lib/check-version.js +9 -0
  12. package/lib/doctor-tui.js +79 -9
  13. package/lib/doctor.js +15 -3
  14. package/lib/gate-audit.ts +18 -7
  15. package/lib/gate-runner.js +77 -30
  16. package/lib/init.js +10 -0
  17. package/lib/mattpocock-license-verdict.json +7 -0
  18. package/lib/phase-transition.js +251 -1
  19. package/lib/retro.js +222 -0
  20. package/lib/shared-utils.js +7 -0
  21. package/lib/sprint-init.js +207 -0
  22. package/lib/sprint-state-migrator.js +1 -0
  23. package/lib/sprint-status.js +111 -0
  24. package/mock-policy/AGENTS.md +3 -3
  25. package/mutation/AGENTS.md +3 -3
  26. package/package.json +3 -2
  27. package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
  28. package/plugins/claude-code/skills/batch-grill-me/SKILL.md +15 -0
  29. package/plugins/claude-code/skills/delphi-review/AGENTS.md +3 -3
  30. package/plugins/claude-code/skills/delphi-review/SKILL.md +59 -4
  31. package/plugins/claude-code/skills/delphi-review/references/requirements.md +390 -0
  32. package/plugins/claude-code/skills/delphi-review/references/round-templates.md +67 -0
  33. package/plugins/claude-code/skills/domain-modeling/ADR-FORMAT.md +64 -0
  34. package/plugins/claude-code/skills/domain-modeling/CONTEXT-FORMAT.md +60 -0
  35. package/plugins/claude-code/skills/domain-modeling/SKILL.md +74 -0
  36. package/plugins/claude-code/skills/grill-with-docs/SKILL.md +7 -0
  37. package/plugins/claude-code/skills/grilling/SKILL.md +12 -0
  38. package/plugins/claude-code/skills/sprint-flow/AGENTS.md +3 -3
  39. package/plugins/claude-code/skills/sprint-flow/SKILL.md +168 -43
  40. package/plugins/claude-code/skills/sprint-flow/references/components/memory.md +1 -1
  41. package/plugins/claude-code/skills/sprint-flow/references/components/middleware.md +1 -1
  42. package/plugins/claude-code/skills/sprint-flow/references/components/skill-invocations.md +21 -20
  43. package/plugins/claude-code/skills/sprint-flow/references/components/tool-descriptions.md +22 -23
  44. package/plugins/claude-code/skills/sprint-flow/references/orchestration-rules.md +14 -12
  45. package/plugins/claude-code/skills/sprint-flow/references/phase-2-design.md +145 -133
  46. package/plugins/claude-code/skills/sprint-flow/references/phase-3-build.md +69 -2
  47. package/plugins/claude-code/skills/sprint-flow/references/phase-4-verify.md +93 -31
  48. package/plugins/claude-code/skills/sprint-flow/references/phase-5-ship.md +99 -14
  49. package/plugins/claude-code/skills/sprint-flow/references/phase-6-close.md +37 -5
  50. package/plugins/claude-code/skills/sprint-flow/references/phase-overview.md +58 -53
  51. package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +3 -3
  52. package/plugins/claude-code/skills/test-specification-alignment/SKILL.md +8 -3
  53. package/plugins/claude-code/skills/to-issues/SKILL.md +1 -1
  54. package/plugins/opencode/index.ts +1 -0
  55. package/plugins/opencode/package.json +1 -1
  56. package/plugins/opencode/skills/batch-grill-me/SKILL.md +15 -0
  57. package/plugins/opencode/skills/delphi-review/AGENTS.md +3 -3
  58. package/plugins/opencode/skills/delphi-review/SKILL.md +59 -4
  59. package/plugins/opencode/skills/delphi-review/references/requirements.md +390 -0
  60. package/plugins/opencode/skills/delphi-review/references/round-templates.md +67 -0
  61. package/plugins/opencode/skills/domain-modeling/ADR-FORMAT.md +64 -0
  62. package/plugins/opencode/skills/domain-modeling/CONTEXT-FORMAT.md +60 -0
  63. package/plugins/opencode/skills/domain-modeling/SKILL.md +74 -0
  64. package/plugins/opencode/skills/grill-with-docs/SKILL.md +7 -0
  65. package/plugins/opencode/skills/grilling/SKILL.md +12 -0
  66. package/plugins/opencode/skills/sprint-flow/AGENTS.md +3 -3
  67. package/plugins/opencode/skills/sprint-flow/SKILL.md +168 -43
  68. package/plugins/opencode/skills/sprint-flow/references/components/memory.md +1 -1
  69. package/plugins/opencode/skills/sprint-flow/references/components/middleware.md +1 -1
  70. package/plugins/opencode/skills/sprint-flow/references/components/skill-invocations.md +21 -20
  71. package/plugins/opencode/skills/sprint-flow/references/components/tool-descriptions.md +22 -23
  72. package/plugins/opencode/skills/sprint-flow/references/orchestration-rules.md +14 -12
  73. package/plugins/opencode/skills/sprint-flow/references/phase-2-design.md +145 -133
  74. package/plugins/opencode/skills/sprint-flow/references/phase-3-build.md +69 -2
  75. package/plugins/opencode/skills/sprint-flow/references/phase-4-verify.md +93 -31
  76. package/plugins/opencode/skills/sprint-flow/references/phase-5-ship.md +99 -14
  77. package/plugins/opencode/skills/sprint-flow/references/phase-6-close.md +37 -5
  78. package/plugins/opencode/skills/sprint-flow/references/phase-overview.md +58 -53
  79. package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +3 -3
  80. package/plugins/opencode/skills/test-specification-alignment/SKILL.md +8 -3
  81. package/plugins/opencode/skills/to-issues/SKILL.md +1 -1
  82. package/plugins/qoder/plugin.json +1 -1
  83. package/plugins/qoder/skills/delphi-review/AGENTS.md +3 -3
  84. package/plugins/qoder/skills/sprint-flow/AGENTS.md +3 -3
  85. package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +3 -3
  86. package/principles/AGENTS.md +3 -3
  87. package/scripts/__tests__/check-mattpocock-license.test.js +229 -0
  88. package/scripts/__tests__/sync-package-content.test.js +50 -0
  89. package/scripts/check-mattpocock-license.cjs +302 -0
  90. package/scripts/migrate-audit-anomalies.mjs +78 -0
  91. package/scripts/sync-package-content.js +52 -5
  92. package/skills/batch-grill-me/SKILL.md +15 -0
  93. package/skills/delphi-review/AGENTS.md +3 -3
  94. package/skills/delphi-review/SKILL.md +59 -4
  95. package/skills/delphi-review/references/requirements.md +390 -0
  96. package/skills/delphi-review/references/round-templates.md +67 -0
  97. package/skills/domain-modeling/ADR-FORMAT.md +64 -0
  98. package/skills/domain-modeling/CONTEXT-FORMAT.md +60 -0
  99. package/skills/domain-modeling/SKILL.md +74 -0
  100. package/skills/grill-with-docs/SKILL.md +7 -0
  101. package/skills/grilling/SKILL.md +12 -0
  102. package/skills/sprint-flow/AGENTS.md +3 -3
  103. package/skills/sprint-flow/SKILL.md +168 -43
  104. package/skills/sprint-flow/references/components/memory.md +1 -1
  105. package/skills/sprint-flow/references/components/middleware.md +1 -1
  106. package/skills/sprint-flow/references/components/skill-invocations.md +21 -20
  107. package/skills/sprint-flow/references/components/tool-descriptions.md +22 -23
  108. package/skills/sprint-flow/references/orchestration-rules.md +14 -12
  109. package/skills/sprint-flow/references/phase-2-design.md +145 -133
  110. package/skills/sprint-flow/references/phase-3-build.md +69 -2
  111. package/skills/sprint-flow/references/phase-4-verify.md +93 -31
  112. package/skills/sprint-flow/references/phase-5-ship.md +99 -14
  113. package/skills/sprint-flow/references/phase-6-close.md +37 -5
  114. package/skills/sprint-flow/references/phase-overview.md +58 -53
  115. package/skills/test-specification-alignment/AGENTS.md +3 -3
  116. package/skills/test-specification-alignment/SKILL.md +8 -3
  117. package/skills/to-issues/SKILL.md +1 -1
@@ -3,8 +3,9 @@ name: delphi-review
3
3
  version: 1.1.0
4
4
  description: >
5
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.
6
+ design review (default), code-walkthrough (--mode code-walkthrough), and requirements
7
+ (lightweight, --mode requirements) modes. Uses 2-3 experts from at least 2 different domestic
8
+ model providers with a >=90% statistical consensus threshold.
8
9
  Outputs structured verdict (APPROVED/PASS_WITH_CAVEATS/REQUEST_CHANGES/BLOCKED).
9
10
 
10
11
  WHAT: Anonymous multi-expert review with iterative consensus building for designs, plans,
@@ -20,12 +21,13 @@ description: >
20
21
  "多专家评审", "consensus review", "code walkthrough", "push review", "architecture review",
21
22
  "delphi review", "run delphi", "start delphi", "评审这个架构", "review this architecture",
22
23
  "评审PR", "review this PR with delphi", "delphi评审", "delphi 评审", "run delphi review",
23
- "执行delphi", "启动delphi评审".
24
+ "执行delphi", "启动delphi评审", "review the requirements", "评审需求", "requirements review",
25
+ "/requirements-review".
24
26
  NEGATIVE TRIGGERS: "how does delphi work", "what is delphi review", "code review checklist",
25
27
  "review my code quickly", "can you review this", "peer review", "I need a review",
26
28
  "explain the review process", "review guidelines", "how to review a design",
27
29
  "code review template", "review format", "PR review", "帮我review一下",
28
- "just review this", "quick review", "review steps".
30
+ "just review this", "quick review", "review steps", "review my requirements document".
29
31
  maturity: beta
30
32
  auto_continue: true
31
33
  triggers:
@@ -51,6 +53,10 @@ triggers:
51
53
  - "run delphi review"
52
54
  - "执行delphi"
53
55
  - "启动delphi评审"
56
+ - "review the requirements"
57
+ - "评审需求"
58
+ - "requirements review"
59
+ - "/requirements-review"
54
60
  triggers_negative_examples:
55
61
  - "how does delphi work" # educational question about the process
56
62
  - "what is delphi review" # asking for explanation, not execution
@@ -72,6 +78,7 @@ triggers_negative_examples:
72
78
  - "review format" # asking about format, not executing
73
79
  - "show me how to review" # educational request about reviewing
74
80
  - "review checklist example" # asking for examples, not running review
81
+ - "review my requirements document" # educational discussion about requirements, not executing review
75
82
  triggers_negative_test_cases:
76
83
  - input: "how does delphi work"
77
84
  expect: "NOT triggered"
@@ -129,6 +136,16 @@ triggers_negative_test_cases:
129
136
  expect: "NOT triggered"
130
137
  - input: "run delphi"
131
138
  expect: "triggered"
139
+ - input: "review the requirements"
140
+ expect: "triggered"
141
+ - input: "评审需求"
142
+ expect: "triggered"
143
+ - input: "requirements review"
144
+ expect: "triggered"
145
+ - input: "/requirements-review"
146
+ expect: "triggered"
147
+ - input: "review my requirements document"
148
+ expect: "NOT triggered"
132
149
  workflow_steps:
133
150
  - "Step 0: Input Validation → Output: [DelphiReview] or [DelphiReview:BLOCKED]"
134
151
  - "Round 1: Anonymous Independent Review → Output: [DelphiReview Round 1] expert JSON verdicts"
@@ -203,6 +220,10 @@ tools_denied:
203
220
  - run delphi review
204
221
  - 执行delphi
205
222
  - 启动delphi评审
223
+ - review the requirements
224
+ - 评审需求
225
+ - requirements review
226
+ - /requirements-review
206
227
 
207
228
  **NOT triggered by:**
208
229
  - "how does delphi work" (educational)
@@ -222,6 +243,7 @@ tools_denied:
222
243
  - "code review template" (asking for template)
223
244
  - "review format" (asking about format)
224
245
  - "show me how to review" (educational)
246
+ - "review my requirements document" (educational discussion, not execution)
225
247
 
226
248
  ## Workflow
227
249
 
@@ -280,9 +302,12 @@ Each round MUST output a structured round marker:
280
302
  |------|------|------|------|
281
303
  | `design`(默认) | `/delphi-review` | 需求/设计/架构/PR 评审 | 共识报告 + specification.yaml |
282
304
  | `code-walkthrough` | `--mode code-walkthrough` | git push 前代码走查 | `.code-walkthrough-result.json` |
305
+ | `requirements` | `--mode requirements` | Phase 2 THINK 阶段需求评审 | `.sprint-state/phase-outputs/requirements-reviewed.json` |
283
306
 
284
307
  **Code Walkthrough 模式**的完整规范 → 详见 `references/code-walkthrough.md`
285
308
 
309
+ **Requirements 模式**的完整规范 → 详见 `references/requirements.md`
310
+
286
311
  ---
287
312
 
288
313
  ## 参数配置
@@ -419,6 +444,28 @@ Phase 0: 准备 → Round 1: 匿名独立评审 → 共识检查
419
444
 
420
445
  **For code-walkthrough mode**, output follows `.code-walkthrough-result.json` schema (see `references/code-walkthrough.md`).
421
446
 
447
+ **For requirements mode**, output follows `requirements-reviewed.json` schema (see `references/requirements.md`):
448
+
449
+ ```json
450
+ {
451
+ "mode": "requirements",
452
+ "verdict": "APPROVED|GAPS_FOUND",
453
+ "timestamp": "2026-07-25T10:30:00Z",
454
+ "requirements_hash": "<SHA-256 hex digest>",
455
+ "head_commit": "<git rev-parse HEAD>",
456
+ "context_file_used": "CONTEXT.md",
457
+ "round": 1,
458
+ "expert_verdicts": [
459
+ { "role": "architecture", "verdict": "APPROVED", "confidence": 9 },
460
+ { "role": "feasibility", "verdict": "APPROVED", "confidence": 8 }
461
+ ],
462
+ "requirements_statement": "<short summary of what was reviewed>",
463
+ "gaps_found": [],
464
+ "rounds_used": 1,
465
+ "escalation_needed": false
466
+ }
467
+ ```
468
+
422
469
  **Anti-patterns mapping:**
423
470
  - `Round 1 → "评审完成"` → MUST NOT have `verdict: APPROVED` if `critical_issues` exist
424
471
  - `只处理 Critical,忽略 Major` → MUST include `major_concerns` array
@@ -452,6 +499,11 @@ Phase 0: 准备 → Round 1: 匿名独立评审 → 共识检查
452
499
  {"mode":"code-walkthrough","commit":"abc123...","timestamp":"...","verdict":"APPROVED","consensus_ratio":1.0}
453
500
  ```
454
501
 
502
+ **Requirements mode APPROVED** → `.sprint-state/delphi-reviewed.json`:
503
+ ```json
504
+ {"mode":"requirements","timestamp":"...","verdict":"APPROVED","consensus_ratio":1.0}
505
+ ```
506
+
455
507
  ---
456
508
 
457
509
  ## Anti-Patterns
@@ -468,6 +520,8 @@ Phase 0: 准备 → Round 1: 匿名独立评审 → 共识检查
468
520
 
469
521
  **Code-walkthrough 专属 Anti-Patterns** → 详见 `references/code-walkthrough.md`
470
522
 
523
+ **Requirements 专属 Anti-Patterns** → 详见 `references/requirements.md`
524
+
471
525
  ---
472
526
 
473
527
  ## Red Flags
@@ -499,5 +553,6 @@ Phase 0: 准备 → Round 1: 匿名独立评审 → 共识检查
499
553
  | File | Content |
500
554
  |------|---------|
501
555
  | `@references/code-walkthrough.md` | Code-walkthrough mode specification |
556
+ | `@references/requirements.md` | Requirements mode specification |
502
557
  | `@references/orchestrator-dispatch.md` | Orchestrator auto-dispatch rules (#218 subagent multi-round loop) |
503
558
  | `@references/round-templates.md` | Round templates (anonymous/exchange/final/fix report formats) |
@@ -0,0 +1,390 @@
1
+ # Requirements Mode Reference
2
+
3
+ > Extracted from `SKILL.md`. This file contains ALL content specific to the `requirements` mode of Delphi Review.
4
+
5
+ ---
6
+
7
+ ## Overview
8
+
9
+ 需求评审模式,用于 grill-with-docs 完成共享理解后、设计文档生成前,对需求完整性进行轻量级多专家 Delphi 评审。
10
+
11
+ **触发命令**: `/delphi-review --mode requirements`
12
+
13
+ **设计背景**: Issue #368 识别出原始意图中"需求评审一次 + 设计评审一次"的第一次评审被完全丢弃。本模式恢复该评审点,在需求探索(grill-with-docs)与设计文档生成之间插入一道轻量质量门禁。
14
+
15
+ **定位**:
16
+ - **轻量**: 2 专家(architecture + feasibility)、最多 1 轮(循环语义下最多 2 轮)
17
+ - **需求焦点**: 评审对象是需求陈述 + CONTEXT.md,不是设计文档或代码
18
+ - **程序化阻塞**: 输出 `requirements-reviewed.json`,由 `phase-transition 2 completed` 校验
19
+ - **防陈旧绑定**: `requirements_hash`(SHA-256)绑定需求内容,防止旧证据复用
20
+
21
+ ---
22
+
23
+ ## Five Core Properties
24
+
25
+ 1. **匿名性** — Expert A/B 互不知道对方意见(Round 1)
26
+ 2. **迭代共识** — GAPS_FOUND 时回到 grill-with-docs 补充,最多 2 轮循环
27
+ 3. **关键缺口零容忍** — Critical requirement gaps 必须在进入设计前解决
28
+ 4. **防陈旧绑定** — requirements_hash 绑定需求内容 + CONTEXT.md,旧证据不可复用
29
+ 5. **轻量但严格** — 2 专家配置,但共识要求 2/2(100%),不因轻量而降标
30
+
31
+ ---
32
+
33
+ ## 触发条件
34
+
35
+ - **自动触发**: sprint-flow Phase 2 THINK 链中,grill-with-docs 完成后、设计文档生成前(参见 `skills/sprint-flow/references/phase-2-design.md` Step 2)
36
+ - **手动触发**: `/delphi-review --mode requirements`
37
+
38
+ **⚠️ 重要调用方式说明**:
39
+
40
+ - ✅ **正确**: sprint-flow 编排层在 Phase 2 Step 2 自动调用
41
+ - ✅ **正确**: 在 Agent session 中执行 `/delphi-review --mode requirements`
42
+ - ❌ **错误**: 在设计文档已生成后调用(应在设计前)
43
+ - ❌ **错误**: 用 requirements 模式评审设计文档或代码(那是 design / code-walkthrough 模式的职责)
44
+
45
+ **与 sprint-flow 的集成**:
46
+
47
+ ```
48
+ sprint-flow Phase 2 THINK:
49
+ Step 0: CONTEXT.md 预检
50
+ Step 1: grill-with-docs(需求访谈)
51
+ Step 2: delphi-review --mode requirements ← 本模式
52
+ Step 3: 原生设计文档生成
53
+ Step 4: HARD-GATE(用户审批设计文档)
54
+ ```
55
+
56
+ **lightweight sprint 例外**: 当 `change_type == "修改已存在代码"` 时,sprint-flow 跳过 R1 需求评审,需求维度合并入 R2 设计评审。
57
+
58
+ ---
59
+
60
+ ## 流程概览
61
+
62
+ ```
63
+ grill-with-docs (completed)
64
+ │
65
+ ▼
66
+ delphi-review --mode requirements
67
+ │
68
+ ├─→ Context gather: CONTEXT.md + grill session summary + user requirements statement
69
+ │
70
+ ├─→ Expert A (architecture) anonymous review — focus: requirements completeness,
71
+ │ requirement→AC coverage, scenario coverage
72
+ │
73
+ ├─→ Expert B (feasibility) anonymous review — focus: testability of acceptance criteria,
74
+ │ user persona clarity, scope boundaries
75
+ │
76
+ ├─→ Consensus check
77
+ │ │
78
+ │ ├─→ Both APPROVED → write requirements-reviewed.json verdict=APPROVED
79
+ │ │
80
+ │ └─→ Either GAPS_FOUND → record gaps, set verdict=GAPS_FOUND
81
+ │
82
+ └─→ Return to sprint-flow orchestrator
83
+ │
84
+ ├─→ APPROVED → proceed to design doc generation
85
+ └─→ GAPS_FOUND → loop back to grill-with-docs (1 more round, max 2 total)
86
+ ```
87
+
88
+ ---
89
+
90
+ ## 专家角色
91
+
92
+ | 专家 | 视角 | 配置 |
93
+ |------|------|------|
94
+ | Expert A (architecture) | 需求完整性 + 需求→AC 映射 + 场景覆盖 | `.delphi-config.json` → `experts.architecture` |
95
+ | Expert B (feasibility) | AC 可测试性 + 用户画像 + 范围边界 | `.delphi-config.json` → `experts.feasibility` |
96
+
97
+ > ⚠️ **注意**: requirements 模式**不使用** technical 专家。技术实现细节属于设计/实现阶段(design / code-walkthrough 模式),不属于需求评审范畴。
98
+
99
+ > ⚠️ **注意**: 至少配置 **两个不同 provider** 的模型。详见 [INSTALL.md](./INSTALL.md)。
100
+
101
+ **专家选择理由**(设计决策 §16.4 C3):
102
+ - **architecture 专家**: 天然映射范围/覆盖到需求层面——需求完整性、需求→AC 映射、场景覆盖、领域术语一致性
103
+ - **feasibility 专家**: 天然映射可测试性/假设到验收标准——AC 可测试性、用户画像清晰度、范围边界、隐含假设
104
+ - **technical 专家**: 排除——技术实现细节在需求阶段尚未确定,评审无意义
105
+
106
+ ---
107
+
108
+ ## 评审焦点(模式切换指令)
109
+
110
+ ### Expert A (architecture) — 需求模式焦点
111
+
112
+ | 维度 | 检查内容 |
113
+ |------|---------|
114
+ | **需求完整性** | 所有用户场景是否已覆盖,是否有遗漏的用例路径 |
115
+ | **需求→AC 映射** | 每个需求是否有对应的验收标准,映射是否完整 |
116
+ | **场景覆盖** | 正常流、异常流、边界场景是否均已识别 |
117
+ | **领域术语一致性** | 需求陈述中的术语是否与 CONTEXT.md 领域模型一致(交叉引用) |
118
+ | **AC 精确度** | 验收标准是否具体、可度量、无歧义 |
119
+
120
+ ### Expert B (feasibility) — 需求模式焦点
121
+
122
+ | 维度 | 检查内容 |
123
+ |------|---------|
124
+ | **AC 可测试性** | 每个验收标准是否可被自动化或手动测试验证 |
125
+ | **用户画像清晰度** | 目标用户/角色是否明确定义,场景是否贴合真实使用 |
126
+ | **范围边界清晰度** | 需求边界(in-scope vs out-of-scope)是否明确划定 |
127
+ | **需求间依赖** | 需求之间是否存在隐含依赖或冲突 |
128
+ | **隐含假设** | 是否存在未明确声明的假设(技术、业务、环境) |
129
+
130
+ ---
131
+
132
+ ## 共识标准
133
+
134
+ | 条件 | 结果 |
135
+ |------|------|
136
+ | 2/2 APPROVED + 无 Critical gaps | ✅ verdict=APPROVED,进入设计文档生成 |
137
+ | 2/2 APPROVED + 有 Minor gaps | ✅ verdict=APPROVED(记录 gaps 供参考) |
138
+ | 1/2 APPROVED, 1/2 GAPS_FOUND | ❌ verdict=GAPS_FOUND,记录 gaps |
139
+ | 0/2 APPROVED | ❌ verdict=GAPS_FOUND,记录 gaps |
140
+ | 有 Critical requirement gaps | ❌ verdict=GAPS_FOUND |
141
+
142
+ **共识要求**: 2/2 一致 APPROVED(100%)。轻量配置不降低共识标准。
143
+
144
+ ---
145
+
146
+ ## 循环控制(Loop Semantics)
147
+
148
+ ```
149
+ Round 1: delphi-review --mode requirements
150
+ │
151
+ ├─→ APPROVED → 完成,进入设计文档生成
152
+ │
153
+ └─→ GAPS_FOUND
154
+ │
155
+ ├─→ gaps 记录到 requirements-reviewed.json
156
+ ├─→ 返回 sprint-flow → grill-with-docs 补充访谈
157
+ │
158
+ ▼
159
+ Round 2: delphi-review --mode requirements(带 Round 1 gaps 上下文)
160
+ │
161
+ ├─→ APPROVED → 完成,进入设计文档生成
162
+ │
163
+ └─→ GAPS_FOUND
164
+ │
165
+ └─→ escalation_needed: true
166
+ → sprint-flow Phase 2 处理升级 UX(交用户决策)
167
+ ```
168
+
169
+ **硬性限制**:
170
+ - **最多 2 轮**(Round 1 + 可选 Round 2)
171
+ - **禁止无界循环** — Round 2 后仍 GAPS_FOUND 必须升级
172
+ - **Round 2 上下文**: 专家看到 Round 1 的 gaps 列表,评估是否已修复
173
+ - **升级语义**: `escalation_needed: true` 写入 requirements-reviewed.json,sprint-flow 负责 UX
174
+
175
+ ---
176
+
177
+ ## 输出格式
178
+
179
+ ### 证据文件: `.sprint-state/phase-outputs/requirements-reviewed.json`
180
+
181
+ ```json
182
+ {
183
+ "mode": "requirements",
184
+ "verdict": "APPROVED",
185
+ "timestamp": "2026-07-25T10:30:00Z",
186
+ "requirements_hash": "a1b2c3d4e5f6...(SHA-256 hex digest)",
187
+ "head_commit": "abc123def456789...",
188
+ "context_file_used": "CONTEXT.md",
189
+ "round": 1,
190
+ "expert_verdicts": [
191
+ { "role": "architecture", "verdict": "APPROVED", "confidence": 9 },
192
+ { "role": "feasibility", "verdict": "APPROVED", "confidence": 8 }
193
+ ],
194
+ "requirements_statement": "实现用户注册流程,支持邮箱验证和密码重置",
195
+ "gaps_found": [],
196
+ "rounds_used": 1,
197
+ "escalation_needed": false
198
+ }
199
+ ```
200
+
201
+ ### GAPS_FOUND 示例
202
+
203
+ ```json
204
+ {
205
+ "mode": "requirements",
206
+ "verdict": "GAPS_FOUND",
207
+ "timestamp": "2026-07-25T10:30:00Z",
208
+ "requirements_hash": "a1b2c3d4e5f6...",
209
+ "head_commit": "abc123def456789...",
210
+ "context_file_used": "CONTEXT.md",
211
+ "round": 1,
212
+ "expert_verdicts": [
213
+ { "role": "architecture", "verdict": "APPROVED", "confidence": 8 },
214
+ { "role": "feasibility", "verdict": "GAPS_FOUND", "confidence": 7 }
215
+ ],
216
+ "requirements_statement": "实现用户注册流程,支持邮箱验证和密码重置",
217
+ "gaps_found": [
218
+ "密码重置的过期时间未定义",
219
+ "邮箱验证失败的重试策略缺失",
220
+ "AC-003 不可测试:'系统应快速响应' 无量化指标"
221
+ ],
222
+ "rounds_used": 1,
223
+ "escalation_needed": false
224
+ }
225
+ ```
226
+
227
+ ### 字段说明
228
+
229
+ | 字段 | 类型 | 说明 |
230
+ |------|------|------|
231
+ | `mode` | string | 固定值 `"requirements"` |
232
+ | `verdict` | string | `APPROVED` 或 `GAPS_FOUND` |
233
+ | `timestamp` | string | 评审完成时间 (ISO 8601 UTC) |
234
+ | `requirements_hash` | string | SHA-256 hex digest(防陈旧绑定,见下文) |
235
+ | `head_commit` | string | 当前 `git rev-parse HEAD` |
236
+ | `context_file_used` | string | 引用的 CONTEXT.md 路径 |
237
+ | `round` | number | 当前轮次(1 或 2) |
238
+ | `expert_verdicts` | array | 各专家裁决(2 项:architecture + feasibility) |
239
+ | `requirements_statement` | string | 被评审需求的简短摘要 |
240
+ | `gaps_found` | array | GAPS_FOUND 时的缺口列表(APPROVED 时为空数组) |
241
+ | `rounds_used` | number | 实际使用的轮次数 |
242
+ | `escalation_needed` | boolean | Round 2 后仍 GAPS_FOUND 时为 `true` |
243
+
244
+ ### 状态文件: `.sprint-state/delphi-reviewed.json`
245
+
246
+ APPROVED 时同步写入状态文件(与 design / code-walkthrough 模式一致):
247
+
248
+ ```json
249
+ {
250
+ "mode": "requirements",
251
+ "timestamp": "2026-07-25T10:30:00Z",
252
+ "verdict": "APPROVED",
253
+ "consensus_ratio": 1.0
254
+ }
255
+ ```
256
+
257
+ > 此文件供 `verify-consensus.sh` 校验。GAPS_FOUND 时**不写入**此文件(评审未完成)。
258
+
259
+ ---
260
+
261
+ ## Hash 绑定(防陈旧绑定 — §8.4)
262
+
263
+ `requirements_hash` = SHA-256 of:
264
+
265
+ ```
266
+ requirements_statement + CONTEXT.md content + ISO timestamp prefix (YYYY-MM-DD)
267
+ ```
268
+
269
+ **计算规则**:
270
+ 1. 拼接: `requirements_statement` 字符串 + `CONTEXT.md` 文件完整内容(若存在)+ 当日日期前缀 `YYYY-MM-DD`
271
+ 2. 对拼接结果计算 SHA-256 hex digest
272
+ 3. 若 CONTEXT.md 不存在,仅拼接 `requirements_statement` + 日期前缀
273
+
274
+ **目的**: 防止旧证据复用。`phase-transition 2 completed` 校验时:
275
+ - 文件必须存在
276
+ - `verdict` 必须为 `APPROVED`
277
+ - `requirements_hash` 必须为非空字符串
278
+ - 若 hash 与当前需求内容不匹配 → BLOCK(防陈旧绑定)
279
+
280
+ **与 phase-transition.js 的集成**(v0.17.1 已实现):
281
+
282
+ ```javascript
283
+ // EVIDENCE_FILES[2] — 已存在于 phase-transition.js
284
+ {
285
+ path: '.sprint-state/phase-outputs/requirements-reviewed.json',
286
+ requiredFields: ['verdict', 'requirements_hash'],
287
+ blockingCheck: (data) => data.verdict === 'APPROVED',
288
+ blockingMessage: 'Requirements review verdict is not APPROVED',
289
+ }
290
+ ```
291
+
292
+ ---
293
+
294
+ ## 证据文件路径
295
+
296
+ | 文件 | 路径 | 校验时机 | 校验方 |
297
+ |------|------|----------|--------|
298
+ | requirements-reviewed.json | `.sprint-state/phase-outputs/` | `phase-transition 2 completed` | phase-transition.js Layer 2 |
299
+ | delphi-reviewed.json | `.sprint-state/` | verify-consensus.sh | verify-consensus.sh |
300
+
301
+ ---
302
+
303
+ ## Anti-Patterns
304
+
305
+ **只在 `--mode requirements` 时适用:**
306
+
307
+ | ❌ Don't | ✅ Do | Why |
308
+ |----------|------|-----|
309
+ | 使用全部 3 个专家 | 仅使用 architecture + feasibility | 轻量配置(设计决策 §16.4 C3),technical 属设计阶段 |
310
+ | 无界循环评审 | 最多 2 轮,之后升级 | 防止无限循环(设计 §5.3 step 3) |
311
+ | 跳过 CONTEXT.md 交叉引用 | 始终交叉引用领域术语 | 需求应使用 CONTEXT.md 中的规范术语 |
312
+ | 输出泛化批准 | 输出 hash 绑定的需求陈述 | 防陈旧绑定(§8.4,Round 1 设计反馈 #14) |
313
+ | 接受 1/2 APPROVED | 要求 2/2 共识(100%) | 轻量配置仍需严格共识 |
314
+ | Round 2 中复用 Round 1 gaps 作为新发现 | Round 2 专家获得 Round 1 gaps 上下文 | 迭代改进,避免重复劳动 |
315
+ | 评审设计文档或代码 | 仅评审需求陈述 + CONTEXT.md | 设计/代码评审是 design / code-walkthrough 模式的职责 |
316
+ | GAPS_FOUND 时写入 delphi-reviewed.json | 仅 APPROVED 时写入状态文件 | GAPS_FOUND 表示评审未完成 |
317
+ | 在 lightweight sprint 中执行 R1 | `change_type == "修改已存在代码"` 时跳过 R1 | 需求维度合并入 R2 设计评审 |
318
+
319
+ ---
320
+
321
+ ## Security Notes
322
+
323
+ - **只读评审**: requirements 模式不修改任何源文件,仅写入证据文件到 `.sprint-state/`
324
+ - **Hash 完整性**: `requirements_hash` 使用 SHA-256,防止需求内容被篡改后复用旧证据
325
+ - **Commit 绑定**: `head_commit` 记录评审时的 git HEAD,提供时间线追溯
326
+ - **无外部 API 泄露**: 评审内容仅传递给配置的国产模型 provider,不经过第三方服务
327
+ - **证据不可伪造**: phase-transition.js 程序化校验证据文件,LLM 无法绕过
328
+
329
+ ---
330
+
331
+ ## Triggers / Negative Triggers
332
+
333
+ **触发(requirements 模式特有)**:
334
+ - `/delphi-review --mode requirements`
335
+ - "review the requirements"
336
+ - "评审需求"
337
+ - "requirements review"
338
+ - "/requirements-review"
339
+
340
+ **不触发**:
341
+ - "review my requirements document"(教育性讨论,非执行评审)
342
+ - "requirements template"(询问模板格式)
343
+ - "how to write requirements"(教育性)
344
+ - "check my requirements"(模糊,可能是 Casual 检查)
345
+
346
+ ---
347
+
348
+ ## Terminal State Checklist (requirements mode)
349
+
350
+ **Pre-requisites (MANDATORY - BLOCK if missing):**
351
+ - [ ] grill-with-docs 已完成(或 CONTEXT.md 快速路径)
352
+ - [ ] 需求陈述可用(非空)
353
+ - [ ] Expert A (architecture) 模型 API 可用
354
+ - [ ] Expert B (feasibility) 模型 API 可用
355
+
356
+ **CRITICAL - 共识验证 (requirements):**
357
+ - [ ] 2/2 专家 APPROVED
358
+ - [ ] 无 Critical requirement gaps 未解决
359
+ - [ ] requirements_hash 已计算并写入
360
+
361
+ **Final Requirements (requirements):**
362
+ - [ ] `.sprint-state/phase-outputs/requirements-reviewed.json` 已写入
363
+ - [ ] JSON 格式有效,包含所有必需字段
364
+ - [ ] verdict 为 APPROVED 或 GAPS_FOUND
365
+ - [ ] IF APPROVED: `.sprint-state/delphi-reviewed.json` 已写入(mode=requirements)
366
+ - [ ] IF GAPS_FOUND: gaps_found 数组非空,escalation_needed 正确设置
367
+ - [ ] IF Round 2 后仍 GAPS_FOUND: escalation_needed = true
368
+
369
+ **IF 任何 Pre-requisite 缺失:**
370
+ - **CANNOT 完成评审**
371
+ - **MUST BLOCK 并通知用户**
372
+
373
+ **IF GAPS_FOUND (Round 1):**
374
+ - 返回 sprint-flow → grill-with-docs 补充
375
+ - 重新执行 requirements 评审(Round 2)
376
+
377
+ **IF GAPS_FOUND (Round 2):**
378
+ - **escalation_needed = true**
379
+ - **MUST 升级给用户决策**
380
+ - **CANNOT 自动继续**
381
+
382
+ **⭐ APPROVED 后必做 (requirements mode):写入证据文件**
383
+
384
+ IF mode == `requirements` AND 最终裁决是 APPROVED,评审完成后必须:
385
+
386
+ 1. 写入 `.sprint-state/phase-outputs/requirements-reviewed.json`
387
+ 2. 写入 `.sprint-state/delphi-reviewed.json`(状态文件)
388
+ 3. 验证 JSON 格式有效
389
+ 4. 验证 requirements_hash 非空
390
+ 5. 验证 head_commit 匹配当前 HEAD
@@ -65,3 +65,70 @@
65
65
  ### Critical Issues 修复 | ### Major Concerns 处理 | ### Minor Concerns 说明
66
66
  ### 请求重新评审
67
67
  ```
68
+
69
+ ---
70
+
71
+ ## Requirements Mode: Round 1(匿名独立需求评审)
72
+
73
+ ### 执行方式
74
+
75
+ 2 位专家(architecture + feasibility)独立收到:需求陈述 + CONTEXT.md + grill session 摘要 + "独立评审需求完整性,不知道其他专家意见"。
76
+
77
+ ### 输出格式
78
+
79
+ ```markdown
80
+ ## Requirements Review - Expert [A(architecture)/B(feasibility)]
81
+
82
+ ### 需求摘要
83
+ [被评审需求的简短概括]
84
+
85
+ ### 评审焦点
86
+ - 需求完整性: [评估]
87
+ - 需求→AC 映射: [评估]
88
+ - 场景覆盖: [评估]
89
+ - AC 可测试性: [评估]
90
+ - 用户画像清晰度: [评估]
91
+ - 范围边界: [评估]
92
+
93
+ ### 缺口清单 (Gaps)
94
+ #### Critical Gaps (必须解决才能进入设计)
95
+ 1. [缺口描述] - 影响: [...] - 补充建议: [...]
96
+ #### Minor Gaps (建议补充但不阻塞)
97
+ 1. [...]
98
+
99
+ ### 裁决: [APPROVED / GAPS_FOUND]
100
+ ### 置信度: [X/10]
101
+ ### 关键理由
102
+ 1. [...]
103
+ ```
104
+
105
+ ## Requirements Mode: Round 2(带上下文的补充评审,如需要)
106
+
107
+ ### 触发条件
108
+
109
+ Round 1 裁决为 GAPS_FOUND,grill-with-docs 补充访谈后重新评审。
110
+
111
+ ### 执行方式
112
+
113
+ 2 位专家收到:更新后的需求陈述 + CONTEXT.md + **Round 1 gaps 列表** + "评估 Round 1 缺口是否已修复,是否有新缺口"。
114
+
115
+ ### 输出格式
116
+
117
+ ```markdown
118
+ ## Requirements Review Round 2 - Expert [A(architecture)/B(feasibility)]
119
+
120
+ ### Round 1 缺口修复验证
121
+ | Round 1 Gap | 状态 | 说明 |
122
+ |-------------|------|------|
123
+ | [gap 描述] | ✅ 已修复 / ❌ 仍存在 | [验证说明] |
124
+
125
+ ### 新发现缺口(如有)
126
+ 1. [新缺口描述]
127
+
128
+ ### 裁决: [APPROVED / GAPS_FOUND]
129
+ ### 置信度: [X/10]
130
+ ### 立场变化说明
131
+ [与 Round 1 相比的立场变化]
132
+ ```
133
+
134
+ > ⚠️ Round 2 后仍 GAPS_FOUND → `escalation_needed: true`,升级给用户决策。禁止 Round 3。
@@ -0,0 +1,64 @@
1
+ # ADR Format
2
+
3
+ ## Filename convention
4
+
5
+ `docs/adr/{NNNN}-{kebab-case-title}.md`
6
+
7
+ Where `{NNNN}` is a zero-padded incrementing number (e.g., `0001`, `0002`).
8
+
9
+ ## Structure
10
+
11
+ ```md
12
+ # {NNNN}. {Title}
13
+
14
+ ## Status
15
+
16
+ Proposed | Accepted | Deprecated | Superseded by ADR-XXXX
17
+
18
+ ## Context
19
+
20
+ {The issue(s) or situation(s) motivating this decision. What forces are at play? What is the problem?}
21
+
22
+ ## Decision
23
+
24
+ {The decision made. Stated in full sentences, in the present tense. What did we decide to do?}
25
+
26
+ ## Consequences
27
+
28
+ ### Positive
29
+ - {Benefit 1}
30
+ - {Benefit 2}
31
+
32
+ ### Negative
33
+ - {Trade-off 1}
34
+ - {Trade-off 2}
35
+
36
+ ### Neutral
37
+ - {Neutral observation 1}
38
+
39
+ ## Alternatives Considered
40
+
41
+ ### {Alternative 1 title}
42
+ {Brief description and why it was rejected.}
43
+
44
+ ### {Alternative 2 title}
45
+ {Brief description and why it was rejected.}
46
+ ```
47
+
48
+ ## Rules
49
+
50
+ - **Write for future readers, not present participants.** Future readers won't have the conversation context.
51
+ - **Be honest about trade-offs.** Every decision has costs. Name them.
52
+ - **One decision per ADR.** If you're writing "we decided X AND Y", split them.
53
+ - **Keep the decision short.** 1-3 sentences. The context section is where the complexity lives.
54
+ - **Superseded decisions are not deleted.** When a decision is overturned, create a new ADR that supersedes it. Update the old one's status to "Superseded by ADR-XXXX". This preserves history.
55
+ - **Don't document trivial choices.** If the answer is obvious or easily reversible, skip the ADR.
56
+
57
+ ## When NOT to write an ADR
58
+
59
+ - The decision is easily reversible.
60
+ - The decision is a personal preference with no team impact.
61
+ - The decision is well-documented elsewhere (e.g., in the project's CONTRIBUTING.md).
62
+ - The decision follows an obvious path with no real alternatives.
63
+
64
+ When in doubt, skip it. An ADR that shouldn't exist creates more noise than value.