feat: implement model management commands and overlays for enhanced user interaction

This commit is contained in:
asepharyana
2026-07-12 02:06:46 +07:00
parent 9f272d5973
commit 662e269f2c
8 changed files with 403 additions and 26 deletions
+29 -7
View File
@@ -12,12 +12,21 @@ pub enum Command {
LessonList,
Mode(ModeKind),
Clear,
ClearConfirm,
Login { provider: String },
Edit(String),
McpAdd {
name: String,
command: String,
},
ModelList,
ModelUse {
provider: String,
},
ModelAdd {
name: String,
base_url: String,
},
Unknown(String),
}
@@ -33,7 +42,9 @@ pub fn parse_command(text: &str) -> Command {
match cmd {
"/help" => Command::Help,
"/quit" => Command::Quit,
"/clear" if arg1.is_empty() => Command::ClearConfirm,
"/clear" => Command::Clear,
"/mode" if arg1.is_empty() => Command::Help, // open help to show available modes
"/mode" => {
let mode = match arg1 {
"chat" | "c" => ModeKind::Chat,
@@ -53,25 +64,36 @@ pub fn parse_command(text: &str) -> Command {
"/lesson" if arg1 == "reject" && !arg2.is_empty() => Command::LessonReject(arg2.to_string()),
"/lesson" if !arg1.is_empty() => Command::LessonCreate(arg1.to_string()),
"/lesson" => Command::LessonList,
"/login" if arg1.is_empty() => Command::LessonList,
"/login" if !arg1.is_empty() => Command::Login { provider: arg1.to_string() },
"/login" => Command::Login { provider: "zen".to_string() },
"/edit" if !arg1.is_empty() => Command::Edit(arg1.to_string()),
"/edit" => Command::Edit(".".to_string()),
"/mcp" if arg1.is_empty() => {
Command::Mode(ModeKind::Mcp)
}
"/mcp" if arg1 == "add" && !arg2.is_empty() => {
// /mcp add <name> <command> [args...]
// name is the first word of arg2, the rest is the command
let rest = arg2.trim();
if let Some(space) = rest.find(' ') {
let name = rest[..space].to_string();
let command = rest[space + 1..].trim().to_string();
Command::McpAdd { name, command }
} else {
Command::McpAdd {
name: rest.to_string(),
command: String::new(),
}
Command::McpAdd { name: rest.to_string(), command: String::new() }
}
}
"/model" if arg1 == "ls" || arg1 == "list" => Command::ModelList,
"/model" if arg1 == "add" && !arg2.is_empty() => {
let rest = arg2.trim();
if let Some(space) = rest.find(' ') {
let name = rest[..space].to_string();
let base_url = rest[space + 1..].trim().to_string();
Command::ModelAdd { name, base_url }
} else {
Command::ModelAdd { name: rest.to_string(), base_url: String::new() }
}
}
"/model" if arg1.is_empty() => Command::ModelList,
"/model" => Command::ModelUse { provider: arg1.to_string() },
_ => Command::Unknown(cmd.to_string()),
}
}