feat(coding-agent): support session dir env

closes #4027
This commit is contained in:
Mario Zechner
2026-04-30 21:37:53 +02:00
parent 8632e1b948
commit 8191d59c17
7 changed files with 21 additions and 9 deletions

View File

@@ -327,6 +327,13 @@ export const VERSION: string = pkg.version || "0.0.0";
// e.g., PI_CODING_AGENT_DIR or TAU_CODING_AGENT_DIR
export const ENV_AGENT_DIR = `${APP_NAME.toUpperCase()}_CODING_AGENT_DIR`;
export const ENV_SESSION_DIR = `${APP_NAME.toUpperCase()}_CODING_AGENT_SESSION_DIR`;
export function expandTildePath(path: string): string {
if (path === "~") return homedir();
if (path.startsWith("~/")) return homedir() + path.slice(1);
return path;
}
const DEFAULT_SHARE_VIEWER_URL = "https://pi.dev/session/";
@@ -344,10 +351,7 @@ export function getShareViewerUrl(gistId: string): string {
export function getAgentDir(): string {
const envDir = process.env[ENV_AGENT_DIR];
if (envDir) {
// Expand tilde to home directory
if (envDir === "~") return homedir();
if (envDir.startsWith("~/")) return homedir() + envDir.slice(1);
return envDir;
return expandTildePath(envDir);
}
return join(homedir(), CONFIG_DIR_NAME, "agent");
}