llm-usage-metrics 0.8.1 → 0.10.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 +42 -11
- package/dist/bin.js +7 -0
- package/dist/index.js +31540 -18768
- package/package.json +9 -4
package/README.md
CHANGED
|
@@ -29,18 +29,26 @@ The CLI parses session content on your machine. It discovers standard source loc
|
|
|
29
29
|
|
|
30
30
|
## Quick start
|
|
31
31
|
|
|
32
|
-
Requires Node.js 24 or
|
|
32
|
+
Requires Node.js 22.16+ or 24+ (Node 23 lacks the SQLite busy timeout the ledger uses), or Bun 1.4+.
|
|
33
33
|
|
|
34
34
|
```bash
|
|
35
35
|
# Run without installing
|
|
36
|
-
npx --yes llm-usage-metrics@latest
|
|
36
|
+
npx --yes llm-usage-metrics@latest
|
|
37
37
|
|
|
38
|
-
# Or install the llm-usage
|
|
38
|
+
# Or install it: the package provides `llm-usage` and the alias `llm-usage-metrics`
|
|
39
39
|
npm install -g llm-usage-metrics
|
|
40
|
-
llm-usage
|
|
40
|
+
llm-usage
|
|
41
|
+
|
|
42
|
+
# Or with Bun (--bun runs the CLI on Bun instead of Node)
|
|
43
|
+
bunx --bun llm-usage-metrics@latest
|
|
44
|
+
|
|
45
|
+
# Optional: tab completion (bash shown; zsh and fish work the same way)
|
|
46
|
+
echo 'source <(llm-usage completion bash)' >> ~/.bashrc
|
|
41
47
|
```
|
|
42
48
|
|
|
43
|
-
|
|
49
|
+
With no command, `llm-usage` prints cost and tokens for today, the last 7 days, and month to date, a month-end projection (checked against `monthlyBudgetUsd` when you set one), what prompt caching saved you this month, then your current and longest streak, best day, and a year-long activity heatmap. `llm-usage daily` breaks the last 7 days down by day and source, and `llm-usage weekly` covers the last 8 weeks; add `--since YYYY-MM-DD` or `--all` for older usage.
|
|
50
|
+
|
|
51
|
+
If the report is empty, check source discovery. `doctor` lists the paths each source searched and marks it found, not installed, or unparseable:
|
|
44
52
|
|
|
45
53
|
```bash
|
|
46
54
|
llm-usage doctor
|
|
@@ -50,6 +58,7 @@ llm-usage doctor
|
|
|
50
58
|
|
|
51
59
|
| Question | Command |
|
|
52
60
|
| --------------------------------------------------------- | ----------------------------------------- |
|
|
61
|
+
| What did I spend today, this week, and this month? | `llm-usage` |
|
|
53
62
|
| How much did I use by day, week, or month? | `llm-usage daily`, `weekly`, `monthly` |
|
|
54
63
|
| How did one period change from another? | `llm-usage compare` |
|
|
55
64
|
| Which conversations or repositories used the most? | `llm-usage session` |
|
|
@@ -57,6 +66,7 @@ llm-usage doctor
|
|
|
57
66
|
| How does repo-attributed usage line up with Git activity? | `llm-usage efficiency monthly` |
|
|
58
67
|
| What would the same token mix cost on another model? | `llm-usage optimize monthly` |
|
|
59
68
|
| What did the year add up to? | `llm-usage wrapped` |
|
|
69
|
+
| What can my status bar show? | `llm-usage statusline` |
|
|
60
70
|
| How do I get the raw normalized events out? | `llm-usage events` |
|
|
61
71
|
| Which sources and local stores are healthy? | `llm-usage doctor` |
|
|
62
72
|
| Which departed files can leave the event ledger? | `llm-usage prune` |
|
|
@@ -69,7 +79,7 @@ Common examples:
|
|
|
69
79
|
# A chosen calendar range
|
|
70
80
|
llm-usage monthly --since 2026-06-01 --until 2026-06-30
|
|
71
81
|
|
|
72
|
-
# Current
|
|
82
|
+
# Current month to date compared with the same days of the previous month
|
|
73
83
|
llm-usage compare
|
|
74
84
|
|
|
75
85
|
# Ten highest-cost conversations
|
|
@@ -87,6 +97,9 @@ llm-usage optimize monthly \
|
|
|
87
97
|
--candidate-model gpt-4.1 \
|
|
88
98
|
--candidate-model gpt-5-codex
|
|
89
99
|
|
|
100
|
+
# One line for the Claude Code status line, tmux, or starship
|
|
101
|
+
llm-usage statusline
|
|
102
|
+
|
|
90
103
|
# Normalized events as JSONL, e.g. total tokens per line via jq
|
|
91
104
|
llm-usage events --since 2026-06-01 | jq '.totalTokens'
|
|
92
105
|
```
|
|
@@ -157,10 +170,10 @@ The pricing request never includes session content. See [Pricing](https://ayagma
|
|
|
157
170
|
|
|
158
171
|
## Local event ledger
|
|
159
172
|
|
|
160
|
-
A SQLite event ledger stores normalized events and parse diagnostics. Unchanged files can skip parsing on later runs.
|
|
173
|
+
A SQLite event ledger stores normalized events and parse diagnostics. Unchanged files can skip parsing on later runs. Reports also include retained history for files that have left the disk (Claude Code, for example, deletes old transcripts), with moved or copied files suppressed. Leave it out with `--no-history`:
|
|
161
174
|
|
|
162
175
|
```bash
|
|
163
|
-
llm-usage monthly --history
|
|
176
|
+
llm-usage monthly --no-history
|
|
164
177
|
```
|
|
165
178
|
|
|
166
179
|
`prune` is a dry run unless you pass `--apply`:
|
|
@@ -172,17 +185,32 @@ llm-usage prune --departed-before 2026-01-01 --apply
|
|
|
172
185
|
|
|
173
186
|
Deleting the ledger also deletes retained history. Read [Caching](https://ayagmar.github.io/llm-usage-metrics/caching/) before clearing it as a troubleshooting step.
|
|
174
187
|
|
|
188
|
+
## Multiple machines
|
|
189
|
+
|
|
190
|
+
Reports can include your other machines' usage over ssh. Install llm-usage-metrics there, make sure ssh logs in without a prompt, then:
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
llm-usage machine add laptop # syncs over ssh laptop; see the docs for other destinations
|
|
194
|
+
llm-usage monthly # this machine and the laptop, fetched when due
|
|
195
|
+
llm-usage monthly --machine laptop # only the laptop
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
A session that reached both machines (a copied or synced `~/.claude`) is counted once. See [Multiple machines](https://ayagmar.github.io/llm-usage-metrics/machines/).
|
|
199
|
+
|
|
175
200
|
## Output
|
|
176
201
|
|
|
177
202
|
```bash
|
|
178
|
-
llm-usage daily --json
|
|
203
|
+
llm-usage daily --all --json
|
|
179
204
|
llm-usage daily --markdown
|
|
205
|
+
llm-usage daily --compact
|
|
180
206
|
llm-usage monthly --share
|
|
181
207
|
```
|
|
182
208
|
|
|
183
|
-
|
|
209
|
+
Terminal tables fit the terminal width: on a narrow terminal, token counts are abbreviated and less-used columns are hidden, with a `stderr` note saying what was left out. `--compact` asks for the short table directly.
|
|
210
|
+
|
|
211
|
+
Report data goes to `stdout`. Diagnostics go to `stderr` as one summary line plus any warnings, which keeps JSON and Markdown safe to redirect; `--quiet` keeps only warnings and `--verbose` adds per-source and skipped-row detail. JSON output is wrapped in a versioned envelope: `{ "schemaVersion": 1, "report": "usage", "data": ... }`. Scripts written against pre-0.8.0 JSON should follow the [migration guide](https://ayagmar.github.io/llm-usage-metrics/migrating-to-0-8/).
|
|
184
212
|
|
|
185
|
-
Terminal, JSON, and Markdown availability varies by report.
|
|
213
|
+
Terminal, JSON, and Markdown availability varies by report. Summary, usage, compare, trends, wrapped, efficiency, and optimize can write a 1200×630 share card: an SVG plus an HTML page that shows it in dark and light and exports a PNG in your browser. `--share --no-open` writes the files without opening the page. The [output guide](https://ayagmar.github.io/llm-usage-metrics/output-formats/) contains the format matrix and file names.
|
|
186
214
|
|
|
187
215
|
## Performance
|
|
188
216
|
|
|
@@ -201,9 +229,12 @@ pnpm run format:check
|
|
|
201
229
|
pnpm run build
|
|
202
230
|
```
|
|
203
231
|
|
|
232
|
+
The website has a [docs overview](https://ayagmar.github.io/llm-usage-metrics/docs/) and a [report chooser](https://ayagmar.github.io/llm-usage-metrics/reports/) for finding the right command. Its landing page and source navigation use the CLI source registry; regenerate CLI and security references after behavior changes.
|
|
233
|
+
|
|
204
234
|
Site commands:
|
|
205
235
|
|
|
206
236
|
```bash
|
|
237
|
+
pnpm run site:docs:generate
|
|
207
238
|
pnpm run site:check
|
|
208
239
|
pnpm run site:build
|
|
209
240
|
pnpm run site:dev
|