feat(ai): add OpenCode CLI provider
This commit is contained in:
1 parent
f711855ddf
commit
309e3aef5e
36 files changed
+1197
-30
No files matched your search
@@ -94,6 +94,30 @@ describe("useAiModelCatalog", () => {
|
||||
expect(apiMock.aiResolveModelEffort).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it("tracks OpenCode executable and environment changes without depending on environment key order", async () => {
|
||||
const initial: AiConfigItem = {
|
||||
...config(),
|
||||
provider: "opencode-cli",
|
||||
endpoint: "",
|
||||
apiKey: "",
|
||||
model: "default",
|
||||
opencodeCliPath: "/opt/homebrew/bin/opencode",
|
||||
opencodeCliEnv: { HTTPS_PROXY: "http://127.0.0.1:7890", NO_PROXY: "localhost" },
|
||||
};
|
||||
apiMock.aiListModels.mockResolvedValueOnce([{ id: "first" }]).mockResolvedValueOnce([{ id: "second" }]);
|
||||
|
||||
await expect(catalog.loadModels(initial)).resolves.toEqual([{ id: "first" }]);
|
||||
await expect(
|
||||
catalog.loadModels({
|
||||
...initial,
|
||||
opencodeCliEnv: { NO_PROXY: "localhost", HTTPS_PROXY: "http://127.0.0.1:7890" },
|
||||
}),
|
||||
).resolves.toEqual([{ id: "first" }]);
|
||||
await expect(catalog.loadModels({ ...initial, opencodeCliPath: "/usr/local/bin/opencode" })).resolves.toEqual([{ id: "second" }]);
|
||||
|
||||
expect(apiMock.aiListModels).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it("does not let a stale request overwrite a newer provider catalog", async () => {
|
||||
let resolveInitial: ((models: { id: string }[]) => void) | undefined;
|
||||
apiMock.aiListModels
|
||||
|
||||
@@ -57,6 +57,7 @@ function configSignature(config: AiConfigItem): string {
|
||||
codexCliPath: config.codexCliPath ?? null,
|
||||
claudeCodeCliPath: config.claudeCodeCliPath ?? null,
|
||||
piAgentCliPath: config.piAgentCliPath ?? null,
|
||||
opencodeCliPath: config.opencodeCliPath ?? null,
|
||||
connectionFingerprint: fingerprint(
|
||||
JSON.stringify({
|
||||
apiKey: config.apiKey,
|
||||
@@ -65,6 +66,7 @@ function configSignature(config: AiConfigItem): string {
|
||||
codexCliEnv: sortedRecord(config.codexCliEnv),
|
||||
claudeCodeCliEnv: sortedRecord(config.claudeCodeCliEnv),
|
||||
piAgentCliEnv: sortedRecord(config.piAgentCliEnv),
|
||||
opencodeCliEnv: sortedRecord(config.opencodeCliEnv),
|
||||
}),
|
||||
),
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user