@boyingliu01/xp-gate 0.36.1 → 0.37.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 (123) hide show
  1. package/adapters/cpp.sh +78 -10
  2. package/adapters/csharp.sh +58 -3
  3. package/adapters/gate-3.sh +15 -5
  4. package/adapters/gate-8.sh +131 -9
  5. package/adapters/typescript.sh +32 -8
  6. package/build-integrity/__tests__/import-resolver.test.ts +257 -0
  7. package/build-integrity/__tests__/quote-masker.test.ts +177 -0
  8. package/build-integrity/gate-10.ts +127 -9
  9. package/build-integrity/quote-masker.ts +266 -0
  10. package/gate-10.sh +66 -0
  11. package/gate-12-file-hygiene.sh +15 -7
  12. package/gate-13-compiler-strictness.sh +81 -1
  13. package/gate-3.sh +15 -5
  14. package/gate-6-layers.sh +375 -0
  15. package/gate-8.sh +131 -9
  16. package/hooks/gate-10.sh +66 -0
  17. package/hooks/gate-12-file-hygiene.sh +15 -7
  18. package/hooks/gate-13-compiler-strictness.sh +81 -1
  19. package/hooks/gate-3.sh +15 -5
  20. package/hooks/gate-6-layers.sh +375 -0
  21. package/hooks/gate-8.sh +131 -9
  22. package/hooks/gate-registry.sh +2 -2
  23. package/hooks/hook-module-resolution.sh +1 -1
  24. package/hooks/lib/assertion-quality.sh +8 -2
  25. package/hooks/lib/ccn-ratchet.sh +10 -0
  26. package/hooks/lib/layer-baseline.cjs +88 -0
  27. package/hooks/lib/typecheck.sh +28 -5
  28. package/hooks/pre-commit +376 -53
  29. package/hooks/pre-push +46 -13
  30. package/lib/__tests__/agent-runtime-journal.test.js +1 -1
  31. package/lib/__tests__/arch.test.js +9 -0
  32. package/lib/__tests__/audit-cli-contract.test.ts +1 -1
  33. package/lib/__tests__/check-alignment-reasons.test.mjs +11 -1
  34. package/lib/__tests__/check-all-skip-accounting.test.js +1 -1
  35. package/lib/__tests__/detect-deps-gate-identity.test.js +135 -0
  36. package/lib/__tests__/detect-deps.test.js +2 -1
  37. package/lib/__tests__/doctor-469-hook-env.test.js +7 -1
  38. package/lib/__tests__/doctor-arch-tools.test.js +169 -0
  39. package/lib/__tests__/doctor-delphi.test.js +1 -1
  40. package/lib/__tests__/doctor-drift-round2.test.js +4 -1
  41. package/lib/__tests__/doctor-executed-surface.test.js +45 -24
  42. package/lib/__tests__/doctor-module-drift.test.js +13 -7
  43. package/lib/__tests__/doctor-module-resolution-parity.test.js +74 -2
  44. package/lib/__tests__/doctor-tui-skill-freshness.test.js +21 -6
  45. package/lib/__tests__/doctor.test.js +17 -0
  46. package/lib/__tests__/gate-runner-tsx-invocation.test.js +149 -0
  47. package/lib/__tests__/gate-runner.test.js +23 -7
  48. package/lib/__tests__/init-gitignore.test.js +204 -0
  49. package/lib/__tests__/init.test.js +24 -3
  50. package/lib/__tests__/language-tools-build-file-install.test.js +82 -0
  51. package/lib/__tests__/language-tools-detect.test.js +61 -0
  52. package/lib/__tests__/mirror-sync.test.js +2 -0
  53. package/lib/__tests__/phase-transition.test.js +19 -1
  54. package/lib/__tests__/sprint-status-rework.test.js +32 -12
  55. package/lib/__tests__/test-alignment-range-guard.test.ts +82 -0
  56. package/lib/__tests__/test-alignment.test.ts +13 -3
  57. package/lib/__tests__/update-skill.test.js +2 -2
  58. package/lib/detect-deps.js +7 -1
  59. package/lib/doctor.js +81 -17
  60. package/lib/gate-runner.js +101 -7
  61. package/lib/hook-module-resolution.js +18 -6
  62. package/lib/init.js +136 -1
  63. package/lib/language-tools.js +217 -1
  64. package/lib/layer-baseline.cjs +88 -0
  65. package/lib/mattpocock-license-verdict.json +1 -1
  66. package/lib/principles.js +21 -6
  67. package/lib/test-alignment.ts +452 -55
  68. package/mock-policy/AGENTS.md +1 -1
  69. package/mutation/AGENTS.md +1 -1
  70. package/package.json +2 -1
  71. package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
  72. package/plugins/claude-code/skills/delphi-review/.delphi-config.json.example +34 -24
  73. package/plugins/claude-code/skills/delphi-review/AGENTS.md +1 -1
  74. package/plugins/claude-code/skills/delphi-review/INSTALL.md +29 -1
  75. package/plugins/claude-code/skills/sprint-flow/AGENTS.md +1 -1
  76. package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +1 -1
  77. package/plugins/dsh/package.json +1 -1
  78. package/plugins/dsh/skills/delphi-review/.delphi-config.json.example +34 -24
  79. package/plugins/dsh/skills/delphi-review/AGENTS.md +1 -1
  80. package/plugins/dsh/skills/delphi-review/INSTALL.md +29 -1
  81. package/plugins/dsh/skills/sprint-flow/AGENTS.md +1 -1
  82. package/plugins/dsh/skills/test-specification-alignment/AGENTS.md +1 -1
  83. package/plugins/dsh/src/client.test.ts +1 -1
  84. package/plugins/dsh/src/command.test.ts +1 -1
  85. package/plugins/dsh/src/contract.test.ts +1 -1
  86. package/plugins/dsh/src/credentials.test.ts +1 -1
  87. package/plugins/opencode/package.json +1 -1
  88. package/plugins/opencode/skills/delphi-review/.delphi-config.json.example +34 -24
  89. package/plugins/opencode/skills/delphi-review/AGENTS.md +1 -1
  90. package/plugins/opencode/skills/delphi-review/INSTALL.md +29 -1
  91. package/plugins/opencode/skills/sprint-flow/AGENTS.md +1 -1
  92. package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +1 -1
  93. package/plugins/qoder/plugin.json +1 -1
  94. package/plugins/qoder/skills/delphi-review/.delphi-config.json.example +34 -24
  95. package/plugins/qoder/skills/delphi-review/AGENTS.md +1 -1
  96. package/plugins/qoder/skills/delphi-review/INSTALL.md +29 -1
  97. package/plugins/qoder/skills/sprint-flow/AGENTS.md +1 -1
  98. package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +1 -1
  99. package/principles/AGENTS.md +1 -1
  100. package/principles/__tests__/config-arch-group.test.ts +106 -0
  101. package/principles/__tests__/config-enforcement.test.ts +1 -1
  102. package/principles/adapters/control-nesting.ts +572 -0
  103. package/principles/adapters/csharp.ts +73 -42
  104. package/principles/adapters/java.ts +9 -5
  105. package/principles/adapters/typescript.ts +138 -176
  106. package/principles/config.ts +37 -2
  107. package/principles/index.ts +57 -4
  108. package/principles/reporter.ts +99 -65
  109. package/principles/rules/arch/__tests__/dependency.test.ts +180 -0
  110. package/principles/rules/arch/__tests__/naming.test.ts +133 -0
  111. package/principles/rules/arch/__tests__/shared.test.ts +113 -0
  112. package/principles/rules/arch/dependency.ts +264 -0
  113. package/principles/rules/arch/naming.ts +188 -0
  114. package/principles/rules/arch/shared.ts +169 -0
  115. package/principles/rules/exports.ts +26 -0
  116. package/principles/rules/index.ts +11 -18
  117. package/scripts/__tests__/sync-package-content.test.js +23 -1
  118. package/scripts/sync-package-content.js +8 -2
  119. package/skills/delphi-review/.delphi-config.json.example +34 -24
  120. package/skills/delphi-review/AGENTS.md +1 -1
  121. package/skills/delphi-review/INSTALL.md +29 -1
  122. package/skills/sprint-flow/AGENTS.md +1 -1
  123. package/skills/test-specification-alignment/AGENTS.md +1 -1
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Layer-baseline comparison for Gate 6's layer check.
4
+ *
5
+ * Reads findings on stdin (one per line, fields separated by real TABs) and a
6
+ * JSON ledger as argv[2], and writes the findings that are NOT in the ledger.
7
+ *
8
+ * Exit 4 when the ledger exists but cannot be parsed. The caller treats that as
9
+ * BLOCK (fail-closed): a ledger that silently reads as empty would turn every
10
+ * accepted violation back into a new one, and the next natural response — re-run
11
+ * with a bigger baseline — quietly launders the debt.
12
+ *
13
+ * Why this is a file and not an inline `node -e`: the first version embedded
14
+ * this in bash single quotes, and the TAB separators ended up inside a JSON
15
+ * string literal, which JSON.parse rejects (raw control character). The error
16
+ * was then swallowed by `2>/dev/null`, so the ratchet silently reset on every
17
+ * run. Three levels of quoting is where that hid; one level is enough.
18
+ *
19
+ * Ledger shape:
20
+ * { "accepted": [ { "file", "from", "to", "imports" }, ... ] }
21
+ *
22
+ * A plain tab-joined string is also accepted for entries, so hand-written and
23
+ * generated ledgers both work.
24
+ */
25
+
26
+ 'use strict';
27
+
28
+ const fs = require('fs');
29
+
30
+ const SEVERITY_EXIT_UNREADABLE = 4;
31
+
32
+ /** Normalise one ledger entry to the tab-joined form used on stdin. */
33
+ function toKey(entry) {
34
+ if (typeof entry === 'string') {
35
+ return entry;
36
+ }
37
+ if (entry && typeof entry === 'object') {
38
+ return [entry.file, entry.from, entry.to, entry.imports].join('\t');
39
+ }
40
+ return '';
41
+ }
42
+
43
+ /** Read and validate the ledger. Throws when it cannot be used. */
44
+ function readLedger(path) {
45
+ const raw = fs.readFileSync(path, 'utf8');
46
+ const parsed = JSON.parse(raw);
47
+ const accepted = Array.isArray(parsed.accepted) ? parsed.accepted : [];
48
+ return new Set(accepted.map(toKey).filter(Boolean));
49
+ }
50
+
51
+ /** Split stdin into findings and drop the baselined ones. */
52
+ function filterFindings(raw, known) {
53
+ return raw
54
+ .split('\n')
55
+ .filter(Boolean)
56
+ .filter(line => !known.has(line));
57
+ }
58
+
59
+ function main() {
60
+ const ledgerPath = process.argv[2];
61
+ if (!ledgerPath) {
62
+ process.stderr.write('usage: layer-baseline.cjs <ledger.json> < findings\n');
63
+ process.exit(SEVERITY_EXIT_UNREADABLE);
64
+ return;
65
+ }
66
+
67
+ let known;
68
+ try {
69
+ known = readLedger(ledgerPath);
70
+ } catch (err) {
71
+ process.stderr.write(`layer-baseline unreadable: ${err.message}\n`);
72
+ process.exit(SEVERITY_EXIT_UNREADABLE);
73
+ return;
74
+ }
75
+
76
+ let raw = '';
77
+ process.stdin.setEncoding('utf8');
78
+ process.stdin.on('data', chunk => {
79
+ raw += chunk;
80
+ });
81
+ process.stdin.on('end', () => {
82
+ process.stdout.write(filterFindings(raw, known).join('\n'));
83
+ });
84
+ }
85
+
86
+ main();
87
+
88
+ module.exports = { toKey, readLedger, filterFindings };
@@ -2,6 +2,6 @@
2
2
  "verdict": "PASS",
3
3
  "license_type": "MIT",
4
4
  "sha256": "0e7ac423bf2c6e223b7c5b156f8cf72da49d748e56a1641402c31f22ad07dbb5",
5
- "checked_at": "2026-11-05T16:16:15.014Z",
5
+ "checked_at": "2026-11-09T03:15:43.031Z",
6
6
  "source": "network"
7
7
  }
package/lib/principles.js CHANGED
@@ -304,25 +304,40 @@ function expandTargets(targets) {
304
304
  }
305
305
 
306
306
  function principles(args) {
307
- const target = args[0];
308
- if (!target) {
309
- console.error('Usage: xp-gate principles <file_or_directory> [--format console|json|sarif]');
307
+ // #761: the CLI advertises `<file_or_directory>` while the implementation read
308
+ // `args[0]` only. `xp-gate principles a.ts b.ts c.ts` therefore analysed `a.ts`
309
+ // and dropped the rest without saying so -- the caller asked for three files,
310
+ // one was checked, and the report looked complete. Collect every positional
311
+ // argument instead, skipping the value that belongs to --format.
312
+ const formatIdx = args.indexOf('--format');
313
+ const positional = [];
314
+ for (let i = 0; i < args.length; i += 1) {
315
+ const arg = args[i];
316
+ if (arg === '--format') {
317
+ i += 1; // its value is not a target
318
+ continue;
319
+ }
320
+ if (arg.startsWith('--')) continue;
321
+ positional.push(arg);
322
+ }
323
+
324
+ if (positional.length === 0) {
325
+ console.error('Usage: xp-gate principles <file_or_directory>... [--format console|json|sarif]');
310
326
  return Promise.resolve(1);
311
327
  }
312
328
 
313
- const formatIdx = args.indexOf('--format');
314
329
  const format = formatIdx >= 0 ? args[formatIdx + 1] : 'console';
315
330
 
316
331
  // Expand directories before handing them to the checker (#565). Passing a
317
332
  // directory straight through made the checker examine zero files while the
318
333
  // CLI printed "No violations found" and exited 0.
319
- const files = expandTargets([target]);
334
+ const files = expandTargets(positional);
320
335
  if (files.length === 0) {
321
336
  // Nothing to analyse is NOT a pass. Saying so is the whole point: silence
322
337
  // here is indistinguishable from a clean directory. Exit 2 mirrors the
323
338
  // checker's own "examined nothing" contract, which reserves 1 for
324
339
  // "examined files and found violations".
325
- console.error(`[xp-gate principles] no analysable source files under: ${target}`);
340
+ console.error(`[xp-gate principles] no analysable source files under: ${positional.join(' ')}`);
326
341
  console.error(' Supported: ' + Array.from(SOURCE_EXTENSIONS).join(' '));
327
342
  return Promise.resolve(2);
328
343
  }