Pythagora-io / gpt-pilot

The first real AI developer
Other
29.98k stars 2.98k forks source link

[Enhancement]: Enhancing Code Refactoring Capability for Advanced Code Generation #796

Open moamen270 opened 6 months ago

moamen270 commented 6 months ago

Version

Command-line (Python) version

Suggestion

Feature description

Refactoring code is an essential aspect of software development, aiding in improving code readability, maintainability, and performance. However, the process of identifying which methods or functions need refactoring, along with understanding their dependencies and potential impact on the overall software, can be challenging.

Goal / Motivation

The goal of this issue is to enhance code generation agent's ability to perform advanced code refactoring. By improving its capability to analyze code, identify refactor opportunities, and understand the implications of those changes, we can significantly improve the efficiency and effectiveness of our code generation process.

What strategies or methodologies can we employ to further enhance code generation agent's capability to intelligently identify refactor opportunities and predict their impact on the software system?

senko commented 5 months ago

Hi @moamen270 , thank you for the thoughtful suggestion!

We have some ideas how to approach this, in steps. First, we've determined that it will have to be a separate agent, (working title is "Refactor Agent" :). In our previous tests, we've seen that CodeMonkey (the agent currently doing code generation) can easily get confused and produce worse results if also asked to refactor-as-you-code (ie. how humans do most low-impact refactors).

So the idea is to add this new refactor agent, with the sole purpose of "review the current code base and identify if there is something that should be refactored", which would probably run once per task (at the end of task). To start with, it'd be some simple refactors, and then we can learn from the experience and improve it (the same strategy we do with all the other agents).