mytoken

command module
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2026 License: MIT Imports: 20 Imported by: 0

README

MyToken!!!!!

Release CI Downloads Platforms Go Built with MyGo

⚡ Powered by MyGo!

English · 简体中文

Install · Screenshots · Harnesses · CLI · Roadmap · Download

Where did all your tokens go? MyToken!!!!! reads the session logs your AI coding harnesses already write to disk, attributes every request to a session, provider and model, prices it, and shows you the result in a native desktop app — or as JSON from the command line.

Everything happens on your machine. No account, no telemetry, no uploads: by default the app makes two kinds of request — the price table download, and a daily update check on github.com (Settings turns it off). Relay-site reconciliation is opt-in per site, and a site is only ever contacted with the key you already gave that site.

  • Twenty-two harnesses in one window — Claude Code, Codex CLI, DSH, pi, Gemini CLI, opencode, Crush, Cline, Roo Code, Kilo Code, Claude Desktop, WorkBuddy, CodeBuddy, Hermes, Qwen Code, Kimi, OpenClaude, Grok, OpenClaw, Droid, Goose and Forge.
  • Session × provider × model — token classes kept apart (input, output, cache read, cache write, reasoning), with cache-hit rate, per-project and per-day breakdowns, and sub-agent trees.
  • Attribution you can audit — every provider is labelled with how it was determined: log, cc-switch, config-timeline, inferred or user-rule (see Provider attribution).
  • Costs that match your bill — models.dev prices with a LiteLLM fallback, plus per-provider multipliers and per-model overrides for plans and credit packs.
  • Tray-resident — closing the window keeps scanning; the tray panel shows today's tokens and cost, the last 24 hours, and the top models.
  • CLI for scripts — mytoken stats --json prints the same numbers the app shows.
  • Native, small, fast — built with MyGo's native UI package: no Electron, no WebView, no cgo. A full first scan of this machine's logs takes seconds.

Screenshots

Overview Sessions
Rankings Tray panel
CLI Settings
mytoken stats in a terminal

Supported harnesses

MyToken!!!!! reads the logs each harness already keeps. Nothing is written back to them: the readers are read-only and store only numbers plus a session title (the first 60 characters of the first user message).

Harness ID Where the logs live
Claude Code claude-code ~/.claude/projects/**/*.jsonl ($CLAUDE_CONFIG_DIR/projects), plus ~/.config/claude/projects when it exists
Codex CLI codex $CODEX_HOME/sessions and $CODEX_HOME/archived_sessions (~/.codex by default)
DSH — DeepSeek Harness dsh $DSH_HOME/sessions (~/.dsh/sessions by default)
pi pi $PI_HOME/agent/sessions (~/.pi/agent/sessions by default)
Gemini CLI gemini $GEMINI_CLI_HOME/tmp (~/.gemini/tmp by default)
opencode opencode $OPENCODE_DATA_HOME, else $XDG_DATA_HOME/opencode, else ~/.local/share/opencode
Crush crush $CRUSH_GLOBAL_DATA, else $XDG_DATA_HOME/crush, else ~/.local/share/crush
Cline cline …/globalStorage/saoudrizwan.claude-dev/tasks, plus ~/.cline/data/tasks and ~/.cline/data/sessions
Roo Code roo …/globalStorage/rooveterinaryinc.roo-cline/tasks
Kilo Code kilo …/globalStorage/kilocode.kilo-code/tasks
Claude Desktop claude-desktop …/Claude/local-agent-mode-sessions and its Claude-3p sibling (macOS: ~/Library/Application Support, Windows: %APPDATA%), plus the Cowork usage ledger
WorkBuddy workbuddy $WORKBUDDY_HOME/projects (~/.workbuddy/projects by default)
CodeBuddy codebuddy $CODEBUDDY_HOME/projects (~/.codebuddy/projects by default)
Hermes hermes $HERMES_HOME (~/.hermes by default), SQLite
Qwen Code qwen $QWEN_DATA_DIR/projects (~/.qwen/projects by default)
Kimi kimi $KIMI_SHARE_DIR/sessions (~/.kimi/sessions by default)
OpenClaude openclaude $CODEBURN_OPENCLAUDE_DIR/projects, else ~/.openclaude/projects
Grok grok $GROK_HOME (~/.grok by default)
OpenClaw openclaw ~/.openclaw/agents, plus the ~/.moltbot, ~/.moldbot and ~/.clawdbot spellings
Droid droid $FACTORY_DIR (~/.factory by default)
Goose goose $GOOSE_PATH_ROOT/…, else ~/.local/share/goose/sessions (Windows: %APPDATA%\Block\goose\sessions), SQLite
Forge forge ~/.forge by default, SQLite

For the VS Code family extensions, …/globalStorage is resolved per platform and per editor — editors: VS Code, VS Code Insiders, Cursor, Windsurf, VSCodium, Trae; platforms: ~/Library/Application Support/<editor>/User/globalStorage on macOS, ~/.config/<editor>/User/globalStorage (or $XDG_CONFIG_HOME/…) on Linux, and %APPDATA%\<editor>\User\globalStorage on Windows.

Every reader can be pointed somewhere else, which is handy for non-default installs, containers and archived logs:

Variable Effect
MYTOKEN_HOME Where the index lives (all platforms)
CLAUDE_CONFIG_DIR Claude Code config dir instead of ~/.claude
CODEX_HOME Codex data dir instead of ~/.codex
DSH_HOME DSH data dir instead of ~/.dsh
PI_HOME pi data dir instead of ~/.pi
GEMINI_CLI_HOME Gemini CLI data dir instead of ~/.gemini
MYTOKEN_GEMINI_DIRS Explicit Gemini CLI log dirs (path list)
OPENCODE_DATA_HOME opencode data dir
MYTOKEN_OPENCODE_DIRS Explicit opencode dirs (path list)
CRUSH_GLOBAL_DATA Crush data dir
MYTOKEN_CRUSH_DIRS Explicit Crush dirs (path list)
CLINE_DIR, CLINE_DATA_DIR, CLINE_SESSION_DATA_DIR Cline data dirs
MYTOKEN_CLINE_DIRS, MYTOKEN_ROO_DIRS, MYTOKEN_KILO_DIRS Explicit Cline / Roo / Kilo dirs (path list)
MYTOKEN_CLAUDEDESKTOP_DIRS Explicit Claude Desktop session dirs (path list)
WORKBUDDY_HOME, CODEBUDDY_HOME WorkBuddy / CodeBuddy home dir instead of ~/.workbuddy / ~/.codebuddy
HERMES_HOME Hermes home dir instead of ~/.hermes
QWEN_DATA_DIR, MYTOKEN_QWEN_DIRS Qwen Code data dir, or explicit dirs (path list)
KIMI_SHARE_DIR, MYTOKEN_KIMI_DIRS Kimi share dir, or explicit dirs (path list)
CODEBURN_OPENCLAUDE_DIR, MYTOKEN_OPENCLAUDE_DIRS OpenClaude data dir, or explicit dirs (path list)
GROK_HOME, MYTOKEN_GROK_DIRS Grok home dir, or explicit dirs (path list)
MYTOKEN_OPENCLAW_DIRS Explicit OpenClaw agent dirs (path list)
FACTORY_DIR, MYTOKEN_DROID_DIRS Droid home dir, or explicit dirs (path list)
GOOSE_PATH_ROOT, MYTOKEN_GOOSE_DIRS Goose data root, or explicit dirs (path list)
MYTOKEN_FORGE_DIRS Explicit Forge dirs (path list)

Provider attribution

A log rarely says which account or gateway served a request, so the provider is resolved by a priority chain, and the app tells you which step produced the answer:

  1. log — the harness recorded the provider itself.
  2. cc-switch — matched against the read-only ~/.cc-switch/cc-switch.db request log (same app type, model and tokens, within ±120 s).
  3. config-timeline — the base URL in ~/.claude/settings.json or ~/.codex/config.toml at the time of the request, tracked as a timeline.
  4. inferred — deduced from the model name (claude-* → Anthropic, gpt-*/o* → OpenAI, gemini-* → Google, deepseek-* → DeepSeek, …). Shown as inferred, never as fact.
  5. user-rule — your own rules win over everything above.

Pricing

  • Prices come from models.dev, with LiteLLM's model_prices_and_context_window.json as the fallback and a bundled offline snapshot for the first run. The table is cached on disk for 24 hours and the app works entirely offline with the cached copy.
  • Each of the five token classes is priced separately; reasoning tokens fall back to the output rate when the table has no reasoning price.
  • Per-provider multipliers and per-model overrides cover subscriptions, credit packs and negotiated rates, and pricing can be imported from cc-switch (model_pricing, providers.cost_multiplier).
  • Model mappings. Model names a relay or your own config invented have no price in any table, so they are listed as unpriced instead of guessed at. Map each one to the real model — and optionally to a provider — under Settings → Model mappings, and those requests are priced and merged into the rankings from then on.
  • A cost recorded in the log itself always wins over the computed one, and requests that no price can be found for are reported as unpriced instead of silently costing nothing.

Privacy

  • Local only. The index, the price cache and the settings never leave your machine. There is no telemetry, no analytics, no crash reporting, no account and no sync.
  • Two requests by default — the price table and the update check. The price table comes from models.dev, falling back to LiteLLM; with a cached or bundled table no request is made. Once a day the app asks github.com whether there is a new version, sending nothing but the request itself; Settings turns this off, and builds that cannot update themselves (development builds, the Debian package) never ask. The command line never checks. Relay reconciliation is off by default and enabled per site and per layer (ratios, balance, bills), so nothing else is contacted until you ask.
  • Keys are never stored or forwarded. A relay key is read into memory, sent only to the site it belongs to, and the index keeps just its key ID (the first 12 hex digits of a SHA-256). Keys never appear in logs, error messages or --json output.
  • Read-only readers. Harness logs are opened for reading; the index is a separate SQLite file that you can delete at any time to start over.
  • No conversation content. Only numbers and metadata are stored. The single exception is the session title: the first 60 characters of the first user message, so the session list is readable.
Platform Index directory
macOS ~/Library/Application Support/MyToken
Windows %APPDATA%\MyToken
Linux $XDG_DATA_HOME/mytoken (usually ~/.local/share/mytoken)

The database is mytoken.db inside it. Set MYTOKEN_HOME to keep it elsewhere (handy for trying the app against a scratch index); delete the directory to reset.

Install

macOS (disk image)

Download mytoken-<version>-darwin-universal.dmg from Releases, open it and drag MyToken!!!!! into Applications. The bundle is ad-hoc signed rather than notarized, so the first launch needs right-click → Open (or xattr -dr com.apple.quarantine /Applications/mytoken.app). The app's file name is mytoken.app; Finder and the menu bar show MyToken!!!!!.

Windows (installer)

Download mytoken-<version>-windows-amd64-setup.exe (or -arm64-) and run it. The installer is unsigned, so SmartScreen asks for More info → Run anyway the first time. It installs mytoken.exe, a Start Menu entry and the uninstaller.

Linux (install script)

v=0.2.1 arch=amd64   # or arm64
curl -fLO https://github.com/zzstar101/mytoken/releases/download/v$v/mytoken-$v-linux-$arch.tar.gz
curl -fLO https://github.com/zzstar101/mytoken/releases/download/v$v/install.sh
sh install.sh mytoken-$v-linux-$arch.tar.gz

Installs per user, without root: the app in ~/.local/mytoken.app, the mytoken command in ~/.local/bin and an entry in the applications menu. sh install.sh --uninstall removes it and keeps your data.

Linux (Debian package)

sudo apt install ./mytoken_<version>_amd64.deb

Installs /opt/mytoken, the /usr/bin/mytoken command and a desktop entry. It depends on GTK 3, WebKitGTK 4.1 and libayatana-appindicator3 (the tray icon).

With the Go toolchain

go install github.com/zzstar101/mytoken@latest

Builds the same binary the bundles carry, including the CLI, into $(go env GOPATH)/bin/mytoken.

Command line

The app binary is also the CLI: run it with no arguments for the GUI, or with a subcommand for the terminal. The full reference is in docs/CLI.md.

mytoken stats                                  # last 7 days, per session
mytoken stats --since 30d --by model           # 30 days, grouped by model
mytoken stats --last week --by day --timezone Asia/Shanghai
mytoken stats --since 2026-10-01 --until 2026-11-01 --by provider
mytoken stats --by model --no-cost             # leave costs out
mytoken stats --since 90d --format csv > usage.csv   # CSV export (--json also works)
mytoken sessions --last 7d --limit 20          # session list, most recent first
mytoken stats --since 30d --offline            # never touch the network
mytoken scan                                   # re-index now
mytoken doctor                                 # check sources, paths and versions
mytoken prices list                            # the active price table
mytoken prices set --provider zai --multiplier 0.5
mytoken prices import-ccswitch                 # import cc-switch pricing
mytoken version

--by accepts session, provider, model, project, day or harness. stats and sessions share the range flags --since/--until (a duration like 7d, or a date) and --last (today, week, month, or 30d), plus --timezone, --offline, --no-cost and --format table|json|csv (--json is short for --format json); --since and --last cannot be combined. mytoken help lists every command, and each flag is documented in docs/CLI.md.

Building from source

Requirements: Go 1.27 or newer, and no cgo (CGO_ENABLED=0 — the SQLite driver is pure Go). Running the app needs macOS 12+, Windows 10+ or a Linux desktop with GTK 3 and WebKitGTK 4.1.

git clone https://github.com/zzstar101/mytoken
cd mytoken

make build     # ./mytoken, version taken from the latest v* tag
make run       # run the app from source
make check     # gofmt check, go vet, go test

make help lists the packaging targets:

make app       # this platform
make dmg       # universal macOS .app and .dmg
make linux     # linux/amd64 + linux/arm64: binaries, .deb, tarballs, install.sh
make windows   # windows/amd64 + windows/arm64 (.exe and installer; needs makensis)

These wrap go tool mygo build -platform …. MyGo is pinned in go.mod's tool directive, so there is nothing to install globally, and its bundle metadata lives in mygo.json — identifier, icon, macOS display name, Linux desktop entry. Note that MyGo names the bundle and executable after name (mytoken), which keeps the CLI command and the artifact file names shell-friendly; the macOS display name is set back to MyToken!!!!! through CFBundleDisplayName.

Releasing

Releases are cut from tags:

make bump TAG=v0.2.0   # writes the version into mygo.json (or edit it by hand)
git commit -am "release v0.2.0"
git tag v0.2.0
git push origin main --tags

.github/workflows/release.yml then creates a draft release and builds the macOS universal bundle, the Windows installers and the Linux packages, attaching them to that draft; review it and publish. The version always comes from the tag, and no secrets are required: macOS bundles are ad-hoc signed and Windows installers unsigned. Signing and notarization secrets are documented at the top of the workflow.

.github/workflows/ci.yml runs go vet and go test on macOS, Linux and Windows, plus a gofmt check, for every push and pull request.

Credits

  • tokscale — several harness readers follow tokscale's documented parsing rules (for example Gemini CLI's token folding and accepted field names); no code was copied.
  • codeburn — the qwen, kimi, openclaude, claude-desktop, grok, openclaw, droid, goose and forge readers were written from its provider readers (see THIRD_PARTY_NOTICES).
  • MyGo — the native UI toolkit the app is built with. Powered by MyGo!
  • models.dev and LiteLLM — the price tables.
  • cc-switch — the pricing import format and the provider request log used by attribution.

Disclaimer

MyToken!!!!! is an unofficial fan tribute to the band MyGO!!!!! — the name, the colour palette and the little decorations in the UI are affectionate nods, nothing more. This project is not affiliated with, endorsed by or connected to the band, its members or their labels, and it ships no official artwork. All trademarks belong to their respective owners.

License

MIT © 2026 zzstar101

Documentation

Overview

Command mytoken is MyToken!!!!!: a tray-resident tracker of the tokens AI coding harnesses spend, per session × provider × model.

mytoken                 run the app (tray + main window)
mytoken stats [--json]  print usage without a window
mytoken scan            index the logs once
mytoken help            list every command (see docs/CLI.md)

Directories

Path Synopsis
internal
app
Package app wires the backend and registered parsers.
Package app wires the backend and registered parsers.
attrib
Package attrib resolves providers without reading conversation content.
Package attrib resolves providers without reading conversation content.
cli
Package cli serves the non-GUI commands.
Package cli serves the non-GUI commands.
gui
Package gui is MyToken!!!!!'s native interface: the main window and the tray panel, drawn with MyGo's ui package (no WebView).
Package gui is MyToken!!!!!'s native interface: the main window and the tray panel, drawn with MyGo's ui package (no WebView).
harness
Package harness defines the parser contract (docs/SPEC.md §4) and a registry.
Package harness defines the parser contract (docs/SPEC.md §4) and a registry.
harness/claude
Package claude parses Claude Code transcripts.
Package claude parses Claude Code transcripts.
harness/claudedesktop
Package claudedesktop parses Claude Desktop agent sessions.
Package claudedesktop parses Claude Desktop agent sessions.
harness/cline
Package cline parses Cline (saoudrizwan.claude-dev) task logs.
Package cline parses Cline (saoudrizwan.claude-dev) task logs.
harness/clinetask
Package clinetask parses the "Cline task" on-disk format shared by the Cline, Roo Code and Kilo Code VS Code extensions, plus the standalone Cline CLI session format.
Package clinetask parses the "Cline task" on-disk format shared by the Cline, Roo Code and Kilo Code VS Code extensions, plus the standalone Cline CLI session format.
harness/codebuddy
Package codebuddy parses CodeBuddy session logs.
Package codebuddy parses CodeBuddy session logs.
harness/codex
Package codex parses Codex CLI rollout logs.
Package codex parses Codex CLI rollout logs.
harness/crush
Package crush parses Crush (charmbracelet/crush) session usage.
Package crush parses Crush (charmbracelet/crush) session usage.
harness/droid
Package droid parses Factory Droid (Droid CLI) session transcripts.
Package droid parses Factory Droid (Droid CLI) session transcripts.
harness/dsh
Package dsh parses DeepSeek Harness (DSH) session logs.
Package dsh parses DeepSeek Harness (DSH) session logs.
harness/forge
Package forge parses the Forge (Factory) conversation database.
Package forge parses the Forge (Factory) conversation database.
harness/gemini
Package gemini parses Gemini CLI chat recordings (model.Harness "gemini").
Package gemini parses Gemini CLI chat recordings (model.Harness "gemini").
harness/goose
Package goose parses the Goose CLI session database.
Package goose parses the Goose CLI session database.
harness/grok
Package grok parses Grok CLI ("Grok Build", xAI's coding agent) recordings (model.Harness "grok").
Package grok parses Grok CLI ("Grok Build", xAI's coding agent) recordings (model.Harness "grok").
harness/harnesstest
Package harnesstest is the conformance suite every harness parser must pass (see docs/HARNESS.md).
Package harnesstest is the conformance suite every harness parser must pass (see docs/HARNESS.md).
harness/hermes
Package hermes parses Hermes session usage from its SQLite state database.
Package hermes parses Hermes session usage from its SQLite state database.
harness/kilo
Package kilo parses Kilo Code (kilocode.kilo-code) task logs.
Package kilo parses Kilo Code (kilocode.kilo-code) task logs.
harness/kimi
Package kimi parses Kimi CLI wire logs.
Package kimi parses Kimi CLI wire logs.
harness/openclaude
Package openclaude parses OpenClaude (npm @gitlawb/openclaude) transcripts.
Package openclaude parses OpenClaude (npm @gitlawb/openclaude) transcripts.
harness/openclaw
Package openclaw parses OpenClaw agent transcripts (model.Harness "openclaw"), including the clawdbot/moltbot/moldbot installations the agent was previously shipped as.
Package openclaw parses OpenClaw agent transcripts (model.Harness "openclaw"), including the clawdbot/moltbot/moldbot installations the agent was previously shipped as.
harness/opencode
Package opencode parses OpenCode session usage.
Package opencode parses OpenCode session usage.
harness/pi
Package pi parses Pi coding-agent session logs.
Package pi parses Pi coding-agent session logs.
harness/qwen
Package qwen parses Qwen Code chat transcripts.
Package qwen parses Qwen Code chat transcripts.
harness/roo
Package roo parses Roo Code (rooveterinaryinc.roo-cline) task logs.
Package roo parses Roo Code (rooveterinaryinc.roo-cline) task logs.
harness/workbuddy
Package workbuddy parses WorkBuddy session logs.
Package workbuddy parses WorkBuddy session logs.
model
Package model holds the shared, frozen types of MyToken!!!!!.
Package model holds the shared, frozen types of MyToken!!!!!.
pricing
Package pricing supplies offline-first, refreshable per-million-token prices.
Package pricing supplies offline-first, refreshable per-million-token prices.
pricing/gen command
Command gen regenerates the embedded models.dev price catalog.
Command gen regenerates the embedded models.dev price catalog.
query
Package query is the read API shared by the UI and the CLI (docs/SPEC.md §5).
Package query is the read API shared by the UI and the CLI (docs/SPEC.md §5).
reconcile
Package reconcile compares persisted relay charges with local usage.
Package reconcile compares persisted relay charges with local usage.
relay
Package relay detects the kind of a gateway site (中转站) and reads the little that gateway exposes: its per-model ratios, the balance of one key, and — for the gateways that keep per-request logs — the bills themselves.
Package relay detects the kind of a gateway site (中转站) and reads the little that gateway exposes: its per-model ratios, the balance of one key, and — for the gateways that keep per-request logs — the bills themselves.
scan
Package scan incrementally indexes registered harness sources.
Package scan incrementally indexes registered harness sources.
source
Package source defines optional, read-only provider data sources: cc-switch's local database and the harness config files that say which provider a tool is currently pointing at.
Package source defines optional, read-only provider data sources: cc-switch's local database and the harness config files that say which provider a tool is currently pointing at.
sqlitedsn
Package sqlitedsn builds SQLite file: URIs that work on every platform.
Package sqlitedsn builds SQLite file: URIs that work on every platform.
store
Package store owns the local, derived SQLite index.
Package store owns the local, derived SQLite index.
scripts
setversion command
Command setversion keeps the "version" field of mygo.json in sync with the git tag a release is built from.
Command setversion keeps the "version" field of mygo.json in sync with the git tag a release is built from.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL