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.js CHANGED
@@ -1,7 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  import { FastMCP } from "fastmcp";
3
+ import winston from "winston";
4
+ import winston_daily_rotate_file from "winston-daily-rotate-file";
5
+ import path_0, { join } from "path";
3
6
  import fs_0, { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
4
- import { join } from "path";
7
+ import promises, { mkdir, readFile, stat, writeFile } from "fs/promises";
8
+ import { convertToHtml } from "mammoth";
9
+ import html_to_md from "html-to-md";
5
10
  var __webpack_require__ = {};
6
11
  (()=>{
7
12
  __webpack_require__.d = (exports, definition)=>{
@@ -135,11 +140,88 @@ __webpack_require__.d(external_namespaceObject, {
135
140
  util: ()=>util_util,
136
141
  void: ()=>voidType
137
142
  });
143
+ path_0.join(process.cwd(), '.aico');
144
+ const getStorageDir = ()=>{
145
+ const envDir = process.env.MCP_STORAGE_DIR + "/.aico";
146
+ if (!existsSync(envDir)) mkdirSync(envDir, {
147
+ recursive: true
148
+ });
149
+ return envDir;
150
+ };
138
151
  const SERVICE_CONFIG = {
139
- name: "intention-coding",
140
- version: "1.0.0",
152
+ name: "\u667A\u80FD\u8F6F\u4EF6\u661F\u5DE5\u5382",
153
+ version: "0.0.1",
141
154
  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"
142
155
  };
156
+ const logDir = getStorageDir() + '/logs';
157
+ const levels = {
158
+ error: 0,
159
+ warn: 1,
160
+ info: 2,
161
+ debug: 3,
162
+ verbose: 4
163
+ };
164
+ const colors = {
165
+ error: 'red',
166
+ warn: 'yellow',
167
+ info: 'green',
168
+ debug: 'blue',
169
+ verbose: 'cyan'
170
+ };
171
+ winston.addColors(colors);
172
+ const consoleFormat = winston.format.combine(winston.format.timestamp({
173
+ format: 'YYYY-MM-DD HH:mm:ss'
174
+ }), winston.format.colorize(), winston.format.printf(({ timestamp, level, message })=>`${timestamp} [${level}]: ${message}`));
175
+ const fileFormat = winston.format.combine(winston.format.timestamp(), winston.format.json());
176
+ const transports = [
177
+ new winston.transports.Console({
178
+ format: consoleFormat,
179
+ level: 'verbose'
180
+ }),
181
+ new winston_daily_rotate_file({
182
+ filename: path_0.join(logDir, 'application-%DATE%.log'),
183
+ datePattern: 'YYYY-MM-DD',
184
+ zippedArchive: true,
185
+ maxSize: '20m',
186
+ maxFiles: '14d',
187
+ format: fileFormat,
188
+ level: 'info'
189
+ })
190
+ ];
191
+ const logger_logger = winston.createLogger({
192
+ level: 'debug',
193
+ levels,
194
+ format: winston.format.combine(winston.format.errors({
195
+ stack: true
196
+ }), winston.format.splat()),
197
+ transports,
198
+ exceptionHandlers: [
199
+ new winston_daily_rotate_file({
200
+ filename: path_0.join(logDir, 'exceptions-%DATE%.log'),
201
+ datePattern: 'YYYY-MM-DD',
202
+ zippedArchive: true,
203
+ maxSize: '1m',
204
+ maxFiles: '14d',
205
+ format: fileFormat
206
+ })
207
+ ],
208
+ rejectionHandlers: [
209
+ new winston_daily_rotate_file({
210
+ filename: path_0.join(logDir, 'rejections-%DATE%.log'),
211
+ datePattern: 'YYYY-MM-DD',
212
+ zippedArchive: true,
213
+ maxSize: '1m',
214
+ maxFiles: '14d',
215
+ format: fileFormat
216
+ })
217
+ ]
218
+ });
219
+ process.on('SIGINT', ()=>{
220
+ logger_logger.end(()=>{
221
+ console.log("\u65E5\u5FD7\u5DF2\u5173\u95ED");
222
+ process.exit(0);
223
+ });
224
+ });
143
225
  var util_util;
144
226
  (function(util) {
145
227
  util.assertEqual = (_)=>{};
@@ -3806,7 +3888,7 @@ const v3 = external_namespaceObject;
3806
3888
  const esm = v3;
3807
3889
  const RequirementClarifierParams = objectType({
3808
3890
  user_input: stringType().describe("\u7528\u6237\u8F93\u5165\u7684\u9700\u6C42\u63CF\u8FF0"),
3809
- context: stringType().optional().describe("\u9700\u6C42\u4E0A\u4E0B\u6587\u4FE1\u606F")
3891
+ 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")
3810
3892
  });
3811
3893
  const RequirementManagerParams = objectType({
3812
3894
  clarified_info: stringType().describe("\u6F84\u6E05\u540E\u7684\u9700\u6C42\u4FE1\u606F"),
@@ -3825,6 +3907,275 @@ const RequirementManagerParams = objectType({
3825
3907
  const ArchitectureDesignerParams = objectType({
3826
3908
  design_focus: stringType().optional().default("full_architecture").describe("\u8BBE\u8BA1\u91CD\u70B9")
3827
3909
  });
3910
+ async function invokeFlow(params, streamCb) {
3911
+ const { appid = 'app-ESTcrkOPOmkxdrO0120mE4s1', data, timeout = 1800000 } = params;
3912
+ const controller = new AbortController();
3913
+ const signal = controller.signal;
3914
+ const fetchData = async (retryCount = 0)=>{
3915
+ try {
3916
+ const fetchOptions = {
3917
+ method: 'POST',
3918
+ headers: {
3919
+ Authorization: `Bearer ${appid}`,
3920
+ 'Content-Type': 'application/json'
3921
+ },
3922
+ body: JSON.stringify({
3923
+ inputs: data,
3924
+ response_mode: 'streaming',
3925
+ user: "aico-mcp"
3926
+ }),
3927
+ signal
3928
+ };
3929
+ const res = await fetch('http://11.0.166.20:9199/v1/workflows/run', fetchOptions);
3930
+ if (!res.ok) {
3931
+ if (retryCount < 3) {
3932
+ await new Promise((resolve)=>setTimeout(resolve, 1000));
3933
+ return fetchData(retryCount + 1);
3934
+ }
3935
+ const errorResponse = await res.text();
3936
+ throw new Error(`\u{7F51}\u{7EDC}\u{54CD}\u{5E94}\u{5F02}\u{5E38}: ${res.status} ${res.statusText} - ${errorResponse}`);
3937
+ }
3938
+ if (res.ok) if (res.body) {
3939
+ const reader = res.body.getReader();
3940
+ const decoder = new TextDecoder('utf-8');
3941
+ if (streamCb) return void new ReadableStream({
3942
+ start (controller) {
3943
+ let buffer = '';
3944
+ function push() {
3945
+ reader.read().then(({ done, value })=>{
3946
+ if (done) {
3947
+ const lines = buffer.split('\n');
3948
+ for (const line of lines)handleLine(line, controller);
3949
+ if (streamCb) streamCb({
3950
+ isEnd: true
3951
+ });
3952
+ controller.close();
3953
+ return;
3954
+ }
3955
+ const chunkText = decoder.decode(value, {
3956
+ stream: true
3957
+ });
3958
+ buffer += chunkText;
3959
+ const lines = buffer.split('\n');
3960
+ for(let i = 0; i < lines.length - 1; i++)handleLine(lines[i], controller);
3961
+ buffer = lines[lines.length - 1];
3962
+ push();
3963
+ });
3964
+ }
3965
+ function handleLine(line, controller) {
3966
+ line = line.trim();
3967
+ if (line.startsWith('data:')) {
3968
+ const dataStr = line.slice(5).trim();
3969
+ if ('' === dataStr) return;
3970
+ try {
3971
+ var _jsonData_data;
3972
+ const jsonData = JSON.parse(dataStr);
3973
+ if (null == (_jsonData_data = jsonData.data) ? void 0 : _jsonData_data.text) {
3974
+ const wrappedData = {
3975
+ content: jsonData.data.text.toString(),
3976
+ controller
3977
+ };
3978
+ if (streamCb) streamCb(wrappedData);
3979
+ }
3980
+ } catch (e) {
3981
+ console.error("\u89E3\u6790JSON\u5931\u8D25:", e);
3982
+ }
3983
+ }
3984
+ }
3985
+ push();
3986
+ }
3987
+ });
3988
+ {
3989
+ let buffer = '';
3990
+ let accumulatedText = '';
3991
+ let isResponseEnded = false;
3992
+ const readAll = async ()=>{
3993
+ const { done, value } = await reader.read();
3994
+ if (done) {
3995
+ if (!isResponseEnded) throw new Error("\u54CD\u5E94\u63D0\u524D\u7ED3\u675F");
3996
+ return accumulatedText;
3997
+ }
3998
+ const chunkText = decoder.decode(value, {
3999
+ stream: true
4000
+ });
4001
+ buffer += chunkText;
4002
+ const lines = buffer.split('\n');
4003
+ for(let i = 0; i < lines.length - 1; i++){
4004
+ const line = lines[i].trim();
4005
+ if (!line.startsWith('data:')) continue;
4006
+ const dataStr = line.slice(5).trim();
4007
+ if ('' !== dataStr) try {
4008
+ const jsonData = JSON.parse(dataStr);
4009
+ switch(jsonData.event){
4010
+ case 'message':
4011
+ case 'agent_message':
4012
+ case 'text_chunk':
4013
+ {
4014
+ const content = 'text_chunk' === jsonData.event ? jsonData.data.text : jsonData.answer;
4015
+ accumulatedText += content;
4016
+ break;
4017
+ }
4018
+ case 'workflow_finished':
4019
+ accumulatedText = jsonData.data;
4020
+ isResponseEnded = true;
4021
+ break;
4022
+ case 'message_end':
4023
+ isResponseEnded = true;
4024
+ break;
4025
+ case 'error':
4026
+ throw new Error(`\u{670D}\u{52A1}\u{5668}\u{9519}\u{8BEF}: ${jsonData.code}, ${jsonData.message}`);
4027
+ default:
4028
+ break;
4029
+ }
4030
+ } catch (e) {
4031
+ throw new Error("\u89E3\u6790JSON\u5931\u8D25: " + e.message);
4032
+ }
4033
+ }
4034
+ buffer = lines[lines.length - 1];
4035
+ return readAll();
4036
+ };
4037
+ return readAll();
4038
+ }
4039
+ } else throw new Error("\u54CD\u5E94\u4F53\u4E3A\u7A7A");
4040
+ {
4041
+ const errorResponse = await res.text();
4042
+ throw new Error(`\u{7F51}\u{7EDC}\u{54CD}\u{5E94}\u{5F02}\u{5E38}: ${res.status} ${res.statusText} - ${errorResponse}`);
4043
+ }
4044
+ } catch (error) {
4045
+ if ('AbortError' === error.name) throw new Error("\u8BF7\u6C42\u5DF2\u88AB\u4E2D\u6B62\uFF0C\u8D85\u65F6");
4046
+ throw error;
4047
+ }
4048
+ };
4049
+ try {
4050
+ const result = await Promise.race([
4051
+ fetchData(),
4052
+ new Promise((_, reject)=>{
4053
+ setTimeout(()=>{
4054
+ controller.abort();
4055
+ reject(new Error("\u8BF7\u6C42\u8D85\u65F6"));
4056
+ }, timeout);
4057
+ })
4058
+ ]);
4059
+ if (streamCb) return;
4060
+ return result;
4061
+ } catch (error) {
4062
+ controller.abort();
4063
+ throw error;
4064
+ }
4065
+ }
4066
+ function removeCodeBlock(content) {
4067
+ const codeBlockMatch = content.trim().match(/^```(\w+)\n/);
4068
+ let language = '';
4069
+ if (codeBlockMatch) language = codeBlockMatch[1];
4070
+ const startRegExp = new RegExp(`^\\\`\\\`\\\`${language}\\n`);
4071
+ return content.trim().replace(startRegExp, '').replace(/\n?```$/, '');
4072
+ }
4073
+ const sanitizeFileName = (input)=>input.replace(/[\\/:*?"<>|\n\r#%&]/g, '').trim().replace(/\s+/g, '_').replace(/_+/g, '_').replace(/^_+|_+$/g, '');
4074
+ function removeImagesFromMarkdown(content) {
4075
+ let cleaned = content.replace(/!\[.*?\]\(.*?\)/g, '');
4076
+ cleaned = cleaned.replace(/<img\b[^>]*>/g, '');
4077
+ cleaned = cleaned.replace(/!\[.*?\]\(data:image\/[a-z+]+;base64,[a-zA-Z0-9+/=]+\)/g, '');
4078
+ cleaned = cleaned.replace(/\n{3,}/g, '\n\n');
4079
+ return cleaned.trim();
4080
+ }
4081
+ const requirementClarifier = {
4082
+ name: "requirement_clarifier",
4083
+ 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",
4084
+ parameters: RequirementClarifierParams,
4085
+ execute: async (args)=>{
4086
+ const { user_input, file_path = "" } = args;
4087
+ try {
4088
+ logger_logger.info({
4089
+ module: 'requirement_clarifier',
4090
+ message: "\u5904\u7406\u7528\u6237\u8F93\u5165",
4091
+ data: {
4092
+ user_input,
4093
+ file_path
4094
+ }
4095
+ });
4096
+ let context = user_input;
4097
+ if (file_path) {
4098
+ const markdownContent = await promises.readFile(file_path, 'utf8');
4099
+ context = removeImagesFromMarkdown(markdownContent);
4100
+ }
4101
+ const analysisContent = await getAiAnalysis(context);
4102
+ logger_logger.info({
4103
+ module: 'requirement_clarifier',
4104
+ message: "\u6536\u5230AI\u5206\u6790\u7ED3\u679C",
4105
+ context,
4106
+ user_input
4107
+ });
4108
+ const fileName = sanitizeFileName(analysisContent.length > 10 ? analysisContent.substring(0, 10) : `analysis_${Date.now()}`);
4109
+ const mdDir = path_0.join(getStorageDir(), 'requirement');
4110
+ await promises.mkdir(mdDir, {
4111
+ recursive: true
4112
+ });
4113
+ const mdPath = path_0.join(mdDir, `${fileName}.md`);
4114
+ const mdPathResolved = path_0.resolve(mdPath);
4115
+ await promises.writeFile(mdPath, analysisContent, 'utf8');
4116
+ logger_logger.info({
4117
+ module: 'requirement_clarifier',
4118
+ message: "\u9700\u6C42\u5206\u6790\u6587\u4EF6\u5DF2\u4FDD\u5B58",
4119
+ path: mdPathResolved
4120
+ });
4121
+ return formatAnalysisPrompt(user_input, context, analysisContent, mdPathResolved);
4122
+ } catch (error) {
4123
+ const errorMsg = `\u{9700}\u{6C42}\u{5206}\u{6790}\u{5931}\u{8D25}: ${error instanceof Error ? error.message : String(error)}`;
4124
+ logger_logger.error({
4125
+ module: 'requirement_clarifier',
4126
+ message: errorMsg,
4127
+ stack: error instanceof Error ? error.stack : void 0
4128
+ });
4129
+ throw new Error(errorMsg);
4130
+ }
4131
+ }
4132
+ };
4133
+ const getAiAnalysis = async (input)=>{
4134
+ let content = '';
4135
+ try {
4136
+ await new Promise((resolve, reject)=>{
4137
+ invokeFlow({
4138
+ appid: 'app-wEfVL90NAXYy7dx8YhnFLS9y',
4139
+ data: {
4140
+ content: input
4141
+ }
4142
+ }, (res)=>{
4143
+ try {
4144
+ if (res.content) content += res.content;
4145
+ if (res.isEnd) resolve(true);
4146
+ } catch (error) {
4147
+ reject(error);
4148
+ }
4149
+ }).catch(reject);
4150
+ });
4151
+ return removeCodeBlock(content);
4152
+ } catch (error) {
4153
+ 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"}`);
4154
+ }
4155
+ };
4156
+ const formatAnalysisPrompt = (userInput, context, content, filePath)=>`# \u{1F50D} AI\u{9700}\u{6C42}\u{5206}\u{6790}\u{5B8C}\u{6210}
4157
+
4158
+ ## \u{1F4DD} \u{7528}\u{6237}\u{539F}\u{59CB}\u{9700}\u{6C42}
4159
+ ${userInput}
4160
+
4161
+ ## \u{1F4CB} \u{5F53}\u{524D}\u{4E0A}\u{4E0B}\u{6587}
4162
+ ${context}
4163
+ ------------------------------
4164
+ ## \u{1F52C} \u{9700}\u{6C42}\u{5206}\u{6790}\u{7ED3}\u{679C}
4165
+ ${content}
4166
+
4167
+ ## \u{1F4C1} \u{5206}\u{6790}\u{6587}\u{4EF6}\u{4F4D}\u{7F6E}
4168
+ ${filePath}
4169
+
4170
+ **\u{1F4A1} \u{4E13}\u{4E1A}\u{5EFA}\u{8BAE}\u{FF1A}**
4171
+ \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}
4172
+
4173
+ **\u{1F3AF} \u{4E0B}\u{4E00}\u{6B65}\u{FF1A}**
4174
+ \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}
4175
+
4176
+ ---
4177
+ *\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}*
4178
+ `;
3828
4179
  function _define_property(obj, key, value) {
3829
4180
  if (key in obj) Object.defineProperty(obj, key, {
3830
4181
  value: value,
@@ -3835,13 +4186,6 @@ function _define_property(obj, key, value) {
3835
4186
  else obj[key] = value;
3836
4187
  return obj;
3837
4188
  }
3838
- const getStorageDir = ()=>{
3839
- const envDir = process.env.MCP_STORAGE_DIR || "./intention-coding";
3840
- if (!existsSync(envDir)) mkdirSync(envDir, {
3841
- recursive: true
3842
- });
3843
- return envDir;
3844
- };
3845
4189
  class RequirementStorage {
3846
4190
  get requirementsFile() {
3847
4191
  return this._requirementsFile;
@@ -3972,6 +4316,7 @@ class RequirementStorage {
3972
4316
  this.loadRequirements();
3973
4317
  }
3974
4318
  }
4319
+ const requirements_utils_storage = new RequirementStorage();
3975
4320
  const requirements_utils_currentRequirements = {
3976
4321
  project_overview: [],
3977
4322
  functional_requirements: [],
@@ -3982,18 +4327,8 @@ const requirements_utils_currentRequirements = {
3982
4327
  clarification_history: [],
3983
4328
  architecture_designs: [],
3984
4329
  last_updated: null,
3985
- project_id: null
3986
- };
3987
- const categoryMapping = {
3988
- 项目概述: "project_overview",
3989
- 核心功能需求: "functional_requirements",
3990
- 功能和UI需求: "functional_requirements",
3991
- 功能需求: "functional_requirements",
3992
- 技术需求: "technical_requirements",
3993
- 技术和设计约束: "technical_requirements",
3994
- 设计需求: "design_requirements",
3995
- 部署需求: "deployment_requirements",
3996
- AI约束: "ai_constraints"
4330
+ project_id: null,
4331
+ requirement_analysis: []
3997
4332
  };
3998
4333
  function countRequirements(requirements) {
3999
4334
  return [
@@ -4005,21 +4340,20 @@ function countRequirements(requirements) {
4005
4340
  "ai_constraints"
4006
4341
  ].reduce((sum, key)=>sum + requirements[key].length, 0);
4007
4342
  }
4008
- function getStorageCategory(category) {
4009
- return categoryMapping[category] || "functional_requirements";
4010
- }
4011
- function addRequirementEntry(requirements, category, content) {
4012
- const storageCategory = getStorageCategory(category);
4343
+ function addRequirementEntry(type, category, content) {
4013
4344
  const requirementEntry = {
4014
4345
  timestamp: new Date().toISOString(),
4015
4346
  category,
4016
4347
  content
4017
4348
  };
4018
- if (Array.isArray(requirements[storageCategory])) requirements[storageCategory].push(requirementEntry);
4019
- else requirements[storageCategory] = [
4349
+ requirements_utils_currentRequirements[type] = [
4020
4350
  requirementEntry
4021
4351
  ];
4022
- return requirements;
4352
+ requirements_utils_storage.saveHistoryEntry(type, content, {
4353
+ category
4354
+ });
4355
+ requirements_utils_storage.saveRequirements(requirements_utils_currentRequirements);
4356
+ return requirements_utils_currentRequirements;
4023
4357
  }
4024
4358
  function formatRequirementUpdateResponse(category, content, requirements, requirementsFile, historyFile) {
4025
4359
  const total = countRequirements(requirements);
@@ -4045,100 +4379,6 @@ function formatRequirementUpdateResponse(category, content, requirements, requir
4045
4379
  ## \u{1F3AF} \u{4E0B}\u{4E00}\u{6B65}\u{5EFA}\u{8BAE}
4046
4380
  \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}`;
4047
4381
  }
4048
- const requirementClarifierTool = {
4049
- name: "requirement_clarifier",
4050
- 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",
4051
- parameters: RequirementClarifierParams,
4052
- execute: async (args)=>{
4053
- const { user_input, context = "" } = args;
4054
- const storage = new RequirementStorage();
4055
- if (!requirements_utils_currentRequirements.clarification_history) requirements_utils_currentRequirements.clarification_history = [];
4056
- requirements_utils_currentRequirements.clarification_history.push({
4057
- timestamp: new Date().toISOString(),
4058
- content: `\u{7528}\u{6237}\u{8F93}\u{5165}: ${user_input} | \u{4E0A}\u{4E0B}\u{6587}: ${context}`
4059
- });
4060
- storage.saveHistoryEntry("requirement_clarification", user_input, {
4061
- context
4062
- });
4063
- storage.saveRequirements(requirements_utils_currentRequirements);
4064
- 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}
4065
-
4066
- ## \u{1F4DD} \u{7528}\u{6237}\u{8F93}\u{5165}
4067
- ${user_input}
4068
-
4069
- ## \u{1F4CB} \u{5F53}\u{524D}\u{4E0A}\u{4E0B}\u{6587}
4070
- ${context}
4071
-
4072
- ## \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}
4073
-
4074
- ### 1. \u{9879}\u{76EE}\u{7C7B}\u{578B}\u{8BC6}\u{522B}
4075
- \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}
4076
- - **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}
4077
- - **\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}
4078
- - **\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}
4079
- - **\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}
4080
- - **\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}
4081
-
4082
- ### 2. \u{9700}\u{6C42}\u{5B8C}\u{6574}\u{6027}\u{6DF1}\u{5EA6}\u{5206}\u{6790}
4083
- \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}
4084
-
4085
- **\u{1F3AF} \u{9879}\u{76EE}\u{76EE}\u{6807}\u{7EF4}\u{5EA6}**
4086
- - \u{89E3}\u{51B3}\u{4EC0}\u{4E48}\u{5177}\u{4F53}\u{95EE}\u{9898}\u{FF1F}
4087
- - \u{76EE}\u{6807}\u{7528}\u{6237}\u{7FA4}\u{4F53}\u{662F}\u{8C01}\u{FF1F}
4088
- - \u{9884}\u{671F}\u{8FBE}\u{5230}\u{4EC0}\u{4E48}\u{6548}\u{679C}\u{FF1F}
4089
-
4090
- **\u{2699}\u{FE0F} \u{529F}\u{80FD}\u{9700}\u{6C42}\u{7EF4}\u{5EA6}**
4091
- - \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}
4092
- - \u{6B21}\u{8981}\u{529F}\u{80FD}\u{6709}\u{54EA}\u{4E9B}\u{FF1F}
4093
- - \u{529F}\u{80FD}\u{7684}\u{4F18}\u{5148}\u{7EA7}\u{5982}\u{4F55}\u{FF1F}
4094
-
4095
- **\u{1F527} \u{6280}\u{672F}\u{9700}\u{6C42}\u{7EF4}\u{5EA6}**
4096
- - \u{6709}\u{6280}\u{672F}\u{6808}\u{504F}\u{597D}\u{5417}\u{FF1F}
4097
- - \u{6027}\u{80FD}\u{8981}\u{6C42}\u{5982}\u{4F55}\u{FF1F}
4098
- - \u{517C}\u{5BB9}\u{6027}\u{8981}\u{6C42}\u{FF1F}
4099
-
4100
- **\u{1F3A8} \u{7528}\u{6237}\u{4F53}\u{9A8C}\u{7EF4}\u{5EA6}**
4101
- - \u{754C}\u{9762}\u{98CE}\u{683C}\u{504F}\u{597D}\u{FF1F}
4102
- - \u{4EA4}\u{4E92}\u{65B9}\u{5F0F}\u{8981}\u{6C42}\u{FF1F}
4103
-
4104
- **\u{1F4CA} \u{89C4}\u{6A21}\u{548C}\u{6027}\u{80FD}\u{7EF4}\u{5EA6}**
4105
- - \u{9884}\u{671F}\u{7528}\u{6237}\u{89C4}\u{6A21}\u{FF1F}
4106
- - \u{5E76}\u{53D1}\u{91CF}\u{8981}\u{6C42}\u{FF1F}
4107
-
4108
- **\u{1F680} \u{90E8}\u{7F72}\u{548C}\u{7EF4}\u{62A4}\u{7EF4}\u{5EA6}**
4109
- - \u{90E8}\u{7F72}\u{73AF}\u{5883}\u{504F}\u{597D}\u{FF1F}
4110
- - \u{7EF4}\u{62A4}\u{65B9}\u{5F0F}\u{FF1F}
4111
-
4112
- ### 3. \u{667A}\u{80FD}\u{6F84}\u{6E05}\u{7B56}\u{7565}
4113
- \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}
4114
- - \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}
4115
- - \u{63D0}\u{4F9B}\u{5177}\u{4F53}\u{9009}\u{9879}\u{5E2E}\u{52A9}\u{7528}\u{6237}\u{7406}\u{89E3}
4116
- - \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}
4117
-
4118
- ## \u{1F4E4} \u{8F93}\u{51FA}\u{683C}\u{5F0F}\u{8981}\u{6C42}
4119
-
4120
- **\u{1F50D} \u{9700}\u{6C42}\u{5206}\u{6790}\u{7ED3}\u{679C}\u{FF1A}**
4121
- - **\u{9879}\u{76EE}\u{7C7B}\u{578B}**\u{FF1A}[\u{660E}\u{786E}\u{8BC6}\u{522B}\u{7684}\u{7C7B}\u{578B}]
4122
- - **\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}]
4123
- - **\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}]
4124
-
4125
- **\u{2753} \u{5173}\u{952E}\u{6F84}\u{6E05}\u{95EE}\u{9898}\u{FF1A}**
4126
- 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}]
4127
- 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}]
4128
- 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}]
4129
-
4130
- **\u{1F4A1} \u{4E13}\u{4E1A}\u{5EFA}\u{8BAE}\u{FF1A}**
4131
- [\u{57FA}\u{4E8E}\u{5206}\u{6790}\u{7ED9}\u{51FA}\u{7684}\u{5EFA}\u{8BAE}\u{548C}\u{63D0}\u{793A}]
4132
-
4133
- **\u{1F3AF} \u{4E0B}\u{4E00}\u{6B65}\u{6307}\u{5BFC}\u{FF1A}**
4134
- [\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}]
4135
-
4136
- ---
4137
- *\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}*
4138
- `;
4139
- return analysisPrompt;
4140
- }
4141
- };
4142
4382
  const requirementManagerTool = {
4143
4383
  name: "requirement_manager",
4144
4384
  description: "\u9700\u6C42\u6587\u6863\u7BA1\u7406\u5668 - \u5B9E\u65F6\u66F4\u65B0\u548C\u7EF4\u62A4\u7ED3\u6784\u5316\u7684\u9700\u6C42\u6587\u6863",
@@ -4146,11 +4386,7 @@ const requirementManagerTool = {
4146
4386
  execute: async (args)=>{
4147
4387
  const { clarified_info, category } = args;
4148
4388
  const storage = new RequirementStorage();
4149
- addRequirementEntry(requirements_utils_currentRequirements, category, clarified_info);
4150
- storage.saveHistoryEntry("requirement_update", clarified_info, {
4151
- category
4152
- });
4153
- storage.saveRequirements(requirements_utils_currentRequirements);
4389
+ addRequirementEntry("functional_requirements", category, clarified_info);
4154
4390
  return formatRequirementUpdateResponse(category, clarified_info, requirements_utils_currentRequirements, storage.requirementsFile, storage.historyFile);
4155
4391
  }
4156
4392
  };
@@ -4332,18 +4568,6 @@ ${storage.storageDir}/
4332
4568
  }
4333
4569
  }
4334
4570
  };
4335
- let view_requirements_status_currentRequirements = {
4336
- project_overview: [],
4337
- functional_requirements: [],
4338
- technical_requirements: [],
4339
- design_requirements: [],
4340
- deployment_requirements: [],
4341
- ai_constraints: [],
4342
- clarification_history: [],
4343
- architecture_designs: [],
4344
- last_updated: null,
4345
- project_id: null
4346
- };
4347
4571
  const viewRequirementsStatusTool = {
4348
4572
  name: "view_requirements_status",
4349
4573
  description: "\u67E5\u770B\u5F53\u524D\u9700\u6C42\u6587\u6863\u7684\u8BE6\u7EC6\u72B6\u6001\u548C\u5185\u5BB9",
@@ -4351,7 +4575,7 @@ const viewRequirementsStatusTool = {
4351
4575
  execute: async ()=>{
4352
4576
  var _currentRequirements_last_updated;
4353
4577
  const storage = new RequirementStorage();
4354
- const totalClarifications = view_requirements_status_currentRequirements.clarification_history.length;
4578
+ const totalClarifications = requirements_utils_currentRequirements.clarification_history.length;
4355
4579
  const totalRequirements = [
4356
4580
  "project_overview",
4357
4581
  "functional_requirements",
@@ -4359,12 +4583,12 @@ const viewRequirementsStatusTool = {
4359
4583
  "design_requirements",
4360
4584
  "deployment_requirements",
4361
4585
  "ai_constraints"
4362
- ].reduce((sum, key)=>sum + view_requirements_status_currentRequirements[key].length, 0);
4363
- const totalArchitectures = view_requirements_status_currentRequirements.architecture_designs.length;
4586
+ ].reduce((sum, key)=>sum + requirements_utils_currentRequirements[key].length, 0);
4587
+ const totalArchitectures = requirements_utils_currentRequirements.architecture_designs.length;
4364
4588
  let statusReport = `# \u{1F4CB} \u{5F53}\u{524D}\u{9700}\u{6C42}\u{6587}\u{6863}\u{72B6}\u{6001}
4365
4589
 
4366
4590
  ## \u{1F4CA} \u{603B}\u{4F53}\u{7EDF}\u{8BA1}
4367
- - **\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"}
4591
+ - **\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"}
4368
4592
  - **\u{9700}\u{6C42}\u{6F84}\u{6E05}\u{6B21}\u{6570}**: ${totalClarifications}
4369
4593
  - **\u{9700}\u{6C42}\u{6761}\u{76EE}\u{603B}\u{6570}**: ${totalRequirements}
4370
4594
  - **\u{67B6}\u{6784}\u{8BBE}\u{8BA1}\u{65B9}\u{6848}**: ${totalArchitectures}
@@ -4372,30 +4596,30 @@ const viewRequirementsStatusTool = {
4372
4596
 
4373
4597
  ## \u{1F4DD} \u{9700}\u{6C42}\u{5206}\u{7C7B}\u{8BE6}\u{60C5}
4374
4598
 
4375
- ### \u{1F3AF} \u{9879}\u{76EE}\u{6982}\u{8FF0} (${view_requirements_status_currentRequirements.project_overview.length} \u{6761})
4599
+ ### \u{1F3AF} \u{9879}\u{76EE}\u{6982}\u{8FF0} (${requirements_utils_currentRequirements.project_overview.length} \u{6761})
4376
4600
  `;
4377
- view_requirements_status_currentRequirements.project_overview.forEach((item, i)=>{
4601
+ requirements_utils_currentRequirements.project_overview.forEach((item, i)=>{
4378
4602
  const content = item.content;
4379
4603
  statusReport += `${i + 1}. ${content.slice(0, 100)}${content.length > 100 ? "..." : ""}\n`;
4380
4604
  });
4381
4605
  statusReport += `
4382
- ### \u{2699}\u{FE0F} \u{529F}\u{80FD}\u{9700}\u{6C42} (${view_requirements_status_currentRequirements.functional_requirements.length} \u{6761})
4606
+ ### \u{2699}\u{FE0F} \u{529F}\u{80FD}\u{9700}\u{6C42} (${requirements_utils_currentRequirements.functional_requirements.length} \u{6761})
4383
4607
  `;
4384
- view_requirements_status_currentRequirements.functional_requirements.forEach((item, i)=>{
4608
+ requirements_utils_currentRequirements.functional_requirements.forEach((item, i)=>{
4385
4609
  const content = item.content;
4386
4610
  statusReport += `${i + 1}. ${content.slice(0, 100)}${content.length > 100 ? "..." : ""}\n`;
4387
4611
  });
4388
4612
  statusReport += `
4389
- ### \u{1F527} \u{6280}\u{672F}\u{9700}\u{6C42} (${view_requirements_status_currentRequirements.technical_requirements.length} \u{6761})
4613
+ ### \u{1F527} \u{6280}\u{672F}\u{9700}\u{6C42} (${requirements_utils_currentRequirements.technical_requirements.length} \u{6761})
4390
4614
  `;
4391
- view_requirements_status_currentRequirements.technical_requirements.forEach((item, i)=>{
4615
+ requirements_utils_currentRequirements.technical_requirements.forEach((item, i)=>{
4392
4616
  const content = item.content;
4393
4617
  statusReport += `${i + 1}. ${content.slice(0, 100)}${content.length > 100 ? "..." : ""}\n`;
4394
4618
  });
4395
4619
  statusReport += `
4396
- ### \u{1F3D7}\u{FE0F} \u{67B6}\u{6784}\u{8BBE}\u{8BA1} (${view_requirements_status_currentRequirements.architecture_designs.length} \u{4E2A})
4620
+ ### \u{1F3D7}\u{FE0F} \u{67B6}\u{6784}\u{8BBE}\u{8BA1} (${requirements_utils_currentRequirements.architecture_designs.length} \u{4E2A})
4397
4621
  `;
4398
- view_requirements_status_currentRequirements.architecture_designs.forEach((design, i)=>{
4622
+ requirements_utils_currentRequirements.architecture_designs.forEach((design, i)=>{
4399
4623
  var _design_timestamp;
4400
4624
  const focus = design.design_focus || "\u672A\u6307\u5B9A";
4401
4625
  const timestamp = (null == (_design_timestamp = design.timestamp) ? void 0 : _design_timestamp.slice(0, 19)) || "\u672A\u77E5\u65F6\u95F4";
@@ -4426,7 +4650,109 @@ const viewRequirementsStatusTool = {
4426
4650
  return statusReport;
4427
4651
  }
4428
4652
  };
4429
- const mcp = new FastMCP({
4653
+ const Word2MdParams = objectType({
4654
+ file_path: stringType().describe("\u9700\u8981\u89E3\u6790\u7684Word\u6587\u6863\u7684\u7EDD\u5BF9\u8DEF\u5F84"),
4655
+ options: objectType({
4656
+ skip_images: booleanType().optional().default(false).describe("\u662F\u5426\u8DF3\u8FC7\u56FE\u7247\u8F6C\u6362"),
4657
+ table_style: enumType([
4658
+ 'simple',
4659
+ 'grid',
4660
+ 'pipe'
4661
+ ]).optional().default('simple').describe("\u8868\u683C\u8F6C\u6362\u6837\u5F0F"),
4662
+ strict_mode: booleanType().optional().default(false).describe("\u4E25\u683C\u6A21\u5F0F\uFF08\u4FDD\u7559\u66F4\u591A\u683C\u5F0F\uFF09")
4663
+ }).optional().default({}).describe("\u8F6C\u6362\u9009\u9879")
4664
+ });
4665
+ function word2md_validateFilePath(filePath) {
4666
+ const normalized = path_0.normalize(filePath);
4667
+ const resolved = path_0.resolve(normalized);
4668
+ const cwd = process.cwd();
4669
+ if (!resolved.startsWith(cwd)) {
4670
+ logger_logger.warn(`\u{6587}\u{4EF6}\u{8BBF}\u{95EE}\u{8D85}\u{51FA}\u{5DE5}\u{4F5C}\u{76EE}\u{5F55}: ${filePath}`);
4671
+ return false;
4672
+ }
4673
+ if (!resolved.toLowerCase().endsWith('.docx')) {
4674
+ logger_logger.warn(`\u{4EC5}\u{652F}\u{6301}.docx\u{683C}\u{5F0F}\u{6587}\u{4EF6}: ${filePath}`);
4675
+ return false;
4676
+ }
4677
+ return true;
4678
+ }
4679
+ const word2mdTool = {
4680
+ name: "word2md",
4681
+ description: "\u5C06Word\u6587\u6863(.docx)\u8F6C\u6362\u4E3AMarkdown\u683C\u5F0F",
4682
+ parameters: Word2MdParams,
4683
+ execute: async (args)=>{
4684
+ const { file_path } = args;
4685
+ try {
4686
+ if (!word2md_validateFilePath(file_path)) throw new Error(`\u{6587}\u{4EF6}\u{8DEF}\u{5F84}\u{65E0}\u{6548}: ${file_path}`);
4687
+ const stats = await stat(file_path);
4688
+ 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}`);
4689
+ const buffer = await readFile(file_path);
4690
+ const htmlResult = await convertToHtml({
4691
+ buffer
4692
+ });
4693
+ if (htmlResult.messages && htmlResult.messages.length > 0) logger_logger.warn("Word\u8F6C\u6362\u8B66\u544A", {
4694
+ file: file_path,
4695
+ warnings: htmlResult.messages
4696
+ });
4697
+ const markdownContent = html_to_md(htmlResult.value);
4698
+ const textOnlyContent = removeImagesFromMarkdown(markdownContent);
4699
+ const mdDir = path_0.join(getStorageDir(), 'md');
4700
+ await mkdir(mdDir, {
4701
+ recursive: true
4702
+ });
4703
+ const baseName = path_0.basename(file_path, '.docx');
4704
+ const fullMdPath = path_0.join(mdDir, `${baseName}.md`);
4705
+ await writeFile(fullMdPath, markdownContent, 'utf8');
4706
+ const textOnlyPath = path_0.join(mdDir, `${baseName}_text_only.md`);
4707
+ await writeFile(textOnlyPath, textOnlyContent, 'utf8');
4708
+ const textOnlyPathResolved = path_0.resolve(textOnlyPath);
4709
+ return `
4710
+ # \u{2705} \u{6587}\u{6863}\u{8F6C}\u{6362}\u{5B8C}\u{6210}
4711
+ - \u{5B8C}\u{6574}MD\u{6587}\u{4EF6}: ${path_0.resolve(fullMdPath)}
4712
+ - \u{7EAF}\u{6587}\u{672C}MD\u{6587}\u{4EF6}(\u{65E0}\u{56FE}\u{7247}): ${textOnlyPathResolved}
4713
+
4714
+ # \u{4EFB}\u{52A1}\u{89C4}\u{5212}\u{FF1A}
4715
+ 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}
4716
+ 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}
4717
+ `;
4718
+ } catch (error) {
4719
+ const errorMsg = error instanceof Error ? error.message : String(error);
4720
+ logger_logger.error(`Word\u{8F6C}\u{6362}\u{5931}\u{8D25}: ${errorMsg}`, {
4721
+ tool: "word2md",
4722
+ file_path
4723
+ });
4724
+ return errorMsg;
4725
+ }
4726
+ }
4727
+ };
4728
+ const IntentRecognizerParams = objectType({
4729
+ user_input: stringType().describe("\u7528\u6237\u539F\u59CB\u8F93\u5165\u6587\u672C"),
4730
+ context: stringType().optional().describe("\u4E0A\u4E0B\u6587\u4FE1\u606F")
4731
+ });
4732
+ const ContractItem = objectType({
4733
+ tool_name: stringType().describe("\u8981\u6267\u884C\u7684\u5DE5\u5177\u540D\u79F0"),
4734
+ arguments: recordType(anyType()).optional().describe("\u5DE5\u5177\u6267\u884C\u53C2\u6570")
4735
+ });
4736
+ objectType({
4737
+ sequence: arrayType(ContractItem).describe("\u5DE5\u5177\u6267\u884C\u5E8F\u5217")
4738
+ });
4739
+ const intentRecognizer = {
4740
+ name: "intent_recognizer",
4741
+ description: "\u5206\u6790\u7528\u6237\u610F\u56FE\u751F\u6210\u5DE5\u5177\u6267\u884C\u5408\u7EA6",
4742
+ parameters: IntentRecognizerParams,
4743
+ execute: async (args)=>{
4744
+ const { user_input, context = "" } = args;
4745
+ if (!user_input || user_input.trim().length < 3) throw new Error("\u8F93\u5165\u65E0\u6548\uFF1A\u81F3\u5C11\u9700\u89813\u4E2A\u5B57\u7B26");
4746
+ if (!context) throw new Error("\u8BF7\u4ECE\u4E0A\u4E00\u6B65\u63D0\u70BC\u51FA\u4E0A\u4E0B\u6587\u518D\u91CD\u65B0\u6267\u884C");
4747
+ 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}`);
4748
+ return `
4749
+ # \u{4EFB}\u{52A1}\u{89C4}\u{5212}\u{FF1A}
4750
+ 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}
4751
+ 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}
4752
+ `;
4753
+ }
4754
+ };
4755
+ const server = new FastMCP({
4430
4756
  name: SERVICE_CONFIG.name,
4431
4757
  version: SERVICE_CONFIG.version,
4432
4758
  ping: {
@@ -4435,12 +4761,14 @@ const mcp = new FastMCP({
4435
4761
  logLevel: "info"
4436
4762
  }
4437
4763
  });
4438
- mcp.addTool(requirementClarifierTool);
4439
- mcp.addTool(requirementManagerTool);
4440
- mcp.addTool(architectureDesignerTool);
4441
- mcp.addTool(exportFinalDocumentTool);
4442
- mcp.addTool(viewRequirementsStatusTool);
4443
- console.log("\uD83D\uDE80 \u542F\u52A8AI\u9700\u6C42\u5206\u6790\u548C\u8BBE\u8BA1\u52A9\u624B");
4444
- mcp.start({
4764
+ server.addTool(word2mdTool);
4765
+ server.addTool(intentRecognizer);
4766
+ server.addTool(requirementClarifier);
4767
+ server.addTool(requirementManagerTool);
4768
+ server.addTool(architectureDesignerTool);
4769
+ server.addTool(exportFinalDocumentTool);
4770
+ server.addTool(viewRequirementsStatusTool);
4771
+ logger_logger.info(`\u{1F680} \u{542F}\u{52A8}${SERVICE_CONFIG.name}\u{6210}\u{529F}`);
4772
+ server.start({
4445
4773
  transportType: "stdio"
4446
4774
  });