feat(doctor): add --output flag to export diagnostics (bd-9cc)

Add ability to save doctor diagnostics to a JSON file for historical
analysis and bug reporting. The export includes timestamp and platform
info (OS, Go version, SQLite version) for tracking intermittent issues.

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-03 11:41:00 -08:00
parent e1e3427d9b
commit e5de1db585
2 changed files with 57 additions and 10 deletions

View File

@@ -36,7 +36,7 @@ func RunPerformanceDiagnostics(path string) {
}
// Collect platform info
platformInfo := collectPlatformInfo(dbPath)
platformInfo := CollectPlatformInfo(path)
fmt.Printf("\nPlatform: %s\n", platformInfo["os_arch"])
fmt.Printf("Go: %s\n", platformInfo["go_version"])
fmt.Printf("SQLite: %s\n", platformInfo["sqlite_version"])
@@ -95,7 +95,9 @@ func RunPerformanceDiagnostics(path string) {
fmt.Printf(" go tool pprof -http=:8080 %s\n\n", profilePath)
}
func collectPlatformInfo(dbPath string) map[string]string {
// CollectPlatformInfo gathers platform information for diagnostics.
// bd-9cc: Exported for use by --output flag.
func CollectPlatformInfo(path string) map[string]string {
info := make(map[string]string)
// OS and architecture
@@ -104,7 +106,9 @@ func collectPlatformInfo(dbPath string) map[string]string {
// Go version
info["go_version"] = runtime.Version()
// SQLite version
// SQLite version - try to find database
beadsDir := filepath.Join(path, ".beads")
dbPath := filepath.Join(beadsDir, beads.CanonicalDatabaseName)
db, err := sql.Open("sqlite3", "file:"+dbPath+"?mode=ro")
if err == nil {
defer db.Close()