| Crates.io | ai-code-buddy |
| lib.rs | ai-code-buddy |
| version | 0.4.20 |
| created_at | 2025-07-31 22:52:53.677102+00 |
| updated_at | 2025-08-29 05:13:08.165312+00 |
| description | An AI-powered code review tool with elegant Bevy-based TUI |
| homepage | https://github.com/edgarhsanchez/ai_code_buddy |
| repository | https://github.com/edgarhsanchez/ai_code_buddy |
| max_upload_size | |
| id | 1775853 |
| size | 2,203,683 |

๐ค An AI-powered code review tool with an elegant Bevy-based TUI that analyzes Git repositories and provides intelligent feedback on code quality, security vulnerabilities, and maintainability issues.
The default mode launches an elegant terminal user interface built with Bevy:
ai-code-buddy
Features:
For automation and CI/CD integration:
ai-code-buddy --cli --format summary
Example Output:
๐ AI Code Review Tool
๐ Repository: .
๐ฟ Comparing: main โ HEAD
๐ฏ Code Review Summary
==========================================
๐ฟ Branches: main โ feat/bevy_rewrite
๐ Files modified: 12
โ Lines added: 486
โ Lines removed: 234
๐ Total issues: 5
๐ค AI Assessment:
Based on the code changes between branches, I've analyzed 12 files with detailed
attention to security, performance, and code quality.
KEY FINDINGS:
โข src/main.rs:
โ ๏ธ HIGH: Line 45: Consider using more specific error types
๐ถ MEDIUM: Line 67: Function complexity could be reduced
โข src/widgets/analysis.rs:
๐จ CRITICAL: Line 123: Potential unsafe memory access
โ ๏ธ HIGH: Line 156: Missing input validation
๐ Technology Stack:
Languages: Rust
Frameworks: Bevy, Ratatui
๐ Issues by Category:
Security: 2 issues
Performance: 1 issue
Maintainability: 2 issues
cargo install ai-code-buddy
The build system automatically detects your hardware and enables the best acceleration:
macOS (Homebrew) - Coming Soon:
# Future release - not yet available
brew install ai-code-buddy
Ubuntu/Debian:
# Install Rust if not already installed
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/env
# Install AI Code Buddy
cargo install ai-code-buddy
Windows:
# Install Rust via rustup-init.exe from https://rustup.rs/
# Then install AI Code Buddy
cargo install ai-code-buddy
Docker (Cross-Platform):
# Build image
docker build -t ai-code-buddy .
# Run analysis on current directory
docker run -v $(pwd):/workspace ai-code-buddy --cli
# Clone the repository
git clone https://github.com/edgarhsanchez/ai_code_buddy.git
cd ai_code_buddy
# Build with GPU acceleration (auto-detected)
cargo build --release
# Run directly
./target/release/ai-code-buddy --help
# Optional: Add to PATH
sudo ln -s $(pwd)/target/release/ai-code-buddy /usr/local/bin/
# Force specific GPU backend
cargo install ai-code-buddy --features gpu-metal # Apple Silicon
cargo install ai-code-buddy --features gpu-cuda # NVIDIA CUDA (Windows only)
cargo install ai-code-buddy --features gpu-mkl # Intel MKL
# CPU-only build (smaller binary)
cargo install ai-code-buddy --no-default-features
# Check version and features
ai-code-buddy --version
ai-code-buddy --help
# Test with a simple repository
cd ~/your-git-project
ai-code-buddy --cli --format summary
# Force GPU mode to test acceleration
ai-code-buddy --gpu --cli --verbose
# Expected output for Apple Silicon:
# ๐ Apple Silicon detected, using Metal backend
# ๐ง AI Analyzer initialized with Metal backend
# Force CPU mode for comparison
ai-code-buddy --cpu --cli --verbose
| Component | Requirement | Purpose |
|---|---|---|
| Rust | 1.70+ | Building and running the application |
| Git | 2.0+ | Repository analysis and branch comparison |
| Terminal | Modern with Unicode | TUI interface and proper display |
| Memory | 512MB+ RAM | Analysis processing (more for large repos) |
| Storage | 50MB+ free | Binary installation and analysis cache |
macOS:
Linux:
Windows:
โ "cargo: command not found"
# Install Rust toolchain
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/env
โ GPU acceleration not working
# Check if GPU features were compiled
ai-code-buddy --gpu --cli --verbose
# If Metal not available on Apple Silicon:
cargo install ai-code-buddy --features gpu-metal --force
# If CUDA not available with NVIDIA (Windows only):
cargo install ai-code-buddy --features gpu-cuda --force
โ "failed to compile" on older systems
# Update Rust to latest version
rustup update
# Clean install with latest Rust
cargo install ai-code-buddy --force
โ Out of memory during compilation
# Reduce parallel compilation jobs
export CARGO_BUILD_JOBS=2
cargo install ai-code-buddy
# Or use pre-compiled binary (when available)
โ Permission denied on Unix systems
# Install to user directory instead of system
cargo install ai-code-buddy --root ~/.local
export PATH="$HOME/.local/bin:$PATH"
# 1. Navigate to any Git repository
cd ~/my-project
# 2. Run interactive analysis
ai-code-buddy
# 3. Or get a quick CLI summary
ai-code-buddy --cli --format summary
# Analyze current branch vs main
ai-code-buddy --cli --source main --target HEAD
# Focus on security issues only
ai-code-buddy --cli --include "src/**" --format detailed
# Generate a report for your team
ai-code-buddy --cli --format markdown > code-review.md
# CI/CD integration test
ai-code-buddy --cli --format json > review.json
# View comprehensive credits and acknowledgments
ai-code-buddy --cli --credits
ai-code-buddy [OPTIONS] [REPO_PATH]
| Argument | Description | Default |
|---|---|---|
[REPO_PATH] |
Path to the Git repository | Current directory (.) |
| Option | Short | Description | Default | Example |
|---|---|---|---|---|
--source <BRANCH> |
-s |
Source branch to compare from | main |
-s feature-branch |
--target <BRANCH> |
-t |
Target branch to compare to | HEAD |
-t develop |
--cli |
Run in CLI mode with text output | Interactive TUI | --cli |
|
--verbose |
-v |
Enable verbose output for debugging | Off | -v |
--credits |
Show credits and list all contributors | Off | --credits |
|
--format <FORMAT> |
-f |
Output format for results | summary |
-f json |
--exclude <PATTERN> |
Exclude files matching glob pattern | None | --exclude "test_files/**" |
|
--include <PATTERN> |
Include only files matching glob pattern | None | --include "src/**" |
|
--gpu |
Enable GPU acceleration (auto-detected) | Auto-detected | --gpu |
|
--cpu |
Force CPU mode (disable GPU) | GPU if available | --cpu |
|
--disable-ai |
Disable AI-powered analysis | AI enabled | --disable-ai |
|
--help |
-h |
Print help information | --help |
|
--version |
-V |
Print version information | --version |
AI Code Buddy features advanced AI-powered analysis that goes beyond traditional pattern matching to provide deeper insights into code quality, architecture, and maintainability.
Default Behavior (AI Enabled):
# AI analysis is enabled by default for maximum insights
ai-code-buddy --cli
# Output: ๐ค AI inference enabled - using advanced AI analysis
Disable AI Analysis (Rule-based Only):
# Use traditional rule-based analysis only
ai-code-buddy --cli --disable-ai
# Output: ๐ AI inference disabled - using rule-based analysis only
Performance Comparison:
# AI-enhanced analysis (more comprehensive)
ai-code-buddy --cli --format summary
# Result: ~33 issues detected
# Rule-based analysis (faster)
ai-code-buddy --cli --disable-ai --format summary
# Result: ~27 issues detected
| Mode | Use Case | Pros | Cons |
|---|---|---|---|
| AI Enabled (Default) | Comprehensive code review, architecture assessment | More thorough analysis, better insights | Slightly slower |
| AI Disabled | Quick scans, CI/CD pipelines, performance-critical | Faster execution, consistent results | Fewer issues detected |
| Format | Description | Use Case |
|---|---|---|
summary |
Summary output with key findings | Quick overview and human review |
detailed |
Detailed output with all issues | Comprehensive analysis |
json |
JSON format for programmatic use | CI/CD integration, tooling |
markdown |
Markdown format for documentation | GitHub Issues, documentation |
Launch the modern Bevy-powered terminal interface for comprehensive analysis:
ai-code-buddy
๐ฎ TUI Navigation:
๐ TUI Features:
# Basic analysis of current branch vs main
ai-code-buddy --cli
# Compare specific branches
ai-code-buddy --cli --source main --target feature-branch
# Analyze specific directory with focus
ai-code-buddy --cli --include "src/**" --exclude "tests/**"
# Comprehensive OWASP security scan
ai-code-buddy --cli --format detailed --include "**/*.js" --include "**/*.py" --include "**/*.rs"
# Focus on authentication and authorization code
ai-code-buddy --cli --include "**/auth/**" --include "**/security/**" --include "**/admin/**"
# Quick security check for critical files
ai-code-buddy --cli --include "**/*auth*" --include "**/*login*" --include "**/*password*"
# Focus on performance-critical code paths
ai-code-buddy --cli --include "src/core/**" --include "src/engine/**" --format detailed
# Large codebase optimization
ai-code-buddy --cli --exclude "target/**" --exclude "node_modules/**" --exclude "dist/**"
# Algorithm analysis
ai-code-buddy --cli --include "**/*algorithm*" --include "**/*performance*" --verbose
# View comprehensive project credits and contributors
ai-code-buddy --cli --credits
Credits Output:
๐ AI Code Buddy - Comprehensive Credits & Acknowledgments
==========================================================
๐ About AI Code Buddy:
An intelligent code analysis tool with elegant Bevy-powered TUI
that provides comprehensive code reviews with AI assistance.
๐ฅ Project Contributors:
โข Edgar Sanchez <esanchez@m2iab.com> (76 commits)
โข Edgar H Sanchez <esanchez@m2iab.com> (14 commits)
๐ฆ Library Dependencies & Licenses:
๐ง anyhow v1.0.95
๐ License: MIT OR Apache-2.0
๐ Description: Flexible concrete Error type built on std::error::Error
๐ Repository: https://github.com/dtolnay/anyhow
๐ฅ Key Contributors: David Tolnay, And 50+ contributors
[... additional libraries ...]
๐ Special Thanks:
โข The Rust Programming Language team
โข All open source contributors
โข The Bevy game engine community
โข The broader Rust ecosystem
#!/bin/bash
# .git/hooks/pre-commit
echo "๐ Running AI Code Buddy analysis..."
# Run analysis and check for critical issues
ai-code-buddy --cli --format json --source main --target HEAD > /tmp/review.json
# Exit with error if critical issues found
if jq -e '.issues[] | select(.severity == "Critical")' /tmp/review.json > /dev/null; then
echo "โ Critical issues found! Review required."
ai-code-buddy --cli --format summary --source main --target HEAD
exit 1
fi
echo "โ
No critical issues found."
GitHub Actions:
name: AI Code Review
on: [pull_request]
jobs:
code-review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history for branch comparison
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install AI Code Buddy
run: cargo install ai-code-buddy
- name: Run Code Analysis
run: |
ai-code-buddy --cli --format json \
--source ${{ github.event.pull_request.base.ref }} \
--target ${{ github.event.pull_request.head.ref }} \
> review.json
- name: Check Critical Issues
run: |
CRITICAL_COUNT=$(jq '[.issues[] | select(.severity == "Critical")] | length' review.json)
echo "Critical issues found: $CRITICAL_COUNT"
if [ "$CRITICAL_COUNT" -gt 0 ]; then
echo "โ Critical security issues detected!"
ai-code-buddy --cli --format markdown \
--source ${{ github.event.pull_request.base.ref }} \
--target ${{ github.event.pull_request.head.ref }} \
> review-report.md
exit 1
fi
- name: Upload Review Report
uses: actions/upload-artifact@v3
if: always()
with:
name: code-review-report
path: review.json
GitLab CI:
stages:
- analysis
code_review:
stage: analysis
image: rust:latest
script:
- cargo install ai-code-buddy
- ai-code-buddy --cli --format json --source $CI_MERGE_REQUEST_TARGET_BRANCH_NAME --target $CI_COMMIT_REF_NAME > review.json
- ai-code-buddy --cli --format markdown --source $CI_MERGE_REQUEST_TARGET_BRANCH_NAME --target $CI_COMMIT_REF_NAME > review.md
artifacts:
reports:
junit: review.json
paths:
- review.md
expire_in: 1 week
only:
- merge_requests
Jenkins Pipeline:
pipeline {
agent any
stages {
stage('Code Review') {
steps {
sh 'cargo install ai-code-buddy'
sh '''
ai-code-buddy --cli --format json \
--source ${CHANGE_TARGET} --target ${CHANGE_BRANCH} \
> review.json
'''
script {
def review = readJSON file: 'review.json'
def criticalIssues = review.issues.findAll { it.severity == 'Critical' }
if (criticalIssues.size() > 0) {
error("Critical security issues found: ${criticalIssues.size()}")
}
}
}
post {
always {
archiveArtifacts artifacts: 'review.json', fingerprint: true
}
}
}
}
}
#!/bin/bash
# weekly-security-scan.sh
# Generate comprehensive security report
ai-code-buddy --cli --format markdown \
--source main --target HEAD \
--include "src/**" --include "lib/**" \
> "security-report-$(date +%Y-%m-%d).md"
# Generate JSON for metrics tracking
ai-code-buddy --cli --format json \
--source main --target HEAD \
> "metrics-$(date +%Y-%m-%d).json"
# Send to security team if critical issues found
CRITICAL_COUNT=$(jq '[.issues[] | select(.severity == "Critical")] | length' "metrics-$(date +%Y-%m-%d).json")
if [ "$CRITICAL_COUNT" -gt 0 ]; then
echo "โ ๏ธ $CRITICAL_COUNT critical security issues found!"
# Send alert email, Slack notification, etc.
fi
# Comprehensive Rust analysis
ai-code-buddy --cli --include "**/*.rs" --include "**/Cargo.toml" --format detailed
# Focus on unsafe code and memory safety
ai-code-buddy --cli --include "**/*.rs" --verbose | grep -i "unsafe\|memory\|pointer"
# Performance analysis for Rust
ai-code-buddy --cli --include "src/**/*.rs" --exclude "tests/**" --format json | \
jq '.issues[] | select(.category == "Performance")'
# Python security and performance scan
ai-code-buddy --cli --include "**/*.py" --include "**/requirements.txt" --format detailed
# Django/Flask security analysis
ai-code-buddy --cli \
--include "**/*.py" \
--include "**/settings.py" \
--include "**/views.py" \
--include "**/models.py"
# Focus on potential injection vulnerabilities
ai-code-buddy --cli --include "**/*.py" --format json | \
jq '.issues[] | select(.description | contains("injection"))'
# Full Node.js/React project analysis
ai-code-buddy --cli \
--include "**/*.js" --include "**/*.ts" --include "**/*.jsx" --include "**/*.tsx" \
--include "**/package.json" \
--exclude "**/node_modules/**" --exclude "**/dist/**"
# Frontend security focus (XSS, DOM manipulation)
ai-code-buddy --cli \
--include "src/**/*.js" --include "src/**/*.ts" \
--format detailed | grep -i "xss\|dom\|innerhtml"
# API security analysis
ai-code-buddy --cli \
--include "**/routes/**" --include "**/api/**" --include "**/controllers/**" \
--format json
# Focus on core business logic
ai-code-buddy --cli \
--include "src/core/**" \
--include "src/services/**" \
--include "src/models/**" \
--exclude "**/*test*" \
--exclude "**/*spec*"
# Exclude all build and dependency directories
ai-code-buddy --cli \
--exclude "target/**" \
--exclude "node_modules/**" \
--exclude "vendor/**" \
--exclude "dist/**" \
--exclude "build/**" \
--exclude ".git/**" \
--exclude "**/*.min.js"
# Include only configuration and security files
ai-code-buddy --cli \
--include "**/*config*" \
--include "**/*auth*" \
--include "**/*security*" \
--include "**/.env*" \
--include "**/secrets/**"
# Authentication and authorization
ai-code-buddy --cli \
--include "**/*auth*" \
--include "**/*login*" \
--include "**/*session*" \
--include "**/*token*" \
--include "**/*jwt*"
# Database and API security
ai-code-buddy --cli \
--include "**/*db*" \
--include "**/*database*" \
--include "**/*api*" \
--include "**/*query*" \
--include "**/*sql*"
# Configuration and secrets
ai-code-buddy --cli \
--include "**/*.env*" \
--include "**/*config*" \
--include "**/*secret*" \
--include "**/*key*" \
--include "**/settings*"
Each format serves different use cases. Here are examples with actual output from running the tool:
Best for quick overviews and human review:
ai-code-buddy --cli --format summary
Actual Output:
๐ AI Code Review Tool (CLI Mode)
๐ Repository: .
๐ฟ Comparing: main โ HEAD
๐ Starting AI-powered analysis...
๐ Found 36 changed files
๐ GPU acceleration enabled (auto-detected or requested)
๐ง Initializing AI analyzer...
๐ Apple Silicon detected, using Metal backend
๐ง Using backend: Metal
๐ AI inference currently disabled due to token sampling issues
๐ง Using enhanced rule-based analysis for comprehensive code review
๐ง AI Analyzer initialized with Metal backend
๐ Analyzing: .DS_Store (Committed) [0.0%]
๐ Analyzing: build.rs (Staged) [2.8%]
๐ Analyzing: Cargo.toml (Staged) [8.3%]
๐ Analyzing: CHANGELOG.md (Modified) [11.1%]
๐ Analyzing: format_demo.js (Staged) [16.7%]
๐ Analyzing: README.md (Staged) [19.4%]
๐ Analyzing: src/args.rs (Staged) [22.2%]
[... continues with progress indicators ...]
โ
AI analysis complete! Found 43 issues.
๐ฏ Code Review Summary
==========================================
๐ Files analyzed: 36
๐ Total issues: 43
โ ๏ธ Severity breakdown:
๐จ Critical: 7
โ ๏ธ High: 1
๐ถ Medium: 3
โน๏ธ Low: 32
Comprehensive analysis with line-by-line issues:
ai-code-buddy --cli --format detailed --gpu
Actual Output:
๐ฏ Code Review Summary
==========================================
๐ Files analyzed: 36
๐ Total issues: 43
โ ๏ธ Severity breakdown:
๐จ Critical: 7
โ ๏ธ High: 1
๐ถ Medium: 3
โน๏ธ Low: 32
๐ Detailed Analysis:
==========================================
๐จ ๐ก build.rs (Line 100) [staged]: Command injection vulnerability - sanitize inputs
โน๏ธ ๐ด CHANGELOG.md (Line 20) [modified]: Line too long (124 chars) - consider breaking into multiple lines
๐จ ๐ก format_demo.js (Line 1) [staged]: Hardcoded credentials detected - use environment variables
๐จ ๐ก format_demo.js (Line 1) [staged]: Code injection vulnerability - avoid eval/exec
โ ๏ธ ๐ก src/core/ai_analyzer.rs (Line 555) [staged]: Unsafe code block - requires justification and review
๐ถ ๐ก src/core/analysis.rs (Line 50) [staged]: Nested loops detected - consider optimization
โน๏ธ ๐ก README.md (Line 8) [staged]: Line too long (202 chars) - consider breaking into multiple lines
[... continues with all issues ...]
Perfect for automation and CI/CD integration:
ai-code-buddy --cli --format json --gpu
Actual Output:
{
"files_count": 36,
"issues_count": 43,
"critical_issues": 7,
"high_issues": 1,
"medium_issues": 3,
"low_issues": 32,
"issues": [
{
"file": "build.rs",
"line": 100,
"severity": "Critical",
"category": "Security",
"description": "Command injection vulnerability - sanitize inputs",
"commit_status": "Staged"
},
{
"file": "format_demo.js",
"line": 1,
"severity": "Critical",
"category": "Security",
"description": "Hardcoded credentials detected - use environment variables",
"commit_status": "Staged"
},
{
"file": "format_demo.js",
"line": 1,
"severity": "Critical",
"category": "Security",
"description": "Code injection vulnerability - avoid eval/exec",
"commit_status": "Staged"
},
{
"file": "src/core/ai_analyzer.rs",
"line": 555,
"severity": "High",
"category": "Security",
"description": "Unsafe code block - requires justification and review",
"commit_status": "Staged"
},
{
"file": "src/core/analysis.rs",
"line": 50,
"severity": "Medium",
"category": "Performance",
"description": "Nested loops detected - consider optimization",
"commit_status": "Staged"
}
]
}
#### ๐ Markdown Format
Great for documentation and GitHub Issues:
```bash
ai-code-buddy --cli --format markdown --gpu
Actual Output:
# Code Review Report
## Summary
- **Files analyzed**: 36
- **Total issues**: 43
- **Critical**: 7
- **High**: 1
- **Medium**: 3
- **Low**: 32
## Issues
- **build.rs:100** - Critical -  Security - Command injection vulnerability - sanitize inputs
- **CHANGELOG.md:20** - Low -  Code Quality - Line too long (124 chars) - consider breaking into multiple lines
- **format_demo.js:1** - Critical -  Security - Hardcoded credentials detected - use environment variables
- **format_demo.js:1** - Critical -  Security - Code injection vulnerability - avoid eval/exec
- **src/core/ai_analyzer.rs:555** - High -  Security - Unsafe code block - requires justification and review
- **src/core/analysis.rs:50** - Medium -  Performance - Nested loops detected - consider optimization
[... continues with all issues ...]
Include specific file patterns:
ai-code-buddy --cli --format summary --include "src/**" --include "*.js"
Actual Output:
๐ฏ Code Review Summary
==========================================
๐ Files analyzed: 36
๐ Total issues: 32 # Note: Fewer issues (32 vs 43) because only src/ and .js files analyzed
โ ๏ธ Severity breakdown:
๐จ Critical: 5
โ ๏ธ High: 1
๐ถ Medium: 3
โน๏ธ Low: 23
Exclude specific file patterns:
ai-code-buddy --cli --format summary --exclude "test_files/**" --exclude "*.md"
Actual Output:
๐ฏ Code Review Summary
==========================================
๐ Files analyzed: 36
๐ Total issues: 34 # Note: Fewer issues (34 vs 43) because .md files excluded
โ ๏ธ Severity breakdown:
๐จ Critical: 6
โ ๏ธ High: 1
๐ถ Medium: 3
โน๏ธ Low: 24
Verbose output with detailed progress:
ai-code-buddy --cli --format summary --verbose
GPU-accelerated analysis with JSON output:
ai-code-buddy --cli --format json --gpu
Branch comparison with markdown export:
ai-code-buddy --cli --format markdown --source main --target feature-branch > review.md
CI/CD pipeline integration:
# Exit with non-zero code if critical issues found
ai-code-buddy --cli --format json --source main --target HEAD | jq '
if .critical_issues > 0 then
error("Found \(.critical_issues) critical security issues")
else
"โ
No critical issues found"
end'
Security-focused analysis:
ai-code-buddy --cli --format detailed \
--include "**/*config*" \
--include "**/*secret*" \
--include "**/*key*" \
--include "**/settings*"
| Format | Best For | File Size | Human Readable | Machine Parseable |
|---|---|---|---|---|
summary |
Quick daily checks | Smallest | โ High | โ No |
detailed |
Complete code review | Medium | โ High | โ ๏ธ Partial |
json |
CI/CD automation | Medium | โ No | โ Perfect |
markdown |
Documentation/PRs | Largest | โ Perfect | โ ๏ธ Partial |
# Daily development workflow
ai-code-buddy --cli --format summary
# Weekly team review with details
ai-code-buddy --cli --format detailed --source main --target develop | \
tee "weekly-review-$(date +%Y-%U).txt"
# CI/CD automation
ai-code-buddy --cli --format json --source main --target HEAD | jq '
{
"summary": {
"total_issues": (.issues | length),
"critical_issues": (.issues | map(select(.severity == "Critical")) | length),
"files_analyzed": .metrics.files_analyzed
},
"security_issues": (.issues | map(select(.category == "Security"))),
"performance_issues": (.issues | map(select(.category == "Performance")))
}'
# Generate team review report
ai-code-buddy --cli --format markdown --source main --target feature-branch > review.md
# Add to pull request description
echo "## ๐ค AI Code Review Results" >> pr-description.md
ai-code-buddy --cli --format markdown --source main --target HEAD >> pr-description.md
ai-code-buddy [OPTIONS] [REPO_PATH]
| Argument | Description | Default |
|---|---|---|
[REPO_PATH] |
Path to the Git repository | Current directory (.) |
| Option | Short | Description | Default | Example |
|---|---|---|---|---|
--source <BRANCH> |
-s |
Source branch to compare from | main |
-s feature-branch |
--target <BRANCH> |
-t |
Target branch to compare to | HEAD |
-t develop |
--cli |
Run in CLI mode instead of TUI | Interactive TUI | --cli |
|
--verbose |
-v |
Enable verbose output for debugging | Off | -v |
--credits |
Show credits and list all contributors | Off | --credits |
|
--format <FORMAT> |
-f |
Output format for results | summary |
-f json |
--exclude <PATTERN> |
Exclude files matching glob pattern | None | --exclude "test_files/**" |
|
--include <PATTERN> |
Include only files matching glob pattern | None | --include "src/**" |
|
--help |
-h |
Print help information | --help |
|
--version |
-V |
Print version information | --version |
| Format | Description | Use Case |
|---|---|---|
summary |
Summary output with key findings | Quick overview and human review |
detailed |
Detailed output with all issues | Comprehensive analysis |
json |
JSON format for programmatic use | CI/CD integration, tooling |
markdown |
Markdown format for documentation | GitHub Issues, documentation |
AI Code Buddy analyzes code across multiple dimensions:
AI Code Buddy automatically detects and analyzes:
The tool respects standard development environment variables:
# Git configuration
export GIT_DIR="/path/to/.git"
export GIT_WORK_TREE="/path/to/workdir"
# Analysis customization
export AI_CODE_BUDDY_VERBOSE=1 # Enable verbose output
export AI_CODE_BUDDY_FORMAT=json # Set default output format
For large repositories, optimize analysis performance:
# Focus on recent changes only
ai-code-buddy --cli --source HEAD~10 --target HEAD
# Exclude large binary/generated directories
ai-code-buddy --cli \
--exclude "target/**" \
--exclude "node_modules/**" \
--exclude "vendor/**" \
--exclude "*.min.js" \
--exclude "dist/**"
# Parallel analysis (automatic for multiple files)
ai-code-buddy --cli --verbose # Shows parallel processing info
๐ฆ Pre-built Image (Coming Soon):
# Pull from Docker Hub (future release)
docker pull edgarhsanchez/ai-code-buddy:latest
# Run analysis on current directory
docker run -v $(pwd):/workspace edgarhsanchez/ai-code-buddy:latest --cli
๐ง Build Your Own Image:
# Dockerfile
FROM rust:1.70-slim as builder
WORKDIR /app
COPY . .
RUN cargo build --release
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y \
git \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/target/release/ai-code-buddy /usr/local/bin/
ENTRYPOINT ["ai-code-buddy"]
# Build the image
docker build -t ai-code-buddy .
# Run analysis
docker run -v $(pwd):/workspace -w /workspace ai-code-buddy --cli
๐ Development Environment:
# docker-compose.yml
version: '3.8'
services:
code-review:
build: .
volumes:
- .:/workspace
- ./reports:/reports
working_dir: /workspace
command: ["--cli", "--format", "json"]
environment:
- AI_CODE_BUDDY_VERBOSE=1
# Run with Docker Compose
docker-compose run code-review --source main --target HEAD
๐ Automated Code Review Job:
# k8s-code-review-job.yaml
apiVersion: batch/v1
kind: Job
metadata:
name: ai-code-review
spec:
template:
spec:
containers:
- name: ai-code-buddy
image: edgarhsanchez/ai-code-buddy:latest
command: ["ai-code-buddy"]
args: ["--cli", "--format", "json", "--source", "main", "--target", "HEAD"]
volumeMounts:
- name: source-code
mountPath: /workspace
- name: reports
mountPath: /reports
env:
- name: AI_CODE_BUDDY_FORMAT
value: "json"
volumes:
- name: source-code
gitRepo:
repository: "https://github.com/your-org/your-repo.git"
- name: reports
persistentVolumeClaim:
claimName: reports-pvc
restartPolicy: Never
๐ Scheduled Security Scans:
#!/bin/bash
# enterprise-security-scan.sh
# Daily security scan with Docker
docker run --rm \
-v /opt/repositories:/repositories \
-v /opt/reports:/reports \
edgarhsanchez/ai-code-buddy:latest \
--cli --format json \
--include "**/*.rs" --include "**/*.py" --include "**/*.js" \
--exclude "**/test/**" \
/repositories/critical-app > /reports/daily-scan-$(date +%Y%m%d).json
# Check for critical issues and alert
CRITICAL_COUNT=$(jq '[.issues[] | select(.severity == "Critical")] | length' /reports/daily-scan-$(date +%Y%m%d).json)
if [ "$CRITICAL_COUNT" -gt 0 ]; then
# Send alert to security team
slack-notify "๐จ $CRITICAL_COUNT critical security issues found in daily scan!"
fi
๐ Multi-Repository Analysis:
# multi-repo-analysis.yml
version: '3.8'
services:
frontend-review:
image: edgarhsanchez/ai-code-buddy:latest
volumes:
- ./frontend:/workspace
command: ["--cli", "--include", "**/*.js", "--include", "**/*.ts", "--format", "json"]
backend-review:
image: edgarhsanchez/ai-code-buddy:latest
volumes:
- ./backend:/workspace
command: ["--cli", "--include", "**/*.rs", "--format", "json"]
mobile-review:
image: edgarhsanchez/ai-code-buddy:latest
volumes:
- ./mobile:/workspace
command: ["--cli", "--include", "**/*.swift", "--include", "**/*.kt", "--format", "json"]
# Exclude large directories for faster analysis
ai-code-buddy --cli --exclude "target/**" --exclude "node_modules/**" --exclude "dist/**"
# Focus on specific areas
ai-code-buddy --cli --include "src/**" --include "lib/**"
# Use JSON format for programmatic processing
ai-code-buddy --cli --format json | jq '.issues.Security | length'
# Run comprehensive OWASP analysis
ai-code-buddy --cli --include "**/*.js" --include "**/*.py" --include "**/*.rs" --format detailed
# Focus on authentication and authorization code
ai-code-buddy --cli --include "**/auth/**" --include "**/security/**"
# Check for hardcoded secrets
ai-code-buddy --cli --verbose | grep -i "secret\|password\|key"
Pre-commit analysis:
ai-code-buddy --cli --source main --target HEAD
Feature branch review:
ai-code-buddy --cli --source main --target feature/new-feature --format markdown > review.md
CI/CD integration:
ai-code-buddy --cli --format json > review.json
# Parse JSON for automated decision making
# Include patterns (multiple patterns supported)
ai-code-buddy --cli \
--include "src/**/*.rs" \
--include "lib/**/*.rs" \
--include "tests/**/*.rs"
# Exclude patterns (combine with include for precision)
ai-code-buddy --cli \
--include "**/*.py" \
--exclude "**/migrations/**" \
--exclude "**/venv/**" \
--exclude "**/__pycache__/**"
AI Code Buddy includes comprehensive OWASP Top 10 security analysis with precise line-by-line vulnerability detection:
๐จ A01: Broken Access Control
๐ A02: Cryptographic Failures
๐ A03: Injection
โ ๏ธ A04: Insecure Design
๐ง A05: Security Misconfiguration
๐งฉ A06: Vulnerable Components
๐ A07: Authentication Failures
๐ก๏ธ A08: Software Integrity Failures
๐ A09: Logging & Monitoring Failures
๐ A10: Server-Side Request Forgery
-v) for debugging analysis issues# Exclude common build/generated directories
ai-code-buddy --cli --exclude "target/**" --exclude "node_modules/**" --exclude ".git/**"
# Include only source code
ai-code-buddy --cli --include "src/**" --include "lib/**" --include "tests/**"
# Language-specific filtering
ai-code-buddy --cli --include "**/*.rs" --include "**/*.toml" # Rust projects
ai-code-buddy --cli --include "**/*.js" --include "**/*.ts" # JavaScript projects # JavaScript projects
# Verify you're in a git repository
git status
# Initialize git if needed
git init
# Or specify repository path explicitly
ai-code-buddy --cli /path/to/your/repo
# List available branches
git branch -a
# Use correct branch names (check remote branches)
ai-code-buddy --cli --source origin/main --target feature-branch
# For new repositories with default branch
ai-code-buddy --cli --source HEAD~1 --target HEAD
This usually indicates:
Solutions:
# Check what files are being analyzed
ai-code-buddy --cli --verbose
# Broaden file inclusion
ai-code-buddy --cli --include "**/*"
# Check different branches
ai-code-buddy --cli --source HEAD~5 --target HEAD
# Exclude build directories
ai-code-buddy --cli --exclude "target/**" --exclude "node_modules/**"
# Focus on recent changes
ai-code-buddy --cli --source HEAD~10 --target HEAD
# Use more specific file patterns
ai-code-buddy --cli --include "src/**/*.rs"
# If TUI doesn't display correctly, use CLI mode
ai-code-buddy --cli
# Check terminal compatibility
echo $TERM
# For terminals with limited Unicode support
TERM=xterm-256color ai-code-buddy
# For very large repositories, increase available memory or use filtering
ai-code-buddy --cli --exclude "vendor/**" --exclude "third_party/**"
# Process files in smaller batches
ai-code-buddy --cli --include "src/module1/**"
ai-code-buddy --cli --include "src/module2/**"
ai-code-buddy --cli --verbose
Shows detailed processing information including:
ai-code-buddy --version
ai-code-buddy --help
ai-code-buddy --credits
# Success - analysis completed without errors
echo $? # Returns 0
# Error - analysis failed or invalid arguments
echo $? # Returns 1
# Critical issues found (when configured)
echo $? # Returns 2
# GitHub Actions example
name: Code Review
on: [pull_request]
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history for branch comparison
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install AI Code Buddy
run: cargo install ai-code-buddy
- name: Run Analysis
run: |
ai-code-buddy --cli \
--format json \
--source ${{ github.event.pull_request.base.ref }} \
--target ${{ github.event.pull_request.head.ref }} \
> review.json
- name: Check for Critical Issues
run: |
CRITICAL_ISSUES=$(jq '.issues | to_entries[] | select(.value[] | .severity == "Critical") | length' review.json)
if [ "$CRITICAL_ISSUES" -gt 0 ]; then
echo "Found $CRITICAL_ISSUES critical security issues"
exit 1
fi
- name: Post Review Comment
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const review = JSON.parse(fs.readFileSync('review.json', 'utf8'));
// Process and post review results
#!/bin/sh
# .git/hooks/pre-commit
echo "Running AI Code Buddy analysis..."
ai-code-buddy --cli --format summary --source HEAD~1 --target HEAD
if [ $? -ne 0 ]; then
echo "Code review found critical issues. Commit aborted."
exit 1
fi
// VS Code tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "AI Code Review",
"type": "shell",
"command": "ai-code-buddy",
"args": ["--cli", "--source", "main", "--target", "HEAD"],
"group": "build",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "new"
}
}
]
}
# Set default options
export AI_CODE_BUDDY_DEFAULT_SOURCE="main"
export AI_CODE_BUDDY_DEFAULT_TARGET="HEAD"
export AI_CODE_BUDDY_DEFAULT_FORMAT="summary"
# Git configuration (respects standard Git environment)
export GIT_DIR="/custom/.git"
export GIT_WORK_TREE="/custom/workdir"
# Performance tuning
export AI_CODE_BUDDY_CACHE_DIR="/tmp/ai-code-buddy-cache"
export AI_CODE_BUDDY_MAX_FILE_SIZE="1048576" # 1MB limit
โ Q: What programming languages does AI Code Buddy support? ๐ก A: Currently supports Rust, JavaScript/TypeScript, and Python with language-specific security and performance analysis. Go, Java, C++, and C# support is planned for 2025.
โ Q: Does it work with any Git repository? ๐ก A: Yes! AI Code Buddy works with any Git repository and can analyze both committed and uncommitted changes. It automatically detects the repository structure and programming languages.
โ Q: Can I use it without GPU acceleration? ๐ก A: Absolutely! The tool includes a comprehensive rule-based analysis engine that provides excellent results on CPU-only systems. GPU acceleration is an optional enhancement.
โ Q: How long does analysis take? ๐ก A: Analysis time varies by repository size:
--exclude patterns to focus analysis and reduce time.โ Q: How accurate are the security vulnerability detections? ๐ก A: Our OWASP-based analysis has a 95%+ accuracy rate for critical vulnerabilities with minimal false positives. The tool is designed for precision over recall to avoid alert fatigue.
โ Q: Can I customize the analysis rules?
๐ก A: Custom rule configuration is planned for Q2 2025. Currently, you can use --include and --exclude patterns to focus analysis on specific areas of your codebase.
โ Q: Does it store or transmit my code anywhere? ๐ก A: No! All analysis happens locally on your machine. No code is transmitted to external servers or stored anywhere except your local file system.
โ Q: How do I integrate with my CI/CD pipeline?
๐ก A: Use the --cli mode with --format json for programmatic integration. Check the CI/CD examples section for GitHub Actions, GitLab CI, and Jenkins templates.
โ Q: Why am I getting "cargo: command not found"? ๐ก A: You need to install Rust first:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/env
โ Q: How do I enable GPU acceleration? ๐ก A: GPU acceleration is automatically detected during installation. For manual control:
# Force GPU features
cargo install ai-code-buddy --features gpu-metal # Apple Silicon
cargo install ai-code-buddy --features gpu-cuda # NVIDIA (Windows only)
โ Q: Can I run this in Docker? ๐ก A: Yes! See the Docker section for container usage examples. Perfect for CI/CD environments where you don't want to install Rust directly.
โ Q: Analysis is taking too long. How can I speed it up? ๐ก A: Use these optimization strategies:
# Exclude large directories
ai-code-buddy --cli --exclude "target/**" --exclude "node_modules/**"
# Focus on recent changes only
ai-code-buddy --cli --source HEAD~10 --target HEAD
# Analyze specific languages
ai-code-buddy --cli --include "**/*.rs" --include "**/*.py"
โ Q: Does it work well with large monorepos? ๐ก A: Yes, but use filtering for best performance. The tool is optimized for repositories up to 100k files with proper exclusion patterns.
โ Q: Can I run multiple analyses in parallel?
๐ก A: Each ai-code-buddy instance analyzes files in parallel internally. For multiple repositories, run separate instances or use Docker Compose with multiple services.
โ Q: What's the difference between output formats? ๐ก A:
summary: Human-readable overview (default)detailed: Complete issue list with descriptionsjson: Machine-readable for automationmarkdown: Perfect for documentation and reportsโ Q: How do I filter issues by severity?
๐ก A: Use jq with JSON output:
ai-code-buddy --cli --format json | jq '.issues[] | select(.severity == "Critical")'
โ Q: Can I export reports to other tools? ๐ก A: Yes! JSON output integrates with most tools. Markdown works great for GitHub Issues, and the format is compatible with many security platforms.
โ Q: I'm seeing "GPU support requested but not compiled in" - what's wrong? ๐ก A: This happens when GPU features weren't included during compilation. Reinstall with explicit features:
cargo install ai-code-buddy --features gpu-metal --force # Apple Silicon
โ Q: The tool isn't finding issues in my JavaScript code. Why?
๐ก A: Make sure your files have proper extensions (.js, .ts, .jsx, .tsx) and aren't in excluded directories like node_modules/.
โ Q: How do I report a false positive or false negative? ๐ก A: Please open an issue on GitHub with:
--verbose flag for debugging infoโ Q: The analysis seems stuck. What should I do? ๐ก A: Try these steps:
--verbose to see progress details--exclude "**/*.{jpg,png,pdf,zip}"โ Q: How can I contribute new language support?
๐ก A: We'd love your help! Check the Contributing section for guidelines on adding new language patterns. Start with the detect_language() function in ai_analyzer.rs.
โ Q: Can I add custom security rules?
๐ก A: Custom rules will be supported in Q2 2025. For now, you can modify the patterns in rule_based_analysis() and build from source.
โ Q: How do I build from source for development? ๐ก A:
git clone https://github.com/edgarhsanchez/ai_code_buddy.git
cd ai_code_buddy
cargo build --release
./target/release/ai-code-buddy --help
AI Code Buddy maintains comprehensive test coverage to ensure reliability and quality.
# Run all tests
cargo test
# Run tests with focused coverage (see tarpaulin.toml for filters)
cargo coverage --verbose
# Run specific test suites
cargo test --test test_args
cargo test --test test_git
cargo test --test test_widget_states
cargo test --test test_integration
Our testing strategy includes:
Core Module Tests
test_args.rs: CLI argument parsing and validation (7 tests)test_git.rs: Git repository operations and analysis (6 tests)test_theme.rs: UI theming and styling (14 tests)test_review.rs: Code review data structures (5 tests)Widget State Tests
test_widget_states.rs: UI state management and transitions (21 tests)Integration Tests
test_integration.rs: End-to-end UI component testing (7 tests)We strive for high test coverage with the following priorities:
# Generate HTML coverage report (respects tarpaulin.toml)
cargo coverage --verbose --out Html
# Generate JSON coverage data (optional)
cargo coverage --out Json
# View coverage in browser
open coverage/tarpaulin-report.html
We welcome contributions! Here's how you can help:
Fork and Clone
git clone https://github.com/your-username/ai_code_buddy.git
cd ai_code_buddy
Development Setup
# Install Rust if needed
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Build the project
cargo build
# Run tests
cargo test
# Test the CLI
cargo run -- --cli --help
Create a Feature Branch
git checkout -b feature/amazing-feature
Make Your Changes and Test
# Test your changes with the tool itself
cargo run -- --cli --source main --target feature/amazing-feature
# Run the full test suite
cargo test --all-features
# Check formatting and linting
cargo fmt --check
cargo clippy -- -D warnings
Commit and Push
# Use conventional commit format for automated versioning
./commit.sh feat "add amazing feature"
# Or commit manually following conventional format:
git add .
git commit -m "feat: add amazing feature"
git push origin feature/amazing-feature
This project uses Conventional Commits for automated semantic versioning and release management.
Commit Message Format:
type(scope): description
[optional body]
[optional footer]
Types that trigger version bumps:
feat: โ MINOR version bump (new features)fix: โ PATCH version bump (bug fixes)feat!: or BREAKING CHANGE: โ MAJOR version bumpQuick commit examples:
./commit.sh feat "add user authentication system"
./commit.sh fix "resolve memory leak in analysis"
./commit.sh docs "update installation guide"
Automated Release Process:
When your PR is merged to main:
Cargo.toml version is automatically updatedv1.2.3)๐ Full Guide: See CONVENTIONAL_COMMITS.md for detailed information.
Open a Pull Request
# Test with different repositories
cd /path/to/test-repo
/path/to/ai_code_buddy/target/debug/ai-code-buddy --cli
# Test with the included example files
cd /path/to/ai_code_buddy
cargo run -- --cli --include "test_files/**" --format detailed
# Test TUI mode
cargo run
# Test output formats
cargo run -- --cli --format json
cargo run -- --cli --format markdown
cargo fmt and cargo clippyfeat:, fix:, docs:, etc.)This project is licensed under the MIT License - see the LICENSE file for details.
.ai-code-buddy.toml configuration filesMachine Learning Enhancements
Enterprise Features
Performance & Scalability
Made with โค๏ธ and ๐ฆ by the AI Code Buddy team
For more examples, advanced usage guides, and community discussions, visit our documentation and join our discussions.