From a3093cd5e58a27f08a97e0122a57c83b50540f71 Mon Sep 17 00:00:00 2001 From: Parth Sareen Date: Mon, 2 Mar 2026 14:17:18 -0800 Subject: [PATCH] cmd/opencode: rename provider from "Ollama (local)" to "Ollama" (#14566) The "(local)" qualifier is unnecessary since there's only one Ollama provider. Existing configs with the old name are migrated automatically; custom names are left unchanged. --- cmd/config/opencode.go | 7 ++++++- cmd/config/opencode_test.go | 38 +++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/cmd/config/opencode.go b/cmd/config/opencode.go index b4715beb9..b044359e1 100644 --- a/cmd/config/opencode.go +++ b/cmd/config/opencode.go @@ -122,13 +122,18 @@ func (o *OpenCode) Edit(modelList []string) error { if !ok { ollama = map[string]any{ "npm": "@ai-sdk/openai-compatible", - "name": "Ollama (local)", + "name": "Ollama", "options": map[string]any{ "baseURL": envconfig.Host().String() + "/v1", }, } } + // Migrate legacy provider name + if name, _ := ollama["name"].(string); name == "Ollama (local)" { + ollama["name"] = "Ollama" + } + models, ok := ollama["models"].(map[string]any) if !ok { models = make(map[string]any) diff --git a/cmd/config/opencode_test.go b/cmd/config/opencode_test.go index 8de174588..f48db587d 100644 --- a/cmd/config/opencode_test.go +++ b/cmd/config/opencode_test.go @@ -232,6 +232,44 @@ func TestOpenCodeEdit(t *testing.T) { } }) + t.Run("migrate Ollama (local) provider name", func(t *testing.T) { + cleanup() + os.MkdirAll(configDir, 0o755) + os.WriteFile(configPath, []byte(`{"provider":{"ollama":{"name":"Ollama (local)","npm":"@ai-sdk/openai-compatible","options":{"baseURL":"http://localhost:11434/v1"}}}}`), 0o644) + + if err := o.Edit([]string{"llama3.2"}); err != nil { + t.Fatal(err) + } + + data, _ := os.ReadFile(configPath) + var cfg map[string]any + json.Unmarshal(data, &cfg) + provider := cfg["provider"].(map[string]any) + ollama := provider["ollama"].(map[string]any) + if ollama["name"] != "Ollama" { + t.Errorf("provider name not migrated: got %q, want %q", ollama["name"], "Ollama") + } + }) + + t.Run("preserve custom provider name", func(t *testing.T) { + cleanup() + os.MkdirAll(configDir, 0o755) + os.WriteFile(configPath, []byte(`{"provider":{"ollama":{"name":"My Custom Ollama","npm":"@ai-sdk/openai-compatible","options":{"baseURL":"http://localhost:11434/v1"}}}}`), 0o644) + + if err := o.Edit([]string{"llama3.2"}); err != nil { + t.Fatal(err) + } + + data, _ := os.ReadFile(configPath) + var cfg map[string]any + json.Unmarshal(data, &cfg) + provider := cfg["provider"].(map[string]any) + ollama := provider["ollama"].(map[string]any) + if ollama["name"] != "My Custom Ollama" { + t.Errorf("custom provider name was changed: got %q, want %q", ollama["name"], "My Custom Ollama") + } + }) + t.Run("remove model preserves non-ollama models", func(t *testing.T) { cleanup() os.MkdirAll(configDir, 0o755)