/** * Migration helpers extracted from `reconcile-service.ts` * 800-line cap. Behaviour-preserving verbatim move. */ /** * * Move the legacy runtime files at: * - `.peaks/.session.json` * - `.peaks/.active-skill.json` * - `.peaks/sop-state/` * into their new canonical home at: * - `.peaks/_runtime/session.json` * - `.peaks/_runtime/active-skill.json` * - `.peaks/_runtime/sop-state/` * * Behavior: * - Idempotent: re-running on a tree that is already on the new * layout produces `migratedFiles: []`. * - Best-effort: uses `fs.renameSync` (atomic on POSIX, best-effort * on Windows) and falls back to `copyFileSync` + `unlinkSync` if * rename throws (e.g. cross-device move on Windows). Errors are * collected per file and returned in the `errors` array so the * reconcile envelope can surface them without blocking the rest of * the migration. * - Creates `.peaks/_runtime/` on demand if any of the old paths * are present. * * @returns `{ migratedFiles, errors }`. `migratedFiles` lists the * *old* relative paths (e.g. `.peaks/.session.json`) that were * successfully moved, in move order. `errors` lists per-file * failures with the old path and a human-readable message. */ export declare function migrateOldRuntimeState(projectRoot: string): { migratedFiles: string[]; errors: Array<{ path: string; message: string; }>; }; /** * * Move the legacy per-session sub-agent state files at: * - `.peaks/_runtime//system/subagent-progress.json` * - `.peaks/_runtime//system/progress-spawn.json` * into the new canonical home at: * - `.peaks/_sub_agents//subagent-progress.json` * - `.peaks/_sub_agents//progress-spawn.json` * * Behavior: * - Idempotent: re-running on a tree that is already on the new layout * produces `migratedFiles: []`. * - Best-effort: uses `fs.renameSync` and falls back to `copyFileSync + * unlinkSync` if rename throws (e.g. cross-device move on Windows). * - Empty `/system/` dir removal (R-2 guard): the legacy `system/` * subdir is only removed when it has zero other files, so a tree where * the user had unrelated content in `system/` is left untouched. * - New-path-wins: when both old and new files exist, the old file is * removed (the new path is authoritative). * * Walks every discovered session — not just the canonical one — so a user * with 6 pre-migration sessions gets all of them migrated in one reconcile * pass. * * @returns `{ migratedFiles, errors }`. `migratedFiles` lists the *old* * relative paths (e.g. `.peaks/_runtime//system/subagent-progress.json`) that * were successfully moved. `errors` lists per-file failures. */ export declare function migrateSubAgentState(projectRoot: string): { migratedFiles: string[]; errors: Array<{ path: string; message: string; }>; };