MCPcopy Create free account
hub / github.com/diillson/chatcli / showMemoryProfile

Method showMemoryProfile

cli/memory_command.go:219–274  ·  view source on GitHub ↗

--- New commands ---

()

Source from the content-addressed store, hash-verified

217// --- New commands ---
218
219func (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.

Callers 1

handleMemoryCommandMethod · 0.95

Calls 10

TFunction · 0.92
colorizeFunction · 0.85
printProfileScalarsFunction · 0.85
printProfileListsFunction · 0.85
printProfileTimelineFunction · 0.85
sortedStringKeysFunction · 0.85
ManagerMethod · 0.80
IsZeroMethod · 0.80
GetMethod · 0.65
IsEmptyMethod · 0.45

Tested by

no test coverage detected