import { join } from "node:path"; import { fileURLToPath } from "node:url"; const EXTENSION_ID = "pi-permission-system"; /** * Bundle-level `config/` is the single source of truth for policy and hard * guards: paths resolve relative to this source file so the installed bundle * is read directly, with no deployment, seeding, or migration into the agent * dir. Only disposable runtime state (logs) stays under `/my-pi/`. */ const BUNDLE_CONFIG_DIR = fileURLToPath(new URL("../../config", import.meta.url)); const BUNDLE_MANAGED_DIR = "my-pi"; const BUNDLE_PERMISSION_DIR = "permission-system"; export const DEBUG_LOG_FILENAME = `${EXTENSION_ID}-debug.jsonl`; export const REVIEW_LOG_FILENAME = `${EXTENSION_ID}-permission-review.jsonl`; /** * Bundle-owned runtime directory under the agent dir — logs only. Stale files * left here from earlier deployments are ignored, never migrated. */ export function getGlobalConfigDir(agentDir: string): string { return join(agentDir, BUNDLE_MANAGED_DIR, BUNDLE_PERMISSION_DIR); } export function getGlobalConfigPath(): string { return join(BUNDLE_CONFIG_DIR, "pi-permission-policy.jsonc"); } export function getHardGuardConfigPath(): string { return join(BUNDLE_CONFIG_DIR, "pi-permission-hard-guards.jsonc"); } export function getGlobalLogsDir(agentDir: string): string { return join(getGlobalConfigDir(agentDir), "logs"); } /** * Directory holding project-scoped custom agent definition files. * * `/.pi/agents` is a Pi platform convention, also encoded by * `@gotgenes/pi-subagents`' `loadCustomAgents` (`config/custom-agents.ts`). * The two packages encode it independently — pi-permission-system has no * dependency on pi-subagents (ADR-0002) — so this is this package's * authoritative copy. */ export function getProjectAgentsDir(cwd: string): string { return join(cwd, ".pi", "agents"); }