Public: anyone can read this; the crew can change it.
Tokens as a unit people can feel: files, runs, issues and pulls carry a token count the way storage carries MB and GB #526
Token counts now appear in the places that already show a size, a cost or a share of a window. Every count goes through one formatter in src/kernel/tokens-format.ts, which writes them like storage sizes: 850 tok, 1.2k tok, 48k tok, 1.1M tok. Counts the provider reported are shown bare.
stopped closed without shipping deploy 5e452c9
5 earlier comments
Shows token counts next to byte sizes in the studio, along with what that many tokens costs and how much of a model's context window it fills (#403).
This update merges main back into the branch. The only conflict was forge.json: both sides had added one test file to the check command, this branch test/tokens.test.ts and main test/fleet-ops.test.ts. The check command now runs both. Nothing else needed changing by hand.
I ran the full check command locally after the merge. Type-checking passed, and 654 of the 655 tests passed. The one failure was "checks > when a slot frees, the newest of several queued checks runs first", which waits on timing and ran while three test groups were running in parallel. It passed on its own, and again together with test/tokens.test.ts and test/fleet-ops.test.ts (44/44). This branch doesn't touch the checks code, so I left the test as it is.
🤖 Generated with Claude Code
Files, runs, issues and pulls now show a token count, the same way storage shows MB and GB. This push merges the latest main into the branch and keeps that change.
Merge conflicts
forge.json: I tookmain's shorter check command and addedtokensafterusage.fleet-opswas already inmain's list, so both of this change's test files stay in the check.src/web/pages/board.ts:mainchanged the windows strip into separate groups ("The crew's" and "Not offered to the crew"), with a shared card for each credential. I keptmain's layout and put this change's token count into that card: after used, left and resets, a window now shows· N tokens countedwhen it has any.
Check results: On a clean run, the full check passes (688 tests across 47 files). An earlier run of the same command had 4 timeouts in tests that start app processes (meter, apps and apps-adversarial). I reran each of those files on its own on this branch, and on clean main for meter and apps; they passed every time except one meter run on this branch, which passed when I ran it again. They look like load-related flakes, not something this change causes. No tests were edited.
To try it: sign in as a site admin on the preview, open the board, and look at the subscription windows strip.
🤖 Generated with Claude Code
Files, runs, issues and pulls carry a token count the way storage carries MB and GB, and the subscription windows on the board show · N tokens counted next to used, left and resets.
This push merges the latest main into the branch. The only conflict was the check command in forge.json. main added crew-parks and told-by to the list, and this branch added tokens. The resolved command keeps all three, so this change's tests still run in the check. Nothing else conflicted; the board.ts, pull.ts and studio/change.ts changes from main merged on their own.
I ran the full check locally after the merge and it passed: 732 tests across 52 files, with no failures and no tests edited.
To try it, sign in as a site admin on the preview, open the board and look at the subscription windows strip.
🤖 Generated with Claude Code
Files, runs, issues and pulls carry a token count the way storage carries MB and GB, and the subscription windows on the board show · N tokens counted next to used, left and resets.
This push merges the latest main into the branch. The only conflict was the check command in forge.json. main added surfaces-adversarial and orgs to the list, and this branch added tokens. The resolved command keeps all of them, so this change's tests still run in the check. src/web/pages/board.ts merged on its own.
I ran the full check locally after the merge and it passed: 721 tests across 51 files, with no failures and no tests edited.
To try it, sign in as a site admin on the preview, open the board and look at the subscription windows strip.
🤖 Generated with Claude Code
Token counts now appear in the places that already show a size, a cost or a share of a window. Every count goes through one formatter in
src/kernel/tokens-format.ts, which writes them like storage sizes:850 tok,1.2k tok,48k tok,1.1M tok. Counts the provider reported are shown bare. Estimates get a~. Each count has a tooltip naming Claude's tokenizer, giving the exact number and, for an estimate, the ratio it came from.treeListinginsrc/web/pages/repo.ts, also used when browsing another forge): each file shows its tokens beside its size. A line under the listing gives the file count, bytes and tokens for the files at that level. Subdirectories aren't included, because git doesn't report their sizes, and the tooltip says so./runs/:id, both views): tokens in and out beside the cost, read from the usage ledger. Only people who can write to the repo see them, the same rule as the studio's cost.issueUsagequery insrc/core/usage.ts. Writers only.0 tok;test/subscriptions.test.tsexpects that line unchanged.docs/DESIGN.md: adds the rule (a token count goes where a byte size goes, never as a badge on its own) and a checklist item for it.Left out:
usage(issue_id): not added. That table has one row per run, and a new migration number is likely to clash with other open branches.test/tokens.test.tsis new and is part of the forge.json check. It covers the formatter at its rounding edges (9,950 becomes10k, 999,500 becomes1.0M, never1000k) and each estimate against a hand calculation. On a live app it checks that the listing, file, editor, run, issue, Subscriptions and board pages show the expected counts, and that a reader who can't write sees none of the spend. The full check passes and no existing test was changed.I also ran the other tests that load these pages. Three fail on a clean
mainas well: two dashboard query-count tests intest/surfaces-adversarial.test.tsand one origin-authorization timeout. Two board and origin-browse tests timed out once under load and passed on a rerun.To try it, open any repository tree or file, then a run, issue or pull that the crew worked on, then
/settings/subscriptionsand/board.🤖 Generated with Claude Code
Closes #403