tokmon 0.5.0 → 0.5.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 (3) hide show
  1. package/README.md +55 -32
  2. package/dist/cli.js +20 -3
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,30 +1,33 @@
1
1
  # tokmon
2
2
 
3
- Terminal dashboard for Claude Code usage and costs. Tabbed interface with auto-refresh.
3
+ Terminal dashboard for Claude Code usage, costs, and rate limits.
4
4
 
5
5
  Built with [Ink](https://github.com/vadimdemedes/ink), TypeScript.
6
6
 
7
7
  ```
8
- ◉ tokmon · 2s 01:17:09 AM
8
+ ◉ tokmon · 2s 02:48:39 AM
9
9
 
10
- Dashboard Daily ←→ or 1-2
10
+ Dashboard Table Tab/←→
11
11
 
12
12
  ┃ Claude
13
13
 
14
- ┃ Today $166.10 252.7M tokens
15
- ┃ This Week $399.79 608.2M tokens
16
- ┃ This Month $1337.03 2.2B tokens
17
-
18
- ┃ Active Block 12m remaining
14
+ ┃ Today $372.55 614.9M tokens
15
+ ┃ This Week $606.23 970.5M tokens
16
+ ┃ This Month $1543.48 2.5B tokens
19
17
 
20
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━─ 96%
18
+ Burn rate $132.65/hr
19
+
20
+ ┃ Rate Limits
21
21
 
22
- $314.37 spent · ~$328.01 proj · $65.60/hr
22
+ Session ━━━━────────────────────────── 13% resets 4h 11m
23
+ ┃ Weekly ━━━━━━━━━━━━━───────────────── 44% resets 17h 11m
24
+ ┃ Sonnet ━───────────────────────────── 3% resets 2d 20h
25
+ ┃ Extra $0.00 / $42.50 limit
23
26
 
24
27
  ──────────────────────────────────────────────────
25
- Total $1337.03
28
+ Total $1543.48
26
29
 
27
- by David Ilie (davidilie.com)
30
+ by David Ilie (davidilie.com) · s=settings q=quit
28
31
  ```
29
32
 
30
33
  ## Quick Start
@@ -45,7 +48,7 @@ pnpm dlx tokmon
45
48
  npm install -g tokmon
46
49
  ```
47
50
 
48
- Then just run `tokmon`. Press `Ctrl+C` to exit.
51
+ Then just run `tokmon`. Press `q` to quit.
49
52
 
50
53
  ## Options
51
54
 
@@ -54,45 +57,65 @@ Then just run `tokmon`. Press `Ctrl+C` to exit.
54
57
  -h, --help Show help
55
58
  ```
56
59
 
57
- ```bash
58
- tokmon -i 5 # refresh every 5 seconds
59
- ```
60
+ ## Keybindings
60
61
 
61
- ## Views
62
+ | Key | Action |
63
+ |-----|--------|
64
+ | `Tab` / `←→` | Switch between Dashboard and Table |
65
+ | `1` `2` | Jump to view |
66
+ | `d` `w` `m` | Daily / Weekly / Monthly (in Table view) |
67
+ | `↑` `↓` | Scroll table |
68
+ | `PgUp` `PgDn` | Scroll table fast |
69
+ | `s` | Settings |
70
+ | `q` | Quit |
62
71
 
63
- Navigate between views with `←` `→` arrow keys, `Tab`, or number keys `1` `2`.
72
+ ## Views
64
73
 
65
74
  | View | Description |
66
75
  |------|-------------|
67
- | **Dashboard** | Today / week / month cost summaries, active 5-hour block with burn rate |
68
- | **Daily** | Per-day breakdown table with model, token, and cost columns (scrollable with `↑` `↓`) |
76
+ | **Dashboard** | Today / week / month cost summaries, burn rate ($/hr), real-time rate limits with reset countdowns |
77
+ | **Table → Daily** | Per-day breakdown with models, tokens, and costs (6 months of history) |
78
+ | **Table → Weekly** | Grouped by ISO week |
79
+ | **Table → Monthly** | Grouped by month |
80
+
81
+ ## Rate Limits
82
+
83
+ Fetches real billing data from Anthropic's OAuth API (reads your token from macOS Keychain automatically). Shows:
84
+
85
+ - **Session** — 5-hour utilization with reset countdown
86
+ - **Weekly** — 7-day utilization with reset countdown
87
+ - **Sonnet** — Sonnet-specific limits (if applicable)
88
+ - **Extra usage** — spend vs monthly limit
89
+
90
+ Polls every 2 minutes to stay within API rate limits.
91
+
92
+ ## Settings
93
+
94
+ Press `s` to open settings. Persisted to `~/.config/tokmon/config.json` (macOS/Linux) or `%APPDATA%\tokmon\config.json` (Windows).
95
+
96
+ - **Refresh interval** — adjust with `←→`
97
+ - **Clear screen** — on/off toggle
69
98
 
70
99
  ## How It Works
71
100
 
72
- Reads Claude Code's JSONL session logs directly from `~/.claude/projects/`. Calculates costs using Claude model pricing (Opus, Sonnet, Haiku). Caches file reads by mtime so subsequent refreshes are near-instant.
101
+ Reads Claude Code's JSONL session logs directly from `~/.claude/projects/`. Calculates costs using Claude model pricing (Opus, Sonnet, Haiku). Caches file reads by mtime so refreshes are near-instant.
102
+
103
+ Dashboard loads current month only (fast). Table loads 6 months lazily on first switch.
73
104
 
74
105
  Cross-platform: supports macOS, Linux, and Windows (`%APPDATA%`, `XDG_CONFIG_HOME`, `CLAUDE_CONFIG_DIR`).
75
106
 
76
107
  ## CI/CD
77
108
 
78
- Publishes to npm automatically via GitHub Actions when a version tag is pushed:
109
+ Publishes to npm via GitHub Actions on version tags:
79
110
 
80
111
  ```bash
81
- git tag v0.2.0 && git push --tags
112
+ git tag v0.5.0 && git push --tags
82
113
  ```
83
114
 
84
115
  ## Requirements
85
116
 
86
117
  - Node.js 20+
87
- - [Claude Code](https://docs.anthropic.com/en/docs/claude-code) (generates usage data in `~/.claude/projects/`)
88
-
89
- ## Tech Stack
90
-
91
- | Tool | Purpose |
92
- |------|---------|
93
- | Ink 5 | React terminal UI |
94
- | TypeScript 5.7+ | Strict mode |
95
- | tsup | Build |
118
+ - [Claude Code](https://docs.anthropic.com/en/docs/claude-code)
96
119
 
97
120
  ## Author
98
121
 
package/dist/cli.js CHANGED
@@ -198,11 +198,20 @@ async function fetchDashboard() {
198
198
  const todayStart = new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime();
199
199
  const weekDay = d.getDay();
200
200
  const weekStart = new Date(d.getFullYear(), d.getMonth(), d.getDate() - (weekDay === 0 ? 6 : weekDay - 1)).getTime();
201
+ const now = Date.now();
201
202
  const entries = await loadEntries(monthStart);
203
+ const todayEntries = entries.filter((e) => e.ts >= todayStart);
204
+ let burnRate = 0;
205
+ if (todayEntries.length > 0) {
206
+ const oldest = Math.min(...todayEntries.map((e) => e.ts));
207
+ const hrs = (now - oldest) / 36e5;
208
+ if (hrs > 0) burnRate = todayEntries.reduce((s, e) => s + e.cost, 0) / hrs;
209
+ }
202
210
  return {
203
- today: sum(entries.filter((e) => e.ts >= todayStart)),
211
+ today: sum(todayEntries),
204
212
  week: sum(entries.filter((e) => e.ts >= weekStart)),
205
- month: sum(entries.filter((e) => e.ts >= monthStart))
213
+ month: sum(entries.filter((e) => e.ts >= monthStart)),
214
+ burnRate
206
215
  };
207
216
  }
208
217
  async function fetchTable() {
@@ -615,7 +624,15 @@ function DashboardView({ data, billing }) {
615
624
  /* @__PURE__ */ jsx(Box, { height: 1 }),
616
625
  /* @__PURE__ */ jsx(SummaryRow, { label: "Today", summary: data.today }),
617
626
  /* @__PURE__ */ jsx(SummaryRow, { label: "This Week", summary: data.week }),
618
- /* @__PURE__ */ jsx(SummaryRow, { label: "This Month", summary: data.month })
627
+ /* @__PURE__ */ jsx(SummaryRow, { label: "This Month", summary: data.month }),
628
+ data.burnRate > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
629
+ /* @__PURE__ */ jsx(Box, { height: 1 }),
630
+ /* @__PURE__ */ jsxs(Box, { children: [
631
+ /* @__PURE__ */ jsx(Box, { width: 14, children: /* @__PURE__ */ jsx(Text, { dimColor: true, children: "Burn rate" }) }),
632
+ /* @__PURE__ */ jsx(Box, { width: 12, justifyContent: "flex-end", children: /* @__PURE__ */ jsx(Text, { color: "red", children: currency(data.burnRate) }) }),
633
+ /* @__PURE__ */ jsx(Text, { dimColor: true, children: "/hr" })
634
+ ] })
635
+ ] })
619
636
  ]
620
637
  }
621
638
  ),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tokmon",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Terminal dashboard for Claude Code usage and costs",
5
5
  "type": "module",
6
6
  "bin": {