承接 jesse-bos/openai-commit-messages 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jesse-bos/openai-commit-messages

最新稳定版本:v1.0.0

Composer 安装命令:

composer require jesse-bos/openai-commit-messages

包简介

A Laravel package that generates AI-powered commit messages using OpenAI

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

OpenAI Commit Messages is a Laravel package that generates meaningful commit messages using OpenAI based on your git changes. It first checks for staged changes, and if none are found, analyzes unstaged changes. Just run one command and get a suggested commit message!

Installation

Step 1: Install the Package

composer require jesse-bos/openai-commit-messages --dev

This automatically installs the required OpenAI Laravel package as well.

Step 2: Publish OpenAI Configuration

php artisan vendor:publish --provider="OpenAI\Laravel\ServiceProvider"

Step 3: Add your OpenAI API Key

  1. Get an API key from OpenAI's website
  2. Add it to your .env file:
OPENAI_API_KEY=sk-your-actual-api-key-here

Step 4: Optionally configure the Package

If you want to customize the OpenAI model, publish the package config:

php artisan vendor:publish --tag="openai-commit-messages-config"

Prerequisites

  • PHP 8.3+
  • Laravel 11.0+ or 12.0+
  • OpenAI API key with sufficient credits

Usage

Verify your setup (recommended first time)

After installation, verify that everything is configured correctly by running the command. The package will automatically check:

  • ✓ OpenAI API key is set
  • ✓ OpenAI configuration is published
  • ✓ You're in a git repository
  • ✓ Model configuration

Generate commit messages

After making changes in your git repository, simply run:

php artisan openai:commit-message

The package will automatically:

  1. First check for staged changes (files added with git add or staged via Tower, GitHub Desktop, etc.)
  2. If no staged changes found, it will analyze unstaged changes
  3. Generate a commit message based on the found changes using OpenAI

The tool works seamlessly with any git workflow:

  • Command line: git add . then php artisan openai:commit-message
  • Tower/GitHub Desktop: Stage files in the GUI, then run php artisan openai:commit-message
  • Quick preview: Just run php artisan openai:commit-message to see a message for unstaged changes

After getting the suggested message, create your commit:

git commit -m "the suggested message"

Configuration

You can configure the package by publishing and editing the config file:

php artisan vendor:publish --tag="openai-commit-messages-config"

Available Configuration Options

return [
    'openai' => [
        // OpenAI model to use for generating commit messages
        'model' => env('OPENAI_COMMIT_MESSAGES_MODEL', 'gpt-4o-mini'),
    ],

    'commit' => [
        // Maximum length for the commit message
        'max_length' => 72,

        // Use conventional commit format (e.g. feat: message, fix: bug)
        'conventional' => true,
    ],
];

Environment Variables

You can also configure the OpenAI model using an environment variable:

OPENAI_COMMIT_MESSAGES_MODEL=gpt-4o

Testing

composer test

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 34
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-25