Skip to content

negoziator/ai-commit

Repository files navigation

🤖 AI-Commit 🤖

License

Your coding companion, ensures that every commit you make is meaningful, insightful, and contributing positively towards your development workflow.

Current version

Table of Contents

Setup

A minimum of Node v20 is required. Check your Node.js version with node --version.

Installation

  1. Install AI-Commit:

    npm install -g @negoziator/ai-commit
    
  2. Retrieve your API key from OpenAI

    Note: This requires an OpenAI account. If you don't have one, you can sign up for a free trial.

  3. Set the key so aicommit can use it:

    aicommit config set OPENAI_KEY=<your token>

    This will create a .aicommit file in your home directory.

Upgrading

npm update -g @negoziator/ai-commit

Usage

CLI Mode

Use aicommit directly to generate a commit message for your staged changes:

git add <files...>
aicommit

Configuration

Manage configuration using the aicommit config command.

To get a configuration option value, use the command:

aicommit config get <key>

For example, to retrieve the API key, you can use:

aicommit config get OPENAI_KEY
> sk_1234567890

To set a configuration option, use the command:

aicommit config set <key>=<value>

Options

Option Default Description
OPENAI_KEY N/A The OpenAI API key.
locale en Locale for the generated commit messages.
generate 1 Number of commit messages to generate.
model gpt-4o-mini The Chat Completions model to use.
timeout 10000 ms Network request timeout to the OpenAI API.
max-length 50 Maximum character length of the generated commit message.
type "" Type of commit message to generate.
auto-confirm false Automatically confirm the generated commit message without user prompt.
prepend-reference false Prepend issue reference from branch name to commit message.
temperature 0.2 The temperature (0.0-2.0) is used to control the randomness of the output from OpenAI

Maintainers

NegoZiatoR

Contributing

If you want to help fix a bug or implement a feature in Issues, checkout the Contribution Guide to learn how to setup and test the project.