Skip to main content

A toolkit for using OpenAI's GPT-4o-mini model to assist with Git workflows.

Project description

🧰 Git AI Toolkit

👋 Description

This tool can generate commit messages for your Git repository by summarizing the changes using the OpenAI API. It identifies the Git repository, checks for changes (both staged and unstaged), and uses OpenAI to provide a comprehensive commit message following conventional commit formats. If you approve, the changes can be committed and optionally pushed to the remote repository.

Enhanced Features

  • Conventional Commit Format: Uses standardized types (feat, fix, docs, etc.)
  • Smart Context Gathering: Analyzes branch, file types, and repository context
  • Staged & Unstaged Changes: Handles both types of changes with selective staging
  • Interactive Editing: Edit commit messages before finalizing
  • Project-Specific Conventions: Learns from your commit history
  • Color-Coded Output: Better visual organization of information
  • Extended Description: Auto-generates detailed descriptions for complex changes
  • Progress Indicators: Spinners show status during long-running operations
  • Command-Line Options: Full-featured command-line interface with help system
  • Clear Error Messages: Human-readable errors with specific recovery steps
  • Smart Feedback: Contextual suggestions for next steps after each action

🚀 Installation

Install the package via pip:

pip install git_ai_toolkit

⚙️ Configuration

Option 1: Interactive Setup (Recommended)

Run the interactive setup command that will guide you through the process of configuring your OpenAI API key:

gitai-setup

The setup will:

  1. Ask for your OpenAI API key
  2. Validate the key format
  3. Test the connection to the OpenAI API
  4. Add the key to your environment variables permanently

Option 2: Manual Setup

If you prefer to set up the API key manually:

  1. Add Your OpenAI API Key

    Add your OpenAI API key to your environment variables by updating your shell's configuration file.

    For zsh (Zsh users):

    echo '\nexport OPENAI_API_KEY="your_openai_api_key_here"' >> ~/.zshrc
    source ~/.zshrc
    

    For bash (Bash users):

    echo '\nexport OPENAI_API_KEY="your_openai_api_key_here"' >> ~/.bashrc
    source ~/.bashrc
    

    For Windows users:

    setx OPENAI_API_KEY "your_openai_api_key_here"
    

    Replace your_openai_api_key_here with your actual OpenAI API key.

💻 Usage

Basic Usage

gitai             # Generate commit message for all changes
gitai --stage     # Stage all changes and generate commit
gitai --push      # Auto-push after committing
gitai --offline   # Skip AI and write commit manually 

Complete Command Reference

Main Command: gitai

usage: gitai [-h] [--stage] [--push] [--offline] [--model MODEL]
             [--max-tokens MAX_TOKENS] [--debug] [--version]

Generate AI-powered Git commit messages and streamline your Git workflow.

options:
  -h, --help            show this help message and exit
  --stage, -s           Stage all unstaged files before generating commit
  --push, -p            Push changes after committing
  --offline, -o         Skip AI generation and craft commit message manually

Advanced options:
  --model MODEL, -m MODEL
                        OpenAI model to use (default: gpt-4o-mini)
  --max-tokens MAX_TOKENS
                        Maximum tokens for AI response (default: 300)
  --debug               Show detailed debug information
  --version, -v         Show version information and exit

Examples:
  gitai                    # Generate commit message for all changes
  gitai --stage            # Stage all changes and generate commit
  gitai --offline          # Skip AI generation and write manually
  gitai --push             # Automatically push after committing
  gitai --model gpt-4o     # Use a specific OpenAI model

Setup Command: gitai-setup

usage: gitai-setup [-h] [--key KEY] [--skip-validation] [--version]

Set up the Git AI Toolkit by configuring your OpenAI API key.

options:
  -h, --help            show this help message and exit
  --key KEY, -k KEY     Your OpenAI API key (if provided, skips prompt)
  --skip-validation, -s
                        Skip API key validation and testing
  --version, -v         Show version information and exit

Examples:
  gitai-setup                     # Interactive setup
  gitai-setup --key sk-xxx        # Directly set API key
  gitai-setup --skip-validation   # Skip API validation check

Workflow Examples

Standard Workflow

  1. Make changes to your code
  2. Run gitai to generate a commit message
  3. Review and accept or edit the generated message
  4. Choose whether to push changes to remote

Quick Workflow

# Make changes to your code then:
gitai --stage --push  # Stage all changes, commit with AI message, and push

Manual Workflow

# Make changes to your code then:
gitai --offline  # Skip AI and write your own commit message

License

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

git_ai_toolkit-0.2.4.tar.gz (19.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

git_ai_toolkit-0.2.4-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

Details for the file git_ai_toolkit-0.2.4.tar.gz.

File metadata

  • Download URL: git_ai_toolkit-0.2.4.tar.gz
  • Upload date:
  • Size: 19.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.8

File hashes

Hashes for git_ai_toolkit-0.2.4.tar.gz
Algorithm Hash digest
SHA256 dab4b087f56cdfbe0f970540f54bc65762c4a27430ff896641c83df20385d58a
MD5 559b5da7e2f91dc3d39e5043a716549a
BLAKE2b-256 ce07738ca812abda1b9251a2a723efa7746282ee7e330b2eb88461628540b683

See more details on using hashes here.

File details

Details for the file git_ai_toolkit-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: git_ai_toolkit-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 19.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.8

File hashes

Hashes for git_ai_toolkit-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 7a7cc65af89a02610f63faf87a0512be9da08408be3358a14f2c1c497d08bd26
MD5 5074f1d2629346f15d38337b1f6c536f
BLAKE2b-256 a9430edff26785e8c6ab6687baedbd886d0c35c27147df7cdcd2d8e522ce1cac

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page