feat(daemon): Add --global flag for multi-repo support
Implements bd-121: Global daemon with system-wide socket Changes: - Add --global flag to daemon command - Use ~/.beads/bd.sock when --global is set - Skip git repo validation for global daemon - Update daemon discovery to check ~/.beads/ as fallback - Both Go CLI and Python MCP client check global socket - Update all tests to pass global parameter Benefits: - Single daemon serves all repos on system - No per-repo daemon management needed - Better resource usage for users with many repos - Automatic fallback when local daemon not running Usage: bd daemon --global # Start global daemon bd daemon --status --global # Check global status bd daemon --stop --global # Stop global daemon Related: bd-73 (multi-repo epic) Amp-Thread-ID: https://ampcode.com/threads/T-ea606216-b886-4af0-bba8-56d000362d01 Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -169,9 +169,24 @@ var rootCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
// getSocketPath returns the daemon socket path based on the database location
|
||||
// If no local socket exists, check for global socket at ~/.beads/bd.sock
|
||||
func getSocketPath() string {
|
||||
// Socket lives in same directory as database: .beads/bd.sock
|
||||
return filepath.Join(filepath.Dir(dbPath), "bd.sock")
|
||||
// First check local socket (same directory as database: .beads/bd.sock)
|
||||
localSocket := filepath.Join(filepath.Dir(dbPath), "bd.sock")
|
||||
if _, err := os.Stat(localSocket); err == nil {
|
||||
return localSocket
|
||||
}
|
||||
|
||||
// Fall back to global socket at ~/.beads/bd.sock
|
||||
if home, err := os.UserHomeDir(); err == nil {
|
||||
globalSocket := filepath.Join(home, ".beads", "bd.sock")
|
||||
if _, err := os.Stat(globalSocket); err == nil {
|
||||
return globalSocket
|
||||
}
|
||||
}
|
||||
|
||||
// Default to local socket even if it doesn't exist
|
||||
return localSocket
|
||||
}
|
||||
|
||||
// outputJSON outputs data as pretty-printed JSON
|
||||
|
||||
Reference in New Issue
Block a user