feat: added a .edit command for editing the MCP configuration file
This commit is contained in:
@@ -1344,6 +1344,18 @@ impl RequestContext {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn edit_mcp_config(&self) -> Result<()> {
|
||||
let mcp_path = paths::mcp_config_file();
|
||||
let editor = self.app.config.editor()?;
|
||||
edit_file(&editor, &mcp_path)?;
|
||||
println!(
|
||||
"NOTE: Remember to restart {} for changes to '{}' to take effect",
|
||||
env!("CARGO_CRATE_NAME"),
|
||||
mcp_path.display(),
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn new_role(&self, app: &AppConfig, name: &str) -> Result<()> {
|
||||
if self.macro_flag {
|
||||
bail!("No role");
|
||||
|
||||
+14
-4
@@ -45,7 +45,7 @@ pub const DEFAULT_CONTINUATION_PROMPT: &str = indoc! {"
|
||||
4. Continue with the next pending item now. Call tools immediately."
|
||||
};
|
||||
|
||||
static REPL_COMMANDS: LazyLock<[ReplCommand; 40]> = LazyLock::new(|| {
|
||||
static REPL_COMMANDS: LazyLock<[ReplCommand; 41]> = LazyLock::new(|| {
|
||||
[
|
||||
ReplCommand::new(".help", "Show this help guide", AssertState::pass()),
|
||||
ReplCommand::new(".info", "Show system info", AssertState::pass()),
|
||||
@@ -59,6 +59,11 @@ static REPL_COMMANDS: LazyLock<[ReplCommand; 40]> = LazyLock::new(|| {
|
||||
"Modify configuration file",
|
||||
AssertState::False(StateFlags::AGENT),
|
||||
),
|
||||
ReplCommand::new(
|
||||
".edit mcp-config",
|
||||
"Modify the MCP servers configuration file",
|
||||
AssertState::False(StateFlags::AGENT),
|
||||
),
|
||||
ReplCommand::new(".model", "Switch LLM model", AssertState::pass()),
|
||||
ReplCommand::new(
|
||||
".prompt",
|
||||
@@ -627,8 +632,13 @@ pub async fn run_repl_command(
|
||||
let app = Arc::clone(&ctx.app.config);
|
||||
ctx.edit_agent_config(app.as_ref())?;
|
||||
}
|
||||
Some("mcp-config") => {
|
||||
ctx.edit_mcp_config()?;
|
||||
}
|
||||
_ => {
|
||||
println!(r#"Usage: .edit <config|role|session|rag-docs|agent-config>"#)
|
||||
println!(
|
||||
r#"Usage: .edit <config|mcp-config|role|session|rag-docs|agent-config>"#
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1231,8 +1241,8 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn repl_commands_has_40_entries() {
|
||||
assert_eq!(REPL_COMMANDS.len(), 40);
|
||||
fn repl_commands_has_41_entries() {
|
||||
assert_eq!(REPL_COMMANDS.len(), 41);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user