#[derive(Debug, Clone)]
pub struct SlashCommand {
pub name: &'static str,
pub description: &'static str,
}
pub const BUILTIN_COMMANDS: &[SlashCommand] = &[
SlashCommand {
name: "help",
description: "show available commands and help",
},
SlashCommand {
name: "exit",
description: "exit OpenDev",
},
SlashCommand {
name: "quit",
description: "exit OpenDev (alias for /exit)",
},
SlashCommand {
name: "clear",
description: "clear current session and start fresh",
},
SlashCommand {
name: "models",
description: "interactive model/provider selector (global)",
},
SlashCommand {
name: "session-models",
description: "set model for this session only",
},
SlashCommand {
name: "mode",
description: "switch between NORMAL and PLAN mode",
},
SlashCommand {
name: "init",
description: "analyze codebase and generate AGENTS.md",
},
SlashCommand {
name: "mcp",
description: "manage MCP servers and tools",
},
SlashCommand {
name: "tasks",
description: "list background tasks",
},
SlashCommand {
name: "task",
description: "show output from a background task (usage: /task <id>)",
},
SlashCommand {
name: "kill",
description: "kill a background task (usage: /kill <id>)",
},
SlashCommand {
name: "agents",
description: "create and manage custom agents",
},
SlashCommand {
name: "skills",
description: "create and manage custom skills with AI assistance",
},
SlashCommand {
name: "plugins",
description: "manage plugins and marketplaces",
},
SlashCommand {
name: "autonomy",
description: "set autonomy level (manual/semi-auto/auto)",
},
SlashCommand {
name: "sound",
description: "play a test notification sound",
},
SlashCommand {
name: "compact",
description: "manually compact conversation context",
},
SlashCommand {
name: "undo",
description: "undo last file changes",
},
SlashCommand {
name: "redo",
description: "redo undone changes",
},
SlashCommand {
name: "share",
description: "share session as HTML",
},
SlashCommand {
name: "sessions",
description: "list saved sessions",
},
SlashCommand {
name: "bg",
description: "manage background agents",
},
];
pub fn find_matching_commands(query: &str) -> Vec<&'static SlashCommand> {
let query_lower = query.to_lowercase();
BUILTIN_COMMANDS
.iter()
.filter(|cmd| cmd.name.starts_with(&query_lower))
.collect()
}
pub fn is_command(name: &str) -> bool {
BUILTIN_COMMANDS.iter().any(|cmd| cmd.name == name)
}
#[cfg(test)]
#[path = "slash_commands_tests.rs"]
mod tests;