mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
fix: read config from file for reload and improve provider validation
- Change reloadConfig to read from opencode.json file instead of HTTP API - Add logging for OpenCode PATCH responses to aid debugging - Make providerId optional in schema with custom validation when needed - Update test to mock fs.readFile instead of fetch
This commit is contained in:
1 parent
1f55bcdfc2
commit
8cfc6c0a17
5 files changed
+24
-35
No files matched your search
@@ -384,18 +384,12 @@ class OpenCodeServerManager {
|
||||
async reloadConfig(): Promise<void> {
|
||||
logger.info('Reloading OpenCode configuration (via API)')
|
||||
try {
|
||||
const response = await fetch(`http://${OPENCODE_SERVER_HOST}:${OPENCODE_SERVER_PORT}/config`, {
|
||||
method: 'GET'
|
||||
})
|
||||
const configPath = getOpenCodeConfigFilePath()
|
||||
const fileContent = await fs.readFile(configPath, 'utf-8')
|
||||
const fileConfig = JSON.parse(fileContent) as Record<string, unknown>
|
||||
logger.info(`Read config from file for reload: ${configPath}`)
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to get current config: ${response.status}`)
|
||||
}
|
||||
|
||||
const currentConfig = await response.json() as Record<string, unknown>
|
||||
logger.info('Triggering OpenCode config reload via PATCH')
|
||||
|
||||
const patchResult = await patchOpenCodeConfig(currentConfig)
|
||||
const patchResult = await patchOpenCodeConfig(fileConfig)
|
||||
if (!patchResult.success) {
|
||||
const errorMessage = patchResult.error || 'Failed to reload config'
|
||||
const validationIssues = patchResult.details || []
|
||||
|
||||
Reference in new issue
Block a user