Giter Site home page Giter Site logo

guanguans / ai-commit Goto Github PK

View Code? Open in Web Editor NEW
189.0 3.0 7.0 109.67 MB

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

License: MIT License

PHP 100.00%
ai changelog chatgpt commit commit-message commitizen commitlint git git-diff gpt

ai-commit's Introduction

ai-commit

logo

简体中文 | ENGLISH

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

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

Support

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 -#
chmod +x ai-commit

Install via Composer

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

Usage

Quick start

./ai-commit config set generators.bito_cli.path bito-cli-path... --global # Config Bito Cli path(Optional)
./ai-commit config set generators.openai.api_key sk-... --global # Config OpenAI API key
./ai-commit config set generators.openai_chat.api_key sk-... --global # Config OpenAI API key

./ai-commit config set generator openai_chat --global # Config default generator(Optional)
./ai-commit commit # Generate and commit message
╰─ ./ai-commit commit --generator=openai_chat --no-edit --no-verify --ansi                                           ─╯
1. Generating commit message: generating...
{
    "subject": "chore(ai-commit): update settings and commands",
    "body": "- Set Width to 1200\n- Set Height to 742\n- Set TypingSpeed to 10ms\n- Set PlaybackSpeed to 0.2\n- Update git commands and sleep times"
}
1. Generating commit message: ✔

2. Confirming commit message: confirming...
+------------------------------------------------+---------------------------------------+
| subject                                        | body                                  |
+------------------------------------------------+---------------------------------------+
| chore(ai-commit): update settings and commands | - Set Width to 1200                   |
|                                                | - Set Height to 742                   |
|                                                | - Set TypingSpeed to 10ms             |
|                                                | - Set PlaybackSpeed to 0.2            |
|                                                | - Update git commands and sleep times |
+------------------------------------------------+---------------------------------------+

 Do you want to commit this message? (yes/no) [yes]:
 > 


2. Confirming commit message: ✔

3. Committing message: committing...

3. Committing message: ✔

                                                                                                                        
 [OK] Successfully generated and committed message.                                                                     
                                                                                                                                                                                                                                                                                        

List commands

╰─ ./ai-commit list                                                     ─╯

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

  1.2.5

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

  commit      Automagically generate conventional commit message 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 message 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: "openai_chat"]
  -p, --prompt=PROMPT                    Specify prompt name of message generated [default: "conventional"]
      --no-edit                          Enable or disable git commit `--no-edit` option
      --no-verify                        Enable or disable git commit `--no-verify` option
  -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: 200]
  -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.

ai-commit's People

Contributors

dependabot[bot] avatar github-actions[bot] avatar guanguans avatar imgbotapp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ai-commit's Issues

不支持 PHP8.1?

During inheritance of ArrayAccess: Uncaught ErrorException: Return type of Illuminate\S  
  upport\Collection::offsetExists($key) should either be compatible with ArrayAccess::off  
  setExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be use  
  d to temporarily suppress the notice in phar:///Users/hdj/.composer/vendor/guanguans/ai  
  -commit/builds/ai-commit/vendor/illuminate/support/Collection.php:1349 

keep geting commit message like "commit message"

I keep getting the commit message shown in the pic below.
image

I have added Avoid using general terms like "update", "commit message", or "change" in the subject line, be specific about what was updated or changed." to the prompts but it doesn't work.
image

Is it possible to filter the message?

400 Request Exception when trying to generate commit

Describe the bug

  [Illuminate\Http\Client\RequestException (400)]
  HTTP request returned status code 400

To Reproduce
Steps to reproduce the behavior:

  1. Configure ai-commit
  2. Run ai-commit commit -v
  3. See error

Expected behavior
I expected the function to work similar to the demo

Screenshots
image

Additional context

增加一个配置,让ai-commit忽略部分文件

Is your feature request related to a problem? Please describe.
我使用protobuf生成一些文件,提交代码的时候ai-commit会去分析这些文件,这样耗费我大量的token,而且3.5模型会因为超大上下文而无法正常工作。

Describe the solution you'd like
能不能增加一个配置,让ai-commit忽略部分文件,像.gitignore那样,以xx开头文件不作为prompt发送

Describe alternatives you've considered
我尝试过在prompt让AI不分析生成式文件,但似乎不起作用

非常感谢作者让我们用上这么方便的工具(造福想不出commit词的打工人)

cURL error 60: SSL certificate problem

Describe the bug
I can not use the command 'ai-commit commit'. It gives me an error about a ssl certificate problem.

To Reproduce
Steps to reproduce the behavior:

  1. Open PowerShell under Windows (current version)
  2. Go into the folder with the git-repo to use with ai-commit
  3. make sure that your apikey is correct
  4. Enter the command 'ai-commit commit'
  5. see the following output:
    `1. Generating commit messages: failed

In CurlFactory.php line 211:

cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/
libcurl-errors.html) for https://api.openai.com/v1/completions`

Expected behavior
The error should not accoure and the commit should have been generated.

Additional context

  • OS: Windows 11
  • Shell: PowerShell Core 7.2
  • php version: PHP 7.4.33 (cli) (built: Nov 2 2022 16:00:55) ( ZTS Visual C++ 2017 x64 ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies
  • ai-commit version: 1.2.6

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.