Skip to content

fmind/GitWorks

Repository files navigation

GitWorks: AI-Powered GitHub Repository Reviewer ✨

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.

Features

  • 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 guidelines variable 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.

How it Works

  1. Setup: You provide a GitHub Personal Access Token (PAT) and a Gemini API Key, stored securely in Colab Secrets.
  2. Configuration: You specify the target GitHub repository (owner/repo) and configure Gemini model parameters.
  3. 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.
  4. Content Aggregation: The content of all text files is combined into a single string, formatted with file path indicators.
  5. AI Analysis: The aggregated content, along with the predefined guidelines and 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).
  6. Output: The generated review (title and body) is displayed in the Colab output.
  7. Issue Creation (Optional): If CREATE_ISSUE is set to True, the script uses the GitHub API to create a new issue in the target repository with the AI-generated title and body.

Usage

  1. Open the script (.ipynb file) in Google Colab.
  2. Complete the Setup steps to configure your secrets.
  3. Navigate to the CONFIGS section in the script.
    • Set the REPOSITORY variable to the target repository you want to analyze (e.g., "your-username/your-repo").
    • Adjust MODEL, TEMPERATURE, and MAX_OUTPUT_TOKENS as needed for the Gemini AI.
    • Set CREATE_ISSUE to True if you want the script to automatically create an issue in the target repository, or False to only display the review in the Colab output.
  4. (Optional) Modify the guidelines string variable under CONTENTS > Guidelines if you want to use custom review criteria.
  5. Run all cells in the notebook (Runtime > Run all).
  6. Observe the output in the ANALYSIS > Review section.
  7. If CREATE_ISSUE was True, check the "Issues" tab of the target repository for the newly created review issue.

Configuration Parameters

  • 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.0 makes 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.

Guidelines

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.

Contributing

Contributions are welcome! Please feel free to submit pull requests or open issues to improve the script or suggest new features.

License

MIT License

About

An automated AI-driven code review tool that enforces custom repository guidelines on GitHub projects using Gemini.

Topics

Resources

Stars

Watchers

Forks

Contributors