clearer
This commit is contained in:
@@ -162,8 +162,8 @@ g3 "implement a function to calculate fibonacci numbers"
|
||||
# Traditional autonomous mode (reads requirements.md)
|
||||
g3 --autonomous
|
||||
|
||||
# Traditional interactive mode (chat-style, disables accumulative mode)
|
||||
g3 --accumulative # Note: --accumulative flag disables the new default
|
||||
# Traditional chat mode (simple interactive chat without autonomous runs)
|
||||
g3 --chat
|
||||
```
|
||||
|
||||
```bash
|
||||
|
||||
@@ -214,9 +214,9 @@ pub struct Cli {
|
||||
#[arg(long, value_name = "TEXT")]
|
||||
pub requirements: Option<String>,
|
||||
|
||||
/// Interactive mode: prompt for requirements and save to requirements.md before starting autonomous mode
|
||||
/// Enable traditional chat mode (disables accumulative autonomous mode)
|
||||
#[arg(long)]
|
||||
pub interactive_requirements: bool,
|
||||
pub chat: bool,
|
||||
|
||||
/// Enable machine-friendly output mode with JSON markers and stats
|
||||
#[arg(long)]
|
||||
@@ -313,112 +313,6 @@ pub async fn run() -> Result<()> {
|
||||
|
||||
// Create project model
|
||||
let project = if cli.autonomous {
|
||||
// Handle interactive requirements mode with AI enhancement
|
||||
if cli.interactive_requirements {
|
||||
println!("\n📝 Interactive Requirements Mode");
|
||||
println!("================================\n");
|
||||
println!("Describe what you want to build (can be brief):");
|
||||
println!("Press Ctrl+D (Unix) or Ctrl+Z (Windows) when done.\n");
|
||||
|
||||
use std::io::{self, Read, Write};
|
||||
let mut requirements_input = String::new();
|
||||
io::stdin().read_to_string(&mut requirements_input)?;
|
||||
|
||||
if requirements_input.trim().is_empty() {
|
||||
anyhow::bail!("No requirements provided. Exiting.");
|
||||
}
|
||||
|
||||
println!("\n🤖 Enhancing your requirements with AI...\n");
|
||||
|
||||
// Create a temporary agent to enhance the requirements
|
||||
let temp_config = Config::load_with_overrides(
|
||||
cli.config.as_deref(),
|
||||
cli.provider.clone(),
|
||||
cli.model.clone(),
|
||||
)?;
|
||||
|
||||
let ui_writer = ConsoleUiWriter::new();
|
||||
let mut temp_agent = Agent::new_with_readme_and_quiet(
|
||||
temp_config,
|
||||
ui_writer,
|
||||
None,
|
||||
true, // quiet mode
|
||||
).await?;
|
||||
|
||||
// Craft the enhancement prompt
|
||||
let enhancement_prompt = format!(
|
||||
r#"You are a requirements analyst. Take this brief user input and expand it into a structured requirements document.
|
||||
|
||||
USER INPUT:
|
||||
{}
|
||||
|
||||
Create a professional requirements document with:
|
||||
1. A clear project title (# heading)
|
||||
2. An overview section explaining what will be built
|
||||
3. Organized requirements (functional, technical, quality)
|
||||
4. Acceptance criteria
|
||||
5. Any technical constraints or preferences mentioned
|
||||
|
||||
Format as proper markdown. Be specific and actionable. If the user's input is vague, make reasonable assumptions but keep it focused on what they described.
|
||||
|
||||
Output ONLY the markdown content, no explanations or meta-commentary."#,
|
||||
requirements_input.trim()
|
||||
);
|
||||
|
||||
// Execute enhancement task
|
||||
let result = temp_agent
|
||||
.execute_task_with_timing(&enhancement_prompt, None, false, false, false, false)
|
||||
.await?;
|
||||
|
||||
let enhanced_requirements = result.response.trim().to_string();
|
||||
|
||||
// Show the enhanced requirements
|
||||
println!("\n📋 Enhanced Requirements Document:");
|
||||
println!("{}\n", "=".repeat(60));
|
||||
println!("{}", enhanced_requirements);
|
||||
println!("{}\n", "=".repeat(60));
|
||||
|
||||
// Ask for confirmation
|
||||
println!("\n❓ Is this requirements document acceptable?");
|
||||
println!(" [y] Yes, proceed with autonomous mode");
|
||||
println!(" [e] Edit and save manually");
|
||||
println!(" [n] No, cancel\n");
|
||||
|
||||
print!("Your choice (y/e/n): ");
|
||||
io::stdout().flush()?;
|
||||
|
||||
let mut choice = String::new();
|
||||
io::stdin().read_line(&mut choice)?;
|
||||
let choice = choice.trim().to_lowercase();
|
||||
|
||||
let requirements_path = workspace_dir.join("requirements.md");
|
||||
|
||||
match choice.as_str() {
|
||||
"y" | "yes" => {
|
||||
// Save enhanced requirements
|
||||
std::fs::write(&requirements_path, &enhanced_requirements)?;
|
||||
println!("\n✅ Requirements saved to: {}", requirements_path.display());
|
||||
println!("🚀 Starting autonomous mode...\n");
|
||||
}
|
||||
"e" | "edit" => {
|
||||
// Save enhanced requirements for manual editing
|
||||
std::fs::write(&requirements_path, &enhanced_requirements)?;
|
||||
println!("\n✅ Requirements saved to: {}", requirements_path.display());
|
||||
println!("📝 Please edit the file and run: g3 --autonomous");
|
||||
println!(" Exiting for now.\n");
|
||||
return Ok(());
|
||||
}
|
||||
"n" | "no" => {
|
||||
println!("\n❌ Cancelled. No files were saved.\n");
|
||||
return Ok(());
|
||||
}
|
||||
_ => {
|
||||
println!("\n❌ Invalid choice. Cancelled.\n");
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(requirements_text) = &cli.requirements {
|
||||
// Use requirements text override
|
||||
Project::new_autonomous_with_requirements(workspace_dir.clone(), requirements_text.clone())?
|
||||
@@ -522,7 +416,7 @@ Output ONLY the markdown content, no explanations or meta-commentary."#,
|
||||
// 1. No task is provided (not single-shot)
|
||||
// 2. Not in autonomous mode
|
||||
// 3. Not explicitly disabled with --accumulative flag
|
||||
let use_accumulative = cli.task.is_none() && !cli.autonomous && !cli.accumulative;
|
||||
let use_accumulative = cli.task.is_none() && !cli.autonomous && !cli.accumulative && !cli.chat;
|
||||
|
||||
if use_accumulative {
|
||||
// Run accumulative mode and return early
|
||||
@@ -566,13 +460,14 @@ async fn run_accumulative_mode(
|
||||
let output = SimpleOutput::new();
|
||||
|
||||
output.print("");
|
||||
output.print("🪿 G3 AI Coding Agent - Accumulative Mode");
|
||||
output.print("🪿 G3 AI Coding Agent - Autonomous Mode");
|
||||
output.print(" >> describe what you want, I'll build it iteratively");
|
||||
output.print("");
|
||||
output.print(&format!("📁 Workspace: {}", workspace_dir.display()));
|
||||
output.print("");
|
||||
output.print("💡 Each input you provide will be added to requirements");
|
||||
output.print(" and I'll automatically work on implementing them.");
|
||||
output.print(" and I'll automatically work on implementing them. You can");
|
||||
output.print(" interrupt at any time (Ctrl+C) to add clarifications or more requirements.");
|
||||
output.print("");
|
||||
output.print(" Type 'exit' or 'quit' to stop, Ctrl+D to finish");
|
||||
output.print("");
|
||||
|
||||
@@ -191,9 +191,12 @@ g3 --quiet
|
||||
|
||||
### Disable Accumulative Mode
|
||||
|
||||
To use the traditional interactive chat mode:
|
||||
To use the traditional chat mode (without automatic autonomous runs):
|
||||
|
||||
```bash
|
||||
g3 --chat
|
||||
|
||||
# Alternative: legacy flag also works
|
||||
g3 --accumulative
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user