Yaget is a Python-based tool designed to enhance your codebase by scanning for TODO
comments, capturing relevant context, and generating code suggestions using the LangChain library integrated with OpenAI’s powerful language models. This tool simplifies managing TODO
items and provides valuable suggestions for code improvements.
🚧 Disclaimer: Yaget is a personal project currently in an early prototype stage. It is developed for learning, experimentation, and personal use. As such, features may be incomplete, and functionality might be limited or subject to change. Please use it with this understanding. Feedback and suggestions are welcome as the project continues to evolve.
...
- Project File Scanning: Traverse through your project directory to locate files containing
TODO
comments. - Context Capture: Dynamically capture the context around
TODO
comments until anENDTODO
marker is reached. - Prompt Generation: Utilize LangChain to create detailed prompts based on the captured context.
- AI-Powered Code Suggestions: Generate actionable code snippets using OpenAI's language models.
- Flexible Configuration: Customize the number of lines captured before
TODO
comments and specify file types for scanning.
git clone https://github.com/keyfour/yaget.git
cd yaget
python -m venv venv
source venv/bin/activate # On Windows, use `venv\Scripts\activate`
pip install -r requirements.txt
Create a .env
file in the project root directory and add your OpenAI API key:
OPENAI_API_KEY=your_openai_api_key
Run the script with the project directory and optional parameters for context lines:
python yaget.py /path/to/your/project --before_lines 3
project_directory
: The path to the directory containing your project files.--before_lines
: (Optional) Number of lines before theTODO
to include in the context. Default is 2 lines.
To scan a project at /home/user/project
and include 3 lines before each TODO
:
python yaget.py /home/user/project --before_lines 3
Yaget generates detailed prompts and suggestions for each TODO
found. Example output:
Prompt:
For the TODO: 'TODO: Refactor this function' in file /home/user/project/main.py, considering the context:
def process_data(data):
# Initial processing steps
pass
# ENDTODO
Generate an implementation suggestion.
Generated Snippet:
Suggested implementation for TODO: 'TODO: Refactor this function':
def process_data(data):
# Optimized processing steps
# TODO: Implement efficient sorting algorithm
pass
- yaget.py: Main script to run the tool.
- requirements.txt: List of dependencies.
- README.md: This readme file.
- .env: Environment file for storing API keys (not included in the repository).
-
Fork and Clone the repository:
git clone https://github.com/yourusername/yaget.git cd yaget
-
Install Dependencies:
pip install -r requirements.txt
-
Create and Activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
Add tests to ensure functionality using frameworks like unittest
or pytest
.
We welcome contributions! Please submit a pull request or open an issue with any suggestions or changes.
This project is licensed under the MIT License. See the LICENSE file for details.
- LangChain: For providing the framework to integrate language models.
- OpenAI: For the API enabling advanced AI-powered code suggestions.
For further details, visit the LangChain Documentation and OpenAI Documentation.
Feel free to contact us for support or inquiries.