From bc532d99be0c407fe5e6ef82018350837ac2fb97 Mon Sep 17 00:00:00 2001 From: sigoden Date: Sun, 19 Jan 2025 17:32:22 +0800 Subject: feat: support `.edit config` and `.edit agent-config` repl commands (#1103) --- src/repl/mod.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/repl/mod.rs') diff --git a/src/repl/mod.rs b/src/repl/mod.rs index 908fa67..28f31bc 100644 --- a/src/repl/mod.rs +++ b/src/repl/mod.rs @@ -29,9 +29,10 @@ use std::{env, process}; const MENU_NAME: &str = "completion_menu"; lazy_static::lazy_static! { - static ref REPL_COMMANDS: [ReplCommand; 34] = [ + static ref REPL_COMMANDS: [ReplCommand; 36] = [ ReplCommand::new(".help", "Show this help message", AssertState::pass()), ReplCommand::new(".info", "View system info", AssertState::pass()), + ReplCommand::new(".edit config", "Edit the configuration file", AssertState::False(StateFlags::AGENT)), ReplCommand::new(".model", "Change the current LLM", AssertState::pass()), ReplCommand::new( ".prompt", @@ -104,6 +105,11 @@ lazy_static::lazy_static! { "Use the conversation starter", AssertState::True(StateFlags::AGENT) ), + ReplCommand::new( + ".edit agent-config", + "Edit the agent-specific config file", + AssertState::True(StateFlags::AGENT), + ), ReplCommand::new( ".info agent", "View agent info", @@ -490,6 +496,9 @@ pub async fn run_repl_command( bail!("Cannot perform this operation because you are in a macro") } match args { + Some("config") => { + config.read().edit_config()?; + } Some("role") => { config.write().edit_role()?; } @@ -499,8 +508,11 @@ pub async fn run_repl_command( Some("rag-docs") => { Config::edit_rag_docs(config, abort_signal.clone()).await?; } + Some("agent-config") => { + config.write().edit_agent_config()?; + } _ => { - println!(r#"Usage: .edit "#) + println!(r#"Usage: .edit "#) } } } -- cgit v1.2.3