Skip to content

Commit a0076ec

Browse files
Copilotneongreen
andcommitted
beads-merge: Add AGENTS.md and jj configuration guide
Co-authored-by: neongreen <1523306+neongreen@users.noreply.github.com>
1 parent bd003df commit a0076ec

3 files changed

Lines changed: 71 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,3 +561,38 @@ The `.github/workflows/copilot-setup-steps.yml` workflow ensures bd is available
561561
- [bd Documentation](https://github.com/steveyegge/beads/blob/main/README.md)
562562
- [bd Workflow Guide](https://github.com/steveyegge/beads/blob/main/WORKFLOW.md)
563563
- [bd for Agents](https://github.com/steveyegge/beads/blob/main/AGENTS.md)
564+
565+
### Merge Tool Configuration
566+
567+
This repository includes `beads-merge`, a custom 3-way merge tool for `.beads/issues.jsonl` files. To use it with jj:
568+
569+
1. Build the tool: `cd beads-merge && go build -o beads-merge .`
570+
2. Add to your jj config (`~/.jjconfig.toml`):
571+
572+
```toml
573+
[merge-tools.beads-merge]
574+
program = "/absolute/path/to/mono/beads-merge/beads-merge"
575+
merge-args = ["$base", "$left", "$right"]
576+
577+
[merge-tools.beads-merge.diff-args]
578+
# Optional: configure for 2-way diff if needed
579+
program = "diff"
580+
```
581+
582+
3. Configure automatic merge for .jsonl files in `.beads/`:
583+
584+
```toml
585+
[merge]
586+
# Use beads-merge for .beads/issues.jsonl
587+
tool-edits = [
588+
{ pattern = ".beads/issues.jsonl", tool = "beads-merge" }
589+
]
590+
```
591+
592+
The merge tool will:
593+
- Match issues by id, created_at, and created_by
594+
- Intelligently merge field changes
595+
- Combine dependency arrays
596+
- Output conflict markers for unresolvable conflicts
597+
598+
See [beads-merge/README.md](./beads-merge/README.md) for details on the merge algorithm.

beads-merge/AGENTS.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# beads-merge Agent Guidelines
2+
3+
## Purpose
4+
5+
beads-merge is a 3-way merge tool specifically for beads `.jsonl` issue files. It implements intelligent merging based on issue identity and field-specific merge strategies.
6+
7+
## Testing Requirements
8+
9+
- All changes to merge logic must include unit tests
10+
- Test both successful merge cases and conflict scenarios
11+
- Integration tests should cover real-world merge patterns from `.beads/issues.jsonl`
12+
13+
## Merge Algorithm Constraints
14+
15+
### DO NOT change these without discussion:
16+
17+
1. Issue identity is based on `.id`, `.created_at`, and `.created_by` only
18+
2. Timestamps (updated_at, closed_at) always use max value
19+
3. Dependencies are always merged (deduplicated by issue_id + depends_on_id + type)
20+
4. String fields use 3-way merge (prefer the side that changed from base)
21+
22+
### Fields that need special handling:
23+
24+
- Priority: integer field, handle like strings but compare as numbers
25+
- Dependencies: array, must deduplicate based on composite key
26+
27+
## Common Issues
28+
29+
### Issue not merging when expected
30+
Check that `.id`, `.created_at`, and `.created_by` match exactly in all three files. Even minor differences (timezone, precision) will cause issues to be treated as different.
31+
32+
### Dependencies being duplicated
33+
Ensure the deduplication key includes all three fields: issue_id, depends_on_id, and type. Two dependencies with same issue_id and depends_on_id but different types are distinct.
34+
35+
### Incorrect conflict markers
36+
Conflicts should only be generated when both sides changed the same field to different values (not when base == left or base == right).

beads-merge/beads-merge

2.8 MB
Binary file not shown.

0 commit comments

Comments
 (0)