Compare commits

...

2 Commits

Author SHA1 Message Date
Michael Neale
6a4be9ddd7 gitignore awareness 2025-10-28 17:55:12 +11:00
Michael Neale
2a44fbb7b2 suggest rg when available for performance 2025-10-28 15:27:22 +11:00
3 changed files with 782 additions and 364 deletions

View File

@@ -14,6 +14,7 @@ The heart of the agent system, containing:
- **Context Window Management**: Intelligent tracking of token usage with context thinning (50-80%) and auto-summarization at 80% capacity - **Context Window Management**: Intelligent tracking of token usage with context thinning (50-80%) and auto-summarization at 80% capacity
- **Tool System**: Built-in tools for file operations, shell commands, computer control, TODO management, and structured output - **Tool System**: Built-in tools for file operations, shell commands, computer control, TODO management, and structured output
- **Streaming Response Parser**: Real-time parsing of LLM responses with tool call detection and execution - **Streaming Response Parser**: Real-time parsing of LLM responses with tool call detection and execution
- **Smart Project Awareness**: Automatically detects and respects `.gitignore` patterns, informing the agent about ignored files
- **Task Execution**: Support for single and iterative task execution with automatic retry logic - **Task Execution**: Support for single and iterative task execution with automatic retry logic
#### **g3-providers** #### **g3-providers**
@@ -97,7 +98,10 @@ These commands give you fine-grained control over context management, allowing y
- **Final Output**: Formatted result presentation - **Final Output**: Formatted result presentation
### Provider Flexibility ### Provider Flexibility
- Support for multiple LLM providers through a unified interface
### Smart Project Awareness
- Automatically detects and respects `.gitignore` when present
- Hot-swappable providers without code changes - Hot-swappable providers without code changes
- Provider-specific optimizations and feature support - Provider-specific optimizations and feature support
- Local model support for offline operation - Local model support for offline operation

View File

@@ -0,0 +1,76 @@
#[cfg(test)]
mod gitignore_prompt_tests {
use crate::Agent;
use crate::ui_writer::UiWriter;
// Mock UI writer for testing
struct MockUiWriter;
impl UiWriter for MockUiWriter {
fn print_agent_prompt(&self) {}
fn print_agent_response(&self, _text: &str) {}
fn print(&self, _message: &str) {}
fn print_inline(&self, _message: &str) {}
fn print_tool_output_line(&self, _line: &str) {}
fn print_system_prompt(&self, _text: &str) {}
fn print_tool_header(&self, _tool_name: &str) {}
fn print_tool_arg(&self, _key: &str, _value: &str) {}
fn print_tool_output_header(&self) {}
fn update_tool_output_line(&self, _line: &str) {}
fn print_tool_output_summary(&self, _total_lines: usize) {}
fn print_tool_timing(&self, _duration: &str) {}
fn print_context_status(&self, _message: &str) {}
fn print_context_thinning(&self, _message: &str) {}
fn println(&self, _text: &str) {}
fn flush(&self) {}
fn notify_sse_received(&self) {}
fn wants_full_output(&self) -> bool { false }
}
#[test]
fn test_gitignore_prompt_snippet_with_file() {
// Create a temporary .gitignore file
let test_gitignore = "# Test comment\ntarget/\n*.log\n\n# Another comment\nlogs/\n";
std::fs::write(".gitignore.test", test_gitignore).unwrap();
// Temporarily rename actual .gitignore if it exists
let has_real_gitignore = std::path::Path::new(".gitignore").exists();
if has_real_gitignore {
std::fs::rename(".gitignore", ".gitignore.backup").unwrap();
}
// Rename test file to .gitignore
std::fs::rename(".gitignore.test", ".gitignore").unwrap();
let snippet = Agent::<MockUiWriter>::get_gitignore_prompt_snippet();
// Restore original .gitignore
std::fs::remove_file(".gitignore").unwrap();
if has_real_gitignore {
std::fs::rename(".gitignore.backup", ".gitignore").unwrap();
}
assert!(snippet.contains("IMPORTANT"));
assert!(snippet.contains(".gitignore"));
assert!(snippet.contains("target/"));
assert!(snippet.contains("*.log"));
}
#[test]
fn test_gitignore_prompt_snippet_without_file() {
// Temporarily rename .gitignore if it exists
let has_gitignore = std::path::Path::new(".gitignore").exists();
if has_gitignore {
std::fs::rename(".gitignore", ".gitignore.backup").unwrap();
}
let snippet = Agent::<MockUiWriter>::get_gitignore_prompt_snippet();
// Restore .gitignore
if has_gitignore {
std::fs::rename(".gitignore.backup", ".gitignore").unwrap();
}
assert_eq!(snippet, "");
}
}

File diff suppressed because it is too large Load Diff