diff options
| author | sigoden <sigoden@gmail.com> | 2025-01-19 17:32:22 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-19 17:32:22 +0800 |
| commit | bc532d99be0c407fe5e6ef82018350837ac2fb97 (patch) | |
| tree | 8d26ad57b79e0fbf46e9299b5fffd4348b8fea3d /src/repl/mod.rs | |
| parent | ef5febaa0ea5779d11bba062a2f623262931147e (diff) | |
| download | aichat-bc532d99be0c407fe5e6ef82018350837ac2fb97.tar.gz | |
feat: support `.edit config` and `.edit agent-config` repl commands (#1103)
Diffstat (limited to 'src/repl/mod.rs')
| -rw-r--r-- | src/repl/mod.rs | 16 |
1 files changed, 14 insertions, 2 deletions
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", @@ -105,6 +106,11 @@ lazy_static::lazy_static! { 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", AssertState::True(StateFlags::AGENT), @@ -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 <role|session|rag-docs>"#) + println!(r#"Usage: .edit <config|role|session|rag-docs|agent-config>"#) } } } |
