mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-19 00:03:13 +03:00
fix(core): rename legacy provider in top-level model (#51901)
This commit is contained in:
committed by
GitHub
Unverified
parent
54956aac22
commit
d113a40f55
@@ -10,6 +10,7 @@ import { ConfigCompaction } from "@opencode/schema/config/compaction"
|
||||
import { ConfigFormatter } from "@opencode/schema/config/formatter"
|
||||
import { ConfigLSP } from "@opencode/schema/config/lsp"
|
||||
import { ConfigMedia } from "@opencode/schema/config/media"
|
||||
import { ConfigModel } from "@opencode/schema/config/model"
|
||||
import { ConfigMCP } from "@opencode/schema/config/mcp"
|
||||
import { ConfigPlugin } from "@opencode/schema/config/plugin"
|
||||
import { ConfigPolicy } from "@opencode/schema/config/policy"
|
||||
@@ -196,10 +197,14 @@ export function normalize(input: unknown): Result {
|
||||
normalizeFormatter(input, encoded, diagnostics)
|
||||
normalizeLsp(input, encoded, diagnostics)
|
||||
|
||||
const model = own(input, "model")
|
||||
? decodeValue(ConfigModel.Selection, input.model, ["model"], diagnostics)
|
||||
: undefined
|
||||
if (model) encoded.model = { ...model, providerID: ConfigMigrateV1.providerID(model.providerID) }
|
||||
|
||||
const nativeAtomic = {
|
||||
$schema: Info.fields.$schema,
|
||||
shell: Info.fields.shell,
|
||||
model: Info.fields.model,
|
||||
default_agent: Info.fields.default_agent,
|
||||
share: Info.fields.share,
|
||||
enterprise: Info.fields.enterprise,
|
||||
|
||||
@@ -160,7 +160,7 @@ function migrateGoogleVertexAnthropicProvider(info: ConfigProviderV1.Info) {
|
||||
}
|
||||
}
|
||||
|
||||
// Rename these only while migrating unambiguous V1 fields.
|
||||
// Renames retired provider IDs in V1 fields and the shared top-level model.
|
||||
export function providerID(input: string) {
|
||||
if (input === "azure-cognitive-services") return "azure"
|
||||
if (input === "google-vertex-anthropic") return "google-vertex"
|
||||
|
||||
@@ -737,8 +737,7 @@ describe("Config", () => {
|
||||
},
|
||||
})
|
||||
|
||||
// The top-level model decodes as a native V2 field, so it does not receive the legacy provider rename.
|
||||
expect(migrated.model).toEqual({ providerID: "azure-cognitive-services", model: "deployment" })
|
||||
expect(migrated.model).toEqual({ providerID: "azure", model: "deployment" })
|
||||
expect(migrated.agents?.reviewer?.model).toEqual({ providerID: "google-vertex", model: "claude-sonnet" })
|
||||
expect(migrated.commands?.review?.model).toEqual({ providerID: "azure", model: "deployment" })
|
||||
expect(migrated.experimental?.policies).toEqual([
|
||||
|
||||
@@ -149,6 +149,21 @@ describe("ConfigNormalize", () => {
|
||||
expect(() => Schema.decodeUnknownSync(Info)(result.encoded)).not.toThrow()
|
||||
})
|
||||
|
||||
test("renames legacy provider IDs in the top-level model", () => {
|
||||
expect(normalized({ model: "google-vertex-anthropic/claude#high" }).encoded.model).toEqual({
|
||||
providerID: "google-vertex",
|
||||
model: "claude",
|
||||
variant: "high",
|
||||
})
|
||||
expect(
|
||||
normalized({ model: { providerID: "azure-cognitive-services", model: "deployment" } }).encoded.model,
|
||||
).toEqual({ providerID: "azure", model: "deployment" })
|
||||
expect(normalized({ model: "anthropic/claude" }).encoded.model).toEqual({
|
||||
providerID: "anthropic",
|
||||
model: "claude",
|
||||
})
|
||||
})
|
||||
|
||||
test("migrates the legacy small model to the title agent", () => {
|
||||
const result = normalized({ small_model: "anthropic/claude-haiku-4-5" })
|
||||
expect(result.encoded.agents).toEqual({
|
||||
|
||||
Reference in New Issue
Block a user