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