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

@@ -75,6 +75,35 @@ describe("convertClaudeToOpenCode", () => {
expect(modelCommand?.model).toBe("openai/gpt-4o")
})
test("resolves bare Claude model aliases to full IDs", () => {
const plugin: ClaudePlugin = {
root: "/tmp/plugin",
manifest: { name: "fixture", version: "1.0.0" },
agents: [
{
name: "cheap-agent",
description: "Agent using bare alias",
body: "Test agent.",
sourcePath: "/tmp/plugin/agents/cheap-agent.md",
model: "haiku",
},
],
commands: [],
skills: [],
}
const bundle = convertClaudeToOpenCode(plugin, {
agentMode: "subagent",
inferTemperature: false,
permissions: "none",
})
const agent = bundle.agents.find((a) => a.name === "cheap-agent")
expect(agent).toBeDefined()
const parsed = parseFrontmatter(agent!.content)
expect(parsed.data.model).toBe("anthropic/claude-haiku-4-5")
})
test("converts hooks into plugin file", async () => {
const plugin = await loadClaudePlugin(fixtureRoot)
const bundle = convertClaudeToOpenCode(plugin, {