edaa95fec0
Move three pure helpers from src/shared/ into @oh-my-opencode/model-core so the package can stand alone without depending on plugin internals:
- buildModelCapabilitiesSnapshotFromModelsDev + fetchModelCapabilitiesSnapshot (models.dev normalization)
- parseModelSuggestion (cross-provider ProviderModelNotFoundError suggestion extraction)
- resolveActualContextLimit (Anthropic GA 1M context override)
Split provider-model-id-transform into two variants exposed by model-core:
- transformModelForProvider keeps the runtime dash to dot Anthropic rewrite used by the SDK
- transformModelForProviderDisplay preserves hyphenated Anthropic IDs so the installer writes registry-compatible model strings, fixing the ProviderModelNotFoundError fresh installs hit when the dotted form leaks into the config
src/shared/* and src/cli/provider-model-id-transform.ts collapse to re-export shims that point at the new core modules. Stale src/shared/{known-variants,model-capability-aliases,model-capability-guardrails,model-capability-heuristics}.ts re-export files plus the duplicated context-limit-resolver test are removed in favor of the canonical model-core copies.
Tests: bun test packages/model-core src/shared/model-capabilities-cache.test.ts src/cli/provider-model-id-transform.test.ts
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
import { describe, expect, test } from "bun:test"
|
|
|
|
import {
|
|
transformModelForProvider,
|
|
transformModelForProviderDisplay,
|
|
} from "./provider-model-id-transform"
|
|
|
|
describe("provider model ID transforms", () => {
|
|
test("keeps separate Anthropic API and display behavior", () => {
|
|
// #given an Anthropic model ID in config-display form
|
|
const provider = "anthropic"
|
|
const model = "claude-opus-4-7"
|
|
|
|
// #when both model-core transform variants are called
|
|
const apiResult = transformModelForProvider(provider, model)
|
|
const displayResult = transformModelForProviderDisplay(provider, model)
|
|
|
|
// #then API calls use dotted Anthropic versions while display keeps hyphens
|
|
expect(apiResult).toBe("claude-opus-4.7")
|
|
expect(displayResult).toBe("claude-opus-4-7")
|
|
})
|
|
|
|
test("produces identical results for non-Anthropic providers", () => {
|
|
// #given non-Anthropic provider/model pairs
|
|
const scenarios = [
|
|
{ provider: "openai", model: "gpt-4o" },
|
|
{ provider: "google", model: "gemini-2.5-pro" },
|
|
{ provider: "github-copilot", model: "gemini-3-flash" },
|
|
{ provider: "vercel", model: "claude-opus-4-7" },
|
|
] as const
|
|
|
|
for (const scenario of scenarios) {
|
|
// #when both transform variants are called
|
|
const apiResult = transformModelForProvider(
|
|
scenario.provider,
|
|
scenario.model,
|
|
)
|
|
const displayResult = transformModelForProviderDisplay(
|
|
scenario.provider,
|
|
scenario.model,
|
|
)
|
|
|
|
// #then the variants match outside the direct Anthropic provider branch
|
|
expect(displayResult).toBe(apiResult)
|
|
}
|
|
})
|
|
})
|