conflicts
Merge conflict parser
Parse files with git conflict markers into structured JSON. Returns ours/theirs content, line numbers, refs, and surrounding context. Supports standard and diff3 styles.
Features
- Structured JSON output with ours/theirs content
- Line numbers and ref labels for each side
- Context lines above and below conflicts
- Supports standard and diff3 (|||||||) styles
- Handles CRLF line endings
- Process multiple files in one call
Install
go install github.com/hegner123/conflicts@latestThe Problem: Parsing conflict markers from raw file content
# AI agent reads a conflicted file and sees:
<<<<<<< HEAD
func processUser(id int) error {
=======
func processUser(ctx context.Context, id int) error {
>>>>>>> feature/add-context
# The agent must manually parse these markers,
# figure out which side is which,
# and reason about the merge - all from raw text.Solution
$ conflicts --cli --file /path/to/conflicted.goOutput
{"files":[{"file":"/path/to/conflicted.go","conflicts":[{"line":10,"end_line":14,"ours_ref":"HEAD","theirs_ref":"feature/add-context","ours":["func processUser(id int) error {"],"theirs":["func processUser(ctx context.Context, id int) error {"],"context_above":["// processUser handles user operations"],"context_below":[" db := getDB()"]}]}],"total":1,"has_diff3":false,"summary":"1 conflict in 1 file"}Comparison
| Metric | Value |
|---|---|
| Conflict styles supported | Standard + diff3 |
| Output | Structured JSON vs raw marker parsing |
| Multi-file | Process all conflicted files in one call |