npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

tokenaires

v0.3.0

Published

Sync your AI coding agent token usage to the Tokenaires leaderboard.

Readme

tokenaires

The command line client for Tokenaires, the public rich list for developers ranked by AI tokens used.

It reads the usage logs your coding agents already keep on your machine, and uploads one small numeric record per model call. Your prompts, code and file paths never leave your computer.

Install and run

npx tokenaires

The first run logs you in, then syncs. Requires Node.js 22.15 or newer, which brings the built in SQLite reader and zstd support the CLI uses.

To install it globally instead:

npm install -g tokenaires
tokenaires

Commands

| Command | What it does | | --- | --- | | tokenaires | Logs in if needed, then syncs. | | tokenaires login | Connects this device with a code you approve in the browser. | | tokenaires scan | Reads local logs and prints totals per source, top models, record count and date range. Sends nothing and needs no login or network. Also available as tokenaires --dry-run. Files that have not changed since the last scan are read from the local scan cache. | | tokenaires sync [--quiet] | Uploads new records, then prints accepted, already synced and rejected counts, your rank and your profile link. | | tokenaires status | Shows login state, handle, rank, tier and progress to the next tier. | | tokenaires logout | Signs this device out on the server, then deletes the saved login and device key. Offline, it still deletes them and says the server copy of the token stays active. | | tokenaires schedule on [--every <hours>] | macOS: installs a LaunchAgent that runs sync --quiet every 6 hours, or at the interval you pick with --every (whole hours from 2 to 24, for example --every 2h, --every 12h or --every 1d). Linux: prints a crontab line to add. Run it again with a new --every to change the interval. | | tokenaires schedule off | macOS: unloads and removes the LaunchAgent. Linux: prints the line to remove. |

In a terminal, scan and sync show a live progress bar while logs are read and records upload, then a summary card with your tier, ranks and progress to the next tier. When output is piped, in CI, or with TERM=dumb, they print plain result lines without animation, and NO_COLOR=1 turns colours off. sync --quiet prints nothing unless something goes wrong.

The LaunchAgent lives at ~/Library/LaunchAgents/com.tokenaires.sync.plist and points at the Node binary and script you ran it with. If you used npx, install globally first so the path stays valid.

What is read

Everything is read locally. Text logs are read line by line, and only lines that can carry usage are decoded. Databases are opened read only and are never written to. Only records with exact token counts reported by the provider and a stable id from the tool itself are counted. Nothing is estimated from text.

  • Claude Code: every *.jsonl file under projects in each Claude config folder, including nested subagent and workflow folders. The folders are $CLAUDE_CONFIG_DIR when set (a list separated by commas or the path separator, ~ allowed), otherwise ~/.claude, ~/.config/claude and $XDG_CONFIG_HOME/claude. On Windows the Claude and Codex homes inside WSL distros are read too. Claude Desktop agent sessions are read from the transcripts under local-agent-mode-sessions/**/.claude/projects (the audit logs next to them are skipped, they repeat the same calls). Only assistant lines with a message id and usage block are used. <synthetic> and zero usage lines are skipped. Streamed duplicates are merged, keeping the line with the final output count, and a call that appears in two files is counted once. Advisor calls recorded inside a message are counted under the advisor model.
  • Codex: every *.jsonl and zstd compressed *.jsonl.zst rollout under $CODEX_HOME/sessions and $CODEX_HOME/archived_sessions (CODEX_HOME defaults to ~/.codex). A compressed copy next to a plain file of the same name is skipped, and archived copies count once. Once a rollout writes token_usage_record lines they are the only source for that rollout, so compaction calls are counted and the context updates written after them are not. Older rollouts use token_count events, skipping re-emitted events and counting calls after a counter reset. History that a forked or spawned session copies from its parent is recognised and skipped, so it is never counted twice.
  • Gemini CLI: session files under ~/.gemini/tmp/*/chats, including subagent folders and the older single JSON format (GEMINI_CLI_HOME moves the base folder). Each Gemini message with recorded usage counts once, keeping its last write. Cached tokens are split out of input, thinking tokens are added to output, and tool prompt tokens count as input when the reported total includes them.
  • Antigravity: conversation databases under ~/.gemini/antigravity/conversations, ~/.gemini/antigravity-cli/conversations and ~/.gemini/antigravity-ide/conversations. Each generation row with a usage block and response id counts once. Conversations kept only as .pb files carry no readable usage and are skipped.
  • OpenCode: opencode*.db in $OPENCODE_DATA_DIR, or $XDG_DATA_HOME/opencode (default ~/.local/share/opencode), from both the 1.x and 2.x table layouts, plus the older file based message store under storage/message. Assistant and compaction messages with usage count once per message id. The OPENCODE_DB_PREFIX variable changes the database file prefix.
  • Kimi Code: each agent's wire.jsonl under ~/.kimi-code/sessions (KIMI_CODE_HOME moves it), main agent and subagents alike. Every usage.record line is one model call with exact input, output and cache counts, labelled with the model from the request before it. A forked session starts with a copy of its parent's log, so only the lines after the fork marker are counted. Sessions from the older Python kimi-cli under ~/.kimi/sessions (KIMI_SHARE_DIR moves it) are read too, counting each provider message id once and taking the model name from config.toml.
  • Qwen Code: chat logs under ~/.qwen/projects/*/chats, archived chats, subagent transcripts under subagents, and the older JSON sessions under ~/.qwen/tmp/*/chats (QWEN_HOME moves the base folder, and QWEN_RUNTIME_DIR is read as well). Each assistant turn with usage counts once by its id, so a branched copy of a session is not counted twice. Cached tokens are split out of input. Thinking tokens count as output only when the reported total shows they were billed separately, because some backends estimate them from text. Subagent turns take their model from the agent's metadata file.
  • Copilot CLI: the assistant_usage_events table in ~/.copilot/session-store.db (COPILOT_HOME moves it), one row per request including compaction. Cached tokens are split out of input. The per session totals written at shutdown are skipped, because they add up across resumes.
  • Kilo Code: kilo.db and channel databases in $XDG_DATA_HOME/kilo (default ~/.local/share/kilo), which use the OpenCode layout, plus a database named by KILO_DB. Sessions Kilo imported from its old extension carry zero usage and are skipped.
  • Cursor: not counted. Cursor keeps per message token counts at zero in its local database and only stores context window estimates, so there is nothing exact to read.

What is uploaded

Exactly these fields per record, and nothing else:

| Field | Example | | --- | --- | | source | claude-code, codex, gemini-cli, antigravity, opencode, kimi-code, qwen-code, copilot-cli, cline, roo-code or kilo-code | | recordId | the tool's own id for the call: the Claude message and request id, the Codex session id and line number, the Gemini session and message id, the Antigravity conversation and response id, the OpenCode or Kilo message id, the Kimi Code session, agent and line or the kimi-cli message id, a hash of the Copilot session, row and time, the Qwen message id, or the Cline or Roo task and request time | | model | claude-opus-5-5 | | occurredAt | 2026-11-03T10:15:00.000Z | | inputTokens | uncached input tokens | | outputTokens | output tokens | | cacheReadTokens | cached input tokens read | | cacheWriteTokens | input tokens written to cache | | reasoningTokens | reasoning tokens, already included in output |

Never uploaded: prompts, responses, code, tool output, working directories, file paths, project names, git branches or session titles. A test in this repository checks that the upload payload contains only the fields above.

Each sync asks the server for your latest record per source and sends records from 48 hours before that point onward. The server ignores records it already has. When a new CLI version changes which records are counted, for example by reading a new source or older compressed logs, the next sync sends every local record once so older calls are not missed, then goes back to the 48 hour window. The file sync-state.json next to your config remembers that this happened. It holds only your handle and a version number.

Privacy

  • Run tokenaires scan any time to see exactly what would be counted, with no network access.
  • Your login lives in $XDG_CONFIG_HOME/tokenaires/config.json (default ~/.config/tokenaires/config.json), readable only by you (file mode 0600, folder 0700). It holds the API address, your access token, the device id, the device private key and your handle.
  • tokenaires logout revokes the device token on the server and deletes that file.
  • To make repeat scans fast, the CLI keeps a scan cache next to the config file at scan-cache.json.gz, with the same file permissions. For each log file it stores the local path, size and modification time, and the numeric records that would be uploaded (record id, model, time and token counts). It never stores prompts, responses or file contents, and the paths in it are never uploaded. A file that changes is read again, the cache is rebuilt on each new CLI version, and deleting the file is always safe. Set TOKENAIRES_NO_CACHE=1 to turn it off.
  • SQLite databases are opened read only in immutable mode, so the CLI never writes to them or creates journal files next to them. When a small database has recent changes still in its write ahead log, the database and log are copied to a private temporary folder, read there and deleted.

Anti tamper

  • At login the CLI creates an Ed25519 key pair for this device. Only the public key is sent to the server. The private key stays in your config file.
  • Every upload is signed. The signed message is the timestamp, a dot, and the SHA-256 of the exact request body. The server checks the signature, the device and the timestamp, so a batch cannot be altered or replayed later.
  • Record ids come from the agents' own logs, so the same call cannot be counted twice or claimed by two accounts.
  • The server also rejects records dated in the future, records older than the agent or model, and implausible token ratios. The sync summary lists each rejection reason.

Configuration

| Variable | Default | | --- | --- | | TOKENAIRES_API_URL | https://tokenaires.cc/api/v1 | | TOKENAIRES_WEB_URL | https://tokenaires.cc | | TOKENAIRES_NO_BROWSER | unset. Set it to skip opening the browser at login. | | XDG_CONFIG_HOME | ~/.config | | CLAUDE_CONFIG_DIR | unset. Claude config folders, separated by commas or the path separator. | | CODEX_HOME | ~/.codex | | GEMINI_CLI_HOME | your home folder | | OPENCODE_DATA_DIR | $XDG_DATA_HOME/opencode | | OPENCODE_DB_PREFIX | opencode | | XDG_DATA_HOME | ~/.local/share | | TOKENAIRES_NO_CACHE | unset. Set it to scan without the local scan cache. |

For local development against the backend:

TOKENAIRES_API_URL=http://localhost:7020/api/v1 TOKENAIRES_WEB_URL=http://localhost:7021 node dist/cli.js

Development

pnpm install
pnpm typecheck
pnpm lint
pnpm test
pnpm build
node dist/cli.js scan

The build is a single self contained file at dist/cli.js. The Node built ins node:sqlite and node:zlib are used as is.

Credits

Some of the log reading rules, such as how forked Codex sessions replay their parent's history and how Antigravity stores usage, were learned from codeburn (MIT). See THIRD_PARTY_NOTICES.md.