Skip to content

Navigation Menu

Sign in
Sign up

zg install --target opencode fails on JSONC configs (comments in opencode.json) #97

Open

Description

Describe the bug

zg install --target opencode throws Invalid JSON when the existing
~/.config/opencode/opencode.json contains // comments (JSONC).

To reproduce

  1. Create ~/.config/opencode/opencode.json with a comment (opencode
    officially supports JSONC; configs it manages commonly carry comments):

    {
     // "model": "some-model", // e.g. a commented-out model line
     "mcp": {}
    }
  2. Run zg install --target opencode --yes

Actual result

Error: Invalid JSON in /home/<user>/.config/opencode/opencode.json.
Cause: Expected double-quoted property name in JSON at position ...

Expected result

zg merges its managed zvec_grep MCP entry into the existing config while
preserving the user's comments and unrelated keys.

Root cause (from source)

src/cli/install.tsparseJsonObject() uses strict JSON.parse. The file
already imports parse from jsonc-parser, but it is only used on the Qoder
path (parseJsoncSettings); the OpenCode (and other mcpServers container)
paths parse with plain JSON.parse.

Suggested fix

Parse agent config files with jsonc-parser everywhere. If the managed entry
is written back with JSON.stringify, also keep the comments — e.g. use a
comment-preserving editor (jsonc-parser's modify/applyEdits or similar) so
the user's commented-out settings survive the install. Uninstall
(uninstallJsonMcpServer) has the same read problem and should be covered
too.

Environment

  • zvec-grep: 0.2.1
  • Node: v24
  • OS: Linux

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      AltStyle によって変換されたページ (->オリジナル) /