From d12b5b7221c5c5f6c3059110a093e024ef9c5d8e Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Sat, 1 Nov 2025 11:56:44 -0700 Subject: [PATCH] Fix bd doctor to respect custom database names from config.json Fixes #197: bd doctor was hardcoded to look for beads.db and didn't check config.json for custom database names like beady.db. Now both checkDatabaseVersion() and checkIDFormat() check config.json first before falling back to the canonical database name. --- cmd/bd/doctor.go | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/cmd/bd/doctor.go b/cmd/bd/doctor.go index 29ddd79c..e973373c 100644 --- a/cmd/bd/doctor.go +++ b/cmd/bd/doctor.go @@ -14,6 +14,7 @@ import ( "github.com/fatih/color" "github.com/spf13/cobra" "github.com/steveyegge/beads" + "github.com/steveyegge/beads/internal/configfile" "github.com/steveyegge/beads/internal/daemon" _ "modernc.org/sqlite" ) @@ -191,7 +192,15 @@ func checkInstallation(path string) doctorCheck { func checkDatabaseVersion(path string) doctorCheck { beadsDir := filepath.Join(path, ".beads") - dbPath := filepath.Join(beadsDir, beads.CanonicalDatabaseName) + + // Check config.json first for custom database name + var dbPath string + if cfg, err := configfile.Load(beadsDir); err == nil && cfg != nil && cfg.Database != "" { + dbPath = cfg.DatabasePath(beadsDir) + } else { + // Fall back to canonical database name + dbPath = filepath.Join(beadsDir, beads.CanonicalDatabaseName) + } // Check if database file exists if _, err := os.Stat(dbPath); os.IsNotExist(err) { @@ -257,7 +266,15 @@ func checkDatabaseVersion(path string) doctorCheck { func checkIDFormat(path string) doctorCheck { beadsDir := filepath.Join(path, ".beads") - dbPath := filepath.Join(beadsDir, beads.CanonicalDatabaseName) + + // Check config.json first for custom database name + var dbPath string + if cfg, err := configfile.Load(beadsDir); err == nil && cfg != nil && cfg.Database != "" { + dbPath = cfg.DatabasePath(beadsDir) + } else { + // Fall back to canonical database name + dbPath = filepath.Join(beadsDir, beads.CanonicalDatabaseName) + } // Check if using JSONL-only mode if _, err := os.Stat(dbPath); os.IsNotExist(err) {