@boyingliu01/xp-gate 0.32.3 → 0.33.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.
Files changed (48) hide show
  1. package/bin/xp-gate.js +2 -2
  2. package/gates/common-process.ts +178 -0
  3. package/gates/common.ts +208 -0
  4. package/gates/gate-3.ts +144 -0
  5. package/gates/gate-7.ts +126 -0
  6. package/gates/gate-8.ts +92 -0
  7. package/gates/gate-9.ts +269 -0
  8. package/gates/pbt-detect.ts +163 -0
  9. package/gates/python-health.ts +266 -0
  10. package/gates/test-layers.ts +312 -0
  11. package/lib/__tests__/check-changed-brief.test.js +63 -0
  12. package/lib/__tests__/check-normalize-exit.test.js +24 -0
  13. package/lib/__tests__/shared-utils.test.js +21 -0
  14. package/lib/__tests__/uninstall.test.js +18 -0
  15. package/lib/check.js +140 -5
  16. package/lib/gate-runner.js +6 -1
  17. package/lib/mattpocock-license-verdict.json +1 -1
  18. package/lib/shared-utils.js +6 -1
  19. package/lib/uninstall.js +21 -1
  20. package/mock-policy/AGENTS.md +2 -2
  21. package/mutation/AGENTS.md +2 -2
  22. package/package.json +2 -1
  23. package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
  24. package/plugins/claude-code/skills/delphi-review/AGENTS.md +2 -2
  25. package/plugins/claude-code/skills/sprint-flow/AGENTS.md +2 -2
  26. package/plugins/claude-code/skills/sprint-flow/references/phase-3-build.md +26 -0
  27. package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +2 -2
  28. package/plugins/dsh/package.json +1 -1
  29. package/plugins/dsh/skills/delphi-review/AGENTS.md +2 -2
  30. package/plugins/dsh/skills/sprint-flow/AGENTS.md +2 -2
  31. package/plugins/dsh/skills/sprint-flow/references/phase-3-build.md +26 -0
  32. package/plugins/dsh/skills/test-specification-alignment/AGENTS.md +2 -2
  33. package/plugins/opencode/package.json +1 -1
  34. package/plugins/opencode/skills/delphi-review/AGENTS.md +2 -2
  35. package/plugins/opencode/skills/sprint-flow/AGENTS.md +2 -2
  36. package/plugins/opencode/skills/sprint-flow/references/phase-3-build.md +26 -0
  37. package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +2 -2
  38. package/plugins/qoder/plugin.json +1 -1
  39. package/plugins/qoder/skills/delphi-review/AGENTS.md +2 -2
  40. package/plugins/qoder/skills/sprint-flow/AGENTS.md +2 -2
  41. package/plugins/qoder/skills/sprint-flow/references/phase-3-build.md +26 -0
  42. package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +2 -2
  43. package/principles/AGENTS.md +2 -2
  44. package/scripts/sync-package-content.js +6 -1
  45. package/skills/delphi-review/AGENTS.md +2 -2
  46. package/skills/sprint-flow/AGENTS.md +2 -2
  47. package/skills/sprint-flow/references/phase-3-build.md +26 -0
  48. package/skills/test-specification-alignment/AGENTS.md +2 -2
@@ -22,6 +22,32 @@
22
22
 
23
23
  ---
24
24
 
25
+ ## 提交前自检清单(P1 红线前移 — 2026-10-30,直接解 #652)
26
+
27
+ > 背景:47.6% 的提交是 fix/revert(323/679)。多数返工是"提交时才被门禁打回"——
28
+ > 红线原本只活在 `githooks/` 里,AI 在 BUILD 期间看不到。这一页把会**阻断提交**的
29
+ > 阈值提前到编码时自检,目标是"第一次提交就过",而不是"提交→被打回→改→再提交"。
30
+
31
+ **每次准备 `git commit` 前,逐条自检(按被拦频率排序):**
32
+
33
+ | # | 门禁 | 红线(会被 BLOCK/WARN 的硬阈值) | 自查方法 |
34
+ |---|------|------------------------------|----------|
35
+ | 1 | **Gate 3 CCN** | 单函数圈复杂度 **>10 BLOCK**、**>5 WARN** | 拆函数 / 早返回 / 抽策略表;`xp-gate check 3 <file>` |
36
+ | 2 | **Gate 6 Boy Scout** | **新文件 0 warning**;修改文件 warning 数不得高于 `.warnings-baseline.json`;**单函数 ≤50 行**;**嵌套 ≤4 层** | 新文件当"零容忍"写;改动前 `xp-gate check 6` 看基线 |
37
+ | 3 | **Gate 2 重复代码** | jscpd 相似度 **>5% BLOCK** | 抽公共函数,别复制粘贴;`xp-gate check 2 <dir>` |
38
+ | 4 | **Gate 4 Principles** | 14 条 Clean Code/SOLID 规则,任一 error/warning 即拦(按 `.principlesrc`) | `xp-gate check 4 <file>`;避免超长参数表、空 catch、`as any` |
39
+ | 5 | **Gate 1 Lint** | 适配器 lint 任一 error | 提交前跑一次项目 lint;不要留未用变量/导入 |
40
+ | 6 | **Gate 5 测试** | 测试全绿 + 覆盖率 ≥80%(新 .ts/.tsx 无测试直接 BLOCK) | 新代码先写测试(TDD);`npx vitest run <file>` |
41
+ | 7 | **mirror/sync 纪律** | 改 `githooks/` 或 `skills/` 后必须 `node src/npm-package/scripts/sync-package-content.js --fix` 且 `bash scripts/check-hook-mirror.sh` 报 PASS | 忘了同步会在 pre-push 的 mirror 校验被打回 |
42
+
43
+ **一条命令抢先看**:`xp-gate check . --changed --brief` 只跑"本次 diff 会触发的门禁",
44
+ 一屏出 PASS/SKIP/BLOCK,目标 <5 s。把它放在 ralph-loop 每个 REQ 的 step 0,先看红不红,
45
+ 再决定是否继续写——而不是写到一半才被 `git commit` 拦下。
46
+
47
+ **根因提醒**:Gate 3/6 是"返工双雄"。写完一个函数先扫一眼长度和嵌套,比提交后返工快得多。
48
+
49
+ ---
50
+
25
51
  ## BUILD Entry Contract Check (MANDATORY — v0.18.0+, 程序化)
26
52
 
27
53
  **Purpose**: Validate `slices-manifest.json` schema and slice↔REQ cross-artifact consistency before entering BUILD.
@@ -1,9 +1,9 @@
1
1
  # SKILLS/TEST-SPECIFICATION-ALIGNMENT KNOWLEDGE BASE
2
2
 
3
3
  **Generated:** 2026-10-30
4
- **Commit:** e5ca7d9d
4
+ **Commit:** e713c2d1
5
5
  **Branch:** main
6
- **Version:** 0.32.3.0
6
+ **Version:** 0.33.1.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
3
  **Generated:** 2026-10-30
4
- **Commit:** e5ca7d9d
4
+ **Commit:** e713c2d1
5
5
  **Branch:** main
6
- **Version:** 0.32.3.0
6
+ **Version:** 0.33.1.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.
@@ -504,7 +504,12 @@ function main() {
504
504
  const mutation = syncModules('mutation');
505
505
  const mockPolicy = syncModules('mock-policy');
506
506
  const buildIntegrity = syncModules('build-integrity');
507
- console.error(`[sync] done: ${skills} skill(s), ${plugins} plugin(s), ${scripts} script(s), ${adapters} adapter entries, ${hooks} hook entries, ${principles + mutation + mockPolicy + buildIntegrity} module(s)`);
507
+ // #658: test-layers / pbt / python-health gate modules live in src/gates/ and
508
+ // were never bundled, so `xp-gate check test-layers` found no module in an npm
509
+ // install and silently skipped. Ship them (they import only ./common* which
510
+ // ship alongside).
511
+ const gates = syncModules('gates');
512
+ console.error(`[sync] done: ${skills} skill(s), ${plugins} plugin(s), ${scripts} script(s), ${adapters} adapter entries, ${hooks} hook entries, ${principles + mutation + mockPolicy + buildIntegrity + gates} module(s)`);
508
513
  if (skills !== CORE_SKILLS.length) {
509
514
  console.error(`[sync] ERROR: expected ${CORE_SKILLS.length} skills, copied ${skills}`);
510
515
  process.exit(1);
@@ -1,9 +1,9 @@
1
1
  # SKILLS/DELPHI-REVIEW KNOWLEDGE BASE
2
2
 
3
3
  **Generated:** 2026-10-30
4
- **Commit:** e5ca7d9d
4
+ **Commit:** e713c2d1
5
5
  **Branch:** main
6
- **Version:** 0.32.3.0
6
+ **Version:** 0.33.1.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Delphi Consensus Review — multi-round anonymous expert review (≥90% threshold, exactly 3 experts with distinct executable model IDs). Supports design, requirements, and code-walkthrough modes.
@@ -1,9 +1,9 @@
1
1
  # SKILLS/SPRINT-FLOW KNOWLEDGE BASE
2
2
 
3
3
  **Generated:** 2026-10-30
4
- **Commit:** e5ca7d9d
4
+ **Commit:** e713c2d1
5
5
  **Branch:** main
6
- **Version:** 0.32.3.0
6
+ **Version:** 0.33.1.0
7
7
 
8
8
  ## OVERVIEW
9
9
  **6-phase** development pipeline (v2.0 compact redesign, Issue #290): PREP → DESIGN → BUILD → VERIFY → SHIP → CLOSE. Phase 3/6 BUILD default build mode is **ralph-loop** (REQ-level iteration, 40-67% token savings vs parallel). HARD-GATE between DESIGN (2/6) and BUILD (3/6): design must pass Delphi review (≥90% consensus) before any coding.
@@ -22,6 +22,32 @@
22
22
 
23
23
  ---
24
24
 
25
+ ## 提交前自检清单(P1 红线前移 — 2026-10-30,直接解 #652)
26
+
27
+ > 背景:47.6% 的提交是 fix/revert(323/679)。多数返工是"提交时才被门禁打回"——
28
+ > 红线原本只活在 `githooks/` 里,AI 在 BUILD 期间看不到。这一页把会**阻断提交**的
29
+ > 阈值提前到编码时自检,目标是"第一次提交就过",而不是"提交→被打回→改→再提交"。
30
+
31
+ **每次准备 `git commit` 前,逐条自检(按被拦频率排序):**
32
+
33
+ | # | 门禁 | 红线(会被 BLOCK/WARN 的硬阈值) | 自查方法 |
34
+ |---|------|------------------------------|----------|
35
+ | 1 | **Gate 3 CCN** | 单函数圈复杂度 **>10 BLOCK**、**>5 WARN** | 拆函数 / 早返回 / 抽策略表;`xp-gate check 3 <file>` |
36
+ | 2 | **Gate 6 Boy Scout** | **新文件 0 warning**;修改文件 warning 数不得高于 `.warnings-baseline.json`;**单函数 ≤50 行**;**嵌套 ≤4 层** | 新文件当"零容忍"写;改动前 `xp-gate check 6` 看基线 |
37
+ | 3 | **Gate 2 重复代码** | jscpd 相似度 **>5% BLOCK** | 抽公共函数,别复制粘贴;`xp-gate check 2 <dir>` |
38
+ | 4 | **Gate 4 Principles** | 14 条 Clean Code/SOLID 规则,任一 error/warning 即拦(按 `.principlesrc`) | `xp-gate check 4 <file>`;避免超长参数表、空 catch、`as any` |
39
+ | 5 | **Gate 1 Lint** | 适配器 lint 任一 error | 提交前跑一次项目 lint;不要留未用变量/导入 |
40
+ | 6 | **Gate 5 测试** | 测试全绿 + 覆盖率 ≥80%(新 .ts/.tsx 无测试直接 BLOCK) | 新代码先写测试(TDD);`npx vitest run <file>` |
41
+ | 7 | **mirror/sync 纪律** | 改 `githooks/` 或 `skills/` 后必须 `node src/npm-package/scripts/sync-package-content.js --fix` 且 `bash scripts/check-hook-mirror.sh` 报 PASS | 忘了同步会在 pre-push 的 mirror 校验被打回 |
42
+
43
+ **一条命令抢先看**:`xp-gate check . --changed --brief` 只跑"本次 diff 会触发的门禁",
44
+ 一屏出 PASS/SKIP/BLOCK,目标 <5 s。把它放在 ralph-loop 每个 REQ 的 step 0,先看红不红,
45
+ 再决定是否继续写——而不是写到一半才被 `git commit` 拦下。
46
+
47
+ **根因提醒**:Gate 3/6 是"返工双雄"。写完一个函数先扫一眼长度和嵌套,比提交后返工快得多。
48
+
49
+ ---
50
+
25
51
  ## BUILD Entry Contract Check (MANDATORY — v0.18.0+, 程序化)
26
52
 
27
53
  **Purpose**: Validate `slices-manifest.json` schema and slice↔REQ cross-artifact consistency before entering BUILD.
@@ -1,9 +1,9 @@
1
1
  # SKILLS/TEST-SPECIFICATION-ALIGNMENT KNOWLEDGE BASE
2
2
 
3
3
  **Generated:** 2026-10-30
4
- **Commit:** e5ca7d9d
4
+ **Commit:** e713c2d1
5
5
  **Branch:** main
6
- **Version:** 0.32.3.0
6
+ **Version:** 0.33.1.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.