diff --git a/src/commands/helpers.ts b/src/commands/helpers.ts index fdaba79..8dfa7b8 100644 --- a/src/commands/helpers.ts +++ b/src/commands/helpers.ts @@ -82,7 +82,17 @@ export async function teardownSession(root: string, branch: string, worktree: st } /** Lock files to skip AI resolution — accept theirs and move on (basename match so `packages/foo/bun.lock` is also covered). */ -const SKIP_RESOLVE = new Set(["bun.lock", "Cargo.lock"]) +const SKIP_RESOLVE = new Set([ + "bun.lock", + "Cargo.lock", + "package-lock.json", + "yarn.lock", + "pnpm-lock.yaml", + "go.sum", + "Gemfile.lock", + "composer.lock", + "poetry.lock", +]) /** Resolve conflict markers in files using Claude, then stage them. */ export async function resolveConflicts( @@ -95,10 +105,7 @@ export async function resolveConflicts( onFile(file, i + 1, files.length) if (SKIP_RESOLVE.has(basename(file))) { - const result = await $`git checkout --theirs -- ${file}`.cwd(cwd).nothrow().quiet() - if (result.exitCode !== 0) { - throw new Error(`Failed to resolve lock file ${file}: ${result.stderr.toString().trim()}`) - } + await git.checkoutTheirs(file, cwd) await git.stageFile(file, cwd) continue } @@ -111,7 +118,7 @@ export async function resolveConflicts( ) if (resolved.exitCode !== 0) { - throw new Error(`Claude failed to resolve ${file}: ${resolved.stderr}`) + throw new Error(`Claude failed to resolve ${file}: ${resolved.stderr.toString().trim()}`) } await Bun.write(join(cwd, file), resolved.stdout.trimEnd() + "\n") diff --git a/src/git.ts b/src/git.ts index 810146b..3f55b02 100644 --- a/src/git.ts +++ b/src/git.ts @@ -133,6 +133,14 @@ export async function commit(message: string, cwd: string): Promise { } } +/** Accept "theirs" version of a conflicted file. */ +export async function checkoutTheirs(file: string, cwd: string): Promise { + const result = await $`git checkout --theirs -- ${file}`.cwd(cwd).nothrow().quiet() + if (result.exitCode !== 0) { + throw new Error(`Failed to checkout theirs for ${file}: ${result.stderr.toString().trim()}`) + } +} + /** Stage a file. */ export async function stageFile(file: string, cwd: string): Promise { const result = await $`git add ${file}`.cwd(cwd).nothrow().quiet()