gai

Crates.iogai
lib.rsgai
version0.1.4
sourcesrc
created_at2023-06-10 17:47:09.22683
updated_at2023-10-11 07:42:44.484348
descriptionAutomatically generate commit messages from a git diff using AI
homepagehttps://github.com/dpecos/gai
repositoryhttps://github.com/dpecos/gai
max_upload_size
id887001
size167,863
Daniel Pecos Martinez (dpecos)

documentation

README

GAI (Git + AI)

GAI (Git + AI) is a command-line interface (CLI) tool written in Rust that utilizes OpenAI models to generate informative commit messages from a git diff by reading from its standard input (stdin). It combines the power of Git with advanced language models to automate the process of creating meaningful and concise commit messages based on the changes made to your Git repository.

Features

  • Uses OpenAI models to analyze the git diff and generate descriptive commit messages.
  • Seamlessly integrates with Git to streamline the commit process.
  • Saves time and effort in writing commit messages manually.

Getting Started

Prerequisites

Before using GAI, ensure that you have the following prerequisites installed on your system:

Installation

To install GAI, follow these steps:

From crates.io

cargo install gai

From code

  1. Clone the GAI repository:

    git clone https://github.com/dpecos/gai.git
    
  2. Change into the cloned repository directory:

    cd gai
    
  3. Build and install GAI using Cargo:

    cargo install --path .
    

    This will build GAI and install it into your system.

Configuration

GAI requires an OpenAI API key to run. Before using GAI, make sure to set the OPENAI_API_KEY environment variable with your OpenAI API key.

export OPENAI_API_KEY=<your-openai-api-key>

Usage

To use GAI, follow these steps:

  1. Navigate to your Git repository's root directory.

  2. Run the git diff command to generate the diff of your changes.

  3. Pipe the git diff output to GAI:

    git diff | gai
    

    (Note: you can also pass the diff from your staged changes with git diff --cached)

    GAI will process the input from git diff using OpenAI models and generate a commit message based on the changes.

    Note: GAI reads from the standard input (stdin), so make sure to pipe the git diff output correctly.

  4. Review the generated commit message and make any necessary adjustments.

  5. Commit your changes using the generated commit message:

    git commit -m "$(git diff | gai)"
    

    This will create a new commit with the generated commit message.

An alternative is to define a shell alias that brings everything together:

alias gaic='git diff --cached | gai | git commit -F -'

But if this feels too much of rush, and you'd like to confirm the commit message manually, you can use ays like this:

alias gaic='git diff --cached | gai | ays --preview "Use this message for the commit?" | git commit -F -'

And this is how your workflow would look like:

gai

Contributing

Contributions to GAI are welcome! If you find any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request to the GitHub repository.

Before contributing, please review the Contribution Guidelines for important information.

License

GAI is licensed under the MIT License. Feel free to use, modify, and distribute this project as per the license terms.

Acknowledgments

GAI was created by Daniel Pecos Martinez. Special thanks to all the contributors who have helped make this project better.

Contact

If you have any questions, suggestions, or feedback, you can reach out to the project maintainer at me@danielpecos.com.

Happy coding!

Commit count: 23

cargo fmt