Repository navigation
fix(schema): publish config schema that accepts V1 and V2 shapes - #55524
Conversation
There was a problem hiding this comment.
This looks sound. I checked it with ajv against the base's static config.json and against the schema generated from this branch. The base rejects V2 configs, including the reproductions from the linked reports (permissions, skills: [], update, mcp.servers, agents, providers). With this PR they validate, V1 and mixed configs still validate, and unknown keys are still rejected. bun test and typecheck in packages/schema pass.
Public API: only the published config schema at opencode.ai/config.json and docs.opencode.ai/config.json changes.
- Added: the V2 top-level keys (
permissions,policies,agents,commands,plugins,providers,update,snapshots,warming,worktree, ...), and V2 sub-shapes such asmcp.serversandmcp.timeout. - Modified: V1-only keys (
permission,agent,provider,autoupdate, ...) are still accepted but markeddeprecated.skillsaccepts either the array or the V1{ paths, urls }object. The root is now a flat object schema instead of a top-level$ref. - Removed: nothing.
This is backwards compatible: existing V1 configs keep validating.
No blocking concerns.
Fixes #53398
Fixes #50724
Fixes #48812
Fixes #43748
Fixes #41014
Fixes #46248
Related: #53744, #52177
9acd900 to
6715ed5
Compare
|
When will this take effect? |
|
it is deployed rn |
|
Nice! I checked this morning and it wasn't working. Looks good now though. Thank you |
Summary
https://opencode.ai/config.jsonis the$schemaused by everyopencode.json(c), and both V1 and V2 read that file. Today it's a static V1 file that was frozen intopackages/console/app/publicwhenpackages/opencodewas removed fromdev. As a result, editors flag valid V2 configs as errors:permissions,agents,providers,mcp.servers,skills: [],update,warming, and others.This PR builds the file during the deploy, so it now matches how V2 parses config:
Config.Infoin@opencode/schema/config.packages/schema/script/config-v1.json, moved here and refreshed from today'sv1branch; only theautoupdatedescription changed). Fields only V1 understands are markeddeprecated. This matchesConfigNormalize, which accepts V1 and V2 fields mixed in one file.mcplegacy server entries,compaction.reserved,experimental.mcp_timeout, ...).skillschanged type, so it accepts either shape.$ref.allowCommentsandallowTrailingCommasstay.Deployment
vite buildand writes.output/public/config.json. This is the console's build script before5caf1f9f6f, now pointed at the new generator. Thedevandproductiondeploys serve it atopencode.ai/config.json. Thev1branch only deploysapp.opencode.ai, so it never touched this file.packages/webbuild hook (docs.opencode.ai/config.json) now runs the generator instead of copying the static file.Config.Info, so future V2 config changes need no manual step.Other changes
optionallose their annotations on the encoded side.Known gaps (follow-ups)
optional. Where V1 had a matching field, its description is used instead.serversortimeoutvalidates against the V2 shape.Validation
Done locally; no test is added to the PR. The deploy builds fail loudly if the generator throws.
bun run buildinpackages/console/appandpackages/webboth emitconfig.json, byte-identical to the generator output.opencode.jsonexamples in the V1 (all locales) and V2 docs, plus 680 random V1-valid configs from a fuzzer. Nothing the live schema accepts is rejected.Config.Info, encoded, all accepted. The samples cover every top-level key.ConfigNormalize. The only disagreements are the known gaps above, plus unknown keys, which the schema rejects and the runtime ignores.anyOf;Config.Infofrom a Class to a Struct still generates identical output.bun run checkpasses.Issues
Fixes #53398
Fixes #50724
Fixes #48812
Fixes #43748
Fixes #41014
Fixes #46248
Related: #53744, #52177