import { join } from "node:path"; const EXTENSION_ID = "pi-permission-system"; /** * Bundle-owned config tree under the agent directory: install.sh / update.sh * delete and rebuild `my-pi/` wholesale on every run, so policy, hard guards, * and logs all live beneath it. Files at the former * `extensions/pi-permission-system/` location are ignored — never migrated. */ const BUNDLE_CONFIG_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`; export function getGlobalConfigDir(agentDir: string): string { return join(agentDir, BUNDLE_CONFIG_DIR, BUNDLE_PERMISSION_DIR); } export function getGlobalConfigPath(agentDir: string): string { return join(getGlobalConfigDir(agentDir), "policy.jsonc"); } export function getHardGuardConfigPath(agentDir: string): string { return join(getGlobalConfigDir(agentDir), "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"); } export function getLegacyGlobalPolicyPath(agentDir: string): string { return join(agentDir, "pi-permissions.jsonc"); } export function getLegacyExtensionConfigPath(extensionRoot: string): string { return join(extensionRoot, "config.json"); }