mdeloughry/gcm-gen
Composer 安装命令:
composer require mdeloughry/gcm-gen
包简介
Git Commit Message Generator
README 文档
README
GCM-Gen is a CLI tool that generates meaningful commit messages by analysing your git changes. It uses AI to understand your code changes and generate appropriate commit messages. Supports both ChatGPT and Ollama for AI processing.
Features
- 🤖 AI-powered commit message generation (ChatGPT or Ollama)
- ⚡ Quick and easy to use
- 🛠️ Configurable prompts and settings
- 📝 Direct git commit integration with branch-based commit types
- 🎨 Beautiful terminal UI
Choosing an LLM Provider
GCM-Gen supports two AI providers, each with their own advantages:
ChatGPT (Recommended for Best Results)
- ✅ Superior commit message quality
- ✅ Faster processing
- ✅ Lower system requirements
- ❌ Requires API key
- ❌ Sends code diffs to OpenAI servers
- ❌ Usage costs (pay per API call)
Ollama (Recommended for Privacy/Offline Use)
- ✅ Completely free to use
- ✅ Runs 100% locally
- ✅ No data leaves your machine
- ❌ Requires significant system resources
- ❌ Slower processing time
- ❌ May produce less consistent results
Choose ChatGPT if you want the best quality commit messages and don't mind the API costs. Choose Ollama if you need to keep your code private or want a free, offline solution.
Requirements
Core Requirements
- PHP 8.1 or higher
- Composer
- Git
AI Provider Requirements
Option 1: ChatGPT
- OpenAI API Key
- Sign up at OpenAI Platform
- Create an API key at API Keys
- Add the API key to your configuration file
Option 2: Ollama
- Install Ollama
- Visit Ollama.ai to download and install
- Follow the installation instructions for your operating system
- Start the Ollama service:
ollama serve
- Pull the required model:
ollama pull llama3.2
Installation
Global Installation
composer global require mdeloughry/gcm-gen
Make sure your global Composer bin directory is in your system's PATH.
Usage
# Generate a commit message gcm-gen g # Generate and commit in one go gcm-gen c # Show current configuration gcm-gen config # Edit configuration gcm-gen config --edit
Configuration
On first run, GCM-Gen will create a configuration file at ~/.config/gcm-gen.config.php. You can edit this file directly or use:
gcm-gen config --edit
Configuration Options
The configuration file supports both ChatGPT and Ollama providers. Here's a complete example:
return [ 'provider' => 'chatgpt', // or 'ollama' 'ignore_files' => [ 'vendor', 'node_modules', 'package-lock.json', 'yarn.lock', 'composer.lock', 'dist', 'build', 'public', 'storage', ], 'ollama' => [ 'model' => 'llama3.2', // Default model ], 'chatgpt' => [ 'model' => 'gpt-4', // Default model 'api_key' => 'your-api-key-here', ], 'prompt' => <<<EOL Generate a git commit message based on the following rules: 1. First line: - Use imperative mood (Add not Added) - Max 50 characters - Format: [type] - [ticket] [description] - [ticket] is optional and can be built from the branch name look for the pattern '/(?:#(\d+)|([A-Z]+-\d+))/i' - [type] from branch patterns using emojis only (no branch pattern match): feature/* → ✨ bugfix/hotfix/* → 🐛 release/* → 🔖 default → 🤖 2. Optional body (if changes are complex): - Leave one blank line after subject - Create a new line at 72 characters - Explain the type of change in the first line - Explain what and why, not how - Add BREAKING CHANGE: for breaking changes EOL, ];
Configuration Breakdown
provider: Choose between 'chatgpt' or 'ollama'ignore_files: List of files and directories to exclude from the git diff analysisollama: Ollama-specific settingsmodel: The Ollama model to use (default: llama3.2)
chatgpt: ChatGPT-specific settingsmodel: The GPT model to use (default: gpt-4)api_key: Your OpenAI API key
prompt: The template used to generate commit messages, supporting:- Automatic emoji type based on branch name
- Ticket number extraction from branch names
- Conventional commit message formatting
Development Setup
- Clone the repository:
git clone https://github.com/mdeloughry/gcm-gen.git
cd gcm-gen
- Install dependencies:
composer install
- Set up your environment:
- Copy
.env.exampleto.env - Add your OpenAI API key to
.env
- Run tests:
composer test
Development Requirements
- PHP 8.1 or higher
- Composer
- OpenAI API key or Ollama installed locally
- Git
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
If you encounter any problems or have suggestions, please open an issue.
mdeloughry/gcm-gen 适用场景与选型建议
mdeloughry/gcm-gen 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 15 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 12 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「generator」 「git」 「message」 「commit」 「ai」 「openai」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mdeloughry/gcm-gen 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mdeloughry/gcm-gen 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mdeloughry/gcm-gen 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Memio's PrettyPrinter, used to generate PHP code from given Model
Easily manage git hooks in your composer config
PHP AMQP Binding Library
MediaWiki extension that allows embedding external content, specified by URL, into your wiki pages
Nagios plugin to verify a git repository.
GitHub Webhook Listener with plugin-based API for creating your own triggerered actions
统计信息
- 总下载量: 15
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-12-07