Awesome Go

thermal

CategoryArtificial Intelligence
SubcategoryArtificial Intelligence
Stars2

Terminal contribution heatmap, streak tracker, and token leaderboard for AI coding assistants

About thermal

This large README is shown as a plain-text preview. Read the full README at the source

<p align="center">
  <img src="assets/thermal.webp" alt="Thermal Gopher Mascot" width="160" />
</p>

# Thermal

[![Go Report Card](https://goreportcard.com/badge/github.com/jadmadi/thermal)](https://goreportcard.com/report/github.com/jadmadi/thermal)
[![PkgGoDev](https://pkg.go.dev/badge/github.com/jadmadi/thermal)](https://pkg.go.dev/github.com/jadmadi/thermal)
[![CI](https://github.com/jadmadi/thermal/actions/workflows/ci.yml/badge.svg)](https://github.com/jadmadi/thermal/actions/workflows/ci.yml)
[![License: AGPL-3.0](https://img.shields.io/badge/License-AGPL_3.0-blue.svg)](https://www.gnu.org/licenses/agpl-3.0)
[![Dual License: Commercial](https://img.shields.io/badge/Dual_License-Commercial-green.svg)](DUAL-LICENSE.md)
[![Governance: Solo Authority](https://img.shields.io/badge/Governance-Solo_Authority-purple.svg)](GOVERNANCE.md)
[![SLSA Level 3](https://slsa.dev/images/gh-badge-level3.svg)](https://slsa.dev)

> Multi-agent terminal heatmap, token FinOps, and live burn monitor for 15 AI coding agents.

```bash
# Automated install (Linux & macOS)
curl -fsSL https://jadmadi.net/thermal/install.sh | sh

# Homebrew (macOS & Linux)
brew install jadmadi/tap/thermal

# Go toolchain
go install github.com/jadmadi/thermal/cmd/thermal@latest
```

Unlike `git log`, which only shows committed code, Thermal shows what your agents actually burned: tokens, cost, and streaks across tools, even when nothing got committed. All local, zero cloud telemetry, and sub-10ms cached execution on the baseline fixture — see [docs/PERFORMANCE.md](docs/PERFORMANCE.md) for the measured limits at directory-scan scale.

![Thermal leaderboard](assets/leaderboard.webp)

*Illustrative capture from an earlier build; CMD now reports tokens and ranks in Token Warriors. Rows depend on the tools installed.*

## Why Thermal

**Thermal is the local-first answer to what your AI coding agents cost and what they produced — across 15 tools, with zero uploads and zero writes to your data.**

**Situation.** Developers run several agents in parallel, and each writes tokens, models, and spend to disk in its own SQLite, JSONL, or JSON format.

**Complication.** The numbers do not add up: spend and output are fragmented per tool, and nothing shows what an agent burned when the work was never committed.

**Question.** How do I see all of it in one place, safely?

**Answer.** Thermal scans every source read-only, unifies the math, prices what it can, and renders it in your terminal.

**The supporting argument, top to bottom:**

1. **Coverage — one model of the data.** Fifteen agents are ingested through three shapes — SQLite (`?mode=ro`, memory-mapped), JSONL transcripts, and JSON session files — behind one registry in `internal/loaders`. Model ids are canonicalized before they become keys, token types are disjoint, and subdirectories fold into their nearest git root, so one project merges across every tool that touched it.
2. **Trust — local, read-only, honest about limits.** Zero telemetry, no account, no daemon, and strictly read-only ingestion are codified anti-goals in [`GOVERNANCE.md`](GOVERNANCE.md). The daily update check is opt-out and `--offline` keeps pricing on disk. Recorded cost wins over an estimate, estimates carry a `~`, and models the catalog cannot price are named in the `No pricing for` line rather than treated as free.
3. **Insight — answers counting cannot.** `stats`, `mix`, and `trend` add distribution analytics, share drift, and regression forecasts.
4. **Speed — fast, and in every surface.** Sub-10ms cached invocation is an architectural invariant, kept by disk-backed delta snapshots, bounded worker pools, and a single static CGO-free binary. CLI reports, the live monitor (`thermal live`), and NDJSON streaming (`thermal live --json --stream`) render the same numbers, and tests assert that live totals agree with the static commands.

**The evidence:** a strict layered dependency rule (`loaders → thermal → pricing → render`), the [promise ledger](docs/PROMISES.md) with reproducible evidence and stated limits, [measured performance](docs/PERFORMANCE.md), SLSA Build Level 3 provenance, and a single-command pre-flight suite (`./scripts/check.sh`) gating every change.

**The price:** the CLI is free under AGPL-3.0. The **Commercial Use License is $30 per developer per year** for internal commercial use; embedding, hosted services, and support commitments are separate [Enterprise & OEM terms](DUAL-LICENSE.md). [Buy the $30 license](https://paypal.me/Madise/30) or read the [terms](COMMERCIAL-LICENSE.md).

## Pricing

| Edition | Price | Scope |
| --- | --- | --- |
| **Community** | **Free** (AGPL-3.0) | Personal, academic, and open-source use; full CLI and live monitor |
| **Commercial Use** | **$30 / developer / year** | Internal commercial use by named developers; updates; community support. No redistribution, embedding, hosted service, or SLA |
| **Enterprise & OEM** | **Contact** | Proprietary embedding, closed-source hosted services, fleet/security review, custom loaders, and support commitments |

[Live pricing page](https://thermal.jadmadi.net/pricing.html) · [Buy the $30 Commercial Use License](https://paypal.me/Madise/30) · [Commercial license terms](COMMERCIAL-LICENSE.md) · [Enterprise & OEM](mailto:[email protected]?subject=Thermal%20Enterprise%20%26%20OEM)

## Supported Tools

| Tool               | Data Source                                        | Metrics                                       |
|--------------------|----------------------------------------------------|-----------------------------------------------|
| **Devin**          | SQLite DB (sessions + message_nodes)               | Token usage, sessions, cost                   |
| **OpenCode**       | SQLite DB (v1 and v2 storage)                      | Token usage, sessions, cost                   |
| **MiMoCode**       | SQLite DB                                          | Token usage, sessions, cost                   |
| **Codex**          | SQLite DB (state_5.sqlite) + rollout JSONL         | Token usage, sessions, model/source breakdown |
| **codewhale**      | JSON sessions                                      | Token usage, sessions, cost                   |
| **ZCode**          | SQLite DB (`model_usage` telemetry)                | Token usage, sessions, model/agent breakdown  |
| **Grok**           | JSONL session logs (`turn_completed` usage)        | Token usage, sessions, cost, model breakdown  |
| **Muse**           | SQLite session index                               | Prompt activity, sessions, model breakdown    |
| **Claude**         | JSONL session transcripts                          | Token usage, sessions, model breakdown        |
| **Droid**          | JSONL session transcripts                          | Message activity, sessions                    |
| **DeepSeek (DSH)** | JSON session cache (`~/.dsh/storages`)             | Token usage, sessions, model breakdown        |
| **Nous Hermes**    | SQLite DB (`~/.hermes/state.db`)                   | Token usage, sessions, cost, model breakdown  |
| **Zed**            | SQLite DB (`~/.local/share/zed/threads/threads.db`)| Token usage, sessions, model breakdown        |
| **command-code**   | JSONL session transcripts (`projects/*/*.jsonl`)   | Token usage, sessions, cost, models, projects |
| **Agy**            | Transcript logs (JSONL)                            | Step activity, sessions, model breakdown      |

Tools with token data appear in the **Token Warriors** leaderboard; activity-only tools appear in **Activity Hunters**.

Each tool also accepts short aliases: `mimo`, `oc`, `cmd`, `whale`, `zc`, `ccode`, `dsh`, `deepseek`, `hermes`, `nous`.

## Install

### Quick Install

```bash
# Automated installer (Linux & macOS)
curl -fsSL https://jadmadi.net/thermal/install.sh | sh

# Homebrew (macOS & Linux)
brew install jadmadi/tap/thermal

# Go toolchain
go install github.com/jadmadi/thermal/cmd/thermal@latest
```

Prefer a hosted page? The documentation site in
[`docs/pages`](docs/pages) covers the same ground with rendered terminal
output: https://jadmadi.net/project/thermal/

Or download a pre-built binary from [Releases](https://github.com/jadmadi/thermal/releases).

All official releases provide cryptographic build provenance conforming to **SLSA Build Level 3** (`checksums.txt.intoto.jsonl`), generated by this repository's OpenSSF provenance workflow on release tags. The `v0.20.0` release has been independently verified with [`slsa-verifier`](https://github.com/slsa-framework/slsa-verifier) — see [`docs/PROMISES.md`](docs/PROMISES.md) and the [verification log](docs/evaluations/2026-10-15-release-provenance/commands.log). Verify any release asset yourself:

```bash
# Verify checksums.txt against SLSA Level 3 provenance
slsa-verifier verify-artifact checksums.txt \
  --provenance-path checksums.txt.intoto.jsonl \
  --source-uri github.com/jadmadi/thermal \
  --source-tag v0.20.0

# Verify the downloaded archive against the verified checksums
sha256sum --check --ignore-missing checksums.txt
```

Or build from source using the included build script:

```bash
git clone https://github.com/jadmadi/thermal
cd thermal
./build.sh --install   # Builds the current platform and installs into GOBIN, else GOPATH/bin, else ~/.local/bin
```

`--install` replaces the binary atomically, runs it to verify the version, and warns if another `thermal` earlier in `PATH` still shadows it. Use `./build.sh --install /custom/bin` or `--prefix /custom/bin` to choose the directory. `./build.sh --release` only builds into the repo root.

You can run `./build.sh --help` to explore available build modes (`--release`, `--dev`, `--upx`) and cross-compilation targets. Or build manually with Go:

```bash
CGO_ENABLED=0 go build -ldflags="-s -w" -trimpath -o thermal ./cmd/thermal
```

## Update

If you installed via binary or `go install`:

```bash
# Preview without downloading or mutating
thermal upgrade --check
thermal upgrade --dry-run

# Upgrade interactively, or confirm non-interactively
thermal upgrade
thermal upgrade --yes
```

`--check` reports current/latest/update availability without downloading.
`--dry-run` resolves the asset and target without downloading. A mutation
requires a terminal confirmation or `--yes`; non-interactive mutation without
`--yes` exits `3`. `--json` emits exactly one object on stdout. A failed
download, extraction, or rename leaves the existing binary intact. Upgrading
across minor versions? Consult **[docs/MIGRATION.md](docs/MIGRATION.md)** for
breaking changes, retired aliases, and JSON schema updates.

Thermal also checks for newer releases in the background once a day (cached in `~/.cache/thermal/update.json`) and prints an update reminder to stderr during interactive terminal sessions when a new release is available. You can opt out at any time with `--no-update-check` or by setting `THERMAL_NO_UPDATE_CHECK=1`.

If you installed via `go install`, you can also update with:

```bash
go install github.com/jadmadi/thermal/cmd/thermal@latest
```

Check your current version:

```bash
thermal version
thermal -V          # short form
thermal --version   # long form
```

A source build prints `dev (built from source; version not stamped)` with
`commit: unknown` and `built: unknown`; a release build prints its semver,
commit, and build time. `version --json` adds `stamped` and `semver`, so a
missing stamp is explicit rather than implied.

`-v` means verbose diagnostics, not version. `thermal -v` announces
`verbose diagnostics enabled` on stderr, then renders the normal leaderboard;
use `-V` or `--version` for build metadata.

## Usage

```bash
# Default: leaderboard showing all installed tools
thermal

# Show a specific tool's heatmap
thermal --tool opencode
thermal --tool codex
thermal --tool devin

# Auto-detect the first installed tool
thermal --tool auto

# Read one tool's data from an explicit file or directory (requires --tool)
thermal --tool opencode --db /path/to/opencode.db

# Codex and directory-backed tools take a data directory
thermal --tool codex --db /path/to/.codex

# Show last 26 weeks (default: 52, range: 4-104)
thermal --weeks 26

# Output raw JSON
thermal --json

# Enable verbose diagnostic warnings (outputs non-fatal loading errors to stderr)
thermal --verbose

# Disable colors
thermal --no-color
```

`--verbose` also reports skipped JSONL records. A half-written final line is
counted as `truncatedTails` and `skippedRecords` in the report, with one warning
naming the file; a clean scan omits those keys. A partial read still exits `0`.

The leaderboard ranks by contribution streak and says so: `Ranked by current
streak · all time`. A legend defines `Strk` (current streak), `Best` (longest
streak), `Days` (active days), and the cost markers (`$` recorded, `~$`
estimated, `≥$` partial known, `—` unpriced, `≈` approximate). The footer
states `recorded + estimated = shown`, and unpriced models are listed with
their volume.

To rank by volume instead:

```bash
thermal --sort tokens   # biggest token consumers first
thermal --sort cost     # biggest recorded spend first
```

JSON consumers get explicit metadata:
`thermal --json | jq '.ranking, .costBasis, .unpricedModels'`.

### Argument validation

Flags may appear before, between, or after command words. Every value is
validated once, and Thermal never silently falls back to a different window:

- `--last` must be at least 1; omit it or use `--since`/`--until` for all time.
- `--since` may not be after `--until`.
- A positional tool may not conflict with `--tool`.
- Unknown flags and invalid values exit `2` with a one-line explanation and an
  example; data and semantic failures exit `1`.
- `-h`/`--help` is intercepted anywhere: `thermal daily --help` and
  `thermal help daily` print the same scoped page and never run the command.
  `live --help` and `upgrade --help` are always safe.
- Unknown commands and tools exit `2` with a nearest-match suggestion. Paths
  are identified as paths and pointed at `--db`; report words used in the tool
  slot are named as report commands.

### Glossary

`thermal help glossary` lists the domain terms, and `thermal help streak`,
`thermal help token`, `thermal help warriors`, or `thermal help activity` explain
one in place. `thermal doctor` and `thermal config` route to `thermal sources`
instead of a vendor list; `thermal top` points at `--top <N>`.

### Exit codes

| Code | Meaning |
| --- | --- |
| `0` | Success, including a requested stop and no-data success |
| `1` | Data, IO, or network failure |
| `2` | Usage error, invalid value, wrong slot, or width refusal |
| `3` | Refused non-interactive mutation (for example `upgrade` without `--yes`) |

`thermal --help`, `thermal upgrade --help`, and every report page print the
same contract. `--offline` on `upgrade` fails closed with exit `1` because
release metadata is not cached; it is never reported as an unknown flag.

### First run

If no agent data is found, Thermal prints a short onboarding block and exits
`0`; "no sessions yet" is a state, not a failed command. The block names
`thermal sources`, which prints the stat-only inventory of all 15 sources with
`found`, `empty`, `missing`, `unreadable`, or `wrong-shape` states. `thermal
sources --json` returns the same 15-entry inventory for automation. The
inventory never reads database rows, transcripts, prompts, or project names.

`thermal --json` and every report keep the envelope you asked for when there is
no data: `type` stays the requested verb, collections are empty, and
`state:"no-data"` plus `next` explain the situation. Add `--require-data` to
restore the strict exit `1` for scripts that treat empty data as a failure;
stdout keeps the same payload.

If a named tool has no data, the error names the tool and display path, then
offers `thermal sources`, the all-tools report, and the exact `--db` override.
Filesystem failures are specific: a symlink loop points at `readlink -f`, a
permission failure names the mode and `chmod`, and a wrong file or directory
shape keeps its existing precise fix. `--verbose` adds one raw OS line, never a
stack trace.

Prompt integration: `thermal statusline` prints one line, or nothing and exits
`0` when no source has data; `--json` returns `state:"no-data"` in that case.
In a pipe, `thermal live` writes its guidance to stderr and exits `2`; use
`thermal live --json` or `thermal live --json --stream` for automation.

### Terminal width

Width resolves once per invocation: `--width N` (40–240), then the terminal
when stdout is a TTY, then `COLUMNS` when stdout is a TTY, then 100. A pipe
ignores `COLUMNS`, so CI and cron should pass `--width` explicitly. Text output
caps at 96 columns; `--json` ignores width.

| Command | Minimum | Columns dropped below 80 |
| --- | --- | --- |
| Leaderboard | 40 | Best, Days, Cost, Strk |
| daily / weekly / monthly | 56 | Models, Input, Output, Reason, Cache |
| projects | 48 | P-Days, Tools, Last |
| models | 48 | M-Days, Tools, Last |
| stats | 40 | bars shrink |
| trend | 48 | sparkline cells |
| audit | 56 | path truncation + advice wrap |
| changelog | 48 | bullet wrap |
| help | 48 | description wrap |
| heatmap | 40 | weeks auto-fit, caption |
| live | 60 | stacked KPI layout at 60–79 |

Below a command's minimum, Thermal prints a two-line refusal and exits `2`
instead of clipping. Heatmaps auto-fit their weeks and caption the fit; `live`
refuses below 60 columns and never enters the alternate screen.

## Reports

Daily, weekly, and monthly reports fold the same data into period tables with tokens, cost, and per-model rows. `--last` counts periods at the report's grain, so `weekly --last 7` is seven weeks; add `d`, `w`, or `m` to pin the unit, as in `weekly --last 14d` or `monthly --last 3m`.

```bash
# Last 7 days for OpenCode
thermal opencode daily --last 7

# Weekly report for every installed tool
thermal weekly

# A date window (YYYY-MM-DD or YYYYMMDD)
thermal weekly --since 2026-08-01 --until 2026-08-31

# This month, with a row per model
thermal monthly --last 1 --breakdown

# Oldest first, weeks starting on Monday
thermal weekly --order asc --start-of-week monday

# JSON for scripting
thermal weekly --json
```

`--top N` caps rows on the leaderboard, daily, weekly, monthly, projects,
models, and changelog. Totals always describe the full window. `--top 0` shows
all rows; an absent changelog `--top` keeps the three-release default. Charts
state `chart shows X of Y` and suggest a valid `--top Y`.

Project and model totals are additive: tokens, cost, and project-days/model-days
sum their rows; `activeDays` is the distinct calendar-day count and `toolCount`
is the distinct tool count. The footer names `per project`/`per model` and the
distinct-day denominator so the two day counts cannot be confused.

Analytics name their denominators: `stats` reports `Mean / active day` with
`Basis: N active days`, while `trend` reports `Mean / calendar day` with
`Basis: N calendar days`. The trend projection labels its `Point estimate` and
`95% residual` band and explains the least-squares method and zero clamp; audit
splits score components, largest penalty, and a verb-led biggest win, and
defines PASS/WARN/CRIT.

![Thermal weekly report](docs/pages/shot-weekly.webp)

Daily, weekly, and monthly tables list token-bearing periods only: days with
no classified tokens, no recorded cost, and no model attribution (pure step
or message counts, empty sessions) are skipped so the Tokens column and the
Total row stay in tokens. That activity still counts toward streaks and the
leaderboard.

## Charts

`daily`, `weekly`, `monthly`, `projects`, and `models` take `--chart` to print
bar rows under the table; `mix`, `stats`, and `trend` reject it instead of
silently ignoring it. The bars are plain text, so they survive being pasted into
a chat, an issue, or a commit message, where a terminal heatmap does not.

```bash

Frequently Asked Questions

What is thermal?

thermal is a Artificial Intelligence library for the Go programming language. Terminal contribution heatmap, streak tracker, and token leaderboard for AI coding assistants

How do I install thermal?

Install thermal with the Go module system using `go get jadmadi/thermal`. Check the repository for the current installation instructions.

What category does thermal belong to?

thermal is listed under Artificial Intelligence, specifically Artificial Intelligence.

← Back to Artificial Intelligence