claude-burn 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026
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.
package/README.md ADDED
@@ -0,0 +1,82 @@
1
+ # claude-burn
2
+
3
+ See which Claude Code sessions are eating your tokens and how fast.
4
+
5
+ Zero dependencies. Reads local JSONL files. Nothing leaves your machine.
6
+
7
+ ![claude-burn dashboard](screenshot.png)
8
+
9
+ ## Quick start
10
+
11
+ ```bash
12
+ npx claude-burn
13
+ ```
14
+
15
+ Opens a dashboard at `http://localhost:8787` with auto-refresh.
16
+
17
+ To install globally:
18
+
19
+ ```bash
20
+ npm install -g claude-burn
21
+ claude-burn
22
+ ```
23
+
24
+ ## Features
25
+
26
+ - **Active session detection** — see which sessions are running right now
27
+ - **Token breakdown** — input, output, cache read, cache write per session
28
+ - **Burn rate** — recent (last 3 min) and average (active time) tokens/min
29
+ - **Active vs idle time** — excludes idle gaps from duration calculations
30
+ - **Subagent tracking** — token usage per agent with model info on hover
31
+ - **Session share bar** — proportional token distribution across sessions
32
+ - **API cost equivalent** — what your usage would cost at API pricing (per model)
33
+ - **Timeline chart** — cumulative token growth over time
34
+ - **Search and sort** — filter sessions by title, sort by recent/tokens/burn rate
35
+ - **Keyboard shortcuts** — `R` refresh, `J/K` navigate, `/` search, `1-7` time filter
36
+ - **Auto-refresh** — every 5s for 24h and under, manual for longer ranges
37
+
38
+ ## Options
39
+
40
+ ```
41
+ claude-burn [options]
42
+
43
+ --port <n> Server port (default: 8787)
44
+ --data-dir <path> Claude data directory (default: ~/.claude/projects)
45
+ --no-open Don't auto-open browser
46
+ --version, -v Show version
47
+ --help, -h Show help
48
+ ```
49
+
50
+ ## Keyboard shortcuts
51
+
52
+ | Key | Action |
53
+ |-----|--------|
54
+ | `R` | Refresh data |
55
+ | `J` / `K` | Navigate sessions down / up |
56
+ | `/` | Focus search |
57
+ | `Esc` | Clear search |
58
+ | `1` - `7` | Time filter (1h, 6h, 12h, 24h, 3d, 7d, 30d) |
59
+
60
+ ## How it works
61
+
62
+ Claude Code stores a `.jsonl` file for every session in `~/.claude/projects/`. Each line contains timestamps, token usage, model info, and message content. This tool parses those files and displays the data in a local web dashboard.
63
+
64
+ Pricing is calculated per model:
65
+ | Model | Input | Output | Cache read | Cache write |
66
+ |-------|-------|--------|------------|-------------|
67
+ | Opus 4.6 | $5/M | $25/M | $0.50/M | $6.25/M |
68
+ | Sonnet 4.6 | $3/M | $15/M | $0.30/M | $3.75/M |
69
+ | Haiku 4.5 | $1/M | $5/M | $0.10/M | $1.25/M |
70
+
71
+ ## Requirements
72
+
73
+ - Node.js 18+
74
+ - Claude Code (session data must exist in `~/.claude/projects/`)
75
+
76
+ ## Privacy
77
+
78
+ All data stays on your machine. No analytics, no network calls, no telemetry. The server binds to `127.0.0.1` only.
79
+
80
+ ## License
81
+
82
+ MIT
@@ -0,0 +1,104 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { createServer, getAllSessions } = require('../src/server');
4
+ const { exec } = require('child_process');
5
+ const fs = require('fs');
6
+ const os = require('os');
7
+ const path = require('path');
8
+
9
+ const pkg = require('../package.json');
10
+ const args = process.argv.slice(2);
11
+
12
+ if (args.includes('--version') || args.includes('-v')) {
13
+ console.log(pkg.version);
14
+ process.exit(0);
15
+ }
16
+
17
+ if (args.includes('--help') || args.includes('-h')) {
18
+ console.log(`
19
+ \x1b[32mclaude-burn\x1b[0m v${pkg.version}
20
+ Monitor Claude Code token usage
21
+
22
+ Usage:
23
+ claude-burn [options]
24
+
25
+ Options:
26
+ --port <n> Server port (default: 8787)
27
+ --data-dir <path> Claude data directory (default: ~/.claude/projects)
28
+ --no-open Don't auto-open browser
29
+ --version, -v Show version
30
+ --help, -h Show this help
31
+ `);
32
+ process.exit(0);
33
+ }
34
+
35
+ function getArg(flag, defaultVal) {
36
+ const idx = args.indexOf(flag);
37
+ if (idx !== -1 && idx + 1 < args.length) return args[idx + 1];
38
+ return defaultVal;
39
+ }
40
+
41
+ const port = parseInt(getArg('--port', '8787'), 10);
42
+ const dataDir = getArg('--data-dir',
43
+ process.env.CLAUDE_CONFIG_DIR
44
+ ? path.join(process.env.CLAUDE_CONFIG_DIR, 'projects')
45
+ : path.join(os.homedir(), '.claude', 'projects')
46
+ );
47
+ const noOpen = args.includes('--no-open');
48
+
49
+ // Check if data directory exists
50
+ if (!fs.existsSync(dataDir)) {
51
+ console.log(`\n \x1b[32mclaude-burn\x1b[0m v${pkg.version}\n`);
52
+ console.log(` \x1b[31mNo Claude Code data found at:\x1b[0m ${dataDir}`);
53
+ console.log(` Make sure Claude Code is installed and has been used at least once.`);
54
+ console.log(` Or specify a custom path: claude-burn --data-dir /path/to/projects\n`);
55
+ process.exit(1);
56
+ }
57
+
58
+ // Count sessions
59
+ let sessionCount = 0;
60
+ try {
61
+ for (const dir of fs.readdirSync(dataDir)) {
62
+ const dirPath = path.join(dataDir, dir);
63
+ if (fs.statSync(dirPath).isDirectory()) {
64
+ for (const f of fs.readdirSync(dirPath)) {
65
+ if (f.endsWith('.jsonl')) sessionCount++;
66
+ }
67
+ }
68
+ }
69
+ } catch {}
70
+
71
+ const server = createServer({ port, dataDir });
72
+
73
+ server.listen(port, '127.0.0.1', () => {
74
+ const url = `http://localhost:${port}`;
75
+ console.log(`\n \x1b[32mclaude-burn\x1b[0m v${pkg.version}\n`);
76
+ console.log(` Dashboard: \x1b[4m${url}\x1b[0m`);
77
+ console.log(` Scanning: ${dataDir} (${sessionCount} sessions)`);
78
+ console.log(`\n Press \x1b[2mCtrl+C\x1b[0m to stop\n`);
79
+
80
+ if (!noOpen) {
81
+ const cmd = process.platform === 'darwin' ? `open "${url}"`
82
+ : process.platform === 'win32' ? `start "${url}"`
83
+ : `xdg-open "${url}"`;
84
+ exec(cmd, () => {});
85
+ }
86
+ });
87
+
88
+ server.on('error', (err) => {
89
+ if (err.code === 'EADDRINUSE') {
90
+ console.log(`\n \x1b[31mPort ${port} is already in use.\x1b[0m`);
91
+ console.log(` Try: claude-burn --port ${port + 1}\n`);
92
+ process.exit(1);
93
+ }
94
+ throw err;
95
+ });
96
+
97
+ // Graceful shutdown
98
+ function shutdown() {
99
+ console.log('\n Stopped.\n');
100
+ server.close(() => process.exit(0));
101
+ setTimeout(() => process.exit(0), 1000);
102
+ }
103
+ process.on('SIGINT', shutdown);
104
+ process.on('SIGTERM', shutdown);
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "claude-burn",
3
+ "version": "1.0.0",
4
+ "description": "Monitor Claude Code token usage, burn rate, and session attribution. Zero dependencies.",
5
+ "bin": {
6
+ "claude-burn": "./bin/claude-burn.js"
7
+ },
8
+ "files": [
9
+ "bin/",
10
+ "src/",
11
+ "public/"
12
+ ],
13
+ "keywords": [
14
+ "claude",
15
+ "claude-code",
16
+ "token-monitor",
17
+ "usage",
18
+ "anthropic",
19
+ "burn-rate",
20
+ "dashboard",
21
+ "cli",
22
+ "developer-tools"
23
+ ],
24
+ "author": "annsheronova",
25
+ "license": "MIT",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/annsheronova/claude-burn.git"
29
+ },
30
+ "homepage": "https://github.com/annsheronova/claude-burn",
31
+ "bugs": {
32
+ "url": "https://github.com/annsheronova/claude-burn/issues"
33
+ },
34
+ "engines": {
35
+ "node": ">=18.0.0"
36
+ }
37
+ }