token-rats 0.0.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 +92 -0
- package/dist/index.js +5681 -0
- package/package.json +36 -0
package/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# token-rats
|
|
2
|
+
|
|
3
|
+
> Strava for AI token burn — sync your Claude Code + Cursor usage to your Token Rats leaderboard.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx token-rats login # one-time auth
|
|
9
|
+
npx token-rats sync # upload your usage
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Or install globally:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install -g token-rats
|
|
16
|
+
token-rats sync
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Commands
|
|
20
|
+
|
|
21
|
+
| Command | Description |
|
|
22
|
+
|---|---|
|
|
23
|
+
| `token-rats login` | Open your browser to authenticate (device-code flow). Saves a token to `~/.config/token-rats/token`. |
|
|
24
|
+
| `token-rats sync` | Discover Claude Code logs and the Cursor cache, parse them, and upload counts to your leaderboard. |
|
|
25
|
+
| `token-rats whoami` | Show the currently signed-in account handle. |
|
|
26
|
+
| `token-rats logout` | Delete your stored credentials. |
|
|
27
|
+
| `token-rats --version` | Print the CLI version. |
|
|
28
|
+
| `token-rats help` | Print this help. |
|
|
29
|
+
|
|
30
|
+
### Sync flags
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
token-rats sync [--dry-run] [--verbose] [--api-url <url>]
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
| Flag | Description |
|
|
37
|
+
|---|---|
|
|
38
|
+
| `--dry-run` | Parse files but do not upload. Prints what would be sent. |
|
|
39
|
+
| `--verbose` | Print which files were discovered and how many records each contains. |
|
|
40
|
+
| `--api-url <url>` | Override the API base URL (useful for local dev or staging). |
|
|
41
|
+
|
|
42
|
+
## What data is collected
|
|
43
|
+
|
|
44
|
+
**Token Rats reads usage counts only.** It reads:
|
|
45
|
+
|
|
46
|
+
- Input token count
|
|
47
|
+
- Output token count
|
|
48
|
+
- Model name
|
|
49
|
+
- Session start/end timestamps
|
|
50
|
+
|
|
51
|
+
It does **not** read, store, or transmit any prompt or completion content.
|
|
52
|
+
|
|
53
|
+
The parser source code is in [`packages/parsers/`](../parsers/). You can audit exactly what is extracted before running `sync`. **We literally can't read what you typed.**
|
|
54
|
+
|
|
55
|
+
## Data sources
|
|
56
|
+
|
|
57
|
+
### Claude Code
|
|
58
|
+
|
|
59
|
+
Reads `~/.claude/projects/**/*.jsonl` (macOS/Linux) or `%USERPROFILE%\.claude\projects\**\*.jsonl` (Windows).
|
|
60
|
+
|
|
61
|
+
### Cursor
|
|
62
|
+
|
|
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`
|
|
67
|
+
|
|
68
|
+
If the Cursor database is not found or cannot be read, the CLI skips it silently and continues with Claude Code data.
|
|
69
|
+
|
|
70
|
+
## Auth
|
|
71
|
+
|
|
72
|
+
Authentication uses a device-code flow:
|
|
73
|
+
|
|
74
|
+
1. `token-rats login` calls the Token Rats API to get a one-time code and URL.
|
|
75
|
+
2. Your browser opens the URL automatically (or you can copy-paste it).
|
|
76
|
+
3. You sign in with GitHub on the web.
|
|
77
|
+
4. The CLI polls until approved, then saves your token to `~/.config/token-rats/token` (mode 0600 — readable only by you).
|
|
78
|
+
|
|
79
|
+
## Requirements
|
|
80
|
+
|
|
81
|
+
- Node.js ≥ 20
|
|
82
|
+
- A Token Rats account (sign up at [tokenrats.com](https://tokenrats.com))
|
|
83
|
+
|
|
84
|
+
## Privacy
|
|
85
|
+
|
|
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.
|
|
87
|
+
|
|
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.
|
|
89
|
+
|
|
90
|
+
## License
|
|
91
|
+
|
|
92
|
+
MIT
|