tokenmeter-dashboard 0.2.0__tar.gz

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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Serkan Korkut
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,168 @@
1
+ Metadata-Version: 2.4
2
+ Name: tokenmeter-dashboard
3
+ Version: 0.2.0
4
+ Summary: Local token usage, cost and limits dashboard for Claude Code, Codex and GitHub Copilot CLI
5
+ Author: Serkan Korkut
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/serkankorkut/tokenmeter
8
+ Project-URL: Source, https://github.com/serkankorkut/tokenmeter
9
+ Keywords: claude-code,codex,copilot,tokens,cost,dashboard,llm
10
+ Classifier: Environment :: Web Environment
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Software Development
16
+ Classifier: Topic :: System :: Monitoring
17
+ Requires-Python: >=3.9
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Dynamic: license-file
21
+
22
+ # Tokenmeter
23
+
24
+ ![Tokenmeter demo](https://raw.githubusercontent.com/serkankorkut/tokenmeter/main/docs/demo.gif)
25
+
26
+ A local dashboard that shows token usage and estimated cost for every prompt you send in **Claude Code** and **Codex**. Zero dependencies: one Python file, one HTML file, nothing leaves your machine.
27
+
28
+ ## What you get
29
+
30
+ - Live feed of every model turn from **Claude Code**, **Codex** and **GitHub Copilot CLI**, updated a few seconds after each prompt finishes
31
+ - Spend tile that shows what you actually pay first (your subscription, prorated to the range) with the API-equivalent cost underneath, or the API cost on top if you have no plan configured
32
+ - Usage limits: Codex 5-hour and weekly windows as Codex reports them, plus rolling 5-hour and 7-day usage for every tool
33
+ - Active sessions with a context-fill gauge, so you see compaction coming
34
+ - Every prompt with its text, the turns it triggered, tokens, cost and duration, plus a resume command. Click any header to sort by date, tokens, cost, turns or duration
35
+ - Cache-miss detector: turns where the cached prefix collapsed and had to be re-written, with the prompt that was in progress and what the re-write cost
36
+ - Most expensive prompts, cost per git commit, cost mix by token type, and breakdowns by model, project and session
37
+ - Budget alerts: set a daily or monthly cap and get a desktop notification when you cross it
38
+ - Team mode: teammates export daily aggregates to one shared Tokenmeter and you filter by person
39
+ - Menu bar widget for SwiftBar or xbar showing today's spend
40
+ - Filters for time range, tool, project, model and user, kept in the URL so views are bookmarkable, plus CSV export and light and dark themes
41
+
42
+ ## How it works
43
+
44
+ Nothing is installed inside Claude Code or Codex. Both tools already save every conversation to a log file on your disk, and each model reply in that log includes how many tokens it used. Tokenmeter just reads those logs.
45
+
46
+ 1. Claude Code saves logs in `~/.claude/projects/`, Codex in `~/.codex/sessions/`, Copilot CLI in `~/.copilot/session-store.db`.
47
+ 2. `server.py` reads every log once, pulls out each prompt and each model reply with its token counts, and keeps them in memory.
48
+ 3. It multiplies tokens by the prices in `pricing.json` to estimate cost.
49
+ 4. It serves a web page at `http://127.0.0.1:7788`. The page asks the server every 4 seconds if anything changed and redraws when it has.
50
+
51
+ When you send a new prompt, the tool appends to its log, Tokenmeter notices the file grew, re-reads that one file, and the new turn shows up. Only your machine is involved. Nothing is sent anywhere.
52
+
53
+ The `/tokenmeter` skill is just a shortcut that starts `server.py` and gives you the link.
54
+
55
+ ## Install
56
+
57
+ Any machine with Python 3.9 or newer. Pick one:
58
+
59
+ ```bash
60
+ brew install serkankorkut/tap/tokenmeter
61
+ ```
62
+
63
+ ```bash
64
+ pipx install tokenmeter-dashboard
65
+ ```
66
+
67
+ ```bash
68
+ uvx tokenmeter-dashboard
69
+ ```
70
+
71
+ Or, as a Claude Code plugin straight from GitHub:
72
+
73
+ ```bash
74
+ claude plugin marketplace add serkankorkut/tokenmeter
75
+ claude plugin install tokenmeter@tokenmeter
76
+ ```
77
+
78
+ Or clone and link, which also installs the Codex skill and the `tokenmeter` command:
79
+
80
+ ```bash
81
+ git clone https://github.com/serkankorkut/tokenmeter ~/repo/tokenmeter
82
+ ~/repo/tokenmeter/install.sh
83
+ ```
84
+
85
+ With Homebrew you can keep it running in the background: `brew services start tokenmeter`.
86
+
87
+ Then in either tool:
88
+
89
+ ```
90
+ /tokenmeter
91
+ ```
92
+
93
+ or from a shell:
94
+
95
+ ```bash
96
+ tokenmeter --open
97
+ ```
98
+
99
+ ## Configuration
100
+
101
+ Everything lives in `pricing.json` next to `server.py`:
102
+
103
+ | Key | Purpose |
104
+ |---|---|
105
+ | model prefixes | USD per million tokens: input, cache_read, cache_write_5m, cache_write_1h, output. Anthropic and OpenAI list prices are included |
106
+ | `_plans` | What you pay per month per tool. Drives the Subscription spend tile |
107
+ | `_budget` | `daily` and `monthly` caps in API-equivalent USD. Desktop notification once per period when exceeded |
108
+ | `_context_windows` | Context size by model prefix, for the context-fill gauge |
109
+
110
+ Environment and flags:
111
+
112
+ | Setting | Default | Purpose |
113
+ |---|---|---|
114
+ | `TOKENMETER_PORT` / `--port` | `7788` | Listen port |
115
+ | `--host` | `127.0.0.1` | Bind address. Use `0.0.0.0` only for a team server |
116
+ | `--open` | | Open the browser after starting |
117
+ | `--user NAME` | your login | Name shown in team mode |
118
+ | `--export URL` | | Push your last 30 days to a team server every hour. Prompt text is never sent |
119
+ | `TOKENMETER_TOKEN` | | Shared secret for team ingest, sent as `X-Tokenmeter-Token` |
120
+ | `CLAUDE_CONFIG_DIR`, `CODEX_HOME`, `COPILOT_DB` | `~/.claude`, `~/.codex`, `~/.copilot/session-store.db` | Where each tool keeps its logs |
121
+ | `TOKENMETER_DIR` | `~/.tokenmeter` | Where team data is stored |
122
+
123
+ ### What "% of tokens" means
124
+
125
+ In the model, project and session tables it is that row's share of all tokens in the current filter. It always sums to 100 percent across a table.
126
+
127
+ ### Limits
128
+
129
+ Codex writes its 5-hour and weekly quota usage into every session log, so Tokenmeter shows the real percentages and reset times, as of the last Codex turn. Anthropic does not write Claude plan usage to disk. If a Claude Code OAuth token is present in the macOS keychain Tokenmeter queries the usage endpoint; otherwise it shows rolling 5-hour and 7-day totals from the logs.
130
+
131
+ ### Team mode
132
+
133
+ On a shared machine: `tokenmeter --host 0.0.0.0` with `TOKENMETER_TOKEN` set. On each laptop: `tokenmeter --export http://that-host:7788` with the same token. The shared dashboard gains a user filter. Only token counts, models, project paths and timestamps travel; prompt text stays local.
134
+
135
+ ### Menu bar
136
+
137
+ Copy `menubar/tokenmeter.1m.sh` into your SwiftBar or xbar plugin folder. It shows today's spend and, on click, the 5-hour and monthly numbers.
138
+
139
+ ## API
140
+
141
+ | Endpoint | Returns |
142
+ |---|---|
143
+ | `GET /api/usage` | All records, prompts, and metadata as JSON |
144
+ | `GET /api/version` | Cheap change token, polled by the UI |
145
+ | `GET /api/export.csv?since=ISO` | CSV of records |
146
+ | `GET /api/summary` | Today, last 5 hours, month, projection, limits. Used by the menu bar widget |
147
+ | `GET /api/commits` | Recent commits per repo, for cost-per-commit |
148
+ | `POST /api/ingest` | Team mode receiver |
149
+ | `GET /api/health` | `{"ok": true, "app": "tokenmeter"}` |
150
+
151
+ ## Development
152
+
153
+ ```bash
154
+ python3 test_server.py
155
+ python3 -m tokenmeter --open
156
+ ```
157
+
158
+ Release: bump the version in `pyproject.toml` and `tokenmeter/__init__.py`, tag `vX.Y.Z` and push. The GitHub Action publishes to PyPI via trusted publishing. Then regenerate the Homebrew formula with `release/brew-formula.sh > ../homebrew-tap/Formula/tokenmeter.rb`.
159
+
160
+ ## Roadmap
161
+
162
+ - Gemini CLI, Cursor agent and OpenCode parsers once their transcript formats are pinned down
163
+ - Slack or email weekly digest
164
+ - Windows notification support for budget alerts
165
+
166
+ ## License
167
+
168
+ MIT
@@ -0,0 +1,147 @@
1
+ # Tokenmeter
2
+
3
+ ![Tokenmeter demo](https://raw.githubusercontent.com/serkankorkut/tokenmeter/main/docs/demo.gif)
4
+
5
+ A local dashboard that shows token usage and estimated cost for every prompt you send in **Claude Code** and **Codex**. Zero dependencies: one Python file, one HTML file, nothing leaves your machine.
6
+
7
+ ## What you get
8
+
9
+ - Live feed of every model turn from **Claude Code**, **Codex** and **GitHub Copilot CLI**, updated a few seconds after each prompt finishes
10
+ - Spend tile that shows what you actually pay first (your subscription, prorated to the range) with the API-equivalent cost underneath, or the API cost on top if you have no plan configured
11
+ - Usage limits: Codex 5-hour and weekly windows as Codex reports them, plus rolling 5-hour and 7-day usage for every tool
12
+ - Active sessions with a context-fill gauge, so you see compaction coming
13
+ - Every prompt with its text, the turns it triggered, tokens, cost and duration, plus a resume command. Click any header to sort by date, tokens, cost, turns or duration
14
+ - Cache-miss detector: turns where the cached prefix collapsed and had to be re-written, with the prompt that was in progress and what the re-write cost
15
+ - Most expensive prompts, cost per git commit, cost mix by token type, and breakdowns by model, project and session
16
+ - Budget alerts: set a daily or monthly cap and get a desktop notification when you cross it
17
+ - Team mode: teammates export daily aggregates to one shared Tokenmeter and you filter by person
18
+ - Menu bar widget for SwiftBar or xbar showing today's spend
19
+ - Filters for time range, tool, project, model and user, kept in the URL so views are bookmarkable, plus CSV export and light and dark themes
20
+
21
+ ## How it works
22
+
23
+ Nothing is installed inside Claude Code or Codex. Both tools already save every conversation to a log file on your disk, and each model reply in that log includes how many tokens it used. Tokenmeter just reads those logs.
24
+
25
+ 1. Claude Code saves logs in `~/.claude/projects/`, Codex in `~/.codex/sessions/`, Copilot CLI in `~/.copilot/session-store.db`.
26
+ 2. `server.py` reads every log once, pulls out each prompt and each model reply with its token counts, and keeps them in memory.
27
+ 3. It multiplies tokens by the prices in `pricing.json` to estimate cost.
28
+ 4. It serves a web page at `http://127.0.0.1:7788`. The page asks the server every 4 seconds if anything changed and redraws when it has.
29
+
30
+ When you send a new prompt, the tool appends to its log, Tokenmeter notices the file grew, re-reads that one file, and the new turn shows up. Only your machine is involved. Nothing is sent anywhere.
31
+
32
+ The `/tokenmeter` skill is just a shortcut that starts `server.py` and gives you the link.
33
+
34
+ ## Install
35
+
36
+ Any machine with Python 3.9 or newer. Pick one:
37
+
38
+ ```bash
39
+ brew install serkankorkut/tap/tokenmeter
40
+ ```
41
+
42
+ ```bash
43
+ pipx install tokenmeter-dashboard
44
+ ```
45
+
46
+ ```bash
47
+ uvx tokenmeter-dashboard
48
+ ```
49
+
50
+ Or, as a Claude Code plugin straight from GitHub:
51
+
52
+ ```bash
53
+ claude plugin marketplace add serkankorkut/tokenmeter
54
+ claude plugin install tokenmeter@tokenmeter
55
+ ```
56
+
57
+ Or clone and link, which also installs the Codex skill and the `tokenmeter` command:
58
+
59
+ ```bash
60
+ git clone https://github.com/serkankorkut/tokenmeter ~/repo/tokenmeter
61
+ ~/repo/tokenmeter/install.sh
62
+ ```
63
+
64
+ With Homebrew you can keep it running in the background: `brew services start tokenmeter`.
65
+
66
+ Then in either tool:
67
+
68
+ ```
69
+ /tokenmeter
70
+ ```
71
+
72
+ or from a shell:
73
+
74
+ ```bash
75
+ tokenmeter --open
76
+ ```
77
+
78
+ ## Configuration
79
+
80
+ Everything lives in `pricing.json` next to `server.py`:
81
+
82
+ | Key | Purpose |
83
+ |---|---|
84
+ | model prefixes | USD per million tokens: input, cache_read, cache_write_5m, cache_write_1h, output. Anthropic and OpenAI list prices are included |
85
+ | `_plans` | What you pay per month per tool. Drives the Subscription spend tile |
86
+ | `_budget` | `daily` and `monthly` caps in API-equivalent USD. Desktop notification once per period when exceeded |
87
+ | `_context_windows` | Context size by model prefix, for the context-fill gauge |
88
+
89
+ Environment and flags:
90
+
91
+ | Setting | Default | Purpose |
92
+ |---|---|---|
93
+ | `TOKENMETER_PORT` / `--port` | `7788` | Listen port |
94
+ | `--host` | `127.0.0.1` | Bind address. Use `0.0.0.0` only for a team server |
95
+ | `--open` | | Open the browser after starting |
96
+ | `--user NAME` | your login | Name shown in team mode |
97
+ | `--export URL` | | Push your last 30 days to a team server every hour. Prompt text is never sent |
98
+ | `TOKENMETER_TOKEN` | | Shared secret for team ingest, sent as `X-Tokenmeter-Token` |
99
+ | `CLAUDE_CONFIG_DIR`, `CODEX_HOME`, `COPILOT_DB` | `~/.claude`, `~/.codex`, `~/.copilot/session-store.db` | Where each tool keeps its logs |
100
+ | `TOKENMETER_DIR` | `~/.tokenmeter` | Where team data is stored |
101
+
102
+ ### What "% of tokens" means
103
+
104
+ In the model, project and session tables it is that row's share of all tokens in the current filter. It always sums to 100 percent across a table.
105
+
106
+ ### Limits
107
+
108
+ Codex writes its 5-hour and weekly quota usage into every session log, so Tokenmeter shows the real percentages and reset times, as of the last Codex turn. Anthropic does not write Claude plan usage to disk. If a Claude Code OAuth token is present in the macOS keychain Tokenmeter queries the usage endpoint; otherwise it shows rolling 5-hour and 7-day totals from the logs.
109
+
110
+ ### Team mode
111
+
112
+ On a shared machine: `tokenmeter --host 0.0.0.0` with `TOKENMETER_TOKEN` set. On each laptop: `tokenmeter --export http://that-host:7788` with the same token. The shared dashboard gains a user filter. Only token counts, models, project paths and timestamps travel; prompt text stays local.
113
+
114
+ ### Menu bar
115
+
116
+ Copy `menubar/tokenmeter.1m.sh` into your SwiftBar or xbar plugin folder. It shows today's spend and, on click, the 5-hour and monthly numbers.
117
+
118
+ ## API
119
+
120
+ | Endpoint | Returns |
121
+ |---|---|
122
+ | `GET /api/usage` | All records, prompts, and metadata as JSON |
123
+ | `GET /api/version` | Cheap change token, polled by the UI |
124
+ | `GET /api/export.csv?since=ISO` | CSV of records |
125
+ | `GET /api/summary` | Today, last 5 hours, month, projection, limits. Used by the menu bar widget |
126
+ | `GET /api/commits` | Recent commits per repo, for cost-per-commit |
127
+ | `POST /api/ingest` | Team mode receiver |
128
+ | `GET /api/health` | `{"ok": true, "app": "tokenmeter"}` |
129
+
130
+ ## Development
131
+
132
+ ```bash
133
+ python3 test_server.py
134
+ python3 -m tokenmeter --open
135
+ ```
136
+
137
+ Release: bump the version in `pyproject.toml` and `tokenmeter/__init__.py`, tag `vX.Y.Z` and push. The GitHub Action publishes to PyPI via trusted publishing. Then regenerate the Homebrew formula with `release/brew-formula.sh > ../homebrew-tap/Formula/tokenmeter.rb`.
138
+
139
+ ## Roadmap
140
+
141
+ - Gemini CLI, Cursor agent and OpenCode parsers once their transcript formats are pinned down
142
+ - Slack or email weekly digest
143
+ - Windows notification support for budget alerts
144
+
145
+ ## License
146
+
147
+ MIT
@@ -0,0 +1,35 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "tokenmeter-dashboard"
7
+ version = "0.2.0"
8
+ description = "Local token usage, cost and limits dashboard for Claude Code, Codex and GitHub Copilot CLI"
9
+ readme = "README.md"
10
+ license = {text = "MIT"}
11
+ requires-python = ">=3.9"
12
+ authors = [{name = "Serkan Korkut"}]
13
+ keywords = ["claude-code", "codex", "copilot", "tokens", "cost", "dashboard", "llm"]
14
+ classifiers = [
15
+ "Environment :: Web Environment",
16
+ "Intended Audience :: Developers",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Operating System :: OS Independent",
19
+ "Programming Language :: Python :: 3",
20
+ "Topic :: Software Development",
21
+ "Topic :: System :: Monitoring"
22
+ ]
23
+
24
+ [project.urls]
25
+ Homepage = "https://github.com/serkankorkut/tokenmeter"
26
+ Source = "https://github.com/serkankorkut/tokenmeter"
27
+
28
+ [project.scripts]
29
+ tokenmeter = "tokenmeter.server:main"
30
+
31
+ [tool.setuptools]
32
+ packages = ["tokenmeter"]
33
+
34
+ [tool.setuptools.package-data]
35
+ tokenmeter = ["index.html", "pricing.json"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1 @@
1
+ from tokenmeter.server import __version__
@@ -0,0 +1,3 @@
1
+ from tokenmeter.server import main
2
+
3
+ main()