# SWE Agent - Headless Agentic IDE

A cutting-edge multi-agent Software Engineering system that leverages advanced LangGraph state machines for intelligent code analysis, generation, and workflow optimization.

## 🚀 Quick Start

### Installation
```bash
pip install swe-ai-agent
```

### Basic Usage
```bash
# Interactive mode
swe-agent --interactive

# Pair programming interface
swe-agent --pair

# Modern terminal interface
swe-agent --warp

# Direct task execution
swe-agent --task "create a Python calculator"
```

## 🎯 Features

### Multi-Agent Architecture
- **Planner Agent**: Creates comprehensive project plans with human approval workflow
- **Software Engineer Agent**: Main orchestrator for task delegation and workflow management
- **Code Analyzer Agent**: Specializes in code analysis with universal language detection
- **Editor Agent**: Handles file navigation, editing, and patch creation

### Universal Language Support
- **Language-Agnostic**: Supports all programming languages through Claude's natural understanding
- **No Hardcoded Rules**: Uses AI comprehension instead of predefined language patterns
- **Smart Detection**: Automatically identifies project structure and dependencies

### Advanced Interface Options
- **Interactive Mode**: Continuous task input and execution
- **Pair Programming**: Aider-inspired terminal UI for conversational development
- **Warp Interface**: Modern AI-powered terminal with code diff visualization
- **Direct Tasks**: One-shot task execution with comprehensive results

### Comprehensive Tool Suite
- **23 Advanced Tools**: File operations, shell commands, git integration, code analysis
- **Security Scanning**: Automated code security analysis with detect-secrets
- **Tool Usage Tracking**: Monitor and analyze tool usage patterns
- **Workflow Analytics**: Detailed performance metrics and optimization

## 🛠️ Architecture

### Core Components
```
SWE Agent/
├── Multi-Agent System (LangGraph + Claude Sonnet 4)
├── Universal Language Support (No hardcoded rules)
├── Advanced Tool Suite (23 tools)
├── State Machine Orchestration
└── Rich CLI Interfaces
```

### Key Technologies
- **LangGraph**: State machine orchestration and agent coordination
- **Claude Sonnet 4**: Latest Anthropic model for natural language understanding
- **Rich**: Enhanced CLI interface with professional formatting
- **Security Integration**: Comprehensive code security scanning

## 📋 Usage Examples

### Interactive Development
```bash
swe-agent --interactive
> analyze this codebase
> create tests for the main module
> refactor the authentication system
> add error handling to the API
```

### Pair Programming
```bash
swe-agent --pair
# Launches Aider-inspired interface with:
# - File context management
# - Git integration
# - Conversational development
# - Real-time code assistance
```

### Modern Terminal (Warp Style)
```bash
swe-agent --warp
# Features:
# - AI-powered command suggestions
# - Visual code diff display
# - Git status integration
# - Multi-panel layout
```

### Direct Task Execution
```bash
swe-agent --task "build a REST API with authentication"
swe-agent --task "add comprehensive logging to the project"
swe-agent --task "optimize database queries for performance"
```

## 🔧 Configuration

### Environment Variables
```bash
export ANTHROPIC_API_KEY="your_api_key_here"
```

### Optional Configuration
```bash
# Enable planner for complex tasks
swe-agent --task "complex project" --use-planner

# Set custom output directory
swe-agent --interactive --output-dir ./custom-output

# Configure repository path
swe-agent --pair --repo-path /path/to/project
```

## 📊 Performance Features

### Tool Usage Analytics
- Track which tools each agent uses
- Monitor workflow performance
- Identify optimization opportunities
- View detailed usage statistics

### Security Scanning
- Automatic code security analysis
- Integration with detect-secrets
- Comprehensive vulnerability detection
- Security best practices enforcement

### Workflow Optimization
- Intelligent task routing
- Loop prevention mechanisms
- Progress tracking and reporting
- Error handling and recovery

## 🎨 Interface Screenshots

### Warp Interface
- Modern terminal with AI integration
- Visual code diff display
- Git status and branch information
- Multi-panel layout with command history

### Pair Programming
- Conversational development interface
- File context management
- Git integration and status
- Real-time code assistance

## 🔒 Security

### Code Security Scanning
- Automated vulnerability detection
- Secret detection and prevention
- Security best practices enforcement
- Integration with industry-standard tools

### Safe Operations
- Backup system for file modifications
- Git integration for version control
- Comprehensive error handling
- User confirmation for destructive operations

## 📈 Recent Updates (v1.0.12)

### Latest Features
- **Enhanced Warp Interface**: Fixed AI command execution and added code diff visualization
- **Improved Error Handling**: Better workflow method calls and error recovery
- **Visual Code Diffs**: Show exactly what code changes were made, similar to VS Code
- **Fallback Detection**: Smart file change detection when git is restricted

### Bug Fixes
- Fixed workflow method calls from `run()` to `run_workflow()`
- Improved AI command execution in terminal interfaces
- Enhanced change detection with fallback mechanisms
- Better error messages and user feedback

## 🤝 Contributing

### Development Setup
```bash
git clone https://github.com/your-repo/swe-agent
cd swe-agent
pip install -e .
```

### Running Tests
```bash
# Run specific workflows
python main.py --task "test task"

# Interactive testing
python main.py --interactive

# Pair programming mode
python main.py --pair
```

## 📝 License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.

## 🔗 Links

- **PyPI Package**: https://pypi.org/project/swe-ai-agent/
- **Documentation**: Coming soon
- **Issues**: Report bugs and request features
- **Discussions**: Join the community

## 🆕 What's New

### Version 1.0.12
- Enhanced Warp terminal interface with code diff visualization
- Fixed AI command execution workflow methods
- Improved error handling and user feedback
- Added fallback file change detection

### Version 1.0.11
- Comprehensive security scanning with detect-secrets
- Enhanced tool suite with 23 advanced tools
- Improved agent prompts and tool documentation

### Version 1.0.10
- Working PyPI package with all interfaces functional
- Pair programming terminal interface
- Modern Warp-style terminal with AI integration

---

Built with ❤️ using Claude Sonnet 4 and LangGraph state machines.