Skip to content

feat(cli): extend the OpenCode plugin to every documented context surface - #1487

Open
JCVIDev wants to merge 1 commit into
DeusData:mainfrom
JCVIDev:feat/opencode-context-hooks
Open

feat(cli): extend the OpenCode plugin to every documented context surface#1487
JCVIDev wants to merge 1 commit into
DeusData:mainfrom
JCVIDev:feat/opencode-context-hooks

Conversation

@JCVIDev

@JCVIDev JCVIDev commented Aug 7, 2026

Copy link
Copy Markdown

Summary

OpenCode is the closest client to Claude-parity for models CBM has no first-party hook dialect for (DeepSeek, etc.): it already gets MCP + the skill + the three read-only agents, but its generated plugin only covered one of the four context surfaces other clients get through hook configuration. This PR extends cbm_client_adapter_opencode() so the generated cbm-augment.ts covers every surface OpenCode documents — and nothing it doesn't:

  • grep/glob graph lookup (existing surface, improved): the plugin now pipes the event through hook-augment and unwraps hookSpecificOutput.additionalContext instead of pasting the raw Claude JSON envelope into the tool output.
  • Post-read index-coverage notes: tool.execute.after for read maps OpenCode's filePath arg to the PostToolUse/Read event hook-augment already accepts.
  • Session-start tier routing: OpenCode documents no context-output lifecycle hook, so the SessionStart note is carried on the first tool result of each session (deduped per sessionID).
  • Post-compaction reinjection: via the documented experimental.session.compacting hook, appending to the mutable output.context array.

Every path stays fail-open (all failures resolve to ''; context is only ever appended), consistent with the hook-augment contract, and the plugin body remains marker-free so cbm_text_upsert_managed_block owns the lifecycle (regenerated on install/update, per the #616 lesson).

Why only these surfaces

Checked against the published OpenCode plugin docs: tool.execute.before/after, the event bus, and experimental.session.compacting are the documented context-capable hooks; there is no chat.message-style hook. Per CBM policy the generator does not invent undocumented vendor surfaces, so session-start context rides on the first tool result rather than a fabricated lifecycle hook.

Testing

README's OpenCode matrix row updated to describe the four surfaces.

🤖 Generated with Claude Code

…face

The generated OpenCode adapter covered only the grep/glob graph lookup, so
OpenCode sessions missed the read-coverage and lifecycle context other
clients get through their hook configuration. Extend the plugin to the
surfaces OpenCode documents:

- unwrap hook-augment's additionalContext envelope so plain text, not raw
  JSON, lands in the tool output
- post-read index-coverage notes via tool.execute.after, mapping OpenCode's
  filePath argument to the file_path key the default dialect reads
- session-start tier routing injected once per sessionID on the first tool
  result, since OpenCode documents no context-output lifecycle hook
- post-compaction reinjection through the documented experimental
  session.compacting surface (output.context)

Every failure path resolves to the empty string: the adapter can degrade to
a no-op but never blocks a tool call. Pin the new surfaces in
test_agent_clients (31/31 pass; the DeusData#616 payload guard stays green) and
record the wider surface in the README client matrix.

Signed-off-by: jc <jcvi007@gmail.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@JCVIDev
JCVIDev requested a review from DeusData as a code owner August 7, 2026 13:41
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Thanks for opening this — it has been seen, and it is queued.

This note is automated, but it is not a brush-off: it exists so you know where your PR stands instead of having to guess from silence.

Current review status: working through a backlog. 0.9.1-rc.1 is out, so the release freeze that held reviews is over — but it left a large queue of open pull requests behind it, and we are reading through them oldest-first. The background is in discussion #1144.

What that means for this PR, concretely:

  • It will not be closed for inactivity. No stale bot touches pull requests here.
  • It may still sit a while before a human reads it. That is on us, not on you.
  • Older PRs are read first, so a recent one is not being skipped — it is behind a queue.

Things that will genuinely speed it up whenever review does happen:

  • Keep it rebased on main — the tree is moving quickly right now, and a conflicting branch cannot be reviewed as the diff you intended.
  • Get CI green, or say which failures you believe are pre-existing.
  • Keep the change to one claim. Bundled features and refactors get split before they get merged, which costs you a round trip.
  • Every commit needs a sign-off (git commit -s) — CI enforces DCO.

If this fixes a bug, a reproduction we can run is worth more than a description of the symptom.

Thanks for contributing, and sorry in advance for the wait.

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.

2 participants