tokenrace 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.
- package/README.md +105 -1
- package/package.json +31 -6
package/README.md
CHANGED
|
@@ -1,2 +1,106 @@
|
|
|
1
1
|
# tokenrace
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
Real-time token, cost and session monitor for [Claude Code](https://claude.ai/code).
|
|
4
|
+
|
|
5
|
+
Run one command — tokenrace starts a local server that receives telemetry from Claude Code via OpenTelemetry and shows it in a live dashboard in your browser.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx tokenrace
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## What it shows
|
|
14
|
+
|
|
15
|
+
- **Tokens** — input, output and cache tokens per session and over time
|
|
16
|
+
- **Cost** — total cost, cost per project, cost per day
|
|
17
|
+
- **Sessions** — every Claude Code session with duration, model, tool calls
|
|
18
|
+
- **Projects** — group sessions by project, compare cost and efficiency
|
|
19
|
+
- **Tools** — which tools Claude uses most (Bash, Edit, Read…) and approval rate
|
|
20
|
+
- **Events** — live feed of every API request, tool use and hook
|
|
21
|
+
- **Agents** — tree view of multi-agent hierarchies
|
|
22
|
+
- **Cache efficiency** — cache hit rate and estimated savings
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Requirements
|
|
27
|
+
|
|
28
|
+
- Node.js 18 or later
|
|
29
|
+
- Claude Code CLI
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Setup
|
|
34
|
+
|
|
35
|
+
### 1. Start tokenrace
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npx tokenrace
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The dashboard opens automatically at `http://localhost:1337`.
|
|
42
|
+
|
|
43
|
+
### 2. Enable telemetry in Claude Code
|
|
44
|
+
|
|
45
|
+
Paste this in your terminal **before** running `claude`:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
export CLAUDE_CODE_ENABLE_TELEMETRY=1
|
|
49
|
+
export OTEL_METRICS_EXPORTER=otlp
|
|
50
|
+
export OTEL_LOGS_EXPORTER=otlp
|
|
51
|
+
export OTEL_EXPORTER_OTLP_PROTOCOL=http/json
|
|
52
|
+
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:1337
|
|
53
|
+
export OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=cumulative
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### 3. Label your session (optional)
|
|
57
|
+
|
|
58
|
+
You can tag sessions from the dashboard, or set a project name upfront:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
export OTEL_RESOURCE_ATTRIBUTES="project=my-project"
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### 4. Run Claude Code
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
claude
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Data appears in the dashboard immediately.
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Persistent data
|
|
75
|
+
|
|
76
|
+
tokenrace saves all data to `~/.tokenrace/data.json`. Data persists across restarts — use the **Reset** button in the dashboard to clear it.
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Options
|
|
81
|
+
|
|
82
|
+
| Environment variable | Default | Description |
|
|
83
|
+
|---|---|---|
|
|
84
|
+
| `TOKENRACE_PORT` | `1337` | Port for the dashboard and OTLP receiver |
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## How it works
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
Claude Code → OTLP HTTP/JSON → localhost:1337/v1/*
|
|
92
|
+
↓
|
|
93
|
+
in-memory store + ~/.tokenrace/data.json
|
|
94
|
+
↓
|
|
95
|
+
REST API + Server-Sent Events
|
|
96
|
+
↓
|
|
97
|
+
React dashboard at localhost:1337/
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
A single Node.js process handles everything: OTLP receiver, REST API, SSE stream and static file serving.
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## License
|
|
105
|
+
|
|
106
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tokenrace",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Monitor en tiempo real para Claude Code",
|
|
5
|
-
"bin": {
|
|
5
|
+
"bin": {
|
|
6
|
+
"tokenrace": "./bin/cli.js"
|
|
7
|
+
},
|
|
6
8
|
"type": "module",
|
|
7
9
|
"scripts": {
|
|
8
10
|
"start": "node bin/cli.js",
|
|
@@ -19,8 +21,31 @@
|
|
|
19
21
|
"devDependencies": {
|
|
20
22
|
"supertest": "^7.0.0"
|
|
21
23
|
},
|
|
22
|
-
"files": [
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
"files": [
|
|
25
|
+
"bin/",
|
|
26
|
+
"src/",
|
|
27
|
+
"dist/"
|
|
28
|
+
],
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=18"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"claude",
|
|
34
|
+
"claude-code",
|
|
35
|
+
"telemetry",
|
|
36
|
+
"dashboard",
|
|
37
|
+
"opentelemetry",
|
|
38
|
+
"otlp",
|
|
39
|
+
"tokens",
|
|
40
|
+
"cost"
|
|
41
|
+
],
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "https://github.com/franciscovaleromartin/tokenrace"
|
|
46
|
+
},
|
|
47
|
+
"homepage": "https://github.com/franciscovaleromartin/tokenrace#readme",
|
|
48
|
+
"bugs": {
|
|
49
|
+
"url": "https://github.com/franciscovaleromartin/tokenrace/issues"
|
|
50
|
+
}
|
|
26
51
|
}
|