Fix bd-73: Add git worktree detection and warnings

- Implement robust worktree detection using git-dir vs git-common-dir comparison
- Add prominent warning when daemon mode is active in a worktree
- Warn in 3 places: initial connection, auto-start, and daemon start command
- Show shared database path and clarify BEADS_AUTO_START_DAEMON behavior
- Document limitations and solutions in README.md and AGENTS.md
- Add comprehensive tests for detection and path truncation

Fixes #55

Amp-Thread-ID: https://ampcode.com/threads/T-254eb9e3-1a42-42d7-afdf-b7ca2d2dcb8b
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Steve Yegge
2025-10-22 23:05:00 -07:00
parent 3fae41cb35
commit 5a6177b4bc
7 changed files with 302 additions and 0 deletions

View File

@@ -188,6 +188,8 @@ var rootCmd = &cobra.Command{
if os.Getenv("BD_DEBUG") != "" {
fmt.Fprintf(os.Stderr, "Debug: connected to daemon at %s (health: %s)\n", socketPath, health.Status)
}
// Warn if using daemon with git worktrees
warnWorktreeDaemon(dbPath)
return // Skip direct storage initialization
} else {
// Health check failed or daemon unhealthy
@@ -248,6 +250,8 @@ var rootCmd = &cobra.Command{
elapsed := time.Since(startTime).Milliseconds()
fmt.Fprintf(os.Stderr, "Debug: auto-start succeeded; connected at %s in %dms\n", socketPath, elapsed)
}
// Warn if using daemon with git worktrees
warnWorktreeDaemon(dbPath)
return // Skip direct storage initialization
} else {
// Auto-started daemon is unhealthy