# Repository Briefing: junhoyeo/tokscale
> Source: https://repoforai.com/repo/junhoyeo/tokscale (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/junhoyeo/tokscale
- **Official Docs / Website**: https://tokscale.ai
- **Category**: Coding, Skills & MCP (AI 编程 / Skills / MCP)
- **Primary Language**: Rust
- **License**: MIT
- **Engineering Health**: A+ (94/100 · Maintenance 35/35 · Adoption 19/25 · Releases 20/20 · License 20/20)
- **Latest Release**: v4.24.0 (2026-12-02) — https://github.com/junhoyeo/tokscale/releases
- **Review Snapshot**: 2026-12-04
- **Deployment / Stack Signals**: Docker, Self-Hosted, CLI
- **Momentum**: 5,949 ★ total (+4 24h / +44 7d) · 489 forks
- **Topics**: `ai`, `ai-agents`, `ampcode`, `claude`, `claude-code`, `clawdbot`, `codex`, `cursor`, `cursor-ide`, `droid`, `gemini`, `gemini-cli`
- **When to Use**: Best for: Developers and teams using several coding agents who want to compare usage by model, workspace, session, or machine and export the results for internal reporting. Skip if: You need invoice-grade reconciliation, enforced spending caps in the request path, or complete visibility into clients that do not log or expose usage.

## Overview
```text
### Architecture & Core Mechanics
Tokscale is a usage collector and reporting tool, not an agent runtime or an inference gateway. The `tokscale` npm alias installs `@tokscale/cli` with the required native Rust package, `@tokscale/core`. The core scans client-specific sources, parses usage records, and aggregates them for the Ratatui interface, plain tables, or JSON output. The sources are heterogeneous: OpenCode has SQLite and legacy message storage, Codex has live and archived JSONL rollouts, and some clients expose usage through APIs or caches.

The web frontend under `packages/frontend` is a separate surface for submitted usage, with public profiles at `/u/[username]`, SVG embeds at `/api/embed/[username]/svg`, a leaderboard, and group pages. Docker Compose pairs the app with PostgreSQL. For integrations, the concrete interfaces are client-specific data ingestion and CLI exports; nothing in this reporting flow requires an MCP server or sending model requests through Tokscale.

### Key Capabilities & Differentiators
Tokscale brings clients such as Claude Code, Codex, OpenCode, Gemini CLI, GitHub Copilot CLI, and Cursor into one reporting surface. Its ten default Ratatui views include subscription usage, models, time breakdowns, sessions, and projects; per-minute reporting is opt-in. Reports distinguish input, output, cache-read, cache-write, and reasoning tokens. Pricing is fetched from LiteLLM and cached on disk for one hour, with OpenRouter fallback and Cursor model pricing support.

Grouping choices determine what remains visible: `--group-by model` consolidates clients and providers, while `--group-by client,provider,model` keeps them separate. Workspace reports can merge Git worktrees with `--merge-worktrees`; machine reports can distinguish imported session folders using `scanner.extraScanPaths` and `scanner.machineLabels`. For scripts, session-and-model exports expose `sessionId`, and workspace exports carry `workspaceKey` and `workspaceLabel`.

### Trade-offs & Limitations
Tokscale is most useful where provider dashboards are least comparable: usage spans multiple agents, and the question is which client, workspace, or session drove it. Provider billing remains authoritative for charges. Tokscale derives estimates from observed usage and price tables, so a reported cost is not an invoice or the amount paid under a subscription. Compared with a gateway that meters requests in transit, Tokscale can analyze existing records without rerouting inference traffic, but coverage depends on what each client logs or exposes.

Scan time and resource usage depend on the size and format of session histories, including any archives imported from other machines. Copying folders and assigning machine labels gives useful attribution, but is not centralized fleet collection. Local reporting also has a different exposure profile from publishing on the leaderboard: review what is submitted and displayed before using `submit` or autosubmit. Self-hosting gives control of the deployment, but still leaves responsibility for access, database backups, and updates with the operator.

### Hardware & Deployment Guide
Run the CLI with `npx tokscale@latest`, `bunx tokscale@latest`, or `deno x npm:tokscale@latest`. Published packages include native binaries for supported targets. A source build uses Bun and the Rust toolchain, with `bun run build:core` to compile the required native component. For supported offline reports, use `tokscale --offline`; prefill the pricing cache while connected with `tokscale pricing refresh --no-spinner` if the offline reports need cost estimates.

For self-hosting, Compose uses the `tokscale:latest` image built by `make docker/build`, alongside `postgres:16-alpine` and a persistent `postgres_data` volume. The database port is bound to host loopback by default. When replacing the development credentials, keep the three `POSTGRES_*` settings and `DATABASE_URL` aligned. On the release side, v4.23.0 added Capy sync, including subscription usage without local session logs; v4.23.1 added Zed usage on ChatGPT subscriptions; v4.24.0 added custom date ranges to public profiles.
```

## Key Capabilities
```text
- Source ingestion: Reads OpenCode SQLite and legacy message storage, Codex JSONL and compressed archives, and Copilot CLI usage events without requiring OTEL.
- Archive deduplication: Counts copies of the same Codex rollout once when the same session appears in multiple archives.
- Cost estimation: Uses LiteLLM pricing with a one-hour disk cache, OpenRouter fallback, and Cursor model pricing; distinguishes input, output, cache, and reasoning tokens.
- Attribution: Groups reports by workspace, session, machine, or client and provider; `--merge-worktrees` folds Git worktrees into the parent repository for workspace reporting.
- Reporting: Ratatui provides ten default views; JSON exports support scripting, and `--offline` runs supported local reports without network requests.
- Publishing: Docker Compose pairs the web app with PostgreSQL 16; the web surface includes public profiles, SVG embeds, leaderboards, and groups.
```

## Quick Start / Clone
```bash
# Run directly with npx
npx tokscale@latest

# Or use bunx
bunx tokscale@latest

# Or use Deno without installing an alias
deno x npm:tokscale@latest

# Light mode (table rendering only)
npx tokscale@latest --light
```
