feat(onboard): add OpenCode Zen as model provider

This commit is contained in:
Magi Metal
2026-01-09 18:12:07 -05:00
committed by Peter Steinberger
parent 9b1f164447
commit a399fa36c8
11 changed files with 676 additions and 35 deletions

View File

@@ -0,0 +1,57 @@
import { describe, expect, it } from "vitest";
import type { ClawdbotConfig } from "../config/config.js";
import {
applyOpencodeZenModelDefault,
OPENCODE_ZEN_DEFAULT_MODEL,
} from "./opencode-zen-model-default.js";
describe("applyOpencodeZenModelDefault", () => {
it("sets opencode-zen default when model is unset", () => {
const cfg: ClawdbotConfig = { agents: { defaults: {} } };
const applied = applyOpencodeZenModelDefault(cfg);
expect(applied.changed).toBe(true);
expect(applied.next.agents?.defaults?.model).toEqual({
primary: OPENCODE_ZEN_DEFAULT_MODEL,
});
});
it("overrides existing model", () => {
const cfg = {
agents: { defaults: { model: "anthropic/claude-opus-4-5" } },
} as ClawdbotConfig;
const applied = applyOpencodeZenModelDefault(cfg);
expect(applied.changed).toBe(true);
expect(applied.next.agents?.defaults?.model).toEqual({
primary: OPENCODE_ZEN_DEFAULT_MODEL,
});
});
it("no-ops when already opencode-zen default", () => {
const cfg = {
agents: { defaults: { model: OPENCODE_ZEN_DEFAULT_MODEL } },
} as ClawdbotConfig;
const applied = applyOpencodeZenModelDefault(cfg);
expect(applied.changed).toBe(false);
expect(applied.next).toEqual(cfg);
});
it("preserves fallbacks when setting primary", () => {
const cfg: ClawdbotConfig = {
agents: {
defaults: {
model: {
primary: "anthropic/claude-opus-4-5",
fallbacks: ["google/gemini-3-pro"],
},
},
},
};
const applied = applyOpencodeZenModelDefault(cfg);
expect(applied.changed).toBe(true);
expect(applied.next.agents?.defaults?.model).toEqual({
primary: OPENCODE_ZEN_DEFAULT_MODEL,
fallbacks: ["google/gemini-3-pro"],
});
});
});