/** * [WHO]: WorktreeManager class - temporary workspace and git worktree management * [FROM]: Depends on node:fs/promises, node:path, node:child_process * [TO]: Consumed by ./index.ts, core/sub-agent/*, extensions/builtin/subagent/*, extensions/builtin/team/* * [HERE]: core/workspace/worktree-manager.ts - workspace management for SubAgents */ export interface WorkspacePath { /** Absolute path to the workspace */ readonly path: string; /** Type of workspace */ readonly type: "temp" | "worktree"; } export interface WorkspaceChange { path: string; status: "added" | "modified" | "deleted"; } /** * Manager for creating and disposing workspaces for SubAgents. * Provides temporary directories and git worktrees. */ export declare class WorktreeManager { private tempDirs; private worktrees; private snapshots; /** * Create a temporary workspace. * Copies seed files to a new temp directory. * @param seedFiles Files to copy to the temp workspace * @param prefix Prefix for the temp directory name */ createTempWorkspace(seedFiles?: string[], prefix?: string, sourceCwd?: string): Promise; /** * Create a temporary snapshot workspace by copying the current project tree. * Used as a fallback when git worktree is unavailable. */ createSnapshotWorkspace(sourceCwd: string, prefix?: string): Promise; /** * Create a git worktree for the given branch. * @param branch Branch name for the worktree * @param cwd Working directory for git operations */ createGitWorktree(branch?: string, cwd?: string): Promise; /** * List changed files inside a workspace. */ listChangedFiles(workspace: WorkspacePath): Promise; listChanges(workspace: WorkspacePath): Promise; writePatch(workspace: WorkspacePath, outputPath: string): Promise; applyChanges(workspace: WorkspacePath, targetCwd: string): Promise; /** * Dispose of a workspace. * Removes temp directories and worktrees. * @param workspace The workspace to dispose */ dispose(workspace: WorkspacePath): Promise; /** * Get all active temp directories. */ getActiveTempDirs(): string[]; /** * Clean up all temp directories. */ disposeAll(): Promise; private resolveWorktreeOwner; private parseGitStatusLine; private collectSnapshotChanges; private collectWorkspaceFiles; private shouldIgnoreRelativePath; } /** * Default global worktree manager instance. */ export declare const worktreeManager: WorktreeManager;