--- New commands ---
()
| 217 | // --- New commands --- |
| 218 | |
| 219 | func (cli *ChatCLI) showMemoryProfile() { |
| 220 | mgr := cli.memoryStore.Manager() |
| 221 | profile := mgr.Profile.Get() |
| 222 | |
| 223 | fmt.Println() |
| 224 | fmt.Println(colorize(" "+i18n.T("mem.cmd.profile.title"), ColorCyan+ColorBold)) |
| 225 | fmt.Println(colorize(" ─────────────────────────────────────────", ColorGray)) |
| 226 | |
| 227 | if mgr.Profile.IsEmpty() && len(profile.TopCommands) == 0 { |
| 228 | fmt.Println(colorize(" "+i18n.T("mem.cmd.profile.empty"), ColorGray)) |
| 229 | fmt.Println() |
| 230 | return |
| 231 | } |
| 232 | |
| 233 | printProfileScalars(profile) |
| 234 | printProfileLists(profile) |
| 235 | printProfileTimeline(profile) |
| 236 | |
| 237 | if len(profile.TopCommands) > 0 { |
| 238 | fmt.Printf("\n %s\n", colorize(i18n.T("mem.cmd.profile.top_commands"), ColorYellow)) |
| 239 | type cmdCount struct { |
| 240 | cmd string |
| 241 | count int |
| 242 | } |
| 243 | var cmds []cmdCount |
| 244 | for c, n := range profile.TopCommands { |
| 245 | cmds = append(cmds, cmdCount{c, n}) |
| 246 | } |
| 247 | sort.Slice(cmds, func(i, j int) bool { |
| 248 | return cmds[i].count > cmds[j].count |
| 249 | }) |
| 250 | limit := 10 |
| 251 | if len(cmds) < limit { |
| 252 | limit = len(cmds) |
| 253 | } |
| 254 | for _, c := range cmds[:limit] { |
| 255 | fmt.Printf(" %s (%d)\n", c.cmd, c.count) |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | if len(profile.Preferences) > 0 { |
| 260 | fmt.Printf("\n %s\n", colorize(i18n.T("mem.cmd.profile.preferences"), ColorYellow)) |
| 261 | for _, k := range sortedStringKeys(profile.Preferences) { |
| 262 | label := k |
| 263 | if profile.FieldMeta["pref:"+k].Sensitive { |
| 264 | label = "🔒 " + k |
| 265 | } |
| 266 | fmt.Printf(" %s: %s\n", label, profile.Preferences[k]) |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | if !profile.LastUpdated.IsZero() { |
| 271 | fmt.Printf("\n %s %s\n", colorize(i18n.T("mem.cmd.profile.last_updated"), ColorGray), profile.LastUpdated.Format("2006-01-02 15:04")) |
| 272 | } |
| 273 | fmt.Println() |
| 274 | } |
| 275 | |
| 276 | // rememberMemoryFact stores a fact deterministically via /memory remember. |
no test coverage detected