refactor: unify boundary-safe reads for bootstrap and includes

This commit is contained in:
Peter Steinberger
2026-02-26 12:42:06 +01:00
parent 199ef9f8ea
commit 242188b7b1
8 changed files with 374 additions and 100 deletions

View File

@@ -1,6 +1,6 @@
import {
filterBootstrapFilesForSession,
loadExtraBootstrapFiles,
loadExtraBootstrapFilesWithDiagnostics,
} from "../../../agents/workspace.js";
import { createSubsystemLogger } from "../../../logging/subsystem.js";
import { resolveHookConfig } from "../../config.js";
@@ -45,7 +45,19 @@ const bootstrapExtraFilesHook: HookHandler = async (event) => {
}
try {
const extras = await loadExtraBootstrapFiles(context.workspaceDir, patterns);
const { files: extras, diagnostics } = await loadExtraBootstrapFilesWithDiagnostics(
context.workspaceDir,
patterns,
);
if (diagnostics.length > 0) {
log.debug("skipped extra bootstrap candidates", {
skipped: diagnostics.length,
reasons: diagnostics.reduce<Record<string, number>>((counts, item) => {
counts[item.reason] = (counts[item.reason] ?? 0) + 1;
return counts;
}, {}),
});
}
if (extras.length === 0) {
return;
}