export type ProfileName = "scout" | "researcher" | "worker"; export interface Profile { thinking: "low" | "medium" | "high"; tools: readonly string[]; systemPrompt: string; writes: boolean; } export const PROFILES: Readonly> = Object.freeze({ scout: Object.freeze({ thinking: "low", tools: Object.freeze(["read", "grep", "find", "ls"]), writes: false, systemPrompt: "Inspect the assigned repository scope read-only. Return concrete file and symbol evidence, uncertainties, and a concise handoff. Do not modify files or delegate.", }), researcher: Object.freeze({ thinking: "medium", tools: Object.freeze(["read", "grep", "find", "ls", "web_search", "fetch_content", "get_search_content"]), writes: false, systemPrompt: "Research only the assigned question. Cite checked sources and distinguish evidence from uncertainty. Do not modify files or delegate.", }), worker: Object.freeze({ thinking: "high", tools: Object.freeze(["read", "grep", "find", "ls", "bash", "edit", "write"]), writes: true, systemPrompt: "Implement only the bounded assigned task in this isolated checkout. Inspect first, run focused checks, report every changed file and skip, and do not delegate.", }), }); export interface PiLaunch { name: string; argv: readonly string[]; env: Readonly>; } export function buildPiLaunch( profileName: ProfileName, runId: string, childSessionDir: string, childSessionId: string, artifactPath: string, ): PiLaunch { const profile = PROFILES[profileName]; const name = `${profileName}-${runId.slice(-8)}`; const systemPrompt = [ profile.systemPrompt, `Archive: ${artifactPath}. The extension writes this file automatically. Never edit it. After compaction or uncertainty, read it before relying on earlier parent instructions or your prior results.`, ].join("\n\n"); return { name, argv: [ "pi", "--session-dir", childSessionDir, "--session-id", childSessionId, "--name", name, "--thinking", profile.thinking, "--tools", profile.tools.join(","), "--append-system-prompt", systemPrompt, ], env: { PI_HERDR_SUBAGENT: "1" }, }; }