Skip to main content

zeph_core/agent/
slash_commands.rs

1// SPDX-FileCopyrightText: 2026 Andrei G <bug-ops>
2// SPDX-License-Identifier: MIT OR Apache-2.0
3
4//! Static registry of all slash commands available in the agent loop.
5//!
6//! Used by `/help` to enumerate and display commands grouped by category.
7
8/// Broad grouping for displaying commands in `/help` output.
9#[derive(Debug, Clone, Copy, PartialEq, Eq)]
10pub enum SlashCategory {
11    Session,
12    Model,
13    Info,
14    Memory,
15    Tools,
16    Debug,
17    Planning,
18    Advanced,
19}
20
21impl SlashCategory {
22    #[must_use]
23    pub fn as_str(self) -> &'static str {
24        match self {
25            Self::Session => "Session",
26            Self::Model => "Model",
27            Self::Info => "Info",
28            Self::Memory => "Memory",
29            Self::Tools => "Tools",
30            Self::Debug => "Debug",
31            Self::Planning => "Planning",
32            Self::Advanced => "Advanced",
33        }
34    }
35}
36
37/// Metadata for a single slash command displayed by `/help`.
38pub struct SlashCommandInfo {
39    pub name: &'static str,
40    /// Argument hint shown after the command name, e.g. `[path]` or `<name>`.
41    pub args: &'static str,
42    pub description: &'static str,
43    pub category: SlashCategory,
44    /// When `Some`, this entry was compiled in only for that feature.
45    /// Shown in the help output as `[requires: <feature>]`.
46    pub feature_gate: Option<&'static str>,
47}
48
49/// All slash commands recognised by the agent loop, in display order.
50///
51/// Feature-gated entries are wrapped in `#[cfg(feature = "...")]` so that
52/// only commands compiled into the binary appear in `/help`.
53pub const COMMANDS: &[SlashCommandInfo] = &[
54    // --- Info ---
55    SlashCommandInfo {
56        name: "/help",
57        args: "",
58        description: "Show this help message",
59        category: SlashCategory::Info,
60        feature_gate: None,
61    },
62    SlashCommandInfo {
63        name: "/status",
64        args: "",
65        description: "Show current session status (provider, model, tokens, uptime)",
66        category: SlashCategory::Info,
67        feature_gate: None,
68    },
69    SlashCommandInfo {
70        name: "/skills",
71        args: "",
72        description: "List loaded skills (grouped by category when available)",
73        category: SlashCategory::Info,
74        feature_gate: None,
75    },
76    SlashCommandInfo {
77        name: "/skills confusability",
78        args: "",
79        description: "Show skill pairs with high embedding similarity (potential disambiguation failures)",
80        category: SlashCategory::Info,
81        feature_gate: None,
82    },
83    #[cfg(feature = "guardrail")]
84    SlashCommandInfo {
85        name: "/guardrail",
86        args: "",
87        description: "Show guardrail status (provider, model, action, timeout, stats)",
88        category: SlashCategory::Info,
89        feature_gate: Some("guardrail"),
90    },
91    SlashCommandInfo {
92        name: "/log",
93        args: "",
94        description: "Toggle verbose log output",
95        category: SlashCategory::Info,
96        feature_gate: None,
97    },
98    // --- Session ---
99    SlashCommandInfo {
100        name: "/exit",
101        args: "",
102        description: "Exit the agent (also: /quit)",
103        category: SlashCategory::Session,
104        feature_gate: None,
105    },
106    SlashCommandInfo {
107        name: "/new",
108        args: "[--no-digest] [--keep-plan]",
109        description: "Start a new conversation (reset context, preserve memory and MCP)",
110        category: SlashCategory::Session,
111        feature_gate: None,
112    },
113    SlashCommandInfo {
114        name: "/clear",
115        args: "",
116        description: "Clear conversation history",
117        category: SlashCategory::Session,
118        feature_gate: None,
119    },
120    SlashCommandInfo {
121        name: "/reset",
122        args: "",
123        description: "Reset conversation history (alias for /clear, replies with confirmation)",
124        category: SlashCategory::Session,
125        feature_gate: None,
126    },
127    SlashCommandInfo {
128        name: "/clear-queue",
129        args: "",
130        description: "Discard queued messages",
131        category: SlashCategory::Session,
132        feature_gate: None,
133    },
134    SlashCommandInfo {
135        name: "/compact",
136        args: "",
137        description: "Compact the context window",
138        category: SlashCategory::Session,
139        feature_gate: None,
140    },
141    // --- Model ---
142    SlashCommandInfo {
143        name: "/model",
144        args: "[id|refresh]",
145        description: "Show or switch the active model",
146        category: SlashCategory::Model,
147        feature_gate: None,
148    },
149    SlashCommandInfo {
150        name: "/provider",
151        args: "[name|status]",
152        description: "List configured providers or switch to one by name",
153        category: SlashCategory::Model,
154        feature_gate: None,
155    },
156    // --- Memory ---
157    SlashCommandInfo {
158        name: "/feedback",
159        args: "<skill> <message>",
160        description: "Submit feedback for a skill",
161        category: SlashCategory::Memory,
162        feature_gate: None,
163    },
164    SlashCommandInfo {
165        name: "/graph",
166        args: "[subcommand]",
167        description: "Query or manage the knowledge graph",
168        category: SlashCategory::Memory,
169        feature_gate: None,
170    },
171    SlashCommandInfo {
172        name: "/memory",
173        args: "[tiers|promote <id>...]",
174        description: "Show memory tier stats or manually promote messages to semantic tier",
175        category: SlashCategory::Memory,
176        feature_gate: None,
177    },
178    #[cfg(feature = "compression-guidelines")]
179    SlashCommandInfo {
180        name: "/guidelines",
181        args: "",
182        description: "Show current compression guidelines",
183        category: SlashCategory::Memory,
184        feature_gate: Some("compression-guidelines"),
185    },
186    // --- Tools ---
187    SlashCommandInfo {
188        name: "/skill",
189        args: "<name>",
190        description: "Load and display a skill body",
191        category: SlashCategory::Tools,
192        feature_gate: None,
193    },
194    SlashCommandInfo {
195        name: "/mcp",
196        args: "[add|list|tools|remove]",
197        description: "Manage MCP servers",
198        category: SlashCategory::Tools,
199        feature_gate: None,
200    },
201    SlashCommandInfo {
202        name: "/image",
203        args: "<path>",
204        description: "Attach an image to the next message",
205        category: SlashCategory::Tools,
206        feature_gate: None,
207    },
208    SlashCommandInfo {
209        name: "/agent",
210        args: "[subcommand]",
211        description: "Manage sub-agents",
212        category: SlashCategory::Tools,
213        feature_gate: None,
214    },
215    // --- Planning ---
216    SlashCommandInfo {
217        name: "/plan",
218        args: "[goal|confirm|cancel|status|list|resume|retry]",
219        description: "Create or manage execution plans",
220        category: SlashCategory::Planning,
221        feature_gate: None,
222    },
223    // --- Debug ---
224    SlashCommandInfo {
225        name: "/debug-dump",
226        args: "[path]",
227        description: "Enable or toggle debug dump output",
228        category: SlashCategory::Debug,
229        feature_gate: None,
230    },
231    SlashCommandInfo {
232        name: "/dump-format",
233        args: "<json|raw|trace>",
234        description: "Switch debug dump format at runtime",
235        category: SlashCategory::Debug,
236        feature_gate: None,
237    },
238    // --- Advanced (feature-gated) ---
239    #[cfg(feature = "scheduler")]
240    SlashCommandInfo {
241        name: "/scheduler",
242        args: "[list]",
243        description: "List scheduled tasks",
244        category: SlashCategory::Tools,
245        feature_gate: Some("scheduler"),
246    },
247    #[cfg(feature = "experiments")]
248    SlashCommandInfo {
249        name: "/experiment",
250        args: "[subcommand]",
251        description: "Experimental features",
252        category: SlashCategory::Advanced,
253        feature_gate: Some("experiments"),
254    },
255    #[cfg(feature = "lsp-context")]
256    SlashCommandInfo {
257        name: "/lsp",
258        args: "",
259        description: "Show LSP context status",
260        category: SlashCategory::Advanced,
261        feature_gate: Some("lsp-context"),
262    },
263    #[cfg(feature = "policy-enforcer")]
264    SlashCommandInfo {
265        name: "/policy",
266        args: "[status|check <tool> [args_json]]",
267        description: "Inspect policy status or dry-run evaluation",
268        category: SlashCategory::Tools,
269        feature_gate: Some("policy-enforcer"),
270    },
271    #[cfg(feature = "context-compression")]
272    SlashCommandInfo {
273        name: "/focus",
274        args: "",
275        description: "Show Focus Agent status (active session, knowledge block size)",
276        category: SlashCategory::Advanced,
277        feature_gate: Some("context-compression"),
278    },
279    #[cfg(feature = "context-compression")]
280    SlashCommandInfo {
281        name: "/sidequest",
282        args: "",
283        description: "Show SideQuest eviction stats (passes run, tokens freed)",
284        category: SlashCategory::Advanced,
285        feature_gate: Some("context-compression"),
286    },
287];