codex-meter 0.3.0__tar.gz
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.
- codex_meter-0.3.0/.gitignore +14 -0
- codex_meter-0.3.0/CHANGELOG.md +130 -0
- codex_meter-0.3.0/LICENSE +21 -0
- codex_meter-0.3.0/PKG-INFO +304 -0
- codex_meter-0.3.0/README.md +273 -0
- codex_meter-0.3.0/pyproject.toml +92 -0
- codex_meter-0.3.0/schemas/rates.schema.json +73 -0
- codex_meter-0.3.0/schemas/tier-overrides.schema.json +69 -0
- codex_meter-0.3.0/src/codex_meter/__init__.py +12 -0
- codex_meter-0.3.0/src/codex_meter/__main__.py +4 -0
- codex_meter-0.3.0/src/codex_meter/aggregation.py +127 -0
- codex_meter-0.3.0/src/codex_meter/budgets.py +133 -0
- codex_meter-0.3.0/src/codex_meter/cli.py +2455 -0
- codex_meter-0.3.0/src/codex_meter/config.py +164 -0
- codex_meter-0.3.0/src/codex_meter/exporters.py +339 -0
- codex_meter-0.3.0/src/codex_meter/forecasts.py +92 -0
- codex_meter-0.3.0/src/codex_meter/humanize.py +38 -0
- codex_meter-0.3.0/src/codex_meter/insights.py +132 -0
- codex_meter-0.3.0/src/codex_meter/intervals.py +129 -0
- codex_meter-0.3.0/src/codex_meter/live.py +286 -0
- codex_meter-0.3.0/src/codex_meter/models.py +282 -0
- codex_meter-0.3.0/src/codex_meter/parse_cache.py +189 -0
- codex_meter-0.3.0/src/codex_meter/parser.py +498 -0
- codex_meter-0.3.0/src/codex_meter/pricing.py +311 -0
- codex_meter-0.3.0/src/codex_meter/prom_export.py +116 -0
- codex_meter-0.3.0/src/codex_meter/py.typed +0 -0
- codex_meter-0.3.0/src/codex_meter/render.py +545 -0
- codex_meter-0.3.0/src/codex_meter/timeutil.py +75 -0
- codex_meter-0.3.0/src/codex_meter/windows.py +153 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.3.0 - 2026-05-13
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- `insights` command for cache-savings, service-tier confidence, spend concentration,
|
|
7
|
+
and usage acceleration hints.
|
|
8
|
+
- `tail` command for recent usage events/sessions.
|
|
9
|
+
- Sidecar parse cache with `--no-parse-cache` bypass for parser debugging.
|
|
10
|
+
- Live TUI hotkeys (`q`, `?`, `r`, `p`) and `--max-ticks` for headless tests.
|
|
11
|
+
- Forecast API-dollar projection and sparkline output.
|
|
12
|
+
- Default `overview` invocation now accepts data-source, tier, rate-card, cache,
|
|
13
|
+
format, output, compact, and width options.
|
|
14
|
+
- `rates refresh --allow-network` now writes a pricing-source audit snapshot
|
|
15
|
+
with embedded rates, observed rates, and discrepancies instead of an empty
|
|
16
|
+
placeholder.
|
|
17
|
+
- Release automation now builds checked wheel/sdist artifacts, publishes through
|
|
18
|
+
PyPI Trusted Publishing, and attaches release assets on GitHub.
|
|
19
|
+
- Dependabot configuration now covers `uv` dependencies and GitHub Actions.
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
- Cost reporting now uses exact decimal arithmetic internally, exposes exact
|
|
23
|
+
decimal strings in JSON output, and marks partial or estimated pricing when
|
|
24
|
+
rates or service tiers are not source-verified.
|
|
25
|
+
- `rates refresh --allow-network` audits fast-mode multipliers and long-context
|
|
26
|
+
rules in addition to per-token rates.
|
|
27
|
+
- GPT-5.4 now carries the official `>272K` long-context rule.
|
|
28
|
+
- GPT-5.1-Codex-Max remains API-priced, but Codex credit totals are marked
|
|
29
|
+
partial unless a local `--rates-file` supplies credit rates.
|
|
30
|
+
- Table rendering now honors terminal/`--width` instead of collapsing to 80 columns.
|
|
31
|
+
- Grouped reports accept `--top` as an alias for `--top-threads`.
|
|
32
|
+
- Doctor, rates, forecast, compare, what-if, and budgets now support CSV/Markdown
|
|
33
|
+
alongside table/JSON.
|
|
34
|
+
- GPT-5.1-Codex-Max now has API-equivalent rates in the embedded card.
|
|
35
|
+
- Receipts include cache savings, tier-source breakdowns, warning counts, and top
|
|
36
|
+
insights, and redact full local labels by default. Use `--show-sensitive` for
|
|
37
|
+
private/local receipts with full session/project labels.
|
|
38
|
+
- `init` scaffolds the full config surface.
|
|
39
|
+
- Parse-cache entries are independent of the requested report window, so normal
|
|
40
|
+
rolling `now` invocations can reuse parsed sessions. Cache payloads now use
|
|
41
|
+
JSON instead of pickle.
|
|
42
|
+
- Source distributions are trimmed to release-relevant files.
|
|
43
|
+
- Install documentation now leads with public PyPI, `uvx`, `pipx`, and Homebrew
|
|
44
|
+
paths instead of source-checkout installation.
|
|
45
|
+
|
|
46
|
+
### Fixed
|
|
47
|
+
- Reasoning tokens are no longer double-counted when Codex logs already include
|
|
48
|
+
them in `output_tokens`.
|
|
49
|
+
- Literal `[budgets]` text no longer disappears in Rich output.
|
|
50
|
+
- Doctor clock-skew output uses directional wording instead of signed seconds.
|
|
51
|
+
- What-if no-op scenarios now say there is no change.
|
|
52
|
+
- Compare warns when one window is too sparse to be representative.
|
|
53
|
+
- GPT-5.3-Codex-Spark stays unpriced/research-preview instead of being
|
|
54
|
+
normalized to GPT-5.3-Codex.
|
|
55
|
+
- Rate-limit samples are retained for burn-rate math and only truncated at
|
|
56
|
+
render/report time.
|
|
57
|
+
- SQLite connections are closed explicitly, making warning-as-error test runs
|
|
58
|
+
clean on Python 3.13.
|
|
59
|
+
- Monthly receipts include events through the final sub-second before the next
|
|
60
|
+
month starts.
|
|
61
|
+
|
|
62
|
+
## 0.2.0
|
|
63
|
+
|
|
64
|
+
### Added
|
|
65
|
+
- **Live TUI** (`codex-meter live`): full-window dashboard with today's credits, 7-day
|
|
66
|
+
total, 5-hour primary + weekly secondary countdowns, burn rate, ETA to 100%.
|
|
67
|
+
Border turns red at >= 80% used. `--interval` to tune refresh, graceful SIGINT.
|
|
68
|
+
- **Window math** (`windows.py`): `WindowState` decoded from rate-limit samples;
|
|
69
|
+
Unix-epoch `resets_at` handled correctly; burn rate requires >= 3 samples in
|
|
70
|
+
a 6-hour lookback; ETA projection only when burn rate is positive.
|
|
71
|
+
- **Analytics suite**:
|
|
72
|
+
- `forecast`: month-end credit projection with linear + EWMA estimators
|
|
73
|
+
and a ±1σ band. Optional `--cap` reports days-to-depletion.
|
|
74
|
+
- `compare --a --b`: side-by-side credit, dollar, and token deltas
|
|
75
|
+
between two windows (`last 7 days`, `previous 7 days`, ISO ranges, etc.).
|
|
76
|
+
- `whatif --tier --model`: re-cost the trailing window under a hypothetical
|
|
77
|
+
tier or model swap; rejects unknown models with the rate-card list.
|
|
78
|
+
- **Budgets** (`budgets check`): TOML `[budgets]` table (flat keys,
|
|
79
|
+
nested-by-period, or `items = [...]` list). Severity ladder ok/warn/breach
|
|
80
|
+
drives the exit code so CI can gate on it.
|
|
81
|
+
- **Rate card subcommands**:
|
|
82
|
+
- `rates show` (table + JSON) with age + stale-after-90d flag.
|
|
83
|
+
- `rates refresh` stub reserved for the network-opt-in flow.
|
|
84
|
+
- **Exporters**:
|
|
85
|
+
- `export grafana`: dashboard JSON wired to codex-meter Prometheus metrics.
|
|
86
|
+
- `export receipt --month YYYY-MM --format markdown|html`: totals, models,
|
|
87
|
+
top sessions, top projects. HTML escapes user-supplied labels.
|
|
88
|
+
- `export prometheus --host --port`: stdlib `/metrics` endpoint serving
|
|
89
|
+
`codex_meter_credits_used`, `burn_per_hour`,
|
|
90
|
+
`window_used_percent{window}`, `tokens_total{model,tier,kind}`,
|
|
91
|
+
`events_total`, `long_context_events_total`. Binds 127.0.0.1 by default.
|
|
92
|
+
- `[prom]` optional extra installs `prometheus-client`.
|
|
93
|
+
- **`init`** subcommand: scaffolds `.codex-meter.toml` with commented defaults;
|
|
94
|
+
refuses overwrite without `--force`.
|
|
95
|
+
- **`doctor` v2**: Python version, session root + file count, state DB, Codex
|
|
96
|
+
config, `codex --version` (best-effort), rate-card age, clock skew vs latest
|
|
97
|
+
event, parser warnings. JSON output for CI. Exit code reflects worst check.
|
|
98
|
+
- **Intervals** (`intervals.py`): `today`, `yesterday`, `last N days`,
|
|
99
|
+
`previous N days`, `last N hours`, `this/last week`, `this/last month`,
|
|
100
|
+
ISO date, `YYYY-MM-DD..YYYY-MM-DD` range.
|
|
101
|
+
- **JSON Schemas**: `schemas/rates.schema.json`, `schemas/tier-overrides.schema.json`
|
|
102
|
+
(Draft 2020-12) for editor autocomplete + validation.
|
|
103
|
+
|
|
104
|
+
### Pricing accuracy
|
|
105
|
+
- `Rates` gains `reasoning_output` (defaults to `output` rate). Pricing now
|
|
106
|
+
accounts for reasoning tokens, which were previously invisible.
|
|
107
|
+
- `LongContextRule` lives on `ModelCard`; only `gpt-5.5` carries the
|
|
108
|
+
272K-token, ×2/×1.5 rule today. Other models do not get the multiplier.
|
|
109
|
+
|
|
110
|
+
### Refactor
|
|
111
|
+
- `cli.py` deduplicated: subcommands share `Annotated` Option type aliases.
|
|
112
|
+
- `ModelCard` replaces parallel rate dicts.
|
|
113
|
+
- `RateCard` loads any local override file exactly once per run.
|
|
114
|
+
- `Usage` frozen dataclass replaces ad-hoc `dict[str, int]` usage shapes
|
|
115
|
+
across events, aggregation, and pricing.
|
|
116
|
+
- `humanize.py` carved out for `format_int`, `redact`, `REDACTION_LIMIT`.
|
|
117
|
+
- `limits` command participates in the unified render pipeline and
|
|
118
|
+
supports `--format table|json|csv|markdown` with decoded reset times.
|
|
119
|
+
|
|
120
|
+
### Packaging
|
|
121
|
+
- `__version__` resolves through `importlib.metadata` with a local fallback.
|
|
122
|
+
- `py.typed` marker shipped (PEP 561).
|
|
123
|
+
- `pytest-cov` wired up; line+branch coverage at >= 82%.
|
|
124
|
+
|
|
125
|
+
## 0.1.0
|
|
126
|
+
|
|
127
|
+
- Initial open-source-ready CLI scaffold.
|
|
128
|
+
- Added Codex JSONL parsing, SQLite metadata joins, token aggregation, Codex
|
|
129
|
+
credit estimates, API-equivalent dollar estimates, service-tier inference,
|
|
130
|
+
and table/JSON/CSV/Markdown output.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Rajdeep Mondal
|
|
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.
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: codex-meter
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Local Codex usage intelligence for sessions, projects, models, cache, and rate-limit windows.
|
|
5
|
+
Project-URL: Homepage, https://github.com/rajdeepmondaldotcom/codex-meter
|
|
6
|
+
Project-URL: Repository, https://github.com/rajdeepmondaldotcom/codex-meter
|
|
7
|
+
Project-URL: Issues, https://github.com/rajdeepmondaldotcom/codex-meter/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/rajdeepmondaldotcom/codex-meter/blob/main/CHANGELOG.md
|
|
9
|
+
Author: Rajdeep Mondal
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: cli,codex,credits,openai,tokens,usage
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Environment :: Console
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Software Development
|
|
23
|
+
Classifier: Topic :: Utilities
|
|
24
|
+
Classifier: Typing :: Typed
|
|
25
|
+
Requires-Python: >=3.11
|
|
26
|
+
Requires-Dist: rich>=13.7
|
|
27
|
+
Requires-Dist: typer>=0.12
|
|
28
|
+
Provides-Extra: prom
|
|
29
|
+
Requires-Dist: prometheus-client>=0.20; extra == 'prom'
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
|
|
32
|
+
# codex-meter
|
|
33
|
+
|
|
34
|
+
[](https://github.com/rajdeepmondaldotcom/codex-meter/actions/workflows/ci.yml)
|
|
35
|
+
[](https://pypi.org/project/codex-meter/)
|
|
36
|
+
[](pyproject.toml)
|
|
37
|
+
[](LICENSE)
|
|
38
|
+
|
|
39
|
+
Understand your Codex work locally.
|
|
40
|
+
|
|
41
|
+
`codex-meter` turns local Codex logs into a clear record of how your coding work
|
|
42
|
+
happened: sessions, projects, models, tiers, cache reuse, tokens, credits,
|
|
43
|
+
API-equivalent dollars, and rate-limit windows.
|
|
44
|
+
|
|
45
|
+
No cloud sync. No account login. No billing scrape. Just local evidence you can
|
|
46
|
+
inspect, export, and trust.
|
|
47
|
+
|
|
48
|
+
## Install
|
|
49
|
+
|
|
50
|
+
Requires Python 3.11+.
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
uvx codex-meter
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Persistent install:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
uv tool install codex-meter
|
|
60
|
+
codex-meter
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
With `pipx`:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
pipx install codex-meter
|
|
67
|
+
codex-meter
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
With `pip`:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
python -m pip install codex-meter
|
|
74
|
+
codex-meter
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Prometheus exporter:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
uv tool install 'codex-meter[prom]'
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Homebrew:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
brew install rajdeepmondaldotcom/tap/codex-meter
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Start Here
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
codex-meter # 7 / 30 / 90 day overview
|
|
93
|
+
codex-meter doctor # check local data and assumptions
|
|
94
|
+
codex-meter live # watch usage while you work
|
|
95
|
+
codex-meter project --days 30 # see project activity
|
|
96
|
+
codex-meter models --days 30 # inspect model and tier mix
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
The first run parses local session files. Later runs use a sidecar parse cache.
|
|
100
|
+
Use `--no-parse-cache` when debugging parser behavior.
|
|
101
|
+
|
|
102
|
+
## Why It Exists
|
|
103
|
+
|
|
104
|
+
Codex already leaves a detailed trail on your machine. The problem is that the
|
|
105
|
+
trail is split across JSONL sessions, SQLite metadata, config, rate-limit
|
|
106
|
+
samples, and pricing assumptions. `codex-meter` turns that trail into one local
|
|
107
|
+
view.
|
|
108
|
+
|
|
109
|
+
It answers:
|
|
110
|
+
|
|
111
|
+
- What did I use?
|
|
112
|
+
- Where did it go?
|
|
113
|
+
- Which model and tier drove it?
|
|
114
|
+
- How much input was cached?
|
|
115
|
+
- What changed across sessions, projects, and days?
|
|
116
|
+
|
|
117
|
+
This is not an OpenAI billing ledger. It is local usage intelligence.
|
|
118
|
+
|
|
119
|
+
## Commands
|
|
120
|
+
|
|
121
|
+
| Need | Command |
|
|
122
|
+
| --- | --- |
|
|
123
|
+
| Overview | `codex-meter` |
|
|
124
|
+
| Daily / weekly / monthly | `codex-meter daily`, `weekly`, `monthly` |
|
|
125
|
+
| Sessions | `codex-meter session --top 20` |
|
|
126
|
+
| Projects | `codex-meter project --days 30` |
|
|
127
|
+
| Models and tiers | `codex-meter models --days 30` |
|
|
128
|
+
| Recent events | `codex-meter tail --n 20` |
|
|
129
|
+
| Rate limits | `codex-meter limits` |
|
|
130
|
+
| Insights | `codex-meter insights` |
|
|
131
|
+
| Forecast | `codex-meter forecast --days 14` |
|
|
132
|
+
| Compare windows | `codex-meter compare --a "last 7 days" --b "previous 7 days"` |
|
|
133
|
+
| What-if pricing | `codex-meter whatif --tier standard` |
|
|
134
|
+
| Optional budgets | `codex-meter budgets check` |
|
|
135
|
+
| Receipt | `codex-meter export receipt --month 2026-05 --format html` |
|
|
136
|
+
| Prometheus | `codex-meter export prometheus --port 9090` |
|
|
137
|
+
| Grafana | `codex-meter export grafana > dashboard.json` |
|
|
138
|
+
|
|
139
|
+
Most report commands support:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
--format table|json|csv|markdown
|
|
143
|
+
--output report.json
|
|
144
|
+
--since 2026-05-01
|
|
145
|
+
--days 30
|
|
146
|
+
--top 20
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Live View
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
codex-meter live
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Shows today's usage, trailing 7-day usage, 5-hour and weekly windows, burn rate,
|
|
156
|
+
and ETA to 100% when enough samples exist.
|
|
157
|
+
|
|
158
|
+
Hotkeys:
|
|
159
|
+
|
|
160
|
+
| Key | Action |
|
|
161
|
+
| --- | --- |
|
|
162
|
+
| `q` | Quit |
|
|
163
|
+
| `?` | Help |
|
|
164
|
+
| `r` | Refresh |
|
|
165
|
+
| `p` | Pause |
|
|
166
|
+
|
|
167
|
+
## Budgets
|
|
168
|
+
|
|
169
|
+
Create a config:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
codex-meter init
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Add limits:
|
|
176
|
+
|
|
177
|
+
```toml
|
|
178
|
+
[budgets]
|
|
179
|
+
daily_credits = 25000
|
|
180
|
+
weekly_credits = 100000
|
|
181
|
+
monthly_credits = 400000
|
|
182
|
+
weekly_api_dollars = 50.0
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Check them:
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
codex-meter budgets check
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Exit codes are built for automation:
|
|
192
|
+
|
|
193
|
+
| Exit | Meaning |
|
|
194
|
+
| ---: | --- |
|
|
195
|
+
| `0` | ok |
|
|
196
|
+
| `1` | warning |
|
|
197
|
+
| `2` | breached or failed |
|
|
198
|
+
|
|
199
|
+
## Exports
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
codex-meter export receipt --month 2026-05 --format markdown
|
|
203
|
+
codex-meter export receipt --month 2026-05 --format html > receipt.html
|
|
204
|
+
codex-meter export prometheus --host 127.0.0.1 --port 9090
|
|
205
|
+
codex-meter export grafana > dashboard.json
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Receipts redact local session and project labels by default. Use
|
|
209
|
+
`--show-sensitive` only for private artifacts.
|
|
210
|
+
|
|
211
|
+
Prometheus exposes credits, burn rate, rate-limit window percent, event count,
|
|
212
|
+
long-context event count, and tokens by model/tier/kind.
|
|
213
|
+
|
|
214
|
+
## Data Sources
|
|
215
|
+
|
|
216
|
+
`codex-meter` reads:
|
|
217
|
+
|
|
218
|
+
- `~/.codex/sessions/**/*.jsonl`
|
|
219
|
+
- `~/.codex/state_5.sqlite`
|
|
220
|
+
- `~/.codex/config.toml`
|
|
221
|
+
|
|
222
|
+
Normal reports do not touch the network. The only networked command is explicit:
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
codex-meter rates refresh --allow-network
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
That writes a local pricing-source audit snapshot, including observed token
|
|
229
|
+
rates, fast multipliers, long-context rules, and discrepancies. It does not
|
|
230
|
+
rewrite the embedded rate card.
|
|
231
|
+
|
|
232
|
+
## Accuracy
|
|
233
|
+
|
|
234
|
+
The hard part is not adding tokens. It is making assumptions visible.
|
|
235
|
+
|
|
236
|
+
`codex-meter` tracks cached input separately, applies per-model long-context
|
|
237
|
+
rules, uses exact decimal math internally, and reports whether service tiers
|
|
238
|
+
came from logs, config, overrides, or assumptions. If a model or credit rate is
|
|
239
|
+
not source-verified, reports mark pricing as partial instead of silently using a
|
|
240
|
+
fallback as exact.
|
|
241
|
+
|
|
242
|
+
Reasoning tokens are only billed separately when the Codex token log shows they
|
|
243
|
+
are not already included in output tokens. This prevents double-counting on
|
|
244
|
+
current local Codex logs.
|
|
245
|
+
|
|
246
|
+
Service-tier precedence:
|
|
247
|
+
|
|
248
|
+
1. `--service-tier standard|fast`
|
|
249
|
+
2. `--tier-overrides overrides.json`
|
|
250
|
+
3. logged tier
|
|
251
|
+
4. current `~/.codex/config.toml`
|
|
252
|
+
5. `--unknown-service-tier`
|
|
253
|
+
|
|
254
|
+
Inspect pricing:
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
codex-meter rates show
|
|
258
|
+
codex-meter rates show --format json
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Use local overrides when needed:
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
codex-meter daily --rates-file ./rates.json
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
Schemas:
|
|
268
|
+
|
|
269
|
+
- [`schemas/rates.schema.json`](schemas/rates.schema.json)
|
|
270
|
+
- [`schemas/tier-overrides.schema.json`](schemas/tier-overrides.schema.json)
|
|
271
|
+
|
|
272
|
+
## Privacy
|
|
273
|
+
|
|
274
|
+
The default posture is local and conservative.
|
|
275
|
+
|
|
276
|
+
- Reports read local files.
|
|
277
|
+
- Prompt and session labels are redacted unless requested.
|
|
278
|
+
- Receipts hide full session IDs and project paths by default.
|
|
279
|
+
- JSON, CSV, Markdown, and HTML exports may still contain local metadata.
|
|
280
|
+
|
|
281
|
+
Treat exports as sensitive unless you made them for sharing.
|
|
282
|
+
|
|
283
|
+
## Development
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
uv sync --dev
|
|
287
|
+
uv run ruff check .
|
|
288
|
+
uv run ruff format --check .
|
|
289
|
+
PYTHONWARNINGS=error::ResourceWarning uv run pytest
|
|
290
|
+
uv run pytest --cov=src/codex_meter --cov-report=term
|
|
291
|
+
uv run python -m build
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
Smoke test against your own logs:
|
|
295
|
+
|
|
296
|
+
```bash
|
|
297
|
+
uv run codex-meter doctor
|
|
298
|
+
uv run codex-meter overview
|
|
299
|
+
uv run codex-meter rates show
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
## License
|
|
303
|
+
|
|
304
|
+
MIT
|