GitHub - tarikbc/ReportGen: This script provides an automated way to summarize changes made to files in a Git repository. It uses the OpenAI API to generate concise, human-readable summaries of the git diff output, useful for generating changelogs or quick summaries of recent modifications. · GitHub
Skip to content

tarikbc/ReportGen

Folders and files

Repository files navigation

Report Generator

This script provides an automated way to summarize changes made to files in a Git repository. It uses the OpenAI API to generate concise, human-readable summaries of the git diff output, useful for generating changelogs or quick summaries of recent modifications.

Features

  • Summarize Current Changes: By default, it fetches and summarizes the git diff output for each changed file in your current working directory.
  • Summarize Specific Commits: You can now specify a commit hash to summarize the changes introduced by that particular commit.
  • Batch Processing: Sends the diff summary to OpenAI's API in batches (limited to 4000 characters) for summary generation.
  • Content Sanitization: Sanitizes the content to ensure only relevant alphanumeric and selected symbols are included.
  • Readable Output: Displays each summary generated by the OpenAI API, making it easy to track modifications.
  • Token Usage Tracking: Counts input and output tokens for each API call and displays the total usage.
  • Cost Calculation: Provides a detailed cost estimate for the API calls, formatted with appropriate precision.
  • Self-Update Mechanism: Easily update the tool to the latest version from the main branch.

Prerequisites

  • Git: Ensure git is installed and you are working in a repository.
  • OpenAI API Key: Required to send requests to OpenAI's API. This should be stored in a .env file in the project directory.
  • jq: This JSON processor is used to format API request and response data.
  • cURL: Used to make HTTP requests to the OpenAI API.
  • Python 3: Used to parse JSON responses from the OpenAI API.
  • bc: Used for floating-point calculations in cost estimation.

Installation

  1. Clone the repository and navigate to the project directory.

  2. Create a .env file in the project root with your OpenAI API key:

    OPENAI_API_KEY=your_openai_api_key
    
  3. Ensure the required tools are installed:

    • Install jq on Debian-based systems with sudo apt-get install jq.
    • Install curl if not already available.
    • Ensure Python 3 is installed and accessible via python3.
    • Ensure bc is installed for cost calculations.
  4. Run the install.sh script to set up the reportgen command:

    chmod +x install.sh
    ./install.sh

    This creates a symbolic link to the index.sh script in /usr/local/bin, allowing you to run reportgen from anywhere.

Usage

  1. Summarize Current Working Changes:

    reportgen

    This will:

    • Load your OpenAI API key from the .env file.
    • Check for changed files in the repository.
    • Generate a sanitized diff summary for each file, sending it in 4000-character batches to OpenAI for summarization.
    • Display the output of each summarized topic in the terminal.
    • Show the total token usage and estimated cost.
  2. Summarize a Specific Commit:

    reportgen <commit_hash>

    For example:

    reportgen 8d403a9

    This will:

    • Generate a summary of changes introduced by that specific commit.
    • Provide a concise set of topics reflecting what changed in that commit.
    • Display token usage and cost information.
  3. Update the Tool:

    reportgen --update

    This will:

    • Check if the script is in a git repository.
    • Fetch the latest changes from the main branch.
    • Warn about and confirm before overwriting any local modifications.
    • Pull the latest version and return to your original branch.

    Example Output

    • Added new type definitions for Tutor entity in Tutors component
    • Refactored TutorItem props for improved type safety
    • Updated TutorsList component to handle missing index ...

    ===== USAGE SUMMARY ===== Input tokens: 1240 Output tokens: 317 Total tokens: 1557 Cost: $0.38 USD

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

This script provides an automated way to summarize changes made to files in a Git repository. It uses the OpenAI API to generate concise, human-readable summaries of the git diff output, useful for generating changelogs or quick summaries of recent modifications.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors

Languages