llm-usage-metrics 0.1.8 → 0.1.10
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 +60 -22
- package/dist/index.js +364 -111
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# llm-usage-metrics
|
|
2
2
|
|
|
3
|
+
[](https://deepwiki.com/ayagmar/llm-usage-metrics)
|
|
4
|
+
[](https://github.com/ayagmar/llm-usage-metrics/actions/workflows/ci.yml)
|
|
5
|
+
[](https://codecov.io/gh/ayagmar/llm-usage-metrics)
|
|
6
|
+
[](https://www.npmjs.com/package/llm-usage-metrics)
|
|
7
|
+
[](https://www.npmjs.com/package/llm-usage-metrics)
|
|
8
|
+
[](https://packagephobia.com/result?p=llm-usage-metrics)
|
|
9
|
+
|
|
3
10
|
CLI to aggregate local LLM usage from:
|
|
4
11
|
|
|
5
12
|
- `~/.pi/agent/sessions/**/*.jsonl`
|
|
@@ -10,7 +17,7 @@ Reports are available for daily, weekly (Monday-start), and monthly periods.
|
|
|
10
17
|
|
|
11
18
|
Project documentation is available in [`docs/`](./docs/README.md).
|
|
12
19
|
|
|
13
|
-
Built-in adapters currently support `.pi`, `.codex`, and OpenCode SQLite. The codebase is structured to add more sources (for example Claude/Gemini exports) through the `SourceAdapter` pattern. See [`CONTRIBUTING.md`](./CONTRIBUTING.md).
|
|
20
|
+
Built-in adapters currently support 3 sources: `.pi`, `.codex`, and OpenCode SQLite. The codebase is structured to add more sources (for example Claude/Gemini exports) through the `SourceAdapter` pattern. See [`CONTRIBUTING.md`](./CONTRIBUTING.md).
|
|
14
21
|
|
|
15
22
|
## Install
|
|
16
23
|
|
|
@@ -38,7 +45,7 @@ When installed globally, the CLI performs a lightweight npm update check on star
|
|
|
38
45
|
|
|
39
46
|
Behavior:
|
|
40
47
|
|
|
41
|
-
- uses a local cache (`~/.cache/llm-usage-metrics/update-check.json`) with a 1-hour default TTL
|
|
48
|
+
- uses a local cache (`<platform-cache-root>/llm-usage-metrics/update-check.json`; defaults to `~/.cache/llm-usage-metrics/update-check.json` on Linux when `XDG_CACHE_HOME` is unset) with a 1-hour default TTL
|
|
42
49
|
- optional session-scoped cache mode via `LLM_USAGE_UPDATE_CACHE_SCOPE=session`
|
|
43
50
|
- skips checks for `--help` / `--version` invocations
|
|
44
51
|
- skips checks when run through `npx`
|
|
@@ -161,48 +168,76 @@ OpenCode safety notes:
|
|
|
161
168
|
- unreadable/missing explicit paths fail fast with actionable errors
|
|
162
169
|
- OpenCode CLI is optional for troubleshooting and not required for runtime parsing
|
|
163
170
|
|
|
164
|
-
### Filter by source
|
|
171
|
+
### Filter by source (`--source`)
|
|
165
172
|
|
|
166
|
-
|
|
173
|
+
Use `--source` to limit reports to one or more source ids.
|
|
167
174
|
|
|
168
|
-
|
|
169
|
-
llm-usage monthly --source codex
|
|
170
|
-
```
|
|
175
|
+
Supported source ids:
|
|
171
176
|
|
|
172
|
-
|
|
177
|
+
- `pi`
|
|
178
|
+
- `codex`
|
|
179
|
+
- `opencode`
|
|
173
180
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
181
|
+
Behavior:
|
|
182
|
+
|
|
183
|
+
- repeatable or comma-separated (`--source pi --source codex` or `--source pi,codex`)
|
|
184
|
+
- case-insensitive source id matching
|
|
185
|
+
- unknown ids fail fast with a validation error
|
|
177
186
|
|
|
178
|
-
|
|
187
|
+
Examples:
|
|
179
188
|
|
|
180
189
|
```bash
|
|
181
|
-
|
|
182
|
-
|
|
190
|
+
# only codex data
|
|
191
|
+
llm-usage monthly --source codex
|
|
183
192
|
|
|
184
|
-
|
|
193
|
+
# only pi data
|
|
194
|
+
llm-usage monthly --source pi
|
|
185
195
|
|
|
186
|
-
|
|
196
|
+
# only OpenCode data
|
|
197
|
+
llm-usage monthly --source opencode
|
|
198
|
+
|
|
199
|
+
# multiple sources
|
|
187
200
|
llm-usage monthly --source pi --source codex
|
|
188
201
|
llm-usage monthly --source pi,codex
|
|
202
|
+
|
|
203
|
+
# OpenCode source with explicit DB path
|
|
204
|
+
llm-usage monthly --source opencode --opencode-db /path/to/opencode.db
|
|
189
205
|
```
|
|
190
206
|
|
|
191
|
-
### Filter by provider (
|
|
207
|
+
### Filter by provider (`--provider`)
|
|
208
|
+
|
|
209
|
+
Use `--provider` to keep only events whose provider contains the filter text.
|
|
210
|
+
|
|
211
|
+
Behavior:
|
|
212
|
+
|
|
213
|
+
- case-insensitive substring match
|
|
214
|
+
- optional flag (when omitted, all providers are included)
|
|
215
|
+
- works together with `--source` and `--model`
|
|
216
|
+
|
|
217
|
+
Examples:
|
|
192
218
|
|
|
193
219
|
```bash
|
|
220
|
+
# all OpenAI-family providers
|
|
194
221
|
llm-usage monthly --provider openai
|
|
222
|
+
|
|
223
|
+
# GitHub Models providers
|
|
195
224
|
llm-usage monthly --provider github
|
|
196
|
-
|
|
225
|
+
|
|
226
|
+
# source + provider together
|
|
227
|
+
llm-usage monthly --source codex --provider openai
|
|
197
228
|
```
|
|
198
229
|
|
|
199
|
-
### Filter by model (
|
|
230
|
+
### Filter by model (`--model`)
|
|
200
231
|
|
|
201
|
-
`--model` supports repeatable
|
|
232
|
+
`--model` supports repeatable and comma-separated filters. Matching is case-insensitive.
|
|
202
233
|
|
|
203
|
-
|
|
234
|
+
Per filter value:
|
|
235
|
+
|
|
236
|
+
- if an exact model id exists in the currently selected event set (after source/provider/date filtering), exact matching is used
|
|
204
237
|
- otherwise, substring matching is used
|
|
205
238
|
|
|
239
|
+
Examples:
|
|
240
|
+
|
|
206
241
|
```bash
|
|
207
242
|
# substring match (all Claude-family models)
|
|
208
243
|
llm-usage monthly --model claude
|
|
@@ -210,9 +245,12 @@ llm-usage monthly --model claude
|
|
|
210
245
|
# exact match when present
|
|
211
246
|
llm-usage monthly --model claude-sonnet-4.5
|
|
212
247
|
|
|
213
|
-
# multiple filters
|
|
248
|
+
# multiple model filters
|
|
214
249
|
llm-usage monthly --model claude --model gpt-5
|
|
215
250
|
llm-usage monthly --model claude,gpt-5
|
|
251
|
+
|
|
252
|
+
# source + provider + model together
|
|
253
|
+
llm-usage monthly --source opencode --provider openai --model gpt-4.1
|
|
216
254
|
```
|
|
217
255
|
|
|
218
256
|
### Per-model columns (opt-in detailed table layout)
|