feat: add bootstrap hook and soul-evil hook

This commit is contained in:
Peter Steinberger
2026-01-18 05:24:47 +00:00
parent 7e2d91f3b7
commit ad3c12a43a
15 changed files with 678 additions and 9 deletions

View File

@@ -0,0 +1,41 @@
import { afterEach, beforeEach, describe, expect, it } from "vitest";
import { applyBootstrapHookOverrides } from "./bootstrap-hooks.js";
import {
clearInternalHooks,
registerInternalHook,
type AgentBootstrapHookContext,
} from "../hooks/internal-hooks.js";
import { DEFAULT_SOUL_FILENAME, type WorkspaceBootstrapFile } from "./workspace.js";
function makeFile(name = DEFAULT_SOUL_FILENAME): WorkspaceBootstrapFile {
return {
name,
path: `/tmp/${name}`,
content: "base",
missing: false,
};
}
describe("applyBootstrapHookOverrides", () => {
beforeEach(() => clearInternalHooks());
afterEach(() => clearInternalHooks());
it("returns updated files when a hook mutates the context", async () => {
registerInternalHook("agent:bootstrap", (event) => {
const context = event.context as AgentBootstrapHookContext;
context.bootstrapFiles = [
...context.bootstrapFiles,
{ name: "EXTRA.md", path: "/tmp/EXTRA.md", content: "extra", missing: false },
];
});
const updated = await applyBootstrapHookOverrides({
files: [makeFile()],
workspaceDir: "/tmp",
});
expect(updated).toHaveLength(2);
expect(updated[1]?.name).toBe("EXTRA.md");
});
});