/** * Pi-free git worktree primitives for subagent isolation. * * Each subagent run that edits code gets a DETACHED worktree under * /subagent-worktrees/, branched from HEAD. On completion, * captureHandoff() snapshots the worktree's full delta (including untracked * files, which a plain `git diff HEAD` silently misses) as an untruncated * patch file; removeWorktree() tears the worktree down. * * Every git call is spawnSync with a generous timeout and never throws — * failures surface as error strings (or empty results) so callers can treat * worktree setup/teardown as best-effort. */ /** Repo toplevel for cwd, or null when cwd isn't inside a git repo. Never throws. */ export declare function findRepoRoot(cwd: string): string | null; /** * Create a detached worktree for runId at /subagent-worktrees/ * from HEAD. Leftovers from a prior attempt with the same runId are removed * first; a failed add is retried once after pruning stale registrations. */ export declare function addWorktree(repoRoot: string, runId: string): { path: string; } | { error: string; }; /** * Snapshot the worktree's full delta against HEAD. Stages everything first * (`git add -A`) so UNTRACKED files are captured in the cached diff — the fix * for `git diff HEAD` missing newly created files. The patch is written * UNTRUNCATED to patchPath; when nothing changed, no file is written and the * returned patchPath is null. */ export declare function captureHandoff(worktreePath: string, patchPath: string): { status: string; patchPath: string | null; changedFiles: number; }; /** * Remove a worktree. Prefers `git worktree remove --force` when repoRoot is a * live repo (keeps git's worktree registry clean); falls back to rmSync. * Never throws. */ export declare function removeWorktree(repoRoot: string | null, wtPath: string): void;