diff --git a/packages/handoff/src/session-paths.ts b/packages/handoff/src/session-paths.ts index df4c67156b53a332125922f4ecb650195f3bd9df..901ef1eb6e7484c6d4f5dbd31af99eaadbf77eed 100644 --- a/packages/handoff/src/session-paths.ts +++ b/packages/handoff/src/session-paths.ts @@ -4,8 +4,8 @@ // SPDX-License-Identifier: MIT import * as fs from "node:fs"; -import * as os from "node:os"; import * as path from "node:path"; +import { getAgentDir } from "@earendil-works/pi-coding-agent"; export function getSessionsRoot(sessionFile: string | undefined): string | undefined { if (!sessionFile) return undefined; @@ -19,10 +19,7 @@ export function getSessionsRoot(sessionFile: string | undefined): string | undef } export function getFallbackSessionsRoot(): string | undefined { - const configuredDir = process.env.PI_CODING_AGENT_DIR; - const candidate = configuredDir - ? path.resolve(configuredDir, "sessions") - : path.resolve(os.homedir(), ".pi", "agent", "sessions"); + const candidate = path.resolve(getAgentDir(), "sessions"); return fs.existsSync(candidate) ? candidate : undefined; } diff --git a/packages/personas/src/index.ts b/packages/personas/src/index.ts index 6f8969d45aea4322a8695047acd35882e726d12d..ed0c912e1628e68018233c9637f1e4ba7cca3050 100644 --- a/packages/personas/src/index.ts +++ b/packages/personas/src/index.ts @@ -7,7 +7,7 @@ * * Switch between agent personas stored as markdown files. * - * Personas live in $PI_CODING_AGENT_DIR/personas/ as .md files. + * Personas live in the Pi agent directory's personas/ subdirectory as .md files. * The active persona is appended to the system prompt in a * section, independent of SYSTEM.md and AGENTS.md. * @@ -16,26 +16,15 @@ * /persona none|unset|clear — Remove active persona * * The active persona persists across sessions in a plain text file - * at $PI_CODING_AGENT_DIR/persona. + * at persona in the Pi agent directory. */ import * as fs from "node:fs"; import * as path from "node:path"; -import * as os from "node:os"; -import type { ExtensionAPI } from "@earendil-works/pi-coding-agent"; +import { getAgentDir, type ExtensionAPI } from "@earendil-works/pi-coding-agent"; const CLEAR_KEYWORDS = ["none", "unset", "clear"]; -function getAgentDir(): string { - const envDir = process.env.PI_CODING_AGENT_DIR; - if (envDir) { - if (envDir === "~") return os.homedir(); - if (envDir.startsWith("~/")) return path.join(os.homedir(), envDir.slice(2)); - return envDir; - } - return path.join(os.homedir(), ".pi", "agent"); -} - function getPersonasDir(): string { return path.join(getAgentDir(), "personas"); }