@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.
- package/adapters/cpp.sh +78 -10
- package/adapters/csharp.sh +58 -3
- package/adapters/gate-3.sh +15 -5
- package/adapters/gate-8.sh +131 -9
- package/adapters/typescript.sh +32 -8
- package/build-integrity/__tests__/import-resolver.test.ts +257 -0
- package/build-integrity/__tests__/quote-masker.test.ts +177 -0
- package/build-integrity/gate-10.ts +127 -9
- package/build-integrity/quote-masker.ts +266 -0
- package/gate-10.sh +66 -0
- package/gate-12-file-hygiene.sh +15 -7
- package/gate-13-compiler-strictness.sh +81 -1
- package/gate-3.sh +15 -5
- package/gate-6-layers.sh +375 -0
- package/gate-8.sh +131 -9
- package/hooks/gate-10.sh +66 -0
- package/hooks/gate-12-file-hygiene.sh +15 -7
- package/hooks/gate-13-compiler-strictness.sh +81 -1
- package/hooks/gate-3.sh +15 -5
- package/hooks/gate-6-layers.sh +375 -0
- package/hooks/gate-8.sh +131 -9
- package/hooks/gate-registry.sh +2 -2
- package/hooks/hook-module-resolution.sh +1 -1
- package/hooks/lib/assertion-quality.sh +8 -2
- package/hooks/lib/ccn-ratchet.sh +10 -0
- package/hooks/lib/layer-baseline.cjs +88 -0
- package/hooks/lib/typecheck.sh +28 -5
- package/hooks/pre-commit +376 -53
- package/hooks/pre-push +46 -13
- package/lib/__tests__/agent-runtime-journal.test.js +1 -1
- package/lib/__tests__/arch.test.js +9 -0
- package/lib/__tests__/audit-cli-contract.test.ts +1 -1
- package/lib/__tests__/check-alignment-reasons.test.mjs +11 -1
- package/lib/__tests__/check-all-skip-accounting.test.js +1 -1
- package/lib/__tests__/detect-deps-gate-identity.test.js +135 -0
- package/lib/__tests__/detect-deps.test.js +2 -1
- package/lib/__tests__/doctor-469-hook-env.test.js +7 -1
- package/lib/__tests__/doctor-arch-tools.test.js +169 -0
- package/lib/__tests__/doctor-delphi.test.js +1 -1
- package/lib/__tests__/doctor-drift-round2.test.js +4 -1
- package/lib/__tests__/doctor-executed-surface.test.js +45 -24
- package/lib/__tests__/doctor-module-drift.test.js +13 -7
- package/lib/__tests__/doctor-module-resolution-parity.test.js +74 -2
- package/lib/__tests__/doctor-tui-skill-freshness.test.js +21 -6
- package/lib/__tests__/doctor.test.js +17 -0
- package/lib/__tests__/gate-runner-tsx-invocation.test.js +149 -0
- package/lib/__tests__/gate-runner.test.js +23 -7
- package/lib/__tests__/init-gitignore.test.js +204 -0
- package/lib/__tests__/init.test.js +24 -3
- package/lib/__tests__/language-tools-build-file-install.test.js +82 -0
- package/lib/__tests__/language-tools-detect.test.js +61 -0
- package/lib/__tests__/mirror-sync.test.js +2 -0
- package/lib/__tests__/phase-transition.test.js +19 -1
- package/lib/__tests__/sprint-status-rework.test.js +32 -12
- package/lib/__tests__/test-alignment-range-guard.test.ts +82 -0
- package/lib/__tests__/test-alignment.test.ts +13 -3
- package/lib/__tests__/update-skill.test.js +2 -2
- package/lib/detect-deps.js +7 -1
- package/lib/doctor.js +81 -17
- package/lib/gate-runner.js +101 -7
- package/lib/hook-module-resolution.js +18 -6
- package/lib/init.js +136 -1
- package/lib/language-tools.js +217 -1
- package/lib/layer-baseline.cjs +88 -0
- package/lib/mattpocock-license-verdict.json +1 -1
- package/lib/principles.js +21 -6
- package/lib/test-alignment.ts +452 -55
- package/mock-policy/AGENTS.md +1 -1
- package/mutation/AGENTS.md +1 -1
- package/package.json +2 -1
- package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
- package/plugins/claude-code/skills/delphi-review/.delphi-config.json.example +34 -24
- package/plugins/claude-code/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/claude-code/skills/delphi-review/INSTALL.md +29 -1
- package/plugins/claude-code/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +1 -1
- package/plugins/dsh/package.json +1 -1
- package/plugins/dsh/skills/delphi-review/.delphi-config.json.example +34 -24
- package/plugins/dsh/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/dsh/skills/delphi-review/INSTALL.md +29 -1
- package/plugins/dsh/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/dsh/skills/test-specification-alignment/AGENTS.md +1 -1
- package/plugins/dsh/src/client.test.ts +1 -1
- package/plugins/dsh/src/command.test.ts +1 -1
- package/plugins/dsh/src/contract.test.ts +1 -1
- package/plugins/dsh/src/credentials.test.ts +1 -1
- package/plugins/opencode/package.json +1 -1
- package/plugins/opencode/skills/delphi-review/.delphi-config.json.example +34 -24
- package/plugins/opencode/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/opencode/skills/delphi-review/INSTALL.md +29 -1
- package/plugins/opencode/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +1 -1
- package/plugins/qoder/plugin.json +1 -1
- package/plugins/qoder/skills/delphi-review/.delphi-config.json.example +34 -24
- package/plugins/qoder/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/qoder/skills/delphi-review/INSTALL.md +29 -1
- package/plugins/qoder/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +1 -1
- package/principles/AGENTS.md +1 -1
- package/principles/__tests__/config-arch-group.test.ts +106 -0
- package/principles/__tests__/config-enforcement.test.ts +1 -1
- package/principles/adapters/control-nesting.ts +572 -0
- package/principles/adapters/csharp.ts +73 -42
- package/principles/adapters/java.ts +9 -5
- package/principles/adapters/typescript.ts +138 -176
- package/principles/config.ts +37 -2
- package/principles/index.ts +57 -4
- package/principles/reporter.ts +99 -65
- package/principles/rules/arch/__tests__/dependency.test.ts +180 -0
- package/principles/rules/arch/__tests__/naming.test.ts +133 -0
- package/principles/rules/arch/__tests__/shared.test.ts +113 -0
- package/principles/rules/arch/dependency.ts +264 -0
- package/principles/rules/arch/naming.ts +188 -0
- package/principles/rules/arch/shared.ts +169 -0
- package/principles/rules/exports.ts +26 -0
- package/principles/rules/index.ts +11 -18
- package/scripts/__tests__/sync-package-content.test.js +23 -1
- package/scripts/sync-package-content.js +8 -2
- package/skills/delphi-review/.delphi-config.json.example +34 -24
- package/skills/delphi-review/AGENTS.md +1 -1
- package/skills/delphi-review/INSTALL.md +29 -1
- package/skills/sprint-flow/AGENTS.md +1 -1
- 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 };
|
package/lib/principles.js
CHANGED
|
@@ -304,25 +304,40 @@ function expandTargets(targets) {
|
|
|
304
304
|
}
|
|
305
305
|
|
|
306
306
|
function principles(args) {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
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(
|
|
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: ${
|
|
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
|
}
|