1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//! Slash command system for the TUI.
//!
//! This module provides a trait-based command system that allows:
//! - Framework-provided standard commands (clear, help, themes, etc.)
//! - Custom commands via closures or trait implementations
//! - Agent-specific context data accessible to commands
//!
//! # Quick Start
//!
//! Use the default commands:
//!
//! ```ignore
//! use agent_core::tui::commands::CommandRegistry;
//!
//! // Use all default commands
//! let commands = CommandRegistry::with_defaults().build();
//! agent.set_commands(commands);
//! ```
//!
//! # Custom Commands
//!
//! Add custom commands alongside defaults:
//!
//! ```ignore
//! use agent_core::tui::commands::{CommandRegistry, CustomCommand, CommandResult};
//!
//! let commands = CommandRegistry::with_defaults()
//! .add(CustomCommand::new("deploy", "Deploy the application", |args, ctx| {
//! CommandResult::Message(format!("Deploying to {}...", args))
//! }))
//! .remove("quit") // Optionally remove commands
//! .build();
//! ```
//!
//! # Extension Context
//!
//! Provide agent-specific data to commands:
//!
//! ```ignore
//! struct MyAgentContext {
//! api_key: String,
//! environments: Vec<String>,
//! }
//!
//! agent.set_command_extension(MyAgentContext {
//! api_key: "secret".into(),
//! environments: vec!["staging".into(), "prod".into()],
//! });
//!
//! // In command:
//! CustomCommand::new("deploy", "Deploy app", |args, ctx| {
//! let my_ctx = ctx.extension::<MyAgentContext>().expect("context required");
//! if my_ctx.environments.contains(&args.to_string()) {
//! CommandResult::Message(format!("Deploying to {}...", args))
//! } else {
//! CommandResult::Error(format!("Unknown environment: {}", args))
//! }
//! })
//! ```
// Re-export main types
pub use ;
pub use CustomCommand;
pub use ;
pub use CommandRegistry;
pub use CommandResult;
pub use SlashCommand;
// Re-export standard commands
pub use ;