Fix bd-51: Add git hooks to eliminate auto-flush race condition

- Added --flush-only flag to bd sync command
- Created pre-commit hook to flush pending changes before commit
- Created post-merge hook to import changes after pull/merge
- Added install script for easy setup
- Updated AGENTS.md with git hooks workflow
- Resolves race condition where daemon auto-flush fires after commit

Amp-Thread-ID: https://ampcode.com/threads/T-00b80d3a-4194-4c75-a60e-25a318cf9f91
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Steve Yegge
2025-10-24 22:17:06 -07:00
parent c87f9007a5
commit 0344e1f08b
7 changed files with 199 additions and 265 deletions
+18 -1
View File
@@ -344,7 +344,24 @@ git pull # bd commands will auto-import the updated JSONL
bd ready # Fresh data from git!
```
**Optional**: Use the git hooks in `examples/git-hooks/` for immediate export (no 5-second wait) and guaranteed import after git operations. Not required with auto-sync enabled.
**Recommended**: Install git hooks to eliminate the race condition between auto-flush and commits:
```bash
# One-time setup
./examples/git-hooks/install.sh
```
This installs:
- **pre-commit** - Flushes pending changes immediately before commit (eliminates 5-second wait)
- **post-merge** - Imports updated JSONL after pull/merge (guaranteed sync)
Benefits:
- ✅ No more dirty working tree after commits
- ✅ Immediate flush (no 5-second debounce wait)
- ✅ Automatic collision resolution on merge
- ✅ Works alongside auto-sync
See [examples/git-hooks/README.md](examples/git-hooks/README.md) for details.
### Git Worktrees