@boyingliu01/xp-gate 0.32.2 → 0.33.0

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 (49) hide show
  1. package/adapters/gate-3.sh +483 -28
  2. package/adapters/gate-4.sh +20 -0
  3. package/adapters/gate-7.sh +4 -0
  4. package/bin/xp-gate.js +50 -4
  5. package/gate-4.sh +8 -0
  6. package/hooks/gate-4.sh +8 -0
  7. package/hooks/post-commit +82 -0
  8. package/hooks/pre-commit +19 -0
  9. package/hooks/pre-push +21 -2
  10. package/lib/__tests__/check-changed-brief.test.js +63 -0
  11. package/lib/__tests__/doctor-audit-ledger.test.js +61 -0
  12. package/lib/__tests__/gate-audit.test.ts +144 -0
  13. package/lib/__tests__/shared-utils.test.js +22 -0
  14. package/lib/check.js +114 -2
  15. package/lib/doctor.js +59 -1
  16. package/lib/gate-audit.ts +215 -7
  17. package/lib/mattpocock-license-verdict.json +1 -1
  18. package/lib/shared-utils.js +4 -1
  19. package/mock-policy/AGENTS.md +2 -2
  20. package/mutation/AGENTS.md +2 -2
  21. package/package.json +1 -1
  22. package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
  23. package/plugins/claude-code/skills/delphi-review/AGENTS.md +2 -2
  24. package/plugins/claude-code/skills/sprint-flow/AGENTS.md +2 -2
  25. package/plugins/claude-code/skills/sprint-flow/references/phase-3-build.md +47 -0
  26. package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +2 -2
  27. package/plugins/dsh/package.json +1 -1
  28. package/plugins/dsh/scripts/copy-client.cjs +6 -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 +47 -0
  32. package/plugins/dsh/skills/test-specification-alignment/AGENTS.md +2 -2
  33. package/plugins/dsh/src/contract.test.ts +25 -1
  34. package/plugins/opencode/package.json +1 -1
  35. package/plugins/opencode/skills/delphi-review/AGENTS.md +2 -2
  36. package/plugins/opencode/skills/sprint-flow/AGENTS.md +2 -2
  37. package/plugins/opencode/skills/sprint-flow/references/phase-3-build.md +47 -0
  38. package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +2 -2
  39. package/plugins/qoder/plugin.json +1 -1
  40. package/plugins/qoder/skills/delphi-review/AGENTS.md +2 -2
  41. package/plugins/qoder/skills/sprint-flow/AGENTS.md +2 -2
  42. package/plugins/qoder/skills/sprint-flow/references/phase-3-build.md +47 -0
  43. package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +2 -2
  44. package/principles/AGENTS.md +2 -2
  45. package/scripts/sync-package-content.js +1 -1
  46. package/skills/delphi-review/AGENTS.md +2 -2
  47. package/skills/sprint-flow/AGENTS.md +2 -2
  48. package/skills/sprint-flow/references/phase-3-build.md +47 -0
  49. 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.
@@ -236,6 +262,27 @@ Without these events, the Harness can only infer changes from file diffs and has
236
262
 
237
263
  ---
238
264
 
265
+ ## 工具调用效率自检(P2 硬性 — 2026-10-30 诊断)
266
+
267
+ > BUILD 阶段是工具调用最密集的阶段,也是"等待时间长"的主要来源。依据
268
+ > `docs/plans/2026-10-30-dev-speed-diagnosis.md`:工具延迟占总耗时 58%,其中 32.7% 的
269
+ > shell 调用是纯读取/搜索、calls/step 仅 1.03、`job_output` 阻塞 66.5 h。以下四条在 BUILD
270
+ > 期间是硬性自检项,不满足不得宣称 REQ 完成。
271
+
272
+ | ❌ 低效做法 | ✅ 正确做法 |
273
+ |------------|------------|
274
+ | `cat` / `Get-Content` / `sed -n` / `head` 读文件 | 用 `read` 原生工具(毫秒级,可并发) |
275
+ | `grep` / `rg` / `Select-String` / `findstr` 搜内容 | 用 `grep` 原生工具 |
276
+ | `find` / `ls` / `Get-ChildItem` 找文件 | 用 `glob` 原生工具 |
277
+ | 一个一个发独立调用(改完再想下一个) | 多个互不依赖的调用放进**同一步**并发发出 |
278
+ | 用 `job_output wait:true` / `sleep` 反复阻塞等长任务 | `run_in_background` + 完成通知,需要时短超时取一次 |
279
+ | 打包/发布/插件改动只靠 CI 发现契约破坏 | 先写契约测试(`plugins/dsh/src/contract.test.ts` 范式),本地先红 |
280
+
281
+ **验收目标**:纯读取 shell 占比 <5%(现 32.7%);calls/step ≥2.0(现 1.03);`job_output`
282
+ 调用数下降 ≥50%。这三项在 `xp-gate retro` 的 activity 统计里可复查。
283
+
284
+ ---
285
+
239
286
  ## Blind Review — Read-Only Subagent Convention (v0.18.0+, 证据型标准步骤)
240
287
 
241
288
  **Purpose**: Code review by an isolated subagent with read-only tool access. Replaces the former `freeze/unfreeze` mechanism.
@@ -1,9 +1,9 @@
1
1
  # SKILLS/TEST-SPECIFICATION-ALIGNMENT KNOWLEDGE BASE
2
2
 
3
3
  **Generated:** 2026-10-30
4
- **Commit:** 78786c3f
4
+ **Commit:** 3c5e9aaf
5
5
  **Branch:** main
6
- **Version:** 0.32.2.0
6
+ **Version:** 0.33.0.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boyingliu01/dsh-plugin-xp-gate",
3
- "version": "0.32.2",
3
+ "version": "0.33.0",
4
4
  "description": "XP-Gate deterministic quality gates + AI workflow skills as a DeepSeek Harness (DSH) native plugin: gate-check / gate-principles / gate-arch tools + 12 SKILL.md skills",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -29,4 +29,9 @@ fs.mkdirSync(path.dirname(OUT), { recursive: true });
29
29
  fs.copyFileSync(SRC, OUT);
30
30
 
31
31
  const rel = (p) => path.relative(PLUGIN_ROOT, p).split(path.sep).join('/');
32
- console.log(`[client] ${rel(SRC)} -> ${rel(OUT)}`);
32
+ // stderr, not stdout: this runs from `prepack`, and npm's `pack --json` contract
33
+ // is that stdout carries the JSON blob and nothing else. A single console.log here
34
+ // made `npm pack --dry-run --json | jq ...` fail with "Invalid numeric literal"
35
+ // and took the whole publish job down. `prepack.cjs` already logs to stderr for
36
+ // the same reason; match it.
37
+ console.error(`[client] ${rel(SRC)} -> ${rel(OUT)}`);
@@ -1,9 +1,9 @@
1
1
  # SKILLS/DELPHI-REVIEW KNOWLEDGE BASE
2
2
 
3
3
  **Generated:** 2026-10-30
4
- **Commit:** 78786c3f
4
+ **Commit:** 3c5e9aaf
5
5
  **Branch:** main
6
- **Version:** 0.32.2.0
6
+ **Version:** 0.33.0.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:** 78786c3f
4
+ **Commit:** 3c5e9aaf
5
5
  **Branch:** main
6
- **Version:** 0.32.2.0
6
+ **Version:** 0.33.0.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.
@@ -236,6 +262,27 @@ Without these events, the Harness can only infer changes from file diffs and has
236
262
 
237
263
  ---
238
264
 
265
+ ## 工具调用效率自检(P2 硬性 — 2026-10-30 诊断)
266
+
267
+ > BUILD 阶段是工具调用最密集的阶段,也是"等待时间长"的主要来源。依据
268
+ > `docs/plans/2026-10-30-dev-speed-diagnosis.md`:工具延迟占总耗时 58%,其中 32.7% 的
269
+ > shell 调用是纯读取/搜索、calls/step 仅 1.03、`job_output` 阻塞 66.5 h。以下四条在 BUILD
270
+ > 期间是硬性自检项,不满足不得宣称 REQ 完成。
271
+
272
+ | ❌ 低效做法 | ✅ 正确做法 |
273
+ |------------|------------|
274
+ | `cat` / `Get-Content` / `sed -n` / `head` 读文件 | 用 `read` 原生工具(毫秒级,可并发) |
275
+ | `grep` / `rg` / `Select-String` / `findstr` 搜内容 | 用 `grep` 原生工具 |
276
+ | `find` / `ls` / `Get-ChildItem` 找文件 | 用 `glob` 原生工具 |
277
+ | 一个一个发独立调用(改完再想下一个) | 多个互不依赖的调用放进**同一步**并发发出 |
278
+ | 用 `job_output wait:true` / `sleep` 反复阻塞等长任务 | `run_in_background` + 完成通知,需要时短超时取一次 |
279
+ | 打包/发布/插件改动只靠 CI 发现契约破坏 | 先写契约测试(`plugins/dsh/src/contract.test.ts` 范式),本地先红 |
280
+
281
+ **验收目标**:纯读取 shell 占比 <5%(现 32.7%);calls/step ≥2.0(现 1.03);`job_output`
282
+ 调用数下降 ≥50%。这三项在 `xp-gate retro` 的 activity 统计里可复查。
283
+
284
+ ---
285
+
239
286
  ## Blind Review — Read-Only Subagent Convention (v0.18.0+, 证据型标准步骤)
240
287
 
241
288
  **Purpose**: Code review by an isolated subagent with read-only tool access. Replaces the former `freeze/unfreeze` mechanism.
@@ -1,9 +1,9 @@
1
1
  # SKILLS/TEST-SPECIFICATION-ALIGNMENT KNOWLEDGE BASE
2
2
 
3
3
  **Generated:** 2026-10-30
4
- **Commit:** 78786c3f
4
+ **Commit:** 3c5e9aaf
5
5
  **Branch:** main
6
- **Version:** 0.32.2.0
6
+ **Version:** 0.33.0.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect } from "vitest"
2
- import { readFileSync } from "node:fs"
2
+ import { readFileSync, readdirSync } from "node:fs"
3
3
  import { join, resolve } from "node:path"
4
4
  import { fileURLToPath } from "node:url"
5
5
 
@@ -95,4 +95,28 @@ describe("packaging contract", () => {
95
95
  // A report with no explicit verdict must not be counted toward consensus.
96
96
  expect(core).toContain("INVALID_NO_VERDICT")
97
97
  })
98
+
99
+ /**
100
+ * @test REQ-DSH-019 prepack scripts keep stdout clean for `npm pack --json`
101
+ * @intent 发布流水线用 `npm pack --dry-run --json | jq ...` 量 tarball 大小。
102
+ * `prepack` 里任何一句 console.log 都会混进那个 JSON 流,jq 报
103
+ * "Invalid numeric literal" 并以 exit 5 结束——0.32.2 的 dsh 插件正是
104
+ * 因此没发出去,而 create-release 依赖三个 publish job,于是 tag 与
105
+ * release 一起被跳过。日志一律走 stderr。
106
+ * @covers AC-DSH-019-01
107
+ */
108
+ it("prepack-time scripts log to stderr, never stdout", () => {
109
+ const scriptsDir = join(PKG_ROOT, "scripts")
110
+ const files = readdirSync(scriptsDir).filter((f) => f.endsWith(".cjs"))
111
+ expect(files.length, "no prepack scripts found").toBeGreaterThan(0)
112
+
113
+ for (const f of files) {
114
+ const source = readFileSync(join(scriptsDir, f), "utf8")
115
+ // Strip comments so an explanatory "console.log" in prose does not fail it.
116
+ const code = source.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/.*$/gm, "")
117
+ expect(code, `${f} writes to stdout and would corrupt npm pack --json`).not.toMatch(
118
+ /console\.log\s*\(/,
119
+ )
120
+ }
121
+ })
98
122
  })
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boyingliu01/opencode-plugin",
3
- "version": "0.32.2",
3
+ "version": "0.33.0",
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
3
  **Generated:** 2026-10-30
4
- **Commit:** 78786c3f
4
+ **Commit:** 3c5e9aaf
5
5
  **Branch:** main
6
- **Version:** 0.32.2.0
6
+ **Version:** 0.33.0.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:** 78786c3f
4
+ **Commit:** 3c5e9aaf
5
5
  **Branch:** main
6
- **Version:** 0.32.2.0
6
+ **Version:** 0.33.0.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.
@@ -236,6 +262,27 @@ Without these events, the Harness can only infer changes from file diffs and has
236
262
 
237
263
  ---
238
264
 
265
+ ## 工具调用效率自检(P2 硬性 — 2026-10-30 诊断)
266
+
267
+ > BUILD 阶段是工具调用最密集的阶段,也是"等待时间长"的主要来源。依据
268
+ > `docs/plans/2026-10-30-dev-speed-diagnosis.md`:工具延迟占总耗时 58%,其中 32.7% 的
269
+ > shell 调用是纯读取/搜索、calls/step 仅 1.03、`job_output` 阻塞 66.5 h。以下四条在 BUILD
270
+ > 期间是硬性自检项,不满足不得宣称 REQ 完成。
271
+
272
+ | ❌ 低效做法 | ✅ 正确做法 |
273
+ |------------|------------|
274
+ | `cat` / `Get-Content` / `sed -n` / `head` 读文件 | 用 `read` 原生工具(毫秒级,可并发) |
275
+ | `grep` / `rg` / `Select-String` / `findstr` 搜内容 | 用 `grep` 原生工具 |
276
+ | `find` / `ls` / `Get-ChildItem` 找文件 | 用 `glob` 原生工具 |
277
+ | 一个一个发独立调用(改完再想下一个) | 多个互不依赖的调用放进**同一步**并发发出 |
278
+ | 用 `job_output wait:true` / `sleep` 反复阻塞等长任务 | `run_in_background` + 完成通知,需要时短超时取一次 |
279
+ | 打包/发布/插件改动只靠 CI 发现契约破坏 | 先写契约测试(`plugins/dsh/src/contract.test.ts` 范式),本地先红 |
280
+
281
+ **验收目标**:纯读取 shell 占比 <5%(现 32.7%);calls/step ≥2.0(现 1.03);`job_output`
282
+ 调用数下降 ≥50%。这三项在 `xp-gate retro` 的 activity 统计里可复查。
283
+
284
+ ---
285
+
239
286
  ## Blind Review — Read-Only Subagent Convention (v0.18.0+, 证据型标准步骤)
240
287
 
241
288
  **Purpose**: Code review by an isolated subagent with read-only tool access. Replaces the former `freeze/unfreeze` mechanism.
@@ -1,9 +1,9 @@
1
1
  # SKILLS/TEST-SPECIFICATION-ALIGNMENT KNOWLEDGE BASE
2
2
 
3
3
  **Generated:** 2026-10-30
4
- **Commit:** 78786c3f
4
+ **Commit:** 3c5e9aaf
5
5
  **Branch:** main
6
- **Version:** 0.32.2.0
6
+ **Version:** 0.33.0.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xp-gate",
3
- "version": "0.32.2",
3
+ "version": "0.33.0",
4
4
  "displayName": "XP-Gate",
5
5
  "description": "Extreme Programming quality gates + AI workflow skills for Qoder. Includes 12 pre-commit gates (Gate 0-11), 8 pre-push gates, Sprint Flow (6 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
3
  **Generated:** 2026-10-30
4
- **Commit:** 78786c3f
4
+ **Commit:** 3c5e9aaf
5
5
  **Branch:** main
6
- **Version:** 0.32.2.0
6
+ **Version:** 0.33.0.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:** 78786c3f
4
+ **Commit:** 3c5e9aaf
5
5
  **Branch:** main
6
- **Version:** 0.32.2.0
6
+ **Version:** 0.33.0.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.
@@ -236,6 +262,27 @@ Without these events, the Harness can only infer changes from file diffs and has
236
262
 
237
263
  ---
238
264
 
265
+ ## 工具调用效率自检(P2 硬性 — 2026-10-30 诊断)
266
+
267
+ > BUILD 阶段是工具调用最密集的阶段,也是"等待时间长"的主要来源。依据
268
+ > `docs/plans/2026-10-30-dev-speed-diagnosis.md`:工具延迟占总耗时 58%,其中 32.7% 的
269
+ > shell 调用是纯读取/搜索、calls/step 仅 1.03、`job_output` 阻塞 66.5 h。以下四条在 BUILD
270
+ > 期间是硬性自检项,不满足不得宣称 REQ 完成。
271
+
272
+ | ❌ 低效做法 | ✅ 正确做法 |
273
+ |------------|------------|
274
+ | `cat` / `Get-Content` / `sed -n` / `head` 读文件 | 用 `read` 原生工具(毫秒级,可并发) |
275
+ | `grep` / `rg` / `Select-String` / `findstr` 搜内容 | 用 `grep` 原生工具 |
276
+ | `find` / `ls` / `Get-ChildItem` 找文件 | 用 `glob` 原生工具 |
277
+ | 一个一个发独立调用(改完再想下一个) | 多个互不依赖的调用放进**同一步**并发发出 |
278
+ | 用 `job_output wait:true` / `sleep` 反复阻塞等长任务 | `run_in_background` + 完成通知,需要时短超时取一次 |
279
+ | 打包/发布/插件改动只靠 CI 发现契约破坏 | 先写契约测试(`plugins/dsh/src/contract.test.ts` 范式),本地先红 |
280
+
281
+ **验收目标**:纯读取 shell 占比 <5%(现 32.7%);calls/step ≥2.0(现 1.03);`job_output`
282
+ 调用数下降 ≥50%。这三项在 `xp-gate retro` 的 activity 统计里可复查。
283
+
284
+ ---
285
+
239
286
  ## Blind Review — Read-Only Subagent Convention (v0.18.0+, 证据型标准步骤)
240
287
 
241
288
  **Purpose**: Code review by an isolated subagent with read-only tool access. Replaces the former `freeze/unfreeze` mechanism.
@@ -1,9 +1,9 @@
1
1
  # SKILLS/TEST-SPECIFICATION-ALIGNMENT KNOWLEDGE BASE
2
2
 
3
3
  **Generated:** 2026-10-30
4
- **Commit:** 78786c3f
4
+ **Commit:** 3c5e9aaf
5
5
  **Branch:** main
6
- **Version:** 0.32.2.0
6
+ **Version:** 0.33.0.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:** 78786c3f
4
+ **Commit:** 3c5e9aaf
5
5
  **Branch:** main
6
- **Version:** 0.32.2.0
6
+ **Version:** 0.33.0.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.
@@ -221,7 +221,7 @@ function syncHooks() {
221
221
 
222
222
  // #505: hook-module-resolution.sh is GENERATED, but it must still ship beside
223
223
  // pre-commit — the hook aborts with FATAL when it is missing, by design.
224
- const HOOK_FILES = ['pre-commit', 'pre-push', 'post-merge', 'adapter-common.sh', 'hook-module-resolution.sh'];
224
+ const HOOK_FILES = ['pre-commit', 'pre-push', 'post-commit', 'post-merge', 'adapter-common.sh', 'hook-module-resolution.sh'];
225
225
  let copied = 0;
226
226
 
227
227
  for (const name of HOOK_FILES) {
@@ -1,9 +1,9 @@
1
1
  # SKILLS/DELPHI-REVIEW KNOWLEDGE BASE
2
2
 
3
3
  **Generated:** 2026-10-30
4
- **Commit:** 78786c3f
4
+ **Commit:** 3c5e9aaf
5
5
  **Branch:** main
6
- **Version:** 0.32.2.0
6
+ **Version:** 0.33.0.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:** 78786c3f
4
+ **Commit:** 3c5e9aaf
5
5
  **Branch:** main
6
- **Version:** 0.32.2.0
6
+ **Version:** 0.33.0.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.
@@ -236,6 +262,27 @@ Without these events, the Harness can only infer changes from file diffs and has
236
262
 
237
263
  ---
238
264
 
265
+ ## 工具调用效率自检(P2 硬性 — 2026-10-30 诊断)
266
+
267
+ > BUILD 阶段是工具调用最密集的阶段,也是"等待时间长"的主要来源。依据
268
+ > `docs/plans/2026-10-30-dev-speed-diagnosis.md`:工具延迟占总耗时 58%,其中 32.7% 的
269
+ > shell 调用是纯读取/搜索、calls/step 仅 1.03、`job_output` 阻塞 66.5 h。以下四条在 BUILD
270
+ > 期间是硬性自检项,不满足不得宣称 REQ 完成。
271
+
272
+ | ❌ 低效做法 | ✅ 正确做法 |
273
+ |------------|------------|
274
+ | `cat` / `Get-Content` / `sed -n` / `head` 读文件 | 用 `read` 原生工具(毫秒级,可并发) |
275
+ | `grep` / `rg` / `Select-String` / `findstr` 搜内容 | 用 `grep` 原生工具 |
276
+ | `find` / `ls` / `Get-ChildItem` 找文件 | 用 `glob` 原生工具 |
277
+ | 一个一个发独立调用(改完再想下一个) | 多个互不依赖的调用放进**同一步**并发发出 |
278
+ | 用 `job_output wait:true` / `sleep` 反复阻塞等长任务 | `run_in_background` + 完成通知,需要时短超时取一次 |
279
+ | 打包/发布/插件改动只靠 CI 发现契约破坏 | 先写契约测试(`plugins/dsh/src/contract.test.ts` 范式),本地先红 |
280
+
281
+ **验收目标**:纯读取 shell 占比 <5%(现 32.7%);calls/step ≥2.0(现 1.03);`job_output`
282
+ 调用数下降 ≥50%。这三项在 `xp-gate retro` 的 activity 统计里可复查。
283
+
284
+ ---
285
+
239
286
  ## Blind Review — Read-Only Subagent Convention (v0.18.0+, 证据型标准步骤)
240
287
 
241
288
  **Purpose**: Code review by an isolated subagent with read-only tool access. Replaces the former `freeze/unfreeze` mechanism.
@@ -1,9 +1,9 @@
1
1
  # SKILLS/TEST-SPECIFICATION-ALIGNMENT KNOWLEDGE BASE
2
2
 
3
3
  **Generated:** 2026-10-30
4
- **Commit:** 78786c3f
4
+ **Commit:** 3c5e9aaf
5
5
  **Branch:** main
6
- **Version:** 0.32.2.0
6
+ **Version:** 0.33.0.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.