-
Notifications
You must be signed in to change notification settings - Fork 166
zg install --target opencode writes opencode.json even when the active config is opencode.jsonc #103
Description
Environment
- zg 0.2.1, Linux, Node 24
- OpenCode v2 with the config at
~/.config/opencode/opencode.jsonc(JSONC, with comments) OPENCODE_CONFIGnot set
What happened
zg install --target opencode wrote a managed zvec_grep MCP entry into ~/.config/opencode/opencode.json. OpenCode reads our opencode.jsonc, so the installer created a shadow file that the agent never loads -- the integration silently does nothing until the entry is added to the .jsonc manually.
Repro
- Have
~/.config/opencode/opencode.jsoncas your active OpenCode config (noopencode.jsonpresent). - Run
zg install --target opencode --yes. ~/.config/opencode/opencode.jsonis created with the managed entry; the agent still has no zvec-grep tool.
Expected
The installer should detect an existing opencode.jsonc (or an OPENCODE_CONFIG pointing at one) and write the managed entry there, preserving JSONC comments and unrelated settings the way the Qwen/Qoder paths already do. If both exist, prefer the one OpenCode actually loads and say so in the output.
Workaround we use
Hand-adding the flat entry to opencode.jsonc: "zvec_grep": { "type": "local"|"remote", ... , "enabled": true }. Everything else about the integration (agent toolset, guidance, server) works great once the entry lands in the real config -- thanks for a genuinely useful tool.
Suggested fix
In the opencode target resolution, stat opencode.jsonc before defaulting to opencode.json, and route managed-block writes through a JSONC-preserving editor (the Qwen settings.json path already preserves comments, so the machinery seems to exist).