{"id":45974222,"url":"https://github.com/hanbu97/tokenusage","last_synced_at":"2026-03-06T22:01:30.007Z","repository":{"id":341181420,"uuid":"1169218965","full_name":"hanbu97/tokenusage","owner":"hanbu97","description":"Blazing-fast Rust token usage tracker for Codex and Claude Code with unified reports, live monitoring, CLI/TUI/GUI dashboards.","archived":false,"fork":false,"pushed_at":"2026-03-05T15:52:13.000Z","size":2791,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-05T22:06:12.248Z","etag":null,"topics":["claude-code","cli","codex","gui","rust","token","token-usage","tui"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/hanbu97.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-02-28T10:58:15.000Z","updated_at":"2026-03-05T16:10:37.000Z","dependencies_parsed_at":"2026-03-04T20:01:00.380Z","dependency_job_id":"c23ee80f-86b6-4ccc-8e1a-559812e64182","html_url":"https://github.com/hanbu97/tokenusage","commit_stats":null,"previous_names":["hanbu97/tokenusage"],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/hanbu97/tokenusage","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanbu97%2Ftokenusage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanbu97%2Ftokenusage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanbu97%2Ftokenusage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanbu97%2Ftokenusage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hanbu97","download_url":"https://codeload.github.com/hanbu97/tokenusage/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanbu97%2Ftokenusage/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30200756,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T19:07:06.838Z","status":"ssl_error","status_checked_at":"2026-03-06T18:57:34.882Z","response_time":250,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["claude-code","cli","codex","gui","rust","token","token-usage","tui"],"created_at":"2026-02-28T16:02:18.900Z","updated_at":"2026-03-06T22:01:29.964Z","avatar_url":"https://github.com/hanbu97.png","language":"Rust","readme":"# tokenusage (`tu`)\n\nFast Rust CLI/TUI/GUI token usage tracker for Codex usage and Claude Code usage.\n\n[![CI](https://github.com/hanbu97/tokenusage/actions/workflows/ci.yml/badge.svg)](https://github.com/hanbu97/tokenusage/actions/workflows/ci.yml)\n[![Release](https://github.com/hanbu97/tokenusage/actions/workflows/release.yml/badge.svg)](https://github.com/hanbu97/tokenusage/actions/workflows/release.yml)\n\n`tu` scans local session logs and gives one merged token + cost view across Codex and Claude in CLI, live monitor, and GUI.\n\n**Benchmark:** up to **131.1x faster than `ccusage`** on warm runs (**34.5x** on cold runs) with real local Codex logs. [See full benchmark](#benchmark-details).\n\n## Screenshots\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd width=\"50%\" align=\"center\" valign=\"top\"\u003e\n      \u003cimg src=\"docs/images/cli-demo-padded.png\" alt=\"tu cli demo\" width=\"100%\" /\u003e\n    \u003c/td\u003e\n    \u003ctd width=\"50%\" align=\"center\" valign=\"top\"\u003e\n      \u003cimg src=\"docs/images/gui-demo.png\" alt=\"tu gui demo\" width=\"100%\" /\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n## Install\n\n### cargo (crates.io)\n\n```bash\ncargo install tokenusage --bin tu\n```\n\n### npm\n\n```bash\nnpm install -g tokenusage\n```\n\n### cargo-binstall (prebuilt binary)\n\n```bash\ncargo binstall tokenusage --no-confirm\n```\n\n## Quick Start\n\n```bash\ntu\ntu live\ntu gui\n```\n\n## Why tokenusage\n\n- Faster feedback loop: native Rust + parallel scan/parsing + incremental cache.\n- One dashboard for both Codex and Claude, with merged totals and per-model breakdown.\n- Works in terminal and desktop GUI without sending your logs to a cloud service.\n\n## FAQ\n\n### Where does the data come from?\n\nFrom local log directories only:\n- Claude: `~/.config/claude/projects`, `~/.claude/projects`\n- Codex: `~/.codex/sessions`, `~/.config/codex/sessions`\n\nYou can override with `--claude-projects-dir` and `--codex-sessions-dir`.\n\n### How is cost estimated?\n\n`tu` uses OpenRouter pricing when available, caches it for 6 hours, and falls back to built-in offline rates when network pricing is unavailable.\n\n### Is my data private?\n\nYes for usage logs: parsing is local. `tu` only requests pricing metadata unless you run `--offline`.\n\n## Benchmark Details\n\nBenchmark setup:\n\n- Machine: Apple M3 Max, macOS 15.6.1\n- Dataset: `~/.codex/sessions` (71 JSONL files, ~537 MB), date range `2025-09-01` to `2026-02-28`\n- `tu` version: `1.1.2`\n- `@ccusage/codex` version: `18.0.8`\n- Both in default mode (online pricing behavior, network enabled)\n\nResults:\n\n| Tool | Command | Time |\n|---|---|---:|\n| `tu` (cold, rebuild cache) | `tu codex --rebuild-cache -s 2025-09-01 -u 2026-02-28` | **0.19s** |\n| `@ccusage/codex` (single run) | `ccusage-codex daily -s 2025-09-01 -u 2026-02-28` | **6.56s** |\n| `tu` (warm, avg of 10 runs) | `tu codex -s 2025-09-01 -u 2026-02-28` | **0.052s** |\n| `@ccusage/codex` (warm, avg of 10 runs) | `ccusage-codex daily -s 2025-09-01 -u 2026-02-28` | **6.819s** |\n\n- Cold-run speedup: about **34.5x**\n- Warm-run speedup: about **131.1x**\n\n\u003e Notes: results vary by hardware, filesystem cache state, and log volume.\n\n## Command Overview\n\n```text\ntu [daily|codex|claude|monthly|weekly|session|blocks|live|statusline|gui]\n```\n\nUseful commands:\n- `tu daily --tui`\n- `tu daily --json`\n- `tu daily --jq '.rows[0]'`\n- `tu blocks --active`\n- `tu blocks --live`\n- `tu live`\n- `tu statusline`\n\n## Config File\n\nConfig search order:\n1. `./.tu/tu.json`\n2. `~/.config/tu/tu.json`\n3. `~/.config/tokenusage/tokenusage.json`\n\nUse an explicit config file:\n\n```bash\ntu --config /path/to/tu.json\n```\n\nExample:\n\n```json\n{\n  \"defaults\": {\n    \"timezone\": \"Asia/Shanghai\",\n    \"workers\": 16,\n    \"compact\": false\n  },\n  \"commands\": {\n    \"daily\": {\n      \"instances\": true\n    },\n    \"live\": {\n      \"sessionLength\": 5,\n      \"refreshInterval\": 1\n    },\n    \"weekly\": {\n      \"startOfWeek\": \"monday\"\n    }\n  }\n}\n```\n\n## Pricing\n\n```bash\ntu --pricing-file ./pricing.json\n```\n\nOffline-only mode:\n\n```bash\ntu --offline\n```\n\n## Demo Dataset (No Real Data)\n\n```bash\npython3 examples/demo/generate_demo_data.py\ntu daily --config ./examples/demo/tu.demo.json --since 2026-02-09 --until 2026-02-28\ntu live --config ./examples/demo/tu.demo.json\ntu gui --config ./examples/demo/tu.demo.json --since 2026-02-09 --until 2026-02-28\n```\n\n## Development\n\n```bash\ncargo fmt\ncargo clippy --all-targets --all-features\ncargo check\n```\n\n## License\n\nMIT. See [LICENSE](./LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhanbu97%2Ftokenusage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhanbu97%2Ftokenusage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhanbu97%2Ftokenusage/lists"}