Repository navigation
Expand file tree
/
Copy pathsidebar.go
More file actions
74 lines (62 loc) · 2.34 KB
/
Copy pathsidebar.go
File metadata and controls
74 lines (62 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package main
import (
"encoding/json"
"fmt"
"os"
"time"
)
// runSidebar runs the sidebar display loop. It reads the stats file every second
// and pretty-prints the stats with ANSI colors. This function never returns.
func runSidebar(statsFile string) {
for {
fmt.Print("\033[2J\033[H") // clear screen, cursor home
data, err := os.ReadFile(statsFile)
if err != nil {
fmt.Print("\033[90mWaiting for agent...\033[0m")
time.Sleep(time.Second)
continue
}
var s Stats
if err := json.Unmarshal(data, &s); err != nil {
fmt.Print("\033[90mReading stats...\033[0m")
time.Sleep(time.Second)
continue
}
model := s.ModelName
if model == "" {
model = "..."
}
ctx := fmt.Sprintf("%.0f%%", s.ContextPercent)
fmt.Println("\033[36m\u250c\u2500 Agent Stats \u2500\u2500\u2500\u2500\u2500\u2510\033[0m")
fmt.Println("\033[36m\u2502\033[0m \033[36m\u2502\033[0m")
fmt.Printf("\033[36m\u2502\033[0m Model: \033[93m%-9s\033[0m \033[36m\u2502\033[0m\n", model)
fmt.Printf("\033[36m\u2502\033[0m Context: \033[92m%-8s\033[0m \033[36m\u2502\033[0m\n", ctx)
fmt.Println("\033[36m\u2502\033[0m \033[36m\u2502\033[0m")
fmt.Printf("\033[36m\u2502\033[0m LLM calls: \033[97m%-5d\033[0m \033[36m\u2502\033[0m\n", s.LLMRoundTrips)
fmt.Printf("\033[36m\u2502\033[0m Tool calls: \033[97m%-5d\033[0m \033[36m\u2502\033[0m\n", s.ToolCallsMade)
fmt.Println("\033[36m\u2502\033[0m \033[36m\u2502\033[0m")
fmt.Printf("\033[36m\u2502\033[0m Sub-agents: \033[97m%d/%d\033[0m \033[36m\u2502\033[0m\n", s.SubAgentsActive, s.SubAgentsSpawned)
fmt.Println("\033[36m\u2502\033[0m \033[90m(active/total)\033[0m \033[36m\u2502\033[0m")
fmt.Println("\033[36m\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\033[0m")
time.Sleep(time.Second)
}
}
// printStatusBar reads the stats file and prints a single-line summary for
// the tmux status bar, then exits.
func printStatusBar(statsFile string) {
data, err := os.ReadFile(statsFile)
if err != nil {
fmt.Print("[starting...]")
return
}
var s Stats
if err := json.Unmarshal(data, &s); err != nil {
fmt.Print("[...]")
return
}
model := s.ModelName
if model == "" {
model = "?"
}
fmt.Printf("[ctx: %.0f%%] [%s]", s.ContextPercent, model)
}