{"_id":"@djain212004/aitokens","name":"@djain212004/aitokens","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@djain212004/aitokens","version":"0.1.0","description":"Live terminal HUD for AI token usage and cost across Claude Code and Codex CLI","keywords":["ai","tokens","claude","claude-code","codex","openai","anthropic","cli","tui","cost","billing"],"license":"MIT","type":"module","engines":{"node":">=20"},"bin":{"aitokens":"bin/aitokens.js"},"scripts":{"build":"tsc -p tsconfig.json && node scripts/copy-public.mjs","dev":"tsx src/cli.tsx","watch:tsc":"tsc -p tsconfig.json --watch","test":"vitest run","test:watch":"vitest","lint":"tsc -p tsconfig.json --noEmit","prepublishOnly":"npm run build"},"dependencies":{"chokidar":"^4.0.3","commander":"^13.1.0","ink":"^5.2.1","react":"^18.3.1"},"devDependencies":{"@types/node":"^22.10.0","@types/react":"^18.3.12","tsx":"^4.19.2","typescript":"^5.7.0","vitest":"^2.1.8"},"_id":"@djain212004/aitokens@0.1.0","_nodeVersion":"22.20.0","_npmVersion":"11.7.0","dist":{"integrity":"sha512-+3MjPlzvyg+F90fCzAM28QuoILFcnAXb98v8HnK6bJm/93rHT+VRw0/JoLfHlfapaOh8s/xEZxvDyKIw4xfOzQ==","shasum":"db14f9bc8095a6231070e7db3495ba71acbd41e4","tarball":"https://registry.npmjs.org/@djain212004/aitokens/-/aitokens-0.1.0.tgz","fileCount":38,"unpackedSize":134124,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIE80+CwW2NFP/LyXECcYm4xkhL3IpNZ6U/7fUScy65QtAiBKr1qM6Fx6Un19SBAg5eY1ZC1MKqly0JdEZbK/NL3ndg=="}]},"_npmUser":{"name":"djain212004","email":"jaindaksh212004@gmail.com"},"directories":{},"maintainers":[{"name":"djain212004","email":"jaindaksh212004@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/aitokens_0.1.0_1778475952489_0.896891500274269"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-11T05:05:52.263Z","0.1.0":"2026-05-11T05:05:52.629Z","modified":"2026-05-11T05:05:52.913Z"},"maintainers":[{"name":"djain212004","email":"jaindaksh212004@gmail.com"}],"description":"Live terminal HUD for AI token usage and cost across Claude Code and Codex CLI","keywords":["ai","tokens","claude","claude-code","codex","openai","anthropic","cli","tui","cost","billing"],"license":"MIT","readme":"# aitokens\n\nLive terminal HUD **and** local web dashboard that track your AI token burn — across **Claude Code** and **Codex CLI** — in real time, with dollar cost. Pricing is sourced from the [LiteLLM community JSON](https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json) and is editable from the web UI.\n\n```\n┌─ aitokens ─────────────────────────────────────── 14:32:07 ─┐\n│                                                             │\n│  Today                                                      │\n│  Claude Code   12.4M tok    $4.12                           │\n│  Codex          3.1M tok    $1.05                           │\n│  Total         15.5M tok    $5.17                           │\n│                                                             │\n│  Last 7 days                                                │\n│  Claude Code   84.7M tok   $28.40                           │\n│  Codex         19.2M tok    $6.55                           │\n│  Total        103.9M tok   $34.95                           │\n│                                                             │\n│  Live (last 5 min)        ▁▂▃▅▆▇█▆▄▂                        │\n│  Burn rate: 18.4k tok/min  ($0.07/min)                      │\n│  Active: claude-code · sonnet-4-6 · session a1b2c3          │\n└─────────────────────────────────────────────────────────────┘\n```\n\n## Why\n\nIf you use Claude Code and Codex CLI heavily, you have no built-in way to see what you're spending. `aitokens` watches the JSONL session logs both tools already write to disk, sums up tokens, prices them with a maintainable rate table, and renders a live HUD.\n\nNo daemon. No telemetry. No API keys. It only reads files you already have on disk.\n\n## Install\n\n```sh\nnpm i -g aitokens\n```\n\n## Use\n\n```sh\naitokens                          # live terminal HUD (alias for `watch`)\naitokens watch                    # same\naitokens serve                    # web dashboard at http://127.0.0.1:<ephemeral-port>\n                                  #   --port=<n>      pin the port (default 0 = OS picks)\n                                  #   --bind=<addr>   default 127.0.0.1 (loopback only)\n                                  #   --no-open       don't auto-launch the browser\naitokens today                    # one-shot summary for today\naitokens week                     # last 7 days\naitokens session                  # current/most-recent session per tool\naitokens prices                   # show effective pricing\naitokens prices update            # refresh from LiteLLM\naitokens prices set <m> k=v...    # set rates inline, e.g. `prices set gpt-5 input=1.25`\n```\n\n### Web dashboard\n\n`aitokens serve` starts a tiny local HTTP server (loopback, ephemeral port by default), opens your browser, and shows the same Today / Week / Live panels as the terminal HUD plus an editable pricing table. Edits save to `~/.aitokens/prices.json` on blur and the cost columns recompute live via Server-Sent Events.\n\n### What it reads\n\n- `~/.claude/projects/**/*.jsonl` — Claude Code session transcripts\n- `~/.codex/sessions/**/*.jsonl` — Codex CLI session rollouts\n\nIf a directory is missing, that source is skipped without error.\n\n### Override paths (testing)\n\n```sh\nAITOKENS_CLAUDE_DIR=/path/to/fixtures/claude-code \\\nAITOKENS_CODEX_DIR=/path/to/fixtures/codex \\\naitokens watch\n```\n\n### Time zone\n\n`today` and `week` are computed in your local time zone. Override with `TZ` env or `--tz` flag (e.g., `--tz=Asia/Calcutta`).\n\n### Lookback window\n\nInitial scan covers the last 30 days by default. Pass `--since=7d` or `--since=2026-04-01` to change.\n\n## Pricing\n\nThree layers, deep-merged in this order (latter wins):\n\n1. Bundled `prices.json` — offline floor / unknown-model fallback.\n2. LiteLLM community JSON — fetched on `aitokens prices update`, written to the override file.\n3. Your edits — `~/.aitokens/prices.json`. These survive subsequent `prices update` runs.\n\nThree ways to edit:\n\n```sh\naitokens prices update                                           # pull from LiteLLM\naitokens prices set claude-sonnet-4-6 input=3 output=15           # inline CLI edit\n# Or open http://127.0.0.1:<port> from `aitokens serve` and edit cells in the table.\n```\n\nYou can also hand-edit the override file directly:\n\n```json\n{\n  \"models\": {\n    \"claude-sonnet-4-6\": {\n      \"provider\": \"anthropic\",\n      \"input\": 3.0,\n      \"output\": 15.0,\n      \"cache_read\": 0.3,\n      \"cache_write\": 3.75\n    }\n  }\n}\n```\n\nRates are USD per **1,000,000 tokens**. Unknown models cost $0 with a one-time warning.\n\n## What about GitHub Copilot?\n\nCopilot doesn't expose per-call token usage to users locally. Adding it would require a local proxy (intrusive) or scraping the GitHub billing API (aggregate-only). It's intentionally out of scope for v1.\n\n## Develop\n\n```sh\nnpm install\nnpm run lint     # tsc --noEmit\nnpm test         # vitest\nnpm run build    # produces dist/\nnode bin/aitokens.js watch   # smoke run from source build\n```\n\nTest the parsers against fixtures without touching your real logs:\n\n```sh\nAITOKENS_CLAUDE_DIR=test/fixtures/claude-code \\\nAITOKENS_CODEX_DIR=test/fixtures/codex \\\nnode bin/aitokens.js today\n```\n\n## Notes\n\n- Bundled `prices.json` is the offline floor. Run `aitokens prices update` periodically to pull the latest from LiteLLM.\n- 1M-context Claude variants currently fall back to the standard model rate via prefix match; if you use them heavily, add a dedicated entry in your override.\n- Override the LiteLLM URL via `AITOKENS_PRICES_URL` or `aitokens prices update --url=<your-mirror>`.\n- `aitokens serve` binds 127.0.0.1 only by default. If you want LAN access (e.g., a homelab dashboard) pass `--bind=0.0.0.0` — note the price-edit endpoints are unauthenticated; only do this on trusted networks.\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-b6d2243971fb5b079431761ed61278df"}