ai-git-tools 2.0.13 → 2.0.15
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
package/package.json
CHANGED
|
@@ -15,7 +15,6 @@ export function parseCliArgs() {
|
|
|
15
15
|
noConfirm: false,
|
|
16
16
|
interactiveReviewers: undefined,
|
|
17
17
|
autoLabels: null,
|
|
18
|
-
orgName: null,
|
|
19
18
|
};
|
|
20
19
|
|
|
21
20
|
for (let i = 0; i < args.length; i++) {
|
|
@@ -29,9 +28,6 @@ export function parseCliArgs() {
|
|
|
29
28
|
case '--model':
|
|
30
29
|
config.model = args[++i];
|
|
31
30
|
break;
|
|
32
|
-
case '--org':
|
|
33
|
-
config.orgName = args[++i];
|
|
34
|
-
break;
|
|
35
31
|
case '--draft':
|
|
36
32
|
config.draft = true;
|
|
37
33
|
break;
|
|
@@ -75,7 +71,7 @@ export async function loadConfig() {
|
|
|
75
71
|
// 使用內建預設值
|
|
76
72
|
config = {
|
|
77
73
|
ai: { model: 'gpt-4.1', maxDiffLength: 8000, maxRetries: 3 },
|
|
78
|
-
github: {
|
|
74
|
+
github: { defaultBase: 'release', autoLabels: true },
|
|
79
75
|
reviewers: { interactiveReviewers: true, maxSuggested: 5, gitHistoryDepth: 20, excludeAuthors: [] },
|
|
80
76
|
output: { verbose: false, saveHistory: false },
|
|
81
77
|
};
|
|
@@ -86,7 +82,6 @@ export async function loadConfig() {
|
|
|
86
82
|
|
|
87
83
|
// 合併配置(CLI 參數優先)
|
|
88
84
|
if (cliConfig.model) config.ai.model = cliConfig.model;
|
|
89
|
-
if (cliConfig.orgName) config.github.orgName = cliConfig.orgName;
|
|
90
85
|
if (cliConfig.interactiveReviewers !== undefined) config.reviewers.interactiveReviewers = cliConfig.interactiveReviewers;
|
|
91
86
|
if (cliConfig.autoLabels !== undefined) config.github.autoLabels = cliConfig.autoLabels;
|
|
92
87
|
|
|
@@ -106,13 +101,12 @@ export async function loadConfig() {
|
|
|
106
101
|
function showHelp() {
|
|
107
102
|
console.log(`
|
|
108
103
|
使用方式:
|
|
109
|
-
|
|
104
|
+
npx ai-git-tools pr [選項]
|
|
110
105
|
|
|
111
106
|
選項:
|
|
112
107
|
--base <branch> 指定目標分支 (預設: 自動偵測最新 release 分支)
|
|
113
108
|
--head <branch> 指定來源分支 (預設: 當前分支)
|
|
114
109
|
--model <model> 指定 AI 模型 (預設: gpt-4.1)
|
|
115
|
-
--org <org-name> 指定 GitHub 組織名稱 (預設: kingsinfo-project)
|
|
116
110
|
--draft 創建草稿 PR
|
|
117
111
|
--preview 僅預覽 PR 內容,不實際創建
|
|
118
112
|
--no-confirm 跳過確認直接創建
|
|
@@ -121,8 +115,8 @@ function showHelp() {
|
|
|
121
115
|
--help 顯示此說明
|
|
122
116
|
|
|
123
117
|
範例:
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
118
|
+
npx ai-git-tools pr
|
|
119
|
+
npx ai-git-tools pr --base main --draft
|
|
120
|
+
npx ai-git-tools pr --interactive-reviewers --auto-labels
|
|
127
121
|
`);
|
|
128
122
|
}
|
|
@@ -15,7 +15,7 @@ export class PRWorkflow {
|
|
|
15
15
|
constructor(config) {
|
|
16
16
|
this.config = config;
|
|
17
17
|
this.git = new GitOperations();
|
|
18
|
-
this.github = new GitHubAPI(
|
|
18
|
+
this.github = new GitHubAPI(); // 自動從 git remote 偵測組織名稱
|
|
19
19
|
this.ai = new AIAnalyzer({ model: config.ai.model });
|
|
20
20
|
this.labelAnalyzer = new LabelAnalyzer();
|
|
21
21
|
this.reviewerSelector = new ReviewerSelector({
|
|
@@ -319,15 +319,21 @@ export class PRWorkflow {
|
|
|
319
319
|
// 獲取當前用戶
|
|
320
320
|
const currentUser = this.git.getCurrentUser();
|
|
321
321
|
|
|
322
|
-
// 抓取 GitHub 團隊資訊
|
|
323
|
-
const teams = await this.github.fetchTeams();
|
|
324
|
-
|
|
325
322
|
// 根據 Git History 建議 Reviewers
|
|
326
323
|
const suggestedReviewers = this.reviewerSelector.getReviewersByGitHistory(
|
|
327
324
|
changeData.changedFiles
|
|
328
325
|
);
|
|
329
326
|
|
|
330
|
-
//
|
|
327
|
+
// 如果禁用互動式選擇,直接自動選擇
|
|
328
|
+
if (!this.config.reviewers.interactiveReviewers) {
|
|
329
|
+
console.log('🤖 自動選擇 reviewers(基於 Git 歷史)\n');
|
|
330
|
+
return this.reviewerSelector.autoSelectReviewers(suggestedReviewers, currentUser);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// 抓取 GitHub 團隊資訊(只在互動模式需要)
|
|
334
|
+
const teams = await this.github.fetchTeams();
|
|
335
|
+
|
|
336
|
+
// 選擇 Reviewers(互動模式)
|
|
331
337
|
return await this.reviewerSelector.select(teams, suggestedReviewers, currentUser);
|
|
332
338
|
}
|
|
333
339
|
|
|
@@ -353,6 +359,8 @@ export class PRWorkflow {
|
|
|
353
359
|
const labels = await this.labelAnalyzer.analyzeAndApply(prNumber, prData);
|
|
354
360
|
if (labels.length > 0) {
|
|
355
361
|
console.log(`📌 已添加 Labels: ${labels.join(', ')}\n`);
|
|
362
|
+
} else {
|
|
363
|
+
log.info('未找到適合的 Labels');
|
|
356
364
|
}
|
|
357
365
|
}
|
|
358
366
|
|