tweak auto mode
This commit is contained in:
12
CHANGELOG.md
12
CHANGELOG.md
@@ -5,10 +5,14 @@
|
|||||||
### Added
|
### Added
|
||||||
|
|
||||||
**Interactive Requirements Mode**
|
**Interactive Requirements Mode**
|
||||||
- **Interactive Requirements Entry**: New `--interactive-requirements` flag for autonomous mode
|
- **AI-Enhanced Interactive Requirements**: New `--interactive-requirements` flag for autonomous mode
|
||||||
- Prompts user to enter requirements via stdin (multi-line support)
|
- User enters brief description of what they want to build
|
||||||
- Automatically saves requirements to `requirements.md` in workspace
|
- AI automatically enhances input into structured requirements.md document
|
||||||
- Shows preview of entered requirements
|
- Generates professional markdown with:
|
||||||
|
- Project title and overview
|
||||||
|
- Organized requirements (functional, technical, quality)
|
||||||
|
- Acceptance criteria
|
||||||
|
- User can review, accept, edit manually, or cancel before proceeding
|
||||||
- Seamlessly transitions to autonomous mode
|
- Seamlessly transitions to autonomous mode
|
||||||
|
|
||||||
**Autonomous Mode Configuration**
|
**Autonomous Mode Configuration**
|
||||||
|
|||||||
27
README.md
27
README.md
@@ -61,13 +61,36 @@ G3 features an autonomous mode where two agents collaborate:
|
|||||||
- **Player Agent**: Executes tasks and implements solutions
|
- **Player Agent**: Executes tasks and implements solutions
|
||||||
- **Coach Agent**: Reviews work and provides feedback
|
- **Coach Agent**: Reviews work and provides feedback
|
||||||
|
|
||||||
### Option 1: Interactive Requirements (Recommended)
|
### Option 1: Interactive Requirements with AI Enhancement (Recommended)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
g3 --autonomous --interactive-requirements
|
g3 --autonomous --interactive-requirements
|
||||||
```
|
```
|
||||||
|
|
||||||
Enter your requirements (multi-line), then press **Ctrl+D** (Unix/Mac) or **Ctrl+Z** (Windows) to start.
|
**How it works:**
|
||||||
|
1. Describe what you want to build (can be brief)
|
||||||
|
2. Press **Ctrl+D** (Unix/Mac) or **Ctrl+Z** (Windows)
|
||||||
|
3. AI enhances your input into a structured requirements document
|
||||||
|
4. Review the enhanced requirements
|
||||||
|
5. Choose to proceed, edit manually, or cancel
|
||||||
|
6. If accepted, autonomous mode starts automatically
|
||||||
|
|
||||||
|
**Example:**
|
||||||
|
```
|
||||||
|
You type: "build a todo app with cli in python"
|
||||||
|
|
||||||
|
AI generates:
|
||||||
|
# Todo List CLI Application
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
A command-line todo list application built in Python...
|
||||||
|
|
||||||
|
## Functional Requirements
|
||||||
|
1. Add tasks with descriptions
|
||||||
|
2. Mark tasks as complete
|
||||||
|
3. Delete tasks
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
### Option 2: Direct Requirements
|
### Option 2: Direct Requirements
|
||||||
|
|
||||||
|
|||||||
@@ -397,14 +397,14 @@ pub async fn run() -> Result<()> {
|
|||||||
|
|
||||||
// Create project model
|
// Create project model
|
||||||
let project = if cli.autonomous {
|
let project = if cli.autonomous {
|
||||||
// Handle interactive requirements mode
|
// Handle interactive requirements mode with AI enhancement
|
||||||
if cli.interactive_requirements {
|
if cli.interactive_requirements {
|
||||||
println!("\n📝 Interactive Requirements Mode");
|
println!("\n📝 Interactive Requirements Mode");
|
||||||
println!("================================\n");
|
println!("================================\n");
|
||||||
println!("Please enter your project requirements.");
|
println!("Describe what you want to build (can be brief):");
|
||||||
println!("You can enter multiple lines. Press Ctrl+D (Unix) or Ctrl+Z (Windows) when done.\n");
|
println!("Press Ctrl+D (Unix) or Ctrl+Z (Windows) when done.\n");
|
||||||
|
|
||||||
use std::io::{self, Read};
|
use std::io::{self, Read, Write};
|
||||||
let mut requirements_input = String::new();
|
let mut requirements_input = String::new();
|
||||||
io::stdin().read_to_string(&mut requirements_input)?;
|
io::stdin().read_to_string(&mut requirements_input)?;
|
||||||
|
|
||||||
@@ -412,25 +412,96 @@ pub async fn run() -> Result<()> {
|
|||||||
anyhow::bail!("No requirements provided. Exiting.");
|
anyhow::bail!("No requirements provided. Exiting.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save to requirements.md in workspace
|
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(),
|
||||||
|
)?;
|
||||||
|
|
||||||
|
// Create a simple output writer for the enhancement task
|
||||||
|
let ui_writer = ConsoleUiWriter::new();
|
||||||
|
let mut temp_agent = Agent::new_with_readme_and_quiet(
|
||||||
|
temp_config,
|
||||||
|
ui_writer,
|
||||||
|
None,
|
||||||
|
true, // quiet mode for enhancement
|
||||||
|
).await?;
|
||||||
|
|
||||||
|
// Create enhancement prompt
|
||||||
|
let enhancement_prompt = format!(
|
||||||
|
r#"Convert the following user input into a well-structured requirements.md 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");
|
let requirements_path = workspace_dir.join("requirements.md");
|
||||||
std::fs::write(&requirements_path, &requirements_input)?;
|
|
||||||
|
|
||||||
println!("\n✅ Requirements saved to: {}", requirements_path.display());
|
match choice.as_str() {
|
||||||
println!("📏 Length: {} characters\n", requirements_input.len());
|
"y" | "yes" => {
|
||||||
|
// Save enhanced requirements
|
||||||
// Show a preview
|
std::fs::write(&requirements_path, &enhanced_requirements)?;
|
||||||
let preview_lines: Vec<&str> = requirements_input.lines().take(5).collect();
|
println!("\n✅ Requirements saved to: {}", requirements_path.display());
|
||||||
println!("Preview (first 5 lines):");
|
println!("🚀 Starting autonomous mode...\n");
|
||||||
println!("---");
|
}
|
||||||
for line in preview_lines {
|
"e" | "edit" => {
|
||||||
println!("{}", line);
|
// 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 requirements_input.lines().count() > 5 {
|
|
||||||
println!("... ({} more lines)", requirements_input.lines().count() - 5);
|
|
||||||
}
|
|
||||||
println!("---\n");
|
|
||||||
println!("🚀 Starting autonomous mode...\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(requirements_text) = cli.requirements {
|
if let Some(requirements_text) = cli.requirements {
|
||||||
|
|||||||
39
test-ai-requirements.sh
Executable file
39
test-ai-requirements.sh
Executable file
@@ -0,0 +1,39 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Test script for AI-enhanced interactive requirements mode
|
||||||
|
|
||||||
|
echo "Testing AI-enhanced interactive requirements mode..."
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Create a test workspace
|
||||||
|
TEST_WORKSPACE="/tmp/g3-test-interactive-$(date +%s)"
|
||||||
|
mkdir -p "$TEST_WORKSPACE"
|
||||||
|
|
||||||
|
echo "Test workspace: $TEST_WORKSPACE"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Create sample brief input
|
||||||
|
BRIEF_INPUT="build a calculator cli in rust with basic operations"
|
||||||
|
|
||||||
|
echo "Brief input:"
|
||||||
|
echo "---"
|
||||||
|
echo "$BRIEF_INPUT"
|
||||||
|
echo "---"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
echo "This will:"
|
||||||
|
echo "1. Send brief input to AI"
|
||||||
|
echo "2. AI generates structured requirements.md"
|
||||||
|
echo "3. Show enhanced requirements"
|
||||||
|
echo "4. Prompt for confirmation (y/e/n)"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
echo "To test manually, run:"
|
||||||
|
echo "cargo run -- --autonomous --interactive-requirements --workspace $TEST_WORKSPACE"
|
||||||
|
echo ""
|
||||||
|
echo "Then type: $BRIEF_INPUT"
|
||||||
|
echo "Press Ctrl+D"
|
||||||
|
echo "Review the AI-generated requirements"
|
||||||
|
echo "Choose 'y' to proceed, 'e' to edit, or 'n' to cancel"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
echo "Test workspace will be at: $TEST_WORKSPACE"
|
||||||
Reference in New Issue
Block a user