ai-git-tools 2.0.9 → 2.0.11
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/README.md
CHANGED
|
@@ -223,7 +223,7 @@ export default {
|
|
|
223
223
|
|
|
224
224
|
// Reviewer 設定
|
|
225
225
|
reviewers: {
|
|
226
|
-
|
|
226
|
+
interactiveReviewers: false, // 啟用 reviewer 選擇
|
|
227
227
|
maxSuggested: 5, // 最多建議人數
|
|
228
228
|
gitHistoryDepth: 20, // Git 歷史分析深度
|
|
229
229
|
excludeAuthors: [], // 排除特定作者
|
package/package.json
CHANGED
package/src/commands/init.js
CHANGED
|
@@ -30,7 +30,7 @@ export default {
|
|
|
30
30
|
|
|
31
31
|
// Reviewers 相關配置
|
|
32
32
|
reviewers: {
|
|
33
|
-
|
|
33
|
+
interactiveReviewers: true, // 啟用互動式 reviewer 選擇(true: 顯示選單,false: 跳過,創建 PR 後手動添加)
|
|
34
34
|
maxSuggested: 5, // 最多建議幾位 reviewers(基於 Git 歷史分析)
|
|
35
35
|
gitHistoryDepth: 20, // 分析 Git 歷史的深度(最近 N 筆 commits)
|
|
36
36
|
excludeAuthors: [], // 排除的作者列表(例如:['bot@example.com', 'ci-user'])
|
|
@@ -13,7 +13,7 @@ export function parseCliArgs() {
|
|
|
13
13
|
draft: false,
|
|
14
14
|
preview: false,
|
|
15
15
|
noConfirm: false,
|
|
16
|
-
|
|
16
|
+
interactiveReviewers: undefined,
|
|
17
17
|
autoLabels: null,
|
|
18
18
|
orgName: null,
|
|
19
19
|
};
|
|
@@ -41,8 +41,8 @@ export function parseCliArgs() {
|
|
|
41
41
|
case '--no-confirm':
|
|
42
42
|
config.noConfirm = true;
|
|
43
43
|
break;
|
|
44
|
-
case '--
|
|
45
|
-
config.
|
|
44
|
+
case '--interactive-reviewers':
|
|
45
|
+
config.interactiveReviewers = true;
|
|
46
46
|
break;
|
|
47
47
|
case '--auto-labels':
|
|
48
48
|
config.autoLabels = true;
|
|
@@ -78,8 +78,8 @@ export async function loadConfig() {
|
|
|
78
78
|
// 使用內建預設值
|
|
79
79
|
config = {
|
|
80
80
|
ai: { model: 'gpt-4.1', maxDiffLength: 8000, maxRetries: 3 },
|
|
81
|
-
github: { orgName: '
|
|
82
|
-
reviewers: {
|
|
81
|
+
github: { orgName: '', defaultBase: 'release', autoLabels: true },
|
|
82
|
+
reviewers: { interactiveReviewers: true, maxSuggested: 5, gitHistoryDepth: 20, excludeAuthors: [] },
|
|
83
83
|
output: { verbose: false, saveHistory: false },
|
|
84
84
|
};
|
|
85
85
|
}
|
|
@@ -90,8 +90,8 @@ export async function loadConfig() {
|
|
|
90
90
|
// 合併配置(CLI 參數優先)
|
|
91
91
|
if (cliConfig.model) config.ai.model = cliConfig.model;
|
|
92
92
|
if (cliConfig.orgName) config.github.orgName = cliConfig.orgName;
|
|
93
|
-
if (cliConfig.
|
|
94
|
-
if (cliConfig.autoLabels) config.github.autoLabels = cliConfig.autoLabels;
|
|
93
|
+
if (cliConfig.interactiveReviewers !== undefined) config.reviewers.interactiveReviewers = cliConfig.interactiveReviewers;
|
|
94
|
+
if (cliConfig.autoLabels !== undefined) config.github.autoLabels = cliConfig.autoLabels;
|
|
95
95
|
|
|
96
96
|
// 其他 CLI 參數直接加入 config
|
|
97
97
|
config.baseBranch = cliConfig.baseBranch;
|
|
@@ -119,14 +119,14 @@ function showHelp() {
|
|
|
119
119
|
--draft 創建草稿 PR
|
|
120
120
|
--preview 僅預覽 PR 內容,不實際創建
|
|
121
121
|
--no-confirm 跳過確認直接創建
|
|
122
|
-
--
|
|
123
|
-
--auto-labels
|
|
122
|
+
--interactive-reviewers 啟用互動式 reviewer 選擇(預設啟用)
|
|
123
|
+
--auto-labels 自動添加 Labels(預設啟用)
|
|
124
124
|
--no-labels 不添加 Labels
|
|
125
125
|
--help 顯示此說明
|
|
126
126
|
|
|
127
127
|
範例:
|
|
128
128
|
node scripts/ai-auto-pr.mjs
|
|
129
129
|
node scripts/ai-auto-pr.mjs --base main --draft
|
|
130
|
-
node scripts/ai-auto-pr.mjs --
|
|
130
|
+
node scripts/ai-auto-pr.mjs --interactive-reviewers --auto-labels
|
|
131
131
|
`);
|
|
132
132
|
}
|
|
@@ -19,7 +19,7 @@ export class PRWorkflow {
|
|
|
19
19
|
this.ai = new AIAnalyzer({ model: config.ai.model });
|
|
20
20
|
this.labelAnalyzer = new LabelAnalyzer();
|
|
21
21
|
this.reviewerSelector = new ReviewerSelector({
|
|
22
|
-
|
|
22
|
+
interactiveReviewers: config.reviewers.interactiveReviewers,
|
|
23
23
|
maxSuggested: config.reviewers.maxSuggested,
|
|
24
24
|
gitHistoryDepth: config.reviewers.gitHistoryDepth,
|
|
25
25
|
excludeAuthors: config.reviewers.excludeAuthors,
|
|
@@ -73,12 +73,16 @@ export class PRWorkflow {
|
|
|
73
73
|
const prUrl = await this.createPR(prContent, baseBranch, headBranch, reviewers);
|
|
74
74
|
|
|
75
75
|
// 10. 添加 Labels(如果啟用)
|
|
76
|
-
if (this.config.github.autoLabels && prUrl) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
76
|
+
if (this.config.github.autoLabels === true && prUrl) {
|
|
77
|
+
try {
|
|
78
|
+
const prNumber = prUrl.split('/').pop();
|
|
79
|
+
await this.addLabels(prNumber, {
|
|
80
|
+
...prContent,
|
|
81
|
+
stats: changeData.stats,
|
|
82
|
+
});
|
|
83
|
+
} catch (error) {
|
|
84
|
+
log.warning('無法自動添加 Labels: ' + error.message);
|
|
85
|
+
}
|
|
82
86
|
}
|
|
83
87
|
|
|
84
88
|
this.logger.success('完成!');
|
|
@@ -8,7 +8,7 @@ import { InteractiveSelect } from '../ui/interactive-select.js';
|
|
|
8
8
|
*/
|
|
9
9
|
export class ReviewerSelector {
|
|
10
10
|
constructor(config = {}) {
|
|
11
|
-
this.
|
|
11
|
+
this.interactiveReviewers = config.interactiveReviewers !== undefined ? config.interactiveReviewers : true;
|
|
12
12
|
this.maxSuggested = config.maxSuggested || 5;
|
|
13
13
|
this.gitHistoryDepth = config.gitHistoryDepth || 20;
|
|
14
14
|
this.excludeAuthors = config.excludeAuthors || [];
|
|
@@ -220,13 +220,13 @@ export class ReviewerSelector {
|
|
|
220
220
|
* 選擇 Reviewers(根據模式)
|
|
221
221
|
*/
|
|
222
222
|
async select(teamsData, suggestedReviewers, currentUser) {
|
|
223
|
-
if (this.
|
|
224
|
-
//
|
|
223
|
+
if (this.interactiveReviewers) {
|
|
224
|
+
// interactiveReviewers: true 表示啟用互動式選擇(手動選擇)
|
|
225
225
|
return this.selectInteractive(teamsData, suggestedReviewers, currentUser);
|
|
226
226
|
} else {
|
|
227
|
-
//
|
|
228
|
-
console.log('
|
|
229
|
-
return
|
|
227
|
+
// interactiveReviewers: false 表示自動選擇(基於 Git 歷史)
|
|
228
|
+
console.log('🤖 自動選擇 reviewers(基於 Git 歷史)\n');
|
|
229
|
+
return this.autoSelectReviewers(suggestedReviewers, currentUser);
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
}
|
|
@@ -24,7 +24,7 @@ export default {
|
|
|
24
24
|
|
|
25
25
|
// Reviewer 設定(用於 PR 工具)
|
|
26
26
|
reviewers: {
|
|
27
|
-
|
|
27
|
+
interactiveReviewers: true, // 是否啟用 reviewer 選擇功能(true: 啟用互動選擇 | false: 跳過選擇)
|
|
28
28
|
maxSuggested: 5, // 最多建議的 reviewers 數量(基於 Git 歷史分析)
|
|
29
29
|
gitHistoryDepth: 20, // Git 歷史分析深度(查看最近 N 筆 commit)
|
|
30
30
|
excludeAuthors: [], // 排除特定作者(email 或 username),例如: ['bot@', 'ci-user']
|