import { type GitRunner } from "./git-process.ts"; export interface WorktreeInfo { path: string; cwd: string; branch: string; repoRoot: string; baseCommit: string; } export type WorktreePayload = { outcome: "pruned"; path: string; branch: string; } | { outcome: "retained"; path: string; branch: string; commits: number; dirty: boolean; } | { outcome: "recovery"; path: string; branch: string; note: string; commits?: number; dirty?: boolean; }; export declare class WorktreeSetupError extends Error { name: string; readonly worktree: WorktreeInfo; constructor(message: string, worktree: WorktreeInfo); } /** * Creates one worktree per child from parent HEAD. Returns undefined only when * the workspace is not a git repository or HEAD is unborn — callers degrade * silently to the shared working directory. Setup failures in a real git * repository (unwritable path, stale branch, git lock) throw so an isolated * role never silently loses its isolation. */ export declare function createChildWorktree(cwd: string, childId: string, run?: GitRunner, signal?: AbortSignal, onPrepared?: (worktree: WorktreeInfo) => Promise): Promise; export interface WorktreeDirtyInspection { dirty: boolean; failure?: string; initializedSubmodules?: boolean; } export declare function inspectIndexFlags(cwd: string, run?: GitRunner, signal?: AbortSignal): Promise<{ hidden: boolean; failure?: string; }>; /** Proves a worktree has no tracked, untracked, ignored, index-hidden, or nested submodule work. */ export declare function inspectWorktreeDirty(cwd: string, run?: GitRunner): Promise; /** * Inspects and possibly prunes a child worktree after it finishes. Commit count * reads the dedicated branch and refuses to prune when checkout HEAD no longer * names it; the clean-tree proof includes untracked, ignored, and submodule * changes despite repository config. A worktree with zero branch commits and a * clean tree is removed only when every probe succeeds and base_commit was * recorded; any uncertainty preserves work and omits unknown measurements. */ export declare function finalizeChildWorktree(info: WorktreeInfo, run?: GitRunner): Promise; /** Context block telling the child to work inside its isolated worktree. */ export declare function worktreeContextNote(info: WorktreeInfo): string;