File size: 1,077 Bytes
10b5888
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Codex Usage Profiler

Local CLI for summarizing Codex usage from `~/.codex/state_5.sqlite` and rollout
JSONL files.

It reports:

- daily and ISO-week token totals
- tokens by cwd, model, role, and main vs subagent
- top sessions
- optional rollout token breakdowns for input, cached input, output, and
  reasoning tokens when those events exist
- Markdown and static HTML output

## Usage

```bash
python3 -m codex_usage_profiler
```

Default output is written to:

- `reports/codex-usage.md`
- `reports/codex-usage.html`

Useful options:

```bash
python3 -m codex_usage_profiler \
  --state ~/.codex/state_5.sqlite \
  --sessions-dir ~/.codex/sessions \
  --out reports \
  --format both \
  --tz Europe/Berlin \
  --days 30 \
  --top 25
```

`--days N` includes the last `N` local calendar days including today. Week
buckets use ISO weeks, starting on Monday.

The report never includes raw prompts, messages, command output, or model
responses. It only uses metadata and token counters.

## Development

Run tests with:

```bash
python3 -m unittest discover -s tests
```