@boyingliu01/xp-gate 0.38.97 → 0.38.98

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.
@@ -0,0 +1,141 @@
1
+ import { readFile } from 'fs/promises';
2
+ import { join } from 'path';
3
+
4
+ /**
5
+ * Entry-point reachability for Gate 9's pack check.
6
+ *
7
+ * Extracted from `gate-10.ts` when that file crossed the 1050-line limit that
8
+ * Gate 4's `clean-code.large-file` rule enforces — the same reason and the same
9
+ * shape as the `quote-masker.ts` split beside this file. The seam is real:
10
+ * nothing here knows about tsc, npm, git or gates. It answers one question —
11
+ * given a manifest and a list of shipped paths, which declared entry points are
12
+ * absent from the package?
13
+ *
14
+ * WHY THE QUESTION NEEDS ASKING
15
+ *
16
+ * `npm pack --dry-run` reports which files WOULD publish. That is not the same as
17
+ * "the package can be used". Measured 2026-11-22 on a project declaring
18
+ *
19
+ * { "main": "dist/nonexistent.js", "files": ["dist"] }
20
+ *
21
+ * whose dist/ held only `tsconfig.tsbuildinfo`. npm shipped that file plus
22
+ * `package.json`; the existing check only required "at least one file that is not
23
+ * package.json", so it passed. The resulting tarball contains no JavaScript, and
24
+ * every `require()` of the published package would throw MODULE_NOT_FOUND.
25
+ *
26
+ * A manifest that disagrees with its own contents is the defect the
27
+ * build-integrity gate is named for, so it belongs to gate 9 rather than to a
28
+ * general packaging audit.
29
+ */
30
+
31
+ /**
32
+ * Collect every string leaf of an entry-point field, including nested objects.
33
+ *
34
+ * `exports` is the reason for the recursion: it is usually
35
+ * `{ ".": { "require": "./dist/a.js", "types": "./dist/a.d.ts" } }`, and the
36
+ * strings that matter are two levels down.
37
+ */
38
+ function collectEntryLeaves(value: unknown, out: string[]): void {
39
+ if (typeof value === 'string') {
40
+ out.push(value);
41
+ return;
42
+ }
43
+ if (!value || typeof value !== 'object') return;
44
+ for (const nested of Object.values(value as Record<string, unknown>)) {
45
+ collectEntryLeaves(nested, out);
46
+ }
47
+ }
48
+
49
+ /** Strip a leading "./" or "/" so a declared entry becomes a package-relative path. */
50
+ function toPackageRelative(raw: string): string {
51
+ return raw.replace(/^\.\//, '').replace(/^\//, '');
52
+ }
53
+
54
+ /**
55
+ * Whether a declared entry points into THIS package at all.
56
+ *
57
+ * `main` is conventionally written WITHOUT a leading "./" — "dist/index.js" is
58
+ * the normal form — so the prefix is stripped rather than required. Requiring it
59
+ * is the bug this module already had once: every real manifest was filtered out
60
+ * and the check silently evaluated nothing while reporting success.
61
+ *
62
+ * A bare name with no slash is a dependency resolved inside node_modules, not a
63
+ * path in the tarball, so it is not this module's business.
64
+ */
65
+ function isPackageRelativeEntry(raw: string): boolean {
66
+ const rel = toPackageRelative(raw);
67
+ if (rel === '' || rel === '.') return false;
68
+ if (!rel.includes('/') && !/\.[a-z0-9]+$/i.test(rel)) return false;
69
+ return true;
70
+ }
71
+
72
+ /**
73
+ * The paths npm would accept for a declared entry.
74
+ *
75
+ * Covers extension and directory resolution so an ordinary extensionless manifest
76
+ * ("main": "dist/index") is not a false block — npm resolves both of those, and a
77
+ * checker that did not would reject correct packages.
78
+ */
79
+ function entryCandidates(raw: string): string[] {
80
+ const rel = toPackageRelative(raw);
81
+ return [
82
+ rel,
83
+ `${rel}.js`,
84
+ `${rel}.mjs`,
85
+ `${rel}.cjs`,
86
+ `${rel}.d.ts`,
87
+ `${rel}/index.js`,
88
+ `${rel}/index.mjs`,
89
+ ];
90
+ }
91
+
92
+ /** The fields npm treats as package entry points. */
93
+ const ENTRY_FIELDS = ['main', 'module', 'types', 'exports'] as const;
94
+
95
+ /**
96
+ * Declared entry points that will not exist once the package is installed.
97
+ *
98
+ * Returns the original spelling of each absent entry so the operator can find it
99
+ * in package.json. An empty array means every declared entry is really shipped.
100
+ */
101
+ export function missingEntryPoints(
102
+ manifest: Record<string, unknown>,
103
+ presentPaths: Set<string>
104
+ ): string[] {
105
+ const declared: string[] = [];
106
+ for (const field of ENTRY_FIELDS) {
107
+ collectEntryLeaves(manifest[field], declared);
108
+ }
109
+ return declared
110
+ .filter(isPackageRelativeEntry)
111
+ .filter((raw) => !entryCandidates(raw).some((c) => presentPaths.has(c)));
112
+ }
113
+
114
+ /**
115
+ * The operator-facing message when a manifest names files the tarball lacks, or
116
+ * null when every declared entry is really shipped.
117
+ */
118
+ export function unreachableEntryPointsMessage(
119
+ manifest: Record<string, unknown>,
120
+ files: Array<{ path: string }>
121
+ ): string | null {
122
+ const present = new Set(files.map((f) => f.path));
123
+ const missing = missingEntryPoints(manifest, present);
124
+ if (missing.length === 0) return null;
125
+ return `package.json declares ${missing.length} entry point(s) the package does not contain: ${missing.join(', ')}`;
126
+ }
127
+
128
+ /**
129
+ * Read a package manifest, or null when it is absent or unparseable.
130
+ *
131
+ * A missing manifest is not an error here -- it means there is nothing to
132
+ * reconcile, which is the same situation as a manifest with no entry fields.
133
+ */
134
+ export async function readManifest(projectRoot: string): Promise<Record<string, unknown> | null> {
135
+ try {
136
+ const raw = await readFile(join(projectRoot, 'package.json'), 'utf8');
137
+ return JSON.parse(raw) as Record<string, unknown>;
138
+ } catch {
139
+ return null;
140
+ }
141
+ }
@@ -5,6 +5,7 @@ import * as fsNative from 'fs';
5
5
  import path from 'path';
6
6
  import { maskTextQuotes } from './quote-masker';
7
7
  import { fileURLToPath } from 'url';
8
+ import { readManifest, unreachableEntryPointsMessage } from './entry-points.js';
8
9
  import type {
9
10
  CheckResult,
10
11
  Gate10Options,
@@ -588,6 +589,38 @@ function inspectPackedFiles(
588
589
  return { ok: true, count: files.length };
589
590
  }
590
591
 
592
+ /**
593
+ * Declared entry points that will not be present after `npm install`.
594
+ *
595
+ * WHY THIS EXISTS
596
+ *
597
+ * npm pack answers "which files would publish", not "can the package be used".
598
+ * Measured 2026-11-22 on a project whose package.json said
599
+ *
600
+ * { "main": "dist/nonexistent.js", "files": ["dist"] }
601
+ *
602
+ * with a dist/ holding only tsconfig.tsbuildinfo. npm pack shipped
603
+ * `dist/tsconfig.tsbuildinfo` and `package.json`, inspectPackedFiles saw one
604
+ * non-manifest file, and the gate reported Overall: PASS. The published tarball
605
+ * had no JavaScript in it at all, so every `require()` of that package would have
606
+ * thrown MODULE_NOT_FOUND — and the build-integrity gate called it healthy.
607
+ *
608
+ * The pack check was not wrong; it was answering a narrower question than the one
609
+ * its PASS implies. A manifest that points at files the package does not contain
610
+ * is the exact failure mode this gate is named for.
611
+ *
612
+ * WHAT IS CHECKED, AND WHAT IS DELIBERATELY NOT
613
+ *
614
+ * Only `main` / `module` / `types` (the flat fields) and the string leaves of
615
+ * `exports`. Bare specifiers are skipped: `"main": "some-dependency"` is legal npm
616
+ * and resolves inside node_modules, so treating it as a project path would be a
617
+ * false block. Conditional exports objects are walked for their string leaves
618
+ * because that is where the real entry points live in modern packages.
619
+ *
620
+ * Returns the list of declared-but-absent paths. Empty means nothing to report.
621
+ */
622
+
623
+
591
624
  /**
592
625
  * npm pack is only meaningful when package.json declares a `files` allowlist —
593
626
  * without one, npm ships everything and the "which files would publish" check
@@ -678,6 +711,46 @@ const packFailureResult = (error: unknown, timeoutMs: number): CheckResult => {
678
711
  return { status: 'fail', message: `npm pack failed: ${detail}`, durationMs };
679
712
  };
680
713
 
714
+ /**
715
+ * The operator-facing message when a manifest names files the tarball lacks, or
716
+ * null when every declared entry is really shipped.
717
+ *
718
+ * Split out of runPackCheck to keep that function under the complexity ratchet,
719
+ * and because it carries its own justification: "npm pack shipped something" is
720
+ * not "the package works". Measured 2026-11-22 -- a package whose only shipped
721
+ * file was dist/tsconfig.tsbuildinfo, declaring "main": "dist/nonexistent.js",
722
+ * passed the pack check and produced a tarball no require() could load. A manifest
723
+ * that disagrees with its own contents is the defect this gate exists to catch.
724
+ */
725
+ async function unreachableEntryPoints(
726
+ projectRoot: string,
727
+ files: Array<{ path: string }>
728
+ ): Promise<string | null> {
729
+ const manifest = await readManifest(projectRoot);
730
+ if (!manifest) return null;
731
+ return unreachableEntryPointsMessage(manifest, files);
732
+ }
733
+
734
+ /**
735
+ * The verdict for a successful `npm pack --dry-run`, or the reason it is not one.
736
+ *
737
+ * Split from runPackCheck so that function stays under the complexity ratchet: the
738
+ * ratchet counts decisions, and "did npm ship anything" plus "does the manifest
739
+ * agree with what it shipped" are two independent decisions that were previously
740
+ * inline. Each one already had its own justification comment; now each is a unit.
741
+ */
742
+ async function packVerdict(
743
+ projectRoot: string,
744
+ stdout: string
745
+ ): Promise<{ ok: true; count: number } | { ok: false; message: string }> {
746
+ const packages = JSON.parse(stdout) as Array<{ files?: Array<{ path: string }> }>;
747
+ const shipped = inspectPackedFiles(packages);
748
+ if (!shipped.ok) return shipped;
749
+ const missingEntry = await unreachableEntryPoints(projectRoot, packages[0].files || []);
750
+ if (missingEntry) return { ok: false, message: missingEntry };
751
+ return { ok: true, count: shipped.count };
752
+ }
753
+
681
754
  export async function runPackCheck(
682
755
  projectRoot: string,
683
756
  timeoutMs: number
@@ -696,8 +769,7 @@ export async function runPackCheck(
696
769
  shell: true,
697
770
  maxBuffer: 10 * 1024 * 1024,
698
771
  });
699
-
700
- const verdict = inspectPackedFiles(JSON.parse(stdout) as Array<{ files?: Array<{ path: string }> }>);
772
+ const verdict = await packVerdict(projectRoot, stdout);
701
773
  if (!verdict.ok) {
702
774
  return { status: 'fail', message: verdict.message, durationMs: Date.now() - startTime };
703
775
  }
@@ -2,6 +2,6 @@
2
2
  "verdict": "PASS",
3
3
  "license_type": "MIT",
4
4
  "sha256": "0e7ac423bf2c6e223b7c5b156f8cf72da49d748e56a1641402c31f22ad07dbb5",
5
- "checked_at": "2026-11-22T15:39:02.244Z",
5
+ "checked_at": "2026-11-22T16:15:26.305Z",
6
6
  "source": "network"
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boyingliu01/xp-gate",
3
- "version": "0.38.97",
3
+ "version": "0.38.98",
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.38.97",
3
+ "version": "0.38.98",
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": {
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.38.97.0
6
+ **Version:** 0.38.98.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.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.38.97.0
6
+ **Version:** 0.38.98.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; each REQ starts from a clean context instead of accumulating one across REQs). HARD-GATE between DESIGN (2/6) and BUILD (3/6): design must pass Delphi review (≥90% consensus) before any coding.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.38.97.0
6
+ **Version:** 0.38.98.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.38.97",
3
+ "version": "0.38.98",
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",
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.38.97.0
6
+ **Version:** 0.38.98.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.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.38.97.0
6
+ **Version:** 0.38.98.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; each REQ starts from a clean context instead of accumulating one across REQs). HARD-GATE between DESIGN (2/6) and BUILD (3/6): design must pass Delphi review (≥90% consensus) before any coding.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.38.97.0
6
+ **Version:** 0.38.98.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.38.97",
3
+ "version": "0.38.98",
4
4
  "type": "module",
5
5
  "main": "index.ts",
6
6
  "description": "XP-Gate quality gates + AI workflow skills for OpenCode",
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.38.97.0
6
+ **Version:** 0.38.98.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.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.38.97.0
6
+ **Version:** 0.38.98.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; each REQ starts from a clean context instead of accumulating one across REQs). HARD-GATE between DESIGN (2/6) and BUILD (3/6): design must pass Delphi review (≥90% consensus) before any coding.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.38.97.0
6
+ **Version:** 0.38.98.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.38.97",
3
+ "version": "0.38.98",
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": {
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.38.97.0
6
+ **Version:** 0.38.98.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.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.38.97.0
6
+ **Version:** 0.38.98.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; each REQ starts from a clean context instead of accumulating one across REQs). HARD-GATE between DESIGN (2/6) and BUILD (3/6): design must pass Delphi review (≥90% consensus) before any coding.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.38.97.0
6
+ **Version:** 0.38.98.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.38.97.0
6
+ **Version:** 0.38.98.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.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.38.97.0
6
+ **Version:** 0.38.98.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; each REQ starts from a clean context instead of accumulating one across REQs). HARD-GATE between DESIGN (2/6) and BUILD (3/6): design must pass Delphi review (≥90% consensus) before any coding.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.38.97.0
6
+ **Version:** 0.38.98.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.