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:
Chris Scott committed 2026-04-13 21:44:39 -04:00
1 parent 1f55bcdfc2
commit 8cfc6c0a17
5 files changed
+24 -35

No files matched your search

@@ -86,7 +86,7 @@ function jsonObjectField(label: string) {
}
const modelFormSchema = z.object({
providerId: z.string().min(1, 'Provider is required'),
providerId: z.string(),
modelId: z.string().min(1, 'Model ID is required').regex(/^[a-zA-Z0-9._-]+$/, 'Must use only letters, numbers, dots, hyphens, and underscores'),
backingModelId: z.string(),
providerModelProviderId: z.string(),
@@ -124,6 +124,10 @@ const modelFormSchema = z.object({
if (data.newProviderType === 'npm' && !data.newProviderNpm?.trim()) {
ctx.addIssue({ code: z.ZodIssueCode.custom, message: 'NPM package is required for npm providers', path: ['newProviderNpm'] })
}
} else {
if (!data.providerId?.trim()) {
ctx.addIssue({ code: z.ZodIssueCode.custom, message: 'Provider is required', path: ['providerId'] })
}
}
for (const [field, label] of [