From a328e62cab6e9f6f81bba7691ab911199de75ff1 Mon Sep 17 00:00:00 2001 From: 404kernel Date: Mon, 19 Oct 2026 04:52:17 +0000 Subject: [PATCH] feat: add live system telemetry dashboard and update commands documentation --- README.md | 9 ++++++- internal/tools/stats.go | 60 +++++++++++++++++++++++++++++++++++++++++ internal/ui/model.go | 16 +++++++++++ 3 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 internal/tools/stats.go diff --git a/README.md b/README.md index ab8a5c1..9946725 100644 --- a/README.md +++ b/README.md @@ -131,7 +131,14 @@ Kernel includes a suite of instant commands accessible directly from the input b |---|---| | `/help` | Displays the interactive command and shortcuts reference | | `/clear` | Clears the viewport for a clean conversation | -| `/pet` | Pet Sparky! (+20 XP, restores affection to 100% ♥) | +| `/pet` | Pet companion (+20 XP, restores affection to 100% ♥) | +| `/skin ` | Change companion avatar (`cat`, `dragon`, `drone`, `dog`) | +| `/stats` | Live system telemetry, RAM & CPU dashboard | +| `/tree [dir]` | Visual directory tree explorer with file type icons | +| `/diff ` | Inspect git diffs directly in the terminal | +| `/auto ` | Autonomous coding agent workflow | +| `/voice [on/off]` | Toggle sound effects, barks, and chimes | +| `/speak ` | Text-to-speech audio reader | | `/model ` | Dynamically switch models (e.g. `/model gemini-3.5-flash`, `/model gpt-4o`) | | `/web ` | Performs a zero-key live web search and returns markdown summaries | | `/read ` | Reads and displays syntax-highlighted code from any project file | diff --git a/internal/tools/stats.go b/internal/tools/stats.go new file mode 100644 index 0000000..5fbeef7 --- /dev/null +++ b/internal/tools/stats.go @@ -0,0 +1,60 @@ +package tools + +import ( + "fmt" + "runtime" + "strings" + "time" +) + +var startTime = time.Now() + +type SystemTelemetry struct { + Uptime time.Duration + OS string + Arch string + GoVersion string + NumCPU int + Goroutines int + AllocMB float64 + TotalAllocMB float64 + SysMB float64 + NumGC uint32 +} + +// GetSystemTelemetry collects live runtime and hardware telemetry metrics +func GetSystemTelemetry() SystemTelemetry { + var m runtime.MemStats + runtime.ReadMemStats(&m) + + return SystemTelemetry{ + Uptime: time.Since(startTime), + OS: runtime.GOOS, + Arch: runtime.GOARCH, + GoVersion: runtime.Version(), + NumCPU: runtime.NumCPU(), + Goroutines: runtime.NumGoroutine(), + AllocMB: float64(m.Alloc) / (1024 * 1024), + TotalAllocMB: float64(m.TotalAlloc) / (1024 * 1024), + SysMB: float64(m.Sys) / (1024 * 1024), + NumGC: m.NumGC, + } +} + +// FormatSystemTelemetry renders a formatted cyberpunk stats dashboard +func FormatSystemTelemetry(t SystemTelemetry) string { + uptimeStr := t.Uptime.Round(time.Second).String() + + var b strings.Builder + b.WriteString("### 📊 System Telemetry & Hardware Status\n\n") + b.WriteString("```text\n") + b.WriteString("╭──────────────────────────┬──────────────────────────╮\n") + b.WriteString(fmt.Sprintf("│ Platform: %-12s │ Uptime: %-12s │\n", t.OS+"/"+t.Arch, uptimeStr)) + b.WriteString(fmt.Sprintf("│ CPU Cores: %-12d │ Goroutines: %-12d │\n", t.NumCPU, t.Goroutines)) + b.WriteString(fmt.Sprintf("│ Mem Alloc: %-9.2f MB │ Mem Sys: %-9.2f MB │\n", t.AllocMB, t.SysMB)) + b.WriteString(fmt.Sprintf("│ Garbage C: %-12d │ Go Version: %-12s │\n", t.NumGC, t.GoVersion)) + b.WriteString("╰──────────────────────────┴──────────────────────────╯\n") + b.WriteString("```\n") + + return b.String() +} diff --git a/internal/ui/model.go b/internal/ui/model.go index 22c5e02..0c921d2 100644 --- a/internal/ui/model.go +++ b/internal/ui/model.go @@ -529,6 +529,7 @@ func (m *Model) handleSlashCommand(input string) (tea.Model, tea.Cmd, bool) { "- `/web ` — Live zero-key web search\n" + "- `/voice [on|off]` — Toggle audio synthesis & chimes\n" + "- `/speak ` — Read text aloud with system TTS\n" + + "- `/stats` — Live system telemetry, RAM & CPU dashboard\n" + "- `/model ` — Switch active model dynamically\n" + "- `/save [filename]` — Export conversation to Markdown file\n" + "- `/exec ` or `$ ` — Run shell commands inside Kernel\n" + @@ -769,6 +770,21 @@ func (m *Model) handleSlashCommand(input string) (tea.Model, tea.Cmd, bool) { return m, nil, true } + // Live System Telemetry (/stats or /sys) + if cmd == "/stats" || cmd == "/sys" { + m.textInput.Reset() + telem := tools.GetSystemTelemetry() + formatted := tools.FormatSystemTelemetry(telem) + m.Messages = append(m.Messages, chatMessage{ + Role: "KERNEL", + Content: formatted, + Time: time.Now().Format("15:04"), + }) + m.pet.AddXP(10) + m.updateViewport() + return m, nil, true + } + // Interactive Directory Tree (/tree [dir]) if cmd == "/tree" { m.textInput.Reset()