Files
oh-my-openagent/src/cli/run/model-resolver.ts
YeonGyu-Kim 0eb447113e feat(cli): add --model option to run command for model override
Add -m, --model <provider/model> option to oh-my-opencode run command.
Allows users to override the model while keeping the agent unchanged.

Changes:
- Add model?: string to RunOptions interface
- Create model-resolver.ts to parse provider/model format
- Add model-resolver.test.ts with 7 test cases (TDD)
- Add --model CLI option with help text examples
- Wire resolveRunModel in runner.ts and pass to promptAsync
- Export resolveRunModel from barrel (index.ts)

Example usage:
  bunx oh-my-opencode run --model anthropic/claude-sonnet-4 "Fix the bug"
  bunx oh-my-opencode run --agent Sisyphus --model openai/gpt-5.4 "Task"
2026-03-11 19:42:46 +09:00

30 lines
712 B
TypeScript

export function resolveRunModel(
modelString?: string
): { providerID: string; modelID: string } | undefined {
if (modelString === undefined) {
return undefined
}
const trimmed = modelString.trim()
if (trimmed.length === 0) {
throw new Error("Model string cannot be empty")
}
const parts = trimmed.split("/")
if (parts.length < 2) {
throw new Error("Model string must be in 'provider/model' format")
}
const providerID = parts[0]
if (providerID.length === 0) {
throw new Error("Provider cannot be empty")
}
const modelID = parts.slice(1).join("/")
if (modelID.length === 0) {
throw new Error("Model ID cannot be empty")
}
return { providerID, modelID }
}