export type WorktreeMode = { enabled: false; } | { enabled: true; detached: true; name: null; } | { enabled: true; detached: false; name: string; }; export interface ParsedWorktreeMode { mode: WorktreeMode; remainingArgs: string[]; } export interface WorktreePlanInput { cwd: string; scope: 'launch' | 'team' | 'autoresearch'; mode: WorktreeMode; teamName?: string; workerName?: string; worktreeTag?: string; } export interface PlannedWorktreeTarget { enabled: true; scope: 'launch' | 'team' | 'autoresearch'; repoRoot: string; worktreePath: string; detached: boolean; baseRef: string; branchName: string | null; } export interface EnsureWorktreeResult { enabled: true; repoRoot: string; worktreePath: string; detached: boolean; branchName: string | null; created: boolean; reused: boolean; createdBranch: boolean; /** True when the worktree had uncommitted changes at launch time. */ dirty?: boolean; } export interface EnsureWorktreeOptions { allowDirtyReuse?: boolean; } export declare function isGitRepository(cwd: string): boolean; export declare function isWorktreeDirty(worktreePath: string): boolean; export declare function readWorkspaceStatusLines(cwd: string): string[]; export declare function assertCleanLeaderWorkspaceForWorkerWorktrees(cwd: string): void; export declare function parseWorktreeMode(args: string[]): ParsedWorktreeMode; export declare function planWorktreeTarget(input: WorktreePlanInput): PlannedWorktreeTarget | { enabled: false; }; export declare function ensureWorktree(plan: PlannedWorktreeTarget | { enabled: false; }, options?: EnsureWorktreeOptions): EnsureWorktreeResult | { enabled: false; }; export interface RollbackWorktreeOptions { /** Shutdown requires a clean checkout; provisioning and approved cleanup may discard it. */ force?: boolean; /** When true, skip `git branch -D` for branches created during provisioning (ralph policy). */ skipBranchDeletion?: boolean; } /** * True when `candidate` is `root` or a descendant of it. Uses the platform's * path rules, so Windows separators, drive letters, and case are handled and a * sibling such as `/repo/wt2` is not treated as inside `/repo/wt`. */ export declare function isPathWithin(candidate: string, root: string, platform?: NodeJS.Platform): boolean; /** * Replay any pending submodule recovery journals at the start of shutdown. * If the process was killed after moving submodules but before creating placeholders, * the recovery.json file persists in the .git/omx-submodule-recovery directory. * Replaying it ensures submodules are restored before any git status/add operations. * Completed archives are skipped (marked with .completed) to avoid destroying * worker-local commits that were moved from a removed worktree. * Returns true if all recovery journals were successfully replayed or didn't exist; * returns false if any recovery remained unresolved, indicating shutdown should abort. */ export declare function replaySubmoduleRecovery(worktreePath: string, repoRoot: string): Promise; /** * Mark a recovery directory as completed so it won't be replayed. * Called after a worktree removal succeeds to indicate the checkouts were * successfully moved but we're destroying the worktree anyway. */ export declare function markSubmoduleRecoveryCompleted(recoveryDir: string): Promise; /** * Recheck all submodule placeholders immediately before worktree removal. * A watcher may have repopulated a submodule path after the placeholder was created, * and those writes may not be detected as dirty by git status. Verify all placeholders * are still empty to prevent silent data loss. * Uses the pre-move checkout list because after moves, `git submodule foreach` * returns no paths (the checkouts are now in the recovery archive). */ export declare function recheckSubmodulePlaceholdersBeforeRemoval(worktreePath: string, originalCheckouts: string[]): Promise; export declare function rollbackProvisionedWorktrees(results: Array, options?: RollbackWorktreeOptions): Promise; export declare function removeWorktreeForce(repoRoot: string, worktreePath: string): Promise; //# sourceMappingURL=worktree.d.ts.map