intention-coding 0.5.3 → 0.5.4
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/dist/index.cjs +944 -543
- package/dist/services/image-analysis/analyzer.d.ts +0 -18
- package/dist/services/image-analysis/analyzer.d.ts.map +1 -1
- package/dist/services/image-analysis/index.d.ts +2 -2
- package/dist/services/image-analysis/index.d.ts.map +1 -1
- package/dist/services/image-analysis/types.d.ts +1 -148
- package/dist/services/image-analysis/types.d.ts.map +1 -1
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/project-template/index.d.ts +2 -2
- package/dist/services/requirement/index.d.ts +75 -0
- package/dist/services/requirement/index.d.ts.map +1 -0
- package/dist/services/requirement-analyzer/index.d.ts +4 -4
- package/package.json +1 -1
- package/dist/services/code-generator/index.d.ts +0 -50
- package/dist/services/code-generator/index.d.ts.map +0 -1
- package/dist/services/code-generator/stages/execution-stage.d.ts +0 -96
- package/dist/services/code-generator/stages/execution-stage.d.ts.map +0 -1
- package/dist/services/code-generator/stages/ideation-stage.d.ts +0 -34
- package/dist/services/code-generator/stages/ideation-stage.d.ts.map +0 -1
- package/dist/services/code-generator/stages/optimization-stage.d.ts +0 -47
- package/dist/services/code-generator/stages/optimization-stage.d.ts.map +0 -1
- package/dist/services/code-generator/stages/planning-stage.d.ts +0 -34
- package/dist/services/code-generator/stages/planning-stage.d.ts.map +0 -1
- package/dist/services/code-generator/stages/research-stage.d.ts +0 -36
- package/dist/services/code-generator/stages/research-stage.d.ts.map +0 -1
- package/dist/services/code-generator/stages/review-stage.d.ts +0 -34
- package/dist/services/code-generator/stages/review-stage.d.ts.map +0 -1
- package/dist/services/code-generator/types.d.ts +0 -233
- package/dist/services/code-generator/types.d.ts.map +0 -1
- package/dist/services/code-generator/utils/instruction-executor.d.ts +0 -70
- package/dist/services/code-generator/utils/instruction-executor.d.ts.map +0 -1
- package/dist/services/code-generator/workflow-manager.d.ts +0 -47
- package/dist/services/code-generator/workflow-manager.d.ts.map +0 -1
- package/dist/services/requirement-handler/core/agents/align-agent.d.ts +0 -31
- package/dist/services/requirement-handler/core/agents/align-agent.d.ts.map +0 -1
- package/dist/services/requirement-handler/core/agents/approve-agent.d.ts +0 -33
- package/dist/services/requirement-handler/core/agents/approve-agent.d.ts.map +0 -1
- package/dist/services/requirement-handler/core/agents/architect-agent.d.ts +0 -29
- package/dist/services/requirement-handler/core/agents/architect-agent.d.ts.map +0 -1
- package/dist/services/requirement-handler/core/agents/assess-agent.d.ts +0 -53
- package/dist/services/requirement-handler/core/agents/assess-agent.d.ts.map +0 -1
- package/dist/services/requirement-handler/core/agents/atomize-agent.d.ts +0 -33
- package/dist/services/requirement-handler/core/agents/atomize-agent.d.ts.map +0 -1
- package/dist/services/requirement-handler/core/agents/automate-agent.d.ts +0 -43
- package/dist/services/requirement-handler/core/agents/automate-agent.d.ts.map +0 -1
- package/dist/services/requirement-handler/core/requirement-handler-service.d.ts +0 -35
- package/dist/services/requirement-handler/core/requirement-handler-service.d.ts.map +0 -1
- package/dist/services/requirement-handler/core/types.d.ts +0 -143
- package/dist/services/requirement-handler/core/types.d.ts.map +0 -1
- package/dist/services/requirement-handler/index.d.ts +0 -87
- package/dist/services/requirement-handler/index.d.ts.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -66,7 +66,7 @@ var __webpack_exports__ = {};
|
|
|
66
66
|
try {
|
|
67
67
|
if (process.env.LOG_DIR) logDir = process.env.LOG_DIR;
|
|
68
68
|
else {
|
|
69
|
-
const storageDir =
|
|
69
|
+
const storageDir = config_getStorageDir();
|
|
70
70
|
logDir = storageDir ? storageDir + '/logs' : './.aico/logs';
|
|
71
71
|
}
|
|
72
72
|
} catch (error) {
|
|
@@ -130,7 +130,7 @@ var __webpack_exports__ = {};
|
|
|
130
130
|
format: fileFormat,
|
|
131
131
|
level: 'info'
|
|
132
132
|
}));
|
|
133
|
-
const
|
|
133
|
+
const logger_logger = external_winston_default().createLogger({
|
|
134
134
|
level: 'debug',
|
|
135
135
|
levels,
|
|
136
136
|
format: external_winston_default().format.combine(external_winston_default().format.errors({
|
|
@@ -159,8 +159,8 @@ var __webpack_exports__ = {};
|
|
|
159
159
|
] : []
|
|
160
160
|
});
|
|
161
161
|
process.on('SIGINT', ()=>{
|
|
162
|
-
|
|
163
|
-
|
|
162
|
+
logger_logger.end(()=>{
|
|
163
|
+
logger_logger.info("\u65E5\u5FD7\u5DF2\u5173\u95ED");
|
|
164
164
|
process.exit(0);
|
|
165
165
|
});
|
|
166
166
|
});
|
|
@@ -243,7 +243,7 @@ var __webpack_exports__ = {};
|
|
|
243
243
|
const contextManager = new ContextManager();
|
|
244
244
|
const detectProjectRoot = (enableLogging = false)=>{
|
|
245
245
|
if (process.env.MCP_STORAGE_DIR) {
|
|
246
|
-
if (enableLogging)
|
|
246
|
+
if (enableLogging) logger_logger.info(`\u{4F7F}\u{7528}\u{73AF}\u{5883}\u{53D8}\u{91CF} MCP_STORAGE_DIR: ${process.env.MCP_STORAGE_DIR}`);
|
|
247
247
|
return process.env.MCP_STORAGE_DIR;
|
|
248
248
|
}
|
|
249
249
|
let currentDir = process.cwd();
|
|
@@ -254,12 +254,12 @@ var __webpack_exports__ = {};
|
|
|
254
254
|
'pyproject.toml',
|
|
255
255
|
'go.mod'
|
|
256
256
|
];
|
|
257
|
-
if (enableLogging)
|
|
257
|
+
if (enableLogging) logger_logger.info(`\u{5F00}\u{59CB}\u{4ECE}\u{5F53}\u{524D}\u{76EE}\u{5F55}\u{68C0}\u{6D4B}\u{9879}\u{76EE}\u{6839}\u{76EE}\u{5F55}: ${currentDir}`);
|
|
258
258
|
while('/' !== currentDir){
|
|
259
259
|
for (const marker of markers){
|
|
260
260
|
const markerPath = (0, external_path_namespaceObject.resolve)(currentDir, marker);
|
|
261
261
|
if (external_fs_namespaceObject.existsSync(markerPath)) {
|
|
262
|
-
if (enableLogging)
|
|
262
|
+
if (enableLogging) logger_logger.info(`\u{627E}\u{5230}\u{9879}\u{76EE}\u{6807}\u{8BB0}\u{6587}\u{4EF6} ${marker} \u{5728}: ${currentDir}`);
|
|
263
263
|
return currentDir;
|
|
264
264
|
}
|
|
265
265
|
}
|
|
@@ -267,7 +267,7 @@ var __webpack_exports__ = {};
|
|
|
267
267
|
if (parentDir === currentDir) break;
|
|
268
268
|
currentDir = parentDir;
|
|
269
269
|
}
|
|
270
|
-
if (enableLogging)
|
|
270
|
+
if (enableLogging) logger_logger.warn(`\u{672A}\u{627E}\u{5230}\u{9879}\u{76EE}\u{6807}\u{8BB0}\u{6587}\u{4EF6}\u{FF0C}\u{4F7F}\u{7528}\u{5F53}\u{524D}\u{5DE5}\u{4F5C}\u{76EE}\u{5F55}: ${process.cwd()}`);
|
|
271
271
|
return process.cwd();
|
|
272
272
|
};
|
|
273
273
|
let _PROJECT_ROOT = null;
|
|
@@ -289,9 +289,9 @@ var __webpack_exports__ = {};
|
|
|
289
289
|
_PROJECT_ROOT = detectedRoot;
|
|
290
290
|
if (!process.env.MCP_STORAGE_DIR) process.env.MCP_STORAGE_DIR = detectedRoot;
|
|
291
291
|
contextManager.setCachedData("project_root", detectedRoot);
|
|
292
|
-
|
|
292
|
+
logger_logger.info(`\u{9879}\u{76EE}\u{6839}\u{76EE}\u{5F55}\u{5DF2}\u{8BBE}\u{7F6E}\u{4E3A}: ${detectedRoot}`);
|
|
293
293
|
};
|
|
294
|
-
const
|
|
294
|
+
const config_getStorageDir = ()=>{
|
|
295
295
|
try {
|
|
296
296
|
const cachedRoot = contextManager.getCachedData("project_root");
|
|
297
297
|
if (cachedRoot && 'string' == typeof cachedRoot) return cachedRoot + "/.aico";
|
|
@@ -317,7 +317,7 @@ var __webpack_exports__ = {};
|
|
|
317
317
|
const external_html_to_md_namespaceObject = require("html-to-md");
|
|
318
318
|
var external_html_to_md_default = /*#__PURE__*/ __webpack_require__.n(external_html_to_md_namespaceObject);
|
|
319
319
|
const external_os_namespaceObject = require("os");
|
|
320
|
-
const
|
|
320
|
+
const common_sanitizeFileName = (input)=>input.replace(/[\\/:*?"<>|\n\r#%&]/g, '').trim().replace(/\s+/g, '_').replace(/_+/g, '_').replace(/^_+|_+$/g, '');
|
|
321
321
|
function normalizePath(filePath) {
|
|
322
322
|
if (!filePath || 'string' != typeof filePath) throw new Error("\u6587\u4EF6\u8DEF\u5F84\u4E0D\u80FD\u4E3A\u7A7A");
|
|
323
323
|
filePath = filePath.trim().replace(/^["']|["']$/g, '');
|
|
@@ -329,14 +329,14 @@ var __webpack_exports__ = {};
|
|
|
329
329
|
const resolved = external_path_default().resolve(normalized);
|
|
330
330
|
return resolved;
|
|
331
331
|
}
|
|
332
|
-
async function
|
|
332
|
+
async function common_validateAndResolvePath(filePath) {
|
|
333
333
|
if (!filePath) throw new Error("\u6587\u4EF6\u8DEF\u5F84\u53C2\u6570\u7F3A\u5931\uFF0C\u8BF7\u63D0\u4F9B filePath \u53C2\u6570");
|
|
334
334
|
const resolved = normalizePath(filePath);
|
|
335
335
|
try {
|
|
336
336
|
await external_fs_namespaceObject.promises.access(resolved, external_fs_namespaceObject.constants.R_OK);
|
|
337
337
|
} catch (error) {
|
|
338
338
|
const osInfo = `[${process.platform}]`;
|
|
339
|
-
|
|
339
|
+
logger_logger.warn(`\u{6587}\u{4EF6}\u{4E0D}\u{5B58}\u{5728}\u{6216}\u{4E0D}\u{53EF}\u{8BFB} ${osInfo}: ${resolved}`, error);
|
|
340
340
|
throw new Error(`\u{6587}\u{4EF6}\u{4E0D}\u{5B58}\u{5728}\u{6216}\u{4E0D}\u{53EF}\u{8BFB} ${osInfo}: ${resolved}`);
|
|
341
341
|
}
|
|
342
342
|
return resolved;
|
|
@@ -3968,9 +3968,9 @@ var __webpack_exports__ = {};
|
|
|
3968
3968
|
const { filePath } = args;
|
|
3969
3969
|
if (!filePath) throw new Error("\u6587\u4EF6\u8DEF\u5F84\u53C2\u6570\u7F3A\u5931\uFF0C\u8BF7\u63D0\u4F9B filePath \u53C2\u6570");
|
|
3970
3970
|
try {
|
|
3971
|
-
const resolvedPath = await
|
|
3971
|
+
const resolvedPath = await common_validateAndResolvePath(filePath);
|
|
3972
3972
|
const buffer = await promises_namespaceObject.readFile(resolvedPath);
|
|
3973
|
-
const mdDir = external_path_default().join(
|
|
3973
|
+
const mdDir = external_path_default().join(config_getStorageDir(), 'md');
|
|
3974
3974
|
const baseName = external_path_default().basename(filePath, '.docx');
|
|
3975
3975
|
const outputDir = external_path_default().join(mdDir, baseName);
|
|
3976
3976
|
const imgsDir = external_path_default().join(outputDir, 'imgs');
|
|
@@ -3980,7 +3980,7 @@ var __webpack_exports__ = {};
|
|
|
3980
3980
|
await promises_namespaceObject.mkdir(imgsDir, {
|
|
3981
3981
|
recursive: true
|
|
3982
3982
|
});
|
|
3983
|
-
|
|
3983
|
+
logger_logger.info("\u5F00\u59CB\u8F6C\u6362Word\u6587\u6863", {
|
|
3984
3984
|
file: filePath,
|
|
3985
3985
|
outputDir,
|
|
3986
3986
|
imgsDir
|
|
@@ -4006,7 +4006,7 @@ var __webpack_exports__ = {};
|
|
|
4006
4006
|
await promises_namespaceObject.writeFile(imagePath, imageBuffer);
|
|
4007
4007
|
htmlContent = htmlContent.replace(img.fullMatch, `<img src="./imgs/${imageFileName}" />`);
|
|
4008
4008
|
} catch (err) {
|
|
4009
|
-
|
|
4009
|
+
logger_logger.error("\u56FE\u7247\u5904\u7406\u5931\u8D25", {
|
|
4010
4010
|
error: err instanceof Error ? err.message : String(err),
|
|
4011
4011
|
imageNumber: i + 1
|
|
4012
4012
|
});
|
|
@@ -4017,7 +4017,7 @@ var __webpack_exports__ = {};
|
|
|
4017
4017
|
value: htmlContent,
|
|
4018
4018
|
messages: basicResult.messages
|
|
4019
4019
|
};
|
|
4020
|
-
if (htmlResult.messages && htmlResult.messages.length > 0)
|
|
4020
|
+
if (htmlResult.messages && htmlResult.messages.length > 0) logger_logger.warn("Word\u8F6C\u6362\u8B66\u544A", {
|
|
4021
4021
|
file: filePath,
|
|
4022
4022
|
warnings: htmlResult.messages
|
|
4023
4023
|
});
|
|
@@ -4042,7 +4042,7 @@ var __webpack_exports__ = {};
|
|
|
4042
4042
|
};
|
|
4043
4043
|
} catch (error) {
|
|
4044
4044
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
4045
|
-
|
|
4045
|
+
logger_logger.error(`Word\u{8F6C}\u{6362}\u{5931}\u{8D25}: ${errorMsg}`, {
|
|
4046
4046
|
tool: "word2md",
|
|
4047
4047
|
filePath
|
|
4048
4048
|
});
|
|
@@ -4094,17 +4094,17 @@ var __webpack_exports__ = {};
|
|
|
4094
4094
|
const { preserve_formatting = true, extract_metadata = true } = options;
|
|
4095
4095
|
try {
|
|
4096
4096
|
initializeProjectRoot();
|
|
4097
|
-
const resolvedPath = await
|
|
4097
|
+
const resolvedPath = await common_validateAndResolvePath(file_path);
|
|
4098
4098
|
if (!file_path.toLowerCase().endsWith('.pdf')) throw new Error("\u6587\u4EF6\u5FC5\u987B\u662FPDF\u683C\u5F0F\uFF08.pdf\u6269\u5C55\u540D\uFF09");
|
|
4099
|
-
|
|
4099
|
+
logger_logger.info("\u5F00\u59CB\u8BFB\u53D6PDF\u6587\u4EF6", {
|
|
4100
4100
|
file: file_path
|
|
4101
4101
|
});
|
|
4102
4102
|
const dataBuffer = await promises_namespaceObject.readFile(resolvedPath);
|
|
4103
|
-
|
|
4103
|
+
logger_logger.info("\u5F00\u59CB\u89E3\u6790PDF\u5185\u5BB9");
|
|
4104
4104
|
const pdfParse = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "pdf-parse/lib/pdf-parse.js"));
|
|
4105
4105
|
const pdfData = await pdfParse.default(dataBuffer);
|
|
4106
|
-
const mdDir = external_path_default().join(
|
|
4107
|
-
const baseName =
|
|
4106
|
+
const mdDir = external_path_default().join(config_getStorageDir(), 'md');
|
|
4107
|
+
const baseName = common_sanitizeFileName(external_path_default().basename(file_path, '.pdf'));
|
|
4108
4108
|
const outputDir = external_path_default().join(mdDir, baseName);
|
|
4109
4109
|
await promises_namespaceObject.mkdir(outputDir, {
|
|
4110
4110
|
recursive: true
|
|
@@ -4133,7 +4133,7 @@ var __webpack_exports__ = {};
|
|
|
4133
4133
|
markdownLength: markdownContent.length,
|
|
4134
4134
|
outputFile: external_path_default().resolve(fullMdPath)
|
|
4135
4135
|
};
|
|
4136
|
-
|
|
4136
|
+
logger_logger.info("PDF\u8F6C\u6362\u5B8C\u6210", stats);
|
|
4137
4137
|
return {
|
|
4138
4138
|
content: [
|
|
4139
4139
|
{
|
|
@@ -4160,7 +4160,7 @@ var __webpack_exports__ = {};
|
|
|
4160
4160
|
};
|
|
4161
4161
|
} catch (error) {
|
|
4162
4162
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
4163
|
-
|
|
4163
|
+
logger_logger.error(`PDF\u{8F6C}\u{6362}\u{5931}\u{8D25}: ${errorMsg}`, {
|
|
4164
4164
|
tool: "pdf2md",
|
|
4165
4165
|
file_path,
|
|
4166
4166
|
error: errorMsg
|
|
@@ -4181,188 +4181,7 @@ var __webpack_exports__ = {};
|
|
|
4181
4181
|
}
|
|
4182
4182
|
}
|
|
4183
4183
|
};
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
\u{8BF7}\u{6309}\u{4EE5}\u{4E0B}\u{6B65}\u{9AA4}\u{8FDB}\u{884C}\u{5206}\u{6790}\u{FF1A}
|
|
4187
|
-
|
|
4188
|
-
## 1. \u{4EE3}\u{7801}\u{5E93}\u{5206}\u{6790}
|
|
4189
|
-
\u{5206}\u{6790}\u{5F53}\u{524D}\u{4EE3}\u{7801}\u{5E93}\u{FF0C}\u{603B}\u{7ED3}\u{FF1A}
|
|
4190
|
-
- \u{4E3B}\u{8981}\u{529F}\u{80FD}\u{6A21}\u{5757}\u{53CA}\u{5176}\u{5B9E}\u{73B0}
|
|
4191
|
-
- \u{5173}\u{952E}\u{4E1A}\u{52A1}\u{903B}\u{8F91}\u{6D41}\u{7A0B}
|
|
4192
|
-
- \u{91CD}\u{8981}\u{6570}\u{636E}\u{7ED3}\u{6784}
|
|
4193
|
-
- \u{6838}\u{5FC3}\u{7B97}\u{6CD5}\u{5B9E}\u{73B0}
|
|
4194
|
-
|
|
4195
|
-
## 2. \u{63A5}\u{53E3}\u{4E0E}\u{9700}\u{6C42}\u{5BF9}\u{5E94}\u{5173}\u{7CFB}\u{8868}
|
|
4196
|
-
\u{6839}\u{636E}\u{4EE3}\u{7801}\u{53D8}\u{66F4}\u{FF0C}\u{751F}\u{6210}\u{63A5}\u{53E3}\u{4E0E}\u{9700}\u{6C42}\u{5BF9}\u{5E94}\u{5173}\u{7CFB}\u{8868}\u{FF1A}
|
|
4197
|
-
|
|
4198
|
-
| \u{9700}\u{6C42}\u{529F}\u{80FD} | \u{5B9E}\u{73B0}\u{63A5}\u{53E3} | \u{8BF7}\u{6C42}\u{65B9}\u{5F0F} | URL | \u{53D8}\u{66F4}\u{72B6}\u{6001} |
|
|
4199
|
-
|---------|---------|---------|-----|----------|
|
|
4200
|
-
| [\u{9700}\u{6C42}\u{529F}\u{80FD}\u{63CF}\u{8FF0}] | [Controller.method] | [GET/POST/PUT/DELETE] | [/api/path] | [\u{65B0}\u{589E}/\u{4FEE}\u{6539}/\u{5220}\u{9664}] |
|
|
4201
|
-
|
|
4202
|
-
## 3. \u{6838}\u{5FC3}\u{903B}\u{8F91}\u{65B9}\u{6CD5}\u{8868}
|
|
4203
|
-
\u{5206}\u{6790}\u{6838}\u{5FC3}\u{4E1A}\u{52A1}\u{903B}\u{8F91}\u{65B9}\u{6CD5}\u{FF1A}
|
|
4204
|
-
|
|
4205
|
-
| \u{65B9}\u{6CD5}\u{540D}\u{79F0} | \u{6240}\u{5C5E}\u{7C7B} | \u{529F}\u{80FD}\u{8BF4}\u{660E} | \u{53D8}\u{66F4}\u{72B6}\u{6001} |
|
|
4206
|
-
|---------|-------|---------|----------|
|
|
4207
|
-
| [methodName] | [ClassName] | [\u{529F}\u{80FD}\u{63CF}\u{8FF0}] | [\u{65B0}\u{589E}/\u{4FEE}\u{6539}/\u{5220}\u{9664}] |
|
|
4208
|
-
|
|
4209
|
-
## 4. \u{524D}\u{7AEF}\u{9875}\u{9762}\u{4E0E}\u{63A5}\u{53E3}\u{5BF9}\u{5E94}\u{5173}\u{7CFB}\u{8868}
|
|
4210
|
-
\u{5206}\u{6790}\u{524D}\u{7AEF}\u{9875}\u{9762}\u{53D8}\u{66F4}\u{FF1A}
|
|
4211
|
-
|
|
4212
|
-
| \u{9875}\u{9762}\u{540D}\u{79F0} | \u{8C03}\u{7528}\u{63A5}\u{53E3} | \u{7EC4}\u{4EF6}\u{540D}\u{79F0} | \u{8DEF}\u{7531}\u{8DEF}\u{5F84} | \u{53D8}\u{66F4}\u{72B6}\u{6001} |
|
|
4213
|
-
|---------|---------|---------|---------|----------|
|
|
4214
|
-
| [\u{9875}\u{9762}\u{540D}\u{79F0}] | [Controller.method] | [ComponentName] | [/path] | [\u{65B0}\u{589E}/\u{4FEE}\u{6539}/\u{5220}\u{9664}] |
|
|
4215
|
-
|
|
4216
|
-
## 5. \u{524D}\u{7AEF}\u{6838}\u{5FC3}\u{7EC4}\u{4EF6}\u{8868}
|
|
4217
|
-
\u{5206}\u{6790}\u{524D}\u{7AEF}\u{7EC4}\u{4EF6}\u{53D8}\u{66F4}\u{FF1A}
|
|
4218
|
-
|
|
4219
|
-
| \u{7EC4}\u{4EF6}\u{540D}\u{79F0} | \u{6240}\u{5C5E}\u{9875}\u{9762} | \u{529F}\u{80FD}\u{8BF4}\u{660E} | \u{53D8}\u{66F4}\u{72B6}\u{6001} |
|
|
4220
|
-
|---------|---------|---------|----------|
|
|
4221
|
-
| [ComponentName] | [PageName] | [\u{529F}\u{80FD}\u{63CF}\u{8FF0}] | [\u{65B0}\u{589E}/\u{4FEE}\u{6539}/\u{5220}\u{9664}] |
|
|
4222
|
-
|
|
4223
|
-
## 6. \u{9700}\u{6C42}\u{5B8C}\u{6574}\u{6027}\u{68C0}\u{67E5}
|
|
4224
|
-
\u{5BF9}\u{6BD4}\u{539F}\u{59CB}\u{9700}\u{6C42}\u{FF0C}\u{68C0}\u{67E5}\u{FF1A}
|
|
4225
|
-
- \u{2705} \u{5DF2}\u{5B8C}\u{6210}\u{7684}\u{529F}\u{80FD}
|
|
4226
|
-
- \u{26A0}\u{FE0F} \u{90E8}\u{5206}\u{5B8C}\u{6210}\u{7684}\u{529F}\u{80FD}
|
|
4227
|
-
- \u{274C} \u{672A}\u{5B9E}\u{73B0}\u{7684}\u{529F}\u{80FD}
|
|
4228
|
-
- \u{1F504} \u{9700}\u{8981}\u{8FDB}\u{4E00}\u{6B65}\u{5B8C}\u{5584}\u{7684}\u{529F}\u{80FD}
|
|
4229
|
-
|
|
4230
|
-
## 7. \u{5EFA}\u{8BAE}\u{4E0E}\u{603B}\u{7ED3}
|
|
4231
|
-
- \u{5B9E}\u{73B0}\u{8D28}\u{91CF}\u{8BC4}\u{4F30}
|
|
4232
|
-
- \u{6F5C}\u{5728}\u{95EE}\u{9898}\u{8BC6}\u{522B}
|
|
4233
|
-
- \u{540E}\u{7EED}\u{5F00}\u{53D1}\u{5EFA}\u{8BAE}
|
|
4234
|
-
- \u{6D4B}\u{8BD5}\u{5EFA}\u{8BAE}
|
|
4235
|
-
|
|
4236
|
-
\u{8BF7}\u{786E}\u{4FDD}\u{6240}\u{6709}\u{8868}\u{683C}\u{4E0A}\u{4E0B}\u{5BF9}\u{9F50}\u{FF0C}\u{5185}\u{5BB9}\u{8BE6}\u{5B9E}\u{51C6}\u{786E}\u{3002}`;
|
|
4237
|
-
objectType({
|
|
4238
|
-
baseBranch: stringType().default('main').describe("\u57FA\u51C6\u5206\u652F\u540D\u79F0\uFF0C\u7528\u4E8E\u5BF9\u6BD4\u53D8\u66F4"),
|
|
4239
|
-
requirementFile: stringType().optional().describe("\u9700\u6C42\u6587\u6863\u6587\u4EF6\u8DEF\u5F84\uFF08\u53EF\u9009\uFF09"),
|
|
4240
|
-
includeUncommitted: booleanType().default(true).describe("\u662F\u5426\u5305\u542B\u672A\u63D0\u4EA4\u7684\u53D8\u66F4"),
|
|
4241
|
-
outputFormat: enumType([
|
|
4242
|
-
'markdown',
|
|
4243
|
-
'json'
|
|
4244
|
-
]).default('markdown').describe("\u8F93\u51FA\u683C\u5F0F")
|
|
4245
|
-
});
|
|
4246
|
-
const changeSummarizer = {
|
|
4247
|
-
name: "\u4EE3\u7801\u53D8\u66F4\u5206\u6790\u667A\u80FD\u4F53",
|
|
4248
|
-
description: "\u5206\u6790\u4EE3\u7801\u5E76\u4E0E\u9700\u6C42\u8FDB\u884C\u5BF9\u6BD4\uFF0C\u786E\u4FDD\u5B9E\u73B0\u5B8C\u6574\u6027",
|
|
4249
|
-
inputSchema: {
|
|
4250
|
-
baseBranch: stringType().default('main').describe("\u57FA\u51C6\u5206\u652F\u540D\u79F0\uFF0C\u7528\u4E8E\u5BF9\u6BD4\u53D8\u66F4"),
|
|
4251
|
-
requirementFile: stringType().optional().describe("\u9700\u6C42\u6587\u6863\u6587\u4EF6\u8DEF\u5F84\uFF08\u53EF\u9009\uFF09"),
|
|
4252
|
-
includeUncommitted: booleanType().default(true).describe("\u662F\u5426\u5305\u542B\u672A\u63D0\u4EA4\u7684\u53D8\u66F4"),
|
|
4253
|
-
outputFormat: enumType([
|
|
4254
|
-
'markdown',
|
|
4255
|
-
'json'
|
|
4256
|
-
]).default('markdown').describe("\u8F93\u51FA\u683C\u5F0F")
|
|
4257
|
-
},
|
|
4258
|
-
handler: async (args)=>{
|
|
4259
|
-
try {
|
|
4260
|
-
initializeProjectRoot();
|
|
4261
|
-
console.log('[CHANGE-SUMMARIZER DEBUG] args:', JSON.stringify(args, null, 2));
|
|
4262
|
-
console.log('[CHANGE-SUMMARIZER DEBUG] args.baseBranch:', args.baseBranch);
|
|
4263
|
-
console.log('[CHANGE-SUMMARIZER DEBUG] args.outputFormat:', args.outputFormat);
|
|
4264
|
-
logger.info({
|
|
4265
|
-
module: 'change-summarizer',
|
|
4266
|
-
message: 'Starting code analysis',
|
|
4267
|
-
args
|
|
4268
|
-
});
|
|
4269
|
-
let requirementContent = '';
|
|
4270
|
-
if (args.requirementFile && external_fs_default().existsSync(args.requirementFile)) requirementContent = external_fs_default().readFileSync(args.requirementFile, 'utf-8');
|
|
4271
|
-
const analysisPrompt = buildAnalysisPrompt(requirementContent);
|
|
4272
|
-
const outputPath = await saveAnalysisResult(analysisPrompt, args.outputFormat);
|
|
4273
|
-
logger.info({
|
|
4274
|
-
module: 'change-summarizer',
|
|
4275
|
-
message: 'Code analysis completed',
|
|
4276
|
-
outputPath
|
|
4277
|
-
});
|
|
4278
|
-
return {
|
|
4279
|
-
content: [
|
|
4280
|
-
{
|
|
4281
|
-
type: "text",
|
|
4282
|
-
text: JSON.stringify({
|
|
4283
|
-
success: true,
|
|
4284
|
-
message: "\u4EE3\u7801\u53D8\u66F4\u5206\u6790\u667A\u80FD\u4F53\u6D4B\u8BD5\u6210\u529F",
|
|
4285
|
-
data: {
|
|
4286
|
-
baseBranch: args.baseBranch || 'main',
|
|
4287
|
-
outputFormat: args.outputFormat || 'markdown'
|
|
4288
|
-
}
|
|
4289
|
-
})
|
|
4290
|
-
}
|
|
4291
|
-
]
|
|
4292
|
-
};
|
|
4293
|
-
} catch (error) {
|
|
4294
|
-
logger.error({
|
|
4295
|
-
module: 'change-summarizer',
|
|
4296
|
-
message: 'Code analysis failed',
|
|
4297
|
-
error: error instanceof Error ? error.message : String(error)
|
|
4298
|
-
});
|
|
4299
|
-
return {
|
|
4300
|
-
content: [
|
|
4301
|
-
{
|
|
4302
|
-
type: "text",
|
|
4303
|
-
text: JSON.stringify({
|
|
4304
|
-
success: false,
|
|
4305
|
-
message: `\u{4EE3}\u{7801}\u{53D8}\u{66F4}\u{5206}\u{6790}\u{667A}\u{80FD}\u{4F53}\u{6267}\u{884C}\u{5931}\u{8D25}: ${error instanceof Error ? error.message : String(error)}`,
|
|
4306
|
-
data: null
|
|
4307
|
-
})
|
|
4308
|
-
}
|
|
4309
|
-
],
|
|
4310
|
-
isError: true
|
|
4311
|
-
};
|
|
4312
|
-
}
|
|
4313
|
-
}
|
|
4314
|
-
};
|
|
4315
|
-
changeSummarizer.handler = changeSummarizer.handler;
|
|
4316
|
-
function buildAnalysisPrompt(requirementContent) {
|
|
4317
|
-
const changesSection = `
|
|
4318
|
-
## \u{4EE3}\u{7801}\u{4E0A}\u{4E0B}\u{6587}\u{5206}\u{6790}
|
|
4319
|
-
|
|
4320
|
-
\u{8BF7}\u{57FA}\u{4E8E}\u{4EE5}\u{4E0B}\u{5185}\u{5BB9}\u{8FDB}\u{884C}\u{5206}\u{6790}\u{FF1A}
|
|
4321
|
-
- \u{5F53}\u{524D}\u{4EE3}\u{7801}\u{5E93}\u{7684}\u{6574}\u{4F53}\u{7ED3}\u{6784}
|
|
4322
|
-
- \u{4E3B}\u{8981}\u{529F}\u{80FD}\u{6A21}\u{5757}\u{7684}\u{5B9E}\u{73B0}
|
|
4323
|
-
- \u{5173}\u{952E}\u{4E1A}\u{52A1}\u{903B}\u{8F91}
|
|
4324
|
-
- \u{63A5}\u{53E3}\u{5B9A}\u{4E49}\u{4E0E}\u{5B9E}\u{73B0}
|
|
4325
|
-
- \u{524D}\u{7AEF}\u{7EC4}\u{4EF6}\u{4E0E}\u{9875}\u{9762}
|
|
4326
|
-
`;
|
|
4327
|
-
const requirementSection = requirementContent ? `
|
|
4328
|
-
## \u{9700}\u{6C42}\u{6587}\u{6863}\u{5185}\u{5BB9}
|
|
4329
|
-
${requirementContent}
|
|
4330
|
-
` : `
|
|
4331
|
-
## \u{9700}\u{6C42}\u{6587}\u{6863}
|
|
4332
|
-
\u{672A}\u{63D0}\u{4F9B}\u{9700}\u{6C42}\u{6587}\u{6863}\u{FF0C}\u{8BF7}\u{57FA}\u{4E8E}\u{4EE3}\u{7801}\u{53D8}\u{66F4}\u{8FDB}\u{884C}\u{5206}\u{6790}\u{3002}
|
|
4333
|
-
`;
|
|
4334
|
-
return `
|
|
4335
|
-
${changeAnalysisPrompt}
|
|
4336
|
-
|
|
4337
|
-
${changesSection}
|
|
4338
|
-
|
|
4339
|
-
${requirementSection}
|
|
4340
|
-
|
|
4341
|
-
\u{8BF7}\u{57FA}\u{4E8E}\u{4EE5}\u{4E0A}\u{4FE1}\u{606F}\u{8FDB}\u{884C}\u{8BE6}\u{7EC6}\u{5206}\u{6790}\u{3002}
|
|
4342
|
-
`;
|
|
4343
|
-
}
|
|
4344
|
-
async function saveAnalysisResult(prompt, format) {
|
|
4345
|
-
const storageDir = getStorageDir();
|
|
4346
|
-
if (!storageDir || 'string' != typeof storageDir) throw new Error("\u5B58\u50A8\u76EE\u5F55\u914D\u7F6E\u9519\u8BEF\uFF0C\u65E0\u6CD5\u4FDD\u5B58\u5206\u6790\u7ED3\u679C");
|
|
4347
|
-
const outputDir = external_path_default().join(storageDir, 'change-analysis');
|
|
4348
|
-
if (!external_fs_default().existsSync(outputDir)) external_fs_default().mkdirSync(outputDir, {
|
|
4349
|
-
recursive: true
|
|
4350
|
-
});
|
|
4351
|
-
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
4352
|
-
const filename = `change-analysis-${timestamp}.${'json' === format ? 'json' : 'md'}`;
|
|
4353
|
-
const outputPath = external_path_default().join(outputDir, filename);
|
|
4354
|
-
if ('json' === format) {
|
|
4355
|
-
const jsonData = {
|
|
4356
|
-
timestamp: new Date().toISOString(),
|
|
4357
|
-
prompt,
|
|
4358
|
-
type: 'change-analysis'
|
|
4359
|
-
};
|
|
4360
|
-
external_fs_default().writeFileSync(outputPath, JSON.stringify(jsonData, null, 2), 'utf-8');
|
|
4361
|
-
} else external_fs_default().writeFileSync(outputPath, prompt, 'utf-8');
|
|
4362
|
-
return outputPath;
|
|
4363
|
-
}
|
|
4364
|
-
const external_sharp_namespaceObject = require("sharp");
|
|
4365
|
-
var external_sharp_default = /*#__PURE__*/ __webpack_require__.n(external_sharp_namespaceObject);
|
|
4184
|
+
require("aico-pack");
|
|
4366
4185
|
class OpenAIService {
|
|
4367
4186
|
qwenConfig = {
|
|
4368
4187
|
apiKey: 'sk-95b0bc60b7464bbbafd64edc2f5bab14',
|
|
@@ -4683,7 +4502,266 @@ ${requirementSection}
|
|
|
4683
4502
|
}
|
|
4684
4503
|
}
|
|
4685
4504
|
}
|
|
4686
|
-
const
|
|
4505
|
+
const openai_openAIService = new OpenAIService();
|
|
4506
|
+
objectType({
|
|
4507
|
+
input_type: enumType([
|
|
4508
|
+
"text",
|
|
4509
|
+
"md_file"
|
|
4510
|
+
]).describe("\u8F93\u5165\u7C7B\u578B\uFF1A\u76F4\u63A5\u6587\u672C\u8F93\u5165\u6216\u5F15\u7528\u5DF2\u751F\u6210\u7684MD\u6587\u4EF6"),
|
|
4511
|
+
content: stringType().optional().describe("\u5F53input_type\u4E3Atext\u65F6\uFF0C\u76F4\u63A5\u8F93\u5165\u7684\u9700\u6C42\u5185\u5BB9"),
|
|
4512
|
+
md_file_path: stringType().optional().describe("\u5F53input_type\u4E3Amd_file\u65F6\uFF0C\u8981\u5206\u6790\u7684MD\u6587\u4EF6\u8DEF\u5F84"),
|
|
4513
|
+
feature_name: stringType().describe("\u529F\u80FD\u540D\u79F0\uFF0C\u7528\u4E8E\u751F\u6210\u8F93\u51FA\u6587\u4EF6\u540D"),
|
|
4514
|
+
custom_prompt: stringType().optional().describe("\u81EA\u5B9A\u4E49\u63D0\u793A\u8BCD\uFF0C\u7528\u4E8E\u6307\u5BFCAI\u751F\u6210\u7279\u5B9A\u98CE\u683C\u7684\u9700\u6C42\u6587\u6863"),
|
|
4515
|
+
analysis_depth: enumType([
|
|
4516
|
+
"basic",
|
|
4517
|
+
"detailed",
|
|
4518
|
+
"comprehensive"
|
|
4519
|
+
]).default("detailed").describe("\u5206\u6790\u6DF1\u5EA6\uFF1A\u57FA\u7840\u3001\u8BE6\u7EC6\u3001\u7EFC\u5408"),
|
|
4520
|
+
use_streaming: booleanType().default(false).describe("\u662F\u5426\u4F7F\u7528\u6D41\u5F0F\u5904\u7406\uFF08\u9002\u7528\u4E8E\u5927\u6587\u4EF6\uFF09"),
|
|
4521
|
+
chunk_size: numberType().min(10).max(1000).default(100).describe("\u5206\u5757\u5927\u5C0F\uFF08\u4EC5\u5728use_streaming\u4E3Atrue\u65F6\u6709\u6548\uFF09")
|
|
4522
|
+
}).refine((data)=>{
|
|
4523
|
+
if ("text" === data.input_type) return data.content && data.content.trim().length > 0;
|
|
4524
|
+
if ("md_file" === data.input_type) return data.md_file_path && data.md_file_path.trim().length > 0;
|
|
4525
|
+
return false;
|
|
4526
|
+
}, {
|
|
4527
|
+
message: "\u5F53input_type\u4E3Atext\u65F6content\u5FC5\u586B\uFF0C\u5F53input_type\u4E3Amd_file\u65F6md_file_path\u5FC5\u586B"
|
|
4528
|
+
});
|
|
4529
|
+
const requirementAnalyzerTool = {
|
|
4530
|
+
name: "\u9700\u6C42\u62A5\u544A\u751F\u6210\u667A\u80FD\u4F53",
|
|
4531
|
+
description: "\u667A\u80FD\u5206\u6790\u9700\u6C42\u5E76\u751F\u6210\u7EDF\u4E00\u7684\u6280\u672F\u6587\u6863\uFF0C\u652F\u6301\u9879\u76EE\u60C5\u51B5\u611F\u77E5\u548C\u7CBE\u786E\u6A21\u677F\u5339\u914D",
|
|
4532
|
+
inputSchema: {
|
|
4533
|
+
input_type: enumType([
|
|
4534
|
+
"text",
|
|
4535
|
+
"md_file"
|
|
4536
|
+
]).describe("\u8F93\u5165\u7C7B\u578B\uFF1A\u76F4\u63A5\u6587\u672C\u8F93\u5165\u6216\u5F15\u7528\u5DF2\u751F\u6210\u7684MD\u6587\u4EF6"),
|
|
4537
|
+
content: stringType().optional().describe("\u5F53input_type\u4E3Atext\u65F6\uFF0C\u76F4\u63A5\u8F93\u5165\u7684\u9700\u6C42\u5185\u5BB9"),
|
|
4538
|
+
md_file_path: stringType().optional().describe("\u5F53input_type\u4E3Amd_file\u65F6\uFF0C\u8981\u5206\u6790\u7684MD\u6587\u4EF6\u8DEF\u5F84"),
|
|
4539
|
+
feature_name: stringType().describe("\u529F\u80FD\u540D\u79F0\uFF0C\u7528\u4E8E\u751F\u6210\u8F93\u51FA\u6587\u4EF6\u540D"),
|
|
4540
|
+
custom_prompt: stringType().optional().describe("\u81EA\u5B9A\u4E49\u63D0\u793A\u8BCD\uFF0C\u7528\u4E8E\u6307\u5BFCAI\u751F\u6210\u7279\u5B9A\u98CE\u683C\u7684\u9700\u6C42\u6587\u6863"),
|
|
4541
|
+
analysis_depth: enumType([
|
|
4542
|
+
"basic",
|
|
4543
|
+
"detailed",
|
|
4544
|
+
"comprehensive"
|
|
4545
|
+
]).default("detailed").describe("\u5206\u6790\u6DF1\u5EA6\uFF1A\u57FA\u7840\u3001\u8BE6\u7EC6\u3001\u7EFC\u5408"),
|
|
4546
|
+
use_streaming: booleanType().default(false).describe("\u662F\u5426\u4F7F\u7528\u6D41\u5F0F\u5904\u7406\uFF08\u9002\u7528\u4E8E\u5927\u6587\u4EF6\uFF09"),
|
|
4547
|
+
chunk_size: numberType().min(10).max(1000).default(100).describe("\u5206\u5757\u5927\u5C0F\uFF08\u4EC5\u5728use_streaming\u4E3Atrue\u65F6\u6709\u6548\uFF09")
|
|
4548
|
+
},
|
|
4549
|
+
handler: async (args)=>{
|
|
4550
|
+
try {
|
|
4551
|
+
return {
|
|
4552
|
+
content: [
|
|
4553
|
+
{
|
|
4554
|
+
type: "text",
|
|
4555
|
+
text: JSON.stringify({
|
|
4556
|
+
success: true,
|
|
4557
|
+
message: "\u9700\u6C42\u5206\u6790\u667A\u80FD\u4F53\u6D4B\u8BD5\u6210\u529F",
|
|
4558
|
+
data: {
|
|
4559
|
+
input_type: args.input_type,
|
|
4560
|
+
feature_name: args.feature_name
|
|
4561
|
+
}
|
|
4562
|
+
})
|
|
4563
|
+
}
|
|
4564
|
+
]
|
|
4565
|
+
};
|
|
4566
|
+
} catch (error) {
|
|
4567
|
+
return {
|
|
4568
|
+
content: [
|
|
4569
|
+
{
|
|
4570
|
+
type: "text",
|
|
4571
|
+
text: JSON.stringify({
|
|
4572
|
+
success: false,
|
|
4573
|
+
message: `\u{9700}\u{6C42}\u{5206}\u{6790}\u{667A}\u{80FD}\u{4F53}\u{6267}\u{884C}\u{5931}\u{8D25}: ${error.message}`,
|
|
4574
|
+
data: null
|
|
4575
|
+
})
|
|
4576
|
+
}
|
|
4577
|
+
],
|
|
4578
|
+
isError: true
|
|
4579
|
+
};
|
|
4580
|
+
}
|
|
4581
|
+
}
|
|
4582
|
+
};
|
|
4583
|
+
const changeAnalysisPrompt = `\u{8BF7}\u{5206}\u{6790}\u{5F53}\u{524D}\u{4EE3}\u{7801}\u{5E93}\u{FF0C}\u{5E76}\u{4E0E}\u{9700}\u{6C42}\u{8FDB}\u{884C}\u{5BF9}\u{6BD4}\u{FF0C}\u{786E}\u{4FDD}\u{5B9E}\u{73B0}\u{7684}\u{5B8C}\u{6574}\u{6027}\u{3002}
|
|
4584
|
+
|
|
4585
|
+
\u{8BF7}\u{6309}\u{4EE5}\u{4E0B}\u{6B65}\u{9AA4}\u{8FDB}\u{884C}\u{5206}\u{6790}\u{FF1A}
|
|
4586
|
+
|
|
4587
|
+
## 1. \u{4EE3}\u{7801}\u{5E93}\u{5206}\u{6790}
|
|
4588
|
+
\u{5206}\u{6790}\u{5F53}\u{524D}\u{4EE3}\u{7801}\u{5E93}\u{FF0C}\u{603B}\u{7ED3}\u{FF1A}
|
|
4589
|
+
- \u{4E3B}\u{8981}\u{529F}\u{80FD}\u{6A21}\u{5757}\u{53CA}\u{5176}\u{5B9E}\u{73B0}
|
|
4590
|
+
- \u{5173}\u{952E}\u{4E1A}\u{52A1}\u{903B}\u{8F91}\u{6D41}\u{7A0B}
|
|
4591
|
+
- \u{91CD}\u{8981}\u{6570}\u{636E}\u{7ED3}\u{6784}
|
|
4592
|
+
- \u{6838}\u{5FC3}\u{7B97}\u{6CD5}\u{5B9E}\u{73B0}
|
|
4593
|
+
|
|
4594
|
+
## 2. \u{63A5}\u{53E3}\u{4E0E}\u{9700}\u{6C42}\u{5BF9}\u{5E94}\u{5173}\u{7CFB}\u{8868}
|
|
4595
|
+
\u{6839}\u{636E}\u{4EE3}\u{7801}\u{53D8}\u{66F4}\u{FF0C}\u{751F}\u{6210}\u{63A5}\u{53E3}\u{4E0E}\u{9700}\u{6C42}\u{5BF9}\u{5E94}\u{5173}\u{7CFB}\u{8868}\u{FF1A}
|
|
4596
|
+
|
|
4597
|
+
| \u{9700}\u{6C42}\u{529F}\u{80FD} | \u{5B9E}\u{73B0}\u{63A5}\u{53E3} | \u{8BF7}\u{6C42}\u{65B9}\u{5F0F} | URL | \u{53D8}\u{66F4}\u{72B6}\u{6001} |
|
|
4598
|
+
|---------|---------|---------|-----|----------|
|
|
4599
|
+
| [\u{9700}\u{6C42}\u{529F}\u{80FD}\u{63CF}\u{8FF0}] | [Controller.method] | [GET/POST/PUT/DELETE] | [/api/path] | [\u{65B0}\u{589E}/\u{4FEE}\u{6539}/\u{5220}\u{9664}] |
|
|
4600
|
+
|
|
4601
|
+
## 3. \u{6838}\u{5FC3}\u{903B}\u{8F91}\u{65B9}\u{6CD5}\u{8868}
|
|
4602
|
+
\u{5206}\u{6790}\u{6838}\u{5FC3}\u{4E1A}\u{52A1}\u{903B}\u{8F91}\u{65B9}\u{6CD5}\u{FF1A}
|
|
4603
|
+
|
|
4604
|
+
| \u{65B9}\u{6CD5}\u{540D}\u{79F0} | \u{6240}\u{5C5E}\u{7C7B} | \u{529F}\u{80FD}\u{8BF4}\u{660E} | \u{53D8}\u{66F4}\u{72B6}\u{6001} |
|
|
4605
|
+
|---------|-------|---------|----------|
|
|
4606
|
+
| [methodName] | [ClassName] | [\u{529F}\u{80FD}\u{63CF}\u{8FF0}] | [\u{65B0}\u{589E}/\u{4FEE}\u{6539}/\u{5220}\u{9664}] |
|
|
4607
|
+
|
|
4608
|
+
## 4. \u{524D}\u{7AEF}\u{9875}\u{9762}\u{4E0E}\u{63A5}\u{53E3}\u{5BF9}\u{5E94}\u{5173}\u{7CFB}\u{8868}
|
|
4609
|
+
\u{5206}\u{6790}\u{524D}\u{7AEF}\u{9875}\u{9762}\u{53D8}\u{66F4}\u{FF1A}
|
|
4610
|
+
|
|
4611
|
+
| \u{9875}\u{9762}\u{540D}\u{79F0} | \u{8C03}\u{7528}\u{63A5}\u{53E3} | \u{7EC4}\u{4EF6}\u{540D}\u{79F0} | \u{8DEF}\u{7531}\u{8DEF}\u{5F84} | \u{53D8}\u{66F4}\u{72B6}\u{6001} |
|
|
4612
|
+
|---------|---------|---------|---------|----------|
|
|
4613
|
+
| [\u{9875}\u{9762}\u{540D}\u{79F0}] | [Controller.method] | [ComponentName] | [/path] | [\u{65B0}\u{589E}/\u{4FEE}\u{6539}/\u{5220}\u{9664}] |
|
|
4614
|
+
|
|
4615
|
+
## 5. \u{524D}\u{7AEF}\u{6838}\u{5FC3}\u{7EC4}\u{4EF6}\u{8868}
|
|
4616
|
+
\u{5206}\u{6790}\u{524D}\u{7AEF}\u{7EC4}\u{4EF6}\u{53D8}\u{66F4}\u{FF1A}
|
|
4617
|
+
|
|
4618
|
+
| \u{7EC4}\u{4EF6}\u{540D}\u{79F0} | \u{6240}\u{5C5E}\u{9875}\u{9762} | \u{529F}\u{80FD}\u{8BF4}\u{660E} | \u{53D8}\u{66F4}\u{72B6}\u{6001} |
|
|
4619
|
+
|---------|---------|---------|----------|
|
|
4620
|
+
| [ComponentName] | [PageName] | [\u{529F}\u{80FD}\u{63CF}\u{8FF0}] | [\u{65B0}\u{589E}/\u{4FEE}\u{6539}/\u{5220}\u{9664}] |
|
|
4621
|
+
|
|
4622
|
+
## 6. \u{9700}\u{6C42}\u{5B8C}\u{6574}\u{6027}\u{68C0}\u{67E5}
|
|
4623
|
+
\u{5BF9}\u{6BD4}\u{539F}\u{59CB}\u{9700}\u{6C42}\u{FF0C}\u{68C0}\u{67E5}\u{FF1A}
|
|
4624
|
+
- \u{2705} \u{5DF2}\u{5B8C}\u{6210}\u{7684}\u{529F}\u{80FD}
|
|
4625
|
+
- \u{26A0}\u{FE0F} \u{90E8}\u{5206}\u{5B8C}\u{6210}\u{7684}\u{529F}\u{80FD}
|
|
4626
|
+
- \u{274C} \u{672A}\u{5B9E}\u{73B0}\u{7684}\u{529F}\u{80FD}
|
|
4627
|
+
- \u{1F504} \u{9700}\u{8981}\u{8FDB}\u{4E00}\u{6B65}\u{5B8C}\u{5584}\u{7684}\u{529F}\u{80FD}
|
|
4628
|
+
|
|
4629
|
+
## 7. \u{5EFA}\u{8BAE}\u{4E0E}\u{603B}\u{7ED3}
|
|
4630
|
+
- \u{5B9E}\u{73B0}\u{8D28}\u{91CF}\u{8BC4}\u{4F30}
|
|
4631
|
+
- \u{6F5C}\u{5728}\u{95EE}\u{9898}\u{8BC6}\u{522B}
|
|
4632
|
+
- \u{540E}\u{7EED}\u{5F00}\u{53D1}\u{5EFA}\u{8BAE}
|
|
4633
|
+
- \u{6D4B}\u{8BD5}\u{5EFA}\u{8BAE}
|
|
4634
|
+
|
|
4635
|
+
\u{8BF7}\u{786E}\u{4FDD}\u{6240}\u{6709}\u{8868}\u{683C}\u{4E0A}\u{4E0B}\u{5BF9}\u{9F50}\u{FF0C}\u{5185}\u{5BB9}\u{8BE6}\u{5B9E}\u{51C6}\u{786E}\u{3002}`;
|
|
4636
|
+
objectType({
|
|
4637
|
+
baseBranch: stringType().default('main').describe("\u57FA\u51C6\u5206\u652F\u540D\u79F0\uFF0C\u7528\u4E8E\u5BF9\u6BD4\u53D8\u66F4"),
|
|
4638
|
+
requirementFile: stringType().optional().describe("\u9700\u6C42\u6587\u6863\u6587\u4EF6\u8DEF\u5F84\uFF08\u53EF\u9009\uFF09"),
|
|
4639
|
+
includeUncommitted: booleanType().default(true).describe("\u662F\u5426\u5305\u542B\u672A\u63D0\u4EA4\u7684\u53D8\u66F4"),
|
|
4640
|
+
outputFormat: enumType([
|
|
4641
|
+
'markdown',
|
|
4642
|
+
'json'
|
|
4643
|
+
]).default('markdown').describe("\u8F93\u51FA\u683C\u5F0F")
|
|
4644
|
+
});
|
|
4645
|
+
const changeSummarizer = {
|
|
4646
|
+
name: "\u4EE3\u7801\u53D8\u66F4\u5206\u6790\u667A\u80FD\u4F53",
|
|
4647
|
+
description: "\u5206\u6790\u4EE3\u7801\u5E76\u4E0E\u9700\u6C42\u8FDB\u884C\u5BF9\u6BD4\uFF0C\u786E\u4FDD\u5B9E\u73B0\u5B8C\u6574\u6027",
|
|
4648
|
+
inputSchema: {
|
|
4649
|
+
baseBranch: stringType().default('main').describe("\u57FA\u51C6\u5206\u652F\u540D\u79F0\uFF0C\u7528\u4E8E\u5BF9\u6BD4\u53D8\u66F4"),
|
|
4650
|
+
requirementFile: stringType().optional().describe("\u9700\u6C42\u6587\u6863\u6587\u4EF6\u8DEF\u5F84\uFF08\u53EF\u9009\uFF09"),
|
|
4651
|
+
includeUncommitted: booleanType().default(true).describe("\u662F\u5426\u5305\u542B\u672A\u63D0\u4EA4\u7684\u53D8\u66F4"),
|
|
4652
|
+
outputFormat: enumType([
|
|
4653
|
+
'markdown',
|
|
4654
|
+
'json'
|
|
4655
|
+
]).default('markdown').describe("\u8F93\u51FA\u683C\u5F0F")
|
|
4656
|
+
},
|
|
4657
|
+
handler: async (args)=>{
|
|
4658
|
+
try {
|
|
4659
|
+
initializeProjectRoot();
|
|
4660
|
+
console.log('[CHANGE-SUMMARIZER DEBUG] args:', JSON.stringify(args, null, 2));
|
|
4661
|
+
console.log('[CHANGE-SUMMARIZER DEBUG] args.baseBranch:', args.baseBranch);
|
|
4662
|
+
console.log('[CHANGE-SUMMARIZER DEBUG] args.outputFormat:', args.outputFormat);
|
|
4663
|
+
logger_logger.info({
|
|
4664
|
+
module: 'change-summarizer',
|
|
4665
|
+
message: 'Starting code analysis',
|
|
4666
|
+
args
|
|
4667
|
+
});
|
|
4668
|
+
let requirementContent = '';
|
|
4669
|
+
if (args.requirementFile && external_fs_default().existsSync(args.requirementFile)) requirementContent = external_fs_default().readFileSync(args.requirementFile, 'utf-8');
|
|
4670
|
+
const analysisPrompt = buildAnalysisPrompt(requirementContent);
|
|
4671
|
+
const outputPath = await saveAnalysisResult(analysisPrompt, args.outputFormat);
|
|
4672
|
+
logger_logger.info({
|
|
4673
|
+
module: 'change-summarizer',
|
|
4674
|
+
message: 'Code analysis completed',
|
|
4675
|
+
outputPath
|
|
4676
|
+
});
|
|
4677
|
+
return {
|
|
4678
|
+
content: [
|
|
4679
|
+
{
|
|
4680
|
+
type: "text",
|
|
4681
|
+
text: JSON.stringify({
|
|
4682
|
+
success: true,
|
|
4683
|
+
message: "\u4EE3\u7801\u53D8\u66F4\u5206\u6790\u667A\u80FD\u4F53\u6D4B\u8BD5\u6210\u529F",
|
|
4684
|
+
data: {
|
|
4685
|
+
baseBranch: args.baseBranch || 'main',
|
|
4686
|
+
outputFormat: args.outputFormat || 'markdown'
|
|
4687
|
+
}
|
|
4688
|
+
})
|
|
4689
|
+
}
|
|
4690
|
+
]
|
|
4691
|
+
};
|
|
4692
|
+
} catch (error) {
|
|
4693
|
+
logger_logger.error({
|
|
4694
|
+
module: 'change-summarizer',
|
|
4695
|
+
message: 'Code analysis failed',
|
|
4696
|
+
error: error instanceof Error ? error.message : String(error)
|
|
4697
|
+
});
|
|
4698
|
+
return {
|
|
4699
|
+
content: [
|
|
4700
|
+
{
|
|
4701
|
+
type: "text",
|
|
4702
|
+
text: JSON.stringify({
|
|
4703
|
+
success: false,
|
|
4704
|
+
message: `\u{4EE3}\u{7801}\u{53D8}\u{66F4}\u{5206}\u{6790}\u{667A}\u{80FD}\u{4F53}\u{6267}\u{884C}\u{5931}\u{8D25}: ${error instanceof Error ? error.message : String(error)}`,
|
|
4705
|
+
data: null
|
|
4706
|
+
})
|
|
4707
|
+
}
|
|
4708
|
+
],
|
|
4709
|
+
isError: true
|
|
4710
|
+
};
|
|
4711
|
+
}
|
|
4712
|
+
}
|
|
4713
|
+
};
|
|
4714
|
+
changeSummarizer.handler = changeSummarizer.handler;
|
|
4715
|
+
function buildAnalysisPrompt(requirementContent) {
|
|
4716
|
+
const changesSection = `
|
|
4717
|
+
## \u{4EE3}\u{7801}\u{4E0A}\u{4E0B}\u{6587}\u{5206}\u{6790}
|
|
4718
|
+
|
|
4719
|
+
\u{8BF7}\u{57FA}\u{4E8E}\u{4EE5}\u{4E0B}\u{5185}\u{5BB9}\u{8FDB}\u{884C}\u{5206}\u{6790}\u{FF1A}
|
|
4720
|
+
- \u{5F53}\u{524D}\u{4EE3}\u{7801}\u{5E93}\u{7684}\u{6574}\u{4F53}\u{7ED3}\u{6784}
|
|
4721
|
+
- \u{4E3B}\u{8981}\u{529F}\u{80FD}\u{6A21}\u{5757}\u{7684}\u{5B9E}\u{73B0}
|
|
4722
|
+
- \u{5173}\u{952E}\u{4E1A}\u{52A1}\u{903B}\u{8F91}
|
|
4723
|
+
- \u{63A5}\u{53E3}\u{5B9A}\u{4E49}\u{4E0E}\u{5B9E}\u{73B0}
|
|
4724
|
+
- \u{524D}\u{7AEF}\u{7EC4}\u{4EF6}\u{4E0E}\u{9875}\u{9762}
|
|
4725
|
+
`;
|
|
4726
|
+
const requirementSection = requirementContent ? `
|
|
4727
|
+
## \u{9700}\u{6C42}\u{6587}\u{6863}\u{5185}\u{5BB9}
|
|
4728
|
+
${requirementContent}
|
|
4729
|
+
` : `
|
|
4730
|
+
## \u{9700}\u{6C42}\u{6587}\u{6863}
|
|
4731
|
+
\u{672A}\u{63D0}\u{4F9B}\u{9700}\u{6C42}\u{6587}\u{6863}\u{FF0C}\u{8BF7}\u{57FA}\u{4E8E}\u{4EE3}\u{7801}\u{53D8}\u{66F4}\u{8FDB}\u{884C}\u{5206}\u{6790}\u{3002}
|
|
4732
|
+
`;
|
|
4733
|
+
return `
|
|
4734
|
+
${changeAnalysisPrompt}
|
|
4735
|
+
|
|
4736
|
+
${changesSection}
|
|
4737
|
+
|
|
4738
|
+
${requirementSection}
|
|
4739
|
+
|
|
4740
|
+
\u{8BF7}\u{57FA}\u{4E8E}\u{4EE5}\u{4E0A}\u{4FE1}\u{606F}\u{8FDB}\u{884C}\u{8BE6}\u{7EC6}\u{5206}\u{6790}\u{3002}
|
|
4741
|
+
`;
|
|
4742
|
+
}
|
|
4743
|
+
async function saveAnalysisResult(prompt, format) {
|
|
4744
|
+
const storageDir = config_getStorageDir();
|
|
4745
|
+
if (!storageDir || 'string' != typeof storageDir) throw new Error("\u5B58\u50A8\u76EE\u5F55\u914D\u7F6E\u9519\u8BEF\uFF0C\u65E0\u6CD5\u4FDD\u5B58\u5206\u6790\u7ED3\u679C");
|
|
4746
|
+
const outputDir = external_path_default().join(storageDir, 'change-analysis');
|
|
4747
|
+
if (!external_fs_default().existsSync(outputDir)) external_fs_default().mkdirSync(outputDir, {
|
|
4748
|
+
recursive: true
|
|
4749
|
+
});
|
|
4750
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
4751
|
+
const filename = `change-analysis-${timestamp}.${'json' === format ? 'json' : 'md'}`;
|
|
4752
|
+
const outputPath = external_path_default().join(outputDir, filename);
|
|
4753
|
+
if ('json' === format) {
|
|
4754
|
+
const jsonData = {
|
|
4755
|
+
timestamp: new Date().toISOString(),
|
|
4756
|
+
prompt,
|
|
4757
|
+
type: 'change-analysis'
|
|
4758
|
+
};
|
|
4759
|
+
external_fs_default().writeFileSync(outputPath, JSON.stringify(jsonData, null, 2), 'utf-8');
|
|
4760
|
+
} else external_fs_default().writeFileSync(outputPath, prompt, 'utf-8');
|
|
4761
|
+
return outputPath;
|
|
4762
|
+
}
|
|
4763
|
+
const external_sharp_namespaceObject = require("sharp");
|
|
4764
|
+
var external_sharp_default = /*#__PURE__*/ __webpack_require__.n(external_sharp_namespaceObject);
|
|
4687
4765
|
async function invokeFlow(params, streamCb) {
|
|
4688
4766
|
const { appid = 'app-ESTcrkOPOmkxdrO0120mE4s1', data, timeout = 1800000 } = params;
|
|
4689
4767
|
const controller = new AbortController();
|
|
@@ -4880,24 +4958,6 @@ ${requirementSection}
|
|
|
4880
4958
|
throw new Error("\u6587\u4EF6\u4E0A\u4F20\u5931\u8D25: \u672A\u77E5\u9519\u8BEF");
|
|
4881
4959
|
}
|
|
4882
4960
|
}
|
|
4883
|
-
var types_AnalysisType = /*#__PURE__*/ function(AnalysisType) {
|
|
4884
|
-
AnalysisType["GENERAL"] = "general";
|
|
4885
|
-
AnalysisType["OBJECTS"] = "objects";
|
|
4886
|
-
AnalysisType["TEXT"] = "text";
|
|
4887
|
-
AnalysisType["SCENE"] = "scene";
|
|
4888
|
-
AnalysisType["PEOPLE"] = "people";
|
|
4889
|
-
AnalysisType["TECHNICAL"] = "technical";
|
|
4890
|
-
AnalysisType["UI_DESIGN"] = "ui_design";
|
|
4891
|
-
AnalysisType["REQUIREMENT"] = "requirement";
|
|
4892
|
-
AnalysisType["CUSTOM"] = "custom";
|
|
4893
|
-
return AnalysisType;
|
|
4894
|
-
}({});
|
|
4895
|
-
var types_DetailLevel = /*#__PURE__*/ function(DetailLevel) {
|
|
4896
|
-
DetailLevel["BRIEF"] = "brief";
|
|
4897
|
-
DetailLevel["DETAILED"] = "detailed";
|
|
4898
|
-
DetailLevel["COMPREHENSIVE"] = "comprehensive";
|
|
4899
|
-
return DetailLevel;
|
|
4900
|
-
}({});
|
|
4901
4961
|
class ImageAnalysisError extends Error {
|
|
4902
4962
|
code;
|
|
4903
4963
|
context;
|
|
@@ -4913,7 +4973,6 @@ ${requirementSection}
|
|
|
4913
4973
|
AnalysisErrorCodes["IMAGE_CORRUPTED"] = "IMAGE_CORRUPTED";
|
|
4914
4974
|
AnalysisErrorCodes["ANALYSIS_FAILED"] = "ANALYSIS_FAILED";
|
|
4915
4975
|
AnalysisErrorCodes["AI_SERVICE_ERROR"] = "AI_SERVICE_ERROR";
|
|
4916
|
-
AnalysisErrorCodes["INVALID_ANALYSIS_TYPE"] = "INVALID_ANALYSIS_TYPE";
|
|
4917
4976
|
return AnalysisErrorCodes;
|
|
4918
4977
|
}({});
|
|
4919
4978
|
const SUPPORTED_IMAGE_FORMATS = [
|
|
@@ -4930,7 +4989,7 @@ ${requirementSection}
|
|
|
4930
4989
|
async analyzeImage(imagePath, context) {
|
|
4931
4990
|
const startTime = Date.now();
|
|
4932
4991
|
try {
|
|
4933
|
-
|
|
4992
|
+
logger_logger.info("\u5F00\u59CB\u56FE\u7247\u5185\u5BB9\u5206\u6790", {
|
|
4934
4993
|
imagePath: imagePath
|
|
4935
4994
|
});
|
|
4936
4995
|
await this.validateParams(imagePath);
|
|
@@ -4944,20 +5003,16 @@ ${requirementSection}
|
|
|
4944
5003
|
});
|
|
4945
5004
|
const result = {
|
|
4946
5005
|
basic_info: basicInfo,
|
|
4947
|
-
analysis_type: types_AnalysisType.GENERAL,
|
|
4948
|
-
detail_level: types_DetailLevel.DETAILED,
|
|
4949
5006
|
content: analysisContent,
|
|
4950
|
-
processing_time_ms: processingTime
|
|
4951
|
-
confidence_score: this.calculateConfidenceScore(analysisContent)
|
|
5007
|
+
processing_time_ms: processingTime
|
|
4952
5008
|
};
|
|
4953
|
-
|
|
5009
|
+
logger_logger.info("\u56FE\u7247\u5185\u5BB9\u5206\u6790\u5B8C\u6210", {
|
|
4954
5010
|
imagePath: imagePath,
|
|
4955
|
-
processingTimeMs: processingTime
|
|
4956
|
-
confidenceScore: result.confidence_score
|
|
5011
|
+
processingTimeMs: processingTime
|
|
4957
5012
|
});
|
|
4958
5013
|
return result;
|
|
4959
5014
|
} catch (error) {
|
|
4960
|
-
|
|
5015
|
+
logger_logger.error("\u56FE\u7247\u5185\u5BB9\u5206\u6790\u5931\u8D25", {
|
|
4961
5016
|
error,
|
|
4962
5017
|
params: {
|
|
4963
5018
|
image_path: imagePath
|
|
@@ -4970,7 +5025,7 @@ ${requirementSection}
|
|
|
4970
5025
|
try {
|
|
4971
5026
|
const imageBase64 = await this.imageToBase64(imagePath);
|
|
4972
5027
|
const prompt = this.buildAnalysisPrompt(imagePath, basicInfo, context);
|
|
4973
|
-
const aiResponse = await
|
|
5028
|
+
const aiResponse = await openai_openAIService.analyzeImage({
|
|
4974
5029
|
image_base64: imageBase64,
|
|
4975
5030
|
prompt: prompt,
|
|
4976
5031
|
system_prompt: "\u4F60\u662F\u4E00\u4E2A\u4E13\u4E1A\u7684\u56FE\u7247\u5206\u6790\u4E13\u5BB6\uFF0C\u8BF7\u4E25\u683C\u57FA\u4E8E\u4EFB\u52A1\u6307\u4EE4\u5206\u6790\u56FE\u7247\u5185\u5BB9\uFF0C\u4E0D\u504F\u79BB\u4EFB\u52A1\u8303\u56F4\uFF0C\u4E0D\u6DFB\u52A0\u65E0\u5173\u4FE1\u606F\u3002"
|
|
@@ -4978,13 +5033,26 @@ ${requirementSection}
|
|
|
4978
5033
|
const analysisContent = this.parseAIResponse(aiResponse);
|
|
4979
5034
|
return analysisContent;
|
|
4980
5035
|
} catch (error) {
|
|
4981
|
-
|
|
5036
|
+
logger_logger.warn("\u4E3BAI\u5206\u6790\u5931\u8D25\uFF0C\u5C1D\u8BD5Dify\u515C\u5E95\u5206\u6790", {
|
|
4982
5037
|
error,
|
|
4983
5038
|
params: {
|
|
4984
5039
|
image_path: imagePath
|
|
4985
5040
|
}
|
|
4986
5041
|
});
|
|
4987
|
-
|
|
5042
|
+
try {
|
|
5043
|
+
return await this.fallbackToDifyAnalysis(imagePath, context);
|
|
5044
|
+
} catch (fallbackError) {
|
|
5045
|
+
logger_logger.error("Dify\u515C\u5E95\u5206\u6790\u4E5F\u5931\u8D25", {
|
|
5046
|
+
error: fallbackError,
|
|
5047
|
+
params: {
|
|
5048
|
+
image_path: imagePath
|
|
5049
|
+
}
|
|
5050
|
+
});
|
|
5051
|
+
throw new ImageAnalysisError("\u8BC6\u522B\u56FE\u7247\u5931\u8D25", types_AnalysisErrorCodes.ANALYSIS_FAILED, {
|
|
5052
|
+
originalError: error,
|
|
5053
|
+
fallbackError
|
|
5054
|
+
});
|
|
5055
|
+
}
|
|
4988
5056
|
}
|
|
4989
5057
|
}
|
|
4990
5058
|
buildAnalysisPrompt(imagePath, basicInfo, context) {
|
|
@@ -4998,48 +5066,18 @@ ${requirementSection}
|
|
|
4998
5066
|
const contextPrompt = context ? `
|
|
4999
5067
|
|
|
5000
5068
|
## \u{5206}\u{6790}\u{6307}\u{4EE4}
|
|
5001
|
-
${context}
|
|
5002
|
-
|
|
5003
|
-
\u{8BF7}\u{4E25}\u{683C}\u{6839}\u{636E}\u{4EE5}\u{4E0A}\u{6307}\u{4EE4}\u{8FDB}\u{884C}\u{56FE}\u{7247}\u{5206}\u{6790}\u{FF0C}\u{4E0D}\u{504F}\u{79BB}\u{4EFB}\u{52A1}\u{8303}\u{56F4}\u{FF0C}\u{4E0D}\u{6DFB}\u{52A0}\u{65E0}\u{5173}\u{4FE1}\u{606F}\u{3002}` : '';
|
|
5004
|
-
const strictPrompt = `
|
|
5005
|
-
|
|
5006
|
-
## \u{5206}\u{6790}\u{8981}\u{6C42}
|
|
5007
|
-
\u{4F60}\u{5FC5}\u{987B}\u{4E25}\u{683C}\u{6839}\u{636E}\u{4EFB}\u{52A1}\u{6307}\u{4EE4}\u{5206}\u{6790}\u{56FE}\u{7247}\u{5185}\u{5BB9}\u{FF0C}\u{4E0D}\u{504F}\u{79BB}\u{7528}\u{6237}\u{8981}\u{6C42}\u{7684}\u{8303}\u{56F4}\u{FF0C}\u{4E0D}\u{6DFB}\u{52A0}\u{65E0}\u{5173}\u{4FE1}\u{606F}\u{3002}\u{786E}\u{4FDD}\u{5206}\u{6790}\u{7ED3}\u{679C}\u{6E05}\u{6670}\u{51C6}\u{786E}\u{FF0C}\u{53EA}\u{5305}\u{542B}\u{4E0E}\u{4EFB}\u{52A1}\u{76F8}\u{5173}\u{7684}\u{4FE1}\u{606F}\u{3002}`;
|
|
5008
|
-
return `${basePrompt}${contextPrompt}${strictPrompt}`.trim();
|
|
5069
|
+
${context}` : '';
|
|
5070
|
+
return `${basePrompt}${contextPrompt}`.trim();
|
|
5009
5071
|
}
|
|
5010
5072
|
parseAIResponse(aiResponse) {
|
|
5011
5073
|
if (!aiResponse || 'string' != typeof aiResponse) throw new ImageAnalysisError("AI\u670D\u52A1\u8FD4\u56DE\u65E0\u6548\u54CD\u5E94", types_AnalysisErrorCodes.AI_SERVICE_ERROR, {
|
|
5012
5074
|
aiResponse
|
|
5013
5075
|
});
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
});
|
|
5018
|
-
const cleanedResponse = this.cleanAIResponse(aiResponse);
|
|
5019
|
-
const content = {
|
|
5020
|
-
summary: cleanedResponse,
|
|
5021
|
-
details: {
|
|
5022
|
-
raw_response: aiResponse
|
|
5023
|
-
},
|
|
5076
|
+
return {
|
|
5077
|
+
summary: aiResponse.trim(),
|
|
5078
|
+
details: {},
|
|
5024
5079
|
tags: []
|
|
5025
5080
|
};
|
|
5026
|
-
logger.debug("\u5185\u5BB9\u89E3\u6790\u7ED3\u679C", {
|
|
5027
|
-
summaryLength: content.summary.length
|
|
5028
|
-
});
|
|
5029
|
-
return content;
|
|
5030
|
-
}
|
|
5031
|
-
cleanAIResponse(response) {
|
|
5032
|
-
let cleaned = response.trim();
|
|
5033
|
-
const patternsToRemove = [
|
|
5034
|
-
/^(?:好的|明白了|根据您的要求|根据分析|根据图片内容)[,,::]\s*/i,
|
|
5035
|
-
/(?:以下是|下面是对|分析结果如下|内容如下)[::]\s*/i,
|
|
5036
|
-
/\n(?:总结|结论|综上所述)[::]\s*/i
|
|
5037
|
-
];
|
|
5038
|
-
patternsToRemove.forEach((pattern)=>{
|
|
5039
|
-
cleaned = cleaned.replace(pattern, '');
|
|
5040
|
-
});
|
|
5041
|
-
cleaned = cleaned.replace(/\n{3,}/g, '\n\n').trim();
|
|
5042
|
-
return cleaned;
|
|
5043
5081
|
}
|
|
5044
5082
|
async getImageBasicInfo(imagePath) {
|
|
5045
5083
|
try {
|
|
@@ -5052,9 +5090,7 @@ ${context}
|
|
|
5052
5090
|
width: metadata.width || 0,
|
|
5053
5091
|
height: metadata.height || 0
|
|
5054
5092
|
},
|
|
5055
|
-
file_size: stats.size
|
|
5056
|
-
color_space: metadata.space,
|
|
5057
|
-
has_alpha: metadata.hasAlpha
|
|
5093
|
+
file_size: stats.size
|
|
5058
5094
|
};
|
|
5059
5095
|
} catch (error) {
|
|
5060
5096
|
throw new ImageAnalysisError(`\u{65E0}\u{6CD5}\u{8BFB}\u{53D6}\u{56FE}\u{7247}\u{4FE1}\u{606F}: ${imagePath}`, types_AnalysisErrorCodes.IMAGE_CORRUPTED, {
|
|
@@ -5108,135 +5144,6 @@ ${context}
|
|
|
5108
5144
|
supportedFormats: SUPPORTED_IMAGE_FORMATS
|
|
5109
5145
|
});
|
|
5110
5146
|
}
|
|
5111
|
-
calculateConfidenceScore(content) {
|
|
5112
|
-
let score = 0.5;
|
|
5113
|
-
if (content.summary.length > 100) score += 0.2;
|
|
5114
|
-
if (content.tags && content.tags.length > 0) score += 0.1;
|
|
5115
|
-
if (content.objects && content.objects.length > 0) score += 0.1;
|
|
5116
|
-
if (content.text_content && content.text_content.length > 0) score += 0.1;
|
|
5117
|
-
return Math.min(score, 1.0);
|
|
5118
|
-
}
|
|
5119
|
-
extractValue(text, pattern) {
|
|
5120
|
-
const match = text.match(pattern);
|
|
5121
|
-
return match ? match[1].trim() : null;
|
|
5122
|
-
}
|
|
5123
|
-
extractBoolean(text, pattern) {
|
|
5124
|
-
return pattern.test(text);
|
|
5125
|
-
}
|
|
5126
|
-
extractList(text, pattern) {
|
|
5127
|
-
const match = text.match(pattern);
|
|
5128
|
-
if (match) return match[1].split(/[,,、]/).map((item)=>item.trim()).filter(Boolean);
|
|
5129
|
-
return [];
|
|
5130
|
-
}
|
|
5131
|
-
extractUIComponents(text) {
|
|
5132
|
-
const components = [];
|
|
5133
|
-
const componentPatterns = [
|
|
5134
|
-
/按钮|button/gi,
|
|
5135
|
-
/输入框|input|文本框/gi,
|
|
5136
|
-
/导航|navigation|nav/gi,
|
|
5137
|
-
/卡片|card/gi,
|
|
5138
|
-
/列表|list/gi,
|
|
5139
|
-
/表格|table/gi
|
|
5140
|
-
];
|
|
5141
|
-
componentPatterns.forEach((pattern, index)=>{
|
|
5142
|
-
const matches = text.match(pattern);
|
|
5143
|
-
if (matches) components.push({
|
|
5144
|
-
type: [
|
|
5145
|
-
'button',
|
|
5146
|
-
'input',
|
|
5147
|
-
'navigation',
|
|
5148
|
-
'card',
|
|
5149
|
-
'list',
|
|
5150
|
-
'table'
|
|
5151
|
-
][index],
|
|
5152
|
-
name: matches[0],
|
|
5153
|
-
position: {
|
|
5154
|
-
x: 0,
|
|
5155
|
-
y: 0,
|
|
5156
|
-
width: 0,
|
|
5157
|
-
height: 0
|
|
5158
|
-
},
|
|
5159
|
-
properties: {}
|
|
5160
|
-
});
|
|
5161
|
-
});
|
|
5162
|
-
return components;
|
|
5163
|
-
}
|
|
5164
|
-
extractColorScheme(text) {
|
|
5165
|
-
return {
|
|
5166
|
-
primary_colors: this.extractList(text, /主色调[::]\s*([^\n]+)/i),
|
|
5167
|
-
secondary_colors: this.extractList(text, /辅助色[::]\s*([^\n]+)/i),
|
|
5168
|
-
background_colors: this.extractList(text, /背景色[::]\s*([^\n]+)/i)
|
|
5169
|
-
};
|
|
5170
|
-
}
|
|
5171
|
-
extractTypography(text) {
|
|
5172
|
-
return {
|
|
5173
|
-
fonts: this.extractList(text, /字体[::]\s*([^\n]+)/i),
|
|
5174
|
-
text_hierarchy: this.extractList(text, /文字层次[::]\s*([^\n]+)/i)
|
|
5175
|
-
};
|
|
5176
|
-
}
|
|
5177
|
-
extractNavigation(text) {
|
|
5178
|
-
return {
|
|
5179
|
-
type: this.extractValue(text, /导航类型[::]\s*([^\n]+)/i) || "\u672A\u8BC6\u522B",
|
|
5180
|
-
elements: this.extractList(text, /导航元素[::]\s*([^\n]+)/i)
|
|
5181
|
-
};
|
|
5182
|
-
}
|
|
5183
|
-
extractFunctionalRequirements(text) {
|
|
5184
|
-
const requirements = [];
|
|
5185
|
-
const funcReqPattern = /功能需求[::][\s\S]*?(?=非功能需求|用户故事|$)/i;
|
|
5186
|
-
const match = text.match(funcReqPattern);
|
|
5187
|
-
if (match) {
|
|
5188
|
-
const reqText = match[0];
|
|
5189
|
-
const reqItems = reqText.split(/\d+\./).filter((item)=>item.trim());
|
|
5190
|
-
reqItems.forEach((item, index)=>{
|
|
5191
|
-
if (item.trim()) requirements.push({
|
|
5192
|
-
id: `FR-${index + 1}`,
|
|
5193
|
-
title: item.split('\n')[0].trim(),
|
|
5194
|
-
description: item.trim(),
|
|
5195
|
-
priority: 'medium',
|
|
5196
|
-
category: "\u529F\u80FD\u9700\u6C42",
|
|
5197
|
-
acceptance_criteria: []
|
|
5198
|
-
});
|
|
5199
|
-
});
|
|
5200
|
-
}
|
|
5201
|
-
return requirements;
|
|
5202
|
-
}
|
|
5203
|
-
extractNonFunctionalRequirements(text) {
|
|
5204
|
-
const requirements = [];
|
|
5205
|
-
const nfrTypes = [
|
|
5206
|
-
"\u6027\u80FD",
|
|
5207
|
-
"\u5B89\u5168",
|
|
5208
|
-
"\u53EF\u7528\u6027",
|
|
5209
|
-
"\u53EF\u7EF4\u62A4\u6027",
|
|
5210
|
-
"\u53EF\u6269\u5C55\u6027"
|
|
5211
|
-
];
|
|
5212
|
-
nfrTypes.forEach((type)=>{
|
|
5213
|
-
const pattern = new RegExp(`${type}[\u{FF1A}:]\\s*([^\\n]+)`, 'i');
|
|
5214
|
-
const match = text.match(pattern);
|
|
5215
|
-
if (match) requirements.push({
|
|
5216
|
-
type: type,
|
|
5217
|
-
description: match[1].trim(),
|
|
5218
|
-
metric: '',
|
|
5219
|
-
target_value: ''
|
|
5220
|
-
});
|
|
5221
|
-
});
|
|
5222
|
-
return requirements;
|
|
5223
|
-
}
|
|
5224
|
-
extractUserStories(text) {
|
|
5225
|
-
const stories = [];
|
|
5226
|
-
const storyPattern = /作为.*?我希望.*?以便.*?/g;
|
|
5227
|
-
const matches = text.match(storyPattern);
|
|
5228
|
-
if (matches) matches.forEach((story, index)=>{
|
|
5229
|
-
const parts = story.split(/我希望|以便/);
|
|
5230
|
-
if (parts.length >= 3) stories.push({
|
|
5231
|
-
as_a: parts[0].replace("\u4F5C\u4E3A", '').trim(),
|
|
5232
|
-
i_want: parts[1].trim(),
|
|
5233
|
-
so_that: parts[2].trim(),
|
|
5234
|
-
acceptance_criteria: [],
|
|
5235
|
-
priority: 'medium'
|
|
5236
|
-
});
|
|
5237
|
-
});
|
|
5238
|
-
return stories;
|
|
5239
|
-
}
|
|
5240
5147
|
formatFileSize(bytes) {
|
|
5241
5148
|
if (0 === bytes) return '0 B';
|
|
5242
5149
|
const k = 1024;
|
|
@@ -5250,7 +5157,7 @@ ${context}
|
|
|
5250
5157
|
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${sizes[i]}`;
|
|
5251
5158
|
}
|
|
5252
5159
|
async fallbackToDifyAnalysis(imagePath, context) {
|
|
5253
|
-
|
|
5160
|
+
logger_logger.info("\u5F00\u59CBDify\u515C\u5E95\u56FE\u7247\u5206\u6790", {
|
|
5254
5161
|
imagePath: imagePath,
|
|
5255
5162
|
context: context
|
|
5256
5163
|
});
|
|
@@ -5260,7 +5167,7 @@ ${context}
|
|
|
5260
5167
|
filePath: imagePath,
|
|
5261
5168
|
user: 'aico-mcp'
|
|
5262
5169
|
});
|
|
5263
|
-
|
|
5170
|
+
logger_logger.info("\u6587\u4EF6\u4E0A\u4F20\u6210\u529F\uFF0C\u6587\u4EF6ID:", uploadResult.id);
|
|
5264
5171
|
const workflowData = {
|
|
5265
5172
|
imagePath: {
|
|
5266
5173
|
type: 'image',
|
|
@@ -5273,16 +5180,15 @@ ${context}
|
|
|
5273
5180
|
appid: 'app-AvlLh0nfN4l9oz1MSW4sEAQ6',
|
|
5274
5181
|
data: workflowData
|
|
5275
5182
|
});
|
|
5276
|
-
|
|
5183
|
+
logger_logger.info("Dify\u5DE5\u4F5C\u6D41\u8C03\u7528\u6210\u529F", {
|
|
5277
5184
|
response: workflowResponse
|
|
5278
5185
|
});
|
|
5279
|
-
if (workflowResponse?.status === 'failed') throw new Error(`Dify\u{5DE5}\u{4F5C}\u{6D41}\u{6267}\u{884C}\u{5931}\u{8D25}: ${workflowResponse.error || "\u672A\u77E5\u9519\u8BEF"}`);
|
|
5280
|
-
if (workflowResponse?.status !== 'succeeded') throw new Error(`Dify\u{5DE5}\u{4F5C}\u{6D41}\u{72B6}\u{6001}\u{5F02}\u{5E38}: ${workflowResponse?.status}`);
|
|
5281
5186
|
let summary = "\u5206\u6790\u5B8C\u6210";
|
|
5282
5187
|
if ('string' == typeof workflowResponse) summary = workflowResponse;
|
|
5283
5188
|
else if (workflowResponse?.data?.text) summary = workflowResponse.data.text;
|
|
5284
5189
|
else if (workflowResponse?.answer) summary = workflowResponse.answer;
|
|
5285
5190
|
else if (workflowResponse?.outputs?.text) summary = workflowResponse.outputs.text;
|
|
5191
|
+
else if (workflowResponse?.status === 'failed') throw new Error(`Dify\u{5DE5}\u{4F5C}\u{6D41}\u{6267}\u{884C}\u{5931}\u{8D25}: ${workflowResponse.error || "\u672A\u77E5\u9519\u8BEF"}`);
|
|
5286
5192
|
return {
|
|
5287
5193
|
summary: summary,
|
|
5288
5194
|
details: {
|
|
@@ -5294,7 +5200,7 @@ ${context}
|
|
|
5294
5200
|
]
|
|
5295
5201
|
};
|
|
5296
5202
|
} catch (error) {
|
|
5297
|
-
|
|
5203
|
+
logger_logger.error("Dify\u670D\u52A1\u8C03\u7528\u5931\u8D25", {
|
|
5298
5204
|
error: error instanceof Error ? error.message : String(error),
|
|
5299
5205
|
imagePath: imagePath,
|
|
5300
5206
|
context: context
|
|
@@ -5317,7 +5223,7 @@ ${context}
|
|
|
5317
5223
|
handler: async (args)=>{
|
|
5318
5224
|
const analyzer = new ImageAnalyzer();
|
|
5319
5225
|
try {
|
|
5320
|
-
|
|
5226
|
+
logger_logger.info("\u56FE\u7247\u5185\u5BB9\u7406\u89E3\u667A\u80FD\u4F53\u5F00\u59CB\u6267\u884C", {
|
|
5321
5227
|
imagePath: args.image_path
|
|
5322
5228
|
});
|
|
5323
5229
|
const validatedArgs = ImageAnalysisParamsSchema.parse(args);
|
|
@@ -5335,14 +5241,12 @@ ${context}
|
|
|
5335
5241
|
- \u{5904}\u{7406}\u{65F6}\u{95F4}\u{FF1A}${result.processing_time_ms}ms
|
|
5336
5242
|
|
|
5337
5243
|
\u{56FE}\u{7247}\u{63CF}\u{8FF0}\u{FF1A}
|
|
5338
|
-
${result.content.summary}
|
|
5339
|
-
|
|
5340
|
-
${result.content.tags && result.content.tags.length > 0 ? `\u{5173}\u{952E}\u{6807}\u{7B7E}\u{FF1A}${result.content.tags.map((tag)=>`\`${tag}\``).join(' ')}` : ''}`
|
|
5244
|
+
${result.content.summary}`
|
|
5341
5245
|
}
|
|
5342
5246
|
]
|
|
5343
5247
|
};
|
|
5344
5248
|
} catch (error) {
|
|
5345
|
-
|
|
5249
|
+
logger_logger.error("\u56FE\u7247\u5185\u5BB9\u7406\u89E3\u667A\u80FD\u4F53\u6267\u884C\u5931\u8D25", {
|
|
5346
5250
|
error,
|
|
5347
5251
|
args
|
|
5348
5252
|
});
|
|
@@ -5373,51 +5277,16 @@ ${result.content.tags && result.content.tags.length > 0 ? `\u{5173}\u{952E}\u{68
|
|
|
5373
5277
|
[types_AnalysisErrorCodes.UNSUPPORTED_FORMAT]: "\u4E0D\u652F\u6301\u7684\u56FE\u7247\u683C\u5F0F",
|
|
5374
5278
|
[types_AnalysisErrorCodes.FILE_NOT_FOUND]: "\u56FE\u7247\u6587\u4EF6\u672A\u627E\u5230",
|
|
5375
5279
|
[types_AnalysisErrorCodes.IMAGE_CORRUPTED]: "\u56FE\u7247\u6587\u4EF6\u635F\u574F",
|
|
5376
|
-
[types_AnalysisErrorCodes.ANALYSIS_FAILED]: "\
|
|
5377
|
-
[types_AnalysisErrorCodes.AI_SERVICE_ERROR]: "AI\u670D\u52A1\u9519\u8BEF"
|
|
5378
|
-
[types_AnalysisErrorCodes.INVALID_ANALYSIS_TYPE]: "\u65E0\u6548\u7684\u5206\u6790\u7C7B\u578B"
|
|
5280
|
+
[types_AnalysisErrorCodes.ANALYSIS_FAILED]: "\u56FE\u7247\u8BC6\u522B\u5931\u8D25",
|
|
5281
|
+
[types_AnalysisErrorCodes.AI_SERVICE_ERROR]: "AI\u670D\u52A1\u9519\u8BEF"
|
|
5379
5282
|
};
|
|
5380
5283
|
const errorTitle = errorMessages[error.code] || "\u5206\u6790\u9519\u8BEF";
|
|
5381
|
-
return
|
|
5382
|
-
# \u{274C} ${errorTitle}
|
|
5383
|
-
|
|
5384
|
-
## \u{9519}\u{8BEF}\u{4FE1}\u{606F}
|
|
5385
|
-
${error.message}
|
|
5386
|
-
|
|
5387
|
-
## \u{9519}\u{8BEF}\u{4EE3}\u{7801}
|
|
5388
|
-
${error.code}
|
|
5389
|
-
|
|
5390
|
-
## \u{89E3}\u{51B3}\u{5EFA}\u{8BAE}
|
|
5391
|
-
${getErrorSuggestion(error.code)}
|
|
5392
|
-
|
|
5393
|
-
## \u{652F}\u{6301}\u{7684}\u{529F}\u{80FD}
|
|
5394
|
-
- **\u{56FE}\u{7247}\u{683C}\u{5F0F}**: ${SUPPORTED_IMAGE_FORMATS.join(", ")}
|
|
5395
|
-
- **\u{5206}\u{6790}\u{7C7B}\u{578B}**: \u{901A}\u{7528}\u{3001}\u{7269}\u{4F53}\u{8BC6}\u{522B}\u{3001}\u{6587}\u{5B57}\u{8BC6}\u{522B}\u{3001}\u{573A}\u{666F}\u{5206}\u{6790}\u{3001}\u{4EBA}\u{7269}\u{5206}\u{6790}\u{3001}\u{6280}\u{672F}\u{5206}\u{6790}\u{3001}UI\u{8BBE}\u{8BA1}\u{7A3F}\u{3001}\u{9700}\u{6C42}\u{8BC6}\u{522B}\u{3001}\u{81EA}\u{5B9A}\u{4E49}
|
|
5396
|
-
- **\u{8BE6}\u{7EC6}\u{7A0B}\u{5EA6}**: \u{7B80}\u{8981}\u{3001}\u{8BE6}\u{7EC6}\u{3001}\u{5168}\u{9762}
|
|
5397
|
-
|
|
5398
|
-
## \u{9519}\u{8BEF}\u{8BE6}\u{60C5}
|
|
5399
|
-
- **\u{65F6}\u{95F4}**: ${new Date().toISOString()}
|
|
5400
|
-
- **\u{4E0A}\u{4E0B}\u{6587}**: ${error.context ? JSON.stringify(error.context, null, 2) : "\u65E0"}
|
|
5401
|
-
|
|
5402
|
-
\u{8BF7}\u{6839}\u{636E}\u{4E0A}\u{8FF0}\u{4FE1}\u{606F}\u{8C03}\u{6574}\u{53C2}\u{6570}\u{540E}\u{91CD}\u{8BD5}\u{3002}
|
|
5403
|
-
`.trim();
|
|
5284
|
+
return `\u{274C} ${errorTitle}\n\n${error.message}`;
|
|
5404
5285
|
}
|
|
5405
5286
|
function formatUnknownErrorResponse(error) {
|
|
5406
|
-
return
|
|
5407
|
-
# \u{274C} \u{7CFB}\u{7EDF}\u{9519}\u{8BEF}
|
|
5408
|
-
|
|
5409
|
-
\u{56FE}\u{7247}\u{5185}\u{5BB9}\u{5206}\u{6790}\u{8FC7}\u{7A0B}\u{4E2D}\u{53D1}\u{751F}\u{672A}\u{77E5}\u{9519}\u{8BEF}\u{FF0C}\u{8BF7}\u{7A0D}\u{540E}\u{91CD}\u{8BD5}\u{6216}\u{8054}\u{7CFB}\u{6280}\u{672F}\u{652F}\u{6301}\u{3002}
|
|
5287
|
+
return `\u{274C} \u{7CFB}\u{7EDF}\u{9519}\u{8BEF}
|
|
5410
5288
|
|
|
5411
|
-
|
|
5412
|
-
**\u{65F6}\u{95F4}**: ${new Date().toISOString()}
|
|
5413
|
-
|
|
5414
|
-
## \u{5EFA}\u{8BAE}
|
|
5415
|
-
1. \u{68C0}\u{67E5}\u{56FE}\u{7247}\u{6587}\u{4EF6}\u{662F}\u{5426}\u{5B58}\u{5728}\u{4E14}\u{53EF}\u{8BFB}
|
|
5416
|
-
2. \u{786E}\u{8BA4}\u{56FE}\u{7247}\u{683C}\u{5F0F}\u{662F}\u{5426}\u{652F}\u{6301}
|
|
5417
|
-
3. \u{9A8C}\u{8BC1}\u{56FE}\u{7247}\u{6587}\u{4EF6}\u{662F}\u{5426}\u{635F}\u{574F}
|
|
5418
|
-
4. \u{68C0}\u{67E5}\u{7F51}\u{7EDC}\u{8FDE}\u{63A5}\u{662F}\u{5426}\u{6B63}\u{5E38}
|
|
5419
|
-
5. \u{5982}\u{95EE}\u{9898}\u{6301}\u{7EED}\u{FF0C}\u{8BF7}\u{8054}\u{7CFB}\u{6280}\u{672F}\u{652F}\u{6301}
|
|
5420
|
-
`.trim();
|
|
5289
|
+
${error?.message || "\u672A\u77E5\u9519\u8BEF"}`;
|
|
5421
5290
|
}
|
|
5422
5291
|
function formatFileSize(bytes) {
|
|
5423
5292
|
if (0 === bytes) return "0 B";
|
|
@@ -5431,18 +5300,6 @@ ${getErrorSuggestion(error.code)}
|
|
|
5431
5300
|
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
5432
5301
|
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${sizes[i]}`;
|
|
5433
5302
|
}
|
|
5434
|
-
function getErrorSuggestion(errorCode) {
|
|
5435
|
-
const suggestions = {
|
|
5436
|
-
[types_AnalysisErrorCodes.INVALID_IMAGE_PATH]: "\u8BF7\u68C0\u67E5\u56FE\u7247\u8DEF\u5F84\u662F\u5426\u6B63\u786E",
|
|
5437
|
-
[types_AnalysisErrorCodes.UNSUPPORTED_FORMAT]: "\u8BF7\u4F7F\u7528\u652F\u6301\u7684\u56FE\u7247\u683C\u5F0F\uFF08jpg, png, gif\u7B49\uFF09",
|
|
5438
|
-
[types_AnalysisErrorCodes.FILE_NOT_FOUND]: "\u8BF7\u786E\u8BA4\u56FE\u7247\u6587\u4EF6\u5B58\u5728\u4E14\u8DEF\u5F84\u6B63\u786E",
|
|
5439
|
-
[types_AnalysisErrorCodes.IMAGE_CORRUPTED]: "\u8BF7\u68C0\u67E5\u56FE\u7247\u6587\u4EF6\u662F\u5426\u5B8C\u6574\u4E14\u672A\u635F\u574F",
|
|
5440
|
-
[types_AnalysisErrorCodes.ANALYSIS_FAILED]: "\u8BF7\u91CD\u8BD5\u6216\u4F7F\u7528\u4E0D\u540C\u7684\u5206\u6790\u7C7B\u578B",
|
|
5441
|
-
[types_AnalysisErrorCodes.AI_SERVICE_ERROR]: "\u8BF7\u68C0\u67E5\u7F51\u7EDC\u8FDE\u63A5\u6216\u7A0D\u540E\u91CD\u8BD5",
|
|
5442
|
-
[types_AnalysisErrorCodes.INVALID_ANALYSIS_TYPE]: "\u8BF7\u4F7F\u7528\u6709\u6548\u7684\u5206\u6790\u7C7B\u578B"
|
|
5443
|
-
};
|
|
5444
|
-
return suggestions[errorCode] || "\u8BF7\u68C0\u67E5\u8F93\u5165\u53C2\u6570\u5E76\u91CD\u8BD5";
|
|
5445
|
-
}
|
|
5446
5303
|
class ImageConversionError extends Error {
|
|
5447
5304
|
code;
|
|
5448
5305
|
context;
|
|
@@ -5491,7 +5348,7 @@ ${getErrorSuggestion(error.code)}
|
|
|
5491
5348
|
const inputPaths = Array.isArray(params.input_paths) ? params.input_paths : [
|
|
5492
5349
|
params.input_paths
|
|
5493
5350
|
];
|
|
5494
|
-
|
|
5351
|
+
logger_logger.info("\u5F00\u59CB\u56FE\u7247\u8F6C\u6362", {
|
|
5495
5352
|
inputCount: inputPaths.length,
|
|
5496
5353
|
outputFormat: params.output_format,
|
|
5497
5354
|
isBatch: inputPaths.length > 1
|
|
@@ -5509,7 +5366,7 @@ ${getErrorSuggestion(error.code)}
|
|
|
5509
5366
|
processing_time_ms: processingTime
|
|
5510
5367
|
}
|
|
5511
5368
|
};
|
|
5512
|
-
|
|
5369
|
+
logger_logger.info("\u56FE\u7247\u8F6C\u6362\u5B8C\u6210", {
|
|
5513
5370
|
total: results.length,
|
|
5514
5371
|
successful,
|
|
5515
5372
|
failed,
|
|
@@ -5517,7 +5374,7 @@ ${getErrorSuggestion(error.code)}
|
|
|
5517
5374
|
});
|
|
5518
5375
|
return batchResult;
|
|
5519
5376
|
} catch (error) {
|
|
5520
|
-
|
|
5377
|
+
logger_logger.error("\u56FE\u7247\u8F6C\u6362\u5931\u8D25", {
|
|
5521
5378
|
error,
|
|
5522
5379
|
params
|
|
5523
5380
|
});
|
|
@@ -5531,14 +5388,14 @@ ${getErrorSuggestion(error.code)}
|
|
|
5531
5388
|
await this.ensureOutputDirectory(outputPath);
|
|
5532
5389
|
const metadata = await this.getImageMetadata(inputPath);
|
|
5533
5390
|
const result = await this.performConversion(inputPath, outputPath, params, metadata);
|
|
5534
|
-
|
|
5391
|
+
logger_logger.info("\u5355\u5F20\u56FE\u7247\u8F6C\u6362\u6210\u529F", {
|
|
5535
5392
|
inputPath,
|
|
5536
5393
|
outputPath,
|
|
5537
5394
|
format: params.output_format
|
|
5538
5395
|
});
|
|
5539
5396
|
return result;
|
|
5540
5397
|
} catch (error) {
|
|
5541
|
-
|
|
5398
|
+
logger_logger.error("\u5355\u5F20\u56FE\u7247\u8F6C\u6362\u5931\u8D25", {
|
|
5542
5399
|
error,
|
|
5543
5400
|
inputPath
|
|
5544
5401
|
});
|
|
@@ -5735,7 +5592,7 @@ ${getErrorSuggestion(error.code)}
|
|
|
5735
5592
|
initializeProjectRoot();
|
|
5736
5593
|
const converter = new ImageConverter();
|
|
5737
5594
|
try {
|
|
5738
|
-
|
|
5595
|
+
logger_logger.info("\u56FE\u7247\u683C\u5F0F\u8F6C\u6362\u667A\u80FD\u4F53\u5F00\u59CB\u6267\u884C", {
|
|
5739
5596
|
inputPaths: args.input_paths,
|
|
5740
5597
|
outputFormat: args.output_format,
|
|
5741
5598
|
isBatch: Array.isArray(args.input_paths)
|
|
@@ -5760,7 +5617,7 @@ ${getErrorSuggestion(error.code)}
|
|
|
5760
5617
|
]
|
|
5761
5618
|
};
|
|
5762
5619
|
} catch (error) {
|
|
5763
|
-
|
|
5620
|
+
logger_logger.error("\u56FE\u7247\u683C\u5F0F\u8F6C\u6362\u667A\u80FD\u4F53\u6267\u884C\u5931\u8D25", {
|
|
5764
5621
|
error,
|
|
5765
5622
|
args
|
|
5766
5623
|
});
|
|
@@ -5871,7 +5728,7 @@ ${error.message}
|
|
|
5871
5728
|
${error.code}
|
|
5872
5729
|
|
|
5873
5730
|
## \u{89E3}\u{51B3}\u{5EFA}\u{8BAE}
|
|
5874
|
-
${
|
|
5731
|
+
${getErrorSuggestion(error.code)}
|
|
5875
5732
|
|
|
5876
5733
|
## \u{652F}\u{6301}\u{7684}\u{683C}\u{5F0F}
|
|
5877
5734
|
- **\u{8F93}\u{5165}\u{683C}\u{5F0F}**: ${SUPPORTED_INPUT_FORMATS.join(", ")}
|
|
@@ -5915,7 +5772,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
5915
5772
|
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
5916
5773
|
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${sizes[i]}`;
|
|
5917
5774
|
}
|
|
5918
|
-
function
|
|
5775
|
+
function getErrorSuggestion(errorCode) {
|
|
5919
5776
|
const suggestions = {
|
|
5920
5777
|
[types_ConversionErrorCodes.INVALID_INPUT_PATH]: "\u8BF7\u68C0\u67E5\u8F93\u5165\u8DEF\u5F84\u662F\u5426\u6B63\u786E",
|
|
5921
5778
|
[types_ConversionErrorCodes.UNSUPPORTED_FORMAT]: "\u8BF7\u4F7F\u7528\u652F\u6301\u7684\u56FE\u7247\u683C\u5F0F",
|
|
@@ -6010,7 +5867,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6010
5867
|
});
|
|
6011
5868
|
class ImagePreprocessor {
|
|
6012
5869
|
async validateImage(imagePath) {
|
|
6013
|
-
|
|
5870
|
+
logger_logger.info("ImagePreprocessor: \u5F00\u59CB\u9A8C\u8BC1\u56FE\u7247", imagePath);
|
|
6014
5871
|
const result = {
|
|
6015
5872
|
isValid: false,
|
|
6016
5873
|
fileExists: false,
|
|
@@ -6022,7 +5879,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6022
5879
|
result.formatSupported = types_SUPPORTED_IMAGE_FORMATS.includes(fileExtension);
|
|
6023
5880
|
if (!result.formatSupported) {
|
|
6024
5881
|
result.errorMessage = `\u{4E0D}\u{652F}\u{6301}\u{7684}\u{56FE}\u{7247}\u{683C}\u{5F0F}: ${fileExtension}`;
|
|
6025
|
-
|
|
5882
|
+
logger_logger.warn("\u4E0D\u652F\u6301\u7684\u56FE\u7247\u683C\u5F0F", {
|
|
6026
5883
|
imagePath,
|
|
6027
5884
|
format: fileExtension
|
|
6028
5885
|
});
|
|
@@ -6031,12 +5888,12 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6031
5888
|
try {
|
|
6032
5889
|
await external_node_fs_promises_namespaceObject.access(imagePath, external_node_fs_namespaceObject.constants.R_OK);
|
|
6033
5890
|
result.readable = true;
|
|
6034
|
-
|
|
5891
|
+
logger_logger.debug("\u56FE\u7247\u6587\u4EF6\u53EF\u8BFB", {
|
|
6035
5892
|
imagePath
|
|
6036
5893
|
});
|
|
6037
5894
|
} catch (error) {
|
|
6038
5895
|
result.errorMessage = "\u56FE\u7247\u6587\u4EF6\u65E0\u6CD5\u8BFB\u53D6\uFF0C\u8BF7\u68C0\u67E5\u6587\u4EF6\u6743\u9650";
|
|
6039
|
-
|
|
5896
|
+
logger_logger.warn("\u56FE\u7247\u6587\u4EF6\u65E0\u6CD5\u8BFB\u53D6", {
|
|
6040
5897
|
imagePath
|
|
6041
5898
|
});
|
|
6042
5899
|
return result;
|
|
@@ -6045,32 +5902,32 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6045
5902
|
const metadata = await external_sharp_default()(imagePath).metadata();
|
|
6046
5903
|
if (!metadata.width || !metadata.height) {
|
|
6047
5904
|
result.errorMessage = "\u65E0\u6CD5\u83B7\u53D6\u56FE\u7247\u5C3A\u5BF8\u4FE1\u606F\uFF0C\u53EF\u80FD\u6587\u4EF6\u5DF2\u635F\u574F";
|
|
6048
|
-
|
|
5905
|
+
logger_logger.warn("\u65E0\u6CD5\u83B7\u53D6\u56FE\u7247\u5C3A\u5BF8", {
|
|
6049
5906
|
imagePath
|
|
6050
5907
|
});
|
|
6051
5908
|
return result;
|
|
6052
5909
|
}
|
|
6053
|
-
|
|
5910
|
+
logger_logger.debug("\u56FE\u7247\u5143\u6570\u636E\u83B7\u53D6\u6210\u529F", {
|
|
6054
5911
|
imagePath,
|
|
6055
5912
|
width: metadata.width,
|
|
6056
5913
|
height: metadata.height
|
|
6057
5914
|
});
|
|
6058
5915
|
} catch (error) {
|
|
6059
5916
|
result.errorMessage = "\u56FE\u7247\u6587\u4EF6\u683C\u5F0F\u9519\u8BEF\u6216\u5DF2\u635F\u574F";
|
|
6060
|
-
|
|
5917
|
+
logger_logger.warn("\u56FE\u7247\u6587\u4EF6\u635F\u574F", {
|
|
6061
5918
|
imagePath,
|
|
6062
5919
|
error: error instanceof Error ? error.message : error
|
|
6063
5920
|
});
|
|
6064
5921
|
return result;
|
|
6065
5922
|
}
|
|
6066
5923
|
result.isValid = true;
|
|
6067
|
-
|
|
5924
|
+
logger_logger.info("\u56FE\u7247\u9A8C\u8BC1\u6210\u529F", {
|
|
6068
5925
|
imagePath
|
|
6069
5926
|
});
|
|
6070
5927
|
return result;
|
|
6071
5928
|
} catch (error) {
|
|
6072
5929
|
result.errorMessage = `\u{56FE}\u{7247}\u{9A8C}\u{8BC1}\u{8FC7}\u{7A0B}\u{4E2D}\u{53D1}\u{751F}\u{9519}\u{8BEF}: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`;
|
|
6073
|
-
|
|
5930
|
+
logger_logger.error("\u56FE\u7247\u9A8C\u8BC1\u5931\u8D25", {
|
|
6074
5931
|
imagePath,
|
|
6075
5932
|
error
|
|
6076
5933
|
});
|
|
@@ -6078,7 +5935,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6078
5935
|
}
|
|
6079
5936
|
}
|
|
6080
5937
|
async getImageInfo(imagePath) {
|
|
6081
|
-
|
|
5938
|
+
logger_logger.info("ImagePreprocessor: \u5F00\u59CB\u83B7\u53D6\u56FE\u7247\u4FE1\u606F", imagePath);
|
|
6082
5939
|
try {
|
|
6083
5940
|
const stats = await external_node_fs_promises_namespaceObject.stat(imagePath);
|
|
6084
5941
|
const fileName = external_node_path_namespaceObject.basename(imagePath);
|
|
@@ -6114,7 +5971,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6114
5971
|
fileName,
|
|
6115
5972
|
createdAt: stats.birthtime
|
|
6116
5973
|
};
|
|
6117
|
-
|
|
5974
|
+
logger_logger.info("\u56FE\u7247\u4FE1\u606F\u83B7\u53D6\u6210\u529F", {
|
|
6118
5975
|
imagePath,
|
|
6119
5976
|
width,
|
|
6120
5977
|
height,
|
|
@@ -6125,7 +5982,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6125
5982
|
return imageInfo;
|
|
6126
5983
|
} catch (error) {
|
|
6127
5984
|
if (error instanceof ImageRecognitionError) throw error;
|
|
6128
|
-
|
|
5985
|
+
logger_logger.error("\u83B7\u53D6\u56FE\u7247\u4FE1\u606F\u5931\u8D25", {
|
|
6129
5986
|
imagePath,
|
|
6130
5987
|
error
|
|
6131
5988
|
});
|
|
@@ -6140,7 +5997,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6140
5997
|
const heightCondition = height >= LONG_IMAGE_THRESHOLDS.MIN_HEIGHT;
|
|
6141
5998
|
const aspectRatioCondition = aspectRatio <= 1 / LONG_IMAGE_THRESHOLDS.MIN_ASPECT_RATIO;
|
|
6142
5999
|
const isLong = heightCondition && aspectRatioCondition;
|
|
6143
|
-
|
|
6000
|
+
logger_logger.debug("\u957F\u56FE\u68C0\u6D4B\u7ED3\u679C", {
|
|
6144
6001
|
width,
|
|
6145
6002
|
height,
|
|
6146
6003
|
aspectRatio: aspectRatio.toFixed(2),
|
|
@@ -6151,7 +6008,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6151
6008
|
return isLong;
|
|
6152
6009
|
}
|
|
6153
6010
|
async assessImageQuality(imagePath) {
|
|
6154
|
-
|
|
6011
|
+
logger_logger.info("ImagePreprocessor: \u5F00\u59CB\u8BC4\u4F30\u56FE\u7247\u8D28\u91CF", {
|
|
6155
6012
|
imagePath
|
|
6156
6013
|
});
|
|
6157
6014
|
try {
|
|
@@ -6193,7 +6050,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6193
6050
|
clarity: clarityScore,
|
|
6194
6051
|
recommendation
|
|
6195
6052
|
};
|
|
6196
|
-
|
|
6053
|
+
logger_logger.info("\u56FE\u7247\u8D28\u91CF\u8BC4\u4F30\u5B8C\u6210", {
|
|
6197
6054
|
imagePath,
|
|
6198
6055
|
totalScore: totalScore.toFixed(3),
|
|
6199
6056
|
resolutionScore: resolutionScore.toFixed(3),
|
|
@@ -6204,7 +6061,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6204
6061
|
return assessment;
|
|
6205
6062
|
} catch (error) {
|
|
6206
6063
|
if (error instanceof ImageRecognitionError) throw error;
|
|
6207
|
-
|
|
6064
|
+
logger_logger.error("\u56FE\u7247\u8D28\u91CF\u8BC4\u4F30\u5931\u8D25", {
|
|
6208
6065
|
imagePath,
|
|
6209
6066
|
error
|
|
6210
6067
|
});
|
|
@@ -6220,7 +6077,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6220
6077
|
}
|
|
6221
6078
|
class ConfigCalculator {
|
|
6222
6079
|
async calculateSegmentConfig(imageInfo, qualityAssessment, maxSegments = LONG_IMAGE_THRESHOLDS.MAX_SEGMENTS) {
|
|
6223
|
-
|
|
6080
|
+
logger_logger.info("ConfigCalculator: \u5F00\u59CB\u8BA1\u7B97\u5206\u6BB5\u914D\u7F6E", {
|
|
6224
6081
|
width: imageInfo.width,
|
|
6225
6082
|
height: imageInfo.height,
|
|
6226
6083
|
isLongImage: imageInfo.isLongImage
|
|
@@ -6236,7 +6093,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6236
6093
|
],
|
|
6237
6094
|
estimatedTime: this.estimateSegmentProcessingTime(1, imageInfo.size)
|
|
6238
6095
|
};
|
|
6239
|
-
|
|
6096
|
+
logger_logger.info("\u975E\u957F\u56FE\uFF0C\u4F7F\u7528\u5355\u6BB5\u914D\u7F6E", config);
|
|
6240
6097
|
return config;
|
|
6241
6098
|
}
|
|
6242
6099
|
const segmentHeight = this.calculateOptimalSegmentHeight(imageInfo, qualityAssessment);
|
|
@@ -6255,13 +6112,13 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6255
6112
|
processingOrder,
|
|
6256
6113
|
estimatedTime
|
|
6257
6114
|
};
|
|
6258
|
-
|
|
6115
|
+
logger_logger.info("\u5206\u6BB5\u914D\u7F6E\u8BA1\u7B97\u5B8C\u6210", {
|
|
6259
6116
|
...config,
|
|
6260
6117
|
estimatedTimeMinutes: (estimatedTime / 60000).toFixed(1)
|
|
6261
6118
|
});
|
|
6262
6119
|
return config;
|
|
6263
6120
|
} catch (error) {
|
|
6264
|
-
|
|
6121
|
+
logger_logger.error("\u5206\u6BB5\u914D\u7F6E\u8BA1\u7B97\u5931\u8D25", {
|
|
6265
6122
|
error,
|
|
6266
6123
|
imageInfo
|
|
6267
6124
|
});
|
|
@@ -6291,7 +6148,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6291
6148
|
return Math.max(overlapHeight, LONG_IMAGE_THRESHOLDS.MIN_OVERLAP);
|
|
6292
6149
|
}
|
|
6293
6150
|
calculateConcurrencyConfig(imageSize, segmentCount = 1) {
|
|
6294
|
-
|
|
6151
|
+
logger_logger.info("ConfigCalculator: \u5F00\u59CB\u8BA1\u7B97\u5E76\u53D1\u914D\u7F6E", {
|
|
6295
6152
|
imageSize: `${(imageSize / 1024 / 1024).toFixed(2)}MB`,
|
|
6296
6153
|
segmentCount
|
|
6297
6154
|
});
|
|
@@ -6313,7 +6170,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6313
6170
|
delayBetweenBatches,
|
|
6314
6171
|
memoryLimit: PERFORMANCE_LIMITS.MAX_MEMORY_MB
|
|
6315
6172
|
};
|
|
6316
|
-
|
|
6173
|
+
logger_logger.info("\u5E76\u53D1\u914D\u7F6E\u8BA1\u7B97\u5B8C\u6210", {
|
|
6317
6174
|
...config,
|
|
6318
6175
|
systemInfo: {
|
|
6319
6176
|
totalMemoryGB: (totalMemoryMB / 1024).toFixed(1),
|
|
@@ -6325,7 +6182,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6325
6182
|
});
|
|
6326
6183
|
return config;
|
|
6327
6184
|
} catch (error) {
|
|
6328
|
-
|
|
6185
|
+
logger_logger.error("\u5E76\u53D1\u914D\u7F6E\u8BA1\u7B97\u5931\u8D25", {
|
|
6329
6186
|
error,
|
|
6330
6187
|
imageSize,
|
|
6331
6188
|
segmentCount
|
|
@@ -6342,7 +6199,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6342
6199
|
return this.estimateSegmentProcessingTime(segmentCount, imageSize);
|
|
6343
6200
|
}
|
|
6344
6201
|
estimateSegmentProcessingTime(segmentCount, imageSize) {
|
|
6345
|
-
|
|
6202
|
+
logger_logger.info("ConfigCalculator: \u5F00\u59CB\u9884\u4F30\u5904\u7406\u65F6\u95F4", {
|
|
6346
6203
|
segmentCount,
|
|
6347
6204
|
imageSize
|
|
6348
6205
|
});
|
|
@@ -6360,7 +6217,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6360
6217
|
const startupOverhead = 2000;
|
|
6361
6218
|
const finalizationOverhead = 1000;
|
|
6362
6219
|
const estimatedTime = totalTime + startupOverhead + finalizationOverhead;
|
|
6363
|
-
|
|
6220
|
+
logger_logger.info("\u5904\u7406\u65F6\u95F4\u9884\u4F30\u5B8C\u6210", {
|
|
6364
6221
|
segmentCount,
|
|
6365
6222
|
baseTimePerSegment,
|
|
6366
6223
|
concurrencyEfficiency,
|
|
@@ -6369,7 +6226,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6369
6226
|
});
|
|
6370
6227
|
return estimatedTime;
|
|
6371
6228
|
} catch (error) {
|
|
6372
|
-
|
|
6229
|
+
logger_logger.error("\u5904\u7406\u65F6\u95F4\u9884\u4F30\u5931\u8D25", {
|
|
6373
6230
|
error,
|
|
6374
6231
|
segmentCount,
|
|
6375
6232
|
imageSize
|
|
@@ -6380,7 +6237,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6380
6237
|
}
|
|
6381
6238
|
class analyzer_ImageAnalyzer {
|
|
6382
6239
|
async analyzeLongImage(imagePath, imageInfo, segmentConfig, concurrencyConfig, apiPreference = 'auto') {
|
|
6383
|
-
|
|
6240
|
+
logger_logger.info("ImageAnalyzer: \u5F00\u59CB\u5206\u6790\u957F\u56FE", {
|
|
6384
6241
|
imagePath,
|
|
6385
6242
|
totalSegments: segmentConfig.totalSegments,
|
|
6386
6243
|
maxConcurrency: concurrencyConfig.maxConcurrency
|
|
@@ -6414,7 +6271,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6414
6271
|
outputPath: '',
|
|
6415
6272
|
success: 0 === summary.failedSegments
|
|
6416
6273
|
};
|
|
6417
|
-
|
|
6274
|
+
logger_logger.info("\u957F\u56FE\u5206\u6790\u5B8C\u6210", {
|
|
6418
6275
|
imagePath,
|
|
6419
6276
|
totalSegments: summary.totalSegments,
|
|
6420
6277
|
successfulSegments: summary.successfulSegments,
|
|
@@ -6423,7 +6280,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6423
6280
|
});
|
|
6424
6281
|
return result;
|
|
6425
6282
|
} catch (error) {
|
|
6426
|
-
|
|
6283
|
+
logger_logger.error("\u957F\u56FE\u5206\u6790\u5931\u8D25", {
|
|
6427
6284
|
imagePath,
|
|
6428
6285
|
error
|
|
6429
6286
|
});
|
|
@@ -6439,7 +6296,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6439
6296
|
const segments = await this.generateSegments(imagePath, imageInfo, segmentConfig);
|
|
6440
6297
|
for(let i = 0; i < segments.length; i += batchSize){
|
|
6441
6298
|
const batch = segments.slice(i, i + batchSize);
|
|
6442
|
-
|
|
6299
|
+
logger_logger.info(`\u{5904}\u{7406}\u{6279}\u{6B21} ${Math.floor(i / batchSize) + 1}/${Math.ceil(segments.length / batchSize)}`, {
|
|
6443
6300
|
batchSize: batch.length,
|
|
6444
6301
|
startIndex: i
|
|
6445
6302
|
});
|
|
@@ -6447,7 +6304,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6447
6304
|
try {
|
|
6448
6305
|
return await this.analyzeSegment(buffer, info, apiPreference);
|
|
6449
6306
|
} catch (error) {
|
|
6450
|
-
|
|
6307
|
+
logger_logger.error(`\u{6BB5}\u{843D} ${info.index} \u{5206}\u{6790}\u{5931}\u{8D25}`, {
|
|
6451
6308
|
error
|
|
6452
6309
|
});
|
|
6453
6310
|
return {
|
|
@@ -6469,7 +6326,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6469
6326
|
}
|
|
6470
6327
|
async analyzeSegment(imageBuffer, segmentInfo, apiPreference = 'auto') {
|
|
6471
6328
|
const startTime = Date.now();
|
|
6472
|
-
|
|
6329
|
+
logger_logger.info("ImageAnalyzer: \u5F00\u59CB\u5206\u6790\u56FE\u7247\u6BB5\u843D", {
|
|
6473
6330
|
segmentIndex: segmentInfo.index,
|
|
6474
6331
|
totalSegments: segmentInfo.totalSegments,
|
|
6475
6332
|
isFirstSegment: segmentInfo.isFirstSegment,
|
|
@@ -6484,7 +6341,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6484
6341
|
try {
|
|
6485
6342
|
if ('glm-4v' === apiPreference || 'auto' === apiPreference) {
|
|
6486
6343
|
apiUsed = 'glm-4v-flash';
|
|
6487
|
-
aiResponse = await
|
|
6344
|
+
aiResponse = await openai_openAIService.analyzeImage({
|
|
6488
6345
|
image_base64: base64Image,
|
|
6489
6346
|
prompt,
|
|
6490
6347
|
system_prompt: systemPrompt,
|
|
@@ -6494,7 +6351,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6494
6351
|
});
|
|
6495
6352
|
} else if ('moonshot' === apiPreference) {
|
|
6496
6353
|
apiUsed = 'kimi-latest';
|
|
6497
|
-
aiResponse = await
|
|
6354
|
+
aiResponse = await openai_openAIService.analyzeImage({
|
|
6498
6355
|
image_base64: base64Image,
|
|
6499
6356
|
prompt,
|
|
6500
6357
|
system_prompt: systemPrompt,
|
|
@@ -6504,13 +6361,13 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6504
6361
|
});
|
|
6505
6362
|
}
|
|
6506
6363
|
} catch (primaryError) {
|
|
6507
|
-
|
|
6364
|
+
logger_logger.warn(`\u{4E3B}\u{8981}API ${apiUsed} \u{8C03}\u{7528}\u{5931}\u{8D25}\u{FF0C}\u{5C1D}\u{8BD5}\u{5907}\u{7528}API`, {
|
|
6508
6365
|
error: primaryError instanceof Error ? primaryError.message : primaryError
|
|
6509
6366
|
});
|
|
6510
6367
|
try {
|
|
6511
6368
|
if ('kimi-latest' !== apiUsed) {
|
|
6512
6369
|
apiUsed = 'kimi-latest';
|
|
6513
|
-
aiResponse = await
|
|
6370
|
+
aiResponse = await openai_openAIService.analyzeImage({
|
|
6514
6371
|
image_base64: base64Image,
|
|
6515
6372
|
prompt,
|
|
6516
6373
|
system_prompt: systemPrompt,
|
|
@@ -6520,7 +6377,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6520
6377
|
});
|
|
6521
6378
|
} else {
|
|
6522
6379
|
apiUsed = 'glm-4v-flash';
|
|
6523
|
-
aiResponse = await
|
|
6380
|
+
aiResponse = await openai_openAIService.analyzeImage({
|
|
6524
6381
|
image_base64: base64Image,
|
|
6525
6382
|
prompt,
|
|
6526
6383
|
system_prompt: systemPrompt,
|
|
@@ -6551,7 +6408,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6551
6408
|
totalTokens: Math.ceil((prompt.length + aiResponse.length) / 4)
|
|
6552
6409
|
}
|
|
6553
6410
|
};
|
|
6554
|
-
|
|
6411
|
+
logger_logger.info("\u6BB5\u843D\u5206\u6790\u5B8C\u6210", {
|
|
6555
6412
|
segmentIndex: segmentInfo.index,
|
|
6556
6413
|
textLength: textContent.length,
|
|
6557
6414
|
descriptionLength: imageDescription.length,
|
|
@@ -6562,7 +6419,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6562
6419
|
return result;
|
|
6563
6420
|
} catch (error) {
|
|
6564
6421
|
const processingTime = Date.now() - startTime;
|
|
6565
|
-
|
|
6422
|
+
logger_logger.error("\u6BB5\u843D\u5206\u6790\u5931\u8D25", {
|
|
6566
6423
|
segmentIndex: segmentInfo.index,
|
|
6567
6424
|
error,
|
|
6568
6425
|
processingTimeMs: processingTime
|
|
@@ -6646,7 +6503,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6646
6503
|
let textContent = '';
|
|
6647
6504
|
let imageDescription = '';
|
|
6648
6505
|
let confidence = 0.9;
|
|
6649
|
-
|
|
6506
|
+
logger_logger.debug("AI\u54CD\u5E94\u539F\u59CB\u5185\u5BB9", {
|
|
6650
6507
|
responseLength: response.length,
|
|
6651
6508
|
responsePreview: response.substring(0, 200) + (response.length > 200 ? '...' : '')
|
|
6652
6509
|
});
|
|
@@ -6656,7 +6513,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6656
6513
|
textContent = '';
|
|
6657
6514
|
imageDescription = '';
|
|
6658
6515
|
confidence = 0.9;
|
|
6659
|
-
|
|
6516
|
+
logger_logger.debug("\u68C0\u6D4B\u5230\u65E0\u6587\u5B57\u5185\u5BB9\u6807\u8BC6");
|
|
6660
6517
|
return {
|
|
6661
6518
|
textContent,
|
|
6662
6519
|
imageDescription,
|
|
@@ -6671,14 +6528,14 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6671
6528
|
const chineseRatio = chineseCharCount / totalCharCount;
|
|
6672
6529
|
confidence = Math.min(0.9, 0.6 + 0.3 * chineseRatio);
|
|
6673
6530
|
} else confidence = totalCharCount > 10 ? 0.8 : 0.6;
|
|
6674
|
-
|
|
6531
|
+
logger_logger.debug("AI\u54CD\u5E94\u89E3\u6790\u7ED3\u679C", {
|
|
6675
6532
|
textContentLength: textContent.length,
|
|
6676
6533
|
chineseCharCount,
|
|
6677
6534
|
totalCharCount,
|
|
6678
6535
|
confidence
|
|
6679
6536
|
});
|
|
6680
6537
|
} catch (error) {
|
|
6681
|
-
|
|
6538
|
+
logger_logger.warn("AI\u54CD\u5E94\u89E3\u6790\u5931\u8D25\uFF0C\u4F7F\u7528\u539F\u59CB\u54CD\u5E94", {
|
|
6682
6539
|
error
|
|
6683
6540
|
});
|
|
6684
6541
|
textContent = response.trim();
|
|
@@ -6738,7 +6595,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6738
6595
|
}
|
|
6739
6596
|
async processImage(imagePath) {
|
|
6740
6597
|
const startTime = Date.now();
|
|
6741
|
-
|
|
6598
|
+
logger_logger.info("ImageRecognitionProcessor: \u5F00\u59CB\u5904\u7406\u56FE\u7247", {
|
|
6742
6599
|
imagePath
|
|
6743
6600
|
});
|
|
6744
6601
|
try {
|
|
@@ -6749,7 +6606,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6749
6606
|
});
|
|
6750
6607
|
const imageInfo = await this.preprocessor.getImageInfo(imagePath);
|
|
6751
6608
|
const qualityAssessment = await this.preprocessor.assessImageQuality(imagePath);
|
|
6752
|
-
|
|
6609
|
+
logger_logger.info("\u56FE\u7247\u4FE1\u606F\u83B7\u53D6\u5B8C\u6210", {
|
|
6753
6610
|
width: imageInfo.width,
|
|
6754
6611
|
height: imageInfo.height,
|
|
6755
6612
|
isLongImage: imageInfo.isLongImage,
|
|
@@ -6757,7 +6614,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6757
6614
|
});
|
|
6758
6615
|
const segmentConfig = await this.configCalculator.calculateSegmentConfig(imageInfo, qualityAssessment, 20);
|
|
6759
6616
|
const concurrencyConfig = this.configCalculator.calculateConcurrencyConfig(imageInfo.size, segmentConfig.totalSegments);
|
|
6760
|
-
|
|
6617
|
+
logger_logger.info("\u5206\u6BB5\u914D\u7F6E\u8BA1\u7B97\u5B8C\u6210", {
|
|
6761
6618
|
totalSegments: segmentConfig.totalSegments,
|
|
6762
6619
|
segmentHeight: segmentConfig.segmentHeight,
|
|
6763
6620
|
maxConcurrency: concurrencyConfig.maxConcurrency
|
|
@@ -6765,7 +6622,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6765
6622
|
const analysisResult = await this.analyzer.analyzeLongImage(imagePath, imageInfo, segmentConfig, concurrencyConfig, 'auto');
|
|
6766
6623
|
const outputPath = await this.generateSingleOutputFile(imageInfo, analysisResult.segmentResults, analysisResult.summary);
|
|
6767
6624
|
const totalTime = Date.now() - startTime;
|
|
6768
|
-
|
|
6625
|
+
logger_logger.info("\u56FE\u7247\u5904\u7406\u5B8C\u6210", {
|
|
6769
6626
|
outputPath,
|
|
6770
6627
|
totalSegments: analysisResult.summary.totalSegments,
|
|
6771
6628
|
successfulSegments: analysisResult.summary.successfulSegments,
|
|
@@ -6784,7 +6641,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6784
6641
|
}
|
|
6785
6642
|
};
|
|
6786
6643
|
} catch (error) {
|
|
6787
|
-
|
|
6644
|
+
logger_logger.error("\u56FE\u7247\u5904\u7406\u5931\u8D25", {
|
|
6788
6645
|
imagePath,
|
|
6789
6646
|
error
|
|
6790
6647
|
});
|
|
@@ -6808,7 +6665,7 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
6808
6665
|
}
|
|
6809
6666
|
}
|
|
6810
6667
|
async generateSingleOutputFile(imageInfo, segmentResults, summary) {
|
|
6811
|
-
const baseDir =
|
|
6668
|
+
const baseDir = config_getStorageDir();
|
|
6812
6669
|
const dateDir = new Date().toISOString().split('T')[0];
|
|
6813
6670
|
const outputDirectory = external_path_namespaceObject.join(baseDir, 'image-recognition', dateDir);
|
|
6814
6671
|
await external_fs_namespaceObject.promises.mkdir(outputDirectory, {
|
|
@@ -6839,7 +6696,7 @@ ${allTextContent || "\u672A\u8BC6\u522B\u5230\u6587\u5B57\u5185\u5BB9"}
|
|
|
6839
6696
|
**\u{8BC6}\u{522B}\u{5B8C}\u{6210}\u{65F6}\u{95F4}**: ${new Date().toLocaleString('zh-CN')}
|
|
6840
6697
|
`;
|
|
6841
6698
|
await external_fs_namespaceObject.promises.writeFile(outputPath, content, 'utf8');
|
|
6842
|
-
|
|
6699
|
+
logger_logger.info("\u8F93\u51FA\u6587\u4EF6\u751F\u6210\u5B8C\u6210", {
|
|
6843
6700
|
outputPath,
|
|
6844
6701
|
fileName,
|
|
6845
6702
|
contentLength: content.length
|
|
@@ -6855,14 +6712,14 @@ ${allTextContent || "\u672A\u8BC6\u522B\u5230\u6587\u5B57\u5185\u5BB9"}
|
|
|
6855
6712
|
},
|
|
6856
6713
|
handler: async (args)=>{
|
|
6857
6714
|
initializeProjectRoot();
|
|
6858
|
-
|
|
6715
|
+
logger_logger.info("\u56FE\u7247\u5185\u5BB9\u8BC6\u522B\u667A\u80FD\u4F53: \u5F00\u59CB\u5904\u7406", {
|
|
6859
6716
|
args
|
|
6860
6717
|
});
|
|
6861
6718
|
try {
|
|
6862
6719
|
const { imagePath } = ImageRecognitionParamsSchema.parse(args);
|
|
6863
6720
|
const processor = new ImageRecognitionProcessor();
|
|
6864
6721
|
const result = await processor.processImage(imagePath);
|
|
6865
|
-
|
|
6722
|
+
logger_logger.info("\u56FE\u7247\u5185\u5BB9\u8BC6\u522B\u667A\u80FD\u4F53: \u5904\u7406\u5B8C\u6210", {
|
|
6866
6723
|
outputPath: result.outputPath,
|
|
6867
6724
|
summary: result.summary
|
|
6868
6725
|
});
|
|
@@ -6888,7 +6745,7 @@ ${allTextContent || "\u672A\u8BC6\u522B\u5230\u6587\u5B57\u5185\u5BB9"}
|
|
|
6888
6745
|
]
|
|
6889
6746
|
};
|
|
6890
6747
|
} catch (error) {
|
|
6891
|
-
|
|
6748
|
+
logger_logger.error("\u56FE\u7247\u5185\u5BB9\u8BC6\u522B\u667A\u80FD\u4F53: \u5904\u7406\u5931\u8D25", {
|
|
6892
6749
|
error
|
|
6893
6750
|
});
|
|
6894
6751
|
return {
|
|
@@ -6929,8 +6786,8 @@ ${allTextContent || "\u672A\u8BC6\u522B\u5230\u6587\u5B57\u5185\u5BB9"}
|
|
|
6929
6786
|
if (!filePath) throw new Error("\u6587\u4EF6\u8DEF\u5F84\u53C2\u6570\u7F3A\u5931\uFF0C\u8BF7\u63D0\u4F9B filePath \u53C2\u6570");
|
|
6930
6787
|
try {
|
|
6931
6788
|
if (!isValidExcelPath(filePath)) throw new Error(`\u{6587}\u{4EF6}\u{683C}\u{5F0F}\u{4E0D}\u{652F}\u{6301}\u{FF0C}\u{8BF7}\u{63D0}\u{4F9B}\u{6709}\u{6548}\u{7684}Excel\u{6587}\u{4EF6}\u{8DEF}\u{5F84}(.xlsx, .xls, .xlsm): ${filePath}`);
|
|
6932
|
-
const resolvedPath = await
|
|
6933
|
-
|
|
6789
|
+
const resolvedPath = await common_validateAndResolvePath(filePath);
|
|
6790
|
+
logger_logger.info("\u5F00\u59CB\u8BFB\u53D6Excel\u6587\u4EF6", {
|
|
6934
6791
|
tool: 'read_excel',
|
|
6935
6792
|
originalPath: filePath,
|
|
6936
6793
|
resolvedPath: resolvedPath,
|
|
@@ -6969,7 +6826,7 @@ ${allTextContent || "\u672A\u8BC6\u522B\u5230\u6587\u5B57\u5185\u5BB9"}
|
|
|
6969
6826
|
columnCount: filteredData.length > 0 ? Object.keys(filteredData[0]).length : 0,
|
|
6970
6827
|
range: range
|
|
6971
6828
|
};
|
|
6972
|
-
const jsonDir = external_path_default().join(
|
|
6829
|
+
const jsonDir = external_path_default().join(config_getStorageDir(), 'excel');
|
|
6973
6830
|
const baseName = external_path_default().basename(filePath, external_path_default().extname(filePath));
|
|
6974
6831
|
const outputDir = external_path_default().join(jsonDir, baseName);
|
|
6975
6832
|
await promises_namespaceObject.mkdir(outputDir, {
|
|
@@ -6977,7 +6834,7 @@ ${allTextContent || "\u672A\u8BC6\u522B\u5230\u6587\u5B57\u5185\u5BB9"}
|
|
|
6977
6834
|
});
|
|
6978
6835
|
const jsonFilePath = external_path_default().join(outputDir, `${baseName}_${sheetName}.json`);
|
|
6979
6836
|
await promises_namespaceObject.writeFile(jsonFilePath, JSON.stringify(filteredData, null, 2), 'utf8');
|
|
6980
|
-
|
|
6837
|
+
logger_logger.info("Excel\u8BFB\u53D6\u5B8C\u6210", {
|
|
6981
6838
|
file: filePath,
|
|
6982
6839
|
sheet: sheetName,
|
|
6983
6840
|
rows: filteredData.length,
|
|
@@ -7009,7 +6866,7 @@ ${JSON.stringify(filteredData.slice(0, 3), null, 2)}
|
|
|
7009
6866
|
} catch (error) {
|
|
7010
6867
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
7011
6868
|
const osInfo = `[${process.platform}]`;
|
|
7012
|
-
|
|
6869
|
+
logger_logger.error(`Excel\u{8BFB}\u{53D6}\u{5931}\u{8D25} ${osInfo}: ${errorMsg}`, {
|
|
7013
6870
|
tool: "read_excel",
|
|
7014
6871
|
filePath,
|
|
7015
6872
|
resolvedPath: error.resolvedPath || filePath,
|
|
@@ -7072,7 +6929,7 @@ ${JSON.stringify(filteredData.slice(0, 3), null, 2)}
|
|
|
7072
6929
|
try {
|
|
7073
6930
|
let jsonData = [];
|
|
7074
6931
|
if ('string' == typeof data) try {
|
|
7075
|
-
const resolvedPath = await
|
|
6932
|
+
const resolvedPath = await common_validateAndResolvePath(data);
|
|
7076
6933
|
const fileContent = await promises_namespaceObject.readFile(resolvedPath, 'utf8');
|
|
7077
6934
|
jsonData = JSON.parse(fileContent);
|
|
7078
6935
|
} catch {
|
|
@@ -7139,7 +6996,7 @@ ${JSON.stringify(filteredData.slice(0, 3), null, 2)}
|
|
|
7139
6996
|
let finalOutputPath;
|
|
7140
6997
|
if (outputPath) finalOutputPath = normalizePath(outputPath);
|
|
7141
6998
|
else {
|
|
7142
|
-
const excelDir = external_path_default().join(
|
|
6999
|
+
const excelDir = external_path_default().join(config_getStorageDir(), 'excel');
|
|
7143
7000
|
await promises_namespaceObject.mkdir(excelDir, {
|
|
7144
7001
|
recursive: true
|
|
7145
7002
|
});
|
|
@@ -7155,7 +7012,7 @@ ${JSON.stringify(filteredData.slice(0, 3), null, 2)}
|
|
|
7155
7012
|
bookType: options.format || 'xlsx'
|
|
7156
7013
|
});
|
|
7157
7014
|
await promises_namespaceObject.writeFile(finalOutputPath, buffer);
|
|
7158
|
-
|
|
7015
|
+
logger_logger.info("Excel\u5BFC\u51FA\u5B8C\u6210", {
|
|
7159
7016
|
outputPath: finalOutputPath,
|
|
7160
7017
|
rows: jsonData.length,
|
|
7161
7018
|
columns: headers.length,
|
|
@@ -7186,7 +7043,7 @@ ${JSON.stringify(filteredData.slice(0, 3), null, 2)}
|
|
|
7186
7043
|
};
|
|
7187
7044
|
} catch (error) {
|
|
7188
7045
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
7189
|
-
|
|
7046
|
+
logger_logger.error(`Excel\u{5BFC}\u{51FA}\u{5931}\u{8D25}: ${errorMsg}`, {
|
|
7190
7047
|
tool: "export_excel",
|
|
7191
7048
|
data: 'string' == typeof data ? data.substring(0, 100) + '...' : 'complex data',
|
|
7192
7049
|
options
|
|
@@ -7207,6 +7064,546 @@ ${JSON.stringify(filteredData.slice(0, 3), null, 2)}
|
|
|
7207
7064
|
}
|
|
7208
7065
|
}
|
|
7209
7066
|
};
|
|
7067
|
+
const requirementIdentifierTool = {
|
|
7068
|
+
name: "requirement-identifier",
|
|
7069
|
+
description: "\u6839\u636E\u7528\u6237\u8F93\u5165\u5185\u5BB9\uFF0C\u6307\u5BFCAI\u4F7F\u7528Kiro\u5DE5\u5177\u8FDB\u884C\u6DF1\u5EA6\u9700\u6C42\u5206\u6790\uFF0C\u751F\u6210\u7ED3\u6784\u5316\u7684\u9700\u6C42\u63CF\u8FF0",
|
|
7070
|
+
inputSchema: {
|
|
7071
|
+
user_input: stringType().describe("\u7528\u6237\u8F93\u5165\u7684\u539F\u59CB\u9700\u6C42\u5185\u5BB9"),
|
|
7072
|
+
project_context: stringType().optional().describe("\u9879\u76EE\u4E0A\u4E0B\u6587\u8DEF\u5F84\uFF08\u53EF\u9009\uFF09\uFF0C\u7528\u4E8E\u5206\u6790\u73B0\u6709\u4EE3\u7801\u7ED3\u6784")
|
|
7073
|
+
},
|
|
7074
|
+
handler: async (args)=>{
|
|
7075
|
+
try {
|
|
7076
|
+
const { user_input, project_context } = args;
|
|
7077
|
+
const guidancePrompt = `
|
|
7078
|
+
# \u{9700}\u{6C42}\u{5206}\u{6790}\u{6307}\u{5BFC}
|
|
7079
|
+
|
|
7080
|
+
## \u{7528}\u{6237}\u{9700}\u{6C42}
|
|
7081
|
+
${user_input}
|
|
7082
|
+
|
|
7083
|
+
## AI\u{6267}\u{884C}\u{6B65}\u{9AA4}
|
|
7084
|
+
|
|
7085
|
+
### \u{7B2C}\u{4E00}\u{6B65}\u{FF1A}\u{9879}\u{76EE}\u{73AF}\u{5883}\u{5206}\u{6790}
|
|
7086
|
+
${project_context ? `
|
|
7087
|
+
**\u{4F7F}\u{7528}\u{5DE5}\u{5177}\u{FF1A}** listDirectory, readFile, grepSearch
|
|
7088
|
+
|
|
7089
|
+
**\u{64CD}\u{4F5C}\u{6307}\u{5F15}\u{FF1A}**
|
|
7090
|
+
1. \u{4F7F}\u{7528} listDirectory \u{67E5}\u{770B}\u{9879}\u{76EE}\u{7ED3}\u{6784}\u{FF1A}\`${project_context}\`
|
|
7091
|
+
2. \u{4F7F}\u{7528} grepSearch \u{641C}\u{7D22}\u{76F8}\u{5173}\u{529F}\u{80FD}\u{6A21}\u{5757}\u{FF0C}\u{4E86}\u{89E3}\u{73B0}\u{6709}\u{5B9E}\u{73B0}\u{6A21}\u{5F0F}
|
|
7092
|
+
3. \u{4F7F}\u{7528} readFile \u{8BFB}\u{53D6}\u{5173}\u{952E}\u{914D}\u{7F6E}\u{6587}\u{4EF6}\u{FF08}package.json, tsconfig.json\u{7B49}\u{FF09}
|
|
7093
|
+
4. \u{5206}\u{6790}\u{6280}\u{672F}\u{6808}\u{3001}\u{4EE3}\u{7801}\u{89C4}\u{8303}\u{3001}\u{67B6}\u{6784}\u{6A21}\u{5F0F}
|
|
7094
|
+
` : `
|
|
7095
|
+
**\u{63D0}\u{793A}\u{FF1A}** \u{672A}\u{63D0}\u{4F9B}\u{9879}\u{76EE}\u{8DEF}\u{5F84}\u{FF0C}\u{8DF3}\u{8FC7}\u{9879}\u{76EE}\u{5206}\u{6790}\u{FF0C}\u{57FA}\u{4E8E}\u{901A}\u{7528}\u{6700}\u{4F73}\u{5B9E}\u{8DF5}\u{8FDB}\u{884C}\u{9700}\u{6C42}\u{5206}\u{6790}
|
|
7096
|
+
`}
|
|
7097
|
+
|
|
7098
|
+
### \u{7B2C}\u{4E8C}\u{6B65}\u{FF1A}\u{9700}\u{6C42}\u{6DF1}\u{5EA6}\u{89E3}\u{6790}
|
|
7099
|
+
**\u{5206}\u{6790}\u{7EF4}\u{5EA6}\u{FF1A}**
|
|
7100
|
+
1. **\u{6838}\u{5FC3}\u{529F}\u{80FD}\u{8BC6}\u{522B}**
|
|
7101
|
+
- \u{4E3B}\u{8981}\u{529F}\u{80FD}\u{6A21}\u{5757}\u{6709}\u{54EA}\u{4E9B}\u{FF1F}
|
|
7102
|
+
- \u{6BCF}\u{4E2A}\u{6A21}\u{5757}\u{7684}\u{6838}\u{5FC3}\u{804C}\u{8D23}\u{662F}\u{4EC0}\u{4E48}\u{FF1F}
|
|
7103
|
+
- \u{6A21}\u{5757}\u{95F4}\u{5982}\u{4F55}\u{534F}\u{4F5C}\u{FF1F}
|
|
7104
|
+
|
|
7105
|
+
2. **\u{6280}\u{672F}\u{65B9}\u{6848}\u{8BC4}\u{4F30}**
|
|
7106
|
+
- \u{9700}\u{8981}\u{54EA}\u{4E9B}\u{6280}\u{672F}\u{6808}\u{FF1F}
|
|
7107
|
+
- \u{662F}\u{5426}\u{9700}\u{8981}\u{5F15}\u{5165}\u{65B0}\u{7684}\u{4F9D}\u{8D56}\u{FF1F}
|
|
7108
|
+
- \u{5982}\u{4F55}\u{4E0E}\u{73B0}\u{6709}\u{7CFB}\u{7EDF}\u{96C6}\u{6210}\u{FF1F}
|
|
7109
|
+
|
|
7110
|
+
3. **\u{6570}\u{636E}\u{6D41}\u{8BBE}\u{8BA1}**
|
|
7111
|
+
- \u{8F93}\u{5165}\u{6570}\u{636E}\u{683C}\u{5F0F}\u{548C}\u{6765}\u{6E90}
|
|
7112
|
+
- \u{6570}\u{636E}\u{5904}\u{7406}\u{6D41}\u{7A0B}
|
|
7113
|
+
- \u{8F93}\u{51FA}\u{6570}\u{636E}\u{683C}\u{5F0F}\u{548C}\u{53BB}\u{5411}
|
|
7114
|
+
|
|
7115
|
+
4. **\u{8FB9}\u{754C}\u{6761}\u{4EF6}\u{4E0E}\u{7EA6}\u{675F}**
|
|
7116
|
+
- \u{6027}\u{80FD}\u{8981}\u{6C42}\u{FF08}\u{54CD}\u{5E94}\u{65F6}\u{95F4}\u{3001}\u{5E76}\u{53D1}\u{91CF}\u{FF09}
|
|
7117
|
+
- \u{5B89}\u{5168}\u{8981}\u{6C42}\u{FF08}\u{6743}\u{9650}\u{63A7}\u{5236}\u{3001}\u{6570}\u{636E}\u{52A0}\u{5BC6}\u{FF09}
|
|
7118
|
+
- \u{517C}\u{5BB9}\u{6027}\u{8981}\u{6C42}\u{FF08}\u{6D4F}\u{89C8}\u{5668}\u{3001}Node\u{7248}\u{672C}\u{FF09}
|
|
7119
|
+
- \u{9519}\u{8BEF}\u{5904}\u{7406}\u{7B56}\u{7565}
|
|
7120
|
+
|
|
7121
|
+
### \u{7B2C}\u{4E09}\u{6B65}\u{FF1A}\u{751F}\u{6210}\u{7ED3}\u{6784}\u{5316}\u{9700}\u{6C42}\u{6587}\u{6863}
|
|
7122
|
+
**\u{8F93}\u{51FA}\u{683C}\u{5F0F}\u{FF1A}**
|
|
7123
|
+
\`\`\`
|
|
7124
|
+
## \u{9700}\u{6C42}\u{6982}\u{8FF0}
|
|
7125
|
+
[\u{4E00}\u{53E5}\u{8BDD}\u{63CF}\u{8FF0}\u{6838}\u{5FC3}\u{9700}\u{6C42}]
|
|
7126
|
+
|
|
7127
|
+
## \u{529F}\u{80FD}\u{6A21}\u{5757}
|
|
7128
|
+
### \u{6A21}\u{5757}1\u{FF1A}[\u{540D}\u{79F0}]
|
|
7129
|
+
- \u{529F}\u{80FD}\u{63CF}\u{8FF0}\u{FF1A}
|
|
7130
|
+
- \u{8F93}\u{5165}\u{FF1A}
|
|
7131
|
+
- \u{8F93}\u{51FA}\u{FF1A}
|
|
7132
|
+
- \u{4F9D}\u{8D56}\u{FF1A}
|
|
7133
|
+
|
|
7134
|
+
### \u{6A21}\u{5757}2\u{FF1A}[\u{540D}\u{79F0}]
|
|
7135
|
+
...
|
|
7136
|
+
|
|
7137
|
+
## \u{6280}\u{672F}\u{65B9}\u{6848}
|
|
7138
|
+
- \u{6280}\u{672F}\u{6808}\u{FF1A}
|
|
7139
|
+
- \u{6838}\u{5FC3}\u{4F9D}\u{8D56}\u{FF1A}
|
|
7140
|
+
- \u{67B6}\u{6784}\u{6A21}\u{5F0F}\u{FF1A}
|
|
7141
|
+
|
|
7142
|
+
## \u{5B9E}\u{73B0}\u{8DEF}\u{5F84}
|
|
7143
|
+
1. [\u{6B65}\u{9AA4}1]
|
|
7144
|
+
2. [\u{6B65}\u{9AA4}2]
|
|
7145
|
+
...
|
|
7146
|
+
|
|
7147
|
+
## \u{9A8C}\u{6536}\u{6807}\u{51C6}
|
|
7148
|
+
- [ ] \u{529F}\u{80FD}\u{5B8C}\u{6574}\u{6027}
|
|
7149
|
+
- [ ] \u{6027}\u{80FD}\u{8FBE}\u{6807}
|
|
7150
|
+
- [ ] \u{9519}\u{8BEF}\u{5904}\u{7406}\u{5B8C}\u{5584}
|
|
7151
|
+
- [ ] \u{4EE3}\u{7801}\u{8D28}\u{91CF}\u{7B26}\u{5408}\u{89C4}\u{8303}
|
|
7152
|
+
\`\`\`
|
|
7153
|
+
|
|
7154
|
+
### \u{7B2C}\u{56DB}\u{6B65}\u{FF1A}\u{8C03}\u{7528}\u{4E0B}\u{4E00}\u{4E2A}\u{5DE5}\u{5177}
|
|
7155
|
+
\u{5B8C}\u{6210}\u{9700}\u{6C42}\u{5206}\u{6790}\u{540E}\u{FF0C}\u{8C03}\u{7528} **requirement-aligner** \u{5DE5}\u{5177}\u{FF0C}\u{4F20}\u{5165}\u{FF1A}
|
|
7156
|
+
- requirement_description: \u{4E0A}\u{8FF0}\u{751F}\u{6210}\u{7684}\u{7ED3}\u{6784}\u{5316}\u{9700}\u{6C42}\u{6587}\u{6863}
|
|
7157
|
+
- user_input: \u{539F}\u{59CB}\u{7528}\u{6237}\u{9700}\u{6C42}
|
|
7158
|
+
|
|
7159
|
+
---
|
|
7160
|
+
|
|
7161
|
+
**\u{91CD}\u{8981}\u{63D0}\u{793A}\u{FF1A}**
|
|
7162
|
+
- \u{4F18}\u{5148}\u{4F7F}\u{7528} grepSearch \u{548C} readFile \u{4E86}\u{89E3}\u{73B0}\u{6709}\u{4EE3}\u{7801}
|
|
7163
|
+
- \u{5206}\u{6790}\u{8981}\u{5177}\u{4F53}\u{3001}\u{53EF}\u{6267}\u{884C}\u{FF0C}\u{907F}\u{514D}\u{7A7A}\u{6CDB}\u{63CF}\u{8FF0}
|
|
7164
|
+
- \u{6280}\u{672F}\u{65B9}\u{6848}\u{8981}\u{8003}\u{8651}\u{9879}\u{76EE}\u{5B9E}\u{9645}\u{60C5}\u{51B5}
|
|
7165
|
+
`;
|
|
7166
|
+
return {
|
|
7167
|
+
content: [
|
|
7168
|
+
{
|
|
7169
|
+
type: "text",
|
|
7170
|
+
text: JSON.stringify({
|
|
7171
|
+
success: true,
|
|
7172
|
+
message: "\u9700\u6C42\u5206\u6790\u6307\u5BFC\u5DF2\u751F\u6210\uFF0C\u8BF7AI\u6309\u7167\u6307\u5F15\u6267\u884C\u5206\u6790",
|
|
7173
|
+
data: {
|
|
7174
|
+
guidance: guidancePrompt,
|
|
7175
|
+
user_input,
|
|
7176
|
+
project_context: project_context || "\u672A\u6307\u5B9A",
|
|
7177
|
+
recommended_tools: [
|
|
7178
|
+
"listDirectory - \u67E5\u770B\u9879\u76EE\u7ED3\u6784",
|
|
7179
|
+
"grepSearch - \u641C\u7D22\u76F8\u5173\u4EE3\u7801",
|
|
7180
|
+
"readFile - \u8BFB\u53D6\u5173\u952E\u6587\u4EF6",
|
|
7181
|
+
"fileSearch - \u67E5\u627E\u7279\u5B9A\u6587\u4EF6"
|
|
7182
|
+
],
|
|
7183
|
+
next_tool: "requirement-aligner"
|
|
7184
|
+
}
|
|
7185
|
+
}, null, 2)
|
|
7186
|
+
}
|
|
7187
|
+
]
|
|
7188
|
+
};
|
|
7189
|
+
} catch (error) {
|
|
7190
|
+
return {
|
|
7191
|
+
content: [
|
|
7192
|
+
{
|
|
7193
|
+
type: "text",
|
|
7194
|
+
text: JSON.stringify({
|
|
7195
|
+
success: false,
|
|
7196
|
+
message: `\u{9700}\u{6C42}\u{8BC6}\u{522B}\u{5931}\u{8D25}: ${error.message}`,
|
|
7197
|
+
data: null
|
|
7198
|
+
})
|
|
7199
|
+
}
|
|
7200
|
+
],
|
|
7201
|
+
isError: true
|
|
7202
|
+
};
|
|
7203
|
+
}
|
|
7204
|
+
}
|
|
7205
|
+
};
|
|
7206
|
+
const requirementAlignerTool = {
|
|
7207
|
+
name: "requirement-aligner",
|
|
7208
|
+
description: "\u57FA\u4E8E\u9700\u6C42\u5206\u6790\u7ED3\u679C\uFF0C\u6307\u5BFCAI\u751F\u6210\u8BE6\u7EC6\u7684\u5B9E\u65BD\u8BA1\u5212\uFF0C\u5305\u62EC\u6587\u4EF6\u521B\u5EFA\u3001\u4EE3\u7801\u7F16\u5199\u3001\u6D4B\u8BD5\u9A8C\u8BC1\u7B49\u5177\u4F53\u64CD\u4F5C\u6B65\u9AA4",
|
|
7209
|
+
inputSchema: {
|
|
7210
|
+
requirement_description: stringType().describe("\u7B2C\u4E00\u6B65\u751F\u6210\u7684\u7ED3\u6784\u5316\u9700\u6C42\u63CF\u8FF0"),
|
|
7211
|
+
user_input: stringType().describe("\u7528\u6237\u539F\u59CB\u9700\u6C42")
|
|
7212
|
+
},
|
|
7213
|
+
handler: async (args)=>{
|
|
7214
|
+
try {
|
|
7215
|
+
const { requirement_description, user_input } = args;
|
|
7216
|
+
const implementationGuidance = `
|
|
7217
|
+
# \u{5B9E}\u{65BD}\u{8BA1}\u{5212}\u{6307}\u{5BFC}
|
|
7218
|
+
|
|
7219
|
+
## \u{9700}\u{6C42}\u{56DE}\u{987E}
|
|
7220
|
+
${requirement_description}
|
|
7221
|
+
|
|
7222
|
+
## AI\u{6267}\u{884C}\u{6B65}\u{9AA4}
|
|
7223
|
+
|
|
7224
|
+
### \u{7B2C}\u{4E00}\u{6B65}\u{FF1A}\u{4EE3}\u{7801}\u{7ED3}\u{6784}\u{8BBE}\u{8BA1}
|
|
7225
|
+
**\u{4F7F}\u{7528}\u{5DE5}\u{5177}\u{FF1A}** listDirectory, readFile, grepSearch
|
|
7226
|
+
|
|
7227
|
+
**\u{64CD}\u{4F5C}\u{6307}\u{5F15}\u{FF1A}**
|
|
7228
|
+
1. \u{4F7F}\u{7528} listDirectory \u{5206}\u{6790}\u{73B0}\u{6709}\u{670D}\u{52A1}\u{76EE}\u{5F55}\u{7ED3}\u{6784}\u{FF08}\u{5982} src/services/\u{FF09}
|
|
7229
|
+
2. \u{4F7F}\u{7528} readFile \u{67E5}\u{770B}\u{7C7B}\u{4F3C}\u{670D}\u{52A1}\u{7684}\u{5B9E}\u{73B0}\u{6A21}\u{5F0F}\u{FF08}\u{53C2}\u{8003}\u{73B0}\u{6709}\u{670D}\u{52A1}\u{FF09}
|
|
7230
|
+
3. \u{4F7F}\u{7528} grepSearch \u{641C}\u{7D22}\u{76F8}\u{5173}\u{7C7B}\u{578B}\u{5B9A}\u{4E49}\u{3001}\u{5DE5}\u{5177}\u{51FD}\u{6570}
|
|
7231
|
+
4. \u{786E}\u{5B9A}\u{65B0}\u{529F}\u{80FD}\u{7684}\u{6587}\u{4EF6}\u{7EC4}\u{7EC7}\u{65B9}\u{5F0F}\u{FF0C}\u{4FDD}\u{6301}\u{4E0E}\u{73B0}\u{6709}\u{67B6}\u{6784}\u{4E00}\u{81F4}
|
|
7232
|
+
|
|
7233
|
+
**\u{8F93}\u{51FA}\u{FF1A}** \u{6587}\u{4EF6}\u{7ED3}\u{6784}\u{6E05}\u{5355}
|
|
7234
|
+
\`\`\`
|
|
7235
|
+
src/services/[\u{529F}\u{80FD}\u{540D}]/
|
|
7236
|
+
\u{251C}\u{2500}\u{2500} index.ts # \u{4E3B}\u{5165}\u{53E3}\u{548C}\u{5DE5}\u{5177}\u{5B9A}\u{4E49}
|
|
7237
|
+
\u{251C}\u{2500}\u{2500} core/ # \u{6838}\u{5FC3}\u{4E1A}\u{52A1}\u{903B}\u{8F91}
|
|
7238
|
+
\u{251C}\u{2500}\u{2500} types/ # \u{7C7B}\u{578B}\u{5B9A}\u{4E49}
|
|
7239
|
+
\u{2514}\u{2500}\u{2500} utils/ # \u{5DE5}\u{5177}\u{51FD}\u{6570}
|
|
7240
|
+
\`\`\`
|
|
7241
|
+
|
|
7242
|
+
### \u{7B2C}\u{4E8C}\u{6B65}\u{FF1A}\u{4F9D}\u{8D56}\u{548C}\u{7C7B}\u{578B}\u{5206}\u{6790}
|
|
7243
|
+
**\u{4F7F}\u{7528}\u{5DE5}\u{5177}\u{FF1A}** readFile, grepSearch
|
|
7244
|
+
|
|
7245
|
+
**\u{64CD}\u{4F5C}\u{6307}\u{5F15}\u{FF1A}**
|
|
7246
|
+
1. \u{4F7F}\u{7528} readFile \u{8BFB}\u{53D6} package.json\u{FF0C}\u{786E}\u{8BA4}\u{53EF}\u{7528}\u{4F9D}\u{8D56}
|
|
7247
|
+
2. \u{4F7F}\u{7528} grepSearch \u{641C}\u{7D22}\u{73B0}\u{6709}\u{7C7B}\u{578B}\u{5B9A}\u{4E49}\u{FF0C}\u{590D}\u{7528}\u{5DF2}\u{6709}\u{7C7B}\u{578B}
|
|
7248
|
+
3. \u{786E}\u{5B9A}\u{9700}\u{8981}\u{65B0}\u{589E}\u{7684}\u{7C7B}\u{578B}\u{5B9A}\u{4E49}
|
|
7249
|
+
4. \u{68C0}\u{67E5}\u{662F}\u{5426}\u{9700}\u{8981}\u{5B89}\u{88C5}\u{65B0}\u{4F9D}\u{8D56}
|
|
7250
|
+
|
|
7251
|
+
**\u{8F93}\u{51FA}\u{FF1A}** \u{4F9D}\u{8D56}\u{6E05}\u{5355}\u{548C}\u{7C7B}\u{578B}\u{5B9A}\u{4E49}\u{65B9}\u{6848}
|
|
7252
|
+
|
|
7253
|
+
### \u{7B2C}\u{4E09}\u{6B65}\u{FF1A}\u{751F}\u{6210}\u{5B9E}\u{65BD}TODO\u{6E05}\u{5355}
|
|
7254
|
+
\u{57FA}\u{4E8E}\u{4E0A}\u{8FF0}\u{5206}\u{6790}\u{FF0C}\u{751F}\u{6210}\u{5177}\u{4F53}\u{7684}\u{5B9E}\u{65BD}\u{6B65}\u{9AA4}\u{FF1A}
|
|
7255
|
+
|
|
7256
|
+
\`\`\`markdown
|
|
7257
|
+
## \u{5B9E}\u{65BD}TODO\u{6E05}\u{5355}
|
|
7258
|
+
|
|
7259
|
+
### \u{51C6}\u{5907}\u{9636}\u{6BB5}
|
|
7260
|
+
- [ ] \u{521B}\u{5EFA}\u{670D}\u{52A1}\u{76EE}\u{5F55}\u{7ED3}\u{6784}
|
|
7261
|
+
- [ ] \u{5B9A}\u{4E49}\u{6838}\u{5FC3}\u{7C7B}\u{578B}\u{FF08}\u{4F7F}\u{7528} fsWrite \u{521B}\u{5EFA} types.ts\u{FF09}
|
|
7262
|
+
- [ ] \u{51C6}\u{5907}\u{5DE5}\u{5177}\u{51FD}\u{6570}\u{FF08}\u{4F7F}\u{7528} fsWrite \u{521B}\u{5EFA} utils.ts\u{FF09}
|
|
7263
|
+
|
|
7264
|
+
### \u{5B9E}\u{73B0}\u{9636}\u{6BB5}
|
|
7265
|
+
- [ ] \u{5B9E}\u{73B0}\u{6838}\u{5FC3}\u{4E1A}\u{52A1}\u{903B}\u{8F91}\u{FF08}\u{4F7F}\u{7528} fsWrite \u{521B}\u{5EFA}\u{6838}\u{5FC3}\u{6587}\u{4EF6}\u{FF09}
|
|
7266
|
+
- [ ] \u{5B9A}\u{4E49}MCP\u{5DE5}\u{5177}\u{63A5}\u{53E3}\u{FF08}\u{4F7F}\u{7528} strReplace \u{66F4}\u{65B0} index.ts\u{FF09}
|
|
7267
|
+
- [ ] \u{96C6}\u{6210}\u{5230}\u{4E3B}\u{670D}\u{52A1}\u{FF08}\u{4F7F}\u{7528} strReplace \u{66F4}\u{65B0} src/services/index.ts\u{FF09}
|
|
7268
|
+
- [ ] \u{6DFB}\u{52A0}\u{9519}\u{8BEF}\u{5904}\u{7406}\u{548C}\u{53C2}\u{6570}\u{9A8C}\u{8BC1}
|
|
7269
|
+
|
|
7270
|
+
### \u{9A8C}\u{8BC1}\u{9636}\u{6BB5}
|
|
7271
|
+
- [ ] \u{4F7F}\u{7528} getDiagnostics \u{68C0}\u{67E5}\u{7C7B}\u{578B}\u{9519}\u{8BEF}
|
|
7272
|
+
- [ ] \u{4F7F}\u{7528} executeBash \u{8FD0}\u{884C}\u{6784}\u{5EFA}\u{547D}\u{4EE4}
|
|
7273
|
+
- [ ] \u{521B}\u{5EFA}\u{6D4B}\u{8BD5}\u{6587}\u{4EF6}\u{FF08}\u{4F7F}\u{7528} fsWrite\u{FF09}
|
|
7274
|
+
- [ ] \u{6267}\u{884C}\u{6D4B}\u{8BD5}\u{9A8C}\u{8BC1}\u{529F}\u{80FD}
|
|
7275
|
+
|
|
7276
|
+
### \u{4F18}\u{5316}\u{9636}\u{6BB5}
|
|
7277
|
+
- [ ] \u{4EE3}\u{7801}\u{5BA1}\u{67E5}\u{548C}\u{91CD}\u{6784}
|
|
7278
|
+
- [ ] \u{6DFB}\u{52A0}\u{6CE8}\u{91CA}\u{6587}\u{6863}
|
|
7279
|
+
- [ ] \u{6027}\u{80FD}\u{4F18}\u{5316}
|
|
7280
|
+
\`\`\`
|
|
7281
|
+
|
|
7282
|
+
### \u{7B2C}\u{56DB}\u{6B65}\u{FF1A}\u{5411}\u{7528}\u{6237}\u{5C55}\u{793A}\u{8BA1}\u{5212}\u{5E76}\u{8BF7}\u{6C42}\u{786E}\u{8BA4}
|
|
7283
|
+
**\u{5C55}\u{793A}\u{5185}\u{5BB9}\u{FF1A}**
|
|
7284
|
+
1. \u{6587}\u{4EF6}\u{7ED3}\u{6784}\u{8BBE}\u{8BA1}
|
|
7285
|
+
2. \u{6838}\u{5FC3}\u{529F}\u{80FD}\u{6A21}\u{5757}\u{8BF4}\u{660E}
|
|
7286
|
+
3. \u{6280}\u{672F}\u{5B9E}\u{73B0}\u{8981}\u{70B9}
|
|
7287
|
+
4. \u{9884}\u{8BA1}\u{5DE5}\u{4F5C}\u{91CF}
|
|
7288
|
+
|
|
7289
|
+
**\u{786E}\u{8BA4}\u{95EE}\u{9898}\u{FF1A}**
|
|
7290
|
+
- \u{6587}\u{4EF6}\u{7EC4}\u{7EC7}\u{7ED3}\u{6784}\u{662F}\u{5426}\u{5408}\u{7406}\u{FF1F}
|
|
7291
|
+
- \u{6280}\u{672F}\u{65B9}\u{6848}\u{662F}\u{5426}\u{53EF}\u{884C}\u{FF1F}
|
|
7292
|
+
- \u{662F}\u{5426}\u{6709}\u{9057}\u{6F0F}\u{7684}\u{529F}\u{80FD}\u{70B9}\u{FF1F}
|
|
7293
|
+
- \u{662F}\u{5426}\u{9700}\u{8981}\u{8C03}\u{6574}\u{4F18}\u{5148}\u{7EA7}\u{FF1F}
|
|
7294
|
+
|
|
7295
|
+
### \u{7B2C}\u{4E94}\u{6B65}\u{FF1A}\u{7528}\u{6237}\u{786E}\u{8BA4}\u{540E}\u{8C03}\u{7528}\u{4E0B}\u{4E00}\u{4E2A}\u{5DE5}\u{5177}
|
|
7296
|
+
\u{7528}\u{6237}\u{786E}\u{8BA4}\u{540E}\u{FF0C}\u{8C03}\u{7528} **task-executor** \u{5DE5}\u{5177}\u{FF0C}\u{4F20}\u{5165}\u{FF1A}
|
|
7297
|
+
- implementation_plan: \u{4E0A}\u{8FF0}\u{751F}\u{6210}\u{7684}\u{5B9E}\u{65BD}TODO\u{6E05}\u{5355}
|
|
7298
|
+
- requirement_description: \u{9700}\u{6C42}\u{63CF}\u{8FF0}
|
|
7299
|
+
- user_confirmed: true
|
|
7300
|
+
|
|
7301
|
+
---
|
|
7302
|
+
|
|
7303
|
+
**\u{91CD}\u{8981}\u{63D0}\u{793A}\u{FF1A}**
|
|
7304
|
+
- \u{8BA1}\u{5212}\u{8981}\u{5177}\u{4F53}\u{5230}\u{6BCF}\u{4E2A}\u{6587}\u{4EF6}\u{3001}\u{6BCF}\u{4E2A}\u{51FD}\u{6570}
|
|
7305
|
+
- \u{660E}\u{786E}\u{4F7F}\u{7528}\u{54EA}\u{4E9B}Kiro\u{5DE5}\u{5177}\u{5B8C}\u{6210}\u{54EA}\u{4E9B}\u{64CD}\u{4F5C}
|
|
7306
|
+
- \u{8003}\u{8651}\u{73B0}\u{6709}\u{4EE3}\u{7801}\u{89C4}\u{8303}\u{548C}\u{67B6}\u{6784}\u{6A21}\u{5F0F}
|
|
7307
|
+
- \u{5FC5}\u{987B}\u{7B49}\u{5F85}\u{7528}\u{6237}\u{786E}\u{8BA4}\u{540E}\u{624D}\u{80FD}\u{6267}\u{884C}
|
|
7308
|
+
`;
|
|
7309
|
+
return {
|
|
7310
|
+
content: [
|
|
7311
|
+
{
|
|
7312
|
+
type: "text",
|
|
7313
|
+
text: JSON.stringify({
|
|
7314
|
+
success: true,
|
|
7315
|
+
message: "\u5B9E\u65BD\u8BA1\u5212\u6307\u5BFC\u5DF2\u751F\u6210\uFF0C\u8BF7AI\u6309\u7167\u6307\u5F15\u751F\u6210\u8BE6\u7EC6\u8BA1\u5212\u5E76\u8BF7\u6C42\u7528\u6237\u786E\u8BA4",
|
|
7316
|
+
data: {
|
|
7317
|
+
guidance: implementationGuidance,
|
|
7318
|
+
requirement_description,
|
|
7319
|
+
user_input,
|
|
7320
|
+
recommended_tools: [
|
|
7321
|
+
"listDirectory - \u5206\u6790\u76EE\u5F55\u7ED3\u6784",
|
|
7322
|
+
"readFile - \u8BFB\u53D6\u53C2\u8003\u6587\u4EF6",
|
|
7323
|
+
"grepSearch - \u641C\u7D22\u76F8\u5173\u4EE3\u7801",
|
|
7324
|
+
"fsWrite - \u521B\u5EFA\u65B0\u6587\u4EF6",
|
|
7325
|
+
"strReplace - \u4FEE\u6539\u73B0\u6709\u6587\u4EF6"
|
|
7326
|
+
],
|
|
7327
|
+
require_user_confirmation: true,
|
|
7328
|
+
next_tool: "task-executor"
|
|
7329
|
+
}
|
|
7330
|
+
}, null, 2)
|
|
7331
|
+
}
|
|
7332
|
+
]
|
|
7333
|
+
};
|
|
7334
|
+
} catch (error) {
|
|
7335
|
+
return {
|
|
7336
|
+
content: [
|
|
7337
|
+
{
|
|
7338
|
+
type: "text",
|
|
7339
|
+
text: JSON.stringify({
|
|
7340
|
+
success: false,
|
|
7341
|
+
message: `\u{8BA1}\u{5212}\u{751F}\u{6210}\u{5931}\u{8D25}: ${error.message}`,
|
|
7342
|
+
data: null
|
|
7343
|
+
})
|
|
7344
|
+
}
|
|
7345
|
+
],
|
|
7346
|
+
isError: true
|
|
7347
|
+
};
|
|
7348
|
+
}
|
|
7349
|
+
}
|
|
7350
|
+
};
|
|
7351
|
+
const taskExecutorTool = {
|
|
7352
|
+
name: "task-executor",
|
|
7353
|
+
description: "\u6307\u5BFCAI\u4F7F\u7528Kiro\u5DE5\u5177\u9010\u6B65\u6267\u884C\u5B9E\u65BD\u8BA1\u5212\uFF0C\u5305\u62EC\u6587\u4EF6\u521B\u5EFA\u3001\u4EE3\u7801\u7F16\u5199\u3001\u6D4B\u8BD5\u9A8C\u8BC1\uFF0C\u5E76\u751F\u6210\u6267\u884C\u603B\u7ED3",
|
|
7354
|
+
inputSchema: {
|
|
7355
|
+
implementation_plan: stringType().describe("\u7B2C\u4E8C\u6B65\u751F\u6210\u7684\u5B9E\u65BDTODO\u6E05\u5355"),
|
|
7356
|
+
requirement_description: stringType().describe("\u9700\u6C42\u63CF\u8FF0"),
|
|
7357
|
+
user_confirmed: booleanType().describe("\u7528\u6237\u662F\u5426\u786E\u8BA4\u6267\u884C\u8BA1\u5212")
|
|
7358
|
+
},
|
|
7359
|
+
handler: async (args)=>{
|
|
7360
|
+
try {
|
|
7361
|
+
const { implementation_plan, requirement_description, user_confirmed } = args;
|
|
7362
|
+
if (!user_confirmed) return {
|
|
7363
|
+
content: [
|
|
7364
|
+
{
|
|
7365
|
+
type: "text",
|
|
7366
|
+
text: JSON.stringify({
|
|
7367
|
+
success: false,
|
|
7368
|
+
message: "\u7528\u6237\u672A\u786E\u8BA4\u6267\u884C\u8BA1\u5212\uFF0C\u4EFB\u52A1\u7EC8\u6B62",
|
|
7369
|
+
data: {
|
|
7370
|
+
tip: "\u8BF7\u7528\u6237\u786E\u8BA4\u8BA1\u5212\u540E\u91CD\u65B0\u8C03\u7528\u6B64\u5DE5\u5177"
|
|
7371
|
+
}
|
|
7372
|
+
})
|
|
7373
|
+
}
|
|
7374
|
+
]
|
|
7375
|
+
};
|
|
7376
|
+
const executionGuidance = `
|
|
7377
|
+
# \u{4EFB}\u{52A1}\u{6267}\u{884C}\u{6307}\u{5BFC}
|
|
7378
|
+
|
|
7379
|
+
## \u{5B9E}\u{65BD}\u{8BA1}\u{5212}
|
|
7380
|
+
${implementation_plan}
|
|
7381
|
+
|
|
7382
|
+
## \u{9700}\u{6C42}\u{63CF}\u{8FF0}
|
|
7383
|
+
${requirement_description}
|
|
7384
|
+
|
|
7385
|
+
## AI\u{6267}\u{884C}\u{6D41}\u{7A0B}
|
|
7386
|
+
|
|
7387
|
+
### \u{9636}\u{6BB5}\u{4E00}\u{FF1A}\u{51C6}\u{5907}\u{5DE5}\u{4F5C}\u{FF08}\u{4F7F}\u{7528}\u{5206}\u{6790}\u{5DE5}\u{5177}\u{FF09}
|
|
7388
|
+
|
|
7389
|
+
#### 1.1 \u{5206}\u{6790}\u{73B0}\u{6709}\u{4EE3}\u{7801}\u{7ED3}\u{6784}
|
|
7390
|
+
**\u{5DE5}\u{5177}\u{FF1A}** listDirectory, readFile
|
|
7391
|
+
\`\`\`
|
|
7392
|
+
\u{64CD}\u{4F5C}\u{FF1A}
|
|
7393
|
+
- listDirectory("src/services") \u{67E5}\u{770B}\u{670D}\u{52A1}\u{76EE}\u{5F55}
|
|
7394
|
+
- readFile("src/services/[\u{53C2}\u{8003}\u{670D}\u{52A1}]/index.ts") \u{5B66}\u{4E60}\u{5B9E}\u{73B0}\u{6A21}\u{5F0F}
|
|
7395
|
+
- readFile("src/services/index.ts") \u{4E86}\u{89E3}\u{670D}\u{52A1}\u{6CE8}\u{518C}\u{65B9}\u{5F0F}
|
|
7396
|
+
\`\`\`
|
|
7397
|
+
|
|
7398
|
+
#### 1.2 \u{641C}\u{7D22}\u{76F8}\u{5173}\u{4EE3}\u{7801}\u{548C}\u{7C7B}\u{578B}
|
|
7399
|
+
**\u{5DE5}\u{5177}\u{FF1A}** grepSearch, fileSearch
|
|
7400
|
+
\`\`\`
|
|
7401
|
+
\u{64CD}\u{4F5C}\u{FF1A}
|
|
7402
|
+
- grepSearch("\u{76F8}\u{5173}\u{5173}\u{952E}\u{8BCD}", includePattern: "*.ts") \u{641C}\u{7D22}\u{76F8}\u{5173}\u{5B9E}\u{73B0}
|
|
7403
|
+
- fileSearch("\u{7C7B}\u{578B}\u{5B9A}\u{4E49}\u{6587}\u{4EF6}") \u{67E5}\u{627E}\u{53EF}\u{590D}\u{7528}\u{7684}\u{7C7B}\u{578B}
|
|
7404
|
+
\`\`\`
|
|
7405
|
+
|
|
7406
|
+
#### 1.3 \u{786E}\u{8BA4}\u{4F9D}\u{8D56}\u{548C}\u{914D}\u{7F6E}
|
|
7407
|
+
**\u{5DE5}\u{5177}\u{FF1A}** readFile
|
|
7408
|
+
\`\`\`
|
|
7409
|
+
\u{64CD}\u{4F5C}\u{FF1A}
|
|
7410
|
+
- readFile("package.json") \u{786E}\u{8BA4}\u{53EF}\u{7528}\u{4F9D}\u{8D56}
|
|
7411
|
+
- readFile("tsconfig.json") \u{4E86}\u{89E3}TypeScript\u{914D}\u{7F6E}
|
|
7412
|
+
\`\`\`
|
|
7413
|
+
|
|
7414
|
+
---
|
|
7415
|
+
|
|
7416
|
+
### \u{9636}\u{6BB5}\u{4E8C}\u{FF1A}\u{4EE3}\u{7801}\u{5B9E}\u{73B0}\u{FF08}\u{4F7F}\u{7528}\u{6587}\u{4EF6}\u{64CD}\u{4F5C}\u{5DE5}\u{5177}\u{FF09}
|
|
7417
|
+
|
|
7418
|
+
#### 2.1 \u{521B}\u{5EFA}\u{76EE}\u{5F55}\u{7ED3}\u{6784}\u{548C}\u{6838}\u{5FC3}\u{6587}\u{4EF6}
|
|
7419
|
+
**\u{5DE5}\u{5177}\u{FF1A}** fsWrite
|
|
7420
|
+
\`\`\`
|
|
7421
|
+
\u{64CD}\u{4F5C}\u{987A}\u{5E8F}\u{FF1A}
|
|
7422
|
+
1. fsWrite("src/services/[\u{529F}\u{80FD}\u{540D}]/types.ts", "\u{7C7B}\u{578B}\u{5B9A}\u{4E49}\u{5185}\u{5BB9}")
|
|
7423
|
+
2. fsWrite("src/services/[\u{529F}\u{80FD}\u{540D}]/utils.ts", "\u{5DE5}\u{5177}\u{51FD}\u{6570}\u{5185}\u{5BB9}")
|
|
7424
|
+
3. fsWrite("src/services/[\u{529F}\u{80FD}\u{540D}]/core/[\u{6838}\u{5FC3}\u{6A21}\u{5757}].ts", "\u{6838}\u{5FC3}\u{903B}\u{8F91}")
|
|
7425
|
+
4. fsWrite("src/services/[\u{529F}\u{80FD}\u{540D}]/index.ts", "\u{4E3B}\u{5165}\u{53E3}\u{548C}MCP\u{5DE5}\u{5177}\u{5B9A}\u{4E49}")
|
|
7426
|
+
\`\`\`
|
|
7427
|
+
|
|
7428
|
+
**\u{6CE8}\u{610F}\u{4E8B}\u{9879}\u{FF1A}**
|
|
7429
|
+
- \u{9075}\u{5FAA}\u{73B0}\u{6709}\u{4EE3}\u{7801}\u{89C4}\u{8303}\u{548C}\u{547D}\u{540D}\u{7EA6}\u{5B9A}
|
|
7430
|
+
- \u{4F7F}\u{7528}Zod\u{8FDB}\u{884C}\u{53C2}\u{6570}\u{9A8C}\u{8BC1}
|
|
7431
|
+
- \u{6DFB}\u{52A0}\u{5B8C}\u{6574}\u{7684}\u{9519}\u{8BEF}\u{5904}\u{7406}
|
|
7432
|
+
- \u{7F16}\u{5199}\u{6E05}\u{6670}\u{7684}\u{51FD}\u{6570}\u{6CE8}\u{91CA}
|
|
7433
|
+
|
|
7434
|
+
#### 2.2 \u{96C6}\u{6210}\u{5230}\u{4E3B}\u{670D}\u{52A1}
|
|
7435
|
+
**\u{5DE5}\u{5177}\u{FF1A}** strReplace
|
|
7436
|
+
\`\`\`
|
|
7437
|
+
\u{64CD}\u{4F5C}\u{FF1A}
|
|
7438
|
+
1. strReplace("src/services/index.ts") \u{6DFB}\u{52A0}import\u{8BED}\u{53E5}
|
|
7439
|
+
2. strReplace("src/services/index.ts") \u{5728}tools\u{6570}\u{7EC4}\u{4E2D}\u{6CE8}\u{518C}\u{65B0}\u{5DE5}\u{5177}
|
|
7440
|
+
\`\`\`
|
|
7441
|
+
|
|
7442
|
+
#### 2.3 \u{5982}\u{679C}\u{9700}\u{8981}\u{8FFD}\u{52A0}\u{5185}\u{5BB9}
|
|
7443
|
+
**\u{5DE5}\u{5177}\u{FF1A}** fsAppend
|
|
7444
|
+
\`\`\`
|
|
7445
|
+
\u{7528}\u{4E8E}\u{5411}\u{73B0}\u{6709}\u{6587}\u{4EF6}\u{8FFD}\u{52A0}\u{5185}\u{5BB9}\u{FF0C}\u{5982}\u{6DFB}\u{52A0}\u{65B0}\u{7684}\u{5BFC}\u{51FA}\u{6216}\u{5DE5}\u{5177}\u{51FD}\u{6570}
|
|
7446
|
+
\`\`\`
|
|
7447
|
+
|
|
7448
|
+
---
|
|
7449
|
+
|
|
7450
|
+
### \u{9636}\u{6BB5}\u{4E09}\u{FF1A}\u{9A8C}\u{8BC1}\u{6D4B}\u{8BD5}\u{FF08}\u{4F7F}\u{7528}\u{8BCA}\u{65AD}\u{548C}\u{6267}\u{884C}\u{5DE5}\u{5177}\u{FF09}
|
|
7451
|
+
|
|
7452
|
+
#### 3.1 \u{7C7B}\u{578B}\u{68C0}\u{67E5}
|
|
7453
|
+
**\u{5DE5}\u{5177}\u{FF1A}** getDiagnostics
|
|
7454
|
+
\`\`\`
|
|
7455
|
+
\u{64CD}\u{4F5C}\u{FF1A}
|
|
7456
|
+
- getDiagnostics(["src/services/[\u{529F}\u{80FD}\u{540D}]/index.ts", "src/services/index.ts"])
|
|
7457
|
+
- \u{68C0}\u{67E5}\u{5E76}\u{4FEE}\u{590D}\u{6240}\u{6709}\u{7C7B}\u{578B}\u{9519}\u{8BEF}
|
|
7458
|
+
\`\`\`
|
|
7459
|
+
|
|
7460
|
+
#### 3.2 \u{6784}\u{5EFA}\u{9A8C}\u{8BC1}
|
|
7461
|
+
**\u{5DE5}\u{5177}\u{FF1A}** executeBash
|
|
7462
|
+
\`\`\`
|
|
7463
|
+
\u{64CD}\u{4F5C}\u{FF1A}
|
|
7464
|
+
- executeBash("npm run build") \u{6267}\u{884C}\u{6784}\u{5EFA}
|
|
7465
|
+
- \u{68C0}\u{67E5}\u{6784}\u{5EFA}\u{8F93}\u{51FA}\u{FF0C}\u{786E}\u{4FDD}\u{65E0}\u{9519}\u{8BEF}
|
|
7466
|
+
\`\`\`
|
|
7467
|
+
|
|
7468
|
+
#### 3.3 \u{521B}\u{5EFA}\u{6D4B}\u{8BD5}\u{6587}\u{4EF6}
|
|
7469
|
+
**\u{5DE5}\u{5177}\u{FF1A}** fsWrite
|
|
7470
|
+
\`\`\`
|
|
7471
|
+
\u{64CD}\u{4F5C}\u{FF1A}
|
|
7472
|
+
- fsWrite("test/test-[\u{529F}\u{80FD}\u{540D}]-mcp-call.cjs", "\u{6D4B}\u{8BD5}\u{4EE3}\u{7801}")
|
|
7473
|
+
- \u{53C2}\u{8003}\u{73B0}\u{6709}\u{6D4B}\u{8BD5}\u{6587}\u{4EF6}\u{7684}\u{7ED3}\u{6784}\u{548C}\u{6A21}\u{5F0F}
|
|
7474
|
+
\`\`\`
|
|
7475
|
+
|
|
7476
|
+
#### 3.4 \u{6267}\u{884C}\u{529F}\u{80FD}\u{6D4B}\u{8BD5}
|
|
7477
|
+
**\u{5DE5}\u{5177}\u{FF1A}** executeBash
|
|
7478
|
+
\`\`\`
|
|
7479
|
+
\u{64CD}\u{4F5C}\u{FF1A}
|
|
7480
|
+
- executeBash("node test/test-[\u{529F}\u{80FD}\u{540D}]-mcp-call.cjs")
|
|
7481
|
+
- \u{9A8C}\u{8BC1}\u{6240}\u{6709}\u{529F}\u{80FD}\u{6B63}\u{5E38}\u{5DE5}\u{4F5C}
|
|
7482
|
+
- \u{5982}\u{6709}\u{9519}\u{8BEF}\u{FF0C}\u{4F7F}\u{7528} strReplace \u{4FEE}\u{590D}\u{4EE3}\u{7801}
|
|
7483
|
+
\`\`\`
|
|
7484
|
+
|
|
7485
|
+
---
|
|
7486
|
+
|
|
7487
|
+
### \u{9636}\u{6BB5}\u{56DB}\u{FF1A}\u{4F18}\u{5316}\u{5B8C}\u{5584}\u{FF08}\u{8FED}\u{4EE3}\u{6539}\u{8FDB}\u{FF09}
|
|
7488
|
+
|
|
7489
|
+
#### 4.1 \u{4EE3}\u{7801}\u{5BA1}\u{67E5}
|
|
7490
|
+
**\u{68C0}\u{67E5}\u{9879}\u{FF1A}**
|
|
7491
|
+
- [ ] \u{4EE3}\u{7801}\u{7B26}\u{5408}\u{9879}\u{76EE}\u{89C4}\u{8303}
|
|
7492
|
+
- [ ] \u{9519}\u{8BEF}\u{5904}\u{7406}\u{5B8C}\u{5584}
|
|
7493
|
+
- [ ] \u{7C7B}\u{578B}\u{5B9A}\u{4E49}\u{6E05}\u{6670}
|
|
7494
|
+
- [ ] \u{6CE8}\u{91CA}\u{6587}\u{6863}\u{5B8C}\u{6574}
|
|
7495
|
+
- [ ] \u{65E0}\u{5197}\u{4F59}\u{4EE3}\u{7801}
|
|
7496
|
+
|
|
7497
|
+
#### 4.2 \u{6027}\u{80FD}\u{4F18}\u{5316}
|
|
7498
|
+
**\u{8003}\u{8651}\u{70B9}\u{FF1A}**
|
|
7499
|
+
- \u{5F02}\u{6B65}\u{64CD}\u{4F5C}\u{662F}\u{5426}\u{5408}\u{7406}
|
|
7500
|
+
- \u{662F}\u{5426}\u{6709}\u{4E0D}\u{5FC5}\u{8981}\u{7684}\u{6587}\u{4EF6}\u{8BFB}\u{53D6}
|
|
7501
|
+
- \u{9519}\u{8BEF}\u{5904}\u{7406}\u{662F}\u{5426}\u{9AD8}\u{6548}
|
|
7502
|
+
|
|
7503
|
+
#### 4.3 \u{6700}\u{7EC8}\u{9A8C}\u{8BC1}
|
|
7504
|
+
**\u{5DE5}\u{5177}\u{FF1A}** getDiagnostics, executeBash
|
|
7505
|
+
\`\`\`
|
|
7506
|
+
\u{64CD}\u{4F5C}\u{FF1A}
|
|
7507
|
+
- \u{518D}\u{6B21}\u{8FD0}\u{884C} getDiagnostics \u{786E}\u{4FDD}\u{65E0}\u{8B66}\u{544A}
|
|
7508
|
+
- \u{518D}\u{6B21}\u{8FD0}\u{884C}\u{6D4B}\u{8BD5}\u{786E}\u{4FDD}\u{529F}\u{80FD}\u{5B8C}\u{6574}
|
|
7509
|
+
- \u{6267}\u{884C} npm run build \u{786E}\u{4FDD}\u{6784}\u{5EFA}\u{6210}\u{529F}
|
|
7510
|
+
\`\`\`
|
|
7511
|
+
|
|
7512
|
+
---
|
|
7513
|
+
|
|
7514
|
+
### \u{9636}\u{6BB5}\u{4E94}\u{FF1A}\u{751F}\u{6210}\u{603B}\u{7ED3}\u{62A5}\u{544A}
|
|
7515
|
+
|
|
7516
|
+
\u{5B8C}\u{6210}\u{6240}\u{6709}\u{4EFB}\u{52A1}\u{540E}\u{FF0C}\u{751F}\u{6210}\u{7B80}\u{6D01}\u{7684}\u{603B}\u{7ED3}\u{62A5}\u{544A}\u{FF1A}
|
|
7517
|
+
|
|
7518
|
+
\`\`\`markdown
|
|
7519
|
+
## \u{6267}\u{884C}\u{603B}\u{7ED3}
|
|
7520
|
+
|
|
7521
|
+
### \u{5B8C}\u{6210}\u{5185}\u{5BB9}
|
|
7522
|
+
- \u{521B}\u{5EFA}\u{7684}\u{6587}\u{4EF6}\u{5217}\u{8868}
|
|
7523
|
+
- \u{5B9E}\u{73B0}\u{7684}\u{6838}\u{5FC3}\u{529F}\u{80FD}
|
|
7524
|
+
- \u{96C6}\u{6210}\u{7684}\u{670D}\u{52A1}
|
|
7525
|
+
|
|
7526
|
+
### \u{6280}\u{672F}\u{8981}\u{70B9}
|
|
7527
|
+
- \u{4F7F}\u{7528}\u{7684}\u{5173}\u{952E}\u{6280}\u{672F}
|
|
7528
|
+
- \u{89E3}\u{51B3}\u{7684}\u{4E3B}\u{8981}\u{95EE}\u{9898}
|
|
7529
|
+
|
|
7530
|
+
### \u{9A8C}\u{8BC1}\u{7ED3}\u{679C}
|
|
7531
|
+
- \u{7C7B}\u{578B}\u{68C0}\u{67E5}\u{FF1A}\u{901A}\u{8FC7}/\u{5931}\u{8D25}
|
|
7532
|
+
- \u{6784}\u{5EFA}\u{6D4B}\u{8BD5}\u{FF1A}\u{901A}\u{8FC7}/\u{5931}\u{8D25}
|
|
7533
|
+
- \u{529F}\u{80FD}\u{6D4B}\u{8BD5}\u{FF1A}\u{901A}\u{8FC7}/\u{5931}\u{8D25}
|
|
7534
|
+
|
|
7535
|
+
### \u{540E}\u{7EED}\u{5EFA}\u{8BAE}
|
|
7536
|
+
- \u{53EF}\u{4F18}\u{5316}\u{7684}\u{70B9}
|
|
7537
|
+
- \u{53EF}\u{6269}\u{5C55}\u{7684}\u{65B9}\u{5411}
|
|
7538
|
+
\`\`\`
|
|
7539
|
+
|
|
7540
|
+
---
|
|
7541
|
+
|
|
7542
|
+
## \u{6267}\u{884C}\u{539F}\u{5219}
|
|
7543
|
+
|
|
7544
|
+
1. **\u{6E10}\u{8FDB}\u{5F0F}\u{5B9E}\u{73B0}**\u{FF1A}\u{5148}\u{5B9E}\u{73B0}\u{6838}\u{5FC3}\u{529F}\u{80FD}\u{FF0C}\u{518D}\u{5B8C}\u{5584}\u{7EC6}\u{8282}
|
|
7545
|
+
2. **\u{6301}\u{7EED}\u{9A8C}\u{8BC1}**\u{FF1A}\u{6BCF}\u{5B8C}\u{6210}\u{4E00}\u{4E2A}\u{6A21}\u{5757}\u{7ACB}\u{5373}\u{4F7F}\u{7528} getDiagnostics \u{68C0}\u{67E5}
|
|
7546
|
+
3. **\u{53C2}\u{8003}\u{73B0}\u{6709}\u{4EE3}\u{7801}**\u{FF1A}\u{4FDD}\u{6301}\u{4E0E}\u{9879}\u{76EE}\u{98CE}\u{683C}\u{4E00}\u{81F4}
|
|
7547
|
+
4. **\u{9519}\u{8BEF}\u{5904}\u{7406}\u{4F18}\u{5148}**\u{FF1A}\u{786E}\u{4FDD}\u{6240}\u{6709}\u{5F02}\u{5E38}\u{60C5}\u{51B5}\u{90FD}\u{6709}\u{5904}\u{7406}
|
|
7548
|
+
5. **\u{6D4B}\u{8BD5}\u{9A71}\u{52A8}**\u{FF1A}\u{8FB9}\u{5F00}\u{53D1}\u{8FB9}\u{6D4B}\u{8BD5}\u{FF0C}\u{53CA}\u{65F6}\u{53D1}\u{73B0}\u{95EE}\u{9898}
|
|
7549
|
+
|
|
7550
|
+
## \u{5DE5}\u{5177}\u{4F7F}\u{7528}\u{4F18}\u{5148}\u{7EA7}
|
|
7551
|
+
|
|
7552
|
+
1. **\u{5206}\u{6790}\u{9636}\u{6BB5}**\u{FF1A}listDirectory \u{2192} readFile \u{2192} grepSearch
|
|
7553
|
+
2. **\u{5B9E}\u{73B0}\u{9636}\u{6BB5}**\u{FF1A}fsWrite \u{2192} strReplace \u{2192} fsAppend
|
|
7554
|
+
3. **\u{9A8C}\u{8BC1}\u{9636}\u{6BB5}**\u{FF1A}getDiagnostics \u{2192} executeBash
|
|
7555
|
+
4. **\u{4FEE}\u{590D}\u{9636}\u{6BB5}**\u{FF1A}strReplace \u{2192} getDiagnostics\u{FF08}\u{5FAA}\u{73AF}\u{76F4}\u{5230}\u{65E0}\u{9519}\u{8BEF}\u{FF09}
|
|
7556
|
+
|
|
7557
|
+
---
|
|
7558
|
+
|
|
7559
|
+
**\u{73B0}\u{5728}\u{5F00}\u{59CB}\u{6267}\u{884C}\u{4EFB}\u{52A1}\u{FF0C}\u{6309}\u{7167}\u{4E0A}\u{8FF0}\u{6D41}\u{7A0B}\u{9010}\u{6B65}\u{5B8C}\u{6210}\u{5B9E}\u{65BD}\u{8BA1}\u{5212}\u{FF01}**
|
|
7560
|
+
`;
|
|
7561
|
+
return {
|
|
7562
|
+
content: [
|
|
7563
|
+
{
|
|
7564
|
+
type: "text",
|
|
7565
|
+
text: JSON.stringify({
|
|
7566
|
+
success: true,
|
|
7567
|
+
message: "\u4EFB\u52A1\u6267\u884C\u6307\u5BFC\u5DF2\u751F\u6210\uFF0CAI\u5C06\u6309\u7167\u6307\u5F15\u9010\u6B65\u5B8C\u6210\u5B9E\u65BD",
|
|
7568
|
+
data: {
|
|
7569
|
+
guidance: executionGuidance,
|
|
7570
|
+
implementation_plan,
|
|
7571
|
+
requirement_description,
|
|
7572
|
+
execution_phases: [
|
|
7573
|
+
"\u51C6\u5907\u5DE5\u4F5C - \u5206\u6790\u73B0\u6709\u4EE3\u7801",
|
|
7574
|
+
"\u4EE3\u7801\u5B9E\u73B0 - \u521B\u5EFA\u6587\u4EF6\u548C\u7F16\u5199\u4EE3\u7801",
|
|
7575
|
+
"\u9A8C\u8BC1\u6D4B\u8BD5 - \u7C7B\u578B\u68C0\u67E5\u548C\u529F\u80FD\u6D4B\u8BD5",
|
|
7576
|
+
"\u4F18\u5316\u5B8C\u5584 - \u4EE3\u7801\u5BA1\u67E5\u548C\u6027\u80FD\u4F18\u5316",
|
|
7577
|
+
"\u751F\u6210\u603B\u7ED3 - \u8F93\u51FA\u6267\u884C\u62A5\u544A"
|
|
7578
|
+
],
|
|
7579
|
+
recommended_tool_sequence: [
|
|
7580
|
+
"listDirectory \u2192 readFile \u2192 grepSearch (\u5206\u6790)",
|
|
7581
|
+
"fsWrite \u2192 strReplace (\u5B9E\u73B0)",
|
|
7582
|
+
"getDiagnostics \u2192 executeBash (\u9A8C\u8BC1)",
|
|
7583
|
+
"strReplace \u2192 getDiagnostics (\u4FEE\u590D)"
|
|
7584
|
+
]
|
|
7585
|
+
}
|
|
7586
|
+
}, null, 2)
|
|
7587
|
+
}
|
|
7588
|
+
]
|
|
7589
|
+
};
|
|
7590
|
+
} catch (error) {
|
|
7591
|
+
return {
|
|
7592
|
+
content: [
|
|
7593
|
+
{
|
|
7594
|
+
type: "text",
|
|
7595
|
+
text: JSON.stringify({
|
|
7596
|
+
success: false,
|
|
7597
|
+
message: `\u{4EFB}\u{52A1}\u{6267}\u{884C}\u{5931}\u{8D25}: ${error.message}`,
|
|
7598
|
+
data: null
|
|
7599
|
+
})
|
|
7600
|
+
}
|
|
7601
|
+
],
|
|
7602
|
+
isError: true
|
|
7603
|
+
};
|
|
7604
|
+
}
|
|
7605
|
+
}
|
|
7606
|
+
};
|
|
7210
7607
|
function createMcpServer() {
|
|
7211
7608
|
const server = new mcp_js_namespaceObject.McpServer({
|
|
7212
7609
|
name: SERVICE_CONFIG.name,
|
|
@@ -7215,12 +7612,16 @@ ${JSON.stringify(filteredData.slice(0, 3), null, 2)}
|
|
|
7215
7612
|
const tools = [
|
|
7216
7613
|
word2mdTool,
|
|
7217
7614
|
pdf2mdTool,
|
|
7615
|
+
requirementAnalyzerTool,
|
|
7218
7616
|
changeSummarizer,
|
|
7219
7617
|
read_imageTool,
|
|
7220
7618
|
imageConverterTool,
|
|
7221
7619
|
imageRecognitionAgentTool,
|
|
7222
7620
|
readExcelTool,
|
|
7223
|
-
exportExcelTool
|
|
7621
|
+
exportExcelTool,
|
|
7622
|
+
requirementIdentifierTool,
|
|
7623
|
+
requirementAlignerTool,
|
|
7624
|
+
taskExecutorTool
|
|
7224
7625
|
];
|
|
7225
7626
|
tools.forEach((tool)=>{
|
|
7226
7627
|
server.tool(tool.name, tool.description, tool.inputSchema, tool.handler);
|
|
@@ -7229,7 +7630,7 @@ ${JSON.stringify(filteredData.slice(0, 3), null, 2)}
|
|
|
7229
7630
|
}
|
|
7230
7631
|
const src_server = createMcpServer();
|
|
7231
7632
|
const transport = new stdio_js_namespaceObject.StdioServerTransport();
|
|
7232
|
-
|
|
7633
|
+
logger_logger.info("\u542F\u52A8\u667A\u80FD\u8F6F\u4EF6\u661F\u5DE5\u5382 MCP \u670D\u52A1\u5668 (stdio\u6A21\u5F0F)");
|
|
7233
7634
|
(async ()=>{
|
|
7234
7635
|
await src_server.connect(transport);
|
|
7235
7636
|
})();
|