diff --git a/crates/g3-cli/src/accumulative.rs b/crates/g3-cli/src/accumulative.rs index a466df4..6fed11a 100644 --- a/crates/g3-cli/src/accumulative.rs +++ b/crates/g3-cli/src/accumulative.rs @@ -300,6 +300,7 @@ async fn handle_command( chat_combined_content, workspace_dir, cli.new_session, + false, // from_agent_mode ) .await?; diff --git a/crates/g3-cli/src/agent_mode.rs b/crates/g3-cli/src/agent_mode.rs index 8dcdfe1..944ab0b 100644 --- a/crates/g3-cli/src/agent_mode.rs +++ b/crates/g3-cli/src/agent_mode.rs @@ -49,16 +49,23 @@ pub async fn run_agent_mode( // Change to the workspace directory first so session scanning works correctly std::env::set_current_dir(&workspace_dir)?; - // Check for incomplete agent sessions before starting a new one (unless --new-session is set) - let resuming_session = if new_session { - output.print("\n๐Ÿ†• Starting new session (--new-session flag set)"); - output.print(""); + // Check for incomplete agent sessions before starting a new one + // Skip session resume entirely when in chat mode (--agent --chat) + let resuming_session = if chat { + None // Chat mode always starts fresh + } else if new_session { + if !chat { + output.print("\n๐Ÿ†• Starting new session (--new-session flag set)"); + output.print(""); + } None } else { find_incomplete_agent_session(agent_name).ok().flatten() }; - if let Some(ref incomplete_session) = resuming_session { + // Only show session resume info when not in chat mode + if !chat { + if let Some(ref incomplete_session) = resuming_session { output.print(&format!( "\n๐Ÿ”„ Found incomplete session for agent '{}'", agent_name @@ -73,6 +80,7 @@ pub async fn run_agent_mode( output.print(""); output.print(" Resuming incomplete session..."); output.print(""); + } } // Load agent prompt: workspace agents/.md first, then embedded fallback @@ -85,8 +93,10 @@ pub async fn run_agent_mode( })?; let source = if from_disk { "workspace" } else { "embedded" }; - output.print(&format!(">> agent mode | {} ({})", agent_name, source)); - // Format workspace path, replacing home dir with ~ + // Only print verbose header when not in chat mode + if !chat { + output.print(&format!(">> agent mode | {} ({})", agent_name, source)); + } let workspace_display = { let path_str = workspace_dir.display().to_string(); dirs::home_dir() @@ -97,7 +107,8 @@ pub async fn run_agent_mode( }) .unwrap_or(path_str) }; - output.print(&format!("-> {}", workspace_display)); + // Always print workspace path (it's part of minimal output) + print!("{}-> {}{}\n", crossterm::style::SetForegroundColor(crossterm::style::Color::DarkGrey), workspace_display, crossterm::style::ResetColor); // Load config let mut config = g3_config::Config::load(config_path)?; @@ -139,10 +150,13 @@ pub async fn run_agent_mode( } else { "ยท" }; - output.print(&format!( - " {} README {} AGENTS.md {} Memory", + // Always print status line (part of minimal output) + print!( + "{} {} README {} AGENTS.md {} Memory{}\n", + crossterm::style::SetForegroundColor(crossterm::style::Color::DarkGrey), readme_status, agents_status, memory_status, - )); + crossterm::style::ResetColor + ); // Get language-specific prompts (same mechanism as normal mode) let language_content = get_language_prompts_for_workspace(&workspace_dir); @@ -153,8 +167,11 @@ pub async fn run_agent_mode( None } else { let (content, matched_langs) = get_agent_language_prompts_for_workspace_with_langs(&workspace_dir, agent_name); - for lang in matched_langs { - output.print(&format!(" โœ“ {}: {} language guidance", agent_name, lang)); + // Only print language guidance info when not in chat mode + if !chat { + for lang in matched_langs { + output.print(&format!(" โœ“ {}: {} language guidance", agent_name, lang)); + } } content }; @@ -244,7 +261,6 @@ pub async fn run_agent_mode( // If chat mode is enabled, run interactive loop instead of single task if chat { - output.print(""); return run_interactive( agent, false, // show_prompt @@ -252,6 +268,7 @@ pub async fn run_agent_mode( combined_content, &workspace_dir, new_session, + true, // from_agent_mode - skip session resume and verbose welcome ) .await; } diff --git a/crates/g3-cli/src/interactive.rs b/crates/g3-cli/src/interactive.rs index d499611..f6b7e44 100644 --- a/crates/g3-cli/src/interactive.rs +++ b/crates/g3-cli/src/interactive.rs @@ -16,6 +16,7 @@ use crate::task_execution::execute_task_with_retry; use crate::utils::display_context_progress; /// Run interactive mode with console output. +/// If `from_agent_mode` is true, skip session resume and verbose welcome (agent_mode already printed context info). pub async fn run_interactive( mut agent: Agent, show_prompt: bool, @@ -23,11 +24,13 @@ pub async fn run_interactive( combined_content: Option, workspace_path: &Path, new_session: bool, + from_agent_mode: bool, ) -> Result<()> { let output = SimpleOutput::new(); - // Check for session continuation (skip if --new-session was passed) - if !new_session { + // Check for session continuation (skip if --new-session was passed or coming from agent mode) + // Agent mode with --chat should start fresh without prompting + if !new_session && !from_agent_mode { if let Ok(Some(continuation)) = g3_core::load_continuation() { output.print(""); output.print(&format!( @@ -67,78 +70,81 @@ pub async fn run_interactive( } } - output.print(""); - output.print("g3 programming agent"); - output.print(" >> what shall we build today?"); - output.print(""); + // Skip verbose welcome when coming from agent mode (it already printed context info) + if !from_agent_mode { + output.print(""); + output.print("g3 programming agent"); + output.print(" >> what shall we build today?"); + output.print(""); - // Display provider and model information - match agent.get_provider_info() { - Ok((provider, model)) => { + // Display provider and model information + match agent.get_provider_info() { + Ok((provider, model)) => { + print!( + "๐Ÿ”ง {}{}{} | {}{}{}\n", + SetForegroundColor(Color::Cyan), + provider, + ResetColor, + SetForegroundColor(Color::Yellow), + model, + ResetColor + ); + } + Err(e) => { + error!("Failed to get provider info: {}", e); + } + } + + // Display message if AGENTS.md or README was loaded + if let Some(ref content) = combined_content { + // Check what was loaded + let has_agents = content.contains("Agent Configuration"); + let has_readme = content.contains("Project README"); + let has_memory = content.contains("Project Memory"); + + let readme_status = if has_readme { "โœ“" } else { "ยท" }; + let agents_status = if has_agents { "โœ“" } else { "ยท" }; + let memory_status = if has_memory { "โœ“" } else { "ยท" }; + + // Extract project name if README is loaded + let project_name = if has_readme { + // Extract the first heading or title from the README + extract_readme_heading(content) + } else { + None + }; + + if let Some(name) = project_name { + print!("{}>> {}{}\n", SetForegroundColor(Color::DarkGrey), name, ResetColor); + } print!( - "๐Ÿ”ง {}{}{} | {}{}{}\n", - SetForegroundColor(Color::Cyan), - provider, - ResetColor, - SetForegroundColor(Color::Yellow), - model, + "{} {} README | {} AGENTS.md | {} Memory{}\n", + SetForegroundColor(Color::DarkGrey), + readme_status, agents_status, memory_status, ResetColor ); } - Err(e) => { - error!("Failed to get provider info: {}", e); - } - } - // Display message if AGENTS.md or README was loaded - if let Some(ref content) = combined_content { - // Check what was loaded - let has_agents = content.contains("Agent Configuration"); - let has_readme = content.contains("Project README"); - let has_memory = content.contains("Project Memory"); - - let readme_status = if has_readme { "โœ“" } else { "ยท" }; - let agents_status = if has_agents { "โœ“" } else { "ยท" }; - let memory_status = if has_memory { "โœ“" } else { "ยท" }; - - // Extract project name if README is loaded - let project_name = if has_readme { - // Extract the first heading or title from the README - extract_readme_heading(content) - } else { - None + // Display workspace path + let workspace_display = { + let path_str = workspace_path.display().to_string(); + dirs::home_dir() + .and_then(|home| { + path_str + .strip_prefix(&home.display().to_string()) + .map(|s| format!("~{}", s)) + }) + .unwrap_or(path_str) }; - - if let Some(name) = project_name { - print!("{}>> {}{}\n", SetForegroundColor(Color::DarkGrey), name, ResetColor); - } print!( - "{} {} README | {} AGENTS.md | {} Memory{}\n", + "{}-> {}{}\n", SetForegroundColor(Color::DarkGrey), - readme_status, agents_status, memory_status, + workspace_display, ResetColor ); + output.print(""); } - // Display workspace path - let workspace_display = { - let path_str = workspace_path.display().to_string(); - dirs::home_dir() - .and_then(|home| { - path_str - .strip_prefix(&home.display().to_string()) - .map(|s| format!("~{}", s)) - }) - .unwrap_or(path_str) - }; - print!( - "{}-> {}{}\n", - SetForegroundColor(Color::DarkGrey), - workspace_display, - ResetColor - ); - output.print(""); - // Initialize rustyline editor with history let mut rl = DefaultEditor::new()?; diff --git a/crates/g3-cli/src/lib.rs b/crates/g3-cli/src/lib.rs index 5888d7f..565b919 100644 --- a/crates/g3-cli/src/lib.rs +++ b/crates/g3-cli/src/lib.rs @@ -218,6 +218,7 @@ async fn run_console_mode( combined_content, project.workspace(), cli.new_session, + false, // from_agent_mode ) .await }