feat: add Git worktree compatibility (PR #478)

Adds comprehensive Git worktree support for beads issue tracking:

Core changes:
- New internal/git/gitdir.go package for worktree detection
- GetGitDir() returns proper .git location (main repo, not worktree)
- Updated all hooks to use git.GetGitDir() instead of local helper
- BeadsDir() now prioritizes main repository's .beads directory

Features:
- Hooks auto-install in main repo when run from worktree
- Shared .beads directory across all worktrees
- Config option no-install-hooks to disable auto-install
- New bd worktree subcommand for diagnostics

Documentation:
- New docs/WORKTREES.md with setup instructions
- Updated CHANGELOG.md and AGENT_INSTRUCTIONS.md

Testing:
- Updated tests to use exported git.GetGitDir()
- Added worktree detection tests

Co-authored-by: Claude <noreply@anthropic.com>
Closes: #478
This commit is contained in:
matt wilkie
2025-12-13 10:40:40 -08:00
committed by Steve Yegge
parent de7b511765
commit e01b7412d9
64 changed files with 1895 additions and 3708 deletions

View File

@@ -1,13 +1,11 @@
# bd - Beads Issue Tracker 🔗
[![Run in Smithery](https://smithery.ai/badge/skills/steveyegge)](https://smithery.ai/skills?ns=steveyegge&utm_source=github&utm_medium=badge)
[![Go Version](https://img.shields.io/github/go-mod/go-version/steveyegge/beads)](https://go.dev/)
[![Release](https://img.shields.io/github/v/release/steveyegge/beads)](https://github.com/steveyegge/beads/releases)
[![npm version](https://img.shields.io/npm/v/@beads/bd)](https://www.npmjs.com/package/@beads/bd)
[![CI](https://img.shields.io/github/actions/workflow/status/steveyegge/beads/ci.yml?branch=main&label=tests)](https://github.com/steveyegge/beads/actions/workflows/ci.yml)
[![Go Report Card](https://goreportcard.com/badge/github.com/steveyegge/beads)](https://goreportcard.com/report/github.com/steveyegge/beads)
[![Git Worktrees](https://img.shields.io/badge/git-worktrees-🚧-orange)](docs/WORKTREES.md)
[![License](https://img.shields.io/github/license/steveyegge/beads)](LICENSE)
[![PyPI](https://img.shields.io/pypi/v/beads-mcp)](https://pypi.org/project/beads-mcp/)
@@ -63,6 +61,7 @@ Agents report that they enjoy working with Beads, and they will use it spontaneo
- 🌍 **Distributed by design** - Agents on multiple machines share one logical database via git
- 🚀 **Optional Agent Mail** - Real-time multi-agent coordination (<100ms vs 2-5s git sync, 98.5% reduction in git traffic)
- 🔐 **Protected branch support** - Works with GitHub/GitLab protected branches via separate sync branch
- 🌳 **Git worktree compatible** - Enhanced support for git worktrees with shared database architecture
- 🏗️ **Extensible** - Add your own tables to the SQLite database
- 🔍 **Multi-project isolation** - Each project gets its own database, auto-discovered by directory
- 🌲 **Dependency trees** - Visualize full dependency graphs
@@ -116,11 +115,6 @@ brew tap steveyegge/beads
brew install bd
```
**mise (polyglot runtime manager):**
```bash
mise use -g ubi:steveyegge/beads[exe=bd]
```
For full, platform-specific instructions (Windows, Arch Linux, manual builds, IDE integrations, etc.) see the canonical guide in [docs/INSTALLING.md](docs/INSTALLING.md).
**Claude Code for Web:** See [npm-package/CLAUDE_CODE_WEB.md](npm-package/CLAUDE_CODE_WEB.md) for SessionStart hook setup.
@@ -325,8 +319,8 @@ git push
git pull
# bd automatically detects JSONL is newer and imports on next command
bd ready # Shows issues ready to work on (with fresh data from git)
bd list # Lists all issues, including those from other machines
bd ready # Fresh data from git!
bd list # Shows issues from other machines
```
**Manual sync (optional):**
@@ -336,7 +330,7 @@ bd sync # Immediately flush pending changes and import latest JSONL
**For zero-lag sync**, install the git hooks:
```bash
bd hooks install
cd examples/git-hooks && ./install.sh
```
This adds: