fix: polish opencode-zen onboarding (#623) (thanks @magimetal)

This commit is contained in:
Peter Steinberger
2026-01-10 01:07:56 +01:00
parent 05bd100f7a
commit c69c4caa33
9 changed files with 166 additions and 5 deletions

View File

@@ -9,6 +9,8 @@ import {
applyAuthProfileConfig,
applyMinimaxApiConfig,
applyMinimaxApiProviderConfig,
applyOpencodeZenConfig,
applyOpencodeZenProviderConfig,
writeOAuthCredentials,
} from "./onboard-auth.js";
@@ -250,3 +252,61 @@ describe("applyMinimaxApiProviderConfig", () => {
);
});
});
describe("applyOpencodeZenProviderConfig", () => {
it("adds opencode-zen provider with correct settings", () => {
const cfg = applyOpencodeZenProviderConfig({});
expect(cfg.models?.providers?.["opencode-zen"]).toMatchObject({
baseUrl: "https://opencode.ai/zen/v1",
apiKey: "opencode-zen",
api: "openai-completions",
});
expect(
cfg.models?.providers?.["opencode-zen"]?.models.length,
).toBeGreaterThan(0);
});
it("adds allowlist entries for fallback models", () => {
const cfg = applyOpencodeZenProviderConfig({});
const models = cfg.agents?.defaults?.models ?? {};
expect(Object.keys(models)).toContain("opencode-zen/claude-opus-4-5");
expect(Object.keys(models)).toContain("opencode-zen/gpt-5.2");
});
it("preserves existing alias for the default model", () => {
const cfg = applyOpencodeZenProviderConfig({
agents: {
defaults: {
models: {
"opencode-zen/claude-opus-4-5": { alias: "My Opus" },
},
},
},
});
expect(
cfg.agents?.defaults?.models?.["opencode-zen/claude-opus-4-5"]?.alias,
).toBe("My Opus");
});
});
describe("applyOpencodeZenConfig", () => {
it("sets correct primary model", () => {
const cfg = applyOpencodeZenConfig({});
expect(cfg.agents?.defaults?.model?.primary).toBe(
"opencode-zen/claude-opus-4-5",
);
});
it("preserves existing model fallbacks", () => {
const cfg = applyOpencodeZenConfig({
agents: {
defaults: {
model: { fallbacks: ["anthropic/claude-opus-4-5"] },
},
},
});
expect(cfg.agents?.defaults?.model?.fallbacks).toEqual([
"anthropic/claude-opus-4-5",
]);
});
});