Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

tokematics-cli

Quota panels for the Kimi, Claude Code and Codex CLIs, in one terminal command. Shows plan usage (percent used, time to reset) and, where the provider exposes it, pay-as-you-go balance -- without opening a browser.

  ┌ Kimi Usage ──────────────────────────────────────────────────────────────┐
  │  Plan usage                                                              │
  │    Weekly limit  ████░░░░░░░░░░░░░░   23% used   resets in 6d 3h 33m     │
  │    5h limit      █████████░░░░░░░░░   49% used   resets in 1h 33m        │
  │  Extra Usage                                                             │
  │    Used this month   $183.04                                             │
  │    Monthly limit     Unlimited                                           │
  │    Balance           $  6.96                                             │
  └──────────────────────────────────────────────────────────────────────────┘

Platform support: macOS only, for now

tokematics-cli currently runs on macOS only. The blocker is the Claude Code panel: it reads the CLI's OAuth token out of the macOS Keychain via security find-generic-password, which has no equivalent on Linux or Windows. The Kimi and Codex panels have no macOS-specific dependency -- they read plain JSON/token files on disk (~/.kimi-code/..., ~/.codex/auth.json) and would already work anywhere those CLIs run.

See "Porting to other platforms" below if you want to fix that.

Requirements

  • bash
  • python3 (stdlib only -- no pip installs)
  • one or more of the CLIs it reports on: kimi, claude, codex. A tool with no binary on PATH is skipped silently; you don't need all three.

Install

curl -fsSL https://raw.githubusercontent.com/cloudyventures/tokematics-cli/main/tokematics-cli \
  -o ~/.local/bin/tokematics-cli
chmod +x ~/.local/bin/tokematics-cli

Or clone and symlink, if you'd rather track updates via git:

git clone https://github.com/cloudyventures/tokematics-cli.git
ln -s "$(pwd)/tokematics-cli/tokematics-cli" ~/.local/bin/tokematics-cli

Either way, ~/.local/bin needs to be on your PATH.

Usage

tokematics-cli                 show all three panels (Kimi, Claude, Codex)
tokematics-cli kimi            show only the Kimi panel
tokematics-cli claude          show only the Claude panel
tokematics-cli codex           show only the Codex panel
tokematics-cli --watch [name]  refresh every 5 minutes (all panels, or one); q/esc to exit
tokematics-cli server start    start the local Kimi web server in the background
tokematics-cli server stop     stop it
tokematics-cli --help          this help

A tool with no binary installed is skipped silently. A tool with a binary but missing or stale credentials prints a one-line hint naming the login command (claude login, codex login, ...) instead of an error. The Kimi panel needs its local usage server running first (tokematics-cli server start); it talks to kimi web over 127.0.0.1, not a public API.

How each panel gets its data

  • Kimi -- reads the auth token at ~/.kimi-code/server.token and the most recently active server instance under ~/.kimi-code/server/instances/*.json, then calls that local server's /api/v1/oauth/usage.
  • Claude -- reads the OAuth token from the macOS Keychain (service Claude Code-credentials) and calls api.anthropic.com/api/oauth/usage.
  • Codex -- reads the access token from ~/.codex/auth.json and calls chatgpt.com/backend-api/wham/usage.

All three calls use each provider's own CLI OAuth token -- there's no separate API key to configure.

Porting to other platforms

The only macOS-specific piece is the Claude panel's Keychain read. To port:

  • Linux: Claude Code writes its OAuth token to ~/.claude/.credentials.json directly (no system keychain in the picture), so the fix is a plain os.path.exists + json.load in place of the security find-generic-password subprocess call, branched on sys.platform.
  • Windows: untested. Claude Code's Windows credential storage would need the same kind of lookup as the Linux path, or its own branch if it uses Windows Credential Manager instead of a plain file.

The Kimi and Codex panels need no changes to run on either platform; they already just read local files.

Contributions welcome for either.

About

Quota panels for the Kimi, Claude Code and Codex CLIs

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages