Skip to main content

systemprompt_cli/commands/core/
mod.rs

1//! `core` command group: the platform's primary domain commands.
2//!
3//! Dispatches the [`CoreCommands`] subgroups — artifacts, content, files,
4//! contexts, skills, plugins, marketplace, and hooks. On a `--database-url`
5//! invocation only the content and files subgroups are served; the rest require
6//! a full profile context.
7//!
8//! Copyright (c) systemprompt.io — Business Source License 1.1.
9//! See <https://systemprompt.io> for licensing details.
10
11pub mod artifacts;
12pub mod content;
13pub mod contexts;
14pub mod files;
15pub mod hooks;
16pub mod marketplace;
17pub mod plugins;
18pub mod skills;
19
20use anyhow::Result;
21use clap::Subcommand;
22
23use crate::context::CommandContext;
24
25#[derive(Debug, Subcommand)]
26pub enum CoreCommands {
27    #[command(subcommand, about = "Artifact inspection and debugging")]
28    Artifacts(artifacts::ArtifactsCommands),
29
30    #[command(subcommand, about = "Content management and analytics")]
31    Content(content::ContentCommands),
32
33    #[command(subcommand, about = "File management and uploads")]
34    Files(files::FilesCommands),
35
36    #[command(subcommand, about = "Context management")]
37    Contexts(contexts::ContextsCommands),
38
39    #[command(subcommand, about = "Skill management and database sync")]
40    Skills(skills::SkillsCommands),
41
42    #[command(subcommand, about = "Plugin management and marketplace generation")]
43    Plugins(plugins::PluginsCommands),
44
45    #[command(subcommand, about = "Marketplace manifest diagnostics")]
46    Marketplace(marketplace::MarketplaceCommands),
47
48    #[command(subcommand, about = "Hook validation and inspection")]
49    Hooks(hooks::HooksCommands),
50}
51
52pub async fn execute(cmd: CoreCommands, ctx: &CommandContext) -> Result<()> {
53    if ctx.is_database_scoped() && !matches!(cmd, CoreCommands::Content(_) | CoreCommands::Files(_))
54    {
55        return Err(crate::shared::database_scoped_command_error());
56    }
57
58    match cmd {
59        CoreCommands::Artifacts(cmd) => artifacts::execute(cmd, ctx).await,
60        CoreCommands::Content(cmd) => content::execute(cmd, ctx).await,
61        CoreCommands::Files(cmd) => files::execute(cmd, ctx).await,
62        CoreCommands::Contexts(cmd) => contexts::execute(cmd, ctx).await,
63        CoreCommands::Skills(cmd) => skills::execute(cmd, ctx),
64        CoreCommands::Plugins(cmd) => plugins::execute(cmd, ctx),
65        CoreCommands::Marketplace(cmd) => marketplace::execute(cmd, ctx).await,
66        CoreCommands::Hooks(cmd) => hooks::execute(cmd, ctx),
67    }
68}