map Claude Code model strings to OpenCode format when importing agents

This commit is contained in:
Jeon Suyeol
2026-03-06 11:56:03 +09:00
parent ee3d88af9d
commit 77a2ab7bdf
4 changed files with 101 additions and 0 deletions
@@ -5,6 +5,7 @@ import { parseFrontmatter } from "../../shared/frontmatter"
import { isMarkdownFile } from "../../shared/file-utils"
import { getClaudeConfigDir } from "../../shared"
import type { AgentScope, AgentFrontmatter, LoadedAgent } from "./types"
import { mapClaudeModelToOpenCode } from "./claude-model-mapper"
function parseToolsConfig(toolsStr?: string): Record<string, boolean> | undefined {
if (!toolsStr) return undefined
@@ -42,10 +43,13 @@ function loadAgentsFromDir(agentsDir: string, scope: AgentScope): LoadedAgent[]
const formattedDescription = `(${scope}) ${originalDescription}`
const mappedModel = mapClaudeModelToOpenCode(data.model)
const config: AgentConfig = {
description: formattedDescription,
mode: "subagent",
prompt: body.trim(),
...(mappedModel && { model: mappedModel }),
}
const toolsConfig = parseToolsConfig(data.tools)