Skip to content

feat(opencode): V2 commands.pre-execute alongside V1 trigger - #76

Merged
filipeforattini merged 1 commit into
mainfrom
feat/commands-pre-execute-shim
Aug 21, 2026
Merged

feat(opencode): V2 commands.pre-execute alongside V1 trigger#76
filipeforattini merged 1 commit into
mainfrom
feat/commands-pre-execute-shim

Conversation

@filipeforattini

@filipeforattini filipeforattini commented Aug 21, 2026

Copy link
Copy Markdown

Third V1→V2 shim in the series (#70 #72 #75). Adds SessionEvent.Command.PreExecute (live waterfall event, type session.next.command.pre_execute) carrying { command, sessionID, arguments, parts } and wires EventV2Bridge.waterfall into the command dispatch next to the existing V1 plugin.trigger('command.execute.before', ...).

What this PR does

  • Adds Command.PreExecute as a sibling namespace to Tool, carrying command/arguments/parts.
  • The command dispatch now runs a waterfall with a single listener that delegates to the V1 trigger so existing plugins keep working unchanged.
  • Listeners return { parts } to rewrite the prompt payload; throwing short-circuits the command.

Pattern

Same shape as #70 / #72: waterfall returns the (possibly transformed) result, V1 listener falls back to the mutated shared value when no V2 plugin exists, and V2 plugins get right of last say when they do.

Out of scope

  • agent.pre-system for experimental.chat.system.transform
  • permission.request for permission.ask
  • experimental.session.compacting / experimental.compaction.autocontinue / experimental.text.complete (all emit)

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

filipeforattini added a commit that referenced this pull request Aug 21, 2026
…77)

Adds `SessionEvent.Agent.PreSystem` (live waterfall event, type `session.next.agent.pre_system`) carrying `{ agent, sessionID, messageID, system }` and wires `EventV2Bridge.waterfall` into the agent generate dispatch next to the existing V1 `plugin.trigger('experimental.chat.system.transform', ...)`.

The waterfall currently has a single listener that delegates to the V1 trigger so existing plugins keep working. Listeners return `{ system }` to rewrite the system prompt; throwing short-circuits the generate. Same shim pattern as #70 #72 #75 #76. `EventV2Bridge` joins the Agent layer's deps so the generate function's new service requirement propagates cleanly; `cli/cmd/agent.ts` provisions the service when running the generate effect locally.
filipeforattini added a commit that referenced this pull request Aug 21, 2026
Adds `SessionEvent.Text.Complete` (live waterfall event, type `session.next.text.complete`) carrying `{ sessionID, messageID, partID, text }` and wires `EventV2Bridge.waterfall` into the text-complete dispatch next to the existing V1 `plugin.trigger('experimental.text.complete', ...)`.

The waterfall currently has a single listener that delegates to the V1 trigger so existing plugins keep working. Listeners return `{ text }` to transform the final text; throwing short-circuits the text part. Same shim pattern as #70 #72 #75 #76 #77 #78 #79.
Adds `SessionEvent.Command.PreExecute` (live waterfall event, type `session.next.command.pre_execute`) carrying `{ command, sessionID, arguments, parts }` and wires `EventV2Bridge.waterfall` into the command dispatch next to the existing V1 `plugin.trigger('command.execute.before', ...)`.

The waterfall currently has a single listener that delegates to the V1 trigger so existing plugins keep working. Listeners return `{ parts }` to rewrite the prompt payload; throwing short-circuits the command. Same shim pattern as #70 #72.
@filipeforattini
filipeforattini force-pushed the feat/commands-pre-execute-shim branch from c76d09f to 7831f17 Compare August 21, 2026 15:12
@filipeforattini
filipeforattini merged commit 00eec8c into main Aug 21, 2026
3 checks passed
@filipeforattini
filipeforattini deleted the feat/commands-pre-execute-shim branch August 21, 2026 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant