Skip to content

DaveAlessi/github-auto-fixer

Repository files navigation

GitHub Auto-Fixer

An automated tool that uses LLMs to fix code issues in GitHub repositories.

Features

  • Creates branches and fixes code issues automatically
  • Uses LLM (OpenAI/Anthropic) to generate fixes
  • Creates pull requests with proposed changes
  • Monitors CI/CD tests and retries on failures
  • Iteratively improves fixes based on test feedback

Setup

  1. Clone this repository

  2. Install dependencies:

    pip install -r requirements.txt
  3. Copy .env.example to .env and fill in your credentials:

    cp .env.example .env
  4. Edit .env with your GitHub token and LLM API key

Usage

python main.py --repo "DaveAlessi/ClockGPT" --file "server.js" --issue "Cross-site request forgery" --branch "auto-fix-working-branch" --base-branch "main" --line-numbers "9" --max-retries 2

Project Structure

github-auto-fixer/
├── config/          # Configuration and prompt templates
├── models/          # Data models
├── services/        # External API integrations
├── parsers/         # Response parsing utilities
├── orchestration/   # Main workflow logic
├── utils/           # Helper utilities
└── tests/           # Unit tests

Requirements

  • Python 3.9+
  • GitHub Personal Access Token with repo and workflow scopes
  • OpenAI or Anthropic API key

Data Flow Through Files

main.py
  ↓ creates FixRequest object (models/fix_request.py)
  ↓ passes to orchestrator
  ↓
fix_orchestrator.py
  ↓ uses github_service.py
  ↓ → create_branch()
  ↓ → get_file_contents()
  ↓
  ↓ passes file to llm_service.py
  ↓ → generate_fix()
  ↓
  ↓ receives LLM response
  ↓ passes to llm_response_parser.py
  ↓ → parse_with_fallback()
  ↓
  ↓ validates with validators.py
  ↓ → validate_code_syntax()
  ↓
  ↓ uses github_service.py
  ↓ → push_file()
  ↓ → create_pull_request()
  ↓
  ↓ uses test_monitor_service.py
  ↓ → wait_for_completion()
  ↓
  ↓ if FAIL:
  ↓   uses test_log_parser.py
  ↓   → extract_failures()
  ↓   checks retry_strategy.py
  ↓   → should_retry()
  ↓   back to llm_service.py
  ↓   → generate_retry_fix()
  ↓   [LOOP]
  ↓
  ↓ if PASS or max retries:
  ↓ creates FixResult object (models/fix_result.py)
  ↓ returns to main.py
  ↓
main.py displays results

Configuration Files

.env (not committed)

GITHUB_TOKEN=ghp_xxxxxxxxxxxxx
OPENAI_API_KEY=sk-xxxxxxxxxxxxx
# or
ANTHROPIC_API_KEY=sk-ant-xxxxxxxxxxxxx

MAX_RETRY_ATTEMPTS=3
TEST_POLL_INTERVAL=10
TEST_TIMEOUT=900
LOG_LEVEL=INFO

.env.example (committed as template)

GITHUB_TOKEN=your_token_here
OPENAI_API_KEY=your_key_here
MAX_RETRY_ATTEMPTS=3
TEST_POLL_INTERVAL=10
TEST_TIMEOUT=900
LOG_LEVEL=INFO

requirements.txt

requests
openai
anthropic
pydantic (for data models)
python-dotenv (for env vars)
pytest (for testing)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages