plugin: v2 has no hook for assistant text, so live message rewriting is impossible
Summary
V1 allowed a plugin to register experimental.text.complete and rewrite each
assistant text part before it reached the UI. V2 exposes no equivalent hook, so a
plugin that normalizes links or citations in outbound messages cannot be
migrated; the only fallback is a prompt instruction.
Environment
- opencode version: 2.2.6
- OS: Windows_NT 10.0.26300 (win32 x64)
- Terminal: OpenWork Desktop (embedded server; no terminal env vars)
- Shell: C:\WINDOWS\system32\cmd.exe
- Install/channel: latest
- Active plugins: built-in OpenWork plugin set (context, provider-sync, sandbox, mcp-results, mcp-readiness, visible-reasoning, gateway-quota, auto-route, provider-filters)
Reproduction
- On V1, drop a plugin in
~/.config/opencode/plugins/text.jsthat exports a function returning{ "experimental.text.complete": async (input, output) => { ... } }and rewritesoutput.text. Each assistant text part is transformed before it is displayed. - On V2, the same file fails to load with
Plugin must export a default definition with an id and an effect or setup function(expected: the plugin API changed). - Rewrite it with
Plugin.define({ id, setup(ctx) }). The documented hooks areprompt,context,compaction,generate,title, provider/model, native HTTP, native WebSocket, tools, permissions and shell. - None of them receives the assistant's outbound text.
Expected Behavior
A supported way to observe or transform assistant text parts before they are
persisted or rendered — for example a part/text hook, or a session hook for
assistant output — so integrations can normalize the reply as it is produced.
Actual Behavior
No such hook exists in V2. The available interception points are inbound
(prompt) or model-request assembly (context, compaction, generate,
title): they change what the model receives, not what it emits. A V1-format
plugin produces only a startup WARN, with no user-visible signal:
message="failed to load plugin" ... Plugin must export a default definition
with an id and an effect or setup function
Additional Context
Concrete use case: a desktop client renders bare file paths as clickable targets and needs link normalization in the assistant's reply — converting a markdown link to a bare relative path, for instance. On V1 this ran transparently on every text part; on V2 it is gone, and the workaround is to depend exclusively on the model following an instruction, with a post-hoc audit that cannot patch the message.
Reference: the V2 plugin server docs list the hooks above (https://opencode.ai/docs/build/plugins/server); the migration guide covers the API break but not a replacement for this hook (https://opencode.ai/docs/build/plugins/migrate-v1).
Thanks for the detailed report, @brunotorresdigital! I think this is a duplicate of #53019, which asks for the same thing: a V2 plugin hook that can observe or rewrite assistant text parts, either as a display-only transform or as a hook like V1's experimental.text.complete that runs before the text is saved. The V1 migration guide also lists experimental.text.complete among the experimental V1 hooks that have no direct V2 equivalent.
Possible duplicates and related issues, ordered by likelihood:
- #53019: the same request for V2. It is still open, and other plugin authors have added use cases there (stripping markers, repairing output, checking rendered blocks).
- #34035: an earlier V1-era request to filter streamed output before it is displayed (closed).
I'm closing this issue now as a duplicate of #53019. Please add your use case there (normalizing links for a client that turns file paths into clickable targets), since it helps the maintainers see who needs this. If you think this is a different problem, reply here and the issue will reopen.