import { homedir } from "node:os";
import { join } from "node:path";

const LEGACY_PI_AGENT_ROOT = join(homedir(), ".pi", "agent");

export function resolveAgentRootPath(): string {
  const agentDir = process.env.PI_CODING_AGENT_DIR?.trim();
  return agentDir && agentDir.length > 0 ? agentDir : LEGACY_PI_AGENT_ROOT;
}

export function resolveGlobalCompactionPolicyPath(): string {
  return join(resolveAgentRootPath(), "compaction-policy.json");
}
