Description
While attempting to extend the library by creating a GenerateUnitTests patchflow, several limitations in the current architecture were identified. These limitations hinder the easy extension of the library, which is one of the short-term goals of Patchwork.
Current Limitations
-
Tight Coupling: The CallCode2Prompt step is tightly coupled to the GenerateREADME patchflow. This makes it difficult to reuse or adapt for other patchflows.
-
Limited Functionality: The current
CallCode2Prompt.py
in the main branch has limited functionality, focusing only on README.md file handling. -
Inflexible ModifyCode Class: The ModifyCode class in ModifyCode.py is not designed to handle multiple modes of operation, making it challenging to add new patchflow types.
-
Lack of Standardized Extension Method: There's no clear, standardized base model to add new patchflows to the library.
Proposed Solutions
-
Generalize CallCode2Prompt:
- Refactor CallCode2Prompt to accept a mode parameter.
- Implement separate handling methods for different modes (e.g., README, unit tests).
- Create a flexible file selection mechanism based on the mode.
-
Enhance ModifyCode Class:
- Implement a mode-based execution in the ModifyCode class.
- Add separate methods for handling different types of modifications (e.g., updating README, creating unit test files).
- Ensure the class can easily accommodate new modes in the future.
-
Standardize Patchflow Creation:
- Create a base Patchflow class that new patchflows can inherit from.
- Implement common methods and attributes in the base class.
- Provide clear documentation on how to create new patchflows.
-
Update Existing Patchflows:
- Refactor GenerateREADME to use the new generalized components.
- Create a new GenerateUnitTests patchflow using the generalized components.
-
Improve Documentation:
- Update the contributor guidelines to reflect the new extension process.
- Provide examples of how to create new patchflows using the generalized components.
Discussion Points
- Are there any other components that need generalization to improve extensibility?
- How can we ensure backward compatibility while making these changes?
- What level of abstraction is appropriate to balance flexibility and ease of use?
By addressing these points, we can significantly improve Patchwork's extensibility, making it easier for contributors to add new features and patchflows in the future.
Some Changes Already Being Worked on
Here's a link to a branch with the proposed changes already been worked.