@boyingliu01/xp-gate 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,151 @@
1
+ # Sprint Progress Template
2
+
3
+ 本模板定义了 Sprint 进度看板的标准显示格式。
4
+ Orchestrator 在每个 Phase 完成后、以及响应用户 `--status` 查询时,使用此模板渲染进度。
5
+
6
+ ## 渲染规则
7
+
8
+ 1. 从 `.sprint-state/sprint-state.json` 读取 `id`, `task_description`, `phase`, `status`, `started_at`, `phase_history`, `outputs`, `isolation`
9
+ 2. 按下方模板渲染 ASCII 看板
10
+ 3. 状态图标映射:✅ completed | 🔄 running | ⏸️ paused | ⬜ pending | ⏭️ skipped | ❌ failed
11
+
12
+ ## 看板模板
13
+
14
+ ```
15
+ +============================================================+
16
+ | SPRINT PROGRESS {sprint_id} |
17
+ +============================================================+
18
+ | 需求: {task_description} |
19
+ | 分支: {branch} |
20
+ | 状态: {overall_status} 启动: {started_at} |
21
+ +============================================================+
22
+ | |
23
+ | {icon_-1} Phase -1 ISOLATE {duration_-1} |
24
+ | {icon_-0.5} Phase -0.5 AUTO-ESTIMATE {duration_-0.5} |
25
+ | {icon_0} Phase 0 THINK {duration_0} |
26
+ | {icon_1} Phase 1 PLAN {duration_1} |
27
+ | {icon_2} Phase 2 BUILD {duration_2} |
28
+ | {icon_3} Phase 3 REVIEW {duration_3} |
29
+ | {icon_4} Phase 4 USER ACCEPT {duration_4} |
30
+ | {icon_5} Phase 5 FEEDBACK {duration_5} |
31
+ | {icon_6} Phase 6 SHIP {duration_6} |
32
+ | {icon_7} Phase 7 LAND {duration_7} |
33
+ | {icon_8} Phase 8 CLEANUP {duration_8} |
34
+ | |
35
+ | [{progress_bar}] {pct}% |
36
+ +============================================================+
37
+ | > 当前: Phase {current_phase} {current_phase_name} |
38
+ | 状态: {current_phase_status} |
39
+ | |
40
+ | 下一步: {next_action} |
41
+ | {next_action_detail} |
42
+ +============================================================+
43
+ | 输出物: |
44
+ | {output_list} |
45
+ +============================================================+
46
+ ```
47
+
48
+ ## 字段说明
49
+
50
+ | 字段 | 来源 | 说明 |
51
+ |------|------|------|
52
+ | `{sprint_id}` | `sprint-state.json → id` | Sprint 标识 |
53
+ | `{task_description}` | `sprint-state.json → task_description` | 需求描述(缺失时显示 "-") |
54
+ | `{branch}` | `sprint-state.json → isolation.branch` | 工作分支 |
55
+ | `{overall_status}` | `sprint-state.json → status` | running / paused / completed |
56
+ | `{started_at}` | `sprint-state.json → started_at` | Sprint 启动时间(格式化: YYYY-MM-DD HH:MM) |
57
+ | `{icon_N}` | `phase_history[N].status` | 状态图标(见上方映射) |
58
+ | `{duration_N}` | `phase_history[N].duration_seconds` | 耗时(见下方格式化规则) |
59
+ | `{current_phase}` | `sprint-state.json → phase` | 当前阶段编号 |
60
+ | `{current_phase_name}` | Phase 名称映射 | ISOLATE / AUTO-ESTIMATE / THINK 等 |
61
+ | `{current_phase_status}` | `phase_history` 中当前阶段的 status | running / paused / completed |
62
+ | `{next_action}` | 下方"下一步行动表" | 用户需要执行的操作 |
63
+ | `{next_action_detail}` | 操作细节 | 具体指令 |
64
+ | `{output_list}` | `sprint-state.json → outputs` | 已生成的输出物路径列表(每项一行) |
65
+ | `{progress_bar}` | 已完成阶段数 / 总阶段数 | 格式: `████▓░░░░░░` |
66
+ | `{pct}` | 完成百分比 | 整数 |
67
+
68
+ ## 进度条生成规则
69
+
70
+ ```
71
+ 总阶段数 = 11(Phase -1, -0.5, 0, 1, 2, 3, 4, 5, 6, 7, 8)
72
+ 已完成数 = phase_history 中 status == "completed" 的数量
73
+ 每个阶段 = 1 个字符宽度
74
+ 填充: 已完成 = █ | 当前 = ▓ | 待做 = ░ | 跳过 = ▒
75
+ ```
76
+
77
+ ## 下一步行动表
78
+
79
+ | 当前阶段 | 当前状态 | 下一步行动 | 行动细节 |
80
+ |---------|---------|-----------|---------|
81
+ | Phase -1 | completed | 确认环境 | 检查 worktree 路径,准备进入需求分析 |
82
+ | Phase -0.5 | completed | 确认评估 | 查看 AUTO-ESTIMATE 结果,选择流程级别 |
83
+ | Phase 0 | completed | 确认设计 | 审阅设计文档,确认后进入 Phase 1 |
84
+ | Phase 0 | paused | 审阅设计 | 设计文档等待您的 APPROVED 确认 |
85
+ | Phase 1 | completed | 确认评审 | delphi-review 已通过,检查 specification.yaml |
86
+ | Phase 1 | paused | 等待评审 | delphi-review 进行中或等待 taste_decisions 确认 |
87
+ | Phase 2 | completed | 审阅代码 | BUILD 完成,进入 Phase 3 REVIEW |
88
+ | Phase 2 | running | 等待构建 | ralph-loop 迭代中,无需操作 |
89
+ | Phase 3 | completed | 开始验收 | 进入 Phase 4 人工验收 |
90
+ | Phase 4 | completed | 确认反馈 | 验收完成,Phase 5 自动进行 |
91
+ | Phase 4 | paused | 执行验收 | 必须人工验收,请实际使用后确认 |
92
+ | Phase 5 | completed | 确认发布 | 反馈已收集,准备进入 Phase 6 SHIP |
93
+ | Phase 6 | completed | 确认合并 | PR 已创建,确认是否合并 |
94
+ | Phase 7 | completed | 确认清理 | 合并成功,准备清理 worktree |
95
+ | Phase 8 | completed | Sprint 完成 | 检查 Sprint Summary,如有 emergent issues 考虑 Sprint 2 |
96
+ | 任意 | failed | 处理错误 | 查看错误信息,决定修复或放弃 |
97
+
98
+ ## 耗时格式化规则
99
+
100
+ ```
101
+ < 60s → "{N}s"
102
+ < 60m → "{N}m"
103
+ < 24h → "{X}h {Y}m"
104
+ >= 24h → "{X}d {Y}h"
105
+ 无数据 → "-"
106
+ ```
107
+
108
+ ## 向后兼容
109
+
110
+ 当 `sprint-state.json` 缺少以下字段时(旧版 sprint 创建的状态文件),渲染规则:
111
+ - `task_description` 缺失 → 显示 "-"
112
+ - `started_at` 缺失 → 显示 "-"
113
+ - `phase_history` 缺失 → 从 `phase` 字段推断:小于等于 `phase` 的阶段标记为 ✅,当前阶段标记为 🔄,其余标记为 ⬜;所有耗时显示 "-"
114
+
115
+ ## 示例渲染
116
+
117
+ ```
118
+ +============================================================+
119
+ | SPRINT PROGRESS sprint-2026-06-04-01 |
120
+ +============================================================+
121
+ | 需求: 为 sprint-flow 添加进度看板功能 |
122
+ | 分支: sprint/2026-06-04-01 |
123
+ | 状态: running 启动: 2026-06-04 19:25 |
124
+ +============================================================+
125
+ | |
126
+ | ✅ Phase -1 ISOLATE 3m |
127
+ | ✅ Phase -0.5 AUTO-ESTIMATE 1m |
128
+ | ✅ Phase 0 THINK 2m |
129
+ | ✅ Phase 1 PLAN 5m |
130
+ | 🔄 Phase 2 BUILD 12m |
131
+ | ⬜ Phase 3 REVIEW - |
132
+ | ⬜ Phase 4 USER ACCEPT - |
133
+ | ⬜ Phase 5 FEEDBACK - |
134
+ | ⬜ Phase 6 SHIP - |
135
+ | ⬜ Phase 7 LAND - |
136
+ | ⬜ Phase 8 CLEANUP - |
137
+ | |
138
+ | [████▓░░░░░░] 36% |
139
+ +============================================================+
140
+ | > 当前: Phase 2 BUILD |
141
+ | 状态: running |
142
+ | |
143
+ | 下一步: 等待构建完成 |
144
+ | ralph-loop 迭代中,完成后自动进入 Phase 3 REVIEW |
145
+ +============================================================+
146
+ | 输出物: |
147
+ | 设计文档: .sprint-state/phase-outputs/design-doc.md |
148
+ | 评审报告: .sprint-state/delphi-reviewed.json |
149
+ | 规格说明: .sprint-state/phase-outputs/specification.yaml |
150
+ +============================================================+
151
+ ```
@@ -1,10 +1,20 @@
1
1
  ---
2
2
  name: test-specification-alignment
3
- description: "测试与 Specification 对齐验证引擎。确保测试准确反映需求和设计。两阶段执行:Phase 1 验证对齐(可修改测试),Phase 2 执行测试(禁止修改测试)。MANDATORY before any release. TRIGGER: 'run tests', 'verify tests', before BUILD (TDD + review) Arbiter, before gstack-ship."
3
+ description: "Use when asked to run tests, verify tests, align tests with specification.yaml, before BUILD verification, or before release/ship."
4
4
  ---
5
5
 
6
6
  # Test-Specification Alignment Engine
7
7
 
8
+ ## Workflow Steps
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
17
+
8
18
  ## 核心原则
9
19
 
10
20
  **测试是系统的防护网,也是系统的使用手册。测试必须准确反映原始需求和设计方案。**
@@ -37,6 +47,89 @@ Alignment report MUST be output as valid JSON:
37
47
 
38
48
  ---
39
49
 
50
+ ## Triggers
51
+
52
+ ### Automatic Triggers
53
+ - BUILD (TDD + review) Round 1 after Driver outputs tests
54
+ - Gate 1 verification before proceeding
55
+ - gstack-ship release before deployment
56
+
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
+
64
+ ---
65
+
66
+ ## Scope
67
+
68
+ ### 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
74
+
75
+ ### OUT Scope
76
+ - 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)
81
+
82
+ ### Boundaries
83
+ - **Start**: After BUILD (TDD + review) Round 1 outputs tests
84
+ - **End**: Terminal State ✅ ALL_TESTS_PASS or ESCALATE_TO_HUMAN for specification issues
85
+ - **Inputs**: `specification.yaml`, `tests/` directory
86
+ - **Outputs**: Alignment report (JSON), test execution report, failure classification
87
+
88
+ ---
89
+
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
+
40
133
  ## 触发条件
41
134
 
42
135
  ### 自动触发
@@ -588,6 +681,10 @@ legacy_mode:
588
681
  |------|------|------|
589
682
  | V1.0 | 2026-04-06 | 初始设计 |
590
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) |
685
+
686
+ ---
687
+
591
688
  ## Output Format (MANDATORY)
592
689
  Alignment report MUST be output as valid JSON:
593
690
  ```json