ai-git-tools 2.0.56 → 2.0.58
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/bin/cli.js
CHANGED
|
@@ -87,6 +87,7 @@ program
|
|
|
87
87
|
.option('--no-confirm', '跳過確認直接創建')
|
|
88
88
|
.option('--auto-labels', '自動添加 Labels (預設啟用)')
|
|
89
89
|
.option('--include-impact', '在 PR 中包含影響範圍分析和注意事項 (預設關閉)')
|
|
90
|
+
.option('--force-new', '強制創建新 PR,不更新現有 PR')
|
|
90
91
|
.action(async (options) => {
|
|
91
92
|
try {
|
|
92
93
|
await prCommand(options);
|
package/package.json
CHANGED
package/src/commands/pr.js
CHANGED
|
@@ -36,7 +36,7 @@ function checkGHAuth(logger) {
|
|
|
36
36
|
/**
|
|
37
37
|
* PR 命令主函數(完全照抄 scripts/ai-auto-pr.mjs)
|
|
38
38
|
*/
|
|
39
|
-
export async function prCommand() {
|
|
39
|
+
export async function prCommand(options = {}) {
|
|
40
40
|
const logger = new Logger();
|
|
41
41
|
|
|
42
42
|
// ── 第一步:確認 gh CLI 已登入 ──────────────────────────
|
|
@@ -54,6 +54,11 @@ export async function prCommand() {
|
|
|
54
54
|
console.log(` Max Diff Length: ${config.ai.maxDiffLength}`);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
// 將命令行選項合併到配置中
|
|
58
|
+
if (options.forceNew) {
|
|
59
|
+
config.forceNew = true;
|
|
60
|
+
}
|
|
61
|
+
|
|
57
62
|
// 執行工作流程(使用 scripts/ 的完整工作流)
|
|
58
63
|
const workflow = new PRWorkflow(config);
|
|
59
64
|
await workflow.execute();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CopilotClient } from '@github/copilot-sdk';
|
|
1
|
+
import { CopilotClient, approveAll } from '@github/copilot-sdk';
|
|
2
2
|
import { CONSTANTS, PROJECT_SKILLS_CONTEXT } from '../utils/constants.js';
|
|
3
3
|
import { getSkillsSummaryForPrompt, log } from '../utils/helpers.js';
|
|
4
4
|
|
|
@@ -15,7 +15,10 @@ export class AIAnalyzer {
|
|
|
15
15
|
*/
|
|
16
16
|
async createClient() {
|
|
17
17
|
const client = new CopilotClient();
|
|
18
|
-
const session = await client.createSession({
|
|
18
|
+
const session = await client.createSession({
|
|
19
|
+
model: this.model,
|
|
20
|
+
onPermissionRequest: approveAll
|
|
21
|
+
});
|
|
19
22
|
return { client, session };
|
|
20
23
|
}
|
|
21
24
|
|
|
@@ -193,20 +193,22 @@ export class GitHubAPI {
|
|
|
193
193
|
* 創建或更新 PR
|
|
194
194
|
*/
|
|
195
195
|
async createOrUpdatePR(params) {
|
|
196
|
-
const { title, body, baseBranch, headBranch, reviewers } = params;
|
|
196
|
+
const { title, body, baseBranch, headBranch, reviewers, forceNew } = params;
|
|
197
197
|
const bodyFile = '/tmp/pr-body.md';
|
|
198
198
|
writeFileSync(bodyFile, body);
|
|
199
199
|
|
|
200
200
|
try {
|
|
201
|
-
// 檢查 PR
|
|
201
|
+
// 檢查 PR 是否已存在(除非強制創建新 PR)
|
|
202
202
|
let existingPRUrl = null;
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
203
|
+
if (!forceNew) {
|
|
204
|
+
try {
|
|
205
|
+
existingPRUrl = execSync(
|
|
206
|
+
`gh pr list --head "${headBranch}" --base "${baseBranch}" --json url --jq '.[0].url'`,
|
|
207
|
+
{ encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] }
|
|
208
|
+
).trim();
|
|
209
|
+
} catch (error) {
|
|
210
|
+
// PR 不存在
|
|
211
|
+
}
|
|
210
212
|
}
|
|
211
213
|
|
|
212
214
|
const escapedTitle = title.replace(/"/g, '\\"');
|