Uh oh!
There was an error while loading. Please reload this page.
fix(#56): OpenCode context injection and MCP capture were both broken - #57
Conversation
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
commented
Aug 26, 2026
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 Other fixes:
Also researched Jason's architectural question (should this shell out to All 93 tests passing, |
Summary
1.0.0vs0.13.0everywhere else) with a 3-way version-agreement check.local-cinow runs.opencode-plugin's own checks.docs/index.htmlupdated to match.Test plan
npm testin.opencode-plugin— 89/89 passing (5 new tests covering the two production bugs + the ported behaviors)local-ci— all checks green, including the newopencode plugincustom checkopencode run), not just unit tests — see OpenCode: live verification findings — context injection broken, MCP capture broken, skills confirmed not pluggable #56 for the full verification matrixCloses#49
🤖 Generated with Claude Code
https://claude.ai/code/session_018GvEcZ2V5qSX2KB1q2qLsu