/** * postinstall.ts * * Runs automatically after `pi install npm:@aethrekh/pisces`. * * 1. Copies SYSTEM.md to ~/.pi/agent/APPEND_SYSTEM.md so the Pisces persona * is injected into every Pi session without needing a restart. * 2. Copies pisces-editorial-noir.json to ~/.pi/agent/themes/ so Pi can find * it by name at startup and correctly restore a saved theme preference. */ import * as fs from "fs"; import * as path from "path"; import * as os from "os"; const AGENT_DIR = path.join(os.homedir(), ".pi", "agent"); const THEMES_DIR = path.join(AGENT_DIR, "themes"); const THEME_NAME = "pisces-editorial-noir.json"; const THEME_SRC = path.join(__dirname, "themes", THEME_NAME); const THEME_DEST = path.join(THEMES_DIR, THEME_NAME); const SYSTEM_SRC = path.join(__dirname, "SYSTEM.md"); const SYSTEM_DEST = path.join(AGENT_DIR, "APPEND_SYSTEM.md"); function installSystem(): void { if (!fs.existsSync(SYSTEM_SRC)) { console.log("Pisces: SYSTEM.md not found — skipping persona install."); return; } try { fs.mkdirSync(AGENT_DIR, { recursive: true }); fs.copyFileSync(SYSTEM_SRC, SYSTEM_DEST); console.log(`Pisces: installed persona → ${SYSTEM_DEST}`); } catch (err) { console.error("Pisces: could not install persona:", err); } } function installTheme(): void { if (!fs.existsSync(THEME_SRC)) { console.log("Pisces: theme source not found — skipping theme install."); return; } try { fs.mkdirSync(THEMES_DIR, { recursive: true }); fs.copyFileSync(THEME_SRC, THEME_DEST); console.log(`Pisces: installed theme → ${THEME_DEST}`); } catch (err) { // Non-fatal: theme will still be available via resources_discover, just // won't persist across restarts if the user saves it as their preference. console.error("Pisces: could not install theme:", err); } } installSystem(); installTheme();