Remove the daemon subcommand, --no-daemon flag, and all daemon-related code from bd. With Dolt native backend, there is no daemon. This eliminates the deepest heresy vector where agents see daemon flags and conclude beads has a daemon architecture. Deleted 65+ daemon-specific files (~24.7k lines) including: - daemon.go, daemon_autostart.go, daemon_sync.go, daemon_server.go, etc. - internal/daemon/ package (registry, discovery, kill_*) - doctor/daemon.go, doctor/fix/daemon.go - activity.go (daemon-only activity command) - All corresponding test files Edited core files to remove daemon references: - main.go: removed --no-daemon flag, daemon connection block, imports - context.go: removed DaemonClient, DaemonStatus, NoDaemon fields - direct_mode.go: simplified to remove daemon fallback logic - doctor.go: removed daemon health checks - init.go: removed daemon stop before reinit - reset.go: removed daemon stop logic - worktree.go: removed daemon worktree safety checks Created compatibility stubs: - daemon_deprecated.go: stub variables/functions for 66 files that still reference daemonClient (always nil), enabling gradual cleanup - sync_helpers.go: extracted non-daemon sync functions (export/import) - sync_state.go: extracted sync state management Follow-up: Remove dead `if daemonClient != nil` branches from 66 command files, then delete daemon_deprecated.go and internal/rpc. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Executed-By: beads/polecats/quartz Rig: beads Role: polecats
98 lines
3.7 KiB
Go
98 lines
3.7 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"os/exec"
|
|
"strings"
|
|
|
|
"github.com/steveyegge/beads/internal/beads"
|
|
"github.com/steveyegge/beads/internal/git"
|
|
)
|
|
|
|
// isGitWorktree detects if the current directory is in a git worktree.
|
|
// This is a wrapper around git.IsWorktree() for CLI-layer compatibility.
|
|
func isGitWorktree() bool {
|
|
return git.IsWorktree()
|
|
}
|
|
|
|
// gitRevParse runs git rev-parse with the given flag and returns the trimmed output.
|
|
// This is a helper for CLI utilities that need git command execution.
|
|
func gitRevParse(flag string) string {
|
|
out, err := exec.Command("git", "rev-parse", flag).Output()
|
|
if err != nil {
|
|
return ""
|
|
}
|
|
return strings.TrimSpace(string(out))
|
|
}
|
|
|
|
// getWorktreeGitDir returns the .git directory path for a worktree
|
|
// Returns empty string if not in a git repo or not a worktree
|
|
func getWorktreeGitDir() string {
|
|
gitDir, err := git.GetGitDir()
|
|
if err != nil {
|
|
return ""
|
|
}
|
|
return gitDir
|
|
}
|
|
|
|
// truncateForBox truncates a path to fit in the warning box
|
|
func truncateForBox(path string, maxLen int) string {
|
|
if len(path) <= maxLen {
|
|
return path
|
|
}
|
|
// Truncate with ellipsis
|
|
return "..." + path[len(path)-(maxLen-3):]
|
|
}
|
|
|
|
// warnMultipleDatabases prints a warning if multiple .beads databases exist
|
|
// in the directory hierarchy, to prevent confusion and database pollution
|
|
func warnMultipleDatabases(currentDB string) {
|
|
databases := beads.FindAllDatabases()
|
|
if len(databases) <= 1 {
|
|
return // Only one database found, no warning needed
|
|
}
|
|
|
|
// Find which database is active
|
|
activeIdx := -1
|
|
for i, db := range databases {
|
|
if db.Path == currentDB {
|
|
activeIdx = i
|
|
break
|
|
}
|
|
}
|
|
|
|
fmt.Fprintln(os.Stderr)
|
|
fmt.Fprintln(os.Stderr, "╔══════════════════════════════════════════════════════════════════════════╗")
|
|
fmt.Fprintf(os.Stderr, "║ WARNING: %d beads databases detected in directory hierarchy ║\n", len(databases))
|
|
fmt.Fprintln(os.Stderr, "╠══════════════════════════════════════════════════════════════════════════╣")
|
|
fmt.Fprintln(os.Stderr, "║ Multiple databases can cause confusion and database pollution. ║")
|
|
fmt.Fprintln(os.Stderr, "║ ║")
|
|
|
|
for i, db := range databases {
|
|
isActive := (i == activeIdx)
|
|
issueInfo := ""
|
|
if db.IssueCount >= 0 {
|
|
issueInfo = fmt.Sprintf(" (%d issues)", db.IssueCount)
|
|
}
|
|
|
|
marker := " "
|
|
if isActive {
|
|
marker = "▶"
|
|
}
|
|
|
|
line := fmt.Sprintf("%s %s%s", marker, db.BeadsDir, issueInfo)
|
|
fmt.Fprintf(os.Stderr, "║ %-72s ║\n", truncateForBox(line, 72))
|
|
}
|
|
|
|
fmt.Fprintln(os.Stderr, "║ ║")
|
|
if activeIdx == 0 {
|
|
fmt.Fprintln(os.Stderr, "║ Currently using the closest database (▶). This is usually correct. ║")
|
|
} else {
|
|
fmt.Fprintln(os.Stderr, "║ WARNING: Not using the closest database! Check your BEADS_DB setting. ║")
|
|
}
|
|
fmt.Fprintln(os.Stderr, "║ ║")
|
|
fmt.Fprintln(os.Stderr, "║ RECOMMENDED: Consolidate or remove unused databases to avoid confusion. ║")
|
|
fmt.Fprintln(os.Stderr, "╚══════════════════════════════════════════════════════════════════════════╝")
|
|
fmt.Fprintln(os.Stderr)
|
|
}
|