cosmetic tool call stuff

This commit is contained in:
Dhanji Prasanna
2025-10-10 14:18:35 +11:00
parent 426a9b88a9
commit 57b7bcb0de
2 changed files with 32 additions and 31 deletions

View File

@@ -249,7 +249,7 @@ fn extract_readme_heading(readme_content: &str) -> Option<String> {
// Process the content line by line, skipping the prefix line if present // Process the content line by line, skipping the prefix line if present
let lines_iter = readme_content.lines(); let lines_iter = readme_content.lines();
let mut content_lines = Vec::new(); let mut content_lines = Vec::new();
for line in lines_iter { for line in lines_iter {
// Skip the "📚 Project README (from ...):" line // Skip the "📚 Project README (from ...):" line
if line.starts_with("📚 Project README") { if line.starts_with("📚 Project README") {
@@ -258,11 +258,11 @@ fn extract_readme_heading(readme_content: &str) -> Option<String> {
content_lines.push(line); content_lines.push(line);
} }
let content = content_lines.join("\n"); let content = content_lines.join("\n");
// Look for the first markdown heading // Look for the first markdown heading
for line in content.lines() { for line in content.lines() {
let trimmed = line.trim(); let trimmed = line.trim();
// Check for H1 heading (# Title) // Check for H1 heading (# Title)
if trimmed.starts_with("# ") { if trimmed.starts_with("# ") {
let title = trimmed[2..].trim(); let title = trimmed[2..].trim();
@@ -271,17 +271,21 @@ fn extract_readme_heading(readme_content: &str) -> Option<String> {
return Some(title.to_string()); return Some(title.to_string());
} }
} }
// Skip other markdown headings for now (##, ###, etc.) // Skip other markdown headings for now (##, ###, etc.)
// We're only looking for the main H1 heading // We're only looking for the main H1 heading
} }
// If no H1 heading found, look for the first non-empty, non-metadata line as a fallback // If no H1 heading found, look for the first non-empty, non-metadata line as a fallback
for line in content.lines().take(5) { for line in content.lines().take(5) {
let trimmed = line.trim(); let trimmed = line.trim();
// Skip empty lines, other heading markers, and metadata // Skip empty lines, other heading markers, and metadata
if !trimmed.is_empty() && !trimmed.starts_with("📚") && !trimmed.starts_with('#') if !trimmed.is_empty()
&& !trimmed.starts_with("==") && !trimmed.starts_with("--") { && !trimmed.starts_with("📚")
&& !trimmed.starts_with('#')
&& !trimmed.starts_with("==")
&& !trimmed.starts_with("--")
{
// Limit length for display // Limit length for display
return Some(if trimmed.len() > 100 { return Some(if trimmed.len() > 100 {
format!("{}...", &trimmed[..97]) format!("{}...", &trimmed[..97])
@@ -334,7 +338,10 @@ async fn run_interactive_retro(
} else { } else {
"PROJECT DOCUMENTATION LOADED".to_string() "PROJECT DOCUMENTATION LOADED".to_string()
}; };
tui.output(&format!("SYSTEM: PROJECT README LOADED - {}\n\n", readme_snippet)); tui.output(&format!(
"SYSTEM: PROJECT README LOADED - {}\n\n",
readme_snippet
));
} }
tui.output("SYSTEM: READY FOR INPUT\n\n"); tui.output("SYSTEM: READY FOR INPUT\n\n");
tui.output("\n\n"); tui.output("\n\n");
@@ -561,27 +568,10 @@ async fn run_interactive<W: UiWriter>(
let output = SimpleOutput::new(); let output = SimpleOutput::new();
output.print(""); output.print("");
output.print("🪿 G3 AI Coding Agent - Interactive Mode"); output.print("🪿 G3 AI Coding Agent");
output.print("I solve problems by writing and executing code. what shall we build today?"); output.print(" >> what shall we build today?");
output.print(""); output.print("");
// Display message if README was loaded
if readme_content.is_some() {
// Extract the first heading or title from the README
let readme_snippet = if let Some(ref content) = readme_content {
extract_readme_heading(content)
.unwrap_or_else(|| "Project documentation loaded".to_string())
} else {
"Project documentation loaded".to_string()
};
output.print(&format!("📚 Project README loaded: {}", readme_snippet));
if readme_snippet.len() > 80 {
output.print(" (Full README available in context)");
}
output.print("");
}
// Display provider and model information // Display provider and model information
match agent.get_provider_info() { match agent.get_provider_info() {
Ok((provider, model)) => { Ok((provider, model)) => {
@@ -592,8 +582,19 @@ async fn run_interactive<W: UiWriter>(
} }
} }
output.print(""); // Display message if README was loaded
output.print("CTRL-D to quit; ↑/↓ for history"); if readme_content.is_some() {
// Extract the first heading or title from the README
let readme_snippet = if let Some(ref content) = readme_content {
extract_readme_heading(content)
.unwrap_or_else(|| "Project documentation loaded".to_string())
} else {
"Project documentation loaded".to_string()
};
output.print(&format!("📚 detected: {}", readme_snippet));
}
output.print(""); output.print("");
// Initialize rustyline editor with history // Initialize rustyline editor with history

View File

@@ -98,12 +98,12 @@ impl UiWriter for ConsoleUiWriter {
} }
fn print_tool_output_line(&self, line: &str) { fn print_tool_output_line(&self, line: &str) {
println!("{}", line); println!("\x1b[2m{}\x1b[0m", line);
} }
fn print_tool_output_summary(&self, hidden_count: usize) { fn print_tool_output_summary(&self, hidden_count: usize) {
println!( println!(
"│ ... ({} more line{})", "\x1b[2m... ({} more line{})\x1b[0m",
hidden_count, hidden_count,
if hidden_count == 1 { "" } else { "s" } if hidden_count == 1 { "" } else { "s" }
); );