llmtop 0.1.0 → 0.1.1

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.
Files changed (2) hide show
  1. package/README.md +59 -204
  2. package/package.json +4 -2
package/README.md CHANGED
@@ -1,260 +1,115 @@
1
1
  <div align="center">
2
2
 
3
3
  <picture>
4
- <source media="(prefers-color-scheme: dark)" srcset="docs/brand/svg/llmtop-lockup-reversed.svg">
5
- <img alt="llmtop" src="docs/brand/svg/llmtop-lockup.svg" width="360">
4
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nguyencanhtrung/llmtop/main/docs/brand/svg/llmtop-lockup-reversed.svg">
5
+ <img alt="llmtop" src="https://raw.githubusercontent.com/nguyencanhtrung/llmtop/main/docs/brand/svg/llmtop-lockup.svg" width="320">
6
6
  </picture>
7
7
 
8
8
  **Local usage and cost analytics for Claude Code, Codex and Antigravity**
9
9
 
10
- _Transcripts are archived into SQLite and priced on your own machine. The server binds to `127.0.0.1` only, and neither the server nor the dashboard makes a network request._
11
-
12
- [![License](https://img.shields.io/badge/license-MIT-blue)](#license)
13
- [![Node.js](https://img.shields.io/badge/node-%3E%3D22.15-blue)](package.json)
14
- [![Last commit](https://img.shields.io/github/last-commit/nguyencanhtrung/llmtop)](https://github.com/nguyencanhtrung/llmtop/commits/main)
15
-
16
- [Quickstart](#quickstart) · [Features](#features) · [Commands](#commands) · [Docs](#documentation) · [License](#license)
10
+ [![npm](https://img.shields.io/npm/v/llmtop?color=blue)](https://www.npmjs.com/package/llmtop)
11
+ [![Node.js](https://img.shields.io/badge/node-%3E%3D22.15-blue)](https://github.com/nguyencanhtrung/llmtop/blob/main/package.json)
12
+ [![License](https://img.shields.io/badge/license-MIT-blue)](https://github.com/nguyencanhtrung/llmtop/blob/main/LICENSE)
17
13
 
18
14
  <picture>
19
- <source media="(prefers-color-scheme: dark)" srcset="docs/assets/overview-dark.png">
20
- <img src="docs/assets/overview-light.png" alt="Overview dashboard showing output tokens, cost, sessions, cache reads, cache savings and output speed for the last 30 days with daily charts" width="900">
15
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nguyencanhtrung/llmtop/main/docs/assets/overview-dark.png">
16
+ <img src="https://raw.githubusercontent.com/nguyencanhtrung/llmtop/main/docs/assets/overview-light.png" alt="llmtop overview dashboard showing multi-provider tokens, cost, sessions and cache metrics" width="900">
21
17
  </picture>
22
18
 
23
- <sub>Every figure in these screenshots is synthetic demo data served by <code>make demo</code>.</sub>
19
+ <sub>Synthetic multi-provider demo data served by <code>make demo</code>.</sub>
24
20
 
25
21
  </div>
26
22
 
27
- ## Overview
23
+ ## Quickstart
24
+
25
+ ```bash
26
+ npm install -g llmtop
27
+ llmtop serve
28
+ ```
29
+
30
+ Or run without installing: `npx llmtop serve`. Open <http://localhost:4310>.
28
31
 
29
- llmtop is a local dashboard and CLI for developers using AI coding agents. It archives local transcripts from Claude Code (`~/.claude/projects`), Codex (`~/.codex/sessions`) and Antigravity CLI (`~/.gemini/antigravity-cli`), ingests them into SQLite through `node:sqlite`, and prices every request against [prices.md](prices.md). Providers with no local transcripts are skipped automatically. Seven views and a matching CLI answer what summary totals hide: which repository costs the most, which sessions ran long, which models and subagents did the work, why the prompt cache rebuilt, and what carrying long context costs.
32
+ - **Local-only:** Binds `127.0.0.1` only; zero telemetry, zero outbound requests, zero runtime npm dependencies.
33
+ - **Zero setup:** Automatically reads `~/.claude/projects`, `~/.codex/sessions`, and `~/.gemini/antigravity-cli`, skipping absent tools.
34
+ - **Persistent archive:** Copies transcripts into append-only `.jsonl.zst` frames and indexes them into SQLite (`node:sqlite`) under `~/.config/llmtop/data/`. Requires **Node.js 22.15+**.
30
35
 
31
- Nothing leaves your machine. The HTTP server binds to `127.0.0.1` only, and neither the server nor the browser app makes any outbound network request. Archives and the SQLite database live under `~/.config/llmtop/data/` by default: `archive/<provider>/` keeps an append-only copy of each transcript so history survives host deletion, while `usage.db` is disposable and rebuilt from the archive whenever the schema changes. Cost figures use list prices from [prices.md](prices.md); on a subscription plan, cost represents quota spent rather than direct billing.
36
+ ## Views
32
37
 
33
- ## Features
38
+ - **Overview & Projects:** Cost, output tokens, cache savings, speed, daily splits (model / provider / project / effort), and Git-aware project treemap.
39
+ - **Models & Subagents:** Request behavior, effort comparisons, and main-thread vs. delegated subagent work across providers.
40
+ - **Activity & Cache:** Working hours heatmap, tool calls, skill sources, and prompt cache rebuilds by cause (`start`, `compaction`, `idle`, `other`).
41
+ - **Context & Sessions:** Pre/post-compaction context cost, counterfactual compaction replay, and sortable bilingual (EN/VI) session explorer.
34
42
 
35
- - **Multi-provider transcript archiving.** Reads Claude Code, Codex and Antigravity CLI transcripts into append-only zstd-compressed frames under `~/.config/llmtop/data/archive/<provider>/`, keeping line numbers stable so `session:line` references never drift even if the host removes old files.
36
- - **Prompt cache rebuild analysis.** Tracks every cache rebuild, its extra write cost compared to reading, and its cause: session start, compaction, idle break past the cache lifetime (`5–15m`, `15–60m`, `>1h`), or other.
37
- - **Context and compaction replay.** Measures what each compaction costs, breaks down context-reading cost by carried context size, and replays main conversations counterfactually to compare compaction thresholds.
38
- - **Project cost treemap.** Groups sessions by repository (nearest `.git` directory above the session working directory, or folder name fallback) and sizes tiles by cost.
39
- - **Model and subagent breakdown.** Reports output and thinking tokens per request, requests per owner turn, tool calls and failure share, output speed, effort-level cost, and the share of work delegated to subagents by model.
40
- - **Sortable session explorer.** Lists every conversation with its title, length, model, cost, and cache lapse count.
41
- - **Matching CLI and dashboard.** Provides `scan`, `show`, `usage`, `prices`, and `serve` (with `--json` on listing commands). For the same window and filters, `usage` and the dashboard report identical totals.
42
- - **Bilingual local dashboard.** Built with Vite, React and TypeScript with automatic light/dark themes, English and Vietnamese UI strings, and zero runtime npm dependencies at install time (bundled UI assets + Node's built-in `node:sqlite`).
43
- - **Private by default.** Serves exclusively on `127.0.0.1` with no telemetry, remote API calls, or asset CDNs.
43
+ <details>
44
+ <summary><strong>More screenshots (light &amp; dark)</strong></summary>
44
45
 
45
46
  <p align="center">
46
47
  <picture>
47
- <source media="(prefers-color-scheme: dark)" srcset="docs/assets/cache-dark.png">
48
- <img src="docs/assets/cache-light.png" alt="Activity view showing prompt cache rebuilds by cause and extra cost" width="900">
48
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nguyencanhtrung/llmtop/main/docs/assets/models-dark.png">
49
+ <img src="https://raw.githubusercontent.com/nguyencanhtrung/llmtop/main/docs/assets/models-light.png" alt="Main thread and subagent output by model" width="880">
49
50
  </picture>
50
- <br>
51
- <sub>Cache rebuilds by cause and extra cost.</sub>
51
+ <br><sub>Main thread and subagent breakdown across providers.</sub>
52
52
  </p>
53
53
 
54
54
  <p align="center">
55
55
  <picture>
56
- <source media="(prefers-color-scheme: dark)" srcset="docs/assets/context-dark.png">
57
- <img src="docs/assets/context-light.png" alt="Context view replaying sessions with compaction at alternative thresholds against the current threshold" width="900">
56
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nguyencanhtrung/llmtop/main/docs/assets/treemap-dark.png">
57
+ <img src="https://raw.githubusercontent.com/nguyencanhtrung/llmtop/main/docs/assets/treemap-light.png" alt="Repository cost share treemap" width="880">
58
58
  </picture>
59
- <br>
60
- <sub>Compaction cost and counterfactual context replay across compaction points.</sub>
59
+ <br><sub>Repository cost share treemap.</sub>
61
60
  </p>
62
61
 
63
62
  <p align="center">
64
63
  <picture>
65
- <source media="(prefers-color-scheme: dark)" srcset="docs/assets/treemap-dark.png">
66
- <img src="docs/assets/treemap-light.png" alt="Projects view showing a treemap of cost per repository" width="900">
64
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nguyencanhtrung/llmtop/main/docs/assets/cache-dark.png">
65
+ <img src="https://raw.githubusercontent.com/nguyencanhtrung/llmtop/main/docs/assets/cache-light.png" alt="Prompt cache rebuilds by cause and extra cost" width="880">
67
66
  </picture>
68
- <br>
69
- <sub>Repository cost share treemap.</sub>
67
+ <br><sub>Prompt cache rebuilds by cause and extra cost.</sub>
70
68
  </p>
71
69
 
72
70
  <p align="center">
73
71
  <picture>
74
- <source media="(prefers-color-scheme: dark)" srcset="docs/assets/models-dark.png">
75
- <img src="docs/assets/models-light.png" alt="Subagents view showing output tokens per model for the main thread and delegated subagents" width="900">
72
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nguyencanhtrung/llmtop/main/docs/assets/context-dark.png">
73
+ <img src="https://raw.githubusercontent.com/nguyencanhtrung/llmtop/main/docs/assets/context-light.png" alt="Counterfactual compaction threshold replay" width="880">
76
74
  </picture>
77
- <br>
78
- <sub>Main thread and subagent output by model.</sub>
75
+ <br><sub>Compaction threshold replay.</sub>
79
76
  </p>
80
77
 
81
78
  <p align="center">
82
79
  <picture>
83
- <source media="(prefers-color-scheme: dark)" srcset="docs/assets/sessions-dark.png">
84
- <img src="docs/assets/sessions-light.png" alt="Sessions view showing a table of conversations sorted by cost" width="900">
80
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nguyencanhtrung/llmtop/main/docs/assets/sessions-dark.png">
81
+ <img src="https://raw.githubusercontent.com/nguyencanhtrung/llmtop/main/docs/assets/sessions-light.png" alt="Sortable sessions explorer" width="880">
85
82
  </picture>
86
- <br>
87
- <sub>Sortable sessions table with length, model, cost and cache lapses.</sub>
83
+ <br><sub>Sortable session explorer.</sub>
88
84
  </p>
89
85
 
90
- ## Prerequisites
91
-
92
- - **Node.js 22.15 or later** (required by [package.json](package.json) for built-in `node:sqlite` and zstd support) and **npm**
93
- - **Local agent transcripts** from at least one supported tool (`~/.claude/projects`, `~/.codex/sessions`, or `~/.gemini/antigravity-cli`); optional if previewing with `make demo`
94
- - Optional: **`make`** for convenience targets (every workflow also runs directly via `npm` and `node`)
95
- - Optional: **Google Chrome or Chromium** only if regenerating README screenshots with `make screenshots` (set `CHROME` to override the binary path)
96
-
97
- ## Quickstart
98
-
99
- Install globally from npm (zero runtime dependencies):
100
-
101
- ```bash
102
- npm install -g llmtop
103
- llmtop serve
104
- ```
105
-
106
- Or run once without installing:
107
-
108
- ```bash
109
- npx llmtop serve
110
- ```
111
-
112
- Open <http://localhost:4310>. Your first visit scans local transcripts into `~/.config/llmtop/data/`; use the Refresh button in the sidebar footer to scan again. Pass `--port <n>` to `llmtop serve` to use another port, or press `Ctrl+C` to stop.
113
-
114
- <details>
115
- <summary><strong>From source (development)</strong></summary>
116
-
117
- ```bash
118
- git clone https://github.com/nguyencanhtrung/llmtop.git
119
- cd llmtop
120
- make start
121
- ```
122
-
123
- `make start` installs dependencies via `npm ci` when needed, builds `dashboard/dist`, starts the server in the background on `http://localhost:4310` (`data/serve.pid`, `data/serve.log`), and returns once ready. Stop it anytime with `make stop`. Without `make`, run `npm install` then `npm start`.
124
-
125
- To explore ten weeks of synthetic usage data without scanning your local transcripts, run `make demo` and open <http://localhost:4311>.
126
-
127
86
  </details>
128
87
 
129
- ## Commands
88
+ ## CLI
130
89
 
131
- | CLI command | `make` target | What it does |
132
- | --- | --- | --- |
133
- | `llmtop serve [--port n]` | `make start` | Serve the dashboard on `http://localhost:<port>` (`make start` runs in the background) |
134
- | | `make stop` | Stop the background server started by `make start` |
135
- | `npm run dev` | `make dev` | Serve the dashboard with Vite hot reload in the foreground |
136
- | `node test/fixtures/demo.mjs` | `make demo` | Serve ten weeks of synthetic demo data at `http://localhost:4311` |
137
- | `llmtop scan` | `make scan` | Archive new transcript lines and ingest them into `usage.db` |
138
- | `llmtop usage --days 30 --by model` | `make usage DAYS=30 BY=model` | Show tokens and cost in the terminal; `ARGS="..."` passes extra flags |
139
- | `llmtop prices` | `make prices` | Check [prices.md](prices.md) against host-recorded session costs |
140
- | `npm test` | `make test` | Run the `node --test` suite on synthetic data |
141
- | `npm run check` | `make check` | Type-check `dashboard/` with TypeScript |
142
- | `npm run build` | `make build` | Type-check and build `dashboard/dist` |
90
+ CLI and dashboard totals stay identical for the same window and filters (`--json` supported on listing commands).
143
91
 
144
- Run `make` alone to list targets. Full CLI reference:
145
-
146
- ```text
147
- llmtop scan archive new transcript lines and ingest them
148
- llmtop show <session>:<line> print one archived record
92
+ ```bash
93
+ llmtop serve [--port n] # Dashboard at http://localhost:4310
94
+ llmtop scan # Archive new transcript lines into usage.db
149
95
  llmtop usage [--days n | --since d --until d] [--by day|model|provider|effort|project|session|hour|tool|skill|subagent]
150
- [--provider name] [--project name] [--model family] [--effort level]
151
- llmtop prices the price table checked against the host's cost records
152
- llmtop serve [--port n] the built dashboard on http://localhost:<port>
153
- llmtop --help | --version show CLI usage or installed version
96
+ [--provider name] [--project name] [--model family] [--effort level] [--json]
97
+ llmtop prices [--json] # Verify prices.md against host cost records
98
+ llmtop show <session>:<line> # Print one archived record
99
+ llmtop --help | --version
154
100
  ```
155
101
 
156
- Listing commands accept `--json`. For one window and one set of filters, `usage` and the dashboard report the same totals.
102
+ ## Configuration
157
103
 
158
- ## How it works
104
+ Optional settings live in `~/.config/llmtop/config.json` (see [llmtop.config.example.json](https://github.com/nguyencanhtrung/llmtop/blob/main/llmtop.config.example.json)). Override paths with `XDG_CONFIG_HOME`, `LLMTOP_CONFIG`, or `LLMTOP_DATA`. Token rates come from [prices.md](https://github.com/nguyencanhtrung/llmtop/blob/main/prices.md).
159
105
 
160
- <details>
161
- <summary><strong>Where data lives</strong></summary>
106
+ ## Development
162
107
 
163
- ```text
164
- ~/.config/llmtop/
165
- ├── config.json optional configuration file
166
- └── data/
167
- ├── archive/
168
- │ ├── claude/ append-only .jsonl.zst frames, line numbers stable
169
- │ ├── codex/ append-only .jsonl.zst frames + session_index.jsonl
170
- │ └── agy/ append-only .jsonl.zst frames
171
- └── usage.db SQLite database rebuilt from archive on schema changes
108
+ ```bash
109
+ git clone https://github.com/nguyencanhtrung/llmtop.git && cd llmtop
110
+ make start # Build dashboard and serve at http://localhost:4310 (make stop to end)
111
+ make demo # Serve 10 weeks of synthetic data at http://localhost:4311
112
+ make test # Run node --test suite (make check / make build / make screenshots)
172
113
  ```
173
114
 
174
- The archive preserves transcripts even if the host tool later deletes them. Deleting `usage.db` is safe and the next `llmtop scan` rebuilds it from `archive/`. In a cloned repository, if `llmtop.config.json` exists in the repo root and `~/.config/llmtop/config.json` does not, the local repo config is still used for convenience.
175
-
176
- A session's project is resolved to the nearest directory at or above its working directory containing `.git`; if none exists, the directory's own name is used.
177
-
178
- </details>
179
-
180
- <details>
181
- <summary><strong>How cost is computed</strong></summary>
182
-
183
- When a host records session cost, llmtop preserves that total and spreads it across the session's requests weighted by their token counts priced on their date from [prices.md](prices.md) (USD per million tokens, effective from each row's `from` date until a later row for the same model). Sessions without a host cost record are estimated from [prices.md](prices.md) and marked as estimated. `prices` and the scan report highlight mismatches between host cost records and the table; append a new dated row when a price changes rather than editing historical rows.
184
-
185
- Each request cost is split into context reads, cache writes, output, and web search. Background calls not written to transcripts (such as Haiku calls for `WebSearch`) are split using host-recorded per-model token totals; web search covers cost above token prices on models that ran web searches. Models missing from [prices.md](prices.md) remain `"Not split"`.
186
-
187
- Cache savings compare each request's bill without the prompt cache (cache reads priced as uncached input) against the actual bill including cache write premiums. Because raw savings scale with total volume, the Overview compares periods using the share of cost spent reading context instead, where a rise indicates worse cache efficiency.
188
-
189
- </details>
190
-
191
- <details>
192
- <summary><strong>Cache rebuilds</strong></summary>
193
-
194
- Prompt caches make reading prior context cheap, while rebuilding the cache writes most of the context again at a much higher rate. llmtop flags a request as a rebuild when it writes at least 20,000 tokens to the cache and more than half of all tokens it read or wrote, or when it is the first request of a thread after a compaction and writes at least 20,000 tokens. The Activity view and `usage` group rebuilds by cause:
195
-
196
- | Cause | Meaning |
197
- | --- | --- |
198
- | At session start | First request of a thread (main conversation or subagent); unavoidable |
199
- | At compaction | A compaction occurred since the thread's previous request |
200
- | After idle | Gap since the previous request exceeded cache lifetime (`1h` if the latest write used 1h cache, else `5m`; bucketed as `5–15m`, `15–60m`, `>1h`) |
201
- | Other | Any other rebuild not explained by the causes above |
202
-
203
- Extra rebuild cost equals the rewritten tokens priced as cache writes (`5m` and `1h` as recorded, defaulting unsplit writes to `1h`) minus the same tokens priced as cache reads. The Sessions view surfaces idle rebuild counts per session as cache lapses. The `20,000`-token and `50%` thresholds are fixed conventions rather than host-reported events; models without a price row count rebuilds without an extra-cost figure.
204
-
205
- </details>
206
-
207
- <details>
208
- <summary><strong>Compaction and the context</strong></summary>
209
-
210
- When a conversation approaches its context limit, the agent writes a summary and continues from the compacted context. Transcripts record pre-compaction and post-compaction context sizes and durations when available; older transcripts with only summaries still count the compaction event.
211
-
212
- Each compaction costs the summary request plus the subsequent cache rebuild. Because summary requests are not written to transcripts directly, llmtop attributes host-recorded tokens beyond transcript requests evenly across a session's compactions per model.
213
-
214
- The Context view buckets context-reading cost by the context size carried by each request, with a dedicated row for unattributed host-recorded cost so totals match the Overview. The current compaction point is the median pre-compaction context across the last five automatic main-thread compactions per model family; counterfactual replay estimates total cost at alternative compaction thresholds using list prices (excluding files re-read after compaction, so thresholds below the current one may cost more in practice than shown).
215
-
216
- </details>
217
-
218
- <details>
219
- <summary><strong>Skills</strong></summary>
220
-
221
- The Activity view and `usage --by skill` count skill invocations by name across user slash commands that load a skill (excluding built-in commands like `/compact`) and agent skill calls, including failed calls. Each skill is grouped by where it was loaded from:
222
-
223
- | Source | Location |
224
- | --- | --- |
225
- | Project | `.claude/skills/` in a repository |
226
- | Personal | `~/.claude/skills/` |
227
- | Plugin | Installed plugin (`plugin:skill`) |
228
- | Built-in | Bundled agent skills |
229
- | Other | Unmatched or unrecorded directory |
230
-
231
- </details>
232
-
233
- <details>
234
- <summary><strong>Configuration (optional)</strong></summary>
235
-
236
- Create `~/.config/llmtop/config.json` (using [llmtop.config.example.json](llmtop.config.example.json) as a reference), or set `XDG_CONFIG_HOME` / `LLMTOP_CONFIG` to point elsewhere (`LLMTOP_DATA` overrides the data folder). All keys are optional; relative paths resolve from the config file's directory, and unknown keys pass through untouched.
237
-
238
- | Key | Default | Meaning |
239
- | --- | --- | --- |
240
- | `providers` | `{ "claude": { "transcripts": "~/.claude/projects" }, "codex": { "transcripts": "~/.codex/sessions" }, "agy": { "transcripts": "~/.gemini/antigravity-cli" } }` | Enabled transcript sources (`claude`, `codex`, `agy`); any other provider key raises an error |
241
- | `data` | `data` (inside `~/.config/llmtop`) | Directory for `archive/` and `usage.db` |
242
- | `port` | `4310` | HTTP server port |
243
- | `timeZone` | System time zone | Time zone used to bucket days and hours |
244
- | `prices` | `prices.md` bundled in package | Markdown price table |
245
-
246
- </details>
247
-
248
- ## Documentation
249
-
250
- | Topic | Document |
251
- | --- | --- |
252
- | Pricing table & model rates | [prices.md](prices.md) |
253
- | Example configuration | [llmtop.config.example.json](llmtop.config.example.json) |
254
- | Brand kit, logo rules & tokens | [Brand guide](docs/brand/README.md) · [Brand tokens](docs/brand/brand.json) |
255
- | Issues, branches, commits & PRs | [CONTRIBUTING.md](CONTRIBUTING.md) |
256
- | Agent guide & repository layout | [CLAUDE.md](CLAUDE.md) · [AGENTS.md](AGENTS.md) |
257
-
258
- ## License
259
-
260
- Licensed under the [MIT License](LICENSE) (`Copyright (c) 2026 Trung Nguyen`). Third-party dependencies retain their own licenses.
115
+ See [CONTRIBUTING.md](https://github.com/nguyencanhtrung/llmtop/blob/main/CONTRIBUTING.md) and [docs/brand/README.md](https://github.com/nguyencanhtrung/llmtop/blob/main/docs/brand/README.md). [MIT License](https://github.com/nguyencanhtrung/llmtop/blob/main/LICENSE).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "llmtop",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "description": "Local usage and cost analytics dashboard and CLI for Claude Code, Codex and Antigravity",
6
6
  "author": "Trung Nguyen",
@@ -29,7 +29,9 @@
29
29
  "publishConfig": {
30
30
  "access": "public"
31
31
  },
32
- "engines": { "node": ">=22.15.0" },
32
+ "engines": {
33
+ "node": ">=22.15.0"
34
+ },
33
35
  "bin": {
34
36
  "llmtop": "./bin/llmtop.mjs"
35
37
  },