Skip to content

fix(#56): OpenCode context injection and MCP capture were both broken - #57

Merged
jsirish merged 2 commits into
mainfrom
opencode-live-verification-parity
Aug 26, 2026
Merged

fix(#56): OpenCode context injection and MCP capture were both broken#57
jsirish merged 2 commits into
mainfrom
opencode-live-verification-parity

Conversation

@jsirish

Copy link
Copy Markdown
Member

Summary

Test plan

Closes#49

🤖 Generated with Claude Code

https://claude.ai/code/session_018GvEcZ2V5qSX2KB1q2qLsu

jsirishand others added 2 commits August 25, 2026 21:00
Live verification of the OpenCode plugin (never done since it shipped in
v0.13.0) found two production bugs that unit tests couldn't catch:
- Session-start context injection never reached a real conversation.
experimental.chat.system.transform fires twice per turn (once for
OpenCode's small-model title-generation call, once for the real
primary-agent call), same session id both times. The plugin's
delete-on-first-read design let the title call consume the injected
block before the real call ever saw it. Fixed by pushing on every
transform call while pending and clearing only at session.idle.
- MCP tool calls were silently dropped. OpenCode's real MCP tool ids use
a single underscore (confirmed live as perplexity-ask_perplexity_ask),
not Claude Code's mcp__server__tool convention the capture switch
checked for. Any unmatched tool is now captured by name.
Also closes the resulting gap in post-compaction recovery (session.created
doesn't re-fire after compaction on OpenCode, so session.compacted now
queues the recovery block directly), ports three session-start diagnostics
the TypeScript plugin never had (version line, unconsumed-buffer sweep,
gitignore nudge), fixes a worktree-note symlink false-positive, bounds the
injected git status, and syncs the plugin's version (was 1.0.0 vs 0.13.0
everywhere else) with a 3-way version-agreement check.
Closes#49 (local-ci now runs the opencode-plugin checks it always should
have). README restructured so Claude Code / Codex CLI / OpenCode read as
peer harnesses instead of Codex/OpenCode being bolted onto a
Claude-Code-first doc; docs/index.html updated to match.
Full investigation and findings: #56
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018GvEcZ2V5qSX2KB1q2qLsu
Two independent review passes (code-reviewer, pr-test-analyzer,
silent-failure-hunter, comment-analyzer) found real bugs, including one in
this branch's own P5 fix:
- The worktree-sharing symlink fix canonicalized only one side of the
comparison (root), while dataRoot's own main-tree branch returned a raw,
uncanonicalized path — inverting the bug instead of fixing it, confirmed
live: every plain macOS project under /var/folders (or /tmp) falsely
claimed worktree-sharing. Fixed at the root cause in lib.ts's
computeDataRoot(), matching _lib.sh's tl_data_root(): canonicalize on
every return path, not just the linked-worktree one.
- Post-compaction recovery pointed at a data-dir-relative path
(buffer/session-x.md) instead of data-root-relative like every other
injected path.
- NOISY_TOOLS was missing OpenCode's `list` and `todowrite` built-ins,
which the P0b fix's broadened default case would otherwise have started
logging on every call.
- Several new failure paths swallowed errors instead of breadcrumbing them
to .capture-errors, the plugin's existing diagnostic surface for exactly
this.
- Stale comments describing the removed mcp__ convention and the old
delete-on-first-read design.
Also researched (per Jason's ask) whether OpenCode's plugin architecture
should shell out to the existing hooks/*.sh scripts instead of a TypeScript
reimplementation, matching Codex's approach. Filed #58
tracking anomalyco/opencode#12472 (native Claude Code hook compat, open,
not shipped) as the trigger to revisit; not attempted now since no stable
compat surface exists yet.
Adds regression tests for the two zero-coverage gaps the test-analyzer
flagged (P5's real linked-worktree case, P4's gitignore nudge) — both
would have caught the P5 regression above.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018GvEcZ2V5qSX2KB1q2qLsu
@jsirish

Copy link
Copy Markdown
MemberAuthor

Ran the required `/review-pr` pass (4 parallel agents: code-reviewer, pr-test-analyzer, silent-failure-hunter, comment-analyzer). Findings and fixes, pushed in 291cbbc:

Critical — the P5 fix itself was buggy. Both code-reviewer and my own manual testing independently caught it: the worktree-sharing symlink fix canonicalized only root, not dataRoot, which flips the bug rather than fixing it (confirmed live: every plain macOS project under /var/folders//tmp falsely claimed worktree-sharing). Fixed at the source in lib.ts's computeDataRoot() to canonicalize on every return path, matching _lib.sh's tl_data_root() exactly. Re-verified live in both directions (plain project silent, real linked worktree still fires correctly) and added regression tests for both — pr-test-analyzer flagged this as a zero-coverage gap on a claimed fix.

Other fixes:

  • Post-compaction recovery's path pointer was data-dir-relative instead of data-root-relative like every other injected path.
  • NOISY_TOOLS was missing OpenCode's list/todowrite built-ins, which the broadened P0b default case would have started logging on every call.
  • Several new failure paths (corrupt package.json, unreadable buffer, failed recovery read) swallowed errors instead of breadcrumbing to .capture-errors, the plugin's existing convention.
  • Stale comments (removed mcp__ convention, old delete-on-first-read design), a naive path-prefix check, README's dangling session.idle cross-reference.

Also researched Jason's architectural question (should this shell out to hooks/*.sh instead of reimplementing in TS) via context7 + the upstream anomalyco/opencode repo. Filed #58 tracking anomalyco/opencode#12472 (native Claude Code hook compat — open, active, not shipped) as the trigger to revisit; not attempted now since no stable compat surface exists yet.

All 93 tests passing, local-ci clean.

@jsirish
jsirish merged commit cedbaa0 into mainAug 26, 2026
2 checks passed
@jsirish
jsirish deleted the opencode-live-verification-parity branch August 26, 2026 02:34
Sign up for freeto 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.

local-ci parity gap: .opencode-plugin's npm ci/typecheck/test has no local-ci counterpart

1 participant

@jsirish