systemprompt_cli/commands/plugins/capabilities/
llm_providers.rs1use clap::Args;
2
3use crate::CliConfig;
4use crate::commands::plugins::discover_registry;
5use crate::commands::plugins::types::{LlmProviderWithExtension, LlmProvidersListOutput};
6use crate::shared::CommandOutput;
7
8#[derive(Debug, Clone, Args)]
9pub struct LlmProvidersArgs {
10 #[arg(long, help = "Filter by extension ID")]
11 pub extension: Option<String>,
12}
13
14pub fn execute(args: &LlmProvidersArgs, _config: &CliConfig) -> CommandOutput {
15 let registry = discover_registry();
16
17 let providers: Vec<LlmProviderWithExtension> = registry
18 .extensions()
19 .iter()
20 .filter(|ext| args.extension.as_ref().is_none_or(|f| ext.id().contains(f)))
21 .flat_map(|ext| {
22 ext.llm_providers()
23 .iter()
24 .enumerate()
25 .map(|(i, _provider)| LlmProviderWithExtension {
26 extension_id: systemprompt_identifiers::PluginId::new(ext.id()),
27 extension_name: ext.name().to_owned(),
28 provider_name: format!("llm_provider_{}", i),
29 })
30 .collect::<Vec<_>>()
31 })
32 .collect();
33
34 let total = providers.len();
35
36 let output = LlmProvidersListOutput { providers, total };
37
38 CommandOutput::table_of(vec!["extension_id", "provider_name"], &output.providers)
39 .with_title("LLM Providers Across Extensions")
40}