/** * Git worktree isolation for parallel sub-agents. * * Each parallel agent gets its own worktree under `.phi/worktrees/` so its * writes never touch the main working tree. After the agent finishes, its diff * (against the base ref) is applied back onto the main working tree with * explicit conflict detection: when the main tree has moved on the same files * (typically because another agent was merged first), the merge returns a * conflict report containing BOTH diffs instead of silently overwriting. */ export declare const WORKTREE_ROOT: string; export interface Worktree { id: string; path: string; baseRef: string; } export interface MergeConflictInfo { /** Files touched by both the incoming worktree diff and the current main tree. */ files: string[]; /** The diff produced by the worktree being merged (incoming changes). */ incomingDiff: string; /** The diff of the main working tree against the same base (already-applied changes). */ currentDiff: string; } export interface MergeResult { ok: boolean; /** The incoming diff, when applied successfully. */ applied?: string; conflict?: MergeConflictInfo; } export declare function worktreePath(repoRoot: string, id: string): string; /** Create a detached worktree for `id` under .phi/worktrees/, based on baseRef. */ export declare function createWorktree(repoRoot: string, id: string, baseRef?: string): Worktree; /** * Merge a worktree's changes back onto the main working tree. * * Checks the worktree diff (tracked files, including commits made inside the * worktree) with `git apply --check` and every new untracked file BEFORE writing * anything, then applies them. A conflict therefore never leaves the main tree * half-merged: it returns an explicit report with both diffs. Never throws on * conflict; throws only on unexpected git failures. */ export declare function mergeWorktree(repoRoot: string, id: string): MergeResult; /** Remove a worktree and its directory (forced: pending changes are discarded). */ export declare function removeWorktree(repoRoot: string, id: string): void; //# sourceMappingURL=worktree.d.ts.map