|
| 1 | +# ai-commit |
| 2 | + |
| 3 | +<p align="center"><img src="docs/logo.png" alt="logo" style="width: 62%; height: 62%;"></p> |
| 4 | + |
| 5 | +[简体中文](README-zh_CN.md) | [ENGLISH](README.md) | [日本語](README-ja_JP.md) | [繁體中文](README-zh_TW.md) |
| 6 | + |
| 7 | +> Automagically generate conventional git commit message with AI. - 使用 AI 自動生成約定式 git 提交訊息。 |
| 8 | +
|
| 9 | +[](https://github.com/guanguans/ai-commit/actions) |
| 10 | +[](https://github.com/guanguans/ai-commit/actions) |
| 11 | +[](https://codecov.io/gh/guanguans/ai-commit) |
| 12 | +[](https://packagist.org/packages/guanguans/ai-commit) |
| 13 | + |
| 14 | +[](https://packagist.org/packages/guanguans/ai-commit) |
| 15 | +[](https://packagist.org/packages/guanguans/ai-commit) |
| 16 | + |
| 17 | +## 支援 |
| 18 | + |
| 19 | +- [x] [Bito Cli](https://github.com/gitbito/CLI) |
| 20 | +- [x] [ERNIE-Bot-turbo](https://cloud.baidu.com/doc/WENXINWORKSHOP/s/Nlks5zkzu#ernie-bot-turbo) |
| 21 | +- [x] [ERNIE-Bot](https://cloud.baidu.com/doc/WENXINWORKSHOP/s/Nlks5zkzu#ernie-bot) |
| 22 | +- [x] [GitHub Copilot CLI](https://github.com/github/gh-copilot) |
| 23 | +- [x] [Moonshot](https://platform.moonshot.cn/docs/api-reference) |
| 24 | +- [x] [OpenAI Chat](https://platform.openai.com/docs/api-reference/chat) |
| 25 | +- [x] [OpenAI](https://platform.openai.com/docs/api-reference/completions) |
| 26 | +- [ ] ... |
| 27 | + |
| 28 | +## 系統需求 |
| 29 | + |
| 30 | +* PHP >= 7.3 |
| 31 | + |
| 32 | +## 安裝 |
| 33 | + |
| 34 | +### 下載 [ai-commit](./builds/ai-commit) 檔案 |
| 35 | + |
| 36 | +```shell |
| 37 | +curl 'https://raw.githubusercontent.com/guanguans/ai-commit/main/builds/ai-commit' -o ai-commit -# |
| 38 | +chmod +x ai-commit |
| 39 | +``` |
| 40 | + |
| 41 | +### 透過 Composer 安裝 |
| 42 | + |
| 43 | +```shell |
| 44 | +composer global require guanguans/ai-commit --dev -v # 全域安裝 |
| 45 | +composer require guanguans/ai-commit --dev -v # 本地安裝 |
| 46 | +``` |
| 47 | + |
| 48 | +## 使用方法 |
| 49 | + |
| 50 | +### 快速開始 |
| 51 | + |
| 52 | +```shell |
| 53 | +./ai-commit config set generators.bito_cli.binary bito-cli-binary... --global # 設定 Bito cli 執行檔(可選) |
| 54 | +./ai-commit config set generators.ernie_bot.api_key api-key... --global # 設定 Ernie API 金鑰 |
| 55 | +./ai-commit config set generators.ernie_bot_turbo.api_key api-key... --global # 設定 Ernie API 金鑰 |
| 56 | +./ai-commit config set generators.github_copilot_cli.binary gh-cli-binary... --global # 設定 Github cli 執行檔(可選) |
| 57 | +./ai-commit config set generators.moonshot.api_key sk-... --global # 設定 Moonshot API 金鑰 |
| 58 | +./ai-commit config set generators.openai.api_key sk-... --global # 設定 OpenAI API 金鑰 |
| 59 | +./ai-commit config set generators.openai_chat.api_key sk-... --global # 設定 OpenAI API 金鑰 |
| 60 | + |
| 61 | +./ai-commit config set generator openai_chat --global # 設定預設生成器(可選) |
| 62 | +./ai-commit commit # 使用預設生成器產生並提交訊息 |
| 63 | +./ai-commit commit --generator=github_copilot_cli # 使用指定的生成器產生並提交訊息 |
| 64 | +``` |
| 65 | + |
| 66 | +```shell |
| 67 | +╰─ ./ai-commit commit --generator=openai_chat --no-edit --no-verify --ansi ─╯ |
| 68 | +1. 產生提交訊息中:正在產生... |
| 69 | +{ |
| 70 | + "subject": "chore(ai-commit): update settings and commands", |
| 71 | + "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" |
| 72 | +} |
| 73 | +1. 產生提交訊息:✔ |
| 74 | + |
| 75 | +2. 確認提交訊息:確認中... |
| 76 | ++------------------------------------------------+---------------------------------------+ |
| 77 | +| subject | body | |
| 78 | ++------------------------------------------------+---------------------------------------+ |
| 79 | +| chore(ai-commit): update settings and commands | - Set Width to 1200 | |
| 80 | +| | - Set Height to 742 | |
| 81 | +| | - Set TypingSpeed to 10ms | |
| 82 | +| | - Set PlaybackSpeed to 0.2 | |
| 83 | +| | - Update git commands and sleep times | |
| 84 | ++------------------------------------------------+---------------------------------------+ |
| 85 | + |
| 86 | + 是否要提交此訊息?(yes/no) [yes]: |
| 87 | + > |
| 88 | + |
| 89 | +2. 確認提交訊息:✔ |
| 90 | + |
| 91 | +3. 提交訊息中:提交中... |
| 92 | + |
| 93 | +3. 提交訊息:✔ |
| 94 | + |
| 95 | + |
| 96 | + [OK] 成功產生並提交訊息。 |
| 97 | +``` |
| 98 | + |
| 99 | + |
| 100 | + |
| 101 | +### 指令列表 |
| 102 | + |
| 103 | +```shell |
| 104 | +╰─ ./ai-commit list ─╯ |
| 105 | + |
| 106 | + |
| 107 | + _____ _____ _ _ |
| 108 | + /\ |_ _| / ____| (_) | |
| 109 | + / \ | | | | ___ _ __ ___ _ __ ___ _| |_ |
| 110 | + / /\ \ | | | | / _ \| '_ ` _ \| '_ ` _ \| | __| |
| 111 | + / ____ \ _| |_ | |___| (_) | | | | | | | | | | | | |_ |
| 112 | +/_/ \_\_____| \_____\___/|_| |_| |_|_| |_| |_|_|\__| |
| 113 | + |
| 114 | + |
| 115 | +
|
| 116 | + 1.2.5 |
| 117 | +
|
| 118 | + 使用方式:ai-commit <command> [options] [arguments] |
| 119 | +
|
| 120 | + commit 使用 AI 自動生成約定式提交訊息。 |
| 121 | + completion 輸出 shell 自動完成腳本 |
| 122 | + config 管理設定選項。 |
| 123 | + self-update 允許自我更新建置應用程式 |
| 124 | + thanks 感謝使用此工具。 |
| 125 | +``` |
| 126 | + |
| 127 | +### 設定操作 |
| 128 | + |
| 129 | +```shell |
| 130 | +./ai-commit config [set, get, unset, reset, list, edit] key value --global |
| 131 | +
|
| 132 | +./ai-commit config set key value |
| 133 | +./ai-commit config get key |
| 134 | +./ai-commit config unset key |
| 135 | +./ai-commit config reset key |
| 136 | +./ai-commit config list |
| 137 | +./ai-commit config edit |
| 138 | +``` |
| 139 | + |
| 140 | +### 自動更新 |
| 141 | + |
| 142 | +```shell |
| 143 | +╰─ ./ai-commit self-update ─╯ |
| 144 | +
|
| 145 | +檢查新版本... |
| 146 | +============================= |
| 147 | +
|
| 148 | + |
| 149 | + [OK] 已從版本 1.2.4 更新至 v1.2.5。 |
| 150 | + |
| 151 | +``` |
| 152 | + |
| 153 | +### 指令說明 |
| 154 | + |
| 155 | +```shell |
| 156 | +╰─ ./ai-commit commit --help ─╯ |
| 157 | +描述: |
| 158 | + 使用 AI 自動生成約定式提交訊息。 |
| 159 | +
|
| 160 | +用法: |
| 161 | + commit [options] [--] [<path>] |
| 162 | +
|
| 163 | +參數: |
| 164 | + path 工作目錄 [預設值:"/Users/yaozm/Documents/develop/ai-commit"] |
| 165 | +
|
| 166 | +選項: |
| 167 | + --commit-options[=COMMIT-OPTIONS] 為 `git commit` 指令附加選項 [預設值:["--edit"]] (可多值) |
| 168 | + --diff-options[=DIFF-OPTIONS] 為 `git diff` 指令附加選項 [預設值:[":!*-lock.json",":!*.lock",":!*.sum"]] (可多值) |
| 169 | + -g, --generator=GENERATOR 指定生成器名稱 [預設值:"openai_chat"] |
| 170 | + -p, --prompt=PROMPT 指定訊息生成的提示名稱 [預設值:"conventional"] |
| 171 | + --no-edit 啟用或停用 git commit `--no-edit` 選項 |
| 172 | + --no-verify 啟用或停用 git commit `--no-verify` 選項 |
| 173 | + -c, --config[=CONFIG] 指定設定檔 |
| 174 | + --retry-times=RETRY-TIMES 指定重試次數 [預設值:3] |
| 175 | + --retry-sleep=RETRY-SLEEP 指定重試間隔毫秒數 [預設值:200] |
| 176 | + --dry-run 僅生成訊息而不提交 |
| 177 | + --diff[=DIFF] 指定差異內容 |
| 178 | + -h, --help 顯示指定指令的說明。若未指定指令則顯示 list 指令的說明 |
| 179 | + -q, --quiet 不輸出任何訊息 |
| 180 | + -V, --version 顯示此應用程式版本 |
| 181 | + --ansi|--no-ansi 強制(或停用 --no-ansi)ANSI 輸出 |
| 182 | + -n, --no-interaction 不詢問任何互動問題 |
| 183 | + --env[=ENV] 指令應在其下執行的環境 |
| 184 | + -v|vv|vvv, --verbose 增加訊息的詳細程度:1 為正常輸出,2 為較詳細輸出,3 為偵錯輸出 |
| 185 | +``` |
| 186 | +
|
| 187 | +## 測試 |
| 188 | +
|
| 189 | +```shell |
| 190 | +composer test |
| 191 | +``` |
| 192 | +
|
| 193 | +## 更新日誌 |
| 194 | +
|
| 195 | +有關最近的變更,請參閱 [CHANGELOG](CHANGELOG.md)。 |
| 196 | +
|
| 197 | +## 貢獻 |
| 198 | +
|
| 199 | +詳情請參閱 [CONTRIBUTING](.github/CONTRIBUTING.md)。 |
| 200 | +
|
| 201 | +## 安全漏洞 |
| 202 | +
|
| 203 | +請查看[我們的安全政策](../../security/policy)了解如何回報安全漏洞。 |
| 204 | +
|
| 205 | +## 致謝 |
| 206 | +
|
| 207 | +* [guanguans](https://github.com/guanguans) |
| 208 | +* [所有貢獻者](../../contributors) |
| 209 | +
|
| 210 | +## 授權條款 |
| 211 | +
|
| 212 | +MIT 授權條款 (MIT)。更多資訊請參閱 [授權檔案](LICENSE)。 |
0 commit comments