feat(ai): add AI-assisted conflict resolution#21
Merged
Conversation
- `dub ai resolve` command w/ Gemini via Vercel AI SDK - `dub continue --ai` shorthand for conflict detection + resolution - Interactive batch/per-file review with unified diff preview - Scope warnings for large conflict sets (>10 files, >5000 lines) - Path traversal & duplicate resolution validation - 1 automatic retry on continued conflicts, then hand back to user - Dry-run mode and abort support - SIGINT-safe with conflict state preservation
c53d5fd to
d4fa77a
Compare
There was a problem hiding this comment.
Pull request overview
Adds an AI-assisted merge conflict resolver to DubStack, integrating Gemini via the Vercel AI SDK and wiring it into the CLI as dub ai resolve plus an optional dub continue --ai flow.
Changes:
- Introduces
dub ai resolvewith interactive apply/review/abort and dry-run diff previews. - Adds conflict context collection (conflicted files, markers, relevant git log, restack progress) for prompting.
- Extends
dub continuewith--aito invoke AI resolution when unresolved conflicts are detected.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/lib/conflict-ui.ts | Implements diff preview rendering, interactive prompting, path validation, and applying resolutions. |
| src/lib/conflict-ui.test.ts | Adds unit tests for diffing, preview output, and applying resolutions. |
| src/lib/conflict-context.ts | Collects conflict state and contextual metadata for AI prompting. |
| src/lib/conflict-context.test.ts | Adds integration-style tests using real repos/rebase conflicts. |
| src/index.ts | Registers dub ai resolve and adds dub continue --ai flag. |
| src/commands/continue.ts | Implements --ai probe + delegation to AI resolver. |
| src/commands/continue.test.ts | Tests continueCommand behavior with --ai. |
| src/commands/ai-resolve.ts | Orchestrates AI streaming, parsing, interactive flow, retry, and continue/abort integration. |
| src/commands/ai-resolve.test.ts | Adds unit tests for aiResolve orchestration and flows. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…lidation - Add symlink rejection + ENOENT check in applyResolution - Add symlink/path.resolve guard in gatherConflictContext - Cap computeDiff at 3000 lines to prevent OOM on large files - Use `git add --` to prevent option injection from filenames - Wrap --ai conflict probe in try/catch for consistent DubError - Validate parseResolutions array elements are objects - Fix --abort flag description to mention restack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
dub ai resolvecommand that uses Gemini (via Vercel AI SDK) to analyze and resolve git merge conflicts during rebase/restack operationsdub continue --aishorthand that detects unresolved conflicts and invokes AI resolution before continuingNew files
src/commands/ai-resolve.ts— core command orchestrationsrc/lib/conflict-context.ts— gathers conflict state (files, markers, git log, restack progress)src/lib/conflict-ui.ts— diff computation, interactive prompts, resolution applicationTest plan
ai-resolve(dry-run, abort, apply-all, review individually, scope warning, retry)conflict-context(real git repos with actual rebase conflicts)conflict-ui(diff computation, path validation, batch preview)continue --aiflagpnpm checksclean (biome lint + format)pnpm typecheckclean