Simplify --agent --chat startup: minimal output, no session resume
When running g3 --agent <name> --chat, the output is now minimal: - Workspace path (-> ~/path) - Status line (README/AGENTS.md/Memory) - Context progress bar - Prompt (g3>) Skipped in this mode: - Session resume prompts - "agent mode | name (source)" header - "g3 programming agent" welcome - Provider info display - Language guidance messages Added from_agent_mode parameter to run_interactive() to control whether verbose welcome and session resume are shown.
This commit is contained in:
@@ -300,6 +300,7 @@ async fn handle_command(
|
||||
chat_combined_content,
|
||||
workspace_dir,
|
||||
cli.new_session,
|
||||
false, // from_agent_mode
|
||||
)
|
||||
.await?;
|
||||
|
||||
|
||||
@@ -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/<name>.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;
|
||||
}
|
||||
|
||||
@@ -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<W: UiWriter>(
|
||||
mut agent: Agent<W>,
|
||||
show_prompt: bool,
|
||||
@@ -23,11 +24,13 @@ pub async fn run_interactive<W: UiWriter>(
|
||||
combined_content: Option<String>,
|
||||
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<W: UiWriter>(
|
||||
}
|
||||
}
|
||||
|
||||
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()?;
|
||||
|
||||
|
||||
@@ -218,6 +218,7 @@ async fn run_console_mode(
|
||||
combined_content,
|
||||
project.workspace(),
|
||||
cli.new_session,
|
||||
false, // from_agent_mode
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user