systemprompt_cli/commands/core/
mod.rs1pub mod artifacts;
12pub mod content;
13pub mod contexts;
14pub mod files;
15pub mod hooks;
16pub mod marketplace;
17pub mod plugins;
18pub mod services;
19pub mod skills;
20
21use anyhow::Result;
22use clap::Subcommand;
23
24use crate::context::CommandContext;
25use crate::descriptor::DataImpact;
26
27#[derive(Debug, Subcommand)]
28pub enum CoreCommands {
29 #[command(subcommand, about = "Artifact inspection and debugging")]
30 Artifacts(artifacts::ArtifactsCommands),
31
32 #[command(subcommand, about = "Content management and analytics")]
33 Content(content::ContentCommands),
34
35 #[command(subcommand, about = "File management and uploads")]
36 Files(files::FilesCommands),
37
38 #[command(subcommand, about = "Context management")]
39 Contexts(contexts::ContextsCommands),
40
41 #[command(subcommand, about = "Skill management and database sync")]
42 Skills(skills::SkillsCommands),
43
44 #[command(subcommand, about = "Plugin management and marketplace generation")]
45 Plugins(plugins::PluginsCommands),
46
47 #[command(subcommand, about = "Marketplace manifest diagnostics")]
48 Marketplace(marketplace::MarketplaceCommands),
49
50 #[command(subcommand, about = "Hook validation and inspection")]
51 Hooks(hooks::HooksCommands),
52
53 #[command(
54 subcommand,
55 about = "Services bundles: validate, pack, sign, publish, refresh, inspect"
56 )]
57 Services(services::ServicesCommands),
58}
59
60pub async fn execute(cmd: CoreCommands, ctx: &CommandContext) -> Result<()> {
61 if ctx.is_database_scoped() && !matches!(cmd, CoreCommands::Content(_) | CoreCommands::Files(_))
62 {
63 return Err(crate::shared::database_scoped_command_error());
64 }
65
66 match cmd {
67 CoreCommands::Artifacts(cmd) => artifacts::execute(cmd, ctx).await,
68 CoreCommands::Content(cmd) => content::execute(cmd, ctx).await,
69 CoreCommands::Files(cmd) => files::execute(cmd, ctx).await,
70 CoreCommands::Contexts(cmd) => contexts::execute(cmd, ctx).await,
71 CoreCommands::Skills(cmd) => skills::execute(cmd, ctx).await,
72 CoreCommands::Plugins(cmd) => plugins::execute(cmd, ctx),
73 CoreCommands::Marketplace(cmd) => marketplace::execute(cmd, ctx).await,
74 CoreCommands::Hooks(cmd) => hooks::execute(cmd, ctx),
75 CoreCommands::Services(cmd) => Box::pin(services::execute(cmd, ctx)).await,
76 }
77}
78
79impl CoreCommands {
80 pub const fn data_impact(&self) -> DataImpact {
81 use content::ContentCommands;
82 use content::link::LinkCommands;
83
84 match self {
85 Self::Content(
86 ContentCommands::Delete(_)
87 | ContentCommands::DeleteSource(_)
88 | ContentCommands::Link(LinkCommands::Delete(_)),
89 )
90 | Self::Files(files::FilesCommands::Delete(_))
91 | Self::Contexts(contexts::ContextsCommands::Delete(_)) => DataImpact::Destructive,
92 Self::Content(
93 ContentCommands::List(_)
94 | ContentCommands::Show(_)
95 | ContentCommands::Search(_)
96 | ContentCommands::Edit(_)
97 | ContentCommands::Popular(_)
98 | ContentCommands::Verify(_)
99 | ContentCommands::Status(_)
100 | ContentCommands::Link(
101 LinkCommands::Generate(_)
102 | LinkCommands::Show(_)
103 | LinkCommands::List(_)
104 | LinkCommands::Performance(_),
105 )
106 | ContentCommands::Analytics(_)
107 | ContentCommands::Files(_),
108 )
109 | Self::Files(
110 files::FilesCommands::List(_)
111 | files::FilesCommands::Show(_)
112 | files::FilesCommands::Upload(_)
113 | files::FilesCommands::Validate(_)
114 | files::FilesCommands::Config(_)
115 | files::FilesCommands::Search(_)
116 | files::FilesCommands::Stats(_)
117 | files::FilesCommands::Ai(_),
118 )
119 | Self::Contexts(
120 contexts::ContextsCommands::List(_)
121 | contexts::ContextsCommands::Show(_)
122 | contexts::ContextsCommands::Create(_)
123 | contexts::ContextsCommands::Edit(_)
124 | contexts::ContextsCommands::Use(_)
125 | contexts::ContextsCommands::New(_),
126 )
127 | Self::Artifacts(
128 artifacts::ArtifactsCommands::List(_) | artifacts::ArtifactsCommands::Show(_),
129 )
130 | Self::Skills(_)
131 | Self::Plugins(_)
132 | Self::Marketplace(_)
133 | Self::Hooks(_)
134 | Self::Services(_) => DataImpact::Preserving,
135 }
136 }
137}