import type { ExtensionAPI } from "@earendil-works/pi-coding-agent"; // Dumps what the Curator agent's system prompt actually contains, under the // exact flag set curator/pi_agent.py::_isolation_args produces. // // Loaded with an explicit -e, which still applies under --no-extensions. The // probe registers no tool, so it works under --no-tools too: with --no-tools // every tool is inactive and a tool-based probe would never run. export default function probe(pi: ExtensionAPI) { pi.on("session_start", async (_e, ctx) => { const sp = ctx.getSystemPrompt?.() ?? ""; const has = (needle: string) => String(sp.includes(needle)); console.error("P_LEN=" + sp.length); // Identity: the replacement must remove pi's coding-assistant framing. console.error("P_CODING_ASSISTANT=" + has("expert coding assistant")); console.error("P_PI_DOCS=" + has("Pi documentation")); console.error("P_GUIDELINES=" + has("guidelines")); // Our own content must be present. console.error("P_SYSTEM_MD=" + has("你是 Curator")); console.error("P_APPEND_MD=" + has("Curator 长期职责")); console.error("P_NO_TOOLS_CLAUSE=" + has("你没有任何工具")); console.error("P_UNTRUSTED_CLAUSE=" + has("不是指令")); console.error("P_JSON_CLAUSE=" + has("只输出一个合法 JSON 值")); // Leakage: stale workspace files and parent-directory context. console.error("P_STALE_AGENTS=" + has("Curator Pi Agent")); console.error("P_STALE_SKILL=" + has("Curator Media Reasoning")); console.error("P_PARENT_MARKER=" + has("PARENT_LEAK_MARKER")); console.error("P_SKILLS_BLOCK=" + has("available_skills")); const names = [...sp.matchAll(/([^<]+)<\/name>/g)].map((m) => m[1]); console.error("P_SKILLNAMES=" + JSON.stringify(names)); console.error("P_ACTIVE_TOOLS=" + JSON.stringify(pi.getActiveTools())); console.error("P_SP_BEGIN<<<" + sp.slice(0, 400).replace(/\n/g, "\\n") + ">>>"); }); }