From a4e0f9dbc83c91da32f655f7616cefc8dc73c990 Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Fri, 28 Nov 2025 23:36:11 -0800 Subject: [PATCH] fix(no-db): auto-detect JSONL-only mode when config has no-db:true (bd-5kj) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When .beads exists with issues.jsonl but no SQLite database, and config.yaml has no-db: true, automatically enable JSONL-only mode instead of failing with 'no beads database found'. Also improved error message to mention --no-db option. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- cmd/bd/main.go | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/cmd/bd/main.go b/cmd/bd/main.go index fcbadd14..755584e9 100644 --- a/cmd/bd/main.go +++ b/cmd/bd/main.go @@ -283,6 +283,42 @@ var rootCmd = &cobra.Command{ if foundDB := beads.FindDatabasePath(); foundDB != "" { dbPath = foundDB } else { + // No database found - check if this is JSONL-only mode (bd-5kj) + beadsDir := beads.FindBeadsDir() + if beadsDir != "" { + jsonlPath := filepath.Join(beadsDir, "issues.jsonl") + configPath := filepath.Join(beadsDir, "config.yaml") + + // Check if JSONL exists and config.yaml has no-db: true + jsonlExists := false + if _, err := os.Stat(jsonlPath); err == nil { + jsonlExists = true + } + + isNoDbMode := false + if configData, err := os.ReadFile(configPath); err == nil { + isNoDbMode = strings.Contains(string(configData), "no-db: true") + } + + // If JSONL-only mode is configured, auto-enable it + if jsonlExists && isNoDbMode { + noDb = true + if err := initializeNoDbMode(); err != nil { + fmt.Fprintf(os.Stderr, "Error initializing JSONL-only mode: %v\n", err) + os.Exit(1) + } + // Set actor from flag, viper, or env + if actor == "" { + if user := os.Getenv("USER"); user != "" { + actor = user + } else { + actor = "unknown" + } + } + return + } + } + // Allow some commands to run without a database // - import: auto-initializes database if missing // - setup: creates editor integration files (no DB needed) @@ -290,8 +326,8 @@ var rootCmd = &cobra.Command{ // No database found - error out instead of falling back to ~/.beads fmt.Fprintf(os.Stderr, "Error: no beads database found\n") fmt.Fprintf(os.Stderr, "Hint: run 'bd init' to create a database in the current directory\n") + fmt.Fprintf(os.Stderr, " or use 'bd --no-db' to work with JSONL only (no SQLite)\n") fmt.Fprintf(os.Stderr, " or set BEADS_DIR to point to your .beads directory\n") - fmt.Fprintf(os.Stderr, " or set BEADS_DB to point to your database file (deprecated)\n") os.Exit(1) } // For import/setup commands, set default database path