ai-git-tools 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/LICENSE +21 -0
- package/README.md +353 -0
- package/bin/cli.js +86 -0
- package/package.json +60 -0
- package/src/commands/commit-all.js +266 -0
- package/src/commands/commit.js +115 -0
- package/src/commands/init.js +163 -0
- package/src/commands/pr.js +305 -0
- package/src/commands/workflow.js +36 -0
- package/src/core/ai-client.js +115 -0
- package/src/core/config-loader.js +165 -0
- package/src/core/git-operations.js +263 -0
- package/src/core/github-api.js +139 -0
- package/src/index.js +16 -0
- package/src/utils/helpers.js +88 -0
- package/src/utils/logger.js +123 -0
- package/templates/.ai-git-config.template.js +38 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.0.0] - 2026-02-12
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- 🎯 Smart commit generation for staged changes
|
|
12
|
+
- 🚀 Batch commit with intelligent grouping
|
|
13
|
+
- 📤 Automatic PR creation with AI-generated content
|
|
14
|
+
- 👥 Smart reviewer suggestions based on Git history
|
|
15
|
+
- 🏷️ Automatic label suggestions
|
|
16
|
+
- ⚙️ Configuration file support
|
|
17
|
+
- 🌐 Cross-project compatibility
|
|
18
|
+
- 📝 Comprehensive documentation
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
- \`gitai init\` - Initialize configuration
|
|
22
|
+
- \`gitai commit\` - Single commit generation
|
|
23
|
+
- \`gitai commit-all\` - Batch commit with grouping
|
|
24
|
+
- \`gitai pr\` - PR generation and creation
|
|
25
|
+
- \`gitai workflow\` - Complete workflow automation
|
|
26
|
+
|
|
27
|
+
### Technical Details
|
|
28
|
+
- Built with Commander.js for CLI
|
|
29
|
+
- GitHub Copilot SDK integration
|
|
30
|
+
- Chalk for colorful output
|
|
31
|
+
- Ora for spinners
|
|
32
|
+
- Inquirer for interactive prompts
|
|
33
|
+
- Supports multiple AI models (GPT-4.1, Claude, etc.)
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AI Git Tools
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
# AI Git Tools
|
|
2
|
+
|
|
3
|
+
🤖 AI-powered Git automation tools for commit messages and PR generation
|
|
4
|
+
|
|
5
|
+
使用 AI 自動生成符合規範的 commit message 和 Pull Request,讓你的 Git 工作流程更智能、更高效!
|
|
6
|
+
|
|
7
|
+
## ✨ 功能特色
|
|
8
|
+
|
|
9
|
+
- **🎯 智能 Commit** - 自動分析變更並生成符合 Conventional Commits 規範的 commit message
|
|
10
|
+
- **🚀 批量提交** - 智能分析所有變更,自動分組並提交多個有意義的 commits
|
|
11
|
+
- **📤 自動 PR** - 生成完整的 PR 標題和描述,並自動創建 Pull Request
|
|
12
|
+
- **👥 智能 Reviewer** - 基於 Git 歷史分析,自動建議合適的 reviewers
|
|
13
|
+
- **🏷️ 自動 Labels** - 智能分析變更內容,自動添加合適的 labels
|
|
14
|
+
- **⚙️ 配置檔支援** - 靈活的配置選項,適應不同專案需求
|
|
15
|
+
- **🌐 跨專案通用** - 可在任何 Git 專案中使用
|
|
16
|
+
|
|
17
|
+
## 📦 安裝
|
|
18
|
+
|
|
19
|
+
### NPX 使用(推薦)
|
|
20
|
+
|
|
21
|
+
無需安裝,直接使用:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npx ai-git-tools init
|
|
25
|
+
npx ai-git-tools commit
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### 全域安裝
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install -g ai-git-tools
|
|
32
|
+
gitai init
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### 專案內安裝
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm install --save-dev ai-git-tools
|
|
39
|
+
|
|
40
|
+
# 加入 package.json scripts
|
|
41
|
+
{
|
|
42
|
+
"scripts": {
|
|
43
|
+
"commit": "gitai commit",
|
|
44
|
+
"commit:all": "gitai commit-all",
|
|
45
|
+
"pr": "gitai pr"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## 🚀 快速開始
|
|
51
|
+
|
|
52
|
+
### 1. 初始化配置
|
|
53
|
+
|
|
54
|
+
\`\`\`bash
|
|
55
|
+
npx gitai init
|
|
56
|
+
\`\`\`
|
|
57
|
+
|
|
58
|
+
這會在您的專案根目錄創建 \`.ai-git-config.js\` 配置檔。
|
|
59
|
+
|
|
60
|
+
### 2. 開始使用
|
|
61
|
+
|
|
62
|
+
#### 單次 Commit
|
|
63
|
+
|
|
64
|
+
已經使用 \`git add\` staged 好變更:
|
|
65
|
+
|
|
66
|
+
\`\`\`bash
|
|
67
|
+
git add src/components/Button.jsx
|
|
68
|
+
npx gitai commit
|
|
69
|
+
\`\`\`
|
|
70
|
+
|
|
71
|
+
#### 智能批量 Commit
|
|
72
|
+
|
|
73
|
+
自動分析所有變更並分組提交:
|
|
74
|
+
|
|
75
|
+
\`\`\`bash
|
|
76
|
+
npx gitai commit-all
|
|
77
|
+
# 或簡寫
|
|
78
|
+
npx gitai ca
|
|
79
|
+
\`\`\`
|
|
80
|
+
|
|
81
|
+
#### 創建 PR
|
|
82
|
+
|
|
83
|
+
\`\`\`bash
|
|
84
|
+
npx gitai pr
|
|
85
|
+
\`\`\`
|
|
86
|
+
|
|
87
|
+
#### 完整工作流程
|
|
88
|
+
|
|
89
|
+
Commit + PR 一次完成:
|
|
90
|
+
|
|
91
|
+
\`\`\`bash
|
|
92
|
+
npx gitai workflow
|
|
93
|
+
# 或簡寫
|
|
94
|
+
npx gitai wf
|
|
95
|
+
\`\`\`
|
|
96
|
+
|
|
97
|
+
## 📖 命令說明
|
|
98
|
+
|
|
99
|
+
### \`gitai init\`
|
|
100
|
+
|
|
101
|
+
初始化配置檔案
|
|
102
|
+
|
|
103
|
+
\`\`\`bash
|
|
104
|
+
npx gitai init
|
|
105
|
+
\`\`\`
|
|
106
|
+
|
|
107
|
+
### \`gitai commit\`
|
|
108
|
+
|
|
109
|
+
為已 staged 的變更生成並執行 commit
|
|
110
|
+
|
|
111
|
+
\`\`\`bash
|
|
112
|
+
npx gitai commit [選項]
|
|
113
|
+
|
|
114
|
+
選項:
|
|
115
|
+
-m, --model <model> 指定 AI 模型
|
|
116
|
+
-v, --verbose 顯示詳細輸出
|
|
117
|
+
--max-diff <number> 最大 diff 長度
|
|
118
|
+
--max-retries <number> 最大重試次數
|
|
119
|
+
\`\`\`
|
|
120
|
+
|
|
121
|
+
**範例:**
|
|
122
|
+
|
|
123
|
+
\`\`\`bash
|
|
124
|
+
npx gitai commit
|
|
125
|
+
npx gitai commit --model claude-haiku-4.5
|
|
126
|
+
npx gitai commit --verbose
|
|
127
|
+
\`\`\`
|
|
128
|
+
|
|
129
|
+
### \`gitai commit-all\` (別名: \`ca\`)
|
|
130
|
+
|
|
131
|
+
智能分析所有變更並自動分組提交
|
|
132
|
+
|
|
133
|
+
\`\`\`bash
|
|
134
|
+
npx gitai commit-all [選項]
|
|
135
|
+
|
|
136
|
+
選項:
|
|
137
|
+
-m, --model <model> 指定 AI 模型
|
|
138
|
+
-v, --verbose 顯示詳細輸出
|
|
139
|
+
--max-diff <number> 最大 diff 長度
|
|
140
|
+
--max-retries <number> 最大重試次數
|
|
141
|
+
\`\`\`
|
|
142
|
+
|
|
143
|
+
**範例:**
|
|
144
|
+
|
|
145
|
+
\`\`\`bash
|
|
146
|
+
npx gitai commit-all
|
|
147
|
+
npx gitai ca --verbose
|
|
148
|
+
\`\`\`
|
|
149
|
+
|
|
150
|
+
### \`gitai pr\`
|
|
151
|
+
|
|
152
|
+
生成 PR 並發送到 GitHub
|
|
153
|
+
|
|
154
|
+
\`\`\`bash
|
|
155
|
+
npx gitai pr [選項]
|
|
156
|
+
|
|
157
|
+
選項:
|
|
158
|
+
-b, --base <branch> 目標分支
|
|
159
|
+
-h, --head <branch> 來源分支
|
|
160
|
+
-m, --model <model> 指定 AI 模型
|
|
161
|
+
--draft 創建草稿 PR
|
|
162
|
+
--preview 僅預覽,不創建 PR
|
|
163
|
+
--no-confirm 跳過確認直接創建
|
|
164
|
+
--auto-reviewers 自動選擇 reviewers
|
|
165
|
+
--auto-labels 自動添加 Labels
|
|
166
|
+
--no-labels 不添加 Labels
|
|
167
|
+
--org <name> GitHub 組織名稱
|
|
168
|
+
\`\`\`
|
|
169
|
+
|
|
170
|
+
**範例:**
|
|
171
|
+
|
|
172
|
+
\`\`\`bash
|
|
173
|
+
npx gitai pr
|
|
174
|
+
npx gitai pr --draft
|
|
175
|
+
npx gitai pr --base main --auto-reviewers
|
|
176
|
+
npx gitai pr --preview
|
|
177
|
+
\`\`\`
|
|
178
|
+
|
|
179
|
+
### \`gitai workflow\` (別名: \`wf\`)
|
|
180
|
+
|
|
181
|
+
完整工作流程:commit-all + pr
|
|
182
|
+
|
|
183
|
+
\`\`\`bash
|
|
184
|
+
npx gitai workflow [選項]
|
|
185
|
+
|
|
186
|
+
選項:
|
|
187
|
+
-m, --model <model> 指定 AI 模型
|
|
188
|
+
-v, --verbose 顯示詳細輸出
|
|
189
|
+
-b, --base <branch> PR 目標分支
|
|
190
|
+
--draft 創建草稿 PR
|
|
191
|
+
--auto-reviewers 自動選擇 reviewers
|
|
192
|
+
--auto-labels 自動添加 Labels
|
|
193
|
+
\`\`\`
|
|
194
|
+
|
|
195
|
+
**範例:**
|
|
196
|
+
|
|
197
|
+
\`\`\`bash
|
|
198
|
+
npx gitai workflow
|
|
199
|
+
npx gitai wf --draft --auto-reviewers
|
|
200
|
+
\`\`\`
|
|
201
|
+
|
|
202
|
+
## ⚙️ 配置
|
|
203
|
+
|
|
204
|
+
配置檔案範例(\`.ai-git-config.js\`):
|
|
205
|
+
|
|
206
|
+
\`\`\`javascript
|
|
207
|
+
export default {
|
|
208
|
+
// AI 設定
|
|
209
|
+
ai: {
|
|
210
|
+
model: 'gpt-4.1', // AI 模型
|
|
211
|
+
maxDiffLength: 8000, // 最大 diff 長度
|
|
212
|
+
maxRetries: 3, // 失敗重試次數
|
|
213
|
+
},
|
|
214
|
+
|
|
215
|
+
// GitHub 設定
|
|
216
|
+
github: {
|
|
217
|
+
orgName: null, // 組織名稱(自動偵測)
|
|
218
|
+
defaultBase: 'auto', // 預設目標分支
|
|
219
|
+
autoLabels: true, // 自動添加 Labels
|
|
220
|
+
},
|
|
221
|
+
|
|
222
|
+
// Reviewer 設定
|
|
223
|
+
reviewers: {
|
|
224
|
+
autoSelect: false, // 啟用 reviewer 選擇
|
|
225
|
+
maxSuggested: 5, // 最多建議人數
|
|
226
|
+
gitHistoryDepth: 20, // Git 歷史分析深度
|
|
227
|
+
excludeAuthors: [], // 排除特定作者
|
|
228
|
+
},
|
|
229
|
+
|
|
230
|
+
// 輸出設定
|
|
231
|
+
output: {
|
|
232
|
+
verbose: false, // 詳細輸出
|
|
233
|
+
saveHistory: false, // 儲存歷史
|
|
234
|
+
},
|
|
235
|
+
};
|
|
236
|
+
\`\`\`
|
|
237
|
+
|
|
238
|
+
## 🔧 環境需求
|
|
239
|
+
|
|
240
|
+
- **Node.js** >= 18.0.0
|
|
241
|
+
- **Git** 已安裝並設定
|
|
242
|
+
- **GitHub CLI** (用於 PR 功能)
|
|
243
|
+
\`\`\`bash
|
|
244
|
+
brew install gh
|
|
245
|
+
gh auth login
|
|
246
|
+
\`\`\`
|
|
247
|
+
|
|
248
|
+
## 💡 使用場景
|
|
249
|
+
|
|
250
|
+
### 場景 1:快速提交單個功能
|
|
251
|
+
|
|
252
|
+
\`\`\`bash
|
|
253
|
+
git add src/components/LoginForm.jsx
|
|
254
|
+
npx gitai commit
|
|
255
|
+
# ✅ 自動生成:feat(auth): 新增登入表單元件
|
|
256
|
+
\`\`\`
|
|
257
|
+
|
|
258
|
+
### 場景 2:整理多個變更
|
|
259
|
+
|
|
260
|
+
累積了多個功能變更,想要分開提交:
|
|
261
|
+
|
|
262
|
+
\`\`\`bash
|
|
263
|
+
npx gitai commit-all
|
|
264
|
+
# AI 會自動分析並分組:
|
|
265
|
+
# ✅ Commit 1: feat(auth): 新增登入功能
|
|
266
|
+
# ✅ Commit 2: fix(ui): 修正導航列顯示問題
|
|
267
|
+
# ✅ Commit 3: chore(deps): 更新依賴套件
|
|
268
|
+
\`\`\`
|
|
269
|
+
|
|
270
|
+
### 場景 3:快速發 PR
|
|
271
|
+
|
|
272
|
+
\`\`\`bash
|
|
273
|
+
npx gitai pr --auto-reviewers --auto-labels
|
|
274
|
+
# ✅ 自動生成完整的 PR 標題和描述
|
|
275
|
+
# ✅ 建議合適的 reviewers
|
|
276
|
+
# ✅ 添加相關的 labels
|
|
277
|
+
\`\`\`
|
|
278
|
+
|
|
279
|
+
### 場景 4:完整工作流程
|
|
280
|
+
|
|
281
|
+
\`\`\`bash
|
|
282
|
+
npx gitai workflow
|
|
283
|
+
# ✅ 自動分析並提交所有變更
|
|
284
|
+
# ✅ 創建 PR 並添加 reviewers 和 labels
|
|
285
|
+
\`\`\`
|
|
286
|
+
|
|
287
|
+
## 🎯 Commit Message 格式
|
|
288
|
+
|
|
289
|
+
自動生成的 commit message 遵循 [Conventional Commits](https://www.conventionalcommits.org/) 規範:
|
|
290
|
+
|
|
291
|
+
\`\`\`
|
|
292
|
+
<type>(<scope>): <subject>
|
|
293
|
+
|
|
294
|
+
<body>
|
|
295
|
+
\`\`\`
|
|
296
|
+
|
|
297
|
+
**Type 類型:**
|
|
298
|
+
- \`feat\`: 新功能
|
|
299
|
+
- \`fix\`: 錯誤修正
|
|
300
|
+
- \`docs\`: 文件變更
|
|
301
|
+
- \`style\`: 程式碼格式調整
|
|
302
|
+
- \`refactor\`: 重構
|
|
303
|
+
- \`test\`: 測試
|
|
304
|
+
- \`chore\`: 雜項
|
|
305
|
+
- \`perf\`: 效能優化
|
|
306
|
+
|
|
307
|
+
**範例:**
|
|
308
|
+
|
|
309
|
+
\`\`\`
|
|
310
|
+
feat(auth): 新增使用者登入功能
|
|
311
|
+
|
|
312
|
+
- 實作登入 API endpoint
|
|
313
|
+
- 新增登入頁面 UI
|
|
314
|
+
- 整合 JWT 認證機制
|
|
315
|
+
\`\`\`
|
|
316
|
+
|
|
317
|
+
## 🤔 常見問題
|
|
318
|
+
|
|
319
|
+
### Q: 需要安裝 GitHub Copilot 嗎?
|
|
320
|
+
|
|
321
|
+
A: 需要。本工具使用 GitHub Copilot SDK,需要有 GitHub Copilot 訂閱。
|
|
322
|
+
|
|
323
|
+
### Q: 可以使用其他 AI 模型嗎?
|
|
324
|
+
|
|
325
|
+
A: 可以。支援 GPT-4.1、Claude Haiku 4.5、Claude Sonnet 4.5 等模型,可在配置檔中設定。
|
|
326
|
+
|
|
327
|
+
### Q: 配置檔一定要放在專案根目錄嗎?
|
|
328
|
+
|
|
329
|
+
A: 是的。工具會在當前目錄尋找配置檔。
|
|
330
|
+
|
|
331
|
+
### Q: 可以自訂 commit message 格式嗎?
|
|
332
|
+
|
|
333
|
+
A: 目前遵循 Conventional Commits 規範。未來版本會支援自訂格式。
|
|
334
|
+
|
|
335
|
+
### Q: 支援 Monorepo 嗎?
|
|
336
|
+
|
|
337
|
+
A: 支援。工具會分析整個倉庫的變更。
|
|
338
|
+
|
|
339
|
+
## 📝 授權
|
|
340
|
+
|
|
341
|
+
MIT License
|
|
342
|
+
|
|
343
|
+
## 🤝 貢獻
|
|
344
|
+
|
|
345
|
+
歡迎提交 Issue 和 Pull Request!
|
|
346
|
+
|
|
347
|
+
## 📧 聯絡
|
|
348
|
+
|
|
349
|
+
有問題或建議?歡迎[提交 Issue](https://github.com/yourusername/ai-git-tools/issues)
|
|
350
|
+
|
|
351
|
+
---
|
|
352
|
+
|
|
353
|
+
Made with ❤️ by AI Git Tools Team
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* AI Git Tools CLI
|
|
5
|
+
*
|
|
6
|
+
* AI-powered Git automation for commit messages and PR generation
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { Command } from 'commander';
|
|
10
|
+
import chalk from 'chalk';
|
|
11
|
+
import { commitCommand } from '../src/commands/commit.js';
|
|
12
|
+
import { commitAllCommand } from '../src/commands/commit-all.js';
|
|
13
|
+
import { prCommand } from '../src/commands/pr.js';
|
|
14
|
+
import { workflowCommand } from '../src/commands/workflow.js';
|
|
15
|
+
import { initCommand } from '../src/commands/init.js';
|
|
16
|
+
|
|
17
|
+
const program = new Command();
|
|
18
|
+
|
|
19
|
+
program
|
|
20
|
+
.name('gitai')
|
|
21
|
+
.description('AI-powered Git automation tools')
|
|
22
|
+
.version('1.0.0');
|
|
23
|
+
|
|
24
|
+
// Init 命令
|
|
25
|
+
program
|
|
26
|
+
.command('init')
|
|
27
|
+
.description('初始化配置檔案')
|
|
28
|
+
.action(initCommand);
|
|
29
|
+
|
|
30
|
+
// Commit 命令
|
|
31
|
+
program
|
|
32
|
+
.command('commit')
|
|
33
|
+
.description('為已 staged 的變更生成並執行 commit')
|
|
34
|
+
.option('-m, --model <model>', '指定 AI 模型')
|
|
35
|
+
.option('-v, --verbose', '顯示詳細輸出')
|
|
36
|
+
.option('--max-diff <number>', '最大 diff 長度', parseInt)
|
|
37
|
+
.option('--max-retries <number>', '最大重試次數', parseInt)
|
|
38
|
+
.action(commitCommand);
|
|
39
|
+
|
|
40
|
+
// Commit All 命令
|
|
41
|
+
program
|
|
42
|
+
.command('commit-all')
|
|
43
|
+
.alias('ca')
|
|
44
|
+
.description('智能分析所有變更並自動分組提交')
|
|
45
|
+
.option('-m, --model <model>', '指定 AI 模型')
|
|
46
|
+
.option('-v, --verbose', '顯示詳細輸出')
|
|
47
|
+
.option('--max-diff <number>', '最大 diff 長度', parseInt)
|
|
48
|
+
.option('--max-retries <number>', '最大重試次數', parseInt)
|
|
49
|
+
.action(commitAllCommand);
|
|
50
|
+
|
|
51
|
+
// PR 命令
|
|
52
|
+
program
|
|
53
|
+
.command('pr')
|
|
54
|
+
.description('生成 PR 並發送到 GitHub')
|
|
55
|
+
.option('-b, --base <branch>', '目標分支')
|
|
56
|
+
.option('-h, --head <branch>', '來源分支')
|
|
57
|
+
.option('-m, --model <model>', '指定 AI 模型')
|
|
58
|
+
.option('--draft', '創建草稿 PR')
|
|
59
|
+
.option('--preview', '僅預覽,不創建 PR')
|
|
60
|
+
.option('--no-confirm', '跳過確認直接創建')
|
|
61
|
+
.option('--auto-reviewers', '自動選擇 reviewers')
|
|
62
|
+
.option('--auto-labels', '自動添加 Labels')
|
|
63
|
+
.option('--no-labels', '不添加 Labels')
|
|
64
|
+
.option('--org <name>', 'GitHub 組織名稱')
|
|
65
|
+
.action(prCommand);
|
|
66
|
+
|
|
67
|
+
// Workflow 命令
|
|
68
|
+
program
|
|
69
|
+
.command('workflow')
|
|
70
|
+
.alias('wf')
|
|
71
|
+
.description('完整工作流程:commit-all + pr')
|
|
72
|
+
.option('-m, --model <model>', '指定 AI 模型')
|
|
73
|
+
.option('-v, --verbose', '顯示詳細輸出')
|
|
74
|
+
.option('-b, --base <branch>', 'PR 目標分支')
|
|
75
|
+
.option('--draft', '創建草稿 PR')
|
|
76
|
+
.option('--auto-reviewers', '自動選擇 reviewers')
|
|
77
|
+
.option('--auto-labels', '自動添加 Labels')
|
|
78
|
+
.action(workflowCommand);
|
|
79
|
+
|
|
80
|
+
// 解析命令列參數
|
|
81
|
+
program.parse(process.argv);
|
|
82
|
+
|
|
83
|
+
// 如果沒有提供命令,顯示幫助
|
|
84
|
+
if (!process.argv.slice(2).length) {
|
|
85
|
+
program.outputHelp();
|
|
86
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ai-git-tools",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "AI-powered Git automation tools for commit messages and PR generation",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"gitai": "./bin/cli.js",
|
|
9
|
+
"ai-git-tools": "./bin/cli.js"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
13
|
+
"prepare": "chmod +x bin/cli.js",
|
|
14
|
+
"lint": "eslint src/**/*.js",
|
|
15
|
+
"format": "prettier --write \"src/**/*.js\" \"bin/**/*.js\""
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"git",
|
|
19
|
+
"ai",
|
|
20
|
+
"automation",
|
|
21
|
+
"commit",
|
|
22
|
+
"pull-request",
|
|
23
|
+
"github",
|
|
24
|
+
"copilot",
|
|
25
|
+
"cli"
|
|
26
|
+
],
|
|
27
|
+
"author": "Yiso Tsao <yiso05255@gmail.com>",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=18.0.0"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"bin/",
|
|
34
|
+
"src/",
|
|
35
|
+
"templates/",
|
|
36
|
+
"README.md",
|
|
37
|
+
"README.zh-TW.md",
|
|
38
|
+
"LICENSE",
|
|
39
|
+
"CHANGELOG.md"
|
|
40
|
+
],
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@github/copilot-sdk": "^1.0.0",
|
|
43
|
+
"commander": "^12.0.0",
|
|
44
|
+
"chalk": "^5.3.0",
|
|
45
|
+
"ora": "^8.0.1",
|
|
46
|
+
"inquirer": "^9.2.0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"eslint": "^8.57.0",
|
|
50
|
+
"prettier": "^3.2.0"
|
|
51
|
+
},
|
|
52
|
+
"repository": {
|
|
53
|
+
"type": "git",
|
|
54
|
+
"url": "https://github.com/YisoTsao/ai-git-tools.git"
|
|
55
|
+
},
|
|
56
|
+
"bugs": {
|
|
57
|
+
"url": "https://github.com/YisoTsao/ai-git-tools/issues"
|
|
58
|
+
},
|
|
59
|
+
"homepage": "https://github.com/YisoTsao/ai-git-tools#readme"
|
|
60
|
+
}
|