export interface WorktreeInfo { /** The worktree's top directory. */ path: string; branch: string; /** Top directory of the checkout it was made from. */ repo: string; /** The commit it was made from. */ base: string; } export interface CreatedWorktree extends WorktreeInfo { /** Where the session starts: the dispatch directory's place inside the worktree. */ cwd: string; /** The dispatch checkout had uncommitted changes (they are not in the worktree). */ sourceDirty: boolean; /** M15: ignored files and folders copied in by .worktreeinclude. */ included: string[]; } export declare const INCLUDE_FILE = ".worktreeinclude"; /** What `dir`'s .worktreeinclude names, or `includeFile` instead (the source checkout's). */ export declare function includedEntries(dir: string, includeFile?: string): string[]; export declare const WORKTREES_DIR: string; export declare const BRANCH_PREFIX = "roost/"; export declare class WorktreeError extends Error { } /** The checkout's top directory, or undefined outside a git repository. */ export declare function gitToplevel(cwd: string): string | undefined; /** Lowercase ASCII words of a session name, for directory and branch names. */ export declare function slugOf(name: string): string; /** Make a worktree and branch for a new session started from `cwd`. */ export declare function createWorktree(cwd: string, name: string, rand?: () => string): CreatedWorktree; /** * Undo createWorktree after a dispatch the daemon refused. Even then only what holds * nothing: a clean worktree (ignored files count), a branch still at its base. */ export declare function discardWorktree(w: WorktreeInfo): void; /** * Is this a worktree pi-roost made: the shape of every field, the place under the main * checkout's .pi/worktrees, one repository, and the branch checked out there. The daemon * checks it at dispatch and again before rm deletes anything. */ export declare function validWorktree(w: unknown): Promise; export declare const isInside: (dir: string, root: string) => boolean; export interface WorktreeStatus { exists: boolean; /** Uncommitted or untracked changes. */ dirty: boolean; /** Files git ignores (.env, build output, node_modules): rm would delete them. */ ignored: boolean; /** Commits on the branch beyond base (null when git cannot say). */ ahead: number | null; /** The branch still points at base: deleting it loses nothing. */ atBase: boolean; } export declare function worktreeStatus(w: WorktreeInfo): Promise; /** The last line of a child's report (M9). */ export declare function worktreeLine(w: WorktreeInfo, st: WorktreeStatus): string; /** The worker's system-prompt note. */ export declare function worktreeNote(w: WorktreeInfo): string; export interface CleanupResult { path: string; branch: string; removed: boolean; branchKept: boolean; reason?: string; } /** * After rm: remove what holds no work. `inUse`: another job runs inside the worktree. * Never deletes uncommitted changes or commits that are only on the branch. */ export declare function cleanupWorktree(w: WorktreeInfo, inUse: boolean): Promise; /** What rm did with a session's worktree, for the CLI and the view. */ export declare function cleanupText(r: CleanupResult): string; /** Where a worktree session is shown relative to (its repo), for messages. */ export declare const worktreeLabel: (w: WorktreeInfo) => string; /** M26: what a session changed in its worktree since it started (commits and uncommitted work). */ export interface WorktreeChange { files: number; insertions: number; deletions: number; /** New files git does not track yet (not in the counts above). */ untracked: number; } export declare function worktreeChange(path: string, base: string): Promise; /** "3 files +40 −12 · 1 new", or "no changes". */ export declare function changeText(c: WorktreeChange): string;