intention-coding 0.0.5 → 0.0.7

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
@@ -144,11 +144,96 @@ __webpack_require__.d(external_namespaceObject, {
144
144
  void: ()=>voidType
145
145
  });
146
146
  const external_fastmcp_namespaceObject = require("fastmcp");
147
+ const external_winston_namespaceObject = require("winston");
148
+ var external_winston_default = /*#__PURE__*/ __webpack_require__.n(external_winston_namespaceObject);
149
+ const external_winston_daily_rotate_file_namespaceObject = require("winston-daily-rotate-file");
150
+ var external_winston_daily_rotate_file_default = /*#__PURE__*/ __webpack_require__.n(external_winston_daily_rotate_file_namespaceObject);
151
+ const external_path_namespaceObject = require("path");
152
+ var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
153
+ const external_fs_namespaceObject = require("fs");
154
+ var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_namespaceObject);
155
+ external_path_default().join(process.cwd(), '.aico');
156
+ const getStorageDir = ()=>{
157
+ const envDir = process.env.MCP_STORAGE_DIR + "/.aico";
158
+ if (!external_fs_namespaceObject.existsSync(envDir)) external_fs_namespaceObject.mkdirSync(envDir, {
159
+ recursive: true
160
+ });
161
+ return envDir;
162
+ };
147
163
  const SERVICE_CONFIG = {
148
- name: "intention-coding",
149
- version: "1.0.0",
164
+ name: "\u667A\u80FD\u8F6F\u4EF6\u661F\u5DE5\u5382",
165
+ version: "0.0.1",
150
166
  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"
151
167
  };
168
+ const logDir = getStorageDir() + '/logs';
169
+ const levels = {
170
+ error: 0,
171
+ warn: 1,
172
+ info: 2,
173
+ debug: 3,
174
+ verbose: 4
175
+ };
176
+ const colors = {
177
+ error: 'red',
178
+ warn: 'yellow',
179
+ info: 'green',
180
+ debug: 'blue',
181
+ verbose: 'cyan'
182
+ };
183
+ external_winston_default().addColors(colors);
184
+ const consoleFormat = external_winston_default().format.combine(external_winston_default().format.timestamp({
185
+ format: 'YYYY-MM-DD HH:mm:ss'
186
+ }), external_winston_default().format.colorize(), external_winston_default().format.printf(({ timestamp, level, message })=>`${timestamp} [${level}]: ${message}`));
187
+ const fileFormat = external_winston_default().format.combine(external_winston_default().format.timestamp(), external_winston_default().format.json());
188
+ const transports = [
189
+ new (external_winston_default()).transports.Console({
190
+ format: consoleFormat,
191
+ level: 'verbose'
192
+ }),
193
+ new (external_winston_daily_rotate_file_default())({
194
+ filename: external_path_default().join(logDir, 'application-%DATE%.log'),
195
+ datePattern: 'YYYY-MM-DD',
196
+ zippedArchive: true,
197
+ maxSize: '20m',
198
+ maxFiles: '14d',
199
+ format: fileFormat,
200
+ level: 'info'
201
+ })
202
+ ];
203
+ const logger_logger = external_winston_default().createLogger({
204
+ level: 'debug',
205
+ levels,
206
+ format: external_winston_default().format.combine(external_winston_default().format.errors({
207
+ stack: true
208
+ }), external_winston_default().format.splat()),
209
+ transports,
210
+ exceptionHandlers: [
211
+ new (external_winston_daily_rotate_file_default())({
212
+ filename: external_path_default().join(logDir, 'exceptions-%DATE%.log'),
213
+ datePattern: 'YYYY-MM-DD',
214
+ zippedArchive: true,
215
+ maxSize: '1m',
216
+ maxFiles: '14d',
217
+ format: fileFormat
218
+ })
219
+ ],
220
+ rejectionHandlers: [
221
+ new (external_winston_daily_rotate_file_default())({
222
+ filename: external_path_default().join(logDir, 'rejections-%DATE%.log'),
223
+ datePattern: 'YYYY-MM-DD',
224
+ zippedArchive: true,
225
+ maxSize: '1m',
226
+ maxFiles: '14d',
227
+ format: fileFormat
228
+ })
229
+ ]
230
+ });
231
+ process.on('SIGINT', ()=>{
232
+ logger_logger.end(()=>{
233
+ console.log("\u65E5\u5FD7\u5DF2\u5173\u95ED");
234
+ process.exit(0);
235
+ });
236
+ });
152
237
  var util_util;
153
238
  (function(util) {
154
239
  util.assertEqual = (_)=>{};
@@ -3815,7 +3900,7 @@ const v3 = external_namespaceObject;
3815
3900
  const esm = v3;
3816
3901
  const RequirementClarifierParams = objectType({
3817
3902
  user_input: stringType().describe("\u7528\u6237\u8F93\u5165\u7684\u9700\u6C42\u63CF\u8FF0"),
3818
- context: stringType().optional().describe("\u9700\u6C42\u4E0A\u4E0B\u6587\u4FE1\u606F")
3903
+ file_path: stringType().describe("\u5982\u679C\u9700\u6C42\u63CF\u8FF0\u6765\u81EA\u6587\u6863\uFF0C\u9700\u8981\u63D0\u4F9B\u6587\u6863\u8F6C\u6362\u4E3Amd\u683C\u5F0F\u540E\u7684\u6587\u6863\u7684\u7EDD\u5BF9\u8DEF\u5F84")
3819
3904
  });
3820
3905
  const RequirementManagerParams = objectType({
3821
3906
  clarified_info: stringType().describe("\u6F84\u6E05\u540E\u7684\u9700\u6C42\u4FE1\u606F"),
@@ -3834,9 +3919,277 @@ const RequirementManagerParams = objectType({
3834
3919
  const ArchitectureDesignerParams = objectType({
3835
3920
  design_focus: stringType().optional().default("full_architecture").describe("\u8BBE\u8BA1\u91CD\u70B9")
3836
3921
  });
3837
- const external_fs_namespaceObject = require("fs");
3838
- var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_namespaceObject);
3839
- const external_path_namespaceObject = require("path");
3922
+ async function invokeFlow(params, streamCb) {
3923
+ const { appid = 'app-ESTcrkOPOmkxdrO0120mE4s1', data, timeout = 1800000 } = params;
3924
+ const controller = new AbortController();
3925
+ const signal = controller.signal;
3926
+ const fetchData = async (retryCount = 0)=>{
3927
+ try {
3928
+ const fetchOptions = {
3929
+ method: 'POST',
3930
+ headers: {
3931
+ Authorization: `Bearer ${appid}`,
3932
+ 'Content-Type': 'application/json'
3933
+ },
3934
+ body: JSON.stringify({
3935
+ inputs: data,
3936
+ response_mode: 'streaming',
3937
+ user: "aico-mcp"
3938
+ }),
3939
+ signal
3940
+ };
3941
+ const res = await fetch('http://11.0.166.20:9199/v1/workflows/run', fetchOptions);
3942
+ if (!res.ok) {
3943
+ if (retryCount < 3) {
3944
+ await new Promise((resolve)=>setTimeout(resolve, 1000));
3945
+ return fetchData(retryCount + 1);
3946
+ }
3947
+ const errorResponse = await res.text();
3948
+ throw new Error(`\u{7F51}\u{7EDC}\u{54CD}\u{5E94}\u{5F02}\u{5E38}: ${res.status} ${res.statusText} - ${errorResponse}`);
3949
+ }
3950
+ if (res.ok) if (res.body) {
3951
+ const reader = res.body.getReader();
3952
+ const decoder = new TextDecoder('utf-8');
3953
+ if (streamCb) return void new ReadableStream({
3954
+ start (controller) {
3955
+ let buffer = '';
3956
+ function push() {
3957
+ reader.read().then(({ done, value })=>{
3958
+ if (done) {
3959
+ const lines = buffer.split('\n');
3960
+ for (const line of lines)handleLine(line, controller);
3961
+ if (streamCb) streamCb({
3962
+ isEnd: true
3963
+ });
3964
+ controller.close();
3965
+ return;
3966
+ }
3967
+ const chunkText = decoder.decode(value, {
3968
+ stream: true
3969
+ });
3970
+ buffer += chunkText;
3971
+ const lines = buffer.split('\n');
3972
+ for(let i = 0; i < lines.length - 1; i++)handleLine(lines[i], controller);
3973
+ buffer = lines[lines.length - 1];
3974
+ push();
3975
+ });
3976
+ }
3977
+ function handleLine(line, controller) {
3978
+ line = line.trim();
3979
+ if (line.startsWith('data:')) {
3980
+ const dataStr = line.slice(5).trim();
3981
+ if ('' === dataStr) return;
3982
+ try {
3983
+ var _jsonData_data;
3984
+ const jsonData = JSON.parse(dataStr);
3985
+ if (null == (_jsonData_data = jsonData.data) ? void 0 : _jsonData_data.text) {
3986
+ const wrappedData = {
3987
+ content: jsonData.data.text.toString(),
3988
+ controller
3989
+ };
3990
+ if (streamCb) streamCb(wrappedData);
3991
+ }
3992
+ } catch (e) {
3993
+ console.error("\u89E3\u6790JSON\u5931\u8D25:", e);
3994
+ }
3995
+ }
3996
+ }
3997
+ push();
3998
+ }
3999
+ });
4000
+ {
4001
+ let buffer = '';
4002
+ let accumulatedText = '';
4003
+ let isResponseEnded = false;
4004
+ const readAll = async ()=>{
4005
+ const { done, value } = await reader.read();
4006
+ if (done) {
4007
+ if (!isResponseEnded) throw new Error("\u54CD\u5E94\u63D0\u524D\u7ED3\u675F");
4008
+ return accumulatedText;
4009
+ }
4010
+ const chunkText = decoder.decode(value, {
4011
+ stream: true
4012
+ });
4013
+ buffer += chunkText;
4014
+ const lines = buffer.split('\n');
4015
+ for(let i = 0; i < lines.length - 1; i++){
4016
+ const line = lines[i].trim();
4017
+ if (!line.startsWith('data:')) continue;
4018
+ const dataStr = line.slice(5).trim();
4019
+ if ('' !== dataStr) try {
4020
+ const jsonData = JSON.parse(dataStr);
4021
+ switch(jsonData.event){
4022
+ case 'message':
4023
+ case 'agent_message':
4024
+ case 'text_chunk':
4025
+ {
4026
+ const content = 'text_chunk' === jsonData.event ? jsonData.data.text : jsonData.answer;
4027
+ accumulatedText += content;
4028
+ break;
4029
+ }
4030
+ case 'workflow_finished':
4031
+ accumulatedText = jsonData.data;
4032
+ isResponseEnded = true;
4033
+ break;
4034
+ case 'message_end':
4035
+ isResponseEnded = true;
4036
+ break;
4037
+ case 'error':
4038
+ throw new Error(`\u{670D}\u{52A1}\u{5668}\u{9519}\u{8BEF}: ${jsonData.code}, ${jsonData.message}`);
4039
+ default:
4040
+ break;
4041
+ }
4042
+ } catch (e) {
4043
+ throw new Error("\u89E3\u6790JSON\u5931\u8D25: " + e.message);
4044
+ }
4045
+ }
4046
+ buffer = lines[lines.length - 1];
4047
+ return readAll();
4048
+ };
4049
+ return readAll();
4050
+ }
4051
+ } else throw new Error("\u54CD\u5E94\u4F53\u4E3A\u7A7A");
4052
+ {
4053
+ const errorResponse = await res.text();
4054
+ throw new Error(`\u{7F51}\u{7EDC}\u{54CD}\u{5E94}\u{5F02}\u{5E38}: ${res.status} ${res.statusText} - ${errorResponse}`);
4055
+ }
4056
+ } catch (error) {
4057
+ if ('AbortError' === error.name) throw new Error("\u8BF7\u6C42\u5DF2\u88AB\u4E2D\u6B62\uFF0C\u8D85\u65F6");
4058
+ throw error;
4059
+ }
4060
+ };
4061
+ try {
4062
+ const result = await Promise.race([
4063
+ fetchData(),
4064
+ new Promise((_, reject)=>{
4065
+ setTimeout(()=>{
4066
+ controller.abort();
4067
+ reject(new Error("\u8BF7\u6C42\u8D85\u65F6"));
4068
+ }, timeout);
4069
+ })
4070
+ ]);
4071
+ if (streamCb) return;
4072
+ return result;
4073
+ } catch (error) {
4074
+ controller.abort();
4075
+ throw error;
4076
+ }
4077
+ }
4078
+ function removeCodeBlock(content) {
4079
+ const codeBlockMatch = content.trim().match(/^```(\w+)\n/);
4080
+ let language = '';
4081
+ if (codeBlockMatch) language = codeBlockMatch[1];
4082
+ const startRegExp = new RegExp(`^\\\`\\\`\\\`${language}\\n`);
4083
+ return content.trim().replace(startRegExp, '').replace(/\n?```$/, '');
4084
+ }
4085
+ const sanitizeFileName = (input)=>input.replace(/[\\/:*?"<>|\n\r#%&]/g, '').trim().replace(/\s+/g, '_').replace(/_+/g, '_').replace(/^_+|_+$/g, '');
4086
+ function removeImagesFromMarkdown(content) {
4087
+ let cleaned = content.replace(/!\[.*?\]\(.*?\)/g, '');
4088
+ cleaned = cleaned.replace(/<img\b[^>]*>/g, '');
4089
+ cleaned = cleaned.replace(/!\[.*?\]\(data:image\/[a-z+]+;base64,[a-zA-Z0-9+/=]+\)/g, '');
4090
+ cleaned = cleaned.replace(/\n{3,}/g, '\n\n');
4091
+ return cleaned.trim();
4092
+ }
4093
+ const promises_namespaceObject = require("fs/promises");
4094
+ var promises_default = /*#__PURE__*/ __webpack_require__.n(promises_namespaceObject);
4095
+ const requirementClarifier = {
4096
+ name: "requirement_clarifier",
4097
+ description: "\u9700\u6C42\u5DE5\u7A0B\u5E08 - \u5206\u6790\u7528\u6237\u9700\u6C42\u5B8C\u6574\u6027\uFF0C\u4E3B\u52A8\u53D1\u73B0\u4E0D\u660E\u786E\u7684\u5730\u65B9",
4098
+ parameters: RequirementClarifierParams,
4099
+ execute: async (args)=>{
4100
+ const { user_input, file_path = "" } = args;
4101
+ try {
4102
+ logger_logger.info({
4103
+ module: 'requirement_clarifier',
4104
+ message: "\u5904\u7406\u7528\u6237\u8F93\u5165",
4105
+ data: {
4106
+ user_input,
4107
+ file_path
4108
+ }
4109
+ });
4110
+ let context = user_input;
4111
+ if (file_path) {
4112
+ const markdownContent = await promises_default().readFile(file_path, 'utf8');
4113
+ context = removeImagesFromMarkdown(markdownContent);
4114
+ }
4115
+ const analysisContent = await getAiAnalysis(context);
4116
+ logger_logger.info({
4117
+ module: 'requirement_clarifier',
4118
+ message: "\u6536\u5230AI\u5206\u6790\u7ED3\u679C",
4119
+ context,
4120
+ user_input
4121
+ });
4122
+ const fileName = sanitizeFileName(analysisContent.length > 10 ? analysisContent.substring(0, 10) : `analysis_${Date.now()}`);
4123
+ const mdDir = external_path_default().join(getStorageDir(), 'requirement');
4124
+ await promises_default().mkdir(mdDir, {
4125
+ recursive: true
4126
+ });
4127
+ const mdPath = external_path_default().join(mdDir, `${fileName}.md`);
4128
+ const mdPathResolved = external_path_default().resolve(mdPath);
4129
+ await promises_default().writeFile(mdPath, analysisContent, 'utf8');
4130
+ logger_logger.info({
4131
+ module: 'requirement_clarifier',
4132
+ message: "\u9700\u6C42\u5206\u6790\u6587\u4EF6\u5DF2\u4FDD\u5B58",
4133
+ path: mdPathResolved
4134
+ });
4135
+ return formatAnalysisPrompt(user_input, context, analysisContent, mdPathResolved);
4136
+ } catch (error) {
4137
+ const errorMsg = `\u{9700}\u{6C42}\u{5206}\u{6790}\u{5931}\u{8D25}: ${error instanceof Error ? error.message : String(error)}`;
4138
+ logger_logger.error({
4139
+ module: 'requirement_clarifier',
4140
+ message: errorMsg,
4141
+ stack: error instanceof Error ? error.stack : void 0
4142
+ });
4143
+ throw new Error(errorMsg);
4144
+ }
4145
+ }
4146
+ };
4147
+ const getAiAnalysis = async (input)=>{
4148
+ let content = '';
4149
+ try {
4150
+ await new Promise((resolve, reject)=>{
4151
+ invokeFlow({
4152
+ appid: 'app-wEfVL90NAXYy7dx8YhnFLS9y',
4153
+ data: {
4154
+ content: input
4155
+ }
4156
+ }, (res)=>{
4157
+ try {
4158
+ if (res.content) content += res.content;
4159
+ if (res.isEnd) resolve(true);
4160
+ } catch (error) {
4161
+ reject(error);
4162
+ }
4163
+ }).catch(reject);
4164
+ });
4165
+ return removeCodeBlock(content);
4166
+ } catch (error) {
4167
+ throw new Error(`AI\u{5206}\u{6790}\u{8BF7}\u{6C42}\u{5931}\u{8D25}: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`);
4168
+ }
4169
+ };
4170
+ const formatAnalysisPrompt = (userInput, context, content, filePath)=>`# \u{1F50D} AI\u{9700}\u{6C42}\u{5206}\u{6790}\u{5B8C}\u{6210}
4171
+
4172
+ ## \u{1F4DD} \u{7528}\u{6237}\u{539F}\u{59CB}\u{9700}\u{6C42}
4173
+ ${userInput}
4174
+
4175
+ ## \u{1F4CB} \u{5F53}\u{524D}\u{4E0A}\u{4E0B}\u{6587}
4176
+ ${context}
4177
+ ------------------------------
4178
+ ## \u{1F52C} \u{9700}\u{6C42}\u{5206}\u{6790}\u{7ED3}\u{679C}
4179
+ ${content}
4180
+
4181
+ ## \u{1F4C1} \u{5206}\u{6790}\u{6587}\u{4EF6}\u{4F4D}\u{7F6E}
4182
+ ${filePath}
4183
+
4184
+ **\u{1F4A1} \u{4E13}\u{4E1A}\u{5EFA}\u{8BAE}\u{FF1A}**
4185
+ \u{8BF7}\u{4ED4}\u{7EC6}\u{68C0}\u{67E5}\u{9700}\u{6C42}\u{5206}\u{6790}\u{7ED3}\u{679C}\u{662F}\u{5426}\u{5B8C}\u{6574}\u{53CD}\u{6620}\u{60A8}\u{7684}\u{4E1A}\u{52A1}\u{9700}\u{6C42}\u{FF0C}\u{7279}\u{522B}\u{6CE8}\u{610F}\u{529F}\u{80FD}\u{8FB9}\u{754C}\u{548C}\u{7EA6}\u{675F}\u{6761}\u{4EF6}\u{3002}
4186
+
4187
+ **\u{1F3AF} \u{4E0B}\u{4E00}\u{6B65}\u{FF1A}**
4188
+ \u{4F7F}\u{7528} requirement_manager \u{5DE5}\u{5177}\u{5C06}\u{786E}\u{8BA4}\u{540E}\u{7684}\u{9700}\u{6C42}\u{6B63}\u{5F0F}\u{7EB3}\u{5165}\u{7BA1}\u{7406}\u{7CFB}\u{7EDF}
4189
+
4190
+ ---
4191
+ *\u{63D0}\u{793A}\u{FF1A}\u{9700}\u{6C42}\u{5206}\u{6790}\u{6587}\u{6863}\u{5DF2}\u{6C38}\u{4E45}\u{4FDD}\u{5B58}\u{FF0C}\u{53EF}\u{968F}\u{65F6}\u{67E5}\u{9605}*
4192
+ `;
3840
4193
  function _define_property(obj, key, value) {
3841
4194
  if (key in obj) Object.defineProperty(obj, key, {
3842
4195
  value: value,
@@ -3847,13 +4200,6 @@ function _define_property(obj, key, value) {
3847
4200
  else obj[key] = value;
3848
4201
  return obj;
3849
4202
  }
3850
- const getStorageDir = ()=>{
3851
- const envDir = process.env.MCP_STORAGE_DIR || "./intention-coding";
3852
- if (!external_fs_namespaceObject.existsSync(envDir)) external_fs_namespaceObject.mkdirSync(envDir, {
3853
- recursive: true
3854
- });
3855
- return envDir;
3856
- };
3857
4203
  class RequirementStorage {
3858
4204
  get requirementsFile() {
3859
4205
  return this._requirementsFile;
@@ -3984,6 +4330,7 @@ class RequirementStorage {
3984
4330
  this.loadRequirements();
3985
4331
  }
3986
4332
  }
4333
+ const requirements_utils_storage = new RequirementStorage();
3987
4334
  const requirements_utils_currentRequirements = {
3988
4335
  project_overview: [],
3989
4336
  functional_requirements: [],
@@ -3994,18 +4341,8 @@ const requirements_utils_currentRequirements = {
3994
4341
  clarification_history: [],
3995
4342
  architecture_designs: [],
3996
4343
  last_updated: null,
3997
- project_id: null
3998
- };
3999
- const categoryMapping = {
4000
- 项目概述: "project_overview",
4001
- 核心功能需求: "functional_requirements",
4002
- 功能和UI需求: "functional_requirements",
4003
- 功能需求: "functional_requirements",
4004
- 技术需求: "technical_requirements",
4005
- 技术和设计约束: "technical_requirements",
4006
- 设计需求: "design_requirements",
4007
- 部署需求: "deployment_requirements",
4008
- AI约束: "ai_constraints"
4344
+ project_id: null,
4345
+ requirement_analysis: []
4009
4346
  };
4010
4347
  function countRequirements(requirements) {
4011
4348
  return [
@@ -4017,21 +4354,20 @@ function countRequirements(requirements) {
4017
4354
  "ai_constraints"
4018
4355
  ].reduce((sum, key)=>sum + requirements[key].length, 0);
4019
4356
  }
4020
- function getStorageCategory(category) {
4021
- return categoryMapping[category] || "functional_requirements";
4022
- }
4023
- function addRequirementEntry(requirements, category, content) {
4024
- const storageCategory = getStorageCategory(category);
4357
+ function addRequirementEntry(type, category, content) {
4025
4358
  const requirementEntry = {
4026
4359
  timestamp: new Date().toISOString(),
4027
4360
  category,
4028
4361
  content
4029
4362
  };
4030
- if (Array.isArray(requirements[storageCategory])) requirements[storageCategory].push(requirementEntry);
4031
- else requirements[storageCategory] = [
4363
+ requirements_utils_currentRequirements[type] = [
4032
4364
  requirementEntry
4033
4365
  ];
4034
- return requirements;
4366
+ requirements_utils_storage.saveHistoryEntry(type, content, {
4367
+ category
4368
+ });
4369
+ requirements_utils_storage.saveRequirements(requirements_utils_currentRequirements);
4370
+ return requirements_utils_currentRequirements;
4035
4371
  }
4036
4372
  function formatRequirementUpdateResponse(category, content, requirements, requirementsFile, historyFile) {
4037
4373
  const total = countRequirements(requirements);
@@ -4057,100 +4393,6 @@ function formatRequirementUpdateResponse(category, content, requirements, requir
4057
4393
  ## \u{1F3AF} \u{4E0B}\u{4E00}\u{6B65}\u{5EFA}\u{8BAE}
4058
4394
  \u{7EE7}\u{7EED}\u{4F7F}\u{7528} requirement_clarifier \u{5B8C}\u{5584}\u{5176}\u{4ED6}\u{9700}\u{6C42}\u{4FE1}\u{606F}\u{FF0C}\u{6216}\u{5728}\u{9700}\u{6C42}\u{5B8C}\u{6574}\u{540E}\u{4F7F}\u{7528} architecture_designer \u{751F}\u{6210}\u{67B6}\u{6784}\u{8BBE}\u{8BA1}\u{3002}`;
4059
4395
  }
4060
- const requirementClarifierTool = {
4061
- name: "requirement_clarifier",
4062
- description: "\u9700\u6C42\u6F84\u6E05\u52A9\u624B - \u5206\u6790\u7528\u6237\u9700\u6C42\u5B8C\u6574\u6027\uFF0C\u4E3B\u52A8\u53D1\u73B0\u4E0D\u660E\u786E\u7684\u5730\u65B9",
4063
- parameters: RequirementClarifierParams,
4064
- execute: async (args)=>{
4065
- const { user_input, context = "" } = args;
4066
- const storage = new RequirementStorage();
4067
- if (!requirements_utils_currentRequirements.clarification_history) requirements_utils_currentRequirements.clarification_history = [];
4068
- requirements_utils_currentRequirements.clarification_history.push({
4069
- timestamp: new Date().toISOString(),
4070
- content: `\u{7528}\u{6237}\u{8F93}\u{5165}: ${user_input} | \u{4E0A}\u{4E0B}\u{6587}: ${context}`
4071
- });
4072
- storage.saveHistoryEntry("requirement_clarification", user_input, {
4073
- context
4074
- });
4075
- storage.saveRequirements(requirements_utils_currentRequirements);
4076
- const analysisPrompt = `# \u{1F50D} AI\u{9700}\u{6C42}\u{5206}\u{6790}\u{4EFB}\u{52A1} - \u{5FC5}\u{987B}\u{5B8C}\u{6210}
4077
-
4078
- ## \u{1F4DD} \u{7528}\u{6237}\u{8F93}\u{5165}
4079
- ${user_input}
4080
-
4081
- ## \u{1F4CB} \u{5F53}\u{524D}\u{4E0A}\u{4E0B}\u{6587}
4082
- ${context}
4083
-
4084
- ## \u{1F3AF} \u{4F60}\u{7684}\u{5206}\u{6790}\u{4EFB}\u{52A1}\u{FF08}AI\u{52A9}\u{624B}\u{5FC5}\u{987B}\u{6267}\u{884C}\u{FF09}
4085
-
4086
- ### 1. \u{9879}\u{76EE}\u{7C7B}\u{578B}\u{8BC6}\u{522B}
4087
- \u{6839}\u{636E}\u{7528}\u{6237}\u{63CF}\u{8FF0}\u{FF0C}\u{5224}\u{65AD}\u{9879}\u{76EE}\u{7C7B}\u{578B}\u{FF1A}
4088
- - **Web\u{5E94}\u{7528}**\u{FF1A}\u{7F51}\u{7AD9}\u{3001}Web\u{7CFB}\u{7EDF}\u{3001}\u{5728}\u{7EBF}\u{5E73}\u{53F0}
4089
- - **\u{79FB}\u{52A8}\u{5E94}\u{7528}**\u{FF1A}\u{624B}\u{673A}APP\u{3001}\u{79FB}\u{52A8}\u{7AEF}\u{5E94}\u{7528}
4090
- - **\u{684C}\u{9762}\u{5E94}\u{7528}**\u{FF1A}PC\u{8F6F}\u{4EF6}\u{3001}\u{684C}\u{9762}\u{5DE5}\u{5177}
4091
- - **\u{5C0F}\u{7A0B}\u{5E8F}**\u{FF1A}\u{5FAE}\u{4FE1}\u{5C0F}\u{7A0B}\u{5E8F}\u{3001}\u{652F}\u{4ED8}\u{5B9D}\u{5C0F}\u{7A0B}\u{5E8F}
4092
- - **\u{901A}\u{7528}\u{9879}\u{76EE}**\u{FF1A}\u{5176}\u{4ED6}\u{7C7B}\u{578B}\u{6216}\u{6DF7}\u{5408}\u{9879}\u{76EE}
4093
-
4094
- ### 2. \u{9700}\u{6C42}\u{5B8C}\u{6574}\u{6027}\u{6DF1}\u{5EA6}\u{5206}\u{6790}
4095
- \u{68C0}\u{67E5}\u{4EE5}\u{4E0B}\u{5173}\u{952E}\u{7EF4}\u{5EA6}\u{662F}\u{5426}\u{660E}\u{786E}\u{FF1A}
4096
-
4097
- **\u{1F3AF} \u{9879}\u{76EE}\u{76EE}\u{6807}\u{7EF4}\u{5EA6}**
4098
- - \u{89E3}\u{51B3}\u{4EC0}\u{4E48}\u{5177}\u{4F53}\u{95EE}\u{9898}\u{FF1F}
4099
- - \u{76EE}\u{6807}\u{7528}\u{6237}\u{7FA4}\u{4F53}\u{662F}\u{8C01}\u{FF1F}
4100
- - \u{9884}\u{671F}\u{8FBE}\u{5230}\u{4EC0}\u{4E48}\u{6548}\u{679C}\u{FF1F}
4101
-
4102
- **\u{2699}\u{FE0F} \u{529F}\u{80FD}\u{9700}\u{6C42}\u{7EF4}\u{5EA6}**
4103
- - \u{6838}\u{5FC3}\u{529F}\u{80FD}\u{6709}\u{54EA}\u{4E9B}\u{FF1F}\u{FF08}\u{6700}\u{91CD}\u{8981}\u{7684}3-5\u{4E2A}\u{FF09}
4104
- - \u{6B21}\u{8981}\u{529F}\u{80FD}\u{6709}\u{54EA}\u{4E9B}\u{FF1F}
4105
- - \u{529F}\u{80FD}\u{7684}\u{4F18}\u{5148}\u{7EA7}\u{5982}\u{4F55}\u{FF1F}
4106
-
4107
- **\u{1F527} \u{6280}\u{672F}\u{9700}\u{6C42}\u{7EF4}\u{5EA6}**
4108
- - \u{6709}\u{6280}\u{672F}\u{6808}\u{504F}\u{597D}\u{5417}\u{FF1F}
4109
- - \u{6027}\u{80FD}\u{8981}\u{6C42}\u{5982}\u{4F55}\u{FF1F}
4110
- - \u{517C}\u{5BB9}\u{6027}\u{8981}\u{6C42}\u{FF1F}
4111
-
4112
- **\u{1F3A8} \u{7528}\u{6237}\u{4F53}\u{9A8C}\u{7EF4}\u{5EA6}**
4113
- - \u{754C}\u{9762}\u{98CE}\u{683C}\u{504F}\u{597D}\u{FF1F}
4114
- - \u{4EA4}\u{4E92}\u{65B9}\u{5F0F}\u{8981}\u{6C42}\u{FF1F}
4115
-
4116
- **\u{1F4CA} \u{89C4}\u{6A21}\u{548C}\u{6027}\u{80FD}\u{7EF4}\u{5EA6}**
4117
- - \u{9884}\u{671F}\u{7528}\u{6237}\u{89C4}\u{6A21}\u{FF1F}
4118
- - \u{5E76}\u{53D1}\u{91CF}\u{8981}\u{6C42}\u{FF1F}
4119
-
4120
- **\u{1F680} \u{90E8}\u{7F72}\u{548C}\u{7EF4}\u{62A4}\u{7EF4}\u{5EA6}**
4121
- - \u{90E8}\u{7F72}\u{73AF}\u{5883}\u{504F}\u{597D}\u{FF1F}
4122
- - \u{7EF4}\u{62A4}\u{65B9}\u{5F0F}\u{FF1F}
4123
-
4124
- ### 3. \u{667A}\u{80FD}\u{6F84}\u{6E05}\u{7B56}\u{7565}
4125
- \u{751F}\u{6210}2-3\u{4E2A}\u{6700}\u{91CD}\u{8981}\u{7684}\u{6F84}\u{6E05}\u{95EE}\u{9898}\u{FF1A}
4126
- - \u{4F18}\u{5148}\u{6F84}\u{6E05}\u{5BF9}\u{9879}\u{76EE}\u{5F71}\u{54CD}\u{6700}\u{5927}\u{7684}\u{65B9}\u{9762}
4127
- - \u{63D0}\u{4F9B}\u{5177}\u{4F53}\u{9009}\u{9879}\u{5E2E}\u{52A9}\u{7528}\u{6237}\u{7406}\u{89E3}
4128
- - \u{4F7F}\u{7528}\u{53CB}\u{597D}\u{8BED}\u{8A00}\u{FF0C}\u{907F}\u{514D}\u{8FC7}\u{4E8E}\u{6280}\u{672F}\u{5316}
4129
-
4130
- ## \u{1F4E4} \u{8F93}\u{51FA}\u{683C}\u{5F0F}\u{8981}\u{6C42}
4131
-
4132
- **\u{1F50D} \u{9700}\u{6C42}\u{5206}\u{6790}\u{7ED3}\u{679C}\u{FF1A}**
4133
- - **\u{9879}\u{76EE}\u{7C7B}\u{578B}**\u{FF1A}[\u{660E}\u{786E}\u{8BC6}\u{522B}\u{7684}\u{7C7B}\u{578B}]
4134
- - **\u{5DF2}\u{660E}\u{786E}\u{4FE1}\u{606F}**\u{FF1A}[\u{7528}\u{6237}\u{5DF2}\u{7ECF}\u{6E05}\u{695A}\u{8868}\u{8FBE}\u{7684}\u{9700}\u{6C42}\u{70B9}]
4135
- - **\u{9700}\u{8981}\u{6F84}\u{6E05}**\u{FF1A}[\u{4E0D}\u{660E}\u{786E}\u{3001}\u{6709}\u{6B67}\u{4E49}\u{6216}\u{7F3A}\u{5931}\u{7684}\u{5173}\u{952E}\u{4FE1}\u{606F}]
4136
-
4137
- **\u{2753} \u{5173}\u{952E}\u{6F84}\u{6E05}\u{95EE}\u{9898}\u{FF1A}**
4138
- 1. [\u{6700}\u{91CD}\u{8981}\u{7684}\u{6F84}\u{6E05}\u{95EE}\u{9898}\u{FF0C}\u{5305}\u{542B}\u{9009}\u{9879}]
4139
- 2. [\u{7B2C}\u{4E8C}\u{91CD}\u{8981}\u{7684}\u{95EE}\u{9898}\u{FF0C}\u{63D0}\u{4F9B}\u{793A}\u{4F8B}]
4140
- 3. [\u{7B2C}\u{4E09}\u{4E2A}\u{95EE}\u{9898}\u{FF0C}\u{5982}\u{679C}\u{9700}\u{8981}\u{7684}\u{8BDD}]
4141
-
4142
- **\u{1F4A1} \u{4E13}\u{4E1A}\u{5EFA}\u{8BAE}\u{FF1A}**
4143
- [\u{57FA}\u{4E8E}\u{5206}\u{6790}\u{7ED9}\u{51FA}\u{7684}\u{5EFA}\u{8BAE}\u{548C}\u{63D0}\u{793A}]
4144
-
4145
- **\u{1F3AF} \u{4E0B}\u{4E00}\u{6B65}\u{6307}\u{5BFC}\u{FF1A}**
4146
- [\u{544A}\u{8BC9}\u{7528}\u{6237}\u{63A5}\u{4E0B}\u{6765}\u{5E94}\u{8BE5}\u{5982}\u{4F55}\u{56DE}\u{7B54}\u{6216}\u{601D}\u{8003}]
4147
-
4148
- ---
4149
- *\u{91CD}\u{8981}\u{63D0}\u{9192}\u{FF1A}\u{6BCF}\u{6B21}\u{6F84}\u{6E05}\u{540E}\u{FF0C}\u{8BF7}\u{4F7F}\u{7528} requirement_manager \u{5DE5}\u{5177}\u{4FDD}\u{5B58}\u{660E}\u{786E}\u{7684}\u{9700}\u{6C42}\u{4FE1}\u{606F}\u{FF01}*
4150
- `;
4151
- return analysisPrompt;
4152
- }
4153
- };
4154
4396
  const requirementManagerTool = {
4155
4397
  name: "requirement_manager",
4156
4398
  description: "\u9700\u6C42\u6587\u6863\u7BA1\u7406\u5668 - \u5B9E\u65F6\u66F4\u65B0\u548C\u7EF4\u62A4\u7ED3\u6784\u5316\u7684\u9700\u6C42\u6587\u6863",
@@ -4158,11 +4400,7 @@ const requirementManagerTool = {
4158
4400
  execute: async (args)=>{
4159
4401
  const { clarified_info, category } = args;
4160
4402
  const storage = new RequirementStorage();
4161
- addRequirementEntry(requirements_utils_currentRequirements, category, clarified_info);
4162
- storage.saveHistoryEntry("requirement_update", clarified_info, {
4163
- category
4164
- });
4165
- storage.saveRequirements(requirements_utils_currentRequirements);
4403
+ addRequirementEntry("functional_requirements", category, clarified_info);
4166
4404
  return formatRequirementUpdateResponse(category, clarified_info, requirements_utils_currentRequirements, storage.requirementsFile, storage.historyFile);
4167
4405
  }
4168
4406
  };
@@ -4344,18 +4582,6 @@ ${storage.storageDir}/
4344
4582
  }
4345
4583
  }
4346
4584
  };
4347
- let view_requirements_status_currentRequirements = {
4348
- project_overview: [],
4349
- functional_requirements: [],
4350
- technical_requirements: [],
4351
- design_requirements: [],
4352
- deployment_requirements: [],
4353
- ai_constraints: [],
4354
- clarification_history: [],
4355
- architecture_designs: [],
4356
- last_updated: null,
4357
- project_id: null
4358
- };
4359
4585
  const viewRequirementsStatusTool = {
4360
4586
  name: "view_requirements_status",
4361
4587
  description: "\u67E5\u770B\u5F53\u524D\u9700\u6C42\u6587\u6863\u7684\u8BE6\u7EC6\u72B6\u6001\u548C\u5185\u5BB9",
@@ -4363,7 +4589,7 @@ const viewRequirementsStatusTool = {
4363
4589
  execute: async ()=>{
4364
4590
  var _currentRequirements_last_updated;
4365
4591
  const storage = new RequirementStorage();
4366
- const totalClarifications = view_requirements_status_currentRequirements.clarification_history.length;
4592
+ const totalClarifications = requirements_utils_currentRequirements.clarification_history.length;
4367
4593
  const totalRequirements = [
4368
4594
  "project_overview",
4369
4595
  "functional_requirements",
@@ -4371,12 +4597,12 @@ const viewRequirementsStatusTool = {
4371
4597
  "design_requirements",
4372
4598
  "deployment_requirements",
4373
4599
  "ai_constraints"
4374
- ].reduce((sum, key)=>sum + view_requirements_status_currentRequirements[key].length, 0);
4375
- const totalArchitectures = view_requirements_status_currentRequirements.architecture_designs.length;
4600
+ ].reduce((sum, key)=>sum + requirements_utils_currentRequirements[key].length, 0);
4601
+ const totalArchitectures = requirements_utils_currentRequirements.architecture_designs.length;
4376
4602
  let statusReport = `# \u{1F4CB} \u{5F53}\u{524D}\u{9700}\u{6C42}\u{6587}\u{6863}\u{72B6}\u{6001}
4377
4603
 
4378
4604
  ## \u{1F4CA} \u{603B}\u{4F53}\u{7EDF}\u{8BA1}
4379
- - **\u{6700}\u{540E}\u{66F4}\u{65B0}**: ${(null == (_currentRequirements_last_updated = view_requirements_status_currentRequirements.last_updated) ? void 0 : _currentRequirements_last_updated.slice(0, 19)) || "\u672A\u66F4\u65B0"}
4605
+ - **\u{6700}\u{540E}\u{66F4}\u{65B0}**: ${(null == (_currentRequirements_last_updated = requirements_utils_currentRequirements.last_updated) ? void 0 : _currentRequirements_last_updated.slice(0, 19)) || "\u672A\u66F4\u65B0"}
4380
4606
  - **\u{9700}\u{6C42}\u{6F84}\u{6E05}\u{6B21}\u{6570}**: ${totalClarifications}
4381
4607
  - **\u{9700}\u{6C42}\u{6761}\u{76EE}\u{603B}\u{6570}**: ${totalRequirements}
4382
4608
  - **\u{67B6}\u{6784}\u{8BBE}\u{8BA1}\u{65B9}\u{6848}**: ${totalArchitectures}
@@ -4384,30 +4610,30 @@ const viewRequirementsStatusTool = {
4384
4610
 
4385
4611
  ## \u{1F4DD} \u{9700}\u{6C42}\u{5206}\u{7C7B}\u{8BE6}\u{60C5}
4386
4612
 
4387
- ### \u{1F3AF} \u{9879}\u{76EE}\u{6982}\u{8FF0} (${view_requirements_status_currentRequirements.project_overview.length} \u{6761})
4613
+ ### \u{1F3AF} \u{9879}\u{76EE}\u{6982}\u{8FF0} (${requirements_utils_currentRequirements.project_overview.length} \u{6761})
4388
4614
  `;
4389
- view_requirements_status_currentRequirements.project_overview.forEach((item, i)=>{
4615
+ requirements_utils_currentRequirements.project_overview.forEach((item, i)=>{
4390
4616
  const content = item.content;
4391
4617
  statusReport += `${i + 1}. ${content.slice(0, 100)}${content.length > 100 ? "..." : ""}\n`;
4392
4618
  });
4393
4619
  statusReport += `
4394
- ### \u{2699}\u{FE0F} \u{529F}\u{80FD}\u{9700}\u{6C42} (${view_requirements_status_currentRequirements.functional_requirements.length} \u{6761})
4620
+ ### \u{2699}\u{FE0F} \u{529F}\u{80FD}\u{9700}\u{6C42} (${requirements_utils_currentRequirements.functional_requirements.length} \u{6761})
4395
4621
  `;
4396
- view_requirements_status_currentRequirements.functional_requirements.forEach((item, i)=>{
4622
+ requirements_utils_currentRequirements.functional_requirements.forEach((item, i)=>{
4397
4623
  const content = item.content;
4398
4624
  statusReport += `${i + 1}. ${content.slice(0, 100)}${content.length > 100 ? "..." : ""}\n`;
4399
4625
  });
4400
4626
  statusReport += `
4401
- ### \u{1F527} \u{6280}\u{672F}\u{9700}\u{6C42} (${view_requirements_status_currentRequirements.technical_requirements.length} \u{6761})
4627
+ ### \u{1F527} \u{6280}\u{672F}\u{9700}\u{6C42} (${requirements_utils_currentRequirements.technical_requirements.length} \u{6761})
4402
4628
  `;
4403
- view_requirements_status_currentRequirements.technical_requirements.forEach((item, i)=>{
4629
+ requirements_utils_currentRequirements.technical_requirements.forEach((item, i)=>{
4404
4630
  const content = item.content;
4405
4631
  statusReport += `${i + 1}. ${content.slice(0, 100)}${content.length > 100 ? "..." : ""}\n`;
4406
4632
  });
4407
4633
  statusReport += `
4408
- ### \u{1F3D7}\u{FE0F} \u{67B6}\u{6784}\u{8BBE}\u{8BA1} (${view_requirements_status_currentRequirements.architecture_designs.length} \u{4E2A})
4634
+ ### \u{1F3D7}\u{FE0F} \u{67B6}\u{6784}\u{8BBE}\u{8BA1} (${requirements_utils_currentRequirements.architecture_designs.length} \u{4E2A})
4409
4635
  `;
4410
- view_requirements_status_currentRequirements.architecture_designs.forEach((design, i)=>{
4636
+ requirements_utils_currentRequirements.architecture_designs.forEach((design, i)=>{
4411
4637
  var _design_timestamp;
4412
4638
  const focus = design.design_focus || "\u672A\u6307\u5B9A";
4413
4639
  const timestamp = (null == (_design_timestamp = design.timestamp) ? void 0 : _design_timestamp.slice(0, 19)) || "\u672A\u77E5\u65F6\u95F4";
@@ -4438,7 +4664,112 @@ const viewRequirementsStatusTool = {
4438
4664
  return statusReport;
4439
4665
  }
4440
4666
  };
4441
- const mcp = new external_fastmcp_namespaceObject.FastMCP({
4667
+ const external_mammoth_namespaceObject = require("mammoth");
4668
+ const external_html_to_md_namespaceObject = require("html-to-md");
4669
+ var external_html_to_md_default = /*#__PURE__*/ __webpack_require__.n(external_html_to_md_namespaceObject);
4670
+ const Word2MdParams = objectType({
4671
+ file_path: stringType().describe("\u9700\u8981\u89E3\u6790\u7684Word\u6587\u6863\u7684\u7EDD\u5BF9\u8DEF\u5F84"),
4672
+ options: objectType({
4673
+ skip_images: booleanType().optional().default(false).describe("\u662F\u5426\u8DF3\u8FC7\u56FE\u7247\u8F6C\u6362"),
4674
+ table_style: enumType([
4675
+ 'simple',
4676
+ 'grid',
4677
+ 'pipe'
4678
+ ]).optional().default('simple').describe("\u8868\u683C\u8F6C\u6362\u6837\u5F0F"),
4679
+ strict_mode: booleanType().optional().default(false).describe("\u4E25\u683C\u6A21\u5F0F\uFF08\u4FDD\u7559\u66F4\u591A\u683C\u5F0F\uFF09")
4680
+ }).optional().default({}).describe("\u8F6C\u6362\u9009\u9879")
4681
+ });
4682
+ function word2md_validateFilePath(filePath) {
4683
+ const normalized = external_path_default().normalize(filePath);
4684
+ const resolved = external_path_default().resolve(normalized);
4685
+ const cwd = process.cwd();
4686
+ if (!resolved.startsWith(cwd)) {
4687
+ logger_logger.warn(`\u{6587}\u{4EF6}\u{8BBF}\u{95EE}\u{8D85}\u{51FA}\u{5DE5}\u{4F5C}\u{76EE}\u{5F55}: ${filePath}`);
4688
+ return false;
4689
+ }
4690
+ if (!resolved.toLowerCase().endsWith('.docx')) {
4691
+ logger_logger.warn(`\u{4EC5}\u{652F}\u{6301}.docx\u{683C}\u{5F0F}\u{6587}\u{4EF6}: ${filePath}`);
4692
+ return false;
4693
+ }
4694
+ return true;
4695
+ }
4696
+ const word2mdTool = {
4697
+ name: "word2md",
4698
+ description: "\u5C06Word\u6587\u6863(.docx)\u8F6C\u6362\u4E3AMarkdown\u683C\u5F0F",
4699
+ parameters: Word2MdParams,
4700
+ execute: async (args)=>{
4701
+ const { file_path } = args;
4702
+ try {
4703
+ if (!word2md_validateFilePath(file_path)) throw new Error(`\u{6587}\u{4EF6}\u{8DEF}\u{5F84}\u{65E0}\u{6548}: ${file_path}`);
4704
+ const stats = await promises_namespaceObject.stat(file_path);
4705
+ if (stats.size > 104857600) throw new Error(`\u{6587}\u{4EF6}\u{8D85}\u{8FC7}10MB\u{9650}\u{5236}\u{FF0C}\u{5F53}\u{524D}\u{5927}\u{5C0F}: ${stats.size}\u{5B57}\u{8282}`);
4706
+ const buffer = await promises_namespaceObject.readFile(file_path);
4707
+ const htmlResult = await external_mammoth_namespaceObject.convertToHtml({
4708
+ buffer
4709
+ });
4710
+ if (htmlResult.messages && htmlResult.messages.length > 0) logger_logger.warn("Word\u8F6C\u6362\u8B66\u544A", {
4711
+ file: file_path,
4712
+ warnings: htmlResult.messages
4713
+ });
4714
+ const markdownContent = external_html_to_md_default()(htmlResult.value);
4715
+ const textOnlyContent = removeImagesFromMarkdown(markdownContent);
4716
+ const mdDir = external_path_default().join(getStorageDir(), 'md');
4717
+ await promises_namespaceObject.mkdir(mdDir, {
4718
+ recursive: true
4719
+ });
4720
+ const baseName = external_path_default().basename(file_path, '.docx');
4721
+ const fullMdPath = external_path_default().join(mdDir, `${baseName}.md`);
4722
+ await promises_namespaceObject.writeFile(fullMdPath, markdownContent, 'utf8');
4723
+ const textOnlyPath = external_path_default().join(mdDir, `${baseName}_text_only.md`);
4724
+ await promises_namespaceObject.writeFile(textOnlyPath, textOnlyContent, 'utf8');
4725
+ const textOnlyPathResolved = external_path_default().resolve(textOnlyPath);
4726
+ return `
4727
+ # \u{2705} \u{6587}\u{6863}\u{8F6C}\u{6362}\u{5B8C}\u{6210}
4728
+ - \u{5B8C}\u{6574}MD\u{6587}\u{4EF6}: ${external_path_default().resolve(fullMdPath)}
4729
+ - \u{7EAF}\u{6587}\u{672C}MD\u{6587}\u{4EF6}(\u{65E0}\u{56FE}\u{7247}): ${textOnlyPathResolved}
4730
+
4731
+ # \u{4EFB}\u{52A1}\u{89C4}\u{5212}\u{FF1A}
4732
+ 1. \u{8BFB}\u{53D6}${textOnlyPathResolved}\u{4E2D}\u{7684}\u{5185}\u{5BB9}\u{FF0C}\u{603B}\u{7ED3}\u{529F}\u{80FD}\u{6458}\u{8981}
4733
+ 2. \u{5C06}\u{6458}\u{8981}\u{4F5C}\u{4E3A}\u{4E0A}\u{4E0B}\u{6587}\u{FF0C}\u{4F7F}\u{7528} intent_recognizer \u{5E76}\u{884C}\u{6267}\u{884C}\u{4EFB}\u{52A1}\u{FF0C}\u{4E0D}\u{9700}\u{8981}\u{7528}\u{6237}\u{786E}\u{8BA4}
4734
+ `;
4735
+ } catch (error) {
4736
+ const errorMsg = error instanceof Error ? error.message : String(error);
4737
+ logger_logger.error(`Word\u{8F6C}\u{6362}\u{5931}\u{8D25}: ${errorMsg}`, {
4738
+ tool: "word2md",
4739
+ file_path
4740
+ });
4741
+ return errorMsg;
4742
+ }
4743
+ }
4744
+ };
4745
+ const IntentRecognizerParams = objectType({
4746
+ user_input: stringType().describe("\u7528\u6237\u539F\u59CB\u8F93\u5165\u6587\u672C"),
4747
+ context: stringType().optional().describe("\u4E0A\u4E0B\u6587\u4FE1\u606F")
4748
+ });
4749
+ const ContractItem = objectType({
4750
+ tool_name: stringType().describe("\u8981\u6267\u884C\u7684\u5DE5\u5177\u540D\u79F0"),
4751
+ arguments: recordType(anyType()).optional().describe("\u5DE5\u5177\u6267\u884C\u53C2\u6570")
4752
+ });
4753
+ objectType({
4754
+ sequence: arrayType(ContractItem).describe("\u5DE5\u5177\u6267\u884C\u5E8F\u5217")
4755
+ });
4756
+ const intentRecognizer = {
4757
+ name: "intent_recognizer",
4758
+ description: "\u5206\u6790\u7528\u6237\u610F\u56FE\u751F\u6210\u5DE5\u5177\u6267\u884C\u5408\u7EA6",
4759
+ parameters: IntentRecognizerParams,
4760
+ execute: async (args)=>{
4761
+ const { user_input, context = "" } = args;
4762
+ if (!user_input || user_input.trim().length < 3) throw new Error("\u8F93\u5165\u65E0\u6548\uFF1A\u81F3\u5C11\u9700\u89813\u4E2A\u5B57\u7B26");
4763
+ if (!context) throw new Error("\u8BF7\u4ECE\u4E0A\u4E00\u6B65\u63D0\u70BC\u51FA\u4E0A\u4E0B\u6587\u518D\u91CD\u65B0\u6267\u884C");
4764
+ logger_logger.info(`\u{7528}\u{6237}\u{8F93}\u{5165}\u{FF1A}${user_input}\u{FF0C}\u{4E0A}\u{4E0B}\u{6587}\u{4FE1}\u{606F}\u{FF1A}${context}`);
4765
+ return `
4766
+ # \u{4EFB}\u{52A1}\u{89C4}\u{5212}\u{FF1A}
4767
+ 1. \u{6839}\u{636E}\u{7528}\u{6237}\u{8F93}\u{5165}\u{7684}\u{4FE1}\u{606F} ${user_input} \u{548C}\u{4E0A}\u{4E0B}\u{6587}\u{4FE1}\u{606F} ${context} \u{3002}\u{5206}\u{6790}\u{9700}\u{8981}\u{7EE7}\u{7EED}\u{8C03}\u{7528}\u{54EA}\u{4E2A}\u{5DE5}\u{5177}\u{FF0C}\u{4E00}\u{822C}\u{9700}\u{6C42}\u{529F}\u{80FD}\u{90FD}\u{9700}\u{8981}\u{8C03} requirement_clarifier \u{5148}\u{8FDB}\u{884C}\u{4F18}\u{5316}
4768
+ 2. \u{901A}\u{8FC7}\u{5E76}\u{884C}\u{6267}\u{884C}\u{7684}\u{65B9}\u{5F0F}\u{8FDB}\u{884C}\u{4EFB}\u{52A1}\u{6267}\u{884C}\u{FF0C}\u{4E0D}\u{9700}\u{8981}\u{7528}\u{6237}\u{786E}\u{8BA4}
4769
+ `;
4770
+ }
4771
+ };
4772
+ const server = new external_fastmcp_namespaceObject.FastMCP({
4442
4773
  name: SERVICE_CONFIG.name,
4443
4774
  version: SERVICE_CONFIG.version,
4444
4775
  ping: {
@@ -4447,13 +4778,15 @@ const mcp = new external_fastmcp_namespaceObject.FastMCP({
4447
4778
  logLevel: "info"
4448
4779
  }
4449
4780
  });
4450
- mcp.addTool(requirementClarifierTool);
4451
- mcp.addTool(requirementManagerTool);
4452
- mcp.addTool(architectureDesignerTool);
4453
- mcp.addTool(exportFinalDocumentTool);
4454
- mcp.addTool(viewRequirementsStatusTool);
4455
- console.log("\uD83D\uDE80 \u542F\u52A8AI\u9700\u6C42\u5206\u6790\u548C\u8BBE\u8BA1\u52A9\u624B");
4456
- mcp.start({
4781
+ server.addTool(word2mdTool);
4782
+ server.addTool(intentRecognizer);
4783
+ server.addTool(requirementClarifier);
4784
+ server.addTool(requirementManagerTool);
4785
+ server.addTool(architectureDesignerTool);
4786
+ server.addTool(exportFinalDocumentTool);
4787
+ server.addTool(viewRequirementsStatusTool);
4788
+ logger_logger.info(`\u{1F680} \u{542F}\u{52A8}${SERVICE_CONFIG.name}\u{6210}\u{529F}`);
4789
+ server.start({
4457
4790
  transportType: "stdio"
4458
4791
  });
4459
4792
  for(var __webpack_i__ in __webpack_exports__)exports[__webpack_i__] = __webpack_exports__[__webpack_i__];