Skip to content

loom install --client opencode writes OpenCode's MCP entry - #986

Open
rahulsjha wants to merge 11 commits into
ClickHouse:mainfrom
rahulsjha:feat/install-client-opencode
Open

rahulsjha wants to merge 11 commits into
ClickHouse:mainfrom
rahulsjha:feat/install-client-opencode

Conversation

@rahulsjha

@rahulsjha rahulsjha commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Closes: #722

Changelog category (leave one):

  • New Feature

Changelog entry

loom install --client opencode merges Loom's MCP entry into OpenCode's global configuration. The dashboard also offers an OpenCode configuration snippet.

Why

OpenCode users need the client's remote-server shape and configuration-file lookup rules. The installer selects an existing JSON or JSONC file and keeps its other settings and comments.

Scope and risk

OpenCode joins the coding-client and toolset lists. Its entry contains type: "remote", a complete MCP URL and an Authorization header under mcp.servers. It leaves OAuth at the client's default. The Python client configuration and dashboard fixture use the same shape.

The shared JSONC editor accepts a tuple of section keys through upsert_nested_key; both Zed and OpenCode callers use it. It inserts missing objects, preserves comments and trailing commas, and leaves an already-equal entry byte for byte. Invalid or ambiguous objects refuse the merge, leave the file unchanged and print the entry for manual placement. Dry-run output redacts the token.

OpenCode's global directory follows OPENCODE_CONFIG_DIR, then XDG_CONFIG_HOME/opencode, then ~/.config/opencode, including Windows. Within that directory, lookup checks opencode.json, opencode.jsonc, .opencode/opencode.json and .opencode/opencode.jsonc in that order. When none exists, the installer creates the first. Automatic client detection uses the same resolved location.

Compatibility, rollout and rollback

The configuration targets the OpenCode 2.x mcp.servers layout. The documented OpenCode 1.x package uses a different layout and does not read this entry. The official tagged 2.3.0 configuration writer and root-resolution source were inspected for the format, lookup order and omitted OAuth key; this is source-contract evidence, not a live connectivity result.

There is no server operation or storage-schema change. Existing Zed configurations keep their single-section layout through the shared editor. Reverting removes the install option; an already-written client configuration remains until its owner changes it.

The forward composition preserves the integration table's DSPy entry and adds OpenCode to the client row. The OpenCode qualification row records configuration checked with connectivity unverified, and the connection-status footnote preserves the contradictory background-server observation without counting it as a pass. Contributor commits remain ancestors of this update.

Tests

On f62224dae1, the seven directly related OpenCode fake-unit cases pass (79 unrelated cases deselected, 2.20 seconds). These cover file creation, nested merging, existing settings, JSONC preservation, refusal, path lookup and client detection. The one conflict-resolution Markdown file passes pinned Prettier; whitespace checks pass. The subsequent qualification correction changes only documentation; product and test sources remain byte-identical to that checked commit. No broad local suite was run.

The cancellation fixture waits for real child readiness and closed output streams before cancelling. A delayed-spawn control reproduces the original missing-PID assumption without changing the production job timeout, cancellation assertion or same-PID reap assertion. Historical focused controls show one delayed-spawn failure before this fixture repair and two passing cases after it; the original host delay cause remains unknown. Cleanup always awaits the job, including a failure before readiness, so the original exception is collected.

Main includes the isolated erasure-fixture lease-table repair from #1076. This feature uses that exact fixture and changes no erasure setup or assertions. Its standalone fixture regression stays preserved in #1077.

The changed cancellation-fixture bytes pass Ruff and formatting checks. Two local focused execution attempts were refused by admission before test launch; neither is a test pass. Fresh complete GitHub CI and independent whole-head reviews must qualify this composition. The previous head's Cell acceptance check failed; its cause is not established here and this composition is not claimed as its fix. No failed job was rerun unchanged.

Historical contributor-reported checks include 141 Python client/install/token/snapshot tests, 267 documentation/public-copy tests and frontend tests/build. They are retained in the earlier PR record and are not new validation of this composition.

The contributor also reported comparing generated configuration with OpenCode 2.3.0's own command. Its connection-status run reused a background OpenCode server across configuration homes and showed contradictory results, including a connected report for a rejected token. That run does not establish isolated configuration loading, authentication or end-to-end connectivity. No native client, server, provider or model call was run during this continuation.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): the contributor prepared the implementation; Codex composed published main, checked the configuration contract and ran the focused fake-unit cases.

Checklist

  • Full current-head format, lint, typecheck, unit, integration and required acceptance checks pass in GitHub CI.
  • Current-head frontend tests and build pass in GitHub CI.
  • Existing generated client fixtures and CLI snapshots are included.
  • Documentation names the supported client layout and connectivity limits.
  • Commits are signed off. Existing contributor history contains unsigned commits; their sign-offs remain unresolved.

OpenCode 2.x reads its servers from mcp.servers in ~/.config/opencode/opencode.json
(or opencode.jsonc). loom install merges a remote entry with the bearer header and
oauth: false there, keeping the file's comments and trailing commas, and the token
dialog offers OpenCode too. The JSONC editor now places a key under a nested path.

Signed-off-by: Rahul <132360698+rahulsjha@users.noreply.github.com>
No oauth: false. A run with OpenCode 2.3.0 showed no difference with or without it, and
the entry now matches opencode mcp add --url … --header … key for key.

Signed-off-by: Rahul <132360698+rahulsjha@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 19, 2026 17:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@zlareb1 zlareb1 self-assigned this Nov 19, 2026

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blocking findings. Checked nested configuration writes, JSONC preservation, client detection, token setup and dashboard parity against the documented V2 configuration. All 141 focused client, installer, token and CLI snapshot tests pass.

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JSONC editor retains a compatibility entry point with only a unit-test caller. Remove it and exercise the nested editor directly in that test.

Comment thread server/cli/jsonc_edit.py Resolved
The installer calls upsert_nested_key directly. The one test that still used
the wrapper now calls upsert_nested_key with a one-section path, and the nested
editor's docstring carries the contract on its own.

Signed-off-by: Rahul <132360698+rahulsjha@users.noreply.github.com>

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The unused JSONC wrapper is removed, and its rejection test calls the nested editor directly. No further blocking findings after checking configuration paths, nested writes, token setup and dashboard parity. All 141 focused installer, client, token and CLI snapshot tests pass.

@zlareb1

zlareb1 commented Nov 20, 2026

Copy link
Copy Markdown
Member

check CI failures

@vercel

vercel Bot commented Nov 20, 2026

Copy link
Copy Markdown

@rahulsjha is attempting to deploy a commit to the ClickHouse Team on Vercel.

A member of the Team first needs to authorize it.

@rahulsjha

Copy link
Copy Markdown
Contributor Author

Thanks @zlareb1. The failing job is ci / pytest unit part 2: its log stops at 26% with no failed test, so the job was cut off rather than a test failing. The rest of CI passed. I've merged the latest main into the branch so CI reruns on a current base.

@zlareb1

zlareb1 commented Nov 20, 2026

Copy link
Copy Markdown
Member

The earlier unit part 2 failure also reproduces on its CI merge base and clean main when the tracing exporter starts a worker after fork. Repair #1046 gives the witness an isolated interpreter and preserves the process-proof assertions. The new head still carries the affected test.

@zlareb1

zlareb1 commented Nov 20, 2026

Copy link
Copy Markdown
Member

This head conflicts with main in docs/features/integrations/index.md. GitHub reports mergeable: CONFLICTING, and git merge-tree --write-tree origin/main e3e96d574bf07665830acf6e14bac325c34910e6 confirms that file. Please resolve the conflict so CI can validate the combined changes.

@vercel

vercel Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
loom-docs Ready Ready Preview Nov 20, 2026 11:04pm UTC

Request Review

Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Fenced memory inserts require a lease table in the selected schema. Give each fixture database its own Keeper root while preserving the replicated content checks.

Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blocking findings. Checked nested JSONC edits, configuration lookup, token setup, dashboard parity, the isolated erasure fixture and cancellation-test cleanup. All 203 focused installer, token, CLI snapshot, fixture and sandbox tests pass; one platform-specific test skips on this host.

The fixture repair is on main. Its standalone regression remains in ClickHouse#1077; the feature diff retains its original tests.

Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blocking source findings. Checked configuration lookup, nested JSONC writes, token setup, dashboard parity and cancellation cleanup against the current base. All 200 focused installer, client, token, CLI snapshot and sandbox tests pass; one platform-specific test skips. Hosted parser-cost failures remain a merge gate.

This branch has not been deployed

No deployments
Sign up for free to 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.

loom install --client opencode writes OpenCode's MCP entry

3 participants