@boyingliu01/xp-gate 0.19.1 → 0.19.3

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 (87) hide show
  1. package/gate-10.sh +105 -0
  2. package/hooks/pre-commit +24 -5
  3. package/lib/__tests__/npm-package.test.js +25 -0
  4. package/lib/mattpocock-license-verdict.json +1 -1
  5. package/mock-policy/AGENTS.md +3 -3
  6. package/mutation/AGENTS.md +3 -3
  7. package/package.json +2 -1
  8. package/plugins/claude-code/.claude-plugin/plugin.json +2 -2
  9. package/plugins/claude-code/skills/delphi-review/AGENTS.md +3 -3
  10. package/plugins/claude-code/skills/sprint-flow/AGENTS.md +3 -3
  11. package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +3 -3
  12. package/plugins/dsh/package.json +1 -1
  13. package/plugins/dsh/skills/delphi-review/AGENTS.md +3 -3
  14. package/plugins/dsh/skills/sprint-flow/AGENTS.md +3 -3
  15. package/plugins/dsh/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/sprint-flow/AGENTS.md +3 -3
  19. package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +3 -3
  20. package/plugins/qoder/plugin.json +2 -2
  21. package/plugins/qoder/skills/admin-template-guidelines/SKILL.md +6 -797
  22. package/plugins/qoder/skills/admin-template-guidelines/references/rule-1.md +91 -0
  23. package/plugins/qoder/skills/admin-template-guidelines/references/rule-2.md +155 -0
  24. package/plugins/qoder/skills/admin-template-guidelines/references/rule-3.md +70 -0
  25. package/plugins/qoder/skills/admin-template-guidelines/references/rule-4.md +154 -0
  26. package/plugins/qoder/skills/admin-template-guidelines/references/rule-5.md +126 -0
  27. package/plugins/qoder/skills/admin-template-guidelines/references/rule-6.md +180 -0
  28. package/plugins/qoder/skills/batch-grill-me/SKILL.md +15 -0
  29. package/plugins/qoder/skills/clipboard-vision/describe-clipboard.ps1 +115 -0
  30. package/plugins/qoder/skills/clipboard-vision/describe-clipboard.sh +161 -0
  31. package/plugins/qoder/skills/delphi-review/.delphi-config.json.example +61 -28
  32. package/plugins/qoder/skills/delphi-review/AGENTS.md +3 -3
  33. package/plugins/qoder/skills/delphi-review/INSTALL.md +97 -98
  34. package/plugins/qoder/skills/delphi-review/SKILL.md +77 -54
  35. package/plugins/qoder/skills/delphi-review/hooks.md +19 -0
  36. package/plugins/qoder/skills/delphi-review/opencode.json.delphi.example +6 -10
  37. package/plugins/qoder/skills/delphi-review/references/orchestrator-dispatch.md +64 -0
  38. package/plugins/qoder/skills/delphi-review/references/requirements.md +402 -0
  39. package/plugins/qoder/skills/delphi-review/references/round-templates.md +134 -0
  40. package/plugins/qoder/skills/delphi-review/scripts/verify-consensus.sh +43 -0
  41. package/plugins/qoder/skills/delphi-review/tools.md +29 -0
  42. package/plugins/qoder/skills/domain-modeling/ADR-FORMAT.md +64 -0
  43. package/plugins/qoder/skills/domain-modeling/CONTEXT-FORMAT.md +60 -0
  44. package/plugins/qoder/skills/domain-modeling/SKILL.md +74 -0
  45. package/plugins/qoder/skills/grill-with-docs/SKILL.md +7 -0
  46. package/plugins/qoder/skills/grilling/SKILL.md +12 -0
  47. package/plugins/qoder/skills/ralph-loop/SKILL.md +87 -428
  48. package/plugins/qoder/skills/ralph-loop/references/components.md +113 -0
  49. package/plugins/qoder/skills/ralph-loop/references/workflow-details.md +99 -0
  50. package/plugins/qoder/skills/sprint-flow/AGENTS.md +4 -4
  51. package/plugins/qoder/skills/sprint-flow/SKILL.md +255 -454
  52. package/plugins/qoder/skills/sprint-flow/__tests__/sprint-flow.test.cjs +457 -0
  53. package/plugins/qoder/skills/sprint-flow/hooks.md +18 -0
  54. package/plugins/qoder/skills/sprint-flow/references/components/memory.md +1 -1
  55. package/plugins/qoder/skills/sprint-flow/references/components/middleware.md +1 -1
  56. package/plugins/qoder/skills/sprint-flow/references/components/skill-invocations.md +21 -20
  57. package/plugins/qoder/skills/sprint-flow/references/components/tool-descriptions.md +22 -23
  58. package/plugins/qoder/skills/sprint-flow/references/force-levels.md +0 -1
  59. package/plugins/qoder/skills/sprint-flow/references/orchestration-rules.md +34 -27
  60. package/plugins/qoder/skills/sprint-flow/references/phase-1-prep.md +1 -1
  61. package/plugins/qoder/skills/sprint-flow/references/phase-2-design.md +157 -120
  62. package/plugins/qoder/skills/sprint-flow/references/phase-3-build.md +203 -2
  63. package/plugins/qoder/skills/sprint-flow/references/phase-4-verify.md +107 -34
  64. package/plugins/qoder/skills/sprint-flow/references/phase-5-ship.md +194 -12
  65. package/plugins/qoder/skills/sprint-flow/references/phase-6-close.md +139 -7
  66. package/plugins/qoder/skills/sprint-flow/references/phase-overview.md +486 -0
  67. package/plugins/qoder/skills/sprint-flow/scripts/verify-sprint-state.sh +38 -0
  68. package/plugins/qoder/skills/sprint-flow/tools.md +29 -0
  69. package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +3 -3
  70. package/plugins/qoder/skills/test-specification-alignment/SKILL.md +104 -601
  71. package/plugins/qoder/skills/to-issues/SKILL.md +1 -1
  72. package/principles/AGENTS.md +3 -3
  73. package/skills/delphi-review/AGENTS.md +3 -3
  74. package/skills/sprint-flow/AGENTS.md +3 -3
  75. package/skills/test-specification-alignment/AGENTS.md +3 -3
  76. package/plugins/qoder/skills/clipboard-vision/clipboard-vision/SKILL.md +0 -47
  77. package/plugins/qoder/skills/clipboard-vision/clipboard-vision/__tests__/clipboard-vision-distribution.test.cjs +0 -65
  78. package/plugins/qoder/skills/clipboard-vision/clipboard-vision/__tests__/clipboard-vision-security.test.cjs +0 -185
  79. package/plugins/qoder/skills/clipboard-vision/clipboard-vision/__tests__/clipboard-vision.Tests.ps1 +0 -138
  80. package/plugins/qoder/skills/clipboard-vision/clipboard-vision/__tests__/clipboard-vision.test.cjs +0 -273
  81. package/plugins/qoder/skills/clipboard-vision/clipboard-vision/scripts/clipboard-vision.ps1 +0 -86
  82. package/plugins/qoder/skills/clipboard-vision/clipboard-vision/scripts/clipboard-vision.sh +0 -137
  83. package/plugins/qoder/skills/ralph-loop/references/components/memory.md +0 -55
  84. package/plugins/qoder/skills/ralph-loop/references/components/middleware.md +0 -54
  85. package/plugins/qoder/skills/ralph-loop/references/components/skill-invocations.md +0 -39
  86. package/plugins/qoder/skills/ralph-loop/references/components/system-prompt.md +0 -24
  87. package/plugins/qoder/skills/ralph-loop/references/components/tool-descriptions.md +0 -32
@@ -7,35 +7,40 @@ description: "Use when asked to run tests, verify tests, align tests with specif
7
7
 
8
8
  ## Workflow Steps
9
9
 
10
- 1. **Load Phase 0** — Verify `specification.yaml` and `tests/` directory exist; BLOCK if missing with clear guidance to complete brainstorming → delphi-review → specification-generator flow first
11
- 2. **Phase 1 Alignment (Modify Allowed)** — Parse specification.yaml (YAML) + test files (AST); validate alignment rules; generate alignment report; optionally fix tests to align with requirements; require score ≥80% to proceed
12
- 3. **Coverage Mapping** — Map each REQ-* to at least one test case with `@test` annotation; map each AC-* to at least one assertion; verify test intent declarations (`@test`, `@intent`, `@covers` tags)
13
- 4. **Pre-Phase 2 Freeze** — Invoke `/freeze` skill to lock test directories (`tests/`, `test/`, `__tests__/`, `*.test.ts`, `*.spec.ts`, `*_test.py`, etc.); return confirmation before proceeding
14
- 5. **Phase 2 Execution (Frozen)** — Run all tests; Agent is BLOCKED from modifying/deleting/skipping tests; analyze failures into 4 categories: BUSINESS_CODE_ERROR, TEST_DATA_ERROR, SPECIFICATION_ERROR, ENVIRONMENT_ERROR; SPECIFICATION_ERROR requires ESCALATE_TO_HUMAN
15
- 6. **Failure Classification** — For each failing test, output classification in mandatory format with Type, Test, Root Cause, Action fields; if SPECIFICATION_ERROR detected, offer user options (A: fix spec → re-Phase 1, B: confirm spec → modify code, C: clarify ambiguity)
16
- 7. **JSON Report Output** — Generate alignment report as valid JSON with fields: `alignment_status` (PASS|FAIL|BLOCKED), `phase` (1|2), `score`, `misaligned_tests[]`, `anti_pattern_detected`, `errors[]`; Terminal State: ✅ ALL_TESTS_PASS
10
+ 1. **Load Phase 0** — Verify `specification.yaml` and `tests/` directory exist; BLOCK if missing with guidance to complete brainstorming → delphi-review → specification-generator flow first
11
+ 2. **Phase 1 Alignment (Modify Allowed)** — Parse specification.yaml + test files (AST); validate alignment rules; generate alignment report; optionally fix tests to align with requirements; require score ≥80% to proceed
12
+ 3. **Coverage Mapping** — Map each REQ-* to at least one test with `@test` annotation; map each AC-* to at least one assertion; verify `@test`, `@intent`, `@covers` tags
13
+ 4. **Pre-Phase 2 Freeze** — Lock test directories via read-only subagent convention (reviewer tools restricted to `[Read, Grep, Glob]`, no Write/Edit/Bash); return confirmation before proceeding
14
+ 5. **Phase 2 Execution (Frozen)** — Run all tests; Agent BLOCKED from modifying/deleting/skipping tests; analyze failures into 4 categories
15
+ 6. **Failure Classification** — For each failing test, output with Type, Test, Root Cause, Action fields; SPECIFICATION_ERROR requires ESCALATE_TO_HUMAN with user options (A: fix spec → re-Phase 1, B: confirm spec → modify code, C: clarify ambiguity)
16
+ 7. **JSON Report Output** — Generate alignment report as valid JSON
17
17
 
18
18
  ## 核心原则
19
19
 
20
20
  **测试是系统的防护网,也是系统的使用手册。测试必须准确反映原始需求和设计方案。**
21
21
 
22
- ### 五大特性
23
-
24
- 1. **两阶段分离** — Phase 1 可修改测试对齐,Phase 2 禁止修改测试执行
25
- 2. **结构化验证** — YAML specification + AST 解析,确定性验证
26
- 3. **freeze 约束** — Phase 2 调用 freeze skill 锁定测试目录
27
- 4. **失败分类** — 业务代码/测试数据/Specification/环境 四类错误分流
28
- 5. **零容忍** — Phase 2 绝对禁止修改/删除/跳过测试
22
+ | 特性 | 说明 |
23
+ |------|------|
24
+ | **两阶段分离** | Phase 1 可修改测试对齐,Phase 2 禁止修改测试执行 |
25
+ | **结构化验证** | YAML specification + AST 解析,确定性验证 |
26
+ | **freeze 约束** | Phase 2 调用 freeze skill 锁定测试目录 |
27
+ | **失败分类** | 业务代码/测试数据/Specification/环境 四类错误分流 |
28
+ | **零容忍** | Phase 2 绝对禁止修改/删除/跳过测试 |
29
29
 
30
30
  ---
31
31
 
32
32
  ## Output Format (MANDATORY)
33
- Alignment report MUST be output as valid JSON:
33
+
34
+ > **MANDATORY FILE OUTPUT**: When invoked, you MUST write this report as valid JSON to the file `.sprint-state/phase-outputs/test-alignment-report.json` in the project root. Stdout output alone is not sufficient — `xp-gate phase-transition 4 completed` validates the file, not the stdout.
35
+
34
36
  ```json
35
37
  {
36
38
  "alignment_status": "PASS|FAIL|BLOCKED",
37
39
  "phase": "1|2",
38
40
  "score": 85.5,
41
+ "head_commit": "<git rev-parse HEAD output>",
42
+ "spec_hash": "<SHA-256 of specification.yaml if exists, else null>",
43
+ "timestamp": "<ISO 8601>",
39
44
  "misaligned_tests": [
40
45
  {"test_name": "test_checkout", "spec_requirement": "REQ-003", "gap": "Missing @test annotation"}
41
46
  ],
@@ -43,660 +48,158 @@ Alignment report MUST be output as valid JSON:
43
48
  "errors": []
44
49
  }
45
50
  ```
46
- **Eval assertions check for:** `alignment_status`, `phase`, `score`, `anti_pattern_detected`.
51
+
52
+ **Eval assertions check for:** `alignment_status`, `phase`, `score`, `head_commit`, `spec_hash`, `anti_pattern_detected`.
47
53
 
48
54
  ---
49
55
 
50
56
  ## Triggers
51
57
 
52
- ### Automatic Triggers
58
+ ### Automatic
53
59
  - BUILD (TDD + review) Round 1 after Driver outputs tests
54
60
  - Gate 1 verification before proceeding
55
- - gstack-ship release before deployment
61
+ - Phase 5 SHIP release before deployment (native phase-5 steps)
56
62
 
57
- ### Manual Triggers
58
- - `/test-specification-alignment` command
59
- - `/verify-tests` command
60
- - "run tests" phrase
61
- - "verify tests" phrase
62
- - before gstack-ship
63
+ ### Manual
64
+ - `/test-specification-alignment`, `/verify-tests`, "run tests", "verify tests"
63
65
 
64
66
  ---
65
67
 
66
68
  ## Scope
67
69
 
68
70
  ### IN Scope
69
- - Validation of test alignment against `specification.yaml` (Requirements, User Stories, Acceptance Criteria)
70
- - Phase 1: Test modification to improve alignment (add missing tests, fix annotations, correct intent)
71
- - Phase 2: Test execution with frozen test files (no modifications allowed)
72
- - Failure classification into BUSINESS_CODE_ERROR, TEST_DATA_ERROR, SPECIFICATION_ERROR, ENVIRONMENT_ERROR
73
- - JSON report generation with alignment status, score, misaligned tests, and errors
71
+ - Validation of test alignment against `specification.yaml`
72
+ - Phase 1: Test modification to improve alignment
73
+ - Phase 2: Test execution with frozen test files
74
+ - Failure classification (BUSINESS_CODE_ERROR, TEST_DATA_ERROR, SPECIFICATION_ERROR, ENVIRONMENT_ERROR)
75
+ - JSON report generation
74
76
 
75
77
  ### OUT Scope
76
78
  - Modifying `specification.yaml` during Phase 2 (requires ESCALATE_TO_HUMAN)
77
- - Skipping or deleting tests to make tests pass
78
- - Modifying test assertions to force tests to pass
79
- - Business logic implementation (handled by BUILD phase)
80
- - Environment configuration issues (handled separately)
79
+ - Skipping/deleting/skipping tests
80
+ - Modifying test assertions to force passes
81
+ - Business logic implementation (BUILD phase)
82
+ - Environment configuration
81
83
 
82
84
  ### Boundaries
83
85
  - **Start**: After BUILD (TDD + review) Round 1 outputs tests
84
- - **End**: Terminal State ✅ ALL_TESTS_PASS or ESCALATE_TO_HUMAN for specification issues
86
+ - **End**: Terminal State ✅ ALL_TESTS_PASS or ESCALATE_TO_HUMAN
85
87
  - **Inputs**: `specification.yaml`, `tests/` directory
86
88
  - **Outputs**: Alignment report (JSON), test execution report, failure classification
87
89
 
88
90
  ---
89
91
 
90
- ## Examples
91
-
92
- ### Example 1: Normal Trigger (Should Execute)
93
- **User Input**: "run tests for login feature" or `/test-specification-alignment`
94
-
95
- **Expected Flow**:
96
- 1. Load Phase 0: Check `specification.yaml` exists → ✅ Found
97
- 2. Check `tests/` directory exists → ✅ Found
98
- 3. Phase 1: Parse spec and tests → Alignment score 85% → ✅ Pass threshold
99
- 4. Pre-Phase 2: Call `/freeze tests/` → ✅ Locked
100
- 5. Phase 2: Run tests → 12 passed, 0 failed → ✅ ALL_TESTS_PASS
101
- 6. Output JSON report with `alignment_status: "PASS"`, `phase: "2"`, `score: 85`
102
- 7. Call `/unfreeze tests/` → ✅ Unlocked
103
- 8. Terminal State: ✅ Test-specification-alignment complete
104
-
105
- ---
106
-
107
- ### Example 2: Should NOT Trigger (Missing Specification)
108
- **User Input**: "run tests" in a project without `specification.yaml`
109
-
110
- **Expected Flow**:
111
- 1. Load Phase 0: Check `specification.yaml` exists → ❌ Not Found
112
- 2. BLOCK with message:
113
- ```
114
- ❌ BLOCKED: specification.yaml 不存在
115
-
116
- 要生成 specification.yaml,请先完成需求流程:
117
-
118
- 流程步骤:
119
- 1. brainstorming → 需求探索,生成设计文档
120
- 2. delphi-review → 需求评审 (多轮直到 APPROVED)
121
- 3. spec 自动生成 (从 APPROVED 设计文档提取 specification.yaml)
122
-
123
- 为什么必须这样?
124
- - 在 delphi-review APPROVED 后生成,避免设计文档修改时 spec 也需重新生成
125
- - 遵循"问题发现越早修复成本越低"原则
126
-
127
- 请先完成上述流程,然后再运行 test-specification-alignment。
128
- ```
129
- 3. Terminal State: ❌ BLOCKED_MISSING_SPECIFICATION
130
-
131
- ---
132
-
133
- ## 触发条件
134
-
135
- ### 自动触发
136
-
137
- - BUILD (TDD + review) Round 1 后(Driver 输出 tests)
138
- - Gate 1 验证前
139
- - gstack-ship 发布前
140
-
141
- ### 手动触发
142
-
143
- - `/test-specification-alignment` 命令
144
- - `/verify-tests` 命令
145
-
146
- ---
147
-
148
- ## Specification 定义
149
-
150
- **Specification = Requirements + Design Decisions + API Contracts**
151
-
152
- | 组成部分 | 文件 | 格式 |
153
- |----------|------|------|
154
- | User Stories | `specification.yaml` → `user_stories[]` | YAML: id, actor, feature, benefit, linked_requirements |
155
- | Requirements | `specification.yaml` | YAML |
156
- | Acceptance Criteria | `specification.yaml` | YAML |
157
- | Design Decisions | `specification.yaml` | YAML |
158
- | API Contracts | `specification.yaml` | YAML |
159
-
160
- **User Stories 追溯链**:
161
- ```
162
- US-001 (actor/feature/benefit)
163
- → REQ-XXX-001 (requirement)
164
- → AC-XXX-001-01 (acceptance criteria)
165
- → test('REQ-XXX-001: ...') (@test annotation)
166
- ```
167
-
168
- ---
169
-
170
92
  ## 核心流程
171
93
 
172
94
  ```
173
- ┌─────────────────────────────────────────────────────────────┐
174
- │ Test-Specification Alignment Flow │
175
- ├─────────────────────────────────────────────────────────────┤
176
- │ │
177
- │ Phase 0: 准备 │
178
- │ ├─ 验证 specification.yaml 存在 │
179
- │ ├─ 验证 tests/ 目录存在 │
180
- │ └─ ❌ 缺失 → BLOCK + 提示用户 │
181
- │ └─ 提示: "先完成需求流程: │
182
- │ brainstorming → delphi-review → specification-generator" │
183
- │ │
184
- │ Phase 1: 对齐验证 (可修改测试) │
185
- │ ├─ 解析 specification.yaml (YAML parser) │
186
- │ ├─ 解析测试文件 (AST parser) │
187
- │ ├─ 验证对齐规则 │
188
- │ ├─ 生成 Alignment Report │
189
- │ └─ (可选) 修复测试 │
190
- │ │
191
- │ Checkpoint: Alignment Score >= 80%? │
192
- │ ├─ NO → BLOCK │
193
- │ └─ YES → 继续 │
194
- │ │
195
- │ ⭐ Pre-Phase 2: 调用 freeze skill 锁定测试目录 │
196
- │ │
197
- │ Phase 2: 执行测试 (禁止修改测试) │
198
- │ ├─ 运行所有测试 │
199
- │ ├─ IF Agent 尝试修改测试 → freeze 拦截 │
200
- │ ├─ 失败分析: 业务代码/测试数据/Specification/环境 │
201
- │ │ └─ Specification 错误 → ESCALATE_TO_HUMAN │
202
- │ └─ 全部通过 → 继续 │
203
- │ │
204
- │ ⭐ Post-Phase 2: 调用 unfreeze skill 解锁测试目录 │
205
- │ │
206
- │ Terminal State: ✅ ALL_TESTS_PASS │
207
- │ │
208
- └─────────────────────────────────────────────────────────────┘
209
- ```
210
-
211
- ---
212
-
213
- ## ⚠️ Phase 0 缺失 Specification 处理
95
+ Phase 0: 准备
96
+ ├─ 验证 specification.yaml 存在
97
+ ├─ 验证 tests/ 目录存在
98
+ └─ ❌ 缺失 → BLOCK + 提示用户
214
99
 
215
- ### 错误提示格式
100
+ Phase 1: 对齐验证 (可修改测试)
101
+ ├─ 解析 specification.yaml (YAML parser)
102
+ ├─ 解析测试文件 (AST parser)
103
+ ├─ 验证对齐规则
104
+ └─ (可选) 修复测试
216
105
 
217
- 如果 `specification.yaml` 不存在,必须 BLOCK 并提供清晰的流程指引:
218
-
219
- ```
220
- ❌ BLOCKED: specification.yaml 不存在
106
+ Checkpoint: Alignment Score >= 80%?
107
+ ├─ NO → BLOCK
108
+ └─ YES → 继续
221
109
 
222
- 要生成 specification.yaml,请先完成需求流程:
110
+ ⭐ Pre-Phase 2: 调用 freeze skill 锁定测试目录
223
111
 
224
- 流程步骤:
225
- 1. brainstorming → 需求探索,生成设计文档
226
- 2. delphi-review → 需求评审(多轮直到 APPROVED)
227
- 3. spec 自动生成(从 APPROVED 设计文档提取 specification.yaml)
112
+ Phase 2: 执行测试 (禁止修改测试)
113
+ ├─ 运行所有测试
114
+ ├─ IF Agent 尝试修改测试 → freeze 拦截
115
+ ├─ 失败分析: 业务代码/测试数据/Specification/环境
116
+ │ └─ Specification 错误 → ESCALATE_TO_HUMAN
117
+ └─ 全部通过 → 继续
228
118
 
229
- 为什么必须这样?
230
- - 在 delphi-review APPROVED 后生成,避免设计文档修改时 spec 也需重新生成
231
- - 遵循"问题发现越早修复成本越低"原则
119
+ ⭐ Post-Phase 2: 调用 unfreeze skill
232
120
 
233
- 请先完成上述流程,然后再运行 test-specification-alignment。
121
+ Terminal State: ✅ ALL_TESTS_PASS
234
122
  ```
235
123
 
236
124
  ---
237
125
 
238
126
  ## 强制对齐规则
239
127
 
240
- ### 规则 1: 每个 Requirement 必须有测试
241
-
242
- ```yaml
243
- requirement_to_test:
244
- rule: "每个 REQ-* 必须对应至少一个 test case"
245
- format: "test name 包含 REQ ID 或 JSDoc @test 标签"
246
-
247
- # TypeScript 示例
248
- example_ts: |
249
- /**
250
- * @test REQ-AUTH-001
251
- * @intent 验证用户使用正确凭据可以成功登录
252
- * @covers AC-AUTH-001-01, AC-AUTH-001-02
253
- */
254
- test('REQ-AUTH-001: login success', () => { ... });
255
-
256
- # Python 示例
257
- example_py: |
258
- # @test REQ-AUTH-001
259
- # @intent 验证用户使用正确凭据可以成功登录
260
- # @covers AC-AUTH-001-01, AC-AUTH-001-02
261
- def test_req_auth_001_login_success():
262
- ...
263
-
264
- # Go 示例
265
- example_go: |
266
- // @test REQ-AUTH-001
267
- // @intent 验证用户使用正确凭据可以成功登录
268
- // @covers AC-AUTH-001-01, AC-AUTH-001-02
269
- func Test_REQ_AUTH_001_LoginSuccess(t *testing.T) { ... }
270
- ```
271
-
272
- ### 规则 2: 每个 Acceptance Criteria 必须有断言
273
-
274
- ```yaml
275
- ac_to_assertion:
276
- rule: "每个 AC-* 必须有对应断言覆盖"
277
- format: "断言注释标注 AC ID"
278
- example: |
279
- // AC-AUTH-001-01: 返回 200 和 token
280
- expect(response.status).toBe(200);
281
- expect(response.body.token).toBeDefined();
282
- ```
283
-
284
- ### 规则 3: 测试意图必须明确声明
285
-
286
- ```yaml
287
- test_intent_declaration:
288
- rule: "每个 test case 必须有意图声明"
289
- format: "@test, @intent, @covers JSDoc 标签"
290
- required_tags:
291
- - "@test REQ-XXX-XXX" # 关联的 requirement ID
292
- - "@intent 描述测试意图" # 测试目的
293
- - "@covers AC-XXX-XX" # 覆盖的 acceptance criteria (可选)
294
- ```
295
-
296
- ---
297
-
298
- ## 对齐验证维度
299
-
300
- | 维度 | 权重 | 验证内容 |
128
+ | 规则 | 说明 | 语言示例 |
301
129
  |------|------|----------|
302
- | Requirement Coverage | 30% | 每个 REQ-* 是否有对应测试 |
303
- | Acceptance Criteria Coverage | 25% | 每个 AC-* 是否被断言覆盖 |
304
- | Test Intent Correctness | 20% | 测试意图是否正确声明 |
305
- | Edge Case Coverage | 15% | 边界条件是否覆盖 |
306
- | Test Data Validity | 10% | 测试数据是否合理 |
307
-
308
- **Pass Threshold: 80%**
130
+ | **每个 REQ 必须有测试** | 每个 REQ-* 对应至少一个 test case | TS: `@test REQ-AUTH-001` / Py: `# @test REQ-AUTH-001` / Go: `// @test REQ-AUTH-001` |
131
+ | **每个 AC 必须有断言** | 每个 AC-* 必须有对应断言覆盖 | `// AC-AUTH-001-01: 返回 200` → `expect(response.status).toBe(200)` |
132
+ | **测试意图声明** | 每个 test case 必须有 `@test`, `@intent`, `@covers` 标签 | 详见 `references/specification-format.md` |
309
133
 
310
134
  ---
311
135
 
312
- ## Phase 2: freeze 约束机制
313
-
314
- ### Pre-Phase 2: 锁定测试目录
315
-
316
- ```yaml
317
- pre_phase2:
318
- action: "INVOKE freeze skill"
319
- parameters:
320
- freeze_boundary:
321
- - "tests/"
322
- - "test/"
323
- - "__tests__/"
324
- - "*.test.ts"
325
- - "*.test.js"
326
- - "*.spec.ts"
327
- - "*.spec.js"
328
- - "*_test.py"
329
- - "*_test.go"
330
- - "cypress/"
331
- - "playwright/"
332
- mode: "strict"
333
-
334
- result:
335
- - "测试目录被 freeze skill 锁定"
336
- - "Agent 的 Edit/Write 调用被预拦截"
337
- - "返回: ✅ 测试文件已冻结"
338
- ```
339
-
340
- ### Phase 2 约束
341
-
342
- ```yaml
343
- phase2_constraints:
344
- forbidden_actions:
345
- - action: "修改测试文件"
346
- severity: "CRITICAL"
347
- response: "freeze skill 返回 BLOCKED_ERROR"
348
-
349
- - action: "删除测试文件"
350
- severity: "CRITICAL"
351
- response: "freeze skill 返回 BLOCKED_ERROR"
352
-
353
- - action: "跳过测试 (test.skip, @skip, xit)"
354
- severity: "CRITICAL"
355
- response: "检测并拒绝"
356
-
357
- - action: "修改断言使其永远通过"
358
- severity: "CRITICAL"
359
- response: "检测并拒绝"
360
-
361
- allowed_actions:
362
- - "修改业务代码"
363
- - "修改配置文件"
364
- - "修改环境变量"
365
- ```
366
-
367
- ### Post-Phase 2: 解锁测试目录
136
+ ## Failure Classification
368
137
 
369
- ```yaml
370
- post_phase2:
371
- action: "INVOKE unfreeze skill"
372
- result: "测试目录解除冻结,允许后续修改"
373
- ```
374
-
375
- ---
376
-
377
- ## 失败分析分类
378
-
379
- | 失败类型 | 判断依据 | 处理方式 |
380
- |----------|----------|----------|
138
+ | 类型 | 判断依据 | 处理方式 |
139
+ |------|----------|----------|
381
140
  | **BUSINESS_CODE_ERROR** | 测试正确,业务代码有 bug | 修改业务代码 |
382
141
  | **TEST_DATA_ERROR** | 测试数据不符合业务逻辑 | 回滚到 Phase 1 |
383
142
  | **SPECIFICATION_ERROR** | 测试正确,但 specification 有误 | ESCALATE_TO_HUMAN |
384
143
  | **ENVIRONMENT_ERROR** | 环境/依赖问题 | 修复环境配置 |
385
144
 
386
- ### 失败分类强制输出格式
387
-
388
- 任何 Phase 2 测试失败时,**必须**按以下格式输出:
389
-
390
- ```markdown
391
- ### Failure Classification
392
- - **Type**: [BUSINESS_CODE_ERROR | TEST_DATA_ERROR | SPECIFICATION_ERROR | ENVIRONMENT_ERROR]
393
- - **Test**: [失败的测试名称]
394
- - **Root Cause**: [简要原因]
395
- - **Action**: [对应处理方式]
396
- ```
397
-
398
- ### Specification 错误处理
399
-
400
- ```yaml
401
- specification_issue_flow:
402
- state: "ESCALATE_SPECIFICATION_ISSUE"
403
-
404
- user_options:
405
- - option: "A"
406
- action: "修正 Specification → 重新 Phase 1"
407
- unfreeze_tests: true
408
-
409
- - option: "B"
410
- action: "确认 Specification 正确 → 修改业务代码"
411
- note: "用户明确授权"
412
-
413
- - option: "C"
414
- action: "补充 Specification 澄清歧义"
415
- unfreeze_tests: true
416
- ```
417
-
418
- ---
419
-
420
- ## 状态机
421
-
422
- | State | 名称 | 说明 |
423
- |-------|------|------|
424
- | 0 | IDLE | 初始状态 |
425
- | 1 | PHASE0_PREPARING | 准备阶段 |
426
- | 2 | PHASE0_COMPLETE | 准备完成 |
427
- | 3 | PHASE1_ALIGNING | 对齐验证中 |
428
- | 4 | PHASE1_ALIGNMENT_ISSUES | 发现对齐问题 |
429
- | 5 | PHASE1_FIXING_TESTS | 修复测试中 |
430
- | 6 | PHASE1_COMPLETE | 对齐完成 |
431
- | 7 | PRE_PHASE2_FREEZE | 冻结测试目录 |
432
- | 8 | CHECKPOINT_VERIFIED | 检查点通过 |
433
- | 9 | PHASE2_EXECUTING | 执行测试中 |
434
- | 10 | PHASE2_TEST_FAILURE | 测试失败 |
435
- | 11 | PHASE2_FAILURE_ANALYSIS | 失败分析中 |
436
- | 12 | PHASE2_FIXING_CODE | 修复业务代码中 |
437
- | 13 | PHASE2_SPECIFICATION_ISSUE | Specification 问题 |
438
- | 14 | PHASE2_COMPLETE | 测试通过 |
439
- | 15 | POST_PHASE2_UNFREEZE | 解冻测试目录 |
440
- | 16 | ALL_TESTS_PASS | 全部通过 |
441
-
442
- ### 阻塞状态
443
-
444
- | State | 名称 | 说明 |
445
- |-------|------|------|
446
- | 90 | BLOCKED_MISSING_SPECIFICATION | 缺少 specification |
447
- | 91 | BLOCKED_ALIGNMENT_TOO_LOW | 对齐分数过低 |
448
- | 92 | BLOCKED_TEST_MODIFICATION_VIOLATION | 测试修改违规 |
449
- | 93 | BLOCKED_SPECIFICATION_ISSUE | Specification 问题需用户决策 |
450
- | 94 | BLOCKED_MAX_RETRIES_EXCEEDED | 超过最大重试次数 |
451
-
452
- ---
145
+ ### Specification 错误处理选项
453
146
 
454
- ## 与现有 Skills 集成
455
-
456
- ### 与 BUILD (TDD + review) 集成
457
-
458
- ```
459
- BUILD (TDD + review) Round 1: Driver
460
- ├─ 输出: sealed{code, decisions} + public{tests}
461
- └────────────────────────────────────────────┘
462
- │
463
- ▼
464
- test-specification-alignment (本 skill)
465
- ├─ Phase 1: 验证 Driver 生成的 tests 与 requirements 对齐
466
- ├─ Phase 2: 执行测试验证实现
467
- └────────────────────────────────────────────┘
468
- │
469
- ▼
470
- Gate 1 (verification-loop)
471
- ├─ Static Analysis
472
- └────────────────────────────────────────────┘
473
- │
474
- ▼
475
- BUILD (TDD + review) Round 3: Arbiter
476
- └─ 收到 test-specification-alignment 结果
477
- ```
478
-
479
- ### 与 freeze skill 集成
480
-
481
- - Phase 2 开始前: 调用 `/freeze` 锁定测试目录
482
- - Phase 2 执行中: freeze 拦截所有测试文件修改
483
- - Phase 2 结束后: 调用 `/unfreeze` 解锁
147
+ - **A**: 修正 Specification → 重新 Phase 1 (unfreeze tests)
148
+ - **B**: 确认 Specification 正确 → 修改业务代码 (用户明确授权)
149
+ - **C**: 补充 Specification 澄清歧义 (unfreeze tests)
484
150
 
485
151
  ---
486
152
 
487
- ## Agent 配置
488
-
489
- ### Phase 1 Agent
490
-
491
- ```yaml
492
- phase1_agent:
493
- type: oracle
494
- model: Qwen3.5-Plus
495
- skills:
496
- - test-driven-development
497
- - coding-standards
498
-
499
- constraints:
500
- can_modify_tests: true
501
- must_preserve_test_intent: true
502
- ```
153
+ ## State Machine
503
154
 
504
- ### Phase 2 Agent
505
-
506
- ```yaml
507
- phase2_agent:
508
- type: build
509
- model: GLM-5
510
- skills:
511
- - test-driven-development
512
- - coding-standards
513
-
514
- constraints:
515
- can_modify_tests: false # ❌ 禁止
516
- can_delete_tests: false # ❌ 禁止
517
- can_skip_tests: false # ❌ 禁止
518
- can_modify_business_code: true # ✅ 允许
519
- ```
520
-
521
- ---
522
-
523
- ## 输出报告格式
524
-
525
- ### Alignment Report (Phase 1)
526
-
527
- ```markdown
528
- ## Test-Specification Alignment Report
529
-
530
- ### Summary
531
- - Alignment Score: 85/100
532
- - Total Requirements: 15
533
- - Covered Requirements: 14/15 (93%)
534
- - Total Acceptance Criteria: 42
535
- - Covered AC: 38/42 (90%)
536
-
537
- ### Coverage by Dimension
538
- | Dimension | Score | Weight | Weighted |
539
- |-----------|-------|--------|----------|
540
- | Requirement Coverage | 93% | 30% | 27.9 |
541
- | Acceptance Criteria Coverage | 90% | 25% | 22.5 |
542
- | Test Intent Correctness | 88% | 20% | 17.6 |
543
- | Edge Case Coverage | 80% | 15% | 12.0 |
544
- | Test Data Validity | 90% | 10% | 9.0 |
545
- | **Total** | | | **89.0** |
546
-
547
- ### Misaligned Tests
548
- | Test ID | Issue | Specification Ref | Recommendation |
549
- |---------|-------|-------------------|----------------|
550
- | TEST-012 | Incorrect intent | REQ-AUTH-003 | 修改断言验证 |
551
-
552
- ### Missing Tests
553
- | Requirement ID | Description | Priority |
554
- |----------------|-------------|----------|
555
- | REQ-AUTH-006 | Token 刷新机制 | Critical |
556
-
557
- ### Status
558
- ✅ Alignment Score >= 80%, 可以进入 Phase 2
559
- ```
560
-
561
- ### Test Execution Report (Phase 2)
562
-
563
- ```markdown
564
- ## Test Execution Report
565
-
566
- ### Summary
567
- - Total Tests: 67
568
- - Passed: 65
569
- - Failed: 2
570
- - Skipped: 0
571
-
572
- ### Failed Tests
573
- | Test ID | Error | Root Cause | Fix Applied |
574
- |---------|-------|------------|-------------|
575
- | TEST-034 | AssertionError | 业务代码逻辑错误 | 已修复 |
576
-
577
- ### Freeze Status
578
- - Pre-Phase 2: ✅ 测试目录已冻结
579
- - Phase 2: ✅ 无违规尝试
580
- - Post-Phase 2: ✅ 测试目录已解冻
581
-
582
- ### Status
583
- ✅ All tests pass. Ready for next stage.
584
- ```
585
-
586
- ---
587
-
588
- ## Legacy 模式
589
-
590
- ### 缺失 Specification 的 fallback
591
-
592
- ```yaml
593
- legacy_mode:
594
- trigger: "specification.yaml 不存在"
595
-
596
- options:
597
- - option: "从测试逆向生成 specification"
598
- steps:
599
- - 解析现有测试
600
- - 提取测试意图和断言
601
- - 生成 draft specification
602
- - 用户确认后保存
603
-
604
- - option: "放宽对齐验证"
605
- rules:
606
- - 只验证测试覆盖率 >= 80%
607
- - 不验证测试意图对齐
608
- - 标记为 "LEGACY_MODE"
609
-
610
- - option: "用户提供 specification"
611
- action: "BLOCK until specification provided"
612
- ```
155
+ | State | Description |
156
+ |-------|------------|
157
+ | 0 IDLE | Initial |
158
+ | 1 PHASE0_PREPARING | Preparing |
159
+ | 3 PHASE1_ALIGNING | Aligning |
160
+ | 6 PHASE1_COMPLETE | Alignment done |
161
+ | 7 PRE_PHASE2_FREEZE | Freeze test dirs |
162
+ | 9 PHASE2_EXECUTING | Running tests |
163
+ | 12 PHASE2_FIXING_CODE | Fixing business code |
164
+ | 14 PHASE2_COMPLETE | Tests passed |
165
+ | 15 POST_PHASE2_UNFREEZE | Unfreeze test dirs |
166
+ | 16 ALL_TESTS_PASS | ✅ Done |
167
+ | 90 BLOCKED_MISSING_SPECIFICATION | Missing specification |
168
+ | 93 BLOCKED_SPECIFICATION_ISSUE | Spec issue needs user |
169
+ | 94 BLOCKED_MAX_RETRIES_EXCEEDED | Max retries hit |
613
170
 
614
171
  ---
615
172
 
616
- ## 成本控制
173
+ ## Anti-Patterns
617
174
 
618
- | 指标 | 阈值 |
619
- |------|------|
620
- | 单次对齐验证 | ~$0.02 |
621
- | 单次测试执行 | ~$0.01 |
622
- | 最大重试次数 | 5 |
623
- | 单次总成本上限 | $0.10 |
175
+ | ❌ Error | ✅ Correct |
176
+ |---------|-----------|
177
+ | Phase 2 修改/删除测试文件 | 只能修改业务代码 |
178
+ | Phase 2 跳过测试 (skip/xit) | 检测并拒绝 |
179
+ | 测试失败时修改断言 | 必须修改业务代码 |
180
+ | 缺少 @test 标签 | 强制标注 |
181
+ | Specification 错误时强行通过 | 必须 ESCALATE |
624
182
 
625
183
  ---
626
184
 
627
185
  ## Terminal State Checklist
628
186
 
629
- <MANDATORY-CHECKLIST>
630
-
631
- ### 只能在以下条件全部满足后声明 "test-specification-alignment complete":
632
-
633
- **Pre-requisites:**
634
187
  - [ ] specification.yaml 存在且可解析
635
188
  - [ ] tests/ 目录存在且有测试文件
636
- - [ ] Phase 1 对齐验证完成
637
-
638
- **CRITICAL - Alignment Verification:**
639
- - [ ] Alignment Score >= 80%
640
- - [ ] 所有 Critical 对齐问题已修复
641
- - [ ] 所有 Major 对齐问题已处理
642
-
643
- **CRITICAL - Phase 2 Execution:**
644
- - [ ] freeze skill 已调用,测试目录已锁定
645
- - [ ] 所有测试已执行
646
- - [ ] 无测试修改违规
647
- - [ ] unfreeze skill 已调用
648
-
649
- **Final Requirements:**
650
- - [ ] 所有测试通过
651
- - [ ] 报告已生成
652
-
653
- **IF 有 Specification 问题:**
654
- - **CANNOT claim complete**
655
- - **MUST ESCALATE_TO_HUMAN**
189
+ - [ ] Phase 1 对齐验证完成, score ≥ 80%
190
+ - [ ] Pre-Phase 2: freeze skill 已调用
191
+ - [ ] Phase 2: 所有测试已执行, 无修改违规
192
+ - [ ] Post-Phase 2: unfreeze skill 已调用
193
+ - [ ] 所有测试通过, 报告已生成
656
194
 
657
- **IF Phase 2 测试修改违规:**
658
- - **CANNOT claim complete**
659
- - **MUST BLOCK 并记录违规**
660
-
661
- </MANDATORY-CHECKLIST>
662
-
663
- ---
664
-
665
- ## Anti-Patterns
666
-
667
- | 错误 | 正确 |
668
- |------|------|
669
- | Phase 2 修改测试文件 | ❌ 禁止 — 只能修改业务代码 |
670
- | Phase 2 删除测试文件 | ❌ 禁止 — freeze 会拦截 |
671
- | Phase 2 跳过测试 | ❌ 禁止 — 检测并拒绝 |
672
- | 测试失败时修改断言 | ❌ 禁止 — 必须修改业务代码 |
673
- | 缺少 @test 标签 | ❌ 必须 — 强制标注 |
674
- | Specification 错误时强行通过 | ❌ 禁止 — 必须 ESCALATE |
195
+ **IF Specification 问题 → CANNOT claim complete → MUST ESCALATE_TO_HUMAN**
675
196
 
676
197
  ---
677
198
 
678
- ## 版本历史
679
-
680
- | 版本 | 日期 | 变更 |
681
- |------|------|------|
682
- | V1.0 | 2026-04-06 | 初始设计 |
683
- | V2.0 | 2026-04-06 | Delphi Review 共识版本 |
684
- | V2.1 | 2026-06-02 | Added parser-friendly sections: Workflow Steps (7 steps), Triggers (5+ phrases), Scope (IN/OUT/Boundaries), Examples (2 scenarios) |
199
+ ## Details → see `references/`
685
200
 
686
- ---
687
-
688
- ## Output Format (MANDATORY)
689
- Alignment report MUST be output as valid JSON:
690
- ```json
691
- {
692
- "alignment_status": "PASS|FAIL|BLOCKED",
693
- "phase": "1|2",
694
- "score": 85.5,
695
- "misaligned_tests": [
696
- {"test_name": "test_checkout", "spec_requirement": "REQ-003", "gap": "Missing @test annotation"}
697
- ],
698
- "anti_pattern_detected": false,
699
- "errors": []
700
- }
701
- ```
702
- **Eval assertions check for:** `alignment_status`, `phase`, `score`, `anti_pattern_detected`.
201
+ | Topic | File |
202
+ |-------|------|
203
+ | 对齐验证算法 (AST parsing, score calc, legacy mode) | `references/alignment-verification-algorithm.md` |
204
+ | Specification YAML 格式规范 (完整示例) | `references/specification-format.md` |
205
+ | Phase 2 freeze 约束执行机制 (违规日志, 异常处理, 状态转换) | `references/phase2-constraint-enforcement.md` |