包含 extensions、skills、prompts、settings、auth、models、mcp 等配置。 排除 node_modules、npm 缓存、sessions 等运行时数据。
23 lines
669 B
TypeScript
23 lines
669 B
TypeScript
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);
|
|
}
|