fix: use proper YAML parsing for no-db mode detection (bd-r6k2)

Replace fragile strings.Contains("no-db: true") with proper YAML parsing
to avoid false matches in comments or nested keys.

Changes:
- Add NoDb field to localConfig struct
- Add isNoDbModeConfigured() helper function
- Update main.go and doctor.go to use the helper
- Add 8 test cases for isNoDbModeConfigured

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-07 21:09:32 +11:00
parent cc89ce4914
commit 49bfdc2523
4 changed files with 102 additions and 17 deletions

View File

@@ -296,7 +296,6 @@ var rootCmd = &cobra.Command{
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
@@ -304,11 +303,8 @@ var rootCmd = &cobra.Command{
jsonlExists = true
}
isNoDbMode := false
// configPath is safe: constructed from filepath.Join(beadsDir, hardcoded name)
if configData, err := os.ReadFile(configPath); err == nil { //nolint:gosec
isNoDbMode = strings.Contains(string(configData), "no-db: true")
}
// Use proper YAML parsing to detect no-db mode (bd-r6k2)
isNoDbMode := isNoDbModeConfigured(beadsDir)
// If JSONL-only mode is configured, auto-enable it
if jsonlExists && isNoDbMode {