ai-git-tools 2.0.79 → 2.0.81
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 +96 -20
- package/bin/cli.js +48 -61
- package/package.json +2 -2
- package/src/ai/prompts/commit-message.js +42 -0
- package/src/ai/prompts/pr-content.js +151 -0
- package/src/commands/commit.js +92 -123
- package/src/commands/model-info.js +195 -0
- package/src/commands/pr.js +22 -31
- package/src/commands/usage.js +557 -0
- package/src/core/config-loader.js +151 -113
- package/src/core/git-operations.js +122 -39
- package/src/core/model-client.js +117 -0
- package/src/data/copilot-models.js +108 -0
- package/src/pr-modules/ai/code-analyzer.js +9 -141
- package/src/pr-modules/ai/label-analyzer.js +1 -1
- package/src/pr-modules/core/github-api.js +56 -5
- package/src/pr-modules/core/workflow.js +25 -5
- package/src/pr-modules/reviewers/reviewer-selector.js +2 -2
- package/src/pr-modules/ui/interactive-select.js +1 -1
- package/src/utils/cli-helpers.js +51 -0
- package/src/utils/constants.js +49 -0
- package/src/utils/helpers.js +41 -4
- package/src/utils/logger.js +13 -11
- package/src/{pr-modules/utils/constants.js → utils/project-skills.js} +26 -49
- package/src/pr-modules/core/config-loader.js +0 -132
- package/src/pr-modules/core/git-operations.js +0 -248
- package/src/pr-modules/ui/logger.js +0 -40
- package/src/pr-modules/utils/helpers.js +0 -109
package/README.md
CHANGED
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
- **⚙️ 配置檔支援** - 靈活的配置選項,適應不同專案需求
|
|
15
15
|
- **🌐 跨專案通用** - 可在任何 Git 專案中使用
|
|
16
16
|
|
|
17
|
+
> 📊 想瞭解各命令的完整流程?請參考 [docs/flowchart.md](docs/flowchart.md)。
|
|
18
|
+
|
|
17
19
|
## 📦 安裝
|
|
18
20
|
|
|
19
21
|
### NPX 使用(推薦)
|
|
@@ -49,6 +51,27 @@ npm install --save-dev ai-git-tools
|
|
|
49
51
|
}
|
|
50
52
|
```
|
|
51
53
|
|
|
54
|
+
### 本機直接使用(尚未發布到 npm)
|
|
55
|
+
|
|
56
|
+
如果你想在套件正式發布到 npm 前,直接從本機原始碼執行:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# 方式一:使用 npm link 將本機套件連結到全域
|
|
60
|
+
npm link
|
|
61
|
+
npx ai-git-tools model-info
|
|
62
|
+
|
|
63
|
+
# 方式二:直接使用 node 執行 bin/cli.js
|
|
64
|
+
node bin/cli.js model-info
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
其他命令也適用相同方式,例如:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
npx ai-git-tools init
|
|
71
|
+
npx ai-git-tools commit
|
|
72
|
+
npx ai-git-tools pr
|
|
73
|
+
```
|
|
74
|
+
|
|
52
75
|
## 🚀 快速開始
|
|
53
76
|
|
|
54
77
|
### 1. 初始化配置
|
|
@@ -98,7 +121,7 @@ npx ai-git-tools wf
|
|
|
98
121
|
|
|
99
122
|
## 📖 命令說明
|
|
100
123
|
|
|
101
|
-
### \`
|
|
124
|
+
### \`ai-git-tools init\`
|
|
102
125
|
|
|
103
126
|
初始化配置檔案
|
|
104
127
|
|
|
@@ -106,7 +129,7 @@ npx ai-git-tools wf
|
|
|
106
129
|
npx ai-git-tools init
|
|
107
130
|
\`\`\`
|
|
108
131
|
|
|
109
|
-
### \`
|
|
132
|
+
### \`ai-git-tools commit\`
|
|
110
133
|
|
|
111
134
|
為已 staged 的變更生成並執行 commit
|
|
112
135
|
|
|
@@ -128,7 +151,7 @@ npx ai-git-tools commit --model claude-haiku-4.5
|
|
|
128
151
|
npx ai-git-tools commit --verbose
|
|
129
152
|
\`\`\`
|
|
130
153
|
|
|
131
|
-
### \`
|
|
154
|
+
### \`ai-git-tools commit-all\` (別名: \`ca\`)
|
|
132
155
|
|
|
133
156
|
智能分析所有變更並自動分組提交
|
|
134
157
|
|
|
@@ -149,7 +172,7 @@ npx ai-git-tools commit-all
|
|
|
149
172
|
npx ai-git-tools ca --verbose
|
|
150
173
|
\`\`\`
|
|
151
174
|
|
|
152
|
-
### \`
|
|
175
|
+
### \`ai-git-tools pr\`
|
|
153
176
|
|
|
154
177
|
生成 PR 並發送到 GitHub
|
|
155
178
|
|
|
@@ -175,7 +198,7 @@ npx ai-git-tools pr --preview
|
|
|
175
198
|
npx ai-git-tools pr --no-confirm
|
|
176
199
|
\`\`\`
|
|
177
200
|
|
|
178
|
-
### \`
|
|
201
|
+
### \`ai-git-tools workflow\` (別名: \`wf\`)
|
|
179
202
|
|
|
180
203
|
完整工作流程:commit-all + pr
|
|
181
204
|
|
|
@@ -197,6 +220,31 @@ npx ai-git-tools workflow
|
|
|
197
220
|
npx ai-git-tools wf --preview
|
|
198
221
|
\`\`\`
|
|
199
222
|
|
|
223
|
+
### \`ai-git-tools model-info\`
|
|
224
|
+
|
|
225
|
+
查詢目前 GitHub Copilot SDK 支援的 AI 模型清單與詳細資訊
|
|
226
|
+
|
|
227
|
+
\`\`\`bash
|
|
228
|
+
npx ai-git-tools model-info [選項]
|
|
229
|
+
|
|
230
|
+
選項:
|
|
231
|
+
--json 以 JSON 格式輸出完整模型資料
|
|
232
|
+
--filter <keyword> 依模型名稱、供應商或描述關鍵字過濾
|
|
233
|
+
--model <model> 查詢單一模型的詳細資訊
|
|
234
|
+
--no-cache 忽略快取,強制重新連線 Copilot 取得最新資料
|
|
235
|
+
\`\`\`
|
|
236
|
+
|
|
237
|
+
**範例:**
|
|
238
|
+
|
|
239
|
+
\`\`\`bash
|
|
240
|
+
npx ai-git-tools model-info
|
|
241
|
+
npx ai-git-tools model-info --model gpt-4.1
|
|
242
|
+
npx ai-git-tools model-info --filter claude
|
|
243
|
+
npx ai-git-tools model-info --json
|
|
244
|
+
\`\`\`
|
|
245
|
+
|
|
246
|
+
> 第一次執行會連線到 Copilot CLI 取得模型清單,可能需要數秒鐘;後續預設使用 24 小時快取。
|
|
247
|
+
|
|
200
248
|
## ⚙️ 配置
|
|
201
249
|
|
|
202
250
|
配置檔案範例(\`.ai-git-config.js\`):
|
|
@@ -350,6 +398,49 @@ feat(auth): 新增使用者登入功能
|
|
|
350
398
|
- 整合 JWT 認證機制
|
|
351
399
|
\`\`\`
|
|
352
400
|
|
|
401
|
+
## 🚀 發布到 npm
|
|
402
|
+
|
|
403
|
+
若你是本專案維護者,發布新版本到 npm 的步驟如下:
|
|
404
|
+
|
|
405
|
+
### 1. 確認已登入 npm
|
|
406
|
+
|
|
407
|
+
```bash
|
|
408
|
+
npm whoami
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
若未登入,請執行:
|
|
412
|
+
|
|
413
|
+
```bash
|
|
414
|
+
npm login
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
### 2. 確認版本號
|
|
418
|
+
|
|
419
|
+
修改 [package.json](package.json) 中的 `version` 欄位(例如 `2.0.80`)。
|
|
420
|
+
|
|
421
|
+
> 每次發布版本號必須遞增,否則 npm 會拒絕。
|
|
422
|
+
|
|
423
|
+
### 3. 執行發布
|
|
424
|
+
|
|
425
|
+
```bash
|
|
426
|
+
npm run lint
|
|
427
|
+
npm publish --access public
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
`prepublishOnly` 會自動執行 `npm run lint`,`prepare` 會自動設定 `bin/cli.js` 為可執行檔。
|
|
431
|
+
|
|
432
|
+
### 4. 驗證發布
|
|
433
|
+
|
|
434
|
+
```bash
|
|
435
|
+
npm view ai-git-tools version
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
### 注意事項
|
|
439
|
+
|
|
440
|
+
- 發布前請確認工作目錄乾淨(`git status` 無未提交變更)
|
|
441
|
+
- npm 會自動修正 `package.json` 格式問題(例如 `repository.url` 會正規化為 `git+https://...`)
|
|
442
|
+
- 公開套件請使用 `--access public`,私有套件可省略或改為 `--access restricted`
|
|
443
|
+
|
|
353
444
|
## 🤔 常見問題
|
|
354
445
|
|
|
355
446
|
### Q: 需要安裝 GitHub Copilot 嗎?
|
|
@@ -372,18 +463,3 @@ A: 目前遵循 Conventional Commits 規範。未來版本會支援自訂格式
|
|
|
372
463
|
|
|
373
464
|
A: 支援。工具會分析整個倉庫的變更。
|
|
374
465
|
|
|
375
|
-
## 📝 授權
|
|
376
|
-
|
|
377
|
-
MIT License
|
|
378
|
-
|
|
379
|
-
## 🤝 貢獻
|
|
380
|
-
|
|
381
|
-
歡迎提交 Issue 和 Pull Request!
|
|
382
|
-
|
|
383
|
-
## 📧 聯絡
|
|
384
|
-
|
|
385
|
-
有問題或建議?歡迎[提交 Issue](https://github.com/yourusername/ai-git-tools/issues)
|
|
386
|
-
|
|
387
|
-
---
|
|
388
|
-
|
|
389
|
-
Made with ❤️ by AI Git Tools Team
|
package/bin/cli.js
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* AI Git Tools CLI
|
|
5
|
-
*
|
|
5
|
+
*
|
|
6
6
|
* AI-powered Git automation for commit messages and PR generation
|
|
7
|
-
* 完全重寫版本基於 scripts/ 原始實現
|
|
8
7
|
*/
|
|
9
8
|
|
|
10
9
|
import { Command } from 'commander';
|
|
@@ -15,6 +14,9 @@ import { commitCommand } from '../src/commands/commit.js';
|
|
|
15
14
|
import { commitAllCommand } from '../src/commands/commit-all.js';
|
|
16
15
|
import { prCommand } from '../src/commands/pr.js';
|
|
17
16
|
import { initCommand } from '../src/commands/init.js';
|
|
17
|
+
import { usageCommand } from '../src/commands/usage.js';
|
|
18
|
+
import { modelInfoCommand } from '../src/commands/model-info.js';
|
|
19
|
+
import { registerCommand } from '../src/utils/cli-helpers.js';
|
|
18
20
|
|
|
19
21
|
// 讀取 package.json 獲取版本號
|
|
20
22
|
const __filename = fileURLToPath(import.meta.url);
|
|
@@ -31,70 +33,55 @@ program
|
|
|
31
33
|
.version(packageJson.version);
|
|
32
34
|
|
|
33
35
|
// Init 命令
|
|
34
|
-
program
|
|
35
|
-
.command('init')
|
|
36
|
-
.description('初始化配置檔案 (.ai-git-config.mjs)')
|
|
37
|
-
.action(async (options) => {
|
|
38
|
-
try {
|
|
39
|
-
await initCommand(options);
|
|
40
|
-
process.exit(0);
|
|
41
|
-
} catch (error) {
|
|
42
|
-
process.exit(1);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
36
|
+
registerCommand(program, 'init', '初始化配置檔案 (.ai-git-config.mjs)', [], initCommand);
|
|
45
37
|
|
|
46
38
|
// Commit 命令
|
|
47
|
-
program
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
.option('--max-retries <number>', '最大重試次數')
|
|
54
|
-
.action(async (options) => {
|
|
55
|
-
try {
|
|
56
|
-
await commitCommand(options);
|
|
57
|
-
process.exit(0);
|
|
58
|
-
} catch (error) {
|
|
59
|
-
process.exit(1);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
39
|
+
registerCommand(program, 'commit', 'AI 自動生成 commit message 並提交', [
|
|
40
|
+
{ flags: '--model <model>', description: '指定 AI 模型' },
|
|
41
|
+
{ flags: '-v, --verbose', description: '顯示詳細輸出' },
|
|
42
|
+
{ flags: '--max-diff <number>', description: '最大 diff 長度' },
|
|
43
|
+
{ flags: '--max-retries <number>', description: '最大重試次數' },
|
|
44
|
+
], commitCommand);
|
|
62
45
|
|
|
63
46
|
// Commit All 命令
|
|
64
|
-
program
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
.option('--max-retries <number>', '最大重試次數')
|
|
71
|
-
.action(async (options) => {
|
|
72
|
-
try {
|
|
73
|
-
await commitAllCommand(options);
|
|
74
|
-
process.exit(0);
|
|
75
|
-
} catch (error) {
|
|
76
|
-
process.exit(1);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
47
|
+
registerCommand(program, 'commit-all', '智慧分析所有變更並自動分組提交', [
|
|
48
|
+
{ flags: '--model <model>', description: '指定 AI 模型' },
|
|
49
|
+
{ flags: '-v, --verbose', description: '顯示詳細輸出' },
|
|
50
|
+
{ flags: '--max-diff <number>', description: '最大 diff 長度' },
|
|
51
|
+
{ flags: '--max-retries <number>', description: '最大重試次數' },
|
|
52
|
+
], commitAllCommand);
|
|
79
53
|
|
|
80
54
|
// PR 命令
|
|
81
|
-
program
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
55
|
+
registerCommand(program, 'pr', 'AI 自動生成 PR 並創建 Pull Request', [
|
|
56
|
+
{ flags: '--base <branch>', description: '指定目標分支' },
|
|
57
|
+
{ flags: '--model <model>', description: '指定 AI 模型' },
|
|
58
|
+
{ flags: '--preview', description: '僅預覽 PR 內容,不實際創建' },
|
|
59
|
+
{ flags: '--no-confirm', description: '跳過確認直接創建' },
|
|
60
|
+
{ flags: '--auto-labels', description: '自動添加 Labels (預設啟用)' },
|
|
61
|
+
{ flags: '--include-impact', description: '在 PR 中包含影響範圍分析和注意事項 (預設關閉)' },
|
|
62
|
+
{ flags: '--force-new', description: '強制創建新 PR,不更新現有 PR' },
|
|
63
|
+
], prCommand);
|
|
64
|
+
|
|
65
|
+
// Usage 命令
|
|
66
|
+
registerCommand(program, 'usage', '查看組織 GitHub Copilot 使用狀態與用量', [
|
|
67
|
+
{ flags: '--org <org>', description: '指定組織名稱(預設自動從 git remote 偵測)' },
|
|
68
|
+
{ flags: '--from <date>', description: '開始日期,格式 YYYY-MM-DD(預設:本月第一天)' },
|
|
69
|
+
{ flags: '--to <date>', description: '結束日期,格式 YYYY-MM-DD(預設:今天)' },
|
|
70
|
+
{ flags: '--top <n>', description: '只顯示前 N 名用戶' },
|
|
71
|
+
{ flags: '--sort <by>', description: '排序方式:credits(預設)| amount | name | activity' },
|
|
72
|
+
{ flags: '--team <slug>', description: '只顯示指定團隊的成員' },
|
|
73
|
+
{ flags: '--inactive', description: '同時顯示非活躍用戶' },
|
|
74
|
+
{ flags: '--breakdown', description: '顯示每日使用量明細' },
|
|
75
|
+
{ flags: '--export <file>', description: '匯出為 CSV 檔案(例如 usage.csv)' },
|
|
76
|
+
{ flags: '--json', description: '以 JSON 格式輸出完整資料' },
|
|
77
|
+
], usageCommand);
|
|
78
|
+
|
|
79
|
+
// Model Info 命令
|
|
80
|
+
registerCommand(program, 'model-info', '查看目前可用的 AI 模型資訊', [
|
|
81
|
+
{ flags: '--json', description: '以 JSON 格式輸出完整模型資料' },
|
|
82
|
+
{ flags: '--filter <keyword>', description: '依模型名稱或描述關鍵字過濾' },
|
|
83
|
+
{ flags: '--model <model>', description: '查詢單一模型的詳細資訊' },
|
|
84
|
+
{ flags: '--no-cache', description: '忽略快取,強制重新連線 Copilot 取得最新模型清單' },
|
|
85
|
+
], modelInfoCommand);
|
|
99
86
|
|
|
100
87
|
program.parse();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-git-tools",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.81",
|
|
4
4
|
"description": "AI-powered Git automation tools for commit messages and PR generation",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
},
|
|
52
52
|
"repository": {
|
|
53
53
|
"type": "git",
|
|
54
|
-
"url": "https://github.com/YisoTsao/ai-git-tools.git"
|
|
54
|
+
"url": "git+https://github.com/YisoTsao/ai-git-tools.git"
|
|
55
55
|
},
|
|
56
56
|
"bugs": {
|
|
57
57
|
"url": "https://github.com/YisoTsao/ai-git-tools/issues"
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Commit Message Prompt 生成
|
|
3
|
+
* 集中管理 commit message 的 AI prompt 與後處理
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { getProjectTypePrompt } from '../../utils/helpers.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 生成 commit message prompt
|
|
10
|
+
* @param {string} diff - git diff 內容
|
|
11
|
+
* @param {Object} config - 配置物件
|
|
12
|
+
* @returns {string}
|
|
13
|
+
*/
|
|
14
|
+
export function generateCommitMessagePrompt(diff, config = {}) {
|
|
15
|
+
const projectPrompt = getProjectTypePrompt();
|
|
16
|
+
|
|
17
|
+
return `${projectPrompt}
|
|
18
|
+
|
|
19
|
+
請根據以下 git diff 產生一則 commit message。
|
|
20
|
+
|
|
21
|
+
**Commit Message 規則**:
|
|
22
|
+
1. 使用 Conventional Commits 格式:type(scope): subject
|
|
23
|
+
2. type 必須是:feat/fix/docs/style/refactor/test/chore/perf 其中之一
|
|
24
|
+
3. scope: 影響範圍(如 member、report、auth、api、ui、config)
|
|
25
|
+
4. subject 限制在 50 字內,使用繁體中文
|
|
26
|
+
5. 如果變更複雜,加上 body 說明(使用 bullet points)
|
|
27
|
+
|
|
28
|
+
**重要**:
|
|
29
|
+
- 直接輸出 commit message 純文字,不要使用 markdown 程式碼區塊(\`\`\`)
|
|
30
|
+
- 不要加上任何前綴說明或後綴文字
|
|
31
|
+
- 第一行是標題,如有需要可加上空行後的詳細說明
|
|
32
|
+
|
|
33
|
+
**範例格式**:
|
|
34
|
+
feat(member): 新增會員管理頁面
|
|
35
|
+
|
|
36
|
+
- 實作會員列表查詢功能
|
|
37
|
+
- 新增會員資料編輯表單
|
|
38
|
+
- 整合 Zustand 狀態管理
|
|
39
|
+
|
|
40
|
+
git diff:
|
|
41
|
+
${diff}`;
|
|
42
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PR Content Prompt 生成
|
|
3
|
+
* 集中管理 PR 標題、描述與影響分析的 AI prompt
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { CONSTANTS } from '../../utils/constants.js';
|
|
7
|
+
import { getSkillsSummaryForPrompt, PROJECT_SKILLS_CONTEXT } from '../../utils/project-skills.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 生成 PR 內容 prompt
|
|
11
|
+
* @param {string} commits - commit 訊息
|
|
12
|
+
* @param {string} diff - 程式碼變更 diff
|
|
13
|
+
* @returns {string}
|
|
14
|
+
*/
|
|
15
|
+
export function generatePRContentPrompt(commits, diff) {
|
|
16
|
+
return `你是一個專業的前端工程師,熟悉 Next.js、React 效能優化和團隊開發規範。
|
|
17
|
+
請根據以下 commit 訊息和程式碼變更,直接輸出一個清晰的 Pull Request 標題和描述。
|
|
18
|
+
|
|
19
|
+
**重要原則**:
|
|
20
|
+
- 只根據實際的 commit 訊息和 diff 內容描述變更,不要臆測或誇大
|
|
21
|
+
- 如果 commit 中沒有提到「新增指令 / 新增 API / 新增組件」,請不要用這些詞
|
|
22
|
+
- 文件(如 .github/copilot-instructions.md、prompt 檔案、README)應描述為「新增/更新文件」而非「新增指令」
|
|
23
|
+
- 如果 OpenSpec prompt 被刪除並改為 OpsX prompt,請描述為「以 OpsX 取代 OpenSpec」,不要說「新增 OpenSpec prompt」
|
|
24
|
+
- package.json 若只有版本號變更,請描述為「更新版本號」,不要說「更新相依」
|
|
25
|
+
- 重構相關的改動請優先使用 refactor 類型
|
|
26
|
+
|
|
27
|
+
**輸出格式**(不要加任何引導語,直接輸出以下內容):
|
|
28
|
+
|
|
29
|
+
# [type]: [PR 標題]
|
|
30
|
+
|
|
31
|
+
> type 必須是以下之一:feat / fix / refactor / style / docs / test / chore / perf
|
|
32
|
+
> **重要**:如果有新增任何功能、新增檔案、新增 API、新增組件,優先使用 **feat**
|
|
33
|
+
|
|
34
|
+
## 📝 變更摘要
|
|
35
|
+
[簡述這個 PR 的主要目的和影響範圍,2-3 句話]
|
|
36
|
+
|
|
37
|
+
## 🎯 主要變更
|
|
38
|
+
- [變更項目 1]
|
|
39
|
+
- [變更項目 2]
|
|
40
|
+
- [變更項目 3]
|
|
41
|
+
|
|
42
|
+
## 🔀 變更類型
|
|
43
|
+
- [ ] ✨ 新功能 (feat)
|
|
44
|
+
- [ ] 🐛 Bug 修復 (fix)
|
|
45
|
+
- [ ] ♻️ 重構 (refactor)
|
|
46
|
+
- [ ] 💄 樣式調整 (style)
|
|
47
|
+
- [ ] 📝 文件更新 (docs)
|
|
48
|
+
- [ ] ⚡ 效能改進 (perf)
|
|
49
|
+
- [ ] 🔧 其他 (chore)
|
|
50
|
+
|
|
51
|
+
> 根據 diff 和 commit 自動勾選(可複選),[ ] 改為 [x];有新增檔案或功能必勾 ✨ feat
|
|
52
|
+
|
|
53
|
+
## 🧪 測試方法
|
|
54
|
+
1. [具體的測試步驟 1]
|
|
55
|
+
2. [具體的測試步驟 2]
|
|
56
|
+
3. [具體的測試步驟 3]
|
|
57
|
+
|
|
58
|
+
## 💥 Breaking Changes
|
|
59
|
+
[如果有破壞性變更請詳細說明,沒有則填寫「無」]
|
|
60
|
+
|
|
61
|
+
## 📌 注意事項
|
|
62
|
+
[需要特別注意的事項]
|
|
63
|
+
|
|
64
|
+
## 📸 截圖
|
|
65
|
+
[如果是 UI 變更,提醒需要截圖]
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## ⚠️ 風險與注意事項
|
|
70
|
+
**Risk Level**: \`LOW\` / \`MEDIUM\` / \`HIGH\`
|
|
71
|
+
|
|
72
|
+
[說明潛在風險、破壞性變更(breaking changes)、需要特別小心的地方;沒有則填「無」]
|
|
73
|
+
|
|
74
|
+
## 👀 Reviewer 重點
|
|
75
|
+
- [請 reviewer 特別關注的邏輯或設計決策 1]
|
|
76
|
+
- [請 reviewer 特別關注的邏輯或設計決策 2]
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
**規則**:
|
|
81
|
+
- 直接輸出 # [type]: [標題],繁體中文(台灣正體)
|
|
82
|
+
- type 必須符合 Conventional Commits;以 commit 內容為準,新增檔案/功能優先 feat,重構優先 refactor
|
|
83
|
+
- 變更類型只勾選實際出現的類型,沒有 fix 類 commit 就不要勾 Bug 修復
|
|
84
|
+
- Risk Level:HIGH=核心流程,MEDIUM=影響現有功能,LOW=新增或純重構
|
|
85
|
+
- Reviewer 重點列 1-3 個值得仔細看的地方
|
|
86
|
+
- 描述必須和 commit 訊息一致,禁止虛構功能或誇大影響範圍
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
**Commit 訊息**:
|
|
91
|
+
${commits}
|
|
92
|
+
|
|
93
|
+
**程式碼變更**:
|
|
94
|
+
${diff}`;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* 生成影響分析 prompt
|
|
99
|
+
* @param {string[]} changedFiles - 變更檔案列表
|
|
100
|
+
* @param {string} diff - 程式碼變更 diff
|
|
101
|
+
* @param {string} commits - commit 訊息
|
|
102
|
+
* @returns {string}
|
|
103
|
+
*/
|
|
104
|
+
export function generateImpactAnalysisPrompt(changedFiles, diff, commits) {
|
|
105
|
+
const skillsSummary = getSkillsSummaryForPrompt(PROJECT_SKILLS_CONTEXT);
|
|
106
|
+
|
|
107
|
+
return `你是一個資深的程式碼審查專家,精通 React/Next.js 效能優化與前端架構設計。
|
|
108
|
+
請分析以下程式碼變更,提供專業的影響範圍分析與規範合規檢查。
|
|
109
|
+
|
|
110
|
+
${skillsSummary}
|
|
111
|
+
|
|
112
|
+
**變更檔案列表**:
|
|
113
|
+
${changedFiles.slice(0, CONSTANTS.MAX_FILES_IN_PROMPT).join('\n')}
|
|
114
|
+
${
|
|
115
|
+
changedFiles.length > CONSTANTS.MAX_FILES_IN_PROMPT
|
|
116
|
+
? `... 還有 ${changedFiles.length - CONSTANTS.MAX_FILES_IN_PROMPT} 個檔案`
|
|
117
|
+
: ''
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
**Commit 訊息**:
|
|
121
|
+
${commits.split('\n').slice(0, CONSTANTS.MAX_COMMITS_IN_PROMPT).join('\n')}
|
|
122
|
+
|
|
123
|
+
**程式碼變更內容**:
|
|
124
|
+
\`\`\`diff
|
|
125
|
+
${diff.substring(0, CONSTANTS.MAX_DIFF_LENGTH)}
|
|
126
|
+
${diff.length > CONSTANTS.MAX_DIFF_LENGTH ? '\n... (內容過長已截斷)' : ''}
|
|
127
|
+
\`\`\`
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
請以 JSON 格式輸出分析結果(不要加任何其他文字,只輸出 JSON):
|
|
132
|
+
|
|
133
|
+
\`\`\`json
|
|
134
|
+
{
|
|
135
|
+
"blastRadius": {
|
|
136
|
+
"modules": ["影響的模組1", "影響的模組2"],
|
|
137
|
+
"impacts": ["影響層面1", "影響層面2"],
|
|
138
|
+
"riskLevel": "低|中|高",
|
|
139
|
+
"riskReasons": ["風險原因1", "風險原因2"],
|
|
140
|
+
"externalBehaviors": ["對外行為變更說明"]
|
|
141
|
+
},
|
|
142
|
+
"warnings": [
|
|
143
|
+
{
|
|
144
|
+
"level": "⚠️|ℹ️",
|
|
145
|
+
"message": "問題描述",
|
|
146
|
+
"suggestion": "改善建議"
|
|
147
|
+
}
|
|
148
|
+
]
|
|
149
|
+
}
|
|
150
|
+
\`\`\``;
|
|
151
|
+
}
|