refactor(ollama)!: remove Ollama provider crate and implementation

Deletes the `owlen-ollama` Cargo.toml and source files, fully removing the Ollama provider from the workspace. This aligns the project with the MCP‑only architecture and eliminates direct provider dependencies.
This commit is contained in:
2025-10-12 06:38:21 +02:00
parent 38aba1a6bb
commit 15e5c1206b
19 changed files with 1280 additions and 741 deletions

View File

@@ -57,10 +57,6 @@ impl Default for Config {
fn default() -> Self {
let mut providers = HashMap::new();
providers.insert("ollama".to_string(), default_ollama_provider_config());
providers.insert(
"ollama-cloud".to_string(),
default_ollama_cloud_provider_config(),
);
Self {
schema_version: Self::default_schema_version(),
@@ -200,7 +196,6 @@ impl Config {
}
ensure_provider_config(self, "ollama");
ensure_provider_config(self, "ollama-cloud");
if self.schema_version.is_empty() {
self.schema_version = Self::default_schema_version();
}
@@ -222,9 +217,42 @@ impl Config {
CONFIG_SCHEMA_VERSION
);
}
if let Some(legacy_cloud) = self.providers.remove("ollama_cloud") {
self.merge_legacy_ollama_provider(legacy_cloud);
}
if let Some(legacy_cloud) = self.providers.remove("ollama-cloud") {
self.merge_legacy_ollama_provider(legacy_cloud);
}
self.schema_version = CONFIG_SCHEMA_VERSION.to_string();
}
fn merge_legacy_ollama_provider(&mut self, mut legacy_cloud: ProviderConfig) {
use std::collections::hash_map::Entry;
legacy_cloud.provider_type = "ollama".to_string();
match self.providers.entry("ollama".to_string()) {
Entry::Occupied(mut entry) => {
let target = entry.get_mut();
if target.base_url.is_none() {
target.base_url = legacy_cloud.base_url.take();
}
if target.api_key.is_none() {
target.api_key = legacy_cloud.api_key.take();
}
if target.extra.is_empty() && !legacy_cloud.extra.is_empty() {
target.extra = legacy_cloud.extra;
}
}
Entry::Vacant(entry) => {
entry.insert(legacy_cloud);
}
}
}
fn validate_default_provider(&self) -> Result<()> {
if self.general.default_provider.trim().is_empty() {
return Err(crate::Error::Config(
@@ -308,15 +336,6 @@ fn default_ollama_provider_config() -> ProviderConfig {
}
}
fn default_ollama_cloud_provider_config() -> ProviderConfig {
ProviderConfig {
provider_type: "ollama-cloud".to_string(),
base_url: Some("https://ollama.com".to_string()),
api_key: None,
extra: HashMap::new(),
}
}
/// Default configuration path with user home expansion
pub fn default_config_path() -> PathBuf {
if let Some(config_dir) = dirs::config_dir() {
@@ -787,11 +806,14 @@ pub fn ensure_provider_config<'a>(
) -> &'a ProviderConfig {
use std::collections::hash_map::Entry;
if matches!(provider_name, "ollama_cloud" | "ollama-cloud") {
return ensure_provider_config(config, "ollama");
}
match config.providers.entry(provider_name.to_string()) {
Entry::Occupied(entry) => entry.into_mut(),
Entry::Vacant(entry) => {
let default = match provider_name {
"ollama-cloud" => default_ollama_cloud_provider_config(),
"ollama" => default_ollama_provider_config(),
other => ProviderConfig {
provider_type: other.to_string(),
@@ -857,20 +879,44 @@ mod tests {
}
#[test]
fn default_config_contains_local_and_cloud_providers() {
fn default_config_contains_local_provider() {
let config = Config::default();
assert!(config.providers.contains_key("ollama"));
assert!(config.providers.contains_key("ollama-cloud"));
}
#[test]
fn ensure_provider_config_backfills_cloud_defaults() {
fn ensure_provider_config_aliases_cloud_defaults() {
let mut config = Config::default();
config.providers.remove("ollama-cloud");
config.providers.clear();
let cloud = ensure_provider_config(&mut config, "ollama-cloud");
assert_eq!(cloud.provider_type, "ollama-cloud");
assert_eq!(cloud.base_url.as_deref(), Some("https://ollama.com"));
assert_eq!(cloud.provider_type, "ollama");
assert_eq!(cloud.base_url.as_deref(), Some("http://localhost:11434"));
assert!(config.providers.contains_key("ollama"));
assert!(!config.providers.contains_key("ollama-cloud"));
}
#[test]
fn migrate_ollama_cloud_underscore_key() {
let mut config = Config::default();
config.providers.clear();
config.providers.insert(
"ollama_cloud".to_string(),
ProviderConfig {
provider_type: "ollama_cloud".to_string(),
base_url: Some("https://api.ollama.com".to_string()),
api_key: Some("secret".to_string()),
extra: HashMap::new(),
},
);
config.apply_schema_migrations("1.0.0");
assert!(config.providers.get("ollama_cloud").is_none());
assert!(config.providers.get("ollama-cloud").is_none());
let cloud = config.providers.get("ollama").expect("migrated config");
assert_eq!(cloud.provider_type, "ollama");
assert_eq!(cloud.base_url.as_deref(), Some("https://api.ollama.com"));
assert_eq!(cloud.api_key.as_deref(), Some("secret"));
}
#[test]