(ctx context.Context)
| 551 | } |
| 552 | |
| 553 | func (cli *ChatCLI) runMemoryCompact(ctx context.Context) { |
| 554 | mgr := cli.memoryStore.Manager() |
| 555 | |
| 556 | fmt.Println(colorize(" "+i18n.T("mem.cmd.compact.running"), ColorCyan)) |
| 557 | |
| 558 | llmClient := cli.getClient() |
| 559 | var sendPrompt func(ctx context.Context, prompt string) (string, error) |
| 560 | |
| 561 | if llmClient != nil { |
| 562 | sendPrompt = func(ctx context.Context, prompt string) (string, error) { |
| 563 | history := []models.Message{ |
| 564 | {Role: "user", Content: prompt}, |
| 565 | } |
| 566 | return llmClient.SendPrompt(ctx, prompt, history, 0) |
| 567 | } |
| 568 | } |
| 569 | |
| 570 | ctx, cancel := context.WithTimeout(ctx, 2*time.Minute) |
| 571 | defer cancel() |
| 572 | |
| 573 | factsBefore := mgr.Facts.Count() |
| 574 | |
| 575 | if err := mgr.RunCompaction(ctx, sendPrompt); err != nil { |
| 576 | fmt.Printf(" %s %s %s\n", colorize("ERR", ColorRed), i18n.T("mem.cmd.compact.failed"), err.Error()) |
| 577 | return |
| 578 | } |
| 579 | |
| 580 | factsAfter := mgr.Facts.Count() |
| 581 | |
| 582 | // Also cleanup daily notes |
| 583 | deleted, _ := mgr.CleanupDailyNotes() |
| 584 | |
| 585 | fmt.Printf(" %s %s\n", colorize("OK", ColorGreen), i18n.T("mem.cmd.compact.complete")) |
| 586 | fmt.Printf(" %s\n", i18n.T("mem.cmd.compact.facts_change", factsBefore, factsAfter)) |
| 587 | if deleted > 0 { |
| 588 | fmt.Printf(" %s\n", i18n.T("mem.cmd.compact.notes_removed", deleted)) |
| 589 | } |
| 590 | fmt.Println() |
| 591 | } |
| 592 | |
| 593 | func (cli *ChatCLI) listMemoryNotes() { |
| 594 | if cli.memoryStore == nil { |
no test coverage detected