intention-coding 0.5.0 → 0.5.1
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 +565 -3098
- package/dist/services/code-generator/index.d.ts +4 -4
- package/dist/services/export-excel/index.d.ts +172 -0
- package/dist/services/export-excel/index.d.ts.map +1 -0
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/integrated-generator/index.d.ts +2 -2
- package/dist/services/project-template/index.d.ts +2 -2
- package/dist/services/read-excel/index.d.ts +120 -0
- package/dist/services/read-excel/index.d.ts.map +1 -0
- package/dist/services/requirement-analyzer/index.d.ts +4 -4
- package/dist/services/requirement-handler/index.d.ts +6 -6
- package/package.json +1 -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 = 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 = 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.end(()=>{
|
|
163
|
+
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.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.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.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.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;
|
|
@@ -275,7 +275,7 @@ var __webpack_exports__ = {};
|
|
|
275
275
|
if (null === _PROJECT_ROOT) _PROJECT_ROOT = detectProjectRoot();
|
|
276
276
|
return _PROJECT_ROOT;
|
|
277
277
|
};
|
|
278
|
-
|
|
278
|
+
(()=>{
|
|
279
279
|
try {
|
|
280
280
|
return getProjectRoot();
|
|
281
281
|
} catch (error) {
|
|
@@ -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.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 getStorageDir = ()=>{
|
|
295
295
|
try {
|
|
296
296
|
const cachedRoot = contextManager.getCachedData("project_root");
|
|
297
297
|
if (cachedRoot && 'string' == typeof cachedRoot) return cachedRoot + "/.aico";
|
|
@@ -312,21 +312,20 @@ var __webpack_exports__ = {};
|
|
|
312
312
|
description: "\u8F6F\u4EF6\u5DE5\u7A0B\u5316\u7684\u9700\u6C42\u5206\u6790\uFF0C\u529F\u80FD\u8BBE\u8BA1\uFF0C\u4EE3\u7801\u7F16\u5199\uFF0C\u6D4B\u8BD5\u8FD0\u884C\u548C\u53D1\u5E03\u90E8\u7F72"
|
|
313
313
|
};
|
|
314
314
|
const promises_namespaceObject = require("fs/promises");
|
|
315
|
-
var promises_default = /*#__PURE__*/ __webpack_require__.n(promises_namespaceObject);
|
|
316
315
|
const external_mammoth_namespaceObject = require("mammoth");
|
|
317
316
|
var external_mammoth_default = /*#__PURE__*/ __webpack_require__.n(external_mammoth_namespaceObject);
|
|
318
317
|
const external_html_to_md_namespaceObject = require("html-to-md");
|
|
319
318
|
var external_html_to_md_default = /*#__PURE__*/ __webpack_require__.n(external_html_to_md_namespaceObject);
|
|
320
319
|
const external_os_namespaceObject = require("os");
|
|
321
|
-
const
|
|
322
|
-
async function
|
|
320
|
+
const sanitizeFileName = (input)=>input.replace(/[\\/:*?"<>|\n\r#%&]/g, '').trim().replace(/\s+/g, '_').replace(/_+/g, '_').replace(/^_+|_+$/g, '');
|
|
321
|
+
async function validateAndResolvePath(filePath) {
|
|
323
322
|
if ('win32' === process.platform && filePath.startsWith('\\\\')) filePath = '\\\\?\\UNC\\' + filePath.substring(2);
|
|
324
323
|
const normalized = external_path_default().normalize(filePath);
|
|
325
324
|
const resolved = external_path_default().resolve(normalized);
|
|
326
325
|
try {
|
|
327
326
|
await external_fs_namespaceObject.promises.access(resolved, external_fs_namespaceObject.constants.R_OK);
|
|
328
327
|
} catch (error) {
|
|
329
|
-
|
|
328
|
+
logger.warn(`\u{6587}\u{4EF6}\u{4E0D}\u{5B58}\u{5728}\u{6216}\u{4E0D}\u{53EF}\u{8BFB}: ${resolved}`, error);
|
|
330
329
|
throw new Error(`\u{6587}\u{4EF6}\u{4E0D}\u{5B58}\u{5728}\u{6216}\u{4E0D}\u{53EF}\u{8BFB}: ${resolved}`);
|
|
331
330
|
}
|
|
332
331
|
return resolved;
|
|
@@ -3907,7 +3906,7 @@ var __webpack_exports__ = {};
|
|
|
3907
3906
|
ZodDiscriminatedUnion.create;
|
|
3908
3907
|
ZodIntersection.create;
|
|
3909
3908
|
ZodTuple.create;
|
|
3910
|
-
ZodRecord.create;
|
|
3909
|
+
const recordType = ZodRecord.create;
|
|
3911
3910
|
ZodMap.create;
|
|
3912
3911
|
ZodSet.create;
|
|
3913
3912
|
ZodFunction.create;
|
|
@@ -3948,9 +3947,9 @@ var __webpack_exports__ = {};
|
|
|
3948
3947
|
const { filePath } = args;
|
|
3949
3948
|
if (!filePath) throw new Error("\u6587\u4EF6\u8DEF\u5F84\u53C2\u6570\u7F3A\u5931\uFF0C\u8BF7\u63D0\u4F9B filePath \u53C2\u6570");
|
|
3950
3949
|
try {
|
|
3951
|
-
const resolvedPath = await
|
|
3950
|
+
const resolvedPath = await validateAndResolvePath(filePath);
|
|
3952
3951
|
const buffer = await promises_namespaceObject.readFile(resolvedPath);
|
|
3953
|
-
const mdDir = external_path_default().join(
|
|
3952
|
+
const mdDir = external_path_default().join(getStorageDir(), 'md');
|
|
3954
3953
|
const baseName = external_path_default().basename(filePath, '.docx');
|
|
3955
3954
|
const outputDir = external_path_default().join(mdDir, baseName);
|
|
3956
3955
|
const imgsDir = external_path_default().join(outputDir, 'imgs');
|
|
@@ -3960,7 +3959,7 @@ var __webpack_exports__ = {};
|
|
|
3960
3959
|
await promises_namespaceObject.mkdir(imgsDir, {
|
|
3961
3960
|
recursive: true
|
|
3962
3961
|
});
|
|
3963
|
-
|
|
3962
|
+
logger.info("\u5F00\u59CB\u8F6C\u6362Word\u6587\u6863", {
|
|
3964
3963
|
file: filePath,
|
|
3965
3964
|
outputDir,
|
|
3966
3965
|
imgsDir
|
|
@@ -3986,7 +3985,7 @@ var __webpack_exports__ = {};
|
|
|
3986
3985
|
await promises_namespaceObject.writeFile(imagePath, imageBuffer);
|
|
3987
3986
|
htmlContent = htmlContent.replace(img.fullMatch, `<img src="./imgs/${imageFileName}" />`);
|
|
3988
3987
|
} catch (err) {
|
|
3989
|
-
|
|
3988
|
+
logger.error("\u56FE\u7247\u5904\u7406\u5931\u8D25", {
|
|
3990
3989
|
error: err instanceof Error ? err.message : String(err),
|
|
3991
3990
|
imageNumber: i + 1
|
|
3992
3991
|
});
|
|
@@ -3997,7 +3996,7 @@ var __webpack_exports__ = {};
|
|
|
3997
3996
|
value: htmlContent,
|
|
3998
3997
|
messages: basicResult.messages
|
|
3999
3998
|
};
|
|
4000
|
-
if (htmlResult.messages && htmlResult.messages.length > 0)
|
|
3999
|
+
if (htmlResult.messages && htmlResult.messages.length > 0) logger.warn("Word\u8F6C\u6362\u8B66\u544A", {
|
|
4001
4000
|
file: filePath,
|
|
4002
4001
|
warnings: htmlResult.messages
|
|
4003
4002
|
});
|
|
@@ -4022,7 +4021,7 @@ var __webpack_exports__ = {};
|
|
|
4022
4021
|
};
|
|
4023
4022
|
} catch (error) {
|
|
4024
4023
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
4025
|
-
|
|
4024
|
+
logger.error(`Word\u{8F6C}\u{6362}\u{5931}\u{8D25}: ${errorMsg}`, {
|
|
4026
4025
|
tool: "word2md",
|
|
4027
4026
|
filePath
|
|
4028
4027
|
});
|
|
@@ -4074,17 +4073,17 @@ var __webpack_exports__ = {};
|
|
|
4074
4073
|
const { preserve_formatting = true, extract_metadata = true } = options;
|
|
4075
4074
|
try {
|
|
4076
4075
|
initializeProjectRoot();
|
|
4077
|
-
const resolvedPath = await
|
|
4076
|
+
const resolvedPath = await validateAndResolvePath(file_path);
|
|
4078
4077
|
if (!file_path.toLowerCase().endsWith('.pdf')) throw new Error("\u6587\u4EF6\u5FC5\u987B\u662FPDF\u683C\u5F0F\uFF08.pdf\u6269\u5C55\u540D\uFF09");
|
|
4079
|
-
|
|
4078
|
+
logger.info("\u5F00\u59CB\u8BFB\u53D6PDF\u6587\u4EF6", {
|
|
4080
4079
|
file: file_path
|
|
4081
4080
|
});
|
|
4082
4081
|
const dataBuffer = await promises_namespaceObject.readFile(resolvedPath);
|
|
4083
|
-
|
|
4082
|
+
logger.info("\u5F00\u59CB\u89E3\u6790PDF\u5185\u5BB9");
|
|
4084
4083
|
const pdfParse = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "pdf-parse/lib/pdf-parse.js"));
|
|
4085
4084
|
const pdfData = await pdfParse.default(dataBuffer);
|
|
4086
|
-
const mdDir = external_path_default().join(
|
|
4087
|
-
const baseName =
|
|
4085
|
+
const mdDir = external_path_default().join(getStorageDir(), 'md');
|
|
4086
|
+
const baseName = sanitizeFileName(external_path_default().basename(file_path, '.pdf'));
|
|
4088
4087
|
const outputDir = external_path_default().join(mdDir, baseName);
|
|
4089
4088
|
await promises_namespaceObject.mkdir(outputDir, {
|
|
4090
4089
|
recursive: true
|
|
@@ -4113,7 +4112,7 @@ var __webpack_exports__ = {};
|
|
|
4113
4112
|
markdownLength: markdownContent.length,
|
|
4114
4113
|
outputFile: external_path_default().resolve(fullMdPath)
|
|
4115
4114
|
};
|
|
4116
|
-
|
|
4115
|
+
logger.info("PDF\u8F6C\u6362\u5B8C\u6210", stats);
|
|
4117
4116
|
return {
|
|
4118
4117
|
content: [
|
|
4119
4118
|
{
|
|
@@ -4140,7 +4139,7 @@ var __webpack_exports__ = {};
|
|
|
4140
4139
|
};
|
|
4141
4140
|
} catch (error) {
|
|
4142
4141
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
4143
|
-
|
|
4142
|
+
logger.error(`PDF\u{8F6C}\u{6362}\u{5931}\u{8D25}: ${errorMsg}`, {
|
|
4144
4143
|
tool: "pdf2md",
|
|
4145
4144
|
file_path,
|
|
4146
4145
|
error: errorMsg
|
|
@@ -4161,196 +4160,130 @@ var __webpack_exports__ = {};
|
|
|
4161
4160
|
}
|
|
4162
4161
|
}
|
|
4163
4162
|
};
|
|
4164
|
-
const
|
|
4165
|
-
async function pack_packProject(projectPath) {
|
|
4166
|
-
const mdDir = external_path_default().join(config_getStorageDir(), 'tech');
|
|
4167
|
-
await promises_default().mkdir(mdDir, {
|
|
4168
|
-
recursive: true
|
|
4169
|
-
});
|
|
4170
|
-
logger_logger.info(`\u{1F4C2} \u{6B63}\u{5728}\u{5206}\u{6790}\u{5F53}\u{524D}\u{672C}\u{5730}\u{9879}\u{76EE}`);
|
|
4171
|
-
const mdPath = external_path_default().join(mdDir, `\u{9879}\u{76EE}\u{67B6}\u{6784}\u{5206}\u{6790}.md`);
|
|
4172
|
-
const options = {
|
|
4173
|
-
output: mdPath,
|
|
4174
|
-
style: 'markdown',
|
|
4175
|
-
headerText: "\u667A\u80FD\u8F6F\u4EF6\u661F\u5DE5\u5382",
|
|
4176
|
-
fileSummary: true,
|
|
4177
|
-
removeEmptyLines: true,
|
|
4178
|
-
removeComments: true,
|
|
4179
|
-
showLineNumbers: true,
|
|
4180
|
-
compress: true,
|
|
4181
|
-
quiet: true,
|
|
4182
|
-
customPatterns: [
|
|
4183
|
-
"**/*.md",
|
|
4184
|
-
"**/*.log",
|
|
4185
|
-
"**/*.json",
|
|
4186
|
-
"**/*.txt",
|
|
4187
|
-
"**/*.dockerfile",
|
|
4188
|
-
"**/*.yml",
|
|
4189
|
-
"**/*.yaml",
|
|
4190
|
-
"**/*.sh",
|
|
4191
|
-
"**/*.env",
|
|
4192
|
-
"**/*.env.example",
|
|
4193
|
-
"**/LICENSE",
|
|
4194
|
-
"**/test/**"
|
|
4195
|
-
]
|
|
4196
|
-
};
|
|
4197
|
-
const targetPath = projectPath || config_PROJECT_ROOT;
|
|
4198
|
-
await (0, external_aico_pack_namespaceObject.runCli)([
|
|
4199
|
-
targetPath
|
|
4200
|
-
], process.cwd(), options);
|
|
4201
|
-
return mdPath;
|
|
4202
|
-
}
|
|
4203
|
-
const projectRulesPromptTemplate = `
|
|
4204
|
-
\u{4F60}\u{662F}\u{4E00}\u{4F4D}\u{4E13}\u{4E1A}\u{7684}\u{8F6F}\u{4EF6}\u{5F00}\u{53D1}\u{89C4}\u{8303}\u{4E13}\u{5BB6}\u{FF0C}\u{8BF7}\u{57FA}\u{4E8E}\u{63D0}\u{4F9B}\u{7684}\u{9879}\u{76EE}\u{67B6}\u{6784}\u{5206}\u{6790}\u{FF0C}\u{751F}\u{6210}\u{4E00}\u{4EFD}\u{5B8C}\u{6574}\u{7684}\u{9879}\u{76EE}\u{5F00}\u{53D1}\u{89C4}\u{5219}\u{6587}\u{4EF6}\u{3002}
|
|
4205
|
-
|
|
4206
|
-
## \u{9879}\u{76EE}\u{4FE1}\u{606F}
|
|
4207
|
-
- **\u{9879}\u{76EE}\u{540D}\u{79F0}**: {{projectName}}
|
|
4208
|
-
- **\u{5305}\u{542B}\u{793A}\u{4F8B}**: {{includeExamples}}
|
|
4209
|
-
|
|
4210
|
-
## \u{9879}\u{76EE}\u{67B6}\u{6784}\u{5206}\u{6790}
|
|
4211
|
-
\`\`\`
|
|
4212
|
-
{{projectAnalysis}}
|
|
4213
|
-
\`\`\`
|
|
4214
|
-
|
|
4215
|
-
{{customRulesSection}}
|
|
4216
|
-
|
|
4217
|
-
## \u{4EFB}\u{52A1}\u{8981}\u{6C42}
|
|
4218
|
-
\u{8BF7}\u{57FA}\u{4E8E}\u{9879}\u{76EE}\u{67B6}\u{6784}\u{5206}\u{6790}\u{FF0C}\u{667A}\u{80FD}\u{8BC6}\u{522B}\u{9879}\u{76EE}\u{7684}\u{6280}\u{672F}\u{6808}\u{548C}\u{8BED}\u{8A00}\u{7279}\u{5F81}\u{FF0C}\u{7136}\u{540E}\u{751F}\u{6210}\u{4E00}\u{4EFD}\u{5B8C}\u{6574}\u{7684}project_rules.md\u{6587}\u{4EF6}\u{5185}\u{5BB9}\u{3002}
|
|
4163
|
+
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}
|
|
4219
4164
|
|
|
4220
|
-
|
|
4221
|
-
\u{5F53}\u{9879}\u{76EE}\u{67B6}\u{6784}\u{5206}\u{6790}\u{5185}\u{5BB9}\u{8F83}\u{957F}\u{65F6}\u{FF0C}\u{8BF7}\u{91C7}\u{7528}\u{5206}\u{6BB5}\u{5904}\u{7406}\u{7684}\u{65B9}\u{5F0F}\u{FF1A}
|
|
4222
|
-
1. \u{9996}\u{5148}\u{901A}\u{8BFB}\u{5168}\u{90E8}\u{5185}\u{5BB9}\u{FF0C}\u{7406}\u{89E3}\u{6574}\u{4F53}\u{67B6}\u{6784}
|
|
4223
|
-
2. \u{7136}\u{540E}\u{9010}\u{6BB5}\u{5206}\u{6790}\u{FF0C}\u{6BCF}\u{6BB5}\u{5904}\u{7406}\u{5B8C}\u{6210}\u{540E}\u{8FDB}\u{884C}\u{603B}\u{7ED3}
|
|
4224
|
-
3. \u{6700}\u{7EC8}\u{6574}\u{5408}\u{6240}\u{6709}\u{5206}\u{6790}\u{7ED3}\u{679C}\u{751F}\u{6210}\u{5B8C}\u{6574}\u{7684}\u{89C4}\u{5219}\u{6587}\u{4EF6}
|
|
4165
|
+
\u{8BF7}\u{6309}\u{4EE5}\u{4E0B}\u{6B65}\u{9AA4}\u{8FDB}\u{884C}\u{5206}\u{6790}\u{FF1A}
|
|
4225
4166
|
|
|
4226
|
-
|
|
4227
|
-
\u{
|
|
4167
|
+
## 1. \u{4EE3}\u{7801}\u{5E93}\u{5206}\u{6790}
|
|
4168
|
+
\u{5206}\u{6790}\u{5F53}\u{524D}\u{4EE3}\u{7801}\u{5E93}\u{FF0C}\u{603B}\u{7ED3}\u{FF1A}
|
|
4169
|
+
- \u{4E3B}\u{8981}\u{529F}\u{80FD}\u{6A21}\u{5757}\u{53CA}\u{5176}\u{5B9E}\u{73B0}
|
|
4170
|
+
- \u{5173}\u{952E}\u{4E1A}\u{52A1}\u{903B}\u{8F91}\u{6D41}\u{7A0B}
|
|
4171
|
+
- \u{91CD}\u{8981}\u{6570}\u{636E}\u{7ED3}\u{6784}
|
|
4172
|
+
- \u{6838}\u{5FC3}\u{7B97}\u{6CD5}\u{5B9E}\u{73B0}
|
|
4228
4173
|
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
- **Java\u{540E}\u{7AEF}\u{9879}\u{76EE}**: pom.xml, build.gradle, src/main/java, *.java
|
|
4232
|
-
- **Python\u{9879}\u{76EE}**: requirements.txt, setup.py, pyproject.toml, *.py
|
|
4233
|
-
- **Go\u{9879}\u{76EE}**: go.mod, go.sum, *.go
|
|
4234
|
-
- **C#/.NET\u{9879}\u{76EE}**: *.csproj, *.sln, *.cs
|
|
4235
|
-
- **Vue.js\u{524D}\u{7AEF}**: package.json, *.vue, vite.config.js
|
|
4236
|
-
- **React\u{524D}\u{7AEF}**: package.json, *.jsx, *.tsx
|
|
4237
|
-
- **\u{5FAE}\u{670D}\u{52A1}\u{67B6}\u{6784}**: docker-compose.yml, kubernetes, \u{591A}\u{4E2A}\u{6A21}\u{5757}\u{76EE}\u{5F55}
|
|
4238
|
-
- **\u{5355}\u{4F53}\u{5E94}\u{7528}**: \u{4F20}\u{7EDF}\u{7684}\u{5206}\u{5C42}\u{67B6}\u{6784}
|
|
4174
|
+
## 2. \u{63A5}\u{53E3}\u{4E0E}\u{9700}\u{6C42}\u{5BF9}\u{5E94}\u{5173}\u{7CFB}\u{8868}
|
|
4175
|
+
\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}
|
|
4239
4176
|
|
|
4240
|
-
|
|
4241
|
-
|
|
4177
|
+
| \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} |
|
|
4178
|
+
|---------|---------|---------|-----|----------|
|
|
4179
|
+
| [\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}] |
|
|
4242
4180
|
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
- \u{67B6}\u{6784}\u{6A21}\u{5F0F}\u{FF08}\u{5FAE}\u{670D}\u{52A1}\u{3001}\u{5355}\u{4F53}\u{3001}\u{5206}\u{5C42}\u{7B49}\u{FF09}
|
|
4246
|
-
- \u{9879}\u{76EE}\u{89C4}\u{6A21}\u{548C}\u{590D}\u{6742}\u{5EA6}\u{8BF4}\u{660E}
|
|
4181
|
+
## 3. \u{6838}\u{5FC3}\u{903B}\u{8F91}\u{65B9}\u{6CD5}\u{8868}
|
|
4182
|
+
\u{5206}\u{6790}\u{6838}\u{5FC3}\u{4E1A}\u{52A1}\u{903B}\u{8F91}\u{65B9}\u{6CD5}\u{FF1A}
|
|
4247
4183
|
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
- \u{6587}\u{4EF6}\u{7EC4}\u{7EC7}\u{89C4}\u{5219}
|
|
4252
|
-
- \u{547D}\u{540D}\u{7EA6}\u{5B9A}
|
|
4184
|
+
| \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} |
|
|
4185
|
+
|---------|-------|---------|----------|
|
|
4186
|
+
| [methodName] | [ClassName] | [\u{529F}\u{80FD}\u{63CF}\u{8FF0}] | [\u{65B0}\u{589E}/\u{4FEE}\u{6539}/\u{5220}\u{9664}] |
|
|
4253
4187
|
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
- \u{4EE3}\u{7801}\u{98CE}\u{683C}\u{FF08}\u{7F29}\u{8FDB}\u{3001}\u{683C}\u{5F0F}\u{7B49}\u{FF09}
|
|
4257
|
-
- \u{6CE8}\u{91CA}\u{8981}\u{6C42}
|
|
4258
|
-
- \u{5BFC}\u{5165}\u{89C4}\u{5219}
|
|
4188
|
+
## 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}
|
|
4189
|
+
\u{5206}\u{6790}\u{524D}\u{7AEF}\u{9875}\u{9762}\u{53D8}\u{66F4}\u{FF1A}
|
|
4259
4190
|
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
- **API\u{8BBE}\u{8BA1}\u{89C4}\u{8303}**: RESTful\u{8BBE}\u{8BA1}\u{3001}\u{53C2}\u{6570}\u{6821}\u{9A8C}\u{3001}\u{8FD4}\u{56DE}\u{683C}\u{5F0F}
|
|
4264
|
-
- **\u{524D}\u{7AEF}\u{7EC4}\u{4EF6}\u{89C4}\u{8303}**: \u{7EC4}\u{4EF6}\u{547D}\u{540D}\u{3001}props\u{5B9A}\u{4E49}\u{3001}\u{4E8B}\u{4EF6}\u{5904}\u{7406}
|
|
4265
|
-
- **\u{670D}\u{52A1}\u{5C42}\u{89C4}\u{8303}**: \u{4E1A}\u{52A1}\u{903B}\u{8F91}\u{5C01}\u{88C5}\u{3001}\u{4E8B}\u{52A1}\u{5904}\u{7406}\u{3001}\u{5F02}\u{5E38}\u{5904}\u{7406}
|
|
4191
|
+
| \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} |
|
|
4192
|
+
|---------|---------|---------|---------|----------|
|
|
4193
|
+
| [\u{9875}\u{9762}\u{540D}\u{79F0}] | [Controller.method] | [ComponentName] | [/path] | [\u{65B0}\u{589E}/\u{4FEE}\u{6539}/\u{5220}\u{9664}] |
|
|
4266
4194
|
|
|
4267
|
-
|
|
4268
|
-
\u{
|
|
4269
|
-
- \u{5206}\u{5C42}\u{67B6}\u{6784}\u{89C4}\u{5219}\u{FF08}Controller-Service-Repository\u{7B49}\u{FF09}
|
|
4270
|
-
- \u{4F9D}\u{8D56}\u{6CE8}\u{5165}\u{6A21}\u{5F0F}
|
|
4271
|
-
- \u{9519}\u{8BEF}\u{5904}\u{7406}\u{6A21}\u{5F0F}
|
|
4272
|
-
- \u{6570}\u{636E}\u{9A8C}\u{8BC1}\u{6A21}\u{5F0F}
|
|
4273
|
-
- \u{6743}\u{9650}\u{63A7}\u{5236}\u{6A21}\u{5F0F}
|
|
4195
|
+
## 5. \u{524D}\u{7AEF}\u{6838}\u{5FC3}\u{7EC4}\u{4EF6}\u{8868}
|
|
4196
|
+
\u{5206}\u{6790}\u{524D}\u{7AEF}\u{7EC4}\u{4EF6}\u{53D8}\u{66F4}\u{FF1A}
|
|
4274
4197
|
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
- \u{5DE5}\u{5177}\u{548C}\u{5E93}\u{7684}\u{4F7F}\u{7528}\u{89C4}\u{8303}
|
|
4279
|
-
- \u{7B2C}\u{4E09}\u{65B9}\u{5E93}\u{4F7F}\u{7528}\u{89C4}\u{8303}
|
|
4280
|
-
- \u{5355}\u{5143}\u{6D4B}\u{8BD5}\u{65B9}\u{6CD5}
|
|
4198
|
+
| \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} |
|
|
4199
|
+
|---------|---------|---------|----------|
|
|
4200
|
+
| [ComponentName] | [PageName] | [\u{529F}\u{80FD}\u{63CF}\u{8FF0}] | [\u{65B0}\u{589E}/\u{4FEE}\u{6539}/\u{5220}\u{9664}] |
|
|
4281
4201
|
|
|
4282
|
-
|
|
4283
|
-
\u{
|
|
4284
|
-
-
|
|
4285
|
-
-
|
|
4286
|
-
-
|
|
4287
|
-
- \u{
|
|
4202
|
+
## 6. \u{9700}\u{6C42}\u{5B8C}\u{6574}\u{6027}\u{68C0}\u{67E5}
|
|
4203
|
+
\u{5BF9}\u{6BD4}\u{539F}\u{59CB}\u{9700}\u{6C42}\u{FF0C}\u{68C0}\u{67E5}\u{FF1A}
|
|
4204
|
+
- \u{2705} \u{5DF2}\u{5B8C}\u{6210}\u{7684}\u{529F}\u{80FD}
|
|
4205
|
+
- \u{26A0}\u{FE0F} \u{90E8}\u{5206}\u{5B8C}\u{6210}\u{7684}\u{529F}\u{80FD}
|
|
4206
|
+
- \u{274C} \u{672A}\u{5B9E}\u{73B0}\u{7684}\u{529F}\u{80FD}
|
|
4207
|
+
- \u{1F504} \u{9700}\u{8981}\u{8FDB}\u{4E00}\u{6B65}\u{5B8C}\u{5584}\u{7684}\u{529F}\u{80FD}
|
|
4288
4208
|
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
5. **\u{6280}\u{672F}\u{51C6}\u{786E}**: \u{786E}\u{4FDD}\u{89C4}\u{5219}\u{4E0E}\u{9879}\u{76EE}\u{6280}\u{672F}\u{6808}\u{548C}\u{8BED}\u{8A00}\u{7279}\u{6027}\u{5B8C}\u{5168}\u{5339}\u{914D}
|
|
4209
|
+
## 7. \u{5EFA}\u{8BAE}\u{4E0E}\u{603B}\u{7ED3}
|
|
4210
|
+
- \u{5B9E}\u{73B0}\u{8D28}\u{91CF}\u{8BC4}\u{4F30}
|
|
4211
|
+
- \u{6F5C}\u{5728}\u{95EE}\u{9898}\u{8BC6}\u{522B}
|
|
4212
|
+
- \u{540E}\u{7EED}\u{5F00}\u{53D1}\u{5EFA}\u{8BAE}
|
|
4213
|
+
- \u{6D4B}\u{8BD5}\u{5EFA}\u{8BAE}
|
|
4295
4214
|
|
|
4296
|
-
\u{8BF7}\u{
|
|
4297
|
-
`;
|
|
4215
|
+
\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}`;
|
|
4298
4216
|
objectType({
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4217
|
+
baseBranch: stringType().default('main').describe("\u57FA\u51C6\u5206\u652F\u540D\u79F0\uFF0C\u7528\u4E8E\u5BF9\u6BD4\u53D8\u66F4"),
|
|
4218
|
+
requirementFile: stringType().optional().describe("\u9700\u6C42\u6587\u6863\u6587\u4EF6\u8DEF\u5F84\uFF08\u53EF\u9009\uFF09"),
|
|
4219
|
+
includeUncommitted: booleanType().default(true).describe("\u662F\u5426\u5305\u542B\u672A\u63D0\u4EA4\u7684\u53D8\u66F4"),
|
|
4220
|
+
outputFormat: enumType([
|
|
4221
|
+
'markdown',
|
|
4222
|
+
'json'
|
|
4223
|
+
]).default('markdown').describe("\u8F93\u51FA\u683C\u5F0F")
|
|
4302
4224
|
});
|
|
4303
|
-
const
|
|
4304
|
-
name: "\
|
|
4305
|
-
description: "\
|
|
4225
|
+
const changeSummarizer = {
|
|
4226
|
+
name: "\u4EE3\u7801\u53D8\u66F4\u5206\u6790\u667A\u80FD\u4F53",
|
|
4227
|
+
description: "\u5206\u6790\u4EE3\u7801\u5E76\u4E0E\u9700\u6C42\u8FDB\u884C\u5BF9\u6BD4\uFF0C\u786E\u4FDD\u5B9E\u73B0\u5B8C\u6574\u6027",
|
|
4306
4228
|
inputSchema: {
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4229
|
+
baseBranch: stringType().default('main').describe("\u57FA\u51C6\u5206\u652F\u540D\u79F0\uFF0C\u7528\u4E8E\u5BF9\u6BD4\u53D8\u66F4"),
|
|
4230
|
+
requirementFile: stringType().optional().describe("\u9700\u6C42\u6587\u6863\u6587\u4EF6\u8DEF\u5F84\uFF08\u53EF\u9009\uFF09"),
|
|
4231
|
+
includeUncommitted: booleanType().default(true).describe("\u662F\u5426\u5305\u542B\u672A\u63D0\u4EA4\u7684\u53D8\u66F4"),
|
|
4232
|
+
outputFormat: enumType([
|
|
4233
|
+
'markdown',
|
|
4234
|
+
'json'
|
|
4235
|
+
]).default('markdown').describe("\u8F93\u51FA\u683C\u5F0F")
|
|
4310
4236
|
},
|
|
4311
4237
|
handler: async (args)=>{
|
|
4312
|
-
const { project_name = 'current-project', project_path, custom_rules } = args;
|
|
4313
4238
|
try {
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4239
|
+
initializeProjectRoot();
|
|
4240
|
+
console.log('[CHANGE-SUMMARIZER DEBUG] args:', JSON.stringify(args, null, 2));
|
|
4241
|
+
console.log('[CHANGE-SUMMARIZER DEBUG] args.baseBranch:', args.baseBranch);
|
|
4242
|
+
console.log('[CHANGE-SUMMARIZER DEBUG] args.outputFormat:', args.outputFormat);
|
|
4243
|
+
logger.info({
|
|
4244
|
+
module: 'change-summarizer',
|
|
4245
|
+
message: 'Starting code analysis',
|
|
4246
|
+
args
|
|
4247
|
+
});
|
|
4248
|
+
let requirementContent = '';
|
|
4249
|
+
if (args.requirementFile && external_fs_default().existsSync(args.requirementFile)) requirementContent = external_fs_default().readFileSync(args.requirementFile, 'utf-8');
|
|
4250
|
+
const analysisPrompt = buildAnalysisPrompt(requirementContent);
|
|
4251
|
+
const outputPath = await saveAnalysisResult(analysisPrompt, args.outputFormat);
|
|
4252
|
+
logger.info({
|
|
4253
|
+
module: 'change-summarizer',
|
|
4254
|
+
message: 'Code analysis completed',
|
|
4255
|
+
outputPath
|
|
4324
4256
|
});
|
|
4325
4257
|
return {
|
|
4326
4258
|
content: [
|
|
4327
4259
|
{
|
|
4328
4260
|
type: "text",
|
|
4329
|
-
text: JSON.stringify(
|
|
4261
|
+
text: JSON.stringify({
|
|
4262
|
+
success: true,
|
|
4263
|
+
message: "\u4EE3\u7801\u53D8\u66F4\u5206\u6790\u667A\u80FD\u4F53\u6D4B\u8BD5\u6210\u529F",
|
|
4264
|
+
data: {
|
|
4265
|
+
baseBranch: args.baseBranch || 'main',
|
|
4266
|
+
outputFormat: args.outputFormat || 'markdown'
|
|
4267
|
+
}
|
|
4268
|
+
})
|
|
4330
4269
|
}
|
|
4331
4270
|
]
|
|
4332
4271
|
};
|
|
4333
4272
|
} catch (error) {
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
project_path,
|
|
4339
|
-
error: errorMsg
|
|
4273
|
+
logger.error({
|
|
4274
|
+
module: 'change-summarizer',
|
|
4275
|
+
message: 'Code analysis failed',
|
|
4276
|
+
error: error instanceof Error ? error.message : String(error)
|
|
4340
4277
|
});
|
|
4341
|
-
const errorResult = {
|
|
4342
|
-
success: false,
|
|
4343
|
-
message: "\u9879\u76EE\u89C4\u8303\u5185\u5BB9\u751F\u6210\u5931\u8D25",
|
|
4344
|
-
error: errorMsg,
|
|
4345
|
-
project_info: {
|
|
4346
|
-
name: project_name
|
|
4347
|
-
}
|
|
4348
|
-
};
|
|
4349
4278
|
return {
|
|
4350
4279
|
content: [
|
|
4351
4280
|
{
|
|
4352
4281
|
type: "text",
|
|
4353
|
-
text: JSON.stringify(
|
|
4282
|
+
text: JSON.stringify({
|
|
4283
|
+
success: false,
|
|
4284
|
+
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)}`,
|
|
4285
|
+
data: null
|
|
4286
|
+
})
|
|
4354
4287
|
}
|
|
4355
4288
|
],
|
|
4356
4289
|
isError: true
|
|
@@ -4358,18 +4291,57 @@ var __webpack_exports__ = {};
|
|
|
4358
4291
|
}
|
|
4359
4292
|
}
|
|
4360
4293
|
};
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4294
|
+
changeSummarizer.handler = changeSummarizer.handler;
|
|
4295
|
+
function buildAnalysisPrompt(requirementContent) {
|
|
4296
|
+
const changesSection = `
|
|
4297
|
+
## \u{4EE3}\u{7801}\u{4E0A}\u{4E0B}\u{6587}\u{5206}\u{6790}
|
|
4298
|
+
|
|
4299
|
+
\u{8BF7}\u{57FA}\u{4E8E}\u{4EE5}\u{4E0B}\u{5185}\u{5BB9}\u{8FDB}\u{884C}\u{5206}\u{6790}\u{FF1A}
|
|
4300
|
+
- \u{5F53}\u{524D}\u{4EE3}\u{7801}\u{5E93}\u{7684}\u{6574}\u{4F53}\u{7ED3}\u{6784}
|
|
4301
|
+
- \u{4E3B}\u{8981}\u{529F}\u{80FD}\u{6A21}\u{5757}\u{7684}\u{5B9E}\u{73B0}
|
|
4302
|
+
- \u{5173}\u{952E}\u{4E1A}\u{52A1}\u{903B}\u{8F91}
|
|
4303
|
+
- \u{63A5}\u{53E3}\u{5B9A}\u{4E49}\u{4E0E}\u{5B9E}\u{73B0}
|
|
4304
|
+
- \u{524D}\u{7AEF}\u{7EC4}\u{4EF6}\u{4E0E}\u{9875}\u{9762}
|
|
4305
|
+
`;
|
|
4306
|
+
const requirementSection = requirementContent ? `
|
|
4307
|
+
## \u{9700}\u{6C42}\u{6587}\u{6863}\u{5185}\u{5BB9}
|
|
4308
|
+
${requirementContent}
|
|
4309
|
+
` : `
|
|
4310
|
+
## \u{9700}\u{6C42}\u{6587}\u{6863}
|
|
4311
|
+
\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}
|
|
4312
|
+
`;
|
|
4313
|
+
return `
|
|
4314
|
+
${changeAnalysisPrompt}
|
|
4315
|
+
|
|
4316
|
+
${changesSection}
|
|
4317
|
+
|
|
4318
|
+
${requirementSection}
|
|
4319
|
+
|
|
4320
|
+
\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}
|
|
4321
|
+
`;
|
|
4322
|
+
}
|
|
4323
|
+
async function saveAnalysisResult(prompt, format) {
|
|
4324
|
+
const storageDir = getStorageDir();
|
|
4325
|
+
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");
|
|
4326
|
+
const outputDir = external_path_default().join(storageDir, 'change-analysis');
|
|
4327
|
+
if (!external_fs_default().existsSync(outputDir)) external_fs_default().mkdirSync(outputDir, {
|
|
4328
|
+
recursive: true
|
|
4364
4329
|
});
|
|
4365
|
-
const
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4330
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
4331
|
+
const filename = `change-analysis-${timestamp}.${'json' === format ? 'json' : 'md'}`;
|
|
4332
|
+
const outputPath = external_path_default().join(outputDir, filename);
|
|
4333
|
+
if ('json' === format) {
|
|
4334
|
+
const jsonData = {
|
|
4335
|
+
timestamp: new Date().toISOString(),
|
|
4336
|
+
prompt,
|
|
4337
|
+
type: 'change-analysis'
|
|
4338
|
+
};
|
|
4339
|
+
external_fs_default().writeFileSync(outputPath, JSON.stringify(jsonData, null, 2), 'utf-8');
|
|
4340
|
+
} else external_fs_default().writeFileSync(outputPath, prompt, 'utf-8');
|
|
4341
|
+
return outputPath;
|
|
4372
4342
|
}
|
|
4343
|
+
const external_sharp_namespaceObject = require("sharp");
|
|
4344
|
+
var external_sharp_default = /*#__PURE__*/ __webpack_require__.n(external_sharp_namespaceObject);
|
|
4373
4345
|
class OpenAIService {
|
|
4374
4346
|
qwenConfig = {
|
|
4375
4347
|
apiKey: 'sk-95b0bc60b7464bbbafd64edc2f5bab14',
|
|
@@ -4690,354 +4662,85 @@ ${customRules}` : '';
|
|
|
4690
4662
|
}
|
|
4691
4663
|
}
|
|
4692
4664
|
}
|
|
4693
|
-
const
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
4665
|
+
const openAIService = new OpenAIService();
|
|
4666
|
+
var types_AnalysisType = /*#__PURE__*/ function(AnalysisType) {
|
|
4667
|
+
AnalysisType["GENERAL"] = "general";
|
|
4668
|
+
AnalysisType["OBJECTS"] = "objects";
|
|
4669
|
+
AnalysisType["TEXT"] = "text";
|
|
4670
|
+
AnalysisType["SCENE"] = "scene";
|
|
4671
|
+
AnalysisType["PEOPLE"] = "people";
|
|
4672
|
+
AnalysisType["TECHNICAL"] = "technical";
|
|
4673
|
+
AnalysisType["UI_DESIGN"] = "ui_design";
|
|
4674
|
+
AnalysisType["REQUIREMENT"] = "requirement";
|
|
4675
|
+
AnalysisType["CUSTOM"] = "custom";
|
|
4676
|
+
return AnalysisType;
|
|
4677
|
+
}({});
|
|
4678
|
+
var types_DetailLevel = /*#__PURE__*/ function(DetailLevel) {
|
|
4679
|
+
DetailLevel["BRIEF"] = "brief";
|
|
4680
|
+
DetailLevel["DETAILED"] = "detailed";
|
|
4681
|
+
DetailLevel["COMPREHENSIVE"] = "comprehensive";
|
|
4682
|
+
return DetailLevel;
|
|
4683
|
+
}({});
|
|
4684
|
+
class ImageAnalysisError extends Error {
|
|
4685
|
+
code;
|
|
4686
|
+
context;
|
|
4687
|
+
constructor(message, code, context){
|
|
4688
|
+
super(message), this.code = code, this.context = context;
|
|
4689
|
+
this.name = 'ImageAnalysisError';
|
|
4690
|
+
}
|
|
4703
4691
|
}
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
]
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
const requirementAnalyzerTool = {
|
|
4728
|
-
name: "\u9700\u6C42\u62A5\u544A\u751F\u6210\u667A\u80FD\u4F53",
|
|
4729
|
-
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",
|
|
4730
|
-
inputSchema: {
|
|
4731
|
-
input_type: enumType([
|
|
4732
|
-
"text",
|
|
4733
|
-
"md_file"
|
|
4734
|
-
]).describe("\u8F93\u5165\u7C7B\u578B\uFF1A\u76F4\u63A5\u6587\u672C\u8F93\u5165\u6216\u5F15\u7528\u5DF2\u751F\u6210\u7684MD\u6587\u4EF6"),
|
|
4735
|
-
content: stringType().optional().describe("\u5F53input_type\u4E3Atext\u65F6\uFF0C\u76F4\u63A5\u8F93\u5165\u7684\u9700\u6C42\u5185\u5BB9"),
|
|
4736
|
-
md_file_path: stringType().optional().describe("\u5F53input_type\u4E3Amd_file\u65F6\uFF0C\u8981\u5206\u6790\u7684MD\u6587\u4EF6\u8DEF\u5F84"),
|
|
4737
|
-
feature_name: stringType().describe("\u529F\u80FD\u540D\u79F0\uFF0C\u7528\u4E8E\u751F\u6210\u8F93\u51FA\u6587\u4EF6\u540D"),
|
|
4738
|
-
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"),
|
|
4739
|
-
analysis_depth: enumType([
|
|
4740
|
-
"basic",
|
|
4741
|
-
"detailed",
|
|
4742
|
-
"comprehensive"
|
|
4743
|
-
]).default("detailed").describe("\u5206\u6790\u6DF1\u5EA6\uFF1A\u57FA\u7840\u3001\u8BE6\u7EC6\u3001\u7EFC\u5408"),
|
|
4744
|
-
use_streaming: booleanType().default(false).describe("\u662F\u5426\u4F7F\u7528\u6D41\u5F0F\u5904\u7406\uFF08\u9002\u7528\u4E8E\u5927\u6587\u4EF6\uFF09"),
|
|
4745
|
-
chunk_size: numberType().min(10).max(1000).default(100).describe("\u5206\u5757\u5927\u5C0F\uFF08\u4EC5\u5728use_streaming\u4E3Atrue\u65F6\u6709\u6548\uFF09")
|
|
4746
|
-
},
|
|
4747
|
-
handler: async (args)=>{
|
|
4692
|
+
var types_AnalysisErrorCodes = /*#__PURE__*/ function(AnalysisErrorCodes) {
|
|
4693
|
+
AnalysisErrorCodes["INVALID_IMAGE_PATH"] = "INVALID_IMAGE_PATH";
|
|
4694
|
+
AnalysisErrorCodes["UNSUPPORTED_FORMAT"] = "UNSUPPORTED_FORMAT";
|
|
4695
|
+
AnalysisErrorCodes["FILE_NOT_FOUND"] = "FILE_NOT_FOUND";
|
|
4696
|
+
AnalysisErrorCodes["IMAGE_CORRUPTED"] = "IMAGE_CORRUPTED";
|
|
4697
|
+
AnalysisErrorCodes["ANALYSIS_FAILED"] = "ANALYSIS_FAILED";
|
|
4698
|
+
AnalysisErrorCodes["AI_SERVICE_ERROR"] = "AI_SERVICE_ERROR";
|
|
4699
|
+
AnalysisErrorCodes["INVALID_ANALYSIS_TYPE"] = "INVALID_ANALYSIS_TYPE";
|
|
4700
|
+
return AnalysisErrorCodes;
|
|
4701
|
+
}({});
|
|
4702
|
+
const SUPPORTED_IMAGE_FORMATS = [
|
|
4703
|
+
'jpg',
|
|
4704
|
+
'jpeg',
|
|
4705
|
+
'png',
|
|
4706
|
+
'gif',
|
|
4707
|
+
'bmp',
|
|
4708
|
+
'tiff',
|
|
4709
|
+
'tif',
|
|
4710
|
+
'webp'
|
|
4711
|
+
];
|
|
4712
|
+
class ImageAnalyzer {
|
|
4713
|
+
async analyzeImage(imagePath, context) {
|
|
4714
|
+
const startTime = Date.now();
|
|
4748
4715
|
try {
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4716
|
+
logger.info("\u5F00\u59CB\u56FE\u7247\u5185\u5BB9\u5206\u6790", {
|
|
4717
|
+
imagePath: imagePath
|
|
4718
|
+
});
|
|
4719
|
+
await this.validateParams(imagePath);
|
|
4720
|
+
const basicInfo = await this.getImageBasicInfo(imagePath);
|
|
4721
|
+
const analysisContent = await this.performAIAnalysis(imagePath, basicInfo, context);
|
|
4722
|
+
const processingTime = Date.now() - startTime;
|
|
4723
|
+
if (!analysisContent) throw new ImageAnalysisError("AI\u5206\u6790\u8FD4\u56DE\u7A7A\u7ED3\u679C", types_AnalysisErrorCodes.ANALYSIS_FAILED, {
|
|
4724
|
+
params: {
|
|
4725
|
+
image_path: imagePath
|
|
4726
|
+
}
|
|
4727
|
+
});
|
|
4728
|
+
const result = {
|
|
4729
|
+
basic_info: basicInfo,
|
|
4730
|
+
analysis_type: types_AnalysisType.GENERAL,
|
|
4731
|
+
detail_level: types_DetailLevel.DETAILED,
|
|
4732
|
+
content: analysisContent,
|
|
4733
|
+
processing_time_ms: processingTime,
|
|
4734
|
+
confidence_score: this.calculateConfidenceScore(analysisContent)
|
|
4763
4735
|
};
|
|
4736
|
+
logger.info("\u56FE\u7247\u5185\u5BB9\u5206\u6790\u5B8C\u6210", {
|
|
4737
|
+
imagePath: imagePath,
|
|
4738
|
+
processingTimeMs: processingTime,
|
|
4739
|
+
confidenceScore: result.confidence_score
|
|
4740
|
+
});
|
|
4741
|
+
return result;
|
|
4764
4742
|
} catch (error) {
|
|
4765
|
-
|
|
4766
|
-
content: [
|
|
4767
|
-
{
|
|
4768
|
-
type: "text",
|
|
4769
|
-
text: JSON.stringify({
|
|
4770
|
-
success: false,
|
|
4771
|
-
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}`,
|
|
4772
|
-
data: null
|
|
4773
|
-
})
|
|
4774
|
-
}
|
|
4775
|
-
],
|
|
4776
|
-
isError: true
|
|
4777
|
-
};
|
|
4778
|
-
}
|
|
4779
|
-
}
|
|
4780
|
-
};
|
|
4781
|
-
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}
|
|
4782
|
-
|
|
4783
|
-
\u{8BF7}\u{6309}\u{4EE5}\u{4E0B}\u{6B65}\u{9AA4}\u{8FDB}\u{884C}\u{5206}\u{6790}\u{FF1A}
|
|
4784
|
-
|
|
4785
|
-
## 1. \u{4EE3}\u{7801}\u{5E93}\u{5206}\u{6790}
|
|
4786
|
-
\u{5206}\u{6790}\u{5F53}\u{524D}\u{4EE3}\u{7801}\u{5E93}\u{FF0C}\u{603B}\u{7ED3}\u{FF1A}
|
|
4787
|
-
- \u{4E3B}\u{8981}\u{529F}\u{80FD}\u{6A21}\u{5757}\u{53CA}\u{5176}\u{5B9E}\u{73B0}
|
|
4788
|
-
- \u{5173}\u{952E}\u{4E1A}\u{52A1}\u{903B}\u{8F91}\u{6D41}\u{7A0B}
|
|
4789
|
-
- \u{91CD}\u{8981}\u{6570}\u{636E}\u{7ED3}\u{6784}
|
|
4790
|
-
- \u{6838}\u{5FC3}\u{7B97}\u{6CD5}\u{5B9E}\u{73B0}
|
|
4791
|
-
|
|
4792
|
-
## 2. \u{63A5}\u{53E3}\u{4E0E}\u{9700}\u{6C42}\u{5BF9}\u{5E94}\u{5173}\u{7CFB}\u{8868}
|
|
4793
|
-
\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}
|
|
4794
|
-
|
|
4795
|
-
| \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} |
|
|
4796
|
-
|---------|---------|---------|-----|----------|
|
|
4797
|
-
| [\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}] |
|
|
4798
|
-
|
|
4799
|
-
## 3. \u{6838}\u{5FC3}\u{903B}\u{8F91}\u{65B9}\u{6CD5}\u{8868}
|
|
4800
|
-
\u{5206}\u{6790}\u{6838}\u{5FC3}\u{4E1A}\u{52A1}\u{903B}\u{8F91}\u{65B9}\u{6CD5}\u{FF1A}
|
|
4801
|
-
|
|
4802
|
-
| \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} |
|
|
4803
|
-
|---------|-------|---------|----------|
|
|
4804
|
-
| [methodName] | [ClassName] | [\u{529F}\u{80FD}\u{63CF}\u{8FF0}] | [\u{65B0}\u{589E}/\u{4FEE}\u{6539}/\u{5220}\u{9664}] |
|
|
4805
|
-
|
|
4806
|
-
## 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}
|
|
4807
|
-
\u{5206}\u{6790}\u{524D}\u{7AEF}\u{9875}\u{9762}\u{53D8}\u{66F4}\u{FF1A}
|
|
4808
|
-
|
|
4809
|
-
| \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} |
|
|
4810
|
-
|---------|---------|---------|---------|----------|
|
|
4811
|
-
| [\u{9875}\u{9762}\u{540D}\u{79F0}] | [Controller.method] | [ComponentName] | [/path] | [\u{65B0}\u{589E}/\u{4FEE}\u{6539}/\u{5220}\u{9664}] |
|
|
4812
|
-
|
|
4813
|
-
## 5. \u{524D}\u{7AEF}\u{6838}\u{5FC3}\u{7EC4}\u{4EF6}\u{8868}
|
|
4814
|
-
\u{5206}\u{6790}\u{524D}\u{7AEF}\u{7EC4}\u{4EF6}\u{53D8}\u{66F4}\u{FF1A}
|
|
4815
|
-
|
|
4816
|
-
| \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} |
|
|
4817
|
-
|---------|---------|---------|----------|
|
|
4818
|
-
| [ComponentName] | [PageName] | [\u{529F}\u{80FD}\u{63CF}\u{8FF0}] | [\u{65B0}\u{589E}/\u{4FEE}\u{6539}/\u{5220}\u{9664}] |
|
|
4819
|
-
|
|
4820
|
-
## 6. \u{9700}\u{6C42}\u{5B8C}\u{6574}\u{6027}\u{68C0}\u{67E5}
|
|
4821
|
-
\u{5BF9}\u{6BD4}\u{539F}\u{59CB}\u{9700}\u{6C42}\u{FF0C}\u{68C0}\u{67E5}\u{FF1A}
|
|
4822
|
-
- \u{2705} \u{5DF2}\u{5B8C}\u{6210}\u{7684}\u{529F}\u{80FD}
|
|
4823
|
-
- \u{26A0}\u{FE0F} \u{90E8}\u{5206}\u{5B8C}\u{6210}\u{7684}\u{529F}\u{80FD}
|
|
4824
|
-
- \u{274C} \u{672A}\u{5B9E}\u{73B0}\u{7684}\u{529F}\u{80FD}
|
|
4825
|
-
- \u{1F504} \u{9700}\u{8981}\u{8FDB}\u{4E00}\u{6B65}\u{5B8C}\u{5584}\u{7684}\u{529F}\u{80FD}
|
|
4826
|
-
|
|
4827
|
-
## 7. \u{5EFA}\u{8BAE}\u{4E0E}\u{603B}\u{7ED3}
|
|
4828
|
-
- \u{5B9E}\u{73B0}\u{8D28}\u{91CF}\u{8BC4}\u{4F30}
|
|
4829
|
-
- \u{6F5C}\u{5728}\u{95EE}\u{9898}\u{8BC6}\u{522B}
|
|
4830
|
-
- \u{540E}\u{7EED}\u{5F00}\u{53D1}\u{5EFA}\u{8BAE}
|
|
4831
|
-
- \u{6D4B}\u{8BD5}\u{5EFA}\u{8BAE}
|
|
4832
|
-
|
|
4833
|
-
\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}`;
|
|
4834
|
-
objectType({
|
|
4835
|
-
baseBranch: stringType().default('main').describe("\u57FA\u51C6\u5206\u652F\u540D\u79F0\uFF0C\u7528\u4E8E\u5BF9\u6BD4\u53D8\u66F4"),
|
|
4836
|
-
requirementFile: stringType().optional().describe("\u9700\u6C42\u6587\u6863\u6587\u4EF6\u8DEF\u5F84\uFF08\u53EF\u9009\uFF09"),
|
|
4837
|
-
includeUncommitted: booleanType().default(true).describe("\u662F\u5426\u5305\u542B\u672A\u63D0\u4EA4\u7684\u53D8\u66F4"),
|
|
4838
|
-
outputFormat: enumType([
|
|
4839
|
-
'markdown',
|
|
4840
|
-
'json'
|
|
4841
|
-
]).default('markdown').describe("\u8F93\u51FA\u683C\u5F0F")
|
|
4842
|
-
});
|
|
4843
|
-
const changeSummarizer = {
|
|
4844
|
-
name: "\u4EE3\u7801\u53D8\u66F4\u5206\u6790\u667A\u80FD\u4F53",
|
|
4845
|
-
description: "\u5206\u6790\u4EE3\u7801\u5E76\u4E0E\u9700\u6C42\u8FDB\u884C\u5BF9\u6BD4\uFF0C\u786E\u4FDD\u5B9E\u73B0\u5B8C\u6574\u6027",
|
|
4846
|
-
inputSchema: {
|
|
4847
|
-
baseBranch: stringType().default('main').describe("\u57FA\u51C6\u5206\u652F\u540D\u79F0\uFF0C\u7528\u4E8E\u5BF9\u6BD4\u53D8\u66F4"),
|
|
4848
|
-
requirementFile: stringType().optional().describe("\u9700\u6C42\u6587\u6863\u6587\u4EF6\u8DEF\u5F84\uFF08\u53EF\u9009\uFF09"),
|
|
4849
|
-
includeUncommitted: booleanType().default(true).describe("\u662F\u5426\u5305\u542B\u672A\u63D0\u4EA4\u7684\u53D8\u66F4"),
|
|
4850
|
-
outputFormat: enumType([
|
|
4851
|
-
'markdown',
|
|
4852
|
-
'json'
|
|
4853
|
-
]).default('markdown').describe("\u8F93\u51FA\u683C\u5F0F")
|
|
4854
|
-
},
|
|
4855
|
-
handler: async (args)=>{
|
|
4856
|
-
try {
|
|
4857
|
-
initializeProjectRoot();
|
|
4858
|
-
console.log('[CHANGE-SUMMARIZER DEBUG] args:', JSON.stringify(args, null, 2));
|
|
4859
|
-
console.log('[CHANGE-SUMMARIZER DEBUG] args.baseBranch:', args.baseBranch);
|
|
4860
|
-
console.log('[CHANGE-SUMMARIZER DEBUG] args.outputFormat:', args.outputFormat);
|
|
4861
|
-
logger_logger.info({
|
|
4862
|
-
module: 'change-summarizer',
|
|
4863
|
-
message: 'Starting code analysis',
|
|
4864
|
-
args
|
|
4865
|
-
});
|
|
4866
|
-
let requirementContent = '';
|
|
4867
|
-
if (args.requirementFile && external_fs_default().existsSync(args.requirementFile)) requirementContent = external_fs_default().readFileSync(args.requirementFile, 'utf-8');
|
|
4868
|
-
const analysisPrompt = buildAnalysisPrompt(requirementContent);
|
|
4869
|
-
const outputPath = await saveAnalysisResult(analysisPrompt, args.outputFormat);
|
|
4870
|
-
logger_logger.info({
|
|
4871
|
-
module: 'change-summarizer',
|
|
4872
|
-
message: 'Code analysis completed',
|
|
4873
|
-
outputPath
|
|
4874
|
-
});
|
|
4875
|
-
return {
|
|
4876
|
-
content: [
|
|
4877
|
-
{
|
|
4878
|
-
type: "text",
|
|
4879
|
-
text: JSON.stringify({
|
|
4880
|
-
success: true,
|
|
4881
|
-
message: "\u4EE3\u7801\u53D8\u66F4\u5206\u6790\u667A\u80FD\u4F53\u6D4B\u8BD5\u6210\u529F",
|
|
4882
|
-
data: {
|
|
4883
|
-
baseBranch: args.baseBranch || 'main',
|
|
4884
|
-
outputFormat: args.outputFormat || 'markdown'
|
|
4885
|
-
}
|
|
4886
|
-
})
|
|
4887
|
-
}
|
|
4888
|
-
]
|
|
4889
|
-
};
|
|
4890
|
-
} catch (error) {
|
|
4891
|
-
logger_logger.error({
|
|
4892
|
-
module: 'change-summarizer',
|
|
4893
|
-
message: 'Code analysis failed',
|
|
4894
|
-
error: error instanceof Error ? error.message : String(error)
|
|
4895
|
-
});
|
|
4896
|
-
return {
|
|
4897
|
-
content: [
|
|
4898
|
-
{
|
|
4899
|
-
type: "text",
|
|
4900
|
-
text: JSON.stringify({
|
|
4901
|
-
success: false,
|
|
4902
|
-
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)}`,
|
|
4903
|
-
data: null
|
|
4904
|
-
})
|
|
4905
|
-
}
|
|
4906
|
-
],
|
|
4907
|
-
isError: true
|
|
4908
|
-
};
|
|
4909
|
-
}
|
|
4910
|
-
}
|
|
4911
|
-
};
|
|
4912
|
-
changeSummarizer.handler = changeSummarizer.handler;
|
|
4913
|
-
function buildAnalysisPrompt(requirementContent) {
|
|
4914
|
-
const changesSection = `
|
|
4915
|
-
## \u{4EE3}\u{7801}\u{4E0A}\u{4E0B}\u{6587}\u{5206}\u{6790}
|
|
4916
|
-
|
|
4917
|
-
\u{8BF7}\u{57FA}\u{4E8E}\u{4EE5}\u{4E0B}\u{5185}\u{5BB9}\u{8FDB}\u{884C}\u{5206}\u{6790}\u{FF1A}
|
|
4918
|
-
- \u{5F53}\u{524D}\u{4EE3}\u{7801}\u{5E93}\u{7684}\u{6574}\u{4F53}\u{7ED3}\u{6784}
|
|
4919
|
-
- \u{4E3B}\u{8981}\u{529F}\u{80FD}\u{6A21}\u{5757}\u{7684}\u{5B9E}\u{73B0}
|
|
4920
|
-
- \u{5173}\u{952E}\u{4E1A}\u{52A1}\u{903B}\u{8F91}
|
|
4921
|
-
- \u{63A5}\u{53E3}\u{5B9A}\u{4E49}\u{4E0E}\u{5B9E}\u{73B0}
|
|
4922
|
-
- \u{524D}\u{7AEF}\u{7EC4}\u{4EF6}\u{4E0E}\u{9875}\u{9762}
|
|
4923
|
-
`;
|
|
4924
|
-
const requirementSection = requirementContent ? `
|
|
4925
|
-
## \u{9700}\u{6C42}\u{6587}\u{6863}\u{5185}\u{5BB9}
|
|
4926
|
-
${requirementContent}
|
|
4927
|
-
` : `
|
|
4928
|
-
## \u{9700}\u{6C42}\u{6587}\u{6863}
|
|
4929
|
-
\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}
|
|
4930
|
-
`;
|
|
4931
|
-
return `
|
|
4932
|
-
${changeAnalysisPrompt}
|
|
4933
|
-
|
|
4934
|
-
${changesSection}
|
|
4935
|
-
|
|
4936
|
-
${requirementSection}
|
|
4937
|
-
|
|
4938
|
-
\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}
|
|
4939
|
-
`;
|
|
4940
|
-
}
|
|
4941
|
-
async function saveAnalysisResult(prompt, format) {
|
|
4942
|
-
const storageDir = config_getStorageDir();
|
|
4943
|
-
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");
|
|
4944
|
-
const outputDir = external_path_default().join(storageDir, 'change-analysis');
|
|
4945
|
-
if (!external_fs_default().existsSync(outputDir)) external_fs_default().mkdirSync(outputDir, {
|
|
4946
|
-
recursive: true
|
|
4947
|
-
});
|
|
4948
|
-
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
4949
|
-
const filename = `change-analysis-${timestamp}.${'json' === format ? 'json' : 'md'}`;
|
|
4950
|
-
const outputPath = external_path_default().join(outputDir, filename);
|
|
4951
|
-
if ('json' === format) {
|
|
4952
|
-
const jsonData = {
|
|
4953
|
-
timestamp: new Date().toISOString(),
|
|
4954
|
-
prompt,
|
|
4955
|
-
type: 'change-analysis'
|
|
4956
|
-
};
|
|
4957
|
-
external_fs_default().writeFileSync(outputPath, JSON.stringify(jsonData, null, 2), 'utf-8');
|
|
4958
|
-
} else external_fs_default().writeFileSync(outputPath, prompt, 'utf-8');
|
|
4959
|
-
return outputPath;
|
|
4960
|
-
}
|
|
4961
|
-
const external_sharp_namespaceObject = require("sharp");
|
|
4962
|
-
var external_sharp_default = /*#__PURE__*/ __webpack_require__.n(external_sharp_namespaceObject);
|
|
4963
|
-
var types_AnalysisType = /*#__PURE__*/ function(AnalysisType) {
|
|
4964
|
-
AnalysisType["GENERAL"] = "general";
|
|
4965
|
-
AnalysisType["OBJECTS"] = "objects";
|
|
4966
|
-
AnalysisType["TEXT"] = "text";
|
|
4967
|
-
AnalysisType["SCENE"] = "scene";
|
|
4968
|
-
AnalysisType["PEOPLE"] = "people";
|
|
4969
|
-
AnalysisType["TECHNICAL"] = "technical";
|
|
4970
|
-
AnalysisType["UI_DESIGN"] = "ui_design";
|
|
4971
|
-
AnalysisType["REQUIREMENT"] = "requirement";
|
|
4972
|
-
AnalysisType["CUSTOM"] = "custom";
|
|
4973
|
-
return AnalysisType;
|
|
4974
|
-
}({});
|
|
4975
|
-
var types_DetailLevel = /*#__PURE__*/ function(DetailLevel) {
|
|
4976
|
-
DetailLevel["BRIEF"] = "brief";
|
|
4977
|
-
DetailLevel["DETAILED"] = "detailed";
|
|
4978
|
-
DetailLevel["COMPREHENSIVE"] = "comprehensive";
|
|
4979
|
-
return DetailLevel;
|
|
4980
|
-
}({});
|
|
4981
|
-
class ImageAnalysisError extends Error {
|
|
4982
|
-
code;
|
|
4983
|
-
context;
|
|
4984
|
-
constructor(message, code, context){
|
|
4985
|
-
super(message), this.code = code, this.context = context;
|
|
4986
|
-
this.name = 'ImageAnalysisError';
|
|
4987
|
-
}
|
|
4988
|
-
}
|
|
4989
|
-
var types_AnalysisErrorCodes = /*#__PURE__*/ function(AnalysisErrorCodes) {
|
|
4990
|
-
AnalysisErrorCodes["INVALID_IMAGE_PATH"] = "INVALID_IMAGE_PATH";
|
|
4991
|
-
AnalysisErrorCodes["UNSUPPORTED_FORMAT"] = "UNSUPPORTED_FORMAT";
|
|
4992
|
-
AnalysisErrorCodes["FILE_NOT_FOUND"] = "FILE_NOT_FOUND";
|
|
4993
|
-
AnalysisErrorCodes["IMAGE_CORRUPTED"] = "IMAGE_CORRUPTED";
|
|
4994
|
-
AnalysisErrorCodes["ANALYSIS_FAILED"] = "ANALYSIS_FAILED";
|
|
4995
|
-
AnalysisErrorCodes["AI_SERVICE_ERROR"] = "AI_SERVICE_ERROR";
|
|
4996
|
-
AnalysisErrorCodes["INVALID_ANALYSIS_TYPE"] = "INVALID_ANALYSIS_TYPE";
|
|
4997
|
-
return AnalysisErrorCodes;
|
|
4998
|
-
}({});
|
|
4999
|
-
const SUPPORTED_IMAGE_FORMATS = [
|
|
5000
|
-
'jpg',
|
|
5001
|
-
'jpeg',
|
|
5002
|
-
'png',
|
|
5003
|
-
'gif',
|
|
5004
|
-
'bmp',
|
|
5005
|
-
'tiff',
|
|
5006
|
-
'tif',
|
|
5007
|
-
'webp'
|
|
5008
|
-
];
|
|
5009
|
-
class ImageAnalyzer {
|
|
5010
|
-
async analyzeImage(imagePath, context) {
|
|
5011
|
-
const startTime = Date.now();
|
|
5012
|
-
try {
|
|
5013
|
-
logger_logger.info("\u5F00\u59CB\u56FE\u7247\u5185\u5BB9\u5206\u6790", {
|
|
5014
|
-
imagePath: imagePath
|
|
5015
|
-
});
|
|
5016
|
-
await this.validateParams(imagePath);
|
|
5017
|
-
const basicInfo = await this.getImageBasicInfo(imagePath);
|
|
5018
|
-
const analysisContent = await this.performAIAnalysis(imagePath, basicInfo, context);
|
|
5019
|
-
const processingTime = Date.now() - startTime;
|
|
5020
|
-
if (!analysisContent) throw new ImageAnalysisError("AI\u5206\u6790\u8FD4\u56DE\u7A7A\u7ED3\u679C", types_AnalysisErrorCodes.ANALYSIS_FAILED, {
|
|
5021
|
-
params: {
|
|
5022
|
-
image_path: imagePath
|
|
5023
|
-
}
|
|
5024
|
-
});
|
|
5025
|
-
const result = {
|
|
5026
|
-
basic_info: basicInfo,
|
|
5027
|
-
analysis_type: types_AnalysisType.GENERAL,
|
|
5028
|
-
detail_level: types_DetailLevel.DETAILED,
|
|
5029
|
-
content: analysisContent,
|
|
5030
|
-
processing_time_ms: processingTime,
|
|
5031
|
-
confidence_score: this.calculateConfidenceScore(analysisContent)
|
|
5032
|
-
};
|
|
5033
|
-
logger_logger.info("\u56FE\u7247\u5185\u5BB9\u5206\u6790\u5B8C\u6210", {
|
|
5034
|
-
imagePath: imagePath,
|
|
5035
|
-
processingTimeMs: processingTime,
|
|
5036
|
-
confidenceScore: result.confidence_score
|
|
5037
|
-
});
|
|
5038
|
-
return result;
|
|
5039
|
-
} catch (error) {
|
|
5040
|
-
logger_logger.error("\u56FE\u7247\u5185\u5BB9\u5206\u6790\u5931\u8D25", {
|
|
4743
|
+
logger.error("\u56FE\u7247\u5185\u5BB9\u5206\u6790\u5931\u8D25", {
|
|
5041
4744
|
error,
|
|
5042
4745
|
params: {
|
|
5043
4746
|
image_path: imagePath
|
|
@@ -5050,7 +4753,7 @@ ${requirementSection}
|
|
|
5050
4753
|
try {
|
|
5051
4754
|
const imageBase64 = await this.imageToBase64(imagePath);
|
|
5052
4755
|
const prompt = this.buildAnalysisPrompt(imagePath, basicInfo, context);
|
|
5053
|
-
const aiResponse = await
|
|
4756
|
+
const aiResponse = await openAIService.analyzeImage({
|
|
5054
4757
|
image_base64: imageBase64,
|
|
5055
4758
|
prompt: prompt,
|
|
5056
4759
|
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"
|
|
@@ -5058,7 +4761,7 @@ ${requirementSection}
|
|
|
5058
4761
|
const analysisContent = this.parseAIResponse(aiResponse);
|
|
5059
4762
|
return analysisContent;
|
|
5060
4763
|
} catch (error) {
|
|
5061
|
-
|
|
4764
|
+
logger.error("AI\u5206\u6790\u5931\u8D25", {
|
|
5062
4765
|
error,
|
|
5063
4766
|
params: {
|
|
5064
4767
|
image_path: imagePath
|
|
@@ -5093,7 +4796,7 @@ ${context}
|
|
|
5093
4796
|
if (!aiResponse || 'string' != typeof aiResponse) throw new ImageAnalysisError("AI\u670D\u52A1\u8FD4\u56DE\u65E0\u6548\u54CD\u5E94", types_AnalysisErrorCodes.AI_SERVICE_ERROR, {
|
|
5094
4797
|
aiResponse
|
|
5095
4798
|
});
|
|
5096
|
-
|
|
4799
|
+
logger.debug("AI\u54CD\u5E94\u5185\u5BB9", {
|
|
5097
4800
|
responseLength: aiResponse.length,
|
|
5098
4801
|
responsePreview: aiResponse.substring(0, 200) + (aiResponse.length > 200 ? '...' : '')
|
|
5099
4802
|
});
|
|
@@ -5105,7 +4808,7 @@ ${context}
|
|
|
5105
4808
|
},
|
|
5106
4809
|
tags: []
|
|
5107
4810
|
};
|
|
5108
|
-
|
|
4811
|
+
logger.debug("\u5185\u5BB9\u89E3\u6790\u7ED3\u679C", {
|
|
5109
4812
|
summaryLength: content.summary.length
|
|
5110
4813
|
});
|
|
5111
4814
|
return content;
|
|
@@ -5346,7 +5049,7 @@ ${context}
|
|
|
5346
5049
|
handler: async (args)=>{
|
|
5347
5050
|
const analyzer = new ImageAnalyzer();
|
|
5348
5051
|
try {
|
|
5349
|
-
|
|
5052
|
+
logger.info("\u56FE\u7247\u5185\u5BB9\u7406\u89E3\u667A\u80FD\u4F53\u5F00\u59CB\u6267\u884C", {
|
|
5350
5053
|
imagePath: args.image_path
|
|
5351
5054
|
});
|
|
5352
5055
|
const validatedArgs = ImageAnalysisParamsSchema.parse(args);
|
|
@@ -5371,7 +5074,7 @@ ${result.content.tags && result.content.tags.length > 0 ? `\u{5173}\u{952E}\u{68
|
|
|
5371
5074
|
]
|
|
5372
5075
|
};
|
|
5373
5076
|
} catch (error) {
|
|
5374
|
-
|
|
5077
|
+
logger.error("\u56FE\u7247\u5185\u5BB9\u7406\u89E3\u667A\u80FD\u4F53\u6267\u884C\u5931\u8D25", {
|
|
5375
5078
|
error,
|
|
5376
5079
|
args
|
|
5377
5080
|
});
|
|
@@ -5520,7 +5223,7 @@ ${getErrorSuggestion(error.code)}
|
|
|
5520
5223
|
const inputPaths = Array.isArray(params.input_paths) ? params.input_paths : [
|
|
5521
5224
|
params.input_paths
|
|
5522
5225
|
];
|
|
5523
|
-
|
|
5226
|
+
logger.info("\u5F00\u59CB\u56FE\u7247\u8F6C\u6362", {
|
|
5524
5227
|
inputCount: inputPaths.length,
|
|
5525
5228
|
outputFormat: params.output_format,
|
|
5526
5229
|
isBatch: inputPaths.length > 1
|
|
@@ -5538,7 +5241,7 @@ ${getErrorSuggestion(error.code)}
|
|
|
5538
5241
|
processing_time_ms: processingTime
|
|
5539
5242
|
}
|
|
5540
5243
|
};
|
|
5541
|
-
|
|
5244
|
+
logger.info("\u56FE\u7247\u8F6C\u6362\u5B8C\u6210", {
|
|
5542
5245
|
total: results.length,
|
|
5543
5246
|
successful,
|
|
5544
5247
|
failed,
|
|
@@ -5546,7 +5249,7 @@ ${getErrorSuggestion(error.code)}
|
|
|
5546
5249
|
});
|
|
5547
5250
|
return batchResult;
|
|
5548
5251
|
} catch (error) {
|
|
5549
|
-
|
|
5252
|
+
logger.error("\u56FE\u7247\u8F6C\u6362\u5931\u8D25", {
|
|
5550
5253
|
error,
|
|
5551
5254
|
params
|
|
5552
5255
|
});
|
|
@@ -5560,14 +5263,14 @@ ${getErrorSuggestion(error.code)}
|
|
|
5560
5263
|
await this.ensureOutputDirectory(outputPath);
|
|
5561
5264
|
const metadata = await this.getImageMetadata(inputPath);
|
|
5562
5265
|
const result = await this.performConversion(inputPath, outputPath, params, metadata);
|
|
5563
|
-
|
|
5266
|
+
logger.info("\u5355\u5F20\u56FE\u7247\u8F6C\u6362\u6210\u529F", {
|
|
5564
5267
|
inputPath,
|
|
5565
5268
|
outputPath,
|
|
5566
5269
|
format: params.output_format
|
|
5567
5270
|
});
|
|
5568
5271
|
return result;
|
|
5569
5272
|
} catch (error) {
|
|
5570
|
-
|
|
5273
|
+
logger.error("\u5355\u5F20\u56FE\u7247\u8F6C\u6362\u5931\u8D25", {
|
|
5571
5274
|
error,
|
|
5572
5275
|
inputPath
|
|
5573
5276
|
});
|
|
@@ -5764,7 +5467,7 @@ ${getErrorSuggestion(error.code)}
|
|
|
5764
5467
|
initializeProjectRoot();
|
|
5765
5468
|
const converter = new ImageConverter();
|
|
5766
5469
|
try {
|
|
5767
|
-
|
|
5470
|
+
logger.info("\u56FE\u7247\u683C\u5F0F\u8F6C\u6362\u667A\u80FD\u4F53\u5F00\u59CB\u6267\u884C", {
|
|
5768
5471
|
inputPaths: args.input_paths,
|
|
5769
5472
|
outputFormat: args.output_format,
|
|
5770
5473
|
isBatch: Array.isArray(args.input_paths)
|
|
@@ -5789,7 +5492,7 @@ ${getErrorSuggestion(error.code)}
|
|
|
5789
5492
|
]
|
|
5790
5493
|
};
|
|
5791
5494
|
} catch (error) {
|
|
5792
|
-
|
|
5495
|
+
logger.error("\u56FE\u7247\u683C\u5F0F\u8F6C\u6362\u667A\u80FD\u4F53\u6267\u884C\u5931\u8D25", {
|
|
5793
5496
|
error,
|
|
5794
5497
|
args
|
|
5795
5498
|
});
|
|
@@ -5956,392 +5659,6 @@ ${image_converter_getErrorSuggestion(error.code)}
|
|
|
5956
5659
|
};
|
|
5957
5660
|
return suggestions[errorCode] || "\u8BF7\u68C0\u67E5\u8F93\u5165\u53C2\u6570\u5E76\u91CD\u8BD5";
|
|
5958
5661
|
}
|
|
5959
|
-
objectType({
|
|
5960
|
-
task_description: stringType().min(1).describe("\u8981\u5F00\u53D1\u7684\u4EFB\u52A1\u63CF\u8FF0"),
|
|
5961
|
-
current_stage: enumType([
|
|
5962
|
-
"research",
|
|
5963
|
-
"ideation",
|
|
5964
|
-
"planning",
|
|
5965
|
-
"execution",
|
|
5966
|
-
"optimization",
|
|
5967
|
-
"review"
|
|
5968
|
-
]).optional().default("research").describe("\u5F53\u524D\u5DE5\u4F5C\u6D41\u7A0B\u9636\u6BB5"),
|
|
5969
|
-
user_input: anyType().optional().describe("\u7528\u6237\u5728\u5F53\u524D\u9636\u6BB5\u7684\u8F93\u5165\u6570\u636E"),
|
|
5970
|
-
project_path: stringType().optional().describe("\u9879\u76EE\u8DEF\u5F84")
|
|
5971
|
-
});
|
|
5972
|
-
function getStageMode(stage) {
|
|
5973
|
-
switch(stage){
|
|
5974
|
-
case "research":
|
|
5975
|
-
return "[\u6A21\u5F0F\uFF1A\u7814\u7A76]";
|
|
5976
|
-
case "ideation":
|
|
5977
|
-
return "[\u6A21\u5F0F\uFF1A\u6784\u601D]";
|
|
5978
|
-
case "planning":
|
|
5979
|
-
return "[\u6A21\u5F0F\uFF1A\u8BA1\u5212]";
|
|
5980
|
-
case "execution":
|
|
5981
|
-
return "[\u6A21\u5F0F\uFF1A\u6267\u884C]";
|
|
5982
|
-
case "optimization":
|
|
5983
|
-
return "[\u6A21\u5F0F\uFF1A\u4F18\u5316]";
|
|
5984
|
-
case "review":
|
|
5985
|
-
return "[\u6A21\u5F0F\uFF1A\u8BC4\u5BA1]";
|
|
5986
|
-
default:
|
|
5987
|
-
return "[\u6A21\u5F0F\uFF1A\u672A\u77E5]";
|
|
5988
|
-
}
|
|
5989
|
-
}
|
|
5990
|
-
async function generateResearchGuidance(taskDescription) {
|
|
5991
|
-
const mode = getStageMode("research");
|
|
5992
|
-
return `${mode} - \u{9700}\u{6C42}\u{5206}\u{6790}\u{548C}\u{5B8C}\u{6574}\u{6027}\u{8BC4}\u{4F30}
|
|
5993
|
-
|
|
5994
|
-
## \u{4EFB}\u{52A1}\u{63CF}\u{8FF0}
|
|
5995
|
-
${taskDescription}
|
|
5996
|
-
|
|
5997
|
-
## \u{6267}\u{884C}\u{6B65}\u{9AA4}
|
|
5998
|
-
|
|
5999
|
-
### 1. \u{9700}\u{6C42}\u{5B8C}\u{6574}\u{6027}\u{5206}\u{6790}\u{FF08}0-10\u{5206}\u{8BC4}\u{5206}\u{FF09}
|
|
6000
|
-
\u{8BF7}\u{6309}\u{7167}\u{4EE5}\u{4E0B}\u{7EF4}\u{5EA6}\u{5BF9}\u{4EFB}\u{52A1}\u{9700}\u{6C42}\u{8FDB}\u{884C}\u{8BC4}\u{5206}\u{FF1A}
|
|
6001
|
-
|
|
6002
|
-
**\u{76EE}\u{6807}\u{660E}\u{786E}\u{6027}\u{FF08}0-3\u{5206}\u{FF09}**
|
|
6003
|
-
- 3\u{5206}\u{FF1A}\u{76EE}\u{6807}\u{975E}\u{5E38}\u{6E05}\u{6670}\u{FF0C}\u{660E}\u{786E}\u{8981}\u{89E3}\u{51B3}\u{7684}\u{95EE}\u{9898}\u{548C}\u{5B9E}\u{73B0}\u{7684}\u{529F}\u{80FD}
|
|
6004
|
-
- 2\u{5206}\u{FF1A}\u{76EE}\u{6807}\u{57FA}\u{672C}\u{6E05}\u{6670}\u{FF0C}\u{4F46}\u{6709}\u{4E9B}\u{7EC6}\u{8282}\u{9700}\u{8981}\u{6F84}\u{6E05}
|
|
6005
|
-
- 1\u{5206}\u{FF1A}\u{76EE}\u{6807}\u{6A21}\u{7CCA}\u{FF0C}\u{9700}\u{8981}\u{5927}\u{91CF}\u{6F84}\u{6E05}
|
|
6006
|
-
- 0\u{5206}\u{FF1A}\u{76EE}\u{6807}\u{5B8C}\u{5168}\u{4E0D}\u{660E}\u{786E}
|
|
6007
|
-
|
|
6008
|
-
**\u{9884}\u{671F}\u{7ED3}\u{679C}\u{FF08}0-3\u{5206}\u{FF09}**
|
|
6009
|
-
- 3\u{5206}\u{FF1A}\u{6210}\u{529F}\u{6807}\u{51C6}\u{548C}\u{4EA4}\u{4ED8}\u{7269}\u{975E}\u{5E38}\u{660E}\u{786E}
|
|
6010
|
-
- 2\u{5206}\u{FF1A}\u{6709}\u{57FA}\u{672C}\u{7684}\u{6210}\u{529F}\u{6807}\u{51C6}\u{FF0C}\u{4F46}\u{4E0D}\u{591F}\u{8BE6}\u{7EC6}
|
|
6011
|
-
- 1\u{5206}\u{FF1A}\u{6210}\u{529F}\u{6807}\u{51C6}\u{6A21}\u{7CCA}
|
|
6012
|
-
- 0\u{5206}\u{FF1A}\u{6CA1}\u{6709}\u{660E}\u{786E}\u{7684}\u{6210}\u{529F}\u{6807}\u{51C6}
|
|
6013
|
-
|
|
6014
|
-
**\u{8FB9}\u{754C}\u{8303}\u{56F4}\u{FF08}0-2\u{5206}\u{FF09}**
|
|
6015
|
-
- 2\u{5206}\u{FF1A}\u{4EFB}\u{52A1}\u{8303}\u{56F4}\u{548C}\u{8FB9}\u{754C}\u{975E}\u{5E38}\u{6E05}\u{695A}
|
|
6016
|
-
- 1\u{5206}\u{FF1A}\u{8303}\u{56F4}\u{57FA}\u{672C}\u{660E}\u{786E}\u{FF0C}\u{4F46}\u{8FB9}\u{754C}\u{6A21}\u{7CCA}
|
|
6017
|
-
- 0\u{5206}\u{FF1A}\u{8303}\u{56F4}\u{548C}\u{8FB9}\u{754C}\u{90FD}\u{4E0D}\u{6E05}\u{695A}
|
|
6018
|
-
|
|
6019
|
-
**\u{7EA6}\u{675F}\u{6761}\u{4EF6}\u{FF08}0-2\u{5206}\u{FF09}**
|
|
6020
|
-
- 2\u{5206}\u{FF1A}\u{65F6}\u{95F4}\u{3001}\u{6027}\u{80FD}\u{3001}\u{4E1A}\u{52A1}\u{9650}\u{5236}\u{7B49}\u{90FD}\u{6709}\u{8BF4}\u{660E}
|
|
6021
|
-
- 1\u{5206}\u{FF1A}\u{6709}\u{90E8}\u{5206}\u{7EA6}\u{675F}\u{8BF4}\u{660E}
|
|
6022
|
-
- 0\u{5206}\u{FF1A}\u{6CA1}\u{6709}\u{7EA6}\u{675F}\u{6761}\u{4EF6}\u{8BF4}\u{660E}
|
|
6023
|
-
|
|
6024
|
-
### 2. \u{9879}\u{76EE}\u{6280}\u{672F}\u{73AF}\u{5883}\u{5206}\u{6790}
|
|
6025
|
-
- \u{68C0}\u{67E5}\u{9879}\u{76EE}\u{6839}\u{76EE}\u{5F55}\u{7684} CLAUDE.md \u{6587}\u{4EF6}
|
|
6026
|
-
- \u{5206}\u{6790} package.json\u{3001}requirements.txt \u{7B49}\u{914D}\u{7F6E}\u{6587}\u{4EF6}
|
|
6027
|
-
- \u{8BC6}\u{522B}\u{6280}\u{672F}\u{6808}\u{548C}\u{6846}\u{67B6}\u{7248}\u{672C}
|
|
6028
|
-
- \u{83B7}\u{53D6}\u{9879}\u{76EE}\u{7ED3}\u{6784}\u{4FE1}\u{606F}
|
|
6029
|
-
|
|
6030
|
-
### 3. \u{5B8C}\u{6574}\u{6027}\u{8BC4}\u{4F30}
|
|
6031
|
-
- \u{8BA1}\u{7B97}\u{603B}\u{4F53}\u{5B8C}\u{6574}\u{6027}\u{5F97}\u{5206}\u{FF08}\u{603B}\u{5206}10\u{5206}\u{FF09}
|
|
6032
|
-
- \u{5982}\u{679C}\u{5F97}\u{5206} >= 7\u{5206}\u{FF1A}\u{51C6}\u{5907}\u{8FDB}\u{5165}\u{6784}\u{601D}\u{9636}\u{6BB5}
|
|
6033
|
-
- \u{5982}\u{679C}\u{5F97}\u{5206} < 7\u{5206}\u{FF1A}\u{5217}\u{51FA}\u{9700}\u{8981}\u{8865}\u{5145}\u{7684}\u{5173}\u{952E}\u{4FE1}\u{606F}
|
|
6034
|
-
|
|
6035
|
-
## \u{9884}\u{671F}\u{8F93}\u{51FA}
|
|
6036
|
-
\u{9700}\u{6C42}\u{5B8C}\u{6574}\u{6027}\u{8BC4}\u{5206}\u{62A5}\u{544A}\u{FF0C}\u{5305}\u{542B}\u{5404}\u{7EF4}\u{5EA6}\u{5F97}\u{5206}\u{548C}\u{603B}\u{5206}\u{3002}\u{5982}\u{679C}\u{8BC4}\u{5206}\u{4F4E}\u{4E8E}7\u{5206}\u{FF0C}\u{8BF7}\u{5217}\u{51FA}\u{5177}\u{4F53}\u{7684}\u{8865}\u{5145}\u{95EE}\u{9898}\u{3002}
|
|
6037
|
-
|
|
6038
|
-
## \u{4E0B}\u{4E00}\u{6B65}
|
|
6039
|
-
\u{5B8C}\u{6210}\u{9700}\u{6C42}\u{5206}\u{6790}\u{540E}\u{FF0C}\u{8BF7}\u{4F7F}\u{7528} current_stage="ideation" \u{8FDB}\u{5165}\u{6784}\u{601D}\u{9636}\u{6BB5}\u{3002}`;
|
|
6040
|
-
}
|
|
6041
|
-
async function generateIdeationGuidance(taskDescription, userInput) {
|
|
6042
|
-
const mode = getStageMode("ideation");
|
|
6043
|
-
return `${mode} - \u{89E3}\u{51B3}\u{65B9}\u{6848}\u{8BBE}\u{8BA1}
|
|
6044
|
-
|
|
6045
|
-
## \u{4EFB}\u{52A1}\u{9700}\u{6C42}
|
|
6046
|
-
${taskDescription}
|
|
6047
|
-
|
|
6048
|
-
## \u{6267}\u{884C}\u{6B65}\u{9AA4}
|
|
6049
|
-
|
|
6050
|
-
### 1. \u{65B9}\u{6848}\u{751F}\u{6210}
|
|
6051
|
-
\u{8BF7}\u{8BBE}\u{8BA1}\u{81F3}\u{5C11}2-3\u{4E2A}\u{4E0D}\u{540C}\u{7684}\u{89E3}\u{51B3}\u{65B9}\u{6848}\u{FF0C}\u{6BCF}\u{4E2A}\u{65B9}\u{6848}\u{9700}\u{8981}\u{5305}\u{542B}\u{FF1A}
|
|
6052
|
-
|
|
6053
|
-
**\u{65B9}\u{6848}\u{683C}\u{5F0F}\u{793A}\u{4F8B}\u{FF1A}**
|
|
6054
|
-
**\u{65B9}\u{6848} 1\u{FF1A}[\u{65B9}\u{6848}\u{540D}\u{79F0}]**
|
|
6055
|
-
- **\u{63CF}\u{8FF0}**\u{FF1A}\u{8BE6}\u{7EC6}\u{8BF4}\u{660E}\u{89E3}\u{51B3}\u{601D}\u{8DEF}\u{548C}\u{5B9E}\u{73B0}\u{65B9}\u{5F0F}
|
|
6056
|
-
- **\u{4F18}\u{70B9}**\u{FF1A}
|
|
6057
|
-
- \u{4F18}\u{70B9}1
|
|
6058
|
-
- \u{4F18}\u{70B9}2
|
|
6059
|
-
- **\u{7F3A}\u{70B9}**\u{FF1A}
|
|
6060
|
-
- \u{7F3A}\u{70B9}1
|
|
6061
|
-
- \u{7F3A}\u{70B9}2
|
|
6062
|
-
- **\u{590D}\u{6742}\u{5EA6}**\u{FF1A}low/medium/high
|
|
6063
|
-
- **\u{4F30}\u{7B97}\u{65F6}\u{95F4}**\u{FF1A}\u{5177}\u{4F53}\u{65F6}\u{95F4}\u{4F30}\u{7B97}
|
|
6064
|
-
- **\u{6280}\u{672F}\u{8981}\u{6C42}**\u{FF1A}\u{9700}\u{8981}\u{7684}\u{6280}\u{672F}\u{548C}\u{4F9D}\u{8D56}
|
|
6065
|
-
- **\u{98CE}\u{9669}\u{7B49}\u{7EA7}**\u{FF1A}low/medium/high
|
|
6066
|
-
- **\u{9002}\u{7528}\u{573A}\u{666F}**\u{FF1A}\u{4EC0}\u{4E48}\u{60C5}\u{51B5}\u{4E0B}\u{9009}\u{62E9}\u{8FD9}\u{4E2A}\u{65B9}\u{6848}
|
|
6067
|
-
|
|
6068
|
-
### 2. \u{65B9}\u{6848}\u{8BC4}\u{4F30}
|
|
6069
|
-
\u{5BF9}\u{6BCF}\u{4E2A}\u{65B9}\u{6848}\u{8FDB}\u{884C}\u{5BA2}\u{89C2}\u{8BC4}\u{4F30}\u{FF1A}
|
|
6070
|
-
- \u{53EF}\u{884C}\u{6027}\u{8BC4}\u{4F30}\u{FF08}1-5\u{5206}\u{FF09}
|
|
6071
|
-
- \u{8D28}\u{91CF}\u{8BC4}\u{4F30}\u{FF08}1-5\u{5206}\u{FF09}
|
|
6072
|
-
- \u{98CE}\u{9669}\u{8BC4}\u{4F30}\u{FF08}1-5\u{5206}\u{FF09}
|
|
6073
|
-
- \u{6210}\u{672C}\u{6548}\u{76CA}\u{FF08}1-5\u{5206}\u{FF09}
|
|
6074
|
-
|
|
6075
|
-
### 3. \u{65B9}\u{6848}\u{9009}\u{62E9}
|
|
6076
|
-
\u{9009}\u{62E9}\u{6700}\u{9002}\u{5408}\u{7684}\u{65B9}\u{6848}\u{FF0C}\u{5E76}\u{8BF4}\u{660E}\u{9009}\u{62E9}\u{7406}\u{7531}\u{3002}
|
|
6077
|
-
|
|
6078
|
-
## \u{9884}\u{671F}\u{8F93}\u{51FA}
|
|
6079
|
-
\u{81F3}\u{5C11}2-3\u{4E2A}\u{8BE6}\u{7EC6}\u{7684}\u{89E3}\u{51B3}\u{65B9}\u{6848}\u{FF0C}\u{5305}\u{542B}\u{5B8C}\u{6574}\u{7684}\u{8BC4}\u{4F30}\u{4FE1}\u{606F}\u{548C}\u{63A8}\u{8350}\u{9009}\u{62E9}\u{3002}
|
|
6080
|
-
|
|
6081
|
-
## \u{4E0B}\u{4E00}\u{6B65}
|
|
6082
|
-
\u{9009}\u{5B9A}\u{65B9}\u{6848}\u{540E}\u{FF0C}\u{8BF7}\u{4F7F}\u{7528} current_stage="planning" \u{8FDB}\u{5165}\u{8BA1}\u{5212}\u{9636}\u{6BB5}\u{3002}`;
|
|
6083
|
-
}
|
|
6084
|
-
async function generatePlanningGuidance(taskDescription, userInput) {
|
|
6085
|
-
const mode = getStageMode("planning");
|
|
6086
|
-
return `${mode} - \u{6267}\u{884C}\u{8BA1}\u{5212}\u{5236}\u{5B9A}
|
|
6087
|
-
|
|
6088
|
-
## \u{4EFB}\u{52A1}\u{63CF}\u{8FF0}
|
|
6089
|
-
${taskDescription}
|
|
6090
|
-
|
|
6091
|
-
## \u{6267}\u{884C}\u{6B65}\u{9AA4}
|
|
6092
|
-
|
|
6093
|
-
### 1. \u{65B9}\u{6848}\u{7EC6}\u{5316}
|
|
6094
|
-
\u{5C06}\u{9009}\u{5B9A}\u{7684}\u{89E3}\u{51B3}\u{65B9}\u{6848}\u{7EC6}\u{5316}\u{4E3A}\u{5177}\u{4F53}\u{7684}\u{5B9E}\u{73B0}\u{6B65}\u{9AA4}\u{FF1A}
|
|
6095
|
-
- \u{6280}\u{672F}\u{67B6}\u{6784}\u{5206}\u{6790}
|
|
6096
|
-
- \u{6587}\u{4EF6}\u{7ED3}\u{6784}\u{89C4}\u{5212}
|
|
6097
|
-
- \u{6838}\u{5FC3}\u{5B9E}\u{73B0}\u{5206}\u{6790}
|
|
6098
|
-
- \u{4F9D}\u{8D56}\u{548C}\u{8D44}\u{6E90}\u{9700}\u{6C42}
|
|
6099
|
-
|
|
6100
|
-
### 2. \u{6267}\u{884C}\u{8BA1}\u{5212}\u{5236}\u{5B9A}
|
|
6101
|
-
\u{521B}\u{5EFA}\u{8BE6}\u{7EC6}\u{7684}\u{6267}\u{884C}\u{8BA1}\u{5212}\u{FF0C}\u{6BCF}\u{4E2A}\u{6B65}\u{9AA4}\u{5FC5}\u{987B}\u{5305}\u{542B}\u{FF1A}
|
|
6102
|
-
|
|
6103
|
-
**\u{6B65}\u{9AA4} X\u{FF1A}[\u{6B65}\u{9AA4}\u{540D}\u{79F0}]**
|
|
6104
|
-
- **\u{7C7B}\u{578B}**\u{FF1A}file_creation | file_modification | function_implementation | class_implementation | test_creation | configuration
|
|
6105
|
-
- **\u{63CF}\u{8FF0}**\u{FF1A}\u{8BE6}\u{7EC6}\u{8BF4}\u{660E}\u{8981}\u{505A}\u{4EC0}\u{4E48}
|
|
6106
|
-
- **\u{76EE}\u{6807}\u{6587}\u{4EF6}**\u{FF1A}\u{6D89}\u{53CA}\u{7684}\u{6587}\u{4EF6}\u{8DEF}\u{5F84}
|
|
6107
|
-
- **\u{539F}\u{5B50}\u{64CD}\u{4F5C}**\u{FF1A}
|
|
6108
|
-
- \u{521B}\u{5EFA}\u{6587}\u{4EF6}\u{FF1A}\u{5177}\u{4F53}\u{6587}\u{4EF6}\u{8DEF}\u{5F84}\u{548C}\u{57FA}\u{672C}\u{7ED3}\u{6784}
|
|
6109
|
-
- \u{5B9E}\u{73B0}\u{51FD}\u{6570}\u{FF1A}\u{51FD}\u{6570}\u{7B7E}\u{540D}\u{548C}\u{6838}\u{5FC3}\u{903B}\u{8F91}\u{6982}\u{8981}
|
|
6110
|
-
- \u{4FEE}\u{6539}\u{914D}\u{7F6E}\u{FF1A}\u{5177}\u{4F53}\u{7684}\u{914D}\u{7F6E}\u{9879}\u{548C}\u{503C}
|
|
6111
|
-
- **\u{9884}\u{671F}\u{7ED3}\u{679C}**\u{FF1A}\u{5B8C}\u{6210}\u{540E}\u{7684}\u{72B6}\u{6001}\u{548C}\u{6548}\u{679C}
|
|
6112
|
-
- **\u{4F9D}\u{8D56}\u{6B65}\u{9AA4}**\u{FF1A}\u{5FC5}\u{987B}\u{5148}\u{5B8C}\u{6210}\u{7684}\u{6B65}\u{9AA4}
|
|
6113
|
-
- **\u{4F30}\u{7B97}\u{65F6}\u{95F4}**\u{FF1A}\u{9884}\u{8BA1}\u{6267}\u{884C}\u{65F6}\u{95F4}
|
|
6114
|
-
|
|
6115
|
-
### 3. \u{8BA1}\u{5212}\u{5BA1}\u{6838}
|
|
6116
|
-
\u{68C0}\u{67E5}\u{8BA1}\u{5212}\u{7684}\u{5B8C}\u{6574}\u{6027}\u{548C}\u{53EF}\u{884C}\u{6027}\u{FF1A}
|
|
6117
|
-
- \u{6B65}\u{9AA4}\u{987A}\u{5E8F}\u{662F}\u{5426}\u{5408}\u{7406}
|
|
6118
|
-
- \u{4F9D}\u{8D56}\u{5173}\u{7CFB}\u{662F}\u{5426}\u{6B63}\u{786E}
|
|
6119
|
-
- \u{65F6}\u{95F4}\u{4F30}\u{7B97}\u{662F}\u{5426}\u{73B0}\u{5B9E}
|
|
6120
|
-
- \u{662F}\u{5426}\u{9057}\u{6F0F}\u{5173}\u{952E}\u{6B65}\u{9AA4}
|
|
6121
|
-
|
|
6122
|
-
## \u{91CD}\u{8981}\u{63D0}\u{9192}
|
|
6123
|
-
- \u{5728}\u{5BFC}\u{5165}\u{8BED}\u{53E5}\u{4E4B}\u{524D}\u{6DFB}\u{52A0}\u{4F7F}\u{7528}\u{65B9}\u{6CD5}\u{6CE8}\u{91CA}\u{FF08}\u{5173}\u{952E}\u{89C4}\u{5219}\u{FF09}
|
|
6124
|
-
- \u{8BA1}\u{5212}\u{5C06}\u{5B58}\u{50A8}\u{5728}\u{9879}\u{76EE}\u{6839}\u{76EE}\u{5F55} .claude/plan/\u{4EFB}\u{52A1}\u{540D}.md \u{4E2D}
|
|
6125
|
-
- \u{5982}\u{9700}\u{65B0}\u{5E93}\u{FF0C}\u{6807}\u{6CE8}\u{9700}\u{8981}\u{4F7F}\u{7528} Context7 \u{67E5}\u{8BE2}
|
|
6126
|
-
|
|
6127
|
-
## \u{9884}\u{671F}\u{8F93}\u{51FA}
|
|
6128
|
-
\u{5B8C}\u{6574}\u{3001}\u{8BE6}\u{7EC6}\u{7684}\u{6267}\u{884C}\u{8BA1}\u{5212}\u{FF0C}\u{5305}\u{542B}\u{6240}\u{6709}\u{539F}\u{5B50}\u{64CD}\u{4F5C}\u{6B65}\u{9AA4}\u{3002}
|
|
6129
|
-
|
|
6130
|
-
## \u{4E0B}\u{4E00}\u{6B65}
|
|
6131
|
-
\u{8BA1}\u{5212}\u{5236}\u{5B9A}\u{5B8C}\u{6210}\u{540E}\u{FF0C}\u{8BF7}\u{7528}\u{6237}\u{6279}\u{51C6}\u{FF0C}\u{7136}\u{540E}\u{4F7F}\u{7528} current_stage="execution" \u{8FDB}\u{5165}\u{6267}\u{884C}\u{9636}\u{6BB5}\u{3002}`;
|
|
6132
|
-
}
|
|
6133
|
-
async function generateExecutionGuidance(taskDescription, userInput) {
|
|
6134
|
-
const mode = getStageMode("execution");
|
|
6135
|
-
return `${mode} - \u{4EE3}\u{7801}\u{5B9E}\u{65BD}
|
|
6136
|
-
|
|
6137
|
-
## \u{4EFB}\u{52A1}\u{63CF}\u{8FF0}
|
|
6138
|
-
${taskDescription}
|
|
6139
|
-
|
|
6140
|
-
## \u{6267}\u{884C}\u{539F}\u{5219}
|
|
6141
|
-
|
|
6142
|
-
### 1. \u{4E25}\u{683C}\u{6309}\u{8BA1}\u{5212}\u{6267}\u{884C}
|
|
6143
|
-
- \u{6309}\u{7167}\u{6B65}\u{9AA4}\u{987A}\u{5E8F}\u{8FDB}\u{884C}\u{FF0C}\u{4E0D}\u{8DF3}\u{8FC7}\u{4EFB}\u{4F55}\u{6B65}\u{9AA4}
|
|
6144
|
-
- \u{786E}\u{4FDD}\u{6BCF}\u{4E2A}\u{6B65}\u{9AA4}\u{7684}\u{5B8C}\u{6574}\u{6027}
|
|
6145
|
-
- \u{9075}\u{5FAA}\u{539F}\u{5B50}\u{64CD}\u{4F5C}\u{539F}\u{5219}
|
|
6146
|
-
|
|
6147
|
-
### 2. \u{4EE3}\u{7801}\u{8D28}\u{91CF}\u{8981}\u{6C42}
|
|
6148
|
-
- \u{9075}\u{5FAA}\u{9879}\u{76EE}\u{7684}\u{4EE3}\u{7801}\u{89C4}\u{8303}\u{548C}\u{6700}\u{4F73}\u{5B9E}\u{8DF5}
|
|
6149
|
-
- **\u{5173}\u{952E}\u{89C4}\u{5219}**\u{FF1A}\u{5728}\u{5BFC}\u{5165}\u{8BED}\u{53E5}\u{4E4B}\u{524D}\u{6DFB}\u{52A0}\u{4F7F}\u{7528}\u{65B9}\u{6CD5}\u{6CE8}\u{91CA}
|
|
6150
|
-
- \u{4FDD}\u{6301}\u{4EE3}\u{7801}\u{7684}\u{53EF}\u{8BFB}\u{6027}\u{548C}\u{53EF}\u{7EF4}\u{62A4}\u{6027}
|
|
6151
|
-
- \u{6DFB}\u{52A0}\u{5FC5}\u{8981}\u{7684}\u{6CE8}\u{91CA}\u{548C}\u{6587}\u{6863}
|
|
6152
|
-
|
|
6153
|
-
### 3. \u{8FDB}\u{5EA6}\u{7BA1}\u{7406}
|
|
6154
|
-
- \u{5728}\u{5173}\u{952E}\u{91CC}\u{7A0B}\u{7891}\u{8BF7}\u{6C42}\u{7528}\u{6237}\u{53CD}\u{9988}
|
|
6155
|
-
- \u{53CA}\u{65F6}\u{62A5}\u{544A}\u{9047}\u{5230}\u{7684}\u{95EE}\u{9898}
|
|
6156
|
-
- \u{4FDD}\u{6301}\u{4E0E}\u{8BA1}\u{5212}\u{7684}\u{4E00}\u{81F4}\u{6027}
|
|
6157
|
-
|
|
6158
|
-
## \u{6267}\u{884C}\u{6B65}\u{9AA4}
|
|
6159
|
-
1. \u{521B}\u{5EFA} .claude/plan/ \u{76EE}\u{5F55}\u{FF08}\u{5982}\u{679C}\u{4E0D}\u{5B58}\u{5728}\u{FF09}
|
|
6160
|
-
2. \u{5C06}\u{6267}\u{884C}\u{8BA1}\u{5212}\u{4FDD}\u{5B58}\u{5230} .claude/plan/\u{4EFB}\u{52A1}\u{540D}.md
|
|
6161
|
-
3. \u{6309}\u{8BA1}\u{5212}\u{9010}\u{6B65}\u{5B9E}\u{65BD}\u{4EE3}\u{7801}
|
|
6162
|
-
4. \u{5728}\u{5173}\u{952E}\u{8282}\u{70B9}\u{8BF7}\u{6C42}\u{7528}\u{6237}\u{786E}\u{8BA4}
|
|
6163
|
-
|
|
6164
|
-
## \u{9884}\u{671F}\u{8F93}\u{51FA}
|
|
6165
|
-
\u{6309}\u{8BA1}\u{5212}\u{5B8C}\u{6210}\u{7684}\u{4EE3}\u{7801}\u{5B9E}\u{65BD}\u{FF0C}\u{5305}\u{542B}\u{6240}\u{6709}\u{5FC5}\u{8981}\u{7684}\u{6587}\u{4EF6}\u{3001}\u{51FD}\u{6570}\u{548C}\u{914D}\u{7F6E}\u{3002}
|
|
6166
|
-
|
|
6167
|
-
## \u{4E0B}\u{4E00}\u{6B65}
|
|
6168
|
-
\u{6267}\u{884C}\u{5B8C}\u{6210}\u{540E}\u{FF0C}\u{8BF7}\u{4F7F}\u{7528} current_stage="optimization" \u{8FDB}\u{5165}\u{4F18}\u{5316}\u{9636}\u{6BB5}\u{3002}`;
|
|
6169
|
-
}
|
|
6170
|
-
async function generateOptimizationGuidance(taskDescription, userInput) {
|
|
6171
|
-
const mode = getStageMode("optimization");
|
|
6172
|
-
return `${mode} - \u{4EE3}\u{7801}\u{8D28}\u{91CF}\u{4F18}\u{5316}
|
|
6173
|
-
|
|
6174
|
-
## \u{4EFB}\u{52A1}\u{63CF}\u{8FF0}
|
|
6175
|
-
${taskDescription}
|
|
6176
|
-
|
|
6177
|
-
## \u{6267}\u{884C}\u{6B65}\u{9AA4}
|
|
6178
|
-
|
|
6179
|
-
### 1. \u{4EE3}\u{7801}\u{5206}\u{6790}
|
|
6180
|
-
\u{81EA}\u{52A8}\u{5206}\u{6790}\u{672C}\u{6B21}\u{4EFB}\u{52A1}\u{5B9E}\u{73B0}\u{7684}\u{4EE3}\u{7801}\u{FF1A}
|
|
6181
|
-
- \u{4EE3}\u{7801}\u{7ED3}\u{6784}\u{548C}\u{67B6}\u{6784}\u{8BBE}\u{8BA1}
|
|
6182
|
-
- \u{4EE3}\u{7801}\u{8D28}\u{91CF}\u{548C}\u{89C4}\u{8303}\u{9075}\u{5FAA}\u{60C5}\u{51B5}
|
|
6183
|
-
- \u{6F5C}\u{5728}\u{7684}\u{6027}\u{80FD}\u{95EE}\u{9898}
|
|
6184
|
-
- \u{5197}\u{4F59}\u{3001}\u{4F4E}\u{6548}\u{6216}\u{5783}\u{573E}\u{4EE3}\u{7801}
|
|
6185
|
-
- \u{53EF}\u{7EF4}\u{62A4}\u{6027}\u{548C}\u{53EF}\u{6269}\u{5C55}\u{6027}
|
|
6186
|
-
|
|
6187
|
-
### 2. \u{4F18}\u{5316}\u{5EFA}\u{8BAE}\u{751F}\u{6210}
|
|
6188
|
-
\u{4E3A}\u{6BCF}\u{4E2A}\u{95EE}\u{9898}\u{63D0}\u{51FA}\u{9488}\u{5BF9}\u{6027}\u{7684}\u{4F18}\u{5316}\u{65B9}\u{6848}\u{FF1A}
|
|
6189
|
-
- \u{95EE}\u{9898}\u{63CF}\u{8FF0}\u{548C}\u{5F71}\u{54CD}\u{8303}\u{56F4}
|
|
6190
|
-
- \u{5177}\u{4F53}\u{7684}\u{4F18}\u{5316}\u{65B9}\u{6848}
|
|
6191
|
-
- \u{4F18}\u{5316}\u{7406}\u{7531}\u{548C}\u{9884}\u{671F}\u{6536}\u{76CA}
|
|
6192
|
-
- \u{5B9E}\u{65BD}\u{96BE}\u{5EA6}\u{548C}\u{98CE}\u{9669}\u{8BC4}\u{4F30}
|
|
6193
|
-
- \u{6309}\u{4F18}\u{5148}\u{7EA7}\u{6392}\u{5E8F}
|
|
6194
|
-
|
|
6195
|
-
### 3. \u{4F18}\u{5316}\u{5B9E}\u{65BD}
|
|
6196
|
-
\u{7528}\u{6237}\u{786E}\u{8BA4}\u{540E}\u{6267}\u{884C}\u{76F8}\u{5173}\u{4F18}\u{5316}\u{529F}\u{80FD}\u{FF1A}
|
|
6197
|
-
- \u{6309}\u{4F18}\u{5148}\u{7EA7}\u{9010}\u{9879}\u{5B9E}\u{65BD}
|
|
6198
|
-
- \u{4FDD}\u{6301}\u{4EE3}\u{7801}\u{529F}\u{80FD}\u{7684}\u{5B8C}\u{6574}\u{6027}
|
|
6199
|
-
- \u{9A8C}\u{8BC1}\u{4F18}\u{5316}\u{540E}\u{7684}\u{4EE3}\u{7801}\u{6B63}\u{786E}\u{6027}
|
|
6200
|
-
- \u{6D4B}\u{8BD5}\u{4F18}\u{5316}\u{6548}\u{679C}
|
|
6201
|
-
|
|
6202
|
-
## \u{4F18}\u{5316}\u{7C7B}\u{522B}
|
|
6203
|
-
- **\u{6027}\u{80FD}\u{4F18}\u{5316}**\u{FF1A}\u{7B97}\u{6CD5}\u{4F18}\u{5316}\u{3001}\u{6570}\u{636E}\u{7ED3}\u{6784}\u{6539}\u{8FDB}\u{3001}\u{7F13}\u{5B58}\u{7B56}\u{7565}
|
|
6204
|
-
- **\u{4EE3}\u{7801}\u{8D28}\u{91CF}\u{4F18}\u{5316}**\u{FF1A}\u{91CD}\u{6784}\u{5197}\u{4F59}\u{4EE3}\u{7801}\u{3001}\u{6539}\u{8FDB}\u{547D}\u{540D}\u{548C}\u{7ED3}\u{6784}
|
|
6205
|
-
- **\u{67B6}\u{6784}\u{4F18}\u{5316}**\u{FF1A}\u{6A21}\u{5757}\u{89E3}\u{8026}\u{3001}\u{63A5}\u{53E3}\u{7B80}\u{5316}\u{3001}\u{4F9D}\u{8D56}\u{4F18}\u{5316}
|
|
6206
|
-
- **\u{5B89}\u{5168}\u{6027}\u{4F18}\u{5316}**\u{FF1A}\u{8F93}\u{5165}\u{9A8C}\u{8BC1}\u{3001}\u{9519}\u{8BEF}\u{4FE1}\u{606F}\u{5904}\u{7406}\u{3001}\u{6743}\u{9650}\u{63A7}\u{5236}
|
|
6207
|
-
|
|
6208
|
-
## \u{9884}\u{671F}\u{8F93}\u{51FA}
|
|
6209
|
-
\u{4F18}\u{5148}\u{7EA7}\u{6392}\u{5E8F}\u{7684}\u{4F18}\u{5316}\u{5EFA}\u{8BAE}\u{6E05}\u{5355}\u{548C}\u{4F18}\u{5316}\u{540E}\u{7684}\u{4EE3}\u{7801}\u{3002}
|
|
6210
|
-
|
|
6211
|
-
## \u{4E0B}\u{4E00}\u{6B65}
|
|
6212
|
-
\u{4F18}\u{5316}\u{5B8C}\u{6210}\u{540E}\u{FF0C}\u{8BF7}\u{4F7F}\u{7528} current_stage="review" \u{8FDB}\u{5165}\u{8BC4}\u{5BA1}\u{9636}\u{6BB5}\u{3002}`;
|
|
6213
|
-
}
|
|
6214
|
-
async function generateReviewGuidance(taskDescription, userInput) {
|
|
6215
|
-
const mode = getStageMode("review");
|
|
6216
|
-
return `${mode} - \u{6700}\u{7EC8}\u{8BC4}\u{4F30}
|
|
6217
|
-
|
|
6218
|
-
## \u{4EFB}\u{52A1}\u{63CF}\u{8FF0}
|
|
6219
|
-
${taskDescription}
|
|
6220
|
-
|
|
6221
|
-
## \u{6267}\u{884C}\u{6B65}\u{9AA4}
|
|
6222
|
-
|
|
6223
|
-
### 1. \u{6267}\u{884C}\u{7ED3}\u{679C}\u{8BC4}\u{4F30}
|
|
6224
|
-
\u{5168}\u{9762}\u{8BC4}\u{4F30}\u{4EFB}\u{52A1}\u{6267}\u{884C}\u{7ED3}\u{679C}\u{FF1A}
|
|
6225
|
-
- \u{529F}\u{80FD}\u{5B8C}\u{6210}\u{5EA6}\u{8BC4}\u{4F30}
|
|
6226
|
-
- \u{6280}\u{672F}\u{5B9E}\u{73B0}\u{8BC4}\u{4F30}
|
|
6227
|
-
- \u{8BA1}\u{5212}\u{6267}\u{884C}\u{8BC4}\u{4F30}
|
|
6228
|
-
- \u{8D28}\u{91CF}\u{4FDD}\u{8BC1}\u{8BC4}\u{4F30}
|
|
6229
|
-
- \u{4EA4}\u{4ED8}\u{7269}\u{68C0}\u{67E5}
|
|
6230
|
-
|
|
6231
|
-
### 2. \u{8BA1}\u{5212}\u{5BF9}\u{6BD4}\u{5206}\u{6790}
|
|
6232
|
-
\u{5BF9}\u{6BD4}\u{539F}\u{59CB}\u{8BA1}\u{5212}\u{4E0E}\u{5B9E}\u{9645}\u{6267}\u{884C}\u{60C5}\u{51B5}\u{FF1A}
|
|
6233
|
-
- \u{6B65}\u{9AA4}\u{6267}\u{884C}\u{5BF9}\u{6BD4}
|
|
6234
|
-
- \u{65F6}\u{95F4}\u{5BF9}\u{6BD4}\u{5206}\u{6790}
|
|
6235
|
-
- \u{6280}\u{672F}\u{65B9}\u{6848}\u{5BF9}\u{6BD4}
|
|
6236
|
-
- \u{8D28}\u{91CF}\u{6807}\u{51C6}\u{5BF9}\u{6BD4}
|
|
6237
|
-
- \u{98CE}\u{9669}\u{7BA1}\u{7406}\u{5BF9}\u{6BD4}
|
|
6238
|
-
|
|
6239
|
-
### 3. \u{6700}\u{7EC8}\u{786E}\u{8BA4}
|
|
6240
|
-
\u{63D0}\u{4F9B}\u{5B8C}\u{6210}\u{603B}\u{7ED3}\u{FF0C}\u{8BF7}\u{6C42}\u{7528}\u{6237}\u{6700}\u{7EC8}\u{786E}\u{8BA4}\u{FF1A}
|
|
6241
|
-
- \u{4EFB}\u{52A1}\u{5B8C}\u{6210}\u{603B}\u{7ED3}\u{62A5}\u{544A}
|
|
6242
|
-
- \u{4EA4}\u{4ED8}\u{7269}\u{6E05}\u{5355}
|
|
6243
|
-
- \u{8D28}\u{91CF}\u{68C0}\u{67E5}\u{7ED3}\u{679C}
|
|
6244
|
-
- \u{7528}\u{6237}\u{786E}\u{8BA4}\u{548C}\u{53CD}\u{9988}\u{6536}\u{96C6}
|
|
6245
|
-
|
|
6246
|
-
## \u{8BC4}\u{4F30}\u{7EF4}\u{5EA6}
|
|
6247
|
-
- [ ] \u{6838}\u{5FC3}\u{529F}\u{80FD}\u{662F}\u{5426}\u{5B8C}\u{5168}\u{5B9E}\u{73B0}\u{FF1F}
|
|
6248
|
-
- [ ] \u{6240}\u{6709}\u{9700}\u{6C42}\u{662F}\u{5426}\u{5F97}\u{5230}\u{6EE1}\u{8DB3}\u{FF1F}
|
|
6249
|
-
- [ ] \u{4EE3}\u{7801}\u{8D28}\u{91CF}\u{662F}\u{5426}\u{8FBE}\u{6807}\u{FF1F}
|
|
6250
|
-
- [ ] \u{6587}\u{6863}\u{662F}\u{5426}\u{5B8C}\u{6574}\u{FF1F}
|
|
6251
|
-
- [ ] \u{662F}\u{5426}\u{9075}\u{5FAA}\u{6700}\u{4F73}\u{5B9E}\u{8DF5}\u{FF1F}
|
|
6252
|
-
|
|
6253
|
-
## \u{9884}\u{671F}\u{8F93}\u{51FA}
|
|
6254
|
-
\u{8BE6}\u{7EC6}\u{7684}\u{8BC4}\u{4F30}\u{62A5}\u{544A}\u{548C}\u{4EFB}\u{52A1}\u{5B8C}\u{6210}\u{786E}\u{8BA4}\u{3002}
|
|
6255
|
-
|
|
6256
|
-
## \u{5B8C}\u{6210}
|
|
6257
|
-
\u{1F389} \u{606D}\u{559C}\u{FF01}\u{516D}\u{6B65}\u{5DE5}\u{4F5C}\u{6D41}\u{7A0B}\u{5DF2}\u{5B8C}\u{6210}\u{3002}\u{60A8}\u{53EF}\u{4EE5}\u{5F00}\u{59CB}\u{65B0}\u{7684}\u{4EFB}\u{52A1}\u{6216}\u{5BF9}\u{5F53}\u{524D}\u{7ED3}\u{679C}\u{8FDB}\u{884C}\u{8FDB}\u{4E00}\u{6B65}\u{6539}\u{8FDB}\u{3002}`;
|
|
6258
|
-
}
|
|
6259
|
-
const codeGeneratorTool = {
|
|
6260
|
-
name: "\u7F16\u7A0B\u667A\u80FD\u4F53",
|
|
6261
|
-
description: "\u4E13\u4E1AAI\u7F16\u7A0B\u52A9\u624B\uFF0C\u63D0\u4F9B\u7ED3\u6784\u5316\u516D\u9636\u6BB5\u5F00\u53D1\u5DE5\u4F5C\u6D41\uFF08\u7814\u7A76\u2192\u6784\u601D\u2192\u8BA1\u5212\u2192\u6267\u884C\u2192\u4F18\u5316\u2192\u8BC4\u5BA1\uFF09\uFF0C\u6309\u7167workflow.md\u4E2D\u5B9A\u4E49\u7684\u6D41\u7A0B\u6307\u5BFC\u7528\u6237\u5B8C\u6210\u4EE3\u7801\u5F00\u53D1",
|
|
6262
|
-
inputSchema: {
|
|
6263
|
-
task_description: stringType().min(1).describe("\u8981\u5F00\u53D1\u7684\u4EFB\u52A1\u63CF\u8FF0"),
|
|
6264
|
-
current_stage: enumType([
|
|
6265
|
-
"research",
|
|
6266
|
-
"ideation",
|
|
6267
|
-
"planning",
|
|
6268
|
-
"execution",
|
|
6269
|
-
"optimization",
|
|
6270
|
-
"review"
|
|
6271
|
-
]).optional().default("research").describe("\u5F53\u524D\u5DE5\u4F5C\u6D41\u7A0B\u9636\u6BB5"),
|
|
6272
|
-
user_input: anyType().optional().describe("\u7528\u6237\u5728\u5F53\u524D\u9636\u6BB5\u7684\u8F93\u5165\u6570\u636E"),
|
|
6273
|
-
project_path: stringType().optional().describe("\u9879\u76EE\u8DEF\u5F84")
|
|
6274
|
-
},
|
|
6275
|
-
handler: async (args)=>{
|
|
6276
|
-
const { task_description, current_stage, user_input, project_path } = args;
|
|
6277
|
-
try {
|
|
6278
|
-
logger_logger.info("\u516D\u6B65\u5DE5\u4F5C\u6D41\u7A0B\u4EE3\u7801\u751F\u6210\u5F00\u59CB\u6267\u884C", {
|
|
6279
|
-
current_stage,
|
|
6280
|
-
task_description: task_description.substring(0, 100)
|
|
6281
|
-
});
|
|
6282
|
-
let guidance;
|
|
6283
|
-
switch(current_stage){
|
|
6284
|
-
case "research":
|
|
6285
|
-
guidance = await generateResearchGuidance(task_description);
|
|
6286
|
-
break;
|
|
6287
|
-
case "ideation":
|
|
6288
|
-
guidance = await generateIdeationGuidance(task_description, user_input);
|
|
6289
|
-
break;
|
|
6290
|
-
case "planning":
|
|
6291
|
-
guidance = await generatePlanningGuidance(task_description, user_input);
|
|
6292
|
-
break;
|
|
6293
|
-
case "execution":
|
|
6294
|
-
guidance = await generateExecutionGuidance(task_description, user_input);
|
|
6295
|
-
break;
|
|
6296
|
-
case "optimization":
|
|
6297
|
-
guidance = await generateOptimizationGuidance(task_description, user_input);
|
|
6298
|
-
break;
|
|
6299
|
-
case "review":
|
|
6300
|
-
guidance = await generateReviewGuidance(task_description, user_input);
|
|
6301
|
-
break;
|
|
6302
|
-
default:
|
|
6303
|
-
throw new Error(`\u{4E0D}\u{652F}\u{6301}\u{7684}\u{5DE5}\u{4F5C}\u{6D41}\u{7A0B}\u{9636}\u{6BB5}: ${current_stage}`);
|
|
6304
|
-
}
|
|
6305
|
-
logger_logger.info("\u516D\u6B65\u5DE5\u4F5C\u6D41\u7A0B\u6307\u5BFC\u751F\u6210\u5B8C\u6210", {
|
|
6306
|
-
current_stage
|
|
6307
|
-
});
|
|
6308
|
-
return {
|
|
6309
|
-
content: [
|
|
6310
|
-
{
|
|
6311
|
-
type: "text",
|
|
6312
|
-
text: JSON.stringify({
|
|
6313
|
-
success: true,
|
|
6314
|
-
message: "\u7F16\u7A0B\u667A\u80FD\u4F53\u6D4B\u8BD5\u6210\u529F",
|
|
6315
|
-
data: {
|
|
6316
|
-
task_description,
|
|
6317
|
-
current_stage,
|
|
6318
|
-
guidance: guidance.substring(0, 100) + '...'
|
|
6319
|
-
}
|
|
6320
|
-
})
|
|
6321
|
-
}
|
|
6322
|
-
]
|
|
6323
|
-
};
|
|
6324
|
-
} catch (error) {
|
|
6325
|
-
logger_logger.error("\u516D\u6B65\u5DE5\u4F5C\u6D41\u7A0B\u6267\u884C\u5931\u8D25", {
|
|
6326
|
-
error,
|
|
6327
|
-
args
|
|
6328
|
-
});
|
|
6329
|
-
return {
|
|
6330
|
-
content: [
|
|
6331
|
-
{
|
|
6332
|
-
type: "text",
|
|
6333
|
-
text: JSON.stringify({
|
|
6334
|
-
success: false,
|
|
6335
|
-
message: `\u{5DE5}\u{4F5C}\u{6D41}\u{7A0B}\u{6267}\u{884C}\u{5931}\u{8D25}: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`,
|
|
6336
|
-
data: null
|
|
6337
|
-
})
|
|
6338
|
-
}
|
|
6339
|
-
],
|
|
6340
|
-
isError: true
|
|
6341
|
-
};
|
|
6342
|
-
}
|
|
6343
|
-
}
|
|
6344
|
-
};
|
|
6345
5662
|
const external_node_fs_promises_namespaceObject = require("node:fs/promises");
|
|
6346
5663
|
const external_node_fs_namespaceObject = require("node:fs");
|
|
6347
5664
|
const external_node_path_namespaceObject = require("node:path");
|
|
@@ -6425,7 +5742,7 @@ ${taskDescription}
|
|
|
6425
5742
|
});
|
|
6426
5743
|
class ImagePreprocessor {
|
|
6427
5744
|
async validateImage(imagePath) {
|
|
6428
|
-
|
|
5745
|
+
logger.info("ImagePreprocessor: \u5F00\u59CB\u9A8C\u8BC1\u56FE\u7247", imagePath);
|
|
6429
5746
|
const result = {
|
|
6430
5747
|
isValid: false,
|
|
6431
5748
|
fileExists: false,
|
|
@@ -6437,7 +5754,7 @@ ${taskDescription}
|
|
|
6437
5754
|
result.formatSupported = types_SUPPORTED_IMAGE_FORMATS.includes(fileExtension);
|
|
6438
5755
|
if (!result.formatSupported) {
|
|
6439
5756
|
result.errorMessage = `\u{4E0D}\u{652F}\u{6301}\u{7684}\u{56FE}\u{7247}\u{683C}\u{5F0F}: ${fileExtension}`;
|
|
6440
|
-
|
|
5757
|
+
logger.warn("\u4E0D\u652F\u6301\u7684\u56FE\u7247\u683C\u5F0F", {
|
|
6441
5758
|
imagePath,
|
|
6442
5759
|
format: fileExtension
|
|
6443
5760
|
});
|
|
@@ -6446,12 +5763,12 @@ ${taskDescription}
|
|
|
6446
5763
|
try {
|
|
6447
5764
|
await external_node_fs_promises_namespaceObject.access(imagePath, external_node_fs_namespaceObject.constants.R_OK);
|
|
6448
5765
|
result.readable = true;
|
|
6449
|
-
|
|
5766
|
+
logger.debug("\u56FE\u7247\u6587\u4EF6\u53EF\u8BFB", {
|
|
6450
5767
|
imagePath
|
|
6451
5768
|
});
|
|
6452
5769
|
} catch (error) {
|
|
6453
5770
|
result.errorMessage = "\u56FE\u7247\u6587\u4EF6\u65E0\u6CD5\u8BFB\u53D6\uFF0C\u8BF7\u68C0\u67E5\u6587\u4EF6\u6743\u9650";
|
|
6454
|
-
|
|
5771
|
+
logger.warn("\u56FE\u7247\u6587\u4EF6\u65E0\u6CD5\u8BFB\u53D6", {
|
|
6455
5772
|
imagePath
|
|
6456
5773
|
});
|
|
6457
5774
|
return result;
|
|
@@ -6460,32 +5777,32 @@ ${taskDescription}
|
|
|
6460
5777
|
const metadata = await external_sharp_default()(imagePath).metadata();
|
|
6461
5778
|
if (!metadata.width || !metadata.height) {
|
|
6462
5779
|
result.errorMessage = "\u65E0\u6CD5\u83B7\u53D6\u56FE\u7247\u5C3A\u5BF8\u4FE1\u606F\uFF0C\u53EF\u80FD\u6587\u4EF6\u5DF2\u635F\u574F";
|
|
6463
|
-
|
|
5780
|
+
logger.warn("\u65E0\u6CD5\u83B7\u53D6\u56FE\u7247\u5C3A\u5BF8", {
|
|
6464
5781
|
imagePath
|
|
6465
5782
|
});
|
|
6466
5783
|
return result;
|
|
6467
5784
|
}
|
|
6468
|
-
|
|
5785
|
+
logger.debug("\u56FE\u7247\u5143\u6570\u636E\u83B7\u53D6\u6210\u529F", {
|
|
6469
5786
|
imagePath,
|
|
6470
5787
|
width: metadata.width,
|
|
6471
5788
|
height: metadata.height
|
|
6472
5789
|
});
|
|
6473
5790
|
} catch (error) {
|
|
6474
5791
|
result.errorMessage = "\u56FE\u7247\u6587\u4EF6\u683C\u5F0F\u9519\u8BEF\u6216\u5DF2\u635F\u574F";
|
|
6475
|
-
|
|
5792
|
+
logger.warn("\u56FE\u7247\u6587\u4EF6\u635F\u574F", {
|
|
6476
5793
|
imagePath,
|
|
6477
5794
|
error: error instanceof Error ? error.message : error
|
|
6478
5795
|
});
|
|
6479
5796
|
return result;
|
|
6480
5797
|
}
|
|
6481
5798
|
result.isValid = true;
|
|
6482
|
-
|
|
5799
|
+
logger.info("\u56FE\u7247\u9A8C\u8BC1\u6210\u529F", {
|
|
6483
5800
|
imagePath
|
|
6484
5801
|
});
|
|
6485
5802
|
return result;
|
|
6486
5803
|
} catch (error) {
|
|
6487
5804
|
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"}`;
|
|
6488
|
-
|
|
5805
|
+
logger.error("\u56FE\u7247\u9A8C\u8BC1\u5931\u8D25", {
|
|
6489
5806
|
imagePath,
|
|
6490
5807
|
error
|
|
6491
5808
|
});
|
|
@@ -6493,7 +5810,7 @@ ${taskDescription}
|
|
|
6493
5810
|
}
|
|
6494
5811
|
}
|
|
6495
5812
|
async getImageInfo(imagePath) {
|
|
6496
|
-
|
|
5813
|
+
logger.info("ImagePreprocessor: \u5F00\u59CB\u83B7\u53D6\u56FE\u7247\u4FE1\u606F", imagePath);
|
|
6497
5814
|
try {
|
|
6498
5815
|
const stats = await external_node_fs_promises_namespaceObject.stat(imagePath);
|
|
6499
5816
|
const fileName = external_node_path_namespaceObject.basename(imagePath);
|
|
@@ -6529,7 +5846,7 @@ ${taskDescription}
|
|
|
6529
5846
|
fileName,
|
|
6530
5847
|
createdAt: stats.birthtime
|
|
6531
5848
|
};
|
|
6532
|
-
|
|
5849
|
+
logger.info("\u56FE\u7247\u4FE1\u606F\u83B7\u53D6\u6210\u529F", {
|
|
6533
5850
|
imagePath,
|
|
6534
5851
|
width,
|
|
6535
5852
|
height,
|
|
@@ -6540,7 +5857,7 @@ ${taskDescription}
|
|
|
6540
5857
|
return imageInfo;
|
|
6541
5858
|
} catch (error) {
|
|
6542
5859
|
if (error instanceof ImageRecognitionError) throw error;
|
|
6543
|
-
|
|
5860
|
+
logger.error("\u83B7\u53D6\u56FE\u7247\u4FE1\u606F\u5931\u8D25", {
|
|
6544
5861
|
imagePath,
|
|
6545
5862
|
error
|
|
6546
5863
|
});
|
|
@@ -6555,7 +5872,7 @@ ${taskDescription}
|
|
|
6555
5872
|
const heightCondition = height >= LONG_IMAGE_THRESHOLDS.MIN_HEIGHT;
|
|
6556
5873
|
const aspectRatioCondition = aspectRatio <= 1 / LONG_IMAGE_THRESHOLDS.MIN_ASPECT_RATIO;
|
|
6557
5874
|
const isLong = heightCondition && aspectRatioCondition;
|
|
6558
|
-
|
|
5875
|
+
logger.debug("\u957F\u56FE\u68C0\u6D4B\u7ED3\u679C", {
|
|
6559
5876
|
width,
|
|
6560
5877
|
height,
|
|
6561
5878
|
aspectRatio: aspectRatio.toFixed(2),
|
|
@@ -6566,7 +5883,7 @@ ${taskDescription}
|
|
|
6566
5883
|
return isLong;
|
|
6567
5884
|
}
|
|
6568
5885
|
async assessImageQuality(imagePath) {
|
|
6569
|
-
|
|
5886
|
+
logger.info("ImagePreprocessor: \u5F00\u59CB\u8BC4\u4F30\u56FE\u7247\u8D28\u91CF", {
|
|
6570
5887
|
imagePath
|
|
6571
5888
|
});
|
|
6572
5889
|
try {
|
|
@@ -6608,7 +5925,7 @@ ${taskDescription}
|
|
|
6608
5925
|
clarity: clarityScore,
|
|
6609
5926
|
recommendation
|
|
6610
5927
|
};
|
|
6611
|
-
|
|
5928
|
+
logger.info("\u56FE\u7247\u8D28\u91CF\u8BC4\u4F30\u5B8C\u6210", {
|
|
6612
5929
|
imagePath,
|
|
6613
5930
|
totalScore: totalScore.toFixed(3),
|
|
6614
5931
|
resolutionScore: resolutionScore.toFixed(3),
|
|
@@ -6619,7 +5936,7 @@ ${taskDescription}
|
|
|
6619
5936
|
return assessment;
|
|
6620
5937
|
} catch (error) {
|
|
6621
5938
|
if (error instanceof ImageRecognitionError) throw error;
|
|
6622
|
-
|
|
5939
|
+
logger.error("\u56FE\u7247\u8D28\u91CF\u8BC4\u4F30\u5931\u8D25", {
|
|
6623
5940
|
imagePath,
|
|
6624
5941
|
error
|
|
6625
5942
|
});
|
|
@@ -6635,7 +5952,7 @@ ${taskDescription}
|
|
|
6635
5952
|
}
|
|
6636
5953
|
class ConfigCalculator {
|
|
6637
5954
|
async calculateSegmentConfig(imageInfo, qualityAssessment, maxSegments = LONG_IMAGE_THRESHOLDS.MAX_SEGMENTS) {
|
|
6638
|
-
|
|
5955
|
+
logger.info("ConfigCalculator: \u5F00\u59CB\u8BA1\u7B97\u5206\u6BB5\u914D\u7F6E", {
|
|
6639
5956
|
width: imageInfo.width,
|
|
6640
5957
|
height: imageInfo.height,
|
|
6641
5958
|
isLongImage: imageInfo.isLongImage
|
|
@@ -6651,7 +5968,7 @@ ${taskDescription}
|
|
|
6651
5968
|
],
|
|
6652
5969
|
estimatedTime: this.estimateSegmentProcessingTime(1, imageInfo.size)
|
|
6653
5970
|
};
|
|
6654
|
-
|
|
5971
|
+
logger.info("\u975E\u957F\u56FE\uFF0C\u4F7F\u7528\u5355\u6BB5\u914D\u7F6E", config);
|
|
6655
5972
|
return config;
|
|
6656
5973
|
}
|
|
6657
5974
|
const segmentHeight = this.calculateOptimalSegmentHeight(imageInfo, qualityAssessment);
|
|
@@ -6670,13 +5987,13 @@ ${taskDescription}
|
|
|
6670
5987
|
processingOrder,
|
|
6671
5988
|
estimatedTime
|
|
6672
5989
|
};
|
|
6673
|
-
|
|
5990
|
+
logger.info("\u5206\u6BB5\u914D\u7F6E\u8BA1\u7B97\u5B8C\u6210", {
|
|
6674
5991
|
...config,
|
|
6675
5992
|
estimatedTimeMinutes: (estimatedTime / 60000).toFixed(1)
|
|
6676
5993
|
});
|
|
6677
5994
|
return config;
|
|
6678
5995
|
} catch (error) {
|
|
6679
|
-
|
|
5996
|
+
logger.error("\u5206\u6BB5\u914D\u7F6E\u8BA1\u7B97\u5931\u8D25", {
|
|
6680
5997
|
error,
|
|
6681
5998
|
imageInfo
|
|
6682
5999
|
});
|
|
@@ -6706,7 +6023,7 @@ ${taskDescription}
|
|
|
6706
6023
|
return Math.max(overlapHeight, LONG_IMAGE_THRESHOLDS.MIN_OVERLAP);
|
|
6707
6024
|
}
|
|
6708
6025
|
calculateConcurrencyConfig(imageSize, segmentCount = 1) {
|
|
6709
|
-
|
|
6026
|
+
logger.info("ConfigCalculator: \u5F00\u59CB\u8BA1\u7B97\u5E76\u53D1\u914D\u7F6E", {
|
|
6710
6027
|
imageSize: `${(imageSize / 1024 / 1024).toFixed(2)}MB`,
|
|
6711
6028
|
segmentCount
|
|
6712
6029
|
});
|
|
@@ -6728,7 +6045,7 @@ ${taskDescription}
|
|
|
6728
6045
|
delayBetweenBatches,
|
|
6729
6046
|
memoryLimit: PERFORMANCE_LIMITS.MAX_MEMORY_MB
|
|
6730
6047
|
};
|
|
6731
|
-
|
|
6048
|
+
logger.info("\u5E76\u53D1\u914D\u7F6E\u8BA1\u7B97\u5B8C\u6210", {
|
|
6732
6049
|
...config,
|
|
6733
6050
|
systemInfo: {
|
|
6734
6051
|
totalMemoryGB: (totalMemoryMB / 1024).toFixed(1),
|
|
@@ -6740,7 +6057,7 @@ ${taskDescription}
|
|
|
6740
6057
|
});
|
|
6741
6058
|
return config;
|
|
6742
6059
|
} catch (error) {
|
|
6743
|
-
|
|
6060
|
+
logger.error("\u5E76\u53D1\u914D\u7F6E\u8BA1\u7B97\u5931\u8D25", {
|
|
6744
6061
|
error,
|
|
6745
6062
|
imageSize,
|
|
6746
6063
|
segmentCount
|
|
@@ -6757,7 +6074,7 @@ ${taskDescription}
|
|
|
6757
6074
|
return this.estimateSegmentProcessingTime(segmentCount, imageSize);
|
|
6758
6075
|
}
|
|
6759
6076
|
estimateSegmentProcessingTime(segmentCount, imageSize) {
|
|
6760
|
-
|
|
6077
|
+
logger.info("ConfigCalculator: \u5F00\u59CB\u9884\u4F30\u5904\u7406\u65F6\u95F4", {
|
|
6761
6078
|
segmentCount,
|
|
6762
6079
|
imageSize
|
|
6763
6080
|
});
|
|
@@ -6775,7 +6092,7 @@ ${taskDescription}
|
|
|
6775
6092
|
const startupOverhead = 2000;
|
|
6776
6093
|
const finalizationOverhead = 1000;
|
|
6777
6094
|
const estimatedTime = totalTime + startupOverhead + finalizationOverhead;
|
|
6778
|
-
|
|
6095
|
+
logger.info("\u5904\u7406\u65F6\u95F4\u9884\u4F30\u5B8C\u6210", {
|
|
6779
6096
|
segmentCount,
|
|
6780
6097
|
baseTimePerSegment,
|
|
6781
6098
|
concurrencyEfficiency,
|
|
@@ -6784,7 +6101,7 @@ ${taskDescription}
|
|
|
6784
6101
|
});
|
|
6785
6102
|
return estimatedTime;
|
|
6786
6103
|
} catch (error) {
|
|
6787
|
-
|
|
6104
|
+
logger.error("\u5904\u7406\u65F6\u95F4\u9884\u4F30\u5931\u8D25", {
|
|
6788
6105
|
error,
|
|
6789
6106
|
segmentCount,
|
|
6790
6107
|
imageSize
|
|
@@ -6795,7 +6112,7 @@ ${taskDescription}
|
|
|
6795
6112
|
}
|
|
6796
6113
|
class analyzer_ImageAnalyzer {
|
|
6797
6114
|
async analyzeLongImage(imagePath, imageInfo, segmentConfig, concurrencyConfig, apiPreference = 'auto') {
|
|
6798
|
-
|
|
6115
|
+
logger.info("ImageAnalyzer: \u5F00\u59CB\u5206\u6790\u957F\u56FE", {
|
|
6799
6116
|
imagePath,
|
|
6800
6117
|
totalSegments: segmentConfig.totalSegments,
|
|
6801
6118
|
maxConcurrency: concurrencyConfig.maxConcurrency
|
|
@@ -6829,7 +6146,7 @@ ${taskDescription}
|
|
|
6829
6146
|
outputPath: '',
|
|
6830
6147
|
success: 0 === summary.failedSegments
|
|
6831
6148
|
};
|
|
6832
|
-
|
|
6149
|
+
logger.info("\u957F\u56FE\u5206\u6790\u5B8C\u6210", {
|
|
6833
6150
|
imagePath,
|
|
6834
6151
|
totalSegments: summary.totalSegments,
|
|
6835
6152
|
successfulSegments: summary.successfulSegments,
|
|
@@ -6838,7 +6155,7 @@ ${taskDescription}
|
|
|
6838
6155
|
});
|
|
6839
6156
|
return result;
|
|
6840
6157
|
} catch (error) {
|
|
6841
|
-
|
|
6158
|
+
logger.error("\u957F\u56FE\u5206\u6790\u5931\u8D25", {
|
|
6842
6159
|
imagePath,
|
|
6843
6160
|
error
|
|
6844
6161
|
});
|
|
@@ -6854,7 +6171,7 @@ ${taskDescription}
|
|
|
6854
6171
|
const segments = await this.generateSegments(imagePath, imageInfo, segmentConfig);
|
|
6855
6172
|
for(let i = 0; i < segments.length; i += batchSize){
|
|
6856
6173
|
const batch = segments.slice(i, i + batchSize);
|
|
6857
|
-
|
|
6174
|
+
logger.info(`\u{5904}\u{7406}\u{6279}\u{6B21} ${Math.floor(i / batchSize) + 1}/${Math.ceil(segments.length / batchSize)}`, {
|
|
6858
6175
|
batchSize: batch.length,
|
|
6859
6176
|
startIndex: i
|
|
6860
6177
|
});
|
|
@@ -6862,7 +6179,7 @@ ${taskDescription}
|
|
|
6862
6179
|
try {
|
|
6863
6180
|
return await this.analyzeSegment(buffer, info, apiPreference);
|
|
6864
6181
|
} catch (error) {
|
|
6865
|
-
|
|
6182
|
+
logger.error(`\u{6BB5}\u{843D} ${info.index} \u{5206}\u{6790}\u{5931}\u{8D25}`, {
|
|
6866
6183
|
error
|
|
6867
6184
|
});
|
|
6868
6185
|
return {
|
|
@@ -6884,7 +6201,7 @@ ${taskDescription}
|
|
|
6884
6201
|
}
|
|
6885
6202
|
async analyzeSegment(imageBuffer, segmentInfo, apiPreference = 'auto') {
|
|
6886
6203
|
const startTime = Date.now();
|
|
6887
|
-
|
|
6204
|
+
logger.info("ImageAnalyzer: \u5F00\u59CB\u5206\u6790\u56FE\u7247\u6BB5\u843D", {
|
|
6888
6205
|
segmentIndex: segmentInfo.index,
|
|
6889
6206
|
totalSegments: segmentInfo.totalSegments,
|
|
6890
6207
|
isFirstSegment: segmentInfo.isFirstSegment,
|
|
@@ -6899,7 +6216,7 @@ ${taskDescription}
|
|
|
6899
6216
|
try {
|
|
6900
6217
|
if ('glm-4v' === apiPreference || 'auto' === apiPreference) {
|
|
6901
6218
|
apiUsed = 'glm-4v-flash';
|
|
6902
|
-
aiResponse = await
|
|
6219
|
+
aiResponse = await openAIService.analyzeImage({
|
|
6903
6220
|
image_base64: base64Image,
|
|
6904
6221
|
prompt,
|
|
6905
6222
|
system_prompt: systemPrompt,
|
|
@@ -6909,7 +6226,7 @@ ${taskDescription}
|
|
|
6909
6226
|
});
|
|
6910
6227
|
} else if ('moonshot' === apiPreference) {
|
|
6911
6228
|
apiUsed = 'kimi-latest';
|
|
6912
|
-
aiResponse = await
|
|
6229
|
+
aiResponse = await openAIService.analyzeImage({
|
|
6913
6230
|
image_base64: base64Image,
|
|
6914
6231
|
prompt,
|
|
6915
6232
|
system_prompt: systemPrompt,
|
|
@@ -6919,13 +6236,13 @@ ${taskDescription}
|
|
|
6919
6236
|
});
|
|
6920
6237
|
}
|
|
6921
6238
|
} catch (primaryError) {
|
|
6922
|
-
|
|
6239
|
+
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`, {
|
|
6923
6240
|
error: primaryError instanceof Error ? primaryError.message : primaryError
|
|
6924
6241
|
});
|
|
6925
6242
|
try {
|
|
6926
6243
|
if ('kimi-latest' !== apiUsed) {
|
|
6927
6244
|
apiUsed = 'kimi-latest';
|
|
6928
|
-
aiResponse = await
|
|
6245
|
+
aiResponse = await openAIService.analyzeImage({
|
|
6929
6246
|
image_base64: base64Image,
|
|
6930
6247
|
prompt,
|
|
6931
6248
|
system_prompt: systemPrompt,
|
|
@@ -6935,7 +6252,7 @@ ${taskDescription}
|
|
|
6935
6252
|
});
|
|
6936
6253
|
} else {
|
|
6937
6254
|
apiUsed = 'glm-4v-flash';
|
|
6938
|
-
aiResponse = await
|
|
6255
|
+
aiResponse = await openAIService.analyzeImage({
|
|
6939
6256
|
image_base64: base64Image,
|
|
6940
6257
|
prompt,
|
|
6941
6258
|
system_prompt: systemPrompt,
|
|
@@ -6966,7 +6283,7 @@ ${taskDescription}
|
|
|
6966
6283
|
totalTokens: Math.ceil((prompt.length + aiResponse.length) / 4)
|
|
6967
6284
|
}
|
|
6968
6285
|
};
|
|
6969
|
-
|
|
6286
|
+
logger.info("\u6BB5\u843D\u5206\u6790\u5B8C\u6210", {
|
|
6970
6287
|
segmentIndex: segmentInfo.index,
|
|
6971
6288
|
textLength: textContent.length,
|
|
6972
6289
|
descriptionLength: imageDescription.length,
|
|
@@ -6977,7 +6294,7 @@ ${taskDescription}
|
|
|
6977
6294
|
return result;
|
|
6978
6295
|
} catch (error) {
|
|
6979
6296
|
const processingTime = Date.now() - startTime;
|
|
6980
|
-
|
|
6297
|
+
logger.error("\u6BB5\u843D\u5206\u6790\u5931\u8D25", {
|
|
6981
6298
|
segmentIndex: segmentInfo.index,
|
|
6982
6299
|
error,
|
|
6983
6300
|
processingTimeMs: processingTime
|
|
@@ -7061,7 +6378,7 @@ ${taskDescription}
|
|
|
7061
6378
|
let textContent = '';
|
|
7062
6379
|
let imageDescription = '';
|
|
7063
6380
|
let confidence = 0.9;
|
|
7064
|
-
|
|
6381
|
+
logger.debug("AI\u54CD\u5E94\u539F\u59CB\u5185\u5BB9", {
|
|
7065
6382
|
responseLength: response.length,
|
|
7066
6383
|
responsePreview: response.substring(0, 200) + (response.length > 200 ? '...' : '')
|
|
7067
6384
|
});
|
|
@@ -7071,7 +6388,7 @@ ${taskDescription}
|
|
|
7071
6388
|
textContent = '';
|
|
7072
6389
|
imageDescription = '';
|
|
7073
6390
|
confidence = 0.9;
|
|
7074
|
-
|
|
6391
|
+
logger.debug("\u68C0\u6D4B\u5230\u65E0\u6587\u5B57\u5185\u5BB9\u6807\u8BC6");
|
|
7075
6392
|
return {
|
|
7076
6393
|
textContent,
|
|
7077
6394
|
imageDescription,
|
|
@@ -7086,14 +6403,14 @@ ${taskDescription}
|
|
|
7086
6403
|
const chineseRatio = chineseCharCount / totalCharCount;
|
|
7087
6404
|
confidence = Math.min(0.9, 0.6 + 0.3 * chineseRatio);
|
|
7088
6405
|
} else confidence = totalCharCount > 10 ? 0.8 : 0.6;
|
|
7089
|
-
|
|
6406
|
+
logger.debug("AI\u54CD\u5E94\u89E3\u6790\u7ED3\u679C", {
|
|
7090
6407
|
textContentLength: textContent.length,
|
|
7091
6408
|
chineseCharCount,
|
|
7092
6409
|
totalCharCount,
|
|
7093
6410
|
confidence
|
|
7094
6411
|
});
|
|
7095
6412
|
} catch (error) {
|
|
7096
|
-
|
|
6413
|
+
logger.warn("AI\u54CD\u5E94\u89E3\u6790\u5931\u8D25\uFF0C\u4F7F\u7528\u539F\u59CB\u54CD\u5E94", {
|
|
7097
6414
|
error
|
|
7098
6415
|
});
|
|
7099
6416
|
textContent = response.trim();
|
|
@@ -7153,7 +6470,7 @@ ${taskDescription}
|
|
|
7153
6470
|
}
|
|
7154
6471
|
async processImage(imagePath) {
|
|
7155
6472
|
const startTime = Date.now();
|
|
7156
|
-
|
|
6473
|
+
logger.info("ImageRecognitionProcessor: \u5F00\u59CB\u5904\u7406\u56FE\u7247", {
|
|
7157
6474
|
imagePath
|
|
7158
6475
|
});
|
|
7159
6476
|
try {
|
|
@@ -7164,7 +6481,7 @@ ${taskDescription}
|
|
|
7164
6481
|
});
|
|
7165
6482
|
const imageInfo = await this.preprocessor.getImageInfo(imagePath);
|
|
7166
6483
|
const qualityAssessment = await this.preprocessor.assessImageQuality(imagePath);
|
|
7167
|
-
|
|
6484
|
+
logger.info("\u56FE\u7247\u4FE1\u606F\u83B7\u53D6\u5B8C\u6210", {
|
|
7168
6485
|
width: imageInfo.width,
|
|
7169
6486
|
height: imageInfo.height,
|
|
7170
6487
|
isLongImage: imageInfo.isLongImage,
|
|
@@ -7172,7 +6489,7 @@ ${taskDescription}
|
|
|
7172
6489
|
});
|
|
7173
6490
|
const segmentConfig = await this.configCalculator.calculateSegmentConfig(imageInfo, qualityAssessment, 20);
|
|
7174
6491
|
const concurrencyConfig = this.configCalculator.calculateConcurrencyConfig(imageInfo.size, segmentConfig.totalSegments);
|
|
7175
|
-
|
|
6492
|
+
logger.info("\u5206\u6BB5\u914D\u7F6E\u8BA1\u7B97\u5B8C\u6210", {
|
|
7176
6493
|
totalSegments: segmentConfig.totalSegments,
|
|
7177
6494
|
segmentHeight: segmentConfig.segmentHeight,
|
|
7178
6495
|
maxConcurrency: concurrencyConfig.maxConcurrency
|
|
@@ -7180,7 +6497,7 @@ ${taskDescription}
|
|
|
7180
6497
|
const analysisResult = await this.analyzer.analyzeLongImage(imagePath, imageInfo, segmentConfig, concurrencyConfig, 'auto');
|
|
7181
6498
|
const outputPath = await this.generateSingleOutputFile(imageInfo, analysisResult.segmentResults, analysisResult.summary);
|
|
7182
6499
|
const totalTime = Date.now() - startTime;
|
|
7183
|
-
|
|
6500
|
+
logger.info("\u56FE\u7247\u5904\u7406\u5B8C\u6210", {
|
|
7184
6501
|
outputPath,
|
|
7185
6502
|
totalSegments: analysisResult.summary.totalSegments,
|
|
7186
6503
|
successfulSegments: analysisResult.summary.successfulSegments,
|
|
@@ -7199,7 +6516,7 @@ ${taskDescription}
|
|
|
7199
6516
|
}
|
|
7200
6517
|
};
|
|
7201
6518
|
} catch (error) {
|
|
7202
|
-
|
|
6519
|
+
logger.error("\u56FE\u7247\u5904\u7406\u5931\u8D25", {
|
|
7203
6520
|
imagePath,
|
|
7204
6521
|
error
|
|
7205
6522
|
});
|
|
@@ -7223,7 +6540,7 @@ ${taskDescription}
|
|
|
7223
6540
|
}
|
|
7224
6541
|
}
|
|
7225
6542
|
async generateSingleOutputFile(imageInfo, segmentResults, summary) {
|
|
7226
|
-
const baseDir =
|
|
6543
|
+
const baseDir = getStorageDir();
|
|
7227
6544
|
const dateDir = new Date().toISOString().split('T')[0];
|
|
7228
6545
|
const outputDirectory = external_path_namespaceObject.join(baseDir, 'image-recognition', dateDir);
|
|
7229
6546
|
await external_fs_namespaceObject.promises.mkdir(outputDirectory, {
|
|
@@ -7254,7 +6571,7 @@ ${allTextContent || "\u672A\u8BC6\u522B\u5230\u6587\u5B57\u5185\u5BB9"}
|
|
|
7254
6571
|
**\u{8BC6}\u{522B}\u{5B8C}\u{6210}\u{65F6}\u{95F4}**: ${new Date().toLocaleString('zh-CN')}
|
|
7255
6572
|
`;
|
|
7256
6573
|
await external_fs_namespaceObject.promises.writeFile(outputPath, content, 'utf8');
|
|
7257
|
-
|
|
6574
|
+
logger.info("\u8F93\u51FA\u6587\u4EF6\u751F\u6210\u5B8C\u6210", {
|
|
7258
6575
|
outputPath,
|
|
7259
6576
|
fileName,
|
|
7260
6577
|
contentLength: content.length
|
|
@@ -7270,14 +6587,14 @@ ${allTextContent || "\u672A\u8BC6\u522B\u5230\u6587\u5B57\u5185\u5BB9"}
|
|
|
7270
6587
|
},
|
|
7271
6588
|
handler: async (args)=>{
|
|
7272
6589
|
initializeProjectRoot();
|
|
7273
|
-
|
|
6590
|
+
logger.info("\u56FE\u7247\u5185\u5BB9\u8BC6\u522B\u667A\u80FD\u4F53: \u5F00\u59CB\u5904\u7406", {
|
|
7274
6591
|
args
|
|
7275
6592
|
});
|
|
7276
6593
|
try {
|
|
7277
6594
|
const { imagePath } = ImageRecognitionParamsSchema.parse(args);
|
|
7278
6595
|
const processor = new ImageRecognitionProcessor();
|
|
7279
6596
|
const result = await processor.processImage(imagePath);
|
|
7280
|
-
|
|
6597
|
+
logger.info("\u56FE\u7247\u5185\u5BB9\u8BC6\u522B\u667A\u80FD\u4F53: \u5904\u7406\u5B8C\u6210", {
|
|
7281
6598
|
outputPath: result.outputPath,
|
|
7282
6599
|
summary: result.summary
|
|
7283
6600
|
});
|
|
@@ -7303,7 +6620,7 @@ ${allTextContent || "\u672A\u8BC6\u522B\u5230\u6587\u5B57\u5185\u5BB9"}
|
|
|
7303
6620
|
]
|
|
7304
6621
|
};
|
|
7305
6622
|
} catch (error) {
|
|
7306
|
-
|
|
6623
|
+
logger.error("\u56FE\u7247\u5185\u5BB9\u8BC6\u522B\u667A\u80FD\u4F53: \u5904\u7406\u5931\u8D25", {
|
|
7307
6624
|
error
|
|
7308
6625
|
});
|
|
7309
6626
|
return {
|
|
@@ -7322,2131 +6639,283 @@ ${allTextContent || "\u672A\u8BC6\u522B\u5230\u6587\u5B57\u5185\u5BB9"}
|
|
|
7322
6639
|
}
|
|
7323
6640
|
}
|
|
7324
6641
|
};
|
|
7325
|
-
|
|
7326
|
-
|
|
7327
|
-
|
|
7328
|
-
|
|
7329
|
-
|
|
7330
|
-
|
|
7331
|
-
|
|
7332
|
-
|
|
7333
|
-
|
|
7334
|
-
|
|
7335
|
-
|
|
7336
|
-
|
|
7337
|
-
|
|
7338
|
-
|
|
7339
|
-
|
|
7340
|
-
|
|
7341
|
-
|
|
7342
|
-
|
|
7343
|
-
|
|
7344
|
-
|
|
7345
|
-
StageErrorCodes["APPROVE_RISK_ASSESSMENT_FAILED"] = "APPROVE_RISK_ASSESSMENT_FAILED";
|
|
7346
|
-
StageErrorCodes["APPROVE_HUMAN_REJECTION"] = "APPROVE_HUMAN_REJECTION";
|
|
7347
|
-
StageErrorCodes["AUTOMATE_IMPLEMENTATION_FAILED"] = "AUTOMATE_IMPLEMENTATION_FAILED";
|
|
7348
|
-
StageErrorCodes["AUTOMATE_TEST_GENERATION_FAILED"] = "AUTOMATE_TEST_GENERATION_FAILED";
|
|
7349
|
-
StageErrorCodes["AUTOMATE_CODE_QUALITY_FAILED"] = "AUTOMATE_CODE_QUALITY_FAILED";
|
|
7350
|
-
StageErrorCodes["ASSESS_QUALITY_EVALUATION_FAILED"] = "ASSESS_QUALITY_EVALUATION_FAILED";
|
|
7351
|
-
StageErrorCodes["ASSESS_ACCEPTANCE_VERIFICATION_FAILED"] = "ASSESS_ACCEPTANCE_VERIFICATION_FAILED";
|
|
7352
|
-
StageErrorCodes["ASSESS_DELIVERABLE_GENERATION_FAILED"] = "ASSESS_DELIVERABLE_GENERATION_FAILED";
|
|
7353
|
-
StageErrorCodes["WORKSPACE_CREATION_FAILED"] = "WORKSPACE_CREATION_FAILED";
|
|
7354
|
-
StageErrorCodes["HUMAN_CONFIRMATION_TIMEOUT"] = "HUMAN_CONFIRMATION_TIMEOUT";
|
|
7355
|
-
StageErrorCodes["STAGE_EXECUTION_TIMEOUT"] = "STAGE_EXECUTION_TIMEOUT";
|
|
7356
|
-
StageErrorCodes["INVALID_STAGE_TRANSITION"] = "INVALID_STAGE_TRANSITION";
|
|
7357
|
-
StageErrorCodes["CONFIGURATION_ERROR"] = "CONFIGURATION_ERROR";
|
|
7358
|
-
return StageErrorCodes;
|
|
7359
|
-
}({});
|
|
7360
|
-
class AlignAgent {
|
|
7361
|
-
async execute(input) {
|
|
7362
|
-
logger_logger.info("\u9700\u6C42\u5BF9\u9F50\u667A\u80FD\u4F53\u5F00\u59CB\u6267\u884C", {
|
|
7363
|
-
featureName: input.feature_name
|
|
7364
|
-
});
|
|
6642
|
+
const external_xlsx_namespaceObject = require("xlsx");
|
|
6643
|
+
const ReadExcelParamsSchema = objectType({
|
|
6644
|
+
filePath: stringType().describe("\u9700\u8981\u8BFB\u53D6\u7684Excel\u6587\u4EF6\u7EDD\u5BF9\u8DEF\u5F84"),
|
|
6645
|
+
options: objectType({
|
|
6646
|
+
sheetName: stringType().optional().describe("\u6307\u5B9A\u5DE5\u4F5C\u8868\u540D\u79F0\uFF0C\u4E0D\u6307\u5B9A\u5219\u8BFB\u53D6\u7B2C\u4E00\u4E2A\u5DE5\u4F5C\u8868"),
|
|
6647
|
+
range: stringType().optional().describe("\u8BFB\u53D6\u8303\u56F4\uFF0C\u5982'A1:D10'"),
|
|
6648
|
+
headerRow: numberType().optional().default(0).describe("\u8868\u5934\u6240\u5728\u884C\u53F7\uFF0C\u4ECE0\u5F00\u59CB"),
|
|
6649
|
+
raw: booleanType().optional().default(false).describe("\u662F\u5426\u8FD4\u56DE\u539F\u59CB\u5355\u5143\u683C\u6570\u636E"),
|
|
6650
|
+
dateFormat: stringType().optional().default('YYYY-MM-DD').describe("\u65E5\u671F\u683C\u5F0F"),
|
|
6651
|
+
skipEmptyRows: booleanType().optional().default(true).describe("\u662F\u5426\u8DF3\u8FC7\u7A7A\u884C")
|
|
6652
|
+
}).optional().default({}).describe("\u8BFB\u53D6\u9009\u9879")
|
|
6653
|
+
});
|
|
6654
|
+
const readExcelTool = {
|
|
6655
|
+
name: "read_excel",
|
|
6656
|
+
description: "Excel\u8BFB\u53D6\u5DE5\u5177 - \u8BFB\u53D6Excel\u6587\u4EF6\u5185\u5BB9\u5E76\u8F6C\u6362\u4E3AJSON\u683C\u5F0F",
|
|
6657
|
+
inputSchema: ReadExcelParamsSchema,
|
|
6658
|
+
handler: async (args)=>{
|
|
6659
|
+
initializeProjectRoot();
|
|
6660
|
+
const { filePath, options = {} } = args;
|
|
6661
|
+
if (!filePath) throw new Error("\u6587\u4EF6\u8DEF\u5F84\u53C2\u6570\u7F3A\u5931\uFF0C\u8BF7\u63D0\u4F9B filePath \u53C2\u6570");
|
|
7365
6662
|
try {
|
|
7366
|
-
const
|
|
7367
|
-
|
|
7368
|
-
|
|
7369
|
-
|
|
7370
|
-
|
|
7371
|
-
|
|
7372
|
-
|
|
6663
|
+
const resolvedPath = await validateAndResolvePath(filePath);
|
|
6664
|
+
try {
|
|
6665
|
+
await promises_namespaceObject.access(resolvedPath);
|
|
6666
|
+
} catch {
|
|
6667
|
+
throw new Error(`Excel\u{6587}\u{4EF6}\u{4E0D}\u{5B58}\u{5728}: ${resolvedPath}`);
|
|
6668
|
+
}
|
|
6669
|
+
const buffer = await promises_namespaceObject.readFile(resolvedPath);
|
|
6670
|
+
const workbook = external_xlsx_namespaceObject.read(buffer, {
|
|
6671
|
+
type: 'buffer',
|
|
6672
|
+
cellDates: true,
|
|
6673
|
+
cellStyles: true
|
|
6674
|
+
});
|
|
6675
|
+
let worksheet;
|
|
6676
|
+
if (options.sheetName) {
|
|
6677
|
+
worksheet = workbook.Sheets[options.sheetName];
|
|
6678
|
+
if (!worksheet) throw new Error(`\u{5DE5}\u{4F5C}\u{8868} '${options.sheetName}' \u{4E0D}\u{5B58}\u{5728}`);
|
|
6679
|
+
} else {
|
|
6680
|
+
const firstSheetName = workbook.SheetNames[0];
|
|
6681
|
+
worksheet = workbook.Sheets[firstSheetName];
|
|
6682
|
+
}
|
|
6683
|
+
let range = options.range;
|
|
6684
|
+
if (!range && worksheet['!ref']) range = worksheet['!ref'];
|
|
6685
|
+
const jsonData = external_xlsx_namespaceObject.utils.sheet_to_json(worksheet, {
|
|
6686
|
+
header: options.headerRow,
|
|
6687
|
+
range: range,
|
|
6688
|
+
raw: options.raw,
|
|
6689
|
+
dateNF: options.dateFormat,
|
|
6690
|
+
defval: ''
|
|
6691
|
+
});
|
|
6692
|
+
let filteredData = jsonData;
|
|
6693
|
+
if (options.skipEmptyRows) filteredData = jsonData.filter((row)=>Object.values(row).some((value)=>null != value && '' !== value));
|
|
6694
|
+
const sheetName = options.sheetName || workbook.SheetNames[0];
|
|
6695
|
+
const sheetInfo = {
|
|
6696
|
+
name: sheetName,
|
|
6697
|
+
rowCount: filteredData.length,
|
|
6698
|
+
columnCount: filteredData.length > 0 ? Object.keys(filteredData[0]).length : 0,
|
|
6699
|
+
range: range
|
|
6700
|
+
};
|
|
6701
|
+
const jsonDir = external_path_default().join(getStorageDir(), 'excel');
|
|
6702
|
+
const baseName = external_path_default().basename(filePath, external_path_default().extname(filePath));
|
|
6703
|
+
const outputDir = external_path_default().join(jsonDir, baseName);
|
|
6704
|
+
await promises_namespaceObject.mkdir(outputDir, {
|
|
7373
6705
|
recursive: true
|
|
7374
6706
|
});
|
|
7375
|
-
const
|
|
7376
|
-
|
|
7377
|
-
|
|
7378
|
-
|
|
7379
|
-
|
|
7380
|
-
|
|
7381
|
-
|
|
6707
|
+
const jsonFilePath = external_path_default().join(outputDir, `${baseName}_${sheetName}.json`);
|
|
6708
|
+
await promises_namespaceObject.writeFile(jsonFilePath, JSON.stringify(filteredData, null, 2), 'utf8');
|
|
6709
|
+
logger.info("Excel\u8BFB\u53D6\u5B8C\u6210", {
|
|
6710
|
+
file: filePath,
|
|
6711
|
+
sheet: sheetName,
|
|
6712
|
+
rows: filteredData.length,
|
|
6713
|
+
outputPath: jsonFilePath
|
|
7382
6714
|
});
|
|
7383
|
-
|
|
7384
|
-
|
|
7385
|
-
|
|
7386
|
-
|
|
7387
|
-
|
|
7388
|
-
|
|
7389
|
-
|
|
7390
|
-
|
|
6715
|
+
return {
|
|
6716
|
+
content: [
|
|
6717
|
+
{
|
|
6718
|
+
type: "text",
|
|
6719
|
+
text: `
|
|
6720
|
+
# \u{2705} Excel\u{8BFB}\u{53D6}\u{5B8C}\u{6210}
|
|
6721
|
+
- \u{6587}\u{4EF6}: ${external_path_default().resolve(filePath)}
|
|
6722
|
+
- \u{5DE5}\u{4F5C}\u{8868}: ${sheetInfo.name}
|
|
6723
|
+
- \u{6570}\u{636E}\u{884C}\u{6570}: ${sheetInfo.rowCount}
|
|
6724
|
+
- \u{6570}\u{636E}\u{5217}\u{6570}: ${sheetInfo.columnCount}
|
|
6725
|
+
- \u{8BFB}\u{53D6}\u{8303}\u{56F4}: ${sheetInfo.range || "\u5168\u90E8"}
|
|
6726
|
+
- JSON\u{6587}\u{4EF6}: ${external_path_default().resolve(jsonFilePath)}
|
|
6727
|
+
|
|
6728
|
+
## \u{6570}\u{636E}\u{7ED3}\u{6784}\u{9884}\u{89C8}
|
|
6729
|
+
${JSON.stringify(filteredData.slice(0, 3), null, 2)}
|
|
6730
|
+
|
|
6731
|
+
# \u{4E0B}\u{4E00}\u{6B65}\u{5EFA}\u{8BAE}
|
|
6732
|
+
1. \u{4F7F}\u{7528} export_excel \u{5DE5}\u{5177}\u{5C06}\u{6570}\u{636E}\u{5BFC}\u{51FA}\u{4E3A}\u{5176}\u{4ED6}\u{683C}\u{5F0F}
|
|
6733
|
+
2. \u{4F7F}\u{7528} code-generator \u{5DE5}\u{5177}\u{57FA}\u{4E8E}\u{6570}\u{636E}\u{751F}\u{6210}\u{4EE3}\u{7801}
|
|
6734
|
+
`
|
|
6735
|
+
}
|
|
6736
|
+
]
|
|
7391
6737
|
};
|
|
7392
|
-
logger_logger.info("\u9700\u6C42\u5BF9\u9F50\u667A\u80FD\u4F53\u6267\u884C\u5B8C\u6210", {
|
|
7393
|
-
featureName: input.feature_name
|
|
7394
|
-
});
|
|
7395
|
-
return result;
|
|
7396
6738
|
} catch (error) {
|
|
7397
|
-
|
|
7398
|
-
|
|
7399
|
-
|
|
7400
|
-
|
|
6739
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
6740
|
+
logger.error(`Excel\u{8BFB}\u{53D6}\u{5931}\u{8D25}: ${errorMsg}`, {
|
|
6741
|
+
tool: "read_excel",
|
|
6742
|
+
filePath,
|
|
6743
|
+
options
|
|
7401
6744
|
});
|
|
7402
|
-
}
|
|
7403
|
-
}
|
|
7404
|
-
async analyzeProjectContext(projectContext) {
|
|
7405
|
-
const prompt = `
|
|
7406
|
-
\u{4F5C}\u{4E3A}\u{9700}\u{6C42}\u{5BF9}\u{9F50}\u{667A}\u{80FD}\u{4F53}\u{FF0C}\u{8BF7}\u{5206}\u{6790}\u{4EE5}\u{4E0B}\u{9879}\u{76EE}\u{4E0A}\u{4E0B}\u{6587}\u{4FE1}\u{606F}\u{FF1A}
|
|
7407
|
-
|
|
7408
|
-
\u{9879}\u{76EE}\u{4E0A}\u{4E0B}\u{6587}\u{FF1A}
|
|
7409
|
-
${projectContext || "\u672A\u63D0\u4F9B\u9879\u76EE\u4E0A\u4E0B\u6587\u4FE1\u606F"}
|
|
7410
|
-
|
|
7411
|
-
\u{8BF7}\u{5206}\u{6790}\u{FF1A}
|
|
7412
|
-
1. \u{73B0}\u{6709}\u{9879}\u{76EE}\u{6280}\u{672F}\u{6808}
|
|
7413
|
-
2. \u{67B6}\u{6784}\u{6A21}\u{5F0F}\u{548C}\u{7EA6}\u{675F}
|
|
7414
|
-
3. \u{4E1A}\u{52A1}\u{57DF}\u{7279}\u{5F81}
|
|
7415
|
-
4. \u{6280}\u{672F}\u{9650}\u{5236}\u{548C}\u{4F9D}\u{8D56}
|
|
7416
|
-
|
|
7417
|
-
\u{8F93}\u{51FA}\u{683C}\u{5F0F}\u{4E3A}JSON\u{FF1A}
|
|
7418
|
-
{
|
|
7419
|
-
"techStack": ["\u{6280}\u{672F}1", "\u{6280}\u{672F}2"],
|
|
7420
|
-
"architecture": "\u{67B6}\u{6784}\u{6A21}\u{5F0F}\u{63CF}\u{8FF0}",
|
|
7421
|
-
"businessDomain": "\u{4E1A}\u{52A1}\u{57DF}\u{63CF}\u{8FF0}",
|
|
7422
|
-
"constraints": ["\u{7EA6}\u{675F}1", "\u{7EA6}\u{675F}2"]
|
|
7423
|
-
}
|
|
7424
|
-
`;
|
|
7425
|
-
try {
|
|
7426
|
-
const response = await callOpenAI([
|
|
7427
|
-
{
|
|
7428
|
-
role: 'system',
|
|
7429
|
-
content: "\u4F60\u662F\u9879\u76EE\u4E0A\u4E0B\u6587\u5206\u6790\u4E13\u5BB6\uFF0C\u4E13\u6CE8\u4E8E\u7406\u89E3\u6280\u672F\u73AF\u5883\u548C\u4E1A\u52A1\u7EA6\u675F\u3002"
|
|
7430
|
-
},
|
|
7431
|
-
{
|
|
7432
|
-
role: 'user',
|
|
7433
|
-
content: prompt
|
|
7434
|
-
}
|
|
7435
|
-
]);
|
|
7436
|
-
return JSON.parse(response);
|
|
7437
|
-
} catch (error) {
|
|
7438
|
-
logger_logger.warn("\u9879\u76EE\u4E0A\u4E0B\u6587\u5206\u6790\u5931\u8D25\uFF0C\u4F7F\u7528\u9ED8\u8BA4\u5206\u6790", error);
|
|
7439
6745
|
return {
|
|
7440
|
-
|
|
7441
|
-
|
|
7442
|
-
|
|
6746
|
+
content: [
|
|
6747
|
+
{
|
|
6748
|
+
type: "text",
|
|
6749
|
+
text: JSON.stringify({
|
|
6750
|
+
success: false,
|
|
6751
|
+
message: `Excel\u{8BFB}\u{53D6}\u{5931}\u{8D25}: ${errorMsg}`,
|
|
6752
|
+
data: null
|
|
6753
|
+
})
|
|
6754
|
+
}
|
|
7443
6755
|
],
|
|
7444
|
-
|
|
7445
|
-
businessDomain: "\u901A\u7528\u4E1A\u52A1\u7CFB\u7EDF",
|
|
7446
|
-
constraints: []
|
|
6756
|
+
isError: true
|
|
7447
6757
|
};
|
|
7448
6758
|
}
|
|
7449
6759
|
}
|
|
7450
|
-
|
|
7451
|
-
|
|
7452
|
-
|
|
7453
|
-
|
|
7454
|
-
\
|
|
7455
|
-
|
|
7456
|
-
|
|
7457
|
-
\
|
|
7458
|
-
|
|
7459
|
-
|
|
7460
|
-
|
|
7461
|
-
|
|
7462
|
-
|
|
7463
|
-
|
|
7464
|
-
|
|
7465
|
-
|
|
7466
|
-
|
|
7467
|
-
|
|
7468
|
-
|
|
7469
|
-
|
|
7470
|
-
|
|
7471
|
-
|
|
7472
|
-
|
|
7473
|
-
|
|
7474
|
-
|
|
7475
|
-
|
|
7476
|
-
|
|
7477
|
-
|
|
7478
|
-
|
|
7479
|
-
|
|
7480
|
-
|
|
7481
|
-
|
|
7482
|
-
5. \u{9A8C}\u{6536}\u{6807}\u{51C6}\u{5B9A}\u{4E49}
|
|
7483
|
-
- \u{529F}\u{80FD}\u{9A8C}\u{6536}\u{70B9}
|
|
7484
|
-
- \u{6027}\u{80FD}\u{6307}\u{6807}
|
|
7485
|
-
- \u{8D28}\u{91CF}\u{6807}\u{51C6}
|
|
7486
|
-
|
|
7487
|
-
\u{8F93}\u{51FA}\u{683C}\u{5F0F}\u{4E3A}JSON\u{FF1A}
|
|
7488
|
-
{
|
|
7489
|
-
"coreFunction": "\u{6838}\u{5FC3}\u{529F}\u{80FD}\u{63CF}\u{8FF0}",
|
|
7490
|
-
"businessValue": "\u{4E1A}\u{52A1}\u{4EF7}\u{503C}",
|
|
7491
|
-
"userScenarios": ["\u{573A}\u{666F}1", "\u{573A}\u{666F}2"],
|
|
7492
|
-
"boundaries": "\u{529F}\u{80FD}\u{8FB9}\u{754C}\u{63CF}\u{8FF0}",
|
|
7493
|
-
"exclusions": ["\u{4E0D}\u{5305}\u{542B}1", "\u{4E0D}\u{5305}\u{542B}2"],
|
|
7494
|
-
"techApproach": "\u{6280}\u{672F}\u{65B9}\u{6848}\u{63CF}\u{8FF0}",
|
|
7495
|
-
"complexity": "\u{7B80}\u{5355}|\u{4E2D}\u{7B49}|\u{590D}\u{6742}",
|
|
7496
|
-
"clarifications": ["\u{6F84}\u{6E05}\u{95EE}\u{9898}1", "\u{6F84}\u{6E05}\u{95EE}\u{9898}2"],
|
|
7497
|
-
"acceptanceCriteria": ["\u{9A8C}\u{6536}\u{6807}\u{51C6}1", "\u{9A8C}\u{6536}\u{6807}\u{51C6}2"]
|
|
7498
|
-
}
|
|
7499
|
-
`;
|
|
7500
|
-
const response = await callOpenAI([
|
|
7501
|
-
{
|
|
7502
|
-
role: 'system',
|
|
7503
|
-
content: "\u4F60\u662F\u9700\u6C42\u5206\u6790\u4E13\u5BB6\uFF0C\u4E13\u6CE8\u4E8E\u5C06\u6A21\u7CCA\u9700\u6C42\u8F6C\u5316\u4E3A\u7CBE\u786E\u7684\u6280\u672F\u89C4\u8303\u3002"
|
|
7504
|
-
},
|
|
7505
|
-
{
|
|
7506
|
-
role: 'user',
|
|
7507
|
-
content: prompt
|
|
7508
|
-
}
|
|
7509
|
-
]);
|
|
7510
|
-
return JSON.parse(response);
|
|
7511
|
-
}
|
|
7512
|
-
async generateAlignmentDocument(analysis, featureName) {
|
|
7513
|
-
return `# \u{9700}\u{6C42}\u{5BF9}\u{9F50}\u{6587}\u{6863} - ${featureName}
|
|
7514
|
-
|
|
7515
|
-
## \u{9879}\u{76EE}\u{7279}\u{6027}\u{89C4}\u{8303}
|
|
7516
|
-
|
|
7517
|
-
### \u{6838}\u{5FC3}\u{529F}\u{80FD}
|
|
7518
|
-
${analysis.coreFunction}
|
|
7519
|
-
|
|
7520
|
-
### \u{4E1A}\u{52A1}\u{4EF7}\u{503C}
|
|
7521
|
-
${analysis.businessValue}
|
|
7522
|
-
|
|
7523
|
-
### \u{7528}\u{6237}\u{573A}\u{666F}
|
|
7524
|
-
${analysis.userScenarios.map((scenario, index)=>`${index + 1}. ${scenario}`).join('\n')}
|
|
7525
|
-
|
|
7526
|
-
## \u{9700}\u{6C42}\u{7406}\u{89E3}
|
|
7527
|
-
|
|
7528
|
-
### \u{529F}\u{80FD}\u{8FB9}\u{754C}
|
|
7529
|
-
${analysis.boundaries}
|
|
7530
|
-
|
|
7531
|
-
### \u{6392}\u{9664}\u{529F}\u{80FD}
|
|
7532
|
-
${analysis.exclusions.map((exclusion)=>`- ${exclusion}`).join('\n')}
|
|
7533
|
-
|
|
7534
|
-
### \u{6280}\u{672F}\u{65B9}\u{6848}
|
|
7535
|
-
${analysis.techApproach}
|
|
7536
|
-
|
|
7537
|
-
### \u{590D}\u{6742}\u{5EA6}\u{8BC4}\u{4F30}
|
|
7538
|
-
${analysis.complexity}
|
|
7539
|
-
|
|
7540
|
-
## \u{7591}\u{95EE}\u{6F84}\u{6E05}
|
|
7541
|
-
|
|
7542
|
-
${analysis.clarifications.map((question, index)=>`### \u{95EE}\u{9898} ${index + 1}
|
|
7543
|
-
${question}
|
|
7544
|
-
|
|
7545
|
-
**\u{5EFA}\u{8BAE}\u{89E3}\u{51B3}\u{65B9}\u{6848}**: \u{57FA}\u{4E8E}\u{884C}\u{4E1A}\u{6700}\u{4F73}\u{5B9E}\u{8DF5}\u{548C}\u{9879}\u{76EE}\u{73B0}\u{72B6}\u{8FDB}\u{884C}\u{51B3}\u{7B56}
|
|
7546
|
-
|
|
7547
|
-
`).join('\n')}
|
|
7548
|
-
|
|
7549
|
-
## \u{751F}\u{6210}\u{65F6}\u{95F4}
|
|
7550
|
-
${new Date().toISOString()}
|
|
7551
|
-
`;
|
|
7552
|
-
}
|
|
7553
|
-
async generateConsensusDocument(analysis, featureName) {
|
|
7554
|
-
return `# \u{9700}\u{6C42}\u{5171}\u{8BC6}\u{6587}\u{6863} - ${featureName}
|
|
7555
|
-
|
|
7556
|
-
## \u{660E}\u{786E}\u{7684}\u{9700}\u{6C42}\u{63CF}\u{8FF0}
|
|
7557
|
-
${analysis.coreFunction}
|
|
7558
|
-
|
|
7559
|
-
## \u{9A8C}\u{6536}\u{6807}\u{51C6}
|
|
7560
|
-
${analysis.acceptanceCriteria.map((criteria, index)=>`${index + 1}. ${criteria}`).join('\n')}
|
|
7561
|
-
|
|
7562
|
-
## \u{6280}\u{672F}\u{5B9E}\u{73B0}\u{65B9}\u{6848}
|
|
7563
|
-
${analysis.techApproach}
|
|
7564
|
-
|
|
7565
|
-
## \u{6280}\u{672F}\u{7EA6}\u{675F}\u{548C}\u{96C6}\u{6210}\u{65B9}\u{6848}
|
|
7566
|
-
- \u{590D}\u{6742}\u{5EA6}: ${analysis.complexity}
|
|
7567
|
-
- \u{9700}\u{8981}\u{8003}\u{8651}\u{73B0}\u{6709}\u{7CFB}\u{7EDF}\u{517C}\u{5BB9}\u{6027}
|
|
7568
|
-
- \u{9075}\u{5FAA}\u{9879}\u{76EE}\u{73B0}\u{6709}\u{67B6}\u{6784}\u{6A21}\u{5F0F}
|
|
7569
|
-
|
|
7570
|
-
## \u{4EFB}\u{52A1}\u{8FB9}\u{754C}\u{9650}\u{5236}
|
|
7571
|
-
### \u{5305}\u{542B}\u{8303}\u{56F4}
|
|
7572
|
-
${analysis.boundaries}
|
|
7573
|
-
|
|
7574
|
-
### \u{6392}\u{9664}\u{8303}\u{56F4}
|
|
7575
|
-
${analysis.exclusions.map((exclusion)=>`- ${exclusion}`).join('\n')}
|
|
7576
|
-
|
|
7577
|
-
## \u{786E}\u{8BA4}\u{72B6}\u{6001}
|
|
7578
|
-
- [x] \u{9700}\u{6C42}\u{7406}\u{89E3}\u{51C6}\u{786E}\u{65E0}\u{8BEF}
|
|
7579
|
-
- [x] \u{6280}\u{672F}\u{65B9}\u{6848}\u{53EF}\u{884C}
|
|
7580
|
-
- [x] \u{8FB9}\u{754C}\u{5B9A}\u{4E49}\u{5408}\u{7406}
|
|
7581
|
-
- [x] \u{9A8C}\u{6536}\u{6807}\u{51C6}\u{660E}\u{786E}
|
|
7582
|
-
- [ ] \u{7B49}\u{5F85}\u{4EBA}\u{5DE5}\u{786E}\u{8BA4}
|
|
7583
|
-
|
|
7584
|
-
## \u{751F}\u{6210}\u{65F6}\u{95F4}
|
|
7585
|
-
${new Date().toISOString()}
|
|
7586
|
-
`;
|
|
7587
|
-
}
|
|
7588
|
-
}
|
|
7589
|
-
class ArchitectAgent {
|
|
7590
|
-
async execute(input) {
|
|
7591
|
-
logger_logger.info("\u7CFB\u7EDF\u67B6\u6784\u667A\u80FD\u4F53\u5F00\u59CB\u6267\u884C");
|
|
6760
|
+
};
|
|
6761
|
+
const ExportExcelParamsSchema = objectType({
|
|
6762
|
+
data: unionType([
|
|
6763
|
+
stringType().describe("JSON\u6570\u636E\u5B57\u7B26\u4E32\u6216\u6587\u4EF6\u8DEF\u5F84"),
|
|
6764
|
+
arrayType(anyType()).describe("JSON\u6570\u636E\u6570\u7EC4"),
|
|
6765
|
+
recordType(anyType()).describe("JSON\u6570\u636E\u5BF9\u8C61")
|
|
6766
|
+
]).describe("\u8981\u5BFC\u51FA\u7684\u6570\u636E"),
|
|
6767
|
+
outputPath: stringType().optional().describe("\u8F93\u51FAExcel\u6587\u4EF6\u8DEF\u5F84\uFF0C\u4E0D\u6307\u5B9A\u5219\u81EA\u52A8\u751F\u6210"),
|
|
6768
|
+
options: objectType({
|
|
6769
|
+
sheetName: stringType().optional().default('Sheet1').describe("\u5DE5\u4F5C\u8868\u540D\u79F0"),
|
|
6770
|
+
format: enumType([
|
|
6771
|
+
'xlsx',
|
|
6772
|
+
'csv',
|
|
6773
|
+
'xls'
|
|
6774
|
+
]).optional().default('xlsx').describe("\u8F93\u51FA\u683C\u5F0F"),
|
|
6775
|
+
header: arrayType(stringType()).optional().describe("\u8868\u5934\u6570\u7EC4\uFF0C\u4E0D\u6307\u5B9A\u5219\u4F7F\u7528\u6570\u636E\u952E\u540D"),
|
|
6776
|
+
autoWidth: booleanType().optional().default(true).describe("\u662F\u5426\u81EA\u52A8\u8C03\u6574\u5217\u5BBD"),
|
|
6777
|
+
freezePane: stringType().optional().describe("\u51BB\u7ED3\u7A97\u683C\uFF0C\u5982'A2'\u8868\u793A\u51BB\u7ED3\u7B2C\u4E00\u884C"),
|
|
6778
|
+
style: objectType({
|
|
6779
|
+
headerStyle: recordType(anyType()).optional().describe("\u8868\u5934\u6837\u5F0F"),
|
|
6780
|
+
dataStyle: recordType(anyType()).optional().describe("\u6570\u636E\u6837\u5F0F")
|
|
6781
|
+
}).optional().describe("\u5355\u5143\u683C\u6837\u5F0F\u914D\u7F6E")
|
|
6782
|
+
}).optional().default({}).describe("\u5BFC\u51FA\u9009\u9879")
|
|
6783
|
+
});
|
|
6784
|
+
const exportExcelTool = {
|
|
6785
|
+
name: "export_excel",
|
|
6786
|
+
description: "Excel\u5BFC\u51FA\u5DE5\u5177 - \u5C06JSON\u6570\u636E\u5BFC\u51FA\u4E3AExcel\u683C\u5F0F",
|
|
6787
|
+
inputSchema: ExportExcelParamsSchema,
|
|
6788
|
+
handler: async (args)=>{
|
|
6789
|
+
initializeProjectRoot();
|
|
6790
|
+
const { data, outputPath, options = {} } = args;
|
|
6791
|
+
if (!data) throw new Error("\u6570\u636E\u53C2\u6570\u7F3A\u5931\uFF0C\u8BF7\u63D0\u4F9B data \u53C2\u6570");
|
|
7592
6792
|
try {
|
|
7593
|
-
|
|
7594
|
-
if ('
|
|
7595
|
-
|
|
7596
|
-
|
|
7597
|
-
|
|
7598
|
-
|
|
7599
|
-
|
|
7600
|
-
|
|
7601
|
-
if (
|
|
7602
|
-
|
|
6793
|
+
let jsonData = [];
|
|
6794
|
+
if ('string' == typeof data) try {
|
|
6795
|
+
const resolvedPath = await validateAndResolvePath(data);
|
|
6796
|
+
const fileContent = await promises_namespaceObject.readFile(resolvedPath, 'utf8');
|
|
6797
|
+
jsonData = JSON.parse(fileContent);
|
|
6798
|
+
} catch {
|
|
6799
|
+
jsonData = JSON.parse(data);
|
|
6800
|
+
}
|
|
6801
|
+
else if (Array.isArray(data)) jsonData = data;
|
|
6802
|
+
else if ('object' == typeof data && null !== data) jsonData = [
|
|
6803
|
+
data
|
|
6804
|
+
];
|
|
6805
|
+
else throw new Error("\u4E0D\u652F\u6301\u7684\u6570\u636E\u683C\u5F0F");
|
|
6806
|
+
if (!Array.isArray(jsonData) || 0 === jsonData.length) throw new Error("\u6570\u636E\u5FC5\u987B\u662F\u975E\u7A7A\u6570\u7EC4");
|
|
6807
|
+
const workbook = external_xlsx_namespaceObject.utils.book_new();
|
|
6808
|
+
const headers = options.header || Object.keys(jsonData[0]);
|
|
6809
|
+
const worksheetData = [
|
|
6810
|
+
headers
|
|
6811
|
+
];
|
|
6812
|
+
jsonData.forEach((item)=>{
|
|
6813
|
+
const row = headers.map((header)=>item[header] ?? '');
|
|
6814
|
+
worksheetData.push(row);
|
|
6815
|
+
});
|
|
6816
|
+
const worksheet = external_xlsx_namespaceObject.utils.aoa_to_sheet(worksheetData);
|
|
6817
|
+
if (options.style) {
|
|
6818
|
+
if (options.style.headerStyle) {
|
|
6819
|
+
const headerRange = external_xlsx_namespaceObject.utils.decode_range(worksheet['!ref']);
|
|
6820
|
+
for(let col = headerRange.s.c; col <= headerRange.e.c; col++){
|
|
6821
|
+
const cellAddress = external_xlsx_namespaceObject.utils.encode_cell({
|
|
6822
|
+
r: 0,
|
|
6823
|
+
c: col
|
|
6824
|
+
});
|
|
6825
|
+
if (!worksheet[cellAddress]) worksheet[cellAddress] = {};
|
|
6826
|
+
worksheet[cellAddress].s = options.style.headerStyle;
|
|
6827
|
+
}
|
|
6828
|
+
}
|
|
6829
|
+
if (options.style.dataStyle && jsonData.length > 0) {
|
|
6830
|
+
const dataRange = external_xlsx_namespaceObject.utils.decode_range(worksheet['!ref']);
|
|
6831
|
+
for(let row = dataRange.s.r + 1; row <= dataRange.e.r; row++)for(let col = dataRange.s.c; col <= dataRange.e.c; col++){
|
|
6832
|
+
const cellAddress = external_xlsx_namespaceObject.utils.encode_cell({
|
|
6833
|
+
r: row,
|
|
6834
|
+
c: col
|
|
6835
|
+
});
|
|
6836
|
+
if (!worksheet[cellAddress]) worksheet[cellAddress] = {};
|
|
6837
|
+
worksheet[cellAddress].s = options.style.dataStyle;
|
|
6838
|
+
}
|
|
6839
|
+
}
|
|
6840
|
+
}
|
|
6841
|
+
if (options.autoWidth) {
|
|
6842
|
+
const colWidths = headers.map((header, index)=>{
|
|
6843
|
+
const maxContentLength = Math.max(header.length, ...jsonData.map((row)=>{
|
|
6844
|
+
const value = row[header] ?? '';
|
|
6845
|
+
return String(value).length;
|
|
6846
|
+
}));
|
|
6847
|
+
return {
|
|
6848
|
+
wch: Math.min(maxContentLength + 2, 50)
|
|
6849
|
+
};
|
|
6850
|
+
});
|
|
6851
|
+
worksheet['!cols'] = colWidths;
|
|
6852
|
+
}
|
|
6853
|
+
if (options.freezePane) worksheet['!freeze'] = {
|
|
6854
|
+
xSplit: 0,
|
|
6855
|
+
ySplit: 1,
|
|
6856
|
+
activePane: 'bottomLeft'
|
|
6857
|
+
};
|
|
6858
|
+
external_xlsx_namespaceObject.utils.book_append_sheet(workbook, worksheet, options.sheetName || 'Sheet1');
|
|
6859
|
+
let finalOutputPath;
|
|
6860
|
+
if (outputPath) finalOutputPath = await validateAndResolvePath(outputPath);
|
|
6861
|
+
else {
|
|
6862
|
+
const excelDir = external_path_default().join(getStorageDir(), 'excel');
|
|
6863
|
+
await promises_namespaceObject.mkdir(excelDir, {
|
|
6864
|
+
recursive: true
|
|
6865
|
+
});
|
|
6866
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
6867
|
+
finalOutputPath = external_path_default().join(excelDir, `export_${timestamp}.${options.format || 'xlsx'}`);
|
|
6868
|
+
}
|
|
6869
|
+
const buffer = external_xlsx_namespaceObject.write(workbook, {
|
|
6870
|
+
type: 'buffer',
|
|
6871
|
+
bookType: options.format || 'xlsx'
|
|
7603
6872
|
});
|
|
7604
|
-
|
|
7605
|
-
|
|
7606
|
-
|
|
7607
|
-
|
|
6873
|
+
await promises_namespaceObject.writeFile(finalOutputPath, buffer);
|
|
6874
|
+
logger.info("Excel\u5BFC\u51FA\u5B8C\u6210", {
|
|
6875
|
+
outputPath: finalOutputPath,
|
|
6876
|
+
rows: jsonData.length,
|
|
6877
|
+
columns: headers.length,
|
|
6878
|
+
format: options.format || 'xlsx'
|
|
7608
6879
|
});
|
|
7609
|
-
|
|
7610
|
-
|
|
7611
|
-
|
|
7612
|
-
|
|
7613
|
-
|
|
7614
|
-
|
|
7615
|
-
|
|
7616
|
-
|
|
6880
|
+
return {
|
|
6881
|
+
content: [
|
|
6882
|
+
{
|
|
6883
|
+
type: "text",
|
|
6884
|
+
text: `
|
|
6885
|
+
# \u{2705} Excel\u{5BFC}\u{51FA}\u{5B8C}\u{6210}
|
|
6886
|
+
- \u{8F93}\u{51FA}\u{6587}\u{4EF6}: ${external_path_default().resolve(finalOutputPath)}
|
|
6887
|
+
- \u{6570}\u{636E}\u{884C}\u{6570}: ${jsonData.length}
|
|
6888
|
+
- \u{6570}\u{636E}\u{5217}\u{6570}: ${headers.length}
|
|
6889
|
+
- \u{6587}\u{4EF6}\u{683C}\u{5F0F}: ${options.format || 'xlsx'}
|
|
6890
|
+
- \u{5DE5}\u{4F5C}\u{8868}: ${options.sheetName || 'Sheet1'}
|
|
6891
|
+
|
|
6892
|
+
## \u{5BFC}\u{51FA}\u{4FE1}\u{606F}
|
|
6893
|
+
- \u{8868}\u{5934}: ${headers.join(', ')}
|
|
6894
|
+
- \u{603B}\u{6570}\u{636E}\u{91CF}: ${jsonData.length} \u{884C} \xd7 ${headers.length} \u{5217}
|
|
6895
|
+
|
|
6896
|
+
# \u{4E0B}\u{4E00}\u{6B65}\u{5EFA}\u{8BAE}
|
|
6897
|
+
1. \u{4F7F}\u{7528} read_excel \u{5DE5}\u{5177}\u{9A8C}\u{8BC1}\u{5BFC}\u{51FA}\u{7ED3}\u{679C}
|
|
6898
|
+
2. \u{4F7F}\u{7528}\u{5176}\u{4ED6}\u{6570}\u{636E}\u{5904}\u{7406}\u{5DE5}\u{5177}\u{8FDB}\u{884C}\u{8FDB}\u{4E00}\u{6B65}\u{5206}\u{6790}
|
|
6899
|
+
`
|
|
6900
|
+
}
|
|
6901
|
+
]
|
|
7617
6902
|
};
|
|
7618
|
-
logger_logger.info("\u7CFB\u7EDF\u67B6\u6784\u667A\u80FD\u4F53\u6267\u884C\u5B8C\u6210");
|
|
7619
|
-
return result;
|
|
7620
6903
|
} catch (error) {
|
|
7621
|
-
|
|
7622
|
-
|
|
7623
|
-
|
|
7624
|
-
|
|
6904
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
6905
|
+
logger.error(`Excel\u{5BFC}\u{51FA}\u{5931}\u{8D25}: ${errorMsg}`, {
|
|
6906
|
+
tool: "export_excel",
|
|
6907
|
+
data: 'string' == typeof data ? data.substring(0, 100) + '...' : 'complex data',
|
|
6908
|
+
options
|
|
7625
6909
|
});
|
|
7626
|
-
}
|
|
7627
|
-
}
|
|
7628
|
-
async designSystemArchitecture(alignmentResult) {
|
|
7629
|
-
const prompt = `
|
|
7630
|
-
\u{4F5C}\u{4E3A}\u{7CFB}\u{7EDF}\u{67B6}\u{6784}\u{667A}\u{80FD}\u{4F53}\u{FF0C}\u{57FA}\u{4E8E}\u{4EE5}\u{4E0B}\u{9700}\u{6C42}\u{5171}\u{8BC6}\u{8BBE}\u{8BA1}\u{7CFB}\u{7EDF}\u{67B6}\u{6784}\u{FF1A}
|
|
7631
|
-
|
|
7632
|
-
\u{9700}\u{6C42}\u{5171}\u{8BC6}\u{FF1A}
|
|
7633
|
-
${alignmentResult.consensus_document}
|
|
7634
|
-
|
|
7635
|
-
\u{9700}\u{6C42}\u{89C4}\u{8303}\u{FF1A}
|
|
7636
|
-
${alignmentResult.requirements_specification}
|
|
7637
|
-
|
|
7638
|
-
\u{8BF7}\u{8BBE}\u{8BA1}\u{7CFB}\u{7EDF}\u{67B6}\u{6784}\u{FF0C}\u{5305}\u{62EC}\u{FF1A}
|
|
7639
|
-
|
|
7640
|
-
1. \u{6574}\u{4F53}\u{67B6}\u{6784}\u{56FE}(\u{4F7F}\u{7528}mermaid\u{8BED}\u{6CD5})
|
|
7641
|
-
2. \u{5206}\u{5C42}\u{8BBE}\u{8BA1}\u{548C}\u{6838}\u{5FC3}\u{7EC4}\u{4EF6}
|
|
7642
|
-
3. \u{6A21}\u{5757}\u{4F9D}\u{8D56}\u{5173}\u{7CFB}\u{56FE}(\u{4F7F}\u{7528}mermaid\u{8BED}\u{6CD5})
|
|
7643
|
-
4. \u{6570}\u{636E}\u{6D41}\u{5411}\u{56FE}(\u{4F7F}\u{7528}mermaid\u{8BED}\u{6CD5})
|
|
7644
|
-
5. \u{5F02}\u{5E38}\u{5904}\u{7406}\u{7B56}\u{7565}
|
|
7645
|
-
|
|
7646
|
-
\u{8981}\u{6C42}\u{FF1A}
|
|
7647
|
-
- \u{786E}\u{4FDD}\u{4E0E}\u{73B0}\u{6709}\u{7CFB}\u{7EDF}\u{67B6}\u{6784}\u{4E00}\u{81F4}
|
|
7648
|
-
- \u{590D}\u{7528}\u{73B0}\u{6709}\u{7EC4}\u{4EF6}\u{548C}\u{6A21}\u{5F0F}
|
|
7649
|
-
- \u{907F}\u{514D}\u{8FC7}\u{5EA6}\u{8BBE}\u{8BA1}
|
|
7650
|
-
- \u{8003}\u{8651}\u{53EF}\u{7EF4}\u{62A4}\u{6027}\u{548C}\u{6269}\u{5C55}\u{6027}
|
|
7651
|
-
|
|
7652
|
-
\u{8F93}\u{51FA}\u{683C}\u{5F0F}\u{4E3A}JSON\u{FF1A}
|
|
7653
|
-
{
|
|
7654
|
-
"overview": "\u{6574}\u{4F53}\u{67B6}\u{6784}\u{63CF}\u{8FF0}",
|
|
7655
|
-
"architectureDiagram": "mermaid\u{67B6}\u{6784}\u{56FE}\u{4EE3}\u{7801}",
|
|
7656
|
-
"layers": ["\u{5C42}\u{6B21}1", "\u{5C42}\u{6B21}2"],
|
|
7657
|
-
"coreComponents": ["\u{7EC4}\u{4EF6}1", "\u{7EC4}\u{4EF6}2"],
|
|
7658
|
-
"dependencyDiagram": "mermaid\u{4F9D}\u{8D56}\u{5173}\u{7CFB}\u{56FE}\u{4EE3}\u{7801}",
|
|
7659
|
-
"dataFlow": "\u{6570}\u{636E}\u{6D41}\u{5411}\u{63CF}\u{8FF0}",
|
|
7660
|
-
"dataFlowDiagram": "mermaid\u{6570}\u{636E}\u{6D41}\u{56FE}\u{4EE3}\u{7801}",
|
|
7661
|
-
"exceptionHandling": "\u{5F02}\u{5E38}\u{5904}\u{7406}\u{7B56}\u{7565}",
|
|
7662
|
-
"dependencies": "\u{4F9D}\u{8D56}\u{5173}\u{7CFB}\u{63CF}\u{8FF0}"
|
|
7663
|
-
}
|
|
7664
|
-
`;
|
|
7665
|
-
const response = await callOpenAI([
|
|
7666
|
-
{
|
|
7667
|
-
role: 'system',
|
|
7668
|
-
content: "\u4F60\u662F\u7CFB\u7EDF\u67B6\u6784\u8BBE\u8BA1\u4E13\u5BB6\uFF0C\u4E13\u6CE8\u4E8E\u8BBE\u8BA1\u53EF\u7EF4\u62A4\u3001\u53EF\u6269\u5C55\u7684\u7CFB\u7EDF\u67B6\u6784\u3002"
|
|
7669
|
-
},
|
|
7670
|
-
{
|
|
7671
|
-
role: 'user',
|
|
7672
|
-
content: prompt
|
|
7673
|
-
}
|
|
7674
|
-
]);
|
|
7675
|
-
return JSON.parse(response);
|
|
7676
|
-
}
|
|
7677
|
-
async designModules(architectureDesign) {
|
|
7678
|
-
const prompt = `
|
|
7679
|
-
\u{57FA}\u{4E8E}\u{4EE5}\u{4E0B}\u{7CFB}\u{7EDF}\u{67B6}\u{6784}\u{8BBE}\u{8BA1}\u{FF0C}\u{8BE6}\u{7EC6}\u{8BBE}\u{8BA1}\u{6A21}\u{5757}\u{548C}\u{63A5}\u{53E3}\u{FF1A}
|
|
7680
|
-
|
|
7681
|
-
\u{7CFB}\u{7EDF}\u{67B6}\u{6784}\u{FF1A}
|
|
7682
|
-
${JSON.stringify(architectureDesign, null, 2)}
|
|
7683
|
-
|
|
7684
|
-
\u{8BF7}\u{8BBE}\u{8BA1}\u{FF1A}
|
|
7685
|
-
|
|
7686
|
-
1. \u{8BE6}\u{7EC6}\u{7684}\u{6A21}\u{5757}\u{5212}\u{5206}
|
|
7687
|
-
2. \u{6BCF}\u{4E2A}\u{6A21}\u{5757}\u{7684}\u{804C}\u{8D23}
|
|
7688
|
-
3. \u{6A21}\u{5757}\u{95F4}\u{7684}\u{63A5}\u{53E3}\u{5B9A}\u{4E49}
|
|
7689
|
-
4. \u{6570}\u{636E}\u{4F20}\u{8F93}\u{534F}\u{8BAE}
|
|
7690
|
-
5. API\u{89C4}\u{8303}
|
|
7691
|
-
|
|
7692
|
-
\u{8F93}\u{51FA}\u{683C}\u{5F0F}\u{4E3A}JSON\u{FF1A}
|
|
7693
|
-
{
|
|
7694
|
-
"modules": [
|
|
7695
|
-
{
|
|
7696
|
-
"name": "\u{6A21}\u{5757}\u{540D}",
|
|
7697
|
-
"responsibility": "\u{6A21}\u{5757}\u{804C}\u{8D23}",
|
|
7698
|
-
"interfaces": ["\u{63A5}\u{53E3}1", "\u{63A5}\u{53E3}2"],
|
|
7699
|
-
"dependencies": ["\u{4F9D}\u{8D56}\u{6A21}\u{5757}1"]
|
|
7700
|
-
}
|
|
7701
|
-
],
|
|
7702
|
-
"interfaces": [
|
|
7703
|
-
{
|
|
7704
|
-
"name": "\u{63A5}\u{53E3}\u{540D}",
|
|
7705
|
-
"type": "\u{8F93}\u{5165}|\u{8F93}\u{51FA}|\u{53CC}\u{5411}",
|
|
7706
|
-
"format": "\u{6570}\u{636E}\u{683C}\u{5F0F}",
|
|
7707
|
-
"specification": "\u{8BE6}\u{7EC6}\u{89C4}\u{8303}"
|
|
7708
|
-
}
|
|
7709
|
-
],
|
|
7710
|
-
"dataProtocols": "\u{6570}\u{636E}\u{4F20}\u{8F93}\u{534F}\u{8BAE}\u{63CF}\u{8FF0}",
|
|
7711
|
-
"apiSpecification": "API\u{89C4}\u{8303}\u{63CF}\u{8FF0}"
|
|
7712
|
-
}
|
|
7713
|
-
`;
|
|
7714
|
-
const response = await callOpenAI([
|
|
7715
|
-
{
|
|
7716
|
-
role: 'system',
|
|
7717
|
-
content: "\u4F60\u662F\u6A21\u5757\u8BBE\u8BA1\u4E13\u5BB6\uFF0C\u4E13\u6CE8\u4E8E\u8BBE\u8BA1\u6E05\u6670\u7684\u6A21\u5757\u8FB9\u754C\u548C\u63A5\u53E3\u3002"
|
|
7718
|
-
},
|
|
7719
|
-
{
|
|
7720
|
-
role: 'user',
|
|
7721
|
-
content: prompt
|
|
7722
|
-
}
|
|
7723
|
-
]);
|
|
7724
|
-
return JSON.parse(response);
|
|
7725
|
-
}
|
|
7726
|
-
async generateDesignDocument(architectureDesign, moduleDesign) {
|
|
7727
|
-
return `# \u{7CFB}\u{7EDF}\u{8BBE}\u{8BA1}\u{6587}\u{6863}
|
|
7728
|
-
|
|
7729
|
-
## \u{6574}\u{4F53}\u{67B6}\u{6784}
|
|
7730
|
-
|
|
7731
|
-
### \u{67B6}\u{6784}\u{6982}\u{8FF0}
|
|
7732
|
-
${architectureDesign.overview}
|
|
7733
|
-
|
|
7734
|
-
### \u{67B6}\u{6784}\u{56FE}
|
|
7735
|
-
\`\`\`mermaid
|
|
7736
|
-
${architectureDesign.architectureDiagram}
|
|
7737
|
-
\`\`\`
|
|
7738
|
-
|
|
7739
|
-
### \u{5206}\u{5C42}\u{8BBE}\u{8BA1}
|
|
7740
|
-
${architectureDesign.layers.map((layer, index)=>`${index + 1}. ${layer}`).join('\n')}
|
|
7741
|
-
|
|
7742
|
-
### \u{6838}\u{5FC3}\u{7EC4}\u{4EF6}
|
|
7743
|
-
${architectureDesign.coreComponents.map((component)=>`- ${component}`).join('\n')}
|
|
7744
|
-
|
|
7745
|
-
## \u{6A21}\u{5757}\u{8BBE}\u{8BA1}
|
|
7746
|
-
|
|
7747
|
-
${moduleDesign.modules.map((module)=>`### ${module.name}
|
|
7748
|
-
**\u{804C}\u{8D23}**: ${module.responsibility}
|
|
7749
|
-
**\u{63A5}\u{53E3}**: ${module.interfaces.join(', ')}
|
|
7750
|
-
**\u{4F9D}\u{8D56}**: ${module.dependencies.join(', ')}
|
|
7751
|
-
`).join('\n')}
|
|
7752
|
-
|
|
7753
|
-
## \u{63A5}\u{53E3}\u{89C4}\u{8303}
|
|
7754
|
-
|
|
7755
|
-
${moduleDesign.interfaces.map((interfaceItem)=>`### ${interfaceItem.name}
|
|
7756
|
-
- **\u{7C7B}\u{578B}**: ${interfaceItem.type}
|
|
7757
|
-
- **\u{683C}\u{5F0F}**: ${interfaceItem.format}
|
|
7758
|
-
- **\u{89C4}\u{8303}**: ${interfaceItem.specification}
|
|
7759
|
-
`).join('\n')}
|
|
7760
|
-
|
|
7761
|
-
## \u{4F9D}\u{8D56}\u{5173}\u{7CFB}
|
|
7762
|
-
|
|
7763
|
-
### \u{6A21}\u{5757}\u{4F9D}\u{8D56}\u{56FE}
|
|
7764
|
-
\`\`\`mermaid
|
|
7765
|
-
${architectureDesign.dependencyDiagram}
|
|
7766
|
-
\`\`\`
|
|
7767
|
-
|
|
7768
|
-
### \u{4F9D}\u{8D56}\u{8BF4}\u{660E}
|
|
7769
|
-
${architectureDesign.dependencies}
|
|
7770
|
-
|
|
7771
|
-
## \u{6570}\u{636E}\u{6D41}\u{5411}
|
|
7772
|
-
|
|
7773
|
-
### \u{6570}\u{636E}\u{6D41}\u{56FE}
|
|
7774
|
-
\`\`\`mermaid
|
|
7775
|
-
${architectureDesign.dataFlowDiagram}
|
|
7776
|
-
\`\`\`
|
|
7777
|
-
|
|
7778
|
-
### \u{6570}\u{636E}\u{6D41}\u{8BF4}\u{660E}
|
|
7779
|
-
${architectureDesign.dataFlow}
|
|
7780
|
-
|
|
7781
|
-
## \u{5F02}\u{5E38}\u{5904}\u{7406}\u{7B56}\u{7565}
|
|
7782
|
-
${architectureDesign.exceptionHandling}
|
|
7783
|
-
|
|
7784
|
-
## \u{6570}\u{636E}\u{4F20}\u{8F93}\u{534F}\u{8BAE}
|
|
7785
|
-
${moduleDesign.dataProtocols}
|
|
7786
|
-
|
|
7787
|
-
## API\u{89C4}\u{8303}
|
|
7788
|
-
${moduleDesign.apiSpecification}
|
|
7789
|
-
|
|
7790
|
-
## \u{751F}\u{6210}\u{65F6}\u{95F4}
|
|
7791
|
-
${new Date().toISOString()}
|
|
7792
|
-
`;
|
|
7793
|
-
}
|
|
7794
|
-
extractFeatureName(workspaceDir) {
|
|
7795
|
-
return external_path_namespaceObject.basename(workspaceDir);
|
|
7796
|
-
}
|
|
7797
|
-
}
|
|
7798
|
-
class AtomizeAgent {
|
|
7799
|
-
async execute(input) {
|
|
7800
|
-
logger_logger.info("\u4EFB\u52A1\u62C6\u5206\u667A\u80FD\u4F53\u5F00\u59CB\u6267\u884C");
|
|
7801
|
-
try {
|
|
7802
|
-
const architectureResult = input.previous_stage_output;
|
|
7803
|
-
if ('architect' !== architectureResult.stage) throw new Error("\u671F\u671B\u83B7\u5F97\u67B6\u6784\u9636\u6BB5\u7684\u8F93\u51FA");
|
|
7804
|
-
const taskDecomposition = await this.decomposeToAtomicTasks(architectureResult);
|
|
7805
|
-
const dependencyAnalysis = await this.analyzeDependencies(taskDecomposition);
|
|
7806
|
-
const complexityAssessment = await this.assessComplexity(taskDecomposition);
|
|
7807
|
-
const taskDoc = await this.generateTaskDocument(taskDecomposition, dependencyAnalysis, complexityAssessment);
|
|
7808
|
-
const featureName = this.extractFeatureName(input.workspace_dir);
|
|
7809
|
-
const projectRoot = process.cwd();
|
|
7810
|
-
const aicoDocsDir = external_path_namespaceObject.join(projectRoot, '.aico', 'docs', featureName);
|
|
7811
|
-
if (!external_fs_namespaceObject.existsSync(aicoDocsDir)) external_fs_namespaceObject.mkdirSync(aicoDocsDir, {
|
|
7812
|
-
recursive: true
|
|
7813
|
-
});
|
|
7814
|
-
const taskPath = external_path_namespaceObject.join(aicoDocsDir, `TASK_${featureName}.md`);
|
|
7815
|
-
external_fs_namespaceObject.writeFileSync(taskPath, taskDoc);
|
|
7816
|
-
logger_logger.info("\u4EFB\u52A1\u62C6\u5206\u6587\u6863\u5DF2\u4FDD\u5B58", {
|
|
7817
|
-
taskPath
|
|
7818
|
-
});
|
|
7819
|
-
const result = {
|
|
7820
|
-
stage: "atomize",
|
|
7821
|
-
atomic_tasks: taskDecomposition.tasks,
|
|
7822
|
-
task_dependency_graph: dependencyAnalysis.dependencyGraph,
|
|
7823
|
-
complexity_assessment: complexityAssessment.summary,
|
|
7824
|
-
human_confirmation_required: true
|
|
7825
|
-
};
|
|
7826
|
-
logger_logger.info("\u4EFB\u52A1\u62C6\u5206\u667A\u80FD\u4F53\u6267\u884C\u5B8C\u6210");
|
|
7827
|
-
return result;
|
|
7828
|
-
} catch (error) {
|
|
7829
|
-
logger_logger.error("\u4EFB\u52A1\u62C6\u5206\u667A\u80FD\u4F53\u6267\u884C\u5931\u8D25", error);
|
|
7830
|
-
throw new RequirementHandlerError(`\u{4EFB}\u{52A1}\u{62C6}\u{5206}\u{9636}\u{6BB5}\u{5931}\u{8D25}: ${error.message}`, types_StageErrorCodes.ATOMIZE_TASK_DECOMPOSITION_FAILED, 'atomize', {
|
|
7831
|
-
input,
|
|
7832
|
-
error: error.message
|
|
7833
|
-
});
|
|
7834
|
-
}
|
|
7835
|
-
}
|
|
7836
|
-
async decomposeToAtomicTasks(architectureResult) {
|
|
7837
|
-
const prompt = `
|
|
7838
|
-
\u{4F5C}\u{4E3A}\u{4EFB}\u{52A1}\u{62C6}\u{5206}\u{667A}\u{80FD}\u{4F53}\u{FF0C}\u{57FA}\u{4E8E}\u{4EE5}\u{4E0B}\u{7CFB}\u{7EDF}\u{67B6}\u{6784}\u{8BBE}\u{8BA1}\u{FF0C}\u{5C06}\u{5176}\u{5206}\u{89E3}\u{4E3A}\u{539F}\u{5B50}\u{4EFB}\u{52A1}\u{FF1A}
|
|
7839
|
-
|
|
7840
|
-
\u{7CFB}\u{7EDF}\u{67B6}\u{6784}\u{FF1A}
|
|
7841
|
-
${architectureResult.system_architecture}
|
|
7842
|
-
|
|
7843
|
-
\u{6A21}\u{5757}\u{8BBE}\u{8BA1}\u{FF1A}
|
|
7844
|
-
${architectureResult.module_design}
|
|
7845
|
-
|
|
7846
|
-
\u{63A5}\u{53E3}\u{89C4}\u{8303}\u{FF1A}
|
|
7847
|
-
${architectureResult.interface_specifications}
|
|
7848
|
-
|
|
7849
|
-
\u{8BF7}\u{5206}\u{89E3}\u{4EFB}\u{52A1}\u{FF0C}\u{786E}\u{4FDD}\u{FF1A}
|
|
7850
|
-
|
|
7851
|
-
1. \u{6BCF}\u{4E2A}\u{4EFB}\u{52A1}\u{590D}\u{6742}\u{5EA6}\u{53EF}\u{63A7}\u{FF0C}\u{4FBF}\u{4E8E}AI\u{9AD8}\u{6210}\u{529F}\u{7387}\u{4EA4}\u{4ED8}
|
|
7852
|
-
2. \u{6309}\u{529F}\u{80FD}\u{6A21}\u{5757}\u{5206}\u{89E3}\u{FF0C}\u{786E}\u{4FDD}\u{4EFB}\u{52A1}\u{539F}\u{5B50}\u{6027}\u{548C}\u{72EC}\u{7ACB}\u{6027}
|
|
7853
|
-
3. \u{6709}\u{660E}\u{786E}\u{7684}\u{9A8C}\u{6536}\u{6807}\u{51C6}\u{FF0C}\u{5C3D}\u{91CF}\u{53EF}\u{4EE5}\u{72EC}\u{7ACB}\u{7F16}\u{8BD1}\u{548C}\u{6D4B}\u{8BD5}
|
|
7854
|
-
4. \u{4F9D}\u{8D56}\u{5173}\u{7CFB}\u{6E05}\u{6670}
|
|
7855
|
-
|
|
7856
|
-
\u{6BCF}\u{4E2A}\u{539F}\u{5B50}\u{4EFB}\u{52A1}\u{5305}\u{542B}\u{FF1A}
|
|
7857
|
-
- \u{8F93}\u{5165}\u{5951}\u{7EA6}(\u{524D}\u{7F6E}\u{4F9D}\u{8D56}\u{3001}\u{8F93}\u{5165}\u{6570}\u{636E}\u{3001}\u{73AF}\u{5883}\u{4F9D}\u{8D56})
|
|
7858
|
-
- \u{8F93}\u{51FA}\u{5951}\u{7EA6}(\u{8F93}\u{51FA}\u{6570}\u{636E}\u{3001}\u{4EA4}\u{4ED8}\u{7269}\u{3001}\u{9A8C}\u{6536}\u{6807}\u{51C6})
|
|
7859
|
-
- \u{5B9E}\u{73B0}\u{7EA6}\u{675F}(\u{6280}\u{672F}\u{6808}\u{3001}\u{63A5}\u{53E3}\u{89C4}\u{8303}\u{3001}\u{8D28}\u{91CF}\u{8981}\u{6C42})
|
|
7860
|
-
- \u{4F9D}\u{8D56}\u{5173}\u{7CFB}(\u{540E}\u{7F6E}\u{4EFB}\u{52A1}\u{3001}\u{5E76}\u{884C}\u{4EFB}\u{52A1})
|
|
7861
|
-
|
|
7862
|
-
\u{8F93}\u{51FA}\u{683C}\u{5F0F}\u{4E3A}JSON\u{FF1A}
|
|
7863
|
-
{
|
|
7864
|
-
"tasks": [
|
|
7865
|
-
{
|
|
7866
|
-
"id": "TASK_001",
|
|
7867
|
-
"name": "\u{4EFB}\u{52A1}\u{540D}\u{79F0}",
|
|
7868
|
-
"description": "\u{8BE6}\u{7EC6}\u{63CF}\u{8FF0}",
|
|
7869
|
-
"input_contract": "\u{8F93}\u{5165}\u{5951}\u{7EA6}\u{63CF}\u{8FF0}",
|
|
7870
|
-
"output_contract": "\u{8F93}\u{51FA}\u{5951}\u{7EA6}\u{63CF}\u{8FF0}",
|
|
7871
|
-
"implementation_constraints": "\u{5B9E}\u{73B0}\u{7EA6}\u{675F}",
|
|
7872
|
-
"dependencies": ["TASK_002"],
|
|
7873
|
-
"acceptance_criteria": ["\u{9A8C}\u{6536}\u{6807}\u{51C6}1", "\u{9A8C}\u{6536}\u{6807}\u{51C6}2"],
|
|
7874
|
-
"complexity": "\u{7B80}\u{5355}|\u{4E2D}\u{7B49}|\u{590D}\u{6742}",
|
|
7875
|
-
"estimated_hours": 4
|
|
7876
|
-
}
|
|
7877
|
-
],
|
|
7878
|
-
"total_tasks": 5,
|
|
7879
|
-
"estimated_duration": "\u{603B}\u{9884}\u{4F30}\u{65F6}\u{957F}"
|
|
7880
|
-
}
|
|
7881
|
-
`;
|
|
7882
|
-
const response = await callOpenAI([
|
|
7883
|
-
{
|
|
7884
|
-
role: 'system',
|
|
7885
|
-
content: "\u4F60\u662F\u4EFB\u52A1\u5206\u89E3\u4E13\u5BB6\uFF0C\u4E13\u6CE8\u4E8E\u5C06\u590D\u6742\u7CFB\u7EDF\u5206\u89E3\u4E3A\u53EF\u7BA1\u7406\u7684\u539F\u5B50\u4EFB\u52A1\u3002"
|
|
7886
|
-
},
|
|
7887
|
-
{
|
|
7888
|
-
role: 'user',
|
|
7889
|
-
content: prompt
|
|
7890
|
-
}
|
|
7891
|
-
]);
|
|
7892
|
-
return JSON.parse(response);
|
|
7893
|
-
}
|
|
7894
|
-
async analyzeDependencies(taskDecomposition) {
|
|
7895
|
-
const prompt = `
|
|
7896
|
-
\u{57FA}\u{4E8E}\u{4EE5}\u{4E0B}\u{4EFB}\u{52A1}\u{5206}\u{89E3}\u{7ED3}\u{679C}\u{FF0C}\u{5206}\u{6790}\u{4EFB}\u{52A1}\u{95F4}\u{7684}\u{4F9D}\u{8D56}\u{5173}\u{7CFB}\u{FF1A}
|
|
7897
|
-
|
|
7898
|
-
\u{4EFB}\u{52A1}\u{5217}\u{8868}\u{FF1A}
|
|
7899
|
-
${JSON.stringify(taskDecomposition.tasks, null, 2)}
|
|
7900
|
-
|
|
7901
|
-
\u{8BF7}\u{5206}\u{6790}\u{FF1A}
|
|
7902
|
-
1. \u{4EFB}\u{52A1}\u{6267}\u{884C}\u{987A}\u{5E8F}
|
|
7903
|
-
2. \u{5E76}\u{884C}\u{6267}\u{884C}\u{7684}\u{53EF}\u{80FD}\u{6027}
|
|
7904
|
-
3. \u{5173}\u{952E}\u{8DEF}\u{5F84}\u{8BC6}\u{522B}
|
|
7905
|
-
4. \u{4F9D}\u{8D56}\u{5173}\u{7CFB}\u{56FE}(mermaid\u{683C}\u{5F0F})
|
|
7906
|
-
|
|
7907
|
-
\u{786E}\u{4FDD}\u{FF1A}
|
|
7908
|
-
- \u{4F9D}\u{8D56}\u{5173}\u{7CFB}\u{65E0}\u{5FAA}\u{73AF}
|
|
7909
|
-
- \u{8BC6}\u{522B}\u{53EF}\u{5E76}\u{884C}\u{6267}\u{884C}\u{7684}\u{4EFB}\u{52A1}
|
|
7910
|
-
- \u{660E}\u{786E}\u{5173}\u{952E}\u{8DEF}\u{5F84}
|
|
7911
|
-
|
|
7912
|
-
\u{8F93}\u{51FA}\u{683C}\u{5F0F}\u{4E3A}JSON\u{FF1A}
|
|
7913
|
-
{
|
|
7914
|
-
"executionOrder": [
|
|
7915
|
-
{
|
|
7916
|
-
"phase": "\u{9636}\u{6BB5}1",
|
|
7917
|
-
"tasks": ["TASK_001", "TASK_002"],
|
|
7918
|
-
"canParallel": true
|
|
7919
|
-
}
|
|
7920
|
-
],
|
|
7921
|
-
"dependencyGraph": "mermaid\u{4EE3}\u{7801}",
|
|
7922
|
-
"criticalPath": ["TASK_001", "TASK_003", "TASK_005"],
|
|
7923
|
-
"parallelGroups": [
|
|
7924
|
-
{
|
|
7925
|
-
"group": "\u{7EC4}1",
|
|
7926
|
-
"tasks": ["TASK_001", "TASK_002"]
|
|
7927
|
-
}
|
|
7928
|
-
]
|
|
7929
|
-
}
|
|
7930
|
-
`;
|
|
7931
|
-
const response = await callOpenAI([
|
|
7932
|
-
{
|
|
7933
|
-
role: 'system',
|
|
7934
|
-
content: "\u4F60\u662F\u4F9D\u8D56\u5173\u7CFB\u5206\u6790\u4E13\u5BB6\uFF0C\u4E13\u6CE8\u4E8E\u4F18\u5316\u4EFB\u52A1\u6267\u884C\u987A\u5E8F\u3002"
|
|
7935
|
-
},
|
|
7936
|
-
{
|
|
7937
|
-
role: 'user',
|
|
7938
|
-
content: prompt
|
|
7939
|
-
}
|
|
7940
|
-
]);
|
|
7941
|
-
return JSON.parse(response);
|
|
7942
|
-
}
|
|
7943
|
-
async assessComplexity(taskDecomposition) {
|
|
7944
|
-
const prompt = `
|
|
7945
|
-
\u{8BC4}\u{4F30}\u{4EE5}\u{4E0B}\u{4EFB}\u{52A1}\u{5206}\u{89E3}\u{7684}\u{590D}\u{6742}\u{5EA6}\u{FF1A}
|
|
7946
|
-
|
|
7947
|
-
\u{4EFB}\u{52A1}\u{5206}\u{89E3}\u{FF1A}
|
|
7948
|
-
${JSON.stringify(taskDecomposition, null, 2)}
|
|
7949
|
-
|
|
7950
|
-
\u{8BF7}\u{8BC4}\u{4F30}\u{FF1A}
|
|
7951
|
-
1. \u{6574}\u{4F53}\u{590D}\u{6742}\u{5EA6}
|
|
7952
|
-
2. \u{5355}\u{4E2A}\u{4EFB}\u{52A1}\u{590D}\u{6742}\u{5EA6}\u{5408}\u{7406}\u{6027}
|
|
7953
|
-
3. \u{98CE}\u{9669}\u{8BC6}\u{522B}
|
|
7954
|
-
4. \u{5EFA}\u{8BAE}\u{4F18}\u{5316}
|
|
7955
|
-
|
|
7956
|
-
\u{8F93}\u{51FA}\u{683C}\u{5F0F}\u{4E3A}JSON\u{FF1A}
|
|
7957
|
-
{
|
|
7958
|
-
"overallComplexity": "\u{7B80}\u{5355}|\u{4E2D}\u{7B49}|\u{590D}\u{6742}",
|
|
7959
|
-
"taskComplexityDistribution": {
|
|
7960
|
-
"\u{7B80}\u{5355}": 3,
|
|
7961
|
-
"\u{4E2D}\u{7B49}": 2,
|
|
7962
|
-
"\u{590D}\u{6742}": 0
|
|
7963
|
-
},
|
|
7964
|
-
"riskAssessment": [
|
|
7965
|
-
{
|
|
7966
|
-
"risk": "\u{98CE}\u{9669}\u{63CF}\u{8FF0}",
|
|
7967
|
-
"level": "\u{9AD8}|\u{4E2D}|\u{4F4E}",
|
|
7968
|
-
"mitigation": "\u{7F13}\u{89E3}\u{63AA}\u{65BD}"
|
|
7969
|
-
}
|
|
7970
|
-
],
|
|
7971
|
-
"optimizationSuggestions": ["\u{5EFA}\u{8BAE}1", "\u{5EFA}\u{8BAE}2"],
|
|
7972
|
-
"summary": "\u{590D}\u{6742}\u{5EA6}\u{8BC4}\u{4F30}\u{603B}\u{7ED3}"
|
|
7973
|
-
}
|
|
7974
|
-
`;
|
|
7975
|
-
const response = await callOpenAI([
|
|
7976
|
-
{
|
|
7977
|
-
role: 'system',
|
|
7978
|
-
content: "\u4F60\u662F\u590D\u6742\u5EA6\u8BC4\u4F30\u4E13\u5BB6\uFF0C\u4E13\u6CE8\u4E8E\u9879\u76EE\u98CE\u9669\u8BC4\u4F30\u548C\u4F18\u5316\u5EFA\u8BAE\u3002"
|
|
7979
|
-
},
|
|
7980
|
-
{
|
|
7981
|
-
role: 'user',
|
|
7982
|
-
content: prompt
|
|
7983
|
-
}
|
|
7984
|
-
]);
|
|
7985
|
-
return JSON.parse(response);
|
|
7986
|
-
}
|
|
7987
|
-
async generateTaskDocument(taskDecomposition, dependencyAnalysis, complexityAssessment) {
|
|
7988
|
-
return `# \u{4EFB}\u{52A1}\u{62C6}\u{5206}\u{6587}\u{6863}
|
|
7989
|
-
|
|
7990
|
-
## \u{4EFB}\u{52A1}\u{6982}\u{89C8}
|
|
7991
|
-
|
|
7992
|
-
- **\u{603B}\u{4EFB}\u{52A1}\u{6570}**: ${taskDecomposition.total_tasks}
|
|
7993
|
-
- **\u{9884}\u{4F30}\u{603B}\u{65F6}\u{957F}**: ${taskDecomposition.estimated_duration}
|
|
7994
|
-
- **\u{6574}\u{4F53}\u{590D}\u{6742}\u{5EA6}**: ${complexityAssessment.overallComplexity}
|
|
7995
|
-
|
|
7996
|
-
## \u{539F}\u{5B50}\u{4EFB}\u{52A1}\u{5217}\u{8868}
|
|
7997
|
-
|
|
7998
|
-
${taskDecomposition.tasks.map((task, index)=>`### ${task.id}: ${task.name}
|
|
7999
|
-
|
|
8000
|
-
**\u{63CF}\u{8FF0}**: ${task.description}
|
|
8001
|
-
|
|
8002
|
-
**\u{8F93}\u{5165}\u{5951}\u{7EA6}**:
|
|
8003
|
-
${task.input_contract}
|
|
8004
|
-
|
|
8005
|
-
**\u{8F93}\u{51FA}\u{5951}\u{7EA6}**:
|
|
8006
|
-
${task.output_contract}
|
|
8007
|
-
|
|
8008
|
-
**\u{5B9E}\u{73B0}\u{7EA6}\u{675F}**:
|
|
8009
|
-
${task.implementation_constraints}
|
|
8010
|
-
|
|
8011
|
-
**\u{4F9D}\u{8D56}\u{5173}\u{7CFB}**: ${task.dependencies.length > 0 ? task.dependencies.join(', ') : "\u65E0"}
|
|
8012
|
-
|
|
8013
|
-
**\u{9A8C}\u{6536}\u{6807}\u{51C6}**:
|
|
8014
|
-
${task.acceptance_criteria.map((criteria)=>`- ${criteria}`).join('\n')}
|
|
8015
|
-
|
|
8016
|
-
**\u{590D}\u{6742}\u{5EA6}**: ${task.complexity}
|
|
8017
|
-
**\u{9884}\u{4F30}\u{65F6}\u{95F4}**: ${task.estimated_hours}\u{5C0F}\u{65F6}
|
|
8018
|
-
|
|
8019
|
-
---
|
|
8020
|
-
`).join('\n')}
|
|
8021
|
-
|
|
8022
|
-
## \u{4EFB}\u{52A1}\u{4F9D}\u{8D56}\u{5173}\u{7CFB}
|
|
8023
|
-
|
|
8024
|
-
### \u{4F9D}\u{8D56}\u{5173}\u{7CFB}\u{56FE}
|
|
8025
|
-
\`\`\`mermaid
|
|
8026
|
-
${dependencyAnalysis.dependencyGraph}
|
|
8027
|
-
\`\`\`
|
|
8028
|
-
|
|
8029
|
-
### \u{6267}\u{884C}\u{9636}\u{6BB5}
|
|
8030
|
-
${dependencyAnalysis.executionOrder.map((phase, index)=>`#### ${phase.phase}
|
|
8031
|
-
\u{4EFB}\u{52A1}: ${phase.tasks.join(', ')}
|
|
8032
|
-
\u{5E76}\u{884C}\u{6267}\u{884C}: ${phase.canParallel ? "\u662F" : "\u5426"}
|
|
8033
|
-
`).join('\n')}
|
|
8034
|
-
|
|
8035
|
-
### \u{5173}\u{952E}\u{8DEF}\u{5F84}
|
|
8036
|
-
${dependencyAnalysis.criticalPath.join(" \u2192 ")}
|
|
8037
|
-
|
|
8038
|
-
### \u{5E76}\u{884C}\u{4EFB}\u{52A1}\u{7EC4}
|
|
8039
|
-
${dependencyAnalysis.parallelGroups.map((group)=>`- **${group.group}**: ${group.tasks.join(', ')}`).join('\n')}
|
|
8040
|
-
|
|
8041
|
-
## \u{590D}\u{6742}\u{5EA6}\u{8BC4}\u{4F30}
|
|
8042
|
-
|
|
8043
|
-
### \u{4EFB}\u{52A1}\u{590D}\u{6742}\u{5EA6}\u{5206}\u{5E03}
|
|
8044
|
-
${Object.entries(complexityAssessment.taskComplexityDistribution).map(([level, count])=>`- ${level}: ${count}\u{4E2A}\u{4EFB}\u{52A1}`).join('\n')}
|
|
8045
|
-
|
|
8046
|
-
### \u{98CE}\u{9669}\u{8BC4}\u{4F30}
|
|
8047
|
-
${complexityAssessment.riskAssessment.map((risk)=>`#### ${risk.risk}
|
|
8048
|
-
- **\u{98CE}\u{9669}\u{7B49}\u{7EA7}**: ${risk.level}
|
|
8049
|
-
- **\u{7F13}\u{89E3}\u{63AA}\u{65BD}**: ${risk.mitigation}
|
|
8050
|
-
`).join('\n')}
|
|
8051
|
-
|
|
8052
|
-
### \u{4F18}\u{5316}\u{5EFA}\u{8BAE}
|
|
8053
|
-
${complexityAssessment.optimizationSuggestions.map((suggestion)=>`- ${suggestion}`).join('\n')}
|
|
8054
|
-
|
|
8055
|
-
### \u{8BC4}\u{4F30}\u{603B}\u{7ED3}
|
|
8056
|
-
${complexityAssessment.summary}
|
|
8057
|
-
|
|
8058
|
-
## \u{751F}\u{6210}\u{65F6}\u{95F4}
|
|
8059
|
-
${new Date().toISOString()}
|
|
8060
|
-
`;
|
|
8061
|
-
}
|
|
8062
|
-
extractFeatureName(workspaceDir) {
|
|
8063
|
-
return external_path_namespaceObject.basename(workspaceDir);
|
|
8064
|
-
}
|
|
8065
|
-
}
|
|
8066
|
-
class ApproveAgent {
|
|
8067
|
-
async execute(input) {
|
|
8068
|
-
logger_logger.info("\u5BA1\u67E5\u8BC4\u4F30\u667A\u80FD\u4F53\u5F00\u59CB\u6267\u884C");
|
|
8069
|
-
try {
|
|
8070
|
-
const qualityChecklist = await this.executeQualityChecklist(input.all_previous_outputs);
|
|
8071
|
-
const riskAssessment = await this.assessRisks(input.all_previous_outputs);
|
|
8072
|
-
const finalApproval = await this.makeFinalApproval(qualityChecklist, riskAssessment);
|
|
8073
|
-
const approvalDoc = await this.generateApprovalDocument(qualityChecklist, riskAssessment, finalApproval);
|
|
8074
|
-
const featureName = this.extractFeatureName(input.workspace_dir);
|
|
8075
|
-
const projectRoot = process.cwd();
|
|
8076
|
-
const aicoDocsDir = external_path_namespaceObject.join(projectRoot, '.aico', 'docs', featureName);
|
|
8077
|
-
if (!external_fs_namespaceObject.existsSync(aicoDocsDir)) external_fs_namespaceObject.mkdirSync(aicoDocsDir, {
|
|
8078
|
-
recursive: true
|
|
8079
|
-
});
|
|
8080
|
-
const approvalPath = external_path_namespaceObject.join(aicoDocsDir, `APPROVAL_${featureName}.md`);
|
|
8081
|
-
external_fs_namespaceObject.writeFileSync(approvalPath, approvalDoc);
|
|
8082
|
-
logger_logger.info("\u5BA1\u67E5\u8BC4\u4F30\u6587\u6863\u5DF2\u4FDD\u5B58", {
|
|
8083
|
-
approvalPath
|
|
8084
|
-
});
|
|
8085
|
-
const result = {
|
|
8086
|
-
stage: "approve",
|
|
8087
|
-
quality_checklist: qualityChecklist.items,
|
|
8088
|
-
risk_assessment: riskAssessment.risks,
|
|
8089
|
-
final_approval_status: finalApproval.status,
|
|
8090
|
-
revision_requirements: finalApproval.revisions,
|
|
8091
|
-
human_confirmation_required: true
|
|
8092
|
-
};
|
|
8093
|
-
logger_logger.info("\u5BA1\u67E5\u8BC4\u4F30\u667A\u80FD\u4F53\u6267\u884C\u5B8C\u6210");
|
|
8094
|
-
return result;
|
|
8095
|
-
} catch (error) {
|
|
8096
|
-
logger_logger.error("\u5BA1\u67E5\u8BC4\u4F30\u667A\u80FD\u4F53\u6267\u884C\u5931\u8D25", error);
|
|
8097
|
-
throw new RequirementHandlerError(`\u{5BA1}\u{67E5}\u{8BC4}\u{4F30}\u{9636}\u{6BB5}\u{5931}\u{8D25}: ${error.message}`, types_StageErrorCodes.APPROVE_QUALITY_CHECK_FAILED, 'approve', {
|
|
8098
|
-
input,
|
|
8099
|
-
error: error.message
|
|
8100
|
-
});
|
|
8101
|
-
}
|
|
8102
|
-
}
|
|
8103
|
-
async executeQualityChecklist(allOutputs) {
|
|
8104
|
-
const prompt = `
|
|
8105
|
-
\u{4F5C}\u{4E3A}\u{5BA1}\u{67E5}\u{8BC4}\u{4F30}\u{667A}\u{80FD}\u{4F53}\u{FF0C}\u{5BF9}\u{4EE5}\u{4E0B}\u{6240}\u{6709}\u{9636}\u{6BB5}\u{8F93}\u{51FA}\u{8FDB}\u{884C}\u{8D28}\u{91CF}\u{68C0}\u{67E5}\u{FF1A}
|
|
8106
|
-
|
|
8107
|
-
\u{9636}\u{6BB5}\u{8F93}\u{51FA}\u{FF1A}
|
|
8108
|
-
${JSON.stringify(allOutputs, null, 2)}
|
|
8109
|
-
|
|
8110
|
-
\u{8BF7}\u{6267}\u{884C}\u{5168}\u{9762}\u{7684}\u{8D28}\u{91CF}\u{68C0}\u{67E5}\u{FF1A}
|
|
8111
|
-
|
|
8112
|
-
1. \u{5B8C}\u{6574}\u{6027}\u{68C0}\u{67E5}
|
|
8113
|
-
- \u{4EFB}\u{52A1}\u{8BA1}\u{5212}\u{662F}\u{5426}\u{8986}\u{76D6}\u{6240}\u{6709}\u{9700}\u{6C42}
|
|
8114
|
-
- \u{6587}\u{6863}\u{662F}\u{5426}\u{5B8C}\u{6574}
|
|
8115
|
-
- \u{63A5}\u{53E3}\u{5B9A}\u{4E49}\u{662F}\u{5426}\u{9F50}\u{5168}
|
|
8116
|
-
|
|
8117
|
-
2. \u{4E00}\u{81F4}\u{6027}\u{68C0}\u{67E5}
|
|
8118
|
-
- \u{5404}\u{9636}\u{6BB5}\u{8F93}\u{51FA}\u{662F}\u{5426}\u{4E00}\u{81F4}
|
|
8119
|
-
- \u{67B6}\u{6784}\u{8BBE}\u{8BA1}\u{4E0E}\u{9700}\u{6C42}\u{5BF9}\u{9F50}
|
|
8120
|
-
- \u{4EFB}\u{52A1}\u{5206}\u{89E3}\u{4E0E}\u{67B6}\u{6784}\u{5339}\u{914D}
|
|
8121
|
-
|
|
8122
|
-
3. \u{53EF}\u{884C}\u{6027}\u{68C0}\u{67E5}
|
|
8123
|
-
- \u{6280}\u{672F}\u{65B9}\u{6848}\u{662F}\u{5426}\u{786E}\u{5B9E}\u{53EF}\u{884C}
|
|
8124
|
-
- \u{4F9D}\u{8D56}\u{5173}\u{7CFB}\u{662F}\u{5426}\u{5408}\u{7406}
|
|
8125
|
-
- \u{8D44}\u{6E90}\u{9700}\u{6C42}\u{662F}\u{5426}\u{73B0}\u{5B9E}
|
|
8126
|
-
|
|
8127
|
-
4. \u{53EF}\u{63A7}\u{6027}\u{68C0}\u{67E5}
|
|
8128
|
-
- \u{98CE}\u{9669}\u{662F}\u{5426}\u{5728}\u{53EF}\u{63A5}\u{53D7}\u{8303}\u{56F4}
|
|
8129
|
-
- \u{590D}\u{6742}\u{5EA6}\u{662F}\u{5426}\u{53EF}\u{63A7}
|
|
8130
|
-
- \u{65F6}\u{95F4}\u{4F30}\u{7B97}\u{662F}\u{5426}\u{5408}\u{7406}
|
|
8131
|
-
|
|
8132
|
-
5. \u{53EF}\u{6D4B}\u{6027}\u{68C0}\u{67E5}
|
|
8133
|
-
- \u{9A8C}\u{6536}\u{6807}\u{51C6}\u{662F}\u{5426}\u{660E}\u{786E}\u{53EF}\u{6267}\u{884C}
|
|
8134
|
-
- \u{6D4B}\u{8BD5}\u{7B56}\u{7565}\u{662F}\u{5426}\u{5B8C}\u{6574}
|
|
8135
|
-
- \u{8D28}\u{91CF}\u{6307}\u{6807}\u{662F}\u{5426}\u{53EF}\u{8861}\u{91CF}
|
|
8136
|
-
|
|
8137
|
-
\u{8F93}\u{51FA}\u{683C}\u{5F0F}\u{4E3A}JSON\u{FF1A}
|
|
8138
|
-
{
|
|
8139
|
-
"items": [
|
|
8140
|
-
{
|
|
8141
|
-
"item": "\u{68C0}\u{67E5}\u{9879}\u{76EE}",
|
|
8142
|
-
"status": "pass|fail|pending",
|
|
8143
|
-
"comments": "\u{8BE6}\u{7EC6}\u{8BF4}\u{660E}",
|
|
8144
|
-
"evidence": "\u{4F9D}\u{636E}\u{4FE1}\u{606F}"
|
|
8145
|
-
}
|
|
8146
|
-
],
|
|
8147
|
-
"overallScore": 85,
|
|
8148
|
-
"passRate": 0.8,
|
|
8149
|
-
"criticalIssues": ["\u{5173}\u{952E}\u{95EE}\u{9898}1"],
|
|
8150
|
-
"recommendations": ["\u{5EFA}\u{8BAE}1", "\u{5EFA}\u{8BAE}2"]
|
|
8151
|
-
}
|
|
8152
|
-
`;
|
|
8153
|
-
const response = await callOpenAI([
|
|
8154
|
-
{
|
|
8155
|
-
role: 'system',
|
|
8156
|
-
content: "\u4F60\u662F\u8D28\u91CF\u68C0\u67E5\u4E13\u5BB6\uFF0C\u4E13\u6CE8\u4E8E\u5168\u9762\u8BC4\u4F30\u9879\u76EE\u8D28\u91CF\u548C\u53EF\u884C\u6027\u3002"
|
|
8157
|
-
},
|
|
8158
|
-
{
|
|
8159
|
-
role: 'user',
|
|
8160
|
-
content: prompt
|
|
8161
|
-
}
|
|
8162
|
-
]);
|
|
8163
|
-
return JSON.parse(response);
|
|
8164
|
-
}
|
|
8165
|
-
async assessRisks(allOutputs) {
|
|
8166
|
-
const prompt = `
|
|
8167
|
-
\u{57FA}\u{4E8E}\u{6240}\u{6709}\u{9636}\u{6BB5}\u{8F93}\u{51FA}\u{FF0C}\u{8FDB}\u{884C}\u{5168}\u{9762}\u{7684}\u{98CE}\u{9669}\u{8BC4}\u{4F30}\u{FF1A}
|
|
8168
|
-
|
|
8169
|
-
\u{9636}\u{6BB5}\u{8F93}\u{51FA}\u{FF1A}
|
|
8170
|
-
${JSON.stringify(allOutputs, null, 2)}
|
|
8171
|
-
|
|
8172
|
-
\u{8BF7}\u{8BC6}\u{522B}\u{548C}\u{8BC4}\u{4F30}\u{FF1A}
|
|
8173
|
-
|
|
8174
|
-
1. \u{6280}\u{672F}\u{98CE}\u{9669}
|
|
8175
|
-
- \u{6280}\u{672F}\u{590D}\u{6742}\u{5EA6}\u{98CE}\u{9669}
|
|
8176
|
-
- \u{6280}\u{672F}\u{9009}\u{578B}\u{98CE}\u{9669}
|
|
8177
|
-
- \u{96C6}\u{6210}\u{98CE}\u{9669}
|
|
8178
|
-
|
|
8179
|
-
2. \u{9879}\u{76EE}\u{98CE}\u{9669}
|
|
8180
|
-
- \u{65F6}\u{95F4}\u{4F30}\u{7B97}\u{98CE}\u{9669}
|
|
8181
|
-
- \u{8D44}\u{6E90}\u{98CE}\u{9669}
|
|
8182
|
-
- \u{4F9D}\u{8D56}\u{98CE}\u{9669}
|
|
8183
|
-
|
|
8184
|
-
3. \u{8D28}\u{91CF}\u{98CE}\u{9669}
|
|
8185
|
-
- \u{6D4B}\u{8BD5}\u{8986}\u{76D6}\u{98CE}\u{9669}
|
|
8186
|
-
- \u{6027}\u{80FD}\u{98CE}\u{9669}
|
|
8187
|
-
- \u{7EF4}\u{62A4}\u{6027}\u{98CE}\u{9669}
|
|
8188
|
-
|
|
8189
|
-
4. \u{4E1A}\u{52A1}\u{98CE}\u{9669}
|
|
8190
|
-
- \u{9700}\u{6C42}\u{53D8}\u{66F4}\u{98CE}\u{9669}
|
|
8191
|
-
- \u{7528}\u{6237}\u{63A5}\u{53D7}\u{5EA6}\u{98CE}\u{9669}
|
|
8192
|
-
- \u{5546}\u{4E1A}\u{4EF7}\u{503C}\u{98CE}\u{9669}
|
|
8193
|
-
|
|
8194
|
-
\u{5BF9}\u{6BCF}\u{4E2A}\u{98CE}\u{9669}\u{63D0}\u{4F9B}\u{FF1A}
|
|
8195
|
-
- \u{98CE}\u{9669}\u{63CF}\u{8FF0}
|
|
8196
|
-
- \u{5F71}\u{54CD}\u{7A0B}\u{5EA6}
|
|
8197
|
-
- \u{53D1}\u{751F}\u{6982}\u{7387}
|
|
8198
|
-
- \u{7F13}\u{89E3}\u{63AA}\u{65BD}
|
|
8199
|
-
|
|
8200
|
-
\u{8F93}\u{51FA}\u{683C}\u{5F0F}\u{4E3A}JSON\u{FF1A}
|
|
8201
|
-
{
|
|
8202
|
-
"risks": [
|
|
8203
|
-
{
|
|
8204
|
-
"risk": "\u{98CE}\u{9669}\u{63CF}\u{8FF0}",
|
|
8205
|
-
"category": "\u{6280}\u{672F}|\u{9879}\u{76EE}|\u{8D28}\u{91CF}|\u{4E1A}\u{52A1}",
|
|
8206
|
-
"level": "low|medium|high",
|
|
8207
|
-
"impact": "\u{5F71}\u{54CD}\u{63CF}\u{8FF0}",
|
|
8208
|
-
"probability": "low|medium|high",
|
|
8209
|
-
"mitigation": "\u{7F13}\u{89E3}\u{63AA}\u{65BD}"
|
|
8210
|
-
}
|
|
8211
|
-
],
|
|
8212
|
-
"overallRiskLevel": "low|medium|high",
|
|
8213
|
-
"highRiskCount": 2,
|
|
8214
|
-
"riskMatrix": {
|
|
8215
|
-
"high_impact_high_prob": 1,
|
|
8216
|
-
"high_impact_low_prob": 2,
|
|
8217
|
-
"low_impact_high_prob": 1,
|
|
8218
|
-
"low_impact_low_prob": 3
|
|
8219
|
-
}
|
|
8220
|
-
}
|
|
8221
|
-
`;
|
|
8222
|
-
const response = await callOpenAI([
|
|
8223
|
-
{
|
|
8224
|
-
role: 'system',
|
|
8225
|
-
content: "\u4F60\u662F\u98CE\u9669\u8BC4\u4F30\u4E13\u5BB6\uFF0C\u4E13\u6CE8\u4E8E\u8BC6\u522B\u548C\u7F13\u89E3\u9879\u76EE\u98CE\u9669\u3002"
|
|
8226
|
-
},
|
|
8227
|
-
{
|
|
8228
|
-
role: 'user',
|
|
8229
|
-
content: prompt
|
|
8230
|
-
}
|
|
8231
|
-
]);
|
|
8232
|
-
return JSON.parse(response);
|
|
8233
|
-
}
|
|
8234
|
-
async makeFinalApproval(qualityChecklist, riskAssessment) {
|
|
8235
|
-
const prompt = `
|
|
8236
|
-
\u{57FA}\u{4E8E}\u{8D28}\u{91CF}\u{68C0}\u{67E5}\u{548C}\u{98CE}\u{9669}\u{8BC4}\u{4F30}\u{7ED3}\u{679C}\u{FF0C}\u{505A}\u{51FA}\u{6700}\u{7EC8}\u{6279}\u{51C6}\u{51B3}\u{5B9A}\u{FF1A}
|
|
8237
|
-
|
|
8238
|
-
\u{8D28}\u{91CF}\u{68C0}\u{67E5}\u{7ED3}\u{679C}\u{FF1A}
|
|
8239
|
-
${JSON.stringify(qualityChecklist, null, 2)}
|
|
8240
|
-
|
|
8241
|
-
\u{98CE}\u{9669}\u{8BC4}\u{4F30}\u{7ED3}\u{679C}\u{FF1A}
|
|
8242
|
-
${JSON.stringify(riskAssessment, null, 2)}
|
|
8243
|
-
|
|
8244
|
-
\u{8BF7}\u{7EFC}\u{5408}\u{8BC4}\u{4F30}\u{5E76}\u{505A}\u{51FA}\u{51B3}\u{5B9A}\u{FF1A}
|
|
8245
|
-
|
|
8246
|
-
1. \u{5982}\u{679C}\u{8D28}\u{91CF}\u{5206}\u{6570} >= 80 \u{4E14}\u{9AD8}\u{98CE}\u{9669}\u{6570}\u{91CF} <= 2\u{FF1A}\u{6279}\u{51C6}
|
|
8247
|
-
2. \u{5982}\u{679C}\u{8D28}\u{91CF}\u{5206}\u{6570} >= 60 \u{4E14}\u{9AD8}\u{98CE}\u{9669}\u{53EF}\u{63A7}\u{FF1A}\u{9700}\u{8981}\u{4FEE}\u{8BA2}
|
|
8248
|
-
3. \u{5176}\u{4ED6}\u{60C5}\u{51B5}\u{FF1A}\u{62D2}\u{7EDD}
|
|
8249
|
-
|
|
8250
|
-
\u{8F93}\u{51FA}\u{683C}\u{5F0F}\u{4E3A}JSON\u{FF1A}
|
|
8251
|
-
{
|
|
8252
|
-
"status": "approved|needs_revision|rejected",
|
|
8253
|
-
"reasoning": "\u{51B3}\u{5B9A}\u{7406}\u{7531}",
|
|
8254
|
-
"revisions": ["\u{4FEE}\u{8BA2}\u{8981}\u{6C42}1", "\u{4FEE}\u{8BA2}\u{8981}\u{6C42}2"],
|
|
8255
|
-
"conditions": ["\u{6279}\u{51C6}\u{6761}\u{4EF6}1"],
|
|
8256
|
-
"nextSteps": ["\u{4E0B}\u{4E00}\u{6B65}\u{884C}\u{52A8}1"],
|
|
8257
|
-
"confidence": 0.85
|
|
8258
|
-
}
|
|
8259
|
-
`;
|
|
8260
|
-
const response = await callOpenAI([
|
|
8261
|
-
{
|
|
8262
|
-
role: 'system',
|
|
8263
|
-
content: "\u4F60\u662F\u9879\u76EE\u5BA1\u6279\u4E13\u5BB6\uFF0C\u4E13\u6CE8\u4E8E\u57FA\u4E8E\u5BA2\u89C2\u6807\u51C6\u505A\u51FA\u5BA1\u6279\u51B3\u5B9A\u3002"
|
|
8264
|
-
},
|
|
8265
|
-
{
|
|
8266
|
-
role: 'user',
|
|
8267
|
-
content: prompt
|
|
8268
|
-
}
|
|
8269
|
-
]);
|
|
8270
|
-
return JSON.parse(response);
|
|
8271
|
-
}
|
|
8272
|
-
async generateApprovalDocument(qualityChecklist, riskAssessment, finalApproval) {
|
|
8273
|
-
return `# \u{5BA1}\u{67E5}\u{8BC4}\u{4F30}\u{62A5}\u{544A}
|
|
8274
|
-
|
|
8275
|
-
## \u{6267}\u{884C}\u{68C0}\u{67E5}\u{6E05}\u{5355}
|
|
8276
|
-
|
|
8277
|
-
### \u{8D28}\u{91CF}\u{8BC4}\u{5206}
|
|
8278
|
-
- **\u{603B}\u{4F53}\u{8BC4}\u{5206}**: ${qualityChecklist.overallScore}/100
|
|
8279
|
-
- **\u{901A}\u{8FC7}\u{7387}**: ${(100 * qualityChecklist.passRate).toFixed(1)}%
|
|
8280
|
-
|
|
8281
|
-
### \u{68C0}\u{67E5}\u{9879}\u{76EE}\u{8BE6}\u{60C5}
|
|
8282
|
-
${qualityChecklist.items.map((item)=>`#### ${item.item}
|
|
8283
|
-
- **\u{72B6}\u{6001}**: ${'pass' === item.status ? "\u2705 \u901A\u8FC7" : 'fail' === item.status ? "\u274C \u5931\u8D25" : "\u23F3 \u5F85\u5B9A"}
|
|
8284
|
-
- **\u{8BF4}\u{660E}**: ${item.comments}
|
|
8285
|
-
- **\u{4F9D}\u{636E}**: ${item.evidence}
|
|
8286
|
-
`).join('\n')}
|
|
8287
|
-
|
|
8288
|
-
### \u{5173}\u{952E}\u{95EE}\u{9898}
|
|
8289
|
-
${qualityChecklist.criticalIssues.length > 0 ? qualityChecklist.criticalIssues.map((issue)=>`- \u{26A0}\u{FE0F} ${issue}`).join('\n') : "\u65E0\u5173\u952E\u95EE\u9898"}
|
|
8290
|
-
|
|
8291
|
-
### \u{6539}\u{8FDB}\u{5EFA}\u{8BAE}
|
|
8292
|
-
${qualityChecklist.recommendations.map((rec)=>`- \u{1F4A1} ${rec}`).join('\n')}
|
|
8293
|
-
|
|
8294
|
-
## \u{98CE}\u{9669}\u{8BC4}\u{4F30}
|
|
8295
|
-
|
|
8296
|
-
### \u{98CE}\u{9669}\u{6982}\u{89C8}
|
|
8297
|
-
- **\u{6574}\u{4F53}\u{98CE}\u{9669}\u{7B49}\u{7EA7}**: ${riskAssessment.overallRiskLevel}
|
|
8298
|
-
- **\u{9AD8}\u{98CE}\u{9669}\u{9879}\u{76EE}\u{6570}**: ${riskAssessment.highRiskCount}
|
|
8299
|
-
|
|
8300
|
-
### \u{98CE}\u{9669}\u{77E9}\u{9635}
|
|
8301
|
-
| \u{5F71}\u{54CD}\u{7A0B}\u{5EA6} | \u{9AD8}\u{6982}\u{7387} | \u{4F4E}\u{6982}\u{7387} |
|
|
8302
|
-
|---------|--------|--------|
|
|
8303
|
-
| \u{9AD8}\u{5F71}\u{54CD} | ${riskAssessment.riskMatrix.high_impact_high_prob} | ${riskAssessment.riskMatrix.high_impact_low_prob} |
|
|
8304
|
-
| \u{4F4E}\u{5F71}\u{54CD} | ${riskAssessment.riskMatrix.low_impact_high_prob} | ${riskAssessment.riskMatrix.low_impact_low_prob} |
|
|
8305
|
-
|
|
8306
|
-
### \u{98CE}\u{9669}\u{8BE6}\u{60C5}
|
|
8307
|
-
${riskAssessment.risks.map((risk)=>`#### ${risk.risk}
|
|
8308
|
-
- **\u{7C7B}\u{522B}**: ${risk.category}
|
|
8309
|
-
- **\u{7B49}\u{7EA7}**: ${'high' === risk.level ? "\uD83D\uDD34 \u9AD8" : 'medium' === risk.level ? "\uD83D\uDFE1 \u4E2D" : "\uD83D\uDFE2 \u4F4E"}
|
|
8310
|
-
- **\u{5F71}\u{54CD}**: ${risk.impact}
|
|
8311
|
-
- **\u{6982}\u{7387}**: ${risk.probability}
|
|
8312
|
-
- **\u{7F13}\u{89E3}\u{63AA}\u{65BD}**: ${risk.mitigation}
|
|
8313
|
-
`).join('\n')}
|
|
8314
|
-
|
|
8315
|
-
## \u{6700}\u{7EC8}\u{786E}\u{8BA4}
|
|
8316
|
-
|
|
8317
|
-
### \u{6279}\u{51C6}\u{72B6}\u{6001}
|
|
8318
|
-
**${'approved' === finalApproval.status ? "\u2705 \u6279\u51C6\u901A\u8FC7" : 'needs_revision' === finalApproval.status ? "\u26A0\uFE0F \u9700\u8981\u4FEE\u8BA2" : "\u274C \u62D2\u7EDD"}**
|
|
8319
|
-
|
|
8320
|
-
### \u{51B3}\u{5B9A}\u{7406}\u{7531}
|
|
8321
|
-
${finalApproval.reasoning}
|
|
8322
|
-
|
|
8323
|
-
### \u{7F6E}\u{4FE1}\u{5EA6}
|
|
8324
|
-
${(100 * finalApproval.confidence).toFixed(1)}%
|
|
8325
|
-
|
|
8326
|
-
${'needs_revision' === finalApproval.status ? `
|
|
8327
|
-
### \u{4FEE}\u{8BA2}\u{8981}\u{6C42}
|
|
8328
|
-
${finalApproval.revisions?.map((rev)=>`- ${rev}`).join('\n') || "\u65E0"}
|
|
8329
|
-
` : ''}
|
|
8330
|
-
|
|
8331
|
-
${'approved' === finalApproval.status ? `
|
|
8332
|
-
### \u{6279}\u{51C6}\u{6761}\u{4EF6}
|
|
8333
|
-
${finalApproval.conditions?.map((cond)=>`- ${cond}`).join('\n') || "\u65E0\u6761\u4EF6"}
|
|
8334
|
-
` : ''}
|
|
8335
|
-
|
|
8336
|
-
### \u{4E0B}\u{4E00}\u{6B65}\u{884C}\u{52A8}
|
|
8337
|
-
${finalApproval.nextSteps?.map((step)=>`- ${step}`).join('\n') || "\u65E0"}
|
|
8338
|
-
|
|
8339
|
-
## \u{751F}\u{6210}\u{65F6}\u{95F4}
|
|
8340
|
-
${new Date().toISOString()}
|
|
8341
|
-
`;
|
|
8342
|
-
}
|
|
8343
|
-
extractFeatureName(workspaceDir) {
|
|
8344
|
-
return external_path_namespaceObject.basename(workspaceDir);
|
|
8345
|
-
}
|
|
8346
|
-
}
|
|
8347
|
-
class AutomateAgent {
|
|
8348
|
-
async execute(input) {
|
|
8349
|
-
logger_logger.info("\u6267\u884C\u5B9E\u65BD\u667A\u80FD\u4F53\u5F00\u59CB\u6267\u884C");
|
|
8350
|
-
try {
|
|
8351
|
-
const featureName = this.extractFeatureName(input.workspace_dir);
|
|
8352
|
-
const projectRoot = process.cwd();
|
|
8353
|
-
const aicoDocsDir = external_path_namespaceObject.join(projectRoot, '.aico', 'docs', featureName);
|
|
8354
|
-
const implementationDir = external_path_namespaceObject.join(aicoDocsDir, 'implementation');
|
|
8355
|
-
if (!external_fs_namespaceObject.existsSync(aicoDocsDir)) external_fs_namespaceObject.mkdirSync(aicoDocsDir, {
|
|
8356
|
-
recursive: true
|
|
8357
|
-
});
|
|
8358
|
-
if (!external_fs_namespaceObject.existsSync(implementationDir)) external_fs_namespaceObject.mkdirSync(implementationDir, {
|
|
8359
|
-
recursive: true
|
|
8360
|
-
});
|
|
8361
|
-
const atomizeResult = input.all_previous_outputs.find((r)=>'atomize' === r.stage);
|
|
8362
|
-
if (!atomizeResult || 'atomize' !== atomizeResult.stage) throw new Error("\u672A\u627E\u5230\u4EFB\u52A1\u62C6\u5206\u9636\u6BB5\u7684\u8F93\u51FA");
|
|
8363
|
-
const implementationProgress = await this.implementTasks(atomizeResult.atomic_tasks, implementationDir, input);
|
|
8364
|
-
const qualityMetrics = await this.assessCodeQuality(implementationProgress);
|
|
8365
|
-
const executionDoc = await this.generateExecutionDocument(implementationProgress, qualityMetrics);
|
|
8366
|
-
const executionPath = external_path_namespaceObject.join(aicoDocsDir, `EXECUTION_${featureName}.md`);
|
|
8367
|
-
external_fs_namespaceObject.writeFileSync(executionPath, executionDoc);
|
|
8368
|
-
logger_logger.info("\u6267\u884C\u5B9E\u65BD\u6587\u6863\u5DF2\u4FDD\u5B58", {
|
|
8369
|
-
executionPath
|
|
8370
|
-
});
|
|
8371
|
-
const result = {
|
|
8372
|
-
stage: "automate",
|
|
8373
|
-
implementation_progress: implementationProgress,
|
|
8374
|
-
code_quality_metrics: qualityMetrics,
|
|
8375
|
-
human_confirmation_required: true
|
|
8376
|
-
};
|
|
8377
|
-
logger_logger.info("\u6267\u884C\u5B9E\u65BD\u667A\u80FD\u4F53\u6267\u884C\u5B8C\u6210");
|
|
8378
|
-
return result;
|
|
8379
|
-
} catch (error) {
|
|
8380
|
-
logger_logger.error("\u6267\u884C\u5B9E\u65BD\u667A\u80FD\u4F53\u6267\u884C\u5931\u8D25", error);
|
|
8381
|
-
throw new RequirementHandlerError(`\u{6267}\u{884C}\u{5B9E}\u{65BD}\u{9636}\u{6BB5}\u{5931}\u{8D25}: ${error.message}`, types_StageErrorCodes.AUTOMATE_IMPLEMENTATION_FAILED, 'automate', {
|
|
8382
|
-
input,
|
|
8383
|
-
error: error.message
|
|
8384
|
-
});
|
|
8385
|
-
}
|
|
8386
|
-
}
|
|
8387
|
-
async implementTasks(tasks, implementationDir, input) {
|
|
8388
|
-
const progress = [];
|
|
8389
|
-
for (const task of tasks){
|
|
8390
|
-
logger_logger.info(`\u{5F00}\u{59CB}\u{5B9E}\u{65BD}\u{4EFB}\u{52A1}: ${task.name}`);
|
|
8391
|
-
try {
|
|
8392
|
-
const taskDir = external_path_namespaceObject.join(implementationDir, task.id);
|
|
8393
|
-
if (!external_fs_namespaceObject.existsSync(taskDir)) external_fs_namespaceObject.mkdirSync(taskDir, {
|
|
8394
|
-
recursive: true
|
|
8395
|
-
});
|
|
8396
|
-
const codeFiles = await this.generateCodeFiles(task, taskDir);
|
|
8397
|
-
const testFiles = input.include_tests ? await this.generateTestFiles(task, taskDir) : [];
|
|
8398
|
-
const documentationFiles = input.include_docs ? await this.generateDocumentation(task, taskDir) : [];
|
|
8399
|
-
progress.push({
|
|
8400
|
-
task_id: task.id,
|
|
8401
|
-
status: "completed",
|
|
8402
|
-
code_files: codeFiles,
|
|
8403
|
-
test_files: testFiles,
|
|
8404
|
-
documentation: documentationFiles
|
|
8405
|
-
});
|
|
8406
|
-
logger_logger.info(`\u{4EFB}\u{52A1} ${task.name} \u{5B9E}\u{65BD}\u{5B8C}\u{6210}`);
|
|
8407
|
-
} catch (error) {
|
|
8408
|
-
logger_logger.error(`\u{4EFB}\u{52A1} ${task.name} \u{5B9E}\u{65BD}\u{5931}\u{8D25}`, error);
|
|
8409
|
-
progress.push({
|
|
8410
|
-
task_id: task.id,
|
|
8411
|
-
status: "failed",
|
|
8412
|
-
code_files: [],
|
|
8413
|
-
test_files: [],
|
|
8414
|
-
documentation: [],
|
|
8415
|
-
error: error.message
|
|
8416
|
-
});
|
|
8417
|
-
}
|
|
8418
|
-
}
|
|
8419
|
-
return progress;
|
|
8420
|
-
}
|
|
8421
|
-
async generateCodeFiles(task, taskDir) {
|
|
8422
|
-
const prompt = `
|
|
8423
|
-
\u{4F5C}\u{4E3A}\u{6267}\u{884C}\u{5B9E}\u{65BD}\u{667A}\u{80FD}\u{4F53}\u{FF0C}\u{4E3A}\u{4EE5}\u{4E0B}\u{4EFB}\u{52A1}\u{751F}\u{6210}\u{9AD8}\u{8D28}\u{91CF}\u{7684}\u{4EE3}\u{7801}\u{FF1A}
|
|
8424
|
-
|
|
8425
|
-
\u{4EFB}\u{52A1}\u{4FE1}\u{606F}\u{FF1A}
|
|
8426
|
-
${JSON.stringify(task, null, 2)}
|
|
8427
|
-
|
|
8428
|
-
\u{8981}\u{6C42}\u{FF1A}
|
|
8429
|
-
1. \u{4E25}\u{683C}\u{9075}\u{5FAA}\u{9879}\u{76EE}\u{73B0}\u{6709}\u{4EE3}\u{7801}\u{89C4}\u{8303}
|
|
8430
|
-
2. \u{4FDD}\u{6301}\u{4E0E}\u{73B0}\u{6709}\u{4EE3}\u{7801}\u{98CE}\u{683C}\u{4E00}\u{81F4}
|
|
8431
|
-
3. \u{4F7F}\u{7528}\u{9879}\u{76EE}\u{73B0}\u{6709}\u{7684}\u{5DE5}\u{5177}\u{548C}\u{5E93}
|
|
8432
|
-
4. \u{590D}\u{7528}\u{9879}\u{76EE}\u{73B0}\u{6709}\u{7EC4}\u{4EF6}
|
|
8433
|
-
5. \u{4EE3}\u{7801}\u{5C3D}\u{91CF}\u{7CBE}\u{7B80}\u{6613}\u{8BFB}
|
|
8434
|
-
6. \u{5305}\u{542B}\u{5FC5}\u{8981}\u{7684}\u{9519}\u{8BEF}\u{5904}\u{7406}
|
|
8435
|
-
7. \u{6DFB}\u{52A0}\u{9002}\u{5F53}\u{7684}\u{6CE8}\u{91CA}
|
|
8436
|
-
|
|
8437
|
-
\u{8BF7}\u{751F}\u{6210}\u{4EE3}\u{7801}\u{6587}\u{4EF6}\u{FF0C}\u{8F93}\u{51FA}\u{683C}\u{5F0F}\u{4E3A}JSON\u{FF1A}
|
|
8438
|
-
{
|
|
8439
|
-
"files": [
|
|
8440
|
-
{
|
|
8441
|
-
"filename": "\u{6587}\u{4EF6}\u{540D}.ts",
|
|
8442
|
-
"content": "\u{6587}\u{4EF6}\u{5185}\u{5BB9}",
|
|
8443
|
-
"description": "\u{6587}\u{4EF6}\u{8BF4}\u{660E}"
|
|
8444
|
-
}
|
|
8445
|
-
]
|
|
8446
|
-
}
|
|
8447
|
-
`;
|
|
8448
|
-
try {
|
|
8449
|
-
const response = await callOpenAI([
|
|
8450
|
-
{
|
|
8451
|
-
role: 'system',
|
|
8452
|
-
content: "\u4F60\u662F\u9AD8\u7EA7\u8F6F\u4EF6\u5DE5\u7A0B\u5E08\uFF0C\u4E13\u6CE8\u4E8E\u751F\u6210\u9AD8\u8D28\u91CF\u3001\u53EF\u7EF4\u62A4\u7684\u4EE3\u7801\u3002"
|
|
8453
|
-
},
|
|
8454
|
-
{
|
|
8455
|
-
role: 'user',
|
|
8456
|
-
content: prompt
|
|
8457
|
-
}
|
|
8458
|
-
]);
|
|
8459
|
-
const result = JSON.parse(response);
|
|
8460
|
-
const codeFiles = [];
|
|
8461
|
-
for (const file of result.files){
|
|
8462
|
-
const filePath = external_path_namespaceObject.join(taskDir, file.filename);
|
|
8463
|
-
external_fs_namespaceObject.writeFileSync(filePath, file.content);
|
|
8464
|
-
codeFiles.push(filePath);
|
|
8465
|
-
}
|
|
8466
|
-
return codeFiles;
|
|
8467
|
-
} catch (error) {
|
|
8468
|
-
logger_logger.error("\u4EE3\u7801\u751F\u6210\u5931\u8D25", error);
|
|
8469
|
-
return [];
|
|
8470
|
-
}
|
|
8471
|
-
}
|
|
8472
|
-
async generateTestFiles(task, taskDir) {
|
|
8473
|
-
const prompt = `
|
|
8474
|
-
\u{4E3A}\u{4EE5}\u{4E0B}\u{4EFB}\u{52A1}\u{751F}\u{6210}\u{5168}\u{9762}\u{7684}\u{6D4B}\u{8BD5}\u{7528}\u{4F8B}\u{FF1A}
|
|
8475
|
-
|
|
8476
|
-
\u{4EFB}\u{52A1}\u{4FE1}\u{606F}\u{FF1A}
|
|
8477
|
-
${JSON.stringify(task, null, 2)}
|
|
8478
|
-
|
|
8479
|
-
\u{6D4B}\u{8BD5}\u{8981}\u{6C42}\u{FF1A}
|
|
8480
|
-
1. \u{8986}\u{76D6}\u{6B63}\u{5E38}\u{6D41}\u{7A0B}
|
|
8481
|
-
2. \u{8986}\u{76D6}\u{8FB9}\u{754C}\u{6761}\u{4EF6}
|
|
8482
|
-
3. \u{8986}\u{76D6}\u{5F02}\u{5E38}\u{60C5}\u{51B5}
|
|
8483
|
-
4. \u{4F7F}\u{7528}\u{9879}\u{76EE}\u{7684}\u{6D4B}\u{8BD5}\u{6846}\u{67B6}(vitest)
|
|
8484
|
-
5. \u{6D4B}\u{8BD5}\u{7528}\u{4F8B}\u{6E05}\u{6670}\u{6613}\u{7406}\u{89E3}
|
|
8485
|
-
|
|
8486
|
-
\u{8F93}\u{51FA}\u{683C}\u{5F0F}\u{4E3A}JSON\u{FF1A}
|
|
8487
|
-
{
|
|
8488
|
-
"files": [
|
|
8489
|
-
{
|
|
8490
|
-
"filename": "\u{6587}\u{4EF6}\u{540D}.test.ts",
|
|
8491
|
-
"content": "\u{6D4B}\u{8BD5}\u{6587}\u{4EF6}\u{5185}\u{5BB9}",
|
|
8492
|
-
"description": "\u{6D4B}\u{8BD5}\u{8BF4}\u{660E}"
|
|
8493
|
-
}
|
|
8494
|
-
]
|
|
8495
|
-
}
|
|
8496
|
-
`;
|
|
8497
|
-
try {
|
|
8498
|
-
const response = await callOpenAI([
|
|
8499
|
-
{
|
|
8500
|
-
role: 'system',
|
|
8501
|
-
content: "\u4F60\u662F\u6D4B\u8BD5\u5DE5\u7A0B\u5E08\uFF0C\u4E13\u6CE8\u4E8E\u7F16\u5199\u5168\u9762\u3001\u53EF\u9760\u7684\u6D4B\u8BD5\u7528\u4F8B\u3002"
|
|
8502
|
-
},
|
|
8503
|
-
{
|
|
8504
|
-
role: 'user',
|
|
8505
|
-
content: prompt
|
|
8506
|
-
}
|
|
8507
|
-
]);
|
|
8508
|
-
const result = JSON.parse(response);
|
|
8509
|
-
const testFiles = [];
|
|
8510
|
-
for (const file of result.files){
|
|
8511
|
-
const filePath = external_path_namespaceObject.join(taskDir, file.filename);
|
|
8512
|
-
external_fs_namespaceObject.writeFileSync(filePath, file.content);
|
|
8513
|
-
testFiles.push(filePath);
|
|
8514
|
-
}
|
|
8515
|
-
return testFiles;
|
|
8516
|
-
} catch (error) {
|
|
8517
|
-
logger_logger.error("\u6D4B\u8BD5\u751F\u6210\u5931\u8D25", error);
|
|
8518
|
-
return [];
|
|
8519
|
-
}
|
|
8520
|
-
}
|
|
8521
|
-
async generateDocumentation(task, taskDir) {
|
|
8522
|
-
const prompt = `
|
|
8523
|
-
\u{4E3A}\u{4EE5}\u{4E0B}\u{4EFB}\u{52A1}\u{751F}\u{6210}\u{6280}\u{672F}\u{6587}\u{6863}\u{FF1A}
|
|
8524
|
-
|
|
8525
|
-
\u{4EFB}\u{52A1}\u{4FE1}\u{606F}\u{FF1A}
|
|
8526
|
-
${JSON.stringify(task, null, 2)}
|
|
8527
|
-
|
|
8528
|
-
\u{6587}\u{6863}\u{8981}\u{6C42}\u{FF1A}
|
|
8529
|
-
1. API\u{8BF4}\u{660E}\u{6587}\u{6863}
|
|
8530
|
-
2. \u{4F7F}\u{7528}\u{793A}\u{4F8B}
|
|
8531
|
-
3. \u{6CE8}\u{610F}\u{4E8B}\u{9879}
|
|
8532
|
-
4. \u{6545}\u{969C}\u{6392}\u{9664}
|
|
8533
|
-
|
|
8534
|
-
\u{8F93}\u{51FA}\u{683C}\u{5F0F}\u{4E3A}JSON\u{FF1A}
|
|
8535
|
-
{
|
|
8536
|
-
"files": [
|
|
8537
|
-
{
|
|
8538
|
-
"filename": "README.md",
|
|
8539
|
-
"content": "\u{6587}\u{6863}\u{5185}\u{5BB9}",
|
|
8540
|
-
"description": "\u{6587}\u{6863}\u{8BF4}\u{660E}"
|
|
8541
|
-
}
|
|
8542
|
-
]
|
|
8543
|
-
}
|
|
8544
|
-
`;
|
|
8545
|
-
try {
|
|
8546
|
-
const response = await callOpenAI([
|
|
8547
|
-
{
|
|
8548
|
-
role: 'system',
|
|
8549
|
-
content: "\u4F60\u662F\u6280\u672F\u6587\u6863\u5DE5\u7A0B\u5E08\uFF0C\u4E13\u6CE8\u4E8E\u7F16\u5199\u6E05\u6670\u3001\u5B9E\u7528\u7684\u6280\u672F\u6587\u6863\u3002"
|
|
8550
|
-
},
|
|
8551
|
-
{
|
|
8552
|
-
role: 'user',
|
|
8553
|
-
content: prompt
|
|
8554
|
-
}
|
|
8555
|
-
]);
|
|
8556
|
-
const result = JSON.parse(response);
|
|
8557
|
-
const docFiles = [];
|
|
8558
|
-
for (const file of result.files){
|
|
8559
|
-
const filePath = external_path_namespaceObject.join(taskDir, file.filename);
|
|
8560
|
-
external_fs_namespaceObject.writeFileSync(filePath, file.content);
|
|
8561
|
-
docFiles.push(filePath);
|
|
8562
|
-
}
|
|
8563
|
-
return docFiles;
|
|
8564
|
-
} catch (error) {
|
|
8565
|
-
logger_logger.error("\u6587\u6863\u751F\u6210\u5931\u8D25", error);
|
|
8566
|
-
return [];
|
|
8567
|
-
}
|
|
8568
|
-
}
|
|
8569
|
-
async assessCodeQuality(implementationProgress) {
|
|
8570
|
-
const completedTasks = implementationProgress.filter((p)=>'completed' === p.status);
|
|
8571
|
-
const failedTasks = implementationProgress.filter((p)=>'failed' === p.status);
|
|
8572
|
-
const totalCodeFiles = completedTasks.reduce((sum, task)=>sum + task.code_files.length, 0);
|
|
8573
|
-
const totalTestFiles = completedTasks.reduce((sum, task)=>sum + task.test_files.length, 0);
|
|
8574
|
-
const coverage = totalTestFiles > 0 ? Math.min(100, totalTestFiles / totalCodeFiles * 100) : 0;
|
|
8575
|
-
const successRate = completedTasks.length / implementationProgress.length;
|
|
8576
|
-
return {
|
|
8577
|
-
coverage: Math.round(coverage),
|
|
8578
|
-
complexity: failedTasks.length > 0 ? "\u9AD8" : completedTasks.length > 5 ? "\u4E2D\u7B49" : "\u7B80\u5355",
|
|
8579
|
-
standards_compliance: successRate >= 0.8,
|
|
8580
|
-
success_rate: successRate,
|
|
8581
|
-
total_files: totalCodeFiles + totalTestFiles,
|
|
8582
|
-
failed_tasks: failedTasks.length
|
|
8583
|
-
};
|
|
8584
|
-
}
|
|
8585
|
-
async generateExecutionDocument(implementationProgress, qualityMetrics) {
|
|
8586
|
-
return `# \u{5B9E}\u{65BD}\u{6267}\u{884C}\u{62A5}\u{544A}
|
|
8587
|
-
|
|
8588
|
-
## \u{6267}\u{884C}\u{6982}\u{89C8}
|
|
8589
|
-
|
|
8590
|
-
- **\u{603B}\u{4EFB}\u{52A1}\u{6570}**: ${implementationProgress.length}
|
|
8591
|
-
- **\u{5B8C}\u{6210}\u{4EFB}\u{52A1}**: ${implementationProgress.filter((p)=>'completed' === p.status).length}
|
|
8592
|
-
- **\u{5931}\u{8D25}\u{4EFB}\u{52A1}**: ${implementationProgress.filter((p)=>'failed' === p.status).length}
|
|
8593
|
-
- **\u{6210}\u{529F}\u{7387}**: ${(100 * qualityMetrics.success_rate).toFixed(1)}%
|
|
8594
|
-
|
|
8595
|
-
## \u{4EFB}\u{52A1}\u{6267}\u{884C}\u{8BE6}\u{60C5}
|
|
8596
|
-
|
|
8597
|
-
${implementationProgress.map((progress, index)=>`### ${progress.task_id}
|
|
8598
|
-
- **\u{72B6}\u{6001}**: ${'completed' === progress.status ? "\u2705 \u5B8C\u6210" : 'failed' === progress.status ? "\u274C \u5931\u8D25" : "\u23F3 \u8FDB\u884C\u4E2D"}
|
|
8599
|
-
- **\u{4EE3}\u{7801}\u{6587}\u{4EF6}**: ${progress.code_files.length}\u{4E2A}
|
|
8600
|
-
- **\u{6D4B}\u{8BD5}\u{6587}\u{4EF6}**: ${progress.test_files.length}\u{4E2A}
|
|
8601
|
-
- **\u{6587}\u{6863}\u{6587}\u{4EF6}**: ${progress.documentation.length}\u{4E2A}
|
|
8602
|
-
${'failed' === progress.status ? `- **\u{9519}\u{8BEF}\u{4FE1}\u{606F}**: ${progress.error || "\u672A\u77E5\u9519\u8BEF"}` : ''}
|
|
8603
|
-
|
|
8604
|
-
#### \u{751F}\u{6210}\u{7684}\u{6587}\u{4EF6}
|
|
8605
|
-
${progress.code_files.map((file)=>`- \u{1F4DD} ${external_path_namespaceObject.basename(file)}`).join('\n')}
|
|
8606
|
-
${progress.test_files.map((file)=>`- \u{1F9EA} ${external_path_namespaceObject.basename(file)}`).join('\n')}
|
|
8607
|
-
${progress.documentation.map((file)=>`- \u{1F4DA} ${external_path_namespaceObject.basename(file)}`).join('\n')}
|
|
8608
|
-
|
|
8609
|
-
---
|
|
8610
|
-
`).join('\n')}
|
|
8611
|
-
|
|
8612
|
-
## \u{4EE3}\u{7801}\u{8D28}\u{91CF}\u{6307}\u{6807}
|
|
8613
|
-
|
|
8614
|
-
### \u{6D4B}\u{8BD5}\u{8986}\u{76D6}\u{7387}
|
|
8615
|
-
${qualityMetrics.coverage}%
|
|
8616
|
-
|
|
8617
|
-
### \u{590D}\u{6742}\u{5EA6}\u{8BC4}\u{4F30}
|
|
8618
|
-
${qualityMetrics.complexity}
|
|
8619
|
-
|
|
8620
|
-
### \u{89C4}\u{8303}\u{5408}\u{89C4}\u{6027}
|
|
8621
|
-
${qualityMetrics.standards_compliance ? "\u2705 \u7B26\u5408\u89C4\u8303" : "\u274C \u9700\u8981\u6539\u8FDB"}
|
|
8622
|
-
|
|
8623
|
-
### \u{8BE6}\u{7EC6}\u{6307}\u{6807}
|
|
8624
|
-
- **\u{603B}\u{6587}\u{4EF6}\u{6570}**: ${qualityMetrics.total_files}
|
|
8625
|
-
- **\u{5931}\u{8D25}\u{4EFB}\u{52A1}\u{6570}**: ${qualityMetrics.failed_tasks}
|
|
8626
|
-
- **\u{6210}\u{529F}\u{7387}**: ${(100 * qualityMetrics.success_rate).toFixed(1)}%
|
|
8627
|
-
|
|
8628
|
-
## \u{8D28}\u{91CF}\u{5EFA}\u{8BAE}
|
|
8629
|
-
|
|
8630
|
-
${qualityMetrics.coverage < 80 ? "- \u26A0\uFE0F \u5EFA\u8BAE\u589E\u52A0\u6D4B\u8BD5\u8986\u76D6\u7387" : "- \u2705 \u6D4B\u8BD5\u8986\u76D6\u7387\u826F\u597D"}
|
|
8631
|
-
${qualityMetrics.failed_tasks > 0 ? "- \u26A0\uFE0F \u9700\u8981\u4FEE\u590D\u5931\u8D25\u7684\u4EFB\u52A1" : "- \u2705 \u6240\u6709\u4EFB\u52A1\u6267\u884C\u6210\u529F"}
|
|
8632
|
-
${qualityMetrics.standards_compliance ? "- \u2705 \u4EE3\u7801\u89C4\u8303\u7B26\u5408\u8981\u6C42" : "- \u26A0\uFE0F \u9700\u8981\u6539\u8FDB\u4EE3\u7801\u89C4\u8303"}
|
|
8633
|
-
|
|
8634
|
-
## \u{751F}\u{6210}\u{65F6}\u{95F4}
|
|
8635
|
-
${new Date().toISOString()}
|
|
8636
|
-
`;
|
|
8637
|
-
}
|
|
8638
|
-
extractFeatureName(workspaceDir) {
|
|
8639
|
-
return external_path_namespaceObject.basename(workspaceDir);
|
|
8640
|
-
}
|
|
8641
|
-
}
|
|
8642
|
-
class AssessAgent {
|
|
8643
|
-
async execute(input) {
|
|
8644
|
-
logger_logger.info("\u8D28\u91CF\u8BC4\u4F30\u667A\u80FD\u4F53\u5F00\u59CB\u6267\u884C");
|
|
8645
|
-
try {
|
|
8646
|
-
const executionValidation = await this.validateExecution(input.all_previous_outputs);
|
|
8647
|
-
const qualityAssessment = await this.assessQuality(input.all_previous_outputs, input.workspace_dir);
|
|
8648
|
-
const deliverables = await this.generateDeliverables(input.workspace_dir);
|
|
8649
|
-
const todoItems = await this.generateTodoItems(qualityAssessment, executionValidation);
|
|
8650
|
-
const finalReport = await this.generateFinalReport(qualityAssessment, deliverables, todoItems);
|
|
8651
|
-
const projectSummary = await this.generateProjectSummary(input.all_previous_outputs);
|
|
8652
|
-
const featureName = this.extractFeatureName(input.workspace_dir);
|
|
8653
|
-
const projectRoot = process.cwd();
|
|
8654
|
-
const aicoDocsDir = external_path_namespaceObject.join(projectRoot, '.aico', 'docs', featureName);
|
|
8655
|
-
if (!external_fs_namespaceObject.existsSync(aicoDocsDir)) external_fs_namespaceObject.mkdirSync(aicoDocsDir, {
|
|
8656
|
-
recursive: true
|
|
8657
|
-
});
|
|
8658
|
-
const acceptancePath = external_path_namespaceObject.join(aicoDocsDir, `ACCEPTANCE_${featureName}.md`);
|
|
8659
|
-
const finalPath = external_path_namespaceObject.join(aicoDocsDir, `FINAL_${featureName}.md`);
|
|
8660
|
-
const todoPath = external_path_namespaceObject.join(aicoDocsDir, `TODO_${featureName}.md`);
|
|
8661
|
-
const acceptanceDoc = await this.generateAcceptanceDocument(qualityAssessment, executionValidation);
|
|
8662
|
-
const todoDoc = await this.generateTodoDocument(todoItems);
|
|
8663
|
-
external_fs_namespaceObject.writeFileSync(acceptancePath, acceptanceDoc);
|
|
8664
|
-
external_fs_namespaceObject.writeFileSync(finalPath, finalReport);
|
|
8665
|
-
external_fs_namespaceObject.writeFileSync(todoPath, todoDoc);
|
|
8666
|
-
logger_logger.info("\u8D28\u91CF\u8BC4\u4F30\u6587\u6863\u5DF2\u4FDD\u5B58", {
|
|
8667
|
-
acceptancePath,
|
|
8668
|
-
finalPath,
|
|
8669
|
-
todoPath
|
|
8670
|
-
});
|
|
8671
|
-
const result = {
|
|
8672
|
-
stage: "assess",
|
|
8673
|
-
quality_assessment: qualityAssessment,
|
|
8674
|
-
deliverables: deliverables,
|
|
8675
|
-
todo_items: todoItems,
|
|
8676
|
-
final_report: finalReport,
|
|
8677
|
-
project_summary: projectSummary,
|
|
8678
|
-
human_confirmation_required: true
|
|
8679
|
-
};
|
|
8680
|
-
logger_logger.info("\u8D28\u91CF\u8BC4\u4F30\u667A\u80FD\u4F53\u6267\u884C\u5B8C\u6210");
|
|
8681
|
-
return result;
|
|
8682
|
-
} catch (error) {
|
|
8683
|
-
logger_logger.error("\u8D28\u91CF\u8BC4\u4F30\u667A\u80FD\u4F53\u6267\u884C\u5931\u8D25", error);
|
|
8684
|
-
throw new RequirementHandlerError(`\u{8D28}\u{91CF}\u{8BC4}\u{4F30}\u{9636}\u{6BB5}\u{5931}\u{8D25}: ${error.message}`, types_StageErrorCodes.ASSESS_QUALITY_EVALUATION_FAILED, 'assess', {
|
|
8685
|
-
input,
|
|
8686
|
-
error: error.message
|
|
8687
|
-
});
|
|
8688
|
-
}
|
|
8689
|
-
}
|
|
8690
|
-
async validateExecution(allOutputs) {
|
|
8691
|
-
const executionResult = allOutputs.find((r)=>'automate' === r.stage);
|
|
8692
|
-
const alignResult = allOutputs.find((r)=>'align' === r.stage);
|
|
8693
|
-
if (!executionResult || !alignResult) throw new Error("\u7F3A\u5C11\u5FC5\u8981\u7684\u9636\u6BB5\u8F93\u51FA");
|
|
8694
|
-
const prompt = `
|
|
8695
|
-
\u{4F5C}\u{4E3A}\u{8D28}\u{91CF}\u{8BC4}\u{4F30}\u{667A}\u{80FD}\u{4F53}\u{FF0C}\u{9A8C}\u{8BC1}\u{6267}\u{884C}\u{7ED3}\u{679C}\u{662F}\u{5426}\u{6EE1}\u{8DB3}\u{539F}\u{59CB}\u{9700}\u{6C42}\u{FF1A}
|
|
8696
|
-
|
|
8697
|
-
\u{539F}\u{59CB}\u{9700}\u{6C42}\u{548C}\u{9A8C}\u{6536}\u{6807}\u{51C6}\u{FF1A}
|
|
8698
|
-
${JSON.stringify(alignResult, null, 2)}
|
|
8699
|
-
|
|
8700
|
-
\u{6267}\u{884C}\u{7ED3}\u{679C}\u{FF1A}
|
|
8701
|
-
${JSON.stringify(executionResult, null, 2)}
|
|
8702
|
-
|
|
8703
|
-
\u{8BF7}\u{9A8C}\u{8BC1}\u{FF1A}
|
|
8704
|
-
1. \u{6240}\u{6709}\u{9700}\u{6C42}\u{662F}\u{5426}\u{5DF2}\u{5B9E}\u{73B0}
|
|
8705
|
-
2. \u{9A8C}\u{6536}\u{6807}\u{51C6}\u{662F}\u{5426}\u{5168}\u{90E8}\u{6EE1}\u{8DB3}
|
|
8706
|
-
3. \u{9879}\u{76EE}\u{662F}\u{5426}\u{53EF}\u{4EE5}\u{7F16}\u{8BD1}\u{901A}\u{8FC7}
|
|
8707
|
-
4. \u{6240}\u{6709}\u{6D4B}\u{8BD5}\u{662F}\u{5426}\u{901A}\u{8FC7}
|
|
8708
|
-
5. \u{529F}\u{80FD}\u{5B8C}\u{6574}\u{6027}\u{9A8C}\u{8BC1}
|
|
8709
|
-
6. \u{5B9E}\u{73B0}\u{4E0E}\u{8BBE}\u{8BA1}\u{6587}\u{6863}\u{662F}\u{5426}\u{4E00}\u{81F4}
|
|
8710
|
-
|
|
8711
|
-
\u{8F93}\u{51FA}\u{683C}\u{5F0F}\u{4E3A}JSON\u{FF1A}
|
|
8712
|
-
{
|
|
8713
|
-
"requirements_met": true,
|
|
8714
|
-
"acceptance_criteria_status": [
|
|
8715
|
-
{
|
|
8716
|
-
"criteria": "\u{9A8C}\u{6536}\u{6807}\u{51C6}1",
|
|
8717
|
-
"met": true,
|
|
8718
|
-
"evidence": "\u{6EE1}\u{8DB3}\u{4F9D}\u{636E}"
|
|
8719
|
-
}
|
|
8720
|
-
],
|
|
8721
|
-
"compilation_status": "success|warning|error",
|
|
8722
|
-
"test_status": "all_passed|some_failed|no_tests",
|
|
8723
|
-
"functionality_validation": {
|
|
8724
|
-
"core_features": "\u{5B8C}\u{6574}|\u{90E8}\u{5206}|\u{7F3A}\u{5931}",
|
|
8725
|
-
"edge_cases": "\u{8986}\u{76D6}|\u{90E8}\u{5206}\u{8986}\u{76D6}|\u{672A}\u{8986}\u{76D6}",
|
|
8726
|
-
"error_handling": "\u{5B8C}\u{5584}|\u{57FA}\u{672C}|\u{4E0D}\u{8DB3}"
|
|
8727
|
-
},
|
|
8728
|
-
"design_consistency": true,
|
|
8729
|
-
"overall_validation": "\u{901A}\u{8FC7}|\u{6709}\u{95EE}\u{9898}|\u{5931}\u{8D25}"
|
|
8730
|
-
}
|
|
8731
|
-
`;
|
|
8732
|
-
const response = await callOpenAI([
|
|
8733
|
-
{
|
|
8734
|
-
role: 'system',
|
|
8735
|
-
content: "\u4F60\u662F\u9A8C\u6536\u6D4B\u8BD5\u4E13\u5BB6\uFF0C\u4E13\u6CE8\u4E8E\u9A8C\u8BC1\u9879\u76EE\u4EA4\u4ED8\u7269\u662F\u5426\u6EE1\u8DB3\u9700\u6C42\u3002"
|
|
8736
|
-
},
|
|
8737
|
-
{
|
|
8738
|
-
role: 'user',
|
|
8739
|
-
content: prompt
|
|
8740
|
-
}
|
|
8741
|
-
]);
|
|
8742
|
-
return JSON.parse(response);
|
|
8743
|
-
}
|
|
8744
|
-
async assessQuality(allOutputs, workspaceDir) {
|
|
8745
|
-
const files = this.collectAllFiles(workspaceDir);
|
|
8746
|
-
const prompt = `
|
|
8747
|
-
\u{7EFC}\u{5408}\u{8BC4}\u{4F30}\u{9879}\u{76EE}\u{8D28}\u{91CF}\u{FF1A}
|
|
8748
|
-
|
|
8749
|
-
\u{6240}\u{6709}\u{9636}\u{6BB5}\u{8F93}\u{51FA}\u{FF1A}
|
|
8750
|
-
${JSON.stringify(allOutputs, null, 2)}
|
|
8751
|
-
|
|
8752
|
-
\u{751F}\u{6210}\u{7684}\u{6587}\u{4EF6}\u{FF1A}
|
|
8753
|
-
${JSON.stringify(files, null, 2)}
|
|
8754
|
-
|
|
8755
|
-
\u{8BF7}\u{4ECE}\u{4EE5}\u{4E0B}\u{7EF4}\u{5EA6}\u{8BC4}\u{4F30}\u{8D28}\u{91CF}\u{FF1A}
|
|
8756
|
-
|
|
8757
|
-
1. \u{4EE3}\u{7801}\u{8D28}\u{91CF}
|
|
8758
|
-
- \u{4EE3}\u{7801}\u{89C4}\u{8303}\u{6027}
|
|
8759
|
-
- \u{53EF}\u{8BFB}\u{6027}
|
|
8760
|
-
- \u{590D}\u{6742}\u{5EA6}
|
|
8761
|
-
- \u{9519}\u{8BEF}\u{5904}\u{7406}
|
|
8762
|
-
|
|
8763
|
-
2. \u{6D4B}\u{8BD5}\u{8D28}\u{91CF}
|
|
8764
|
-
- \u{6D4B}\u{8BD5}\u{8986}\u{76D6}\u{7387}
|
|
8765
|
-
- \u{6D4B}\u{8BD5}\u{7528}\u{4F8B}\u{8D28}\u{91CF}
|
|
8766
|
-
- \u{8FB9}\u{754C}\u{6761}\u{4EF6}\u{8986}\u{76D6}
|
|
8767
|
-
|
|
8768
|
-
3. \u{6587}\u{6863}\u{8D28}\u{91CF}
|
|
8769
|
-
- \u{6587}\u{6863}\u{5B8C}\u{6574}\u{6027}
|
|
8770
|
-
- \u{6587}\u{6863}\u{51C6}\u{786E}\u{6027}
|
|
8771
|
-
- \u{6587}\u{6863}\u{4E00}\u{81F4}\u{6027}
|
|
8772
|
-
|
|
8773
|
-
4. \u{67B6}\u{6784}\u{8D28}\u{91CF}
|
|
8774
|
-
- \u{6A21}\u{5757}\u{5316}\u{7A0B}\u{5EA6}
|
|
8775
|
-
- \u{53EF}\u{7EF4}\u{62A4}\u{6027}
|
|
8776
|
-
- \u{53EF}\u{6269}\u{5C55}\u{6027}
|
|
8777
|
-
|
|
8778
|
-
\u{8F93}\u{51FA}\u{683C}\u{5F0F}\u{4E3A}JSON\u{FF1A}
|
|
8779
|
-
{
|
|
8780
|
-
"code_quality": "excellent|good|acceptable|needs_improvement",
|
|
8781
|
-
"test_coverage": 85,
|
|
8782
|
-
"documentation_completeness": 90,
|
|
8783
|
-
"acceptance_criteria_met": true,
|
|
8784
|
-
"detailed_scores": {
|
|
8785
|
-
"code_standards": 90,
|
|
8786
|
-
"readability": 85,
|
|
8787
|
-
"complexity": 80,
|
|
8788
|
-
"error_handling": 75,
|
|
8789
|
-
"test_quality": 85,
|
|
8790
|
-
"doc_accuracy": 90,
|
|
8791
|
-
"modularity": 88
|
|
8792
|
-
},
|
|
8793
|
-
"strengths": ["\u{4F18}\u{70B9}1", "\u{4F18}\u{70B9}2"],
|
|
8794
|
-
"areas_for_improvement": ["\u{6539}\u{8FDB}\u{70B9}1", "\u{6539}\u{8FDB}\u{70B9}2"]
|
|
8795
|
-
}
|
|
8796
|
-
`;
|
|
8797
|
-
const response = await callOpenAI([
|
|
8798
|
-
{
|
|
8799
|
-
role: 'system',
|
|
8800
|
-
content: "\u4F60\u662F\u4EE3\u7801\u8D28\u91CF\u8BC4\u4F30\u4E13\u5BB6\uFF0C\u4E13\u6CE8\u4E8E\u5168\u9762\u8BC4\u4F30\u8F6F\u4EF6\u8D28\u91CF\u3002"
|
|
8801
|
-
},
|
|
8802
|
-
{
|
|
8803
|
-
role: 'user',
|
|
8804
|
-
content: prompt
|
|
8805
|
-
}
|
|
8806
|
-
]);
|
|
8807
|
-
return JSON.parse(response);
|
|
8808
|
-
}
|
|
8809
|
-
async generateDeliverables(workspaceDir) {
|
|
8810
|
-
const deliverables = [];
|
|
8811
|
-
try {
|
|
8812
|
-
if (external_fs_namespaceObject.existsSync(workspaceDir)) {
|
|
8813
|
-
const items = external_fs_namespaceObject.readdirSync(workspaceDir, {
|
|
8814
|
-
withFileTypes: true
|
|
8815
|
-
});
|
|
8816
|
-
for (const item of items)if (item.isFile()) deliverables.push(external_path_namespaceObject.join(workspaceDir, item.name));
|
|
8817
|
-
else if (item.isDirectory()) {
|
|
8818
|
-
const subFiles = this.collectAllFiles(external_path_namespaceObject.join(workspaceDir, item.name));
|
|
8819
|
-
deliverables.push(...subFiles.map((f)=>f.path));
|
|
8820
|
-
}
|
|
8821
|
-
}
|
|
8822
|
-
} catch (error) {
|
|
8823
|
-
logger_logger.warn("\u6536\u96C6\u4EA4\u4ED8\u7269\u65F6\u51FA\u9519", error);
|
|
8824
|
-
}
|
|
8825
|
-
return deliverables;
|
|
8826
|
-
}
|
|
8827
|
-
async generateTodoItems(qualityAssessment, executionValidation) {
|
|
8828
|
-
const prompt = `
|
|
8829
|
-
\u{57FA}\u{4E8E}\u{8D28}\u{91CF}\u{8BC4}\u{4F30}\u{548C}\u{6267}\u{884C}\u{9A8C}\u{8BC1}\u{7ED3}\u{679C}\u{FF0C}\u{751F}\u{6210}TODO\u{6E05}\u{5355}\u{FF1A}
|
|
8830
|
-
|
|
8831
|
-
\u{8D28}\u{91CF}\u{8BC4}\u{4F30}\u{FF1A}
|
|
8832
|
-
${JSON.stringify(qualityAssessment, null, 2)}
|
|
8833
|
-
|
|
8834
|
-
\u{6267}\u{884C}\u{9A8C}\u{8BC1}\u{FF1A}
|
|
8835
|
-
${JSON.stringify(executionValidation, null, 2)}
|
|
8836
|
-
|
|
8837
|
-
\u{8BF7}\u{751F}\u{6210}\u{5F85}\u{529E}\u{4E8B}\u{9879}\u{FF0C}\u{5305}\u{62EC}\u{FF1A}
|
|
8838
|
-
1. \u{4EE3}\u{7801}\u{6539}\u{8FDB}\u{4E8B}\u{9879}
|
|
8839
|
-
2. \u{914D}\u{7F6E}\u{5B8C}\u{5584}\u{4E8B}\u{9879}
|
|
8840
|
-
3. \u{6587}\u{6863}\u{8865}\u{5145}\u{4E8B}\u{9879}
|
|
8841
|
-
4. \u{6D4B}\u{8BD5}\u{589E}\u{5F3A}\u{4E8B}\u{9879}
|
|
8842
|
-
5. \u{90E8}\u{7F72}\u{51C6}\u{5907}\u{4E8B}\u{9879}
|
|
8843
|
-
|
|
8844
|
-
\u{8F93}\u{51FA}\u{683C}\u{5F0F}\u{4E3A}JSON\u{FF1A}
|
|
8845
|
-
{
|
|
8846
|
-
"items": [
|
|
8847
|
-
{
|
|
8848
|
-
"item": "\u{5F85}\u{529E}\u{4E8B}\u{9879}\u{63CF}\u{8FF0}",
|
|
8849
|
-
"priority": "high|medium|low",
|
|
8850
|
-
"category": "\u{4EE3}\u{7801}|\u{914D}\u{7F6E}|\u{6587}\u{6863}|\u{6D4B}\u{8BD5}|\u{90E8}\u{7F72}",
|
|
8851
|
-
"description": "\u{8BE6}\u{7EC6}\u{8BF4}\u{660E}",
|
|
8852
|
-
"estimated_effort": "\u{65F6}\u{95F4}\u{4F30}\u{7B97}"
|
|
8853
|
-
}
|
|
8854
|
-
]
|
|
8855
|
-
}
|
|
8856
|
-
`;
|
|
8857
|
-
const response = await callOpenAI([
|
|
8858
|
-
{
|
|
8859
|
-
role: 'system',
|
|
8860
|
-
content: "\u4F60\u662F\u9879\u76EE\u7BA1\u7406\u4E13\u5BB6\uFF0C\u4E13\u6CE8\u4E8E\u8BC6\u522B\u9879\u76EE\u5B8C\u5584\u673A\u4F1A\u3002"
|
|
8861
|
-
},
|
|
8862
|
-
{
|
|
8863
|
-
role: 'user',
|
|
8864
|
-
content: prompt
|
|
8865
|
-
}
|
|
8866
|
-
]);
|
|
8867
|
-
const result = JSON.parse(response);
|
|
8868
|
-
return result.items;
|
|
8869
|
-
}
|
|
8870
|
-
async generateFinalReport(qualityAssessment, deliverables, todoItems) {
|
|
8871
|
-
return `# \u{9879}\u{76EE}\u{6700}\u{7EC8}\u{62A5}\u{544A}
|
|
8872
|
-
|
|
8873
|
-
## \u{9879}\u{76EE}\u{6982}\u{51B5}
|
|
8874
|
-
|
|
8875
|
-
- **\u{4EA4}\u{4ED8}\u{7269}\u{6570}\u{91CF}**: ${deliverables.length}
|
|
8876
|
-
- **\u{8D28}\u{91CF}\u{7B49}\u{7EA7}**: ${qualityAssessment.code_quality}
|
|
8877
|
-
- **\u{6D4B}\u{8BD5}\u{8986}\u{76D6}\u{7387}**: ${qualityAssessment.test_coverage}%
|
|
8878
|
-
- **\u{6587}\u{6863}\u{5B8C}\u{6574}\u{5EA6}**: ${qualityAssessment.documentation_completeness}%
|
|
8879
|
-
- **\u{9A8C}\u{6536}\u{6807}\u{51C6}**: ${qualityAssessment.acceptance_criteria_met ? "\u2705 \u5DF2\u6EE1\u8DB3" : "\u274C \u672A\u6EE1\u8DB3"}
|
|
8880
|
-
|
|
8881
|
-
## \u{8D28}\u{91CF}\u{8BC4}\u{4F30}\u{8BE6}\u{60C5}
|
|
8882
|
-
|
|
8883
|
-
### \u{4EE3}\u{7801}\u{8D28}\u{91CF}
|
|
8884
|
-
- **\u{6574}\u{4F53}\u{8BC4}\u{7EA7}**: ${qualityAssessment.code_quality}
|
|
8885
|
-
- **\u{4EE3}\u{7801}\u{89C4}\u{8303}**: ${qualityAssessment.detailed_scores.code_standards}/100
|
|
8886
|
-
- **\u{53EF}\u{8BFB}\u{6027}**: ${qualityAssessment.detailed_scores.readability}/100
|
|
8887
|
-
- **\u{590D}\u{6742}\u{5EA6}**: ${qualityAssessment.detailed_scores.complexity}/100
|
|
8888
|
-
- **\u{9519}\u{8BEF}\u{5904}\u{7406}**: ${qualityAssessment.detailed_scores.error_handling}/100
|
|
8889
|
-
|
|
8890
|
-
### \u{6D4B}\u{8BD5}\u{8D28}\u{91CF}
|
|
8891
|
-
- **\u{6D4B}\u{8BD5}\u{8986}\u{76D6}\u{7387}**: ${qualityAssessment.test_coverage}%
|
|
8892
|
-
- **\u{6D4B}\u{8BD5}\u{8D28}\u{91CF}\u{5206}\u{6570}**: ${qualityAssessment.detailed_scores.test_quality}/100
|
|
8893
|
-
|
|
8894
|
-
### \u{6587}\u{6863}\u{8D28}\u{91CF}
|
|
8895
|
-
- **\u{6587}\u{6863}\u{5B8C}\u{6574}\u{5EA6}**: ${qualityAssessment.documentation_completeness}%
|
|
8896
|
-
- **\u{6587}\u{6863}\u{51C6}\u{786E}\u{6027}**: ${qualityAssessment.detailed_scores.doc_accuracy}/100
|
|
8897
|
-
|
|
8898
|
-
### \u{67B6}\u{6784}\u{8D28}\u{91CF}
|
|
8899
|
-
- **\u{6A21}\u{5757}\u{5316}\u{7A0B}\u{5EA6}**: ${qualityAssessment.detailed_scores.modularity}/100
|
|
8900
|
-
|
|
8901
|
-
## \u{9879}\u{76EE}\u{4F18}\u{52BF}
|
|
8902
|
-
|
|
8903
|
-
${qualityAssessment.strengths.map((strength)=>`- \u{2705} ${strength}`).join('\n')}
|
|
8904
|
-
|
|
8905
|
-
## \u{6539}\u{8FDB}\u{5EFA}\u{8BAE}
|
|
8906
|
-
|
|
8907
|
-
${qualityAssessment.areas_for_improvement.map((improvement)=>`- \u{1F4A1} ${improvement}`).join('\n')}
|
|
8908
|
-
|
|
8909
|
-
## \u{4EA4}\u{4ED8}\u{7269}\u{6E05}\u{5355}
|
|
8910
|
-
|
|
8911
|
-
${deliverables.map((file, index)=>`${index + 1}. ${external_path_namespaceObject.basename(file)}`).join('\n')}
|
|
8912
|
-
|
|
8913
|
-
## \u{5F85}\u{529E}\u{4E8B}\u{9879}\u{6982}\u{51B5}
|
|
8914
|
-
|
|
8915
|
-
- **\u{9AD8}\u{4F18}\u{5148}\u{7EA7}**: ${todoItems.filter((item)=>'high' === item.priority).length}\u{9879}
|
|
8916
|
-
- **\u{4E2D}\u{4F18}\u{5148}\u{7EA7}**: ${todoItems.filter((item)=>'medium' === item.priority).length}\u{9879}
|
|
8917
|
-
- **\u{4F4E}\u{4F18}\u{5148}\u{7EA7}**: ${todoItems.filter((item)=>'low' === item.priority).length}\u{9879}
|
|
8918
|
-
|
|
8919
|
-
## \u{9879}\u{76EE}\u{72B6}\u{6001}
|
|
8920
|
-
|
|
8921
|
-
### \u{603B}\u{4F53}\u{8BC4}\u{4EF7}
|
|
8922
|
-
${qualityAssessment.acceptance_criteria_met ? "\u2705 \u9879\u76EE\u5DF2\u6210\u529F\u5B8C\u6210\uFF0C\u6EE1\u8DB3\u6240\u6709\u9A8C\u6536\u6807\u51C6\uFF0C\u53EF\u4EE5\u4EA4\u4ED8\u4F7F\u7528\u3002" : "\u26A0\uFE0F \u9879\u76EE\u57FA\u672C\u5B8C\u6210\uFF0C\u4F46\u4ECD\u6709\u90E8\u5206\u9A8C\u6536\u6807\u51C6\u9700\u8981\u5B8C\u5584\u3002"}
|
|
8923
|
-
|
|
8924
|
-
### \u{5EFA}\u{8BAE}\u{4E0B}\u{4E00}\u{6B65}
|
|
8925
|
-
${'excellent' === qualityAssessment.code_quality ? "\u9879\u76EE\u8D28\u91CF\u4F18\u79C0\uFF0C\u53EF\u4EE5\u76F4\u63A5\u6295\u5165\u751F\u4EA7\u4F7F\u7528\u3002" : 'good' === qualityAssessment.code_quality ? "\u9879\u76EE\u8D28\u91CF\u826F\u597D\uFF0C\u5EFA\u8BAE\u5B8C\u6210\u9AD8\u4F18\u5148\u7EA7TODO\u9879\u540E\u6295\u5165\u4F7F\u7528\u3002" : "\u5EFA\u8BAE\u5148\u5B8C\u6210\u4EE3\u7801\u8D28\u91CF\u6539\u8FDB\u540E\u518D\u6295\u5165\u4F7F\u7528\u3002"}
|
|
8926
|
-
|
|
8927
|
-
## \u{751F}\u{6210}\u{65F6}\u{95F4}
|
|
8928
|
-
${new Date().toISOString()}
|
|
8929
|
-
`;
|
|
8930
|
-
}
|
|
8931
|
-
async generateProjectSummary(allOutputs) {
|
|
8932
|
-
return `\u{9879}\u{76EE}\u{5DF2}\u{901A}\u{8FC7}6A\u{5DE5}\u{4F5C}\u{6D41}\u{5B8C}\u{6210}\u{FF0C}\u{5305}\u{542B}${allOutputs.length}\u{4E2A}\u{6267}\u{884C}\u{9636}\u{6BB5}\u{FF0C}\u{5B9E}\u{73B0}\u{4E86}\u{4ECE}\u{9700}\u{6C42}\u{5206}\u{6790}\u{5230}\u{6700}\u{7EC8}\u{4EA4}\u{4ED8}\u{7684}\u{5B8C}\u{6574}\u{6D41}\u{7A0B}\u{3002}\u{9879}\u{76EE}\u{8D28}\u{91CF}\u{8BC4}\u{4F30}\u{663E}\u{793A}\u{5404}\u{9879}\u{6307}\u{6807}\u{5747}\u{8FBE}\u{5230}\u{9884}\u{671F}\u{6807}\u{51C6}\u{FF0C}\u{53EF}\u{4EE5}\u{6309}\u{8BA1}\u{5212}\u{4EA4}\u{4ED8}\u{4F7F}\u{7528}\u{3002}`;
|
|
8933
|
-
}
|
|
8934
|
-
async generateAcceptanceDocument(qualityAssessment, executionValidation) {
|
|
8935
|
-
return `# \u{9A8C}\u{6536}\u{62A5}\u{544A}
|
|
8936
|
-
|
|
8937
|
-
## \u{9A8C}\u{6536}\u{6982}\u{51B5}
|
|
8938
|
-
|
|
8939
|
-
- **\u{9A8C}\u{6536}\u{72B6}\u{6001}**: ${"\u901A\u8FC7" === executionValidation.overall_validation ? "\u2705 \u901A\u8FC7" : "\u26A0\uFE0F \u6709\u6761\u4EF6\u901A\u8FC7"}
|
|
8940
|
-
- **\u{9700}\u{6C42}\u{6EE1}\u{8DB3}\u{5EA6}**: ${executionValidation.requirements_met ? "\u2705 \u5B8C\u5168\u6EE1\u8DB3" : "\u274C \u90E8\u5206\u6EE1\u8DB3"}
|
|
8941
|
-
- **\u{7F16}\u{8BD1}\u{72B6}\u{6001}**: ${executionValidation.compilation_status}
|
|
8942
|
-
- **\u{6D4B}\u{8BD5}\u{72B6}\u{6001}**: ${executionValidation.test_status}
|
|
8943
|
-
|
|
8944
|
-
## \u{9A8C}\u{6536}\u{6807}\u{51C6}\u{68C0}\u{67E5}
|
|
8945
|
-
|
|
8946
|
-
${executionValidation.acceptance_criteria_status.map((criteria)=>`### ${criteria.criteria}
|
|
8947
|
-
- **\u{72B6}\u{6001}**: ${criteria.met ? "\u2705 \u6EE1\u8DB3" : "\u274C \u4E0D\u6EE1\u8DB3"}
|
|
8948
|
-
- **\u{4F9D}\u{636E}**: ${criteria.evidence}
|
|
8949
|
-
`).join('\n')}
|
|
8950
|
-
|
|
8951
|
-
## \u{529F}\u{80FD}\u{9A8C}\u{8BC1}
|
|
8952
|
-
|
|
8953
|
-
### \u{6838}\u{5FC3}\u{529F}\u{80FD}
|
|
8954
|
-
${executionValidation.functionality_validation.core_features}
|
|
8955
|
-
|
|
8956
|
-
### \u{8FB9}\u{754C}\u{6761}\u{4EF6}
|
|
8957
|
-
${executionValidation.functionality_validation.edge_cases}
|
|
8958
|
-
|
|
8959
|
-
### \u{9519}\u{8BEF}\u{5904}\u{7406}
|
|
8960
|
-
${executionValidation.functionality_validation.error_handling}
|
|
8961
|
-
|
|
8962
|
-
## \u{8BBE}\u{8BA1}\u{4E00}\u{81F4}\u{6027}
|
|
8963
|
-
${executionValidation.design_consistency ? "\u2705 \u4E0E\u8BBE\u8BA1\u6587\u6863\u4E00\u81F4" : "\u274C \u4E0E\u8BBE\u8BA1\u6587\u6863\u6709\u504F\u5DEE"}
|
|
8964
|
-
|
|
8965
|
-
## \u{9A8C}\u{6536}\u{7ED3}\u{8BBA}
|
|
8966
|
-
${"\u901A\u8FC7" === executionValidation.overall_validation ? "\u2705 \u9879\u76EE\u901A\u8FC7\u9A8C\u6536\uFF0C\u6EE1\u8DB3\u6240\u6709\u8981\u6C42\uFF0C\u53EF\u4EE5\u6B63\u5F0F\u4EA4\u4ED8\u3002" : "\u26A0\uFE0F \u9879\u76EE\u57FA\u672C\u7B26\u5408\u8981\u6C42\uFF0C\u4F46\u9700\u8981\u5B8C\u6210\u6807\u6CE8\u7684\u6539\u8FDB\u9879\u540E\u518D\u8FDB\u884C\u6700\u7EC8\u9A8C\u6536\u3002"}
|
|
8967
|
-
|
|
8968
|
-
## \u{751F}\u{6210}\u{65F6}\u{95F4}
|
|
8969
|
-
${new Date().toISOString()}
|
|
8970
|
-
`;
|
|
8971
|
-
}
|
|
8972
|
-
async generateTodoDocument(todoItems) {
|
|
8973
|
-
const highPriority = todoItems.filter((item)=>'high' === item.priority);
|
|
8974
|
-
const mediumPriority = todoItems.filter((item)=>'medium' === item.priority);
|
|
8975
|
-
const lowPriority = todoItems.filter((item)=>'low' === item.priority);
|
|
8976
|
-
return `# \u{5F85}\u{529E}\u{4E8B}\u{9879}\u{6E05}\u{5355}
|
|
8977
|
-
|
|
8978
|
-
## \u{6982}\u{51B5}
|
|
8979
|
-
- **\u{603B}\u{8BA1}**: ${todoItems.length}\u{9879}
|
|
8980
|
-
- **\u{9AD8}\u{4F18}\u{5148}\u{7EA7}**: ${highPriority.length}\u{9879}
|
|
8981
|
-
- **\u{4E2D}\u{4F18}\u{5148}\u{7EA7}**: ${mediumPriority.length}\u{9879}
|
|
8982
|
-
- **\u{4F4E}\u{4F18}\u{5148}\u{7EA7}**: ${lowPriority.length}\u{9879}
|
|
8983
|
-
|
|
8984
|
-
${highPriority.length > 0 ? `## \u{1F534} \u{9AD8}\u{4F18}\u{5148}\u{7EA7}\u{4E8B}\u{9879}
|
|
8985
|
-
|
|
8986
|
-
${highPriority.map((item, index)=>`### ${index + 1}. ${item.item}
|
|
8987
|
-
- **\u{7C7B}\u{522B}**: ${item.category}
|
|
8988
|
-
- **\u{8BF4}\u{660E}**: ${item.description}
|
|
8989
|
-
- **\u{9884}\u{4F30}\u{5DE5}\u{4F5C}\u{91CF}**: ${item.estimated_effort}
|
|
8990
|
-
|
|
8991
|
-
`).join('\n')}` : ''}
|
|
8992
|
-
|
|
8993
|
-
${mediumPriority.length > 0 ? `## \u{1F7E1} \u{4E2D}\u{4F18}\u{5148}\u{7EA7}\u{4E8B}\u{9879}
|
|
8994
|
-
|
|
8995
|
-
${mediumPriority.map((item, index)=>`### ${index + 1}. ${item.item}
|
|
8996
|
-
- **\u{7C7B}\u{522B}**: ${item.category}
|
|
8997
|
-
- **\u{8BF4}\u{660E}**: ${item.description}
|
|
8998
|
-
- **\u{9884}\u{4F30}\u{5DE5}\u{4F5C}\u{91CF}**: ${item.estimated_effort}
|
|
8999
|
-
|
|
9000
|
-
`).join('\n')}` : ''}
|
|
9001
|
-
|
|
9002
|
-
${lowPriority.length > 0 ? `## \u{1F7E2} \u{4F4E}\u{4F18}\u{5148}\u{7EA7}\u{4E8B}\u{9879}
|
|
9003
|
-
|
|
9004
|
-
${lowPriority.map((item, index)=>`### ${index + 1}. ${item.item}
|
|
9005
|
-
- **\u{7C7B}\u{522B}**: ${item.category}
|
|
9006
|
-
- **\u{8BF4}\u{660E}**: ${item.description}
|
|
9007
|
-
- **\u{9884}\u{4F30}\u{5DE5}\u{4F5C}\u{91CF}**: ${item.estimated_effort}
|
|
9008
|
-
|
|
9009
|
-
`).join('\n')}` : ''}
|
|
9010
|
-
|
|
9011
|
-
## \u{5EFA}\u{8BAE}\u{5904}\u{7406}\u{987A}\u{5E8F}
|
|
9012
|
-
|
|
9013
|
-
1. **\u{7ACB}\u{5373}\u{5904}\u{7406}**: \u{9AD8}\u{4F18}\u{5148}\u{7EA7}\u{7684}\u{4EE3}\u{7801}\u{548C}\u{914D}\u{7F6E}\u{7C7B}\u{4E8B}\u{9879}
|
|
9014
|
-
2. **\u{8FD1}\u{671F}\u{5904}\u{7406}**: \u{9AD8}\u{4F18}\u{5148}\u{7EA7}\u{7684}\u{6587}\u{6863}\u{548C}\u{6D4B}\u{8BD5}\u{7C7B}\u{4E8B}\u{9879}
|
|
9015
|
-
3. **\u{540E}\u{7EED}\u{5904}\u{7406}**: \u{4E2D}\u{4F18}\u{5148}\u{7EA7}\u{4E8B}\u{9879}
|
|
9016
|
-
4. **\u{6709}\u{65F6}\u{95F4}\u{65F6}\u{5904}\u{7406}**: \u{4F4E}\u{4F18}\u{5148}\u{7EA7}\u{4E8B}\u{9879}
|
|
9017
|
-
|
|
9018
|
-
## \u{751F}\u{6210}\u{65F6}\u{95F4}
|
|
9019
|
-
${new Date().toISOString()}
|
|
9020
|
-
`;
|
|
9021
|
-
}
|
|
9022
|
-
collectAllFiles(dir) {
|
|
9023
|
-
const files = [];
|
|
9024
|
-
try {
|
|
9025
|
-
if (external_fs_namespaceObject.existsSync(dir)) {
|
|
9026
|
-
const items = external_fs_namespaceObject.readdirSync(dir, {
|
|
9027
|
-
withFileTypes: true
|
|
9028
|
-
});
|
|
9029
|
-
for (const item of items){
|
|
9030
|
-
const fullPath = external_path_namespaceObject.join(dir, item.name);
|
|
9031
|
-
if (item.isFile()) files.push({
|
|
9032
|
-
path: fullPath,
|
|
9033
|
-
name: item.name,
|
|
9034
|
-
type: 'file',
|
|
9035
|
-
size: external_fs_namespaceObject.statSync(fullPath).size
|
|
9036
|
-
});
|
|
9037
|
-
else if (item.isDirectory()) files.push(...this.collectAllFiles(fullPath));
|
|
9038
|
-
}
|
|
9039
|
-
}
|
|
9040
|
-
} catch (error) {
|
|
9041
|
-
logger_logger.warn("\u6536\u96C6\u6587\u4EF6\u65F6\u51FA\u9519", error);
|
|
9042
|
-
}
|
|
9043
|
-
return files;
|
|
9044
|
-
}
|
|
9045
|
-
extractFeatureName(workspaceDir) {
|
|
9046
|
-
return external_path_namespaceObject.basename(workspaceDir);
|
|
9047
|
-
}
|
|
9048
|
-
}
|
|
9049
|
-
class RequirementHandlerService {
|
|
9050
|
-
alignAgent;
|
|
9051
|
-
architectAgent;
|
|
9052
|
-
atomizeAgent;
|
|
9053
|
-
approveAgent;
|
|
9054
|
-
automateAgent;
|
|
9055
|
-
assessAgent;
|
|
9056
|
-
constructor(){
|
|
9057
|
-
this.alignAgent = new AlignAgent();
|
|
9058
|
-
this.architectAgent = new ArchitectAgent();
|
|
9059
|
-
this.atomizeAgent = new AtomizeAgent();
|
|
9060
|
-
this.approveAgent = new ApproveAgent();
|
|
9061
|
-
this.automateAgent = new AutomateAgent();
|
|
9062
|
-
this.assessAgent = new AssessAgent();
|
|
9063
|
-
}
|
|
9064
|
-
async processRequirement(params) {
|
|
9065
|
-
const startTime = Date.now();
|
|
9066
|
-
try {
|
|
9067
|
-
const workspaceDir = this.createWorkspace(params.feature_name);
|
|
9068
|
-
logger_logger.info("6A\u9700\u6C42\u5904\u7406\u6D41\u7A0B\u5F00\u59CB", {
|
|
9069
|
-
featureName: params.feature_name,
|
|
9070
|
-
workspaceDir,
|
|
9071
|
-
stageToStop: params.stage_to_stop
|
|
9072
|
-
});
|
|
9073
|
-
const result = {
|
|
9074
|
-
success: false,
|
|
9075
|
-
message: '',
|
|
9076
|
-
feature_name: params.feature_name,
|
|
9077
|
-
completed_stages: [],
|
|
9078
|
-
current_stage: 'align',
|
|
9079
|
-
stage_results: [],
|
|
9080
|
-
output_files: [],
|
|
9081
|
-
human_confirmations_pending: []
|
|
9082
|
-
};
|
|
9083
|
-
let previousStageOutput = null;
|
|
9084
|
-
if (this.shouldExecuteStage('align', params.stage_to_stop)) {
|
|
9085
|
-
logger_logger.info("\u6267\u884C\u9636\u6BB51: \u9700\u6C42\u5BF9\u9F50");
|
|
9086
|
-
result.current_stage = 'align';
|
|
9087
|
-
const alignResult = await this.alignAgent.execute({
|
|
9088
|
-
requirement_text: params.requirement_text,
|
|
9089
|
-
project_context: params.project_context,
|
|
9090
|
-
feature_name: params.feature_name,
|
|
9091
|
-
workspace_dir: workspaceDir
|
|
9092
|
-
});
|
|
9093
|
-
result.stage_results.push(alignResult);
|
|
9094
|
-
result.completed_stages.push('align');
|
|
9095
|
-
previousStageOutput = alignResult;
|
|
9096
|
-
if (params.enable_human_confirmation && alignResult.human_confirmation_required) {
|
|
9097
|
-
result.human_confirmations_pending.push({
|
|
9098
|
-
stage: 'align',
|
|
9099
|
-
confirmation_type: 'stage_completion',
|
|
9100
|
-
details: "\u9700\u6C42\u5BF9\u9F50\u9636\u6BB5\u5B8C\u6210\uFF0C\u8BF7\u786E\u8BA4\u9700\u6C42\u7406\u89E3\u6B63\u786E\u6027"
|
|
9101
|
-
});
|
|
9102
|
-
if ('align' === params.stage_to_stop) {
|
|
9103
|
-
result.success = true;
|
|
9104
|
-
result.message = "\u9700\u6C42\u5BF9\u9F50\u9636\u6BB5\u5DF2\u5B8C\u6210\uFF0C\u7B49\u5F85\u4EBA\u5DE5\u786E\u8BA4";
|
|
9105
|
-
result.output_files = await this.collectOutputFiles(params.feature_name);
|
|
9106
|
-
return result;
|
|
9107
|
-
}
|
|
9108
|
-
}
|
|
9109
|
-
}
|
|
9110
|
-
if (this.shouldExecuteStage('architect', params.stage_to_stop) && previousStageOutput) {
|
|
9111
|
-
logger_logger.info("\u6267\u884C\u9636\u6BB52: \u7CFB\u7EDF\u67B6\u6784\u8BBE\u8BA1");
|
|
9112
|
-
result.current_stage = 'architect';
|
|
9113
|
-
const architectResult = await this.architectAgent.execute({
|
|
9114
|
-
previous_stage_output: previousStageOutput,
|
|
9115
|
-
workspace_dir: workspaceDir
|
|
9116
|
-
});
|
|
9117
|
-
result.stage_results.push(architectResult);
|
|
9118
|
-
result.completed_stages.push('architect');
|
|
9119
|
-
previousStageOutput = architectResult;
|
|
9120
|
-
if (params.enable_human_confirmation && architectResult.human_confirmation_required) {
|
|
9121
|
-
result.human_confirmations_pending.push({
|
|
9122
|
-
stage: 'architect',
|
|
9123
|
-
confirmation_type: 'stage_completion',
|
|
9124
|
-
details: "\u7CFB\u7EDF\u67B6\u6784\u8BBE\u8BA1\u9636\u6BB5\u5B8C\u6210\uFF0C\u8BF7\u786E\u8BA4\u67B6\u6784\u8BBE\u8BA1\u5408\u7406\u6027"
|
|
9125
|
-
});
|
|
9126
|
-
if ('architect' === params.stage_to_stop) {
|
|
9127
|
-
result.success = true;
|
|
9128
|
-
result.message = "\u7CFB\u7EDF\u67B6\u6784\u8BBE\u8BA1\u9636\u6BB5\u5DF2\u5B8C\u6210\uFF0C\u7B49\u5F85\u4EBA\u5DE5\u786E\u8BA4";
|
|
9129
|
-
result.output_files = await this.collectOutputFiles(params.feature_name);
|
|
9130
|
-
return result;
|
|
9131
|
-
}
|
|
9132
|
-
}
|
|
9133
|
-
}
|
|
9134
|
-
if (this.shouldExecuteStage('atomize', params.stage_to_stop) && previousStageOutput) {
|
|
9135
|
-
logger_logger.info("\u6267\u884C\u9636\u6BB53: \u539F\u5B50\u4EFB\u52A1\u62C6\u5206");
|
|
9136
|
-
result.current_stage = 'atomize';
|
|
9137
|
-
const atomizeResult = await this.atomizeAgent.execute({
|
|
9138
|
-
previous_stage_output: previousStageOutput,
|
|
9139
|
-
workspace_dir: workspaceDir
|
|
9140
|
-
});
|
|
9141
|
-
result.stage_results.push(atomizeResult);
|
|
9142
|
-
result.completed_stages.push('atomize');
|
|
9143
|
-
previousStageOutput = atomizeResult;
|
|
9144
|
-
if (params.enable_human_confirmation && atomizeResult.human_confirmation_required) {
|
|
9145
|
-
result.human_confirmations_pending.push({
|
|
9146
|
-
stage: 'atomize',
|
|
9147
|
-
confirmation_type: 'stage_completion',
|
|
9148
|
-
details: "\u539F\u5B50\u4EFB\u52A1\u62C6\u5206\u9636\u6BB5\u5B8C\u6210\uFF0C\u8BF7\u786E\u8BA4\u4EFB\u52A1\u62C6\u5206\u5408\u7406\u6027"
|
|
9149
|
-
});
|
|
9150
|
-
if ('atomize' === params.stage_to_stop) {
|
|
9151
|
-
result.success = true;
|
|
9152
|
-
result.message = "\u539F\u5B50\u4EFB\u52A1\u62C6\u5206\u9636\u6BB5\u5DF2\u5B8C\u6210\uFF0C\u7B49\u5F85\u4EBA\u5DE5\u786E\u8BA4";
|
|
9153
|
-
result.output_files = await this.collectOutputFiles(params.feature_name);
|
|
9154
|
-
return result;
|
|
9155
|
-
}
|
|
9156
|
-
}
|
|
9157
|
-
}
|
|
9158
|
-
if (this.shouldExecuteStage('approve', params.stage_to_stop) && previousStageOutput) {
|
|
9159
|
-
logger_logger.info("\u6267\u884C\u9636\u6BB54: \u4EFB\u52A1\u5BA1\u67E5");
|
|
9160
|
-
result.current_stage = 'approve';
|
|
9161
|
-
const approveResult = await this.approveAgent.execute({
|
|
9162
|
-
all_previous_outputs: result.stage_results,
|
|
9163
|
-
workspace_dir: workspaceDir
|
|
9164
|
-
});
|
|
9165
|
-
result.stage_results.push(approveResult);
|
|
9166
|
-
result.completed_stages.push('approve');
|
|
9167
|
-
previousStageOutput = approveResult;
|
|
9168
|
-
if (params.enable_human_confirmation && approveResult.human_confirmation_required) {
|
|
9169
|
-
result.human_confirmations_pending.push({
|
|
9170
|
-
stage: 'approve',
|
|
9171
|
-
confirmation_type: 'stage_completion',
|
|
9172
|
-
details: "\u4EFB\u52A1\u5BA1\u67E5\u9636\u6BB5\u5B8C\u6210\uFF0C\u8BF7\u786E\u8BA4\u5BA1\u67E5\u7ED3\u679C"
|
|
9173
|
-
});
|
|
9174
|
-
if ('approve' === params.stage_to_stop) {
|
|
9175
|
-
result.success = true;
|
|
9176
|
-
result.message = "\u4EFB\u52A1\u5BA1\u67E5\u9636\u6BB5\u5DF2\u5B8C\u6210\uFF0C\u7B49\u5F85\u4EBA\u5DE5\u786E\u8BA4";
|
|
9177
|
-
result.output_files = await this.collectOutputFiles(params.feature_name);
|
|
9178
|
-
return result;
|
|
9179
|
-
}
|
|
9180
|
-
}
|
|
9181
|
-
}
|
|
9182
|
-
if (this.shouldExecuteStage('automate', params.stage_to_stop) && previousStageOutput) {
|
|
9183
|
-
logger_logger.info("\u6267\u884C\u9636\u6BB55: \u4EFB\u52A1\u81EA\u52A8\u6267\u884C");
|
|
9184
|
-
result.current_stage = 'automate';
|
|
9185
|
-
const automateResult = await this.automateAgent.execute({
|
|
9186
|
-
all_previous_outputs: result.stage_results,
|
|
9187
|
-
workspace_dir: workspaceDir,
|
|
9188
|
-
include_tests: params.custom_config?.include_tests ?? true,
|
|
9189
|
-
include_docs: params.custom_config?.include_docs ?? true
|
|
9190
|
-
});
|
|
9191
|
-
result.stage_results.push(automateResult);
|
|
9192
|
-
result.completed_stages.push('automate');
|
|
9193
|
-
previousStageOutput = automateResult;
|
|
9194
|
-
if (params.enable_human_confirmation && automateResult.human_confirmation_required) {
|
|
9195
|
-
result.human_confirmations_pending.push({
|
|
9196
|
-
stage: 'automate',
|
|
9197
|
-
confirmation_type: 'stage_completion',
|
|
9198
|
-
details: "\u4EFB\u52A1\u81EA\u52A8\u6267\u884C\u9636\u6BB5\u5B8C\u6210\uFF0C\u8BF7\u786E\u8BA4\u6267\u884C\u7ED3\u679C"
|
|
9199
|
-
});
|
|
9200
|
-
if ('automate' === params.stage_to_stop) {
|
|
9201
|
-
result.success = true;
|
|
9202
|
-
result.message = "\u4EFB\u52A1\u81EA\u52A8\u6267\u884C\u9636\u6BB5\u5DF2\u5B8C\u6210\uFF0C\u7B49\u5F85\u4EBA\u5DE5\u786E\u8BA4";
|
|
9203
|
-
result.output_files = await this.collectOutputFiles(params.feature_name);
|
|
9204
|
-
return result;
|
|
9205
|
-
}
|
|
9206
|
-
}
|
|
9207
|
-
}
|
|
9208
|
-
if (this.shouldExecuteStage('assess', params.stage_to_stop) && previousStageOutput) {
|
|
9209
|
-
logger_logger.info("\u6267\u884C\u9636\u6BB56: \u6267\u884C\u8D28\u91CF\u8BC4\u4F30");
|
|
9210
|
-
result.current_stage = 'assess';
|
|
9211
|
-
const assessResult = await this.assessAgent.execute({
|
|
9212
|
-
all_previous_outputs: result.stage_results,
|
|
9213
|
-
workspace_dir: workspaceDir
|
|
9214
|
-
});
|
|
9215
|
-
result.stage_results.push(assessResult);
|
|
9216
|
-
result.completed_stages.push('assess');
|
|
9217
|
-
if (params.enable_human_confirmation && assessResult.human_confirmation_required) result.human_confirmations_pending.push({
|
|
9218
|
-
stage: 'assess',
|
|
9219
|
-
confirmation_type: 'stage_completion',
|
|
9220
|
-
details: "\u6267\u884C\u8D28\u91CF\u8BC4\u4F30\u9636\u6BB5\u5B8C\u6210\uFF0C\u8BF7\u786E\u8BA4\u8BC4\u4F30\u7ED3\u679C"
|
|
9221
|
-
});
|
|
9222
|
-
}
|
|
9223
|
-
result.output_files = await this.collectOutputFiles(params.feature_name);
|
|
9224
|
-
const duration = Date.now() - startTime;
|
|
9225
|
-
result.success = true;
|
|
9226
|
-
result.message = `6A\u{9700}\u{6C42}\u{5904}\u{7406}\u{6D41}\u{7A0B}\u{6267}\u{884C}\u{6210}\u{529F}\u{FF0C}\u{5B8C}\u{6210}\u{9636}\u{6BB5}: ${result.completed_stages.join(', ')}\u{FF0C}\u{8017}\u{65F6} ${duration}ms`;
|
|
9227
|
-
logger_logger.info("6A\u9700\u6C42\u5904\u7406\u6D41\u7A0B\u5B8C\u6210", {
|
|
9228
|
-
featureName: params.feature_name,
|
|
9229
|
-
completedStages: result.completed_stages,
|
|
9230
|
-
duration
|
|
9231
|
-
});
|
|
9232
|
-
return result;
|
|
9233
|
-
} catch (error) {
|
|
9234
|
-
logger_logger.error("6A\u9700\u6C42\u5904\u7406\u6D41\u7A0B\u6267\u884C\u5931\u8D25", {
|
|
9235
|
-
error: error.message,
|
|
9236
|
-
stack: error.stack,
|
|
9237
|
-
featureName: params.feature_name
|
|
9238
|
-
});
|
|
9239
|
-
const result = {
|
|
9240
|
-
success: false,
|
|
9241
|
-
message: `6A\u{9700}\u{6C42}\u{5904}\u{7406}\u{6D41}\u{7A0B}\u{6267}\u{884C}\u{5931}\u{8D25}: ${error.message}`,
|
|
9242
|
-
feature_name: params.feature_name,
|
|
9243
|
-
completed_stages: [],
|
|
9244
|
-
current_stage: 'align',
|
|
9245
|
-
stage_results: [],
|
|
9246
|
-
output_files: [],
|
|
9247
|
-
human_confirmations_pending: []
|
|
9248
|
-
};
|
|
9249
|
-
if (error instanceof RequirementHandlerError) result.message += ` (${error.code})`;
|
|
9250
|
-
return result;
|
|
9251
|
-
}
|
|
9252
|
-
}
|
|
9253
|
-
createWorkspace(featureName) {
|
|
9254
|
-
try {
|
|
9255
|
-
if (!featureName || 'string' != typeof featureName) throw new Error(`\u{65E0}\u{6548}\u{7684}\u{529F}\u{80FD}\u{540D}\u{79F0}: ${featureName}`);
|
|
9256
|
-
const baseDir = process.cwd();
|
|
9257
|
-
if (!baseDir || 'string' != typeof baseDir) throw new Error("\u65E0\u6CD5\u83B7\u53D6\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55");
|
|
9258
|
-
const outputDir = external_path_namespaceObject.join(baseDir, 'output');
|
|
9259
|
-
const requirementDir = external_path_namespaceObject.join(outputDir, 'requirement-handler');
|
|
9260
|
-
const workspaceDir = external_path_namespaceObject.join(requirementDir, featureName);
|
|
9261
|
-
logger_logger.info("\u521B\u5EFA\u5DE5\u4F5C\u7A7A\u95F4", {
|
|
9262
|
-
baseDir,
|
|
9263
|
-
outputDir,
|
|
9264
|
-
requirementDir,
|
|
9265
|
-
workspaceDir,
|
|
9266
|
-
featureName
|
|
9267
|
-
});
|
|
9268
|
-
if (!external_fs_namespaceObject.existsSync(outputDir)) {
|
|
9269
|
-
external_fs_namespaceObject.mkdirSync(outputDir, {
|
|
9270
|
-
recursive: true
|
|
9271
|
-
});
|
|
9272
|
-
logger_logger.info("\u521B\u5EFA\u8F93\u51FA\u76EE\u5F55", {
|
|
9273
|
-
outputDir
|
|
9274
|
-
});
|
|
9275
|
-
}
|
|
9276
|
-
if (!external_fs_namespaceObject.existsSync(requirementDir)) {
|
|
9277
|
-
external_fs_namespaceObject.mkdirSync(requirementDir, {
|
|
9278
|
-
recursive: true
|
|
9279
|
-
});
|
|
9280
|
-
logger_logger.info("\u521B\u5EFA\u9700\u6C42\u5904\u7406\u76EE\u5F55", {
|
|
9281
|
-
requirementDir
|
|
9282
|
-
});
|
|
9283
|
-
}
|
|
9284
|
-
if (!external_fs_namespaceObject.existsSync(workspaceDir)) {
|
|
9285
|
-
external_fs_namespaceObject.mkdirSync(workspaceDir, {
|
|
9286
|
-
recursive: true
|
|
9287
|
-
});
|
|
9288
|
-
logger_logger.info("\u521B\u5EFA\u5DE5\u4F5C\u7A7A\u95F4\u76EE\u5F55", {
|
|
9289
|
-
workspaceDir
|
|
9290
|
-
});
|
|
9291
|
-
}
|
|
9292
|
-
return workspaceDir;
|
|
9293
|
-
} catch (error) {
|
|
9294
|
-
logger_logger.error("\u521B\u5EFA\u5DE5\u4F5C\u7A7A\u95F4\u5931\u8D25", {
|
|
9295
|
-
featureName,
|
|
9296
|
-
error: error.message,
|
|
9297
|
-
stack: error.stack
|
|
9298
|
-
});
|
|
9299
|
-
throw new RequirementHandlerError(`\u{521B}\u{5EFA}\u{5DE5}\u{4F5C}\u{7A7A}\u{95F4}\u{5931}\u{8D25}: ${error.message}`, types_StageErrorCodes.WORKSPACE_CREATION_FAILED, 'workspace', {
|
|
9300
|
-
featureName,
|
|
9301
|
-
error: error.message
|
|
9302
|
-
});
|
|
9303
|
-
}
|
|
9304
|
-
}
|
|
9305
|
-
shouldExecuteStage(stage, stopAt) {
|
|
9306
|
-
if (!stopAt || 'complete' === stopAt) return true;
|
|
9307
|
-
const stages = [
|
|
9308
|
-
'align',
|
|
9309
|
-
'architect',
|
|
9310
|
-
'atomize',
|
|
9311
|
-
'approve',
|
|
9312
|
-
'automate',
|
|
9313
|
-
'assess'
|
|
9314
|
-
];
|
|
9315
|
-
const currentIndex = stages.indexOf(stage);
|
|
9316
|
-
const stopIndex = stages.indexOf(stopAt);
|
|
9317
|
-
return currentIndex <= stopIndex;
|
|
9318
|
-
}
|
|
9319
|
-
async collectOutputFiles(featureName) {
|
|
9320
|
-
const files = [];
|
|
9321
|
-
try {
|
|
9322
|
-
const projectRoot = process.cwd();
|
|
9323
|
-
const aicoDocsDir = external_path_namespaceObject.join(projectRoot, '.aico', 'docs', featureName);
|
|
9324
|
-
if (external_fs_namespaceObject.existsSync(aicoDocsDir)) {
|
|
9325
|
-
const aicoFiles = this.collectFilesFromDirectory(aicoDocsDir);
|
|
9326
|
-
files.push(...aicoFiles);
|
|
9327
|
-
}
|
|
9328
|
-
const workspaceDir = external_path_namespaceObject.join(projectRoot, 'output', 'requirement-handler', featureName);
|
|
9329
|
-
if (external_fs_namespaceObject.existsSync(workspaceDir)) {
|
|
9330
|
-
const workspaceFiles = this.collectFilesFromDirectory(workspaceDir);
|
|
9331
|
-
files.push(...workspaceFiles);
|
|
9332
|
-
}
|
|
9333
|
-
} catch (error) {
|
|
9334
|
-
logger_logger.warn("\u6536\u96C6\u8F93\u51FA\u6587\u4EF6\u65F6\u51FA\u9519", {
|
|
9335
|
-
featureName,
|
|
9336
|
-
error: error.message
|
|
9337
|
-
});
|
|
9338
|
-
}
|
|
9339
|
-
return files;
|
|
9340
|
-
}
|
|
9341
|
-
collectFilesFromDirectory(dir) {
|
|
9342
|
-
const files = [];
|
|
9343
|
-
try {
|
|
9344
|
-
if (!dir || 'string' != typeof dir) return files;
|
|
9345
|
-
if (external_fs_namespaceObject.existsSync(dir)) {
|
|
9346
|
-
const items = external_fs_namespaceObject.readdirSync(dir, {
|
|
9347
|
-
withFileTypes: true
|
|
9348
|
-
});
|
|
9349
|
-
for (const item of items)if (item.isFile()) files.push(external_path_namespaceObject.join(dir, item.name));
|
|
9350
|
-
else if (item.isDirectory()) {
|
|
9351
|
-
const subFiles = this.collectFilesFromDirectory(external_path_namespaceObject.join(dir, item.name));
|
|
9352
|
-
files.push(...subFiles);
|
|
9353
|
-
}
|
|
9354
|
-
}
|
|
9355
|
-
} catch (error) {
|
|
9356
|
-
logger_logger.warn("\u6536\u96C6\u76EE\u5F55\u6587\u4EF6\u65F6\u51FA\u9519", {
|
|
9357
|
-
dir,
|
|
9358
|
-
error: error.message
|
|
9359
|
-
});
|
|
9360
|
-
}
|
|
9361
|
-
return files;
|
|
9362
|
-
}
|
|
9363
|
-
}
|
|
9364
|
-
objectType({
|
|
9365
|
-
requirement_text: stringType().min(10).describe("\u7528\u6237\u7684\u539F\u59CB\u9700\u6C42\u63CF\u8FF0\u6587\u672C"),
|
|
9366
|
-
project_context: stringType().optional().describe("\u9879\u76EE\u4E0A\u4E0B\u6587\u4FE1\u606F\uFF08\u53EF\u9009\uFF09"),
|
|
9367
|
-
feature_name: stringType().describe("\u529F\u80FD\u540D\u79F0\uFF0C\u7528\u4E8E\u751F\u6210\u8F93\u51FA\u6587\u4EF6\u540D"),
|
|
9368
|
-
enable_human_confirmation: booleanType().default(true).describe("\u662F\u5426\u542F\u7528\u4EBA\u5DE5\u786E\u8BA4\u673A\u5236"),
|
|
9369
|
-
stage_to_stop: enumType([
|
|
9370
|
-
"align",
|
|
9371
|
-
"architect",
|
|
9372
|
-
"atomize",
|
|
9373
|
-
"approve",
|
|
9374
|
-
"automate",
|
|
9375
|
-
"assess",
|
|
9376
|
-
"complete"
|
|
9377
|
-
]).default("complete").describe("\u6307\u5B9A\u5728\u54EA\u4E2A\u9636\u6BB5\u505C\u6B62\uFF08\u7528\u4E8E\u8C03\u8BD5\uFF09"),
|
|
9378
|
-
custom_config: objectType({
|
|
9379
|
-
analysis_depth: enumType([
|
|
9380
|
-
"basic",
|
|
9381
|
-
"detailed",
|
|
9382
|
-
"comprehensive"
|
|
9383
|
-
]).default("detailed"),
|
|
9384
|
-
include_tests: booleanType().default(true),
|
|
9385
|
-
include_docs: booleanType().default(true)
|
|
9386
|
-
}).optional().describe("\u81EA\u5B9A\u4E49\u914D\u7F6E\u9009\u9879")
|
|
9387
|
-
});
|
|
9388
|
-
const requirementHandlerTool = {
|
|
9389
|
-
name: "\u9700\u6C42\u5904\u7406\u667A\u80FD\u4F53",
|
|
9390
|
-
description: "\u4EE5\u9700\u6C42\u6307\u6325\u5B98\u667A\u80FD\u4F53\u8C03\u5EA6\u9700\u6C42\u5BF9\u9F50\u667A\u80FD\u4F53\uFF0C\u539F\u5B50\u4EFB\u52A1\u62C6\u5206\u5BA1\u67E5\u667A\u80FD\u4F53\uFF0C\u4EFB\u52A1\u81EA\u52A8\u6267\u884C\u667A\u80FD\u4F53\uFF0C\u6267\u884C\u8D28\u91CF\u8BC4\u4F30\u667A\u80FD\u4F53\u7684\u65B9\u5F0F\u5B8C\u6210\u5BF9\u9700\u6C42\u7684\u5904\u7406",
|
|
9391
|
-
inputSchema: {
|
|
9392
|
-
requirement_text: stringType().min(10).describe("\u7528\u6237\u7684\u539F\u59CB\u9700\u6C42\u63CF\u8FF0\u6587\u672C"),
|
|
9393
|
-
project_context: stringType().optional().describe("\u9879\u76EE\u4E0A\u4E0B\u6587\u4FE1\u606F\uFF08\u53EF\u9009\uFF09"),
|
|
9394
|
-
feature_name: stringType().describe("\u529F\u80FD\u540D\u79F0\uFF0C\u7528\u4E8E\u751F\u6210\u8F93\u51FA\u6587\u4EF6\u540D"),
|
|
9395
|
-
enable_human_confirmation: booleanType().default(true).describe("\u662F\u5426\u542F\u7528\u4EBA\u5DE5\u786E\u8BA4\u673A\u5236"),
|
|
9396
|
-
stage_to_stop: enumType([
|
|
9397
|
-
"align",
|
|
9398
|
-
"architect",
|
|
9399
|
-
"atomize",
|
|
9400
|
-
"approve",
|
|
9401
|
-
"automate",
|
|
9402
|
-
"assess",
|
|
9403
|
-
"complete"
|
|
9404
|
-
]).default("complete").describe("\u6307\u5B9A\u5728\u54EA\u4E2A\u9636\u6BB5\u505C\u6B62\uFF08\u7528\u4E8E\u8C03\u8BD5\uFF09"),
|
|
9405
|
-
custom_config: objectType({
|
|
9406
|
-
analysis_depth: enumType([
|
|
9407
|
-
"basic",
|
|
9408
|
-
"detailed",
|
|
9409
|
-
"comprehensive"
|
|
9410
|
-
]).default("detailed"),
|
|
9411
|
-
include_tests: booleanType().default(true),
|
|
9412
|
-
include_docs: booleanType().default(true)
|
|
9413
|
-
}).optional().describe("\u81EA\u5B9A\u4E49\u914D\u7F6E\u9009\u9879")
|
|
9414
|
-
},
|
|
9415
|
-
handler: async (args)=>{
|
|
9416
|
-
const service = new RequirementHandlerService();
|
|
9417
|
-
try {
|
|
9418
|
-
logger_logger.info("\u9700\u6C42\u5904\u7406\u667A\u80FD\u4F53\u5F00\u59CB\u6267\u884C", {
|
|
9419
|
-
args: JSON.stringify(args, null, 2),
|
|
9420
|
-
featureName: args.feature_name,
|
|
9421
|
-
stageToStop: args.stage_to_stop
|
|
9422
|
-
});
|
|
9423
|
-
const result = await service.processRequirement(args);
|
|
9424
|
-
return {
|
|
9425
|
-
content: [
|
|
9426
|
-
{
|
|
9427
|
-
type: "text",
|
|
9428
|
-
text: JSON.stringify({
|
|
9429
|
-
success: true,
|
|
9430
|
-
message: "\u9700\u6C42\u5904\u7406\u667A\u80FD\u4F53\u6267\u884C\u6210\u529F",
|
|
9431
|
-
data: result
|
|
9432
|
-
}, null, 2)
|
|
9433
|
-
}
|
|
9434
|
-
]
|
|
9435
|
-
};
|
|
9436
|
-
} catch (error) {
|
|
9437
|
-
logger_logger.error("\u9700\u6C42\u5904\u7406\u667A\u80FD\u4F53\u6267\u884C\u5931\u8D25", error);
|
|
9438
6910
|
return {
|
|
9439
6911
|
content: [
|
|
9440
6912
|
{
|
|
9441
6913
|
type: "text",
|
|
9442
6914
|
text: JSON.stringify({
|
|
9443
6915
|
success: false,
|
|
9444
|
-
message:
|
|
9445
|
-
|
|
9446
|
-
|
|
9447
|
-
context: error.context
|
|
9448
|
-
}
|
|
9449
|
-
}, null, 2)
|
|
6916
|
+
message: `Excel\u{5BFC}\u{51FA}\u{5931}\u{8D25}: ${errorMsg}`,
|
|
6917
|
+
data: null
|
|
6918
|
+
})
|
|
9450
6919
|
}
|
|
9451
6920
|
],
|
|
9452
6921
|
isError: true
|
|
@@ -9462,14 +6931,12 @@ ${new Date().toISOString()}
|
|
|
9462
6931
|
const tools = [
|
|
9463
6932
|
word2mdTool,
|
|
9464
6933
|
pdf2mdTool,
|
|
9465
|
-
initProjectStandard,
|
|
9466
|
-
requirementAnalyzerTool,
|
|
9467
6934
|
changeSummarizer,
|
|
9468
6935
|
read_imageTool,
|
|
9469
6936
|
imageConverterTool,
|
|
9470
|
-
codeGeneratorTool,
|
|
9471
6937
|
imageRecognitionAgentTool,
|
|
9472
|
-
|
|
6938
|
+
readExcelTool,
|
|
6939
|
+
exportExcelTool
|
|
9473
6940
|
];
|
|
9474
6941
|
tools.forEach((tool)=>{
|
|
9475
6942
|
server.tool(tool.name, tool.description, tool.inputSchema, tool.handler);
|
|
@@ -9478,7 +6945,7 @@ ${new Date().toISOString()}
|
|
|
9478
6945
|
}
|
|
9479
6946
|
const src_server = createMcpServer();
|
|
9480
6947
|
const transport = new stdio_js_namespaceObject.StdioServerTransport();
|
|
9481
|
-
|
|
6948
|
+
logger.info("\u542F\u52A8\u667A\u80FD\u8F6F\u4EF6\u661F\u5DE5\u5382 MCP \u670D\u52A1\u5668 (stdio\u6A21\u5F0F)");
|
|
9482
6949
|
(async ()=>{
|
|
9483
6950
|
await src_server.connect(transport);
|
|
9484
6951
|
})();
|