Every engineering team faces the nightmare of Technical Debt. As deadlines loom, functions become "God Objects," global variables bleed into logic, and dependencies tangle like spaghetti. Existing tools (linters) only find problems; they don't fix them.
The Failure of Standard AI:
Standard coding agents suffer from "Graph Blindness." They refactor a file in isolation, often breaking external dependencies (changing a function signature that main.py relies on) or deleting global variables (breaking scope).
CodeReaper is not just a coding assistant; it is a Graph-Aware Architect. It constructs an Abstract Syntax Tree (AST) dependency graph of your repository before touching a single line of code.
- The Inquisitor: Scans code for Cyclomatic Complexity and "Smells" (e.g., Spaghetti Logic).
- The Graph Shield: Detects external imports. If
lib.pyis used bymain.py, the Shield locks the function signature, preventing the agent from breaking the build. - The Scope Guardian: A specialized research module that enforces Semantic Equivalency. It ensures that refactored code maintains access to global state (addressing the "Scope Shadowing" edge case).
CodeReaper uses a Hierarchical Multi-Agent System (HMAS) powered by Google Gemini 2.5 Pro:
- Frontend: Streamlit (Real-time Agent Visualization)
- Brain: Google Gemini API (Reasoning & Refactoring)
- Tools:
DependencyGraph: AST-based import mapping.GlobalScopeGuardian: Semantic analysis for variable scope.GoogleSearch: Fetches live context (e.g., "Python recursion best practices").
This project demonstrates key course concepts:
- ✅ Multi-Agent Orchestration: Sequential workflow (Inquisitor -> Graph Agent -> Researcher -> Surgeon -> Guardian).
- ✅ Custom Tooling: We built
ReaperToolsfor complexity analysis andScopeGuardianfor safety checks. - ✅ Observability: The Streamlit dashboard visualizes the "Thought Process" of every agent in real-time.
Prerequisites: Python 3.9+, Google Gemini API Key.
# 1. Clone & Install
git clone [https://github.com/darksoul-nyx/codereaper.git](https://github.com/darksoul-nyx/codereaper.git)
pip install -r requirements.txt
# 2. Set API Key
export GOOGLE_API_KEY="your_key_here"
# 3. Run the Gauntlet
streamlit run src/app_v2.py