Skip to content

fix(connect): recognize OpenCode's opencode.jsonc global config - #923

Merged
github-actions[bot] merged 3 commits into
mainfrom
fix/922-opencode-jsonc
Jul 28, 2026
Merged

github-actions[bot] merged 3 commits into
mainfrom
fix/922-opencode-jsonc

Conversation

@Dumbris

@Dumbris Dumbris commented Jul 28, 2026

Copy link
Copy Markdown
Member

Related #922

Fresh OpenCode installs (≥ ~1.18) bootstrap ~/.config/opencode/opencode.jsonc, but mcpproxy only recognized opencode.json — so OpenCode showed as not installed and mcpproxy connect opencode refused.

What

  • Path resolution: a Service-level resolver targets whichever candidate exists, preferring opencode.jsonc (OpenCode loads it after .json, so it shadows the same keys — writing a new .json next to an existing .jsonc would be silently shadowed later). Static ConfigPath keeps the .json default for the create-new case. Wired through connect, disconnect, status (GetStatus/GetAllStatus), access classification, preview, undo, and doctor's denial probe.
  • JSONC parsing: unmarshalLenientJSON strips // and /* */ comments (string-aware) before the existing trailing-comma cleanup, so commented files still parse for detection/status.
  • Safe writes: connect/disconnect refuse to rewrite a .jsonc that actually uses comments (mcpproxy re-serializes plain JSON, which would strip them) with a manual-edit hint. OpenCode's comment-free bootstrap stub rewrites safely — the primary broken case now just works.
  • Better refusal: with no OpenCode config at all, the error names both probed files and the directory.
  • docs/setup.md OpenCode section updated.

Testing

  • 8 new tests: candidate resolution (4 layouts), string-aware JSONC parsing, .jsonc-only connect→status→disconnect round-trip (asserts the entry lands inside the .jsonc, $schema preserved, no stray opencode.json created), commented-file refusal leaves the file byte-identical, GetAllStatus detection, both-candidate error message.
  • go test -race on connect + httpapi green; golangci-lint v2 (CI config) 0 issues; ./scripts/test-api-e2e.sh all passed.

Related #922

Recent OpenCode versions bootstrap ~/.config/opencode/opencode.jsonc, so a
fresh install was reported as not installed and 'mcpproxy connect opencode'
refused with a missing opencode.json.

## Changes
- Service-level configPath resolver: opencode targets whichever candidate
  exists, preferring .jsonc (OpenCode loads it after .json, so it shadows the
  same keys); static ConfigPath default (.json) kept for the create-new case.
  Wired through Connect/Disconnect/GetStatus/GetAllStatus/entryAccess/
  preview/undo/DetectAppDataDenial.
- unmarshalLenientJSON now strips // and /* */ comments (string-aware) before
  the trailing-comma cleanup, so commented .jsonc files parse for detection.
- Comment guard: connect/disconnect refuse to rewrite a .jsonc that actually
  uses comments (re-serializing would strip them) with a manual-edit hint;
  OpenCode's comment-free bootstrap stub rewrites safely.
- Missing-config refusal now names both probed files and the directory.
- docs/setup.md OpenCode section updated.

## Testing
- 8 new tests (path resolution, JSONC parsing, .jsonc-only connect/disconnect
  round-trip incl. no stray .json created, commented-file refusal, status
  detection, both-candidates error)
- go test -race ./internal/connect ./internal/httpapi green
- golangci-lint v2 (.github config) 0 issues; scripts/test-api-e2e.sh all pass
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 28, 2026 •

Copy link
Copy Markdown

Deploying mcpproxy-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0a96a50
Status: ✅  Deploy successful!
Preview URL: https://0fde72fb.mcpproxy-docs.pages.dev
Branch Preview URL: https://fix-922-opencode-jsonc.mcpproxy-docs.pages.dev

View logs

Dumbris added 2 commits July 28, 2026 19:40
Related #922

- Unterminated /* block comments now fail parsing instead of silently
  blanking to EOF (malformed .jsonc no longer reports accessible)
- Disconnect retries the other existing opencode candidate when the resolved
  file lacks the entry (connect-to-.json / later .jsonc bootstrap drift)
- Undo accepts backups of either opencode candidate and restores to the file
  the backup came from, not the freshly resolved one (allowlist stays
  registry-derived; traversal-proof construction unchanged)
- Tests: unterminated block, escaped quotes, EOF line comment, commented
  disconnect refusal leaves no backup, cross-candidate disconnect, post-drift
  undo restores .json and leaves .jsonc untouched
…nect (Codex round 2 N1)

Related #922

A malformed/unreadable alternate candidate now surfaces its error instead of
being masked by the resolved file's not_found.
@github-actions

github-actions Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

📦 Build Artifacts

Workflow Run: View Run
Branch: fix/922-opencode-jsonc

Available Artifacts

  • archive-darwin-amd64 (28 MB)
  • archive-darwin-arm64 (25 MB)
  • archive-linux-amd64 (16 MB)
  • archive-linux-arm64 (15 MB)
  • archive-windows-amd64 (28 MB)
  • archive-windows-arm64 (25 MB)
  • frontend-dist-pr (0 MB)
  • installer-dmg-darwin-amd64 (22 MB)
  • installer-dmg-darwin-arm64 (20 MB)

How to Download

Option 1: GitHub Web UI (easiest)

  1. Go to the workflow run page linked above
  2. Scroll to the bottom "Artifacts" section
  3. Click on the artifact you want to download

Option 2: GitHub CLI

gh run download 30379345177 --repo smart-mcp-proxy/mcpproxy-go

Note: Artifacts expire in 14 days.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved (Model B): issue #922 fix — Codex review approved after 2 fix rounds, 15 targeted tests incl. candidate-drift scenarios, go test -race + golangci-lint v2 + test-api-e2e.sh green, qa-gate success at this head SHA.

@github-actions
github-actions Bot enabled auto-merge (squash) July 28, 2026 16:43
@github-actions
github-actions Bot merged commit 6692231 into main Jul 28, 2026
37 of 38 checks passed
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 86.72566% with 15 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/connect/connect.go 88.46% 4 Missing and 5 partials ⚠️
internal/connect/clients.go 73.68% 4 Missing and 1 partial ⚠️
internal/connect/undo.go 92.85% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

Dumbris added a commit that referenced this pull request Aug 3, 2026
…e, note channel

Adversarial review (panel + opencode cross-model) found four genuine
defects:

- opencodeConfigCandidates joined an empty homeDir into CWD-relative
  paths. Every production Service is built without a homeDir (NewService),
  so the #923 jsonc preference — and the new checked_paths — silently
  degraded to stats against the working directory. Empty now resolves via
  os.UserHomeDir, like ConfigPath.
- A permission-blocked aggregate row (access_state=denied, no remediation)
  fell through to the looked-for note, claiming files were checked when
  the stat was forbidden. The gate now allows only absent/unknown/nil.
- The looked-for hint rendered in the orange warning channel on every
  not-installed row; it is informational and now renders secondary
  (ClientRow.noteIsWarning), and the row accessibility label includes the
  note so VoiceOver announces it.
- The home-abbreviation branch had zero coverage (fixtures used /Users/x);
  new tests exercise real-home tilde abbreviation and the denied gate.
github-actions Bot pushed a commit that referenced this pull request Aug 3, 2026
…#949)

* fix(connect): name the checked config paths on "No config found" rows

A user whose ~/.config/opencode/opencode.jsonc exists saw only "No config
found" in the Connect Client form and could not tell which file mcpproxy
had looked for (their core predated the #923 jsonc fix). Make the verdict
explicit instead of a mystery:

- ClientStatus gains additive checked_paths: every config location the
  existence check consults, highest precedence first (both opencode.jsonc
  and opencode.json for OpenCode; the single config_path elsewhere).
- The macOS form renders it as a "Looked for ... in ..." note on
  supported, unconnected rows without a config, home-abbreviated. An
  explicit core note or denied-remediation still outranks it, and a core
  older than the app falls back to naming config_path.

* fix(connect): review round 1 — production home resolution, denied gate, note channel

Adversarial review (panel + opencode cross-model) found four genuine
defects:

- opencodeConfigCandidates joined an empty homeDir into CWD-relative
  paths. Every production Service is built without a homeDir (NewService),
  so the #923 jsonc preference — and the new checked_paths — silently
  degraded to stats against the working directory. Empty now resolves via
  os.UserHomeDir, like ConfigPath.
- A permission-blocked aggregate row (access_state=denied, no remediation)
  fell through to the looked-for note, claiming files were checked when
  the stat was forbidden. The gate now allows only absent/unknown/nil.
- The looked-for hint rendered in the orange warning channel on every
  not-installed row; it is informational and now renders secondary
  (ClientRow.noteIsWarning), and the row accessibility label includes the
  note so VoiceOver announces it.
- The home-abbreviation branch had zero coverage (fixtures used /Users/x);
  new tests exercise real-home tilde abbreviation and the denied gate.
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.

2 participants