/** * Merge Orchestrator - Smart merge strategies for exploration results * * Handles merging winning exploration branches back to main codebase. * * Every git/gh invocation uses SafeExecutor.execute (spawn with an argument * array, no shell) rather than shell-string interpolation — `target_branch`, * commit messages, and conflicted file paths all originate from tool-call * arguments or a merge conflict's crafted filename, none of it sanitized for * shell metacharacters. `target_branch` is additionally validated as a * well-formed git ref before use, as defense-in-depth beyond array-form alone. */ export interface ConflictInfo { conflict_type: 'content' | 'delete' | 'rename'; file_path: string; our_version?: string; resolution_strategy?: 'manual' | 'ours' | 'theirs'; resolved: boolean; their_version?: string; } export interface MergeOptions { auto_resolve_conflicts: boolean; commit_message?: string; create_backup: boolean; create_pr?: boolean; delete_worktree: boolean; pr_body?: string; pr_title?: string; strategy: MergeStrategy; target_branch?: string; } export interface MergeResult { backup_branch?: string; commits_merged?: number; conflicts?: ConflictInfo[]; conflicts_detected: boolean; error?: string; files_changed?: number; merge_commit?: string; pr_url?: string; source_branch: string; strategy: MergeStrategy; success: boolean; target_branch: string; } export type MergeStrategy = 'direct' | 'rebase' | 'squash'; export interface MergeValidation { errors: string[]; valid: boolean; warnings: string[]; } /** * Main merge orchestrator */ export declare class MergeOrchestrator { private repoRoot; private stateManager; private worktreeManager; constructor(repoRoot?: string); /** Run a git command with argv passed literally — never through a shell. */ private runGit; /** Run a gh command with argv passed literally — never through a shell. */ private runGh; /** * Merge an exploration worktree back to target branch */ mergeExploration(explorationId: string, worktreeIndex: number, options?: Partial): Promise; /** * Set merge option defaults */ private setMergeDefaults; /** * Load and validate exploration */ private loadAndValidateExploration; /** * Log validation warnings */ private logValidationWarnings; /** * Prepare target branch */ private prepareTargetBranch; /** * Create backup if requested */ private createBackupIfRequested; /** * Handle merge conflicts */ private handleConflicts; /** * Create PR if requested */ private createPRIfRequested; /** * Cleanup if requested */ private cleanupIfRequested; /** * Update exploration state */ private updateExplorationState; /** * Build success result */ private buildSuccessResult; /** * Build error result */ private buildErrorResult; /** * Validate merge is possible */ private validateMerge; /** * Execute merge based on strategy */ private executeMerge; /** * Direct merge strategy (preserves commit history) */ private executeDirectMerge; /** * Squash merge strategy (single commit) */ private executeSquashMerge; /** * Rebase merge strategy (linear history) */ private executeRebaseMerge; /** * Detect merge conflicts */ private detectConflicts; /** * Attempt to auto-resolve conflicts */ private autoResolveConflicts; /** * Complete merge after conflict resolution */ private completeMerge; /** * Abort merge */ private abortMerge; /** * Create backup branch */ private createBackupBranch; /** * Get current branch */ private getCurrentBranch; /** * Checkout branch */ private checkoutBranch; /** * Create pull request */ private createPullRequest; /** * Cleanup worktree after merge */ private cleanupWorktree; /** * Count commits in a branch (since divergence from target) */ private countCommits; /** * Parse git stats output */ private parseGitStats; /** * Preview merge (dry run) */ previewMerge(explorationId: string, worktreeIndex: number, _targetBranch?: string): Promise<{ can_merge: boolean; commits_to_merge: number; conflicts: ConflictInfo[]; files_changed: number; }>; } //# sourceMappingURL=merge-orchestrator.d.ts.map