refactor(cmd): replace map[string]interface{} with typed JSON response structs (bd-u2sc.1)

Added typed response structs for JSON output in CLI commands:

compact.go:
- CompactDryRunResponse, CompactSuccessResponse
- CompactNoCandidatesResponse, CompactBatchSuccessResponse
- CompactStatsResponse, CompactTierStats
- CompactApplyResponse, TombstonePrunedInfo

cleanup.go:
- CleanupEmptyResponse

daemons.go:
- DaemonStopResponse, DaemonRestartResponse
- DaemonLogsResponse, DaemonKillallEmptyResponse
- DaemonHealthResponse, DaemonHealthReport

daemon_lifecycle.go:
- DaemonStatusResponse

Benefits:
- Compile-time type checking for JSON output
- IDE autocompletion for response fields
- Self-documenting API structure
- Easier refactoring

Note: RPC args and storage update maps remain as-is (require
interface changes for internal APIs).

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-22 15:48:36 -08:00
parent e67712dcd4
commit 4c38075520
4 changed files with 247 additions and 122 deletions

View File

@@ -1,7 +1,6 @@
package main
import (
"encoding/json"
"fmt"
"os"
"time"
@@ -11,6 +10,14 @@ import (
"github.com/steveyegge/beads/internal/ui"
)
// CleanupEmptyResponse is returned when there are no closed issues to delete
type CleanupEmptyResponse struct {
DeletedCount int `json:"deleted_count"`
Message string `json:"message"`
Filter string `json:"filter,omitempty"`
Wisp bool `json:"wisp,omitempty"`
}
// Hard delete mode: bypass tombstone TTL safety, use --older-than days directly
// TODO: Consider consolidating into 'bd doctor --fix' for simpler maintenance UX
@@ -146,18 +153,17 @@ SEE ALSO:
if len(closedIssues) == 0 {
if jsonOutput {
result := map[string]interface{}{
"deleted_count": 0,
"message": "No closed issues to delete",
result := CleanupEmptyResponse{
DeletedCount: 0,
Message: "No closed issues to delete",
}
if olderThanDays > 0 {
result["filter"] = fmt.Sprintf("older than %d days", olderThanDays)
result.Filter = fmt.Sprintf("older than %d days", olderThanDays)
}
if wispOnly {
result["wisp"] = true
result.Wisp = true
}
output, _ := json.MarshalIndent(result, "", " ")
fmt.Println(string(output))
outputJSON(result)
} else {
msg := "No closed issues to delete"
if wispOnly && olderThanDays > 0 {