@francocanzani/ai-commit v1.1.3
ai-commit
Overview
ai-commit is an AI-powered Git commit message generator that assists developers in creating meaningful and structured commit messages using OpenAI or Anthropic's AI models. The tool analyzes the differences in staged changes and generates a proposed commit message based on configurable parameters.
Features
- Generates commit messages based on staged changes.
- Supports multiple AI providers (OpenAI and Anthropic).
- Configurable commit message formats and languages.
- Allows auto-commit and preview options.
Installation
To install ai-commit, run:
npm install ai-commitUsage
To use the tool, you can run it directly from the command line:
npx ai-commitCommands
Generate commit message for staged changes:
npx ai-commitConfigure ai-commit settings:
npx ai-commit --config
Configuration
The configuration settings can be defined in the ai-commit-rc.json file. The tool will attempt to read this file when executed. Here’s an example of the default configuration:
{
"provider": "openai",
"envVariable": "OPENAI_API_KEY",
"format": "Conventional (type(scope): description)",
"language": "english",
"maxLength": 50,
"options": {
"showDiff": false,
"autoCommit": false
}
}Default Configuration
If you choose not to set up a configuration, the default settings are as follows:
- AI Provider: OpenAI (API key will be extracted from the environment variable
OPENAI_API_KEY) - Format: Simple descriptions
- Length: 50 characters maximum
- Language: English
- Auto commit: disabled
API Key Management
- Never store API keys directly in your code or config files.
- Use environment variables to manage your API keys securely.
- Add
.envto your.gitignoreto avoid accidental exposure of your API keys.
Example Usage
- Run
ai-commit-configto set up your preferences or let the tool use the default configuration. - Stage your changes using
git add. - Execute
ai-committo generate a commit message based on the staged changes. - Confirm the proposed commit message or auto-commit based on your settings.
Contributing
Contributions are welcome! Please feel free to open issues or submit pull requests.
License
This project is licensed under the MIT License. See the LICENSE file for details.