export interface WorktreeRow { path: string; /** Checked-out branch, or null when detached. */ branch: string | null; /** Made by GG Coder (under ~/.gg/worktrees): removable from Home. */ managed: boolean; /** The folder is gone (deleted outside git). */ missing: boolean; /** Uncommitted changes in it. */ dirty: number; /** Commits on its branch that the main folder's branch doesn't have. */ ahead: number; /** * On a detached HEAD: commits no branch, tag or remote branch has. Removing * the worktree leaves them unreachable, so it asks first. 0 on a branch. */ unreferenced: number; } export interface WorktreeList { /** The repository's main folder. */ mainPath: string; /** The branch the main folder has checked out, or null when detached. */ mainBranch: string | null; worktrees: WorktreeRow[]; } interface Porcelain { path: string; head: string | null; branch: string | null; bare: boolean; prunable: boolean; } export declare function parseWorktreePorcelain(text: string): Porcelain[]; /** * The project a GG-made worktree belongs to, or null for any other folder. The * sidebar lists only these under their project, as the session lists do. */ export declare function ggWorktreeProject(cwd: string, worktreeOf: string | null, managedRoot: string): string | null; /** The repository's main folder for any checkout of it (itself for the main one), or null. */ export declare function mainCheckoutOf(dir: string): Promise; /** Every linked worktree of the repository `dir` belongs to, with its status. */ export declare function listWorktrees(dir: string, managedRoot: string): Promise; /** * The GG-made worktrees of the repo at `dir`, by real path: what a project's * session list needs, from one git call. {@link listWorktrees} also counts each * one's changes and commits, a few git calls per worktree. */ export declare function managedWorktreePaths(dir: string, managedRoot: string): Promise; /** A removal git or the safety checks refused; `message` is safe to show. */ export declare class WorktreeRemoveError extends Error { /** Uncommitted changes that removing would lose (confirm with `force`). */ readonly dirty: number; /** Detached commits no branch has that removing would lose (confirm with `force`). */ readonly unreferenced: number; name: string; constructor(message: string, /** Uncommitted changes that removing would lose (confirm with `force`). */ dirty?: number, /** Detached commits no branch has that removing would lose (confirm with `force`). */ unreferenced?: number); } /** * Remove a GG-made worktree's folder. The branch and its commits stay. Refuses * the user's own worktrees, one with uncommitted changes or (on a detached * HEAD) commits no branch has unless `force`, one a window is open in * (`openWindows`), and one whose setup is still running (`setupRunning`): it * holds files open there, and Windows can't delete those (EBUSY). */ export declare function removeWorktree(options: { dir: string; target: string; managedRoot: string; force: boolean; openWindows: number; setupRunning?: boolean; }): Promise; /** A GG-made worktree nobody has touched for this long is removed at launch. */ export declare const IDLE_WORKTREE_DAYS = 14; /** * Remove GG-made worktrees under `managedRoot` untouched for 14 days. Each * goes through `removeWorktree` without force, so one with uncommitted * changes, commits no branch has, an open window or a running setup stays, * as does the root of a Fix all run in progress. The branch and its commits * stay, so the worktree can be added again. */ export declare function pruneIdleWorktrees(options: { managedRoot: string; openWindowsIn: (root: string) => Promise; setupRunningIn: (worktree: string) => Promise; /** Checkout roots a Fix all run is working in or waiting on. */ busyRoots: readonly string[]; idleDays?: number; now?: number; }): Promise<{ removed: string[]; kept: Array<{ path: string; reason: string; }>; }>; /** * Whether the process tree a setup started as `pid` still runs. A background * task leads its own process group on POSIX, so the group answers for the * install's children too; on Windows the stop kills the whole tree. */ export declare function processTreeRunning(pid: number): boolean; /** * The setup processes new worktrees run, daemon-wide (the window that started * one may already be closed, its setup still stopping), so removing a worktree * can wait for its setup to let go of the folder. */ export declare class WorktreeSetups { private readonly pids; started(worktree: string, pid: number): Promise; /** * Wait up to `timeoutMs` for the setup running in `worktree` to exit. True * when it still runs after that; false when it finished or there is none. */ stillRunning(worktree: string, timeoutMs?: number, pollMs?: number): Promise; } export interface SetupCommand { command: string; /** Where it came from, for the agent and the picker ("pnpm-lock.yaml"). */ source: string; } export declare const WORKTREE_CONFIG: string; /** * What a new worktree at `root` runs once to become runnable: `setup` from the * project's `.gg/worktree.json` (an empty string or `false` turns it off), * else the install command for its lockfile, else nothing. */ export declare function resolveSetupCommand(root: string): Promise; /** The install command for the lockfile in `dir`, or null when it has none. */ export declare function lockfileSetup(dir: string): SetupCommand | null; /** The agent's note about its new worktree's setup. */ export declare function setupNote(setup: SetupCommand | null, taskId: string | null): string; export {};