token-rats 0.1.0 → 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 +11 -54
- package/dist/index.js +844 -989
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,23 +1,15 @@
|
|
|
1
1
|
# token-rats
|
|
2
2
|
|
|
3
|
-
> Strava for AI token burn — sync your Claude Code + Cursor
|
|
3
|
+
> Strava for AI token burn — sync your Claude Code + Cursor usage to your Token Rats leaderboard.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
npx token-rats login # one-time auth
|
|
9
|
-
npx token-rats sync #
|
|
9
|
+
npx token-rats sync # upload your usage
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
```
|
|
15
|
-
Install background sync? [Y/n]
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
Say yes once and you’re done. A native OS service (launchd on macOS, systemd `--user` on Linux) keeps watching your Claude Code, Cursor, and Codex logs and uploads new sessions automatically. No more `sync` runs, no cron jobs to babysit.
|
|
19
|
-
|
|
20
|
-
For a stable install across reboots, install globally rather than via npx:
|
|
12
|
+
Or install globally:
|
|
21
13
|
|
|
22
14
|
```bash
|
|
23
15
|
npm install -g token-rats
|
|
@@ -29,11 +21,7 @@ token-rats sync
|
|
|
29
21
|
| Command | Description |
|
|
30
22
|
|---|---|
|
|
31
23
|
| `token-rats login` | Open your browser to authenticate (device-code flow). Saves a token to `~/.config/token-rats/token`. |
|
|
32
|
-
| `token-rats sync` | Discover Claude Code
|
|
33
|
-
| `token-rats watch` | Run the watcher in your terminal (Ctrl-C to stop). Useful for debugging. |
|
|
34
|
-
| `token-rats watch --install` | Install the background watcher (launchd / systemd --user). |
|
|
35
|
-
| `token-rats watch --uninstall` | Remove the background watcher. |
|
|
36
|
-
| `token-rats watch --status` | Show whether the watcher is installed and running. |
|
|
24
|
+
| `token-rats sync` | Discover Claude Code logs and the Cursor cache, parse them, and upload counts to your leaderboard. |
|
|
37
25
|
| `token-rats whoami` | Show the currently signed-in account handle. |
|
|
38
26
|
| `token-rats logout` | Delete your stored credentials. |
|
|
39
27
|
| `token-rats --version` | Print the CLI version. |
|
|
@@ -42,42 +30,15 @@ token-rats sync
|
|
|
42
30
|
### Sync flags
|
|
43
31
|
|
|
44
32
|
```
|
|
45
|
-
token-rats sync [--dry-run] [--verbose] [--
|
|
33
|
+
token-rats sync [--dry-run] [--verbose] [--api-url <url>]
|
|
46
34
|
```
|
|
47
35
|
|
|
48
36
|
| Flag | Description |
|
|
49
37
|
|---|---|
|
|
50
38
|
| `--dry-run` | Parse files but do not upload. Prints what would be sent. |
|
|
51
39
|
| `--verbose` | Print which files were discovered and how many records each contains. |
|
|
52
|
-
| `--no-daemon` | Skip the post-sync prompt to install the background watcher. (`TOKEN_RATS_NO_DAEMON=1` does the same globally.) |
|
|
53
40
|
| `--api-url <url>` | Override the API base URL (useful for local dev or staging). |
|
|
54
41
|
|
|
55
|
-
### Watch flags
|
|
56
|
-
|
|
57
|
-
```
|
|
58
|
-
token-rats watch [--install | --uninstall | --status]
|
|
59
|
-
token-rats watch [--interval <ms>] [--verbose]
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
| Flag | Description |
|
|
63
|
-
|---|---|
|
|
64
|
-
| `--install` | Install the background watcher. Idempotent. |
|
|
65
|
-
| `--uninstall` | Remove the background watcher. |
|
|
66
|
-
| `--status` | Print install + running state and the log path. |
|
|
67
|
-
| `--interval <ms>` | Debounce window for file-change uploads. Default: 2000. |
|
|
68
|
-
| `--verbose` | Print per-file change events and uploads. |
|
|
69
|
-
|
|
70
|
-
## Background watcher details
|
|
71
|
-
|
|
72
|
-
- **Sources watched:** Claude Code (`~/.claude/projects/**/*.jsonl`), Codex rollouts, and Cursor's per-workspace SQLite cache.
|
|
73
|
-
- **Cursor polling:** every 90s, `stat()`-first, capped to the 10 most-recently-modified workspaces. Idle CPU is near zero.
|
|
74
|
-
- **macOS:** `~/Library/LaunchAgents/com.tokenrats.watch.plist`. Auto-restarts on crash and runs at login.
|
|
75
|
-
- **Linux:** `~/.config/systemd/user/token-rats-watch.service`. Auto-restarts on crash. For the watcher to survive logout, run once: `sudo loginctl enable-linger $USER`. Without it, the watcher resumes at your next login.
|
|
76
|
-
- **Windows:** not yet supported. Use `token-rats sync` for now.
|
|
77
|
-
- **Logs:** `~/.config/token-rats/logs/watch.log` (or `~/Library/Application Support/token-rats/logs/` on macOS).
|
|
78
|
-
- **Auth expiry:** if your session expires, the watcher backs off 10 minutes instead of crashing. Run `token-rats login` to recover; the watcher picks up on its own.
|
|
79
|
-
- **Upgrades:** when you `npm update -g token-rats`, just run `token-rats sync` once — the daemon re-installs against the new binary path automatically.
|
|
80
|
-
|
|
81
42
|
## What data is collected
|
|
82
43
|
|
|
83
44
|
**Token Rats reads usage counts only.** It reads:
|
|
@@ -99,16 +60,12 @@ Reads `~/.claude/projects/**/*.jsonl` (macOS/Linux) or `%USERPROFILE%\.claude\pr
|
|
|
99
60
|
|
|
100
61
|
### Cursor
|
|
101
62
|
|
|
102
|
-
Reads
|
|
103
|
-
- **macOS:** `~/Library/Application Support
|
|
104
|
-
- **Linux:** `~/.config
|
|
105
|
-
- **Windows:** `%APPDATA
|
|
106
|
-
|
|
107
|
-
Cursor doesn't store token counts on disk for most sessions, so per-request tokens are estimated from request type. Numbers are comparable across Token Rats users but won't match cursor.com to the token. If the Cursor database isn't found or can't be read, the CLI skips it silently.
|
|
108
|
-
|
|
109
|
-
### Codex
|
|
63
|
+
Reads the Cursor sqlite cache:
|
|
64
|
+
- **macOS:** `~/Library/Application Support/Cursor/User/globalStorage/state.vscdb`
|
|
65
|
+
- **Linux:** `~/.config/Cursor/User/globalStorage/state.vscdb`
|
|
66
|
+
- **Windows:** `%APPDATA%\Cursor\User\globalStorage\state.vscdb`
|
|
110
67
|
|
|
111
|
-
|
|
68
|
+
If the Cursor database is not found or cannot be read, the CLI skips it silently and continues with Claude Code data.
|
|
112
69
|
|
|
113
70
|
## Auth
|
|
114
71
|
|
|
@@ -128,4 +85,4 @@ Authentication uses a device-code flow:
|
|
|
128
85
|
|
|
129
86
|
Token Rats is open source. The CLI source is in [`packages/cli/`](.) and the parsers are in [`packages/parsers/`](../parsers/). You can inspect exactly what is read from your disk and what is sent to the server.
|
|
130
87
|
|
|
131
|
-
**Privacy posture:** Token Rats reads usage counts only — never prompts or completions. The parser source is in `packages/parsers/`. We literally can't read what you typed.
|
|
88
|
+
**Privacy posture:** Token Rats reads usage counts only — never prompts or completions. The parser source is in `packages/parsers/`. We literally can't read what you typed.
|