refactor: deduplicate FindJSONLInDir function (bd-8a5)

Extract shared JSONL file discovery logic to internal/utils/path.go.
Both autoimport and beads packages now use this shared implementation.

Changes:
- Add utils.FindJSONLInDir with common logic
- Update autoimport.go to use utils.FindJSONLInDir
- Update beads.go to delegate to utils.FindJSONLInDir
- Update server_export_import_auto.go to use utils.FindJSONLInDir
- Move FindJSONLInDir test to utils/path_test.go
- Fix pre-existing duplicate countIssuesInJSONLFile in init.go

🤖 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-28 23:07:53 -08:00
parent 52fe60859a
commit 40b07045c7
8 changed files with 201 additions and 256 deletions

View File

@@ -18,6 +18,7 @@ import (
"github.com/steveyegge/beads/internal/storage"
"github.com/steveyegge/beads/internal/storage/sqlite"
"github.com/steveyegge/beads/internal/types"
"github.com/steveyegge/beads/internal/utils"
)
// handleExport handles the export operation
@@ -443,7 +444,7 @@ func (s *Server) triggerExport(ctx context.Context, store storage.Storage, dbPat
// Find JSONL path using database directory
// Use FindJSONLInDir to prefer issues.jsonl over other .jsonl files (bd-tqo fix)
dbDir := filepath.Dir(dbPath)
jsonlPath := autoimport.FindJSONLInDir(dbDir)
jsonlPath := utils.FindJSONLInDir(dbDir)
// Get all issues from storage
sqliteStore, ok := store.(*sqlite.SQLiteStorage)