@tokz/cli 0.0.1 → 0.2.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 +78 -0
- package/dist/Fullscreen-GK2ZYXHV.js +26 -0
- package/dist/Root-T6AZELSZ.js +1499 -0
- package/dist/chunk-MO4Y7IF6.js +404 -0
- package/dist/cli.js +108 -0
- package/package.json +35 -8
- package/cli.js +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# tokz
|
|
2
|
+
|
|
3
|
+
Audit where your coding agents' context windows — and API dollars — actually go.
|
|
4
|
+
|
|
5
|
+
Supports multiple agentic coders: **Claude Code** (`~/.claude/projects`),
|
|
6
|
+
**OpenAI Codex CLI** (`~/.codex/sessions` rollout files, cumulative
|
|
7
|
+
token-count deltas), and **OpenCode** (`~/.local/share/opencode/storage`).
|
|
8
|
+
Gemini CLI and Cursor CLI are detected and listed; their session formats
|
|
9
|
+
aren't parsed yet. The TUI opens with an agent picker — choose which agent's
|
|
10
|
+
analytics to explore; everything downstream (projects, dashboards,
|
|
11
|
+
timeframes) is scoped to it.
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx @tokz/cli # interactive TUI: browse projects, drill into charts
|
|
15
|
+
npx @tokz/cli audit # static report for the current project
|
|
16
|
+
npx @tokz/cli audit --all # static report across every project on this machine
|
|
17
|
+
|
|
18
|
+
npm i -g @tokz/cli # installs the `tokz` command
|
|
19
|
+
tokz # then just: tokz
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Interactive TUI
|
|
23
|
+
|
|
24
|
+
Bare `tokz` launches a full-screen terminal UI (Ink) with a live parse
|
|
25
|
+
progress bar, then a landing screen of stat cards — total cost, monthly
|
|
26
|
+
projection, sessions, turns, cache hit rate — plus a 30-day activity
|
|
27
|
+
sparkline.
|
|
28
|
+
|
|
29
|
+
From there:
|
|
30
|
+
|
|
31
|
+
- **Project list** — every project by short name (real paths recovered from
|
|
32
|
+
the transcripts themselves), ranked by cost, with session count, last
|
|
33
|
+
activity, and share bars, plus a pinned **All projects** row. Press `/` to
|
|
34
|
+
filter by name, `s` to cycle sorting (cost · recent · name), `a` to jump to
|
|
35
|
+
the aggregate view.
|
|
36
|
+
- **Dashboard** (per project or aggregated) — six tabs, switched with `1–6`
|
|
37
|
+
or `←`/`→`:
|
|
38
|
+
1. **Overview** — stat cards, 30-day cost sparkline with peak day, cost by
|
|
39
|
+
model, top tools, unused-server warning.
|
|
40
|
+
2. **Models** — per-model token table (input / cache read / cache write /
|
|
41
|
+
output / turns), cost and share, plus the total cost split.
|
|
42
|
+
3. **Tools** — top tools ranked by estimated cost (each turn's bill split
|
|
43
|
+
across the tools that turn called) with call counts and share; MCP tools
|
|
44
|
+
highlighted.
|
|
45
|
+
4. **Servers** — every MCP server with calls observed and estimated cost.
|
|
46
|
+
Covers both configured servers (`.mcp.json`, `~/.claude.json`) and ones
|
|
47
|
+
only visible in transcripts — plugin MCP servers and externally managed
|
|
48
|
+
configs — plus whether each is dead weight in your context window.
|
|
49
|
+
5. **Sessions** — costliest sessions with date, wall-clock length, turns,
|
|
50
|
+
tool calls, and dominant model.
|
|
51
|
+
6. **Activity** — daily cost bars with turn counts, average per active day.
|
|
52
|
+
- **Timeframe** — press `t` anywhere to cycle All time · Today · Yesterday ·
|
|
53
|
+
Last 7 days · Last 30 days; every list, chart, and total rescopes to that
|
|
54
|
+
window (`--days N` does the same for the static report).
|
|
55
|
+
- `?` shows a help overlay, `esc` goes back, `q` quits.
|
|
56
|
+
|
|
57
|
+
The layout is responsive: on narrow terminals the list drops columns (share
|
|
58
|
+
bar, then last-active, then sessions), tables keep only their key columns,
|
|
59
|
+
tab labels collapse to numbers, and the banner shrinks — nothing wraps or
|
|
60
|
+
breaks down to ~35 columns.
|
|
61
|
+
|
|
62
|
+
Piped or non-interactive, `tokz` falls back to the static aggregate report
|
|
63
|
+
automatically.
|
|
64
|
+
|
|
65
|
+
## What it measures
|
|
66
|
+
|
|
67
|
+
Reads Claude Code transcripts (`~/.claude/projects/**/*.jsonl`) and MCP configs
|
|
68
|
+
(`.mcp.json`, `~/.claude.json`). Reports real billed token usage per model
|
|
69
|
+
(input / cache read / cache write / output), dollar cost at current Anthropic
|
|
70
|
+
pricing, a monthly projection, cache hit rate and estimated cache savings,
|
|
71
|
+
per-tool call counts, per-day activity, per-session cost, and — the headline —
|
|
72
|
+
**MCP servers you pay to load on every turn but never call**.
|
|
73
|
+
|
|
74
|
+
Costs are API-equivalent: what these tokens would bill at Anthropic
|
|
75
|
+
pay-as-you-go rates. On a Pro/Max subscription treat it as value received,
|
|
76
|
+
not a bill.
|
|
77
|
+
|
|
78
|
+
100% offline. No API key, no telemetry, nothing leaves your machine.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/ui/Fullscreen.tsx
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
|
+
import { Box } from "ink";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
function size() {
|
|
8
|
+
return { cols: process.stdout.columns || 80, rows: process.stdout.rows || 24 };
|
|
9
|
+
}
|
|
10
|
+
function Fullscreen({ children }) {
|
|
11
|
+
const [dim, setDim] = useState(size);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
const tty = process.stdout.isTTY;
|
|
14
|
+
if (tty) process.stdout.write("\x1B[?1049h\x1B[H");
|
|
15
|
+
const onResize = () => setDim(size());
|
|
16
|
+
process.stdout.on("resize", onResize);
|
|
17
|
+
return () => {
|
|
18
|
+
process.stdout.off("resize", onResize);
|
|
19
|
+
if (tty) process.stdout.write("\x1B[?1049l");
|
|
20
|
+
};
|
|
21
|
+
}, []);
|
|
22
|
+
return /* @__PURE__ */ jsx(Box, { width: dim.cols, height: dim.rows, flexDirection: "column", padding: 1, children });
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
Fullscreen
|
|
26
|
+
};
|