Package Exports
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (bodhi-commit-genius-js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
🚀 Bodhi Commit Genius JS
A powerful npm package that generates smart, AI-powered commit messages for your Git repositories. Works offline with smart heuristics, with cloud AI (OpenAI), or with local AI models (Ollama). Perfect for developers, teams, and organizations looking to maintain clean, consistent, and meaningful Git history.
📦 Installation
# Install globally
npm install -g bodhi-commit-genius-js
# Or install in your project
npm install --save-dev bodhi-commit-genius-js
🚀 Usage Examples
Basic Usage
# Generate message for staged changes
bodhi commit
# Stage and commit all changes
bodhi commit .
# Stage specific files
bodhi commit src/feature.ts tests/feature.test.ts
# Use specific provider
bodhi commit --provider openai
bodhi commit --provider ollama
bodhi commit --provider simple
🎯 Why Choose Bodhi Commit Genius?
- 🤖 AI-Powered Intelligence: Uses advanced AI to understand your code changes
- 🔄 Works Offline: Smart heuristics work without internet or AI
- 🛡️ Fallback Protection: Automatically switches to offline mode if AI is unavailable
- 📊 Smart Analysis: Understands code patterns, file types, and change context
- 🌐 Multiple AI Options: Choose between cloud AI (OpenAI) or local AI (Ollama)
- 💰 Cost-Effective: Free offline mode, optional AI integration
- 🔒 Privacy-Focused: Local AI option for sensitive code
- 🚀 Developer-Friendly: Easy setup, works with existing Git workflow
✨ Features
- 🤖 Smart commit message generation using multiple providers:
- 📝 Simple mode: No dependencies, works offline using smart heuristics
- 🌐 OpenAI mode: Uses OpenAI's GPT models (requires API key)
- 💻 Ollama mode: Uses local LLMs (requires Ollama installation)
- 📊 Intelligent diff analysis for better context understanding
- 🎯 Conventional commits support with type inference
- ⚡ Git hooks integration for seamless workflow
- 🔧 Customizable commit message templates
- 💻 Interactive mode for message editing
- 🚀 TypeScript support out of the box
Advanced Examples
# Custom commit template
bodhi commit --template "type(scope): message"
# Interactive mode
bodhi commit -i
# With OpenAI key
bodhi commit --provider openai --api-key your-key
# With specific Ollama model
bodhi commit --provider ollama --model codellama
Example Commit Messages
Feature Addition
feat(auth): add OAuth2 authentication with Google provider
Bug Fix
fix(api): handle null response in user service
Code Refactoring
refactor(core): move API routes to dedicated modules
Documentation
docs(api): add OpenAPI specification and examples
Testing
test(auth): add integration tests for login flow
Performance
perf(db): optimize user query with index
Configuration
Create a .commitgenius.json
in your project root or configure via CLI:
{
"provider": "simple", // "simple", "ollama", or "openai"
"model": "codellama", // for ollama provider
"apiKey": "your-openai-key", // for openai provider
"template": "{type}: {description}",
"conventionalCommits": true
}
🤖 Provider Setup Guide
Commit Genius offers three modes of operation, giving you the flexibility to use it with or without AI capabilities:
1. Simple Mode (Default) - No AI Required
The simplest way to get started - works offline and requires no additional setup.
✨ Features:
- Works completely offline
- No API keys or external dependencies
- Smart heuristics for commit type detection
- Conventional commit format support
- Analyzes file changes and code patterns
🚀 Setup:
# Just install and use!
npm install -g bodhi-commit-genius-js
bodhi commit
2. OpenAI Mode - Cloud AI
Get high-quality commit messages using OpenAI's GPT models. Requires an API key but offers the best quality.
✨ Features:
- High-quality, context-aware commit messages
- Understands complex code changes
- Best semantic analysis of changes
- Handles multiple files intelligently
🔑 Setup:
Get your OpenAI API key:
- Sign up at platform.openai.com
- Go to API Keys section
- Create a new API key
Configure Commit Genius:
# Set API key permanently cmg config set apiKey your-openai-key cmg config set provider openai # Or use per command bodhi commit --provider openai --api-key your-openai-key
💡 Note: If OpenAI is unavailable or the API key is invalid, Commit Genius will automatically fall back to simple mode.
3. Ollama Mode - Local AI
Run AI locally on your machine. Free to use and privacy-friendly, but requires local installation.
✨ Features:
- Runs completely locally
- No API keys needed
- Good balance of quality and privacy
- Multiple models supported
🚀 Setup:
Install Ollama:
- Windows:
# Download and install from: https://ollama.ai/download/windows
- Mac:
brew install ollama
- Linux:
curl -fsSL https://ollama.ai/install.sh | sh
- Windows:
Pull the model (one-time setup):
ollama pull codellama
Configure Commit Genius:
# Set as default provider cmg config set provider ollama # Or use per command bodhi commit --provider ollama
💡 Note: If Ollama is not running or encounters an error, Commit Genius will automatically fall back to simple mode.
Comparison of Modes
Feature | Simple | OpenAI | Ollama |
---|---|---|---|
Setup Required | None | API Key | Local Install |
Works Offline | ✅ | ❌ | ✅ |
Message Quality | Good | Best | Very Good |
Privacy | Best | Cloud-Based | Local Only |
Cost | Free | Pay-per-use | Free |
Speed | Fastest | Fast | Moderate |
Resource Usage | Minimal | Cloud-Based | Local GPU/CPU |
🔧 Integration Guide
Git Hooks Setup
Automatic Setup
{ "scripts": { "prepare": "bodhi-commit-genius-js install-hooks" } }
Manual Setup
# Install husky npm install husky --save-dev # Add prepare script npm pkg set scripts.prepare="husky install" # Add commit-msg hook npx husky add .husky/commit-msg 'npx bodhi validate $1'
CI/CD Integration
# GitHub Actions Example
name: Validate Commits
on: [pull_request]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- run: npm install -g bodhi-commit-genius-js
- run: cmg validate --from ${{ github.event.pull_request.base.sha }}
IDE Integration
VS Code
- Install Git Lens extension
- Configure external diff tool
- Use with VS Code source control
JetBrains IDEs
- Use with built-in VCS
- Configure external diff tool
- Terminal integration
📚 Best Practices
Commit Organization
- One logical change per commit
- Clear, descriptive messages
- Reference issues when relevant
Message Structure
type(scope): description [optional body] [optional footer]
Common Types
feat
: New featuresfix
: Bug fixesdocs
: Documentationstyle
: Formattingrefactor
: Code restructuringtest
: Adding testschore
: Maintenance
Scopes
- Module names
- Feature areas
- Components
- File types
📝 License
MIT
🙏 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.