1.3.0 • Published 4 months ago
ai-commit-generator-cli v1.3.0
AI Commit Message Generator
A CLI tool that generates commit messages following the Conventional Commits format using the Mistral API.
Features
- Fetches Git diff of uncommitted changes
- Generates a commit message using Mistral AI
- Uses Conventional Commits format
- Prompts for confirmation before committing
Installation
npm install ai-commit-generator-cli
Prerequisites
- Node.js (>=16.x)
- Git installed and initialized in the project
- A valid Mistral API key
Setup
Create a .env
file in your project root and add your Mistral API key:
MISTRAL_API_KEY=your_api_key_here
Usage
Generate and commit
Run the following command inside a Git repository:
ai-commit commit
Using Yarn
If using Yarn, add the following script to your package.json
file:
"scripts": {
"ai-commit": "ai-commit commit"
}
Then run:
yarn run ai-commit
Example Output
Fetching Git diff...
Generating commit message...
Suggested commit: "feat(auth): add login with Google"
Do you want to commit with this message? (y/N)
If you confirm, the commit is created.
Conventional Commit Types
feat
: New featurefix
: Bug fixdocs
: Documentation updatesstyle
: Code style changes (formatting, missing semicolons, etc.)refactor
: Code restructuring without changing functionalitytest
: Adding or fixing testschore
: Maintenance tasks (e.g., dependency updates)
License
MIT