Skip to content

feat(opencode): V2 compaction.pre-compact alongside V1 trigger - #79

Merged
filipeforattini merged 1 commit into
mainfrom
feat/session-compacting-text-shim
Aug 21, 2026
Merged

feat(opencode): V2 compaction.pre-compact alongside V1 trigger#79
filipeforattini merged 1 commit into
mainfrom
feat/session-compacting-text-shim

Conversation

@filipeforattini

@filipeforattini filipeforattini commented Aug 21, 2026

Copy link
Copy Markdown

Sixth V1→V2 shim in the series (#70 #72 #75 #76 #77 #78). Adds SessionEvent.Compaction.PreCompact (live waterfall event, type session.next.compaction.pre_compact) carrying { sessionID, context, prompt } and wires EventV2Bridge.waterfall into the compaction dispatch next to the existing V1 plugin.trigger('experimental.session.compacting', ...).

What this PR does

  • Adds Compaction.PreCompact as a sibling to the existing Compaction.Started/Delta/Ended.
  • The compaction dispatch now runs a waterfall with a single listener that delegates to the V1 trigger so existing plugins keep working unchanged.
  • Listeners return { context, prompt } to inject context or replace the compaction prompt; throwing short-circuits the compaction.
  • The V1 trigger result is mutated with the V2-decided values so downstream code keeps working with a single source of truth.

Pattern

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

Out of scope

  • experimental.text.completeText.Complete (waterfall, similar pattern)
  • experimental.compaction.autocontinue (V1 doesn't mutate, just decides continue/stop)
  • Agent loop decomposition (turn flow as events)
  • Profiles + bundles

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

Adds `SessionEvent.Compaction.PreCompact` (live waterfall event, type `session.next.compaction.pre_compact`) carrying `{ sessionID, context, prompt }` and wires `EventV2Bridge.waterfall` into the compaction dispatch next to the existing V1 `plugin.trigger('experimental.session.compacting', ...)`.

The waterfall currently has a single listener that delegates to the V1 trigger so existing plugins keep working. Listeners return `{ context, prompt }` to inject context or replace the compaction prompt. The V1 result is mutated with the V2-decided values so downstream code keeps working with a single source of truth.
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.
@filipeforattini
filipeforattini merged commit 2a85a59 into main Aug 21, 2026
5 of 7 checks passed
@filipeforattini
filipeforattini deleted the feat/session-compacting-text-shim branch August 21, 2026 15:09
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