codex-usage-tracking 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.
Files changed (102) hide show
  1. codex_usage_tracking-0.3.0/.codex-plugin/plugin.json +44 -0
  2. codex_usage_tracking-0.3.0/.mcp.json +10 -0
  3. codex_usage_tracking-0.3.0/AGENTS.md +126 -0
  4. codex_usage_tracking-0.3.0/CHANGELOG.md +47 -0
  5. codex_usage_tracking-0.3.0/CONTRIBUTING.md +40 -0
  6. codex_usage_tracking-0.3.0/LICENSE +21 -0
  7. codex_usage_tracking-0.3.0/MANIFEST.in +12 -0
  8. codex_usage_tracking-0.3.0/PKG-INFO +278 -0
  9. codex_usage_tracking-0.3.0/README.md +242 -0
  10. codex_usage_tracking-0.3.0/SECURITY.md +43 -0
  11. codex_usage_tracking-0.3.0/assets/icon.svg +8 -0
  12. codex_usage_tracking-0.3.0/docs/architecture.md +53 -0
  13. codex_usage_tracking-0.3.0/docs/assets/dashboard-calls-preview.png +0 -0
  14. codex_usage_tracking-0.3.0/docs/assets/dashboard-calls.png +0 -0
  15. codex_usage_tracking-0.3.0/docs/assets/dashboard-details.png +0 -0
  16. codex_usage_tracking-0.3.0/docs/assets/dashboard-insights.png +0 -0
  17. codex_usage_tracking-0.3.0/docs/assets/dashboard-threads.png +0 -0
  18. codex_usage_tracking-0.3.0/docs/assets/plugin-prompts.png +0 -0
  19. codex_usage_tracking-0.3.0/docs/assets/plugin-thread-leaderboard.png +0 -0
  20. codex_usage_tracking-0.3.0/docs/assets/ux/call-detail-panel.png +0 -0
  21. codex_usage_tracking-0.3.0/docs/assets/ux/insight-overview.png +0 -0
  22. codex_usage_tracking-0.3.0/docs/assets/ux/thread-investigation.png +0 -0
  23. codex_usage_tracking-0.3.0/docs/cli-json-schemas.md +265 -0
  24. codex_usage_tracking-0.3.0/docs/cli-reference.md +134 -0
  25. codex_usage_tracking-0.3.0/docs/dashboard-guide.md +195 -0
  26. codex_usage_tracking-0.3.0/docs/development.md +133 -0
  27. codex_usage_tracking-0.3.0/docs/install.md +144 -0
  28. codex_usage_tracking-0.3.0/docs/mcp.md +81 -0
  29. codex_usage_tracking-0.3.0/docs/pricing-and-credits.md +90 -0
  30. codex_usage_tracking-0.3.0/docs/privacy.md +90 -0
  31. codex_usage_tracking-0.3.0/docs/ui-ux-improvement-plan.md +183 -0
  32. codex_usage_tracking-0.3.0/pyproject.toml +104 -0
  33. codex_usage_tracking-0.3.0/scripts/benchmark_synthetic_history.py +187 -0
  34. codex_usage_tracking-0.3.0/scripts/check_release.py +367 -0
  35. codex_usage_tracking-0.3.0/scripts/install_local_plugin.py +49 -0
  36. codex_usage_tracking-0.3.0/setup.cfg +4 -0
  37. codex_usage_tracking-0.3.0/skills/codex-usage-api/SKILL.md +62 -0
  38. codex_usage_tracking-0.3.0/skills/codex-usage-tracker/SKILL.md +47 -0
  39. codex_usage_tracking-0.3.0/skills/codex-usage-tracker/scripts/run_mcp.py +125 -0
  40. codex_usage_tracking-0.3.0/src/codex_usage_tracker/__init__.py +7 -0
  41. codex_usage_tracking-0.3.0/src/codex_usage_tracker/__main__.py +6 -0
  42. codex_usage_tracking-0.3.0/src/codex_usage_tracker/allowance.py +759 -0
  43. codex_usage_tracking-0.3.0/src/codex_usage_tracker/api_payloads.py +90 -0
  44. codex_usage_tracking-0.3.0/src/codex_usage_tracker/cli.py +1326 -0
  45. codex_usage_tracking-0.3.0/src/codex_usage_tracker/context.py +410 -0
  46. codex_usage_tracking-0.3.0/src/codex_usage_tracker/costing.py +176 -0
  47. codex_usage_tracking-0.3.0/src/codex_usage_tracker/dashboard.py +389 -0
  48. codex_usage_tracking-0.3.0/src/codex_usage_tracker/diagnostics.py +624 -0
  49. codex_usage_tracking-0.3.0/src/codex_usage_tracker/formatting.py +225 -0
  50. codex_usage_tracking-0.3.0/src/codex_usage_tracker/json_contracts.py +350 -0
  51. codex_usage_tracking-0.3.0/src/codex_usage_tracker/mcp_server.py +371 -0
  52. codex_usage_tracking-0.3.0/src/codex_usage_tracker/models.py +92 -0
  53. codex_usage_tracking-0.3.0/src/codex_usage_tracker/parser.py +491 -0
  54. codex_usage_tracking-0.3.0/src/codex_usage_tracker/paths.py +18 -0
  55. codex_usage_tracking-0.3.0/src/codex_usage_tracker/plugin_data/__init__.py +1 -0
  56. codex_usage_tracking-0.3.0/src/codex_usage_tracker/plugin_data/assets/icon.svg +8 -0
  57. codex_usage_tracking-0.3.0/src/codex_usage_tracker/plugin_data/dashboard/dashboard.css +954 -0
  58. codex_usage_tracking-0.3.0/src/codex_usage_tracker/plugin_data/dashboard/dashboard.js +1833 -0
  59. codex_usage_tracking-0.3.0/src/codex_usage_tracker/plugin_data/dashboard/dashboard_data.js +155 -0
  60. codex_usage_tracking-0.3.0/src/codex_usage_tracker/plugin_data/dashboard/dashboard_format.js +132 -0
  61. codex_usage_tracking-0.3.0/src/codex_usage_tracker/plugin_data/dashboard/dashboard_state.js +157 -0
  62. codex_usage_tracking-0.3.0/src/codex_usage_tracker/plugin_data/dashboard/dashboard_template.html +141 -0
  63. codex_usage_tracking-0.3.0/src/codex_usage_tracker/plugin_data/docs/assets/dashboard-calls.png +0 -0
  64. codex_usage_tracking-0.3.0/src/codex_usage_tracker/plugin_data/docs/assets/dashboard-details.png +0 -0
  65. codex_usage_tracking-0.3.0/src/codex_usage_tracker/plugin_data/docs/assets/dashboard-insights.png +0 -0
  66. codex_usage_tracking-0.3.0/src/codex_usage_tracker/plugin_data/docs/assets/dashboard-threads.png +0 -0
  67. codex_usage_tracking-0.3.0/src/codex_usage_tracker/plugin_data/docs/dashboard-guide.html +136 -0
  68. codex_usage_tracking-0.3.0/src/codex_usage_tracker/plugin_data/rate_cards/codex-credit-rates.json +69 -0
  69. codex_usage_tracking-0.3.0/src/codex_usage_tracker/plugin_data/skills/codex-usage-api/SKILL.md +62 -0
  70. codex_usage_tracking-0.3.0/src/codex_usage_tracker/plugin_data/skills/codex-usage-tracker/SKILL.md +47 -0
  71. codex_usage_tracking-0.3.0/src/codex_usage_tracker/plugin_installer.py +312 -0
  72. codex_usage_tracking-0.3.0/src/codex_usage_tracker/pricing.py +57 -0
  73. codex_usage_tracking-0.3.0/src/codex_usage_tracker/pricing_config.py +223 -0
  74. codex_usage_tracking-0.3.0/src/codex_usage_tracker/pricing_estimates.py +44 -0
  75. codex_usage_tracking-0.3.0/src/codex_usage_tracker/pricing_openai.py +253 -0
  76. codex_usage_tracking-0.3.0/src/codex_usage_tracker/projects.py +347 -0
  77. codex_usage_tracking-0.3.0/src/codex_usage_tracker/recommendations.py +270 -0
  78. codex_usage_tracking-0.3.0/src/codex_usage_tracker/reports.py +637 -0
  79. codex_usage_tracking-0.3.0/src/codex_usage_tracker/schema.py +71 -0
  80. codex_usage_tracking-0.3.0/src/codex_usage_tracker/server.py +400 -0
  81. codex_usage_tracking-0.3.0/src/codex_usage_tracker/store.py +666 -0
  82. codex_usage_tracking-0.3.0/src/codex_usage_tracker/support.py +147 -0
  83. codex_usage_tracking-0.3.0/src/codex_usage_tracker/threads.py +183 -0
  84. codex_usage_tracking-0.3.0/src/codex_usage_tracking.egg-info/PKG-INFO +278 -0
  85. codex_usage_tracking-0.3.0/src/codex_usage_tracking.egg-info/SOURCES.txt +100 -0
  86. codex_usage_tracking-0.3.0/src/codex_usage_tracking.egg-info/dependency_links.txt +1 -0
  87. codex_usage_tracking-0.3.0/src/codex_usage_tracking.egg-info/entry_points.txt +2 -0
  88. codex_usage_tracking-0.3.0/src/codex_usage_tracking.egg-info/requires.txt +11 -0
  89. codex_usage_tracking-0.3.0/src/codex_usage_tracking.egg-info/top_level.txt +1 -0
  90. codex_usage_tracking-0.3.0/tests/test_allowance.py +198 -0
  91. codex_usage_tracking-0.3.0/tests/test_cli_lifecycle.py +398 -0
  92. codex_usage_tracking-0.3.0/tests/test_cli_release.py +116 -0
  93. codex_usage_tracking-0.3.0/tests/test_json_contracts.py +50 -0
  94. codex_usage_tracking-0.3.0/tests/test_mcp_launcher.py +58 -0
  95. codex_usage_tracking-0.3.0/tests/test_parser.py +263 -0
  96. codex_usage_tracking-0.3.0/tests/test_plugin_installer.py +226 -0
  97. codex_usage_tracking-0.3.0/tests/test_pricing.py +162 -0
  98. codex_usage_tracking-0.3.0/tests/test_projects.py +123 -0
  99. codex_usage_tracking-0.3.0/tests/test_recommendations.py +72 -0
  100. codex_usage_tracking-0.3.0/tests/test_schema.py +45 -0
  101. codex_usage_tracking-0.3.0/tests/test_store_dashboard_mcp.py +1315 -0
  102. codex_usage_tracking-0.3.0/tests/test_threads.py +53 -0
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "codex-usage-tracker",
3
+ "version": "0.3.0",
4
+ "description": "Unofficial local tracker for aggregate Codex token usage from local session logs.",
5
+ "author": {
6
+ "name": "Douglas Monsky"
7
+ },
8
+ "homepage": "https://github.com/douglasmonsky/codex-usage-tracker",
9
+ "repository": "https://github.com/douglasmonsky/codex-usage-tracker",
10
+ "license": "MIT",
11
+ "keywords": [
12
+ "codex",
13
+ "tokens",
14
+ "usage",
15
+ "mcp",
16
+ "dashboard"
17
+ ],
18
+ "skills": "./skills/",
19
+ "mcpServers": "./.mcp.json",
20
+ "interface": {
21
+ "displayName": "Codex Usage Tracker",
22
+ "shortDescription": "Unofficial local aggregate token usage analytics for Codex",
23
+ "longDescription": "Unofficial independent project, not made by, affiliated with, endorsed by, sponsored by, or supported by OpenAI. Reads local Codex session logs, aggregates exact token usage counters, and generates summaries, CSV exports, and a hoverable dashboard with optional localhost-only raw context loading.",
24
+ "developerName": "Douglas Monsky",
25
+ "category": "Productivity",
26
+ "capabilities": [
27
+ "Interactive",
28
+ "Read",
29
+ "Write"
30
+ ],
31
+ "websiteURL": "https://github.com/douglasmonsky/codex-usage-tracker",
32
+ "privacyPolicyURL": "https://github.com/douglasmonsky/codex-usage-tracker",
33
+ "termsOfServiceURL": "https://github.com/douglasmonsky/codex-usage-tracker",
34
+ "defaultPrompt": [
35
+ "Open dashboard",
36
+ "Heaviest thread?",
37
+ "Thread leaderboard"
38
+ ],
39
+ "brandColor": "#2563EB",
40
+ "composerIcon": "./assets/icon.svg",
41
+ "logo": "./assets/icon.svg",
42
+ "screenshots": []
43
+ }
44
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "mcpServers": {
3
+ "codex-usage-tracker": {
4
+ "command": "python3",
5
+ "args": ["./skills/codex-usage-tracker/scripts/run_mcp.py"],
6
+ "cwd": ".",
7
+ "startup_timeout_sec": 120
8
+ }
9
+ }
10
+ }
@@ -0,0 +1,126 @@
1
+ # Codex Usage Tracker Instructions
2
+
3
+ ## Project Purpose
4
+
5
+ This repo builds a local Codex plugin and dashboard that track aggregate token usage from Codex session logs.
6
+
7
+ ## Tech Stack
8
+
9
+ - Python 3.10+
10
+ - SQLite via the Python standard library
11
+ - MCP Python SDK for Codex tool exposure
12
+ - Pytest for tests
13
+
14
+ ## Repo Layout
15
+
16
+ - `src/codex_usage_tracker/` - parser, SQLite store, reports, dashboard, CLI, and MCP server.
17
+ - `src/codex_usage_tracker/context.py` - on-demand raw-context reader for one selected usage record.
18
+ - `src/codex_usage_tracker/reports.py` - shared application/report services used by CLI and MCP wrappers.
19
+ - `src/codex_usage_tracker/api_payloads.py` - shared stable JSON payload builders for CLI and MCP surfaces.
20
+ - `src/codex_usage_tracker/schema.py` - single source of truth for persisted usage-event columns.
21
+ - `src/codex_usage_tracker/threads.py` - thread attachment inference used by dashboard payload generation.
22
+ - `src/codex_usage_tracker/pricing_config.py`, `pricing_openai.py`, `pricing_estimates.py`, and `costing.py` - pricing config, source parsing, estimate policy, and cost calculations behind the `pricing.py` facade.
23
+ - `src/codex_usage_tracker/allowance.py` - Codex credit-rate and optional local allowance-window helpers.
24
+ - `src/codex_usage_tracker/plugin_installer.py` - package-owned local Codex plugin installer.
25
+ - `src/codex_usage_tracker/plugin_data/` - plugin assets, dashboard template/assets, local dashboard guide, screenshots, and skill files bundled into wheels.
26
+ - `skills/codex-usage-tracker/` and `src/codex_usage_tracker/plugin_data/skills/codex-usage-tracker/` - operational Codex skill for tracker setup, summaries, dashboard generation, and MCP tools.
27
+ - `skills/codex-usage-api/` and `src/codex_usage_tracker/plugin_data/skills/codex-usage-api/` - companion Codex skill for conversational analysis using the stable JSON API/MCP tools.
28
+ - `src/codex_usage_tracker/server.py` - localhost dashboard server with live aggregate refresh and lazy context endpoints.
29
+ - `~/.codex-usage-tracker/pricing.json` - optional local-only pricing config, never committed.
30
+ - `~/.codex-usage-tracker/allowance.json` - optional local-only copied allowance state, never committed.
31
+ - `.codex-plugin/plugin.json` - Codex plugin manifest.
32
+ - `.mcp.json` - MCP server configuration for Codex.
33
+ - `scripts/install_local_plugin.py` - compatibility wrapper around `codex-usage-tracker install-plugin`.
34
+ - `scripts/check_release.py` - release-readiness checks for docs, versions, packaging, wheel contents, and tracked secret patterns.
35
+ - `.github/workflows/ci.yml` - GitHub Actions test and package build workflow.
36
+ - `.github/workflows/pricing-compat.yml` - scheduled/manual non-blocking live pricing parser compatibility check.
37
+ - `docs/` - install, dashboard, CLI, pricing/credits, MCP, privacy, architecture, development, JSON-schema docs, and screenshots built from synthetic aggregate fixture data.
38
+ - `tests/` - synthetic fixtures and unit tests.
39
+
40
+ ## Setup
41
+
42
+ ```bash
43
+ python3 -m venv .venv
44
+ . .venv/bin/activate
45
+ python -m pip install --upgrade pip
46
+ python -m pip install ".[dev]" twine
47
+ codex-usage-tracker install-plugin --python .venv/bin/python
48
+ ```
49
+
50
+ ## Validation
51
+
52
+ Run the local CI gate before pushing to `main`:
53
+
54
+ ```bash
55
+ python -m ruff check .
56
+ python -m mypy
57
+ python -m pytest
58
+ python -m pytest --cov=codex_usage_tracker --cov-report=term-missing
59
+ python -m compileall src
60
+ node --check src/codex_usage_tracker/plugin_data/dashboard/dashboard_format.js
61
+ node --check src/codex_usage_tracker/plugin_data/dashboard/dashboard_data.js
62
+ node --check src/codex_usage_tracker/plugin_data/dashboard/dashboard.js
63
+ node --check src/codex_usage_tracker/plugin_data/dashboard/dashboard_state.js
64
+ python scripts/check_release.py
65
+ git diff --check
66
+ rm -rf dist build src/codex_usage_tracker.egg-info src/codex_usage_tracking.egg-info
67
+ python -m build
68
+ python -m twine check dist/*
69
+ python scripts/check_release.py --dist
70
+ ```
71
+
72
+ Additional smoke checks for touched CLI surfaces:
73
+
74
+ ```bash
75
+ python -m pytest
76
+ python -m compileall src
77
+ node --check src/codex_usage_tracker/plugin_data/dashboard/dashboard.js
78
+ node --check src/codex_usage_tracker/plugin_data/dashboard/dashboard_state.js
79
+ python -m build
80
+ python scripts/check_release.py --dist
81
+ git diff --check
82
+ codex-usage-tracker update-pricing --output /tmp/codex-usage-pricing.json
83
+ codex-usage-tracker update-rate-card --output /tmp/codex-usage-rate-card.json
84
+ codex-usage-tracker doctor
85
+ codex-usage-tracker doctor --suggest-repair
86
+ codex-usage-tracker dashboard --output /tmp/codex-usage-dashboard.html
87
+ codex-usage-tracker serve-dashboard --help
88
+ codex-usage-tracker init-allowance --output /tmp/codex-usage-allowance.json
89
+ codex-usage-tracker parse-allowance --output /tmp/codex-usage-allowance.json "5h 79% 6:50 PM Weekly 33% Jun 7"
90
+ codex-usage-tracker init-thresholds --output /tmp/codex-usage-thresholds.json
91
+ codex-usage-tracker init-projects --output /tmp/codex-usage-projects.json
92
+ codex-usage-tracker support-bundle --output /tmp/codex-usage-support.json
93
+ codex-usage-tracker pricing-coverage
94
+ codex-usage-tracker summary --preset by-subagent-role
95
+ codex-usage-tracker expensive --limit 5
96
+ ```
97
+
98
+ ## Privacy Rules
99
+
100
+ - Never commit real Codex session logs.
101
+ - Never store raw prompts, assistant text, tool outputs, pasted secrets, or message snippets.
102
+ - Raw context may be read only on demand from original local JSONL files; never persist it to SQLite, CSV, generated HTML, fixtures based on real logs, or commits.
103
+ - Store only selected aggregate session metadata for subagents, including parent thread labels; do not persist raw session instructions or source JSON.
104
+ - Keep fixture data synthetic.
105
+ - Keep local SQLite databases, CSV exports, HTML dashboards, caches, and virtualenvs out of git.
106
+ - Do not hard-code real current USD model pricing in source; refresh the local config from OpenAI's published pricing docs or use manual local overrides. Internal Codex model estimates must be explicitly marked as estimates with source and rationale metadata.
107
+ - Source-stamped Codex credit rate-card snapshots must include source/date metadata, confidence labels, and local override support. Manually copied allowance remaining values stay in local config only.
108
+
109
+ ## Definition Of Done
110
+
111
+ - Parser handles synthetic session logs without reading raw message content.
112
+ - SQLite refresh is idempotent.
113
+ - MCP tool functions return concise aggregate data.
114
+ - Dashboard is generated from aggregate-only JSON.
115
+ - Doctor, summary presets, dashboard, and expensive-call views work from CLI and MCP wrappers.
116
+ - `codex-usage-tracker install-plugin` can register the installed package without relying on a source-checkout symlink.
117
+ - `python -m codex_usage_tracker` and `codex-usage-tracker --version` both work.
118
+ - Wheel and source distribution builds include plugin assets and the Codex skill.
119
+ - `scripts/check_release.py --dist` passes before any public release.
120
+ - Pricing coverage clearly separates configured, estimated, and unpriced model usage.
121
+ - Codex credit coverage clearly separates exact rate-card matches, inferred aliases, and missing credit rates.
122
+ - Dashboard Calls and Threads views share filters, totals, and aggregate-only hover details.
123
+ - Dashboard usage docs are updated when the visible dashboard workflow changes, and screenshots must be generated from synthetic data only.
124
+ - Dashboard aggregate refresh is localhost-only and keeps generated HTML aggregate-only; context loading is lazy, localhost-only, explicit, redacted, and not embedded in the static HTML payload.
125
+ - Subagent calls preserve logged parent-session metadata, latch to parent thread labels when available, and auto-review attachment is clearly marked when inferred.
126
+ - Tests and compile checks pass.
@@ -0,0 +1,47 @@
1
+ # Changelog
2
+
3
+ ## Unreleased
4
+
5
+ ## 0.3.0 - 2026-06-08
6
+
7
+ 0.3.0 is a stabilization and public-preview release for the dashboard, CLI, MCP tools, local privacy model, packaged Codex plugin, and companion usage skills. The PyPI/TestPyPI distribution name is now `codex-usage-tracking`; the GitHub repository remains `douglasmonsky/codex-usage-tracker`, the Python import package remains `codex_usage_tracker`, and the installed CLI command remains `codex-usage-tracker`.
8
+
9
+ - Add tested JSON contract validation for stable CLI and MCP payload schemas.
10
+ - Add schema markers to doctor, pricing coverage, MCP dashboard/export/config, and opt-in context payloads.
11
+ - Add ranked CLI/MCP recommendations with severity score, primary recommendation, secondary signals, and thread rollups.
12
+ - Add offset-aware localhost dashboard usage API responses for paged aggregate-row automation.
13
+ - Add a synthetic large-history benchmark script for 10k, 100k, and 500k aggregate-row SQLite fixtures.
14
+ - Add focused mypy coverage for core JSON contract, recommendation, report, schema, model, and store modules.
15
+ - Add Ruff, coverage, and dashboard JavaScript syntax checks to CI.
16
+ - Split dashboard JavaScript helpers into formatting, data, state, and rendering/runtime assets.
17
+ - Add issue templates for bugs, parser compatibility, pricing/allowance issues, and feature requests.
18
+ - Expand security guidance for project metadata privacy, support bundles, and localhost dashboard tokens.
19
+
20
+ ## 0.2.0
21
+
22
+ - Add project metadata privacy modes for dashboard, query, session, summary, CSV export, MCP, and support-bundle surfaces.
23
+ - Add Codex credit estimates and optional local allowance-window context to the dashboard.
24
+ - Add prominent unofficial-project disclaimers to docs, dashboard output, and plugin metadata.
25
+ - Harden malformed token-count parsing, SQLite concurrency, MCP raw-context opt-in, pricing parser diagnostics, bundled dashboard docs, and schema migrations.
26
+ - Fix Python 3.10 compatibility for UTC timestamps and release checks.
27
+ - Add package-owned Codex plugin installation with `codex-usage-tracker install-plugin`.
28
+ - Package plugin assets and the Codex skill into the Python wheel.
29
+ - Add a companion `codex-usage-api` skill for conversational analysis through aggregate-only API/MCP data.
30
+ - Add distribution metadata, source distribution manifest, and CI build checks.
31
+ - Add `python -m codex_usage_tracker` support and CLI `--version` output.
32
+ - Add release-readiness checks for version alignment, required docs, package data, built wheels, and tracked secret patterns.
33
+ - Harden marketplace MCP runtime bootstrapping so cached runtimes refresh when the bundled package pin changes.
34
+ - Harden local dashboard server responses with browser security headers and safer IPv6 localhost URLs.
35
+ - Tighten the dashboard header copy, add click/keyboard row inspection, and keep detailed usage guidance out of the primary UI.
36
+ - Keep call details sticky while scrolling and render timestamps as local human-readable date/time values.
37
+ - Prefer non-review models in mixed thread model summaries, add fit-to-width model labels, and add a scroll-aware `Top` button.
38
+ - Hide single-page dashboard pagination and keep multi-page controls compact in the toolbar.
39
+ - Render fetched and refreshed timestamps as local human-readable date-times and make the call details scrollbar visible.
40
+ - Rewrite the README around practical usage investigations, long-chat context growth, and pre-release limitations.
41
+ - Add a screenshot-driven dashboard guide built from synthetic aggregate fixture data.
42
+ - Preserve requested virtualenv Python paths during plugin install instead of resolving through interpreter symlinks.
43
+ - Keep generated dashboards, SQLite databases, CSV exports, and raw Codex logs out of git.
44
+
45
+ ## 0.1.13
46
+
47
+ - Add dashboard load limits, API limits, and pagination for larger Codex histories.
@@ -0,0 +1,40 @@
1
+ # Contributing
2
+
3
+ Thanks for improving Codex Usage Tracker.
4
+
5
+ ## Local Setup
6
+
7
+ ```bash
8
+ python3 -m venv .venv
9
+ . .venv/bin/activate
10
+ python -m pip install --upgrade pip
11
+ python -m pip install ".[dev]"
12
+ ```
13
+
14
+ ## Checks
15
+
16
+ Run these before opening a pull request:
17
+
18
+ ```bash
19
+ python -m ruff check .
20
+ python -m pytest
21
+ python -m pytest --cov=codex_usage_tracker --cov-report=term-missing
22
+ python -m compileall src
23
+ node --check src/codex_usage_tracker/plugin_data/dashboard/dashboard.js
24
+ node --check src/codex_usage_tracker/plugin_data/dashboard/dashboard_state.js
25
+ python scripts/check_release.py
26
+ python -m build
27
+ python scripts/check_release.py --dist
28
+ git diff --check
29
+ ```
30
+
31
+ ## Privacy Rules
32
+
33
+ - Do not commit real Codex session logs.
34
+ - Do not add tests or docs that include prompts, assistant messages, tool output, secrets, or private data.
35
+ - Keep fixtures synthetic and aggregate-only.
36
+ - Do not make normal reports persist raw transcript content. On-demand context loading must stay explicit, local, redacted, and size-limited.
37
+
38
+ ## Pull Requests
39
+
40
+ Keep changes focused and include the verification commands you ran. For user-visible behavior changes, update `README.md` and `CHANGELOG.md`.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Douglas Monsky
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,12 @@
1
+ include README.md LICENSE CHANGELOG.md CONTRIBUTING.md SECURITY.md AGENTS.md .mcp.json
2
+ recursive-include .codex-plugin *.json
3
+ recursive-include assets *.svg
4
+ recursive-include docs *.md *.png
5
+ recursive-include skills *.md *.py
6
+ recursive-include scripts *.py
7
+ recursive-include src/codex_usage_tracker/plugin_data/assets *
8
+ recursive-include src/codex_usage_tracker/plugin_data/dashboard *
9
+ recursive-include src/codex_usage_tracker/plugin_data/docs *
10
+ recursive-include src/codex_usage_tracker/plugin_data/rate_cards *
11
+ recursive-include src/codex_usage_tracker/plugin_data/skills *
12
+ recursive-include tests *.py
@@ -0,0 +1,278 @@
1
+ Metadata-Version: 2.4
2
+ Name: codex-usage-tracking
3
+ Version: 0.3.0
4
+ Summary: Unofficial local Codex plugin and dashboard for investigating aggregate token usage, costs, caching, and thread patterns.
5
+ Author: Douglas Monsky
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/douglasmonsky/codex-usage-tracker
8
+ Project-URL: Repository, https://github.com/douglasmonsky/codex-usage-tracker
9
+ Project-URL: Issues, https://github.com/douglasmonsky/codex-usage-tracker/issues
10
+ Project-URL: Changelog, https://github.com/douglasmonsky/codex-usage-tracker/blob/main/CHANGELOG.md
11
+ Keywords: codex,mcp,tokens,usage,dashboard,openai,prompt-caching,cost-analysis
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Environment :: Console
14
+ Classifier: Framework :: Pytest
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
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 :: Libraries :: Python Modules
23
+ Classifier: Topic :: System :: Monitoring
24
+ Requires-Python: >=3.10
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: mcp>=1.2.0
28
+ Provides-Extra: dev
29
+ Requires-Dist: build>=1.2; extra == "dev"
30
+ Requires-Dist: mypy>=1.10; extra == "dev"
31
+ Requires-Dist: pytest>=8.0; extra == "dev"
32
+ Requires-Dist: pytest-cov>=5.0; extra == "dev"
33
+ Requires-Dist: ruff>=0.8; extra == "dev"
34
+ Requires-Dist: tomli>=2.0; python_version < "3.11" and extra == "dev"
35
+ Dynamic: license-file
36
+
37
+ # Codex Usage Tracker
38
+
39
+ <p align="center">
40
+ <a href="docs/assets/plugin-prompts.png"><img src="docs/assets/plugin-prompts.png?v=short-prompts" alt="Codex Usage Tracker companion prompts for opening the dashboard, finding the heaviest thread, and showing a thread leaderboard." width="49%"></a>
41
+ <a href="docs/assets/dashboard-calls.png"><img src="docs/assets/dashboard-calls-preview.png?v=usage-dashboard" alt="Codex Usage Tracker dashboard showing filters, usage totals, call rows, and call details." width="49%"></a>
42
+ </p>
43
+
44
+ Local-first dashboard, Codex plugin, and companion skill for understanding where your Codex tokens and usage credits are going.
45
+
46
+ [![CI](https://github.com/douglasmonsky/codex-usage-tracker/actions/workflows/ci.yml/badge.svg)](https://github.com/douglasmonsky/codex-usage-tracker/actions/workflows/ci.yml)
47
+ ![Python 3.10-3.13](https://img.shields.io/badge/python-3.10--3.13-blue)
48
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
49
+
50
+ > **Unofficial project:** Codex Usage Tracker is an independent open-source project. It is not made by, affiliated with, endorsed by, sponsored by, or supported by OpenAI. OpenAI and Codex are trademarks of OpenAI; this project only reads local log files from your machine.
51
+
52
+ Codex Usage Tracker reads the JSONL logs already written by Codex, indexes aggregate usage counters into SQLite, and gives you a dashboard, CLI, and MCP tools for investigating real usage patterns. It keeps prompts, assistant messages, tool output, pasted secrets, and raw transcript content out of SQLite, CSV exports, and generated dashboard HTML.
53
+
54
+ Built for developers using Codex locally who want to know which threads, models, subagents, and long chats are driving usage without uploading logs anywhere.
55
+
56
+ After install, you get a localhost dashboard, a local SQLite aggregate index, CLI reports, MCP tools, and a companion Codex skill for asking questions like "what drove my usage this week?"
57
+
58
+ ## Quick Install
59
+
60
+ ```bash
61
+ python -m pip install --user pipx
62
+ python -m pipx ensurepath
63
+ pipx install codex-usage-tracking
64
+ codex-usage-tracker setup
65
+ codex-usage-tracker serve-dashboard --open
66
+ ```
67
+
68
+ Use your normal Python launcher for your platform: `python3` is common on macOS/Linux, and `py` may be preferable on Windows. On macOS with Homebrew, `brew install pipx` is also fine.
69
+
70
+ Package naming: the PyPI distribution is `codex-usage-tracking`; the installed command is `codex-usage-tracker`; the GitHub repository remains `douglasmonsky/codex-usage-tracker`. The `codex-usage-tracker` PyPI name is not this project, so avoid similarly named packages when following these docs.
71
+
72
+ Development or pre-release source install:
73
+
74
+ ```bash
75
+ pipx install "git+https://github.com/douglasmonsky/codex-usage-tracker.git"
76
+ ```
77
+
78
+ `setup` installs or refreshes the local Codex plugin wrapper, initializes local config templates when needed, refreshes the aggregate index, runs `codex-usage-tracker doctor`, and tells you whether Codex needs a restart for plugin discovery.
79
+
80
+ Want Codex to do it for you? Paste: `Install codex-usage-tracking with pipx, run codex-usage-tracker setup, and open the Codex Usage Tracker dashboard. Use https://github.com/douglasmonsky/codex-usage-tracker only if the PyPI install is unavailable.`
81
+
82
+ After plugin discovery, Codex can use the companion usage skill to refresh local aggregates, call the MCP tools, and explain usage patterns conversationally. Examples: [MCP And Codex Skills](docs/mcp.md).
83
+
84
+ <p align="center">
85
+ <a href="docs/assets/plugin-thread-leaderboard.png"><img src="docs/assets/plugin-thread-leaderboard.png?v=thread-leaderboard" alt="Synthetic Codex chat preview showing the companion skill ranking threads by token usage after refreshing the local aggregate index." width="86%"></a>
86
+ </p>
87
+
88
+ If you only want plugin registration after installing the package:
89
+
90
+ ```bash
91
+ codex-usage-tracker install-plugin
92
+ ```
93
+
94
+ More install paths: [Install Guide](docs/install.md).
95
+
96
+ ## Platform Support
97
+
98
+ The core app is not macOS-only. The CLI, SQLite index, dashboard generator, and localhost server are Python-based and CI-tested on Ubuntu for Python 3.10-3.13. It defaults to `~/.codex` for local Codex logs and `~/.codex-usage-tracker` for tracker data; pass `--codex-home` or `--db` when your local layout differs. Codex plugin discovery depends on Codex's local plugin directories on your machine, so run `codex-usage-tracker doctor` after setup if plugin registration does not appear in Codex.
99
+
100
+ ## Dashboard Preview
101
+
102
+ The Calls table is the main investigation surface: filter, sort, inspect details, and export the exact aggregate rows you are looking at.
103
+
104
+ ![Calls view showing filters, totals, the model-call table, and the details panel.](docs/assets/dashboard-calls.png?v=aa16502)
105
+
106
+ Threads view groups related calls so long chats, subagents, and auto-review passes are easier to reason about as one work session.
107
+
108
+ ![Threads view with one expanded thread and its calls in chronological order.](docs/assets/dashboard-threads.png?v=3cd7338)
109
+
110
+ The details panel keeps the primary cost, cache, context, allowance, and pricing signals visible before raw identifiers.
111
+
112
+ ![Details panel showing aggregate fields for the selected usage row.](docs/assets/dashboard-details.png?v=84cf6dd)
113
+
114
+ Insights still gives a fast triage layer for costly threads, low cache reuse, context bloat, and pricing gaps.
115
+
116
+ ![Insights view with ranked Needs Attention cards, investigation presets, and top threads by attention score.](docs/assets/dashboard-insights.png?v=4a40e4f)
117
+
118
+ The dashboard screenshots use synthetic aggregate fixture data, and the companion prompt and chat previews are synthetic. They do not contain prompts from local logs, assistant responses, tool output, real thread names, real usage totals, or real Codex session content. See the [Dashboard Guide](docs/dashboard-guide.md) for the full walkthrough.
119
+
120
+ If this helped you track Codex usage, starring the repo helps others find it. Issues and feature requests are welcome.
121
+
122
+ ## Why This Exists
123
+
124
+ Codex can quietly burn usage through long-running chats, low cache reuse, reasoning spikes, spawned subagents, and auto-review passes. This tool turns the aggregate counters already on your machine into an insight-first dashboard and scriptable local APIs.
125
+
126
+ Use it to answer:
127
+
128
+ - Which threads used the most tokens, estimated cost, or Codex credits?
129
+ - Are long chats bloating because of accumulated context?
130
+ - Which model or reasoning effort is driving usage?
131
+ - Are subagents or auto-review passes adding unexpected cost?
132
+ - Which calls have low cache reuse, high context pressure, reasoning spikes, or pricing gaps?
133
+ - Which projects, project tags, or active directories are consuming the most usage?
134
+ - What should Codex inspect next using the companion usage skill?
135
+
136
+ ## Long Chats Can Bloat Fast
137
+
138
+ Prompt caching helps, but cached input is not the same as no input. Long threads can accumulate a large cached context, and each new turn may still include cached input plus fresh uncached input, output tokens, reasoning output, and tool-related context.
139
+
140
+ The dashboard makes that pattern visible with:
141
+
142
+ - `Cached input`
143
+ - `Uncached input`
144
+ - `Session cumulative`
145
+ - `Context use`
146
+ - `Cache ratio`
147
+
148
+ Practical takeaway: when old context is no longer useful, starting a fresh thread can be more efficient than dragging a large cached history forward. That is not a rule for every task, but it is one of the clearest usage patterns the tracker is designed to reveal.
149
+
150
+ ## First Useful Workflow
151
+
152
+ ```bash
153
+ codex-usage-tracker update-pricing
154
+ codex-usage-tracker update-rate-card
155
+ codex-usage-tracker setup
156
+ codex-usage-tracker serve-dashboard --open
157
+ ```
158
+
159
+ Then:
160
+
161
+ 1. Leave `Live` enabled while working, or click `Refresh` after a Codex run finishes.
162
+ 2. Start in `Insights` and scan the `Needs Attention` cards.
163
+ 3. Use `Time` presets or calendar fields to focus on today, this week, the last 7 days, this month, or a custom range.
164
+ 4. Use investigation presets for highest-cost threads, highest-credit calls, context bloat, cache misses, pricing gaps, or estimated-price review.
165
+ 5. Open `Threads` to see how a conversation grew and whether subagent or auto-review work attached to it.
166
+ 6. Hover or click rows to inspect aggregate fields in `Call Details`.
167
+ 7. Use `Load context` only when aggregate fields are not enough; context is fetched on demand from the local source JSONL and is not saved into SQLite or the dashboard.
168
+
169
+ Optional allowance context:
170
+
171
+ ```bash
172
+ codex-usage-tracker parse-allowance "5h 79% 6:50 PM Weekly 33% Jun 7"
173
+ ```
174
+
175
+ The tracker cannot read your logged-in ChatGPT plan or live remaining usage automatically. Allowance values are only as accurate as the values you manually copy from Codex Settings, `/status`, or another trusted usage display. Details: [Pricing, Credits, And Allowance](docs/pricing-and-credits.md).
176
+
177
+ ## What It Includes
178
+
179
+ - Local SQLite index at `~/.codex-usage-tracker/usage.sqlite3`.
180
+ - Static dashboard generation plus localhost live refresh.
181
+ - `Insights`, `Calls`, and `Threads` dashboard views.
182
+ - Active-only dashboards by default, with an explicit `All history` toggle for archived sessions.
183
+ - CLI summaries, queries, CSV export, dashboard generation, doctor checks, and support bundles.
184
+ - MCP tools for Codex sessions that want to query local usage data.
185
+ - Companion Codex skills for operational setup and conversational usage analysis.
186
+ - Optional local pricing, Codex credit, allowance, threshold, project alias, and privacy-mode configuration.
187
+
188
+ ## Common Commands
189
+
190
+ ```bash
191
+ codex-usage-tracker summary --preset last-7-days
192
+ codex-usage-tracker query --since 2026-06-01 --min-credits 1
193
+ codex-usage-tracker session <session-id>
194
+ codex-usage-tracker export --output usage.csv
195
+ codex-usage-tracker dashboard --open
196
+ codex-usage-tracker support-bundle --output ~/.codex-usage-tracker/support-bundle.json
197
+ ```
198
+
199
+ Full command reference: [CLI Reference](docs/cli-reference.md).
200
+
201
+ ## Data Privacy
202
+
203
+ The tracker stores aggregate metrics only: session ids, timestamps, local source paths, thread labels, cwd/project metadata, model labels, reasoning effort, token counters, pricing/credit annotations, and derived ratios.
204
+
205
+ It does **not** store prompts, assistant messages, tool output, pasted secrets, raw transcript snippets, or raw context in SQLite, CSV exports, generated dashboard HTML, or synthetic screenshots.
206
+
207
+ On-demand context loading reads a single original local JSONL file only after an explicit row action, redacts common secret patterns, caps returned text size, and can be disabled with:
208
+
209
+ ```bash
210
+ codex-usage-tracker serve-dashboard --no-context-api --open
211
+ ```
212
+
213
+ For shared artifacts, use:
214
+
215
+ ```bash
216
+ codex-usage-tracker --privacy-mode redacted dashboard --open
217
+ codex-usage-tracker --privacy-mode strict export --output usage-redacted.csv
218
+ ```
219
+
220
+ Full model: [Privacy Guide](docs/privacy.md).
221
+
222
+ ## Documentation
223
+
224
+ - [Install Guide](docs/install.md)
225
+ - [Dashboard Guide](docs/dashboard-guide.md)
226
+ - [CLI Reference](docs/cli-reference.md)
227
+ - [Pricing, Credits, And Allowance](docs/pricing-and-credits.md)
228
+ - [MCP And Codex Skills](docs/mcp.md)
229
+ - [Privacy Guide](docs/privacy.md)
230
+ - [Architecture](docs/architecture.md)
231
+ - [CLI And MCP JSON Schemas](docs/cli-json-schemas.md)
232
+ - [Development And Release](docs/development.md)
233
+
234
+ ## Codex-Assisted Install
235
+
236
+ Open a Codex session on your machine and paste this:
237
+
238
+ ```text
239
+ Install and configure Codex Usage Tracker.
240
+ Install the PyPI distribution codex-usage-tracking with pipx. The installed command should be codex-usage-tracker. If PyPI is unavailable, fall back to pipx install "git+https://github.com/douglasmonsky/codex-usage-tracker.git".
241
+ If pipx is missing, install it with the platform's Python launcher or use a local virtual environment.
242
+ After installation, run codex-usage-tracker setup and serve-dashboard --open.
243
+ Verify the dashboard opens locally and tell me the dashboard URL plus whether I need to restart Codex for plugin discovery.
244
+ ```
245
+
246
+ This is optional. The normal shell install above is the fastest trusted path for most users.
247
+
248
+ ## Current Limitations
249
+
250
+ - This is a sidecar dashboard and plugin, not a native Codex chat overlay.
251
+ - Token counts come from Codex's logged counters; the tracker does not re-tokenize prompts.
252
+ - Pricing and Codex credit estimates depend on local rate data and confidence labels.
253
+ - Remaining 5-hour and weekly allowance is not read automatically from the logged-in account.
254
+ - Local Codex logs may not include usage from other ChatGPT agentic surfaces that share the same allowance.
255
+ - Parent-child thread relationships are only as good as the metadata Codex logs; inferred auto-review attachments are labeled as inferred.
256
+
257
+ ## Roadmap
258
+
259
+ - Improve the `Set limits` flow with a paste/import experience for 5-hour and weekly allowance snapshots.
260
+ - Track allowance snapshot history so local Codex credits can be compared against visible remaining-usage changes over time.
261
+ - Clarify top-card token accounting by showing output tokens and reasoning output as a subset instead of implying all token cards add together.
262
+ - Add more insight presets for cache drift, context growth, subagent-heavy workflows, and pricing/credit confidence gaps.
263
+ - Keep the allowance provider boundary ready for an official usage or allowance API if one becomes available.
264
+ - Continue reducing setup friction for pipx installs, local plugin discovery, and Codex companion skill usage.
265
+
266
+ ## Development
267
+
268
+ ```bash
269
+ git clone https://github.com/douglasmonsky/codex-usage-tracker.git
270
+ cd codex-usage-tracker
271
+ python3 -m venv .venv
272
+ . .venv/bin/activate
273
+ python -m pip install --upgrade pip
274
+ python -m pip install ".[dev]"
275
+ python -m pytest
276
+ ```
277
+
278
+ Run the full local CI gate before pushing to `main`. See [Development And Release](docs/development.md).