-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.ts
More file actions
27 lines (23 loc) · 1.01 KB
/
index.ts
File metadata and controls
27 lines (23 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import type { ExtensionAPI, ToolDefinition } from "@mariozechner/pi-coding-agent";
import { registerReadcacheCommands } from "./src/commands.js";
import { clearReplayRuntimeState, createReplayRuntimeState } from "./src/replay.js";
import { pruneObjectsOlderThan } from "./src/object-store.js";
import { createReadOverrideTool } from "./src/tool.js";
export default function (pi: ExtensionAPI): void {
const runtimeState = createReplayRuntimeState();
pi.registerTool(createReadOverrideTool(runtimeState) as unknown as ToolDefinition);
registerReadcacheCommands(pi, runtimeState);
const clearCaches = (): void => {
clearReplayRuntimeState(runtimeState);
};
pi.on("session_start", (_event, ctx) => {
void pruneObjectsOlderThan(ctx.cwd).catch(() => {
// Fail-open: object pruning should never disrupt session startup.
});
});
pi.on("session_compact", clearCaches);
pi.on("session_tree", clearCaches);
pi.on("session_fork", clearCaches);
pi.on("session_switch", clearCaches);
pi.on("session_shutdown", clearCaches);
}