Skip to content

Commit 9ef319f

Browse files
authored
feat: add models.dev schema ref for model autocomplete in opencode.json (#12112)
1 parent 64e2bf8 commit 9ef319f

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

packages/opencode/src/config/config.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ import { iife } from "@/util/iife"
3535
export namespace Config {
3636
const log = Log.create({ service: "config" })
3737

38+
const ModelRef = { $ref: "https://models.dev/model-schema.json#/$defs/Model" }
39+
3840
// Managed settings directory for enterprise deployments (highest priority, admin-controlled)
3941
// These settings override all user and project settings
4042
function getManagedConfigDir(): string {
@@ -660,7 +662,7 @@ export namespace Config {
660662
template: z.string(),
661663
description: z.string().optional(),
662664
agent: z.string().optional(),
663-
model: z.string().optional(),
665+
model: z.string().optional().meta(ModelRef),
664666
subtask: z.boolean().optional(),
665667
})
666668
export type Command = z.infer<typeof Command>
@@ -672,7 +674,7 @@ export namespace Config {
672674

673675
export const Agent = z
674676
.object({
675-
model: z.string().optional(),
677+
model: z.string().optional().meta(ModelRef),
676678
variant: z
677679
.string()
678680
.optional()
@@ -1043,11 +1045,16 @@ export namespace Config {
10431045
.array(z.string())
10441046
.optional()
10451047
.describe("When set, ONLY these providers will be enabled. All other providers will be ignored"),
1046-
model: z.string().describe("Model to use in the format of provider/model, eg anthropic/claude-2").optional(),
1048+
model: z
1049+
.string()
1050+
.describe("Model to use in the format of provider/model, eg anthropic/claude-2")
1051+
.optional()
1052+
.meta(ModelRef),
10471053
small_model: z
10481054
.string()
10491055
.describe("Small model to use for tasks like title generation in the format of provider/model")
1050-
.optional(),
1056+
.optional()
1057+
.meta(ModelRef),
10511058
default_agent: z
10521059
.string()
10531060
.optional()

0 commit comments

Comments
 (0)