Skip to content

kristopolous/bugout

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

18 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

BugOut

Automated bug fix workflow that fetches GitHub issues, extracts features, generates PRDs, creates fixes, finds reviewers, and prepares patch folders.

Overview

BugOut performs 8 automated steps:

  1. Fetch Comments - Uses gh CLI to get all issue comments and saves as JSON
  2. Feature Extraction - Uses AI (parser.py style) to extract structured features from comments
  3. PRD Generation - Analyzes features and generates a Product Requirements Document
  4. Bug Fix Generation - Uses AI to propose a fix based on the PRD
  5. Reviewer Check - Uses Yutori API to find competent reviewers from issue commenters
  6. Patch Folder - Prepares a complete patch folder with all artifacts
  7. Repo Clone & Agentic Loop - Clones the repo and uses OpenAI to analyze and generate precise code changes
  8. Patch Creation - Generates actual unified diff patch files and updates the directory

Requirements

  • Python 3.8+
  • GitHub CLI (gh)
  • .env file in project root with:
    • FASTINO_KEY - For AI inference
    • YUTORI_KEY - For reviewer competence checking
    • OPENAI_HOST - OpenAI API host (e.g., api.openai.com)
    • OPENAI_MODEL - OpenAI model to use (e.g., gpt-4o)
    • OPENAI_API_KEY - OpenAI API key (optional for some endpoints)
  • wxPython - For GUI (optional, see GUI section)

Installation

CLI Installation

# Install dependencies
pip install requests python-dotenv

# Ensure gh CLI is installed
gh --version

# Create .env file in project root (parent of qwen/)
cat > ../.env << EOF
FASTINO_KEY=your-key
YUTORI_KEY=your-key
OPENAI_HOST=api.openai.com
OPENAI_MODEL=gpt-4o
OPENAI_API_KEY=your-openai-key
EOF

GUI Installation (Optional)

# Install all dependencies including wxPython
pip install -r requirements.txt

# Or install wxPython separately:

# Linux (Ubuntu/Debian)
sudo apt-get install python3-wxgtk4.0

# macOS
pip install wxPython

# Windows
pip install wxPython

Usage

Full Workflow (CLI)

Run the complete BugOut workflow from command line:

cd qwen
python bugout.py <repo> <issue_number> [output_dir]

Examples:

# Basic usage
python bugout.py microsoft/vscode 12345

# With custom output directory
python bugout.py facebook/react 67890 ./my_output

# Show help
python bugout.py --help

Graphical Interface (GUI)

Launch the BugOut graphical interface:

python bugout.py --gui

GUI Features:

Component Description
πŸ“ Config Panel Input fields for repo, issue number, output directory
πŸ“Š Status Panel Progress bar, step counter (0/8), Run ID display
πŸ“‹ Log Panel Color-coded live output (success/error/warning/info)
πŸ–±οΈ Control Buttons Run, Stop, Clear Log
πŸ“ Directory Browser Browse button for selecting output location
🎯 Visual Indicators Step-by-step progress with Unicode symbols

GUI Workflow:

  1. Enter repository (e.g., microsoft/vscode)
  2. Enter issue number (e.g., 12345)
  3. Optionally select output directory
  4. Click "πŸš€ Run BugOut"
  5. Watch real-time progress in the log panel
  6. View completion summary with patch folder location

GUI Screenshots:

╔══════════════════════════════════════════════════════════════╗
β•‘     πŸ› BugOut - Automated Bug Fix Workflow              β•‘
╠══════════════════════════════════════════════════════════════╣
β•‘  From bug report to production-ready patch                    β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

Repository:    [microsoft/vscode________________]
Issue Number:  [12345___________________________]
Output Dir:    [./bugout_data___________________] [Browse...]

Status: Running
Progress: [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘] 62%  Step: 5/8
Run ID: a3f5b2c1

Output Log:
  βœ“ Step 1 complete: Fetched 15 comments for issue #12345
  βœ“ Step 2 complete: Extracted features from 16 entries
  βœ“ Step 3 complete: Generated PRD with 16 reports analyzed
  βœ“ Step 4 complete: Generated bug fix
  βœ“ Step 5 complete: Checked 8 reviewers
  β†’ Best reviewer: @somecontributor
  ...

[πŸš€ Run BugOut]  [⏹ Stop]  [πŸ—‘ Clear Log]

Individual Steps

You can also run each step individually:

Step 1: Fetch Comments

python comment_fetcher.py <repo> <issue_number> [output_dir]

Step 2: Extract Features

python feature_extractor.py <comments.json> [output_file]

Step 3: Generate PRD

python prd_generator.py <bugs_with_features.json> [output_prd.md]

Step 4: Generate Bug Fix

python bug_fixer.py <prd.md> <bugs_with_features.json> [output_dir]

Step 5: Check Reviewers

python reviewer_checker_wrapper.py <comments.json> <repo> [output_dir] [wait]

Step 6: Prepare Patch Folder

python patch_generator.py <output_dir> <prd.md> <bug_fix.patch> <reviewer.json> <comments.json> <bugs_with_features.json>

Step 7: Clone Repo & Agentic Loop

python repo_cloner.py <repo> <prd.md> <bug_fix.json|bug_fix.patch> [output_dir]

Step 8: Create Patch File

python patch_creator.py <clone_path> <agent_response.json> <output_dir>

Output Structure

Each run gets a unique 8-character UUID as its directory name for easy tracking and organization.

bugout_data/
└── a3f5b2c1/                 # ← Unique run ID (UUID)
    β”œβ”€β”€ run_metadata.json     # Run info: UUID, repo, issue, timestamp
    β”œβ”€β”€ issue_comments.json   # Raw issue data from GitHub
    β”œβ”€β”€ bugs_with_features.json  # Extracted features
    β”œβ”€β”€ prd.md                # Product Requirements Document
    β”œβ”€β”€ prd.analysis.json     # Feature analysis JSON
    β”œβ”€β”€ bug_fix.patch         # Initial proposed fix
    β”œβ”€β”€ bug_fix.json          # Fix details JSON
    β”œβ”€β”€ reviewer.json         # Reviewer analysis
    β”œβ”€β”€ agent_response.json   # Agentic loop output (Step 7)
    β”œβ”€β”€ generated.patch       # AI-generated unified diff (Step 8)
    β”œβ”€β”€ git.patch             # Git diff patch (Step 8)
    β”œβ”€β”€ applied_changes.json  # Applied changes log (Step 8)
    β”œβ”€β”€ temp/                 # Temp directory with repo clone
    β”‚   └── microsoft_vscode_clone/  # Cloned repository
    β”œβ”€β”€ repo_snapshot/        # Snapshot of modified repo
    └── patch/                # Complete patch folder
        β”œβ”€β”€ prd.md
        β”œβ”€β”€ bug_fix.patch
        β”œβ”€β”€ reviewer.json
        β”œβ”€β”€ issue_comments.json
        β”œβ”€β”€ bugs_with_features.json
        β”œβ”€β”€ analysis.json
        β”œβ”€β”€ bug_fix.json
        β”œβ”€β”€ agent_response.json
        β”œβ”€β”€ generated.patch
        β”œβ”€β”€ git.patch
        β”œβ”€β”€ applied_changes.json
        └── patch_manifest.json  # Includes run_id reference

Run Metadata

Each run creates a run_metadata.json file:

{
  "run_id": "a3f5b2c1",
  "repo": "microsoft/vscode",
  "issue_number": "12345",
  "timestamp": "2026-02-27T10:30:00.000000",
  "output_dir": "./bugout_data/a3f5b2c1"
}

Generated Artifacts

prd.md

Product Requirements Document containing:

  • Executive summary
  • Frequency analysis of bug characteristics
  • Technical details from user reports
  • Functional and non-functional requirements
  • Success criteria

bug_fix.patch

Proposed fix containing:

  • Root cause analysis
  • Fix description
  • Code changes
  • Testing instructions

reviewer.json

Reviewer analysis containing:

  • List of all commenters
  • Competence assessment for each
  • Best reviewer recommendation

agent_response.json (Step 7)

Output from the agentic loop containing:

  • Root cause analysis
  • Affected files list
  • Fix strategy
  • Detailed code changes with line numbers
  • Testing recommendations
  • Confidence score

generated.patch (Step 8)

Unified diff patch file containing:

  • All code changes from the agentic loop
  • Proper diff format for easy review
  • Can be applied with git apply or patch

git.patch (Step 8)

Git-formatted patch from the actual repository changes:

  • Generated from git diff HEAD
  • Ready for git am or PR creation

applied_changes.json (Step 8)

Log of all applied changes containing:

  • List of changes with success/failure status
  • Analysis summary from the agent
  • Testing instructions
  • Confidence score

Environment Variables

Variable Description Required
FASTINO_KEY API key for AI inference Yes
YUTORI_KEY API key for Yutori reviewer check Yes
OPENAI_HOST OpenAI API host (e.g., api.openai.com) Yes
OPENAI_MODEL OpenAI model to use (e.g., gpt-4o) Yes
OPENAI_API_KEY OpenAI API key Optional

The .env file should be in the parent directory (project root).

Example Output

     l         __                       __
  .   .       / /  __ _____ ____  __ __/ /_
   \ /       / _ \/ // / _ `/ _ \/ // / __/
 `/ ! \`    /_.__/\_,_/\_, /\___/\_,_/\__/
 | o:o |              /___/
~| o:o |~
/ \_:_/ \

╔══════════════════════════════════════════════════════════════╗
β•‘     πŸ› BugOut - Automated Bug Fix Workflow              β•‘
╠══════════════════════════════════════════════════════════════╣
β•‘  From bug report to production-ready patch                    β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

Configuration 
  Run ID:      a3f5b2c1
  Repository:  microsoft/vscode
  Issue:       #12345
  Output:      ./bugout_data/a3f5b2c1
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

● [1/8] πŸ”— Fetching issue comments
  βœ… Step 1 complete: Fetched 15 comments for issue #12345

● [2/8] βš™οΈ  Extracting features from comments
  βš™οΈ Processing 16 text entries...
  βœ… Step 2 complete: Extracted features from 16 entries

● [3/8] 🎯 Generating PRD
  βœ… Step 3 complete: Generated PRD with 16 reports analyzed

● [4/8] πŸ› Generating bug fix
  βœ… Step 4 complete: Generated bug fix

● [5/8] β˜… Checking reviewer competence
  βœ… Step 5 complete: Checked 8 reviewers
  βœ… Best reviewer: @somecontributor

● [6/8] πŸ“ Preparing initial patch folder
  βœ… Created: ./bugout_data/a3f5b2c1/patch

● [7/8] πŸš€ Running agentic loop with OpenAI
  πŸ”€ Cloning microsoft/vscode...
  βœ… Clone: ./bugout_data/a3f5b2c1/temp/microsoft_vscode_clone
  β†’ Agent response: ./bugout_data/a3f5b2c1/agent_response.json

● [8/8] ✨ Generating actual patch file
  Applying 3 changes...
  βœ… Generated: ./bugout_data/a3f5b2c1/generated.patch
  βœ… Updated: ./bugout_data/a3f5b2c1/patch

══════════════════════════════════════════════════════════════
  πŸš€ BugOut Complete! 
══════════════════════════════════════════════════════════════

╔══════════════════════════════════════════════════════════════╗
β•‘              BugOut Summary                                β•‘
╠══════════════════════════════════════════════════════════════╣
β•‘  Run ID:     a3f5b2c1                                      β•‘
β•‘  Repository: microsoft/vscode                              β•‘
β•‘  Issue:      #12345                                        β•‘
β•‘  Patch Folder: ./bugout_data/a3f5b2c1/patch                β•‘
β•‘  Best Reviewer: @somecontributor                           β•‘
╠══════════════════════════════════════════════════════════════╣
β•‘  Generated Artifacts:                                      β•‘
β•‘    β€’ prd.md                  (Product Requirements Doc)    β•‘
β•‘    β€’ bug_fix.patch           (Initial Proposed Fix)        β•‘
β•‘    β€’ generated.patch         (AI-Generated Patch)          β•‘
β•‘    β€’ git.patch               (Git Diff Patch)              β•‘
β•‘    β€’ reviewer.json           (Reviewer Analysis)           β•‘
β•‘    β€’ agent_response.json     (Agentic Loop Output)         β•‘
β•‘    β€’ applied_changes.json    (Applied Changes Log)         β•‘
╠══════════════════════════════════════════════════════════════╣
β•‘  Next Steps:                                               β•‘
β•‘    1. Review PRD:        cat ./bugout_data/a3f5b2c1/prd.md β•‘
β•‘    2. Review patch:      cat ./bugout_data/a3f5b2c1/patch/ β•‘
β•‘                          generated.patch                   β•‘
β•‘    3. Contact reviewer:  @somecontributor                  β•‘
β•‘    4. Create PR with the generated patch                   β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

Project Structure

qwen/
β”œβ”€β”€ bugout.py                 # Main CLI orchestrator (8 steps)
β”œβ”€β”€ bugout_gui.py             # wxPython graphical interface
β”œβ”€β”€ comment_fetcher.py        # Step 1: Fetch issue comments
β”œβ”€β”€ feature_extractor.py      # Step 2: AI feature extraction
β”œβ”€β”€ prd_generator.py          # Step 3: Generate PRD
β”œβ”€β”€ bug_fixer.py              # Step 4: Initial bug fix
β”œβ”€β”€ reviewer_checker_wrapper.py # Step 5: Yutori reviewer check
β”œβ”€β”€ patch_generator.py        # Step 6: Initial patch folder
β”œβ”€β”€ repo_cloner.py            # Step 7: Clone repo + agentic loop
β”œβ”€β”€ patch_creator.py          # Step 8: Generate unified diff
β”œβ”€β”€ requirements.txt          # Python dependencies
└── README.md                 # This file

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors