g3usage 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 +346 -46
- package/assets/grok-mark.png +0 -0
- package/assets/grok-mark.svg +4 -0
- package/assets/icon-64.png +0 -0
- package/assets/icon.png +0 -0
- package/assets/icon.svg +7 -0
- package/assets/logo.png +0 -0
- package/assets/logo.svg +8 -0
- package/bin/g3usage.js +4 -0
- package/package.json +13 -7
- package/src/cli.js +9 -6
package/README.md
CHANGED
|
@@ -1,92 +1,392 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<img src="assets/logo.png" alt="G3usage" width="180" />
|
|
4
|
+
|
|
5
|
+
# <img src="assets/icon.png" alt="" width="42" height="42" align="absmiddle" /> G3usage
|
|
6
|
+
|
|
7
|
+
### ccusage — but for **Grok Build**
|
|
8
|
+
|
|
9
|
+
<p>
|
|
10
|
+
<img src="assets/icon-64.png" alt="" width="20" height="20" align="absmiddle" />
|
|
11
|
+
<strong>npm package</strong>
|
|
12
|
+
<code><a href="https://www.npmjs.com/package/g3usage">g3usage</a></code>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
Local CLI that turns your `~/.grok` session logs into **daily / weekly / monthly / session** reports with estimated tokens & API-equivalent cost.
|
|
16
|
+
|
|
17
|
+
<br />
|
|
18
|
+
|
|
19
|
+
[](https://www.npmjs.com/package/g3usage)
|
|
20
|
+
[](https://nodejs.org/)
|
|
21
|
+
[](https://bun.sh)
|
|
22
|
+
[](./LICENSE)
|
|
23
|
+
[](#-features)
|
|
24
|
+
|
|
25
|
+
<br />
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npx g3usage@latest
|
|
29
|
+
# or
|
|
30
|
+
bunx g3usage@latest
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Why G3usage?
|
|
38
|
+
|
|
39
|
+
If you use [Grok Build](https://x.ai/build) heavily, you eventually want the same visibility [ccusage](https://github.com/ccusage/ccusage) gives Claude / Codex users:
|
|
40
|
+
|
|
41
|
+
| Question | G3usage answer |
|
|
42
|
+
|----------|----------------|
|
|
43
|
+
| How many tokens did I burn this week? | `g3usage weekly` |
|
|
44
|
+
| Which days were expensive? | `g3usage daily` |
|
|
45
|
+
| Which session ate my context? | `g3usage session` |
|
|
46
|
+
| What would this cost on the public API? | Cost column (API-equivalent) |
|
|
47
|
+
| Does any of this leave my machine? | **No** — 100% local |
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Features
|
|
52
|
+
|
|
53
|
+
- **Local only** — reads `~/.grok/sessions`, never uploads usage
|
|
54
|
+
- **ccusage-style reports** — `daily` · `weekly` · `monthly` · `session`
|
|
55
|
+
- **JSON export** — pipe into scripts, dashboards, Notion, whatever
|
|
56
|
+
- **Date filters & timezones** — `--since` / `--until` / `--timezone`
|
|
57
|
+
- **Model-aware pricing** — Grok 4.5, Composer 2.5 Fast/Standard, grok-build, …
|
|
58
|
+
- **Zero runtime dependencies** — single small npm package (~10 KB)
|
|
59
|
+
- **Node & Bun** — `npx` / `bunx` / global install, same binary
|
|
60
|
+
|
|
61
|
+
---
|
|
4
62
|
|
|
5
63
|
## Quick start
|
|
6
64
|
|
|
65
|
+
### Run without installing
|
|
66
|
+
|
|
67
|
+
**npm / Node**
|
|
68
|
+
|
|
7
69
|
```bash
|
|
8
70
|
npx g3usage@latest
|
|
71
|
+
npx g3usage@latest daily
|
|
72
|
+
npx g3usage@latest session --json
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Bun** (same package, native runtime)
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
bunx g3usage@latest
|
|
79
|
+
bunx g3usage@latest daily
|
|
80
|
+
bunx g3usage@latest monthly
|
|
81
|
+
bunx g3usage@latest session --json
|
|
9
82
|
```
|
|
10
83
|
|
|
11
|
-
|
|
84
|
+
### Install globally
|
|
12
85
|
|
|
13
86
|
```bash
|
|
87
|
+
# npm
|
|
14
88
|
npm install -g g3usage
|
|
89
|
+
|
|
90
|
+
# bun
|
|
91
|
+
bun install -g g3usage
|
|
92
|
+
|
|
15
93
|
g3usage
|
|
16
|
-
g3usage
|
|
17
|
-
g3usage session
|
|
94
|
+
g3usage weekly
|
|
95
|
+
g3usage session -s 2026-03-01
|
|
18
96
|
```
|
|
19
97
|
|
|
20
|
-
From
|
|
98
|
+
### From source
|
|
21
99
|
|
|
22
100
|
```bash
|
|
101
|
+
git clone https://github.com/GhaythBenAbid/G3usage.git
|
|
102
|
+
cd G3usage
|
|
103
|
+
|
|
104
|
+
# Node
|
|
23
105
|
node bin/g3usage.js daily
|
|
106
|
+
|
|
107
|
+
# Bun
|
|
108
|
+
bun bin/g3usage.js daily
|
|
109
|
+
# or
|
|
110
|
+
bun run start:bun -- daily
|
|
24
111
|
```
|
|
25
112
|
|
|
26
|
-
|
|
113
|
+
Requires **Node.js 18+** or **Bun 1.0+**. Zero dependencies either way.
|
|
27
114
|
|
|
28
|
-
|
|
115
|
+
---
|
|
29
116
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
117
|
+
## Example output
|
|
118
|
+
|
|
119
|
+
_Sample only — dummy numbers, not real usage._
|
|
33
120
|
|
|
34
|
-
|
|
121
|
+
```text
|
|
122
|
+
╭───────────────────────────────────────────────────────────╮
|
|
123
|
+
│ Grok Build Usage Report - Daily │
|
|
124
|
+
╰───────────────────────────────────────────────────────────╯
|
|
35
125
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
126
|
+
┌────────────┬──────────────────────────────────┬───────────┬──────────┬───────────┬──────────┬────────────┐
|
|
127
|
+
│ Date │ Models │ Input │ Output │ Total │ Sessions │ Cost (USD) │
|
|
128
|
+
├────────────┼──────────────────────────────────┼───────────┼──────────┼───────────┼──────────┼────────────┤
|
|
129
|
+
│ 2026-03-12 │ grok-4.5 │ 412,500 │ 88,200 │ 500,700 │ 4 │ $1.35 │
|
|
130
|
+
│ 2026-03-13 │ grok-4.5, grok-composer-2.5-fast │ 980,000 │ 210,000 │ 1,190,000 │ 7 │ $5.12 │
|
|
131
|
+
│ 2026-03-14 │ grok-composer-2.5-fast │ 256,000 │ 64,000 │ 320,000 │ 3 │ $1.73 │
|
|
132
|
+
├────────────┼──────────────────────────────────┼───────────┼──────────┼───────────┼──────────┼────────────┤
|
|
133
|
+
│ Total │ grok-4.5, grok-composer-2.5-fast │ 1,648,500 │ 362,200 │ 2,010,700 │ 14 │ $8.20 │
|
|
134
|
+
└────────────┴──────────────────────────────────┴───────────┴──────────┴───────────┴──────────┴────────────┘
|
|
41
135
|
|
|
42
|
-
|
|
136
|
+
Costs are API-equivalent estimates. SuperGrok / subscription usage may not bill per token.
|
|
137
|
+
Input/Output estimated from cumulative context sizes in local session logs.
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
> Numbers above are **fake demo data** for the README. Run `npx g3usage@latest` to see your own local totals.
|
|
141
|
+
|
|
142
|
+
---
|
|
43
143
|
|
|
44
144
|
## Commands
|
|
45
145
|
|
|
46
|
-
| Command | Description |
|
|
47
|
-
|
|
48
|
-
| `daily` (default) |
|
|
49
|
-
| `weekly` | Group by ISO week |
|
|
50
|
-
| `monthly` | Group by month |
|
|
51
|
-
| `session` | One row per session |
|
|
146
|
+
| Command | Description | Example |
|
|
147
|
+
|---------|-------------|---------|
|
|
148
|
+
| `daily` | Group usage by calendar day **(default)** | `g3usage` or `g3usage daily` |
|
|
149
|
+
| `weekly` | Group by ISO week (`YYYY-Www`) | `g3usage weekly` |
|
|
150
|
+
| `monthly` | Group by month (`YYYY-MM`) | `g3usage monthly` |
|
|
151
|
+
| `session` | One row per Grok Build session | `g3usage session` |
|
|
52
152
|
|
|
53
153
|
### Options
|
|
54
154
|
|
|
155
|
+
| Flag | Description |
|
|
156
|
+
|------|-------------|
|
|
157
|
+
| `-j`, `--json` | Machine-readable JSON (great for scripts) |
|
|
158
|
+
| `-s`, `--since <date>` | Include from date (`YYYY-MM-DD` or `YYYYMMDD`) |
|
|
159
|
+
| `-u`, `--until <date>` | Include until date (inclusive) |
|
|
160
|
+
| `-z`, `--timezone <tz>` | IANA timezone for day/week/month boundaries (default: system) |
|
|
161
|
+
| `--no-cost` | Hide the cost column |
|
|
162
|
+
| `--path <dir>` | Override Grok home (default: `$GROK_HOME` or `~/.grok`) |
|
|
163
|
+
| `-h`, `--help` | Show help |
|
|
164
|
+
| `-v`, `--version` | Print version |
|
|
165
|
+
|
|
166
|
+
### Recipes
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
# Last few days only
|
|
170
|
+
g3usage daily -s 2026-03-01 -u 2026-03-14
|
|
171
|
+
|
|
172
|
+
# Tokyo calendar days
|
|
173
|
+
g3usage daily -z Asia/Tokyo
|
|
174
|
+
|
|
175
|
+
# Export all sessions as JSON
|
|
176
|
+
g3usage session --json > sessions.json
|
|
177
|
+
|
|
178
|
+
# Tokens only, no dollar column
|
|
179
|
+
g3usage monthly --no-cost
|
|
180
|
+
|
|
181
|
+
# Custom Grok install location
|
|
182
|
+
g3usage --path /path/to/grok-home daily
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## How it works
|
|
188
|
+
|
|
189
|
+
### Data source
|
|
190
|
+
|
|
191
|
+
G3usage walks:
|
|
192
|
+
|
|
193
|
+
```text
|
|
194
|
+
$GROK_HOME/sessions/<project>/<session-id>/
|
|
195
|
+
├── updates.jsonl # live stream of session updates (+ totalTokens)
|
|
196
|
+
├── summary.json # id, cwd, title, model, timestamps
|
|
197
|
+
└── signals.json # models used, context peak, latency stats
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
Default home:
|
|
201
|
+
|
|
202
|
+
```text
|
|
203
|
+
~/.grok # or $GROK_HOME if set
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Nothing is sent to the network. Pricing tables are **bundled** in the package (not fetched live).
|
|
207
|
+
|
|
208
|
+
### Token estimation methodology
|
|
209
|
+
|
|
210
|
+
Grok Build currently records a **cumulative context size** as `_meta.totalTokens` on session updates — **not** a clean billed split of input / output / cache.
|
|
211
|
+
|
|
212
|
+
For each user turn (`promptId`), G3usage approximates:
|
|
213
|
+
|
|
214
|
+
| Metric | Formula | Meaning |
|
|
215
|
+
|--------|---------|---------|
|
|
216
|
+
| **Input** | first `totalTokens` in the turn | Context size when the turn starts |
|
|
217
|
+
| **Output** | `max(0, peak − first)` within the turn | How much the context grew during the turn |
|
|
218
|
+
| **Total** | input + output | Estimated tokens for reporting |
|
|
219
|
+
|
|
220
|
+
**Caveats (important):**
|
|
221
|
+
|
|
222
|
+
- Growth includes **tool results**, not only model generations → **output can be an upper bound**
|
|
223
|
+
- Compaction / rewinds can make curves non-monotonic
|
|
224
|
+
- Treat totals as **directional analytics**, not an invoice
|
|
225
|
+
|
|
226
|
+
### Cost estimation
|
|
227
|
+
|
|
228
|
+
Costs are **API-equivalent** using published rates (see `src/pricing.js`).
|
|
229
|
+
|
|
230
|
+
If you authenticate with **SuperGrok / X Premium+**, Grok Build is usually **subscription-based** — you may not pay these per-token rates. The cost column answers:
|
|
231
|
+
|
|
232
|
+
> “What would this usage roughly cost on public list prices?”
|
|
233
|
+
|
|
234
|
+
Not:
|
|
235
|
+
|
|
236
|
+
> “What will my card be charged?”
|
|
237
|
+
|
|
238
|
+
#### Pricing highlights (per 1M tokens)
|
|
239
|
+
|
|
240
|
+
| Model | Input | Cached input | Output | Source |
|
|
241
|
+
|-------|------:|-------------:|-------:|--------|
|
|
242
|
+
| `grok-4.5` | $2.00 | $0.50 | $6.00 | [xAI pricing](https://docs.x.ai/developers/pricing) |
|
|
243
|
+
| `grok-4.3` / `grok-4.20-*` | $1.25 | $0.20 | $2.50 | [xAI pricing](https://docs.x.ai/developers/pricing) |
|
|
244
|
+
| `grok-build-0.1` | $1.00 | $0.20 | $2.00 | [xAI Code API](https://docs.x.ai/developers/pricing) |
|
|
245
|
+
| `composer-2.5` / `grok-composer-2.5` | $0.50 | $0.20 | $2.50 | [Cursor Composer 2.5](https://cursor.com/blog/composer-2-5) |
|
|
246
|
+
| **`composer-2.5-fast` / `grok-composer-2.5-fast`** | **$3.00** | **$0.50** | **$15.00** | [Cursor docs](https://cursor.com/docs/models/cursor-composer-2-5) |
|
|
247
|
+
|
|
248
|
+
> **Fast is ~6× standard** Composer pricing. Fast is the default interactive tier in Cursor product docs — and matches the `*-fast` model ids in Grok Build logs.
|
|
249
|
+
|
|
250
|
+
Unknown models fall back to **Grok 4.5** rates (`$2 / $6`).
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## JSON output
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
g3usage daily --json -s 2026-03-12
|
|
55
258
|
```
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
259
|
+
|
|
260
|
+
Shape (simplified):
|
|
261
|
+
|
|
262
|
+
```json
|
|
263
|
+
{
|
|
264
|
+
"command": "daily",
|
|
265
|
+
"timezone": "America/New_York",
|
|
266
|
+
"grokHome": "/Users/you/.grok",
|
|
267
|
+
"sessionsPath": "/Users/you/.grok/sessions",
|
|
268
|
+
"totals": {
|
|
269
|
+
"inputTokens": 412500,
|
|
270
|
+
"outputTokens": 88200,
|
|
271
|
+
"totalTokens": 500700,
|
|
272
|
+
"cost": 1.35,
|
|
273
|
+
"models": ["grok-4.5"],
|
|
274
|
+
"sessions": 4
|
|
275
|
+
},
|
|
276
|
+
"rows": [
|
|
277
|
+
{
|
|
278
|
+
"key": "2026-03-12",
|
|
279
|
+
"inputTokens": 412500,
|
|
280
|
+
"outputTokens": 88200,
|
|
281
|
+
"totalTokens": 500700,
|
|
282
|
+
"cost": 1.35,
|
|
283
|
+
"models": ["grok-4.5"],
|
|
284
|
+
"sessions": 4
|
|
285
|
+
}
|
|
286
|
+
]
|
|
287
|
+
}
|
|
64
288
|
```
|
|
65
289
|
|
|
66
|
-
|
|
290
|
+
Useful with `jq`:
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
g3usage monthly --json | jq '.totals'
|
|
294
|
+
g3usage session --json | jq '[.rows[] | {title, totalTokens, cost}]'
|
|
295
|
+
```
|
|
67
296
|
|
|
68
|
-
|
|
297
|
+
---
|
|
69
298
|
|
|
70
|
-
|
|
299
|
+
## Environment
|
|
71
300
|
|
|
72
|
-
|
|
73
|
-
|
|
301
|
+
| Variable | Purpose |
|
|
302
|
+
|----------|---------|
|
|
303
|
+
| `GROK_HOME` | Override Grok data directory (default `~/.grok`) |
|
|
304
|
+
| `NO_COLOR` | Disable ANSI colors |
|
|
305
|
+
| `FORCE_COLOR` | Force colors (when supported) |
|
|
74
306
|
|
|
75
|
-
|
|
307
|
+
---
|
|
76
308
|
|
|
77
|
-
##
|
|
309
|
+
## Project layout
|
|
78
310
|
|
|
79
|
-
|
|
311
|
+
```text
|
|
312
|
+
g3usage/
|
|
313
|
+
├── bin/g3usage.js # CLI entry (npx / global bin)
|
|
314
|
+
├── src/
|
|
315
|
+
│ ├── cli.js # commands, args, report wiring
|
|
316
|
+
│ ├── load.js # parse ~/.grok/sessions
|
|
317
|
+
│ ├── aggregate.js # daily / weekly / monthly / session
|
|
318
|
+
│ ├── pricing.js # model → $/1M rates
|
|
319
|
+
│ └── table.js # terminal tables (no deps)
|
|
320
|
+
├── package.json
|
|
321
|
+
└── README.md
|
|
322
|
+
```
|
|
80
323
|
|
|
81
|
-
|
|
324
|
+
---
|
|
325
|
+
|
|
326
|
+
## Comparison
|
|
327
|
+
|
|
328
|
+
| | [ccusage](https://github.com/ccusage/ccusage) | **G3usage** |
|
|
329
|
+
|--|-----------------------------------------------|-------------|
|
|
330
|
+
| Focus | Many coding agents (Claude, Codex, …) | **Grok Build only** |
|
|
331
|
+
| Data | Agent-specific local logs | `~/.grok/sessions` |
|
|
332
|
+
| Reports | daily / weekly / monthly / session / … | daily / weekly / monthly / session |
|
|
333
|
+
| Network | Optional pricing fetch | Fully offline pricing table |
|
|
334
|
+
| Runtime deps | Full CLI stack | **Zero** |
|
|
335
|
+
|
|
336
|
+
---
|
|
337
|
+
|
|
338
|
+
## Limitations & honesty
|
|
339
|
+
|
|
340
|
+
1. **No true I/O billing logs** in Grok Build yet → input/output are **estimates**
|
|
341
|
+
2. **Cache tokens** are not available in local logs → cache cost usually `$0` in reports
|
|
342
|
+
3. **Subscription users** should treat `$` as **API-equivalent**, not actual spend
|
|
343
|
+
4. **Tool-call fees** (web search, etc. on the public API) are **not** included
|
|
344
|
+
5. Pricing tables can drift — open a PR when xAI / Cursor change rates
|
|
345
|
+
|
|
346
|
+
---
|
|
347
|
+
|
|
348
|
+
## Contributing
|
|
349
|
+
|
|
350
|
+
PRs welcome — especially for:
|
|
351
|
+
|
|
352
|
+
- Better token math when Grok exposes real usage fields
|
|
353
|
+
- Pricing updates
|
|
354
|
+
- New report modes (e.g. by project path, by model only)
|
|
355
|
+
- Tests & CI
|
|
82
356
|
|
|
83
357
|
```bash
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
358
|
+
node bin/g3usage.js --help
|
|
359
|
+
node bin/g3usage.js daily --json | head
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
---
|
|
363
|
+
|
|
364
|
+
## Publish notes (maintainers)
|
|
365
|
+
|
|
366
|
+
```bash
|
|
367
|
+
npm login
|
|
368
|
+
npm publish --otp=<code> # 2FA required
|
|
369
|
+
npm version patch && npm publish --otp=<code>
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
Users always get the latest with:
|
|
373
|
+
|
|
374
|
+
```bash
|
|
375
|
+
npx g3usage@latest
|
|
88
376
|
```
|
|
89
377
|
|
|
378
|
+
---
|
|
379
|
+
|
|
90
380
|
## License
|
|
91
381
|
|
|
92
|
-
MIT
|
|
382
|
+
[MIT](./LICENSE)
|
|
383
|
+
|
|
384
|
+
---
|
|
385
|
+
|
|
386
|
+
<div align="center">
|
|
387
|
+
|
|
388
|
+
**G3usage — built for people who live in the terminal with Grok.**
|
|
389
|
+
|
|
390
|
+
`npx g3usage@latest`
|
|
391
|
+
|
|
392
|
+
</div>
|
|
Binary file
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" fill="none" role="img" aria-label="Grok">
|
|
2
|
+
<path d="M395.479 633.828L735.91 381.105C752.599 368.715 776.454 373.548 784.406 392.792C826.26 494.285 807.561 616.253 724.288 699.996C641.016 783.739 525.151 802.104 419.247 760.277L303.556 814.143C469.49 928.202 670.987 899.995 796.901 773.282C896.776 672.843 927.708 535.937 898.785 412.476L899.047 412.739C857.105 231.37 909.358 158.874 1016.4 10.6326C1018.93 7.11771 1021.47 3.60279 1024 0L883.144 141.651V141.212L395.392 633.916" fill="white"/>
|
|
3
|
+
<path d="M325.226 695.251C206.128 580.84 226.662 403.776 328.285 301.668C403.431 226.097 526.549 195.254 634.026 240.596L749.454 186.994C728.657 171.88 702.007 155.623 671.424 144.2C533.19 86.9942 367.693 115.465 255.323 228.382C147.234 337.081 113.244 504.215 171.613 646.833C215.216 753.423 143.739 828.818 71.7385 904.916C46.2237 931.893 20.6216 958.87 0 987.429L325.139 695.339" fill="white"/>
|
|
4
|
+
</svg>
|
|
Binary file
|
package/assets/icon.png
ADDED
|
Binary file
|
package/assets/icon.svg
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" role="img" aria-label="G3usage">
|
|
2
|
+
<rect width="512" height="512" rx="110" fill="#0a0a0a"/>
|
|
3
|
+
<g transform="translate(64 64) scale(0.375)">
|
|
4
|
+
<path d="M395.479 633.828L735.91 381.105C752.599 368.715 776.454 373.548 784.406 392.792C826.26 494.285 807.561 616.253 724.288 699.996C641.016 783.739 525.151 802.104 419.247 760.277L303.556 814.143C469.49 928.202 670.987 899.995 796.901 773.282C896.776 672.843 927.708 535.937 898.785 412.476L899.047 412.739C857.105 231.37 909.358 158.874 1016.4 10.6326C1018.93 7.11771 1021.47 3.60279 1024 0L883.144 141.651V141.212L395.392 633.916" fill="white"/>
|
|
5
|
+
<path d="M325.226 695.251C206.128 580.84 226.662 403.776 328.285 301.668C403.431 226.097 526.549 195.254 634.026 240.596L749.454 186.994C728.657 171.88 702.007 155.623 671.424 144.2C533.19 86.9942 367.693 115.465 255.323 228.382C147.234 337.081 113.244 504.215 171.613 646.833C215.216 753.423 143.739 828.818 71.7385 904.916C46.2237 931.893 20.6216 958.87 0 987.429L325.139 695.339" fill="white"/>
|
|
6
|
+
</g>
|
|
7
|
+
</svg>
|
package/assets/logo.png
ADDED
|
Binary file
|
package/assets/logo.svg
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" role="img" aria-label="G3usage">
|
|
2
|
+
<rect width="512" height="512" rx="110" fill="#0a0a0a"/>
|
|
3
|
+
<g transform="translate(96 72) scale(0.3125)">
|
|
4
|
+
<path d="M395.479 633.828L735.91 381.105C752.599 368.715 776.454 373.548 784.406 392.792C826.26 494.285 807.561 616.253 724.288 699.996C641.016 783.739 525.151 802.104 419.247 760.277L303.556 814.143C469.49 928.202 670.987 899.995 796.901 773.282C896.776 672.843 927.708 535.937 898.785 412.476L899.047 412.739C857.105 231.37 909.358 158.874 1016.4 10.6326C1018.93 7.11771 1021.47 3.60279 1024 0L883.144 141.651V141.212L395.392 633.916" fill="white"/>
|
|
5
|
+
<path d="M325.226 695.251C206.128 580.84 226.662 403.776 328.285 301.668C403.431 226.097 526.549 195.254 634.026 240.596L749.454 186.994C728.657 171.88 702.007 155.623 671.424 144.2C533.19 86.9942 367.693 115.465 255.323 228.382C147.234 337.081 113.244 504.215 171.613 646.833C215.216 753.423 143.739 828.818 71.7385 904.916C46.2237 931.893 20.6216 958.87 0 987.429L325.139 695.339" fill="white"/>
|
|
6
|
+
</g>
|
|
7
|
+
<text x="256" y="430" text-anchor="middle" font-family="Helvetica Neue, Helvetica, Arial, sans-serif" font-size="52" font-weight="700" fill="#f5f5f5">G3usage</text>
|
|
8
|
+
</svg>
|
package/bin/g3usage.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "g3usage",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "G3usage — analyze Grok Build token usage and estimated costs from local session data (ccusage for Grok)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"g3usage": "bin/g3usage.js"
|
|
@@ -9,15 +9,19 @@
|
|
|
9
9
|
"files": [
|
|
10
10
|
"bin",
|
|
11
11
|
"src",
|
|
12
|
+
"assets",
|
|
12
13
|
"README.md",
|
|
13
14
|
"LICENSE"
|
|
14
15
|
],
|
|
15
16
|
"scripts": {
|
|
16
17
|
"start": "node bin/g3usage.js",
|
|
18
|
+
"start:bun": "bun bin/g3usage.js",
|
|
19
|
+
"g3usage": "node bin/g3usage.js",
|
|
17
20
|
"prepublishOnly": "node bin/g3usage.js --version"
|
|
18
21
|
},
|
|
19
22
|
"engines": {
|
|
20
|
-
"node": ">=18"
|
|
23
|
+
"node": ">=18",
|
|
24
|
+
"bun": ">=1.0.0"
|
|
21
25
|
},
|
|
22
26
|
"keywords": [
|
|
23
27
|
"grok",
|
|
@@ -27,16 +31,18 @@
|
|
|
27
31
|
"tokens",
|
|
28
32
|
"cli",
|
|
29
33
|
"ccusage",
|
|
30
|
-
"cost"
|
|
34
|
+
"cost",
|
|
35
|
+
"bun",
|
|
36
|
+
"bunx"
|
|
31
37
|
],
|
|
32
38
|
"author": "",
|
|
33
39
|
"license": "MIT",
|
|
34
40
|
"repository": {
|
|
35
41
|
"type": "git",
|
|
36
|
-
"url": "git+https://github.com/
|
|
42
|
+
"url": "git+https://github.com/GhaythBenAbid/G3usage.git"
|
|
37
43
|
},
|
|
38
44
|
"bugs": {
|
|
39
|
-
"url": "https://github.com/
|
|
45
|
+
"url": "https://github.com/GhaythBenAbid/G3usage/issues"
|
|
40
46
|
},
|
|
41
|
-
"homepage": "https://github.com/
|
|
47
|
+
"homepage": "https://github.com/GhaythBenAbid/G3usage#readme"
|
|
42
48
|
}
|
package/src/cli.js
CHANGED
|
@@ -15,14 +15,17 @@ import {
|
|
|
15
15
|
c,
|
|
16
16
|
} from "./table.js";
|
|
17
17
|
|
|
18
|
-
const VERSION = "0.
|
|
18
|
+
const VERSION = "0.2.0";
|
|
19
19
|
|
|
20
20
|
const HELP = `
|
|
21
|
-
${c.bold("
|
|
21
|
+
${c.bold("G3usage")} — Grok Build usage analysis (ccusage for Grok)
|
|
22
|
+
npm package / CLI: g3usage · Node & Bun
|
|
22
23
|
|
|
23
24
|
${c.bold("USAGE")}
|
|
24
25
|
g3usage [daily] [options]
|
|
25
26
|
g3usage <command> [options]
|
|
27
|
+
npx g3usage@latest
|
|
28
|
+
bunx g3usage@latest
|
|
26
29
|
|
|
27
30
|
${c.bold("COMMANDS")}
|
|
28
31
|
daily Show usage grouped by date (default)
|
|
@@ -191,10 +194,10 @@ function alignFor(mode, noCost) {
|
|
|
191
194
|
function printReport(mode, rows, opts) {
|
|
192
195
|
const t = totals(rows);
|
|
193
196
|
const titleMap = {
|
|
194
|
-
daily: "Grok Build
|
|
195
|
-
weekly: "Grok Build
|
|
196
|
-
monthly: "Grok Build
|
|
197
|
-
session: "Grok Build
|
|
197
|
+
daily: "G3usage · Grok Build — Daily",
|
|
198
|
+
weekly: "G3usage · Grok Build — Weekly",
|
|
199
|
+
monthly: "G3usage · Grok Build — Monthly",
|
|
200
|
+
session: "G3usage · Grok Build — Session",
|
|
198
201
|
};
|
|
199
202
|
|
|
200
203
|
const headers = headersFor(mode, opts.noCost);
|