npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

tktop

v0.4.0

Published

Live htop-style TUI dashboard for AI token consumption across harnesses (OpenCode, Claude Code, Codex, generic JSONL)

Readme

tktop

htop — but for AI tokens. 🔥

A live terminal dashboard that shows, in real time, how many tokens your AI coding agents are burning across every harness on your machine — OpenCode, Claude Code, Codex, and anything that writes JSONL.

npm PyPI License: MIT Runtime: Bun TUI: OpenTUI

npm i -g tktop · pip install tktop-tui


  tktop  AI token consumption monitor · runtime: opencode · 12:02:16
  sessions 3 (1 active) · in 438.1K out 229.0K cache-r 40.13M rsn 0 w 0 cost - burn - tok/min
┌─ scatter · x: tokens(in+out, log) · y: tok/min · 2 dots ─────────────────────────────────────────┐
│ y: 0…100 tok/min                                                                                 │
│                                                                                                  │
│                                                                                                  │
│                                     ✚                                   ★                        │
│100K                                            1M                                              10│
└──────────────────────────────────────────────────────────────────────────────────────────────────┘
 ◆  HARNESS    MODEL                SESSION                   IN       OUT    COST  TOK/MIN ▼   AGE
 ✚  opencode   eliza/glm-5-3        TOKFLOW               383.3K    186.9K       -          -   14s
 ·  opencode   eliza/glm-5-3        ├─ Sweep tokflow …     43.8K     35.8K       -          -   17h
 ·  opencode   eliza/glm-5-3        └─ Test tokflow J…     11.0K      6.3K       -          -   18h

  showing 3 sessions matching "/tokflow"
  sort: 1 burn · 2 recent · 3 tokens · 4 cost  ·  g group: none  ·  a archived:off  ·  / filter · p

(real capture — the two nested sessions are subagents spawned by that very parent session)

live demo — tree view → group-by → filter → drill-down

Why tktop?

You run OpenCode, Claude Code, Codex, and half a dozen agents in parallel. They all eat tokens, and none of them answer the simple question: what's burning right now, how fast, and who's responsible?

tktop answers it at a glance — the way htop does for CPU and nvtop does for GPUs:

  • 🔴 Live — the TUI polls (default every 2s) and sees every session's burn rate change in real time.
  • 🧵 Tree view — press t and subagent sessions nest under their parent with htop-style ├─ / └─ glyphs.
  • 📈 Scatterplot — a live plot above the table: x = tokens consumed (log scale), y = tokens/min; every session is a distinct colored marker whose trail you can follow.
  • 🖱️ Clickable — sort by any column by clicking its header, select rows, scroll with the wheel.
  • 🔭 Panopticon — htop/nvtop class: total in/out at the top, filter (/ / live substring typing), group-by with subtotals, sparkline history per session.
  • 🛰️ Multi-harness — OpenCode, Claude Code, Codex CLI and any JSONL writer, zero configuration: adapters auto-activate when a data directory exists.
  • 🕶️ Read-only, zero-risk — tktop never writes, talks to, or control harnesses. It only reads the traces they already leave on disk.
  • ⚡ Also headless — tktop-dump prints the table once for scripts, logs, CI heat-maps.

Install

npm i -g tktop     # all platforms
tktop

Or from Python:

pip install tktop-tui
tktop

Both install the same tktop command. The pip flavor stages the TUI into ~/.local/share/tktop/ and launches it with Bun — no path conflicts either way.

Requirements: Bun ≥ 1.3.14 on the PATH. If missing, tktop prints the one-line fix and exits — first run of the pip version may also fetch JS dependencies once.

  • warning EACCES ... /usr/lib/node_modules ? — system npm needs sudo. The npm-recommended fix is a user prefix —

    mkdir ~/.npm-global
    npm config set prefix ~/.npm-global
    echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.bashrc
    source ~/.bashrc && npm i -g tktop
  • EBADENGINE warnings about node >= 26 ? — cosmetic; tktop runs under Bun, not Node. npm just engine-checks against the Node it was invoked with.

  • From source: bun run src/index.ts; repo shim: ln -sf ~/tktop/bin/tktop ~/.local/bin/.

  • Headless: tktop-dump (or bun run src/dump.ts) prints one table and exits.

  • CLI flags: --interval <ms> · --filter <s> · --sort <key> (burn, recent, tokens, cost, in, out, cacheR, rsn, age, harness, model, title, dir) · --all (include archived).

Keys & mouse

| Input | Action | |---|---| | click column header | sort by that column — ▼ desc / ▲ asc, click again to reverse | | click row | move the selection cursor there | | mouse wheel | scroll the table (cursor paging) | | 1 2 3 4 | quick sort: burn rate · recency · total tokens · cost | | / | filter, live-typed (harness · session · model · dir · id) — enter confirm, esc cancel | | g | group by: none → harness → model (subtotal rows) | | t | tree view — nest subagent sessions under their parent 🌳 | | a | show/hide archived sessions | | j k ↑ ↓ PgUp PgDn Home End | navigate | | p | toggle the live scatterplot | | r | force refresh now | | ? | help overlay | | q | quit (Ctrl+C works too) |

What you see

| Where | What it means | |---|---| | Header banner | grand totals: input, output, reasoning, cache read/write, cost, live burn | | Scatter plot | every active session is a colored marker · x = (bins+out) tokens, log scale · y = tok/min · 15s afterglow when a session goes idle | | Marker column ◆ | the same marker+color as the dot in the plot, so rows↔dots map at a glance (· = no live dot) | | TOK/MIN + sparkline | live burn rate (EMA) and its recent history — █▆▄▂▂▁▁ falling? generation finished | | CACHE-R / RSN | cache-read and reasoning tokens — hidden costs of agent workloads | | AGE | seconds/minutes since last activity — spot zombie or idle sessions |

Supported harnesses

| Harness | Source | Mode | |---|---|---| | OpenCode | ~/.local/share/opencode/opencode.db (session_v2, read-only) | cumulative counters | | Claude Code | ~/.claude/projects/**.jsonl (auto-detected) | additive per-message usage | | Codex CLI | ~/.codex/sessions/**.jsonl (auto-detected) | latest cumulative token_count | | Anything | generic JSONL via ~/.config/tktop/adapters.json | additive or latest |

Zero configuration for the three built-ins. The generic JSONL adapter adds any tool you use in a few lines:

// ~/.config/tktop/adapters.json
{
  "sources": [
    {
      "harness": "myagent",
      "glob": "~/.myagent/sessions/*.jsonl",
      "sessionId": "session_id",
      "model": "model",
      "title": "prompt",
      "directory": "cwd",
      "timeUpdated": "timestamp",
      "usage": "usage",
      "tokens": {
        "input": "input_tokens",
        "output": "output_tokens",
        "reasoning": "reasoning_tokens",
        "cacheRead": "cache_read_input_tokens"
      },
      "cost": "cost",
      "mode": "additive"   // sum per-line values; use "latest" for cumulative counters
    }
  ]
}

All fields are dotted paths into each JSON line.

How accurate is it?

  • Burn rate (TOK/MIN + sparkline) is derived live from counter deltas between polls and EMA-smoothed — accurate while tktop runs; restarts re-derive from scratch.
  • Cost is whatever the harness records itself (OpenCode accounting, Claude's costUSD). Missing → -.
  • Sessions show - until their harness records new usage (OpenCode persists usage on message completion, not per token).
  • Cache-write is shown in totals; cache-read per session in its column.

Docs / Architecture

| Doc | What | |---|---| | docs/GOAL.md | Goals, scope, and explicit non-goals | | docs/ADR-001-architecture.md | Adapters → Store → UI projection, why it's layered | | docs/ADR-002-tooling-opentui.md | Why Bun + OpenTUI over Node/ncurses | | docs/ADR-003-adapters.md | Adapter data contract & failure discipline | | docs/RESOLUTION-PLAN.md | Shipped phases, verification evidence, roadmap | | CHANGELOG.md | Release history |

Development

git clone https://github.com/AlexKay28/tktop && cd tktop
bun install           # once
bun run src/index.ts  # the TUI
bun run dump          # headless table, data-layer smoke test
bun run typecheck     # bun check

Layered so the data and UI never entangle: adapters (poll() → SessionInfo[], never throws) → Store (rates, sorting, grouping, tree) → UI renderables. Adding a harness means writing one adapter — see src/adapters/ and the generic-JSONL config above as a template.

Roadmap

  • [x] Live htop table, sparklines, EMA burn rates
  • [x] Log-scale scatterplot with marker legend
  • [x] Mouse: click-to-sort, row select, wheel scroll
  • [x] Tree view for subagent sessions
  • [x] npm + PyPI distribution
  • [x] Session drill-down (per-message breakdowns — Enter on a session, headless via tktop-dump --drill)
  • [x] Budget alerts (rate/cost thresholds — ~/.config/tktop/config.json, bell on new alert)
  • [x] @opentui/ssh remote watching (tktop --serve [port], ssh -p <port> localhost)
  • [x] Standalone compiled binary (npm run compile → dist/tktop, ~130 MB, runs with no Bun install)

Ideas welcome — please open an issue.

License

MIT © AlexKay28

If tktop saves you from a runaway agent — leave a ⭐.