feat: configure opencode dsflash-go provider

Refs #2268
This commit is contained in:
UniDesk Codex
2026-06-30 06:17:40 +08:00
parent c1665a0318
commit 2f1d34b36a
4 changed files with 166 additions and 18 deletions
+19
View File
@@ -691,6 +691,7 @@ test("v03 render includes D518 secret-plane smoke on D518 gitops root", async ()
const generatedPaths = generatedFiles.map((filePath) => path.relative(outDir, filePath));
assert.ok(generatedPaths.includes("runtime-v03/kustomization.yaml"));
assert.ok(generatedPaths.includes("runtime-v03/workloads.yaml"));
assert.ok(generatedPaths.includes("runtime-v03/opencode.yaml"));
assert.equal(generatedPaths.includes("runtime-v03/external-secrets.yaml"), true);
const kustomization = await readFile(path.join(outDir, "runtime-v03", "kustomization.yaml"), "utf8");
assert.match(kustomization, /external-secrets\.yaml/u);
@@ -716,6 +717,24 @@ test("v03 render includes D518 secret-plane smoke on D518 gitops root", async ()
.filter((entry) => entry.name === "HWLAB_CODE_AGENT_AGENTRUN_PROVIDER_ID");
assert.ok(agentRunNodeEnv.length > 0, "expected D518 node id to be inferred from gitops root");
assert.deepEqual([...new Set(agentRunNodeEnv.map((entry) => entry.value))], ["D518"]);
const opencode = JSON.parse(await readFile(path.join(outDir, "runtime-v03", "opencode.yaml"), "utf8"));
const opencodeDeployment = (opencode.items ?? []).find((item) => item.kind === "Deployment" && item.metadata?.name === "opencode-server");
assert.ok(opencodeDeployment, "expected opencode-server deployment");
assert.equal(opencodeDeployment.metadata?.annotations?.["hwlab.pikastech.local/opencode-provider-profile"], "dsflash-go");
assert.equal(opencodeDeployment.metadata?.annotations?.["hwlab.pikastech.local/agentrun-provider-secret-ref"], "agentrun-v02/agentrun-v01-provider-dsflash-go");
assert.equal(opencodeDeployment.metadata?.annotations?.["hwlab.pikastech.local/values-printed"], "false");
assert.match(opencodeDeployment.spec?.template?.metadata?.annotations?.["hwlab.pikastech.local/opencode-config-sha256"] ?? "", /^[a-f0-9]{64}$/u);
const opencodeContainer = collectContainersFromItem(opencodeDeployment).find((container) => container.name === "opencode-server");
const opencodeEnvEntries = new Map((opencodeContainer?.env ?? []).map((entry) => [entry.name, entry]));
assert.deepEqual(opencodeEnvEntries.get("OPENCODE_DSFLASH_GO_API_KEY")?.valueFrom?.secretKeyRef, { name: "hwlab-v03-code-agent-provider", key: "opencode-api-key", optional: true });
const opencodeConfig = JSON.parse(opencodeEnvEntries.get("OPENCODE_CONFIG_CONTENT")?.value ?? "{}");
assert.equal(opencodeConfig.model, "dsflash-go/deepseek-v4-flash");
assert.equal(opencodeConfig.small_model, "dsflash-go/deepseek-v4-flash");
assert.equal(opencodeConfig.provider["dsflash-go"].npm, "@ai-sdk/openai-compatible");
assert.equal(opencodeConfig.provider["dsflash-go"].options.baseURL, "https://opencode.ai/zen/go/v1");
assert.equal(opencodeConfig.provider["dsflash-go"].options.apiKey, "{env:OPENCODE_DSFLASH_GO_API_KEY}");
assert.deepEqual(opencodeConfig.provider["dsflash-go"].models["deepseek-v4-flash"].limit, { context: 1000000, output: 384000 });
} finally {
await rm(outDir, { recursive: true, force: true });
await rm(scratchDir, { recursive: true, force: true });