/** * One entry of `git worktree list --porcelain`. `branch` is the short name * (`arcs/plan-x`) or null for bare/detached entries; `head` is null when git * did not report a HEAD line. */ export interface WorktreeInfo { path: string; head: string | null; branch: string | null; bare: boolean; detached: boolean; } /** Result of a successful `git worktree add`. */ export interface AddedWorktree { path: string; branch: string; } /** Branch name for a plan's worktree: `arcs/`. The arcs/ * namespace keeps agent branches out of the way of human branches. */ export declare function planBranchName(planId: string): string; /** Sibling convention: `/-worktrees`. Sibling (not * inside) so worktrees never show up in the main repo's globs or watchers. */ export declare function defaultWorktreeRoot(repoPath: string): string; /** Where a plan's worktree lives by default: `/`. */ export declare function resolvePlanWorktreePath(repoPath: string, planId: string): string; /** * Parse `git worktree list --porcelain`: newline records separated by blank * lines, each field `key value` with the value possibly containing spaces * (paths), so split on the FIRST space only. Empty output → []. */ export declare function listWorktrees(repoPath: string): Promise; /** * Create a worktree via `git worktree add`. With `createBranch` the branch is * created first (`-b []`); otherwise `` must * already exist and is checked out. Returns null on any failure — including * branch-already-checked-out, which callers detect up front via * `isBranchCheckedOutInAnotherWorktree`. */ export declare function addWorktree(repoPath: string, options: { path: string; branch: string; baseRef?: string; createBranch?: boolean; }): Promise; /** Remove a worktree (`git worktree remove [--force]`). True on success. */ export declare function removeWorktree(repoPath: string, path: string, force?: boolean): Promise; /** Drop stale worktree admin entries (`git worktree prune`). True on success. */ export declare function pruneWorktrees(repoPath: string): Promise; /** * True when `branch` is checked out in any non-bare worktree other than * `excludePath` — the mutual-exclusion primitive: two orchestrators must not * dispatch onto the same plan branch. * * Fails CLOSED: if the listing cannot be read, returns TRUE (treat as * contended). A false negative here lets two writers share a branch; a false * positive merely blocks a dispatch that `ensure` would fail anyway. */ export declare function isBranchCheckedOutInAnotherWorktree(repoPath: string, branch: string, excludePath?: string): Promise; /** * Count commits on the worktree's HEAD not reachable from its upstream, or — * when no upstream is configured — from `main`/`master`. 0 means safe to * prune; null means unknown (no upstream AND no base branch found, detached * HEAD, or any git failure), which callers must treat as NOT safe. */ export declare function countUnmergedCommits(worktreePath: string): Promise; /** * Short branch name currently checked out in `worktreePath`, or null when * detached (a detached HEAD is not a branch) or on any failure. */ export declare function currentBranch(worktreePath: string): Promise; //# sourceMappingURL=worktree.d.ts.map