This project aims to assist software developers with refactoring and improving code quality using AI Agents.
The assistant takes Python code as input and generates suggestions to refactor the code to improve readability, maintainability, performance etc. It goes through multiple stages:
- Parses the code into an abstract syntax tree (AST)
- Performs static analysis to gather metrics like cyclomatic complexity, code smells etc.
- Extracts design patterns used
- Analyzes the AST and metrics to suggest refactoring opportunities
- Applies heuristics and ML models to provide intelligent recommendations
- Provides interactive feedback loop for developers to guide refactoring
- Applies suggested refactoring transformations on the AST
- Generates refactored Python code
- Automated unit and integration testing to ensure functionality is preserved
- Regression testing against original test suite
- Benchmarking and profiling to validate performance gains
- Secondary AI review for quality and discrepancy detection
- Manual approval and tweaking by experienced developers
graph TB
A[Python Code] --> B[Code Analysis]
B --> C{Design Patterns and Refactoring Suggestions with Feedback System}
C -- AI Refactoring --> D[Code Generation]
C -- Manual Refactoring --> D
D --> E[Secondary AI Review]
E --> F{Testing}
F -- Test Pass --> G[Benchmarking]
F -- Test Fail --> H{Fix Issues and Repeat Testing}
H -- Fixed --> F
H -- Unfixable Issue --> I[Report Issue]
G --> J{Human Review}
J -- Approval --> K[Deploy]
J -- Rejection --> I
- Python 3.6+
- AST parsing libraries like
ast
- Static analysis libraries like
radon
- Testing framework like
unittest