Skip to main content

systemprompt_cli/commands/plugins/
mod.rs

1pub mod types;
2
3mod capabilities;
4mod config;
5mod list;
6mod run;
7mod show;
8mod validate;
9
10pub mod mcp;
11
12use anyhow::{Context, Result};
13use clap::Subcommand;
14
15use crate::descriptor::{CommandDescriptor, DescribeCommand};
16use crate::shared::render_result;
17use crate::CliConfig;
18
19#[derive(Debug, Subcommand)]
20pub enum PluginsCommands {
21    #[command(about = "List all discovered extensions")]
22    List(list::ListArgs),
23
24    #[command(about = "Show detailed extension information")]
25    Show(show::ShowArgs),
26
27    #[command(about = "Run a CLI extension command", trailing_var_arg = true)]
28    Run(run::RunArgs),
29
30    #[command(about = "Validate extension dependencies and configurations")]
31    Validate(validate::ValidateArgs),
32
33    #[command(about = "Show extension configuration")]
34    Config(config::ConfigArgs),
35
36    #[command(about = "List capabilities across all extensions")]
37    Capabilities(capabilities::CapabilitiesArgs),
38
39    #[command(subcommand, about = "MCP server management")]
40    Mcp(mcp::McpCommands),
41}
42
43impl DescribeCommand for PluginsCommands {
44    fn descriptor(&self) -> CommandDescriptor {
45        match self {
46            Self::Mcp(_) => CommandDescriptor::FULL,
47            Self::Run(_) => CommandDescriptor::PROFILE_ONLY,
48            _ => CommandDescriptor::PROFILE_ONLY.with_remote_eligible(),
49        }
50    }
51}
52
53pub async fn execute(cmd: PluginsCommands, config: &CliConfig) -> Result<()> {
54    match cmd {
55        PluginsCommands::List(args) => {
56            render_result(&list::execute(&args, config));
57            Ok(())
58        },
59        PluginsCommands::Show(args) => {
60            let result = show::execute(&args, config).context("Failed to show extension")?;
61            render_result(&result);
62            Ok(())
63        },
64        PluginsCommands::Run(args) => run::execute(args, config).await,
65        PluginsCommands::Validate(args) => {
66            render_result(&validate::execute(&args, config));
67            Ok(())
68        },
69        PluginsCommands::Config(args) => {
70            let result =
71                config::execute(&args, config).context("Failed to get extension config")?;
72            render_result(&result);
73            Ok(())
74        },
75        PluginsCommands::Capabilities(args) => {
76            capabilities::execute(args, config);
77            Ok(())
78        },
79        PluginsCommands::Mcp(cmd) => mcp::execute_with_config(cmd, config).await,
80    }
81}