(args string)
| 262 | } |
| 263 | |
| 264 | func cmdCompact(args string) { |
| 265 | strategy := rootAgent.Compactor |
| 266 | switch strings.ToLower(args) { |
| 267 | case "": |
| 268 | // use the configured compactor |
| 269 | case "sliding": |
| 270 | strategy = &compact.SlidingWindow{KeepLast: 6} |
| 271 | case "summarize": |
| 272 | strategy = &compact.Summarize{Provider: rootAgent.Provider, Threshold: 0, KeepRecent: 4} |
| 273 | case "none": |
| 274 | strategy = compact.NoCompaction{} |
| 275 | default: |
| 276 | fmt.Printf("unknown strategy: %s (try sliding, summarize, or none)\n", args) |
| 277 | return |
| 278 | } |
| 279 | |
| 280 | before := rootAgent.Messages() |
| 281 | compacted, err := strategy.Compact(context.Background(), before) |
| 282 | if err != nil { |
| 283 | fmt.Printf("compaction error: %v\n", err) |
| 284 | return |
| 285 | } |
| 286 | rootAgent.SetMessages(compacted) |
| 287 | fmt.Println(ui.Dimmed(fmt.Sprintf("compacted: %d → %d messages", len(before), len(compacted)))) |
| 288 | if rootAgent.Verbose && len(before) != len(compacted) { |
| 289 | ui.PrintCompaction(before, compacted) |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | func cmdVerbose(args string) { |
| 294 | switch strings.ToLower(args) { |
nothing calls this directly
no test coverage detected