GeezerVison is showing github.com — mcpx: port the opencode plugin to opencode v2 (a rewrite, and several things get better) · Issue #1858 · developing-today/code
mcpx: port the opencode plugin to opencode v2 (a rewrite, and several things get better) #1858DescriptionRelocated from dezren39/darwin-nix#47 on 2026-10-28 (placement audit): mcpx's single source lives in developing-today/code (pkgs/mcpx); re-home tracked at #309. Original body below; issue references inside it are historical (dezren39/nix numbering).
Parent: #181
Backlog. Findings: pkgs/mcpx/docs/opencode-plugin.md §2 and §4.
v1 plugins do not load in opencode v2 — no shim, no fallback (packages/core/src/plugin/module.ts:60-73). v2 needs a rewrite against {id, setup}, not a port.
What changes, each better than the v1 equivalent:
| v1 today |
v2 |
shell.env per command (carries sessionID) |
shell.create.before has no sessionID → use PUT /api/experimental/session/:id/environment once per session |
experimental.chat.system.transform |
session.hook("context") → event.system (or a budgeted catalog in event.tools, diffed between turns) |
tool map, un-namespaced |
tool.transform(e => e.add(...)) with a namespace |
tool.execute.after sees success only |
union on status — record failures too |
| state file for the remembered daemon |
ctx.storage |
| no way to answer MCP sampling |
ctx.generate.text — the plugin can answer mcpx's sampling questions |
$ for the CLI |
gone — and nothing is lost: since #53 (closes #44) the plugin reaches the daemon over the unix socket and spawns mcpx --json status only as rung 4, the last fallback (plugin/opencode/README.md:83-110, plugin/opencode/mcpx/daemon.ts); backend: v1 never spawns and bin: "" forbids it. In v2, drop rung 4 or keep it through node:child_process, which daemon.ts already imports |
| subdirectory to hide helpers from the loader |
unnecessary; only default is read |
Also new in v2 and worth using: mcp.transform (register a filtered server set per session), permission.hook("evaluate") (real, unlike v1's dead permission.ask), promise-based TUI select() for the daemon picker.
Also: opencode v2's MCP client sends _meta["ai.opencode/sessionID"] on tool calls (packages/core/src/mcp/client.ts:278). When opencode v2 talks to mcpx as an MCP server, mcpx should read that for session attribution and leasing — no environment injection needed at all on that path.
Depends on: #44 (closed, fixed in #53 — the binary-free core exists).
Since this was filed (checked at 05c78b2):
- Phase 2: delegated Manage cannot add members #171's guard covers a v2 port automatically.
TestThePluginReadsNoUndeclaredSetting
(internal/settings/consumed_test.go:209-236) scans every plugin/**/*.ts(x) except tests
(pluginSources, :288-320), so a v2 plugin anywhere under plugin/ must honour only variables declared in
pluginSettings() (internal/settings/plugin.go:18). Phase 2: delegated Manage cannot add members #171 also wired plugin.discoveryRetry and declared
plugin.remember/plugin.annotate; the v2 port keeps all three.
- The dead
permission.ask hook is recorded among the "declared but did nothing" incidents
(docs/declared-but-unread.md:8-12, Update Rust crate proc-macro2 to 1.0.81 - autoclosed #75's PR body); nothing in the v1 plugin is built on it
(docs/plugin-discovery.md:144-145). v2's permission.hook("evaluate") is the real one.
- The opencode-side line references above (
packages/core/src/plugin/module.ts:60-73,
packages/core/src/mcp/client.ts:278) are against opencode's v2 branch and were not re-checked in this pass.
No real choice: v1 plugins do not load in v2, so the only question is when. The table above is the design.
Ease · Impact · Related
Ease L (a rewrite against {id, setup}, not a port) · Impact med-high — nil while v1 is what runs,
total once v2 is (the v1 plugin does not load at all).
Related: #48 (the harness-free core this adapter sits on), #80 and #82 (the extension side; the same /v1
back-channel), #87 (ctx.storage replaces the remembered-daemon file; its lifetime follows #87's rule).
Security/auth deferred; see tracker. Activitydeveloping-today commented on Oct 28, 2026 dezren39 commented on Oct 28, 2026 History carried over from dezren39/darwin-nix#47 (verbatim, oldest first):
@dezren39 · 2026-09-30T07:28:39Z
Integration pass. This issue has no category tracker -- it predates the build-out and is a dependency of several parts of it. Placed in the proposed order at #181.
@dezren39 · 2026-09-30T12:12:01Z
Issues pass (2026-09-30, at 05c78b2).
@dezren39 · 2026-10-28T20:40:37Z
Triage verdict (lane A, task 2037, 2026-10-28): CONFIRMED at current HEAD — a rewrite, routed code-side; kept open under #181.
Evidence (owning repo developing-today/code @ bfcfc15; the mcpx source left dezren39/nix on 2026-10-19, #468):
pkgs/mcpx/plugin/opencode/mcpx-session.ts:737 still hooks the v1 API: "experimental.chat.system.transform": async (_input, output) => {.
pkgs/mcpx/plugin/opencode/README.md still describes v1 loading semantics (every plugin/*.ts export called as a plugin) and install by copying into ~/.config/opencode/plugin.
- No v2 shape exists in the plugin: no
{id, setup} export, no session.hook("context") — the port has not happened.
Routing: no follow-up packet from this triage. This is explicitly a rewrite, not a small_fix, and the code lives in developing-today/code; backlog re-homing is tracked by #309 (OPEN). No counterpart for #47 exists there yet, so #47 stays open under tracker #181 until the re-home lands; the v1→v2 mapping table in this issue body is the spec for whoever picks it up there.
dezren39 commented on Oct 29, 2026 dezren39 commented on Oct 29, 2026 🤖 Agent note · done — triage verdict: scope CONFIRMED (a rewrite, as the issue says); dedupe settled — #730 and #1932 are neighbours, not duplicates; core rewrite routed as queue task 3068, v2-only wins recorded as SET-REMAINDER
- Agent: queue worker (repo-worker-code), Lane C shift
- Session / ID: queue task 2746 (triage)
- Found via: queue claim
- Dedupe (explicit):
- OpenCode 2: validate .opencode config against the v2 schema and port the v1 plugins #730 is NOT a duplicate. Its workstream 2 ports the fleet's deployed copy at
.opencode/plugin/mcpx-session.ts (repo config, under the opencode migration tracker) — a different artifact from the shipped product plugin at pkgs/mcpx/plugin/opencode/ that this issue covers. Both need doing; neither subsumes the other. A cross-note is posted on OpenCode 2: validate .opencode config against the v2 schema and port the v1 plugins #730 so the two ports share one shape instead of diverging.
- mcpx: take the pool's session key from the request (
_meta["ai.opencode/sessionID"]), not the daemon's pid #1932 already owns the server-side half of this issue's "Also" paragraph (_meta["ai.opencode/sessionID"] session attribution) — excluded from the follow-up packet.
- mcpx: a harness-free plugin core, with adapters for codex, claude code, pi, manus #1861 (harness-free plugin core + adapters) is the substrate the v2 adapter sits on, not a duplicate; mcpx docs: plugin pages -- plugins, compatibility, interface and config, opencode v1 and v2, vibeMcp #1855 is the plugin docs pages.
- Scope check against current main
82b019a0 (2026-10-29, via GitHub API): the shipped plugin is still purely v1 — pkgs/mcpx/plugin/opencode/mcpx-session.ts imports { tool, type Plugin } from @opencode-ai/plugin, exports a single default, and hides helpers in the mcpx/ subdirectory precisely because the v1 loader globs plugin/*.ts (its own header comment) — the idiom this issue says v2 abolishes. No v2 tree exists. The daemon core it must reuse (mcpx/daemon.ts, ops.gen.ts) is present, and the settings guard (TestThePluginReadsNoUndeclaredSetting over plugin/**/*.ts(x)) will cover a v2 tree automatically, as the issue records. One caution carried into the packet: this issue's opencode-side line references were taken against opencode's v2 branch and never re-checked — the implementer verifies v2 API facts against the pinned v2 in docs/opencode-plugin.md (reports 2.0.3) and the migration guide, not against those refs.
- Routing — core now, wins as remainder: implementation follow-up enqueued as queue task 3068 (packet
hidden_files/packet-1858-fix.json), scoped to the core rewrite: {id, setup} shape, session-environment API, context hook, namespaced tool.transform registration, status-union tool.execute.after, ctx.storage remembered daemon, v1 plugin untouched beside it.
- SET-REMAINDER (owed after 3068 lands; enqueue then, do not file per-piece issues): the v2-only wins that sit on the core — sampling answers via
ctx.generate.text, mcp.transform filtered per-session registration, permission.hook("evaluate"), promise-based TUI select() daemon picker. All four are specified in this issue's table.
- Links: deployed-copy port OpenCode 2: validate .opencode config against the v2 schema and port the v1 plugins #730 · attribution mcpx: take the pool's session key from the request (
_meta["ai.opencode/sessionID"]), not the daemon's pid #1932 · core substrate mcpx: a harness-free plugin core, with adapters for codex, claude code, pi, manus #1861 · follow-up queue task 3068
dezren39 commented on Nov 17, 2026 agent-note:v1
state: picked-up
queue: repo-health-code-pilot
task: 18145 (triage, worker repo-worker-code, lane code-f)
by: openchamber-scheduled-lane
at: 2026-11-17T02:02:00Z
Claimed for fresh triage revalidation. #1858 and canonical tracker #2841 are open; prior remainder items now include merged PR #7847. I will verify whether item (5) remains and is already routed before recording the verdict. dezren39 commented on Nov 17, 2026 Triage verdict — task 18145 (2026-11-17)
Still live as the set tracker; keep #1858 open. Fresh GitHub checks: #1858 and canonical implementation tracker #2841 are OPEN. The v2 core and previously scoped items (1)–(4) are represented by merged PRs #2489, #3018, #5170, #4997, and #7847 (latest item (3) merge 62e12a01755576a42fc6dc640f7f2858dc246b90). No open PR for this set was found.
Current main still contains the v1 files pkgs/mcpx/plugin/opencode/mcpx-session.ts, mcpx-tui.tsx, and the mcpx/ directory alongside v2/. Therefore item (5), retiring the v1 plugin files, remains; it must stay sequenced after the picker equivalent in #7847. This is already scoped on canonical tracker #2841, whose latest notes keep item (5) as the remaining set work. No duplicate issue was created; #1858 remains open until #2841 item (5) is landed or explicitly waived.
dezren39 commented on Nov 17, 2026 agent-note:v1
state: done
queue: repo-health-code-pilot
task: 18145 (triage, worker repo-worker-code, lane code-f)
by: openchamber-scheduled-lane
at: 2026-11-17T02:05:00Z
Completed triaged: #1858 remains open as the set tracker; item (5) v1 retirement remains on canonical tracker #2841 after PR #7847 merged item (3). Queue completion created follow-on task 19610. See the triage verdict above. Sandbox bookkeeping deferred to fleet reconciliation. dezren39 commented on Nov 17, 2026
state: triaged
task: 19610 (repo-health-code-pilot, lane code-g, origin openchamber-scheduled-lane)
Bulk-intake re-triage verification, 2026-11-17. Fresh check: #1858 is OPEN. Canonical tracker #2841 is OPEN, titled "implement the #1858 SET-REMAINDER items (1)-(5)". No open PR touches the v1 plugin retirement. On main, pkgs/mcpx/plugin/opencode/ still contains mcpx-session.ts and mcpx-tui.tsx alongside v2/.
Verdict: the triage of record stands (task 18145, 2026-11-17). Item (5), retiring the v1 plugin files, is still open. It is sequenced after the picker work in #7847 and already scoped on #2841. No new follow-on packet is needed: it would duplicate #2841. Keep #1858 open as the set tracker. Completing task 19610 as triaged. dezren39 commented on Nov 24, 2026
Second pass (lane oc-code-08, task 21759): revalidated fresh — #1858 OPEN; canonical tracker #2841 OPEN; v1 files (mcpx-session.ts, mcpx-tui.tsx, mcpx/) still present alongside v2/ on main. Item (5) v1 retirement still pending, unchanged since the 2026-11-17 triages. No code touched. dezren39 commented on Nov 24, 2026
Agent note — second pass, task 21759 (lane any-n, 2026-11-24)
- Verdict: substantially resolved, no new packet routed (recorded exception). Core rewrite MERGED: PR feat(mcpx): opencode v2 plugin core — {id, setup}, namespaced tools, ctx.storage (#1858) #2489 (v2 plugin core, merged 2026-10-30) on top of merged groundwork PR docs(mcpx): verified opencode v2 plugin facts and the core-rewrite map (#1858 groundwork) #2457. Verified fresh via gh state.
- Remainder and where it lives: the five v2-only wins were split to mcpx opencode v2 plugin: implement the #1858 SET-REMAINDER items (1)-(5) #2841 (OPEN,
status/blocked queue/blocked), which carries the implementation identity per the one-fix-key-per-issue rule (mcpx: port the opencode plugin to opencode v2 (a rewrite, and several things get better) #1858 stays open as the set tracker until all five items land — closing it now would break #2841s acceptance). mcpx opencode v2 plugin: implement the #1858 SET-REMAINDER items (1)-(5) #2841 has live coverage: queued triage task 19779. A packet here would duplicate that identity or break the set accounting.
- Duplicates: none — no other actionable queue item references mcpx: port the opencode plugin to opencode v2 (a rewrite, and several things get better) #1858 (sweep 2026-11-24); neighbours OpenCode 2: validate .opencode config against the v2 schema and port the v1 plugins #730 (deployed-copy port) and mcpx: take the pool's session key from the request (
_meta["ai.opencode/sessionID"]), not the daemon's pid #1932 (daemon-side attribution) own their slices per the mcpx opencode v2 plugin: implement the #1858 SET-REMAINDER items (1)-(5) #2841 out-of-scope section.
- Tracking: Queue reprioritization programme 2026-11-24: full census, reorder, unblock #14158 (coverage reconciliation pass 2).
developing-today-fleet commented on Nov 26, 2026 Triage verdict (oc-code-01, 2026-11-26): #1858 remains open as the SET-REMAINDER tracker; do not close or create a duplicate implementation packet. Freshly verified: core and items (1)-(4) are merged, including item (3) PR #7847 (MERGED 2026-11-25). Only item (5), retirement of the v1 plugin files, remains and is already tracked by canonical issue #2841. #2841 is OPEN and blocked by its native dependency on #730, which remains OPEN (checked 2026-11-26); the existing follow-on task 19779 is blocked on that same dependency. Keep #1858 open until item (5) lands or is explicitly waived after #730 permits the migration.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|