diff --git a/crates/g3-cli/src/agent_mode.rs b/crates/g3-cli/src/agent_mode.rs index 26141e2..8dcdfe1 100644 --- a/crates/g3-cli/src/agent_mode.rs +++ b/crates/g3-cli/src/agent_mode.rs @@ -12,6 +12,7 @@ use crate::language_prompts::{get_language_prompts_for_workspace, get_agent_lang use crate::simple_output::SimpleOutput; use crate::embedded_agents::load_agent_prompt; use crate::ui_writer_impl::ConsoleUiWriter; +use crate::interactive::run_interactive; /// Run agent mode - loads a specialized agent prompt and executes a single task. pub async fn run_agent_mode( @@ -23,6 +24,7 @@ pub async fn run_agent_mode( task: Option, chrome_headless: bool, safari: bool, + chat: bool, ) -> Result<()> { use g3_core::find_incomplete_agent_session; use g3_core::get_agent_system_prompt; @@ -178,7 +180,7 @@ pub async fn run_agent_mode( // Set agent mode on UI writer for visual differentiation (light gray tool names) ui_writer.set_agent_mode(true); let mut agent = - Agent::new_with_custom_prompt(config, ui_writer, system_prompt, combined_content).await?; + Agent::new_with_custom_prompt(config, ui_writer, system_prompt, combined_content.clone()).await?; // Set agent mode for session tracking agent.set_agent_mode(agent_name); @@ -240,6 +242,21 @@ pub async fn run_agent_mode( // Use provided task if available, otherwise use the default initial_task let final_task = task.as_deref().unwrap_or(initial_task); + // If chat mode is enabled, run interactive loop instead of single task + if chat { + output.print(""); + return run_interactive( + agent, + false, // show_prompt + false, // show_code + combined_content, + &workspace_dir, + new_session, + ) + .await; + } + + // Single-shot mode: execute the task and exit let _result = agent.execute_task(final_task, None, true).await?; // Send auto-memory reminder if enabled and tools were called diff --git a/crates/g3-cli/src/cli_args.rs b/crates/g3-cli/src/cli_args.rs index d64faac..cecd43a 100644 --- a/crates/g3-cli/src/cli_args.rs +++ b/crates/g3-cli/src/cli_args.rs @@ -96,7 +96,7 @@ pub struct Cli { pub codebase_fast_start: Option, /// Run as a specialized agent (loads prompt from agents/.md) - #[arg(long, value_name = "NAME", conflicts_with_all = ["autonomous", "auto", "chat", "planning"])] + #[arg(long, value_name = "NAME", conflicts_with_all = ["autonomous", "auto", "planning"])] pub agent: Option, /// List all available agents (embedded and workspace) diff --git a/crates/g3-cli/src/lib.rs b/crates/g3-cli/src/lib.rs index 9ba91d2..5888d7f 100644 --- a/crates/g3-cli/src/lib.rs +++ b/crates/g3-cli/src/lib.rs @@ -88,6 +88,7 @@ pub async fn run() -> Result<()> { cli.task.clone(), cli.chrome_headless, cli.safari, + cli.chat, ) .await; }