pi-tps-web 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,109 @@
1
+ <div align="center">
2
+
3
+ # 📈 pi-tps-web
4
+
5
+ **Static telemetry inspector for pi's TPS exports**
6
+
7
+ _Drag a `.jsonl` session file — no upload, no cloud, no persistence. Everything stays in the browser._
8
+
9
+ [![pi extension](https://img.shields.io/badge/pi-extension-blueviolet)](https://github.com/earendil-works/pi-coding-agent)
10
+ [![license](https://img.shields.io/badge/license-MIT-blue)](./LICENSE)
11
+
12
+ </div>
13
+
14
+ ---
15
+
16
+ Built for provider engineers to inspect real-world LLM behavior: how cache hit rates shift as conversations grow, where the slow zones live, and whether routing thresholds land where they should.
17
+
18
+ ![preview](./public/preview.png)
19
+
20
+ ## What it shows
21
+
22
+ - **Conversation Timeline** — TTFT, total time, and generation speed plotted over the session lifetime.
23
+ - **TTFT vs Context Size** — Scatter plot with log/linear scale toggle. Color-coded by cache efficiency: fast cache hits in moss green, slow zone (32–65k) in ember, anomalies in amber.
24
+ - **TTFT Distribution** — Histogram of where time is spent across all calls, with median and fast/slow call counts.
25
+ - **Token Composition** — Stacked bar chart of cache read / new input / output for the last 30 requests.
26
+ - **Threshold Crossings** — Compare average TTFT below and above 32k, 50k, 65k, and 80k token thresholds. Progress bars and delta badges tell the routing story.
27
+ - **Anomaly Detector** — Automatic identification of cache drops (sub-agent spawns), slow-zone requests, stall spikes, and massive new-input events.
28
+ - **Cache Efficiency** — Donut chart with overall cache hit rate, token-type breakdown, and cache-rate bars over time.
29
+ - **Request Inspector** — Full list of all calls with inline TTFT, cache-hit badges, and provider/model tags. Model switches, rewinds, and branch summaries appear as contextual markers. Click to drill into one request's tokens, timing, model, and energy footprint.
30
+
31
+ ## Energy data
32
+
33
+ Energy and cost metrics come from the `pi-neuralwatt-provider` extension. If your `.jsonl` does not include energy events, those fields display `-` instead of hiding the UI entirely.
34
+
35
+ ## Usage
36
+
37
+ ### Standalone web app
38
+
39
+ ```bash
40
+ npm install
41
+ npm run dev # local dev
42
+ npm run build # static build to ./dist
43
+ ```
44
+
45
+ In production, serve `./dist` from any static host. The sample data at `./public/sample.jsonl` is included for demo purposes only and is removed by the existing `.gitignore`.
46
+
47
+ ### As a pi extension (alongside pi-tps)
48
+
49
+ pi-tps-web doubles as a pi extension that launches a local web server with the telemetry inspector pre-loaded with your session data. It works alongside `pi-tps` — together, pi-tps tracks TPS and pi-tps-web gives you the visual dashboard.
50
+
51
+ **Install from npm (recommended):**
52
+
53
+ ```bash
54
+ pi install npm:pi-tps-web
55
+ pi install npm:@monotykamary/pi-tps # for telemetry tracking
56
+ ```
57
+
58
+ **Or install from GitHub:**
59
+
60
+ ```bash
61
+ pi install git:github.com/monotykamary/pi-tps-web
62
+ pi install git:github.com/monotykamary/pi-tps
63
+ ```
64
+
65
+ **Or try with `-e` for a one-shot test:**
66
+
67
+ ```bash
68
+ pi -e /path/to/pi-tps-web
69
+ ```
70
+
71
+ > **Git installs:** The `dist/` directory is not tracked in git. On first `/tps-web` invocation, the extension auto-builds it by running `npm install && npx vite build` in the package directory. This only happens once — the build is cached in the git clone at `~/.pi/agent/git/`.
72
+
73
+ **Usage:**
74
+
75
+ Once both extensions are loaded, run the `/tps-web` slash command in pi:
76
+
77
+ ```
78
+ /tps-web # Export current branch telemetry → web inspector
79
+ /tps-web --full # Export all branches → web inspector
80
+ ```
81
+
82
+ This will:
83
+ 1. Export telemetry JSONL to `~/.cache/pi-telemetry/` (same as `/tps-export`)
84
+ 2. Open the folder in Finder/your file manager
85
+ 3. Start a local HTTP server on port 3141 (auto-increments if taken)
86
+ 4. Open the web inspector in your browser with the data pre-loaded
87
+
88
+ Re-running `/tps-web` updates the data and the dashboard auto-refreshes. The web app polls `/api/version` in the background and reloads when new data is available.
89
+
90
+ ## Data format
91
+
92
+ Expects the newline-delimited JSON format produced by `pi-tps` (via `/tps-export`). The export includes telemetry entries plus structural entries that capture the session's branching story:
93
+
94
+ ```jsonl
95
+ {"type":"model_change","id":"...","parentId":null,"timestamp":"...","provider":"neuralwatt","modelId":"moonshotai/Kimi-K2.6"}
96
+ {"type":"custom","customType":"tps","id":"...","parentId":"...","timestamp":"...","data":{"model":{"provider":"...","modelId":"..."},"tokens":{"input":...,"output":...,"cacheRead":...},"timing":{"ttftMs":...,"totalMs":...},...}}
97
+ {"type":"custom","customType":"neuralwatt-energy","id":"...","parentId":"...","timestamp":"...","data":{"energy_joules":...,"cost_usd":...}}
98
+ {"type":"custom","customType":"rewind-turn","id":"...","parentId":"...","timestamp":"...","data":{"v":2,"snapshots":[...],"bindings":[...]}}
99
+ {"type":"branch_summary","id":"...","parentId":"...","timestamp":"...","fromId":"...","summary":"..."}
100
+ ```
101
+
102
+ ### Tree structure
103
+
104
+ ParentIds are re-chained so the exported entries form a self-contained tree. The root is typically a `model_change` entry with `parentId: null`. Branching (rewinds) creates new children at earlier points in the tree, just like pi's native session tree.
105
+ ```
106
+
107
+ ## License
108
+
109
+ MIT