Slash commands (/quit, /help) + zero compiler warnings
1. /quit and /help commands restored: - /quit: exits the interactive loop - /help: shows formatted help box with available commands & tips - Unknown commands get a friendly error pointing to /help - Slash commands intercepted before LLM processing (no token waste) 2. Zero warnings across entire workspace (13 files fixed): - Fixed ambiguous glob re-exports in gyandoot-core - Added #[allow(dead_code)] on intentional dead fields - Fixed unused imports, variables, and macros - Fixed unused assignments in subagents - cleaned up service.rs, profile, kanban warnings install.sh now produces a completely clean build with zero warnings.
This commit is contained in:
@@ -25,6 +25,7 @@ use crate::context::ContextCompressor;
|
||||
use crate::tools::ToolExecutor;
|
||||
|
||||
// ─── CLI color constants ──────────────────────────────────────────────
|
||||
#[allow(dead_code)]
|
||||
mod cli_color {
|
||||
pub const RESET: &str = "\x1b[0m";
|
||||
pub const BOLD: &str = "\x1b[1m";
|
||||
@@ -143,6 +144,7 @@ pub struct AgentLoop {
|
||||
sanitizer: Sanitizer,
|
||||
status: Arc<Mutex<AgentStatus>>,
|
||||
retry_cfg: RetryConfig,
|
||||
#[allow(dead_code)]
|
||||
browser_client: Option<BrowserClient>,
|
||||
}
|
||||
|
||||
@@ -204,7 +206,7 @@ impl AgentLoop {
|
||||
// ── Identity & memory injection on startup ─────────────────────
|
||||
let (agent_name, agent_role, user_name, user_role) = {
|
||||
let memory = self.memory.lock().await;
|
||||
let (l0, _) = memory.identity_get().unwrap_or_default();
|
||||
let (_l0, _) = memory.identity_get().unwrap_or_default();
|
||||
|
||||
// Priority: config identity > config.agent.name > defaults
|
||||
let a_name = if !self.config.identity.agent_name.is_empty() {
|
||||
@@ -267,7 +269,16 @@ impl AgentLoop {
|
||||
// 1. Read user input
|
||||
let user_input = self.read_input().await?;
|
||||
|
||||
// 2. Check exit conditions
|
||||
// 2. Handle built-in slash commands
|
||||
if user_input.starts_with('/') {
|
||||
let should_quit = self.handle_command(&user_input).await;
|
||||
if should_quit {
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// 3. Check exit conditions
|
||||
if self.should_exit(&user_input) {
|
||||
info!("User requested exit");
|
||||
break;
|
||||
@@ -619,7 +630,49 @@ impl AgentLoop {
|
||||
|
||||
/// Check if the user wants to exit.
|
||||
fn should_exit(&self, input: &str) -> bool {
|
||||
matches!(input.to_lowercase().as_str(), "exit" | "quit" | "bye")
|
||||
matches!(input.to_lowercase().as_str(), "exit" | "quit" | "bye" | "/quit")
|
||||
}
|
||||
|
||||
/// Handle a slash command. Returns true if the user wants to exit.
|
||||
async fn handle_command(&self, cmd: &str) -> bool {
|
||||
match cmd.to_lowercase().as_str() {
|
||||
"/quit" | "/exit" => {
|
||||
info!("User requested exit via slash command");
|
||||
true
|
||||
}
|
||||
"/help" => {
|
||||
println!(
|
||||
"\n{bold}{cyan}╔════════════════════════════════════╗\
|
||||
\n║ GyanDoot — Help ║\
|
||||
\n╚════════════════════════════════════╝{reset}\n\
|
||||
\n{bold}Commands:{reset}\
|
||||
\n {green}»{reset} Type anything to chat with the AI\
|
||||
\n {green}/quit{reset} Exit GyanDoot\
|
||||
\n {green}/help{reset} Show this help message\n\
|
||||
\n{bold}Tips:{reset}\
|
||||
\n • Use {cyan}web_search{reset} for online queries\
|
||||
\n • Use {cyan}web_browse{reset} to visit websites\
|
||||
\n • Type {yellow}exit{reset}, {yellow}quit{reset}, or {yellow}bye{reset} to exit\n",
|
||||
bold = cli_color::BOLD,
|
||||
cyan = cli_color::BRIGHT_CYAN,
|
||||
green = cli_color::GREEN,
|
||||
yellow = cli_color::YELLOW,
|
||||
reset = cli_color::RESET,
|
||||
);
|
||||
false
|
||||
}
|
||||
_ => {
|
||||
println!(
|
||||
"\n{yellow}Unknown command:{reset} {cmd}\n\
|
||||
Type {green}/help{reset} for available commands.\n",
|
||||
yellow = cli_color::YELLOW,
|
||||
reset = cli_color::RESET,
|
||||
cmd = cmd,
|
||||
green = cli_color::GREEN,
|
||||
);
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user