@boyingliu01/xp-gate 0.9.4 → 0.9.5

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 (29) hide show
  1. package/lib/doctor.js +34 -18
  2. package/lib/shared-phase-constants.js +23 -9
  3. package/mock-policy/AGENTS.md +3 -3
  4. package/mutation/AGENTS.md +3 -3
  5. package/package.json +1 -1
  6. package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
  7. package/plugins/claude-code/skills/delphi-review/AGENTS.md +3 -3
  8. package/plugins/claude-code/skills/delphi-review/SKILL.md +34 -0
  9. package/plugins/claude-code/skills/sprint-flow/AGENTS.md +3 -3
  10. package/plugins/claude-code/skills/sprint-flow/SKILL.md +53 -1
  11. package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +3 -3
  12. package/plugins/opencode/__tests__/xp-gate-update.test.ts +1 -11
  13. package/plugins/opencode/index.ts +0 -1
  14. package/plugins/opencode/package.json +1 -1
  15. package/plugins/opencode/skills/delphi-review/AGENTS.md +3 -3
  16. package/plugins/opencode/skills/delphi-review/SKILL.md +34 -0
  17. package/plugins/opencode/skills/sprint-flow/AGENTS.md +3 -3
  18. package/plugins/opencode/skills/sprint-flow/SKILL.md +53 -1
  19. package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +3 -3
  20. package/plugins/opencode/tui-plugin.ts +7 -3
  21. package/plugins/qoder/skills/delphi-review/AGENTS.md +3 -3
  22. package/plugins/qoder/skills/sprint-flow/AGENTS.md +3 -3
  23. package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +3 -3
  24. package/principles/AGENTS.md +3 -3
  25. package/skills/delphi-review/AGENTS.md +3 -3
  26. package/skills/delphi-review/SKILL.md +34 -0
  27. package/skills/sprint-flow/AGENTS.md +3 -3
  28. package/skills/sprint-flow/SKILL.md +53 -1
  29. package/skills/test-specification-alignment/AGENTS.md +3 -3
package/lib/doctor.js CHANGED
@@ -386,21 +386,15 @@ function fixMissingAdapters(mode, srcDir, adaptersDir) {
386
386
  return false;
387
387
  }
388
388
 
389
- /**
390
- * Attempt to fix known issues.
391
- * Only operates when mode === 'active' (local or global).
392
- */
393
- function fixIssues(checks, config) {
394
- console.log('');
395
- console.log('Attempting fixes...');
396
- console.log('-------------------');
397
-
398
- const srcDir = PKG_DIR;
389
+ function fixConfigMismatches(config) {
399
390
  let fixed = false;
400
-
401
391
  fixed = fixVersionMismatch(config, getPackageVersion()) || fixed;
402
392
  fixed = fixTemplateDirMismatch(config, getTemplateDir()) || fixed;
393
+ return fixed;
394
+ }
403
395
 
396
+ function fixHooksByMode(config, srcDir) {
397
+ let fixed = false;
404
398
  if (config.mode === 'local') {
405
399
  const gitDir = getGitDir();
406
400
  if (gitDir) {
@@ -410,18 +404,40 @@ function fixIssues(checks, config) {
410
404
  } else {
411
405
  fixed = fixMissingHooks('global', srcDir, GLOBAL_HOOKS_DIR) || fixed;
412
406
  }
407
+ return fixed;
408
+ }
413
409
 
414
- if (config.mode === 'global') {
415
- const hooksPath = getCurrentHooksPath();
416
- if (hooksPath !== GLOBAL_HOOKS_DIR) {
417
- fixed = fixCoreHooksPath(GLOBAL_HOOKS_DIR) || fixed;
418
- }
410
+ function fixGlobalHooksPath(config) {
411
+ if (config.mode !== 'global') return false;
412
+ const hooksPath = getCurrentHooksPath();
413
+ if (hooksPath !== GLOBAL_HOOKS_DIR) {
414
+ return fixCoreHooksPath(GLOBAL_HOOKS_DIR);
419
415
  }
416
+ return false;
417
+ }
420
418
 
421
- const adaptersDir = config.mode === 'local'
419
+ function getAdaptersDirByMode(config) {
420
+ return config.mode === 'local'
422
421
  ? path.join(path.dirname(getGitDir() || ''), 'githooks', 'adapters')
423
422
  : GLOBAL_ADAPTERS_DIR;
424
- fixed = fixMissingAdapters(config.mode, srcDir, adaptersDir) || fixed;
423
+ }
424
+
425
+ /**
426
+ * Attempt to fix known issues.
427
+ * Only operates when mode === 'active' (local or global).
428
+ */
429
+ function fixIssues(checks, config) {
430
+ console.log('');
431
+ console.log('Attempting fixes...');
432
+ console.log('-------------------');
433
+
434
+ const srcDir = PKG_DIR;
435
+ let fixed = false;
436
+
437
+ fixed = fixConfigMismatches(config) || fixed;
438
+ fixed = fixHooksByMode(config, srcDir) || fixed;
439
+ fixed = fixGlobalHooksPath(config) || fixed;
440
+ fixed = fixMissingAdapters(config.mode, srcDir, getAdaptersDirByMode(config)) || fixed;
425
441
 
426
442
  if (!fixed) {
427
443
  console.log(' No fixable issues found.');
@@ -24,6 +24,27 @@ const PHASE_NAMES = {
24
24
 
25
25
  const PHASE_ORDER = ['-1', '-0.5', '0', '1', '2', '3', '4', '5', '6', '7', '8'];
26
26
 
27
+ /**
28
+ * Safely parse a date-like value into epoch ms.
29
+ * @param {*} value - Timestamp to parse
30
+ * @returns {number} Epoch ms, or NaN if invalid
31
+ */
32
+ function parseTime(value) {
33
+ return new Date(value).getTime();
34
+ }
35
+
36
+ /**
37
+ * Get the max of an existing value and a new timestamp (if valid and larger).
38
+ * @param {number} current - Current best value
39
+ * @param {*} candidate - Candidate timestamp
40
+ * @returns {number} Max value
41
+ */
42
+ function maxValid(current, candidate) {
43
+ if (!candidate) return current;
44
+ const t = parseTime(candidate);
45
+ return !isNaN(t) && t > current ? t : current;
46
+ }
47
+
27
48
  /**
28
49
  * Find the most recent timestamp across started_at and phase_history.
29
50
  * @param {object} state - Sprint state object
@@ -31,19 +52,12 @@ const PHASE_ORDER = ['-1', '-0.5', '0', '1', '2', '3', '4', '5', '6', '7', '8'];
31
52
  */
32
53
  function getLatestTimestamp(state) {
33
54
  if (!state || !state.started_at) return 0;
34
- const started = new Date(state.started_at).getTime();
55
+ const started = parseTime(state.started_at);
35
56
  if (isNaN(started)) return 0;
36
57
  let latest = started;
37
58
  if (Array.isArray(state.phase_history)) {
38
59
  for (const ph of state.phase_history) {
39
- if (ph.completed_at) {
40
- const t = new Date(ph.completed_at).getTime();
41
- if (!isNaN(t) && t > latest) latest = t;
42
- }
43
- if (ph.started_at) {
44
- const t = new Date(ph.started_at).getTime();
45
- if (!isNaN(t) && t > latest) latest = t;
46
- }
60
+ latest = maxValid(maxValid(latest, ph.completed_at), ph.started_at);
47
61
  }
48
62
  }
49
63
  return latest;
@@ -1,9 +1,9 @@
1
1
  # SRC/MOCK-POLICY KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-06-19
4
- **Commit:** b67f7f9
3
+ **Generated:** 2026-06-21
4
+ **Commit:** 1050a30
5
5
  **Branch:** main
6
- **Version:** 0.9.4.0
6
+ **Version:** 0.9.5.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Mock layering policy enforcement — Gate M3 of pre-push hook. Ensures integration tests use real implementations for internal dependencies, mock external dependencies, and annotate pending mocks with removal plans. Combines project scope scanning, mock decision engine, and per-file validation into a single pipeline.
@@ -1,9 +1,9 @@
1
1
  # SRC/MUTATION KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-06-19
4
- **Commit:** b67f7f9
3
+ **Generated:** 2026-06-21
4
+ **Commit:** 1050a30
5
5
  **Branch:** main
6
- **Version:** 0.9.4.0
6
+ **Version:** 0.9.5.0
7
7
 
8
8
  ## OVERVIEW
9
9
  **Gate M** (incremental mutation testing) + **Gate M2** helpers (test-layer detection used by `src/mock-policy/`). Pre-push quality gate. TypeScript-only; uses Stryker.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boyingliu01/xp-gate",
3
- "version": "0.9.4",
3
+ "version": "0.9.5",
4
4
  "description": "AI-driven development workflow: 6 quality gates + Delphi review + Sprint Flow",
5
5
  "bin": {
6
6
  "xp-gate": "./bin/xp-gate.js"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xp-gate",
3
- "version": "0.9.4",
3
+ "version": "0.9.5",
4
4
  "displayName": "XP-Gate",
5
5
  "description": "Extreme Programming quality gates + AI workflow skills for Claude Code. Includes 10 quality gates (Gate 0-9), Sprint Flow (11 phases), and Delphi multi-expert review (>=90% consensus).",
6
6
  "author": {
@@ -1,9 +1,9 @@
1
1
  # SKILLS/DELPHI-REVIEW KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-06-19
4
- **Commit:** b67f7f9
3
+ **Generated:** 2026-06-21
4
+ **Commit:** 1050a30
5
5
  **Branch:** main
6
- **Version:** 0.9.4.0
6
+ **Version:** 0.9.5.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.
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: delphi-review
3
3
  description: "Use when asked to review a design, plan, or architecture; before implementation starts; or when multi-expert consensus is needed. Triggers: 'review this design', '评审这个需求', 'design review', '多专家评审', 'consensus review', 'code walkthrough', 'push review', 'architecture review', 'PR review', or any request for multi-expert evaluation of requirements, design docs, or PRs."
4
+ auto_continue: true
4
5
  ---
5
6
 
6
7
  # Delphi Consensus Review
@@ -109,6 +110,39 @@ Phase 0: 准备 → Round 1: 匿名独立评审 → 共识检查
109
110
 
110
111
  **Automatic re-review**: 对于常见可控问题(措辞模糊、AC 缺失、格式问题),subagent 应自行修复后自动重评审,无需等待用户。
111
112
 
113
+ ### ⭐ 自动延续规则(MANDATORY — 防止流程卡住)
114
+
115
+ 当 Delphi Review 启动多轮评审(Round 2+)时,**orchestrator 必须自动延续流程,不得等待用户输入**。
116
+
117
+ **触发条件**:
118
+ - Round N 完成,但未达到终止条件(100% approved + ≥90% consensus + 所有 Critical/Major 已处理)
119
+ - 存在待处理的背景任务(subagent dispatched tasks)
120
+
121
+ **自动延续动作**:
122
+ 1. **收集背景任务结果**:等待 `<system-reminder>` 通知后,立即调用 `background_output(task_id="bg_...")` 获取所有 subagent 输出
123
+ 2. **合成 Round N 总结**:汇总专家意见、共识度、待处理问题
124
+ 3. **自动启动 Round N+1**:立即 dispatch 新一轮 subagent 任务,携带上一轮总结作为上下文
125
+ 4. **循环直至终止**:重复步骤 1-3,直到达到终止条件
126
+
127
+ **终止条件**(满足全部):
128
+ - ✅ 所有专家状态 = APPROVED
129
+ - ✅ 共识度 ≥ 90%
130
+ - ✅ 所有 Critical 级别问题已解决
131
+ - ✅ 所有 Major 级别问题已处理(或已记录为已知问题)
132
+
133
+ **例外情况**(直接输出,不进入下一轮):
134
+ - Round 1 即达到 100% approved + 100% consensus → 直接输出最终报告
135
+ - 已达最大轮数(5 轮)→ 输出"未达成共识"报告,标记为 PROCESS_BLOCK
136
+
137
+ **禁止行为**:
138
+ - ❌ 询问用户"要继续吗?"
139
+ - ❌ 等待用户手动触发 Round N+1
140
+ - ❌ 在未达到终止条件时停止流程
141
+
142
+ **错误处理**:
143
+ - 背景任务超时(>10min)→ 标记为 TIMEOUT,输出部分结果并终止
144
+ - 背景任务失败(subagent 错误)→ 重试 1 次,仍失败则输出错误报告并终止
145
+
112
146
  ---
113
147
 
114
148
  ## 修复与重新评审
@@ -1,9 +1,9 @@
1
1
  # SKILLS/SPRINT-FLOW KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-06-19
4
- **Commit:** b67f7f9
3
+ **Generated:** 2026-06-21
4
+ **Commit:** 1050a30
5
5
  **Branch:** main
6
- **Version:** 0.9.4.0
6
+ **Version:** 0.9.5.0
7
7
 
8
8
  ## OVERVIEW
9
9
  **11-phase** development pipeline: ISOLATE → AUTO-ESTIMATE → THINK → PLAN → BUILD → REVIEW → USER ACCEPTANCE → FEEDBACK → SHIP → LAND → CLEANUP. Phase 2 default build mode is **ralph-loop** (REQ-level iteration, 40-67% token savings vs parallel). HARD-GATE in Phase 1: design must pass Delphi review (≥90% consensus) before any coding.
@@ -408,6 +408,58 @@ Sprint Flow: ISOLATE → AUTO-ESTIMATE → THINK → PLAN → BUILD → REVIEW
408
408
 
409
409
  ---
410
410
 
411
+ ### ⭐ Phase State Persistence(阶段状态持久化 — MANDATORY)
412
+
413
+ **编排器必须在每个 Phase 完成后更新 `.sprint-state/sprint-state.json`**:
414
+
415
+ 1. **Phase 完成后立即更新**(每个 Phase 结束前):
416
+ - `phase`: 更新为当前 Phase 编号(如 `0`, `1`, `2`...)
417
+ - `status`: 更新为 `"completed"`(已完成 Phase)
418
+ - `phase_history`: 追加新条目
419
+
420
+ 2. **`phase_history` 数组条目 schema**:
421
+ ```json
422
+ {
423
+ "phase": 0,
424
+ "phase_name": "THINK",
425
+ "status": "completed",
426
+ "timestamp": "2026-06-20T10:30:00Z"
427
+ }
428
+ ```
429
+
430
+ 3. **检查点**:
431
+ - `--status` 参数读取 `sprint-state.json` 并渲染进度看板
432
+ - TUI panel 显示当前 Phase 和历史
433
+ - `--resume-from` 校验 `phase_history` 中的最后完成 Phase
434
+
435
+ 4. **完整 sprint-state.json 示例**:
436
+ ```json
437
+ {
438
+ "id": "sprint-2026-06-20-01",
439
+ "phase": 2,
440
+ "status": "in_progress",
441
+ "phase_history": [
442
+ {"phase": -1, "phase_name": "ISOLATE", "status": "completed", "timestamp": "2026-06-20T10:00:00Z"},
443
+ {"phase": -0.5, "phase_name": "AUTO-ESTIMATE", "status": "completed", "timestamp": "2026-06-20T10:05:00Z"},
444
+ {"phase": 0, "phase_name": "THINK", "status": "completed", "timestamp": "2026-06-20T10:15:00Z"},
445
+ {"phase": 1, "phase_name": "PLAN", "status": "completed", "timestamp": "2026-06-20T10:30:00Z"}
446
+ ],
447
+ "isolation": {
448
+ "worktree_path": "/home/boyingliu01/projects/xp-gate/.worktrees/sprint/sprint-2026-06-20-01",
449
+ "branch": "sprint/2026-06-20-01"
450
+ },
451
+ "outputs": {
452
+ "pain_document": "phase-outputs/phase-0-summary.md",
453
+ "specification": "phase-outputs/specification.yaml"
454
+ },
455
+ "metrics": {
456
+ "coverage_pct": 85.5
457
+ }
458
+ }
459
+ ```
460
+
461
+ ---
462
+
411
463
  ## 使用示例
412
464
 
413
465
  | 场景 | 命令 | 说明 |
@@ -447,7 +499,7 @@ See [Output Contract](#output-contract) below for the canonical machine-readable
447
499
 
448
500
  **Phase Summary** (每个 Phase 必须输出 YAML frontmatter): `phase/N`, `phase_name`, `status`, `outputs[]`, `decisions[]`, `next_phase_context` + markdown body (≤50 lines)
449
501
 
450
- **Sprint State JSON**: `{id, phase, status, isolation {worktree_path, branch}, outputs, metrics}` — 存储于 `.sprint-state/sprint-state.json`
502
+ **Sprint State JSON**: `{id, phase, status, phase_history[], isolation {worktree_path, branch}, outputs, metrics}` — 存储于 `.sprint-state/sprint-state.json`
451
503
 
452
504
  **Final User-Facing Output**: Phase/status, file paths, validation results, next user decision, PR URL or cleanup report
453
505
 
@@ -1,9 +1,9 @@
1
1
  # SKILLS/TEST-SPECIFICATION-ALIGNMENT KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-06-19
4
- **Commit:** b67f7f9
3
+ **Generated:** 2026-06-21
4
+ **Commit:** 1050a30
5
5
  **Branch:** main
6
- **Version:** 0.9.4.0
6
+ **Version:** 0.9.5.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
@@ -15,7 +15,6 @@ import { mkdirSync, writeFileSync, readFileSync, existsSync, rmSync } from "node
15
15
  import { join } from "node:path"
16
16
  import { tmpdir, homedir } from "node:os"
17
17
  import { execSync, spawn } from "node:child_process"
18
- import { EventEmitter } from "node:events"
19
18
 
20
19
  // ── Pure function: semverLt ──
21
20
 
@@ -189,16 +188,6 @@ function readXpGateConfig(): { autoUpgrade?: boolean } | null {
189
188
  }
190
189
  }
191
190
 
192
- /**
193
- * Wait for a child process to close and resolve with exit code.
194
- */
195
- function waitForSpawn(child: ReturnType<typeof spawn>): Promise<number> {
196
- return new Promise((resolve, reject) => {
197
- child.on("close", (code) => resolve(code ?? -1))
198
- child.on("error", (err) => reject(err))
199
- })
200
- }
201
-
202
191
  // ── Tests ──
203
192
 
204
193
  void describe("semverLt", () => {
@@ -285,6 +274,7 @@ void describe("checkXpGateUpdate — cache & upgrade", () => {
285
274
  })
286
275
  })
287
276
 
277
+
288
278
  // ── UPG-002: spawn-based upgrade tests ──
289
279
 
290
280
  void describe("checkXpGateUpdate — spawn (UPG-002)", () => {
@@ -150,7 +150,6 @@ function readXpGateConfig(): { autoUpgrade?: boolean } | null {
150
150
  return null
151
151
  }
152
152
  }
153
-
154
153
  // ── OpenCode plugin version check (notification only) ──
155
154
 
156
155
  async function checkPluginUpdate(pluginDir: string): Promise<void> {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boyingliu01/opencode-plugin",
3
- "version": "0.9.4",
3
+ "version": "0.9.5",
4
4
  "type": "module",
5
5
  "main": "index.ts",
6
6
  "description": "XP-Gate quality gates + AI workflow skills + Sprint Flow TUI sidebar for OpenCode",
@@ -1,9 +1,9 @@
1
1
  # SKILLS/DELPHI-REVIEW KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-06-19
4
- **Commit:** b67f7f9
3
+ **Generated:** 2026-06-21
4
+ **Commit:** 1050a30
5
5
  **Branch:** main
6
- **Version:** 0.9.4.0
6
+ **Version:** 0.9.5.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.
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: delphi-review
3
3
  description: "Use when asked to review a design, plan, or architecture; before implementation starts; or when multi-expert consensus is needed. Triggers: 'review this design', '评审这个需求', 'design review', '多专家评审', 'consensus review', 'code walkthrough', 'push review', 'architecture review', 'PR review', or any request for multi-expert evaluation of requirements, design docs, or PRs."
4
+ auto_continue: true
4
5
  ---
5
6
 
6
7
  # Delphi Consensus Review
@@ -109,6 +110,39 @@ Phase 0: 准备 → Round 1: 匿名独立评审 → 共识检查
109
110
 
110
111
  **Automatic re-review**: 对于常见可控问题(措辞模糊、AC 缺失、格式问题),subagent 应自行修复后自动重评审,无需等待用户。
111
112
 
113
+ ### ⭐ 自动延续规则(MANDATORY — 防止流程卡住)
114
+
115
+ 当 Delphi Review 启动多轮评审(Round 2+)时,**orchestrator 必须自动延续流程,不得等待用户输入**。
116
+
117
+ **触发条件**:
118
+ - Round N 完成,但未达到终止条件(100% approved + ≥90% consensus + 所有 Critical/Major 已处理)
119
+ - 存在待处理的背景任务(subagent dispatched tasks)
120
+
121
+ **自动延续动作**:
122
+ 1. **收集背景任务结果**:等待 `<system-reminder>` 通知后,立即调用 `background_output(task_id="bg_...")` 获取所有 subagent 输出
123
+ 2. **合成 Round N 总结**:汇总专家意见、共识度、待处理问题
124
+ 3. **自动启动 Round N+1**:立即 dispatch 新一轮 subagent 任务,携带上一轮总结作为上下文
125
+ 4. **循环直至终止**:重复步骤 1-3,直到达到终止条件
126
+
127
+ **终止条件**(满足全部):
128
+ - ✅ 所有专家状态 = APPROVED
129
+ - ✅ 共识度 ≥ 90%
130
+ - ✅ 所有 Critical 级别问题已解决
131
+ - ✅ 所有 Major 级别问题已处理(或已记录为已知问题)
132
+
133
+ **例外情况**(直接输出,不进入下一轮):
134
+ - Round 1 即达到 100% approved + 100% consensus → 直接输出最终报告
135
+ - 已达最大轮数(5 轮)→ 输出"未达成共识"报告,标记为 PROCESS_BLOCK
136
+
137
+ **禁止行为**:
138
+ - ❌ 询问用户"要继续吗?"
139
+ - ❌ 等待用户手动触发 Round N+1
140
+ - ❌ 在未达到终止条件时停止流程
141
+
142
+ **错误处理**:
143
+ - 背景任务超时(>10min)→ 标记为 TIMEOUT,输出部分结果并终止
144
+ - 背景任务失败(subagent 错误)→ 重试 1 次,仍失败则输出错误报告并终止
145
+
112
146
  ---
113
147
 
114
148
  ## 修复与重新评审
@@ -1,9 +1,9 @@
1
1
  # SKILLS/SPRINT-FLOW KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-06-19
4
- **Commit:** b67f7f9
3
+ **Generated:** 2026-06-21
4
+ **Commit:** 1050a30
5
5
  **Branch:** main
6
- **Version:** 0.9.4.0
6
+ **Version:** 0.9.5.0
7
7
 
8
8
  ## OVERVIEW
9
9
  **11-phase** development pipeline: ISOLATE → AUTO-ESTIMATE → THINK → PLAN → BUILD → REVIEW → USER ACCEPTANCE → FEEDBACK → SHIP → LAND → CLEANUP. Phase 2 default build mode is **ralph-loop** (REQ-level iteration, 40-67% token savings vs parallel). HARD-GATE in Phase 1: design must pass Delphi review (≥90% consensus) before any coding.
@@ -408,6 +408,58 @@ Sprint Flow: ISOLATE → AUTO-ESTIMATE → THINK → PLAN → BUILD → REVIEW
408
408
 
409
409
  ---
410
410
 
411
+ ### ⭐ Phase State Persistence(阶段状态持久化 — MANDATORY)
412
+
413
+ **编排器必须在每个 Phase 完成后更新 `.sprint-state/sprint-state.json`**:
414
+
415
+ 1. **Phase 完成后立即更新**(每个 Phase 结束前):
416
+ - `phase`: 更新为当前 Phase 编号(如 `0`, `1`, `2`...)
417
+ - `status`: 更新为 `"completed"`(已完成 Phase)
418
+ - `phase_history`: 追加新条目
419
+
420
+ 2. **`phase_history` 数组条目 schema**:
421
+ ```json
422
+ {
423
+ "phase": 0,
424
+ "phase_name": "THINK",
425
+ "status": "completed",
426
+ "timestamp": "2026-06-20T10:30:00Z"
427
+ }
428
+ ```
429
+
430
+ 3. **检查点**:
431
+ - `--status` 参数读取 `sprint-state.json` 并渲染进度看板
432
+ - TUI panel 显示当前 Phase 和历史
433
+ - `--resume-from` 校验 `phase_history` 中的最后完成 Phase
434
+
435
+ 4. **完整 sprint-state.json 示例**:
436
+ ```json
437
+ {
438
+ "id": "sprint-2026-06-20-01",
439
+ "phase": 2,
440
+ "status": "in_progress",
441
+ "phase_history": [
442
+ {"phase": -1, "phase_name": "ISOLATE", "status": "completed", "timestamp": "2026-06-20T10:00:00Z"},
443
+ {"phase": -0.5, "phase_name": "AUTO-ESTIMATE", "status": "completed", "timestamp": "2026-06-20T10:05:00Z"},
444
+ {"phase": 0, "phase_name": "THINK", "status": "completed", "timestamp": "2026-06-20T10:15:00Z"},
445
+ {"phase": 1, "phase_name": "PLAN", "status": "completed", "timestamp": "2026-06-20T10:30:00Z"}
446
+ ],
447
+ "isolation": {
448
+ "worktree_path": "/home/boyingliu01/projects/xp-gate/.worktrees/sprint/sprint-2026-06-20-01",
449
+ "branch": "sprint/2026-06-20-01"
450
+ },
451
+ "outputs": {
452
+ "pain_document": "phase-outputs/phase-0-summary.md",
453
+ "specification": "phase-outputs/specification.yaml"
454
+ },
455
+ "metrics": {
456
+ "coverage_pct": 85.5
457
+ }
458
+ }
459
+ ```
460
+
461
+ ---
462
+
411
463
  ## 使用示例
412
464
 
413
465
  | 场景 | 命令 | 说明 |
@@ -447,7 +499,7 @@ See [Output Contract](#output-contract) below for the canonical machine-readable
447
499
 
448
500
  **Phase Summary** (每个 Phase 必须输出 YAML frontmatter): `phase/N`, `phase_name`, `status`, `outputs[]`, `decisions[]`, `next_phase_context` + markdown body (≤50 lines)
449
501
 
450
- **Sprint State JSON**: `{id, phase, status, isolation {worktree_path, branch}, outputs, metrics}` — 存储于 `.sprint-state/sprint-state.json`
502
+ **Sprint State JSON**: `{id, phase, status, phase_history[], isolation {worktree_path, branch}, outputs, metrics}` — 存储于 `.sprint-state/sprint-state.json`
451
503
 
452
504
  **Final User-Facing Output**: Phase/status, file paths, validation results, next user decision, PR URL or cleanup report
453
505
 
@@ -1,9 +1,9 @@
1
1
  # SKILLS/TEST-SPECIFICATION-ALIGNMENT KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-06-19
4
- **Commit:** b67f7f9
3
+ **Generated:** 2026-06-21
4
+ **Commit:** 1050a30
5
5
  **Branch:** main
6
- **Version:** 0.9.4.0
6
+ **Version:** 0.9.5.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
@@ -101,6 +101,12 @@ function renderBuildReqs(history: SprintPhaseHistory): string[] {
101
101
  .map(([id, r]) => ` ${statusSymbol(r.status, id, undefined)} ${r.name}`)
102
102
  }
103
103
 
104
+ function appendBuildReqs(lines: string[], key: string, history: SprintPhaseHistory | undefined): void {
105
+ if (key === "2" && history?.reqs) {
106
+ lines.push(...renderBuildReqs(history))
107
+ }
108
+ }
109
+
104
110
  function renderPhaseLines(
105
111
  historyByPhase: Record<string, SprintPhaseHistory>,
106
112
  currentPhase: string | number | undefined,
@@ -110,9 +116,7 @@ function renderPhaseLines(
110
116
  const history = historyByPhase[key]
111
117
  if (!history && String(currentPhase) !== key) continue
112
118
  lines.push(renderPhaseLine(key, history, currentPhase))
113
- if (key === "2" && history?.reqs) {
114
- lines.push(...renderBuildReqs(history))
115
- }
119
+ appendBuildReqs(lines, key, history)
116
120
  }
117
121
  return lines
118
122
  }
@@ -1,9 +1,9 @@
1
1
  # SKILLS/DELPHI-REVIEW KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-06-19
4
- **Commit:** b67f7f9
3
+ **Generated:** 2026-06-21
4
+ **Commit:** 1050a30
5
5
  **Branch:** main
6
- **Version:** 0.9.4.0
6
+ **Version:** 0.9.5.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.
@@ -1,9 +1,9 @@
1
1
  # SKILLS/SPRINT-FLOW KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-06-19
4
- **Commit:** b67f7f9
3
+ **Generated:** 2026-06-21
4
+ **Commit:** 1050a30
5
5
  **Branch:** main
6
- **Version:** 0.9.4.0
6
+ **Version:** 0.9.5.0
7
7
 
8
8
  ## OVERVIEW
9
9
  **11-phase** development pipeline: ISOLATE → AUTO-ESTIMATE → THINK → PLAN → BUILD → REVIEW → USER ACCEPTANCE → FEEDBACK → SHIP → LAND → CLEANUP. Phase 2 default build mode is **ralph-loop** (REQ-level iteration, 40-67% token savings vs parallel). HARD-GATE in Phase 1: 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-06-19
4
- **Commit:** b67f7f9
3
+ **Generated:** 2026-06-21
4
+ **Commit:** 1050a30
5
5
  **Branch:** main
6
- **Version:** 0.9.4.0
6
+ **Version:** 0.9.5.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-06-19
4
- **Commit:** b67f7f9
3
+ **Generated:** 2026-06-21
4
+ **Commit:** 1050a30
5
5
  **Branch:** main
6
- **Version:** 0.9.4.0
6
+ **Version:** 0.9.5.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.
@@ -1,9 +1,9 @@
1
1
  # SKILLS/DELPHI-REVIEW KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-06-19
4
- **Commit:** b67f7f9
3
+ **Generated:** 2026-06-21
4
+ **Commit:** 1050a30
5
5
  **Branch:** main
6
- **Version:** 0.9.4.0
6
+ **Version:** 0.9.5.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.
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: delphi-review
3
3
  description: "Use when asked to review a design, plan, or architecture; before implementation starts; or when multi-expert consensus is needed. Triggers: 'review this design', '评审这个需求', 'design review', '多专家评审', 'consensus review', 'code walkthrough', 'push review', 'architecture review', 'PR review', or any request for multi-expert evaluation of requirements, design docs, or PRs."
4
+ auto_continue: true
4
5
  ---
5
6
 
6
7
  # Delphi Consensus Review
@@ -109,6 +110,39 @@ Phase 0: 准备 → Round 1: 匿名独立评审 → 共识检查
109
110
 
110
111
  **Automatic re-review**: 对于常见可控问题(措辞模糊、AC 缺失、格式问题),subagent 应自行修复后自动重评审,无需等待用户。
111
112
 
113
+ ### ⭐ 自动延续规则(MANDATORY — 防止流程卡住)
114
+
115
+ 当 Delphi Review 启动多轮评审(Round 2+)时,**orchestrator 必须自动延续流程,不得等待用户输入**。
116
+
117
+ **触发条件**:
118
+ - Round N 完成,但未达到终止条件(100% approved + ≥90% consensus + 所有 Critical/Major 已处理)
119
+ - 存在待处理的背景任务(subagent dispatched tasks)
120
+
121
+ **自动延续动作**:
122
+ 1. **收集背景任务结果**:等待 `<system-reminder>` 通知后,立即调用 `background_output(task_id="bg_...")` 获取所有 subagent 输出
123
+ 2. **合成 Round N 总结**:汇总专家意见、共识度、待处理问题
124
+ 3. **自动启动 Round N+1**:立即 dispatch 新一轮 subagent 任务,携带上一轮总结作为上下文
125
+ 4. **循环直至终止**:重复步骤 1-3,直到达到终止条件
126
+
127
+ **终止条件**(满足全部):
128
+ - ✅ 所有专家状态 = APPROVED
129
+ - ✅ 共识度 ≥ 90%
130
+ - ✅ 所有 Critical 级别问题已解决
131
+ - ✅ 所有 Major 级别问题已处理(或已记录为已知问题)
132
+
133
+ **例外情况**(直接输出,不进入下一轮):
134
+ - Round 1 即达到 100% approved + 100% consensus → 直接输出最终报告
135
+ - 已达最大轮数(5 轮)→ 输出"未达成共识"报告,标记为 PROCESS_BLOCK
136
+
137
+ **禁止行为**:
138
+ - ❌ 询问用户"要继续吗?"
139
+ - ❌ 等待用户手动触发 Round N+1
140
+ - ❌ 在未达到终止条件时停止流程
141
+
142
+ **错误处理**:
143
+ - 背景任务超时(>10min)→ 标记为 TIMEOUT,输出部分结果并终止
144
+ - 背景任务失败(subagent 错误)→ 重试 1 次,仍失败则输出错误报告并终止
145
+
112
146
  ---
113
147
 
114
148
  ## 修复与重新评审
@@ -1,9 +1,9 @@
1
1
  # SKILLS/SPRINT-FLOW KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-06-19
4
- **Commit:** b67f7f9
3
+ **Generated:** 2026-06-21
4
+ **Commit:** 1050a30
5
5
  **Branch:** main
6
- **Version:** 0.9.4.0
6
+ **Version:** 0.9.5.0
7
7
 
8
8
  ## OVERVIEW
9
9
  **11-phase** development pipeline: ISOLATE → AUTO-ESTIMATE → THINK → PLAN → BUILD → REVIEW → USER ACCEPTANCE → FEEDBACK → SHIP → LAND → CLEANUP. Phase 2 default build mode is **ralph-loop** (REQ-level iteration, 40-67% token savings vs parallel). HARD-GATE in Phase 1: design must pass Delphi review (≥90% consensus) before any coding.
@@ -408,6 +408,58 @@ Sprint Flow: ISOLATE → AUTO-ESTIMATE → THINK → PLAN → BUILD → REVIEW
408
408
 
409
409
  ---
410
410
 
411
+ ### ⭐ Phase State Persistence(阶段状态持久化 — MANDATORY)
412
+
413
+ **编排器必须在每个 Phase 完成后更新 `.sprint-state/sprint-state.json`**:
414
+
415
+ 1. **Phase 完成后立即更新**(每个 Phase 结束前):
416
+ - `phase`: 更新为当前 Phase 编号(如 `0`, `1`, `2`...)
417
+ - `status`: 更新为 `"completed"`(已完成 Phase)
418
+ - `phase_history`: 追加新条目
419
+
420
+ 2. **`phase_history` 数组条目 schema**:
421
+ ```json
422
+ {
423
+ "phase": 0,
424
+ "phase_name": "THINK",
425
+ "status": "completed",
426
+ "timestamp": "2026-06-20T10:30:00Z"
427
+ }
428
+ ```
429
+
430
+ 3. **检查点**:
431
+ - `--status` 参数读取 `sprint-state.json` 并渲染进度看板
432
+ - TUI panel 显示当前 Phase 和历史
433
+ - `--resume-from` 校验 `phase_history` 中的最后完成 Phase
434
+
435
+ 4. **完整 sprint-state.json 示例**:
436
+ ```json
437
+ {
438
+ "id": "sprint-2026-06-20-01",
439
+ "phase": 2,
440
+ "status": "in_progress",
441
+ "phase_history": [
442
+ {"phase": -1, "phase_name": "ISOLATE", "status": "completed", "timestamp": "2026-06-20T10:00:00Z"},
443
+ {"phase": -0.5, "phase_name": "AUTO-ESTIMATE", "status": "completed", "timestamp": "2026-06-20T10:05:00Z"},
444
+ {"phase": 0, "phase_name": "THINK", "status": "completed", "timestamp": "2026-06-20T10:15:00Z"},
445
+ {"phase": 1, "phase_name": "PLAN", "status": "completed", "timestamp": "2026-06-20T10:30:00Z"}
446
+ ],
447
+ "isolation": {
448
+ "worktree_path": "/home/boyingliu01/projects/xp-gate/.worktrees/sprint/sprint-2026-06-20-01",
449
+ "branch": "sprint/2026-06-20-01"
450
+ },
451
+ "outputs": {
452
+ "pain_document": "phase-outputs/phase-0-summary.md",
453
+ "specification": "phase-outputs/specification.yaml"
454
+ },
455
+ "metrics": {
456
+ "coverage_pct": 85.5
457
+ }
458
+ }
459
+ ```
460
+
461
+ ---
462
+
411
463
  ## 使用示例
412
464
 
413
465
  | 场景 | 命令 | 说明 |
@@ -447,7 +499,7 @@ See [Output Contract](#output-contract) below for the canonical machine-readable
447
499
 
448
500
  **Phase Summary** (每个 Phase 必须输出 YAML frontmatter): `phase/N`, `phase_name`, `status`, `outputs[]`, `decisions[]`, `next_phase_context` + markdown body (≤50 lines)
449
501
 
450
- **Sprint State JSON**: `{id, phase, status, isolation {worktree_path, branch}, outputs, metrics}` — 存储于 `.sprint-state/sprint-state.json`
502
+ **Sprint State JSON**: `{id, phase, status, phase_history[], isolation {worktree_path, branch}, outputs, metrics}` — 存储于 `.sprint-state/sprint-state.json`
451
503
 
452
504
  **Final User-Facing Output**: Phase/status, file paths, validation results, next user decision, PR URL or cleanup report
453
505
 
@@ -1,9 +1,9 @@
1
1
  # SKILLS/TEST-SPECIFICATION-ALIGNMENT KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-06-19
4
- **Commit:** b67f7f9
3
+ **Generated:** 2026-06-21
4
+ **Commit:** 1050a30
5
5
  **Branch:** main
6
- **Version:** 0.9.4.0
6
+ **Version:** 0.9.5.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.