Skip to content

Releases

v2.1.0

Choose a tag to compare

@ramtinJ95 ramtinJ95 released this 10 Nov 23:01
a7ad915

Adds a native token usage panel on OpenCode V2. OpenCode V1 is unaffected.

Added

  • On OpenCode V2, /tokenscope opens a token usage panel beside the session. The panel reads the analysis from the plugin over RPC, so it makes no model request and adds nothing to the session, and it reloads when the session finishes a turn. It is also in the command palette as "Token usage report".
  • The panel's context window split is scaled to the context OpenCode recorded for the last request, so its rows add up to the provider's count. Local tokenization only supplies the proportions.
  • Added bundled pricing for gpt-6.1-terra from models.dev.

Changed

  • On OpenCode V2, the command that has the model print the text report is now /tokenscope-report. /tokenscope on OpenCode V1 is unchanged.

v2.0.0

Choose a tag to compare

@ramtinJ95 ramtinJ95 released this 10 Nov 10:57
c4a5989

Adds OpenCode V2 support. OpenCode V1 keeps working without any change on the user's side: the V1 implementation is unchanged from 1.8.1 and stays in the package for a transition period.

Added

  • Added OpenCode V2 support through the V2 plugin API (@opencode/plugin). The V2 implementation lives in plugin/v2/, produces the same report layers as 1.8.x, and registers both the tokenscope tool (as a directly callable tool) and the /tokenscope command, so V2 needs no command file.
  • Added package routing for both OpenCode majors: main still points at the V1 module, which every OpenCode V1 release and a V1 script install load, and the new exports entry points at the V2 module, which OpenCode V2 resolves. Neither host loads the other's implementation or plugin SDK.
  • On V2, the system category, context breakdown, and tool-definition sizes are measured from the system prompt and tool definitions of the session's latest model request, captured with a session context hook and split by instruction source. Labeled estimates remain as the fallback for sessions with no request since OpenCode started.
  • On V2, the context breakdown has a "Catalogs & Guidance" row for the skill, MCP, reference, and Code Mode catalogs.
  • On V2, recorded usage is read from assistant messages and compaction requests, and reconciled against the session aggregate. Because V2 exposes only the active context (the last compaction onward) to plugins, a compacted session gets a warning that names both totals instead of a generic mismatch.
  • On V2, live pricing with all context tiers comes from the model catalog, child sessions from the session list, and the skill and subagent catalogs from the skill and agent APIs, filtered with the permission rules of the current agent and session.
  • On V2, feature flags can be set as plugin options in opencode.json(c); they take precedence over ~/.config/opencode/tokenscope-config.json.
  • On V2, user-invoked skills and !shell commands are counted alongside replayable tool output.
  • install.sh detects OpenCode V2 and installs through opencode plugin add (or opencode plugin update with --update), then lists leftover files from a V1 script install. The V1 flow is unchanged.

Changed

  • @opencode/plugin ^2.0.0 is an optional peer dependency. @opencode-ai/plugin >=1.1.48 remains a peer dependency for OpenCode V1.

v1.8.1

Choose a tag to compare

@ramtinJ95 ramtinJ95 released this 29 Jul 07:14
7a77530

Added

  • Added a generated report preview near the top of the README and a linked report reference covering section semantics, exclusions, fallbacks, and reconstruction limits.

Changed

  • Reorganized the root and packaged READMEs around installation, report interpretation, current capabilities, configuration, pricing and tokenizer coverage, troubleshooting, privacy, and development.
  • Clarified legacy assistant-message telemetry fallback, config loading behavior, private-report write failures, OpenCode and Hugging Face network access, and npm package resolver semantics.

v1.8.0

Choose a tag to compare

@ramtinJ95 ramtinJ95 released this 09 Jul 20:11
510edda

Added

  • Added OpenCode-compatible arbitrary and multiple context-price tiers, selected independently for every completed provider step before the legacy 200K fallback.
  • Added reconciliation between message-derived step-finish telemetry and OpenCode's session aggregate, with visible warnings when token buckets or recorded cost disagree.
  • Added explicit snapshot-boundary, retained-content, active-revert, missing-metadata, and approximate-tokenizer warnings so incomplete data cannot look exact.
  • Added adaptive precision for small USD values and per-million rates, preserving values such as $0.00001234 and $0.00875/M in displayed formulas.
  • Added dedicated regression coverage for session reconciliation, current OpenCode skill formatting, tokenizer fallbacks, multi-tier pricing, report isolation, and cyclic child-session graphs.

Changed

  • Reframed reports into three distinct layers: locally tokenized retained content, recoverable OpenCode-recorded usage, and visibly labeled explanatory estimates.
  • Renamed API-call totals to completed provider steps and documented that the step invoking TokenScope, later report reads, and the final response are outside the snapshot.
  • Updated pricing estimates to use live OpenCode provider metadata first, with the bundled models.dev-derived catalog retained only as a warned fallback.
  • Updated skill accounting for OpenCode v1.17.18: the verbose permission-filtered catalog belongs to system context, while the static skill-tool description is counted separately from its schema.
  • Changed repeated skill accounting to tokenize and sum each persisted result instead of multiplying the first result size by the call count.
  • Changed zero-cost and mixed-cost reporting to distinguish OpenCode-recorded cost from public API-rate estimates without assuming a subscription or provider invoice.
  • Changed report output to unique, atomically written files in private per-invocation directories under OpenCode's temporary path, leaving analyzed worktrees untouched.
  • Changed updater behavior to reinstall declared dependencies before rebuilding, preventing stale plugin SDK and tokenizer packages from surviving an update.
  • Documented the v1.17.18 accuracy target and the remaining limits around generated system prompts, provider-transformed tools, compaction, reverts, and bundled-pricing freshness.

Fixed

  • Fixed sub-200K and multi-tier cost estimates, strict threshold selection, tier-before-legacy-fallback precedence, per-step tiering, and zero-valued omitted tier cache rates to match OpenCode.
  • Fixed cost formulas and labels so reasoning uses the output rate, fresh/cache-read/cache-write buckets remain non-overlapping, and displayed rates agree with the calculated totals.
  • Removed invalid system-prompt remainder inference that could double-count assistant history and removed the nonexistent fixed project-tree estimate.
  • Bounded heuristic context components so they cannot exceed the observed first cache-write bucket, which is now labeled as an allocation anchor rather than a context-window measurement.
  • Fixed OpenCode-hosted Claude and other non-OpenAI models being tokenized as OpenAI, mapped newer GPT/o-series models to the GPT-4o tokenizer family, and preserved real model names when tokenization is approximate.
  • Fixed silent tokenizer fallbacks by reporting unknown encodings, load failures, and encode failures before using an approximate count.
  • Fixed retained-content handling for ignored:true text, completed compacted tools, and replayable errored or interrupted tool results.
  • Fixed tool-schema reporting that implied current metadata was the exact historical enabled toolset; active-agent permissions, MCP additions, and provider transforms are now called out explicitly.
  • Fixed skill-catalog reconstruction that double-attributed an obsolete catalog-bearing tool description and made unavailable skill/agent metadata visible.
  • Fixed recursive subagent attribution by preferring the session's agent field and stopping duplicate or cyclic traversal.
  • Fixed unsafe pricing-prefix matches that could assign a related model's price without a valid model-version boundary.
  • Fixed concurrent report overwrites, repository pollution, shell-path handling, and stale fixed-filename instructions.

Security

  • Restricted report directories to owner-only permissions and report files to mode 0600 on Unix.
  • Added ownership, symlink, and writable-parent validation before writing potentially sensitive session reports under OpenCode's allowed temporary path.

v1.7.2

Choose a tag to compare

@ramtinJ95 ramtinJ95 released this 02 Jul 18:44

Fixed

  • Fixed OpenCode Desktop context exports by falling back to the OpenCode SDK when the opencode CLI is unavailable.

v1.7.1

Choose a tag to compare

@ramtinJ95 ramtinJ95 released this 13 Jun 17:46

Added

  • Added an opt-in enableDetailedSubagentCostBreakdown config flag that expands subagent report sections with fresh input, cache read, cache write, output, and reasoning token buckets plus estimated per-bucket costs.

Fixed

  • Fixed the default context export runner so npm-installed plugins no longer require Bun to analyze exported session data.
  • Fixed subagent cost reporting to show recorded child-session API costs when available, including mixed main-session subscription and child-session API-cost cases.
  • Fixed subagent estimated cost splits to clearly distinguish API-rate estimates from recorded API costs.
  • Fixed live metadata fallback merging for provider-qualified and bare model aliases when provider metadata is partial.

v1.7.0

Choose a tag to compare

@ramtinJ95 ramtinJ95 released this 07 Jun 10:21

Added

  • Added live OpenCode provider/model metadata lookup for pricing, with bundled models.json retained as a fallback.
  • Added support for current OpenCode nested cache pricing and large-context pricing metadata (cost.cache, cost.tiers, and experimentalOver200K).
  • Added directory-routed OpenCode client calls for session messages, child sessions, tool metadata, and provider metadata so TokenScope analyzes the correct project context.

Changed

  • Reworked cost estimation to price each API call by its own context tier instead of applying large-context rates to aggregated session totals.
  • Improved cache-efficiency cost math by recalculating uncached costs per call and per tier.
  • Updated cost report wording to distinguish OpenCode-recorded actual cost from TokenScope API-equivalent estimates.
  • Raised the supported OpenCode plugin peer range to @opencode-ai/plugin >=1.1.48.

Fixed

  • Fixed context exports to run from the active session directory.
  • Fixed script-installed plugins by including all split library files, installing build dependencies, and building dist/ during install/update.
  • Fixed report summary paths to print a safely shell-quoted full report path.
  • Fixed live pricing alias handling for provider model keys, API model IDs, ambiguous bare aliases, incomplete metadata, cache rates, and non-200K context thresholds.
  • Fixed subagent cost estimates to use the same per-call context-tier pricing as main sessions.

Validation

  • cd plugin && npm test → 50 passing tests.
  • Smoke-tested script install/update and real OpenCode sessions before release.

v1.6.5

Choose a tag to compare

@ramtinJ95 ramtinJ95 released this 31 May 08:20

Changed

  • Aligned TokenScope's OpenCode SDK calls with current session, child-session, and experimental tool endpoint request shapes.
  • Improved context breakdown and tool schema accounting by using current OpenCode tool metadata, workspace-routed tool definitions, generated prompt detection, and cache-write model selection.
  • Updated skill and subagent analysis for current OpenCode skill metadata, optional skill descriptions, and directory-scoped tool definitions.

Fixed

  • Avoided treating user-supplied system overrides as generated OpenCode context unless they match stronger generated-context markers.
  • Stopped using current OpenCode info.tools permission overrides to hide model-visible tool definitions.

v1.6.4

Choose a tag to compare

@ramtinJ95 ramtinJ95 released this 20 May 20:24
91470a4

Added

  • Added DeepSeek V4 Flash and DeepSeek V4 Pro pricing entries.
  • Added a compiled dist/ ESM smoke test to catch strict loader regressions.

Fixed

  • Added explicit .js extensions to compiled ESM imports so TokenScope loads in strict ESM environments such as OpenCode Desktop (#30).

Published to npm as @ramtinj95/opencode-tokenscope@1.6.4.

v1.6.3

Choose a tag to compare

@ramtinJ95 ramtinJ95 released this 14 Apr 09:25

Added

  • Added Bun regression tests covering sessionID fallback behavior and bundled asset resolution for TokenScope

Changed

  • Hardened the suggested /tokenscope slash-command prompt to keep sessionID unset unless the user explicitly asked to analyze a different session

Fixed

  • Normalized blank sessionID tool arguments so OpenCode models that emit sessionID="" still fall back to the current session instead of failing with "No session ID available for token analysis"
  • Fixed bundled asset lookup so built/npm TokenScope installs loaded from dist/ still resolve models.json and tokenscope-config.json from the published package root instead of silently falling back to default pricing

Closes #21