intention-coding 0.6.2 → 0.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env node
1
2
  "use strict";
2
3
  const __rslib_import_meta_url__ = /*#__PURE__*/ function() {
3
4
  return 'undefined' == typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
@@ -10952,7 +10953,87 @@ ${requirement_description}
10952
10953
  }
10953
10954
  return external_path_namespaceObject.resolve(currentDir, "\u6280\u672F\u89C4\u683C\u8BF4\u660E\u4E66\u6A21\u677F.docx");
10954
10955
  }
10956
+ function isEmptySection(section) {
10957
+ if (!section) return true;
10958
+ if ('object' != typeof section) return true;
10959
+ const keys = Object.keys(section);
10960
+ if (0 === keys.length) return true;
10961
+ return keys.every((key)=>{
10962
+ const val = section[key];
10963
+ return !val || '' === val || "\u65E0" === val || "\u4E0D\u6D89\u53CA" === val || "\u4E0D\u6D89\u53CA\u3002" === val;
10964
+ });
10965
+ }
10966
+ function prepareSubSectionData(section, defaultValue = "\u4E0D\u6D89\u53CA\u3002") {
10967
+ if (isEmptySection(section)) return {
10968
+ constraint: defaultValue,
10969
+ useCase: defaultValue,
10970
+ design: defaultValue,
10971
+ intro: defaultValue,
10972
+ dataEstimation: defaultValue,
10973
+ sharding: defaultValue,
10974
+ designIdea: defaultValue,
10975
+ implementation: defaultValue
10976
+ };
10977
+ const normalizeValue = (val)=>{
10978
+ if (!val || '' === val || "\u65E0" === val) return defaultValue;
10979
+ return String(val);
10980
+ };
10981
+ return {
10982
+ constraint: normalizeValue(section.constraint),
10983
+ useCase: normalizeValue(section.useCase),
10984
+ design: normalizeValue(section.design),
10985
+ intro: normalizeValue(section.intro),
10986
+ dataEstimation: normalizeValue(section.dataEstimation),
10987
+ sharding: normalizeValue(section.sharding),
10988
+ designIdea: normalizeValue(section.designIdea),
10989
+ implementation: normalizeValue(section.implementation)
10990
+ };
10991
+ }
10992
+ function flattenSubSection(parentKey, sectionName, section) {
10993
+ const result = {};
10994
+ for (const [key, value] of Object.entries(section))result[`${parentKey}_${sectionName}_${key}`] = value;
10995
+ return result;
10996
+ }
10955
10997
  function prepareRenderData(data) {
10998
+ const defaultNotInvolved = "\u4E0D\u6D89\u53CA\u3002";
10999
+ const techSolution = data.techSolution || {};
11000
+ const flattenedData = {
11001
+ techSolution_trafficEstimation: techSolution.trafficEstimation || defaultNotInvolved
11002
+ };
11003
+ const subSections = [
11004
+ {
11005
+ name: 'messageQueue',
11006
+ data: prepareSubSectionData(techSolution.messageQueue, defaultNotInvolved)
11007
+ },
11008
+ {
11009
+ name: 'databaseSplit',
11010
+ data: prepareSubSectionData(techSolution.databaseSplit, defaultNotInvolved)
11011
+ },
11012
+ {
11013
+ name: 'distributedTransaction',
11014
+ data: prepareSubSectionData(techSolution.distributedTransaction, defaultNotInvolved)
11015
+ },
11016
+ {
11017
+ name: 'distributedLock',
11018
+ data: prepareSubSectionData(techSolution.distributedLock, defaultNotInvolved)
11019
+ },
11020
+ {
11021
+ name: 'scheduledTask',
11022
+ data: prepareSubSectionData(techSolution.scheduledTask, defaultNotInvolved)
11023
+ },
11024
+ {
11025
+ name: 'delayTask',
11026
+ data: prepareSubSectionData(techSolution.delayTask, defaultNotInvolved)
11027
+ },
11028
+ {
11029
+ name: 'cacheDesign',
11030
+ data: prepareSubSectionData(techSolution.cacheDesign, defaultNotInvolved)
11031
+ }
11032
+ ];
11033
+ for (const { name, data: sectionData } of subSections)Object.assign(flattenedData, flattenSubSection('techSolution', name, sectionData));
11034
+ flattenedData.businessException_content = data.businessException?.content || defaultNotInvolved;
11035
+ flattenedData.appendix_exceptionCodeList = data.appendix?.exceptionCodeList || [];
11036
+ flattenedData.appendix_codeValueList = data.appendix?.codeValueList || [];
10956
11037
  const renderData = {
10957
11038
  projectName: data.projectName,
10958
11039
  moduleName: data.moduleName,
@@ -10962,28 +11043,11 @@ ${requirement_description}
10962
11043
  serviceInterfaceList: data.serviceInterfaceList || [],
10963
11044
  designDetailList: data.designDetailList || [],
10964
11045
  tableInfoList: data.tableInfoList || [],
10965
- techSolution: data.techSolution || null,
10966
- businessExceptionList: data.businessExceptionList || [],
10967
- appendix: data.appendix || null
11046
+ ...flattenedData
10968
11047
  };
10969
- if (data.techSolution) {
10970
- const ts = data.techSolution;
10971
- renderData.trafficEstimation = ts.trafficEstimation || null;
10972
- renderData.messageQueueList = ts.messageQueueList || [];
10973
- renderData.databaseSplitList = ts.databaseSplitList || [];
10974
- renderData.distributedTransactionList = ts.distributedTransactionList || [];
10975
- renderData.distributedLockList = ts.distributedLockList || [];
10976
- renderData.scheduledTaskList = ts.scheduledTaskList || [];
10977
- renderData.delayTaskList = ts.delayTaskList || [];
10978
- renderData.cacheDesign = ts.cacheDesign || null;
10979
- if (ts.cacheDesign) {
10980
- renderData.cacheConstraint = ts.cacheDesign.constraint || "\u4E0D\u6D89\u53CA\u3002";
10981
- renderData.cacheScenarioList = ts.cacheDesign.cacheScenarioList || [];
10982
- renderData.cacheDesignDescription = ts.cacheDesign.designDescription || "\u4E0D\u6D89\u53CA\u3002";
10983
- }
10984
- }
10985
- renderData.exceptionCodeList = data.appendix?.exceptionCodeList || [];
10986
- renderData.codeValueList = data.appendix?.codeValueList || [];
11048
+ logger.debug("\u6E32\u67D3\u6570\u636E", {
11049
+ flattenedData
11050
+ });
10987
11051
  return renderData;
10988
11052
  }
10989
11053
  async function renderTechSpecDoc(data, outputDir) {
@@ -11004,20 +11068,20 @@ ${requirement_description}
11004
11068
  paragraphLoop: true,
11005
11069
  linebreaks: true,
11006
11070
  delimiters: {
11007
- start: '{',
11008
- end: '}'
11071
+ start: "{",
11072
+ end: "}"
11009
11073
  }
11010
11074
  });
11011
11075
  const renderData = prepareRenderData(data);
11012
11076
  doc.render(renderData);
11013
11077
  const output = doc.getZip().generate({
11014
- type: 'nodebuffer',
11015
- compression: 'DEFLATE'
11078
+ type: "nodebuffer",
11079
+ compression: "DEFLATE"
11016
11080
  });
11017
11081
  await promises_namespaceObject.mkdir(outputDir, {
11018
11082
  recursive: true
11019
11083
  });
11020
- const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);
11084
+ const timestamp = new Date().toISOString().replace(/[:.]/g, "-").slice(0, 19);
11021
11085
  const outputFileName = `\u{6280}\u{672F}\u{89C4}\u{683C}\u{8BF4}\u{660E}\u{4E66}_${data.projectName}_${data.moduleName}_${timestamp}.docx`;
11022
11086
  const outputPath = external_path_namespaceObject.join(outputDir, outputFileName);
11023
11087
  await promises_namespaceObject.writeFile(outputPath, output);
@@ -11033,7 +11097,7 @@ ${requirement_description}
11033
11097
  error: error.message
11034
11098
  });
11035
11099
  if (error.properties && error.properties.errors) {
11036
- const errorMessages = error.properties.errors.map((e)=>e.properties?.explanation || e.message).join('; ');
11100
+ const errorMessages = error.properties.errors.map((e)=>e.properties?.explanation || e.message).join("; ");
11037
11101
  return {
11038
11102
  success: false,
11039
11103
  outputPath: null,
@@ -11047,6 +11111,11 @@ ${requirement_description}
11047
11111
  };
11048
11112
  }
11049
11113
  }
11114
+ const PROJECT_PATH_DESCRIPTION = "\u9879\u76EE\u6839\u76EE\u5F55\u8DEF\u5F84\uFF0C\u751F\u6210\u7684\u6280\u672F\u89C4\u683C\u8BF4\u660E\u4E66\u4FDD\u5B58\u5230\u9879\u76EE\u6839\u76EE\u5F55\u7684.aico/tech\u4E0B\uFF0C\u6CE8\u610F\u4E0D\u662F\u7528\u6237\u8F93\u5165\u7684\u6A21\u5757\u76EE\u5F55\uFF0C\u662F\u6574\u4E2A\u9879\u76EE\u7684\u6839\u76EE\u5F55";
11115
+ const TECH_SPEC_OUTPUT_DIR = ".aico/tech";
11116
+ function getTechSpecOutputDir(projectPath) {
11117
+ return `${projectPath}/${TECH_SPEC_OUTPUT_DIR}`;
11118
+ }
11050
11119
  const TableFieldDetailSchema = objectType({
11051
11120
  id: stringType().describe("\u5E8F\u53F7"),
11052
11121
  fieldName: stringType().describe("\u5B57\u6BB5\u540D"),
@@ -11054,7 +11123,7 @@ ${requirement_description}
11054
11123
  fieldDescription: stringType().describe("\u5B57\u6BB5\u63CF\u8FF0"),
11055
11124
  fieldLength: stringType().describe("\u5B57\u6BB5\u957F\u5EA6")
11056
11125
  });
11057
- objectType({
11126
+ const TableInfoSchema = objectType({
11058
11127
  id: stringType().describe("\u5E8F\u53F7"),
11059
11128
  tableName: stringType().describe("\u8868\u540D\u79F0"),
11060
11129
  entityName: stringType().describe("\u5BF9\u5E94\u5B9E\u4F53\u540D\u79F0"),
@@ -11083,7 +11152,7 @@ ${requirement_description}
11083
11152
  returnResultList: arrayType(ReturnResultInfoSchema).default([]).describe("\u8FD4\u56DE\u7ED3\u679C\u5217\u8868"),
11084
11153
  implementLogic: stringType().describe("\u5B9E\u73B0\u903B\u8F91")
11085
11154
  });
11086
- objectType({
11155
+ const DesignDetailSchema = objectType({
11087
11156
  serviceName: stringType().describe("\u670D\u52A1\u540D\u79F0"),
11088
11157
  serviceDesc: stringType().describe("\u529F\u80FD\u63CF\u8FF0"),
11089
11158
  interfaceDesignDetailList: arrayType(InterfaceDesignDetailSchema).default([]).describe("\u63A5\u53E3\u8BBE\u8BA1\u8BE6\u60C5\u5217\u8868")
@@ -11094,7 +11163,7 @@ ${requirement_description}
11094
11163
  serviceName: stringType().describe("\u670D\u52A1\u540D"),
11095
11164
  methodName: stringType().describe("\u65B9\u6CD5\u540D")
11096
11165
  });
11097
- objectType({
11166
+ const ServiceInterfaceSchema = objectType({
11098
11167
  id: stringType().describe("\u5E8F\u53F7"),
11099
11168
  serviceType: stringType().describe("\u670D\u52A1\u7C7B\u578B"),
11100
11169
  serviceEnglishName: stringType().describe("\u670D\u52A1\u82F1\u6587\u540D\u79F0"),
@@ -11102,92 +11171,143 @@ ${requirement_description}
11102
11171
  serviceDescription: stringType().describe("\u670D\u52A1\u63CF\u8FF0"),
11103
11172
  interfaceDetailList: arrayType(InterfaceDetailSchema).default([]).describe("\u63A5\u53E3\u8BE6\u60C5\u5217\u8868")
11104
11173
  });
11105
- const TrafficEstimationSchema = objectType({
11174
+ objectType({
11106
11175
  description: stringType().describe("\u63CF\u8FF0"),
11107
11176
  qps: stringType().describe("\u9884\u4F30QPS"),
11108
11177
  peakQps: stringType().describe("\u5CF0\u503CQPS"),
11109
11178
  dailyVolume: stringType().describe("\u65E5\u8BF7\u6C42\u91CF")
11110
11179
  });
11111
- const MessageQueueDesignSchema = objectType({
11112
- topicName: stringType().describe("Topic\u540D\u79F0"),
11113
- description: stringType().describe("\u63CF\u8FF0"),
11114
- producer: stringType().describe("\u751F\u4EA7\u8005"),
11115
- consumer: stringType().describe("\u6D88\u8D39\u8005"),
11116
- messageType: stringType().describe("\u6D88\u606F\u7C7B\u578B")
11117
- });
11118
- const DatabaseSplitDesignSchema = objectType({
11119
- tableName: stringType().describe("\u8868\u540D"),
11120
- splitStrategy: stringType().describe("\u62C6\u5206\u7B56\u7565"),
11121
- splitKey: stringType().describe("\u62C6\u5206\u952E"),
11122
- description: stringType().describe("\u63CF\u8FF0")
11123
- });
11124
- const DistributedTransactionDesignSchema = objectType({
11125
- sceneName: stringType().describe("\u573A\u666F\u540D\u79F0"),
11126
- transactionType: stringType().describe("\u4E8B\u52A1\u7C7B\u578B(TCC/SAGA/2PC\u7B49)"),
11127
- participants: stringType().describe("\u53C2\u4E0E\u65B9"),
11128
- description: stringType().describe("\u63CF\u8FF0")
11129
- });
11130
- const DistributedLockDesignSchema = objectType({
11131
- lockName: stringType().describe("\u9501\u540D\u79F0"),
11132
- lockType: stringType().describe("\u9501\u7C7B\u578B"),
11133
- timeout: stringType().describe("\u8D85\u65F6\u65F6\u95F4"),
11134
- description: stringType().describe("\u63CF\u8FF0")
11135
- });
11136
- const ScheduledTaskDesignSchema = objectType({
11137
- taskName: stringType().describe("\u4EFB\u52A1\u540D\u79F0"),
11138
- cronExpression: stringType().describe("Cron\u8868\u8FBE\u5F0F"),
11139
- description: stringType().describe("\u63CF\u8FF0"),
11140
- executorClass: stringType().describe("\u6267\u884C\u7C7B")
11141
- });
11142
- const DelayTaskDesignSchema = objectType({
11143
- taskName: stringType().describe("\u4EFB\u52A1\u540D\u79F0"),
11144
- delayTime: stringType().describe("\u5EF6\u65F6\u65F6\u95F4"),
11145
- description: stringType().describe("\u63CF\u8FF0"),
11146
- triggerCondition: stringType().describe("\u89E6\u53D1\u6761\u4EF6")
11147
- });
11148
- const CacheScenarioSchema = objectType({
11149
- id: stringType().describe("\u5E8F\u53F7"),
11150
- sceneName: stringType().describe("\u573A\u666F\u540D\u79F0"),
11151
- cacheKey: stringType().describe("\u7F13\u5B58Key"),
11152
- expireTime: stringType().describe("\u8FC7\u671F\u65F6\u95F4"),
11153
- description: stringType().describe("\u63CF\u8FF0")
11154
- });
11155
- const CacheDesignSchema = objectType({
11156
- constraint: stringType().describe("\u7EA6\u675F"),
11157
- cacheScenarioList: arrayType(CacheScenarioSchema).default([]).describe("\u4F7F\u7528\u573A\u666F\u5217\u8868"),
11158
- designDescription: stringType().describe("\u65B9\u6848\u8BBE\u8BA1\u63CF\u8FF0")
11180
+ const SubSectionContentSchema = objectType({
11181
+ constraint: stringType().optional().describe("\u7EA6\u675F"),
11182
+ useCase: stringType().optional().describe("\u4F7F\u7528\u573A\u666F"),
11183
+ design: stringType().optional().describe("\u65B9\u6848\u8BBE\u8BA1"),
11184
+ intro: stringType().optional().describe("\u7AE0\u8282\u7B80\u4ECB"),
11185
+ dataEstimation: stringType().optional().describe("\u6570\u636E\u91CF\u4F30\u7B97"),
11186
+ sharding: stringType().optional().describe("\u5206\u5E93\u5206\u8868\u8BBE\u8BA1"),
11187
+ designIdea: stringType().optional().describe("\u8BBE\u8BA1\u601D\u8DEF"),
11188
+ implementation: stringType().optional().describe("\u5177\u4F53\u5B9E\u73B0")
11159
11189
  });
11160
- objectType({
11161
- trafficEstimation: TrafficEstimationSchema.nullable().optional().describe("6.1 \u6D41\u91CF\u4F30\u7B97\u5206\u6790"),
11162
- messageQueueList: arrayType(MessageQueueDesignSchema).default([]).describe("6.2 \u6D88\u606F\u961F\u5217"),
11163
- databaseSplitList: arrayType(DatabaseSplitDesignSchema).default([]).describe("6.3 \u6570\u636E\u5E93\u62C6\u5206\u8BBE\u8BA1"),
11164
- distributedTransactionList: arrayType(DistributedTransactionDesignSchema).default([]).describe("6.4 \u5206\u5E03\u5F0F\u4E8B\u52A1"),
11165
- distributedLockList: arrayType(DistributedLockDesignSchema).default([]).describe("6.5 \u5206\u5E03\u5F0F\u9501"),
11166
- scheduledTaskList: arrayType(ScheduledTaskDesignSchema).default([]).describe("6.6 \u5B9A\u65F6\u4EFB\u52A1"),
11167
- delayTaskList: arrayType(DelayTaskDesignSchema).default([]).describe("6.7 \u5EF6\u65F6\u4EFB\u52A1"),
11168
- cacheDesign: CacheDesignSchema.nullable().optional().describe("6.8 \u7F13\u5B58\u65B9\u6848")
11190
+ const TechSolutionSchema = objectType({
11191
+ content: stringType().optional().describe("\u6280\u672F\u65B9\u6848\u5B8C\u6574\u5185\u5BB9\uFF08\u7B80\u5316\u6A21\u5F0F\uFF09"),
11192
+ trafficEstimation: stringType().optional().describe("6.1 \u6D41\u91CF\u4F30\u7B97\u5206\u6790"),
11193
+ messageQueue: SubSectionContentSchema.optional().describe("6.2 \u6D88\u606F\u961F\u5217"),
11194
+ databaseSplit: SubSectionContentSchema.optional().describe("6.3 \u6570\u636E\u5E93\u62C6\u5206\u8BBE\u8BA1"),
11195
+ distributedTransaction: SubSectionContentSchema.optional().describe("6.4 \u5206\u5E03\u5F0F\u4E8B\u52A1"),
11196
+ distributedLock: SubSectionContentSchema.optional().describe("6.5 \u5206\u5E03\u5F0F\u9501"),
11197
+ scheduledTask: SubSectionContentSchema.optional().describe("6.6 \u5B9A\u65F6\u4EFB\u52A1"),
11198
+ delayTask: SubSectionContentSchema.optional().describe("6.7 \u5EF6\u65F6\u4EFB\u52A1"),
11199
+ cacheDesign: SubSectionContentSchema.optional().describe("6.8 \u7F13\u5B58\u65B9\u6848")
11169
11200
  });
11170
- objectType({
11171
- id: stringType().describe("\u5E8F\u53F7"),
11172
- sceneName: stringType().describe("\u5F02\u5E38\u573A\u666F"),
11173
- exceptionType: stringType().describe("\u5F02\u5E38\u7C7B\u578B"),
11174
- handleStrategy: stringType().describe("\u5904\u7406\u7B56\u7565"),
11175
- description: stringType().describe("\u63CF\u8FF0")
11201
+ const BusinessExceptionSchema = objectType({
11202
+ content: stringType().describe("\u4E1A\u52A1\u5F02\u5E38\u5904\u7406\u5B8C\u6574\u5185\u5BB9")
11176
11203
  });
11177
11204
  const ExceptionCodeSchema = objectType({
11178
- id: stringType().describe("\u5E8F\u53F7"),
11205
+ id: stringType().optional().describe("\u5E8F\u53F7"),
11179
11206
  exceptionCode: stringType().describe("\u5F02\u5E38\u7F16\u7801"),
11180
11207
  exceptionDescription: stringType().describe("\u5F02\u5E38\u63CF\u8FF0")
11181
11208
  });
11182
11209
  const CodeValueSchema = objectType({
11183
- id: stringType().describe("\u5E8F\u53F7"),
11210
+ id: stringType().optional().describe("\u5E8F\u53F7"),
11184
11211
  propertyName: stringType().describe("\u5C5E\u6027"),
11185
11212
  codeValue: stringType().describe("\u7801\u503C")
11186
11213
  });
11187
- objectType({
11188
- exceptionCodeList: arrayType(ExceptionCodeSchema).default([]).describe("8.1 \u5F02\u5E38\u7801\u8868"),
11189
- codeValueList: arrayType(CodeValueSchema).default([]).describe("8.2 \u7801\u503C")
11214
+ const AppendixSchema = objectType({
11215
+ content: stringType().optional().describe("\u9644\u5F55\u5B8C\u6574\u5185\u5BB9\uFF08\u7B80\u5316\u6A21\u5F0F\uFF09"),
11216
+ exceptionCodeList: arrayType(ExceptionCodeSchema).optional().describe("\u5F02\u5E38\u7801\u8868\u5217\u8868"),
11217
+ codeValueList: arrayType(CodeValueSchema).optional().describe("\u7801\u503C\u5217\u8868")
11190
11218
  });
11219
+ function extractDtoTypeName(typeStr) {
11220
+ if (!typeStr) return null;
11221
+ const genericMatch = typeStr.match(/(?:List|Set|Collection|TableDataInfo|PageInfo|Page|R|Result|Response|Optional)<([^<>]+)>/i);
11222
+ if (genericMatch) return extractDtoTypeName(genericMatch[1]) || genericMatch[1];
11223
+ return typeStr;
11224
+ }
11225
+ function isDtoTypeName(typeName) {
11226
+ if (!typeName) return false;
11227
+ return /(?:DTO|Request|Response|Vo|Bo|Dto|Query|Param|Result|Entity|Model|Info|Key|Form)$/i.test(typeName);
11228
+ }
11229
+ function expandDtoFields(fieldList, dtoDefinitions, mode) {
11230
+ const expandedList = [];
11231
+ let idCounter = 1;
11232
+ for (const field of fieldList){
11233
+ const fieldType = field.propertyType || field.type || "";
11234
+ const fieldName = field.propertyName || field.name || "";
11235
+ const fieldDesc = field.propertyDesc || field.description || "";
11236
+ const fieldRequired = field.required || "\u5426";
11237
+ const dtoTypeName = extractDtoTypeName(fieldType);
11238
+ const isDtoType = dtoTypeName && isDtoTypeName(dtoTypeName);
11239
+ let dtoFields = null;
11240
+ if (isDtoType && dtoTypeName) {
11241
+ const possibleNames = [
11242
+ dtoTypeName,
11243
+ dtoTypeName.replace(/Vo$|Bo$|Dto$/i, ""),
11244
+ dtoTypeName.replace(/Vo$/i, "Bo"),
11245
+ dtoTypeName.replace(/Bo$/i, "Vo")
11246
+ ];
11247
+ for (const name of possibleNames)if (dtoDefinitions[name]) {
11248
+ dtoFields = dtoDefinitions[name];
11249
+ break;
11250
+ }
11251
+ }
11252
+ if (dtoFields && dtoFields.length > 0) for (const dtoField of dtoFields){
11253
+ const dtoFieldName = dtoField.name || dtoField.propertyName || dtoField.fieldName || "";
11254
+ const dtoFieldType = dtoField.type || dtoField.propertyType || dtoField.fieldType || "";
11255
+ const dtoFieldDesc = dtoField.description || dtoField.propertyDesc || dtoField.fieldDescription || "";
11256
+ if ("param" === mode) expandedList.push({
11257
+ id: String(idCounter++),
11258
+ propertyType: dtoFieldType,
11259
+ propertyName: `${fieldName}.${dtoFieldName}`,
11260
+ required: dtoField.required || "\u5426",
11261
+ propertyDesc: dtoFieldDesc
11262
+ });
11263
+ else expandedList.push({
11264
+ id: String(idCounter++),
11265
+ propertyType: dtoFieldType,
11266
+ propertyName: `${fieldName}.${dtoFieldName}`,
11267
+ propertyDesc: dtoFieldDesc
11268
+ });
11269
+ }
11270
+ else if ("param" === mode) expandedList.push({
11271
+ id: field.id || String(idCounter++),
11272
+ propertyType: fieldType,
11273
+ propertyName: fieldName,
11274
+ required: fieldRequired,
11275
+ propertyDesc: fieldDesc
11276
+ });
11277
+ else expandedList.push({
11278
+ id: field.id || String(idCounter++),
11279
+ propertyType: fieldType,
11280
+ propertyName: fieldName,
11281
+ propertyDesc: fieldDesc
11282
+ });
11283
+ }
11284
+ return expandedList;
11285
+ }
11286
+ function generateDtoDefinitionsFromTables(tableInfoList) {
11287
+ const definitions = {};
11288
+ if (!Array.isArray(tableInfoList)) return definitions;
11289
+ for (const table of tableInfoList){
11290
+ const entityName = table.entityName || "";
11291
+ if (!entityName) continue;
11292
+ const fields = table.tableDetailList || table.fieldList || table.fields || [];
11293
+ const dtoFields = fields.map((field)=>({
11294
+ name: field.fieldName || "",
11295
+ type: field.fieldType || "",
11296
+ description: field.fieldDescription || field.fieldDesc || "",
11297
+ required: "\u5426"
11298
+ }));
11299
+ const variations = [
11300
+ entityName,
11301
+ `${entityName}Vo`,
11302
+ `${entityName}Bo`,
11303
+ `${entityName}Dto`,
11304
+ `${entityName}Query`,
11305
+ `${entityName}Form`
11306
+ ];
11307
+ for (const name of variations)definitions[name] = dtoFields;
11308
+ }
11309
+ return definitions;
11310
+ }
11191
11311
  function normalizeInputData(input) {
11192
11312
  const result = {
11193
11313
  ...input
@@ -11195,18 +11315,18 @@ ${requirement_description}
11195
11315
  if (Array.isArray(input.tableInfoList)) result.tableInfoList = input.tableInfoList.map((table, tableIndex)=>{
11196
11316
  const normalizedTable = {
11197
11317
  id: table.id || String(tableIndex + 1),
11198
- tableName: table.tableName || '',
11199
- entityName: table.entityName || table.tableName || '',
11200
- tableDescription: table.tableDescription || table.tableComment || table.comment || '',
11318
+ tableName: table.tableName || "",
11319
+ entityName: table.entityName || table.tableName || "",
11320
+ tableDescription: table.tableDescription || table.tableDesc || table.tableComment || table.comment || "",
11201
11321
  tableDetailList: []
11202
11322
  };
11203
- const fieldList = table.tableDetailList || table.fieldList || [];
11323
+ const fieldList = table.tableDetailList || table.fieldList || table.fields || [];
11204
11324
  normalizedTable.tableDetailList = fieldList.map((field, fieldIndex)=>({
11205
11325
  id: field.id || String(fieldIndex + 1),
11206
- fieldName: field.fieldName || '',
11207
- fieldType: field.fieldType || '',
11208
- fieldDescription: field.fieldDescription || field.fieldComment || field.comment || '',
11209
- fieldLength: field.fieldLength || '-'
11326
+ fieldName: field.fieldName || "",
11327
+ fieldType: field.fieldType || "",
11328
+ fieldDescription: field.fieldDescription || field.fieldDesc || field.fieldComment || field.comment || "",
11329
+ fieldLength: field.fieldLength || "-"
11210
11330
  }));
11211
11331
  return normalizedTable;
11212
11332
  });
@@ -11214,141 +11334,328 @@ ${requirement_description}
11214
11334
  if (void 0 !== service.serviceEnglishName) return service;
11215
11335
  const normalizedService = {
11216
11336
  id: service.id || String(serviceIndex + 1),
11217
- serviceType: service.serviceType || 'REST',
11218
- serviceEnglishName: service.interfaceName || service.serviceEnglishName || '',
11219
- serviceChineseName: service.serviceChineseName || service.interfaceComment || service.interfaceName || '',
11220
- serviceDescription: service.serviceDescription || service.interfaceComment || '',
11337
+ serviceType: service.serviceType || "REST",
11338
+ serviceEnglishName: service.interfaceName || service.serviceEnglishName || "",
11339
+ serviceChineseName: service.serviceChineseName || service.interfaceDesc || service.interfaceComment || service.interfaceName || "",
11340
+ serviceDescription: service.serviceDescription || service.interfaceDesc || service.interfaceComment || "",
11221
11341
  interfaceDetailList: []
11222
11342
  };
11223
- const methodList = service.interfaceDetailList || service.methodList || [];
11343
+ const methodList = service.interfaceDetailList || service.methodList || service.methods || [];
11224
11344
  normalizedService.interfaceDetailList = methodList.map((method, methodIndex)=>({
11225
11345
  id: method.id || String(methodIndex + 1),
11226
- functionDescription: method.functionDescription || method.methodComment || method.comment || '',
11227
- serviceName: method.serviceName || service.interfaceName || service.serviceEnglishName || '',
11228
- methodName: method.methodName || ''
11346
+ functionDescription: method.functionDescription || method.methodDesc || method.methodComment || method.comment || "",
11347
+ serviceName: method.serviceName || service.interfaceName || service.serviceEnglishName || "",
11348
+ methodName: method.methodName || ""
11229
11349
  }));
11230
11350
  return normalizedService;
11231
11351
  });
11232
- if (Array.isArray(input.designDetailList)) result.designDetailList = input.designDetailList.map((design)=>{
11233
- if (void 0 !== design.serviceName && void 0 !== design.interfaceDesignDetailList) return design;
11234
- return {
11235
- serviceName: design.designName || design.serviceName || '',
11236
- serviceDesc: design.designDesc || design.serviceDesc || '',
11237
- interfaceDesignDetailList: design.interfaceDesignDetailList || []
11238
- };
11239
- });
11352
+ if (Array.isArray(input.designDetailList)) {
11353
+ let dtoDefinitions = input.dtoDefinitions || {};
11354
+ if (0 === Object.keys(dtoDefinitions).length && Array.isArray(input.tableInfoList)) dtoDefinitions = generateDtoDefinitionsFromTables(input.tableInfoList);
11355
+ result.designDetailList = input.designDetailList.map((design)=>{
11356
+ const normalizedDesign = {
11357
+ serviceName: design.serviceName || design.moduleName || design.designName || "",
11358
+ serviceDesc: design.serviceDesc || design.moduleDesc || design.designDesc || "",
11359
+ interfaceDesignDetailList: []
11360
+ };
11361
+ const interfaceList = design.interfaceDesignDetailList || [];
11362
+ normalizedDesign.interfaceDesignDetailList = interfaceList.map((iface)=>{
11363
+ const expandedParamList = expandDtoFields(iface.parameterList || [], dtoDefinitions, "param");
11364
+ const expandedReturnList = expandDtoFields(iface.returnResultList || [], dtoDefinitions, "return");
11365
+ return {
11366
+ functionName: iface.functionName || "",
11367
+ interfaceDesc: iface.interfaceDesc || "",
11368
+ className: iface.className || "",
11369
+ methodName: iface.methodName || "",
11370
+ parameterList: expandedParamList,
11371
+ returnResultList: expandedReturnList,
11372
+ implementLogic: iface.implementLogic || ""
11373
+ };
11374
+ });
11375
+ return normalizedDesign;
11376
+ });
11377
+ }
11240
11378
  if (Array.isArray(input.businessExceptionList)) result.businessExceptionList = input.businessExceptionList.map((exception, index)=>{
11241
11379
  if (void 0 !== exception.sceneName) return exception;
11242
11380
  return {
11243
11381
  id: exception.id || String(index + 1),
11244
- sceneName: exception.exceptionCode || exception.sceneName || '',
11245
- exceptionType: exception.exceptionType || 'BusinessException',
11246
- handleStrategy: exception.exceptionSolution || exception.handleStrategy || '',
11247
- description: exception.exceptionDesc || exception.description || ''
11382
+ sceneName: exception.sceneName || exception.exceptionCode || "",
11383
+ exceptionType: exception.exceptionType || "BusinessException",
11384
+ handleStrategy: exception.handleStrategy || exception.solution || exception.exceptionSolution || "",
11385
+ description: exception.description || exception.exceptionDesc || ""
11248
11386
  };
11249
11387
  });
11250
- if ('string' == typeof input.techSolution) result.techSolution = {
11251
- trafficEstimation: null,
11252
- messageQueueList: [],
11253
- databaseSplitList: [],
11254
- distributedTransactionList: [],
11255
- distributedLockList: [],
11256
- scheduledTaskList: [],
11257
- delayTaskList: [],
11258
- cacheDesign: {
11259
- constraint: input.techSolution,
11260
- cacheScenarioList: [],
11261
- designDescription: input.techSolution
11262
- }
11388
+ if (input.techSolution) if ("string" == typeof input.techSolution) result.techSolution = {
11389
+ content: input.techSolution
11390
+ };
11391
+ else if (input.techSolution.content) result.techSolution = input.techSolution;
11392
+ else result.techSolution = {
11393
+ content: "\u6280\u672F\u65B9\u6848\u5185\u5BB9\u9700\u8981\u7531MCP\u5BA2\u6237\u7AEF\u751F\u6210"
11394
+ };
11395
+ if (input.businessException) if ("string" == typeof input.businessException) result.businessException = {
11396
+ content: input.businessException
11397
+ };
11398
+ else result.businessException = input.businessException;
11399
+ else if (input.businessExceptionList) result.businessException = {
11400
+ content: "\u4E1A\u52A1\u5F02\u5E38\u5904\u7406\u5185\u5BB9\u9700\u8981\u7531MCP\u5BA2\u6237\u7AEF\u751F\u6210"
11401
+ };
11402
+ if (input.appendix) if ("string" == typeof input.appendix) result.appendix = {
11403
+ content: input.appendix
11404
+ };
11405
+ else if (input.appendix.content) result.appendix = input.appendix;
11406
+ else result.appendix = {
11407
+ content: "\u9644\u5F55\u5185\u5BB9\u9700\u8981\u7531MCP\u5BA2\u6237\u7AEF\u751F\u6210"
11263
11408
  };
11264
11409
  return result;
11265
11410
  }
11266
- const techSpecGeneratorTool = {
11267
- name: "generate_tech_spec",
11268
- description: `\u{6839}\u{636E}\u{4EE3}\u{7801}\u{5206}\u{6790}\u{7ED3}\u{679C}\u{751F}\u{6210}\u{6280}\u{672F}\u{89C4}\u{683C}\u{8BF4}\u{660E}\u{4E66}(Word\u{6587}\u{6863})\u{3002}
11269
-
11270
- \u{89E6}\u{53D1}\u{8BCD}: \u{751F}\u{6210}\u{6280}\u{672F}\u{89C4}\u{683C}\u{3001}\u{6280}\u{672F}\u{89C4}\u{683C}\u{8BF4}\u{660E}\u{4E66}\u{3001}\u{751F}\u{6210}\u{6280}\u{672F}\u{6587}\u{6863}\u{3001}\u{6280}\u{672F}spec\u{3001}\u{4EE3}\u{7801}\u{6587}\u{6863}\u{5316}\u{3001}\u{751F}\u{6210}\u{89C4}\u{683C}\u{4E66}\u{3001}\u{6280}\u{672F}\u{8BF4}\u{660E}\u{4E66}
11271
-
11272
- \u{9002}\u{7528}\u{573A}\u{666F}:
11273
- - \u{9700}\u{8981}\u{4E3A}\u{9879}\u{76EE}/\u{6A21}\u{5757}\u{751F}\u{6210}\u{6B63}\u{5F0F}\u{7684}\u{6280}\u{672F}\u{89C4}\u{683C}\u{8BF4}\u{660E}\u{4E66}
11274
- - \u{9700}\u{8981}\u{5C06}\u{4EE3}\u{7801}\u{7ED3}\u{6784}\u{6587}\u{6863}\u{5316}\u{4E3A}Word\u{683C}\u{5F0F}
11275
- - \u{9879}\u{76EE}\u{4EA4}\u{4ED8}\u{9700}\u{8981}\u{6280}\u{672F}\u{6587}\u{6863}
11276
-
11277
- \u{8F93}\u{5165}\u{8981}\u{6C42}: \u{9700}\u{8981}\u{5148}\u{5206}\u{6790}\u{4EE3}\u{7801}\u{76EE}\u{5F55}\u{FF0C}\u{6536}\u{96C6}\u{6570}\u{636E}\u{8868}\u{8BBE}\u{8BA1}\u{3001}\u{670D}\u{52A1}\u{63A5}\u{53E3}\u{3001}\u{529F}\u{80FD}\u{8BBE}\u{8BA1}\u{7B49}\u{4FE1}\u{606F}
11278
- \u{8F93}\u{51FA}: Word\u{683C}\u{5F0F}\u{7684}\u{6280}\u{672F}\u{89C4}\u{683C}\u{8BF4}\u{660E}\u{4E66}(.docx)\u{FF0C}\u{4FDD}\u{5B58}\u{5230} .aico/tech/ \u{76EE}\u{5F55}`,
11411
+ const analyzeProjectContextTool = {
11412
+ name: "analyze_project_context",
11413
+ description: "\u5206\u6790\u9879\u76EE\u4E0A\u4E0B\u6587\u4FE1\u606F\uFF0C\u4E3A\u6280\u672F\u89C4\u683C\u8BF4\u660E\u4E66\u751F\u6210\u505A\u51C6\u5907",
11279
11414
  inputSchema: {
11280
- projectPath: stringType().min(1).describe("\u5F53\u524D\u9879\u76EE\u8DEF\u5F84\uFF0C\u751F\u6210\u7684\u6280\u672F\u89C4\u683C\u8BF4\u660E\u4E66\u4FDD\u5B58\u5230\u8BE5\u8DEF\u5F84\u4E0B\u7684.aico/tech\u76EE\u5F55"),
11281
- techSpecData: unionType([
11282
- stringType(),
11283
- objectType({
11284
- projectName: stringType().describe("\u9879\u76EE\u540D\u79F0"),
11285
- moduleName: stringType().describe("\u6A21\u5757\u540D\u79F0"),
11286
- year: stringType().optional().describe("\u5E74\u4EFD\uFF0C\u9ED8\u8BA4\u5F53\u524D\u5E74\u4EFD"),
11287
- month: stringType().optional().describe("\u6708\u4EFD\uFF0C\u9ED8\u8BA4\u5F53\u524D\u6708\u4EFD"),
11288
- referDoc: stringType().optional().describe("\u53C2\u8003\u6587\u6863"),
11289
- serviceInterfaceList: arrayType(anyType()).default([]).describe("\u670D\u52A1\u63A5\u53E3\u6E05\u5355"),
11290
- designDetailList: arrayType(anyType()).default([]).describe("\u670D\u52A1\u63A5\u53E3\u8BBE\u8BA1\u8BE6\u60C5"),
11291
- tableInfoList: arrayType(anyType()).default([]).describe("\u6570\u636E\u5E93\u8868\u4FE1\u606F\u5217\u8868"),
11292
- techSolution: anyType().optional().describe("\u7B2C6\u7AE0-\u6280\u672F\u65B9\u6848"),
11293
- businessExceptionList: arrayType(anyType()).default([]).describe("\u7B2C7\u7AE0-\u4E1A\u52A1\u5F02\u5E38\u5904\u7406\u5217\u8868"),
11294
- appendix: anyType().optional().describe("\u7B2C8\u7AE0-\u9644\u5F55")
11295
- }).passthrough()
11296
- ]).describe("\u6280\u672F\u89C4\u683C\u6570\u636E(JSON\u5BF9\u8C61\u6216JSON\u5B57\u7B26\u4E32)\uFF0C\u5305\u542B: projectName(\u9879\u76EE\u540D), moduleName(\u6A21\u5757\u540D), tableInfoList(\u6570\u636E\u8868), serviceInterfaceList(\u670D\u52A1\u63A5\u53E3), designDetailList(\u8BBE\u8BA1\u8BE6\u60C5)")
11415
+ projectPath: stringType().min(1).describe(PROJECT_PATH_DESCRIPTION)
11416
+ },
11417
+ handler: async (args)=>{
11418
+ const { projectPath } = args;
11419
+ if (!projectPath) return {
11420
+ content: [
11421
+ {
11422
+ type: "text",
11423
+ text: JSON.stringify({
11424
+ success: false,
11425
+ message: "\u7F3A\u5C11\u5FC5\u586B\u53C2\u6570\uFF1AprojectPath"
11426
+ })
11427
+ }
11428
+ ],
11429
+ isError: true
11430
+ };
11431
+ return {
11432
+ content: [
11433
+ {
11434
+ type: "text",
11435
+ text: JSON.stringify({
11436
+ success: true,
11437
+ message: "\u9879\u76EE\u4E0A\u4E0B\u6587\u5206\u6790\u6307\u5BFC",
11438
+ data: {
11439
+ analysisSteps: [
11440
+ {
11441
+ step: 1,
11442
+ action: "\u8BFB\u53D6\u9879\u76EE\u6587\u6863",
11443
+ files: [
11444
+ `${projectPath}/README.md`,
11445
+ `${projectPath}/package.json`
11446
+ ]
11447
+ },
11448
+ {
11449
+ step: 2,
11450
+ action: "\u5206\u6790\u9879\u76EE\u7ED3\u6784",
11451
+ directories: [
11452
+ `${projectPath}/src`
11453
+ ]
11454
+ }
11455
+ ],
11456
+ nextStep: "\u8C03\u7528 generate_final_document \u751F\u6210\u6280\u672F\u89C4\u683C\u8BF4\u660E\u4E66"
11457
+ }
11458
+ })
11459
+ }
11460
+ ]
11461
+ };
11462
+ }
11463
+ };
11464
+ const collectServiceInterfacesTool = {
11465
+ name: "collect_service_interfaces",
11466
+ description: "\u6536\u96C6\u9879\u76EE\u4E2D\u7684\u670D\u52A1\u63A5\u53E3\u6E05\u5355",
11467
+ inputSchema: {
11468
+ projectPath: stringType().min(1).describe(PROJECT_PATH_DESCRIPTION)
11469
+ },
11470
+ handler: async (args)=>({
11471
+ content: [
11472
+ {
11473
+ type: "text",
11474
+ text: JSON.stringify({
11475
+ success: true,
11476
+ message: "\u670D\u52A1\u63A5\u53E3\u6536\u96C6\u6307\u5BFC",
11477
+ data: {
11478
+ scanTargets: [
11479
+ "**/*Controller.{ts,js}",
11480
+ "**/*Service.{ts,js}"
11481
+ ],
11482
+ nextStep: "\u8C03\u7528 generate_final_document \u751F\u6210\u6280\u672F\u89C4\u683C\u8BF4\u660E\u4E66"
11483
+ }
11484
+ })
11485
+ }
11486
+ ]
11487
+ })
11488
+ };
11489
+ const generateInterfaceDesignsTool = {
11490
+ name: "generate_interface_designs",
11491
+ description: "\u57FA\u4E8E\u670D\u52A1\u63A5\u53E3\u6E05\u5355\u751F\u6210\u8BE6\u7EC6\u7684\u63A5\u53E3\u8BBE\u8BA1",
11492
+ inputSchema: {
11493
+ projectPath: stringType().min(1).describe(PROJECT_PATH_DESCRIPTION),
11494
+ serviceInterfaceList: arrayType(ServiceInterfaceSchema).describe("\u670D\u52A1\u63A5\u53E3\u6E05\u5355")
11495
+ },
11496
+ handler: async (args)=>({
11497
+ content: [
11498
+ {
11499
+ type: "text",
11500
+ text: JSON.stringify({
11501
+ success: true,
11502
+ message: "\u63A5\u53E3\u8BBE\u8BA1\u8BE6\u60C5\u751F\u6210\u6307\u5BFC",
11503
+ data: {
11504
+ designPrinciples: [
11505
+ "\u53C2\u6570\u7C7B\u578B\u5FC5\u987B\u5C55\u5F00\u5177\u4F53\u5B57\u6BB5\uFF0C\u7981\u6B62\u4F7F\u7528DTO\u7B49\u7B80\u5316\u540D\u79F0"
11506
+ ],
11507
+ nextStep: "\u8C03\u7528 generate_final_document \u751F\u6210\u6280\u672F\u89C4\u683C\u8BF4\u660E\u4E66"
11508
+ }
11509
+ })
11510
+ }
11511
+ ]
11512
+ })
11513
+ };
11514
+ const collectDatabaseSchemaTool = {
11515
+ name: "collect_database_schema",
11516
+ description: "\u6536\u96C6\u9879\u76EE\u7684\u6570\u636E\u5E93\u8868\u7ED3\u6784\u4FE1\u606F",
11517
+ inputSchema: {
11518
+ projectPath: stringType().min(1).describe(PROJECT_PATH_DESCRIPTION)
11519
+ },
11520
+ handler: async (args)=>({
11521
+ content: [
11522
+ {
11523
+ type: "text",
11524
+ text: JSON.stringify({
11525
+ success: true,
11526
+ message: "\u6570\u636E\u5E93\u7ED3\u6784\u6536\u96C6\u6307\u5BFC",
11527
+ data: {
11528
+ scanTargets: [
11529
+ "**/migrations/**/*.sql",
11530
+ "**/*Entity.{ts,js}"
11531
+ ],
11532
+ nextStep: "\u8C03\u7528 generate_final_document \u751F\u6210\u6280\u672F\u89C4\u683C\u8BF4\u660E\u4E66"
11533
+ }
11534
+ })
11535
+ }
11536
+ ]
11537
+ })
11538
+ };
11539
+ const analyzeTechSolutionTool = {
11540
+ name: "analyze_tech_solution",
11541
+ description: "\u5206\u6790\u9879\u76EE\u7684\u6280\u672F\u65B9\u6848\uFF0C\u6839\u636E\u5B9E\u9645\u60C5\u51B5\u751F\u6210\u6280\u672F\u67B6\u6784\u8BBE\u8BA1",
11542
+ inputSchema: {
11543
+ projectPath: stringType().min(1).describe(PROJECT_PATH_DESCRIPTION)
11544
+ },
11545
+ handler: async (args)=>({
11546
+ content: [
11547
+ {
11548
+ type: "text",
11549
+ text: JSON.stringify({
11550
+ success: true,
11551
+ message: "\u6280\u672F\u65B9\u6848\u5206\u6790\u6307\u5BFC",
11552
+ data: {
11553
+ analysisAreas: [
11554
+ "\u6D41\u91CF\u4F30\u7B97\u5206\u6790",
11555
+ "\u6280\u672F\u67B6\u6784\u8BBE\u8BA1",
11556
+ "\u4E2D\u95F4\u4EF6\u9009\u578B"
11557
+ ],
11558
+ nextStep: "\u8C03\u7528 generate_final_document \u751F\u6210\u6280\u672F\u89C4\u683C\u8BF4\u660E\u4E66"
11559
+ }
11560
+ })
11561
+ }
11562
+ ]
11563
+ })
11564
+ };
11565
+ const collectBusinessExceptionsTool = {
11566
+ name: "collect_business_exceptions",
11567
+ description: "\u6536\u96C6\u9879\u76EE\u4E2D\u7684\u4E1A\u52A1\u5F02\u5E38\u5904\u7406\u60C5\u51B5",
11568
+ inputSchema: {
11569
+ projectPath: stringType().min(1).describe(PROJECT_PATH_DESCRIPTION)
11570
+ },
11571
+ handler: async (args)=>({
11572
+ content: [
11573
+ {
11574
+ type: "text",
11575
+ text: JSON.stringify({
11576
+ success: true,
11577
+ message: "\u4E1A\u52A1\u5F02\u5E38\u5904\u7406\u6536\u96C6\u6307\u5BFC",
11578
+ data: {
11579
+ scanTargets: [
11580
+ "**/*Exception.{ts,js}",
11581
+ "**/errors/**/*.{ts,js}"
11582
+ ],
11583
+ nextStep: "\u8C03\u7528 generate_final_document \u751F\u6210\u6280\u672F\u89C4\u683C\u8BF4\u660E\u4E66"
11584
+ }
11585
+ })
11586
+ }
11587
+ ]
11588
+ })
11589
+ };
11590
+ const generateAppendixTool = {
11591
+ name: "generate_appendix",
11592
+ description: "\u751F\u6210\u6280\u672F\u89C4\u683C\u8BF4\u660E\u4E66\u7684\u9644\u5F55\u5185\u5BB9",
11593
+ inputSchema: {
11594
+ projectPath: stringType().min(1).describe(PROJECT_PATH_DESCRIPTION)
11595
+ },
11596
+ handler: async (args)=>({
11597
+ content: [
11598
+ {
11599
+ type: "text",
11600
+ text: JSON.stringify({
11601
+ success: true,
11602
+ message: "\u9644\u5F55\u5185\u5BB9\u751F\u6210\u6307\u5BFC",
11603
+ data: {
11604
+ contentAreas: [
11605
+ "\u9519\u8BEF\u7801\u8868",
11606
+ "\u914D\u7F6E\u53C2\u6570\u8868",
11607
+ "\u6570\u636E\u5B57\u5178",
11608
+ "\u6280\u672F\u672F\u8BED\u8868"
11609
+ ],
11610
+ nextStep: "\u8C03\u7528 generate_final_document \u751F\u6210\u6280\u672F\u89C4\u683C\u8BF4\u660E\u4E66"
11611
+ }
11612
+ })
11613
+ }
11614
+ ]
11615
+ })
11616
+ };
11617
+ const generateFinalDocumentTool = {
11618
+ name: "generate_final_document",
11619
+ description: "\u6574\u5408\u6240\u6709\u6536\u96C6\u7684\u4FE1\u606F\uFF0C\u751F\u6210\u5B8C\u6574\u7684\u6280\u672F\u89C4\u683C\u8BF4\u660E\u4E66",
11620
+ inputSchema: {
11621
+ projectPath: stringType().min(1).describe(PROJECT_PATH_DESCRIPTION),
11622
+ techSpecData: objectType({
11623
+ projectName: stringType().describe("\u9879\u76EE\u540D\u79F0"),
11624
+ moduleName: stringType().describe("\u6A21\u5757\u540D\u79F0"),
11625
+ year: stringType().optional().describe("\u5E74\u4EFD\uFF0C\u9ED8\u8BA4\u5F53\u524D\u5E74\u4EFD"),
11626
+ month: stringType().optional().describe("\u6708\u4EFD\uFF0C\u9ED8\u8BA4\u5F53\u524D\u6708\u4EFD"),
11627
+ referDoc: stringType().optional().describe("\u53C2\u8003\u6587\u6863"),
11628
+ serviceInterfaceList: arrayType(ServiceInterfaceSchema).default([]).describe("\u670D\u52A1\u63A5\u53E3\u6E05\u5355"),
11629
+ designDetailList: arrayType(DesignDetailSchema).default([]).describe("\u670D\u52A1\u63A5\u53E3\u8BBE\u8BA1\u8BE6\u60C5"),
11630
+ tableInfoList: arrayType(TableInfoSchema).default([]).describe("\u6570\u636E\u5E93\u8868\u4FE1\u606F\u5217\u8868"),
11631
+ techSolution: TechSolutionSchema.optional().describe("\u6280\u672F\u65B9\u6848"),
11632
+ businessException: BusinessExceptionSchema.optional().describe("\u4E1A\u52A1\u5F02\u5E38\u5904\u7406"),
11633
+ appendix: AppendixSchema.optional().describe("\u9644\u5F55"),
11634
+ dtoDefinitions: recordType(stringType(), arrayType(objectType({
11635
+ name: stringType().optional().describe("\u5B57\u6BB5\u540D"),
11636
+ type: stringType().optional().describe("\u5B57\u6BB5\u7C7B\u578B"),
11637
+ required: stringType().optional().describe("\u662F\u5426\u5FC5\u586B"),
11638
+ description: stringType().optional().describe("\u5B57\u6BB5\u63CF\u8FF0")
11639
+ }))).optional().describe("DTO\u5B9A\u4E49\u6620\u5C04\uFF0C\u7528\u4E8E\u5C55\u5F00\u63A5\u53E3\u53C2\u6570\u4E2D\u7684DTO\u4E3A\u5177\u4F53\u5B57\u6BB5")
11640
+ }).describe("\u5B8C\u6574\u7684\u6280\u672F\u89C4\u683C\u6570\u636E")
11297
11641
  },
11298
11642
  handler: async (args)=>{
11299
11643
  try {
11300
11644
  const { projectPath } = args;
11301
11645
  let { techSpecData } = args;
11302
- if (!projectPath) return {
11646
+ if (!projectPath || !techSpecData) return {
11303
11647
  content: [
11304
11648
  {
11305
11649
  type: "text",
11306
11650
  text: JSON.stringify({
11307
11651
  success: false,
11308
- message: "\u7F3A\u5C11\u5FC5\u586B\u53C2\u6570\uFF1AprojectPath",
11309
- data: null
11652
+ message: "\u7F3A\u5C11\u5FC5\u586B\u53C2\u6570"
11310
11653
  })
11311
11654
  }
11312
11655
  ],
11313
11656
  isError: true
11314
11657
  };
11315
- if (!techSpecData) return {
11316
- content: [
11317
- {
11318
- type: "text",
11319
- text: JSON.stringify({
11320
- success: false,
11321
- message: "\u7F3A\u5C11\u5FC5\u586B\u53C2\u6570\uFF1AtechSpecData",
11322
- data: null
11323
- })
11324
- }
11325
- ],
11326
- isError: true
11327
- };
11328
- logger.info("\u63A5\u6536\u5230\u7684 techSpecData \u7C7B\u578B", {
11329
- type: typeof techSpecData
11330
- });
11331
- logger.info("\u63A5\u6536\u5230\u7684 techSpecData \u5185\u5BB9", {
11332
- data: JSON.stringify(techSpecData).substring(0, 500)
11333
- });
11334
- if ("string" == typeof techSpecData) try {
11335
- techSpecData = JSON.parse(techSpecData);
11336
- logger.info("techSpecData \u4ECE\u5B57\u7B26\u4E32\u89E3\u6790\u4E3A\u5BF9\u8C61");
11337
- } catch (parseError) {
11338
- return {
11339
- content: [
11340
- {
11341
- type: "text",
11342
- text: JSON.stringify({
11343
- success: false,
11344
- message: "techSpecData \u53C2\u6570\u683C\u5F0F\u9519\u8BEF\uFF0C\u5E94\u4E3A JSON \u5BF9\u8C61",
11345
- data: null
11346
- })
11347
- }
11348
- ],
11349
- isError: true
11350
- };
11351
- }
11658
+ if ("string" == typeof techSpecData) techSpecData = JSON.parse(techSpecData);
11352
11659
  const now = new Date();
11353
11660
  const normalizedData = normalizeInputData(techSpecData);
11354
11661
  const data = {
@@ -11361,21 +11668,10 @@ ${requirement_description}
11361
11668
  designDetailList: normalizedData.designDetailList || [],
11362
11669
  tableInfoList: normalizedData.tableInfoList || [],
11363
11670
  techSolution: normalizedData.techSolution || void 0,
11364
- businessExceptionList: normalizedData.businessExceptionList || [],
11671
+ businessException: normalizedData.businessException || void 0,
11365
11672
  appendix: normalizedData.appendix || void 0
11366
11673
  };
11367
- const outputDir = external_path_namespaceObject.join(projectPath, ".aico", "tech");
11368
- logger.info("\u5F00\u59CB\u751F\u6210\u6280\u672F\u89C4\u683C\u8BF4\u660E\u4E66", {
11369
- projectPath,
11370
- outputDir,
11371
- projectName: data.projectName,
11372
- moduleName: data.moduleName,
11373
- tableCount: data.tableInfoList.length,
11374
- serviceCount: data.serviceInterfaceList.length,
11375
- hasTechSolution: !!data.techSolution,
11376
- businessExceptionCount: data.businessExceptionList?.length || 0,
11377
- hasAppendix: !!data.appendix
11378
- });
11674
+ const outputDir = getTechSpecOutputDir(projectPath);
11379
11675
  const result = await renderTechSpecDoc(data, outputDir);
11380
11676
  if (result.success) return {
11381
11677
  content: [
@@ -11393,9 +11689,8 @@ ${requirement_description}
11393
11689
  serviceCount: data.serviceInterfaceList.length,
11394
11690
  designCount: data.designDetailList.length,
11395
11691
  hasTechSolution: !!data.techSolution,
11396
- businessExceptionCount: data.businessExceptionList?.length || 0,
11397
- exceptionCodeCount: data.appendix?.exceptionCodeList?.length || 0,
11398
- codeValueCount: data.appendix?.codeValueList?.length || 0
11692
+ hasBusinessException: !!data.businessException,
11693
+ hasAppendix: !!data.appendix
11399
11694
  }
11400
11695
  }
11401
11696
  })
@@ -11408,25 +11703,20 @@ ${requirement_description}
11408
11703
  type: "text",
11409
11704
  text: JSON.stringify({
11410
11705
  success: false,
11411
- message: result.error || "\u6587\u6863\u751F\u6210\u5931\u8D25",
11412
- data: null
11706
+ message: result.error || "\u6587\u6863\u751F\u6210\u5931\u8D25"
11413
11707
  })
11414
11708
  }
11415
11709
  ],
11416
11710
  isError: true
11417
11711
  };
11418
11712
  } catch (error) {
11419
- logger.error("\u6280\u672F\u89C4\u683C\u8BF4\u660E\u4E66\u751F\u6210\u5F02\u5E38", {
11420
- error: error.message
11421
- });
11422
11713
  return {
11423
11714
  content: [
11424
11715
  {
11425
11716
  type: "text",
11426
11717
  text: JSON.stringify({
11427
11718
  success: false,
11428
- message: error.message || "\u751F\u6210\u8FC7\u7A0B\u4E2D\u53D1\u751F\u9519\u8BEF",
11429
- data: null
11719
+ message: error.message || "\u751F\u6210\u8FC7\u7A0B\u4E2D\u53D1\u751F\u9519\u8BEF"
11430
11720
  })
11431
11721
  }
11432
11722
  ],
@@ -11435,6 +11725,16 @@ ${requirement_description}
11435
11725
  }
11436
11726
  }
11437
11727
  };
11728
+ const techSpecGeneratorTools = [
11729
+ analyzeProjectContextTool,
11730
+ collectServiceInterfacesTool,
11731
+ generateInterfaceDesignsTool,
11732
+ collectDatabaseSchemaTool,
11733
+ analyzeTechSolutionTool,
11734
+ collectBusinessExceptionsTool,
11735
+ generateAppendixTool,
11736
+ generateFinalDocumentTool
11737
+ ];
11438
11738
  function createMcpServer() {
11439
11739
  const server = new mcp_js_namespaceObject.McpServer({
11440
11740
  name: SERVICE_CONFIG.name,
@@ -11453,7 +11753,7 @@ ${requirement_description}
11453
11753
  requirementIdentifierTool,
11454
11754
  requirementAlignerTool,
11455
11755
  taskExecutorTool,
11456
- techSpecGeneratorTool
11756
+ ...techSpecGeneratorTools
11457
11757
  ];
11458
11758
  tools.forEach((tool)=>{
11459
11759
  server.tool(tool.name, tool.description, tool.inputSchema, tool.handler);