[PR #864] [MERGED] fix(setup): register OpenCode V2 configurations in mcp.servers #2301

Closed
opened 2026-10-16 21:16:59 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/864
Author: @kaoru0822-kitauji
Created: 10/7/2026
Status: ✅ Merged
Merged: 10/7/2026
Merged by: @kaoru0822-kitauji

Base: main ← Head: fix/opencode-v2-servers


📝 Commits (1)

  • 69d8afe fix(setup): register OpenCode V2 configurations in mcp.servers

📊 Changes

8 files changed (+386 additions, -93 deletions)

View changed files

📝 docs/installation.md (+5 -0)
📝 src/application/ClientConfigurationDocument.test.ts (+13 -3)
📝 src/application/ClientConfigurationDocument.ts (+120 -18)
📝 src/application/ClientRegistrationStatus.ts (+8 -3)
📝 src/application/SetupClientConfiguration.ts (+50 -49)
📝 src/application/Uninstall.ts (+33 -17)
📝 src/application/UpdateMaintenance.ts (+6 -3)
📝 tests/boundary/filesystem/clientConfigurationDialects.test.ts (+151 -0)

📄 Description

Summary

Refs #816 (OpenCode V2 compatibility).

OpenCode V2 places servers under mcp.servers.<name> and uses disabled in place of V1's enabled. Per the migration guide, V2 still loads V1 mcp.<name> entries, and a native V2 entry for the same name takes precedence. mcp.timeout is a V2 setting, not a server.

REA always read and wrote mcp.<name>. That works for V1 files, but it breaks once a configuration is V2-native, for example after "Migrate my OpenCode configuration…" moves REA's entry to mcp.servers.rea. On main:

Operation Result on main with mcp.servers.rea present
rea doctor / registration status reports REA as missing
rea setup writes a V1 mcp.rea that OpenCode ignores in favor of the stale native entry, so the old command and environment stay in effect
rea uninstall "REA registration is absent", so OpenCode keeps launching REA

Fix

  • parseClientConfiguration recognizes a V2-native OpenCode document. An mcp.servers object without a type member is the V2 table; a V1 server named servers has a type. The parser reports the server table's key path, the entry dialect (opencode_v2), and the V1 members beside it (excluding the servers/timeout settings).
  • Setup writes the native entry { "type": "local", "command": [...], "environment"? } to mcp.servers.rea and removes REA's own legacy mcp.rea, which would otherwise conflict. JSONC comments and sibling settings are preserved through path-scoped jsonc-parser edits. Plain V1 documents keep the V1 entry, since both V1 and V2 load it.
  • Status / update maintenance read the entry OpenCode actually loads: native first, then V1.
  • Uninstall removes REA-owned entries from both locations. Ownership checks are unchanged, and foreign rea entries are retained.
  • docs/installation.md gets a short note on this behavior.

No MCP schema change.

Verification

  • New boundary regressions in tests/boundary/filesystem/clientConfigurationDialects.test.ts:

    • V2 document with comments, timeout, a sibling server, and REA's V1 entry: setup moves REA into mcp.servers in native shape, a second run is unchanged, status is aligned, and uninstall leaves only the sibling;
    • entry migrated by OpenCode with a stale rea-agents@3.2.0 command: status reports it, setup updates it, and uninstall removes it;
    • V1 entry beside an empty mcp.servers: status reports it and uninstall removes it;
    • V1 server literally named servers: stays V1.

    2 fail on main and pass here. The other two already behaved correctly on main and guard against regressions.

  • All setup/uninstall/status/update/doctor suites passed: 12 files / 214 tests (clientConfigurationTransactions, clientLifecycle, setupConfig, clientConfigurationBom, clientRegistrationStatus, updateMaintenance, ClientConfigurationDocument, Doctor, …).

  • npm run check:changed, npm run check:fast, and npm run docs:check passed.

OpenCode V2 itself was not run here (not installed); the behavior follows its published V2 MCP and migration docs. No Hopper/Ghidra/IDA verification is needed.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/864 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/7/2026 **Status:** ✅ Merged **Merged:** 10/7/2026 **Merged by:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Base:** `main` ← **Head:** `fix/opencode-v2-servers` --- ### 📝 Commits (1) - [`69d8afe`](https://github.com/morluto/rea/commit/69d8afefc19e014a4bba7a182983a9e77e100a75) fix(setup): register OpenCode V2 configurations in mcp.servers ### 📊 Changes **8 files changed** (+386 additions, -93 deletions) <details> <summary>View changed files</summary> 📝 `docs/installation.md` (+5 -0) 📝 `src/application/ClientConfigurationDocument.test.ts` (+13 -3) 📝 `src/application/ClientConfigurationDocument.ts` (+120 -18) 📝 `src/application/ClientRegistrationStatus.ts` (+8 -3) 📝 `src/application/SetupClientConfiguration.ts` (+50 -49) 📝 `src/application/Uninstall.ts` (+33 -17) 📝 `src/application/UpdateMaintenance.ts` (+6 -3) 📝 `tests/boundary/filesystem/clientConfigurationDialects.test.ts` (+151 -0) </details> ### 📄 Description ## Summary Refs #816 (OpenCode V2 compatibility). [OpenCode V2](https://opencode.ai/v2/docs/mcp-servers/) places servers under `mcp.servers.<name>` and uses `disabled` in place of V1's `enabled`. Per the [migration guide](https://opencode.ai/v2/docs/migrate-v1/), V2 still loads V1 `mcp.<name>` entries, and a native V2 entry for the same name takes precedence. `mcp.timeout` is a V2 setting, not a server. REA always read and wrote `mcp.<name>`. That works for V1 files, but it breaks once a configuration is V2-native, for example after "Migrate my OpenCode configuration…" moves REA's entry to `mcp.servers.rea`. On `main`: | Operation | Result on `main` with `mcp.servers.rea` present | |---|---| | `rea doctor` / registration status | reports REA as **missing** | | `rea setup` | writes a V1 `mcp.rea` that OpenCode **ignores** in favor of the stale native entry, so the old command and environment stay in effect | | `rea uninstall` | "REA registration is absent", so OpenCode **keeps launching REA** | ## Fix - `parseClientConfiguration` recognizes a V2-native OpenCode document. An `mcp.servers` object without a `type` member is the V2 table; a V1 *server* named `servers` has a `type`. The parser reports the server table's key path, the entry `dialect` (`opencode_v2`), and the V1 members beside it (excluding the `servers`/`timeout` settings). - **Setup** writes the native entry `{ "type": "local", "command": [...], "environment"? }` to `mcp.servers.rea` and removes REA's own legacy `mcp.rea`, which would otherwise conflict. JSONC comments and sibling settings are preserved through path-scoped `jsonc-parser` edits. Plain V1 documents keep the V1 entry, since both V1 and V2 load it. - **Status / update maintenance** read the entry OpenCode actually loads: native first, then V1. - **Uninstall** removes REA-owned entries from both locations. Ownership checks are unchanged, and foreign `rea` entries are retained. - `docs/installation.md` gets a short note on this behavior. No MCP schema change. ## Verification - New boundary regressions in `tests/boundary/filesystem/clientConfigurationDialects.test.ts`: - V2 document with comments, `timeout`, a sibling server, and REA's V1 entry: setup moves REA into `mcp.servers` in native shape, a second run is `unchanged`, status is `aligned`, and uninstall leaves only the sibling; - entry migrated by OpenCode with a stale `rea-agents@3.2.0` command: status reports it, setup updates it, and uninstall removes it; - V1 entry beside an empty `mcp.servers`: status reports it and uninstall removes it; - V1 server literally named `servers`: stays V1. **2 fail on `main` and pass here.** The other two already behaved correctly on `main` and guard against regressions. - All setup/uninstall/status/update/doctor suites passed: 12 files / 214 tests (`clientConfigurationTransactions`, `clientLifecycle`, `setupConfig`, `clientConfigurationBom`, `clientRegistrationStatus`, `updateMaintenance`, `ClientConfigurationDocument`, `Doctor`, …). - `npm run check:changed`, `npm run check:fast`, and `npm run docs:check` passed. OpenCode V2 itself was not run here (not installed); the behavior follows its published V2 MCP and migration docs. No Hopper/Ghidra/IDA verification is needed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-16 21:16:59 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#2301
No description provided.