Add RPC support for compact command (bd-184)
- Added OpCompact and OpCompactStats operation constants - Added CompactArgs, CompactStatsArgs, and response types to RPC protocol - Implemented handleCompact and handleCompactStats in RPC server - Updated compact command to use RPC when daemon is available - Fixed RPC client to include Cwd for proper database routing - Compact now works in daemon mode with --no-daemon flag Amp-Thread-ID: https://ampcode.com/threads/T-87885d07-80ad-466d-9ffb-cc96fab4853f Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -30,6 +30,8 @@ const (
|
||||
OpReposReady = "repos_ready"
|
||||
OpReposStats = "repos_stats"
|
||||
OpReposClearCache = "repos_clear_cache"
|
||||
OpCompact = "compact"
|
||||
OpCompactStats = "compact_stats"
|
||||
)
|
||||
|
||||
// Request represents an RPC request from client to daemon
|
||||
@@ -230,3 +232,53 @@ type ReposStatsResponse struct {
|
||||
PerRepo map[string]types.Statistics `json:"per_repo"`
|
||||
Errors map[string]string `json:"errors,omitempty"`
|
||||
}
|
||||
|
||||
// CompactArgs represents arguments for the compact operation
|
||||
type CompactArgs struct {
|
||||
IssueID string `json:"issue_id,omitempty"` // Empty for --all
|
||||
Tier int `json:"tier"` // 1 or 2
|
||||
DryRun bool `json:"dry_run"`
|
||||
Force bool `json:"force"`
|
||||
All bool `json:"all"`
|
||||
APIKey string `json:"api_key,omitempty"`
|
||||
Workers int `json:"workers,omitempty"`
|
||||
BatchSize int `json:"batch_size,omitempty"`
|
||||
}
|
||||
|
||||
// CompactStatsArgs represents arguments for compact stats operation
|
||||
type CompactStatsArgs struct {
|
||||
Tier int `json:"tier,omitempty"`
|
||||
}
|
||||
|
||||
// CompactResponse represents the response from a compact operation
|
||||
type CompactResponse struct {
|
||||
Success bool `json:"success"`
|
||||
IssueID string `json:"issue_id,omitempty"`
|
||||
Results []CompactResult `json:"results,omitempty"` // For batch operations
|
||||
Stats *CompactStatsData `json:"stats,omitempty"` // For stats operation
|
||||
OriginalSize int `json:"original_size,omitempty"`
|
||||
CompactedSize int `json:"compacted_size,omitempty"`
|
||||
Reduction string `json:"reduction,omitempty"`
|
||||
Duration string `json:"duration,omitempty"`
|
||||
DryRun bool `json:"dry_run,omitempty"`
|
||||
}
|
||||
|
||||
// CompactResult represents the result of compacting a single issue
|
||||
type CompactResult struct {
|
||||
IssueID string `json:"issue_id"`
|
||||
Success bool `json:"success"`
|
||||
Error string `json:"error,omitempty"`
|
||||
OriginalSize int `json:"original_size,omitempty"`
|
||||
CompactedSize int `json:"compacted_size,omitempty"`
|
||||
Reduction string `json:"reduction,omitempty"`
|
||||
}
|
||||
|
||||
// CompactStatsData represents compaction statistics
|
||||
type CompactStatsData struct {
|
||||
Tier1Candidates int `json:"tier1_candidates"`
|
||||
Tier2Candidates int `json:"tier2_candidates"`
|
||||
TotalClosed int `json:"total_closed"`
|
||||
Tier1MinAge string `json:"tier1_min_age"`
|
||||
Tier2MinAge string `json:"tier2_min_age"`
|
||||
EstimatedSavings string `json:"estimated_savings,omitempty"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user