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