Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <name>` | 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 <file>` | Inspect git diffs directly in the terminal |
| `/auto <goal>` | Autonomous coding agent workflow |
| `/voice [on/off]` | Toggle sound effects, barks, and chimes |
| `/speak <text>` | Text-to-speech audio reader |
| `/model <id>` | Dynamically switch models (e.g. `/model gemini-3.5-flash`, `/model gpt-4o`) |
| `/web <query>` | Performs a zero-key live web search and returns markdown summaries |
| `/read <path>` | Reads and displays syntax-highlighted code from any project file |
Expand Down
60 changes: 60 additions & 0 deletions internal/tools/stats.go
Original file line number Diff line number Diff line change
@@ -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()
}
16 changes: 16 additions & 0 deletions internal/ui/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,7 @@ func (m *Model) handleSlashCommand(input string) (tea.Model, tea.Cmd, bool) {
"- `/web <query>` — Live zero-key web search\n" +
"- `/voice [on|off]` — Toggle audio synthesis & chimes\n" +
"- `/speak <text>` — Read text aloud with system TTS\n" +
"- `/stats` — Live system telemetry, RAM & CPU dashboard\n" +
"- `/model <name>` — Switch active model dynamically\n" +
"- `/save [filename]` — Export conversation to Markdown file\n" +
"- `/exec <cmd>` or `$ <cmd>` — Run shell commands inside Kernel\n" +
Expand Down Expand Up @@ -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()
Expand Down
Loading