Add the ability to configure rustyline to use a different edit mode (e.g. vi) (#2769)

Co-authored-by: Jack Wright <jack.wright@nike.com>
Co-authored-by: Michael Neale <michael.neale@gmail.com>
This commit is contained in:
Jack Wright
2025-07-13 17:36:06 -07:00
committed by GitHub
parent 3bc36307dc
commit ad1e322854
2 changed files with 29 additions and 3 deletions

View File

@@ -7,6 +7,7 @@ use goose::recipe::{Response, SubRecipe};
use goose::session;
use goose::session::Identifier;
use mcp_client::transport::Error as McpClientError;
use rustyline::EditMode;
use std::process;
use std::sync::Arc;
@@ -136,6 +137,7 @@ async fn offer_extension_debugging_help(
false,
None,
None,
None,
);
// Process the debugging request
@@ -383,6 +385,19 @@ pub async fn build_session(session_config: SessionBuilderConfig) -> Session {
}
}
// Determine editor mode
let edit_mode = config
.get_param::<String>("EDIT_MODE")
.ok()
.and_then(|edit_mode| match edit_mode.to_lowercase().as_str() {
"emacs" => Some(EditMode::Emacs),
"vi" => Some(EditMode::Vi),
_ => {
eprintln!("Invalid EDIT_MODE specified, defaulting to Emacs");
None
}
});
// Create new session
let mut session = Session::new(
agent,
@@ -390,6 +405,7 @@ pub async fn build_session(session_config: SessionBuilderConfig) -> Session {
session_config.debug,
session_config.scheduled_job_id.clone(),
session_config.max_turns,
edit_mode,
);
// Add extensions if provided