feat: add models.dev schema ref for model autocomplete in opencode.json#12528
Merged
rekram1-node merged 2 commits intoanomalyco:devfrom Feb 6, 2026
Merged
feat: add models.dev schema ref for model autocomplete in opencode.json#12528rekram1-node merged 2 commits intoanomalyco:devfrom
rekram1-node merged 2 commits intoanomalyco:devfrom
Conversation
…ef URLs The previous PR (anomalyco#12112) added `.meta({ $ref: 'https://models.dev/...' })` to model fields for editor autocomplete, but `@standard-community/standard-openapi` has a bug in `convertToOpenAPISchema` where it converts external $ref URLs into local `#/components/schemas/{lastSegment}` references. For `https://models.dev/model-schema.json#/$defs/Model`, this extracted just 'Model' and created `#/components/schemas/Model` - colliding with the existing runtime Model object schema. This caused config model fields (which should be strings like 'anthropic/claude-4') to be typed as the full Model object in the generated SDK. The patch strips external $ref URLs (containing '://') and preserves the remaining schema properties (like `type: 'string'`) instead of converting them to broken local references. Verified: SDK generation + typecheck pass, all model fields correctly typed as string.
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Contributor
|
The following comment was made by an LLM, it may be inaccurate: No duplicate PRs found |
…ma-ref # Conflicts: # bun.lock # package.json
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates OpenCode’s configuration JSON Schema generation to reference the external models.dev schema for model fields, enabling editor autocomplete for valid model IDs while ensuring OpenAPI generation doesn’t break on external $refs.
Changes:
- Introduces a shared
ModelIdZod schema annotated with an external$reftohttps://models.dev/model-schema.json#/$defs/Model. - Switches config fields (
model,small_model,agent.*.model,command.*.model) to useModelId. - Adds a Bun patch for
@standard-community/standard-openapi@0.2.9to handle external$refduring OpenAPI conversion.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| patches/@standard-community%2Fstandard-openapi@0.2.9.patch | Patches standard-openapi’s JSON Schema → OpenAPI conversion logic for schemas containing $ref. |
| packages/opencode/src/config/config.ts | Introduces ModelId and applies it to relevant config model fields. |
| package.json | Registers the new patched dependency for Bun. |
| bun.lock | Records the patched dependency in the lockfile. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
kyashrathore
pushed a commit
to kyashrathore/Claxedo
that referenced
this pull request
Feb 7, 2026
kyashrathore
pushed a commit
to kyashrathore/Claxedo
that referenced
this pull request
Feb 8, 2026
fanjia1024
pushed a commit
to fanjia1024/opencode
that referenced
this pull request
Feb 10, 2026
BryceRyan
pushed a commit
to BryceRyan/opencode
that referenced
this pull request
Feb 10, 2026
avion23
pushed a commit
to avion23/opencode
that referenced
this pull request
Feb 13, 2026
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds external $ref to model fields in opencode.json schema, enabling editors to provide autocomplete for all available models from https://models.dev/model-schema.json.
Affected fields:
model(root level)small_model(root level)agent.*.modelcommand.*.modelIncludes a patch for
@standard-community/standard-openapi@0.2.9which has a bug where external$refURLs (likehttps://models.dev/model-schema.json#/$defs/Model) get incorrectly converted to local#/components/schemas/Modelrefs, colliding with existing schemas. Upstream fix: standard-community/standard-openapi#11, related issue: standard-community/standard-openapi#8Related: anomalyco/models.dev#767