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",
73        category: SlashCategory::Info,
74        feature_gate: None,
75    },
76    SlashCommandInfo {
77        name: "/log",
78        args: "",
79        description: "Toggle verbose log output",
80        category: SlashCategory::Info,
81        feature_gate: None,
82    },
83    // --- Session ---
84    SlashCommandInfo {
85        name: "/exit",
86        args: "",
87        description: "Exit the agent (also: /quit)",
88        category: SlashCategory::Session,
89        feature_gate: None,
90    },
91    SlashCommandInfo {
92        name: "/clear",
93        args: "",
94        description: "Clear conversation history",
95        category: SlashCategory::Session,
96        feature_gate: None,
97    },
98    SlashCommandInfo {
99        name: "/clear-queue",
100        args: "",
101        description: "Discard queued messages",
102        category: SlashCategory::Session,
103        feature_gate: None,
104    },
105    SlashCommandInfo {
106        name: "/compact",
107        args: "",
108        description: "Compact the context window",
109        category: SlashCategory::Session,
110        feature_gate: None,
111    },
112    // --- Model ---
113    SlashCommandInfo {
114        name: "/model",
115        args: "[id|refresh]",
116        description: "Show or switch the active model",
117        category: SlashCategory::Model,
118        feature_gate: None,
119    },
120    // --- Memory ---
121    SlashCommandInfo {
122        name: "/feedback",
123        args: "<skill> <message>",
124        description: "Submit feedback for a skill",
125        category: SlashCategory::Memory,
126        feature_gate: None,
127    },
128    SlashCommandInfo {
129        name: "/graph",
130        args: "[subcommand]",
131        description: "Query or manage the knowledge graph",
132        category: SlashCategory::Memory,
133        feature_gate: None,
134    },
135    // --- Tools ---
136    SlashCommandInfo {
137        name: "/skill",
138        args: "<name>",
139        description: "Load and display a skill body",
140        category: SlashCategory::Tools,
141        feature_gate: None,
142    },
143    SlashCommandInfo {
144        name: "/mcp",
145        args: "[add|list|tools|remove]",
146        description: "Manage MCP servers",
147        category: SlashCategory::Tools,
148        feature_gate: None,
149    },
150    SlashCommandInfo {
151        name: "/image",
152        args: "<path>",
153        description: "Attach an image to the next message",
154        category: SlashCategory::Tools,
155        feature_gate: None,
156    },
157    SlashCommandInfo {
158        name: "/agent",
159        args: "[subcommand]",
160        description: "Manage sub-agents",
161        category: SlashCategory::Tools,
162        feature_gate: None,
163    },
164    // --- Planning ---
165    SlashCommandInfo {
166        name: "/plan",
167        args: "[goal|confirm|cancel|status|list|resume|retry]",
168        description: "Create or manage execution plans",
169        category: SlashCategory::Planning,
170        feature_gate: None,
171    },
172    // --- Debug ---
173    SlashCommandInfo {
174        name: "/debug-dump",
175        args: "[path]",
176        description: "Enable or toggle debug dump output",
177        category: SlashCategory::Debug,
178        feature_gate: None,
179    },
180    // --- Advanced (feature-gated) ---
181    #[cfg(feature = "experiments")]
182    SlashCommandInfo {
183        name: "/experiment",
184        args: "[subcommand]",
185        description: "Experimental features",
186        category: SlashCategory::Advanced,
187        feature_gate: Some("experiments"),
188    },
189    #[cfg(feature = "lsp-context")]
190    SlashCommandInfo {
191        name: "/lsp",
192        args: "",
193        description: "Show LSP context status",
194        category: SlashCategory::Advanced,
195        feature_gate: Some("lsp-context"),
196    },
197];