/** * GitWorktreeManager - Manages git worktrees for multi-variant RL execution. * * Provides lifecycle management for isolated workspaces where competing agents * can make independent changes without interference. Supports: * - Git worktree creation (preferred) with automatic cleanup * - Filesystem copy fallback for non-git repos * - Cross-variant diff tracking * - Branch isolation for parallel execution */ import type { UpgradeVariant } from './repoUpgradeOrchestrator.js'; export interface WorktreeInfo { variant: UpgradeVariant; path: string; type: 'worktree' | 'copy' | 'original'; branch?: string; commit?: string; createdAt: number; } export interface WorktreeManagerOptions { /** Base working directory (the original repo) */ baseDir: string; /** Session ID for naming worktrees */ sessionId?: string; /** Skip directories when creating filesystem copies */ skipDirs?: string[]; /** Create isolated branches for each variant */ createBranches?: boolean; /** Branch prefix for variant branches */ branchPrefix?: string; } export interface VariantDiff { variant: UpgradeVariant; filesChanged: string[]; insertions: number; deletions: number; diff: string; } export interface CrossVariantComparison { primary: VariantDiff; refiner?: VariantDiff; commonFiles: string[]; conflictingFiles: string[]; } export declare class GitWorktreeManager { private readonly baseDir; private readonly sessionId; private readonly skipDirs; private readonly createBranches; private readonly branchPrefix; private readonly worktrees; private isGitRepo; private baseCommit; constructor(options: WorktreeManagerOptions); /** * Initialize the manager and detect git repo status. */ initialize(): Promise; /** * Create an isolated workspace for a variant. */ createVariantWorkspace(variant: UpgradeVariant): Promise; /** * Create a git worktree for the variant. */ private createGitWorktree; /** * Create a filesystem copy for non-git repos or when worktree fails. */ private createFilesystemCopy; /** * Get the workspace path for a variant. */ getWorkspacePath(variant: UpgradeVariant): string | undefined; /** * Get all workspace roots as a record. */ getWorkspaceRoots(): Partial>; /** * Get info about a variant's workspace. */ getWorktreeInfo(variant: UpgradeVariant): WorktreeInfo | undefined; /** * Compute diff for a variant's changes since base commit. */ getVariantDiff(variant: UpgradeVariant): Promise; /** * Compute diff for non-git repos by tracking file changes. */ private computeNonGitDiff; /** * Compare changes between primary and refiner variants. */ compareVariants(): Promise; /** * Apply the winning variant's changes to the primary workspace. */ applyWinnerChanges(winner: UpgradeVariant): Promise; /** * Clean up all created worktrees and copies. */ cleanup(): Promise; /** * Run a command in a specific variant's workspace. */ runInWorkspace(variant: UpgradeVariant, command: string, options?: { timeout?: number; }): Promise<{ stdout: string; stderr: string; exitCode: number; }>; /** * Get status summary of all workspaces. */ getStatusSummary(): string; /** * Check if git worktrees are available. */ get supportsWorktrees(): boolean; /** * Get the base commit that all variants started from. */ get baseCommitHash(): string | null; } //# sourceMappingURL=gitWorktreeManager.d.ts.map