@holmes-lab/holmes-kit 0.41.2 → 0.41.3
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/CHANGELOG.md +35 -0
- package/README.md +28 -5
- package/bin/holmes-mcp.js +36 -1
- package/dist/.build-id +1 -1
- package/dist/holmes/cli/claude-switches.d.ts +9 -0
- package/dist/holmes/cli/claude-switches.js +11 -8
- package/dist/holmes/cli/doctor.d.ts +7 -1
- package/dist/holmes/cli/doctor.js +63 -20
- package/dist/holmes/cli/holmes-hook-id.d.ts +9 -0
- package/dist/holmes/cli/holmes-hook-id.js +22 -0
- package/dist/holmes/cli/hook-failure-posture.d.ts +44 -0
- package/dist/holmes/cli/hook-failure-posture.js +65 -0
- package/dist/holmes/cli/index.js +3 -1
- package/dist/holmes/cli/init.d.ts +6 -0
- package/dist/holmes/cli/init.js +151 -3
- package/dist/holmes/cli/native-deps.d.ts +10 -4
- package/dist/holmes/cli/native-deps.js +30 -29
- package/dist/holmes/cli/run-wiring.js +4 -2
- package/dist/holmes/cli/runtime-binding.d.ts +24 -0
- package/dist/holmes/cli/runtime-binding.js +67 -25
- package/dist/holmes/cli/settings-merge.d.ts +3 -2
- package/dist/holmes/cli/settings-merge.js +11 -9
- package/dist/holmes/config/config.d.ts +6 -0
- package/dist/holmes/config/config.js +23 -3
- package/dist/holmes/config/judgement-keys.d.ts +20 -0
- package/dist/holmes/config/judgement-keys.js +100 -0
- package/dist/holmes/config/project-caps.js +3 -2
- package/dist/holmes/governance/autonomous-shell.js +1 -1
- package/dist/holmes/governance/autonomy.d.ts +27 -1
- package/dist/holmes/governance/autonomy.js +126 -6
- package/dist/holmes/governance/wiring-receipt.d.ts +7 -0
- package/dist/holmes/governance/wiring-receipt.js +84 -0
- package/dist/holmes/guardrail/cli-root.d.ts +31 -0
- package/dist/holmes/guardrail/cli-root.js +261 -0
- package/dist/holmes/guardrail/command-traits.d.ts +2 -0
- package/dist/holmes/guardrail/command-traits.js +26 -1
- package/dist/holmes/guardrail/impact-gate.d.ts +17 -1
- package/dist/holmes/guardrail/impact-gate.js +44 -5
- package/dist/holmes/guardrail/outward-acts.js +10 -3
- package/dist/holmes/guardrail/package-manager-acts.d.ts +41 -0
- package/dist/holmes/guardrail/package-manager-acts.js +1298 -0
- package/dist/holmes/guardrail/refusal-codes.js +9 -1
- package/dist/holmes/guardrail/shell-syntax.d.ts +3 -0
- package/dist/holmes/guardrail/shell-syntax.js +7 -2
- package/dist/holmes/guardrail/write-target.d.ts +20 -0
- package/dist/holmes/guardrail/write-target.js +168 -2
- package/dist/holmes/hooks/pre-tool-use.d.ts +110 -3
- package/dist/holmes/hooks/pre-tool-use.js +1208 -60
- package/dist/holmes/mcp/evidence-artifact.d.ts +112 -0
- package/dist/holmes/mcp/evidence-artifact.js +2 -0
- package/dist/holmes/mcp/handlers/maintenance-evidence.d.ts +2 -1
- package/dist/holmes/mcp/handlers/maintenance-evidence.js +24 -2
- package/dist/holmes/mcp/handlers/operator-inspection.d.ts +1 -1
- package/dist/holmes/mcp/handlers/operator-inspection.js +2 -2
- package/dist/holmes/mcp/handlers/requirement-triage.d.ts +1 -1
- package/dist/holmes/mcp/handlers/requirement-triage.js +3 -2
- package/dist/holmes/mcp/handlers/spec-approval.d.ts +1 -1
- package/dist/holmes/mcp/handlers/spec-approval.js +6 -6
- package/dist/holmes/mcp/handlers/test-execution.d.ts +8 -0
- package/dist/holmes/mcp/handlers/test-execution.js +12 -6
- package/dist/holmes/mcp/handlers.d.ts +16 -7
- package/dist/holmes/mcp/maintenance-evidence.d.ts +11 -82
- package/dist/holmes/mcp/maintenance-evidence.js +57 -2
- package/dist/holmes/mcp/outcome-replay.d.ts +18 -0
- package/dist/holmes/mcp/outcome-replay.js +85 -0
- package/dist/holmes/mcp/outcome-windows.d.ts +136 -0
- package/dist/holmes/mcp/outcome-windows.js +236 -0
- package/dist/holmes/mcp/tool-schemas.js +1 -1
- package/dist/holmes/project/hook-specs-arg.d.ts +4 -0
- package/dist/holmes/project/hook-specs-arg.js +39 -0
- package/dist/holmes/project/install-layout.d.ts +11 -0
- package/dist/holmes/project/install-layout.js +109 -0
- package/dist/holmes/project/install-scripts-policy.d.ts +4 -1
- package/dist/holmes/project/install-scripts-policy.js +6 -3
- package/dist/holmes/project/native-recovery.d.ts +29 -0
- package/dist/holmes/project/native-recovery.js +62 -0
- package/dist/holmes/project/root.d.ts +6 -0
- package/dist/holmes/project/root.js +15 -3
- package/dist/holmes/project/wiring-receipt-format.d.ts +20 -0
- package/dist/holmes/project/wiring-receipt-format.js +42 -0
- package/dist/holmes/project/workspace-preflight.d.ts +9 -0
- package/dist/holmes/project/workspace-preflight.js +40 -1
- package/dist/holmes/review/classification-replay.d.ts +53 -0
- package/dist/holmes/review/classification-replay.js +78 -0
- package/dist/holmes/review/head-worktree.js +5 -4
- package/dist/holmes/review/run-provenance.js +3 -2
- package/dist/holmes/review/test-evidence.js +2 -2
- package/dist/holmes/review/test-outcomes.js +3 -1
- package/dist/holmes/rtm/graph-store.d.ts +5 -0
- package/dist/holmes/rtm/graph-store.js +12 -4
- package/dist/holmes/rtm/native-driver.d.ts +42 -0
- package/dist/holmes/rtm/native-driver.js +147 -0
- package/dist/holmes/rtm/rtm-graph.js +11 -2
- package/dist/holmes/runtime/dispatch.d.ts +6 -0
- package/dist/holmes/runtime/dispatch.js +51 -2
- package/dist/holmes/runtime/hook-process.d.ts +6 -0
- package/dist/holmes/runtime/hook-process.js +3 -3
- package/dist/holmes/update/semver-strict.d.ts +3 -0
- package/dist/holmes/update/semver-strict.js +58 -0
- package/docs/install-guide.md +8 -1
- package/package.json +1 -1
- package/playbooks/tdd-slice/PLAYBOOK.md +1 -1
- package/release-history.json +36 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hookFailurePosture = hookFailurePosture;
|
|
4
|
+
exports.hookFailureSentence = hookFailureSentence;
|
|
5
|
+
exports.hookFailurePostureCheck = hookFailurePostureCheck;
|
|
6
|
+
exports.hookFailureNotJudgedCheck = hookFailureNotJudgedCheck;
|
|
7
|
+
// @implements A-SPEC-772.14
|
|
8
|
+
// @implements A-SPEC-772.18
|
|
9
|
+
/**
|
|
10
|
+
* 772.14-2 — what happens to the gate when Holmes's Claude Code PreToolUse hook fails. Measured 2026-11-16 (Claude Code
|
|
11
|
+
* 2.1.325, `claude -p` × 8): with `onFailure` unset, a hook that exits 1, times out or cannot start lets Read, Bash and
|
|
12
|
+
* Edit through and the model sees no error; with `"block"` all three are refused with the hook's stderr.
|
|
13
|
+
*
|
|
14
|
+
* 772.18 — read from `claudeSwitches`, the reader `claude hook switches` uses: every settings file Claude applies
|
|
15
|
+
* (managed, user, project, local, the canonical git root's local), only Holmes's gate entries, and never PASS while those
|
|
16
|
+
* switches say the gate does not run. File reads only — no process, no network. A module of its own: doctor.ts is past
|
|
17
|
+
* the 1,500-line rule.
|
|
18
|
+
*/
|
|
19
|
+
const claude_switches_1 = require("./claude-switches");
|
|
20
|
+
function hookFailurePosture(target, env = (0, claude_switches_1.claudeSwitchEnv)()) {
|
|
21
|
+
const s = (0, claude_switches_1.claudeSwitches)(target, env);
|
|
22
|
+
const { entries, blocking } = s.gateFailure;
|
|
23
|
+
// an unreadable file may hold a gate entry without onFailure, so nothing else can be said
|
|
24
|
+
if (s.unreadable.length > 0)
|
|
25
|
+
return { state: 'unreadable', entries, blocking, files: s.unreadable };
|
|
26
|
+
// A-SPEC-772.18: "Claude refuses every tool if it fails" is false of a gate Claude does not run
|
|
27
|
+
if (s.hooksOff.length > 0 || s.noGate.length > 0)
|
|
28
|
+
return { state: 'not-running', entries, blocking, files: [...s.hooksOff, ...s.noGate] };
|
|
29
|
+
if (entries === 0)
|
|
30
|
+
return { state: 'not-wired', entries, blocking, files: [] };
|
|
31
|
+
return { state: blocking === entries ? 'fail-closed' : 'fail-open', entries, blocking, files: s.gateFailure.files };
|
|
32
|
+
}
|
|
33
|
+
/** The sentence both surfaces say, or null when no Holmes PreToolUse gate is wired where Claude reads it. */
|
|
34
|
+
function hookFailureSentence(p) {
|
|
35
|
+
if (p.state === 'not-wired')
|
|
36
|
+
return null;
|
|
37
|
+
if (p.state === 'unreadable')
|
|
38
|
+
return { open: true, detail: `could not read ${p.files.join(', ')} — whether a failed Holmes hook blocks or lets every tool through is unknown`, fix: 'Make the named settings file a readable JSON object (holmes-kit init rewrites Holmes\'s own entries).' };
|
|
39
|
+
if (p.state === 'not-running')
|
|
40
|
+
return { open: true, detail: `not judged: Claude runs no Holmes gate here (${p.files.join(', ')}) — see the claude hook switches line`, fix: 'Repair what the claude hook switches line names; this line is judged once the gate runs.' };
|
|
41
|
+
if (p.state === 'fail-closed')
|
|
42
|
+
return { open: false, detail: `Holmes's PreToolUse hook carries onFailure "block" (${p.entries} of ${p.entries} entries): if it crashes, times out or cannot start, Claude Code refuses every tool, Read included, until a person repairs it` };
|
|
43
|
+
return {
|
|
44
|
+
open: true,
|
|
45
|
+
detail: `Holmes's PreToolUse hook has no onFailure "block" (${p.entries - p.blocking} of ${p.entries} entries without it) — if the hook crashes, times out or cannot start, Claude Code lets every tool through (measured 2026-11-16)`,
|
|
46
|
+
fix: `A person can add "onFailure": "block" to each Holmes PreToolUse entry in ${p.files.join(', ')} (Claude Code 2.1.295 or later); holmes-kit init keeps it when it rewrites the entry.`,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/** doctor's line. */
|
|
50
|
+
function hookFailurePostureCheck(target, env) {
|
|
51
|
+
const s = hookFailureSentence(hookFailurePosture(target, env));
|
|
52
|
+
if (s === null)
|
|
53
|
+
return null;
|
|
54
|
+
return { name: 'hook failure posture', level: s.open ? 'WARN' : 'PASS', detail: s.detail, ...(s.fix !== undefined ? { fix: s.fix } : {}) };
|
|
55
|
+
}
|
|
56
|
+
/** A-SPEC-772.18 — the surfaces this check does not judge, each with its reason (silence read as "nothing to say"). */
|
|
57
|
+
const NOT_JUDGED = {
|
|
58
|
+
routed: 'the Claude Code gate runs through the runtime router (~/.holmes/runtime), whose settings entries this check does not read',
|
|
59
|
+
codex: 'no failure-behaviour setting for Codex hooks is documented or measured here',
|
|
60
|
+
antigravity: 'no failure-behaviour setting for Antigravity hooks is documented or measured here',
|
|
61
|
+
};
|
|
62
|
+
function hookFailureNotJudgedCheck(surface) {
|
|
63
|
+
return { name: `hook failure posture (${surface})`, level: 'WARN',
|
|
64
|
+
detail: `not judged — ${NOT_JUDGED[surface]}, so whether a failed Holmes hook blocks or lets tools through is unknown` };
|
|
65
|
+
}
|
package/dist/holmes/cli/index.js
CHANGED
|
@@ -37,7 +37,7 @@ exports.isBrokenPipe = void 0;
|
|
|
37
37
|
exports.packageRoot = packageRoot;
|
|
38
38
|
exports.main = main;
|
|
39
39
|
exports.installPipeGuard = installPipeGuard;
|
|
40
|
-
// @implements A-SPEC-794.91, A-SPEC-794.83, A-SPEC-552.4, A-SPEC-552.3, A-SPEC-794.59, A-SPEC-794.58, A-SPEC-794.55, A-SPEC-794.43, A-SPEC-794.42, A-SPEC-794.41, A-SPEC-794.36, A-SPEC-792.48, A-SPEC-792.49, A-SPEC-704, A-SPEC-773, A-SPEC-770.11,A-SPEC-709, A-SPEC-734,A-SPEC-751, A-SPEC-752, A-SPEC-772.4, A-SPEC-779, A-SPEC-102.2, A-SPEC-774.20, A-SPEC-102.7, A-SPEC-779.2, A-SPEC-792.3, A-SPEC-102.10, A-SPEC-102.12, A-SPEC-774.34, A-SPEC-794.30, A-SPEC-794.32, A-SPEC-794.33, A-SPEC-102.29, A-SPEC-102.30, A-SPEC-102.31
|
|
40
|
+
// @implements A-SPEC-772.15, A-SPEC-794.91, A-SPEC-794.83, A-SPEC-552.4, A-SPEC-552.3, A-SPEC-794.59, A-SPEC-794.58, A-SPEC-794.55, A-SPEC-794.43, A-SPEC-794.42, A-SPEC-794.41, A-SPEC-794.36, A-SPEC-792.48, A-SPEC-792.49, A-SPEC-704, A-SPEC-773, A-SPEC-770.11,A-SPEC-709, A-SPEC-734,A-SPEC-751, A-SPEC-752, A-SPEC-772.4, A-SPEC-779, A-SPEC-102.2, A-SPEC-774.20, A-SPEC-102.7, A-SPEC-779.2, A-SPEC-792.3, A-SPEC-102.10, A-SPEC-102.12, A-SPEC-774.34, A-SPEC-794.30, A-SPEC-794.32, A-SPEC-794.33, A-SPEC-102.29, A-SPEC-102.30, A-SPEC-102.31
|
|
41
41
|
// @implements A-SPEC-549.2
|
|
42
42
|
// @implements A-SPEC-591, A-SPEC-626
|
|
43
43
|
const cli_execution_1 = require("./cli-execution");
|
|
@@ -1418,6 +1418,8 @@ async function main(argv, deps = {}) {
|
|
|
1418
1418
|
settingsFile: flags.settings === 'project' ? 'project' : 'local',
|
|
1419
1419
|
mcp: flags['no-mcp'] !== true,
|
|
1420
1420
|
matcher: typeof flags.matcher === 'string' ? flags.matcher : undefined,
|
|
1421
|
+
// @implements A-SPEC-772.15 — which of them the person named; an unnamed one keeps the current wiring
|
|
1422
|
+
explicit: { matcher: flags.matcher !== undefined, specsDir: flags['specs-dir'] !== undefined, settings: flags.settings !== undefined },
|
|
1421
1423
|
dryRun: flags['dry-run'] === true,
|
|
1422
1424
|
force: flags.force === true,
|
|
1423
1425
|
remove: flags.remove === true,
|
|
@@ -25,6 +25,12 @@ export interface InitOptions {
|
|
|
25
25
|
settingsFile: 'local' | 'project';
|
|
26
26
|
mcp: boolean;
|
|
27
27
|
matcher?: string;
|
|
28
|
+
/** @implements A-SPEC-772.15 — which of matcher, spec store and settings file the caller named (the CLI's flags). */
|
|
29
|
+
explicit?: {
|
|
30
|
+
matcher?: boolean;
|
|
31
|
+
specsDir?: boolean;
|
|
32
|
+
settings?: boolean;
|
|
33
|
+
};
|
|
28
34
|
dryRun: boolean;
|
|
29
35
|
force: boolean;
|
|
30
36
|
remove: boolean;
|
package/dist/holmes/cli/init.js
CHANGED
|
@@ -36,7 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.settingsPathOf = exports.MATCHERS = exports.SERVER_NAME = void 0;
|
|
37
37
|
exports.buildHookPlan = buildHookPlan;
|
|
38
38
|
exports.runInit = runInit;
|
|
39
|
-
// @implements A-SPEC-794.121, A-SPEC-794.110, A-SPEC-794.107, A-SPEC-727, A-SPEC-724, A-SPEC-721, A-SPEC-738, A-SPEC-752.8, A-SPEC-772.2, A-SPEC-772.4, A-SPEC-772.5, A-SPEC-772.6, A-SPEC-476.1
|
|
39
|
+
// @implements A-SPEC-772.31, A-SPEC-772.29, A-SPEC-772.28, A-SPEC-772.16, A-SPEC-772.15, A-SPEC-794.121, A-SPEC-794.110, A-SPEC-794.107, A-SPEC-727, A-SPEC-724, A-SPEC-721, A-SPEC-738, A-SPEC-752.8, A-SPEC-772.2, A-SPEC-772.4, A-SPEC-772.5, A-SPEC-772.6, A-SPEC-476.1
|
|
40
40
|
// @implements A-SPEC-709
|
|
41
41
|
// @implements A-SPEC-769.11
|
|
42
42
|
// @implements A-SPEC-340
|
|
@@ -45,6 +45,8 @@ const fs = __importStar(require("node:fs"));
|
|
|
45
45
|
const path = __importStar(require("node:path"));
|
|
46
46
|
const os = __importStar(require("node:os"));
|
|
47
47
|
const settings_merge_1 = require("./settings-merge");
|
|
48
|
+
const hook_specs_arg_1 = require("../project/hook-specs-arg");
|
|
49
|
+
const semver_strict_1 = require("../update/semver-strict");
|
|
48
50
|
const gitignore_merge_1 = require("./gitignore-merge");
|
|
49
51
|
const settings_merge_2 = require("./settings-merge");
|
|
50
52
|
const playbook_skills_1 = require("./playbook-skills");
|
|
@@ -104,7 +106,9 @@ function buildHookPlan(packageRoot, matcher, specsDir = '.ax/specs') {
|
|
|
104
106
|
// --specs-dir docs/specs` reported governed while the gate looked at an empty default directory
|
|
105
107
|
// and refused nothing: the wiring and the enforcement pointed at two different projects. The
|
|
106
108
|
// hooks are told on their own command line; the default stays byte-identical to previous installs.
|
|
107
|
-
|
|
109
|
+
// @implements A-SPEC-772.16 — always named, the default too: argv wins over the harness's HOLMES_SPECS, so a shell
|
|
110
|
+
// profile cannot move the store the gate reads
|
|
111
|
+
const arg = ` --specs "${specsDir}"`;
|
|
108
112
|
const q = (p) => `node "${p}"${arg}`;
|
|
109
113
|
return {
|
|
110
114
|
preToolUseMatcher: matcher,
|
|
@@ -438,9 +442,153 @@ function readForMerge(p) {
|
|
|
438
442
|
throw new InitRefusal(`could not read ${p}, so it was not overwritten: ${(e instanceof Error ? e.message : String(e)).slice(0, 300)}`);
|
|
439
443
|
}
|
|
440
444
|
}
|
|
445
|
+
/**
|
|
446
|
+
* @implements A-SPEC-772.15 — what the existing Holmes PreToolUse gate entry sees: its settings file, matcher and spec
|
|
447
|
+
* store (`--specs "<dir>"` on its command, else the default). null when no file holds one. An unreadable file refuses
|
|
448
|
+
* (readJsonOrRefuse), as every other read init makes before it writes.
|
|
449
|
+
*/
|
|
450
|
+
function currentGateWiring(target, prefer) {
|
|
451
|
+
// A-SPEC-772.29: the file the caller names is read first — the gate it already holds is the one being re-wired
|
|
452
|
+
for (const which of (prefer === 'project' ? ['project', 'local'] : ['local', 'project'])) {
|
|
453
|
+
const s = readJsonOrRefuse((0, exports.settingsPathOf)(target, which)).value;
|
|
454
|
+
// @implements A-SPEC-772.16 — a PreToolUse of the wrong shape is init's shape refusal below, not a TypeError here
|
|
455
|
+
const pre = s?.hooks?.PreToolUse;
|
|
456
|
+
if (!Array.isArray(pre))
|
|
457
|
+
continue;
|
|
458
|
+
for (const g of pre) {
|
|
459
|
+
const h = Array.isArray(g?.hooks) ? g.hooks.find((x) => typeof x?.command === 'string' && (0, settings_merge_1.isHolmesCommand)(x.command) && /pre-tool-use/.test(x.command)) : undefined;
|
|
460
|
+
if (h === undefined)
|
|
461
|
+
continue;
|
|
462
|
+
// A-SPEC-772.16: the hook's own reader (project/hook-specs-arg) — a value it cannot read is a differing store
|
|
463
|
+
const named = (0, hook_specs_arg_1.specsArgOfCommand)(String(h.command));
|
|
464
|
+
return { which, matcher: typeof g.matcher === 'string' ? g.matcher : undefined, specsDir: named ?? '.ax/specs', command: String(h.command) };
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
return null;
|
|
468
|
+
}
|
|
469
|
+
/** @implements A-SPEC-772.16 — matchers earlier releases wrote as their defaults (git history of MATCHERS): widened by a plain init. */
|
|
470
|
+
const OLD_DEFAULT_MATCHERS = new Set(['Bash', 'Bash|Write|Edit']);
|
|
471
|
+
/** @implements A-SPEC-772.16 — the version of the package an existing gate command runs, or null when unreadable. */
|
|
472
|
+
function wiredPackageVersion(command) {
|
|
473
|
+
const script = (0, settings_merge_1.hookScriptPath)(command);
|
|
474
|
+
const m = /^(.*)[/\\]dist[/\\]holmes[/\\]hooks[/\\]pre-tool-use\.js$/.exec(script);
|
|
475
|
+
if (m === null)
|
|
476
|
+
return null;
|
|
477
|
+
try {
|
|
478
|
+
const v = JSON.parse(fs.readFileSync(path.join(m[1], 'package.json'), 'utf8')).version;
|
|
479
|
+
return typeof v === 'string' ? v : null;
|
|
480
|
+
}
|
|
481
|
+
catch {
|
|
482
|
+
return null;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* @implements A-SPEC-772.15 — re-wiring an already-wired target keeps what the gate sees unless the caller names it, and
|
|
487
|
+
* naming a different matcher, spec store or settings file needs a governance-wiring approval, additive or not (the CLI
|
|
488
|
+
* passes allowAdditive on every run, so the self-disarm guard below never ran: `init --matcher Nothing` and
|
|
489
|
+
* `--specs-dir <empty>` switched the gate off without approval — measured 2026-11-16). The package path may change.
|
|
490
|
+
*/
|
|
491
|
+
function keepGateWiring(opts) {
|
|
492
|
+
if (opts.remove)
|
|
493
|
+
return opts;
|
|
494
|
+
// a caller that does not say what it named (a direct runInit call) named what differs from the defaults
|
|
495
|
+
const named = opts.explicit ?? { matcher: opts.matcher !== undefined, specsDir: opts.specsDir !== '.ax/specs', settings: opts.settingsFile === 'project' };
|
|
496
|
+
// @implements A-SPEC-772.29 — a named settings file that already holds the gate is no change of file (whole suite
|
|
497
|
+
// 2026-11-17: a gate in both files, project named, read as "local → project" and refused; A-SPEC-251.1 round 39)
|
|
498
|
+
const cur = currentGateWiring(opts.target, named.settings === true ? opts.settingsFile : undefined);
|
|
499
|
+
if (cur === null)
|
|
500
|
+
return opts;
|
|
501
|
+
const changed = [];
|
|
502
|
+
// A-SPEC-772.16: an old default matcher is widened by a plain init (as before 772.15); a named `.*` widens, so it is free
|
|
503
|
+
const matcherNow = cur.matcher === undefined || OLD_DEFAULT_MATCHERS.has(cur.matcher) ? exports.MATCHERS[opts.mode] : cur.matcher;
|
|
504
|
+
const matcherWanted = opts.matcher ?? exports.MATCHERS[opts.mode];
|
|
505
|
+
if (named.matcher === true && matcherWanted !== matcherNow && matcherWanted !== exports.MATCHERS[opts.mode])
|
|
506
|
+
changed.push(`the matcher (${matcherNow} → ${opts.matcher})`);
|
|
507
|
+
if (cur.specsDir === 'unreadable')
|
|
508
|
+
changed.push('the spec store (the current --specs value cannot be read)');
|
|
509
|
+
else if (named.specsDir === true && opts.specsDir !== cur.specsDir)
|
|
510
|
+
changed.push(`the spec store (${cur.specsDir} → ${opts.specsDir})`);
|
|
511
|
+
if (named.settings === true && opts.settingsFile !== cur.which)
|
|
512
|
+
changed.push(`the settings file (${cur.which} → ${opts.settingsFile})`);
|
|
513
|
+
// @implements A-SPEC-772.31 — the named file's gate is the current wiring only when the other file's gate agrees: the
|
|
514
|
+
// same store, package root and matcher (review of 772.29, M1: a decoy store from an older copy in settings.json passed)
|
|
515
|
+
if (named.settings === true && cur.which === opts.settingsFile) {
|
|
516
|
+
const other = currentGateWiring(opts.target, cur.which === 'project' ? 'local' : 'project');
|
|
517
|
+
if (other !== null && other.which !== cur.which) {
|
|
518
|
+
const pkgOf = (command) => {
|
|
519
|
+
const m = /^(.*)[/\\]dist[/\\]holmes[/\\]hooks[/\\]pre-tool-use\.js$/.exec((0, settings_merge_1.hookScriptPath)(command));
|
|
520
|
+
if (m === null)
|
|
521
|
+
return null;
|
|
522
|
+
try {
|
|
523
|
+
return fs.realpathSync.native(m[1]);
|
|
524
|
+
}
|
|
525
|
+
catch {
|
|
526
|
+
return path.resolve(m[1]);
|
|
527
|
+
}
|
|
528
|
+
};
|
|
529
|
+
const a = pkgOf(cur.command);
|
|
530
|
+
const b = pkgOf(other.command);
|
|
531
|
+
if (other.specsDir !== cur.specsDir || a === null || a !== b || (other.matcher ?? '') !== (cur.matcher ?? '')) {
|
|
532
|
+
changed.push(`the gate (the two gate entries disagree: ${cur.which} — store ${cur.specsDir}, package ${a ?? 'unreadable'}; ${other.which} — store ${other.specsDir}, package ${b ?? 'unreadable'})`);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
// A-SPEC-772.16: a re-pin to a lower version than the one wired is a downgrade (the owner's, as for `upgrade`, 11/15)
|
|
537
|
+
const wiredVersion = wiredPackageVersion(cur.command);
|
|
538
|
+
const ownVersion = (() => { try {
|
|
539
|
+
const v = JSON.parse(fs.readFileSync(path.join(opts.packageRoot, 'package.json'), 'utf8')).version;
|
|
540
|
+
return typeof v === 'string' ? v : null;
|
|
541
|
+
}
|
|
542
|
+
catch {
|
|
543
|
+
return null;
|
|
544
|
+
} })();
|
|
545
|
+
// @implements A-SPEC-772.23 — the two package roots compared by real path (a link to the wired copy's root is that copy;
|
|
546
|
+
// another root is another copy, even when its dist links to the same build)
|
|
547
|
+
const realOr = (p) => { try {
|
|
548
|
+
return fs.realpathSync.native(p);
|
|
549
|
+
}
|
|
550
|
+
catch {
|
|
551
|
+
return path.resolve(p);
|
|
552
|
+
} };
|
|
553
|
+
const wiredRoot = /^(.*)[/\\]dist[/\\]holmes[/\\]hooks[/\\]pre-tool-use\.js$/.exec(path.resolve((0, settings_merge_1.hookScriptPath)(cur.command)))?.[1];
|
|
554
|
+
if (wiredRoot === undefined || realOr(wiredRoot) !== realOr(opts.packageRoot)) {
|
|
555
|
+
// the copy being wired decides a downgrade (a second line: the governing gate refuses another copy first — 772.23)
|
|
556
|
+
if (ownVersion === null)
|
|
557
|
+
changed.push('the holmes-kit build (this copy\'s version cannot be read)');
|
|
558
|
+
// @implements A-SPEC-772.17 — a wired version that cannot be read is no free repair: deleting the wired package.json
|
|
559
|
+
// is allowed by the gate (measured), and no other reference survives it (the workspace record is as cheap to change;
|
|
560
|
+
// the governing version reads the same file), so the re-wiring needs the owner
|
|
561
|
+
else if (wiredVersion === null)
|
|
562
|
+
changed.push('the holmes-kit build (the wired version cannot be read)');
|
|
563
|
+
else {
|
|
564
|
+
// @implements A-SPEC-772.23 — strict semver only, prereleases below their release (`garbage`, `99`, `1e3` and a
|
|
565
|
+
// prerelease over its release compared as versions — review A, measured)
|
|
566
|
+
const order = (0, semver_strict_1.strictSemverCompare)(ownVersion, wiredVersion);
|
|
567
|
+
if (order === null)
|
|
568
|
+
changed.push(`the holmes-kit build (${wiredVersion} → ${ownVersion}: not both strict semver, so the order cannot be judged)`);
|
|
569
|
+
else if (order < 0)
|
|
570
|
+
changed.push(`the holmes-kit build (${wiredVersion} → ${ownVersion}, a lower version)`);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
if (changed.length > 0 && !(0, risk_gate_1.approvalCovers)(opts.approval, { kind: 'governance-wiring', target: opts.target }, new Date().toISOString())) {
|
|
574
|
+
return { ok: false, exitCode: 2, changes: [], messages: [
|
|
575
|
+
`Changing what the gate sees — ${changed.join(', ')} — is changing the governance wiring: an out-of-band approval is required (self-disarm prevention). Nothing was written.`,
|
|
576
|
+
'Set HOLMES_APPROVAL=\'{"actor":"<you>","token":"<any>","rationale":"<why>"}\' (scoped approvals need kind "governance-wiring") and re-run.',
|
|
577
|
+
] };
|
|
578
|
+
}
|
|
579
|
+
return {
|
|
580
|
+
...opts,
|
|
581
|
+
matcher: named.matcher === true ? opts.matcher : matcherNow,
|
|
582
|
+
specsDir: named.specsDir === true || cur.specsDir === 'unreadable' ? opts.specsDir : cur.specsDir,
|
|
583
|
+
settingsFile: named.settings === true ? opts.settingsFile : cur.which,
|
|
584
|
+
};
|
|
585
|
+
}
|
|
441
586
|
function runInit(opts) {
|
|
442
587
|
try {
|
|
443
|
-
|
|
588
|
+
const kept = keepGateWiring(opts);
|
|
589
|
+
if ('ok' in kept)
|
|
590
|
+
return kept;
|
|
591
|
+
return runInitUnguarded(kept);
|
|
444
592
|
}
|
|
445
593
|
catch (e) {
|
|
446
594
|
if (!(e instanceof InitRefusal))
|
|
@@ -12,7 +12,8 @@ import type { Coverage } from '../project/install-scripts-policy';
|
|
|
12
12
|
* Pure. The caller (doctor) gathers the evidence; every process it spawns for that is optional,
|
|
13
13
|
* and "not observed" is carried as `undefined`, never as `false`.
|
|
14
14
|
*/
|
|
15
|
-
export type InstallKind
|
|
15
|
+
export type { InstallKind } from '../project/install-layout';
|
|
16
|
+
import type { InstallKind } from '../project/install-layout';
|
|
16
17
|
export type NativeCause = 'ok' | 'scripts-blocked' | 'abi-mismatch' | 'build-failed' | 'unknown';
|
|
17
18
|
export type Level = 'PASS' | 'WARN' | 'FAIL';
|
|
18
19
|
export interface NativeEvidence {
|
|
@@ -28,6 +29,8 @@ export interface NativeEvidence {
|
|
|
28
29
|
/** How the ROOT package.json that governs this install covers the package (A-SPEC-579). */
|
|
29
30
|
coverage: Coverage;
|
|
30
31
|
installKind: InstallKind;
|
|
32
|
+
/** A-SPEC-580.8: P, when the global kind came from a prefix layout — the global commands name `--prefix <P>`. */
|
|
33
|
+
installPrefix?: string;
|
|
31
34
|
/** win32 only: whether a source build could even start. */
|
|
32
35
|
toolchain?: {
|
|
33
36
|
python: boolean;
|
|
@@ -38,8 +41,7 @@ export interface NativeEvidence {
|
|
|
38
41
|
/** win32 only: `Get-ExecutionPolicy`, when observed. */
|
|
39
42
|
psPolicy?: string;
|
|
40
43
|
}
|
|
41
|
-
|
|
42
|
-
export declare function installKind(packageRoot: string, globalDir?: string): InstallKind;
|
|
44
|
+
export { installKind, installPrefix } from '../project/install-layout';
|
|
43
45
|
/**
|
|
44
46
|
* The narrowest commands that repair each layout. `--allow-scripts=<pkg>` is a per-invocation flag
|
|
45
47
|
* scoped to ONE package — never `--dangerously-allow-all-scripts`, never a change to npm config.
|
|
@@ -51,12 +53,16 @@ export declare function installKind(packageRoot: string, globalDir?: string): In
|
|
|
51
53
|
* prefix to be writable — a protected prefix fails EPERM there, which is the `global prefix`
|
|
52
54
|
* check's territory, not this one's.)
|
|
53
55
|
*/
|
|
54
|
-
export declare function recoveryCommands(ev: Pick<NativeEvidence, 'platform' | 'installKind' | 'packageName' | 'packageVersion'>): string[];
|
|
56
|
+
export declare function recoveryCommands(ev: Pick<NativeEvidence, 'platform' | 'installKind' | 'packageName' | 'packageVersion' | 'installPrefix'>): string[];
|
|
55
57
|
/**
|
|
56
58
|
* What a PowerShell execution policy means for the emitted commands. Only the two policies that
|
|
57
59
|
* refuse every unsigned local script block the `npm.ps1`/`npx.ps1` shims; the rest add nothing.
|
|
58
60
|
*/
|
|
59
61
|
export declare function powershellPolicyNote(policy: string | undefined): string;
|
|
62
|
+
/**
|
|
63
|
+
* @implements A-SPEC-580.10 — doctor alone names `--prefix`; when its fix carries one, the prefix note follows it (the
|
|
64
|
+
* path a `<PREFIX>` stands for, or Git Bash's quoting for a win32 path).
|
|
65
|
+
*/
|
|
60
66
|
export declare function nativeVerdict(ev: NativeEvidence): {
|
|
61
67
|
cause: NativeCause;
|
|
62
68
|
level: Level;
|
|
@@ -1,29 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.installKind =
|
|
3
|
+
exports.installPrefix = exports.installKind = void 0;
|
|
4
4
|
exports.recoveryCommands = recoveryCommands;
|
|
5
5
|
exports.powershellPolicyNote = powershellPolicyNote;
|
|
6
6
|
exports.nativeVerdict = nativeVerdict;
|
|
7
|
-
// @implements A-SPEC-599
|
|
7
|
+
// @implements A-SPEC-599, A-SPEC-580.10, A-SPEC-580.11
|
|
8
8
|
// @implements A-SPEC-580
|
|
9
9
|
// @implements A-SPEC-580.1
|
|
10
|
+
// @implements A-SPEC-580.4
|
|
11
|
+
// @implements A-SPEC-580.7
|
|
12
|
+
// @implements A-SPEC-580.8
|
|
13
|
+
// @implements A-SPEC-580.9
|
|
10
14
|
const npx_bin_1 = require("../project/npx-bin");
|
|
11
|
-
const
|
|
15
|
+
const native_recovery_1 = require("../project/native-recovery");
|
|
12
16
|
const HOLMES_PKG = '@holmes-lab/holmes-kit';
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return 'npx';
|
|
18
|
-
if (globalDir) {
|
|
19
|
-
const g = globalDir.replace(/\\/g, '/').replace(/\/+$/, '');
|
|
20
|
-
if (norm.toLowerCase().startsWith(`${g.toLowerCase()}/`))
|
|
21
|
-
return 'global';
|
|
22
|
-
}
|
|
23
|
-
if (/\/node_modules\/@holmes-lab\/holmes-kit$/.test(norm))
|
|
24
|
-
return 'local';
|
|
25
|
-
return 'repo';
|
|
26
|
-
}
|
|
17
|
+
// @implements A-SPEC-580.9 — the layout reader lives in project/install-layout (rtm/ and project/ read it too)
|
|
18
|
+
var install_layout_1 = require("../project/install-layout");
|
|
19
|
+
Object.defineProperty(exports, "installKind", { enumerable: true, get: function () { return install_layout_1.installKind; } });
|
|
20
|
+
Object.defineProperty(exports, "installPrefix", { enumerable: true, get: function () { return install_layout_1.installPrefix; } });
|
|
27
21
|
/**
|
|
28
22
|
* The narrowest commands that repair each layout. `--allow-scripts=<pkg>` is a per-invocation flag
|
|
29
23
|
* scoped to ONE package — never `--dangerously-allow-all-scripts`, never a change to npm config.
|
|
@@ -36,22 +30,20 @@ function installKind(packageRoot, globalDir) {
|
|
|
36
30
|
* check's territory, not this one's.)
|
|
37
31
|
*/
|
|
38
32
|
function recoveryCommands(ev) {
|
|
33
|
+
// @implements A-SPEC-580.4 — the commands come from the one source (project/native-recovery)
|
|
39
34
|
const npm = (0, npx_bin_1.npmBin)(ev.platform);
|
|
40
|
-
const
|
|
41
|
-
(0, install_scripts_policy_1.approveCommand)(ev.packageName, ev.packageVersion, npm),
|
|
42
|
-
`${npm} rebuild ${ev.packageName} --foreground-scripts`,
|
|
43
|
-
];
|
|
35
|
+
const r = (0, native_recovery_1.nativeRecovery)({ platform: ev.platform, packageName: ev.packageName, packageVersion: ev.packageVersion, prefix: ev.installPrefix });
|
|
44
36
|
switch (ev.installKind) {
|
|
45
|
-
case 'global': return
|
|
46
|
-
case 'npx': return [`${npm} install --save-dev ${HOLMES_PKG}`, ...project];
|
|
47
|
-
default: return project;
|
|
37
|
+
case 'global': return r.global;
|
|
38
|
+
case 'npx': return [`${npm} install --save-dev ${HOLMES_PKG}`, ...r.project];
|
|
39
|
+
default: return r.project;
|
|
48
40
|
}
|
|
49
41
|
}
|
|
50
42
|
/** A rebuild alone (the script is approved or the policy is not the problem). */
|
|
51
43
|
function rebuildCommand(ev) {
|
|
52
44
|
const npm = (0, npx_bin_1.npmBin)(ev.platform);
|
|
53
45
|
return ev.installKind === 'global'
|
|
54
|
-
?
|
|
46
|
+
? (0, native_recovery_1.nativeRecovery)({ platform: ev.platform, packageName: ev.packageName, prefix: ev.installPrefix }).global[0]
|
|
55
47
|
: `${npm} rebuild ${ev.packageName} --foreground-scripts`;
|
|
56
48
|
}
|
|
57
49
|
/**
|
|
@@ -65,8 +57,19 @@ function powershellPolicyNote(policy) {
|
|
|
65
57
|
return '';
|
|
66
58
|
}
|
|
67
59
|
const ABI_RE = /NODE_MODULE_VERSION|compiled against a different Node\.js version/;
|
|
60
|
+
/**
|
|
61
|
+
* @implements A-SPEC-580.10 — doctor alone names `--prefix`; when its fix carries one, the prefix note follows it (the
|
|
62
|
+
* path a `<PREFIX>` stands for, or Git Bash's quoting for a win32 path).
|
|
63
|
+
*/
|
|
68
64
|
function nativeVerdict(ev) {
|
|
69
|
-
const
|
|
65
|
+
const v = verdictOf(ev);
|
|
66
|
+
const note = ev.installKind === 'global'
|
|
67
|
+
? (0, native_recovery_1.nativeRecovery)({ platform: ev.platform, packageName: ev.packageName, prefix: ev.installPrefix }).note : '';
|
|
68
|
+
// A-SPEC-580.11: on its own line — on a command's line its words would be pasted as arguments
|
|
69
|
+
return note !== '' && v.fix !== undefined && v.fix.includes('--prefix ') ? { ...v, fix: `${v.fix}\n${note}` } : v;
|
|
70
|
+
}
|
|
71
|
+
function verdictOf(ev) {
|
|
72
|
+
const pkg = ev.packageVersion ? `${ev.packageName}@${ev.packageVersion}` : ev.packageName; // A-SPEC-580.8: unread → bare name
|
|
70
73
|
const isWin = ev.platform === 'win32';
|
|
71
74
|
const psNote = isWin ? powershellPolicyNote(ev.psPolicy) : '';
|
|
72
75
|
const withPs = (detail) => (psNote ? `${detail} ${psNote}` : detail);
|
|
@@ -95,9 +98,7 @@ function nativeVerdict(ev) {
|
|
|
95
98
|
return {
|
|
96
99
|
cause: 'scripts-blocked', level: 'FAIL',
|
|
97
100
|
detail: withPs(`no binary — ${npmSaid} blocks dependency install scripts unless allowScripts covers ${pkg}${denied}; policy home: ${policyHome}.`),
|
|
98
|
-
fix: `Approve the one script that must run, then rebuild: ${recoveryCommands(ev).
|
|
99
|
-
? "; if ($LASTEXITCODE -ne 0) { throw 'Native dependency recovery failed' }; "
|
|
100
|
-
: ' && ')}`,
|
|
101
|
+
fix: `Approve the one script that must run, then rebuild: ${(0, native_recovery_1.joinCommands)(recoveryCommands(ev), ev.platform)}`,
|
|
101
102
|
};
|
|
102
103
|
}
|
|
103
104
|
// 6b. Early npm 11 did not block scripts, so a missing approval proves nothing about why the
|
|
@@ -41,7 +41,7 @@ exports.exactMcp = exactMcp;
|
|
|
41
41
|
exports.exactGate = exactGate;
|
|
42
42
|
exports.packageInside = packageInside;
|
|
43
43
|
exports.codexTrusts = codexTrusts;
|
|
44
|
-
// @implements A-SPEC-774.30, A-SPEC-774.32
|
|
44
|
+
// @implements A-SPEC-774.30, A-SPEC-774.32, A-SPEC-772.16
|
|
45
45
|
/**
|
|
46
46
|
* What a worktree's wiring launches, judged by content. A "holmes" substring is not wiring: a settings.json holding
|
|
47
47
|
* only that word skipped provisioning and passed the gate check (measured by an orchestrator's review). An MCP entry is Holmes's when it runs
|
|
@@ -211,8 +211,10 @@ function exactGate(docs, want) {
|
|
|
211
211
|
if (event === 'PreToolUse' && matcher !== undefined && matcher !== '.*')
|
|
212
212
|
return false;
|
|
213
213
|
const hooks = g.hooks;
|
|
214
|
+
// A-SPEC-772.16: a command written before every hook named its store (no `--specs`) names the default store
|
|
215
|
+
const legacy = command.replace(/ --specs "\.ax\/specs"$/, '');
|
|
214
216
|
return Array.isArray(hooks) && hooks.some((h) => h && typeof h === 'object'
|
|
215
|
-
&& h.type === 'command' && h.command === command);
|
|
217
|
+
&& h.type === 'command' && (h.command === command || h.command === legacy));
|
|
216
218
|
});
|
|
217
219
|
};
|
|
218
220
|
const parsed = docs.map((d) => ({ file: d.file, doc: parseJson(d.text) }));
|
|
@@ -96,11 +96,35 @@ export declare function runtimeBindingStatus(registryPath: string, workspace: st
|
|
|
96
96
|
duplicateRoutes: DuplicateRoute[];
|
|
97
97
|
router: "changed" | "intact";
|
|
98
98
|
routerOutdated: string[];
|
|
99
|
+
routerLacks: RouterLack[];
|
|
99
100
|
activation: "observed" | "unverified";
|
|
100
101
|
observed: Record<string, string>;
|
|
101
102
|
observedUnrouted: Record<string, string>;
|
|
102
103
|
observedOther: Record<string, string>;
|
|
103
104
|
};
|
|
105
|
+
/**
|
|
106
|
+
* @implements A-SPEC-772.25 — what each router capability is, in which deployed file a text marks it, and what a router
|
|
107
|
+
* without it lets through. One row per capability (a later one is one more row).
|
|
108
|
+
*/
|
|
109
|
+
export declare const ROUTER_CAPABILITIES: ReadonlyArray<{
|
|
110
|
+
capability: string;
|
|
111
|
+
spec: string;
|
|
112
|
+
effect: string;
|
|
113
|
+
markers: ReadonlyArray<{
|
|
114
|
+
file: string;
|
|
115
|
+
marker: string;
|
|
116
|
+
}>;
|
|
117
|
+
}>;
|
|
118
|
+
export type RouterLack = {
|
|
119
|
+
capability: string;
|
|
120
|
+
files: string[];
|
|
121
|
+
spec: string;
|
|
122
|
+
effect: string;
|
|
123
|
+
};
|
|
124
|
+
/** @implements A-SPEC-772.25 — the capabilities the router deployed in `registryDir` lacks; no `dispatch.js`, no router. */
|
|
125
|
+
export declare function routerCapabilities(registryDir: string): RouterLack[];
|
|
126
|
+
/** @implements A-SPEC-772.25 — doctor's words: what the router lets through, and that the owner's setup (not upgrade) fixes it. */
|
|
127
|
+
export declare function routerLacksLine(lacks: RouterLack[]): string;
|
|
104
128
|
export declare function runRuntimeBinding(opts: RuntimeBindingOptions): unknown;
|
|
105
129
|
/**
|
|
106
130
|
* @implements A-SPEC-752.7 — which of `files` lie inside `root` and are tracked by git, relative to `root` and sorted.
|