feat(coding-agent): configurable app name and config dir for forks (#95)

- Add piConfig to package.json for app name and config directory
- Consolidate paths.ts into config.ts with clearer naming
- Fix Bun binary detection (changed from %7EBUN to $bunfs)
- Update all hardcoded paths to use config.ts exports
- getThemesDir() for built-in themes, getCustomThemesDir() for user themes
This commit is contained in:
Mario Zechner 2025-12-03 16:18:59 +01:00
parent 9d5fe1fe85
commit e82fb0fc83
17 changed files with 241 additions and 167 deletions

View file

@ -1,8 +1,8 @@
import type { AgentState, AppMessage } from "@mariozechner/pi-agent-core";
import { randomBytes } from "crypto";
import { appendFileSync, existsSync, mkdirSync, readdirSync, readFileSync, statSync } from "fs";
import { homedir } from "os";
import { join, resolve } from "path";
import { getAgentDir } from "./config.js";
function uuidv4(): string {
const bytes = randomBytes(16);
@ -83,7 +83,7 @@ export class SessionManager {
// Replace all path separators and colons (for Windows drive letters) with dashes
const safePath = "--" + cwd.replace(/^[/\\]/, "").replace(/[/\\:]/g, "-") + "--";
const configDir = resolve(process.env.PI_CODING_AGENT_DIR || join(homedir(), ".pi/agent/"));
const configDir = getAgentDir();
const sessionDir = join(configDir, "sessions", safePath);
if (!existsSync(sessionDir)) {
mkdirSync(sessionDir, { recursive: true });