/** * Ownership registry for `.pi/skills/` mirrors. * * Records which skill names AIWS has mirrored into `.pi/skills/` so that * stale cleanup (`pruneStalePiSkills`) can distinguish AIWS-managed mirrors * from user-custom directories. Persisted locally (`.pi/` is gitignored). */ export declare const PI_SKILL_REGISTRY_FILE = ".aiws-sync.json"; export interface PiSkillRegistry { version: 1; updatedAt: string; managed: string[]; } /** * Read the pi-skill ownership registry. Returns [] when missing or unparsable * (safe failure — callers must not delete anything they cannot attribute). */ export declare function readPiSkillRegistry(piDir: string): Promise; /** Atomically write the pi-skill ownership registry. */ export declare function writePiSkillRegistry(piDir: string, managed: string[]): Promise; /** * Read the names of first-level directories under `dir` (e.g. `.pi/skills/` * or template `.agents/skills/`). Returns [] when the dir is missing. */ export declare function listFirstLevelDirs(dir: string): Promise; /** * Compare two directories recursively (same rel file set + identical bytes). * Used to decide whether a `.pi/skills//` mirror is a pure copy of the * template dir (safe to prune) or a user-diverged override (keep). */ export declare function dirTreesEqual(a: string, b: string): Promise; /** * Clean up `.pi/skills//` mirrors that are no longer needed. * * Two cases are pruned: * 1. Redundant — the name still exists in the template's `.agents/skills/`; * Pi (>=0.84) auto-discovers project `.agents/skills/` dirs directly, so a * same-name `.pi/skills/` mirror only causes a skill-name collision at pi startup. Pruned when the mirror is byte-identical to the template dir. * 2. Stale — recorded in the ownership registry but the skill left the * template; removed as before. * * Safety rules: * - Redundant pruning requires the mirror to be byte-identical to the * template dir (a pure mirror). Diverged copies are kept with a warning. * - Stale pruning only touches names present in the ownership registry * (`.aiws-sync.json`); unregistered dirs are treated as user-custom and * never deleted. * - Deleted dirs are backed up file-by-file into an independent BackupSession * (`aiws rollback` restores them). * - dryRun prints `would remove` and does not modify anything. */ export declare function pruneStalePiSkills(workspaceRoot: string, templateDir: string | undefined, dryRun: boolean): Promise;