repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

feat(ctx): add context indexing extension

cb386463555604df7ff4e0085e4858d8bacfe066

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (5)

pi/agent/extensions/ctx/__tests__/ctx.test.ts

Added
new file mode 100644
1 +import { afterEach, beforeEach, describe, expect, test } from "bun:test";
2 +import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
3 +import { tmpdir } from "node:os";
4 +import { join } from "node:path";
5 +import { CtxStore, defaultDbPath, executeCtxOperation, handleBashToolResult, registerCtxExtension, type CtxToolParams } from "../index.js";
7 +let dir: string;
8 +let dbPath: string;
10 +beforeEach(() => {
11 + dir = mkdtempSync(join(tmpdir(), "pi-ctx-test-"));
12 + dbPath = join(dir, "ctx.db");
13 + process.env.PI_CTX_DB_PATH = dbPath;
14 +});
16 +afterEach(() => {
17 + delete process.env.PI_CTX_DB_PATH;
18 + rmSync(dir, { recursive: true, force: true });
19 +});
21 +describe("ctx DB path", () => {
22 + test("defaults under current Pi session dir", () => {
23 + delete process.env.PI_CTX_DB_PATH;
24 + const sessionFile = join(dir, "sessions", "session.jsonl");
25 + const path = defaultDbPath("/repo/project", {
26 + sessionManager: { getSessionFile: () => sessionFile },
27 + });
28 + expect(path).toStartWith(join(dir, "sessions", "ctx"));
29 + expect(path).toEndWith(".db");
30 + });
32 + test("uses SessionManager sessionDir when no session file exists", () => {
33 + delete process.env.PI_CTX_DB_PATH;
34 + const path = defaultDbPath("/repo/project", {
35 + sessionManager: { getSessionDir: () => join(dir, "session-dir") },
36 + });
37 + expect(path).toStartWith(join(dir, "session-dir", "ctx"));
38 + expect(path).toEndWith(".db");
39 + });
40 +});
42 +describe("CtxStore", () => {
43 + test("indexes and searches chunks", () => {
44 + const store = new CtxStore(dbPath);
45 + const indexed = store.indexText({ kind: "test", label: "sample", text: "alpha beta\npanic stack trace\nomega" });
46 + expect(indexed.chunkCount).toBeGreaterThan(0);
47 + const hits = store.search(["panic trace"], { limit: 3 });
48 + expect(hits).toContain("panic stack trace");
49 + store.close();
50 + });
52 + test("purges project DB content", () => {
53 + const store = new CtxStore(dbPath);
54 + store.indexText({ kind: "test", label: "sample", text: "alpha beta" });
55 + expect(store.stats().sources).toBe(1);
56 + store.purge();
57 + expect(store.stats().sources).toBe(0);
58 + store.close();
59 + });
60 +});
62 +describe("ctx operations", () => {
63 + test("run-js returns printed findings", async () => {
64 + const store = new CtxStore(dbPath);
65 + const result = await executeCtxOperation(store, {
66 + op: "run-js",
67 + code: "console.log('answer', 41 + 1)",
68 + } satisfies CtxToolParams, dir);
69 + expect(result.isError).toBeFalsy();
70 + expect(result.content[0].text).toContain("answer 42");
71 + store.close();
72 + });
74 + test("file-py reads file as text", async () => {
75 + const file = join(dir, "data.txt");
76 + writeFileSync(file, "one\ntwo\nthree\n", "utf8");
77 + const store = new CtxStore(dbPath);
78 + const result = await executeCtxOperation(store, {
79 + op: "file-py",
80 + path: file,
81 + code: "print(len(text.splitlines()))",
82 + } satisfies CtxToolParams, dir);
83 + expect(result.content[0].text.trim()).toBe("3");
84 + store.close();
85 + });
87 + test("large run output is indexed and returns pointer", async () => {
88 + const store = new CtxStore(dbPath);
89 + const result = await executeCtxOperation(store, {
90 + op: "run-js",
91 + code: "console.log('x'.repeat(110_000))",
92 + } satisfies CtxToolParams, dir);
93 + expect(result.content[0].text).toContain("ctx:stored");
94 + expect(result.content[0].text).toContain("Use ctx search");
95 + expect(store.stats().sources).toBe(1);
96 + store.close();
97 + });
98 +});
100 +describe("bash auto-collapse", () => {
101 + test("uses fullOutputPath, stores raw, returns bounded replacement", () => {
102 + const full = join(dir, "bash.log");
103 + const raw = "CTX_RAW_SENTINEL ".repeat(10_000);
104 + writeFileSync(full, raw, "utf8");
105 + const store = new CtxStore(dbPath);
106 + const patch = handleBashToolResult(store, {
107 + toolName: "bash",
108 + input: { command: "python noisy.py" },
109 + content: [{ type: "text", text: "[truncated]" }],
110 + details: { fullOutputPath: full, truncation: { truncated: true } },
111 + isError: false,
112 + });
113 + expect(patch).toBeDefined();
114 + const text = patch!.content[0].text;
115 + expect(text).toContain("ctx:stored");
116 + expect(text).not.toContain("CTX_RAW_SENTINEL");
117 + expect(store.search(["CTX_RAW_SENTINEL"], { limit: 1 })).toContain("CTX_RAW_SENTINEL");
118 + store.close();
119 + });
121 + test("large error output is searched for failures", () => {
122 + const full = join(dir, "bash-error.log");
123 + writeFileSync(full, `${"noise\n".repeat(1000)}panic: exploded\nstack trace here\n`, "utf8");
124 + const store = new CtxStore(dbPath);
125 + const patch = handleBashToolResult(store, {
126 + toolName: "bash",
127 + input: { command: "failing" },
128 + content: [{ type: "text", text: "[truncated]" }],
129 + details: { fullOutputPath: full },
130 + isError: true,
131 + });
132 + expect(patch?.content[0].text).toContain("matched");
133 + expect(patch?.content[0].text).toContain("panic");
134 + store.close();
135 + });
136 +});
138 +describe("extension registration", () => {
139 + test("registers one tool and one command", () => {
140 + const tools: any[] = [];
141 + const commands: Record<string, any> = {};
142 + const handlers: Record<string, Function[]> = {};
143 + registerCtxExtension({
144 + registerTool: (tool: any) => tools.push(tool),
145 + registerCommand: (name: string, command: any) => { commands[name] = command; },
146 + on: (name: string, handler: Function) => { (handlers[name] ??= []).push(handler); },
147 + });
148 + expect(tools.map(t => t.name)).toEqual(["ctx"]);
149 + expect(Object.keys(commands)).toEqual(["ctx"]);
150 + expect(Object.keys(handlers)).toContain("tool_result");
151 + });
152 +});

pi/agent/extensions/ctx/__tests__/harness.test.ts

Added
new file mode 100644
1 +import { afterEach, beforeEach, describe, expect, it } from "bun:test";
2 +import { existsSync, mkdtempSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
3 +import { tmpdir } from "node:os";
4 +import path, { join } from "node:path";
5 +import { createTestSession, type TestSession } from "@marcfargas/pi-test-harness";
7 +const CTX_COMMIT = "0cb5ce5f10fb18c9a80e904e2e3310cc98a28e29";
9 +let root: string;
10 +let sessionDir: string;
11 +let t: TestSession | undefined;
13 +function ctxPath(): string {
14 + return path.resolve(import.meta.dir, "../index.ts");
17 +function ctxTool() {
18 + return t!.session.extensionRunner.getToolDefinition("ctx");
21 +function ctxExec(params: Record<string, unknown>) {
22 + return ctxTool().execute(
23 + `call-${crypto.randomUUID()}`,
24 + params,
25 + undefined,
26 + undefined,
27 + t!.session.extensionRunner.createContext(),
28 + );
31 +function textOf(result: any): string {
32 + return result.content.map((part: { text?: string }) => part.text ?? "").join("\n");
35 +function dbFiles(): string[] {
36 + const dir = join(sessionDir, "ctx");
37 + if (!existsSync(dir)) return [];
38 + return readdirSync(dir).filter((name) => name.endsWith(".db"));
41 +beforeEach(async () => {
42 + root = mkdtempSync(join(tmpdir(), "pi-ctx-harness-"));
43 + sessionDir = join(root, "session");
44 + process.env.PI_CODING_AGENT_SESSION_DIR = sessionDir;
45 + delete process.env.PI_CTX_DB_PATH;
46 + t = await createTestSession({ extensions: [ctxPath()] });
47 +});
49 +afterEach(() => {
50 + t?.dispose();
51 + t = undefined;
52 + delete process.env.PI_CODING_AGENT_SESSION_DIR;
53 + delete process.env.PI_CTX_DB_PATH;
54 + rmSync(root, { recursive: true, force: true });
55 +});
57 +describe("ctx harness integration", () => {
58 + it("loads from git pi-test-harness fork pinned to source-export commit", async () => {
59 + const pkg = await import("@marcfargas/pi-test-harness");
60 + expect(typeof pkg.createTestSession).toBe("function");
61 + const lock = readFileSync(path.resolve(import.meta.dir, "../bun.lock"), "utf8");
62 + expect(lock).toContain(CTX_COMMIT);
63 + });
65 + it("registers exactly one ctx tool and one ctx command", () => {
66 + const [extension] = t!.session.extensionRunner.extensions;
67 + expect([...extension.tools.keys()]).toEqual(["ctx"]);
68 + expect([...extension.commands.keys()]).toEqual(["ctx"]);
69 + });
71 + it("runs JS off-context, stores oversized output, and retrieves exact needles later", async () => {
72 + const result = await ctxExec({
73 + op: "run-js",
74 + query: "ctxneedle12345",
75 + code: `
76 + for (let i = 0; i < 9000; i++) console.log('noise line ' + i + ' ' + 'x'.repeat(20));
77 + console.log('ctxneedle12345 fatal failure in generated report');
78 + for (let i = 0; i < 9000; i++) console.log('tail noise ' + i + ' ' + 'y'.repeat(20));
79 + `,
80 + });
82 + const text = textOf(result);
83 + expect(text).toContain("ctx:stored");
84 + expect(text).toContain("matched");
85 + expect(text.length).toBeLessThan(2_000);
86 + expect(text).not.toContain("tail noise 8999");
87 + expect(dbFiles()).toHaveLength(1);
89 + const search = await ctxExec({ op: "search", query: "ctxneedle12345", limit: 1 });
90 + const searchText = textOf(search);
91 + expect(searchText).toContain("ctxneedle12345 fatal failure");
92 + });
94 + it("analyzes a huge file without returning the file body or indexing small findings", async () => {
95 + const file = join(root, "huge.log");
96 + const lines = Array.from({ length: 25_000 }, (_, i) => `row ${i} boring payload ${"z".repeat(40)}`);
97 + lines[19_876] = "ctxfilemarker67890 ERROR customer=42 shard=west";
98 + writeFileSync(file, `${lines.join("\n")}\n`, "utf8");
100 + const result = await ctxExec({
101 + op: "file-js",
102 + path: file,
103 + code: `
104 + const hit = text.split(/\\n/).find(line => line.includes('ctxfilemarker67890'));
105 + console.log(hit);
106 + `,
107 + });
109 + const out = textOf(result);
110 + expect(out.trim()).toBe("ctxfilemarker67890 ERROR customer=42 shard=west");
111 + expect(out).not.toContain("row 0 boring payload");
112 + const [extension] = t!.session.extensionRunner.extensions;
113 + const stats = await extension.commands.get("ctx").handler("", t!.session.extensionRunner.createContext());
114 + expect(stats.text).toContain("ctx: 0 sources");
115 + });
117 + it("collapses huge bash tool_result using fullOutputPath before it reaches the transcript", async () => {
118 + const raw = [
119 + "header",
120 + ...Array.from({ length: 5 }, (_, i) => `bash noise ${i} ${"a".repeat(30)}`),
121 + "bashneedle24680 terminal fact hidden in full log",
122 + ...Array.from({ length: 7_500 }, (_, i) => `bash tail ${i} ${"a".repeat(30)}`),
123 + ].join("\n");
124 + const full = join(root, "bash-full.log");
125 + writeFileSync(full, raw, "utf8");
127 + const patched = await t!.session.extensionRunner.emitToolResult({
128 + type: "tool_result",
129 + toolName: "bash",
130 + input: { command: "generate massive report" },
131 + content: [{ type: "text", text: "[pi truncated visible output]" }],
132 + details: { fullOutputPath: full, truncation: { truncated: true } },
133 + isError: false,
134 + });
136 + const text = textOf(patched);
137 + expect(text).toContain("ctx:stored");
138 + expect(text).toContain("Use ctx search");
139 + expect(text).not.toContain("bashneedle24680");
140 + expect(patched.details.ctxStored).toBe(true);
141 + expect(statSync(join(sessionDir, "ctx", dbFiles()[0])).size).toBeGreaterThan(0);
143 + const search = await ctxExec({ op: "search", query: "bashneedle24680", limit: 1 });
144 + expect(textOf(search)).toContain("bashneedle24680 terminal fact");
145 + });
147 + it("extracts searchable failure context for huge failing bash output and keeps isError", async () => {
148 + const full = join(root, "bash-error.log");
149 + writeFileSync(full, `${"boring\n".repeat(5_000)}panic ctxboom999 exploded\nstack trace line\n`, "utf8");
151 + const patched = await t!.session.extensionRunner.emitToolResult({
152 + type: "tool_result",
153 + toolName: "bash",
154 + input: { command: "run failing suite" },
155 + content: [{ type: "text", text: "[truncated]" }],
156 + details: { fullOutputPath: full },
157 + isError: true,
158 + });
160 + expect(patched.isError).toBe(true);
161 + expect(textOf(patched)).toContain("ctx:stored");
162 + expect(textOf(patched)).toContain("matched");
164 + const search = await ctxExec({ op: "search", query: "ctxboom999", limit: 1 });
165 + expect(textOf(search)).toContain("panic ctxboom999 exploded");
166 + });
168 + it("search returns the matching region when a hit is buried deep inside a chunk", async () => {
169 + const filler = Array.from({ length: 180 }, (_, i) => `preface ${i} ${"p".repeat(80)}`).join("\n");
170 + await ctxExec({
171 + op: "run-js",
172 + query: "buriedneedle424242",
173 + code: `console.log(${JSON.stringify(`${filler}\nburiedneedle424242 exact match near end of chunk\n${"tail ".repeat(5_000)}`)})`,
174 + });
176 + const search = await ctxExec({ op: "search", query: "buriedneedle424242", limit: 1 });
177 + const out = textOf(search);
178 + expect(out).toContain("buriedneedle424242 exact match");
179 + expect(out.length).toBeLessThan(3_000);
180 + });
182 + it("collapses actual built-in bash execution output using Pi fullOutputPath metadata", async () => {
183 + const bash = (t!.session.agent as any).state.tools.find((tool: any) => tool.name === "bash");
184 + expect(bash).toBeDefined();
185 + const command = `python3 - <<'PY'\nfor i in range(7000): print(f'realbashneedle777 line {i}')\nPY`;
186 + const raw = await bash.execute("bash-real-1", { command }, undefined, undefined, t!.session.extensionRunner.createContext());
187 + expect(typeof raw.details?.fullOutputPath).toBe("string");
188 + expect(raw.details?.truncation?.truncated).toBe(true);
190 + try {
191 + const patched = await t!.session.extensionRunner.emitToolResult({
192 + type: "tool_result",
193 + toolCallId: "bash-real-1",
194 + toolName: "bash",
195 + input: { command },
196 + content: raw.content,
197 + details: raw.details,
198 + isError: raw.isError,
199 + });
201 + expect(textOf(patched)).toContain("ctx:stored");
202 + expect(textOf(patched)).not.toContain("realbashneedle777 line 6999");
203 + const search = await ctxExec({ op: "search", query: "realbashneedle777", limit: 1 });
204 + expect(textOf(search)).toContain("realbashneedle777 line");
205 + } finally {
206 + rmSync(raw.details?.fullOutputPath, { force: true });
208 + });
210 + it("falls back to visible bash content when fullOutputPath is absent", async () => {
211 + const visible = `${"visible filler\n".repeat(9_000)}visibleonly333 final line`;
212 + const patched = await t!.session.extensionRunner.emitToolResult({
213 + type: "tool_result",
214 + toolCallId: "bash-visible-1",
215 + toolName: "bash",
216 + input: { command: "already truncated elsewhere" },
217 + content: [{ type: "text", text: visible }],
218 + details: { truncation: { truncated: true } },
219 + isError: false,
220 + });
222 + expect(textOf(patched)).toContain("ctx:stored");
223 + expect(textOf(patched)).not.toContain("visibleonly333");
224 + const search = await ctxExec({ op: "search", query: "visibleonly333", limit: 1 });
225 + expect(textOf(search)).toContain("visibleonly333 final line");
226 + });
228 + it("handles concurrent ctx writes without lock errors or lost sources", async () => {
229 + const count = 8;
230 + const results = await Promise.all(Array.from({ length: count }, (_, i) => ctxExec({
231 + op: "run-js",
232 + code: `console.log('concurrentneedle${i} ' + '${"x".repeat(130_000)}')`,
233 + })));
235 + for (const result of results) expect(textOf(result)).toContain("ctx:stored");
236 + const [extension] = t!.session.extensionRunner.extensions;
237 + const stats = await extension.commands.get("ctx").handler("", t!.session.extensionRunner.createContext());
238 + expect(stats.text).toContain(`ctx: ${count} sources`);
240 + for (let i = 0; i < count; i++) {
241 + const search = await ctxExec({ op: "search", query: `concurrentneedle${i}`, limit: 1 });
242 + expect(textOf(search)).toContain(`concurrentneedle${i}`);
244 + });
246 + it("keeps unicode output valid while using byte thresholds conservatively", async () => {
247 + const marker = "unicodeNeedle555 測試 ✅";
248 + const result = await ctxExec({
249 + op: "run-js",
250 + code: `console.log('${"😀".repeat(40_000)} ${marker}')`,
251 + });
253 + expect(textOf(result)).toContain("ctx:stored");
254 + const search = await ctxExec({ op: "search", query: "unicodeNeedle555", limit: 1 });
255 + expect(textOf(search)).toContain(marker);
256 + expect(textOf(search)).not.toContain("�");
257 + });
259 + it("closes ctx resources so session directory can be removed after dispose", async () => {
260 + await ctxExec({ op: "run-js", code: "console.log('cleanupneedle ' + 'x'.repeat(120_000))" });
261 + expect(dbFiles()).toHaveLength(1);
262 + t!.dispose();
263 + t = undefined;
264 + rmSync(root, { recursive: true, force: true });
265 + expect(existsSync(root)).toBe(false);
266 + });
268 + it("does not touch small bash output, then /ctx reports, searches, and purges stored data", async () => {
269 + const unchanged = await t!.session.extensionRunner.emitToolResult({
270 + type: "tool_result",
271 + toolName: "bash",
272 + input: { command: "echo small" },
273 + content: [{ type: "text", text: "small output" }],
274 + details: {},
275 + isError: false,
276 + });
277 + expect(unchanged).toBeUndefined();
279 + await ctxExec({ op: "run-js", code: "console.log('cmdneedle13579 ' + 'q'.repeat(120_000))" });
280 + const [extension] = t!.session.extensionRunner.extensions;
281 + const command = extension.commands.get("ctx");
283 + const stats = await command.handler("", t!.session.extensionRunner.createContext());
284 + expect(stats.text).toContain("ctx: 1 sources");
285 + expect(stats.text).toContain("recent:");
287 + const found = await command.handler("cmdneedle13579", t!.session.extensionRunner.createContext());
288 + expect(found.text).toContain("cmdneedle13579");
290 + const purged = await command.handler("--purge", t!.session.extensionRunner.createContext());
291 + expect(purged.text).toBe("ctx purged");
293 + const empty = await command.handler("", t!.session.extensionRunner.createContext());
294 + expect(empty.text).toContain("ctx: 0 sources");
295 + });
296 +});

pi/agent/extensions/ctx/bun.lock

Added
new file mode 100644
1 +{
2 + "lockfileVersion": 1,
3 + "configVersion": 1,
4 + "workspaces": {
5 + "": {
6 + "name": "@bugabinga/pi-ext-ctx",
7 + "devDependencies": {
8 + "@marcfargas/pi-test-harness": "git+ssh://git@github.com/bugabinga/pi-test-harness.git#0cb5ce5f10fb18c9a80e904e2e3310cc98a28e29",
9 + },
10 + "peerDependencies": {
11 + "@earendil-works/pi-coding-agent": "*",
12 + "@earendil-works/pi-tui": "*",
13 + "typebox": "*",
14 + },
15 + },
16 + },
17 + "packages": {
18 + "@anthropic-ai/sdk": ["@anthropic-ai/sdk@0.91.1", "", { "dependencies": { "json-schema-to-ts": "^3.1.1" }, "peerDependencies": { "zod": "^3.25.0 || ^4.0.0" }, "optionalPeers": ["zod"], "bin": { "anthropic-ai-sdk": "bin/cli" } }, "sha512-LAmu761tSN9r66ixvmciswUj/ZC+1Q4iAfpedTfSVLeswRwnY3n2Nb6Tsk+cLPP28aLOPWeMgIuTuCcMC6W/iw=="],
20 + "@aws-crypto/crc32": ["@aws-crypto/crc32@5.2.0", "", { "dependencies": { "@aws-crypto/util": "^5.2.0", "@aws-sdk/types": "^3.222.0", "tslib": "^2.6.2" } }, "sha512-nLbCWqQNgUiwwtFsen1AdzAtvuLRsQS8rYgMuxCrdKf9kOssamGLuPwyTY9wyYblNr9+1XM8v6zoDTPPSIeANg=="],
22 + "@aws-crypto/sha256-browser": ["@aws-crypto/sha256-browser@5.2.0", "", { "dependencies": { "@aws-crypto/sha256-js": "^5.2.0", "@aws-crypto/supports-web-crypto": "^5.2.0", "@aws-crypto/util": "^5.2.0", "@aws-sdk/types": "^3.222.0", "@aws-sdk/util-locate-window": "^3.0.0", "@smithy/util-utf8": "^2.0.0", "tslib": "^2.6.2" } }, "sha512-AXfN/lGotSQwu6HNcEsIASo7kWXZ5HYWvfOmSNKDsEqC4OashTp8alTmaz+F7TC2L083SFv5RdB+qU3Vs1kZqw=="],
24 + "@aws-crypto/sha256-js": ["@aws-crypto/sha256-js@5.2.0", "", { "dependencies": { "@aws-crypto/util": "^5.2.0", "@aws-sdk/types": "^3.222.0", "tslib": "^2.6.2" } }, "sha512-FFQQyu7edu4ufvIZ+OadFpHHOt+eSTBaYaki44c+akjg7qZg9oOQeLlk77F6tSYqjDAFClrHJk9tMf0HdVyOvA=="],
26 + "@aws-crypto/supports-web-crypto": ["@aws-crypto/supports-web-crypto@5.2.0", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-iAvUotm021kM33eCdNfwIN//F77/IADDSs58i+MDaOqFrVjZo9bAal0NK7HurRuWLLpF1iLX7gbWrjHjeo+YFg=="],
28 + "@aws-crypto/util": ["@aws-crypto/util@5.2.0", "", { "dependencies": { "@aws-sdk/types": "^3.222.0", "@smithy/util-utf8": "^2.0.0", "tslib": "^2.6.2" } }, "sha512-4RkU9EsI6ZpBve5fseQlGNUWKMa1RLPQ1dnjnQoe07ldfIzcsGb5hC5W0Dm7u423KWzawlrpbjXBrXCEv9zazQ=="],
30 + "@aws-sdk/client-bedrock-runtime": ["@aws-sdk/client-bedrock-runtime@3.1048.0", "", { "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", "@aws-sdk/core": "^3.974.11", "@aws-sdk/credential-provider-node": "^3.972.42", "@aws-sdk/eventstream-handler-node": "^3.972.16", "@aws-sdk/middleware-eventstream": "^3.972.12", "@aws-sdk/middleware-websocket": "^3.972.19", "@aws-sdk/token-providers": "3.1048.0", "@aws-sdk/types": "^3.973.8", "@smithy/core": "^3.24.2", "@smithy/fetch-http-handler": "^5.4.2", "@smithy/node-http-handler": "^4.7.2", "@smithy/types": "^4.14.1", "tslib": "^2.6.2" } }, "sha512-u+NT61JZEkRFtpL0CAw1N1dwxnaLgwVXQl/zjJxTGgLyS/jTIdg2SdoEoCTHxgDyCnqa1HEi9QOoE9/pYRNpOQ=="],
32 + "@aws-sdk/core": ["@aws-sdk/core@3.974.12", "", { "dependencies": { "@aws-sdk/types": "^3.973.8", "@aws-sdk/xml-builder": "^3.972.24", "@aws/lambda-invoke-store": "^0.2.2", "@smithy/core": "^3.24.2", "@smithy/signature-v4": "^5.4.2", "@smithy/types": "^4.14.1", "bowser": "^2.11.0", "tslib": "^2.6.2" } }, "sha512-qrqgioqYFjwR6LatVNS1L2Vk++EwRIxqSQXPKNv5Ofux2D8UNgqMQ1znnMyEImXquVPTtbf71fc128pvmU6y9A=="],
34 + "@aws-sdk/credential-provider-env": ["@aws-sdk/credential-provider-env@3.972.38", "", { "dependencies": { "@aws-sdk/core": "^3.974.12", "@aws-sdk/types": "^3.973.8", "@smithy/core": "^3.24.2", "@smithy/types": "^4.14.1", "tslib": "^2.6.2" } }, "sha512-m3WjZEgPtioMhPmwqUt+DhlTJ2i9ufR6DhfkyXojb9puEvfR+ur2U5shavu5/Cc9WHHsDCvALi6UFHgcqjhQ5w=="],
36 + "@aws-sdk/credential-provider-http": ["@aws-sdk/credential-provider-http@3.972.40", "", { "dependencies": { "@aws-sdk/core": "^3.974.12", "@aws-sdk/types": "^3.973.8", "@smithy/core": "^3.24.2", "@smithy/fetch-http-handler": "^5.4.2", "@smithy/node-http-handler": "^4.7.2", "@smithy/types": "^4.14.1", "tslib": "^2.6.2" } }, "sha512-D78L/m2Dr6cJnnSvWoAudPhQmCwmJ7j6APXsPYmFpPaKfQTfCSu0rdm8j14Np+VmXF9z8Aj8HE3xFpsrwtfgeg=="],
38 + "@aws-sdk/credential-provider-ini": ["@aws-sdk/credential-provider-ini@3.972.42", "", { "dependencies": { "@aws-sdk/core": "^3.974.12", "@aws-sdk/credential-provider-env": "^3.972.38", "@aws-sdk/credential-provider-http": "^3.972.40", "@aws-sdk/credential-provider-login": "^3.972.42", "@aws-sdk/credential-provider-process": "^3.972.38", "@aws-sdk/credential-provider-sso": "^3.972.42", "@aws-sdk/credential-provider-web-identity": "^3.972.42", "@aws-sdk/nested-clients": "^3.997.10", "@aws-sdk/types": "^3.973.8", "@smithy/core": "^3.24.2", "@smithy/credential-provider-imds": "^4.3.2", "@smithy/types": "^4.14.1", "tslib": "^2.6.2" } }, "sha512-Mu5ESvFXeinafVM8jTIvRqcvK2Ehj4kz3auT39yUcHwu1Vfxo6xRlmUafdKLW4tusjAJukQwK09sCSMgOm7OKg=="],
40 + "@aws-sdk/credential-provider-login": ["@aws-sdk/credential-provider-login@3.972.42", "", { "dependencies": { "@aws-sdk/core": "^3.974.12", "@aws-sdk/nested-clients": "^3.997.10", "@aws-sdk/types": "^3.973.8", "@smithy/core": "^3.24.2", "@smithy/types": "^4.14.1", "tslib": "^2.6.2" } }, "sha512-O6WkZga3kf0yqyJYd1dbeJqVhEgJx/x1UaLgtbR+XuL/YP+K5y6QTxQKL7ka9z3jnQASESKGAPnRyt4D5hQrxA=="],
42 + "@aws-sdk/credential-provider-node": ["@aws-sdk/credential-provider-node@3.972.43", "", { "dependencies": { "@aws-sdk/credential-provider-env": "^3.972.38", "@aws-sdk/credential-provider-http": "^3.972.40", "@aws-sdk/credential-provider-ini": "^3.972.42", "@aws-sdk/credential-provider-process": "^3.972.38", "@aws-sdk/credential-provider-sso": "^3.972.42", "@aws-sdk/credential-provider-web-identity": "^3.972.42", "@aws-sdk/types": "^3.973.8", "@smithy/core": "^3.24.2", "@smithy/credential-provider-imds": "^4.3.2", "@smithy/types": "^4.14.1", "tslib": "^2.6.2" } }, "sha512-D/DJmbrWRP5BXEO3FH+ar4el+2n6OlGofiud7dQun2jES+AQEJjczenp1jBb4MBN7CpGpS8nsWGQLtuzc9tQbA=="],
44 + "@aws-sdk/credential-provider-process": ["@aws-sdk/credential-provider-process@3.972.38", "", { "dependencies": { "@aws-sdk/core": "^3.974.12", "@aws-sdk/types": "^3.973.8", "@smithy/core": "^3.24.2", "@smithy/types": "^4.14.1", "tslib": "^2.6.2" } }, "sha512-EnbYVajGgbkb24s0K1eo4VNAPV5mHIET7LSvirTaFCwkfrfaOJxtSE+wY/tJdKDS21cEYkZs2ruCaAm+W4iblg=="],
46 + "@aws-sdk/credential-provider-sso": ["@aws-sdk/credential-provider-sso@3.972.42", "", { "dependencies": { "@aws-sdk/core": "^3.974.12", "@aws-sdk/nested-clients": "^3.997.10", "@aws-sdk/token-providers": "3.1049.0", "@aws-sdk/types": "^3.973.8", "@smithy/core": "^3.24.2", "@smithy/types": "^4.14.1", "tslib": "^2.6.2" } }, "sha512-RVV/9NbFwI8ZHEH5dn39lGyFmSbSVj1+orZdr6QsOe1mW9DCglmlen0cFaNZmCcqkqc7erNRHNBduxbeZuHAnw=="],
48 + "@aws-sdk/credential-provider-web-identity": ["@aws-sdk/credential-provider-web-identity@3.972.42", "", { "dependencies": { "@aws-sdk/core": "^3.974.12", "@aws-sdk/nested-clients": "^3.997.10", "@aws-sdk/types": "^3.973.8", "@smithy/core": "^3.24.2", "@smithy/types": "^4.14.1", "tslib": "^2.6.2" } }, "sha512-/67fXX0ddllD4u2Nujc5PvT4byHgpMUfz6+RxIKi/0nFIckeorm7JvXgzBuDyVKw0s58EbofmETDWUf9vTEuHQ=="],
50 + "@aws-sdk/eventstream-handler-node": ["@aws-sdk/eventstream-handler-node@3.972.16", "", { "dependencies": { "@aws-sdk/types": "^3.973.8", "@smithy/core": "^3.24.2", "@smithy/types": "^4.14.1", "tslib": "^2.6.2" } }, "sha512-yedpPgKftqjU5SlPFHfqWpOw6xSCRieWRG1euWOlXn4WJxt2VX92VprCa2PpSOXjVCAeK6dTjW9eJRXVig9yGA=="],
52 + "@aws-sdk/middleware-eventstream": ["@aws-sdk/middleware-eventstream@3.972.12", "", { "dependencies": { "@aws-sdk/types": "^3.973.8", "@smithy/core": "^3.24.2", "@smithy/types": "^4.14.1", "tslib": "^2.6.2" } }, "sha512-tHTHHCHNrq6XklQvlzHBDJG4Iuhh7NVPRdtmvP+nHFA+5sxPlIDzlAHHgfoYHGvT3NXP1yVP/L5c3opUn6T3Qg=="],
54 + "@aws-sdk/middleware-websocket": ["@aws-sdk/middleware-websocket@3.972.20", "", { "dependencies": { "@aws-sdk/core": "^3.974.12", "@aws-sdk/types": "^3.973.8", "@smithy/core": "^3.24.2", "@smithy/fetch-http-handler": "^5.4.2", "@smithy/signature-v4": "^5.4.2", "@smithy/types": "^4.14.1", "tslib": "^2.6.2" } }, "sha512-LM6P0i+Lu6pi25oNw2nqxjRxiEOtLgPB7xIvHfa+FxHTRLg8wcgqu3qg2COl4QaT7Es2yCxYdeRLVYazKAwL8g=="],
56 + "@aws-sdk/nested-clients": ["@aws-sdk/nested-clients@3.997.10", "", { "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", "@aws-sdk/core": "^3.974.12", "@aws-sdk/signature-v4-multi-region": "^3.996.27", "@aws-sdk/types": "^3.973.8", "@smithy/core": "^3.24.2", "@smithy/fetch-http-handler": "^5.4.2", "@smithy/node-http-handler": "^4.7.2", "@smithy/types": "^4.14.1", "tslib": "^2.6.2" } }, "sha512-FtQ/Bt327peZJuyo4WZSOLVUTw9ujRxntepiC7L65FxA2P82Xlq0g14T22BuqBUeMjDoxa9nvwiMHjLIfP3eUg=="],
58 + "@aws-sdk/signature-v4-multi-region": ["@aws-sdk/signature-v4-multi-region@3.996.27", "", { "dependencies": { "@aws-sdk/types": "^3.973.8", "@smithy/core": "^3.24.2", "@smithy/signature-v4": "^5.4.2", "@smithy/types": "^4.14.1", "tslib": "^2.6.2" } }, "sha512-0Phbz4t6HI3D3skxvG2uI+VWU034/nSIw1T8d+FPzzQG9EQTrw94o9mOKO2Gv3n3Oc8P7JD7RAUxkoneLWv5Eg=="],
60 + "@aws-sdk/token-providers": ["@aws-sdk/token-providers@3.1048.0", "", { "dependencies": { "@aws-sdk/core": "^3.974.11", "@aws-sdk/nested-clients": "^3.997.9", "@aws-sdk/types": "^3.973.8", "@smithy/core": "^3.24.2", "@smithy/types": "^4.14.1", "tslib": "^2.6.2" } }, "sha512-k0y/GcuesuSfWyUM0WamrGyeZmltRYaPbHO82UDA6mZ/doB+FOHKutikPAtSXMn/hDz970cF+iRuuiYO9VEbAA=="],
62 + "@aws-sdk/types": ["@aws-sdk/types@3.973.8", "", { "dependencies": { "@smithy/types": "^4.14.1", "tslib": "^2.6.2" } }, "sha512-gjlAdtHMbtR9X5iIhVUvbVcy55KnznpC6bkDUWW9z915bi0ckdUr5cjf16Kp6xq0bP5HBD2xzgbL9F9Quv5vUw=="],
64 + "@aws-sdk/util-locate-window": ["@aws-sdk/util-locate-window@3.965.5", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-WhlJNNINQB+9qtLtZJcpQdgZw3SCDCpXdUJP7cToGwHbCWCnRckGlc6Bx/OhWwIYFNAn+FIydY8SZ0QmVu3xTQ=="],
66 + "@aws-sdk/xml-builder": ["@aws-sdk/xml-builder@3.972.24", "", { "dependencies": { "@nodable/entities": "2.1.0", "@smithy/types": "^4.14.1", "fast-xml-parser": "5.7.3", "tslib": "^2.6.2" } }, "sha512-V8z5YcDPfsvzrBlj0xR1vhRtocblhYbqdreCJB/voGd4Sr5zjNAeWxexbnqVtskTJe0vFb5KMqbSL++ePl+zRw=="],
68 + "@aws/lambda-invoke-store": ["@aws/lambda-invoke-store@0.2.4", "", {}, "sha512-iY8yvjE0y651BixKNPgmv1WrQc+GZ142sb0z4gYnChDDY2YqI4P/jsSopBWrKfAt7LOJAkOXt7rC/hms+WclQQ=="],
70 + "@babel/runtime": ["@babel/runtime@7.29.2", "", {}, "sha512-JiDShH45zKHWyGe4ZNVRrCjBz8Nh9TMmZG1kh4QTK8hCBTWBi8Da+i7s1fJw7/lYpM4ccepSNfqzZ/QvABBi5g=="],
72 + "@earendil-works/pi-agent-core": ["@earendil-works/pi-agent-core@0.75.4", "", { "dependencies": { "@earendil-works/pi-ai": "^0.75.4", "ignore": "7.0.5", "typebox": "1.1.38", "yaml": "2.9.0" } }, "sha512-cGYbysb4EqUf0B28OeqFq2ppm1XF3bYBOP71q9dv38yf/UJfzMjiXBeNelrcio+QWIoVrW+xzYm7sMzYIUc9Og=="],
74 + "@earendil-works/pi-ai": ["@earendil-works/pi-ai@0.75.4", "", { "dependencies": { "@anthropic-ai/sdk": "0.91.1", "@aws-sdk/client-bedrock-runtime": "3.1048.0", "@google/genai": "1.52.0", "@mistralai/mistralai": "2.2.1", "http-proxy-agent": "7.0.2", "https-proxy-agent": "7.0.6", "openai": "6.26.0", "partial-json": "0.1.7", "typebox": "1.1.38" }, "bin": { "pi-ai": "dist/cli.js" } }, "sha512-m/w8Hh3vQ0rAycwJiJWdzkypkn4295f4eq/966lDRy8aX5sk6bgYXH8TQmL16TO7Uwc7MbJG0QoyFHgX8RqXUQ=="],
76 + "@earendil-works/pi-coding-agent": ["@earendil-works/pi-coding-agent@0.75.4", "", { "dependencies": { "@earendil-works/pi-agent-core": "^0.75.4", "@earendil-works/pi-ai": "^0.75.4", "@earendil-works/pi-tui": "^0.75.4", "@silvia-odwyer/photon-node": "0.3.4", "chalk": "5.6.2", "cross-spawn": "7.0.6", "diff": "8.0.4", "glob": "13.0.6", "highlight.js": "10.7.3", "hosted-git-info": "9.0.3", "ignore": "7.0.5", "jiti": "2.7.0", "minimatch": "10.2.5", "proper-lockfile": "4.1.2", "typebox": "1.1.38", "undici": "8.3.0", "yaml": "2.9.0" }, "optionalDependencies": { "@mariozechner/clipboard": "0.3.6" }, "bin": { "pi": "dist/cli.js" } }, "sha512-Fb+FRo08b5H9pYKbQJ708/5OKL0+K/yclhfCMEhrBzSPTZZ4c85nY1YsBo4qwL20ohBMlBezHMRuHzcJ1ylEoQ=="],
78 + "@earendil-works/pi-tui": ["@earendil-works/pi-tui@0.75.4", "", { "dependencies": { "get-east-asian-width": "1.6.0", "marked": "15.0.12" }, "optionalDependencies": { "koffi": "2.16.2" } }, "sha512-PDhKU7u6fmEcvHUFHzrRwGc/Ytokj/hO+X4RPf+MWKEGpvg3B1vHv88Ee+Dy33004tYkQF5YeXV4btJZcp5x1g=="],
80 + "@google/genai": ["@google/genai@1.52.0", "", { "dependencies": { "google-auth-library": "^10.3.0", "p-retry": "^4.6.2", "protobufjs": "^7.5.4", "ws": "^8.18.0" }, "peerDependencies": { "@modelcontextprotocol/sdk": "^1.25.2" }, "optionalPeers": ["@modelcontextprotocol/sdk"] }, "sha512-gwSvbpiN/17O9TbsqSsE/OzZcpv5Fo4RQjdngGgogtuB9RsyJ8ZHhX5KjHj1bp5N9snN2eK8LDGXSaWW2hof8Q=="],
82 + "@marcfargas/pi-test-harness": ["@marcfargas/pi-test-harness@git+ssh://git@github.com/bugabinga/pi-test-harness.git#0cb5ce5f10fb18c9a80e904e2e3310cc98a28e29", { "peerDependencies": { "@earendil-works/pi-agent-core": "*", "@earendil-works/pi-ai": "*", "@earendil-works/pi-coding-agent": ">=0.50.0" } }, "0cb5ce5f10fb18c9a80e904e2e3310cc98a28e29"],
84 + "@mariozechner/clipboard": ["@mariozechner/clipboard@0.3.6", "", { "optionalDependencies": { "@mariozechner/clipboard-darwin-arm64": "0.3.6", "@mariozechner/clipboard-darwin-universal": "0.3.6", "@mariozechner/clipboard-darwin-x64": "0.3.6", "@mariozechner/clipboard-linux-arm64-gnu": "0.3.6", "@mariozechner/clipboard-linux-arm64-musl": "0.3.6", "@mariozechner/clipboard-linux-riscv64-gnu": "0.3.6", "@mariozechner/clipboard-linux-x64-gnu": "0.3.6", "@mariozechner/clipboard-linux-x64-musl": "0.3.6", "@mariozechner/clipboard-win32-arm64-msvc": "0.3.6", "@mariozechner/clipboard-win32-x64-msvc": "0.3.6" } }, "sha512-MXdtr+6+ntlIVHdrZYuZNQydu6o8yZswFJ2Ln81j2O/Y9B/LDHvEaIm95xWNPkjGTWriSOeLnQJRFs6dYb60bg=="],
86 + "@mariozechner/clipboard-darwin-arm64": ["@mariozechner/clipboard-darwin-arm64@0.3.6", "", { "os": "darwin", "cpu": "arm64" }, "sha512-HjaisYCAbHi/1+N1yDAQHc8ZXGffufIUT5NSOSVR3f3AuMDusxTtnbK8tZ7JFDkShua1oNGZoNwQHsc8MPtE0Q=="],
88 + "@mariozechner/clipboard-darwin-universal": ["@mariozechner/clipboard-darwin-universal@0.3.6", "", { "os": "darwin" }, "sha512-8BWtPjOtJOJoykml3w0fx0zRrfWP31mXrJwfoA7xzNprkZw1uolCNfgmjDiVBseoKjp16EGITz7bN+61qn8dWA=="],
90 + "@mariozechner/clipboard-darwin-x64": ["@mariozechner/clipboard-darwin-x64@0.3.6", "", { "os": "darwin", "cpu": "x64" }, "sha512-p9syiZD1kU4I+1ya7f7g+zD1GiUvR8fdlRlNmgsZNWlyjtc8rlV2EjTLd/35x1LsdBq020GVvtzp0ZmPgBI09Q=="],
92 + "@mariozechner/clipboard-linux-arm64-gnu": ["@mariozechner/clipboard-linux-arm64-gnu@0.3.6", "", { "os": "linux", "cpu": "arm64" }, "sha512-5JFf5rGofrm+V29HNF+wLthXphHdQpMbKDUYJ5tML6/Z5DLlLOV/9Ak4kDPtYyZ+Dzf+kAusE0VsFg4+tfP1IA=="],
94 + "@mariozechner/clipboard-linux-arm64-musl": ["@mariozechner/clipboard-linux-arm64-musl@0.3.6", "", { "os": "linux", "cpu": "arm64" }, "sha512-JlVjxxw0GbGC0djXYWRIqyteO3J1KZ/QG3udlEFaOD5TLOM1FnmXXAPDQBqr+aBVr720ef9K00dirYnJ0LDCtw=="],
96 + "@mariozechner/clipboard-linux-riscv64-gnu": ["@mariozechner/clipboard-linux-riscv64-gnu@0.3.6", "", { "os": "linux", "cpu": "none" }, "sha512-4t8BUi5zZ+L77otFQVnVSlaTyAX4TVk9EqQm4syMrEQp96trFEHEwwNHcNEBGzYv5+K7mxay50TthYkz47OWzQ=="],
98 + "@mariozechner/clipboard-linux-x64-gnu": ["@mariozechner/clipboard-linux-x64-gnu@0.3.6", "", { "os": "linux", "cpu": "x64" }, "sha512-trtPwcNLW37irwQCJLtCxLw757jjJZk3TSnY/MU9bhtWtA3K9b/eLW0e4RGhUXDoFRds9opNWWaUDuFLa8dm0w=="],
100 + "@mariozechner/clipboard-linux-x64-musl": ["@mariozechner/clipboard-linux-x64-musl@0.3.6", "", { "os": "linux", "cpu": "x64" }, "sha512-WfnzIvOCCWQiN0MmltCEo6cLceUDbYe+I7xyFZjaps5A+2Op/M2CY7Rey+C4ucQhrvmpoHmTSFgY9ODWk7snoA=="],
102 + "@mariozechner/clipboard-win32-arm64-msvc": ["@mariozechner/clipboard-win32-arm64-msvc@0.3.6", "", { "os": "win32", "cpu": "arm64" }, "sha512-+8+1aHYsBPUjmW3otmWlg+Hijt0iJvoBBs5e0mxFeUd4gDaKMB8Bn6x7c6KVtscg7E5j5NFXnwQqNSIAO4p8zQ=="],
104 + "@mariozechner/clipboard-win32-x64-msvc": ["@mariozechner/clipboard-win32-x64-msvc@0.3.6", "", { "os": "win32", "cpu": "x64" }, "sha512-S4xfPmERC8ZkiLHe3vekZCjdDwNEETCuvCgQK2kP6/TnvmUkq1y2Pk+DjM4t8uh9KMX9bH4zs5ePcKa8GTXmfg=="],
106 + "@mistralai/mistralai": ["@mistralai/mistralai@2.2.1", "", { "dependencies": { "ws": "^8.18.0", "zod": "^3.25.0 || ^4.0.0", "zod-to-json-schema": "^3.25.0" } }, "sha512-uKU8CZmL2RzYKmplsU01hii4p3pe4HqJefpWNRWXm1Tcm0Sm4xXfwSLIy4k7ZCPlbETCGcp69E7hZs+WOJ5itQ=="],
108 + "@nodable/entities": ["@nodable/entities@2.1.0", "", {}, "sha512-nyT7T3nbMyBI/lvr6L5TyWbFJAI9FTgVRakNoBqCD+PmID8DzFrrNdLLtHMwMszOtqZa8PAOV24ZqDnQrhQINA=="],
110 + "@protobufjs/aspromise": ["@protobufjs/aspromise@1.1.2", "", {}, "sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ=="],
112 + "@protobufjs/base64": ["@protobufjs/base64@1.1.2", "", {}, "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg=="],
114 + "@protobufjs/codegen": ["@protobufjs/codegen@2.0.5", "", {}, "sha512-zgXFLzW3Ap33e6d0Wlj4MGIm6Ce8O89n/apUaGNB/jx+hw+ruWEp7EwGUshdLKVRCxZW12fp9r40E1mQrf/34g=="],
116 + "@protobufjs/eventemitter": ["@protobufjs/eventemitter@1.1.0", "", {}, "sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q=="],
118 + "@protobufjs/fetch": ["@protobufjs/fetch@1.1.1", "", { "dependencies": { "@protobufjs/aspromise": "^1.1.1" } }, "sha512-GpptLrs57adMSuHi3VNj0mAF8dwh36LMaYF6XyJ6JMWlVsc+t42tm1HSEDmOs3A8fC9yyeisgLhsTVQokOZ0zw=="],
120 + "@protobufjs/float": ["@protobufjs/float@1.0.2", "", {}, "sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ=="],
122 + "@protobufjs/inquire": ["@protobufjs/inquire@1.1.2", "", {}, "sha512-pa0vFRuws4wkvaXKK1uXZMAwAX4/t8ANaJo45iw/oQHNQ9q5xUzwgFmVJGXiga2BeN+zpX7Vf9vmsiIa2J+MUw=="],
124 + "@protobufjs/path": ["@protobufjs/path@1.1.2", "", {}, "sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA=="],
126 + "@protobufjs/pool": ["@protobufjs/pool@1.1.0", "", {}, "sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw=="],
128 + "@protobufjs/utf8": ["@protobufjs/utf8@1.1.1", "", {}, "sha512-oOAWABowe8EAbMyWKM0tYDKi8Yaox52D+HWZhAIJqQXbqe0xI/GV7FhLWqlEKreMkfDjshR5FKgi3mnle0h6Eg=="],
130 + "@silvia-odwyer/photon-node": ["@silvia-odwyer/photon-node@0.3.4", "", {}, "sha512-bnly4BKB3KDTFxrUIcgCLbaeVVS8lrAkri1pEzskpmxu9MdfGQTy8b8EgcD83ywD3RPMsIulY8xJH5Awa+t9fA=="],
132 + "@smithy/core": ["@smithy/core@3.24.3", "", { "dependencies": { "@aws-crypto/crc32": "5.2.0", "@smithy/types": "^4.14.2", "tslib": "^2.6.2" } }, "sha512-Ep/7tPamGY8mgESE3LyLKtxJyy6U52WWAqr/3wial47Sj4u3PiIF73AOGI27UyLy9duTkhZbgzodOfLV4TduZg=="],
134 + "@smithy/credential-provider-imds": ["@smithy/credential-provider-imds@4.3.3", "", { "dependencies": { "@smithy/core": "^3.24.3", "@smithy/types": "^4.14.2", "tslib": "^2.6.2" } }, "sha512-I2Bti0DKFo2IJyN28ijCsx51BAumEYR4/1yZ1FXyBygy9MqbnMqCev4JPth/MbpRfBSRAX35hITSnAdJRo1u5w=="],
136 + "@smithy/fetch-http-handler": ["@smithy/fetch-http-handler@5.4.3", "", { "dependencies": { "@smithy/core": "^3.24.3", "@smithy/types": "^4.14.2", "tslib": "^2.6.2" } }, "sha512-F+DRf8IJazRJgYog2A/yJK7eYVc0rqTlRzO+5ZxjJd4WkZoKz0IJRncf7G6t1pdVT3kryJcwuTFhN1c5m6N47A=="],
138 + "@smithy/is-array-buffer": ["@smithy/is-array-buffer@2.2.0", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-GGP3O9QFD24uGeAXYUjwSTXARoqpZykHadOmA8G5vfJPK0/DC67qa//0qvqrJzL1xc8WQWX7/yc7fwudjPHPhA=="],
140 + "@smithy/node-http-handler": ["@smithy/node-http-handler@4.7.3", "", { "dependencies": { "@smithy/core": "^3.24.3", "@smithy/types": "^4.14.2", "tslib": "^2.6.2" } }, "sha512-/jPhevcTFPMVl6KNjbaI47iOg1zxC7IsnX4PQDGVZKMFceOXtB8IEYaB7a9VvkP/3oC60WzTeKocvSI7vLT0vA=="],
142 + "@smithy/signature-v4": ["@smithy/signature-v4@5.4.3", "", { "dependencies": { "@smithy/core": "^3.24.3", "@smithy/types": "^4.14.2", "tslib": "^2.6.2" } }, "sha512-53+75QuPl6DL+ct6vVEB51FDO5oulXr20TPV46VvJZg76lIlXNWfxi8j+G2V/t0I2qxCBOa3vX/8bmjrpFVo9g=="],
144 + "@smithy/types": ["@smithy/types@4.14.2", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-P+otAxbV4CqBybp7EkcJCrig63yE2E7PuNVOmilVMRcx/O+QDzGULTrKsq4DV13gSfak9ObPrWaHl/9bL5YcWw=="],
146 + "@smithy/util-buffer-from": ["@smithy/util-buffer-from@2.2.0", "", { "dependencies": { "@smithy/is-array-buffer": "^2.2.0", "tslib": "^2.6.2" } }, "sha512-IJdWBbTcMQ6DA0gdNhh/BwrLkDR+ADW5Kr1aZmd4k3DIF6ezMV4R2NIAmT08wQJ3yUK82thHWmC/TnK/wpMMIA=="],
148 + "@smithy/util-utf8": ["@smithy/util-utf8@2.3.0", "", { "dependencies": { "@smithy/util-buffer-from": "^2.2.0", "tslib": "^2.6.2" } }, "sha512-R8Rdn8Hy72KKcebgLiv8jQcQkXoLMOGGv5uI1/k0l+snqkOzQ1R0ChUBCxWMlBsFMekWjq0wRudIweFs7sKT5A=="],
150 + "@types/node": ["@types/node@25.9.1", "", { "dependencies": { "undici-types": ">=7.24.0 <7.24.7" } }, "sha512-xfrlY7UD5rMJk3ZVJP8BNzS28J36YJg+xp+LPXV1TdWxr8uMH5A860QNxYDGQe/ylDSgjxE52Q9VnO7p75tJxg=="],
152 + "@types/retry": ["@types/retry@0.12.0", "", {}, "sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA=="],
154 + "agent-base": ["agent-base@7.1.4", "", {}, "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ=="],
156 + "balanced-match": ["balanced-match@4.0.4", "", {}, "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA=="],
158 + "base64-js": ["base64-js@1.5.1", "", {}, "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA=="],
160 + "bignumber.js": ["bignumber.js@9.3.1", "", {}, "sha512-Ko0uX15oIUS7wJ3Rb30Fs6SkVbLmPBAKdlm7q9+ak9bbIeFf0MwuBsQV6z7+X768/cHsfg+WlysDWJcmthjsjQ=="],
162 + "bowser": ["bowser@2.14.1", "", {}, "sha512-tzPjzCxygAKWFOJP011oxFHs57HzIhOEracIgAePE4pqB3LikALKnSzUyU4MGs9/iCEUuHlAJTjTc5M+u7YEGg=="],
164 + "brace-expansion": ["brace-expansion@5.0.6", "", { "dependencies": { "balanced-match": "^4.0.2" } }, "sha512-kLpxurY4Z4r9sgMsyG0Z9uzsBlgiU/EFKhj/h91/8yHu0edo7XuixOIH3VcJ8kkxs6/jPzoI6U9Vj3WqbMQ94g=="],
166 + "buffer-equal-constant-time": ["buffer-equal-constant-time@1.0.1", "", {}, "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA=="],
168 + "chalk": ["chalk@5.6.2", "", {}, "sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA=="],
170 + "cross-spawn": ["cross-spawn@7.0.6", "", { "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", "which": "^2.0.1" } }, "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA=="],
172 + "data-uri-to-buffer": ["data-uri-to-buffer@4.0.1", "", {}, "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A=="],
174 + "debug": ["debug@4.4.3", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA=="],
176 + "diff": ["diff@8.0.4", "", {}, "sha512-DPi0FmjiSU5EvQV0++GFDOJ9ASQUVFh5kD+OzOnYdi7n3Wpm9hWWGfB/O2blfHcMVTL5WkQXSnRiK9makhrcnw=="],
178 + "ecdsa-sig-formatter": ["ecdsa-sig-formatter@1.0.11", "", { "dependencies": { "safe-buffer": "^5.0.1" } }, "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ=="],
180 + "extend": ["extend@3.0.2", "", {}, "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g=="],
182 + "fast-xml-builder": ["fast-xml-builder@1.2.0", "", { "dependencies": { "path-expression-matcher": "^1.5.0", "xml-naming": "^0.1.0" } }, "sha512-00aAWieqff+ZJhsXA4g1g7M8k+7AYoMUUHF+/zFb5U6Uv/P0Vl4QZo84/IcufzYalLuEj9928bXN9PbbFzMF0Q=="],
184 + "fast-xml-parser": ["fast-xml-parser@5.7.3", "", { "dependencies": { "@nodable/entities": "^2.1.0", "fast-xml-builder": "^1.1.7", "path-expression-matcher": "^1.5.0", "strnum": "^2.2.3" }, "bin": { "fxparser": "src/cli/cli.js" } }, "sha512-C0AaNuC+mscy6vrAQKAc/rMq+zAPHodfHGZu4sGVehvAQt/JLG1O5zEcYcXSY5zSqr4YVgxsB+pHXTq0i7eDlg=="],
186 + "fetch-blob": ["fetch-blob@3.2.0", "", { "dependencies": { "node-domexception": "^1.0.0", "web-streams-polyfill": "^3.0.3" } }, "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ=="],
188 + "formdata-polyfill": ["formdata-polyfill@4.0.10", "", { "dependencies": { "fetch-blob": "^3.1.2" } }, "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g=="],
190 + "gaxios": ["gaxios@7.1.4", "", { "dependencies": { "extend": "^3.0.2", "https-proxy-agent": "^7.0.1", "node-fetch": "^3.3.2" } }, "sha512-bTIgTsM2bWn3XklZISBTQX7ZSddGW+IO3bMdGaemHZ3tbqExMENHLx6kKZ/KlejgrMtj8q7wBItt51yegqalrA=="],
192 + "gcp-metadata": ["gcp-metadata@8.1.2", "", { "dependencies": { "gaxios": "^7.0.0", "google-logging-utils": "^1.0.0", "json-bigint": "^1.0.0" } }, "sha512-zV/5HKTfCeKWnxG0Dmrw51hEWFGfcF2xiXqcA3+J90WDuP0SvoiSO5ORvcBsifmx/FoIjgQN3oNOGaQ5PhLFkg=="],
194 + "get-east-asian-width": ["get-east-asian-width@1.6.0", "", {}, "sha512-QRbvDIbx6YklUe6RxeTeleMR0yv3cYH6PsPZHcnVn7xv7zO1BHN8r0XETu8n6Ye3Q+ahtSarc3WgtNWmehIBfA=="],
196 + "glob": ["glob@13.0.6", "", { "dependencies": { "minimatch": "^10.2.2", "minipass": "^7.1.3", "path-scurry": "^2.0.2" } }, "sha512-Wjlyrolmm8uDpm/ogGyXZXb1Z+Ca2B8NbJwqBVg0axK9GbBeoS7yGV6vjXnYdGm6X53iehEuxxbyiKp8QmN4Vw=="],
198 + "google-auth-library": ["google-auth-library@10.6.2", "", { "dependencies": { "base64-js": "^1.3.0", "ecdsa-sig-formatter": "^1.0.11", "gaxios": "^7.1.4", "gcp-metadata": "8.1.2", "google-logging-utils": "1.1.3", "jws": "^4.0.0" } }, "sha512-e27Z6EThmVNNvtYASwQxose/G57rkRuaRbQyxM2bvYLLX/GqWZ5chWq2EBoUchJbCc57eC9ArzO5wMsEmWftCw=="],
200 + "google-logging-utils": ["google-logging-utils@1.1.3", "", {}, "sha512-eAmLkjDjAFCVXg7A1unxHsLf961m6y17QFqXqAXGj/gVkKFrEICfStRfwUlGNfeCEjNRa32JEWOUTlYXPyyKvA=="],
202 + "graceful-fs": ["graceful-fs@4.2.11", "", {}, "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ=="],
204 + "highlight.js": ["highlight.js@10.7.3", "", {}, "sha512-tzcUFauisWKNHaRkN4Wjl/ZA07gENAjFl3J/c480dprkGTg5EQstgaNFqBfUqCq54kZRIEcreTsAgF/m2quD7A=="],
206 + "hosted-git-info": ["hosted-git-info@9.0.3", "", { "dependencies": { "lru-cache": "^11.1.0" } }, "sha512-Hc+ghLoSt6QaYZUv0WBiIvmMDZuZZ7oaDvdH8MbfOO4lOsxdXLEvuC6ePoGs9H1X9oCLyq6+NVN0MKqD+ydxyg=="],
208 + "http-proxy-agent": ["http-proxy-agent@7.0.2", "", { "dependencies": { "agent-base": "^7.1.0", "debug": "^4.3.4" } }, "sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig=="],
210 + "https-proxy-agent": ["https-proxy-agent@7.0.6", "", { "dependencies": { "agent-base": "^7.1.2", "debug": "4" } }, "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw=="],
212 + "ignore": ["ignore@7.0.5", "", {}, "sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg=="],
214 + "isexe": ["isexe@2.0.0", "", {}, "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw=="],
216 + "jiti": ["jiti@2.7.0", "", { "bin": { "jiti": "lib/jiti-cli.mjs" } }, "sha512-AC/7JofJvZGrrneWNaEnJeOLUx+JlGt7tNa0wZiRPT4MY1wmfKjt2+6O2p2uz2+skll8OZZmJMNqeke7kKbNgQ=="],
218 + "json-bigint": ["json-bigint@1.0.0", "", { "dependencies": { "bignumber.js": "^9.0.0" } }, "sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ=="],
220 + "json-schema-to-ts": ["json-schema-to-ts@3.1.1", "", { "dependencies": { "@babel/runtime": "^7.18.3", "ts-algebra": "^2.0.0" } }, "sha512-+DWg8jCJG2TEnpy7kOm/7/AxaYoaRbjVB4LFZLySZlWn8exGs3A4OLJR966cVvU26N7X9TWxl+Jsw7dzAqKT6g=="],
222 + "jwa": ["jwa@2.0.1", "", { "dependencies": { "buffer-equal-constant-time": "^1.0.1", "ecdsa-sig-formatter": "1.0.11", "safe-buffer": "^5.0.1" } }, "sha512-hRF04fqJIP8Abbkq5NKGN0Bbr3JxlQ+qhZufXVr0DvujKy93ZCbXZMHDL4EOtodSbCWxOqR8MS1tXA5hwqCXDg=="],
224 + "jws": ["jws@4.0.1", "", { "dependencies": { "jwa": "^2.0.1", "safe-buffer": "^5.0.1" } }, "sha512-EKI/M/yqPncGUUh44xz0PxSidXFr/+r0pA70+gIYhjv+et7yxM+s29Y+VGDkovRofQem0fs7Uvf4+YmAdyRduA=="],
226 + "koffi": ["koffi@2.16.2", "", {}, "sha512-owU0MRwv6xkrVqCd+33uw6BaYppkTRXbO/rVdJNI2dvZG0gzyRhYwW25eWtc5pauwK8TGh3AbkFONSezdykfSA=="],
228 + "long": ["long@5.3.2", "", {}, "sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA=="],
230 + "lru-cache": ["lru-cache@11.5.0", "", {}, "sha512-5YgH9UJd7wVb9hIouI2adWpgqrrICkt070Dnj8EUY1+B4B2P9eRLPAkAAo6NICA7CEhOIeBHl46u9zSNpNu7zA=="],
232 + "marked": ["marked@15.0.12", "", { "bin": { "marked": "bin/marked.js" } }, "sha512-8dD6FusOQSrpv9Z1rdNMdlSgQOIP880DHqnohobOmYLElGEqAL/JvxvuxZO16r4HtjTlfPRDC1hbvxC9dPN2nA=="],
234 + "minimatch": ["minimatch@10.2.5", "", { "dependencies": { "brace-expansion": "^5.0.5" } }, "sha512-MULkVLfKGYDFYejP07QOurDLLQpcjk7Fw+7jXS2R2czRQzR56yHRveU5NDJEOviH+hETZKSkIk5c+T23GjFUMg=="],
236 + "minipass": ["minipass@7.1.3", "", {}, "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A=="],
238 + "ms": ["ms@2.1.3", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="],
240 + "node-domexception": ["node-domexception@1.0.0", "", {}, "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ=="],
242 + "node-fetch": ["node-fetch@3.3.2", "", { "dependencies": { "data-uri-to-buffer": "^4.0.0", "fetch-blob": "^3.1.4", "formdata-polyfill": "^4.0.10" } }, "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA=="],
244 + "openai": ["openai@6.26.0", "", { "peerDependencies": { "ws": "^8.18.0", "zod": "^3.25 || ^4.0" }, "optionalPeers": ["ws", "zod"], "bin": { "openai": "bin/cli" } }, "sha512-zd23dbWTjiJ6sSAX6s0HrCZi41JwTA1bQVs0wLQPZ2/5o2gxOJA5wh7yOAUgwYybfhDXyhwlpeQf7Mlgx8EOCA=="],
246 + "p-retry": ["p-retry@4.6.2", "", { "dependencies": { "@types/retry": "0.12.0", "retry": "^0.13.1" } }, "sha512-312Id396EbJdvRONlngUx0NydfrIQ5lsYu0znKVUzVvArzEIt08V1qhtyESbGVd1FGX7UKtiFp5uwKZdM8wIuQ=="],
248 + "partial-json": ["partial-json@0.1.7", "", {}, "sha512-Njv/59hHaokb/hRUjce3Hdv12wd60MtM9Z5Olmn+nehe0QDAsRtRbJPvJ0Z91TusF0SuZRIvnM+S4l6EIP8leA=="],
250 + "path-expression-matcher": ["path-expression-matcher@1.5.0", "", {}, "sha512-cbrerZV+6rvdQrrD+iGMcZFEiiSrbv9Tfdkvnusy6y0x0GKBXREFg/Y65GhIfm0tnLntThhzCnfKwp1WRjeCyQ=="],
252 + "path-key": ["path-key@3.1.1", "", {}, "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q=="],
254 + "path-scurry": ["path-scurry@2.0.2", "", { "dependencies": { "lru-cache": "^11.0.0", "minipass": "^7.1.2" } }, "sha512-3O/iVVsJAPsOnpwWIeD+d6z/7PmqApyQePUtCndjatj/9I5LylHvt5qluFaBT3I5h3r1ejfR056c+FCv+NnNXg=="],
256 + "proper-lockfile": ["proper-lockfile@4.1.2", "", { "dependencies": { "graceful-fs": "^4.2.4", "retry": "^0.12.0", "signal-exit": "^3.0.2" } }, "sha512-TjNPblN4BwAWMXU8s9AEz4JmQxnD1NNL7bNOY/AKUzyamc379FWASUhc/K1pL2noVb+XmZKLL68cjzLsiOAMaA=="],
258 + "protobufjs": ["protobufjs@7.6.0", "", { "dependencies": { "@protobufjs/aspromise": "^1.1.2", "@protobufjs/base64": "^1.1.2", "@protobufjs/codegen": "^2.0.5", "@protobufjs/eventemitter": "^1.1.0", "@protobufjs/fetch": "^1.1.1", "@protobufjs/float": "^1.0.2", "@protobufjs/inquire": "^1.1.2", "@protobufjs/path": "^1.1.2", "@protobufjs/pool": "^1.1.0", "@protobufjs/utf8": "^1.1.1", "@types/node": ">=13.7.0", "long": "^5.3.2" } }, "sha512-LtESOsMPTZgyYtwxhvdgdjGL0HmXEaRA/hVD6sol4zA60hVXXXP/SGmxnqDbgGE8gy7pYex7cym+5vYPcmaXBQ=="],
260 + "retry": ["retry@0.12.0", "", {}, "sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow=="],
262 + "safe-buffer": ["safe-buffer@5.2.1", "", {}, "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ=="],
264 + "shebang-command": ["shebang-command@2.0.0", "", { "dependencies": { "shebang-regex": "^3.0.0" } }, "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA=="],
266 + "shebang-regex": ["shebang-regex@3.0.0", "", {}, "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A=="],
268 + "signal-exit": ["signal-exit@3.0.7", "", {}, "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ=="],
270 + "strnum": ["strnum@2.3.0", "", {}, "sha512-ums3KNd42PGyx5xaoVTO1mjU1bH3NpY4vsrVlnv9PNGqQj8wd7rJ6nEypLrJ7z5vxK5RP0yMLo6J/Gsm62DI5Q=="],
272 + "ts-algebra": ["ts-algebra@2.0.0", "", {}, "sha512-FPAhNPFMrkwz76P7cdjdmiShwMynZYN6SgOujD1urY4oNm80Ou9oMdmbR45LotcKOXoy7wSmHkRFE6Mxbrhefw=="],
274 + "tslib": ["tslib@2.8.1", "", {}, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
276 + "typebox": ["typebox@1.1.38", "", {}, "sha512-pZ0aQPmMmXoUvSbeuWf/Hzsc+avNw/Zd6VeE8CFgkVGWyuHPJvqeJJDeJqLve+K70LvjYIoleGcoJHPT17cWoA=="],
278 + "undici": ["undici@8.3.0", "", {}, "sha512-TkUDgb6tl7KOGZ+7e8E3d2FYgUQgF6z5YypqjWmixVQSQERFcVrVg0ySADm2LVLRh5ljAaHTCR5Fmz3Q34rB7Q=="],
280 + "undici-types": ["undici-types@7.24.6", "", {}, "sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg=="],
282 + "web-streams-polyfill": ["web-streams-polyfill@3.3.3", "", {}, "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw=="],
284 + "which": ["which@2.0.2", "", { "dependencies": { "isexe": "^2.0.0" }, "bin": { "node-which": "./bin/node-which" } }, "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA=="],
286 + "ws": ["ws@8.20.1", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-It4dO0K5v//JtTXuPkfEOaI3uUN87iYPnqo/ZzqCoG3g8uhA66QUMs/SrM0YK7/NAu+r4LMh/9dq2A7k+rHs+w=="],
288 + "xml-naming": ["xml-naming@0.1.0", "", {}, "sha512-k8KO9hrMyNk6tUWqUfkTEZbezRRpONVOzUTnc97VnCvyj6Tf9lyUR9EDAIeiVLv56jsMcoXEwjW8Kv5yPY52lw=="],
290 + "yaml": ["yaml@2.9.0", "", { "bin": { "yaml": "bin.mjs" } }, "sha512-2AvhNX3mb8zd6Zy7INTtSpl1F15HW6Wnqj0srWlkKLcpYl/gMIMJiyuGq2KeI2YFxUPjdlB+3Lc10seMLtL4cA=="],
292 + "zod": ["zod@4.4.3", "", {}, "sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ=="],
294 + "zod-to-json-schema": ["zod-to-json-schema@3.25.2", "", { "peerDependencies": { "zod": "^3.25.28 || ^4" } }, "sha512-O/PgfnpT1xKSDeQYSCfRI5Gy3hPf91mKVDuYLUHZJMiDFptvP41MSnWofm8dnCm0256ZNfZIM7DSzuSMAFnjHA=="],
296 + "@aws-sdk/credential-provider-sso/@aws-sdk/token-providers": ["@aws-sdk/token-providers@3.1049.0", "", { "dependencies": { "@aws-sdk/core": "^3.974.12", "@aws-sdk/nested-clients": "^3.997.10", "@aws-sdk/types": "^3.973.8", "@smithy/core": "^3.24.2", "@smithy/types": "^4.14.1", "tslib": "^2.6.2" } }, "sha512-r7+d0lQMTHKypkmaF5jRTBYLYHCUHzt3gaVoN9SidLhQeWhCmHk3AKrboDTpPF5b7Pt7vKu3+oeMjznM2Eu1ow=="],
298 + "p-retry/retry": ["retry@0.13.1", "", {}, "sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg=="],

pi/agent/extensions/ctx/index.ts

Added
new file mode 100644
1 +import { spawn } from "node:child_process";
2 +import { createHash } from "node:crypto";
3 +import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
4 +import { mkdtemp, rm, writeFile } from "node:fs/promises";
5 +import { tmpdir } from "node:os";
6 +import { dirname, isAbsolute, join, resolve } from "node:path";
7 +import { Type } from "typebox";
8 +import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
10 +const INTENT_SEARCH_THRESHOLD = 5_000;
11 +const LARGE_OUTPUT_THRESHOLD = 102_400;
12 +const MAX_RETURN_BYTES = 12_000;
13 +const MAX_CHUNK_BYTES = 16_000;
14 +const MAX_CHUNK_LINES = 200;
15 +const ERROR_QUERY = "errors failures exceptions panic traceback assertion failed error";
17 +type TextContent = { type: "text"; text: string };
18 +type ToolPatch = { content: TextContent[]; details?: Record<string, unknown>; isError?: boolean };
20 +export type CtxToolParams =
21 + | { op: "run-sh"; script: string; query?: string | string[]; timeoutMs?: number }
22 + | { op: "run-js"; code: string; query?: string | string[]; timeoutMs?: number }
23 + | { op: "run-py"; code: string; query?: string | string[]; timeoutMs?: number }
24 + | { op: "file-sh"; path: string; script: string; query?: string | string[]; timeoutMs?: number }
25 + | { op: "file-js"; path: string; code: string; query?: string | string[]; timeoutMs?: number }
26 + | { op: "file-py"; path: string; code: string; query?: string | string[]; timeoutMs?: number }
27 + | { op: "search"; query: string | string[]; source?: string; limit?: number };
29 +interface SourceRow {
30 + id: number;
31 + kind: string;
32 + label: string;
33 + bytes: number;
34 + created_at: string;
37 +interface SearchRow {
38 + source_id: number;
39 + title: string;
40 + text: string;
41 + label: string;
42 + kind: string;
43 + score: number;
46 +interface RunResult {
47 + stdout: string;
48 + stderr: string;
49 + exitCode: number | null;
50 + timedOut: boolean;
53 +function byteLen(text: string): number {
54 + return Buffer.byteLength(text, "utf8");
57 +function truncateBytes(text: string, max = MAX_RETURN_BYTES): string {
58 + if (byteLen(text) <= max) return text;
59 + let out = "";
60 + let used = 0;
61 + for (const ch of text) {
62 + const n = byteLen(ch);
63 + if (used + n > max) break;
64 + out += ch;
65 + used += n;
66 + }
67 + return `${out}\n… truncated to ${max}B`;
70 +function textOf(content: unknown): string {
71 + if (!Array.isArray(content)) return String(content ?? "");
72 + return content.map((c: any) => c?.type === "text" && typeof c.text === "string" ? c.text : "").join("\n");
75 +function queryTerms(query: string): string[] {
76 + return [...query.matchAll(/[\p{L}\p{N}_]{2,}/gu)]
77 + .map(match => match[0].toLowerCase())
78 + .filter(term => !["and", "or", "not", "near"].includes(term));
81 +function snippetForQuery(text: string, query: string, max = 2500): string {
82 + if (byteLen(text) <= max) return text.trim();
83 + const lower = text.toLowerCase();
84 + let pos = -1;
85 + for (const term of queryTerms(query)) {
86 + const next = lower.indexOf(term);
87 + if (next >= 0 && (pos < 0 || next < pos)) pos = next;
88 + }
89 + if (pos < 0) return truncateBytes(text.trim(), max);
90 + let start = Math.max(0, pos - Math.floor(max / 3));
91 + const newline = text.lastIndexOf("\n", pos);
92 + if (newline >= 0 && newline >= start - 500) start = newline + 1;
93 + let snippet = text.slice(start);
94 + if (start > 0) snippet = `…\n${snippet}`;
95 + return truncateBytes(snippet.trim(), max);
98 +function shortHash(text: string): string {
99 + return createHash("sha256").update(text).digest("hex").slice(0, 8);
102 +export function defaultDbPath(cwd = process.cwd(), ctx?: any): string {
103 + if (process.env.PI_CTX_DB_PATH) return process.env.PI_CTX_DB_PATH;
104 + const sessionFile = ctx?.sessionManager?.getSessionFile?.()
105 + ?? ctx?.sessionManager?.sessionFile
106 + ?? ctx?.sessionFile;
107 + const managerDir = ctx?.sessionManager?.getSessionDir?.()
108 + ?? ctx?.sessionManager?.sessionDir;
109 + const sessionDir = typeof sessionFile === "string" && sessionFile
110 + ? dirname(sessionFile)
111 + : typeof managerDir === "string" && managerDir
112 + ? managerDir
113 + : process.env.PI_CODING_AGENT_SESSION_DIR;
114 + if (typeof sessionDir !== "string" || !sessionDir) {
115 + throw new Error("ctx requires a Pi session dir; use PI_CTX_DB_PATH for tests/no-session runs");
117 + const base = join(sessionDir, "ctx");
118 + mkdirSync(base, { recursive: true });
119 + const hash = createHash("sha256").update(resolve(cwd)).digest("hex").slice(0, 16);
120 + return join(base, `${hash}.db`);
123 +function jsonText(value: unknown): string {
124 + try { return JSON.stringify(value); } catch { return String(value); }
127 +function normalizeQueries(query: string | string[] | undefined): string[] {
128 + if (Array.isArray(query)) return query.map(q => q.trim()).filter(Boolean);
129 + if (typeof query === "string" && query.trim()) return [query.trim()];
130 + return [];
133 +function sourceFilter(source: string | undefined): string | undefined {
134 + const s = source?.trim();
135 + return s ? `%${s}%` : undefined;
138 +function chunkText(text: string): Array<{ title: string; text: string }> {
139 + const lines = text.split(/\r?\n/);
140 + const chunks: Array<{ title: string; text: string }> = [];
141 + let current: string[] = [];
142 + let currentBytes = 0;
143 + let start = 1;
144 + const flush = (end: number) => {
145 + if (current.length === 0) return;
146 + chunks.push({ title: `lines ${start}-${end}`, text: current.join("\n") });
147 + current = [];
148 + currentBytes = 0;
149 + start = end + 1;
150 + };
151 + for (let i = 0; i < lines.length; i++) {
152 + const line = lines[i] ?? "";
153 + const n = byteLen(line) + 1;
154 + if (current.length > 0 && (current.length >= MAX_CHUNK_LINES || currentBytes + n > MAX_CHUNK_BYTES)) {
155 + flush(i);
157 + current.push(line);
158 + currentBytes += n;
160 + flush(lines.length);
161 + return chunks.length ? chunks : [{ title: "output", text }];
164 +export class CtxStore {
165 + #db: any;
166 + readonly dbPath: string;
168 + constructor(dbPath = defaultDbPath()) {
169 + this.dbPath = dbPath;
170 + mkdirSync(dirname(dbPath), { recursive: true });
171 + const { Database } = require("bun:sqlite") as typeof import("bun:sqlite");
172 + this.#db = new Database(dbPath);
173 + this.#db.exec("PRAGMA journal_mode=WAL");
174 + this.#db.exec("PRAGMA busy_timeout=30000");
175 + this.#db.exec(`
176 + CREATE TABLE IF NOT EXISTS sources (
177 + id INTEGER PRIMARY KEY AUTOINCREMENT,
178 + kind TEXT NOT NULL,
179 + label TEXT NOT NULL,
180 + bytes INTEGER NOT NULL,
181 + metadata TEXT,
182 + created_at TEXT NOT NULL DEFAULT (datetime('now'))
183 + );
184 + CREATE VIRTUAL TABLE IF NOT EXISTS chunks_fts USING fts5(
185 + source_id UNINDEXED,
186 + title,
187 + text,
188 + label UNINDEXED,
189 + kind UNINDEXED,
190 + tokenize='porter unicode61'
191 + );
192 + `);
195 + indexText(input: { kind: string; label: string; text: string; metadata?: unknown }): { sourceId: number; chunkCount: number; bytes: number; label: string } {
196 + const bytes = byteLen(input.text);
197 + const source = this.#db.prepare("INSERT INTO sources(kind, label, bytes, metadata) VALUES (?, ?, ?, ?)")
198 + .run(input.kind, input.label, bytes, input.metadata === undefined ? null : jsonText(input.metadata));
199 + const sourceId = Number(source.lastInsertRowid);
200 + const insert = this.#db.prepare("INSERT INTO chunks_fts(source_id, title, text, label, kind) VALUES (?, ?, ?, ?, ?)");
201 + const chunks = chunkText(input.text);
202 + const tx = this.#db.transaction(() => {
203 + for (const chunk of chunks) insert.run(sourceId, chunk.title, chunk.text, input.label, input.kind);
204 + });
205 + tx();
206 + return { sourceId, chunkCount: chunks.length, bytes, label: input.label };
209 + search(queries: string[], opts: { source?: string; limit?: number } = {}): string {
210 + const clean = queries.map(q => q.trim()).filter(Boolean);
211 + if (clean.length === 0) return "ctx: empty query";
212 + const limit = Math.max(1, Math.min(opts.limit ?? 3, 10));
213 + const src = sourceFilter(opts.source);
214 + const lines: string[] = [];
215 + for (const q of clean) {
216 + const rows = src
217 + ? this.#db.prepare("SELECT source_id, title, text, label, kind, bm25(chunks_fts) AS score FROM chunks_fts WHERE chunks_fts MATCH ? AND label LIKE ? ORDER BY score LIMIT ?").all(q, src, limit) as SearchRow[]
218 + : this.#db.prepare("SELECT source_id, title, text, label, kind, bm25(chunks_fts) AS score FROM chunks_fts WHERE chunks_fts MATCH ? ORDER BY score LIMIT ?").all(q, limit) as SearchRow[];
219 + lines.push(`## ${q}`);
220 + if (rows.length === 0) {
221 + lines.push("no matches");
222 + continue;
224 + for (const row of rows) {
225 + lines.push(`### ${row.label} · ${row.title}`);
226 + lines.push(snippetForQuery(row.text, q, 2500));
229 + return lines.join("\n");
232 + intentSearch(indexed: { sourceId: number; chunkCount: number; bytes: number; label: string }, query: string, maxResults = 5): string {
233 + const rows = this.#db.prepare("SELECT source_id, title, text, label, kind, bm25(chunks_fts) AS score FROM chunks_fts WHERE chunks_fts MATCH ? AND source_id = ? ORDER BY score LIMIT ?")
234 + .all(query, indexed.sourceId, maxResults) as SearchRow[];
235 + const kb = (indexed.bytes / 1024).toFixed(1);
236 + if (rows.length === 0) {
237 + return [
238 + `ctx:stored ${indexed.label} (${kb}KB, ${indexed.chunkCount} chunks).`,
239 + `No sections matched "${query}".`,
240 + `Use ctx search with source "${indexed.label}".`,
241 + ].join("\n");
243 + const lines = [
244 + `ctx:stored ${indexed.label} (${kb}KB, ${indexed.chunkCount} chunks).`,
245 + `${rows.length} sections matched "${query}":`,
246 + "",
247 + ];
248 + for (const row of rows) {
249 + const preview = row.text.split(/\r?\n/).find(Boolean)?.slice(0, 160) ?? "";
250 + lines.push(`- ${row.title}: ${preview}`);
252 + lines.push("");
253 + lines.push(`Use ctx search with source "${indexed.label}" for details.`);
254 + return lines.join("\n");
257 + pointer(indexed: { chunkCount: number; bytes: number; label: string }): string {
258 + const kb = (indexed.bytes / 1024).toFixed(1);
259 + return `ctx:stored ${indexed.label} (${kb}KB, ${indexed.chunkCount} chunks).\nUse ctx search with source "${indexed.label}".`;
262 + stats(): { sources: number; bytes: number; recent: SourceRow[] } {
263 + const row = this.#db.prepare("SELECT COUNT(*) AS sources, COALESCE(SUM(bytes), 0) AS bytes FROM sources").get() as { sources: number; bytes: number };
264 + const recent = this.#db.prepare("SELECT id, kind, label, bytes, created_at FROM sources ORDER BY id DESC LIMIT 8").all() as SourceRow[];
265 + return { sources: Number(row.sources), bytes: Number(row.bytes), recent };
268 + formatStats(): string {
269 + const stats = this.stats();
270 + const lines = [`ctx: ${stats.sources} sources, ${(stats.bytes / 1024).toFixed(1)}KB stored`];
271 + if (stats.recent.length) {
272 + lines.push("recent:");
273 + for (const s of stats.recent) lines.push(`- ${s.label} ${s.kind} ${(s.bytes / 1024).toFixed(1)}KB`);
275 + lines.push("usage: /ctx <query> | /ctx --purge");
276 + return lines.join("\n");
279 + purge(): void {
280 + this.#db.exec("DELETE FROM chunks_fts; DELETE FROM sources;");
283 + close(): void {
284 + this.#db.close();
288 +async function runProcess(command: string, args: string[], opts: { cwd: string; input?: string; env?: NodeJS.ProcessEnv; timeoutMs?: number; signal?: AbortSignal }): Promise<RunResult> {
289 + return await new Promise((resolve) => {
290 + let stdout = "";
291 + let stderr = "";
292 + let settled = false;
293 + const child = spawn(command, args, {
294 + cwd: opts.cwd,
295 + env: opts.env ?? process.env,
296 + stdio: [opts.input === undefined ? "ignore" : "pipe", "pipe", "pipe"],
297 + signal: opts.signal,
298 + });
299 + const finish = (result: RunResult) => {
300 + if (settled) return;
301 + settled = true;
302 + if (timer) clearTimeout(timer);
303 + resolve(result);
304 + };
305 + const timer = opts.timeoutMs && opts.timeoutMs > 0 ? setTimeout(() => {
306 + try { child.kill("SIGTERM"); } catch { /* noop */ }
307 + finish({ stdout, stderr, exitCode: null, timedOut: true });
308 + }, opts.timeoutMs) : undefined;
309 + child.stdout?.setEncoding("utf8");
310 + child.stderr?.setEncoding("utf8");
311 + child.stdout?.on("data", (chunk: string) => { stdout += chunk; });
312 + child.stderr?.on("data", (chunk: string) => { stderr += chunk; });
313 + child.on("error", (err) => finish({ stdout, stderr: stderr + String(err), exitCode: 1, timedOut: false }));
314 + child.on("close", (code) => finish({ stdout, stderr, exitCode: code, timedOut: false }));
315 + if (opts.input !== undefined && child.stdin) {
316 + child.stdin.end(opts.input);
318 + });
321 +async function withTempFile<T>(prefix: string, suffix: string, content: string, fn: (path: string) => Promise<T>): Promise<T> {
322 + const dir = await mkdtemp(join(tmpdir(), prefix));
323 + try {
324 + const file = join(dir, `script${suffix}`);
325 + await writeFile(file, content, "utf8");
326 + return await fn(file);
327 + } finally {
328 + await rm(dir, { recursive: true, force: true }).catch(() => {});
332 +function resultText(result: RunResult): { text: string; isError: boolean } {
333 + const isError = result.timedOut || (result.exitCode !== 0 && result.exitCode !== null);
334 + let text = result.stdout;
335 + if (result.stderr) text += (text ? "\n" : "") + result.stderr;
336 + if (result.timedOut) text += `\n(timed out)`;
337 + if (!text) text = "(no output)";
338 + return { text, isError };
341 +function finalizeOutput(store: CtxStore, source: { kind: string; label: string; metadata?: unknown }, text: string, isError: boolean, query?: string | string[]): ToolPatch {
342 + const bytes = byteLen(text);
343 + const queries = normalizeQueries(query);
344 + if (queries.length && bytes > INTENT_SEARCH_THRESHOLD) {
345 + const indexed = store.indexText({ ...source, text });
346 + return { content: [{ type: "text", text: store.intentSearch(indexed, queries.join(" ")) }], isError };
348 + if (isError && bytes > INTENT_SEARCH_THRESHOLD) {
349 + const indexed = store.indexText({ ...source, text });
350 + return { content: [{ type: "text", text: store.intentSearch(indexed, ERROR_QUERY) }], isError };
352 + if (bytes > LARGE_OUTPUT_THRESHOLD) {
353 + const indexed = store.indexText({ ...source, text });
354 + return { content: [{ type: "text", text: store.pointer(indexed) }], isError };
356 + return { content: [{ type: "text", text: truncateBytes(text) }], isError };
359 +export async function executeCtxOperation(store: CtxStore, params: CtxToolParams, cwd: string, signal?: AbortSignal): Promise<ToolPatch> {
360 + const timeoutMs = "timeoutMs" in params ? params.timeoutMs : undefined;
361 + const query = "query" in params ? params.query : undefined;
362 + switch (params.op) {
363 + case "search": {
364 + return { content: [{ type: "text", text: store.search(normalizeQueries(params.query), { source: params.source, limit: params.limit }) }] };
366 + case "run-sh": {
367 + const r = await runProcess("/bin/sh", ["-c", params.script], { cwd, timeoutMs, signal });
368 + const { text, isError } = resultText(r);
369 + return finalizeOutput(store, { kind: "run-sh", label: `run-sh:${shortHash(params.script)}`, metadata: { script: params.script } }, text, isError, query);
371 + case "run-js": {
372 + return await withTempFile("pi-ctx-js-", ".js", params.code, async (file) => {
373 + const r = await runProcess("bun", [file], { cwd, timeoutMs, signal });
374 + const { text, isError } = resultText(r);
375 + return finalizeOutput(store, { kind: "run-js", label: `run-js:${shortHash(params.code)}`, metadata: { code: params.code } }, text, isError, query);
376 + });
378 + case "run-py": {
379 + return await withTempFile("pi-ctx-py-", ".py", params.code, async (file) => {
380 + const r = await runProcess("python3", [file], { cwd, timeoutMs, signal });
381 + const { text, isError } = resultText(r);
382 + return finalizeOutput(store, { kind: "run-py", label: `run-py:${shortHash(params.code)}`, metadata: { code: params.code } }, text, isError, query);
383 + });
385 + case "file-sh": {
386 + const path = isAbsolute(params.path) ? params.path : resolve(cwd, params.path);
387 + const r = await runProcess("/bin/sh", ["-c", params.script], { cwd, timeoutMs, signal, env: { ...process.env, CTX_FILE: path } });
388 + const { text, isError } = resultText(r);
389 + return finalizeOutput(store, { kind: "file-sh", label: `file-sh:${params.path}`, metadata: { path: params.path, script: params.script } }, text, isError, query);
391 + case "file-js": {
392 + const path = isAbsolute(params.path) ? params.path : resolve(cwd, params.path);
393 + const wrapper = `const path = ${JSON.stringify(path)};\nconst text = await Bun.file(path).text();\n${params.code}\n`;
394 + return await withTempFile("pi-ctx-file-js-", ".js", wrapper, async (file) => {
395 + const r = await runProcess("bun", [file], { cwd, timeoutMs, signal });
396 + const { text, isError } = resultText(r);
397 + return finalizeOutput(store, { kind: "file-js", label: `file-js:${params.path}`, metadata: { path: params.path, code: params.code } }, text, isError, query);
398 + });
400 + case "file-py": {
401 + const path = isAbsolute(params.path) ? params.path : resolve(cwd, params.path);
402 + const wrapper = `path = ${JSON.stringify(path)}\ntext = open(path, 'r', encoding='utf-8', errors='replace').read()\n${params.code}\n`;
403 + return await withTempFile("pi-ctx-file-py-", ".py", wrapper, async (file) => {
404 + const r = await runProcess("python3", [file], { cwd, timeoutMs, signal });
405 + const { text, isError } = resultText(r);
406 + return finalizeOutput(store, { kind: "file-py", label: `file-py:${params.path}`, metadata: { path: params.path, code: params.code } }, text, isError, query);
407 + });
412 +export function handleBashToolResult(store: CtxStore, event: any): ToolPatch | undefined {
413 + if (event?.toolName !== "bash") return undefined;
414 + const visible = textOf(event.content);
415 + const fullPath = event.details?.fullOutputPath;
416 + let full = visible;
417 + if (typeof fullPath === "string") {
418 + try {
419 + if (existsSync(fullPath)) full = readFileSync(fullPath, "utf8");
420 + } catch (err) {
421 + return {
422 + content: [{ type: "text", text: `ctx:suppressed bash output; failed to read fullOutputPath (${err instanceof Error ? err.message : String(err)})` }],
423 + details: { ...(event.details ?? {}), ctxSuppressed: true },
424 + isError: event.isError,
425 + };
428 + const bytes = byteLen(full);
429 + if (!event.isError && bytes <= LARGE_OUTPUT_THRESHOLD) return undefined;
430 + if (event.isError && bytes <= INTENT_SEARCH_THRESHOLD) return undefined;
431 + try {
432 + const command = String(event.input?.command ?? "bash");
433 + const label = `${event.isError ? "bash-error" : "bash"}:${shortHash(command)}`;
434 + const indexed = store.indexText({ kind: event.isError ? "bash-error" : "bash", label, text: full, metadata: { command } });
435 + const text = event.isError ? store.intentSearch(indexed, ERROR_QUERY) : store.pointer(indexed);
436 + return {
437 + content: [{ type: "text", text }],
438 + details: { ...(event.details ?? {}), ctxStored: true, ctxSource: label },
439 + isError: event.isError,
440 + };
441 + } catch (err) {
442 + return {
443 + content: [{ type: "text", text: `ctx:suppressed ${bytes}B bash output; storage failed (${err instanceof Error ? err.message : String(err)})` }],
444 + details: { ...(event.details ?? {}), ctxSuppressed: true },
445 + isError: event.isError,
446 + };
450 +function makeStore(ctx?: any): CtxStore {
451 + const cwd = ctx?.cwd ?? process.cwd();
452 + return new CtxStore(defaultDbPath(cwd, ctx));
455 +const Params = Type.Object({
456 + op: Type.Union([
457 + Type.Literal("run-sh"), Type.Literal("run-js"), Type.Literal("run-py"),
458 + Type.Literal("file-sh"), Type.Literal("file-js"), Type.Literal("file-py"), Type.Literal("search"),
459 + ], { description: "Operation" }),
460 + script: Type.Optional(Type.String({ description: "Shell script for run-sh/file-sh" })),
461 + code: Type.Optional(Type.String({ description: "JS/Python code for run-js/run-py/file-js/file-py" })),
462 + path: Type.Optional(Type.String({ description: "File path for file-* ops" })),
463 + query: Type.Optional(Type.Union([Type.String(), Type.Array(Type.String())], { description: "Search query / intent" })),
464 + source: Type.Optional(Type.String({ description: "Source label substring for search" })),
465 + limit: Type.Optional(Type.Number({ description: "Search results per query" })),
466 + timeoutMs: Type.Optional(Type.Number({ description: "Timeout in ms" })),
467 +});
469 +function normalizeParams(raw: any): CtxToolParams {
470 + if (!raw || typeof raw !== "object") throw new Error("ctx params object required");
471 + switch (raw.op) {
472 + case "run-sh": if (typeof raw.script === "string") return raw; break;
473 + case "run-js": if (typeof raw.code === "string") return raw; break;
474 + case "run-py": if (typeof raw.code === "string") return raw; break;
475 + case "file-sh": if (typeof raw.path === "string" && typeof raw.script === "string") return raw; break;
476 + case "file-js": if (typeof raw.path === "string" && typeof raw.code === "string") return raw; break;
477 + case "file-py": if (typeof raw.path === "string" && typeof raw.code === "string") return raw; break;
478 + case "search": if (typeof raw.query === "string" || Array.isArray(raw.query)) return raw; break;
480 + throw new Error("invalid ctx params for op");
483 +export function registerCtxExtension(pi: Pick<ExtensionAPI, "registerTool" | "registerCommand" | "on">): void {
484 + pi.on("tool_result", (event: any, ctx: any) => {
485 + let store: CtxStore | undefined;
486 + try {
487 + store = makeStore(ctx);
488 + return handleBashToolResult(store, event);
489 + } catch (err) {
490 + const text = textOf(event?.content);
491 + const maybeLarge = event?.toolName === "bash" && (event?.details?.fullOutputPath || byteLen(text) > LARGE_OUTPUT_THRESHOLD);
492 + if (!maybeLarge) return undefined;
493 + return {
494 + content: [{ type: "text", text: `ctx:suppressed bash output; store unavailable (${err instanceof Error ? err.message : String(err)})` }],
495 + details: { ...(event.details ?? {}), ctxSuppressed: true },
496 + isError: event.isError,
497 + };
498 + } finally {
499 + store?.close();
501 + });
503 + pi.registerTool({
504 + name: "ctx",
505 + label: "ctx",
506 + description: "Run JS/Py/sh analysis off-context; search stored large bash output.",
507 + promptSnippet: "Run JS/Py/sh analysis off-context; search stored large bash output.",
508 + promptGuidelines: [
509 + "Use ctx run-* for large-output analysis; print only findings.",
510 + "Use ctx file-* for large file analysis without reading whole files into context.",
511 + "Use ctx search when bash output was stored as ctx:stored.",
512 + ],
513 + parameters: Params,
514 + async execute(_toolCallId: string, raw: unknown, signal?: AbortSignal, _onUpdate?: unknown, ctx?: any) {
515 + const store = makeStore(ctx);
516 + try {
517 + const params = normalizeParams(raw);
518 + return await executeCtxOperation(store, params, ctx?.cwd ?? process.cwd(), signal);
519 + } catch (err) {
520 + return { content: [{ type: "text", text: `ctx error: ${err instanceof Error ? err.message : String(err)}` }], details: {}, isError: true };
521 + } finally {
522 + store.close();
524 + },
525 + });
527 + pi.registerCommand("ctx", {
528 + description: "ctx stats/search/purge",
529 + handler: async (args: unknown, ctx: any) => {
530 + const q = String(args ?? "").trim();
531 + const store = makeStore(ctx);
532 + try {
533 + if (q === "--purge") {
534 + if (ctx?.hasUI) {
535 + const ok = await ctx.ui.confirm("ctx purge", "Delete ctx index for this project?");
536 + if (!ok) return { text: "ctx purge cancelled" };
538 + store.purge();
539 + return { text: "ctx purged" };
541 + if (!q) return { text: store.formatStats() };
542 + return { text: store.search([q], { limit: 5 }) };
543 + } finally {
544 + store.close();
546 + },
547 + });
550 +export default function (pi: ExtensionAPI): void {
551 + registerCtxExtension(pi);

pi/agent/extensions/ctx/package.json

Added
new file mode 100644
1 +{
2 + "name": "@bugabinga/pi-ext-ctx",
3 + "version": "0.0.0",
4 + "private": true,
5 + "type": "module",
6 + "main": "index.ts",
7 + "scripts": {
8 + "test": "bun test ./__tests__/*.test.ts"
9 + },
10 + "peerDependencies": {
11 + "@earendil-works/pi-coding-agent": "*",
12 + "@earendil-works/pi-tui": "*",
13 + "typebox": "*"
14 + },
15 + "devDependencies": {
16 + "@marcfargas/pi-test-harness": "git+ssh://git@github.com/bugabinga/pi-test-harness.git#0cb5ce5f10fb18c9a80e904e2e3310cc98a28e29"
17 + }