@boyingliu01/xp-gate 0.12.9 → 0.12.12

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 (58) hide show
  1. package/adapter-common.sh +13 -18
  2. package/adapters/typescript.sh +87 -10
  3. package/gate-3.sh +1 -1
  4. package/hooks/adapter-common.sh +13 -18
  5. package/hooks/pre-commit +166 -27
  6. package/hooks/pre-push +231 -18
  7. package/lib/__tests__/doctor.test.js +65 -38
  8. package/lib/__tests__/sprint-discovery.test.ts +5 -4
  9. package/lib/__tests__/sprint-status.test.ts +5 -4
  10. package/lib/__tests__/tsconfig.json +8 -0
  11. package/lib/check-version.js +19 -4
  12. package/lib/init.js +24 -0
  13. package/lib/upgrade.js +64 -0
  14. package/mock-policy/AGENTS.md +3 -3
  15. package/mutation/AGENTS.md +3 -3
  16. package/mutation/runners/stryker-runner.ts +7 -5
  17. package/package.json +1 -1
  18. package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
  19. package/plugins/claude-code/skills/delphi-review/AGENTS.md +3 -3
  20. package/plugins/claude-code/skills/sprint-flow/AGENTS.md +3 -3
  21. package/plugins/claude-code/skills/sprint-flow/SKILL.md +117 -14
  22. package/plugins/claude-code/skills/sprint-flow/__tests__/sprint-flow.test.cjs +444 -0
  23. package/plugins/claude-code/skills/sprint-flow/references/phase-2-build.md +104 -0
  24. package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +3 -3
  25. package/plugins/opencode/package.json +1 -1
  26. package/plugins/opencode/skills/delphi-review/AGENTS.md +3 -3
  27. package/plugins/opencode/skills/sprint-flow/AGENTS.md +3 -3
  28. package/plugins/opencode/skills/sprint-flow/SKILL.md +117 -14
  29. package/plugins/opencode/skills/sprint-flow/__tests__/sprint-flow.test.cjs +444 -0
  30. package/plugins/opencode/skills/sprint-flow/references/phase-2-build.md +104 -0
  31. package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +3 -3
  32. package/plugins/qoder/plugin.json +1 -1
  33. package/plugins/qoder/skills/delphi-review/AGENTS.md +3 -3
  34. package/plugins/qoder/skills/sprint-flow/AGENTS.md +3 -3
  35. package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +3 -3
  36. package/principles/AGENTS.md +3 -3
  37. package/principles/__tests__/baseline-storage.test.ts +3 -2
  38. package/principles/__tests__/baseline.test.ts +16 -14
  39. package/principles/__tests__/config.test.ts +1 -1
  40. package/principles/__tests__/types.test.ts +1 -0
  41. package/principles/adapters/__tests__/base.test.ts +8 -8
  42. package/principles/adapters/__tests__/cpp.test.ts +26 -26
  43. package/principles/adapters/__tests__/dart.test.ts +11 -11
  44. package/principles/adapters/__tests__/go.test.ts +9 -9
  45. package/principles/adapters/__tests__/java.test.ts +9 -9
  46. package/principles/adapters/__tests__/kotlin.test.ts +10 -10
  47. package/principles/adapters/__tests__/objectivec.test.ts +27 -27
  48. package/principles/adapters/__tests__/python.test.ts +11 -11
  49. package/principles/adapters/__tests__/swift.test.ts +9 -9
  50. package/principles/adapters/__tests__/typescript.test.ts +13 -13
  51. package/principles/config.ts +1 -1
  52. package/principles/rules/__tests__/clean-code/large-file.test.ts +10 -9
  53. package/skills/delphi-review/AGENTS.md +3 -3
  54. package/skills/sprint-flow/AGENTS.md +3 -3
  55. package/skills/sprint-flow/SKILL.md +117 -14
  56. package/skills/sprint-flow/__tests__/sprint-flow.test.cjs +444 -0
  57. package/skills/sprint-flow/references/phase-2-build.md +104 -0
  58. package/skills/test-specification-alignment/AGENTS.md +3 -3
package/lib/init.js CHANGED
@@ -384,6 +384,20 @@ async function installLocal(args) {
384
384
 
385
385
  console.log('\nInstallation complete!');
386
386
  console.log('Run git commit to trigger quality gates');
387
+ console.log('');
388
+ console.log('━━━ FIRST-CLASS TEST QUALITY ━━━');
389
+ console.log('XP-Gate treats test code as a first-class citizen:');
390
+ console.log(' • TypeScript: test files are type-checked, not excluded from tsconfig.json');
391
+ console.log(' • Static analysis: lint/ESLint/Biome check test files alongside source');
392
+ console.log(' • Complexity: cyclomatic complexity is measured on test files too');
393
+ console.log(' • Duplicate code: jscpd scans test files (fixtures/snapshots excluded)');
394
+ console.log(' • Architecture: archlint validates test code structure');
395
+ console.log('');
396
+ console.log(' To include tests in your project:');
397
+ console.log(' 1. Remove __tests__/ from tsconfig.json exclude');
398
+ console.log(' 2. Remove __tests__/ from jscpd.conf.json ignore');
399
+ console.log(' 3. Add tsconfig.json: "types": ["vitest/globals"]');
400
+ console.log(' 4. Run "xp-gate doctor" to verify setup');
387
401
  return 0;
388
402
  }
389
403
 
@@ -441,6 +455,16 @@ async function setupGlobal(args) {
441
455
  console.log('\nGlobal setup complete!');
442
456
  console.log('All git repositories will now use xp-gate quality gates.');
443
457
  console.log('Per-project adapters can still override by creating <repo>/githooks/');
458
+ console.log('');
459
+ console.log('━━━ FIRST-CLASS TEST QUALITY ━━━');
460
+ console.log('XP-Gate treats test code as a first-class citizen:');
461
+ console.log(' All quality gates apply equally to test files.');
462
+ console.log(' To include tests in your project:');
463
+ console.log(' 1. Remove __tests__/ from tsconfig.json exclude');
464
+ console.log(' 2. Remove __tests__/ from jscpd.conf.json ignore');
465
+ console.log(' 3. Remove test patterns from .archlint.yaml ignore');
466
+ console.log(' 4. Add "types": ["vitest/globals"] to tsconfig.json');
467
+ console.log(' 5. Run "xp-gate doctor" to verify');
444
468
  return 0;
445
469
  }
446
470
 
package/lib/upgrade.js CHANGED
@@ -1,6 +1,8 @@
1
1
  const { execSync, spawn } = require('child_process');
2
2
  const { checkUpgrade, formatUpgradeMsg, clearCache, getLocalVersion, getPackageName } = require('./check-version.js');
3
3
 
4
+ const OPENCODE_PLUGIN = '@boyingliu01/opencode-plugin';
5
+
4
6
  /**
5
7
  * Handle checkUpgrade() failure.
6
8
  * @param {Error} err
@@ -59,6 +61,7 @@ function handlePreviewMode(result) {
59
61
 
60
62
  /**
61
63
  * Handle --apply mode: auto-upgrade via npm install -g.
64
+ * Also checks for and updates the local OpenCode plugin.
62
65
  * @param {{ local: string, remote: string, outdated: boolean }} result
63
66
  * @param {string} pkgName
64
67
  * @returns {Promise<number>} exit code
@@ -88,6 +91,10 @@ async function handleApplyMode(result, pkgName) {
88
91
  });
89
92
  clearCache();
90
93
  console.log(`\u2713 Upgraded to v${result.remote}`);
94
+
95
+ // Also check for and update the local OpenCode plugin if installed.
96
+ await upgradeOpenCodePlugin();
97
+
91
98
  return 0;
92
99
  } catch (err) {
93
100
  const msg = err.message || '';
@@ -105,6 +112,63 @@ async function handleApplyMode(result, pkgName) {
105
112
  }
106
113
  }
107
114
 
115
+ async function upgradeOpenCodePlugin() {
116
+ try {
117
+ const hasPlugin = await hasOpenCodePlugin();
118
+ if (!hasPlugin) return;
119
+
120
+ const { stdout: versionOut } = await execAsync('npm list -g ' + OPENCODE_PLUGIN + ' --depth=0 --json 2>/dev/null');
121
+ let currentVersion = '';
122
+ try {
123
+ const parsed = JSON.parse(versionOut);
124
+ const deps = parsed.dependencies || {};
125
+ currentVersion = deps[OPENCODE_PLUGIN]?.version || '';
126
+ } catch { /* skip parse error */ }
127
+ if (currentVersion) {
128
+ console.log(` Found OpenCode plugin v${currentVersion} — upgrading to latest...`);
129
+ }
130
+
131
+ const child = spawn('npm', ['install', '-g', OPENCODE_PLUGIN + '@latest'], {
132
+ stdio: 'pipe',
133
+ timeout: 120000,
134
+ });
135
+ const exitCode = await new Promise((resolve) => {
136
+ child.on('close', (code) => resolve(code));
137
+ child.on('error', () => resolve(1));
138
+ });
139
+ if (exitCode === 0) {
140
+ console.log(' Also updated local OpenCode plugin');
141
+ }
142
+ } catch {
143
+ // Non-blocking: plugin upgrade failure should never break the main flow.
144
+ }
145
+ }
146
+
147
+ function hasOpenCodePlugin() {
148
+ return new Promise((resolve) => {
149
+ const child = spawn('npm', ['list', '-g', OPENCODE_PLUGIN, '--depth=0'], {
150
+ stdio: 'pipe',
151
+ timeout: 10000,
152
+ });
153
+ child.on('close', (code) => resolve(code === 0));
154
+ child.on('error', () => resolve(false));
155
+ });
156
+ }
157
+
158
+ function execAsync(cmd) {
159
+ return new Promise((resolve, reject) => {
160
+ const child = spawn(cmd, { shell: true, stdio: 'pipe', timeout: 10000 });
161
+ let stdout = '', stderr = '';
162
+ child.stdout.on('data', (d) => { stdout += d; });
163
+ child.stderr.on('data', (d) => { stderr += d; });
164
+ child.on('close', (code) => {
165
+ if (code === 0) resolve({ stdout, stderr });
166
+ else reject(new Error(stderr || `exit code ${code}`));
167
+ });
168
+ child.on('error', reject);
169
+ });
170
+ }
171
+
108
172
  /**
109
173
  * Handle default mode: human-readable output.
110
174
  * @param {{ local: string, remote: string, outdated: boolean, lagDays: number, publishedAt?: string }} result
@@ -1,9 +1,9 @@
1
1
  # SRC/MOCK-POLICY KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-07-05
4
- **Commit:** a620d9b
3
+ **Generated:** 2026-07-06
4
+ **Commit:** 132a12e
5
5
  **Branch:** main
6
- **Version:** 0.12.9.0
6
+ **Version:** 0.12.12.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-07-05
4
- **Commit:** a620d9b
3
+ **Generated:** 2026-07-06
4
+ **Commit:** 132a12e
5
5
  **Branch:** main
6
- **Version:** 0.12.9.0
6
+ **Version:** 0.12.12.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.
@@ -1,6 +1,6 @@
1
1
  // @no-test-required: Stryker wrapper — tested via gate-m integration + pre-push Gate M
2
2
  import { spawn } from 'child_process';
3
- import { readFileSync } from 'fs';
3
+ import { existsSync, readFileSync } from 'fs';
4
4
  import { join } from 'path';
5
5
  import type {
6
6
  MutationRunner,
@@ -36,11 +36,11 @@ export class StrykerRunner implements MutationRunner {
36
36
 
37
37
  async run(options: RunMutationOptions): Promise<MutationRunOutcome> {
38
38
  return new Promise((resolve) => {
39
+ const configPath = this.resolveConfig(options.cwd);
39
40
  const args = [
40
41
  'stryker',
41
42
  'run',
42
- '--config',
43
- this.resolveConfig(options.cwd),
43
+ ...(configPath ? ['--config', configPath] : []),
44
44
  ...options.files.flatMap(f => ['--mutate', f]),
45
45
  ];
46
46
 
@@ -91,8 +91,10 @@ export class StrykerRunner implements MutationRunner {
91
91
  });
92
92
  }
93
93
 
94
- private resolveConfig(cwd: string): string {
95
- return join(cwd, STRYKER_PREPUSH_CONFIG);
94
+ private resolveConfig(cwd: string): string | null {
95
+ const configPath = join(cwd, STRYKER_PREPUSH_CONFIG);
96
+ if (existsSync(configPath)) return configPath;
97
+ return null;
96
98
  }
97
99
 
98
100
  private parseReport(cwd: string): MutationRunResult | null {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boyingliu01/xp-gate",
3
- "version": "0.12.9",
3
+ "version": "0.12.12",
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.12.9",
3
+ "version": "0.12.12",
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-07-05
4
- **Commit:** a620d9b
3
+ **Generated:** 2026-07-06
4
+ **Commit:** 132a12e
5
5
  **Branch:** main
6
- **Version:** 0.12.9.0
6
+ **Version:** 0.12.12.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-07-05
4
- **Commit:** a620d9b
3
+ **Generated:** 2026-07-06
4
+ **Commit:** 132a12e
5
5
  **Branch:** main
6
- **Version:** 0.12.9.0
6
+ **Version:** 0.12.12.0
7
7
 
8
8
  ## OVERVIEW
9
9
  **11-phase** development pipeline: ISOLATE → AUTO-ESTIMATE → THINK → PLAN → BUILD → REVIEW → SHIP → LAND → USER ACCEPTANCE → FEEDBACK → 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.
@@ -13,7 +13,7 @@ description: >
13
13
  - "start sprint"
14
14
  - "一键开发"
15
15
  - "/sprint-flow"
16
- 触发后第一行输出: `Sprint Flow: ISOLATE → AUTO-ESTIMATE → THINK → PLAN → BUILD → REVIEW → SHIP → LAND → USER ACCEPTANCE → FEEDBACK → CLEANUP`
16
+ 触发后第一行输出: `Sprint Flow: ISOLATE → AUTO-ESTIMATE → THINK → PLAN → BUILD → REVIEW → FEEDBACK → SHIP → LAND → USER ACCEPTANCE → CLEANUP`
17
17
  用法: /sprint-flow "[需求描述]"
18
18
  示例: /sprint-flow "开发访谈机器人,支持多轮对话"
19
19
  可选参数:
@@ -37,6 +37,44 @@ triggers:
37
37
  - "开发新功能"
38
38
  - "实现 X"
39
39
  - "一键开发"
40
+ triggers_negative_examples:
41
+ - "实现排序算法" # algorithm implementation, not feature development
42
+ - "实现一下" # casual "do it", not a sprint request
43
+ - "帮我实现这个函数" # single function, not full feature
44
+ - "怎么实现登录功能" # asking HOW, not requesting development
45
+ - "start spring boot" # framework name, not sprint
46
+ - "开发环境配置" # environment setup, not feature development
47
+ - "一键部署" # deploy, not develop
48
+ - "新功能建议" # feature suggestion/request, not execution
49
+ - "implement a sort function" # algorithm, not full feature
50
+ - "how to implement auth" # educational question
51
+ triggers_negative_test_cases:
52
+ - input: "实现排序算法"
53
+ expect: "NOT triggered"
54
+ - input: "实现一下"
55
+ expect: "NOT triggered"
56
+ - input: "帮我实现这个函数"
57
+ expect: "NOT triggered"
58
+ - input: "怎么实现登录功能"
59
+ expect: "NOT triggered"
60
+ - input: "start spring boot"
61
+ expect: "NOT triggered"
62
+ - input: "开发环境配置"
63
+ expect: "NOT triggered"
64
+ - input: "一键部署"
65
+ expect: "NOT triggered"
66
+ - input: "新功能建议"
67
+ expect: "NOT triggered"
68
+ - input: "implement a sort function"
69
+ expect: "NOT triggered"
70
+ - input: "how to implement auth"
71
+ expect: "NOT triggered"
72
+ - input: "开发用户认证模块"
73
+ expect: "triggered"
74
+ - input: "/sprint-flow \"开发访谈机器人\""
75
+ expect: "triggered"
76
+ - input: "一键开发 REST API"
77
+ expect: "triggered"
40
78
  workflow_steps:
41
79
  - "Phase -1: ISOLATE"
42
80
  - "Phase -0.5: AUTO-ESTIMATE"
@@ -108,6 +146,35 @@ workflow_steps:
108
146
 
109
147
  ---
110
148
 
149
+ ## Unique Value Proposition
150
+
151
+ Sprint Flow is NOT just a sequential launcher of existing skills. Here's what makes it different from manually running each skill:
152
+
153
+ ### Why Sprint Flow vs Manual Skill Execution
154
+
155
+ | Dimension | Manual Execution | Sprint Flow |
156
+ |-----------|-----------------|-------------|
157
+ | **Context Continuity** | Each skill starts fresh; lost design decisions between phases | Phase summaries + sprint-state.json maintain full traceability across 11 phases |
158
+ | **Gate Enforcement** | No enforcement — easy to skip Delphi, skip TDD, skip UAT | HARD-GATE: design must be APPROVED (≥90% Delphi consensus) before coding; UAT is mandatory (no bypass) |
159
+ | **Token Efficiency** | Linear context accumulation across phases — ~150K+ tokens | Ralph-loop default: 40-67% token savings via clean REQ-level contexts |
160
+ | **Emergent Requirements** | Discovered late, silently ignored or merged | Phase 7 USER ACCEPTANCE explicitly captures emergent issues via template; triggers Sprint 2 for critical issues |
161
+ | **Quality Ecosystem** | No integration with quality gates | Integrated with xp-gate's full quality ecosystem: Gate 5 (coverage), Gate M2 (mock density), Delphi code-walkthrough |
162
+ | **Progress Tracking** | Ad-hoc, memory-based | `.sprint-state/` persistence with phase history, timing, and metrics — `--status` renders progress dashboard |
163
+
164
+ ### Key Differentiators
165
+
166
+ 1. **40-67% Token Savings via Ralph Loop**: Phase 2 default (`ralph-loop`) processes one REQ at a time with clean context, avoiding the linear context accumulation that costs 150K+ tokens in parallel mode.
167
+
168
+ 2. **HARD-GATE Discipline**: Design must pass Delphi review (≥90% consensus, ≥2 model providers, domestic models only) before Phase 2 BUILD can start. This is enforced both in SKILL.md instructions and via the Claude Code plugin's PreToolUse hook.
169
+
170
+ 3. **Emergent Requirements Acknowledgment**: Based on research showing 78% of failures are invisible to AI (arXiv study), Phase 7 USER ACCEPTANCE is a mandatory manual verification step — cannot be automated, skipped, or bypassed.
171
+
172
+ 4. **XP-Gate Quality Ecosystem Integration**: Sprint Flow is part of the broader xp-gate ecosystem. Phase 2 BUILD integrates with Gate 5 (test coverage ≥80%), Gate M2 (mock density ≤30%), and Gate MW (code-walkthrough validation). Phase 3 REVIEW runs Delphi code-walkthrough that generates `.code-walkthrough-result.json` for pre-push enforcement.
173
+
174
+ 5. **Full Lifecycle Coverage**: From worktree isolation (Phase -1) to cleanup (Phase 8), sprint-flow covers the entire development lifecycle — not just the "write code" part. AUTO-ESTIMATE (Phase -0.5) prevents over-engineering by routing lightweight changes through simplified workflows.
175
+
176
+ ---
177
+
111
178
  ## 完整流程(默认无参数)
112
179
 
113
180
  调用 `/sprint-flow "[需求描述]"` 后,自动执行以下流程:
@@ -162,7 +229,7 @@ Phase 8: CLEANUP → worktree remove + branch delete + sprint summary
162
229
 
163
230
  **Phase Flow**:
164
231
  ```
165
- ISOLATE → AUTO-ESTIMATE → THINK → PLAN → [GITHOOKS-GATE] → BUILD → REVIEW → SHIP → LAND → USER ACCEPTFEEDBACK → CLEANUP
232
+ ISOLATE → AUTO-ESTIMATE → THINK → PLAN → [GITHOOKS-GATE] → BUILD → REVIEW → FEEDBACK → SHIP → LAND → USER ACCEPTANCE → CLEANUP
166
233
  ```
167
234
 
168
235
  **Hard Gates**:
@@ -202,7 +269,7 @@ ISOLATE → AUTO-ESTIMATE → THINK → PLAN → [GITHOOKS-GATE] → BUILD → R
202
269
  6. 触发 `/sprint-flow` 后,**第一行输出应包含工作流阶段概览**:
203
270
 
204
271
  ```
205
- Sprint Flow: ISOLATE → AUTO-ESTIMATE → THINK → PLAN → BUILD → REVIEW → SHIP → LAND → USER ACCEPTANCE → FEEDBACK → CLEANUP
272
+ Sprint Flow: ISOLATE → AUTO-ESTIMATE → THINK → PLAN → BUILD → REVIEW → FEEDBACK → SHIP → LAND → USER ACCEPTANCE → CLEANUP
206
273
  ```
207
274
 
208
275
  ### Phase -1: ISOLATE(git worktree 隔离)
@@ -508,17 +575,22 @@ See [Output Contract](#output-contract) below for the canonical machine-readable
508
575
  ## References
509
576
 
510
577
  详细指令文件位于 `@references/`:
511
- - `@references/phase-minus-1-isolate.md` — Phase -1 详细指令
512
- - `@references/phase-minus-0-5-auto-estimate.md` Phase -0.5 详细指令
513
- - `@references/phase-0-think.md` — Phase 0 详细指令
514
- - `@references/phase-1-plan.md` Phase 1 详细指令
515
- - `@references/phase-2-build.md` — Phase 2 详细指令
516
- - `@references/phase-3-review.md` Phase 3 详细指令
517
- - `@references/phase-4-uat.md` Phase 7 USER ACCEPTANCE 详细指令(人工)
518
- - `@references/phase-5-feedback.md` Phase 4 FEEDBACK 详细指令
519
- - `@references/phase-6-ship.md` Phase 5 SHIP 详细指令
520
- - `@references/phase-7-land.md` Phase 6 LAND 详细指令
521
- - `@references/phase-8-cleanup.md` Phase 8 CLEANUP 详细指令
578
+
579
+ > ⚠️ **Filename numbering note**: Reference filenames use legacy numbering that does NOT match the canonical phase numbers in this document. The table below provides the correct mapping.
580
+
581
+ | File | Canonical Phase | Phase Name |
582
+ |------|----------------|------------|
583
+ | `@references/phase-minus-1-isolate.md` | Phase -1 | ISOLATE |
584
+ | `@references/phase-minus-0-5-auto-estimate.md` | Phase -0.5 | AUTO-ESTIMATE |
585
+ | `@references/phase-0-think.md` | Phase 0 | THINK |
586
+ | `@references/phase-1-plan.md` | Phase 1 | PLAN |
587
+ | `@references/phase-2-build.md` | Phase 2 | BUILD |
588
+ | `@references/phase-3-review.md` | Phase 3 | REVIEW |
589
+ | `@references/phase-5-feedback.md` | Phase 4 | FEEDBACK (⚠️ filename says phase-5) |
590
+ | `@references/phase-6-ship.md` | Phase 5 | SHIP (⚠️ filename says phase-6) |
591
+ | `@references/phase-7-land.md` | Phase 6 | LAND (⚠️ filename says phase-7) |
592
+ | `@references/phase-4-uat.md` | Phase 7 | USER ACCEPTANCE (⚠️ filename says phase-4) |
593
+ | `@references/phase-8-cleanup.md` | Phase 8 | CLEANUP |
522
594
 
523
595
  ---
524
596
 
@@ -543,3 +615,34 @@ See [Output Contract](#output-contract) below for the canonical machine-readable
543
615
  | 78% failures invisible | arXiv research | Phase 7 必要性证明 |
544
616
  | Think → Plan → Build → Ship | gstack ETHOS | 整体流程设计 |
545
617
 
618
+ ---
619
+
620
+ ## Phase Flow Consistency
621
+
622
+ This section documents the canonical 11-phase order to ensure all future edits keep the phase sequence synchronized across all locations in this document and its reference files.
623
+
624
+ **Canonical Phase Order** (Phase -1, -0.5, 0..8):
625
+
626
+ | Phase # | Name | Phase # | Name |
627
+ |---------|------|---------|------|
628
+ | -1 | ISOLATE | 4 | FEEDBACK |
629
+ | -0.5 | AUTO-ESTIMATE | 5 | SHIP |
630
+ | 0 | THINK | 6 | LAND |
631
+ | 1 | PLAN | 7 | USER ACCEPTANCE |
632
+ | 2 | BUILD | 8 | CLEANUP |
633
+ | 3 | REVIEW | | |
634
+
635
+ **Locations that MUST keep this order synchronized**:
636
+ 1. **Frontmatter `workflow_steps`** (lines ~40-51): Phase list
637
+ 2. **Frontmatter `description` trigger text** (line ~16): Flow string
638
+ 3. **Body "完整流程" section** (lines ~115-127): Phase descriptions in order
639
+ 4. **Body "Phase Flow" diagram** (line ~164): ASCII flow diagram
640
+ 5. **Body "强制输出格式规范" section** (line ~204): Output format
641
+ 6. **Body "Workflow Steps" table** (lines ~149-162): Step/Phase table
642
+ 7. **Body "References" section** (lines ~516-521): Reference file list
643
+ 8. **`references/orchestration-rules.md` Phase Subagent Dispatch Matrix**: Phase/Name order
644
+ 9. **`references/phase-4-uat.md`**: Phase 7 USER ACCEPTANCE (⚠️ file named phase-4, phase number is 7)
645
+ 10. **`references/phase-5-feedback.md`**: Phase 4 FEEDBACK (⚠️ file named phase-5, phase number is 4)
646
+
647
+ **⚠️ Known naming discrepancy**: Reference files use legacy numbering (`phase-4-uat.md` for Phase 7, `phase-5-feedback.md` for Phase 4, `phase-6-ship.md` for Phase 5, `phase-7-land.md` for Phase 6). The canonical phase NUMBER is determined by the `Phase #` column above — reference file names are mapped via the References section, not by their filename digits.
648
+