Add conflict marker detection to bd import/validate

- bd import now detects git conflict markers and shows resolution steps
- bd validate --checks=conflicts improved with clearer instructions
- Updated AGENTS.md with better conflict resolution docs
- Closes bd-7e7ddffa epic (repair tools complete)

Amp-Thread-ID: https://ampcode.com/threads/T-4a11a65b-56c2-4d92-8f68-66f0a56ab5e3
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Steve Yegge
2025-11-02 16:45:51 -08:00
parent 439f09a255
commit 4ee5b2c2c1
3 changed files with 54 additions and 30 deletions

View File

@@ -59,24 +59,34 @@ Behavior:
lineNum := 0
for scanner.Scan() {
lineNum++
line := scanner.Text()
lineNum++
line := scanner.Text()
// Skip empty lines
if line == "" {
continue
}
// Parse JSON
var issue types.Issue
if err := json.Unmarshal([]byte(line), &issue); err != nil {
fmt.Fprintf(os.Stderr, "Error parsing line %d: %v\n", lineNum, err)
os.Exit(1)
}
allIssues = append(allIssues, &issue)
// Skip empty lines
if line == "" {
continue
}
// Detect git conflict markers
if strings.Contains(line, "<<<<<<<") || strings.Contains(line, "=======") || strings.Contains(line, ">>>>>>>") {
fmt.Fprintf(os.Stderr, "Error: Git conflict markers detected in JSONL file (line %d)\n\n", lineNum)
fmt.Fprintf(os.Stderr, "To resolve:\n")
fmt.Fprintf(os.Stderr, " git checkout --ours .beads/issues.jsonl && bd import -i .beads/issues.jsonl\n")
fmt.Fprintf(os.Stderr, " git checkout --theirs .beads/issues.jsonl && bd import -i .beads/issues.jsonl\n\n")
fmt.Fprintf(os.Stderr, "For advanced field-level merging, see: https://github.com/neongreen/mono/tree/main/beads-merge\n")
os.Exit(1)
}
// Parse JSON
var issue types.Issue
if err := json.Unmarshal([]byte(line), &issue); err != nil {
fmt.Fprintf(os.Stderr, "Error parsing line %d: %v\n", lineNum, err)
os.Exit(1)
}
allIssues = append(allIssues, &issue)
}
if err := scanner.Err(); err != nil {
fmt.Fprintf(os.Stderr, "Error reading input: %v\n", err)
os.Exit(1)