@boyingliu01/xp-gate 0.35.20 → 0.35.22

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 (34) hide show
  1. package/bin/xp-gate.js +12 -0
  2. package/hooks/pre-commit +29 -5
  3. package/hooks/pre-push +44 -5
  4. package/lib/__tests__/agent-runtime-journal.test.js +302 -0
  5. package/lib/__tests__/mirror-sync.test.js +277 -0
  6. package/lib/__tests__/runtime-journal.test.js +164 -0
  7. package/lib/__tests__/test-alignment-java-702.test.ts +11 -16
  8. package/lib/agent-runtime-journal.js +347 -0
  9. package/lib/mattpocock-license-verdict.json +1 -1
  10. package/lib/mirror-sync.js +335 -0
  11. package/lib/runtime-journal.js +156 -0
  12. package/mock-policy/AGENTS.md +2 -2
  13. package/mutation/AGENTS.md +2 -2
  14. package/package.json +1 -1
  15. package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
  16. package/plugins/claude-code/skills/delphi-review/AGENTS.md +2 -2
  17. package/plugins/claude-code/skills/sprint-flow/AGENTS.md +2 -2
  18. package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +2 -2
  19. package/plugins/dsh/package.json +1 -1
  20. package/plugins/dsh/skills/delphi-review/AGENTS.md +2 -2
  21. package/plugins/dsh/skills/sprint-flow/AGENTS.md +2 -2
  22. package/plugins/dsh/skills/test-specification-alignment/AGENTS.md +2 -2
  23. package/plugins/opencode/package.json +1 -1
  24. package/plugins/opencode/skills/delphi-review/AGENTS.md +2 -2
  25. package/plugins/opencode/skills/sprint-flow/AGENTS.md +2 -2
  26. package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +2 -2
  27. package/plugins/qoder/plugin.json +1 -1
  28. package/plugins/qoder/skills/delphi-review/AGENTS.md +2 -2
  29. package/plugins/qoder/skills/sprint-flow/AGENTS.md +2 -2
  30. package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +2 -2
  31. package/principles/AGENTS.md +2 -2
  32. package/skills/delphi-review/AGENTS.md +2 -2
  33. package/skills/sprint-flow/AGENTS.md +2 -2
  34. package/skills/test-specification-alignment/AGENTS.md +2 -2
@@ -0,0 +1,156 @@
1
+ /**
2
+ * `xp-gate runtime-journal` — CLI for the AGENTS.md runtime-efficiency rules.
3
+ *
4
+ * Implements the same "measure don't restate" stance as `gate-rules`: the three
5
+ * rules in AGENTS.md §AGENT RUNTIME DISCIPLINE were written on 2026-10-30, but
6
+ * by 2026-11-02 only rule 1 had taken effect (pure-read shell: 32.7% -> 0.2%)
7
+ * while rule 2 stayed at 1.02 calls/step and rule 3 was violated 103 times with
8
+ * an explicit `wait: true`. A rule nobody measures is a rule nobody follows, so
9
+ * this surfaces the cost as numbers.
10
+ *
11
+ * Advisory by design — it reports share-of-time and never blocks a commit.
12
+ * The behaviour it measures (how the agent waits) is not something a git hook
13
+ * can decide.
14
+ *
15
+ * @module runtime-journal
16
+ */
17
+
18
+ 'use strict';
19
+
20
+ const path = require('path');
21
+ const os = require('os');
22
+
23
+ const {
24
+ analyseSessions,
25
+ discoverSessionDirs,
26
+ summariseForSlot,
27
+ } = require('./agent-runtime-journal');
28
+
29
+ /** Default lookback for the report, in days. */
30
+ const DEFAULT_DAYS = 3;
31
+
32
+ /**
33
+ * Candidate roots that hold DSH session journals, most specific first.
34
+ *
35
+ * `DSH_SESSIONS_DIR` wins so a CI job or a different machine can point at the
36
+ * store without code changes.
37
+ *
38
+ * The DSH store names each project root `--<slug>--`, where the slug is the
39
+ * absolute cwd with every path separator replaced by a dash — e.g.
40
+ * `D:\projects\xp-gate` becomes `--D-projects-xp-gate--`. Deriving it from the
41
+ * full path matters: a basename-only guess (`--xp-gate--`) names a directory
42
+ * that does not exist.
43
+ *
44
+ * @param {string} [cwd] project directory; defaults to `process.cwd()`
45
+ * @returns {string[]}
46
+ */
47
+ function sessionRootCandidates(cwd = process.cwd()) {
48
+ const home = os.homedir();
49
+ const dirs = [];
50
+ if (process.env.DSH_SESSIONS_DIR) dirs.push(process.env.DSH_SESSIONS_DIR);
51
+ const base = path.join(home, '.dsh', 'sessions');
52
+ // Each separator becomes one dash, then the store wraps the slug in an extra
53
+ // dash on both sides: `D:\projects\xp-gate` -> `D-projects-xp-gate` ->
54
+ // `--D-projects-xp-gate--`. The wrapping pair is not redundant; without it
55
+ // the path names a directory that does not exist.
56
+ const slug = String(cwd).replace(/[\\/:]+/g, '-');
57
+ if (slug) dirs.push(path.join(base, `--${slug}--`));
58
+ dirs.push(base);
59
+ return dirs;
60
+ }
61
+
62
+ /**
63
+ * Find the session root that actually exists and contains journals.
64
+ * @param {string[]} candidates
65
+ * @returns {string|null}
66
+ */
67
+ function pickSessionRoot(candidates) {
68
+ for (const candidate of candidates) {
69
+ if (discoverSessionDirs(candidate).length > 0) return candidate;
70
+ }
71
+ return null;
72
+ }
73
+
74
+ /**
75
+ * Parse `--days N` from argv.
76
+ * @param {string[]} argv
77
+ * @param {number} fallback
78
+ * @returns {number}
79
+ */
80
+ function parseDays(argv, fallback) {
81
+ const idx = argv.indexOf('--days');
82
+ if (idx === -1) return fallback;
83
+ const raw = argv[idx + 1];
84
+ const n = Number(raw);
85
+ return Number.isFinite(n) && n > 0 ? n : fallback;
86
+ }
87
+
88
+ /**
89
+ * Run the `runtime-journal` subcommand.
90
+ *
91
+ * Always exits 0: this is a diagnostic. Callers that want a gate can read the
92
+ * JSON and apply their own threshold, which keeps the measurement honest
93
+ * (a tool that fails on bad news gets suppressed, not fixed).
94
+ *
95
+ * @param {string[]} argv
96
+ * @returns {number} exit code (always 0)
97
+ */
98
+ function handleRuntimeJournal(argv) {
99
+ const args = argv || [];
100
+ const json = args.includes('--json');
101
+ const days = parseDays(args, DEFAULT_DAYS);
102
+ const now = Date.now();
103
+ const sinceMs = now - days * 24 * 60 * 60 * 1000;
104
+
105
+ const explicitDir = (() => {
106
+ const idx = args.indexOf('--sessions-dir');
107
+ return idx === -1 ? null : args[idx + 1];
108
+ })();
109
+
110
+ const root = explicitDir
111
+ ? (discoverSessionDirs(explicitDir).length ? explicitDir : null)
112
+ : pickSessionRoot(sessionRootCandidates(process.cwd()));
113
+
114
+ if (!root) {
115
+ // NOT MEASURABLE rather than a zero report: a zero that means "no data"
116
+ // reads as "no problem", the false-green that #636 set out to remove.
117
+ if (json) {
118
+ process.stdout.write(`${JSON.stringify({ measurable: false, reason: 'no session journals found', days }, null, 2)}\n`);
119
+ } else {
120
+ process.stdout.write('Runtime efficiency: NOT MEASURABLE (no session journals found)\n');
121
+ process.stdout.write('Hint: set DSH_SESSIONS_DIR, or pass --sessions-dir <path>.\n');
122
+ }
123
+ return 0;
124
+ }
125
+
126
+ const report = analyseSessions(discoverSessionDirs(root), { sinceMs, untilMs: now });
127
+
128
+ if (json) {
129
+ const payload = {
130
+ measurable: report.toolCalls > 0,
131
+ days,
132
+ window: { from: new Date(sinceMs).toISOString(), to: new Date(now).toISOString() },
133
+ sessionsDir: root,
134
+ ...report,
135
+ };
136
+ process.stdout.write(`${JSON.stringify(payload, null, 2)}\n`);
137
+ return 0;
138
+ }
139
+
140
+ process.stdout.write(`Runtime efficiency — last ${days} day(s)\n`);
141
+ process.stdout.write(`Sessions: ${root}\n`);
142
+ const slots = summariseForSlot(report);
143
+ for (const line of slots) process.stdout.write(` ${line}\n`);
144
+ if (report.toolCalls > 0) {
145
+ process.stdout.write(` measured ${report.toolCalls} tool call(s), median ${report.toolMedianMs} ms\n`);
146
+ }
147
+ return 0;
148
+ }
149
+
150
+ module.exports = {
151
+ DEFAULT_DAYS,
152
+ handleRuntimeJournal,
153
+ sessionRootCandidates,
154
+ pickSessionRoot,
155
+ parseDays,
156
+ };
@@ -1,9 +1,9 @@
1
1
  # SRC/MOCK-POLICY KNOWLEDGE BASE
2
2
 
3
3
  **Generated:** 2026-11-02
4
- **Commit:** 60545e49
4
+ **Commit:** 57ef51ed
5
5
  **Branch:** main
6
- **Version:** 0.35.20.0
6
+ **Version:** 0.35.22.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
3
  **Generated:** 2026-11-02
4
- **Commit:** 60545e49
4
+ **Commit:** 57ef51ed
5
5
  **Branch:** main
6
- **Version:** 0.35.20.0
6
+ **Version:** 0.35.22.0
7
7
 
8
8
  ## OVERVIEW
9
9
  **Gate M** (incremental mutation testing) + **Gate M2** helpers (test-layer detection used by `src/mock-policy/`). Pre-push quality gate. TypeScript-only; uses Stryker.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boyingliu01/xp-gate",
3
- "version": "0.35.20",
3
+ "version": "0.35.22",
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.35.20",
3
+ "version": "0.35.22",
4
4
  "displayName": "XP-Gate",
5
5
  "description": "Extreme Programming quality gates + AI workflow skills for Claude Code. 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-11-02
4
- **Commit:** 60545e49
4
+ **Commit:** 57ef51ed
5
5
  **Branch:** main
6
- **Version:** 0.35.20.0
6
+ **Version:** 0.35.22.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-11-02
4
- **Commit:** 60545e49
4
+ **Commit:** 57ef51ed
5
5
  **Branch:** main
6
- **Version:** 0.35.20.0
6
+ **Version:** 0.35.22.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.
@@ -1,9 +1,9 @@
1
1
  # SKILLS/TEST-SPECIFICATION-ALIGNMENT KNOWLEDGE BASE
2
2
 
3
3
  **Generated:** 2026-11-02
4
- **Commit:** 60545e49
4
+ **Commit:** 57ef51ed
5
5
  **Branch:** main
6
- **Version:** 0.35.20.0
6
+ **Version:** 0.35.22.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.35.20",
3
+ "version": "0.35.22",
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",
@@ -1,9 +1,9 @@
1
1
  # SKILLS/DELPHI-REVIEW KNOWLEDGE BASE
2
2
 
3
3
  **Generated:** 2026-11-02
4
- **Commit:** 60545e49
4
+ **Commit:** 57ef51ed
5
5
  **Branch:** main
6
- **Version:** 0.35.20.0
6
+ **Version:** 0.35.22.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-11-02
4
- **Commit:** 60545e49
4
+ **Commit:** 57ef51ed
5
5
  **Branch:** main
6
- **Version:** 0.35.20.0
6
+ **Version:** 0.35.22.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.
@@ -1,9 +1,9 @@
1
1
  # SKILLS/TEST-SPECIFICATION-ALIGNMENT KNOWLEDGE BASE
2
2
 
3
3
  **Generated:** 2026-11-02
4
- **Commit:** 60545e49
4
+ **Commit:** 57ef51ed
5
5
  **Branch:** main
6
- **Version:** 0.35.20.0
6
+ **Version:** 0.35.22.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/opencode-plugin",
3
- "version": "0.35.20",
3
+ "version": "0.35.22",
4
4
  "type": "module",
5
5
  "main": "index.ts",
6
6
  "description": "XP-Gate quality gates + AI workflow skills for OpenCode",
@@ -1,9 +1,9 @@
1
1
  # SKILLS/DELPHI-REVIEW KNOWLEDGE BASE
2
2
 
3
3
  **Generated:** 2026-11-02
4
- **Commit:** 60545e49
4
+ **Commit:** 57ef51ed
5
5
  **Branch:** main
6
- **Version:** 0.35.20.0
6
+ **Version:** 0.35.22.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-11-02
4
- **Commit:** 60545e49
4
+ **Commit:** 57ef51ed
5
5
  **Branch:** main
6
- **Version:** 0.35.20.0
6
+ **Version:** 0.35.22.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.
@@ -1,9 +1,9 @@
1
1
  # SKILLS/TEST-SPECIFICATION-ALIGNMENT KNOWLEDGE BASE
2
2
 
3
3
  **Generated:** 2026-11-02
4
- **Commit:** 60545e49
4
+ **Commit:** 57ef51ed
5
5
  **Branch:** main
6
- **Version:** 0.35.20.0
6
+ **Version:** 0.35.22.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.35.20",
3
+ "version": "0.35.22",
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-11-02
4
- **Commit:** 60545e49
4
+ **Commit:** 57ef51ed
5
5
  **Branch:** main
6
- **Version:** 0.35.20.0
6
+ **Version:** 0.35.22.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-11-02
4
- **Commit:** 60545e49
4
+ **Commit:** 57ef51ed
5
5
  **Branch:** main
6
- **Version:** 0.35.20.0
6
+ **Version:** 0.35.22.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.
@@ -1,9 +1,9 @@
1
1
  # SKILLS/TEST-SPECIFICATION-ALIGNMENT KNOWLEDGE BASE
2
2
 
3
3
  **Generated:** 2026-11-02
4
- **Commit:** 60545e49
4
+ **Commit:** 57ef51ed
5
5
  **Branch:** main
6
- **Version:** 0.35.20.0
6
+ **Version:** 0.35.22.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-11-02
4
- **Commit:** 60545e49
4
+ **Commit:** 57ef51ed
5
5
  **Branch:** main
6
- **Version:** 0.35.20.0
6
+ **Version:** 0.35.22.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Clean Code & SOLID principles checker — **Gate 4** of pre-commit. 14 rules × 9 language adapters, SARIF 2.1.0 output. Houses the **Boy Scout Rule** enforcement engine (Gate 6) and warning-baseline storage.
@@ -1,9 +1,9 @@
1
1
  # SKILLS/DELPHI-REVIEW KNOWLEDGE BASE
2
2
 
3
3
  **Generated:** 2026-11-02
4
- **Commit:** 60545e49
4
+ **Commit:** 57ef51ed
5
5
  **Branch:** main
6
- **Version:** 0.35.20.0
6
+ **Version:** 0.35.22.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-11-02
4
- **Commit:** 60545e49
4
+ **Commit:** 57ef51ed
5
5
  **Branch:** main
6
- **Version:** 0.35.20.0
6
+ **Version:** 0.35.22.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.
@@ -1,9 +1,9 @@
1
1
  # SKILLS/TEST-SPECIFICATION-ALIGNMENT KNOWLEDGE BASE
2
2
 
3
3
  **Generated:** 2026-11-02
4
- **Commit:** 60545e49
4
+ **Commit:** 57ef51ed
5
5
  **Branch:** main
6
- **Version:** 0.35.20.0
6
+ **Version:** 0.35.22.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.