Files
owlen/crates/core/agent/examples/git_demo.rs
vikingowl 10c8e2baae feat(v2): complete multi-LLM providers, TUI redesign, and advanced agent features
Multi-LLM Provider Support:
- Add llm-core crate with LlmProvider trait abstraction
- Implement Anthropic Claude API client with streaming
- Implement OpenAI API client with streaming
- Add token counting with SimpleTokenCounter and ClaudeTokenCounter
- Add retry logic with exponential backoff and jitter

Borderless TUI Redesign:
- Rewrite theme system with terminal capability detection (Full/Unicode256/Basic)
- Add provider tabs component with keybind switching [1]/[2]/[3]
- Implement vim-modal input (Normal/Insert/Visual/Command modes)
- Redesign chat panel with timestamps and streaming indicators
- Add multi-provider status bar with cost tracking
- Add Nerd Font icons with graceful ASCII fallbacks
- Add syntax highlighting (syntect) and markdown rendering (pulldown-cmark)

Advanced Agent Features:
- Add system prompt builder with configurable components
- Enhance subagent orchestration with parallel execution
- Add git integration module for safe command detection
- Add streaming tool results via channels
- Expand tool set: AskUserQuestion, TodoWrite, LS, MultiEdit, BashOutput, KillShell
- Add WebSearch with provider abstraction

Plugin System Enhancement:
- Add full agent definition parsing from YAML frontmatter
- Add skill system with progressive disclosure
- Wire plugin hooks into HookManager

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 17:24:14 +01:00

75 lines
2.2 KiB
Rust

//! Example demonstrating the git integration module
//!
//! Run with: cargo run -p agent-core --example git_demo
use agent_core::{detect_git_state, format_git_status, is_safe_git_command, is_destructive_git_command};
use std::env;
fn main() -> color_eyre::Result<()> {
color_eyre::install()?;
// Get current working directory
let cwd = env::current_dir()?;
println!("Detecting git state in: {}\n", cwd.display());
// Detect git state
let state = detect_git_state(&cwd)?;
// Display formatted status
println!("{}\n", format_git_status(&state));
// Show detailed file status if there are changes
if !state.status.is_empty() {
println!("Detailed file status:");
for status in &state.status {
match status {
agent_core::GitFileStatus::Modified { path } => {
println!(" M {}", path);
}
agent_core::GitFileStatus::Added { path } => {
println!(" A {}", path);
}
agent_core::GitFileStatus::Deleted { path } => {
println!(" D {}", path);
}
agent_core::GitFileStatus::Renamed { from, to } => {
println!(" R {} -> {}", from, to);
}
agent_core::GitFileStatus::Untracked { path } => {
println!(" ? {}", path);
}
}
}
println!();
}
// Test command safety checking
println!("Command safety checks:");
let test_commands = vec![
"git status",
"git log --oneline",
"git diff HEAD",
"git commit -m 'test'",
"git push --force origin main",
"git reset --hard HEAD~1",
"git rebase main",
"git branch -D feature",
];
for cmd in test_commands {
let is_safe = is_safe_git_command(cmd);
let (is_destructive, warning) = is_destructive_git_command(cmd);
print!(" {} - ", cmd);
if is_safe {
println!("SAFE (read-only)");
} else if is_destructive {
println!("DESTRUCTIVE: {}", warning);
} else {
println!("UNSAFE (modifies state)");
}
}
Ok(())
}