Add EventCompacted to event system (bd-262)

- Add EventCompacted event type constant
- Add compaction fields to Issue struct (CompactionLevel, CompactedAt, OriginalSize)
- Update ApplyCompaction to record compaction events with JSON metadata
- Update bd show to display compaction status with emoji indicators
- Update GetIssue query to load compaction fields
- All tests passing

Amp-Thread-ID: https://ampcode.com/threads/T-3f7946c6-8f5e-4a81-9527-1217041c7b39
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Steve Yegge
2025-10-16 01:00:27 -07:00
parent 5e420e8ee0
commit e99de1b5e3
7 changed files with 74 additions and 7 deletions

View File

@@ -1003,6 +1003,30 @@ var showCmd = &cobra.Command{
fmt.Printf("Created: %s\n", issue.CreatedAt.Format("2006-01-02 15:04"))
fmt.Printf("Updated: %s\n", issue.UpdatedAt.Format("2006-01-02 15:04"))
// Show compaction status
if issue.CompactionLevel > 0 {
tierEmoji := ""
if issue.CompactionLevel == 1 {
tierEmoji = "🗜️ "
} else if issue.CompactionLevel == 2 {
tierEmoji = "📦 "
}
fmt.Printf("\n%sCompacted: Tier %d", tierEmoji, issue.CompactionLevel)
if issue.CompactedAt != nil {
fmt.Printf(" on %s", issue.CompactedAt.Format("2006-01-02"))
}
if issue.OriginalSize > 0 {
currentSize := len(issue.Description) + len(issue.Design) + len(issue.Notes) + len(issue.AcceptanceCriteria)
saved := issue.OriginalSize - currentSize
if saved > 0 {
reduction := float64(saved) / float64(issue.OriginalSize) * 100
fmt.Printf(" (%.0f%% reduction, saved %d bytes)", reduction, saved)
}
}
fmt.Println()
fmt.Printf("💾 Restore: bd compact --restore %s\n", issue.ID)
}
if issue.Description != "" {
fmt.Printf("\nDescription:\n%s\n", issue.Description)
}