import { CONFIG_DIR_NAME } from "@earendil-works/pi-coding-agent"; import { homedir } from "node:os"; import { join, resolve } from "node:path"; export function getAgentDir(): string { const configured = process.env.SPROUTCLAW_CODING_AGENT_DIR?.trim() || process.env.PI_CODING_AGENT_DIR?.trim(); if (!configured) { return join(homedir(), CONFIG_DIR_NAME, "agent"); } if (configured === "~") { return homedir(); } if (configured.startsWith("~/")) { return resolve(homedir(), configured.slice(2)); } return resolve(configured); } export function getAgentPath(...segments: string[]): string { return join(getAgentDir(), ...segments); }