getMemoryArgSuggestions provides the second-level completions for memory's subcommands (load dates, facts/remember categories, profile keys).
(d prompt.Document, args []string, line string)
| 707 | // getMemoryArgSuggestions provides the second-level completions for |
| 708 | // /memory's subcommands (load dates, facts/remember categories, profile keys). |
| 709 | func (cli *ChatCLI) getMemoryArgSuggestions(d prompt.Document, args []string, line string) []prompt.Suggest { |
| 710 | if len(args) < 2 { |
| 711 | return nil |
| 712 | } |
| 713 | word := d.GetWordBeforeCursor() |
| 714 | |
| 715 | switch args[1] { |
| 716 | case "load": |
| 717 | if !atArg(args, line, 2) { |
| 718 | return nil |
| 719 | } |
| 720 | suggestions := []prompt.Suggest{ |
| 721 | {Text: "today", Description: i18n.T("mem.cmd.suggest.load_today")}, |
| 722 | {Text: "yesterday", Description: i18n.T("mem.cmd.suggest.load_yesterday")}, |
| 723 | } |
| 724 | if cli.memoryStore != nil { |
| 725 | for _, note := range cli.memoryStore.GetRecentDailyNotes(7) { |
| 726 | suggestions = append(suggestions, prompt.Suggest{ |
| 727 | Text: note.Date.Format("2006-01-02"), |
| 728 | Description: i18n.T("mem.cmd.suggest.load_date", note.Date.Format("02/Jan")), |
| 729 | }) |
| 730 | } |
| 731 | } |
| 732 | return prompt.FilterHasPrefix(suggestions, word, true) |
| 733 | |
| 734 | case "facts": |
| 735 | if !atArg(args, line, 2) { |
| 736 | return nil |
| 737 | } |
| 738 | return prompt.FilterHasPrefix(memoryCategorySuggestions(false), word, true) |
| 739 | |
| 740 | case "remember": |
| 741 | if !atArg(args, line, 2) { |
| 742 | return nil |
| 743 | } |
| 744 | return prompt.FilterHasPrefix(memoryCategorySuggestions(true), word, true) |
| 745 | |
| 746 | case "profile": |
| 747 | if (len(args) == 2 && strings.HasSuffix(line, " ")) || (len(args) == 3 && args[2] != "set" && !strings.HasSuffix(line, " ")) { |
| 748 | return prompt.FilterHasPrefix( |
| 749 | []prompt.Suggest{{Text: "set", Description: i18n.T("mem.cmd.suggest.profile_set")}}, word, true) |
| 750 | } |
| 751 | if len(args) >= 3 && args[2] == "set" && atArg(args, line, 3) { |
| 752 | return prompt.FilterHasPrefix(memoryProfileKeySuggestions(), word, true) |
| 753 | } |
| 754 | } |
| 755 | return nil |
| 756 | } |
| 757 | |
| 758 | // memoryCategorySuggestions returns the fact categories. When bracketed is |
| 759 | // true they are wrapped as [category] tags (for /memory remember). |
no test coverage detected