fix(install): merge config instead of overwriting on opencode target
The sync path's mergeJsonConfigAtKey had incoming entries overwriting existing user entries on conflict. Reverse the spread order so user config wins, matching the install path's existing behavior. Also add merge feedback logging and a test for the sync merge path. Fixes #125 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -58,12 +58,16 @@ export async function writeOpenCodeBundle(outputRoot: string, bundle: OpenCodeBu
|
||||
const openCodePaths = resolveOpenCodePaths(outputRoot)
|
||||
await ensureDir(openCodePaths.root)
|
||||
|
||||
const hadExistingConfig = await pathExists(openCodePaths.configPath)
|
||||
const backupPath = await backupFile(openCodePaths.configPath)
|
||||
if (backupPath) {
|
||||
console.log(`Backed up existing config to ${backupPath}`)
|
||||
}
|
||||
const merged = await mergeOpenCodeConfig(openCodePaths.configPath, bundle.config)
|
||||
await writeJson(openCodePaths.configPath, merged)
|
||||
if (hadExistingConfig) {
|
||||
console.log("Merged plugin config into existing opencode.json (user settings preserved)")
|
||||
}
|
||||
|
||||
const agentsDir = openCodePaths.agentsDir
|
||||
for (const agent of bundle.agents) {
|
||||
|
||||
Reference in New Issue
Block a user