import type { CheckoutRecord } from "@kenkaiiii/gg-engine/internal/core/checkout-record.js"; export interface BranchRow { name: string; current: boolean; /** Another worktree that has this branch checked out, or null. */ worktree: string | null; /** Last commit time, Unix seconds. */ updatedAt: number; } export interface BranchList { current: string | null; branches: BranchRow[]; } export type SwitchOutcome = { kind: "unchanged"; branch: string; } | { kind: "switched"; branch: string; previous: string | null; } | { kind: "moved"; branch: string; path: string; created: boolean; copied: string[]; }; /** A switch git refused; `message` is safe to show the user. */ export declare class BranchSwitchError extends Error { name: string; } /** Local branches, most recently committed first; `limit: null` lists all. */ export declare function listBranches(dir: string, limit?: number | null): Promise; /** A git command the user ran (through GG) failed; `message` is git's last lines. */ export declare class UserGitError extends Error { name: string; } export interface UserGitOptions { /** Written to stdin, which is then closed. */ input?: string; /** Extra environment on top of `process.env`. */ env?: Readonly>; timeoutMs?: number; } /** * Run git as the user would (hooks and LFS filters apply): this is their own * action. Still the resolved binary, never a `git.exe` planted in the repo root * (Windows searches the cwd first), and no console window. */ export declare function runUserGit(args: readonly string[], cwd: string, opts?: UserGitOptions): Promise; /** `~/.gg/worktrees/-/`, outside the repo, never an existing path. */ export declare function worktreePathFor(worktreesRoot: string, repoRoot: string, branch: string): Promise; /** * Copy the ignored local files a fresh checkout lacks (a worktree only gets * tracked files): those listed in `.worktreeinclude` (gitignore syntax, the * Claude Code / Conductor convention), else `.env` and `.env.*` at the root. * Only files git ignores are copied; dependencies are not. */ export declare function copyLocalFiles(fromRoot: string, toRoot: string): Promise; export interface SwitchRequest { /** The checkout this window works in. */ dir: string; branch: string; /** Create `branch` from the current commit. */ create: boolean; /** Other windows share this checkout: never switch it, use a worktree. */ isolate: boolean; /** Where new worktrees go (`~/.gg/worktrees`). */ worktreesRoot: string; } /** * Put this window on `branch`. In place when nobody else uses the checkout; * otherwise in the worktree that already has the branch, or a new one. */ export declare function switchBranch(req: SwitchRequest): Promise; export interface ResumeCheckout { /** Where the resumed conversation should work. */ cwd: string; /** What to tell its agent, or null when nothing changed for it. */ note: string | null; /** What to show the user in the chat, or null (see `noteCheckout`). */ notice?: string | null; } /** * Where a resumed conversation should open so it is back on the branch it * recorded (`record`), given the folder the window asked for: the folder, or * the worktree that has the branch checked out. Reopening a conversation never * writes to git: it switches no folder (other windows may use it) and creates * no worktree, since that runs the repo's hooks and a new worktree's setup * (an install) without the user asking. A branch checked out nowhere opens in * the folder, and the user is told to pick it in the Git panel, which makes its * worktree. A record from another repository is ignored. */ export declare function resolveResumeCheckout(requestedCwd: string, record: CheckoutRecord): Promise; /** What the agent is told after its window moved into a worktree. */ export declare function worktreeMoveNote(from: string, outcome: Extract): string;