@heogeon0/lazy-ai
v0.0.2
Published
AI-powered commit message generator using Google Gemini API, designed for seamless integration with Lazygit
Maintainers
Readme
lazy-ai
AI-powered commit message generator using Google Gemini API, designed for seamless integration with Lazygit.
Features
- AI-Powered: Generates intelligent commit messages using Google Gemini API
- Conventional Commits: Follows standard commit format (feat, fix, chore, docs, etc.)
- Lazygit Integration: Works perfectly as a custom command in Lazygit
- Multiple Suggestions: Generate multiple commit message options to choose from
- Multilingual: Default language is Korean, customizable to other languages
- Customizable Rules: Add your own commit message rules
Prerequisites
- Node.js 18 or higher
- Git repository
- Google Gemini API key (Get it here)
- (Optional) Lazygit for UI integration
Installation
npm install -g @heogeon0/lazy-aiConfiguration
1. Set up API Key and Model
After installation, configure your Gemini API key:
lazy-ai configYou'll be prompted to enter:
- Gemini API key: Your Google Gemini API key
- Model (optional): Default is
gemini-2.5-flash
Example:
Enter your Google Gemini API key: YOUR_GEMINI_API_KEY_HERE
✓ API key saved
Enter model (default: gemini-2.5-flash):
✓ Model saved
Configuration completed!2. Lazygit Integration (Recommended)
Add this custom command to your Lazygit configuration file:
Config file location:
- Linux/macOS:
~/.config/lazygit/config.yml - Windows:
%APPDATA%\lazygit\config.yml
Add this to your config:
customCommands:
- key: "I"
description: "AI commit message"
command: 'git commit -m "{{.Form.Msg}}"'
context: "files"
prompts:
- type: "menuFromCommand"
title: "AI Commit Messages"
key: "Msg"
command: "lazy-ai g"
filter: '^(?P<number>\d+)\.\s(?P<message>.+)$'
valueFormat: "{{ .message }}"
labelFormat: "{{ .number }}: {{ .message | green }}"
output: logUsage
Standalone CLI
Stage your changes:
git add .Generate commit messages:
lazy-ai generate -n 5 # or use the alias lazy-ai g -n 5Output example:
1. feat: AI 커밋 메시지 생성기 초기 기능 구현 2. feat: Gemini API 통합 및 설정 관리자 추가 3. refactor: 코드 구조 개선 및 타입 안정성 강화 4. docs: README 및 사용 가이드 작성 5. chore: 의존성 업데이트 및 빌드 설정
With Lazygit
Open Lazygit in your repository:
lazygitStage your files (use space to stage)
Press
I(capital i) to trigger the AI commit message generatorSelect a commit message from the generated options
Done! Your commit is created automatically
Commands
lazy-ai config
Configure API key and model settings.
lazy-ai generate [options] (alias: g)
Generate AI-powered commit messages.
Options:
-n, --number <count>: Number of commit messages to generate (default: 5)
Example:
lazy-ai g -n 3How It Works
┌─────────────────────────────────────────────┐
│ 1. Stage files (git add) │
└────────────┬────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────┐
│ 2. Extract git diff (git diff --cached) │
└────────────┬────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────┐
│ 3. Send to Gemini API with prompt rules │
└────────────┬────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────┐
│ 4. Parse AI response │
└────────────┬────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────┐
│ 5. Display formatted commit messages │
└─────────────────────────────────────────────┘Configuration Details
The configuration is stored locally using the conf library:
- macOS:
~/Library/Application Support/lazy-ai-nodejs/config.json - Linux:
~/.config/lazy-ai-nodejs/config.json - Windows:
%APPDATA%\lazy-ai-nodejs\config.json
Stored settings:
apiKey: Your Gemini API keymodel: AI model to use (default:gemini-2.5-flash)language: Output language (default:ko)customRules: Additional commit message rules
Customization
Change Output Language
Currently, the default language is Korean (ko). To use a different language, you can modify the language setting in your config file or add a CLI option for language selection.
Custom Commit Rules
The tool follows Conventional Commits format by default:
feat:- New featurefix:- Bug fixchore:- Maintenance tasksdocs:- Documentationrefactor:- Code refactoringstyle:- Code style changestest:- Adding tests
Troubleshooting
"Error: API key not configured"
Run lazy-ai config to set up your API key.
"Error: No staged changes found"
Stage your files first with git add <files>.
Lazygit custom command not working
- Verify the config file location
- Check YAML indentation (use spaces, not tabs)
- Restart Lazygit after configuration changes
Development
Project Structure
src/
├── cli.ts # CLI commands and entry point
├── ai.ts # Gemini API integration
├── git.ts # Git operations (diff extraction)
├── config.ts # Configuration management
└── rules/
└── output.ts # AI prompt rules and formattingLicense
MIT
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Note: This tool requires staged changes (git add) before generating commit messages. It analyzes the diff to create contextually relevant commit messages.
