diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index 21c3ddc3..021cca96 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -10,6 +10,7 @@ ### Fixed - Fixed extension messages rendering twice on startup when `pi.sendMessage({ display: true })` is called during `session_start` ([#765](https://github.com/badlogic/pi-mono/pull/765) by [@dannote](https://github.com/dannote)) +- Fixed `PI_CODING_AGENT_DIR` env var not expanding tilde (`~`) to home directory ([#768](https://github.com/badlogic/pi-mono/pull/778) by [@aliou](https://github.com/aliou)) ## [0.47.0] - 2026-01-16 diff --git a/packages/coding-agent/src/config.ts b/packages/coding-agent/src/config.ts index 9d9af583..48c3d7a4 100644 --- a/packages/coding-agent/src/config.ts +++ b/packages/coding-agent/src/config.ts @@ -122,7 +122,14 @@ export const ENV_AGENT_DIR = `${APP_NAME.toUpperCase()}_CODING_AGENT_DIR`; /** Get the agent config directory (e.g., ~/.pi/agent/) */ export function getAgentDir(): string { - return process.env[ENV_AGENT_DIR] || join(homedir(), CONFIG_DIR_NAME, "agent"); + 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 join(homedir(), CONFIG_DIR_NAME, "agent"); } /** Get path to user's custom themes directory */