Implement bd sync command for automated git-based synchronization

- Added bd sync command that wraps export → commit → pull → import → push workflow
- Automatically resolves collisions during pull/import
- Supports --dry-run, --message, --no-pull, --no-push flags
- Updated README with bd sync documentation
- Addresses bd-272 (Phase 1: git-based sync)
This commit is contained in:
Steve Yegge
2025-10-16 12:22:23 -07:00
parent 32a718dacd
commit 96e92de7c6
3 changed files with 659 additions and 353 deletions

View File

@@ -881,6 +881,8 @@ Add to git:
### Workflow
#### Manual Workflow
```bash
# Create/update issues - they auto-export after 5 seconds
bd create "Fix bug" -p 1
@@ -896,6 +898,37 @@ git pull
bd ready # Automatically imports first, then shows ready work
```
#### Automatic Sync with `bd sync`
For multi-device workflows, use `bd sync` to automate the entire sync process:
```bash
# Make your changes
bd create "Fix auth bug" -p 1
bd update bd-42 --status in_progress
# Sync everything in one command
bd sync -m "Update issues"
# This does:
# 1. Exports pending changes to JSONL
# 2. Commits to git
# 3. Pulls from remote (auto-resolves collisions)
# 4. Imports updated JSONL
# 5. Pushes to remote
```
Options:
```bash
bd sync # Auto-generated commit message
bd sync -m "Custom message" # Custom commit message
bd sync --dry-run # Preview without changes
bd sync --no-pull # Skip pulling from remote
bd sync --no-push # Commit but don't push
```
The `bd sync` command automatically resolves ID collisions using the same logic as `bd import --resolve-collisions`, making it safe for concurrent updates from multiple devices.
### Optional: Git Hooks for Immediate Sync
Create `.git/hooks/pre-commit`: