Skip to main content

systemprompt_cli/commands/core/
mod.rs

1pub mod agents;
2pub mod artifacts;
3pub mod content;
4pub mod contexts;
5pub mod files;
6pub mod hooks;
7pub mod plugins;
8pub mod skills;
9
10use anyhow::Result;
11use clap::Subcommand;
12use systemprompt_runtime::DatabaseContext;
13
14use crate::CliConfig;
15
16#[derive(Debug, Subcommand)]
17pub enum CoreCommands {
18    #[command(subcommand, about = "Agent entity management and database sync")]
19    Agents(agents::AgentsCommands),
20
21    #[command(subcommand, about = "Artifact inspection and debugging")]
22    Artifacts(artifacts::ArtifactsCommands),
23
24    #[command(subcommand, about = "Content management and analytics")]
25    Content(content::ContentCommands),
26
27    #[command(subcommand, about = "File management and uploads")]
28    Files(files::FilesCommands),
29
30    #[command(subcommand, about = "Context management")]
31    Contexts(contexts::ContextsCommands),
32
33    #[command(subcommand, about = "Skill management and database sync")]
34    Skills(skills::SkillsCommands),
35
36    #[command(subcommand, about = "Plugin management and marketplace generation")]
37    Plugins(plugins::PluginsCommands),
38
39    #[command(subcommand, about = "Hook validation and inspection")]
40    Hooks(hooks::HooksCommands),
41}
42
43pub async fn execute(cmd: CoreCommands, config: &CliConfig) -> Result<()> {
44    match cmd {
45        CoreCommands::Agents(cmd) => agents::execute(cmd).await,
46        CoreCommands::Artifacts(cmd) => artifacts::execute(cmd, config).await,
47        CoreCommands::Content(cmd) => content::execute(cmd).await,
48        CoreCommands::Files(cmd) => files::execute(cmd, config).await,
49        CoreCommands::Contexts(cmd) => contexts::execute(cmd, config).await,
50        CoreCommands::Skills(cmd) => skills::execute(cmd).await,
51        CoreCommands::Plugins(cmd) => plugins::execute(cmd),
52        CoreCommands::Hooks(cmd) => hooks::execute(cmd),
53    }
54}
55
56pub async fn execute_with_db(
57    cmd: CoreCommands,
58    db_ctx: &DatabaseContext,
59    config: &CliConfig,
60) -> Result<()> {
61    match cmd {
62        CoreCommands::Content(cmd) => content::execute_with_db(cmd, db_ctx, config).await,
63        CoreCommands::Files(cmd) => files::execute_with_db(cmd, db_ctx, config).await,
64        CoreCommands::Agents(_)
65        | CoreCommands::Artifacts(_)
66        | CoreCommands::Contexts(_)
67        | CoreCommands::Skills(_)
68        | CoreCommands::Plugins(_)
69        | CoreCommands::Hooks(_) => {
70            anyhow::bail!("This command requires full profile context")
71        },
72    }
73}