Skip to content

Automagically generate conventional git commit messages with AI. - 使用 AI 自动生成约定式 git 提交信息。

License

Notifications You must be signed in to change notification settings

guanguans/ai-commit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ai-commit

简体中文 | ENGLISH

Automagically generate conventional git commit messages with AI. - 使用 AI 自动生成约定式 git 提交信息。

tests check & fix styling codecov Latest Stable Version GitHub release (latest by date) Total Downloads License

Requirement

  • PHP >= 7.3

Installation

Download the ai-commit file

curl 'https://raw.githubusercontent.com/guanguans/ai-commit/main/builds/ai-commit' -o ai-commit --progress
chmod +x ai-commit

Install via Composer

# global
composer global require guanguans/ai-commit --dev -v

# local
composer require guanguans/ai-commit --dev -v

Usage

Quick start

# Config OpenAI API key(https://platform.openai.com/account/api-keys)
./ai-commit config set generators.openaichat.api_key sk-... --global
./ai-commit config set generators.openai.api_key sk-... --global

# Generate and commit message
./ai-commit commit
╰─ ./ai-commit commit                                                                                                   ─╯
1. Generating commit messages: generating...

[
    {
        "id": 1,
        "subject": "Docs(README): Update README files",
        "body": "- Update README-zh_CN.md\n- Update README.md\n- Explain how to configure OpenAI API key"
    },
    {
        "id": 2,
        "subject": "Install(Composer): Add install instructions",
        "body": "- Update README.md\n- Add instructions for global and local install via Composer"
    },
    {
        "id": 3,
        "subject": "Commit Messages): Add best practices",
        "body": "- Update README.md\n- Add best practices for writing commit messages"
    }
1. Generating commit messages: ✔
2. Choosing commit message: choosing...
+----+---------------------------------------------+--------------------------------------------------------------+
| id | subject                                     | body                                                         |
+----+---------------------------------------------+--------------------------------------------------------------+
| 1  | Docs(README): Update README files           | - Update README-zh_CN.md                                     |
|    |                                             | - Update README.md                                           |
|    |                                             | - Explain how to configure OpenAI API key                    |
+----+---------------------------------------------+--------------------------------------------------------------+
| 2  | Install(Composer): Add install instructions | - Update README.md                                           |
|    |                                             | - Add instructions for global and local install via Composer |
+----+---------------------------------------------+--------------------------------------------------------------+
| 3  | Commit Messages): Add best practices        | - Update README.md                                           |
|    |                                             | - Add best practices for writing commit messages             |
+----+---------------------------------------------+--------------------------------------------------------------+

 Please choice a commit message [Docs(README): Update README files]:
  [1] Docs(README): Update README files
  [2] Install(Composer): Add install instructions
  [3] Commit Messages): Add best practices
 > Docs(README): Update README files

2. Choosing commit message: ✔
3. Committing message: committing...
[main 8c07fa3] Docs(README): Update README files
 1 file changed, 1 insertion(+), 29 deletions(-)
3. Committing message: ✔

                                                                                                                        
 [OK] Generate and commit messages have succeeded                                                                       
                                                                                                                        

List commands

╰─ ./ai-commit list                                                     ─╯

  
          _____    _____                          _ _   
    /\   |_   _|  / ____|                        (_) |  
   /  \    | |   | |     ___  _ __ ___  _ __ ___  _| |_ 
  / /\ \   | |   | |    / _ \| '_ ` _ \| '_ ` _ \| | __|
 / ____ \ _| |_  | |___| (_) | | | | | | | | | | | | |_ 
/_/    \_\_____|  \_____\___/|_| |_| |_|_| |_| |_|_|\__|
                                                        
                                                        

  1.2.5

  USAGE: ai-commit <command> [options] [arguments]

  commit      Automagically generate conventional commit messages with AI.
  completion  Dump the shell completion script
  config      Manage config options.
  self-update Allows to self-update a build application
  thanks      Thanks for using this tool.

Operate config

./ai-commit config [set, get, unset, reset, list, edit] key value --global

./ai-commit config set key value
./ai-commit config get key
./ai-commit config unset key
./ai-commit config reset key
./ai-commit config list
./ai-commit config edit

Self update

╰─ ./ai-commit self-update                                        ─╯

Checking for a new version...
=============================

                                                                     
 [OK] Updated from version 1.2.4 to v1.2.5.                          
                                                                     

Command help

╰─ ./ai-commit commit --help                                                                                                                                        ─╯
Description:
  Automagically generate conventional commit messages with AI.

Usage:
  commit [options] [--] [<path>]

Arguments:
  path                                   The working directory [default: "/Users/yaozm/Documents/develop/ai-commit"]
                                         
Options:                                 
      --commit-options[=COMMIT-OPTIONS]  Append options for the `git commit` command [default: ["--edit"]] (multiple values allowed)
      --diff-options[=DIFF-OPTIONS]      Append options for the `git diff` command [default: [":!*.lock",":!*.sum"]] (multiple values allowed)
  -g, --generator=GENERATOR              Specify generator name [default: "openaichat"]
  -p, --prompt=PROMPT                    Specify prompt name of messages generated [default: "conventional"]
      --no-edit                          Force no edit mode
  -c, --config[=CONFIG]                  Specify config file
      --retry-times=RETRY-TIMES          Specify times of retry [default: 3]
      --retry-sleep=RETRY-SLEEP          Specify sleep milliseconds of retry [default: 500]
  -h, --help                             Display help for the given command. When no command is given display help for the list command
  -q, --quiet                            Do not output any message
  -V, --version                          Display this application version
      --ansi|--no-ansi                   Force (or disable --no-ansi) ANSI output
  -n, --no-interaction                   Do not ask any interactive question
      --env[=ENV]                        The environment the command should run under
  -v|vv|vvv, --verbose                   Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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

About

Automagically generate conventional git commit messages with AI. - 使用 AI 自动生成约定式 git 提交信息。

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Contributors 8

Languages