From 0956f08791634d73350a73137c065e418d1ece1b Mon Sep 17 00:00:00 2001 From: Alex Clarke Date: Mon, 27 Jul 2026 19:44:11 -0600 Subject: [PATCH] refactor: move ACP server dispatch into run() for shared flag setup All CLI flag processing (--agent, --role, --rag, --model, --no-memory, --no-stream, --no-workspace-instructions, etc.) now runs through run() before the REPL/cmd split. The ACP server is dispatched right before match is_repl, after apply_prelude and skills loading, so it benefits from the complete context setup with no duplication or drift risk. --- src/main.rs | 33 +++++---------------------------- 1 file changed, 5 insertions(+), 28 deletions(-) diff --git a/src/main.rs b/src/main.rs index 54b02ad..e073f09 100644 --- a/src/main.rs +++ b/src/main.rs @@ -236,34 +236,6 @@ async fn main() -> Result<()> { } } - if cli.acp_server { - ctx.render_mode = RenderMode::Silent; - - if let Some(agent) = &cli.agent { - if !cli.agent_variable.is_empty() { - ctx.agent_variables = Some( - cli.agent_variable - .chunks(2) - .map(|v| (v[0].to_string(), v[1].to_string())) - .collect(), - ); - } - ctx.use_agent(app_config.as_ref(), agent, None, abort_signal.clone()) - .await?; - } else if let Some(role) = &cli.role { - ctx.use_role(app_config.as_ref(), role, abort_signal.clone()) - .await?; - } - if let Some(rag) = &cli.rag { - ctx.use_rag(Some(rag), abort_signal.clone()).await?; - } - if let Some(model_id) = &cli.model { - ctx.set_model_on_role_like(app_config.as_ref(), model_id)?; - } - - return acp::run_acp_server(ctx, abort_signal).await; - } - if let Err(err) = run(ctx, cli, text, abort_signal).await { render_error(err); process::exit(1); @@ -525,6 +497,11 @@ async fn run( ctx.load_skill_repl(name, abort_signal.clone()).await?; } + if cli.acp_server { + ctx.render_mode = RenderMode::Silent; + return acp::run_acp_server(ctx, abort_signal).await; + } + match is_repl { false => { let mut input = create_input(&ctx, text, &cli.file, abort_signal.clone()).await?;