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