minor
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
use g3_config::Config;
|
||||
use g3_core::{project::Project, Agent, ui_writer::UiWriter};
|
||||
use g3_core::{project::Project, ui_writer::UiWriter, Agent};
|
||||
use rustyline::error::ReadlineError;
|
||||
use rustyline::DefaultEditor;
|
||||
use std::path::PathBuf;
|
||||
use tokio_util::sync::CancellationToken;
|
||||
use tracing::{error, info};
|
||||
|
||||
mod retro_tui;
|
||||
mod tui;
|
||||
mod ui_writer_impl;
|
||||
mod retro_tui;
|
||||
use retro_tui::RetroTui;
|
||||
use tui::SimpleOutput;
|
||||
use ui_writer_impl::{ConsoleUiWriter, RetroTuiWriter};
|
||||
use retro_tui::RetroTui;
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(name = "g3")]
|
||||
@@ -93,12 +93,9 @@ pub async fn run() -> Result<()> {
|
||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter};
|
||||
|
||||
// Create a filter that suppresses ALL logs in retro mode
|
||||
let filter = EnvFilter::from_default_env()
|
||||
.add_directive("off".parse().unwrap()); // Turn off all logging
|
||||
let filter = EnvFilter::from_default_env().add_directive("off".parse().unwrap()); // Turn off all logging
|
||||
|
||||
tracing_subscriber::registry()
|
||||
.with(filter)
|
||||
.init();
|
||||
tracing_subscriber::registry().with(filter).init();
|
||||
}
|
||||
|
||||
if !cli.retro {
|
||||
@@ -212,8 +209,6 @@ async fn run_interactive_retro(config: Config, show_prompt: bool, show_code: boo
|
||||
}
|
||||
|
||||
tui.output("");
|
||||
tui.output("Type 'exit' or 'quit' to exit, use Up/Down arrows to scroll output");
|
||||
tui.output("For multiline input: use \\ at the end of a line to continue");
|
||||
tui.output("");
|
||||
|
||||
// Track multiline input
|
||||
@@ -225,7 +220,11 @@ async fn run_interactive_retro(config: Config, show_prompt: bool, show_code: boo
|
||||
loop {
|
||||
// Update context window display
|
||||
let context = agent.get_context_window();
|
||||
tui.update_context(context.used_tokens, context.total_tokens, context.percentage_used());
|
||||
tui.update_context(
|
||||
context.used_tokens,
|
||||
context.total_tokens,
|
||||
context.percentage_used(),
|
||||
);
|
||||
|
||||
// Update the displayed input buffer
|
||||
tui.update_input(&input_buffer);
|
||||
@@ -286,7 +285,17 @@ async fn run_interactive_retro(config: Config, show_prompt: bool, show_code: boo
|
||||
tui.output(&format!("> {}", input));
|
||||
tui.status("PROCESSING");
|
||||
|
||||
match agent.execute_task_with_timing(&input, None, false, show_prompt, show_code, true).await {
|
||||
match agent
|
||||
.execute_task_with_timing(
|
||||
&input,
|
||||
None,
|
||||
false,
|
||||
show_prompt,
|
||||
show_code,
|
||||
true,
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(response) => {
|
||||
tui.output(&response);
|
||||
tui.status("READY");
|
||||
@@ -335,13 +344,17 @@ async fn run_interactive_retro(config: Config, show_prompt: bool, show_code: boo
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn run_interactive<W: UiWriter>(mut agent: Agent<W>, show_prompt: bool, show_code: bool) -> Result<()> {
|
||||
async fn run_interactive<W: UiWriter>(
|
||||
mut agent: Agent<W>,
|
||||
show_prompt: bool,
|
||||
show_code: bool,
|
||||
) -> Result<()> {
|
||||
let output = SimpleOutput::new();
|
||||
|
||||
output.print("");
|
||||
output.print("🤖 G3 AI Coding Agent - Interactive Mode");
|
||||
output.print(
|
||||
"I solve problems by writing and executing code. Tell me what you need to accomplish!"
|
||||
"I solve problems by writing and executing code. Tell me what you need to accomplish!",
|
||||
);
|
||||
output.print("");
|
||||
|
||||
@@ -472,7 +485,13 @@ async fn run_interactive<W: UiWriter>(mut agent: Agent<W>, show_prompt: bool, sh
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn execute_task<W: UiWriter>(agent: &mut Agent<W>, input: &str, show_prompt: bool, show_code: bool, output: &SimpleOutput) {
|
||||
async fn execute_task<W: UiWriter>(
|
||||
agent: &mut Agent<W>,
|
||||
input: &str,
|
||||
show_prompt: bool,
|
||||
show_code: bool,
|
||||
output: &SimpleOutput,
|
||||
) {
|
||||
// Show thinking indicator immediately
|
||||
output.print("🤔 Thinking...");
|
||||
// Note: flush is handled internally by println
|
||||
@@ -533,7 +552,11 @@ async fn execute_task<W: UiWriter>(agent: &mut Agent<W>, input: &str, show_promp
|
||||
|
||||
fn display_context_progress<W: UiWriter>(agent: &Agent<W>, output: &SimpleOutput) {
|
||||
let context = agent.get_context_window();
|
||||
output.print_context(context.used_tokens, context.total_tokens, context.percentage_used());
|
||||
output.print_context(
|
||||
context.used_tokens,
|
||||
context.total_tokens,
|
||||
context.percentage_used(),
|
||||
);
|
||||
}
|
||||
|
||||
/// Set up the workspace directory for autonomous mode
|
||||
@@ -572,13 +595,19 @@ async fn run_autonomous(
|
||||
let output = SimpleOutput::new();
|
||||
|
||||
output.print("🤖 G3 AI Coding Agent - Autonomous Mode");
|
||||
output.print(&format!("📁 Using workspace: {}", project.workspace().display()));
|
||||
output.print(&format!(
|
||||
"📁 Using workspace: {}",
|
||||
project.workspace().display()
|
||||
));
|
||||
|
||||
// Check if requirements exist
|
||||
if !project.has_requirements() {
|
||||
output.print("❌ Error: requirements.md not found in workspace directory");
|
||||
output.print(" Please create a requirements.md file with your project requirements at:");
|
||||
output.print(&format!(" {}/requirements.md", project.workspace().display()));
|
||||
output.print(&format!(
|
||||
" {}/requirements.md",
|
||||
project.workspace().display()
|
||||
));
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
@@ -599,7 +628,10 @@ async fn run_autonomous(
|
||||
let mut implementation_approved = false;
|
||||
|
||||
loop {
|
||||
output.print(&format!("\n=== TURN {}/{} - PLAYER MODE ===", turn, max_turns));
|
||||
output.print(&format!(
|
||||
"\n=== TURN {}/{} - PLAYER MODE ===",
|
||||
turn, max_turns
|
||||
));
|
||||
|
||||
// Player mode: implement requirements (with coach feedback if available)
|
||||
let player_prompt = if coach_feedback.is_empty() {
|
||||
@@ -643,7 +675,10 @@ async fn run_autonomous(
|
||||
// Ensure coach agent is also in the workspace directory
|
||||
project.enter_workspace()?;
|
||||
|
||||
output.print(&format!("\n=== TURN {}/{} - COACH MODE ===", turn, max_turns));
|
||||
output.print(&format!(
|
||||
"\n=== TURN {}/{} - COACH MODE ===",
|
||||
turn, max_turns
|
||||
));
|
||||
|
||||
// Coach mode: critique the implementation
|
||||
let coach_prompt = format!(
|
||||
|
||||
Reference in New Issue
Block a user