Repository navigation
Conversation
OpenCode V2 replaces the V1 plugin API, so the V1 implementation no longer
loads (it failed with: Cannot find package '@opencode-ai/plugin').
- entrypoint: Plugin.define({ id, setup }) from @opencode/plugin, cleanup aborts
the event subscription
- events: message.* / session.error are gone; metrics now come from the step
lifecycle (session.step.started, session.text.started,
session.reasoning.started, session.step.streamed, session.step.ended,
session.step.failed, session.execution.failed)
- metrics are recorded per model step instead of per assistant message, so
turns with tool calls produce one entry per request
- tool: tool()/tool.schema becomes ctx.tool.transform(editor => editor.add())
with a JSON Schema input and a { content } result
- toast moves to a TUI part (ctx.data.on + ctx.ui.toast.show); the server
context has no TUI client
- local plugin becomes a directory (.opencode/plugins/throughput/{index,tui}.ts)
- split metrics/report out of the plugin for testability
- tests converted from bun:test to node:test, rewritten for the step events
- package.json: @opencode/plugin dependency, ./tui export, version 2.0.0
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.
Summary
OpenCode V2 replaced the plugin API, and V1 plugin implementations no longer load. In OpenCode 2.2.5 the current
mainfails at startup:This ports the plugin to the V2 API: entrypoint, context, events, tool registration, and toasts. The metric math, the
benchmarktool output, and the JSONL/Markdown log formats are unchanged, so existing~/.opencode/throughput.jsonlhistory still aggregates correctly.Changes
Plugin.define({ id: "throughput", setup(ctx) })from@opencode/plugin; the cleanup function aborts the event subscription.client.*/directorybecomectx.*/ctx.location.directory.message.updated,message.part.updated,message.removedandsession.errordo not exist in V2. The tracker now consumes the step lifecycle:session.step.started(model ref + start time),session.text.started/session.reasoning.started/session.step.streamed(first output, for TTFT),session.step.ended(latency, tokens, cost, finish),session.step.failed, andsession.execution.failedfor cleanup.tool()/tool.schemareplaced byctx.tool.transform(editor => editor.add({ ... }))with a JSON Schema input and a{ content }result.ctx.data.on+ctx.ui.toast.show), because the V2 server context has no TUI client.client.app.logis replaced byconsole.log, which lands inopencode.log..opencode/plugins/throughput/{index,tui}.ts), since configured local plugin paths must be directories in V2. Implementation is split intosrc/metrics.ts(tracker + formatting) andsrc/report.ts(log IO + aggregation) so it can be tested without the plugin loader.package.jsondepends on@opencode/plugin, exports./tui, and is bumped to2.0.0because the V1 dependency and entrypoint are gone.bun:testtonode:test(bun is not required to run them) and rewritten around the step events.Verification
tsc --noEmitcleannpm test: 21/21 passing/api/pluginreportsid: "throughput",features: { server: true, tui: true },status: active, with no load errors inopencode.log~/.opencode/throughput.jsonland<project>/.opencode/throughput.md, e.g.TTFT 2.5s | TPS 84.5 tok/s | Latency 4.0s, and thebenchmarktool returns aggregated stats from themBreaking change
The package now targets OpenCode V2 and requires
@opencode/plugin2.x. The V1 implementation is removed rather than kept alongside; if V1 support is still needed, the documented dual-entrypoint shape (setup+server()) can be added back, at the cost of maintaining both.