Fix bd-afd: Auto-fix metadata.json jsonl_export mismatch
## Summary When metadata.json gets deleted (git clean, merge conflict, rebase), the version tracking code auto-recreates it using DefaultConfig() which hardcoded jsonl_export to 'issues.jsonl'. But many repos (including beads itself) use 'beads.jsonl', causing a mismatch between config and actual JSONL file. ## Changes 1. **bd doctor --fix auto-detection** (cmd/bd/doctor/fix/database_config.go) - New DatabaseConfig() fix function that auto-detects actual JSONL file - Prefers beads.jsonl over issues.jsonl (canonical name) - Skips backup files and merge artifacts - Wired into doctor.go applyFixes() 2. **Version tracking auto-detection** (cmd/bd/version_tracking.go) - trackBdVersion() now scans for existing JSONL files before defaulting - Prevents mismatches when metadata.json gets recreated - Added findActualJSONLFile() helper function 3. **Canonical default name** (internal/configfile/configfile.go) - DefaultConfig() changed from issues.jsonl to beads.jsonl - Aligns with canonical naming convention 4. **FindJSONLPath preference** (internal/beads/beads.go) - Now prefers beads.jsonl over issues.jsonl when scanning - Default changed from issues.jsonl to beads.jsonl 5. **Test coverage** - Added comprehensive tests for DatabaseConfig fix - Updated configfile tests for new default - Verified backup file skipping logic ## Testing - All existing tests pass - New tests verify auto-fix behavior - Integration tested with simulated mismatches Closes: bd-afd
This commit is contained in:
@@ -252,7 +252,7 @@ func CheckDatabaseConfig(repoPath string) DoctorCheck {
|
||||
Status: "warning",
|
||||
Message: "Configuration mismatch detected",
|
||||
Detail: strings.Join(issues, "\n "),
|
||||
Fix: "Update configuration in .beads/metadata.json:\n" +
|
||||
Fix: "Run 'bd doctor --fix' to auto-detect and fix mismatches, or manually:\n" +
|
||||
" 1. Check which files are actually being used\n" +
|
||||
" 2. Update metadata.json to match the actual filenames\n" +
|
||||
" 3. Or rename the files to match the configuration",
|
||||
|
||||
Reference in New Issue
Block a user