ai-git-tools 2.0.41 → 2.0.42
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/package.json
CHANGED
|
@@ -196,6 +196,9 @@ export async function loadAutodevConfig() {
|
|
|
196
196
|
skipPr: false,
|
|
197
197
|
verbose: false,
|
|
198
198
|
projectRoot: process.cwd(),
|
|
199
|
+
// AI 設定(可被 autodev 子區塊或全域 ai 區塊覆蓋)
|
|
200
|
+
aiModel: 'gpt-4.1',
|
|
201
|
+
maxRetries: 3,
|
|
199
202
|
};
|
|
200
203
|
|
|
201
204
|
// 支援 .ai-git-config.js 和 .ai-git-config.mjs
|
|
@@ -205,11 +208,14 @@ export async function loadAutodevConfig() {
|
|
|
205
208
|
];
|
|
206
209
|
|
|
207
210
|
let userAutodev = {};
|
|
211
|
+
let userAi = {};
|
|
208
212
|
for (const configPath of candidates) {
|
|
209
213
|
if (existsSync(configPath)) {
|
|
210
214
|
try {
|
|
211
215
|
const imported = await import(`file://${configPath}`);
|
|
212
|
-
|
|
216
|
+
const root = imported.default || {};
|
|
217
|
+
userAutodev = root.autodev || {};
|
|
218
|
+
userAi = root.ai || {}; // 讀取全域 ai 區塊
|
|
213
219
|
break;
|
|
214
220
|
} catch (error) {
|
|
215
221
|
console.warn(`⚠️ 載入 autodev 配置失敗: ${error.message}`);
|
|
@@ -219,6 +225,10 @@ export async function loadAutodevConfig() {
|
|
|
219
225
|
|
|
220
226
|
return {
|
|
221
227
|
...defaults,
|
|
228
|
+
// 全域 ai 區塊優先度低於 autodev 子區塊
|
|
229
|
+
aiModel: userAutodev.aiModel ?? userAi.model ?? defaults.aiModel,
|
|
230
|
+
maxRetries: userAutodev.maxRetries ?? userAi.maxRetries ?? defaults.maxRetries,
|
|
231
|
+
// 其他 autodev 欄位
|
|
222
232
|
...userAutodev,
|
|
223
233
|
};
|
|
224
234
|
}
|
|
@@ -99,7 +99,7 @@ export class CodeGenerator {
|
|
|
99
99
|
_buildPrompt(issueData, projectRoot) {
|
|
100
100
|
const { title, body, labels } = issueData;
|
|
101
101
|
|
|
102
|
-
return `你是一個資深軟體工程師,負責基於 GitHub Issue
|
|
102
|
+
return `你是一個資深軟體工程師,負責基於 GitHub Issue 生成完整的代碼框架和測試用例。
|
|
103
103
|
|
|
104
104
|
## Issue 資訊
|
|
105
105
|
標題:${title}
|
|
@@ -109,21 +109,40 @@ ${body}
|
|
|
109
109
|
|
|
110
110
|
## 任務
|
|
111
111
|
1. 分析上方 Issue 的需求
|
|
112
|
-
2.
|
|
113
|
-
|
|
112
|
+
2. **同時**設計兩套檔案:
|
|
113
|
+
a. 實現檔案(src/ 中的原始碼)
|
|
114
|
+
b. 測試檔案(tests/ 或 __tests__/ 中的測試)
|
|
115
|
+
3. 生成初始實現和初始測試
|
|
116
|
+
|
|
117
|
+
## 重要:測試檔案生成
|
|
118
|
+
- 對每個實現檔案,都生成對應的測試檔案
|
|
119
|
+
- 測試檔案應放在 \`tests/\` 或 \`src/__tests__/\` 目錄
|
|
120
|
+
- 測試應覆蓋主要功能(可使用 TODO 標記待補充的測試用例)
|
|
121
|
+
- 測試檔案命名:實現檔案 \`.js\` → 測試檔案 \`.test.js\`
|
|
122
|
+
- 例:\`src/utils/helper.js\` → \`tests/utils/helper.test.js\`
|
|
114
123
|
|
|
115
124
|
## 輸出格式
|
|
116
|
-
請回傳 JSON
|
|
125
|
+
請回傳 JSON 陣列,包含**源文件和測試文件**:
|
|
117
126
|
\`\`\`json
|
|
118
127
|
[
|
|
119
128
|
{
|
|
120
|
-
"filePath": "src/components/MyComponent.
|
|
121
|
-
"content": "//
|
|
129
|
+
"filePath": "src/components/MyComponent.jsx",
|
|
130
|
+
"content": "// React 元件實現...",
|
|
122
131
|
"type": "new"
|
|
123
132
|
},
|
|
124
133
|
{
|
|
125
|
-
"filePath": "
|
|
126
|
-
"content": "//
|
|
134
|
+
"filePath": "tests/components/MyComponent.test.jsx",
|
|
135
|
+
"content": "// Jest 測試...",
|
|
136
|
+
"type": "new"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"filePath": "src/utils/helper.js",
|
|
140
|
+
"content": "// 工具函數...",
|
|
141
|
+
"type": "new"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"filePath": "tests/utils/helper.test.js",
|
|
145
|
+
"content": "// 單元測試...",
|
|
127
146
|
"type": "new"
|
|
128
147
|
}
|
|
129
148
|
]
|
|
@@ -131,11 +150,12 @@ ${body}
|
|
|
131
150
|
|
|
132
151
|
只回傳 JSON,不要其他文字。
|
|
133
152
|
|
|
134
|
-
##
|
|
135
|
-
-
|
|
136
|
-
-
|
|
137
|
-
-
|
|
138
|
-
-
|
|
153
|
+
## 測試框架指南(假設 Jest)
|
|
154
|
+
- \`describe('名稱', () => { ... })\` 分組
|
|
155
|
+
- \`test('應該...', () => { ... })\` 單一測試
|
|
156
|
+
- 包含 arrange-act-assert 結構
|
|
157
|
+
- 對 TODO 部分用 \`test.todo('待實現')\`
|
|
158
|
+
- 可包含 \`// TODO: 補充邊界情況\` 註釋
|
|
139
159
|
|
|
140
160
|
專案根目錄:${projectRoot}`;
|
|
141
161
|
}
|