{"id":50470619,"url":"https://github.com/thebuilder/codex-cost","last_synced_at":"2026-06-01T10:30:43.822Z","repository":{"id":354808378,"uuid":"1225378423","full_name":"thebuilder/codex-cost","owner":"thebuilder","description":"Keep track of tokens 💸","archived":false,"fork":false,"pushed_at":"2026-04-30T08:10:36.000Z","size":0,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-30T08:20:40.134Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thebuilder.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-30T08:08:08.000Z","updated_at":"2026-04-30T08:10:40.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/thebuilder/codex-cost","commit_stats":null,"previous_names":["thebuilder/codex-cost"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/thebuilder/codex-cost","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thebuilder%2Fcodex-cost","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thebuilder%2Fcodex-cost/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thebuilder%2Fcodex-cost/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thebuilder%2Fcodex-cost/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thebuilder","download_url":"https://codeload.github.com/thebuilder/codex-cost/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thebuilder%2Fcodex-cost/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33771627,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-01T02:00:06.963Z","response_time":115,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-01T10:30:42.997Z","updated_at":"2026-06-01T10:30:43.813Z","avatar_url":"https://github.com/thebuilder.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Codex Cost\n\nLocal CLI for estimating Codex usage cost from JSONL session files.\n\n\u003cimg width=\"1774\" height=\"887\" alt=\"image\" src=\"https://github.com/user-attachments/assets/db1394ea-dd5e-4f27-a016-ac8ef1514ff2\" /\u003e\n\n**Features**\n\n- See Codex usage and estimated cost by project or thread\n- Attribute work to projects and clients automatically\n- Filter reports by recent ranges or month names\n- Export clean JSON, CSV, and Excel reports\n- Tune pricing with an editable rate card\n\n\n## Requirements\n\n- Node.js 22 or newer\n- Local Codex files under `~/.codex`\n\n## Install\n\nFrom npm:\n\n```bash\nnpm install -g codex-cost\n```\n\n## Usage\n\nInteractive picker:\n\n```bash\ncodex-cost\n```\n\nInteractive mode starts with:\n\n- Report\n- Export\n- Rates\n\nReport mode asks for a date range before scanning:\n\n- All time\n- Past 1 day\n- Past 1 week\n- Past 1 month\n- Specific month\n\nExport mode prompts for format, date range, and filename. The filename prompt includes a timestamped default.\n\nTerminal reports:\n\n```bash\ncodex-cost report --project \u003cproject-id\u003e\ncodex-cost report --thread \u003cthread-id\u003e\n```\n\nExports:\n\n```bash\ncodex-cost export\ncodex-cost export --out report.xlsx\ncodex-cost export --range 1w\ncodex-cost export --range april\ncodex-cost export --format xlsx --out report.xlsx\ncodex-cost export --format csv --out report.csv\ncodex-cost export --format json --out report.json\n```\n\n`--range` accepts `all`, `1d`, `1w`, `1m`, or a month name. Month names resolve to the nearest current or past month, so `may` in April 2026 resolves to May 2025.\n\nRate card:\n\n```bash\ncodex-cost rates\n```\n\nDebug scan:\n\n```bash\ncodex-cost scan --json\n```\n\n## Data Included\n\nBy default, reports include all readable local Codex JSONL files from:\n\n- `~/.codex/sessions/**/*.jsonl`\n- `~/.codex/archived_sessions/*.jsonl`\n\nThe CLI also reads `~/.codex/session_index.jsonl` for thread names.\n\nNo date range is applied by default. Exact duplicate token-count events are deduplicated.\n\n## Configuration\n\nThe CLI loads config from the current working directory first:\n\n```text\ncodex-cost.config.json\n```\n\nThen falls back to:\n\n```text\n~/.config/codex-cost/config.json\n```\n\nExample:\n\n```json\n{\n  \"codexHome\": \"~/.codex\",\n  \"currency\": \"USD\",\n  \"projectRules\": [\n    {\n      \"id\": \"client-a\",\n      \"name\": \"Client A\",\n      \"pathPrefix\": \"/Users/you/Projects/client-a\"\n    }\n  ],\n  \"threadOverrides\": {\n    \"thread-id\": {\n      \"projectId\": \"client-a\",\n      \"projectName\": \"Client A\",\n      \"name\": \"Renamed Thread\"\n    }\n  },\n  \"rateCards\": {\n    \"custom-model\": {\n      \"inputPerMillion\": 1.25,\n      \"cachedInputPerMillion\": 0.125,\n      \"outputPerMillion\": 10\n    }\n  },\n  \"speedOverrides\": {}\n}\n```\n\nProject attribution uses:\n\n1. Per-thread overrides\n2. Ordered path-prefix rules\n3. Fallback project id from the session cwd basename\n\n## Excel Reports\n\nThe Excel workbook includes:\n\n- `Summary`\n- `Projects`\n- `Threads`\n- `Turns`\n- `RateCard`\n\nCost columns are formulas. Updating values in `RateCard` recalculates `Turns`, then rolls up into `Threads`, `Projects`, and `Summary`.\n\n## Development\n\n```bash\npnpm install\npnpm typecheck\npnpm test\npnpm pack\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthebuilder%2Fcodex-cost","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthebuilder%2Fcodex-cost","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthebuilder%2Fcodex-cost/lists"}