Skip to content

fix(opencode): drop $comment field — schema rejects unknown root keys - #109

Merged
jphein merged 1 commit into
mainfrom
fix/opencode-drop-comment-key
May 22, 2026
Merged

fix(opencode): drop $comment field — schema rejects unknown root keys#109
jphein merged 1 commit into
mainfrom
fix/opencode-drop-comment-key

Conversation

@jphein

@jphein jphein commented May 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

In commit `47018e5` (PR #108) I added a `$comment` field to `.opencode/opencode.json` explaining why the repo-level MCP entry defaults to `enabled: false`. opencode rejects unknown top-level keys via its schema validator and refuses to start the TUI:

```
Error: 4 of 5 requests failed: Unexpected server error.
Affected startup requests: config.providers, provider.list, app.agents, config.get
```

JSON parses (`$comment` is a popular convention, JSON-Schema recognizes it), but opencode's strict schema doesn't allow it. Removing the field unblocks opencode startup. Explanation lives in the commit message + PR descriptions if needed later.

Test plan

  • `opencode --help` returns its banner instead of the ConfigInvalidError stack trace
  • User-level wrapper at `~/.config/opencode/opencode.jsonc` continues to handle the daemon-routed MCP entry
  • Repo-level entry stays `enabled: false` so daemon-routed users don't spawn a second local MCP server

🤖 Generated with Claude Code

…ot fields

The $comment field I added in commit 47018e5 to explain why the
repo-level MCP entry defaults to enabled=false isn't part of
opencode's config schema. Opencode's bootstrap validator throws
ConfigInvalidError and refuses to start the TUI entirely:

  Error: 4 of 5 requests failed: Unexpected server error.
  Affected startup requests: config.providers, provider.list,
  app.agents, config.get

JSON parses fine, but opencode rejects unknown top-level keys.
Move the explanation to a code comment if needed; for now just
remove the field so opencode starts.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 22, 2026 03:49
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a configuration issue where the inclusion of a $comment field in the repository's opencode configuration caused the application to fail during startup. Because the opencode schema validator strictly rejects unknown top-level keys, removing this field ensures the configuration is valid and allows the TUI to initialize correctly.

Highlights

  • Schema Validation Fix: Removed the unsupported $comment field from .opencode/opencode.json to resolve startup errors caused by strict schema validation.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request removes the $comment field from .opencode/opencode.json to resolve a startup failure caused by schema validation. The reviewer suggests renaming the file to .opencode/opencode.jsonc to preserve the documentation using standard JSONC comments while maintaining compatibility with the schema validator.

Comment thread .opencode/opencode.json
@@ -1,6 +1,5 @@
{
"$schema": "https://opencode.ai/config.json",
"$comment": "Repo-level MCP entry disabled by default to avoid spawning a second mempalace-mcp against the legacy local palace when a user-level (daemon-routed) entry is also configured. Contributors without a daemon can flip enabled=true; their python with mempalace installed will be picked up from .venv/bin/python.",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Removing this field fixes the startup failure but loses important documentation for contributors. Since the PR description mentions that opencode.jsonc is supported for user-level configuration, consider renaming this file to .opencode/opencode.jsonc and using standard JSONC comments (//) instead of the $comment key. This would preserve the explanation while satisfying the strict schema validator.

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 encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@jphein
jphein merged commit 637bb01 into main May 22, 2026
10 of 11 checks passed
@jphein
jphein deleted the fix/opencode-drop-comment-key branch May 22, 2026 03:52
jphein added a commit that referenced this pull request May 22, 2026
…merges (#112)

Five PRs landed today that didn't have YAML entries yet; CLAUDE.md +
README still referenced the pre-transfer jphein/mempalace ownership;
the opencode integration recipe didn't cover the two gotchas that
bit us tonight (npm-vs-opencode-cache patch target; the "looks like
an error" stderr lines from local-palace spawns).

YAML additions (newest first):
  - local-palace-retired-marker (#111798cf14)
  - opencode-repo-config-empty-mcp (#1107133eee)
  - opencode-repo-mcp-drop-comment-key (#109637bb01)
  - opencode-repo-mcp-disable-flag (#10847018e5; superseded by #110)
  - mcp-stub-resources-prompts-list (#1076ca0670)

CLAUDE.md changes:
  - Fork URL: `jphein/mempalace` → `techempower-org/mempalace`
  - Origin/upstream line reflects the May 2026 transfer
  - Palace data section: local palace is retired; production lives in
    postgres on disks.jphe.in
  - Python venv: `./venv/` → `./.venv/` (uv convention)
  - Issue tracker links updated to techempower-org

README.md changes:
  - Quickstart and `Open upstream PRs` table use techempower-org URLs

docs/integrations/opencode.md changes:
  - New "Patch target gotcha" subsection: opencode caches plugins under
    ~/.cache/opencode/packages/ independently of the global npm install;
    patches must apply there.
  - New "What 'looks like an error' but isn't" verification subsection
    listing the three stderr lines that surfaced today during debug.
  - New "If you see a different palace count" troubleshooting block:
    palace-count divergence between MCP and CLI usually means an old
    shell without PALACE_DAEMON_URL; on this fork the local palace is
    retired so the CLI now refuses with the marker text.

FORK_CHANGELOG.md regenerated via scripts/render-docs.py. check-docs.sh
clean (29 fork hash refs resolve; only existing MemPalace#1024 pr_state warning,
unchanged).

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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