reread-cli 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +205 -2
- package/bin/reread.js +5 -0
- package/package.json +59 -4
- package/src/analyze.js +430 -0
- package/src/antigravity.js +190 -0
- package/src/args.js +155 -0
- package/src/claude.js +208 -0
- package/src/cli.js +127 -0
- package/src/codex.js +135 -0
- package/src/files.js +116 -0
- package/src/findings.js +122 -0
- package/src/format.js +23 -0
- package/src/meta.js +10 -0
- package/src/prices.js +172 -0
- package/src/render.js +213 -0
- package/src/report.html +1192 -0
- package/src/report.js +69 -0
- package/src/statusline.js +188 -0
- package/src/tools.js +137 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ReRead contributors
|
|
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
CHANGED
|
@@ -1,3 +1,206 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ReRead
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/reread-cli)
|
|
4
|
+
[](https://github.com/tecyfyai/reread/actions/workflows/test.yml)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
|
|
7
|
+
A token usage and prompt cache analyzer for Claude Code, Codex and Antigravity: see how much of your coding agent's
|
|
8
|
+
usage was re-reading context, not new work, and why.
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
npx reread-cli
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
It prints a summary and opens a full report in your browser, built on your machine from the session files Claude
|
|
15
|
+
Code, Codex and Antigravity already keep. Nothing is uploaded, and it has no dependencies. (The numbers below are sample data.)
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
52% of your Claude Code usage was re-reading context
|
|
19
|
+
the last 30 days · 120 sessions · 10,551 replies · $515 at API prices
|
|
20
|
+
|
|
21
|
+
Reading history from the cache 33.6% 95.2% of all tokens read
|
|
22
|
+
Writing history again 18.7% after the cache was lost
|
|
23
|
+
Everything else 47.7% new input, first cache writes, output
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Every reply in a session sends the whole conversation to the model again. Prompt caching makes those re-reads
|
|
27
|
+
cheaper, but in a long session they still add up, and when the cache is lost the whole history is written again at
|
|
28
|
+
full price. ReRead shows you the split, when and why the cache was lost, and which sessions cost the most.
|
|
29
|
+
|
|
30
|
+
Every tool with sessions on your machine is read; `--tool claude`, `--tool codex` or `--tool antigravity` picks one. Needs Node.js 20 or newer (22.15 or newer also reads Codex's archived sessions).
|
|
31
|
+
|
|
32
|
+
## The report
|
|
33
|
+
|
|
34
|
+

|
|
35
|
+
|
|
36
|
+
- **Key findings** first: a few cards, the costliest first, each with one number, what it means and what to do
|
|
37
|
+
(how much of your usage came from long contexts, how concentrated it is in a few sessions, what losing the cache
|
|
38
|
+
cost and why, how large your context grew before each compaction).
|
|
39
|
+
- **The split**: re-reading from the cache, history written again, and everything else.
|
|
40
|
+
- **By day**: what each day cost and how much of it was re-reading.
|
|
41
|
+
- **By context size**: how much of your usage came from replies with a large context (over 150k is where it adds up).
|
|
42
|
+
- **Why the cache was lost**: a break longer than its life (5 minutes or 1 hour), a model switch mid-session, or a
|
|
43
|
+
change near the start of the context (tools, MCP servers, settings).
|
|
44
|
+
- **By project and by model**, and by tool when you use more than one.
|
|
45
|
+
- **Sessions**: the 10 costliest, sortable and searchable across all of them, with their git branch. Open one to see
|
|
46
|
+
its context grow reply by reply, with each rebuild and compaction marked.
|
|
47
|
+
- **Share**: copy a line of text, or save an image card with no project names on it. Hide names in the whole report
|
|
48
|
+
with one switch before a screenshot.
|
|
49
|
+
- **Export** the numbers as JSON or the sessions as CSV.
|
|
50
|
+
|
|
51
|
+
The report is one HTML file, written to a new folder in your temp directory that only you can read (or to the file
|
|
52
|
+
you name with `--html`). It works offline, in light and dark mode.
|
|
53
|
+
|
|
54
|
+
## Cache countdown in your status line
|
|
55
|
+
|
|
56
|
+
`reread statusline` (Claude Code only) prints one line for Claude Code's status line: the context size, how long the cache stays warm,
|
|
57
|
+
and the session's re-read share. When the cache has gone cold, it says what the next reply will cost to write the
|
|
58
|
+
history again, so you can decide to compact or start fresh first.
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
ctx 176k · cache warm 3:41 · re-read 44%
|
|
62
|
+
ctx 176k · cache cold: next reply rewrites 176k (~$0.88) · re-read 44%
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
npm install -g reread-cli
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Then add it to `~/.claude/settings.json`:
|
|
70
|
+
|
|
71
|
+
```json
|
|
72
|
+
{
|
|
73
|
+
"statusLine": { "type": "command", "command": "reread statusline" }
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
More in [docs/statusline.md](docs/statusline.md).
|
|
78
|
+
|
|
79
|
+
## In VS Code
|
|
80
|
+
|
|
81
|
+
The [ReRead extension](vscode/README.md) shows the same countdown in the editor's status bar, for the latest Claude Code
|
|
82
|
+
session in your workspace, whether Claude Code runs in the terminal or in the editor. Click it for the report of that
|
|
83
|
+
workspace, in an editor tab. Install it from the
|
|
84
|
+
[VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=hamperpick.reread), or from
|
|
85
|
+
[Open VSX](https://open-vsx.org/extension/hamperpick/reread) for Cursor, Antigravity and other editors that use it.
|
|
86
|
+
|
|
87
|
+
## Options
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
npx reread-cli [options]
|
|
91
|
+
|
|
92
|
+
Range
|
|
93
|
+
--days <n> look back this many days (default 30; 0 = every session file still kept)
|
|
94
|
+
--since <date> start on this day instead (YYYY-MM-DD, local time)
|
|
95
|
+
--project <text> only sessions whose project folder contains this text
|
|
96
|
+
--tool <name> claude, codex, antigravity or all (default all: every tool with sessions here)
|
|
97
|
+
--dir <path> read the sessions in this folder only
|
|
98
|
+
|
|
99
|
+
Output
|
|
100
|
+
--text the summary only; no browser report
|
|
101
|
+
--html [file] write the report (default: a new private folder in your temp directory)
|
|
102
|
+
--no-open write the report but do not open it
|
|
103
|
+
--json all the numbers as JSON
|
|
104
|
+
--csv every session as CSV
|
|
105
|
+
--md a Markdown summary, to paste into an issue or a pull request
|
|
106
|
+
--by <what> add a breakdown to the summary: project, model, tool or day
|
|
107
|
+
--top <n> sessions in the summary (default 10)
|
|
108
|
+
--anon replace project names with "project 1", "project 2", ... and leave branches out
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Examples:
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
npx reread-cli --days 7 --by model # this week, by model
|
|
115
|
+
npx reread-cli --tool codex # Codex sessions only
|
|
116
|
+
npx reread-cli --project api --text # one project, terminal only
|
|
117
|
+
npx reread-cli --json | jq .summary # the numbers, for your own scripts
|
|
118
|
+
npx reread-cli --csv > sessions.csv # every session, for a spreadsheet
|
|
119
|
+
npx reread-cli --md --anon | pbcopy # a summary to paste, with no project names
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Over SSH or in CI the report is written but not opened; the path is printed. `CLAUDE_CONFIG_DIR` and `CODEX_HOME` are
|
|
123
|
+
respected, and `NO_COLOR` turns colour off. An unknown option is an error, so a typo never runs silently with the defaults.
|
|
124
|
+
|
|
125
|
+
## Private by design
|
|
126
|
+
|
|
127
|
+
ReRead reads only the token counts, model, time, ids, folder name and git branch of each reply in
|
|
128
|
+
`~/.claude/projects/**/*.jsonl`, `~/.codex/sessions/**/rollout-*.jsonl` and Antigravity's
|
|
129
|
+
`~/.gemini/antigravity-cli/brain/*/.system_generated/logs/transcript.jsonl`. It never keeps or prints what you or the
|
|
130
|
+
agent wrote, makes no network requests and has
|
|
131
|
+
no dependencies. The report has no outside scripts, fonts or images, and its security policy lets only its own script
|
|
132
|
+
run. See [SECURITY.md](SECURITY.md).
|
|
133
|
+
|
|
134
|
+
## How it counts
|
|
135
|
+
|
|
136
|
+
Each kind of token is weighed by its API price for the model that read it (input, cache writes, cache reads, output), so the shares match what the same tokens would cost on the API. Subscription plans measure usage
|
|
137
|
+
their own way and do not publish it, so treat the percentage as a guide, not your plan's meter.
|
|
138
|
+
|
|
139
|
+
A reply counts once, in the session that made it, even when a resumed session copies it; a subagent's replies count
|
|
140
|
+
toward the session that started it. "Writing history again" is estimated from token counts: a reply whose cache read
|
|
141
|
+
fell below half of the previous reply's context while the context did not shrink.
|
|
142
|
+
|
|
143
|
+
The details, with every rule and threshold: [docs/how-it-counts.md](docs/how-it-counts.md). None of the tools documents
|
|
144
|
+
its session format, and any may change it; if ReRead reads yours wrong, please
|
|
145
|
+
[open an issue](https://github.com/tecyfyai/reread/issues).
|
|
146
|
+
|
|
147
|
+
Want to see what caching saves for a prompt of your own? The
|
|
148
|
+
[prompt caching calculator](https://tecyfy.com/ai-agents/prompt-caching-calculator) prices it on every Claude model.
|
|
149
|
+
|
|
150
|
+
## FAQ
|
|
151
|
+
|
|
152
|
+
### Why is my Claude Code usage so high?
|
|
153
|
+
|
|
154
|
+
Mostly because every reply sends the whole conversation again. In a session with 150k tokens of context, each reply
|
|
155
|
+
re-reads those 150k tokens, so a long session costs far more per reply than a short one. Run ReRead to see how much of
|
|
156
|
+
your usage that was, and which sessions drove it.
|
|
157
|
+
|
|
158
|
+
### Does Claude Code cache prompts?
|
|
159
|
+
|
|
160
|
+
Yes. Claude Code uses prompt caching on its own, so the history each reply sends again is usually read from the cache,
|
|
161
|
+
at a fraction of the normal input price. The cache lasts 5 minutes after its last use (or 1 hour for the longer
|
|
162
|
+
cache), and each model has its own.
|
|
163
|
+
|
|
164
|
+
### Why was my cache rebuilt?
|
|
165
|
+
|
|
166
|
+
For one of three reasons: a break longer than the cache's life, a switch of model in the middle of a session, or a
|
|
167
|
+
change near the start of the context (tools, MCP servers, settings) while the cache was warm. When that happens the
|
|
168
|
+
whole history is written to the cache again, at the cache-write price. ReRead counts each case and shows where it
|
|
169
|
+
happened in each session.
|
|
170
|
+
|
|
171
|
+
### Does it work with Codex?
|
|
172
|
+
|
|
173
|
+
Yes. ReRead reads Codex's session files (`~/.codex/sessions`, or `$CODEX_HOME/sessions`) next to Claude Code's, prices
|
|
174
|
+
them at OpenAI's API prices, and shows both together or one with `--tool codex`. Codex also caches the history on its
|
|
175
|
+
own, so the same question applies: how much of each reply went to re-reading it.
|
|
176
|
+
|
|
177
|
+
### Does it work with Antigravity or Gemini CLI?
|
|
178
|
+
|
|
179
|
+
With Antigravity, yes: the CLI (`agy`) and the app. Antigravity records each reply's tokens but not which model gave
|
|
180
|
+
it, so ReRead prices its replies at the model in Antigravity's settings (Gemini 3.8 Flash if none is set); the shares
|
|
181
|
+
stay right whatever the model. Gemini CLI was retired for individual users in June 2026 in favour of Antigravity CLI,
|
|
182
|
+
so ReRead does not read it.
|
|
183
|
+
|
|
184
|
+
### How is ReRead different from ccusage?
|
|
185
|
+
|
|
186
|
+
[ccusage](https://github.com/ccusage/ccusage) reports how many tokens you used and what they cost, by day, month or
|
|
187
|
+
session. ReRead explains why: how much of it was re-reading history, when and why the cache was lost, and how much came
|
|
188
|
+
from long contexts, with advice for each. They read the same local files and work well side by side.
|
|
189
|
+
|
|
190
|
+
### Does it work with a Claude Pro or Max plan, or ChatGPT Plus or Pro?
|
|
191
|
+
|
|
192
|
+
Yes. ReRead reads the session files kept on your machine with any plan or API key. Plans measure usage
|
|
193
|
+
their own way, so the dollar figures are what the same tokens would cost on the API; the shares are what matter.
|
|
194
|
+
|
|
195
|
+
### Does ReRead upload anything?
|
|
196
|
+
|
|
197
|
+
No. It reads only token counts from local files, makes no network requests and has no dependencies. See
|
|
198
|
+
[Private by design](#private-by-design).
|
|
199
|
+
|
|
200
|
+
## Contributing
|
|
201
|
+
|
|
202
|
+
Bug reports, ideas and pull requests are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
203
|
+
|
|
204
|
+
## Licence
|
|
205
|
+
|
|
206
|
+
MIT. ReRead is independent and not made, endorsed or supported by Anthropic, OpenAI or Google.
|
package/bin/reread.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reread-cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "Token usage and prompt cache analyzer for Claude Code, Codex and Antigravity: how much of your coding agent's usage was re-reading context, and why. Visual report and a cache-countdown status line. Local only; uploads nothing.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"reread": "bin/reread.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin",
|
|
11
|
+
"src"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"test": "node --test test/*.test.js",
|
|
15
|
+
"lint": "eslint . && prettier --check . && tsc",
|
|
16
|
+
"format": "prettier --write .",
|
|
17
|
+
"preview": "node scripts/preview.js",
|
|
18
|
+
"prepublishOnly": "npm run lint && npm test"
|
|
19
|
+
},
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=20"
|
|
22
|
+
},
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/tecyfyai/reread.git"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://github.com/tecyfyai/reread#readme",
|
|
28
|
+
"bugs": "https://github.com/tecyfyai/reread/issues",
|
|
29
|
+
"keywords": [
|
|
30
|
+
"claude-code",
|
|
31
|
+
"claude",
|
|
32
|
+
"anthropic",
|
|
33
|
+
"openai",
|
|
34
|
+
"openai-codex",
|
|
35
|
+
"codex",
|
|
36
|
+
"gemini",
|
|
37
|
+
"antigravity",
|
|
38
|
+
"claude-code-usage",
|
|
39
|
+
"token-usage",
|
|
40
|
+
"token-cost",
|
|
41
|
+
"prompt-caching",
|
|
42
|
+
"prompt-cache",
|
|
43
|
+
"context-window",
|
|
44
|
+
"llm",
|
|
45
|
+
"llm-cost",
|
|
46
|
+
"ccusage",
|
|
47
|
+
"cli",
|
|
48
|
+
"statusline",
|
|
49
|
+
"usage-limit"
|
|
50
|
+
],
|
|
51
|
+
"author": "ReRead contributors",
|
|
52
|
+
"license": "MIT",
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@eslint/js": "10.0.1",
|
|
55
|
+
"@types/node": "20.19.43",
|
|
56
|
+
"eslint": "10.13.0",
|
|
57
|
+
"globals": "17.13.0",
|
|
58
|
+
"prettier": "3.9.10",
|
|
59
|
+
"typescript": "7.0.2"
|
|
60
|
+
}
|
|
61
|
+
}
|