mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
fix: apply CodeRabbit auto-fixes
This commit is contained in:
1 parent
3e6ebbd1dc
commit
8d92f86142
10 files changed
+262
-28
No files matched your search
@@ -233,6 +233,6 @@ async function applyUpdate(
|
||||
if (error instanceof SyntaxError) {
|
||||
return c.json({ error: 'Invalid config data', details: error.message }, 400)
|
||||
}
|
||||
return c.json({ error: 'Failed to update OpenCode config' }, 500)
|
||||
return toClientReadErrorResponse(c, error, 'Failed to update OpenCode config')
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
withOpenCodeConfigLock,
|
||||
} from './opencode-config-file'
|
||||
import { readManagedOpenCodeConfig } from './opencode-config-effective'
|
||||
import { restoreOpenCodeConfigReferences } from './opencode-config-references'
|
||||
import { patchNamesOpenCodeConfigEntities, restoreOpenCodeConfigReferences } from './opencode-config-references'
|
||||
import { opencodeServerManager } from './opencode-single-server'
|
||||
import { reloadOpenCodeConfig } from './opencode-restart'
|
||||
import type { OpenCodeClient } from './opencode/client'
|
||||
@@ -106,13 +106,9 @@ async function keepOpenCodeConfigReferences(
|
||||
snapshot: OpenCodeConfigSnapshot,
|
||||
openCodeClient: OpenCodeClient,
|
||||
): Promise<Record<string, unknown>> {
|
||||
try {
|
||||
const resolved = await readManagedOpenCodeConfig(openCodeClient.api, snapshot.sources)
|
||||
return restoreOpenCodeConfigReferences(patch, resolved as Record<string, unknown>, snapshot.content)
|
||||
} catch (error) {
|
||||
logger.warn('Could not read the resolved OpenCode config; saving the patch without reference restoration:', error)
|
||||
return patch
|
||||
}
|
||||
if (!patchNamesOpenCodeConfigEntities(patch)) return patch
|
||||
const resolved = await readManagedOpenCodeConfig(openCodeClient.api, snapshot.sources)
|
||||
return restoreOpenCodeConfigReferences(patch, resolved as Record<string, unknown>, snapshot.content)
|
||||
}
|
||||
|
||||
export async function applyOpenCodeConfigUpdate(
|
||||
|
||||
@@ -136,6 +136,11 @@ function setValueAtPath(target: Record<string, unknown>, path: readonly string[]
|
||||
}
|
||||
}
|
||||
|
||||
/** Whether a merge patch names an agent, command, provider or MCP server, the only places references are restored. */
|
||||
export function patchNamesOpenCodeConfigEntities(patch: Record<string, unknown>): boolean {
|
||||
return V1_ENTITY_PATHS.some((mapping) => mapping.named && isRecord(readConfigValueAtPath(patch, mapping.v2Path)))
|
||||
}
|
||||
|
||||
/**
|
||||
* Keeps `{env:…}` and `{file:…}` references in a merge patch of named config entities.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user