|
|
@@ -582,64 +582,52 @@ it.instance(
|
|
|
},
|
|
|
)
|
|
|
|
|
|
-test("model options are merged from existing model", async () => {
|
|
|
- await using tmp = await tmpdir({
|
|
|
- init: async (dir) => {
|
|
|
- await Bun.write(
|
|
|
- path.join(dir, "opencode.json"),
|
|
|
- JSON.stringify({
|
|
|
- $schema: "https://opencode.ai/config.json",
|
|
|
- provider: {
|
|
|
- anthropic: {
|
|
|
- models: {
|
|
|
- "claude-sonnet-4-20250514": {
|
|
|
- options: {
|
|
|
- customOption: "custom-value",
|
|
|
- },
|
|
|
- },
|
|
|
+it.instance(
|
|
|
+ "model options are merged from existing model",
|
|
|
+ Effect.gen(function* () {
|
|
|
+ const providers = yield* Provider.Service.use((provider) => provider.list())
|
|
|
+ const model = providers[ProviderID.anthropic].models["claude-sonnet-4-20250514"]
|
|
|
+ expect(model.options.customOption).toBe("custom-value")
|
|
|
+ }),
|
|
|
+ {
|
|
|
+ config: {
|
|
|
+ provider: {
|
|
|
+ anthropic: {
|
|
|
+ options: {
|
|
|
+ apiKey: "test-api-key",
|
|
|
+ },
|
|
|
+ models: {
|
|
|
+ "claude-sonnet-4-20250514": {
|
|
|
+ options: {
|
|
|
+ customOption: "custom-value",
|
|
|
},
|
|
|
},
|
|
|
},
|
|
|
- }),
|
|
|
- )
|
|
|
- },
|
|
|
- })
|
|
|
- await WithInstance.provide({
|
|
|
- directory: tmp.path,
|
|
|
- fn: async () => {
|
|
|
- set("ANTHROPIC_API_KEY", "test-api-key")
|
|
|
- const providers = await list()
|
|
|
- const model = providers[ProviderID.anthropic].models["claude-sonnet-4-20250514"]
|
|
|
- expect(model.options.customOption).toBe("custom-value")
|
|
|
+ },
|
|
|
+ },
|
|
|
},
|
|
|
- })
|
|
|
-})
|
|
|
+ },
|
|
|
+)
|
|
|
|
|
|
-test("provider removed when all models filtered out", async () => {
|
|
|
- await using tmp = await tmpdir({
|
|
|
- init: async (dir) => {
|
|
|
- await Bun.write(
|
|
|
- path.join(dir, "opencode.json"),
|
|
|
- JSON.stringify({
|
|
|
- $schema: "https://opencode.ai/config.json",
|
|
|
- provider: {
|
|
|
- anthropic: {
|
|
|
- whitelist: ["nonexistent-model"],
|
|
|
- },
|
|
|
+it.instance(
|
|
|
+ "provider removed when all models filtered out",
|
|
|
+ Effect.gen(function* () {
|
|
|
+ const providers = yield* Provider.Service.use((provider) => provider.list())
|
|
|
+ expect(providers[ProviderID.anthropic]).toBeUndefined()
|
|
|
+ }),
|
|
|
+ {
|
|
|
+ config: {
|
|
|
+ provider: {
|
|
|
+ anthropic: {
|
|
|
+ options: {
|
|
|
+ apiKey: "test-api-key",
|
|
|
},
|
|
|
- }),
|
|
|
- )
|
|
|
- },
|
|
|
- })
|
|
|
- await WithInstance.provide({
|
|
|
- directory: tmp.path,
|
|
|
- fn: async () => {
|
|
|
- set("ANTHROPIC_API_KEY", "test-api-key")
|
|
|
- const providers = await list()
|
|
|
- expect(providers[ProviderID.anthropic]).toBeUndefined()
|
|
|
+ whitelist: ["nonexistent-model"],
|
|
|
+ },
|
|
|
+ },
|
|
|
},
|
|
|
- })
|
|
|
-})
|
|
|
+ },
|
|
|
+)
|
|
|
|
|
|
test("closest finds model by partial match", async () => {
|
|
|
await using tmp = await tmpdir({
|