Metadata-Version: 2.4
Name: gtt
Version: 0.2.0
Summary: Grand Theft Token: find out which prompt stole your AI quota. Local usage analytics for Claude Code, Codex, OpenCode, Antigravity and 17 more AI coding tools.
Author: eduardoabreu81
License-Expression: MIT
Project-URL: Homepage, https://github.com/eduardoabreu81/gtt
Project-URL: Repository, https://github.com/eduardoabreu81/gtt
Project-URL: Issues, https://github.com/eduardoabreu81/gtt/issues
Keywords: ai,llm,tokens,usage,cost,claude-code,codex,dashboard,analytics
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Software Development
Classifier: Topic :: Utilities
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: zstd
Requires-Dist: zstandard; extra == "zstd"
Dynamic: license-file

<p align="center"><img src="https://raw.githubusercontent.com/eduardoabreu81/gtt/main/gtt/web/logo.png" alt="gtt" width="120"></p>

# GTT · Grand Theft Token

**Who stole your AI quota?** GTT reads the local logs of your AI coding tools and shows which *prompt*, not just
which day or model, ate your plan limit.

Everything stays on your machine: no proxy, no API keys, no upload. Windows, macOS and Linux, Python 3.9+, no
dependencies. 21 tools: Claude Code, Codex, Antigravity, OpenCode, Kimi, Qwen, Copilot, Grok, Pi, Hermes and more.

![Overview: cost by week, project, tool, provider and model](https://raw.githubusercontent.com/eduardoabreu81/gtt/main/docs/img/overview.png)

## Try it

```bash
pipx install gtt                        # or: pip install gtt
gtt demo                                # a dashboard with made-up data, to look around first
gtt                                     # import your tools' logs and open the live dashboard
```

On Python < 3.14, `pipx install "gtt[zstd]"` also reads Codex sessions older than about a week (Codex
compresses them) and Zed threads.

## What you get

- **Most wanted prompts.** Every prompt you sent, plus everything the agent did until your next one (subagents
  included), ranked by cost. Expand a row to see each call: the context growing, cache reads and writes, the tools
  used, and where the cache was rebuilt.
- **≈ % of your plan limit** per prompt. Codex reports its own 5-hour and weekly %; Claude's comes from an optional
  mod; for the other tools GTT computes it from the quota you set.
- **Why it cost that much:** output vs. new input vs. cache re-reads, and what expired caches cost you.
- **Permanent history** in SQLite, so your weeks survive the tools' own log cleanup (Claude Code deletes transcripts
  after 30 days by default).
- **A dashboard you can click:** weekly history, by tool / project / model / day / hour, filters everywhere,
  US$ or tokens, English or Portuguese, light or dark.
- **A warning before an expensive prompt** (Claude Code): when you come back to a large session after the prompt
  cache expired, GTT holds the prompt once and tells you what re-reading the context will cost.

| Prompts, call by call | Plan limits | Cache |
|---|---|---|
| ![Most wanted prompts](https://raw.githubusercontent.com/eduardoabreu81/gtt/main/docs/img/prompts.png) | ![Limits](https://raw.githubusercontent.com/eduardoabreu81/gtt/main/docs/img/limits.png) | ![Cache](https://raw.githubusercontent.com/eduardoabreu81/gtt/main/docs/img/cache.png) |

## Commands

```bash
gtt                     # sync + live dashboard at http://127.0.0.1:8777
gtt demo                # dashboard with made-up data (your data is not touched)
gtt sync                # import new usage from every detected tool
gtt top                 # most expensive prompts this week, in the terminal
gtt dashboard           # write a static HTML dashboard and open it
gtt sources             # which AI tools were found on this machine
gtt discover            # find tools with token data that GTT doesn't know yet
gtt limit 94            # record the weekly % your Claude app shows (the GTT mod does it automatically)
gtt quota opencode --5h 600 --unit prompts   # plan quota for tools that don't report their own %
gtt import export.zip   # claude.ai or ChatGPT data export (tokens estimated)
gtt hook --install      # Claude Code: warn before a prompt that would re-write an expired cache
gtt mod install         # Claude Code: record the 5-hour and weekly % the API reports
gtt prices              # models without a known price
gtt config --reset-weekday 3 --reset-hour 18   # your weekly reset (0 = Sunday)
gtt config --wsl on     # Windows: also read tools installed inside WSL (Hermes)
gtt schedule --install  # daily sync (Task Scheduler; prints the launchd/cron entry on macOS/Linux)
```

## Supported tools

Where each tool keeps its data, and what GTT does with it: [SOURCES.md](https://github.com/eduardoabreu81/gtt/blob/main/SOURCES.md).

- **Ready:** Claude Code, Codex, Google Antigravity (IDE and the `agy` CLI), OpenCode, ZCode, Qwen Code, Pi agent,
  MiniMax Agent, Kimi Code, Kimi CLI, GitHub Copilot (CLI and VS Code chat), Hermes Agent, Grok CLI, OpenClaw,
  Aider, Goose, Crush, Continue, Cline CLI.
- **Experimental** (format known, not yet checked against real data): Gemini CLI, Cline / Roo Code / Kilo Code
  (editor extensions), Amp, Zed.
- **Estimated from text:** claude.ai and ChatGPT exports, and Antigravity conversations from versions that don't
  keep a `conversations/<id>.db`.

Cursor, Windsurf and a few others keep no token counts on disk, so there is nothing local to read.

## Plan limits (5-hour and weekly)

- **Claude** (optional): `gtt mod install` adds a small Claude Code mod that records the 5-hour and weekly % every
  API response reports; `gtt sync` imports them. No login or token needed; `gtt mod remove` takes it out. Without
  it, record the % by hand (`gtt limit 94` or the Limits page).
- **Codex:** read from its own logs.
- **Others:** GTT splits your usage into 5-hour windows (opened by the first call, like the plans do) and weeks,
  and shows the % once you set the plan's quota with `gtt quota` or on the Limits page.

## About "cost"

Cost is the API list price of each call. Subscription plans don't publish how much each token weighs in the
limit, but API prices weight model, output and cache the same way, so they rank the expensive prompts well. When a
tool reports real spend (OpenCode, Cline), that value is used. Built-in list prices cover Claude, GLM (Z.ai),
Kimi, MiniMax, Qwen, DeepSeek, GPT and Grok, including long-context tiers (`gtt/pricing.py` cites the source of
each price). `gtt prices` lists the models still without one; add or override prices in `prices.json` in the data
folder.

## Claude Code: expired-cache warning

`gtt hook --install` adds a `UserPromptSubmit` hook to Claude Code. When you return to a large session after the
prompt cache has expired (5 min, or 60 min with the 1-hour cache), it holds the prompt once and says how many context
tokens the next call would re-write and what that costs at API prices. Then you can `/compact`, start a new
session, or send the same prompt again to go ahead. The first prompt after a `/compact` is never held. Sessions
below 100k tokens are ignored (`--min-tokens` changes that). `gtt hook --remove` takes it out.

## Daily sync

`gtt schedule --install` creates a daily sync at 12:00 (`--time 08:30` to change). On Windows it is "GTT sync" in
Task Scheduler, set to run later if the PC was off at that time and to run on battery. On macOS and Linux it prints
the launchd or cron entry to add. `gtt schedule --remove` deletes the Windows task.

## Privacy and data

GTT only reads files the tools already keep on your disk. It sends nothing anywhere, reads no credentials and calls
no usage APIs. Data lives in `~/.gtt` (Windows), `~/Library/Application Support/gtt` (macOS) or
`$XDG_DATA_HOME/gtt` (Linux); `GTT_HOME` overrides it. On Windows the home folder is used instead of
`%LOCALAPPDATA%` because apps installed as MSIX packages get new AppData files redirected to a private folder,
which would split the database between a terminal and such an app.

## Development

```bash
git clone https://github.com/eduardoabreu81/gtt && cd gtt
pip install -e .
python -m unittest discover -s tests -v
```

Every importer with a fixture runs against a small real session from that tool, anonymized (`tests/fixtures/`),
and its output is compared with a snapshot. The dashboard is rendered from those fixtures in Node and fails on
`NaN`/`undefined`. CI runs on Ubuntu and Windows with Python 3.9, 3.13 and 3.14. See
[tests/README.md](https://github.com/eduardoabreu81/gtt/blob/main/tests/README.md) for adding a fixture, [AGENTS.md](https://github.com/eduardoabreu81/gtt/blob/main/AGENTS.md) for the architecture and
[PROJECT_LOG.md](https://github.com/eduardoabreu81/gtt/blob/main/PROJECT_LOG.md) for what each tool's data taught us. The README screenshots come from `gtt demo`
(`tests/tools/screenshots.mjs`).

## License

[MIT](https://github.com/eduardoabreu81/gtt/blob/main/LICENSE)
