feat: v0.7.0 — registre de providers LLM : am providers list/show/add/remove/default, settings.providers + default_provider (closes #88)

This commit is contained in:
2026-08-19 15:32:45 -04:00
parent 1948e3bc79
commit d38cd7352f
18 changed files with 823 additions and 13 deletions
+43 -2
View File
@@ -58,6 +58,8 @@ pub struct AmCompleter {
profile_sub: Vec<&'static str>,
/// 'catalog' subcommands (issues #60 #67).
catalog_sub: Vec<&'static str>,
/// 'providers' subcommands (issue #88).
providers_sub: Vec<&'static str>,
/// Short descriptions shown next to candidates in the Tab menu
/// (Nushell-style).
descriptions: BTreeMap<String, String>,
@@ -108,6 +110,7 @@ const COMMAND_DESCRIPTIONS: &[(&str, &str)] = &[
("man", "readable man page in the terminal"),
("models", "list local models (ollama, llama.cpp, LM Studio)"),
("catalog", "manage remote catalogs"),
("providers", "manage the LLM provider registry (base URLs, models, default)"),
("suggest", "recommend an agent for a request"),
("audit", "who changed what, when (config checksums)"),
("service", "register an agent as a system service (autostart)"),
@@ -233,13 +236,14 @@ impl AmCompleter {
"start", "stop", "restart", "run", "doctor", "config", "completion",
"self-update", "self-uninstall", "export", "import", "shell", "theme", "lang",
"tip", "dashboard", "favorite", "unfavorite", "note", "tag", "untag", "tags",
"profile", "man", "models", "catalog", "suggest", "audit",
"profile", "man", "models", "catalog", "providers", "suggest", "audit",
"service", "schedule", "monitor", "web", "sync", "migrate", "playbook", "lab", "plugins",
"ls", "dir", "cd", "ps", "where", "get", "help", "version", "exit",
],
config_sub: vec!["show", "path", "edit", "validate", "add"],
profile_sub: vec!["list", "show"],
catalog_sub: vec!["update", "add", "list"],
providers_sub: vec!["list", "show", "add", "remove", "default"],
shells: vec!["bash", "zsh", "fish", "powershell", "elvish"],
gateway_shells: vec![
"list", "bash", "zsh", "fish", "powershell", "pwsh", "cmd", "sh", "nu",
@@ -286,6 +290,9 @@ impl AmCompleter {
"catalog" => {
pool = self.catalog_sub.iter().map(|s| s.to_string()).collect();
}
"providers" => {
pool = self.providers_sub.iter().map(|s| s.to_string()).collect();
}
"completion" => {
pool = self.shells.iter().map(|s| s.to_string()).collect();
}
@@ -782,7 +789,8 @@ pub fn banner_box(
.to_string(),
));
rows.push(inner(
" config alias · secret · profile · config · doctor · completion · man · tip".to_string(),
" config alias · secret · profile · providers · config · doctor · completion · man · tip"
.to_string(),
));
rows.push(inner(
" models models · models --prune · catalog · suggest · audit".to_string(),
@@ -1489,6 +1497,38 @@ fn handle_line(
return Ok(false);
}
},
"providers" => match rest.first().map(|s| s.as_str()) {
Some("show") if rest.len() >= 2 => Command::Providers(crate::cli::ProviderArgs {
sub: Some(crate::cli::ProvidersCmd::Show {
name: rest[1].clone(),
}),
}),
Some("add") if rest.len() >= 2 => Command::Providers(crate::cli::ProviderArgs {
sub: Some(crate::cli::ProvidersCmd::Add {
name: rest[1].clone(),
base_url: opt_value("--base-url").unwrap_or_default(),
model: opt_value("--model"),
models: opt_value("--models"),
}),
}),
Some("remove") if rest.len() >= 2 => Command::Providers(crate::cli::ProviderArgs {
sub: Some(crate::cli::ProvidersCmd::Remove {
name: rest[1].clone(),
}),
}),
Some("default") if rest.len() >= 2 => Command::Providers(crate::cli::ProviderArgs {
sub: Some(crate::cli::ProvidersCmd::Default {
name: rest[1].clone(),
}),
}),
Some("list") | None => Command::Providers(crate::cli::ProviderArgs {
sub: Some(crate::cli::ProvidersCmd::List),
}),
_ => {
app.log.error(crate::i18n::tr("usage: providers list | show <nom> | add <nom> --base-url <url> | remove <nom> | default <nom>"));
return Ok(false);
}
},
"suggest" => {
if rest.is_empty() {
app.log.error(crate::i18n::tr("usage: suggest <requête> — ex: suggest un agent pour du Python"));
@@ -1894,6 +1934,7 @@ pub fn is_am_command(word: &str) -> bool {
| "tip"
| "models"
| "catalog"
| "providers"
| "suggest"
| "audit"
| "service"