Skip to main content

RA.Aid - ReAct Aid

Project description

██▀███   ▄▄▄            ▄▄▄       ██▓▓█████▄ 
▓██ ▒ ██▒▒████▄         ▒████▄    ▓██▒▒██▀ ██▌
▓██ ░▄█ ▒▒██  ▀█▄       ▒██  ▀█▄  ▒██▒░██   █▌
▒██▀▀█▄  ░██▄▄▄▄██      ░██▄▄▄▄██ ░██░░▓█▄   ▌
░██▓ ▒██▒ ▓█   ▓██▒ ██▓  ▓█   ▓██▒░██░░▒████▓ 
░ ▒▓ ░▒▓░ ▒▒   ▓▒█░ ▒▓▒  ▒▒   ▓▒█░░▓   ▒▒▓  ▒ 
 ░▒ ░ ▒░  ▒   ▒▒ ░ ░▒    ▒   ▒▒ ░ ▒ ░ ░ ▒  ▒ 
 ░░   ░   ░   ▒    ░     ░   ▒    ▒ ░ ░ ░  ░ 
  ░           ░  ░  ░        ░  ░ ░     ░    
                    ░                 ░      

Python Versions License Status

RA.Aid Demo

RA.Aid

RA.Aid (ReAct Aid) is a powerful AI-driven command-line tool that integrates aider (https://aider.chat/) within a LangChain ReAct agent loop. This unique combination allows developers to leverage aider's code editing capabilities while benefiting from LangChain's agent-based task execution framework. The tool provides an intelligent assistant that can help with research, planning, and implementation of development tasks.

⚠️ IMPORTANT: USE AT YOUR OWN RISK ⚠️

  • This tool can and will automatically execute shell commands on your system
  • Shell commands require interactive approval unless --cowboy-mode is enabled
  • The --cowboy-mode flag disables command approval and should be used with extreme caution
  • No warranty is provided, either express or implied
  • Always review the actions the agent proposes before allowing them to proceed

Key Features

  • Multi-Step Task Planning: The agent breaks down complex tasks into discrete, manageable steps and executes them sequentially. This systematic approach ensures thorough implementation and reduces errors.

  • Automated Command Execution: The agent can run shell commands automatically to accomplish tasks. While this makes it powerful, it also means you should carefully review its actions.

  • Three-Stage Architecture:

    1. Research: Analyzes codebases and gathers context
    2. Planning: Breaks down tasks into specific, actionable steps
    3. Implementation: Executes each planned step sequentially

What sets RA.Aid apart is its ability to handle complex programming tasks that extend beyond single-shot code edits. By combining research, strategic planning, and implementation into a cohesive workflow, RA.Aid can:

  • Break down and execute multi-step programming tasks
  • Research and analyze complex codebases to answer architectural questions
  • Plan and implement significant code changes across multiple files
  • Provide detailed explanations of existing code structure and functionality
  • Execute sophisticated refactoring operations with proper planning

Table of Contents

Features

  • Three-Stage Architecture: The workflow consists of three powerful stages:

    1. Research 🔍 - Gather and analyze information
    2. Planning 📋 - Develop execution strategy
    3. Implementation ⚡ - Execute the plan with AI assistance

    Each stage is powered by dedicated AI agents and specialized toolsets.

  • Advanced AI Integration: Built on LangChain and leverages the latest LLMs for natural language understanding and generation.

  • Comprehensive Toolset:

    • Shell command execution
    • Expert querying system
    • File operations and management
    • Memory management
    • Research and planning tools
    • Code analysis capabilities
  • Interactive CLI Interface: Simple yet powerful command-line interface for seamless interaction

  • Modular Design: Structured as a Python package with specialized modules for console output, processing, text utilities, and tools

  • Git Integration: Built-in support for Git operations and repository management

Installation

RA.Aid can be installed directly using pip:

pip install ra-aid

Prerequisites

Before using RA.Aid, you'll need:

  1. Python package aider installed and available in your PATH:
pip install aider-chat
  1. API keys for the required AI services:
# Required: Set up your Anthropic API key
export ANTHROPIC_API_KEY=your_api_key_here

# Optional: Set up OpenAI API key if using OpenAI features
export OPENAI_API_KEY=your_api_key_here

You can get your API keys from:

Usage

RA.Aid is designed to be simple yet powerful. Here's how to use it:

# Basic usage
ra-aid -m "Your task or query here"

# Research-only mode (no implementation)
ra-aid -m "Explain the authentication flow" --research-only

Command Line Options

  • -m, --message: The task or query to be executed (required)
  • --research-only: Only perform research without implementation
  • --cowboy-mode: Skip interactive approval for shell commands

Example Tasks

  1. Code Implementation:

    ra-aid -m "Add input validation to the user registration endpoint"
    
  2. Code Research:

    ra-aid -m "Explain how the authentication middleware works" --research-only
    
  3. Refactoring:

    ra-aid -m "Refactor the database connection code to use connection pooling"
    
  4. Non-Interactive Mode:

    ra-aid -m "Update all deprecated API calls" --cowboy-mode
    

Environment Variables

RA.Aid uses the following environment variables:

  • ANTHROPIC_API_KEY (Required): Your Anthropic API key for accessing Claude
  • OPENAI_API_KEY (Optional): Your OpenAI API key if using OpenAI features

You can set these permanently in your shell's configuration file (e.g., ~/.bashrc or ~/.zshrc):

export ANTHROPIC_API_KEY=your_api_key_here
export OPENAI_API_KEY=your_api_key_here

Architecture

RA.Aid implements a three-stage architecture for handling development and research tasks:

  1. Research Stage:

    • Gathers information and context
    • Analyzes requirements
    • Identifies key components and dependencies
  2. Planning Stage:

    • Develops detailed implementation plans
    • Breaks down tasks into manageable steps
    • Identifies potential challenges and solutions
  3. Implementation Stage:

    • Executes planned tasks
    • Generates code or documentation
    • Performs necessary system operations

Core Components

  • Console Module (console/): Handles console output formatting and user interaction
  • Processing Module (proc/): Manages interactive processing and workflow control
  • Text Module (text/): Provides text processing and manipulation utilities
  • Tools Module (tools/): Contains various utility tools for file operations, search, and more

Dependencies

Core Dependencies

  • langchain-anthropic: LangChain integration with Anthropic's Claude
  • langgraph: Graph-based workflow management
  • rich>=13.0.0: Terminal formatting and output
  • GitPython==3.1.41: Git repository management
  • fuzzywuzzy==0.18.0: Fuzzy string matching
  • python-Levenshtein==0.23.0: Fast string matching
  • pathspec>=0.11.0: Path specification utilities

Development Dependencies

  • pytest>=7.0.0: Testing framework
  • pytest-timeout>=2.2.0: Test timeout management

Development Setup

  1. Clone the repository:
git clone https://github.com/ai-christianson/ra-aid.git
cd ra-aid
  1. Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows use `venv\Scripts\activate`
  1. Install development dependencies:
pip install -r requirements-dev.txt
  1. Run tests:
python -m pytest

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch:
git checkout -b feature/your-feature-name
  1. Make your changes and commit:
git commit -m 'Add some feature'
  1. Push to your fork:
git push origin feature/your-feature-name
  1. Open a Pull Request

Guidelines

  • Follow PEP 8 style guidelines
  • Add tests for new features
  • Update documentation as needed
  • Keep commits focused and message clear
  • Ensure all tests pass before submitting PR

License

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

Copyright (c) 2024 AI Christianson

Contact

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ra_aid-0.1.4.tar.gz (4.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ra_aid-0.1.4-py3-none-any.whl (39.3 kB view details)

Uploaded Python 3

File details

Details for the file ra_aid-0.1.4.tar.gz.

File metadata

  • Download URL: ra_aid-0.1.4.tar.gz
  • Upload date:
  • Size: 4.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for ra_aid-0.1.4.tar.gz
Algorithm Hash digest
SHA256 44b7c2239a689527439a2d5b79e6e49594b84fbedb0bb37be7f579397e2b12b7
MD5 868d5bbb7b717cf6421b116db98bf838
BLAKE2b-256 61eb2ecb952f775783579259184b2248462ec915828258ead5f28ff962980c83

See more details on using hashes here.

File details

Details for the file ra_aid-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: ra_aid-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 39.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for ra_aid-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 822095531df4a729bb63b2001154762c966c7ddf7fae7953bed477a71d4d46a1
MD5 1cfb0724ecbf75fe795c5e65c84245f6
BLAKE2b-256 c0a1c5f7011f1b353b32f278a19991a4aaf9898a6105505f75d7d83e257ccc54

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page