Skip to main content

update_opencode_config

Function update_opencode_config 

Source
pub fn update_opencode_config(project_dir: &Path) -> Result<bool>
Expand description

Update an existing opencode.json/opencode.jsonc, or create a fresh opencode.json, so that sqz’s plugin and MCP server are registered. Idempotent.

If a .jsonc file exists, it is read with comment-stripping, merged, and written back WITHOUT the comments — we can’t losslessly round-trip comments through serde_json. The caller is warned via the return value’s second field so sqz init can surface the fact.

If both files exist for some reason (OpenCode merges both), the .jsonc is treated as authoritative (per find_opencode_config).

Returns (updated, comments_lost) where updated is true if any change was written to disk, and comments_lost is true if sqz had to drop comments from a .jsonc during the merge.