Skip to content

Releases

v0.3.0

Choose a tag to compare

@github-actions github-actions released this 25 Nov 01:00

中文版:release-notes-0.3.0.zh-CN.md · Full changelog: CHANGELOG.md

tokens 0.3.0 expands local-first AI coding token analytics from three tools to five auto-discovered sources — Claude Code, Gemini CLI, Codex, OpenCode, and Antigravity — while keeping all parsing and reporting strictly on your machine. The interactive dashboard receives a dark-first visual redesign with a Today HUD, same-time pace and model-share insights, an official-reference Cost Ledger with local monthly budgets, itemized Other models, and a complete English/Chinese interface. Under the hood, cold scans are roughly 4× faster, cache writes are roughly 5× faster, tokens quota, tokens doctor --models, and tokens outcomes bring rate-limit, routing, and spend-outcome transparency, and cross-platform stability is verified across Windows, macOS, Linux, Chromium, Firefox, and WebKit.

New Data Sources (Antigravity and more)

  • Antigravity as a fifth local source: automatically discovers ~/.gemini/antigravity/conversations/ (or TOKENS_ANTIGRAVITY_DIR) and reads only SQLite usage metadata (input, output, cache read, model, timestamp, and session) in read-only mode without opening conversation content or summaries.
  • OpenCode as a fourth local source: reads ~/.local/share/opencode/opencode.db (honoring XDG_DATA_HOME) in read-only SQLite mode, projecting only token, model, timestamp, session, and directory fields (total = input + output + reasoning + cache read + cache write, with reasoning tracked as thoughts) and tracking -wal updates automatically.
  • Automatic source discovery (--source auto): running tokens without --source now checks directory and file readability for all five registered sources and enables every available tool without opening log contents, while reporting detected and skipped sources in terminal output, tokens doctor, tokens quota, and the dashboard header.
  • Model attribution diagnostics (tokens doctor --models): groups Claude and OpenCode usage by logged request name and resolved backend model (with --since, --until, and --json), showing record counts, token totals, date bounds, attribution basis (logged, hex_alias, native_direct, router_rule, opencode_logged), active CCR router rules, and read-only OpenCode database health counts without exposing project paths or session IDs.

Token Outcomes

  • tokens outcomes [--since] [--until] [--json] reports what the spend produced: maps each session's working directory to its git repository (worktrees of one repository roll up into it) and attributes your own commits — git config identity, extended by TOKENS_OUTCOME_EMAILS — to the session they fall in (from session start to 30 minutes after its last activity); merge commits are excluded, commits outside every session count as manual work, and a lone --since runs through today.
  • Survival and rework metrics by day, project, and model: added/deleted lines, lines still present at HEAD 7 days later (read-only git blame, cached per repository and commit and invalidated when HEAD moves), a rework tax (the share of a session's added lines removed within 7 days, times its spend), retained lines per $1 with a settled-only variant, and cost per commit; commits younger than 7 days stay pending (added lines counted, survival unknown rather than zero), and amounts use the official USD reference prices, covering only the priced part.
  • Honest degradation and separate categories: sessions outside any git repository (with their spend) and sessions without commits are listed separately; the block reports ok, partial (an unreadable repository, a blame timeout, or the per-build blame budget of 400 commits exceeded — reasons names the failed check, alongside bad_session_ts, blame_cache_reset, no_repo, binary_commit, and unestimated_cost), or unavailable when git is missing (session spend still reported).
  • Value by model and by tool: tokens outcomes and a collapsed dashboard “Model comparison” block split spend exactly per (tool, model) and share out commits, retained lines and rework tax by each model's share of spend inside a session, so multi-model sessions no longer credit one “primary model”; rows with fewer than 3 sessions or under $1 settled spend are marked low sample and never ranked. Sessions whose OpenCode worktree was deleted, or Gemini sessions without a recorded directory, are mapped back to their repository from local project records.
  • Same privacy guarantees: the outcomes block holds only counts, ratios, and labels — no commit messages, file names, or author emails — and project names follow --anonymize; lock files, dist/, node_modules/, and *.min.js are excluded from the measurements.

Dashboard New Features

  • Daily briefing: the first screen opens with one rule-based sentence (no model calls) on what today's spend produced, four cards (retained lines per $1, rework tax, subscription payback, cache hit rate) and short prescriptions.
  • Dark-first theme and Today HUD: defaults to a dark canvas with a warm soft-light theme option, translucent shell bars, and a collapsible, draggable Today HUD that displays today's tokens, calls, leading model, and same-time change versus yesterday.
  • Quota burn-down in the Today HUD: the HUD shows the same forecast as tokens quota — one row per Codex (official) and Claude (estimate) window with used percentage, reset time and projected run-out — refreshed by tokens serve; a run-out before the reset is highlighted.
  • Overview insights: adds a Today-vs-Yesterday pace race aligned to the generation clock time (with a 7-day same-time average and full-day projection), a 7-day smoothed model share stream (Share and Stream views), and a multi-week activity calendar.
  • Cost Ledger and Monthly Budget: ships with built-in official USD reference prices (verified against Google Gemini, OpenAI, Anthropic, DeepSeek, Z.ai, and Moonshot pricing pages; GLM and Gemini rechecked against the official pages on 2026-11-19 — GLM-5.3, 5.3-Flash, 5.3-FlashX, 5.2, 5.1, and 5 use Z.ai's international USD rates including the zhipu/ names found in logs, cache writes stay at 0 while cache storage is limited-time free, and Gemini 4 Neon, 4 Hydrogen, 2.5 Pro, 2.5 Flash, and 3 Flash Preview use Google's Standard paid tier, with models the pages do not list staying unpriced), per-source/model manual price overrides, single-model reference restore, local monthly budget tracking with closed-day extrapolation, and exact-decimal Cost CSV export.
  • Itemized Other and eight model color slots: reserves neutral gray for Other, expands named palette capacity to eight models (guaranteeing at least one color slot per active source with usage), and itemizes every folded model with its source and exact tokens across legends, donut slices, trend tooltips, expandable period-table columns (Other (N)), exports, and a "More models" filter.
  • Reporting-timezone date scopes and daily model browser: filters core views by All report, Today, Yesterday, Last 7 days, or a Specific day in the reporting timezone, paired with a 7-day date strip, on-demand month calendar picker, daily model usage table, request-to-backend Route Map SVG diagram, and daily model CSV export.
  • Equal-length A/B comparison, peak profiles, and view summary copy: compares two consecutive equal-length periods with recorded project evidence panels, highlights leading-model changes with a Top model changed X → Y badge, inspects peak-period breakdowns, and copies a readable text summary of the active view in one click.
  • Redesigned Token destinations: pairs a project and model overview with paginated session cards (12 per page), an accessible full-session table, per-session turn replay on every row, and scoped SVG export.

English Interface

  • CLI and in-page language control: --lang en|zh sets the language for terminal tables and static HTML reports (defaulting to system locale or TOKENS_LANG), while the interactive dashboard provides an instant #lang-btn toggle and exports Markdown in the active dashboard language.
  • Single-pass full re-rendering on language switch: toggling between Chinese and English immediately re-renders the date-range bar, Today's pace, trend peaks and milestone tooltips, model share stream, SVG labels, already-rendered lazy sections, open dialogs, and live-mode views without requiring a page reload.
  • Unified English number units and date inputs: English views format large numbers with K/M/B and English month and granularity labels everywhere (never leaking 万/亿), and use a YYYY-MM-DD date input with a calendar button so browser locale placeholders never appear in English mode.
  • Complete provenance and badge translation with user-data protection: translates Data Health freshness sentences, partial/unavailable capability badges (◐/○), season titles, and work-mode copy on both direct English loads and language switches, while preserving user data (project paths, session titles, prompts, and model names) verbatim.

Performance

  • ~4× faster cold Claude log scans: prefilters JSONL lines without a "usage" key before decoding and parses typical usage lines (≤ 256 KB) with the C JSON decoder while retaining the bounded streaming parser for multi-megabyte lines.
  • ~5× faster local cache writes: encodes each top-level cache entry with the C JSON encoder and streams it to disk within bounded single-entry memory, reducing write time on a 117 MB, 202k-record cache from roughly 3.5 seconds to 0.64 seconds.
  • Non-blocking live service (tokens serve): runs log collection in a single background worker (default every 5 minutes) while browsers poll a lightweight /api/status endpoint and download `/ap...
Read more

v0.2.0

Choose a tag to compare

@github-actions github-actions released this 21 Sep 10:19
95f9eac

What's Changed

New Contributors

Full Changelog: https://github.com/LingXi-fur/tokens/commits/v0.2.0