refactor(core): remove provider module, migrate to LLMProvider, add client mode handling, improve serialization error handling, update workspace edition, and clean up conditionals and imports
This commit is contained in:
191
crates/owlen-tui/src/commands/mod.rs
Normal file
191
crates/owlen-tui/src/commands/mod.rs
Normal file
@@ -0,0 +1,191 @@
|
||||
//! Command catalog and lookup utilities for the command palette.
|
||||
|
||||
/// Metadata describing a single command keyword.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct CommandSpec {
|
||||
pub keyword: &'static str,
|
||||
pub description: &'static str,
|
||||
}
|
||||
|
||||
const COMMANDS: &[CommandSpec] = &[
|
||||
CommandSpec {
|
||||
keyword: "quit",
|
||||
description: "Exit the application",
|
||||
},
|
||||
CommandSpec {
|
||||
keyword: "q",
|
||||
description: "Alias for quit",
|
||||
},
|
||||
CommandSpec {
|
||||
keyword: "clear",
|
||||
description: "Clear the conversation",
|
||||
},
|
||||
CommandSpec {
|
||||
keyword: "c",
|
||||
description: "Alias for clear",
|
||||
},
|
||||
CommandSpec {
|
||||
keyword: "w",
|
||||
description: "Alias for write",
|
||||
},
|
||||
CommandSpec {
|
||||
keyword: "save",
|
||||
description: "Alias for write",
|
||||
},
|
||||
CommandSpec {
|
||||
keyword: "load",
|
||||
description: "Load a saved conversation",
|
||||
},
|
||||
CommandSpec {
|
||||
keyword: "o",
|
||||
description: "Alias for load",
|
||||
},
|
||||
CommandSpec {
|
||||
keyword: "open",
|
||||
description: "Open a file in the code view",
|
||||
},
|
||||
CommandSpec {
|
||||
keyword: "close",
|
||||
description: "Close the active code view",
|
||||
},
|
||||
CommandSpec {
|
||||
keyword: "mode",
|
||||
description: "Switch operating mode (chat/code)",
|
||||
},
|
||||
CommandSpec {
|
||||
keyword: "code",
|
||||
description: "Switch to code mode",
|
||||
},
|
||||
CommandSpec {
|
||||
keyword: "chat",
|
||||
description: "Switch to chat mode",
|
||||
},
|
||||
CommandSpec {
|
||||
keyword: "tools",
|
||||
description: "List available tools in current mode",
|
||||
},
|
||||
CommandSpec {
|
||||
keyword: "sessions",
|
||||
description: "List saved sessions",
|
||||
},
|
||||
CommandSpec {
|
||||
keyword: "help",
|
||||
description: "Show help documentation",
|
||||
},
|
||||
CommandSpec {
|
||||
keyword: "h",
|
||||
description: "Alias for help",
|
||||
},
|
||||
CommandSpec {
|
||||
keyword: "model",
|
||||
description: "Select a model",
|
||||
},
|
||||
CommandSpec {
|
||||
keyword: "model info",
|
||||
description: "Show detailed information for a model",
|
||||
},
|
||||
CommandSpec {
|
||||
keyword: "model refresh",
|
||||
description: "Refresh cached model information",
|
||||
},
|
||||
CommandSpec {
|
||||
keyword: "model details",
|
||||
description: "Show details for the active model",
|
||||
},
|
||||
CommandSpec {
|
||||
keyword: "m",
|
||||
description: "Alias for model",
|
||||
},
|
||||
CommandSpec {
|
||||
keyword: "models info",
|
||||
description: "Prefetch detailed information for all models",
|
||||
},
|
||||
CommandSpec {
|
||||
keyword: "new",
|
||||
description: "Start a new conversation",
|
||||
},
|
||||
CommandSpec {
|
||||
keyword: "n",
|
||||
description: "Alias for new",
|
||||
},
|
||||
CommandSpec {
|
||||
keyword: "theme",
|
||||
description: "Switch theme",
|
||||
},
|
||||
CommandSpec {
|
||||
keyword: "themes",
|
||||
description: "List available themes",
|
||||
},
|
||||
CommandSpec {
|
||||
keyword: "tutorial",
|
||||
description: "Show keybinding tutorial",
|
||||
},
|
||||
CommandSpec {
|
||||
keyword: "reload",
|
||||
description: "Reload configuration and themes",
|
||||
},
|
||||
CommandSpec {
|
||||
keyword: "e",
|
||||
description: "Edit a file",
|
||||
},
|
||||
CommandSpec {
|
||||
keyword: "edit",
|
||||
description: "Alias for edit",
|
||||
},
|
||||
CommandSpec {
|
||||
keyword: "ls",
|
||||
description: "List directory contents",
|
||||
},
|
||||
CommandSpec {
|
||||
keyword: "privacy-enable",
|
||||
description: "Enable a privacy-sensitive tool",
|
||||
},
|
||||
CommandSpec {
|
||||
keyword: "privacy-disable",
|
||||
description: "Disable a privacy-sensitive tool",
|
||||
},
|
||||
CommandSpec {
|
||||
keyword: "privacy-clear",
|
||||
description: "Clear stored secure data",
|
||||
},
|
||||
CommandSpec {
|
||||
keyword: "agent",
|
||||
description: "Enable agent mode for autonomous task execution",
|
||||
},
|
||||
CommandSpec {
|
||||
keyword: "stop-agent",
|
||||
description: "Stop the running agent",
|
||||
},
|
||||
];
|
||||
|
||||
/// Return the static catalog of commands.
|
||||
pub fn all() -> &'static [CommandSpec] {
|
||||
COMMANDS
|
||||
}
|
||||
|
||||
/// Return the default suggestion list (all command keywords).
|
||||
pub fn default_suggestions() -> Vec<String> {
|
||||
COMMANDS
|
||||
.iter()
|
||||
.map(|spec| spec.keyword.to_string())
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Generate keyword suggestions for the given input.
|
||||
pub fn suggestions(input: &str) -> Vec<String> {
|
||||
let trimmed = input.trim();
|
||||
if trimmed.is_empty() {
|
||||
return default_suggestions();
|
||||
}
|
||||
|
||||
COMMANDS
|
||||
.iter()
|
||||
.filter_map(|spec| {
|
||||
if spec.keyword.starts_with(trimmed) {
|
||||
Some(spec.keyword.to_string())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
Reference in New Issue
Block a user