Fix bare Claude model alias resolution in OpenCode converter

normalizeModel() turned bare aliases like 'haiku' into 'anthropic/haiku',
which is not a valid OpenCode model ID. This caused
ProviderModelNotFoundError when agents using model: haiku (e.g.
learnings-researcher, lint) were invoked during workflows like /plan.

Add CLAUDE_FAMILY_ALIASES map to resolve haiku, sonnet, and opus to their
full model IDs (e.g. anthropic/claude-haiku-4-5). A console.warn alerts
during conversion so the map can be updated when new versions release.
This commit is contained in:
Walt Beaman
2026-02-12 20:56:58 -06:00
parent 87e98b24d3
commit 4132af155a
2 changed files with 45 additions and 0 deletions

View File

@@ -250,8 +250,24 @@ function rewriteClaudePaths(body: string): string {
.replace(/\.claude\//g, ".opencode/")
}
// Bare Claude family aliases used in Claude Code (e.g. `model: haiku`).
// Update these when new model generations are released.
const CLAUDE_FAMILY_ALIASES: Record<string, string> = {
haiku: "claude-haiku-4-5",
sonnet: "claude-sonnet-4-5",
opus: "claude-opus-4-6",
}
function normalizeModel(model: string): string {
if (model.includes("/")) return model
if (CLAUDE_FAMILY_ALIASES[model]) {
const resolved = `anthropic/${CLAUDE_FAMILY_ALIASES[model]}`
console.warn(
`Warning: bare model alias "${model}" mapped to "${resolved}". ` +
`Update CLAUDE_FAMILY_ALIASES if a newer version is available.`,
)
return resolved
}
if (/^claude-/.test(model)) return `anthropic/${model}`
if (/^(gpt-|o1-|o3-)/.test(model)) return `openai/${model}`
if (/^gemini-/.test(model)) return `google/${model}`