# 🧞‍♂️ Bat Genie: Your AI-Powered Development Companion

Transform your Cursor IDE into an intelligent, proactive development assistant that anticipates your needs and supercharges your coding workflow. Built on top of the powerful [devin.cursorrules](https://github.com/grapeot/devin.cursorrules) framework, Bat Genie takes it further with enhanced features and practical developer tools.

## 🌟 What Makes Bat Genie Special?

Bat Genie combines the power of multiple AI models and development tools to become your personal coding companion. It's like having a senior developer, security expert, and documentation specialist all rolled into one.

### Real-World Examples

1. **Code Review & Optimization**
```python
# Before: A simple but inefficient function
def find_duplicates(lst):
    duplicates = []
    for i in range(len(lst)):
        for j in range(i + 1, len(lst)):
            if lst[i] == lst[j] and lst[i] not in duplicates:
                duplicates.append(lst[i])
    return duplicates

# After Bat Genie's optimization:
from collections import Counter

def find_duplicates(lst):
    return [item for item, count in Counter(lst).items() if count > 1]
# Performance improved from O(n²) to O(n)
```

2. **Security Vulnerability Detection**
```python
# Before: Vulnerable code
@app.route('/user/<username>')
def user_profile(username):
    query = f"SELECT * FROM users WHERE username = '{username}'"
    return db.execute(query).fetchone()

# After Bat Genie's security analysis:
@app.route('/user/<username>')
@login_required
def user_profile(username):
    if not re.match(r'^[a-zA-Z0-9_]+$', username):
        return jsonify({"error": "Invalid username"}), 400
    query = "SELECT * FROM users WHERE username = ?"
    return db.execute(query, (username,)).fetchone()
```

3. **Smart Dependency Management**
```python
# Input: "Need a modern web API with async support and PostgreSQL"
# Bat Genie suggests:
fastapi>=0.103.2  # Modern async web framework
sqlalchemy>=2.0.22  # SQL toolkit and ORM
asyncpg>=0.28.0  # High-performance PostgreSQL client
pydantic>=2.4.2  # Data validation
alembic>=1.12.0  # Database migrations
```

4. **Automated Documentation**
```python
# Before: Undocumented code
class DataProcessor:
    def process_data(self, data, options=None):
        if options is None:
            options = {}
        cleaned_data = self._clean_data(data)
        return self._transform_data(cleaned_data, options)

# After Bat Genie's documentation:
class DataProcessor:
    """A flexible data processing pipeline for cleaning and transforming data.
    
    This class implements a two-step data processing workflow:
    1. Data cleaning: Removes invalid or None values
    2. Data transformation: Applies custom transformations
    
    Examples:
        >>> processor = DataProcessor()
        >>> data = [1, None, 3, None, 5]
        >>> processor.process_data(data, {'transform_func': lambda x: x * 2})
        [2, 6, 10]
    """
```

## 🚀 Features

1. **Intelligent Code Analysis**
   - Real-time code review and suggestions
   - Performance optimization recommendations
   - Security vulnerability detection
   - Best practices enforcement

2. **Smart Documentation**
   - Automatic docstring generation
   - README creation and maintenance
   - API documentation
   - Code examples and usage patterns

3. **Development Workflow Optimization**
   - Dependency management
   - Code refactoring suggestions
   - Test case generation
   - Error analysis and debugging

4. **Multi-Agent Architecture**
   - Strategic Planner (powered by OpenAI's o1)
   - Tactical Executor (powered by Claude/GPT-4)
   - Continuous learning and improvement

## 🔄 Staying Updated

Bat Genie is built as a Git submodule on top of [devin.cursorrules](https://github.com/grapeot/devin.cursorrules), ensuring you always have access to the latest improvements:

```bash
# Initial setup
git submodule add https://github.com/grapeot/devin.cursorrules .cursor/devin
git submodule update --init --recursive

# Update to latest version
git submodule update --remote .cursor/devin
```

## 🛠️ Setup

1. Clone the repository with submodules:
```bash
git clone --recursive https://github.com/yourusername/bat-genie.git
cd bat-genie
```

2. Create and activate Python environment:
```bash
python3 -m venv venv
source venv/bin/activate  # On Windows: .\venv\Scripts\activate
```

3. Install dependencies:
```bash
pip install -r requirements.txt
```

4. Configure your environment:
```bash
cp .env.example .env
# Edit .env with your API keys
```

## 💡 Usage Examples

### Daily Development Tasks

1. **Code Review**
```python
from bat_genie import CodeReviewer

# Review current file or specific code
await reviewer.review_current_file()
```

2. **Dependency Analysis**
```python
from bat_genie import DependencyManager

# Get smart package recommendations
await manager.suggest_dependencies("Need a modern web framework with auth")
```

3. **Security Audit**
```python
from bat_genie import SecurityAnalyzer

# Analyze security of your codebase
await analyzer.audit_directory("./src")
```

## 🤝 Contributing

Contributions are welcome! Check out our [Contributing Guidelines](CONTRIBUTING.md) for details.

## 📄 License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## 🙏 Acknowledgments

Built on top of the excellent [devin.cursorrules](https://github.com/grapeot/devin.cursorrules) project by [@grapeot](https://github.com/grapeot).
