@holmes-lab/holmes-kit 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.
- package/CHANGELOG.md +79 -0
- package/README.md +2 -2
- package/dist/.build-id +1 -1
- package/dist/holmes/cli/doctor.d.ts +35 -0
- package/dist/holmes/cli/doctor.js +278 -1
- package/dist/holmes/cli/runtime-binding.js +190 -174
- package/dist/holmes/cli/settings-merge.d.ts +1 -0
- package/dist/holmes/cli/settings-merge.js +6 -2
- package/dist/holmes/cpg/scan-cache.d.ts +1 -0
- package/dist/holmes/cpg/scan-cache.js +11 -0
- package/dist/holmes/hooks/rtm-refresh-child.d.ts +16 -0
- package/dist/holmes/hooks/rtm-refresh-child.js +49 -15
- package/dist/holmes/hooks/rtm-refresh.d.ts +22 -0
- package/dist/holmes/hooks/rtm-refresh.js +117 -13
- package/dist/holmes/mcp/handlers/graph-operations.js +7 -4
- package/dist/holmes/mcp/handlers/requirement-triage.js +6 -2
- package/dist/holmes/mcp/requirement-triage-evidence.d.ts +7 -0
- package/dist/holmes/mcp/requirement-triage-evidence.js +18 -7
- package/dist/holmes/project/bounded-io.d.ts +1 -0
- package/dist/holmes/project/bounded-io.js +3 -1
- package/dist/holmes/refresh/freshness-coordinator.d.ts +15 -0
- package/dist/holmes/refresh/freshness-coordinator.js +46 -3
- package/package.json +1 -1
|
@@ -42,7 +42,7 @@ exports.codexDuplicateRoutes = codexDuplicateRoutes;
|
|
|
42
42
|
exports.runtimeBindingStatus = runtimeBindingStatus;
|
|
43
43
|
exports.runRuntimeBinding = runRuntimeBinding;
|
|
44
44
|
exports.trackedWorkspacePaths = trackedWorkspacePaths;
|
|
45
|
-
// @implements A-SPEC-769.10, A-SPEC-752.10, A-SPEC-752.9, A-SPEC-751.5, A-SPEC-751.6, A-SPEC-751, A-SPEC-752, A-SPEC-752.7, A-SPEC-752.8
|
|
45
|
+
// @implements A-SPEC-769.10, A-SPEC-752.11, A-SPEC-752.12, A-SPEC-752.13, A-SPEC-752.10, A-SPEC-752.9, A-SPEC-751.5, A-SPEC-751.6, A-SPEC-751, A-SPEC-752, A-SPEC-752.7, A-SPEC-752.8
|
|
46
46
|
const fs = __importStar(require("node:fs"));
|
|
47
47
|
const os = __importStar(require("node:os"));
|
|
48
48
|
const path = __importStar(require("node:path"));
|
|
@@ -557,187 +557,191 @@ function runRuntimeBinding(opts) {
|
|
|
557
557
|
delete ours.Stop;
|
|
558
558
|
add(file, json({ ...doc, 'holmes-kit': ours }));
|
|
559
559
|
};
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
continue;
|
|
574
|
-
for (const file of globalAliases) {
|
|
575
|
-
if (normalized(key).startsWith(normalized(`${file}:`)))
|
|
576
|
-
disabledGlobalKeys.add(key.slice(file.length + 1));
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
const codexFiles = [codexHooks, path.join(root, '.codex/hooks.json')];
|
|
580
|
-
const codexDocs = codexFiles.map((f) => document(readOptional(f), f));
|
|
581
|
-
// @implements A-SPEC-752.9 — Codex keys a hook's enable state by position (<file>:<event>:<group>:<hook>). Measured
|
|
582
|
-
// 2026-10-05: the plan removed two Holmes groups from the user file and wrote one at index 0, whose key said
|
|
583
|
-
// `enabled = false`; the gate was written and never ran. A gate the plan writes is looked up by its own key.
|
|
584
|
-
const planCodex = (forced) => {
|
|
585
|
-
codexProjectEvents.clear();
|
|
586
|
-
const events = codexFiles.map(() => new Set());
|
|
587
|
-
for (const event of ['PreToolUse', 'Stop']) {
|
|
588
|
-
const existing = codexDocs.findIndex((d, source) => Array.isArray(d.hooks?.[event])
|
|
589
|
-
&& d.hooks[event].some((g, group) => Array.isArray(g?.hooks)
|
|
590
|
-
&& g.hooks.some((h, hook) => owns(h?.command) && !disabledGlobalCodex(codexFiles[source], event, group, hook))));
|
|
591
|
-
// Explicit development activation adds missing lifecycles only to this project.
|
|
592
|
-
// Filling an empty user lifecycle would also activate every consumer workspace.
|
|
593
|
-
const empty = codexDocs.findIndex((d) => Array.isArray(d.hooks?.[event]) && d.hooks[event].length === 0);
|
|
594
|
-
const owner = forced.has(event) ? 1 : existing >= 0 ? existing : activate.has('codex') ? 1 : empty >= 0 ? empty : 0;
|
|
595
|
-
events[owner].add(event);
|
|
596
|
-
if (owner === 1)
|
|
597
|
-
codexProjectEvents.add(event);
|
|
560
|
+
// @implements A-SPEC-752.11 — removal plans no harness wiring: every harness entry calls the same router programs and
|
|
561
|
+
// the router reads the registry live, so dropping the binding is the whole act. Measured 2026-10-16: remove planned
|
|
562
|
+
// setup's wiring for a workspace with no Codex project files and chose to rewrite the shared, switched-off user Stop.
|
|
563
|
+
if (opts.operation === 'setup')
|
|
564
|
+
try {
|
|
565
|
+
toml(codexConfig, true);
|
|
566
|
+
toml(path.join(root, '.codex/config.toml'), false);
|
|
567
|
+
const userNativeState = (0, codex_toml_1.parseCodexConfig)(readOptional(codexConfig) ?? '');
|
|
568
|
+
const normalized = (s) => process.platform === 'win32' ? s.toLowerCase() : s;
|
|
569
|
+
const globalAliases = new Set([codexHooks]);
|
|
570
|
+
if (fs.existsSync(codexHooks)) {
|
|
571
|
+
globalAliases.add(fs.realpathSync(codexHooks));
|
|
572
|
+
globalAliases.add(fs.realpathSync.native(codexHooks));
|
|
598
573
|
}
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
const switchedOffKeys = [];
|
|
603
|
-
for (const configFile of [codexConfig, path.join(root, '.codex/config.toml')]) {
|
|
604
|
-
const configState = (0, codex_toml_1.parseCodexConfig)(readOptional(configFile) ?? '');
|
|
605
|
-
if (configState.ok)
|
|
606
|
-
for (const [key, state] of Object.entries(configState.doc.hooks?.state ?? {}))
|
|
607
|
-
if (object(state) && state.enabled === false)
|
|
608
|
-
switchedOffKeys.push(key);
|
|
609
|
-
}
|
|
610
|
-
const gatesSwitchedOff = (events) => {
|
|
611
|
-
const found = [];
|
|
612
|
-
codexFiles.forEach((file, source) => {
|
|
613
|
-
const doc = document(planned.get(file)?.after ?? readOptional(file), file);
|
|
614
|
-
// An entry that already stood there, switched off, is not something this plan writes: doctor reports it.
|
|
615
|
-
const standing = document(readOptional(file), file);
|
|
616
|
-
const aliases = new Set([file]);
|
|
617
|
-
if (fs.existsSync(file)) {
|
|
618
|
-
aliases.add(fs.realpathSync(file));
|
|
619
|
-
aliases.add(fs.realpathSync.native(file));
|
|
620
|
-
}
|
|
621
|
-
for (const [event, keyEvent, entry] of [['PreToolUse', 'pre_tool_use', 'pre-tool-use'], ['Stop', 'stop', 'stop']]) {
|
|
622
|
-
if (!events[source].has(event) || !Array.isArray(doc.hooks?.[event]))
|
|
574
|
+
if (userNativeState.ok)
|
|
575
|
+
for (const [key, state] of Object.entries(userNativeState.doc.hooks?.state ?? {})) {
|
|
576
|
+
if (!object(state) || state.enabled !== false)
|
|
623
577
|
continue;
|
|
624
|
-
|
|
625
|
-
if (
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
return;
|
|
629
|
-
const key = switchedOffKeys.find((k) => [...aliases].some((alias) => normalized(k) === normalized(`${alias}:${keyEvent}:${i}:${j}`)));
|
|
630
|
-
if (key !== undefined)
|
|
631
|
-
found.push({ source, event, key });
|
|
632
|
-
}));
|
|
578
|
+
for (const file of globalAliases) {
|
|
579
|
+
if (normalized(key).startsWith(normalized(`${file}:`)))
|
|
580
|
+
disabledGlobalKeys.add(key.slice(file.length + 1));
|
|
581
|
+
}
|
|
633
582
|
}
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
paths.add(fs.realpathSync(hookFile));
|
|
665
|
-
paths.add(fs.realpathSync.native(hookFile));
|
|
583
|
+
const codexFiles = [codexHooks, path.join(root, '.codex/hooks.json')];
|
|
584
|
+
const codexDocs = codexFiles.map((f) => document(readOptional(f), f));
|
|
585
|
+
// @implements A-SPEC-752.9 — Codex keys a hook's enable state by position (<file>:<event>:<group>:<hook>). Measured
|
|
586
|
+
// 2026-10-05: the plan removed two Holmes groups from the user file and wrote one at index 0, whose key said
|
|
587
|
+
// `enabled = false`; the gate was written and never ran. A gate the plan writes is looked up by its own key.
|
|
588
|
+
const planCodex = (forced) => {
|
|
589
|
+
codexProjectEvents.clear();
|
|
590
|
+
const events = codexFiles.map(() => new Set());
|
|
591
|
+
for (const event of ['PreToolUse', 'Stop']) {
|
|
592
|
+
const existing = codexDocs.findIndex((d, source) => Array.isArray(d.hooks?.[event])
|
|
593
|
+
&& d.hooks[event].some((g, group) => Array.isArray(g?.hooks)
|
|
594
|
+
&& g.hooks.some((h, hook) => owns(h?.command) && !disabledGlobalCodex(codexFiles[source], event, group, hook))));
|
|
595
|
+
// Explicit development activation adds missing lifecycles only to this project.
|
|
596
|
+
// Filling an empty user lifecycle would also activate every consumer workspace.
|
|
597
|
+
const empty = codexDocs.findIndex((d) => Array.isArray(d.hooks?.[event]) && d.hooks[event].length === 0);
|
|
598
|
+
const owner = forced.has(event) ? 1 : existing >= 0 ? existing : activate.has('codex') ? 1 : empty >= 0 ? empty : 0;
|
|
599
|
+
events[owner].add(event);
|
|
600
|
+
if (owner === 1)
|
|
601
|
+
codexProjectEvents.add(event);
|
|
602
|
+
}
|
|
603
|
+
codexFiles.forEach((f, i) => native(f, 'codex', events[i]));
|
|
604
|
+
return events;
|
|
605
|
+
};
|
|
606
|
+
const switchedOffKeys = [];
|
|
607
|
+
for (const configFile of [codexConfig, path.join(root, '.codex/config.toml')]) {
|
|
608
|
+
const configState = (0, codex_toml_1.parseCodexConfig)(readOptional(configFile) ?? '');
|
|
609
|
+
if (configState.ok)
|
|
610
|
+
for (const [key, state] of Object.entries(configState.doc.hooks?.state ?? {}))
|
|
611
|
+
if (object(state) && state.enabled === false)
|
|
612
|
+
switchedOffKeys.push(key);
|
|
666
613
|
}
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
614
|
+
const gatesSwitchedOff = (events) => {
|
|
615
|
+
const found = [];
|
|
616
|
+
codexFiles.forEach((file, source) => {
|
|
617
|
+
const doc = document(planned.get(file)?.after ?? readOptional(file), file);
|
|
618
|
+
// An entry that already stood there, switched off, is not something this plan writes: doctor reports it.
|
|
619
|
+
const standing = document(readOptional(file), file);
|
|
620
|
+
const aliases = new Set([file]);
|
|
621
|
+
if (fs.existsSync(file)) {
|
|
622
|
+
aliases.add(fs.realpathSync(file));
|
|
623
|
+
aliases.add(fs.realpathSync.native(file));
|
|
624
|
+
}
|
|
671
625
|
for (const [event, keyEvent, entry] of [['PreToolUse', 'pre_tool_use', 'pre-tool-use'], ['Stop', 'stop', 'stop']]) {
|
|
672
|
-
|
|
673
|
-
if (!norm(key).startsWith(norm(prefix)))
|
|
626
|
+
if (!events[source].has(event) || !Array.isArray(doc.hooks?.[event]))
|
|
674
627
|
continue;
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
628
|
+
doc.hooks[event].forEach((g, i) => (Array.isArray(g?.hooks) ? g.hooks : []).forEach((h, j) => {
|
|
629
|
+
if (h?.command !== command('codex', entry))
|
|
630
|
+
return;
|
|
631
|
+
if (JSON.stringify(standing.hooks?.[event]?.[i]?.hooks?.[j]) === JSON.stringify(h))
|
|
632
|
+
return;
|
|
633
|
+
const key = switchedOffKeys.find((k) => [...aliases].some((alias) => normalized(k) === normalized(`${alias}:${keyEvent}:${i}:${j}`)));
|
|
634
|
+
if (key !== undefined)
|
|
635
|
+
found.push({ source, event, key });
|
|
636
|
+
}));
|
|
637
|
+
}
|
|
638
|
+
});
|
|
639
|
+
return found;
|
|
640
|
+
};
|
|
641
|
+
let codexEvents = planCodex(new Set());
|
|
642
|
+
// Explicit activation may use the project file; nothing else may choose another place on its own.
|
|
643
|
+
const toProject = new Set(gatesSwitchedOff(codexEvents).filter((g) => g.source === 0 && activate.has('codex')).map((g) => g.event));
|
|
644
|
+
if (toProject.size > 0)
|
|
645
|
+
codexEvents = planCodex(toProject);
|
|
646
|
+
for (const gate of gatesSwitchedOff(codexEvents)) {
|
|
647
|
+
conflicts.push(`the Codex ${gate.event} gate would be written where Codex has it switched off (${gate.key} is enabled = false), so it would not run; `
|
|
648
|
+
+ (gate.source === 0 && !activate.has('codex')
|
|
649
|
+
? "re-run with --activate-hooks codex to write this workspace's project hooks file, or switch that hook on in Codex (/hooks) and preview again"
|
|
650
|
+
: 'switch that hook on in Codex (/hooks) and preview again'));
|
|
651
|
+
}
|
|
652
|
+
// Native disabled state is indexed by source/group/hook. Keeping its bytes while moving
|
|
653
|
+
// the disabled gate would silently enable it. Refuse that migration, never mint trust.
|
|
654
|
+
// Keep each layer's disabled keys: a project enable override does not change
|
|
655
|
+
// the user-level disabled state consumed by other workspaces.
|
|
656
|
+
const nativeStates = [];
|
|
657
|
+
for (const configFile of [codexConfig, path.join(root, '.codex/config.toml')]) {
|
|
658
|
+
const configState = (0, codex_toml_1.parseCodexConfig)(readOptional(configFile) ?? '');
|
|
659
|
+
if (configState.ok)
|
|
660
|
+
nativeStates.push(...Object.entries(configState.doc.hooks?.state ?? {}));
|
|
661
|
+
}
|
|
662
|
+
for (const hookFile of codexFiles) {
|
|
663
|
+
const oldHooks = document(readOptional(hookFile), hookFile);
|
|
664
|
+
const newHooks = document(planned.get(hookFile)?.after ?? readOptional(hookFile), hookFile);
|
|
665
|
+
const norm = (s) => process.platform === 'win32' ? s.toLowerCase() : s;
|
|
666
|
+
const paths = new Set([hookFile]);
|
|
667
|
+
if (fs.existsSync(hookFile)) {
|
|
668
|
+
paths.add(fs.realpathSync(hookFile));
|
|
669
|
+
paths.add(fs.realpathSync.native(hookFile));
|
|
670
|
+
}
|
|
671
|
+
for (const [key, state] of nativeStates) {
|
|
672
|
+
if (!object(state) || state.enabled !== false)
|
|
673
|
+
continue;
|
|
674
|
+
for (const file of paths)
|
|
675
|
+
for (const [event, keyEvent, entry] of [['PreToolUse', 'pre_tool_use', 'pre-tool-use'], ['Stop', 'stop', 'stop']]) {
|
|
676
|
+
const prefix = `${file}:${keyEvent}:`;
|
|
677
|
+
if (!norm(key).startsWith(norm(prefix)))
|
|
678
|
+
continue;
|
|
679
|
+
const indices = key.slice(prefix.length).match(/^(\d+):(\d+)$/);
|
|
680
|
+
if (!indices)
|
|
681
|
+
continue;
|
|
682
|
+
const i = Number(indices[1]);
|
|
683
|
+
const j = Number(indices[2]);
|
|
684
|
+
const old = oldHooks.hooks?.[event]?.[i]?.hooks?.[j];
|
|
685
|
+
const replacement = newHooks.hooks?.[event]?.[i]?.hooks?.[j];
|
|
686
|
+
if (old && JSON.stringify(replacement) !== JSON.stringify(old)
|
|
687
|
+
&& !(owns(old.command) && replacement?.command === command('codex', entry))) {
|
|
688
|
+
throw new Error('A disabled Codex hook would move to a different native state key; review the hook layout before migration');
|
|
689
|
+
}
|
|
685
690
|
}
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
native(path.join(root, agents_1.CODEX_PLUGIN_DIR, 'hooks.json'), 'codex', false);
|
|
694
|
+
// @implements A-SPEC-751.6 — after the Codex lifecycles are planned, so the entry joins the planned document.
|
|
695
|
+
codexFiles.forEach((f) => routeSessionStart(f, codexSessionStartCommand));
|
|
696
|
+
if (activate.has('codex'))
|
|
697
|
+
addCodexSessionStart(codexFiles[1]);
|
|
698
|
+
const claudeFiles = [path.join(home, '.claude/settings.json'), path.join(root, '.claude/settings.local.json'), path.join(root, '.claude/settings.json')];
|
|
699
|
+
const claudeDocs = claudeFiles.map((f) => document(readOptional(f), f));
|
|
700
|
+
const claudeEvents = claudeFiles.map(() => new Set());
|
|
701
|
+
for (const event of ['PreToolUse', 'Stop']) {
|
|
702
|
+
const existing = claudeDocs.findIndex((d) => Array.isArray(d.hooks?.[event]) && d.hooks[event].some((g) => Array.isArray(g?.hooks) && g.hooks.some((h) => owns(h?.command))));
|
|
703
|
+
const empty = claudeDocs.findIndex((d) => Array.isArray(d.hooks?.[event]) && d.hooks[event].length === 0);
|
|
704
|
+
// Keep an existing owner; otherwise honor an explicit empty source before creating a lifecycle.
|
|
705
|
+
claudeEvents[existing >= 0 ? existing : activate.has('claude') ? 1 : empty >= 0 ? empty : 1].add(event);
|
|
706
|
+
}
|
|
707
|
+
claudeFiles.forEach((f, i) => native(f, 'claude', claudeEvents[i]));
|
|
708
|
+
claudeFiles.forEach((f) => routeSessionStart(f));
|
|
709
|
+
mcp(path.join(root, '.mcp.json'), 'claude');
|
|
710
|
+
mcp(path.join(root, '.agents/mcp_config.json'), 'antigravity');
|
|
711
|
+
const agyUser = (0, agents_1.agyUserHooksPath)(home);
|
|
712
|
+
const agyFiles = [agyUser, path.join(root, '.agents/hooks.json')];
|
|
713
|
+
const agyDocs = agyFiles.map((f) => document(readOptional(f), f)['holmes-kit']);
|
|
714
|
+
const agyEvents = agyFiles.map(() => new Set());
|
|
715
|
+
for (const event of ['PreToolUse', 'Stop']) {
|
|
716
|
+
const existing = agyDocs.findIndex((d, i) => object(d) && Array.isArray(d[event]) && d[event].length > 0
|
|
717
|
+
&& !(activate.has('antigravity') && i === 0 && d.enabled === false));
|
|
718
|
+
const empty = agyDocs.findIndex((d) => object(d) && Array.isArray(d[event]) && d[event].length === 0);
|
|
719
|
+
agyEvents[existing >= 0 ? existing : activate.has('antigravity') ? 1 : empty >= 0 ? empty : 1].add(event);
|
|
720
|
+
}
|
|
721
|
+
agyFiles.forEach((f, i) => agy(f, agyEvents[i]));
|
|
722
|
+
// Installed plugin snapshots are independently loaded. Never imply changing the checkout copy suppresses them.
|
|
723
|
+
const plugins = path.join(path.dirname(codexConfig), 'plugins');
|
|
724
|
+
const cache = path.join(plugins, 'cache');
|
|
725
|
+
if (fs.existsSync(cache)) {
|
|
726
|
+
const vendors = fs.readdirSync(cache, { withFileTypes: true }).filter((d) => d.isDirectory() && /holmes/i.test(d.name));
|
|
727
|
+
const visit = (at, depth) => {
|
|
728
|
+
if (depth > 3)
|
|
729
|
+
return;
|
|
730
|
+
for (const d of fs.readdirSync(at, { withFileTypes: true })) {
|
|
731
|
+
const f = path.join(at, d.name);
|
|
732
|
+
if (d.isDirectory())
|
|
733
|
+
visit(f, depth + 1);
|
|
734
|
+
else if (d.isFile() && d.name === 'hooks.json' && /pre-tool-use|holmes-hook|holmes-stop/.test((0, binding_1.readBounded)(f)))
|
|
735
|
+
conflicts.push(`Cached Holmes hook source needs native plugin activation review: ${f}`);
|
|
686
736
|
}
|
|
737
|
+
};
|
|
738
|
+
for (const vendor of vendors)
|
|
739
|
+
visit(path.join(cache, vendor.name), 0);
|
|
687
740
|
}
|
|
688
741
|
}
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
codexFiles.forEach((f) => routeSessionStart(f, codexSessionStartCommand));
|
|
692
|
-
if (activate.has('codex'))
|
|
693
|
-
addCodexSessionStart(codexFiles[1]);
|
|
694
|
-
const claudeFiles = [path.join(home, '.claude/settings.json'), path.join(root, '.claude/settings.local.json'), path.join(root, '.claude/settings.json')];
|
|
695
|
-
const claudeDocs = claudeFiles.map((f) => document(readOptional(f), f));
|
|
696
|
-
const claudeEvents = claudeFiles.map(() => new Set());
|
|
697
|
-
for (const event of ['PreToolUse', 'Stop']) {
|
|
698
|
-
const existing = claudeDocs.findIndex((d) => Array.isArray(d.hooks?.[event]) && d.hooks[event].some((g) => Array.isArray(g?.hooks) && g.hooks.some((h) => owns(h?.command))));
|
|
699
|
-
const empty = claudeDocs.findIndex((d) => Array.isArray(d.hooks?.[event]) && d.hooks[event].length === 0);
|
|
700
|
-
// Keep an existing owner; otherwise honor an explicit empty source before creating a lifecycle.
|
|
701
|
-
claudeEvents[existing >= 0 ? existing : activate.has('claude') ? 1 : empty >= 0 ? empty : 1].add(event);
|
|
702
|
-
}
|
|
703
|
-
claudeFiles.forEach((f, i) => native(f, 'claude', claudeEvents[i]));
|
|
704
|
-
claudeFiles.forEach((f) => routeSessionStart(f));
|
|
705
|
-
mcp(path.join(root, '.mcp.json'), 'claude');
|
|
706
|
-
mcp(path.join(root, '.agents/mcp_config.json'), 'antigravity');
|
|
707
|
-
const agyUser = (0, agents_1.agyUserHooksPath)(home);
|
|
708
|
-
const agyFiles = [agyUser, path.join(root, '.agents/hooks.json')];
|
|
709
|
-
const agyDocs = agyFiles.map((f) => document(readOptional(f), f)['holmes-kit']);
|
|
710
|
-
const agyEvents = agyFiles.map(() => new Set());
|
|
711
|
-
for (const event of ['PreToolUse', 'Stop']) {
|
|
712
|
-
const existing = agyDocs.findIndex((d, i) => object(d) && Array.isArray(d[event]) && d[event].length > 0
|
|
713
|
-
&& !(activate.has('antigravity') && i === 0 && d.enabled === false));
|
|
714
|
-
const empty = agyDocs.findIndex((d) => object(d) && Array.isArray(d[event]) && d[event].length === 0);
|
|
715
|
-
agyEvents[existing >= 0 ? existing : activate.has('antigravity') ? 1 : empty >= 0 ? empty : 1].add(event);
|
|
742
|
+
catch (e) {
|
|
743
|
+
conflicts.push(e.message);
|
|
716
744
|
}
|
|
717
|
-
agyFiles.forEach((f, i) => agy(f, agyEvents[i]));
|
|
718
|
-
// Installed plugin snapshots are independently loaded. Never imply changing the checkout copy suppresses them.
|
|
719
|
-
const plugins = path.join(path.dirname(codexConfig), 'plugins');
|
|
720
|
-
const cache = path.join(plugins, 'cache');
|
|
721
|
-
if (fs.existsSync(cache)) {
|
|
722
|
-
const vendors = fs.readdirSync(cache, { withFileTypes: true }).filter((d) => d.isDirectory() && /holmes/i.test(d.name));
|
|
723
|
-
const visit = (at, depth) => {
|
|
724
|
-
if (depth > 3)
|
|
725
|
-
return;
|
|
726
|
-
for (const d of fs.readdirSync(at, { withFileTypes: true })) {
|
|
727
|
-
const f = path.join(at, d.name);
|
|
728
|
-
if (d.isDirectory())
|
|
729
|
-
visit(f, depth + 1);
|
|
730
|
-
else if (d.isFile() && d.name === 'hooks.json' && /pre-tool-use|holmes-hook|holmes-stop/.test((0, binding_1.readBounded)(f)))
|
|
731
|
-
conflicts.push(`Cached Holmes hook source needs native plugin activation review: ${f}`);
|
|
732
|
-
}
|
|
733
|
-
};
|
|
734
|
-
for (const vendor of vendors)
|
|
735
|
-
visit(path.join(cache, vendor.name), 0);
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
catch (e) {
|
|
739
|
-
conflicts.push(e.message);
|
|
740
|
-
}
|
|
741
745
|
add(destination, after);
|
|
742
746
|
const manifestPath = path.join(dir, 'installation.json');
|
|
743
747
|
const receipt = readOptional(manifestPath);
|
|
@@ -772,9 +776,21 @@ function runRuntimeBinding(opts) {
|
|
|
772
776
|
// file leaves the receipt — and with it the plan — as it was.
|
|
773
777
|
for (const c of planned.values())
|
|
774
778
|
recorded.set(c.path, { path: c.path, digest: digest(wiringViewOf(c.path, c.after)) });
|
|
775
|
-
//
|
|
776
|
-
|
|
777
|
-
|
|
779
|
+
// @implements A-SPEC-752.11 — the receipt forgets a removed workspace: its rows and its identity.
|
|
780
|
+
if (opts.operation === 'remove') {
|
|
781
|
+
// @implements A-SPEC-752.12, A-SPEC-752.13 — a row inside a workspace that stays bound AND is nested inside the
|
|
782
|
+
// removed root is that workspace's; a remaining parent of the removed root does not keep the removed root's rows.
|
|
783
|
+
for (const p of [...recorded.keys()]) {
|
|
784
|
+
if ((0, binding_1.inside)(root, p) && !next.bindings.some((b) => (0, binding_1.inside)(root, b.workspaceRoot) && (0, binding_1.inside)(b.workspaceRoot, p)))
|
|
785
|
+
recorded.delete(p);
|
|
786
|
+
}
|
|
787
|
+
delete runtimeIdentities[root];
|
|
788
|
+
}
|
|
789
|
+
else {
|
|
790
|
+
// Same-path builds still need a new reviewed plan. Legacy receipts gain identity only via apply.
|
|
791
|
+
runtimeIdentities[root] = { packageRoot: selection.packageRoot, buildId: selection.buildId,
|
|
792
|
+
releasePackageRoot: next.releasePackageRoot, releaseBuild };
|
|
793
|
+
}
|
|
778
794
|
add(manifestPath, json({ version: 1, files: [...recorded.values()], runtimeIdentities }));
|
|
779
795
|
const changes = [...planned.values()].filter((c) => c.before !== c.after);
|
|
780
796
|
const planDigest = (0, runtime_binding_approval_1.runtimePlanDigest)({ operation: opts.operation, root, selection, releasePackageRoot: next.releasePackageRoot,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// @implements A-SPEC-100.2
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.AUTONOMY_MCP_ENV = exports.HOLMES_OWNED_MCP_ENV = void 0;
|
|
5
4
|
exports.isHolmesCommand = isHolmesCommand;
|
|
@@ -10,6 +9,9 @@ exports.enableMcpServer = enableMcpServer;
|
|
|
10
9
|
exports.disableMcpServer = disableMcpServer;
|
|
11
10
|
exports.mergeMcpServers = mergeMcpServers;
|
|
12
11
|
exports.removeMcpServer = removeMcpServer;
|
|
12
|
+
// @implements A-SPEC-100.2
|
|
13
|
+
// @implements A-SPEC-769.12
|
|
14
|
+
const hook_process_1 = require("../runtime/hook-process");
|
|
13
15
|
/** A hook entry belongs to holmes-kit iff its command references our hook scripts. */
|
|
14
16
|
function isHolmesCommand(command) {
|
|
15
17
|
return /dist[/\\]holmes[/\\]hooks[/\\](pre-tool-use|stop|session-start)\.js/.test(command) || /\bholmes-(kit|mcp|pre-tool-use|stop)\b/.test(command);
|
|
@@ -42,7 +44,9 @@ function mergeHooks(existing, plan) {
|
|
|
42
44
|
hooks[event] = groups;
|
|
43
45
|
};
|
|
44
46
|
upsert('PreToolUse', { matcher: plan.preToolUseMatcher, hooks: [{ type: 'command', command: plan.preToolUseCommand }] });
|
|
45
|
-
|
|
47
|
+
// Stop takes NO matcher. @implements A-SPEC-769.12 — and carries the Stop timeout: without one Claude applied its own
|
|
48
|
+
// default, unrelated to the dispatcher's 60 s Stop budget.
|
|
49
|
+
upsert('Stop', { hooks: [{ type: 'command', command: plan.stopCommand, timeout: hook_process_1.STOP_HOOK_TIMEOUT_SECONDS }] });
|
|
46
50
|
// @implements A-SPEC-531.2 — the banner hook, wired like Stop (no matcher). Guarded so an older
|
|
47
51
|
// caller that builds a plan without it is unchanged (no empty SessionStart group appears).
|
|
48
52
|
if (plan.sessionStartCommand) {
|
|
@@ -39,6 +39,7 @@ exports.scanCacheDirFor = scanCacheDirFor;
|
|
|
39
39
|
// @implements A-SPEC-113.1
|
|
40
40
|
// @implements A-SPEC-769.9
|
|
41
41
|
// @implements A-SPEC-769.11
|
|
42
|
+
// @implements A-SPEC-769.12
|
|
42
43
|
const fs = __importStar(require("node:fs"));
|
|
43
44
|
const os = __importStar(require("node:os"));
|
|
44
45
|
const path = __importStar(require("node:path"));
|
|
@@ -88,6 +89,7 @@ class ScanFileCache {
|
|
|
88
89
|
dir;
|
|
89
90
|
file;
|
|
90
91
|
tempSuffix;
|
|
92
|
+
axDir;
|
|
91
93
|
entries;
|
|
92
94
|
seen = new Set();
|
|
93
95
|
dirty = false;
|
|
@@ -96,6 +98,10 @@ class ScanFileCache {
|
|
|
96
98
|
constructor(dir, opts = {}) {
|
|
97
99
|
this.dir = dir;
|
|
98
100
|
this.tempSuffix = opts.tempSuffix ?? (() => (0, node_crypto_1.randomBytes)(6).toString('hex'));
|
|
101
|
+
// @implements A-SPEC-769.12, A-SPEC-769.13 — the `.ax` this cache lives under: a save never brings it back.
|
|
102
|
+
const parts = path.resolve(dir).split(path.sep);
|
|
103
|
+
const ax = parts.map((p) => p.toLowerCase()).lastIndexOf('.ax'); // case-insensitive volumes spell it `.AX` too
|
|
104
|
+
this.axDir = ax > 0 ? parts.slice(0, ax + 1).join(path.sep) : null;
|
|
99
105
|
this.file = path.join(dir, 'scan-cache.json');
|
|
100
106
|
try {
|
|
101
107
|
const raw = JSON.parse(fs.readFileSync(this.file, 'utf8'));
|
|
@@ -157,6 +163,11 @@ class ScanFileCache {
|
|
|
157
163
|
}
|
|
158
164
|
try {
|
|
159
165
|
if (this.dirty) {
|
|
166
|
+
// @implements A-SPEC-769.12 — never create a `.ax`: a recursive create recreated one that was removed while the scan
|
|
167
|
+
// ran (init --remove, a deleted workspace), resurrecting the governed marker. Other parents are created as before.
|
|
168
|
+
// @implements A-SPEC-769.13 — whether `.ax` vanished before or after construction: never create it here.
|
|
169
|
+
if (this.axDir !== null && !fs.existsSync(this.axDir))
|
|
170
|
+
throw new Error('the workspace .ax is gone');
|
|
160
171
|
fs.mkdirSync(this.dir, { recursive: true });
|
|
161
172
|
// @implements A-SPEC-769.9 — the Stop hook and the refresh child share this file: a reader in the other
|
|
162
173
|
// process sees the old or the new content, never a partly written one.
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { FreshnessLane, FreshnessReceipt, RefreshFailure } from '../refresh/freshness-coordinator';
|
|
2
|
+
type HeadProbe = (root: string) => {
|
|
3
|
+
head: string | null;
|
|
4
|
+
unanswered: boolean;
|
|
5
|
+
};
|
|
2
6
|
/** The error as a bounded reason: its message (never a stack), at most REFRESH_FAILURE_REASON_MAX characters. */
|
|
3
7
|
export declare function failureReason(error: unknown): string;
|
|
4
8
|
/** The detached worker must publish its own failure; the parent is intentionally non-blocking. */
|
|
@@ -30,8 +34,19 @@ export declare function armSupersedeWatch(root: string, generation: string, opts
|
|
|
30
34
|
exit: () => void;
|
|
31
35
|
owns?: (root: string, generation: string) => boolean;
|
|
32
36
|
}): void;
|
|
37
|
+
/**
|
|
38
|
+
* @implements A-SPEC-719.5 — the worker's two timers, armed as one tested unit: the deadline inside the lease cap
|
|
39
|
+
* (A-SPEC-719.1/719.4) and the supersede watch (A-SPEC-719.2). The main block calls only this.
|
|
40
|
+
*/
|
|
41
|
+
export declare function armRefreshWorkerTimers(root: string, generation: string, deps?: {
|
|
42
|
+
deadline?: typeof armWorkerDeadline;
|
|
43
|
+
watch?: typeof armSupersedeWatch;
|
|
44
|
+
exit?: () => void;
|
|
45
|
+
}): void;
|
|
33
46
|
export interface RefreshChildDeps {
|
|
34
47
|
head: (root: string) => string | null;
|
|
48
|
+
/** @implements A-SPEC-719.5 — the classified probe; when absent, `head` is taken as an answered probe. */
|
|
49
|
+
headProbe?: HeadProbe;
|
|
35
50
|
refreshGraph: (root: string) => Promise<unknown>;
|
|
36
51
|
/** @implements A-SPEC-768.4 — a failed lane may carry `detail` (the embedder's message) beside its reason. */
|
|
37
52
|
refreshSource: (root: string) => Promise<{
|
|
@@ -57,3 +72,4 @@ export interface RefreshChildDeps {
|
|
|
57
72
|
export declare function runRefreshChild(root: string, generation: string, deps: RefreshChildDeps): Promise<void>;
|
|
58
73
|
/** The production phases: the scan/build machinery, loaded only inside the detached child. */
|
|
59
74
|
export declare function defaultRefreshChildDeps(env?: NodeJS.ProcessEnv): RefreshChildDeps;
|
|
75
|
+
export {};
|