Fix fresh clone UX with friendly error messages (bd-dmb)

When opening a database that exists but is missing issue_prefix config
(typical in fresh clone scenarios), show a helpful error message instead
of cryptic migration invariant errors.

The new message:
- Explains the database needs initialization
- Detects if a JSONL file exists and shows the issue count
- Suggests the exact command to run: bd import -i <path>
- Falls back to suggesting bd init --prefix if no JSONL exists

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-11-27 22:40:57 -08:00
parent 151a34be98
commit 8b8a662acb
4 changed files with 144 additions and 66 deletions

View File

@@ -2,6 +2,7 @@ package main
import (
"fmt"
"path/filepath"
"github.com/steveyegge/beads/internal/beads"
"github.com/steveyegge/beads/internal/debug"
@@ -67,6 +68,12 @@ func ensureStoreActive() error {
sqlStore, err := sqlite.New(rootCtx, dbPath)
if err != nil {
// Check for fresh clone scenario (bd-dmb)
if isFreshCloneError(err) {
beadsDir := filepath.Dir(dbPath)
handleFreshCloneError(err, beadsDir)
return fmt.Errorf("database not initialized")
}
return fmt.Errorf("failed to open database: %w", err)
}