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