Compare commits

..

5 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
Dhanji R. Prasanna
4bf0f71bbd Merge pull request #12 from dhanji/libvision
will need this for it to work
2025-10-28 15:12:51 +11:00
Michael Neale
c1ce3038d8 will need this for it to work 2025-10-28 15:07:24 +11:00
Dhanji Prasanna
4b1694b308 machine mode 2025-10-28 14:51:32 +11:00
6 changed files with 799 additions and 402 deletions

5
.cargo/config.toml Normal file
View File

@@ -0,0 +1,5 @@
[target.aarch64-apple-darwin]
rustflags = ["-C", "link-args=-Wl,-rpath,@executable_path"]
[target.x86_64-apple-darwin]
rustflags = ["-C", "link-args=-Wl,-rpath,@executable_path"]

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
- **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
- **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
#### **g3-providers**
@@ -97,7 +98,10 @@ These commands give you fine-grained control over context management, allowing y
- **Final Output**: Formatted result presentation
### 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
- Provider-specific optimizations and feature support
- Local model support for offline operation
@@ -136,8 +140,12 @@ G3 is designed for:
# Build the project
cargo build --release
# Run G3
cargo run
# Run from the build directory
./target/release/g3
# Or copy both files to somewhere in your PATH (macOS only needs both files)
cp target/release/g3 ~/.local/bin/
cp target/release/libVisionBridge.dylib ~/.local/bin/ # macOS only
# Execute a task
g3 "implement a function to calculate fibonacci numbers"

View File

@@ -1,11 +0,0 @@
use std::env;
fn main() {
// Only add rpaths on macOS
if env::var("CARGO_CFG_TARGET_OS").unwrap() == "macos" {
// Add rpath so libVisionBridge.dylib can be found at runtime
// @executable_path means "relative to the executable"
println!("cargo:rustc-link-arg=-Wl,-rpath,@executable_path");
println!("cargo:rustc-link-arg=-Wl,-rpath,@loader_path");
}
}

View File

@@ -1,11 +0,0 @@
use std::env;
fn main() {
// Only add rpaths on macOS
if env::var("CARGO_CFG_TARGET_OS").unwrap() == "macos" {
// Add rpath so libVisionBridge.dylib can be found at runtime
// @executable_path means "relative to the executable"
println!("cargo:rustc-link-arg=-Wl,-rpath,@executable_path");
println!("cargo:rustc-link-arg=-Wl,-rpath,@loader_path");
}
}

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