/** * Git worktree wrappers (AC-9, AC-10, AC-17, NFR-5). * * `createWorktree` creates branch + worktree in one step, always based on * main, so an in-flight session in the primary checkout is never moved * off its branch (idea goal 2). Callers export AIDLC_WORKTREE=1 before * firing on-instance-start actions so the shipped branch action no-ops * (AC-10). * * Removal order (AC-17, design F6): worktree remove FIRST — the claim is * released only after removal succeeds, so a dirty worktree keeps its * instance locked. */ /** Sanitize a path component to [a-z0-9-] (NFR-5). */ export declare function sanitizeComponent(raw: string): string; export interface CreateWorktreeOpts { prefix: string; name: string; worktreeDir: string; projectRoot: string; /** YYYYMMDD stamp; injectable for tests. */ dateStamp?: string; } export interface WorktreeRef { branch: string; /** The worktree's top — the directory git, and so the registry, know it by. */ path: string; /** The worktree's copy of the project; `path` itself for a project at the repository root. */ projectPath: string; } /** * `git worktree add` failed. The message is git's; `left` names what the failed * creation could not remove, for the caller's usual note (start-failure-leaves-branch/AC-3). */ export declare class WorktreeCreateError extends Error { readonly left: string[]; constructor(message: string, left: string[]); } /** * Create branch and worktree in one step, based on main (AC-9). Fails — * never reuses — when the branch or target directory already exists (AC-24). * * `worktreeDir` is resolved against the checkout's top, not the project root. They * are the same directory at the repository root; for a project below it the project * root put the default `../` inside the checkout (worktree-start-in-nested-project/AC-2). */ export declare function createWorktree(opts: CreateWorktreeOpts): WorktreeRef; /** * Remove a worktree and branch this process has just created, for a creation that * failed part way (failed-start-leaves-worktree/AC-3, AC-6). * * Only for a `ref` that `createWorktree` returned in this process: `--force` because * the worktree holds nothing but files the start wrote, `branch -D` because the * branch has no commits of its own. `removeWorktree` is the one for finished work. * Each step is tried on its own and nothing is thrown, so the caller's own error * stays the one reported (AC-7). * * @returns One line per thing left behind; empty when both are gone. */ export declare function discardWorktree(ref: WorktreeRef, projectRoot: string): string[]; /** * Delete a branch this process has just created and nothing else has used: `-D` * because it has no commits of its own. Throws nothing. * * @returns One line naming the branch when it could not be deleted; empty when it is gone. */ export declare function dropBranch(branch: string, projectRoot: string): string[]; export interface RemoveReport { removedWorktree: boolean; deletedBranch: boolean; reason?: string; } /** * Remove a worktree and delete its branch iff merged into main (AC-17). * A dirty worktree fails removal (no --force) and reports; the caller * must NOT release the claim in that case (design F6). */ export declare function removeWorktree(ref: WorktreeRef, projectRoot: string): RemoveReport; /** List worktrees known to git (for status cross-checks, AC-18). */ export declare function listWorktrees(projectRoot: string): Array<{ path: string; branch: string | null; }>; //# sourceMappingURL=worktree.d.ts.map