@boyingliu01/xp-gate 0.8.8 → 0.8.10

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 (141) hide show
  1. package/bin/xp-gate.js +18 -0
  2. package/hooks/pre-commit +565 -120
  3. package/lib/arch.js +49 -0
  4. package/lib/check.js +50 -0
  5. package/lib/init.js +36 -0
  6. package/lib/principles.js +48 -0
  7. package/mock-policy/AGENTS.md +94 -0
  8. package/mock-policy/__tests__/config.test.ts +292 -0
  9. package/mock-policy/__tests__/integration.test.ts +600 -0
  10. package/mock-policy/__tests__/mock-decision-engine.test.ts +231 -0
  11. package/mock-policy/__tests__/scope-scanner.test.ts +535 -0
  12. package/mock-policy/config.ts +106 -0
  13. package/mock-policy/gate-m3.ts +233 -0
  14. package/mock-policy/mock-decision-engine.ts +155 -0
  15. package/mock-policy/schema.ts +22 -0
  16. package/mock-policy/scope-scanner.ts +288 -0
  17. package/mock-policy/types.ts +65 -0
  18. package/mutation/AGENTS.md +73 -0
  19. package/mutation/__tests__/detect-ai-test.test.ts +152 -0
  20. package/mutation/__tests__/gate-m.test.ts +194 -0
  21. package/mutation/detect-ai-test.ts +128 -0
  22. package/mutation/gate-m.ts +619 -0
  23. package/mutation/init-baseline.ts +192 -0
  24. package/mutation/stryker-types.ts +14 -0
  25. package/mutation/types.ts +70 -0
  26. package/mutation/update-baseline.ts +160 -0
  27. package/package.json +5 -2
  28. package/plugins/claude-code/.claude-plugin/plugin.json +2 -2
  29. package/plugins/claude-code/skills/delphi-review/AGENTS.md +7 -7
  30. package/plugins/claude-code/skills/delphi-review/INSTALL.md +1 -1
  31. package/plugins/claude-code/skills/delphi-review/SKILL.md +12 -12
  32. package/plugins/claude-code/skills/delphi-review/references/code-walkthrough.md +1 -1
  33. package/plugins/claude-code/skills/sprint-flow/AGENTS.md +83 -36
  34. package/plugins/claude-code/skills/sprint-flow/SKILL.md +1 -1
  35. package/plugins/claude-code/skills/sprint-flow/references/force-levels.md +1 -1
  36. package/plugins/claude-code/skills/sprint-flow/references/phase-3-review.md +2 -2
  37. package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +3 -3
  38. package/plugins/opencode/README.md +23 -7
  39. package/plugins/opencode/index.ts +36 -21
  40. package/plugins/opencode/package.json +1 -1
  41. package/plugins/opencode/skills/delphi-review/AGENTS.md +7 -7
  42. package/plugins/opencode/skills/delphi-review/INSTALL.md +1 -1
  43. package/plugins/opencode/skills/delphi-review/SKILL.md +12 -12
  44. package/plugins/opencode/skills/delphi-review/references/code-walkthrough.md +1 -1
  45. package/plugins/opencode/skills/sprint-flow/AGENTS.md +83 -36
  46. package/plugins/opencode/skills/sprint-flow/SKILL.md +1 -1
  47. package/plugins/opencode/skills/sprint-flow/references/force-levels.md +1 -1
  48. package/plugins/opencode/skills/sprint-flow/references/phase-3-review.md +2 -2
  49. package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +3 -3
  50. package/plugins/qoder/plugin.json +20 -0
  51. package/plugins/qoder/skills/delphi-review/AGENTS.md +7 -7
  52. package/plugins/qoder/skills/delphi-review/INSTALL.md +1 -1
  53. package/plugins/qoder/skills/delphi-review/SKILL.md +12 -12
  54. package/plugins/qoder/skills/delphi-review/references/code-walkthrough.md +1 -1
  55. package/plugins/qoder/skills/sprint-flow/AGENTS.md +83 -36
  56. package/plugins/qoder/skills/sprint-flow/SKILL.md +51 -1
  57. package/plugins/qoder/skills/sprint-flow/references/force-levels.md +1 -1
  58. package/plugins/qoder/skills/sprint-flow/references/phase-3-review.md +2 -2
  59. package/plugins/qoder/skills/test-driven-development/SKILL.md +371 -0
  60. package/plugins/qoder/skills/test-driven-development/testing-anti-patterns.md +299 -0
  61. package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +3 -3
  62. package/principles/AGENTS.md +111 -0
  63. package/principles/__tests__/analyzer.test.ts +343 -0
  64. package/principles/__tests__/baseline-storage.test.ts +187 -0
  65. package/principles/__tests__/baseline.test.ts +328 -0
  66. package/principles/__tests__/boy-scout-integration.test.ts +264 -0
  67. package/principles/__tests__/boy-scout.test.ts +646 -0
  68. package/principles/__tests__/config.test.ts +78 -0
  69. package/principles/__tests__/index.test.ts +81 -0
  70. package/principles/__tests__/lint-baseline.test.ts +314 -0
  71. package/principles/__tests__/reporter.test.ts +832 -0
  72. package/principles/__tests__/types.test.ts +101 -0
  73. package/principles/adapters/__tests__/base.test.ts +95 -0
  74. package/principles/adapters/__tests__/cpp.test.ts +290 -0
  75. package/principles/adapters/__tests__/dart.test.ts +84 -0
  76. package/principles/adapters/__tests__/go.test.ts +68 -0
  77. package/principles/adapters/__tests__/java.test.ts +68 -0
  78. package/principles/adapters/__tests__/kotlin.test.ts +76 -0
  79. package/principles/adapters/__tests__/objectivec.test.ts +453 -0
  80. package/principles/adapters/__tests__/python.test.ts +84 -0
  81. package/principles/adapters/__tests__/swift.test.ts +68 -0
  82. package/principles/adapters/__tests__/typescript.test.ts +116 -0
  83. package/principles/adapters/base.ts +124 -0
  84. package/principles/adapters/cpp.ts +115 -0
  85. package/principles/adapters/dart.ts +44 -0
  86. package/principles/adapters/go.ts +55 -0
  87. package/principles/adapters/java.ts +56 -0
  88. package/principles/adapters/kotlin.ts +54 -0
  89. package/principles/adapters/objectivec.ts +82 -0
  90. package/principles/adapters/python.ts +83 -0
  91. package/principles/adapters/swift.ts +40 -0
  92. package/principles/adapters/typescript.ts +66 -0
  93. package/principles/analyzer.ts +190 -0
  94. package/principles/baseline.ts +273 -0
  95. package/principles/boy-scout.ts +416 -0
  96. package/principles/config.ts +118 -0
  97. package/principles/index.ts +87 -0
  98. package/principles/lint-baseline.ts +385 -0
  99. package/principles/reporter.ts +188 -0
  100. package/principles/rules/__tests__/clean-code/code-duplication.test.ts +84 -0
  101. package/principles/rules/__tests__/clean-code/deep-nesting.test.ts +74 -0
  102. package/principles/rules/__tests__/clean-code/god-class.test.ts +111 -0
  103. package/principles/rules/__tests__/clean-code/large-file.test.ts +73 -0
  104. package/principles/rules/__tests__/clean-code/long-function.test.ts +83 -0
  105. package/principles/rules/__tests__/clean-code/magic-numbers.test.ts +68 -0
  106. package/principles/rules/__tests__/clean-code/many-exports.test.ts +118 -0
  107. package/principles/rules/__tests__/clean-code/missing-error-handling.test.ts +173 -0
  108. package/principles/rules/__tests__/clean-code/too-many-params.test.ts +60 -0
  109. package/principles/rules/__tests__/clean-code/unused-imports.test.ts +107 -0
  110. package/principles/rules/__tests__/index.test.ts +49 -0
  111. package/principles/rules/__tests__/solid/dip.test.ts +121 -0
  112. package/principles/rules/__tests__/solid/isp.test.ts +60 -0
  113. package/principles/rules/__tests__/solid/lsp.test.ts +184 -0
  114. package/principles/rules/__tests__/solid/ocp.test.ts +69 -0
  115. package/principles/rules/__tests__/solid/srp.test.ts +89 -0
  116. package/principles/rules/clean-code/code-duplication.ts +31 -0
  117. package/principles/rules/clean-code/deep-nesting.ts +38 -0
  118. package/principles/rules/clean-code/god-class.ts +54 -0
  119. package/principles/rules/clean-code/large-file.ts +34 -0
  120. package/principles/rules/clean-code/long-function.ts +47 -0
  121. package/principles/rules/clean-code/magic-numbers.ts +59 -0
  122. package/principles/rules/clean-code/many-exports.ts +40 -0
  123. package/principles/rules/clean-code/missing-error-handling.ts +33 -0
  124. package/principles/rules/clean-code/too-many-params.ts +35 -0
  125. package/principles/rules/clean-code/unused-imports.ts +33 -0
  126. package/principles/rules/index.ts +61 -0
  127. package/principles/rules/solid/dip.ts +47 -0
  128. package/principles/rules/solid/isp.ts +37 -0
  129. package/principles/rules/solid/lsp.ts +79 -0
  130. package/principles/rules/solid/ocp.ts +40 -0
  131. package/principles/rules/solid/srp.ts +44 -0
  132. package/principles/types.ts +27 -0
  133. package/skills/delphi-review/AGENTS.md +7 -7
  134. package/skills/delphi-review/INSTALL.md +1 -1
  135. package/skills/delphi-review/SKILL.md +12 -12
  136. package/skills/delphi-review/references/code-walkthrough.md +1 -1
  137. package/skills/sprint-flow/AGENTS.md +83 -36
  138. package/skills/sprint-flow/SKILL.md +1 -1
  139. package/skills/sprint-flow/references/force-levels.md +1 -1
  140. package/skills/sprint-flow/references/phase-3-review.md +2 -2
  141. package/skills/test-specification-alignment/AGENTS.md +3 -3
@@ -1,68 +1,115 @@
1
1
  # SKILLS/SPRINT-FLOW KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-05-30
4
- **Version:** v0.8.1
3
+ **Generated:** 2026-06-14
4
+ **Commit:** e215a50
5
+ **Branch:** main
6
+ **Version:** 0.8.10.0
5
7
 
6
8
  ## OVERVIEW
7
- 7-phase development pipeline: THINK→PLAN→BUILD→REVIEW→USER ACCEPT→FEEDBACK→SHIP, with ralph-loop default build mode.
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.
10
+
11
+ > **Doc drift**: README/CAPABILITIES still describe a "7-phase" pipeline. The canonical 11-phase model lives in `SKILL.md` and is what actually executes. See root `AGENTS.md` → "Known Drift" #4.
8
12
 
9
13
  ## STRUCTURE
10
14
  ```
11
15
  skills/sprint-flow/
12
- ├── SKILL.md # 7-phase pipeline definition
16
+ ├── SKILL.md # 11-phase pipeline definition (canonical)
17
+ ├── AGENTS.md # This file (mirrored to 7 other locations — DO NOT edit mirrors)
13
18
  ├── evals/ # Evaluation test cases
14
- ├── evolution-history.json # Skill evolution tracking
15
- ├── evolution-log.md # Change history
16
- ├── references/ # Phase reference docs
17
- │ ├── phase-0-think.md # THINK phase guidelines
18
- └── ... # Other phase docs
19
- └── templates/ # Sprint templates
19
+ ├── evolution-history.json
20
+ ├── evolution-log.md
21
+ ├── references/
22
+ │ ├── phase-minus-0-5-auto-estimate.md # Phase -0.5: AUTO-ESTIMATE
23
+ ├── phase-0-think.md # Phase 0: brainstorming → CONTEXT.md + ADR
24
+ │ ├── phase-1-plan.md # Phase 1: autoplan + delphi-review (HARD-GATE)
25
+ │ ├── phase-2-build.md # Phase 2: ralph-loop default + TDD + test-align
26
+ │ ├── phase-3-review.md # Phase 3: code-walkthrough + QA + benchmark
27
+ │ ├── phase-4-uat.md # Phase 4: USER ACCEPTANCE
28
+ │ ├── phase-5-feedback.md # Phase 5: retro + debugging + learn
29
+ │ ├── phase-6-ship.md # Phase 6: finishing-dev-branch + PR
30
+ │ ├── phase-7-land.md # Phase 7: land + deploy
31
+ │ ├── phase-8-cleanup.md # Phase 8: sprint branch cleanup
32
+ │ ├── force-levels.md # Phase forcing rules
33
+ │ └── components/ # Reusable phase building blocks
34
+ └── templates/
35
+ ├── auto-estimate-output-template.md
36
+ ├── auto-estimate-learning-log.md
37
+ ├── pain-document-template.md
38
+ ├── sprint-progress-template.md
39
+ ├── sprint-summary-template.md
40
+ └── emergent-issues-template.md
20
41
  ```
21
42
 
22
43
  ## WHERE TO LOOK
23
44
  | Task | Location | Notes |
24
45
  |------|----------|-------|
25
- | Pipeline def | SKILL.md | 7 phases with hard gates |
46
+ | Pipeline definition | SKILL.md | 11 phases with HARD-GATE between Phase 1 and Phase 2 |
47
+ | Auto-estimate phase | references/phase-minus-0-5-auto-estimate.md | Sizing pass before THINK |
26
48
  | THINK phase | references/phase-0-think.md | brainstorming → CONTEXT.md + ADR |
27
- | Build mode | SKILL.md | ralph-loop (default) vs parallel |
49
+ | PLAN phase + HARD-GATE | references/phase-1-plan.md | autoplan → delphi-review specification.yaml |
50
+ | BUILD phase | references/phase-2-build.md | ralph-loop (default) vs parallel |
51
+ | Force-level rules | references/force-levels.md | Defines when each phase becomes mandatory |
52
+ | Templates | templates/ | Auto-estimate, sprint progress/summary, pain doc, emergent issues |
53
+
54
+ ## THE 11 PHASES
28
55
 
29
- ## 7 PHASES
30
56
  | Phase | Name | Key Action | Hard Gate |
31
57
  |-------|------|-----------|-----------|
32
- | 0 | THINK | brainstorming, CONTEXT.md, ADR | — |
33
- | 1 | PLAN | autoplan delphi-review specification.yaml | HARD-GATE: design must pass |
34
- | 2 | BUILD | ralph-loop (REQ-level iteration) + TDD + test-align | — |
58
+ | -1 | ISOLATE | Isolate working tree / worktree creation | — |
59
+ | -0.5 | AUTO-ESTIMATE | Sizing pass; emits estimate template | |
60
+ | 0 | THINK | brainstorming CONTEXT.md + ADR | — |
61
+ | 1 | PLAN | autoplan → delphi-review → specification.yaml | **HARD-GATE**: design must reach ≥90% Delphi consensus |
62
+ | 2 | BUILD | ralph-loop (REQ-level, default) + TDD + test-spec-alignment | — |
35
63
  | 3 | REVIEW | code-walkthrough + QA + benchmark | — |
36
- | 4 | USER ACCEPT | Manual verification | — |
37
- | 5 | FEEDBACK | Retro + debugging + learn | — |
38
- | 6 | SHIP | finishing-dev-branch + PR/merge | — |
64
+ | 4 | USER ACCEPTANCE | Manual verification | — |
65
+ | 5 | FEEDBACK | retro + debugging + `learn` (Sprint-level) | — |
66
+ | 6 | SHIP | finishing-a-development-branch PR | — |
67
+ | 7 | LAND | land + deploy + canary | — |
68
+ | 8 | CLEANUP | Sprint branch cleanup (per `docs/plans/2026-06-06-sprint-branch-cleanup-design.md`) | — |
39
69
 
40
70
  ## CONVENTIONS
41
- - ralph-loop is Phase 2 **default** mode (saves 40-67% tokens vs parallel)
42
- - delphi-review HARD-GATE in Phase 1: design unapproved → BLOCK coding
43
- - Each REQ in ralph-loop gets clean context (no linear accumulation)
44
- - `learn` called at Phase 5 + each REQ completion
71
+ - **ralph-loop is Phase 2 default**. Each REQ runs in a clean context (no linear accumulation), saving 40-67% tokens vs parallel mode.
72
+ - **delphi-review HARD-GATE in Phase 1**: design must reach ≥90% consensus across ≥2 model providers, domestic models only. Unapproved → BLOCK coding.
73
+ - **`learn` is called twice**: once per REQ in Phase 2 (ralph-loop internal, `progress.log` permanent/contextual classification) and once in Phase 5 (Sprint-level retro).
74
+ - **Phase isolation**: each phase has explicit entry/exit criteria documented in its `references/phase-*.md` file.
75
+ - **Emergent Requirements** discovered in Phase 4 (USER ACCEPTANCE) are explicitly captured via `templates/emergent-issues-template.md` — never silently merged.
76
+ - **Auto-detection**: Phase 0 uses `src/npm-package/lib/ui-detector.ts` to pick the right tech-stack templates.
45
77
 
46
78
  ## ANTI-PATTERNS (THIS PROJECT)
47
- - Do NOT skip delphi-review in Phase 1 — HARD-GATE blocks implementation
48
- - Do NOT use parallel build mode unless explicitly requested
49
- - Do NOT enter Phase 1 (PLAN) without completing THINK phase
50
- - DO NOT implement before design approval
79
+ - Do NOT skip `delphi-review` in Phase 1 — HARD-GATE blocks implementation.
80
+ - Do NOT use parallel build mode unless explicitly requested. Ralph-loop is the default for a reason.
81
+ - Do NOT enter Phase 1 (PLAN) without completing Phase 0 (THINK).
82
+ - Do NOT implement before design is APPROVED — Phase 1 must reach Delphi consensus first.
83
+ - Do NOT merge an Emergent Requirement into the original Sprint silently — capture it via the template.
84
+ - Do NOT terminate Delphi review before ≥90% consensus or 5 rounds, whichever first.
51
85
 
52
86
  ## UNIQUE STYLES
53
- - Auto-detects UI framework (ui-detector.ts in npm-package/lib/)
54
- - Supports --type and --lang flags for tech stack selection
55
- - Phase isolation: each phase has specific entry/exit criteria
56
- - Emergent Requirements acknowledged: user acceptance phase built in
87
+ - **11 phases** including negative-numbered pre-phases (-1, -0.5) intentional, captures the work that happens before "real" coding starts.
88
+ - **HARD-GATE** between PLAN and BUILD is enforced both in the SKILL.md instructions and in the Claude Code plugin's PreToolUse hook (`plugins/claude-code/bin/delphi-review-guard.sh`).
89
+ - **Per-REQ clean context in ralph-loop** = the core efficiency mechanism. Sprint-flow specifically chooses this over parallel mode.
90
+ - **Tech-stack auto-detection** via `--type` and `--lang` flags or `ui-detector.ts`.
57
91
 
58
92
  ## COMMANDS
59
93
  ```bash
94
+ /sprint-flow "开发用户登录" # Full 11-phase pipeline
95
+ /sprint-flow "开发用户登录" --type web-nextjs --lang typescript # Pin tech stack
96
+ /sprint-flow "开发用户登录" --phase build-only # Skip planning (advanced)
97
+ /sprint-flow "开发用户登录" --mode parallel # Legacy all-at-once (NOT default)
60
98
  /delphi-review "开发用户登录" --type web-nextjs --lang typescript
61
- /sprint-flow "开发用户登录" --phase build-only
62
- /sprint-flow "开发用户登录" --mode parallel # Legacy all-at-once
63
99
  ```
64
100
 
65
101
  ## NOTES
66
- - Integrates brainstorming, autoplan, delphi-review, TDD, test-specification-alignment
67
- - ralph-loop internal learnings via progress.log (permanent/contextual classification)
68
- - Phase 5 calls gstack/learn for Sprint-level retrospective
102
+ - Integrates: brainstorming, autoplan, delphi-review, TDD, test-specification-alignment, qa, design-review, benchmark, systematic-debugging, retro, learn, finishing-a-development-branch.
103
+ - ralph-loop's internal learnings are persisted via `progress.log` (permanent vs contextual classification).
104
+ - Phase 5 calls `gstack/learn` for Sprint-level retrospective.
105
+ - Phase 8 cleanup behavior is governed by `docs/plans/2026-06-06-sprint-branch-cleanup-design.md`.
106
+ - This `AGENTS.md` is the canonical version. **7 byte-identical mirrors** exist at:
107
+ - `plugins/claude-code/skills/sprint-flow/AGENTS.md`
108
+ - `plugins/opencode/skills/sprint-flow/AGENTS.md`
109
+ - `plugins/qoder/skills/sprint-flow/AGENTS.md`
110
+ - `src/npm-package/skills/sprint-flow/AGENTS.md`
111
+ - `src/npm-package/plugins/claude-code/skills/sprint-flow/AGENTS.md`
112
+ - `src/npm-package/plugins/opencode/skills/sprint-flow/AGENTS.md`
113
+ - `src/npm-package/plugins/qoder/skills/sprint-flow/AGENTS.md`
114
+ Mirrors are updated by `scripts/copy-skills.sh`. Do NOT edit them by hand.
115
+
@@ -247,7 +247,7 @@ ISOLATE → AUTO-ESTIMATE → THINK → PLAN → [GITHOOKS-GATE] → BUILD → R
247
247
  ```
248
248
 
249
249
  **Hard Gates**:
250
- - **Phase 0→1**: Design must be APPROVED by delphi-review (≥91% consensus)
250
+ - **Phase 0→1**: Design must be APPROVED by delphi-review (≥90% consensus)
251
251
  - **Phase 1→2**: GITHOOKS-GATE (hooks must be installed) + DELPHI-GATE (spec must be APPROVED)
252
252
  - **Phase 4→5**: User acceptance must be completed (mandatory manual step)
253
253
  - **Phase 5→6**: feedback-log.md must exist (HARD-GATE)
@@ -98,7 +98,7 @@ AUTO-ESTIMATE 输出 → Force Levels 执行 → 自动升级机制(如触发
98
98
 
99
99
  | 场景 | DELPHI-GATE | Force Levels |
100
100
  |------|------------|-------------|
101
- | Phase 1 设计评审 | 3 专家、≥95% 共识、生成 specification.yaml | 不适用(设计阶段) |
101
+ | Phase 1 设计评审 | 3 专家、≥90% 共识、生成 specification.yaml | 不适用(设计阶段) |
102
102
  | Phase 2 BUILD 入口 | **必须检查** `.sprint-state/delphi-reviewed.json` 中 `verdict=APPROVED` | 轻量/标准/复杂:通过对应强度的 delphi-review 生成该门禁文件 |
103
103
  | 轻量级评审 | 生成 `delphi-reviewed.json`(2 专家、1 轮、2/2 批准) | 2 专家、1 轮、写入门禁文件 |
104
104
  | 标准级评审 | 生成 `delphi-reviewed.json`(2 专家、最多 2 轮、2/2 批准) | 2 专家、最多 2 轮、写入门禁文件 |
@@ -11,7 +11,7 @@ Web 前端项目额外增加:系统化 QA、视觉审计、性能基线。
11
11
  ## 调用 Skills
12
12
 
13
13
  **所有项目**:
14
- - `delphi-review --mode code-walkthrough` — 多专家匿名代码走查(2-3 domestic models, >=95% consensus)
14
+ - `delphi-review --mode code-walkthrough` — 多专家匿名代码走查(2-3 domestic models, ≥90% consensus)
15
15
  - `test-specification-alignment` — 测试与 Spec 对齐验证
16
16
  - `browse` (gstack) — 浏览器自动化测试
17
17
 
@@ -43,7 +43,7 @@ delphi code-walkthrough 执行:
43
43
  - Round 1: 匿名独立评审(防止 anchoring bias)
44
44
  - Round 2: 交换意见,响应关切
45
45
  - Round 3: 最终立场(如需)
46
- - >=95% 共识 + APPROVED 才通过
46
+ - ≥90% 共识 + APPROVED 才通过
47
47
 
48
48
  **如果 REQUEST_CHANGES**:
49
49
  - ⚠️ 暂停等待用户修复 Critical Issues + 处理 Major Concerns
@@ -1,9 +1,9 @@
1
1
  # SKILLS/TEST-SPECIFICATION-ALIGNMENT KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-05-30
4
- **Commit:** 4517f2b
3
+ **Generated:** 2026-06-14
4
+ **Commit:** e215a50
5
5
  **Branch:** main
6
- **Version:** v0.8.1
6
+ **Version:** 0.8.10.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
@@ -4,9 +4,21 @@ OpenCode plugin exposing xp-gate quality gates and AI workflow skills.
4
4
 
5
5
  ## Tools
6
6
 
7
- - **gate-check**: Run all 6 quality gates on a file/directory
8
- - **gate-principles**: Run Clean Code + SOLID principles checker
9
- - **gate-arch**: Run architecture validation
7
+ These three tools are **dual-surface**: callable both as OpenCode tools (from
8
+ inside an OpenCode session) and as `xp-gate` CLI subcommands (from any shell).
9
+ Both paths produce identical output. See repo README for the matching CLI table.
10
+
11
+ - **gate-check** ⇄ `xp-gate check <path>`: Run user-invokable quality gates
12
+ (Gate 4 Principles + Gate 6 Architecture) on a file or directory.
13
+ - **gate-principles** ⇄ `xp-gate principles <path>`: Run Clean Code + SOLID
14
+ principles checker (Gate 4 standalone).
15
+ - **gate-arch** ⇄ `xp-gate arch`: Run architecture validation (Gate 6
16
+ standalone, layer boundary checks).
17
+
18
+ > Earlier docs said "all 6 quality gates" — that was inaccurate. `gate-check`
19
+ > intentionally runs only the two user-invokable gates (Principles + Arch); the
20
+ > full 10-gate pre-commit suite (Gate 0-9) is enforced by `xp-gate init`'s git
21
+ > hooks, not by this tool. Fixes #208.
10
22
 
11
23
  ## Installation
12
24
 
@@ -29,10 +41,14 @@ Or via local path (development):
29
41
  ## Requirements
30
42
 
31
43
  - OpenCode v0.11+
32
- - xp-gate npm package installed globally (for `gate-check` tool)
33
- - Repository with `src/principles/index.ts` (for `gate-principles` tool)
34
- - `architecture.yaml` in repo root (for `gate-arch` tool)
44
+ - One of:
45
+ - `xp-gate` CLI installed globally (`npm install -g @boyingliu01/xp-gate`) — **preferred**, or
46
+ - the xp-gate repo checked out locally with `src/principles/index.ts` reachable **fallback** (the tool will shell out via `npx -y tsx`)
47
+ - `architecture.yaml` in repo root (for `gate-arch` only)
35
48
 
36
49
  ## Graceful Degradation
37
50
 
38
- If xp-gate CLI is unavailable, tools return helpful install instructions instead of failing.
51
+ Every tool runs a chained shell-out: it first tries `xp-gate <subcommand>` and,
52
+ only if that's not on `PATH`, falls back to invoking the underlying checker
53
+ source directly. If both paths fail, the tool returns install instructions
54
+ instead of throwing.
@@ -1,57 +1,69 @@
1
1
  /**
2
2
  * XP-Gate OpenCode Plugin
3
3
  *
4
- * Exposes 3 custom tools for OpenCode users:
5
- * - gate-check: Run all xp-gate quality checks on a file or directory
6
- * - gate-principles: Run Clean Code + SOLID principles checker
7
- * - gate-arch: Run architecture validation
4
+ * Exposes 3 OpenCode tools that mirror the equivalent `xp-gate` CLI subcommands:
5
+ * - gate-check: Run user-invokable quality gates (Gate 4 Principles + Gate 6 Arch) on a path
6
+ * - gate-principles: Run Clean Code + SOLID principles checker (Gate 4 standalone)
7
+ * - gate-arch: Run architecture validation (Gate 6 standalone)
8
8
  *
9
- * Graceful degradation: if xp-gate CLI not installed, tools return install instructions.
9
+ * Dual-surface design (fixes #208): every tool is callable BOTH from inside an
10
+ * OpenCode session (as these tools) AND from a plain shell (as `xp-gate check`,
11
+ * `xp-gate principles`, `xp-gate arch`). The tools prefer the global `xp-gate`
12
+ * CLI when available, but fall back to running the checker source directly via
13
+ * `npx -y tsx` so they work even before `npm install -g @boyingliu01/xp-gate`.
10
14
  */
11
15
  import { tool } from "@opencode-ai/plugin"
12
16
  import { z } from "zod"
13
17
 
14
- export const XpGatePlugin = async (input) => {
18
+ interface OpenCodePluginInput {
19
+ directory: string
20
+ $: (strings: TemplateStringsArray, ...values: unknown[]) => Promise<{ text(): Promise<string> }>
21
+ }
22
+
23
+ export const XpGatePlugin = async (input: OpenCodePluginInput) => {
15
24
  const { directory, $ } = input
16
25
 
17
26
  return {
18
27
  tool: {
19
28
  "gate-check": tool({
20
29
  description:
21
- "Run xp-gate quality checks on a file or directory. Requires xp-gate CLI installed globally.",
30
+ "Run xp-gate user-invokable quality gates (Gate 4 Principles + Gate 6 Architecture) on a file or directory. Prefers global xp-gate CLI; falls back to running checker source directly.",
22
31
  args: {
23
32
  path: z.string().describe("File or directory path (absolute or relative to workspace)"),
24
- gates: z.array(z.string()).optional().describe("Optional gate subset (e.g. ['principles', 'tests'])"),
33
+ gates: z.array(z.string()).optional().describe("Optional gate subset (e.g. ['principles', 'arch'])"),
25
34
  },
26
35
  async execute(args, ctx) {
27
36
  const cwd = ctx.directory || directory
28
37
  const target = args.path.startsWith("/") ? args.path : `${cwd}/${args.path}`
29
- const gates = args.gates?.length ? ` --gates ${args.gates.join(",")}` : ""
38
+ const gatesFlag = args.gates?.length ? ` --gates ${args.gates.join(",")}` : ""
39
+ // Prefer the installed xp-gate CLI. Fall back to invoking the same
40
+ // subcommand source directly via npx tsx so the tool still works in
41
+ // a fresh clone before `npm install -g @boyingliu01/xp-gate`.
42
+ const cmd = `cd "${cwd}" && (command -v xp-gate >/dev/null 2>&1 && xp-gate check "${target}"${gatesFlag} || node ${directory}/src/npm-package/bin/xp-gate.js check "${target}"${gatesFlag})`
30
43
  try {
31
- const result = await $`bash -c ${`cd "${cwd}" && command -v xp-gate >/dev/null 2>&1 && xp-gate check "${target}"${gates}`}`
44
+ const result = await $`bash -c ${cmd}`
32
45
  const text = await result.text()
33
- return text || "[XP-Gate] Check complete."
46
+ return text || "[XP-Gate] Check complete (no violations)."
34
47
  } catch (err) {
35
- return `[XP-Gate] xp-gate CLI not found.\nInstall: npm install -g @boyingliu01/xp-gate\n${err instanceof Error ? err.message : ""}`
48
+ return `[XP-Gate] gate-check failed.\nInstall xp-gate CLI: npm install -g @boyingliu01/xp-gate\n${err instanceof Error ? err.message : ""}`
36
49
  }
37
50
  },
38
51
  }),
39
52
  "gate-principles": tool({
40
53
  description:
41
- "Run Clean Code + SOLID principles checker on a file.",
54
+ "Run Clean Code + SOLID principles checker (Gate 4 standalone) on a file or directory.",
42
55
  args: {
43
- path: z.string().describe("Source file path to check"),
56
+ path: z.string().describe("Source file or directory path to check"),
44
57
  },
45
58
  async execute(args, ctx) {
46
59
  const cwd = ctx.directory || directory
47
60
  const target = args.path.startsWith("/") ? args.path : `${cwd}/${args.path}`
48
-
49
- // Try xp-gate CLI first (preferred), fall back to npx tsx
50
- const cmd = `cd "${cwd}" && command -v xp-gate >/dev/null 2>&1 && xp-gate principles "${target}" || npx -y tsx ${directory}/src/principles/index.ts --files "${target}" --format console`
61
+ // Try xp-gate CLI first, fall back to the principles source directly.
62
+ const cmd = `cd "${cwd}" && (command -v xp-gate >/dev/null 2>&1 && xp-gate principles "${target}" || npx -y tsx ${directory}/src/principles/index.ts --files "${target}" --format console)`
51
63
  try {
52
64
  const result = await $`bash -c ${cmd}`
53
65
  const text = await result.text()
54
- return text || "[XP-Gate] Principles check complete."
66
+ return text || "[XP-Gate] Principles check complete (no violations)."
55
67
  } catch (err) {
56
68
  return `[XP-Gate] Principles checker failed.\nInstall xp-gate CLI: npm install -g @boyingliu01/xp-gate\n${err instanceof Error ? err.message : ""}`
57
69
  }
@@ -59,18 +71,21 @@ export const XpGatePlugin = async (input) => {
59
71
  }),
60
72
  "gate-arch": tool({
61
73
  description:
62
- "Run architecture validation (layer boundary checks) on the repository.",
74
+ "Run architecture validation (Gate 6 standalone, layer boundary checks) on the repository.",
63
75
  args: {
64
76
  config: z.string().describe("Path to architecture config file").default("architecture.yaml"),
65
77
  },
66
78
  async execute(args, ctx) {
67
79
  const cwd = ctx.directory || directory
80
+ // Prefer xp-gate CLI; fall back to @archlinter/cli directly so the tool
81
+ // also works without xp-gate installed (matches gate-principles pattern).
82
+ const cmd = `cd "${cwd}" && (command -v xp-gate >/dev/null 2>&1 && xp-gate arch --config ${args.config} || npx -y @archlinter/cli scan . --config ${args.config})`
68
83
  try {
69
- const result = await $`bash -c ${`cd "${cwd}" && npx archlint check --config ${args.config}`}`
84
+ const result = await $`bash -c ${cmd}`
70
85
  const text = await result.text()
71
86
  return text || "[XP-Gate] Architecture check complete."
72
87
  } catch (err) {
73
- return `[XP-Gate] Architecture validation requires archlint + ${args.config}.\n${err instanceof Error ? err.message : ""}`
88
+ return `[XP-Gate] Architecture validation failed.\nRequires architecture.yaml in repo root.\nInstall xp-gate CLI: npm install -g @boyingliu01/xp-gate\n${err instanceof Error ? err.message : ""}`
74
89
  }
75
90
  },
76
91
  }),
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boyingliu01/opencode-plugin",
3
- "version": "0.8.8",
3
+ "version": "0.8.10",
4
4
  "type": "module",
5
5
  "main": "index.ts",
6
6
  "description": "XP-Gate quality gates + AI workflow skills for OpenCode",
@@ -1,12 +1,12 @@
1
1
  # SKILLS/DELPHI-REVIEW KNOWLEDGE BASE
2
2
 
3
- **Generated:** 2026-05-30
4
- **Commit:** 4517f2b
3
+ **Generated:** 2026-06-14
4
+ **Commit:** e215a50
5
5
  **Branch:** main
6
- **Version:** v0.8.1
6
+ **Version:** 0.8.10.0
7
7
 
8
8
  ## OVERVIEW
9
- Delphi Consensus Review — multi-round anonymous expert review (≥91% threshold, 3 experts from ≥2 providers, domestic models only). Supports design + code-walkthrough modes.
9
+ Delphi Consensus Review — multi-round anonymous expert review (≥90% threshold, 3 experts from ≥2 providers, domestic models only). Supports design + code-walkthrough modes.
10
10
 
11
11
  ## STRUCTURE
12
12
  ```
@@ -30,7 +30,7 @@ skills/delphi-review/
30
30
 
31
31
  ## CONVENTIONS
32
32
  - 3 experts anonymous in Round 1 (no cross-expert bias)
33
- - ≥91% consensus threshold (was 95%, lowered to 91%)
33
+ - ≥90% consensus threshold (was 95%, now unified to 90%)
34
34
  - Max 5 rounds before forcing decision
35
35
  - Cross-provider required: experts from ≥2 different providers
36
36
  - Domestic models only: glm, kimi, minimax, qwen, deepseek
@@ -39,7 +39,7 @@ skills/delphi-review/
39
39
  - Code-walkthrough skipped on main/master pushes (by design)
40
40
 
41
41
  ## ANTI-PATTERNS (THIS PROJECT)
42
- - Do NOT terminate before achieving true consensus (≥91%)
42
+ - Do NOT terminate before achieving true consensus (≥90%)
43
43
  - Do NOT reveal other experts' opinions during Round 1
44
44
  - Do NOT accept partial agreement without resolution
45
45
  - Do NOT skip code-walkthrough when over thresholds (BLOCK + user decision)
@@ -49,7 +49,7 @@ skills/delphi-review/
49
49
 
50
50
  ## UNIQUE STYLES
51
51
  - Anonymous expert reviews (Round 1)
52
- - Statistical consensus measurement (≥91% threshold)
52
+ - Statistical consensus measurement (≥90% threshold)
53
53
  - Two modes: design review + code-walkthrough
54
54
  - Pre-push integration: .code-walkthrough-result.json stores commit hash + verdict
55
55
  - Delphi guard in claude-code plugin: blocks Edit/Write before APPROVAL
@@ -96,7 +96,7 @@ The skill requires at least 2 experts for code changes, 3 for architecture decis
96
96
  | `experts.architecture` | Architecture reviewer configuration | Required |
97
97
  | `experts.technical` | Technical reviewer configuration | Required |
98
98
  | `experts.feasibility` | Feasibility reviewer configuration | Required for 3-expert mode |
99
- | `consensus.threshold_percent` | Agreement threshold | 95 |
99
+ | `consensus.threshold_percent` | Agreement threshold | 90 |
100
100
  | `consensus.max_review_rounds` | Maximum review rounds | 5 |
101
101
  | `consensus.cross_provider_required` | Require different providers | true |
102
102
 
@@ -9,7 +9,7 @@ description: "Use when asked to review a design, plan, or architecture; before i
9
9
 
10
10
  **In Scope:**
11
11
  - Multi-round anonymous expert consensus review (design + code-walkthrough modes)
12
- - 2-3 experts from different providers with statistical consensus (>= 91%)
12
+ - 2-3 experts from different providers with statistical consensus (>= 90%)
13
13
  - Structured verdict: APPROVED / PASS_WITH_CAVEATS / REQUEST_CHANGES
14
14
  - Domestic models only (no Anthropic/OpenAI/Google)
15
15
 
@@ -27,7 +27,7 @@ description: "Use when asked to review a design, plan, or architecture; before i
27
27
  1. **匿名性** — Round 1 专家互不知道对方意见
28
28
  2. **迭代** — 多轮直到共识,不是固定轮数
29
29
  3. **受控反馈** — 每轮看到其他专家意见
30
- 4. **统计共识** — >=91% 一致才算共识
30
+ 4. **统计共识** — >=90% 一致才算共识
31
31
 
32
32
  ### 质量优先
33
33
 
@@ -95,7 +95,7 @@ description: "Use when asked to review a design, plan, or architecture; before i
95
95
 
96
96
  | 阈值 | 说明 |
97
97
  |------|------|
98
- | **>=91%** | 推荐默认 |
98
+ | **>=90%** | 推荐默认 |
99
99
  | 100% | 完全一致(更严格) |
100
100
 
101
101
  ---
@@ -105,14 +105,14 @@ description: "Use when asked to review a design, plan, or architecture; before i
105
105
  ```
106
106
  Phase 0: 准备 → Round 1: 匿名独立评审 → 共识检查
107
107
 
108
- ├─ 一致 + >=91% + APPROVED → ✅ 完成
108
+ ├─ 一致 + >=90% + APPROVED → ✅ 完成
109
109
 
110
- └─ 不一致 或 <91% 或 REQUEST_CHANGES
110
+ └─ 不一致 或 <90% 或 REQUEST_CHANGES
111
111
 
112
112
 
113
113
  Round 2: 交换意见 → 共识检查
114
114
 
115
- ├─ 一致 + >=91% + APPROVED → ✅ 完成
115
+ ├─ 一致 + >=90% + APPROVED → ✅ 完成
116
116
 
117
117
  └─ 仍分歧 或 REQUEST_CHANGES
118
118
 
@@ -248,11 +248,11 @@ This skill activates on any request for multi-expert review. Common triggers:
248
248
  2. **Dispatch anonymous experts** - 2-3 experts from ≥2 different domestic model providers
249
249
  3. **Collect Round 1 independent reviews** - Anonymous, no cross-expert bias
250
250
  4. **Synthesize feedback** - Measure consensus, identify disagreements
251
- 5. **Run Round 2+ until consensus** - Exchange opinions, iterate until ≥91% agreement
251
+ 5. **Run Round 2+ until consensus** - Exchange opinions, iterate until ≥90% agreement
252
252
  6. **Block on unresolved Critical/Major** - Zero-tolerance: all Critical/Major must be resolved
253
253
  7. **Emit verdict** - APPROVED (with specification.yaml) or REQUEST_CHANGES (fix + re-review)
254
254
 
255
- **Consensus threshold:** ≥91% (project standard for Delphi review approval)
255
+ **Consensus threshold:** ≥90% (project standard for Delphi review approval)
256
256
  **Model policy:** Domestic models only (DeepSeek, Qwen, Kimi, GLM, MiniMax). Foreign models (Anthropic/OpenAI/Google) forbidden.
257
257
 
258
258
  ---
@@ -340,7 +340,7 @@ Every review round output MUST follow this exact JSON structure for design mode:
340
340
  - [ ] Round 2+ 完成(交换意见 / 最终立场)
341
341
 
342
342
  **CRITICAL — 共识验证:**
343
- - [ ] 问题共识比例 >=91%
343
+ - [ ] 问题共识比例 >=90%
344
344
  - [ ] 所有 Critical Issues 已解决
345
345
  - [ ] 所有 Major Concerns 已处理
346
346
 
@@ -422,7 +422,7 @@ Every review round output MUST follow this exact JSON structure for design mode:
422
422
  | 只处理 Critical,忽略 Major | 零容忍:Critical/Major 全部必须处理,不可跳过或降级 |
423
423
  | 单专家自评 | 至少 2 位不同 provider 的专家 |
424
424
  | 用户说"时间紧急"就跳过 | 评审是投资不是开销,跳过后期返工成本更高 |
425
- | "专家几乎一致"就通过 | "几乎" = 不一致,继续到 >=91% |
425
+ | "专家几乎一致"就通过 | "几乎" = 不一致,继续到 >=90% |
426
426
  | 使用 Anthropic/GPT/Gemini 等国外昂贵模型 | 必须使用国产开源模型(DeepSeek, Qwen, Kimi, GLM, MiniMax) |
427
427
  | 三个专家使用同一厂家模型 | 必须来自至少 2 家不同厂家 |
428
428
 
@@ -437,7 +437,7 @@ Every review round output MUST follow this exact JSON structure for design mode:
437
437
  | "这只是小变更" | 所有变更都需要评审 |
438
438
  | "Round 1 就够了" | 不够,必须多轮直到共识 |
439
439
  | "生成报告就完成了" | APPROVED 才算完成 |
440
- | "2/3 同意就是共识" | 还要检查问题共识比例 >=91% |
440
+ | "2/3 同意就是共识" | 还要检查问题共识比例 >=90% |
441
441
 
442
442
  ---
443
443
 
@@ -445,7 +445,7 @@ Every review round output MUST follow this exact JSON structure for design mode:
445
445
 
446
446
  **Delphi 评审完成的唯一标准:**
447
447
  1. ✅ 所有专家裁决 APPROVED
448
- 2. ✅ 问题共识 >=91%
448
+ 2. ✅ 问题共识 >=90%
449
449
  3. ✅ 所有 Critical Issues 已修复验证
450
450
  4. ✅ 所有 Major Concerns 已处理
451
451
  5. ✅ 共识报告已生成
@@ -393,7 +393,7 @@ IF 任何检查失败:
393
393
  | `confidence` | number | 整体置信度 (1-10) |
394
394
  | `experts` | array | 专家评审结果 |
395
395
  | `issues` | array | 未解决的问题(如有) |
396
- | `consensus_ratio` | number | 问题共识比例 (≥0.95 为共识) |
396
+ | `consensus_ratio` | number | 问题共识比例 (≥0.90 为共识) |
397
397
 
398
398
  **有效期机制**:
399
399