Add opencode connect adapter, single-source the onboarding picker#883
Conversation
…ADAPTERS The onboarding agent picker and the connect interactive menu maintained two separate hardcoded lists that had drifted: onboarding offered opencode/goose/kilo/aider/claude-desktop/windsurf/roo (which connect had no adapter for, so picking them hit 'no adapter available, skipped'), while connect had antigravity/kiro/warp/continue/zed/droid/qwen that onboarding never offered. Add a real opencode adapter writing OpenCode's documented mcp schema (top-level mcp key, command as array, type/enabled), and make onboarding's buildAgentOptions derive from connect's ADAPTERS so the two can never diverge again. Connect-only adapters now appear in onboarding; opencode is now wireable; phantom agents with no adapter no longer appear. Fixes #872.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughAdds an OpenCode MCP connect adapter (detect/install with backup/dry-run), registers it in ADAPTERS, refactors onboarding to derive agent options from ADAPTERS, and extends tests and docs to include the new ChangesOpenCode Connect Adapter
Sequence DiagramsequenceDiagram
participant CLI as agentmemory CLI
participant Adapter as OpenCode Adapter
participant FS as Filesystem
participant Config as opencode.json
CLI->>Adapter: detect()
Adapter->>FS: check config directory exists
FS-->>Adapter: exists? boolean
Adapter-->>CLI: boolean result
CLI->>Adapter: install(opts)
Adapter->>FS: read opencode.json (if exists)
FS-->>Config: existing config or {}
Adapter->>Adapter: entryMatches(`@agentmemory/mcp`)
alt entry already exists and not force
Adapter-->>CLI: already-wired
else write required
Adapter->>FS: create backup (if exists)
Adapter->>FS: ensure parent directories
Adapter->>FS: atomic write mcp.agentmemory entry
Adapter->>FS: read back and verify entry
FS-->>Adapter: verification result
alt verification succeeded
Adapter-->>CLI: installed (include backupPath)
else verification failed
Adapter-->>CLI: skipped
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/cli/onboarding.ts (1)
87-87: 💤 Low valueRemove WHAT comment; let the code structure speak.
This comment explains what the code does rather than why. As per coding guidelines, WHAT comments should be replaced with clear code structure.
♻️ Suggested refactor to remove the comment
- // Native plugins first, then MCP-only, each keeping ADAPTERS order. return [ ...options.filter((o) => o.hint === "native plugin"), ...options.filter((o) => o.hint === "MCP server"), ];The two-group filtering pattern is self-documenting: native plugins are filtered first, then MCP servers.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/cli/onboarding.ts` at line 87, Remove the redundant "Native plugins first, then MCP-only, each keeping ADAPTERS order." comment and rely on the existing code structure and naming (the two-group filtering logic that processes native plugins then MCP-only plugins and the ADAPTERS ordering) to be self-explanatory; simply delete that single-line WHAT comment in onboarding.ts near the filtering/grouping logic so the code reads without explanatory WHAT commentary.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/cli/connect/opencode.ts`:
- Around line 57-59: The current construction of mcp spreads next["mcp"] without
verifying it's an object, which can break if next["mcp"] is a non-object; add a
runtime type guard before spreading by checking that next["mcp"] is a plain
object (e.g., typeof next["mcp"] === "object" && next["mcp"] !== null &&
!Array.isArray(next["mcp"])), and only then cast/spread it into const mcp:
Record<string, McpEntry> = { ...(next["mcp"] as Record<string, McpEntry>) };
otherwise use an empty object fallback so mcp is always a safe Record<string,
McpEntry>.
- Around line 27-31: Replace the shell-style expansions inside the environment
object with OpenCode's supported {env:VAR} form: change AGENTMEMORY_URL,
AGENTMEMORY_SECRET, and AGENTMEMORY_TOOLS values to "{env:AGENTMEMORY_URL}",
"{env:AGENTMEMORY_SECRET}", and "{env:AGENTMEMORY_TOOLS}" respectively in the
environment object in opencode.ts; because OpenCode will yield an empty string
when a var is unset, also ensure the code that reads these (or the place that
builds this config) applies the intended defaults (use "http://localhost:3111"
for AGENTMEMORY_URL and "all" for AGENTMEMORY_TOOLS, and empty string or secure
handling for AGENTMEMORY_SECRET) so consumers get the fallback values when env
vars are not provided.
---
Nitpick comments:
In `@src/cli/onboarding.ts`:
- Line 87: Remove the redundant "Native plugins first, then MCP-only, each
keeping ADAPTERS order." comment and rely on the existing code structure and
naming (the two-group filtering logic that processes native plugins then
MCP-only plugins and the ADAPTERS ordering) to be self-explanatory; simply
delete that single-line WHAT comment in onboarding.ts near the
filtering/grouping logic so the code reads without explanatory WHAT commentary.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: add5028b-22a4-421b-9758-fc2b7b4186b6
📒 Files selected for processing (4)
src/cli/connect/index.tssrc/cli/connect/opencode.tssrc/cli/onboarding.tstest/cli-connect.test.ts
…nv block
Guard the mcp spread against a non-object value in an existing opencode.json, and remove the environment block whose shell-style ${VAR:-default} values OpenCode does not expand (writing them literally would clobber a user's real shell AGENTMEMORY_URL). The stdio child inherits the shell env and the shim defaults unset vars. Also drop a redundant inline comment in onboarding.
Adding the opencode adapter changed ADAPTERS (17 -> 18); regenerate the auto-derived agents table so npm run skills:check passes in CI.
|
Docs PR opened: https://github.com/mintlify-community/docs-agentmemory-abc2951c/pull/1 Documented the new OpenCode connect adapter on the Connect Agents and Other MCP Agents pages, including its non-standard config schema. |
|
Thanks! I see that you've added lines for opencode in particular. But I wonder if the root cause remains for some of the other 18 adapters (only 7 are listed in the NATIVE_ADAPTERS list) |
Fixes #872.
Problem
Two hardcoded agent lists had drifted:
src/cli/onboarding.tsofferedopencode, goose, kilo, aider, claude-desktop, windsurf, roo— butconnecthad no adapter for any of them, so onboarding's wire step hitresolveAdapter(name) -> null("no adapter available, skipped"). Phantom offerings.connect'sADAPTERShadantigravity, kiro, warp, continue, zed, droid, qwenthat the onboarding picker never showed.Fix
src/cli/connect/opencode.ts): OpenCode's MCP config is not the standardmcpServersshape, it's a top-levelmcpkey withcommandas an array plustype/enabled(documented in the README). A dedicated adapter writes that schema to~/.config/opencode/opencode.jsonwith the same safety as the generic adapter (preserve existing servers, backup, dry-run, already-wired, post-write verify). Registered inADAPTERS(now 18).onboarding.buildAgentOptions()now derives fromconnect'sADAPTERS(single source of truth) instead of its own arrays. Glyph + native/MCP grouping stay as a local cosmetic lookup with a neutral default. The picker can no longer drift from whatconnectcan wire.Effect
opencodeis now wireable and appears in both pickers.Tests
test/cli-connect.test.ts.ADAPTERS.lengthassertions (17 -> 18).npm run build+ full suite (1412) pass.README's OpenCode row can be updated to mention
agentmemory connect opencodein a follow-up; kept this PR scoped to the bug.Summary by CodeRabbit
New Features
User Experience
Tests
Documentation