GitWorks is a Python script designed to run in Google Colab that automatically reviews GitHub repositories based on a predefined set of guidelines. It leverages the power of Google's Gemini AI to analyze the repository's content and structure, providing feedback formatted as a potential GitHub Issue.
This tool is particularly useful for assessing project maturity, ensuring adherence to coding standards, or checking compliance with specific MLOps practices.
- Automated Repository Analysis: Fetches and concatenates the content of files in a specified GitHub repository.
- AI-Powered Review: Uses Google Gemini to analyze the code and structure against user-provided guidelines.
- Customizable Guidelines: Comes with a built-in MLOps checklist (Prototype, Alpha, Beta, GA levels), but you can easily modify the
guidelinesvariable in the script to fit your own standards. - Configurable: Easily change the target repository, Gemini model parameters (model, temperature, max tokens), and output options.
- GitHub Issue Creation: Optionally creates a new issue in the target repository containing the review title and body generated by Gemini.
- Colab Integration: Designed for easy setup and execution within a Google Colab environment, utilizing Colab Secrets for secure credential management.
- Setup: You provide a GitHub Personal Access Token (PAT) and a Gemini API Key, stored securely in Colab Secrets.
- Configuration: You specify the target GitHub repository (
owner/repo) and configure Gemini model parameters. - Content Fetching: The script uses the GitHub API (via
PyGithub) to recursively fetch the content of all files in the target repository's default branch. - Content Aggregation: The content of all text files is combined into a single string, formatted with file path indicators.
- AI Analysis: The aggregated content, along with the predefined
guidelinesand instructions, is sent to the specified Gemini model. The AI is instructed to perform a review and structure its response as a GitHub issue (title and body). - Output: The generated review (title and body) is displayed in the Colab output.
- Issue Creation (Optional): If
CREATE_ISSUEis set toTrue, the script uses the GitHub API to create a new issue in the target repository with the AI-generated title and body.
- Open the script (
.ipynbfile) in Google Colab. - Complete the Setup steps to configure your secrets.
- Navigate to the CONFIGS section in the script.
- Set the
REPOSITORYvariable to the target repository you want to analyze (e.g.,"your-username/your-repo"). - Adjust
MODEL,TEMPERATURE, andMAX_OUTPUT_TOKENSas needed for the Gemini AI. - Set
CREATE_ISSUEtoTrueif you want the script to automatically create an issue in the target repository, orFalseto only display the review in the Colab output.
- Set the
- (Optional) Modify the
guidelinesstring variable under CONTENTS > Guidelines if you want to use custom review criteria. - Run all cells in the notebook (
Runtime>Run all). - Observe the output in the ANALYSIS > Review section.
- If
CREATE_ISSUEwasTrue, check the "Issues" tab of the target repository for the newly created review issue.
MODEL: The Gemini model to use for the analysis (e.g.,"gemini-1.5-flash").TEMPERATURE: Controls the randomness of the AI's output.0.0makes the output more deterministic. Higher values (e.g.,0.7) increase creativity.MAX_OUTPUT_TOKENS: The maximum number of tokens the AI should generate for the review.REPOSITORY: The target GitHub repository in"owner/repo"format.CREATE_ISSUE: A boolean (True/False) determining whether to create a GitHub issue with the review results.
The script includes a multi-level MLOps checklist within the guidelines variable. The current levels are:
- Level 1: Prototype
- Level 2: Alpha
- Level 3: Beta
- Level 4: GA (General Availability)
You can edit the guidelines string directly in the script to define any set of rules or checks relevant to your project or organization.
Contributions are welcome! Please feel free to submit pull requests or open issues to improve the script or suggest new features.
MIT License