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(
47                mcp::McpCommands::Logs(_)
48                | mcp::McpCommands::List(_)
49                | mcp::McpCommands::ListPackages(_),
50            )
51            | Self::Run(_) => CommandDescriptor::PROFILE_ONLY,
52            Self::Mcp(_) => CommandDescriptor::FULL,
53            _ => CommandDescriptor::PROFILE_ONLY.with_remote_eligible(),
54        }
55    }
56}
57
58pub async fn execute(cmd: PluginsCommands, config: &CliConfig) -> Result<()> {
59    match cmd {
60        PluginsCommands::List(args) => {
61            render_result(&list::execute(&args, config));
62            Ok(())
63        },
64        PluginsCommands::Show(args) => {
65            let result = show::execute(&args, config).context("Failed to show extension")?;
66            render_result(&result);
67            Ok(())
68        },
69        PluginsCommands::Run(args) => run::execute(args, config).await,
70        PluginsCommands::Validate(args) => {
71            render_result(&validate::execute(&args, config));
72            Ok(())
73        },
74        PluginsCommands::Config(args) => {
75            let result =
76                config::execute(&args, config).context("Failed to get extension config")?;
77            render_result(&result);
78            Ok(())
79        },
80        PluginsCommands::Capabilities(args) => {
81            capabilities::execute(args, config);
82            Ok(())
83        },
84        PluginsCommands::Mcp(cmd) => mcp::execute_with_config(cmd, config).await,
85    }
86}