Repository navigation
Add cmd-mod-toks to the registry - #1153
Open
ArcticPole04 wants to merge 1 commit into
Open
ArcticPole04 wants to merge 1 commit into
ArcticPole04 wants to merge 1 commit into
Conversation
A tokens-per-second meter that reports the live generation rate beside the
working spinner and the exact rate in the footer once a request finishes.
The estimate is where most meters in this category go wrong: dividing a
character count by 4 reads CJK about 4x too slow. This one samples the
absolute count from `message_update` instead of deltas, so retries and stream
fragmentation cannot skew it, and it counts tool-call arguments that never
arrive as a text delta. Every request is reconciled against the provider's own
outputTokens, handling both billing styles for reasoning tokens.
kinds reflects what the mod registers: addCommand (/toks), addFlag (status,
spinner, lang), and ui.override('spinner'). It registers no cmd.hooks, so
"hook" is deliberately absent.
cmd mods inspect reports reaches: none and imports: none — the mod reads host
events and writes to cmd.state, with no network, filesystem, or process access.
NOTICE.md credits the two MIT-licensed mods whose measurement constants informed
this one and records what is original here.
90 tests pass on Node's built-in runner; typecheck is clean.
Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add cmd-mod-toks
A tokens-per-second meter for Command Code. It reports the live generation rate beside the
working spinner and the exact rate in the footer once a request finishes.
The crowded part of this category is the estimate. Most meters divide a character count by 4,
which reads Chinese roughly 4x too slow and short chunks roughly 4x too fast. Three things
differ here:
message_update, not deltas. The event carries the whole partial message,so the count is invariant to how a provider fragments the stream, a mid-stream retry
self-corrects as a shrinking total instead of counting withdrawn text twice, and tool-call
arguments are counted — they are billed output tokens that never arrive as a
text_delta.outputTokens; both billing styles are offered as candidates (providers that fold reasoningtokens into that figure and providers that do not) and the closer match wins.
When it cannot be right it shows nothing rather than a plausible wrong number: a decode span
too short to trust, a rate that implies buffered delivery, and silence longer than two seconds
all suppress the reading instead of printing a guess.
Entry
{ "name": "cmd-mod-toks", "source": "cmd-mod-toks", "description": "Honest tokens-per-second meter: samples absolute message_update counts so retries and stream fragmentation cannot skew it, counts CJK as one token, and calibrates against the provider's own outputTokens.", "author": { "name": "ArcticPole04", "github": "ArcticPole04" }, "repo": "https://github.com/ArcticPole04/cmd-mod-toks", "npm": "cmd-mod-toks", "kinds": ["command", "flag", "renderer"], "tags": ["metrics", "throughput", "status-line", "tokens"], "addedAt": "2026-11-17" }kindsreflects what the mod actually registers:addCommand(/toks),addFlag(three:status,spinner,lang), andui.override('spinner'). It registers nocmd.hooks, sohookis deliberately absent.sourcematchesnpm, consistent with every other npm-backed entry in the file.What a reviewer will find
cmd mods inspectreportsreaches: noneandimports: none— the mod reads host events and writes tocmd.state.touches the transcript, permissions, or model routing.
cmd.stateoutlives the process that wrote it, so a storedvalue is checked before use rather than trusted.
NOTICE.mdrecords that two earlier MIT-licensed mods informedthe measurement guards (
cmd-footerfor the plausibility ceiling and its 400 tok/sthreshold,
commandcode-tokenspeed-modfor the 600 ms EMA constant), with their copyrightnotices reproduced. It also states what is original here.
coding agent under human direction, and what that means for the license.
Testing
npm testruns 90 tests on Node's built-in runner;npm run typecheckpasses. The suite iswritten against defects observed while building the mod — retry double-counting, a single-frame
reasoning burst, CJK under-reporting, one-character deltas, missing usage, providers that
exclude reasoning tokens, late first tokens, interruptions, and sparse streams. The measurement
guards are also mutation-tested: invert one and the suite fails.
Pre-submission checks
registry.schema.jsonvalidated:namepattern, 203/240 description,author.namepresent,
kindsall in the enum,tagsall^[a-z0-9-]+$,additionalProperties: falsesatisfied (no extra fields), no
official/featured.https://www.npmjs.com/package/cmd-mod-toks.