/** * Worktree merge — squash-merge an agent's worktree branch back into the base branch. * * Strategy: * 1. In the worktree, check `git status` for any uncommitted changes * - If dirty, commit them on the worktree branch first * 2. Squash all commits on the worktree branch (since its divergence from * the base) into a single commit * 3. Rebase that squashed commit onto the base branch * 4. On success: switch the main repo to the base branch and fast-forward merge * 5. On conflict: abort the rebase, leave the worktree in conflicted state, * return conflict info to the parent agent for resolution * * This is the inverse of Worktrunk's `wt merge`: a fully-automatic merge * that only succeeds for clean rebase. Conflicts bubble up. */ import { join } from "node:path"; import type { WorktreeManager } from "#src/worktree-manager"; /** Result of attempting a merge. */ export type MergeResult = { kind: "merged"; /** The commit SHA of the squashed merge commit. */ commit: string; /** Number of files changed by the merge. */ filesChanged: number; } | { kind: "conflicted"; /** Files that conflicted during the rebase. */ conflictedFiles: string[]; /** Absolute path to the worktree (preserved for inspection). */ worktreePath: string; /** Branch that was being merged. */ branch: string; } | { kind: "skipped"; /** Human-readable reason. */ reason: string; }; /** * Try to merge a worktree branch into the base branch using squash + rebase + fast-forward. * * @param manager - The WorktreeManager rooted at the main repo * @param branch - The worktree branch to merge * @param baseBranch - The branch to merge into (defaults to "main") * @returns MergeResult describing what happened */ export declare function tryMerge(manager: WorktreeManager, branch: string, baseBranch?: string): MergeResult; /** * Check whether a worktree has any changes (committed or uncommitted) * relative to the base branch. Used to skip merge when no work was done. */ export declare function worktreeHasChanges(manager: WorktreeManager, branch: string, baseBranch?: string): boolean; export { join }; //# sourceMappingURL=worktree-merge.d.ts.map