Skip to content

Fix opencode.json overwrite on install/convert#208

Closed
marcindyguda wants to merge 1 commit intoEveryInc:mainfrom
marcindyguda:fix/opencode-config-merge
Closed

Fix opencode.json overwrite on install/convert#208
marcindyguda wants to merge 1 commit intoEveryInc:mainfrom
marcindyguda:fix/opencode-config-merge

Conversation

@marcindyguda
Copy link

@marcindyguda marcindyguda commented Feb 24, 2026

Summary

Fixes #125

After rebasing on main, the core merge logic for writeOpenCodeBundle() was already implemented upstream (ADR-002). This PR contributes the remaining improvements:

  • Extract readJsonSafe() into shared src/utils/files.ts so both sync/opencode.ts and targets/opencode.ts can reuse it (DRY)
  • Remove the duplicate local readJsonSafe() from src/sync/opencode.ts
  • Improve merge test assertions: verify existing MCP servers and commands are preserved alongside new plugin entries
  • Fix test data to use command: ["uvx", "plugin-srv"] arrays matching the OpenCodeMcpServer type (not separate command/args fields)

Test plan

  • All 8 opencode-writer.test.ts tests pass
  • Manual test: create opencode.json with custom keys, run install, verify custom keys are preserved

🤖 Generated with Claude Code

writeOpenCodeBundle() now merges into existing opencode.json instead of
overwriting it, preserving user config (mcp servers, commands, permissions,
tools). Extracted readJsonSafe() into shared utils so both sync and target
paths reuse the same helper.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@marcindyguda marcindyguda force-pushed the fix/opencode-config-merge branch from 5dc0a8f to 75c6ed1 Compare February 24, 2026 20:15
@marcindyguda
Copy link
Author

I can see it is already solved in #201

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.

Installing to opencode overwrites opencode.json file

1 participant