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

@@ -66,6 +66,11 @@ NOTE: Import requires direct database access and does not work with daemon mode.
var err error
store, err = sqlite.New(rootCtx, dbPath)
if err != nil {
// Check for fresh clone scenario (bd-dmb)
beadsDir := filepath.Dir(dbPath)
if handleFreshCloneError(err, beadsDir) {
os.Exit(1)
}
fmt.Fprintf(os.Stderr, "Error: failed to open database: %v\n", err)
os.Exit(1)
}