Skip to main content

codecov PyPI version License: MIT

Gai is a CLI Automation Tool for Git 🚀

command-line application that automates git commit messages and merge requests using AI.

Demo

✨ Features

  • Generate commit messages based on code diffs.
  • Create merge requests with AI-generated titles and descriptions.
  • Works with both GitHub and GitLab.

📦 Installation

Install gai-tool via pip:

pip install gai-tool

🚀 Getting Started

  1. Set API Tokens as Environment Variables:

    # Ensure you have your AI interface and GitHub/GitLab API tokens set:
    export HUGGINGFACE_API_TOKEN='your_hf_api_token'    # If you want to use Hugging Face's API
    export GITHUB_TOKEN='your_github_token'             # If using GitHub
    export GITLAB_TOKEN='your_gitlab_token'             # If using GitLab
    

Supported interfaces:

  • Groq (GROQ_API_KEY)
  • Hugging Face (HUGGINGFACE_API_TOKEN)
  • Gemini (GEMINI_API_KEY or GOOGLE_API_KEY) -- Gemini takes precedence when both are set.
  • Ollama (OLLAMA_API_KEY)
  1. Navigate to your git repository:

    cd /path/to/your/git/repo
    
  2. Start Using gai-tool:

    # Generate an AI-powered commit message:
    gai commit -a
    

⚙️ Configuration

Configuration file is located at ~/.config/gai/config.yaml. Customize settings like the AI interface, temperature, and target branch.

You can also initialize a local configuration file in your project directory:

gai init

This will create a .gai.yaml file in your current directory with your current settings. Local configuration takes precedence over global configuration.

Example configuration:

interface: huggingface
temperature: 0.7
target_branch: master

Customizing AI Behavior

You can customize the AI's behavior by editing the your-project-name/.gai/gai-rules.md file, which is created when you run gai init. These rules are injected into the AI's system prompt.

For a detailed guide, see Customizing AI Behavior with Rules.

📖 Usage

gai-tool provides two main commands: commit and merge.

📝 Commit Messages

Generate an commit message:

gai commit

Options:

  • -a, --all: Stage all changes before committing.
  • -t, --temperature: Override the temperature specified in the config.
  • -i, --interface: Specify and override the AI client API to use (groq or huggingface).

Example:

# Simply
gai commit -a
# Or
gai commit -a -i huggingface

🔀 Merge Requests

Create a merge request:

gai merge

Options:

  • [remote]: Specify the remote git repository (default is origin).
  • --push, -p: Push changes to remote before creating a merge request.
  • --target-branch, -tb: Specify the target branch for the merge request (default is master).
  • -t, --temperature: Override the temperature specified in the config.
  • -i, --interface: Specify and override the AI client API to use (groq or huggingface).

Example:

# Simply
gai merge -p
# Or
gai merge origin --push --target-branch develop -interface groq

🛠 Build Instructions

Build gai-tool from source:

  1. Clone the Repository:

    git clone https://github.com/Danielratmiroff/gai.git
    
  2. Navigate to the Project Directory:

    cd gai
    
  3. Create a Virtual Environment (Optional but Recommended):

    python -m venv venv
    source venv/bin/activate  # On Windows use venv\Scripts\activate
    
  4. Install Build Tools and Dependencies:

    pip install build
    pip install -r requirements.txt
    
  5. Build the Package:

    python -m build
    

    This will generate distribution files in the dist/ directory.

  6. Install the Built Package:

    pip install dist/gai_tool-<VERSION>-py3-none-any.whl
    

🤝 Contributing

Contributions are welcome!

📄 License

MIT License - LICENSE.

Metadata

Release files for gai-tool 0.5.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gai-tool 0.5.3
File Size Uploaded Provenance Actions
gai_tool-0.5.3.tar.gz 18.5 kB Without provenance Details for gai_tool-0.5.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gai-tool 0.5.3
File Interpreter ABI Platform Actions
gai_tool-0.5.3-py3-none-any.whl Python 3 none any Details for gai_tool-0.5.3-py3-none-any.whl

Total release size: 43.0 kB

Release files / gai_tool-0.5.3.tar.gz

Download URL gai_tool-0.5.3.tar.gz
Size 18.5 kB
Tags Source
SHA-256 checksum
How to use checksums
423c16b929e7ac352422ac5162ea90b82ae2e5e6676e9d33069ded47b7f84b47
BLAKE2b-256 checksum
How to use checksums
1998408f7aa13017122e46fc327c8f6bf09dadd238bf2cc5c764d0fbcbc10b1a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.12.3 Linux/6.8.0-63-generic

Release files / gai_tool-0.5.3-py3-none-any.whl

Download URL gai_tool-0.5.3-py3-none-any.whl
Size 24.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aa945fd5d27f888646c1635e140ac0b2d7a476e7223d2fc106e1accbd57ebae3
BLAKE2b-256 checksum
How to use checksums
47f1db156beaf79681dd93801c8bc21c21945af008fe45e9174d4d34c998ba56
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.12.3 Linux/6.8.0-63-generic

Security for gai-tool 0.5.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page