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

Method showMemoryStats

cli/memory_command.go:418–482  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

416}
417
418func (cli *ChatCLI) showMemoryStats() {
419 mgr := cli.memoryStore.Manager()
420 stats := mgr.Patterns.GetStats()
421
422 fmt.Println()
423 fmt.Println(colorize(" "+i18n.T("mem.cmd.stats.title"), ColorCyan+ColorBold))
424 fmt.Println(colorize(" ─────────────────────────────────────────", ColorGray))
425
426 fmt.Printf(" %s %d\n", colorize(i18n.T("mem.cmd.stats.facts_stored"), ColorYellow), mgr.Facts.Count())
427 fmt.Printf(" %s %d\n", colorize(i18n.T("mem.cmd.stats.topics_tracked"), ColorYellow), len(mgr.Topics.GetAll()))
428 fmt.Printf(" %s %d\n", colorize(i18n.T("mem.cmd.stats.projects_tracked"), ColorYellow), len(mgr.Projects.GetAll()))
429
430 fmt.Printf("\n %s\n", colorize(i18n.T("mem.cmd.stats.usage_patterns"), ColorYellow))
431 fmt.Printf(" %s %d\n", i18n.T("mem.cmd.stats.sessions"), stats.SessionCount)
432 fmt.Printf(" %s %d\n", i18n.T("mem.cmd.stats.total_messages"), stats.TotalMessages)
433
434 if stats.AvgSessionSecs > 0 {
435 fmt.Printf(" %s\n", i18n.T("mem.cmd.stats.avg_session", stats.AvgSessionSecs/60.0))
436 }
437
438 // Peak hours
439 peakHours := mgr.Patterns.GetPeakHours(3)
440 if len(peakHours) > 0 {
441 var hourStrs []string
442 for _, h := range peakHours {
443 hourStrs = append(hourStrs, fmt.Sprintf("%02d:00", h))
444 }
445 fmt.Printf(" %s %s\n", i18n.T("mem.cmd.stats.peak_hours"), strings.Join(hourStrs, ", "))
446 }
447
448 // Top commands
449 topCmds := mgr.Patterns.GetTopCommands(5)
450 if len(topCmds) > 0 {
451 fmt.Printf(" %s %s\n", i18n.T("mem.cmd.stats.top_commands"), strings.Join(topCmds, ", "))
452 }
453
454 // Top features
455 if len(stats.FeatureUsage) > 0 {
456 var features []string
457 for f, c := range stats.FeatureUsage {
458 features = append(features, fmt.Sprintf("%s(%d)", f, c))
459 }
460 fmt.Printf(" %s %s\n", i18n.T("mem.cmd.stats.features"), strings.Join(features, ", "))
461 }
462
463 // Common errors
464 if len(stats.CommonErrors) > 0 {
465 fmt.Printf("\n %s\n", colorize(i18n.T("mem.cmd.stats.common_errors"), ColorYellow))
466 limit := 5
467 if len(stats.CommonErrors) < limit {
468 limit = len(stats.CommonErrors)
469 }
470 for _, ep := range stats.CommonErrors[:limit] {
471 fmt.Printf(" %s\n", i18n.T("mem.cmd.stats.error_pattern", ep.Pattern, ep.Count))
472 if ep.Resolution != "" {
473 fmt.Printf(" %s %s\n", i18n.T("mem.cmd.stats.fix"), ep.Resolution)
474 }
475 }

Callers 1

handleMemoryCommandMethod · 0.95

Calls 9

TFunction · 0.92
colorizeFunction · 0.85
ManagerMethod · 0.80
GetStatsMethod · 0.80
GetPeakHoursMethod · 0.80
GetTopCommandsMethod · 0.80
IsZeroMethod · 0.80
CountMethod · 0.65
GetAllMethod · 0.45

Tested by

no test coverage detected