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:
@@ -18,7 +18,7 @@ type Config struct {
|
||||
func DefaultConfig() *Config {
|
||||
return &Config{
|
||||
Database: "beads.db",
|
||||
JSONLExport: "issues.jsonl",
|
||||
JSONLExport: "beads.jsonl", // Default to canonical name (was issues.jsonl)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,9 @@ func TestDefaultConfig(t *testing.T) {
|
||||
t.Errorf("Database = %q, want beads.db", cfg.Database)
|
||||
}
|
||||
|
||||
if cfg.JSONLExport != "issues.jsonl" {
|
||||
t.Errorf("JSONLExport = %q, want issues.jsonl", cfg.JSONLExport)
|
||||
// bd-afd: Default changed from issues.jsonl to beads.jsonl (canonical name)
|
||||
if cfg.JSONLExport != "beads.jsonl" {
|
||||
t.Errorf("JSONLExport = %q, want beads.jsonl", cfg.JSONLExport)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user