rskit_agent/command/
builtins.rs1use rskit_errors::AppError;
4
5use super::{Command, CommandRegistry};
6
7pub fn register_builtins(registry: &mut CommandRegistry) -> Result<(), AppError> {
13 registry.register(Command {
14 name: "help".to_string(),
15 description: "List available commands".to_string(),
16 usage: "/help".to_string(),
17 handler: Box::new(|_args: &str| -> Result<String, AppError> {
18 Ok("Available commands: /help, /clear, /model, /compact\n\
19 Use /help <command> for details."
20 .to_string())
21 }),
22 })?;
23
24 registry.register(Command {
25 name: "clear".to_string(),
26 description: "Clear conversation history".to_string(),
27 usage: "/clear".to_string(),
28 handler: Box::new(|_args: &str| -> Result<String, AppError> {
29 Ok("Conversation history cleared.".to_string())
30 }),
31 })?;
32
33 registry.register(Command {
34 name: "model".to_string(),
35 description: "Show or switch the current model".to_string(),
36 usage: "/model [name]".to_string(),
37 handler: Box::new(|args: &str| -> Result<String, AppError> {
38 if args.is_empty() {
39 Ok("Usage: /model <name> — switch the active model.".to_string())
40 } else {
41 Ok(format!("Model switched to: {args}"))
42 }
43 }),
44 })?;
45
46 registry.register(Command {
47 name: "compact".to_string(),
48 description: "Compact conversation context".to_string(),
49 usage: "/compact".to_string(),
50 handler: Box::new(|_args: &str| -> Result<String, AppError> {
51 Ok("Context compacted.".to_string())
52 }),
53 })?;
54 Ok(())
55}
56
57