intention-coding 0.0.9 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +17 -41
- package/dist/index.js +17 -41
- package/dist/utils/common.d.ts +0 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -200,7 +200,7 @@ const transports = [
|
|
|
200
200
|
level: 'info'
|
|
201
201
|
})
|
|
202
202
|
];
|
|
203
|
-
const
|
|
203
|
+
const logger = external_winston_default().createLogger({
|
|
204
204
|
level: 'debug',
|
|
205
205
|
levels,
|
|
206
206
|
format: external_winston_default().format.combine(external_winston_default().format.errors({
|
|
@@ -229,7 +229,7 @@ const logger_logger = external_winston_default().createLogger({
|
|
|
229
229
|
]
|
|
230
230
|
});
|
|
231
231
|
process.on('SIGINT', ()=>{
|
|
232
|
-
|
|
232
|
+
logger.end(()=>{
|
|
233
233
|
console.log("\u65E5\u5FD7\u5DF2\u5173\u95ED");
|
|
234
234
|
process.exit(0);
|
|
235
235
|
});
|
|
@@ -4094,19 +4094,10 @@ async function validateAndResolvePath(filePath) {
|
|
|
4094
4094
|
if ('win32' === process.platform && filePath.startsWith('\\\\')) filePath = '\\\\?\\UNC\\' + filePath.substring(2);
|
|
4095
4095
|
const normalized = external_path_default().normalize(filePath);
|
|
4096
4096
|
const resolved = external_path_default().resolve(normalized);
|
|
4097
|
-
const cwd = process.cwd();
|
|
4098
|
-
if (!resolved.startsWith(cwd)) {
|
|
4099
|
-
logger_logger.warn(`\u{6587}\u{4EF6}\u{8BBF}\u{95EE}\u{8D85}\u{51FA}\u{5DE5}\u{4F5C}\u{76EE}\u{5F55}: ${filePath}`);
|
|
4100
|
-
throw new Error(`\u{6587}\u{4EF6}\u{8BBF}\u{95EE}\u{8D85}\u{51FA}\u{5DE5}\u{4F5C}\u{76EE}\u{5F55}: ${filePath}`);
|
|
4101
|
-
}
|
|
4102
|
-
if (!resolved.toLowerCase().endsWith('.docx')) {
|
|
4103
|
-
logger_logger.warn(`\u{4EC5}\u{652F}\u{6301}.docx\u{683C}\u{5F0F}\u{6587}\u{4EF6}: ${filePath}`);
|
|
4104
|
-
throw new Error(`\u{4EC5}\u{652F}\u{6301}.docx\u{683C}\u{5F0F}\u{6587}\u{4EF6}: ${filePath}`);
|
|
4105
|
-
}
|
|
4106
4097
|
try {
|
|
4107
4098
|
await external_fs_namespaceObject.promises.access(resolved, external_fs_namespaceObject.promises.constants.R_OK);
|
|
4108
4099
|
} catch (error) {
|
|
4109
|
-
|
|
4100
|
+
logger.warn(`\u{6587}\u{4EF6}\u{4E0D}\u{5B58}\u{5728}\u{6216}\u{4E0D}\u{53EF}\u{8BFB}: ${resolved}`, error);
|
|
4110
4101
|
throw new Error(`\u{6587}\u{4EF6}\u{4E0D}\u{5B58}\u{5728}\u{6216}\u{4E0D}\u{53EF}\u{8BFB}: ${resolved}`);
|
|
4111
4102
|
}
|
|
4112
4103
|
return resolved;
|
|
@@ -4120,7 +4111,7 @@ const requirementClarifier = {
|
|
|
4120
4111
|
execute: async (args)=>{
|
|
4121
4112
|
const { user_input, file_path = "" } = args;
|
|
4122
4113
|
try {
|
|
4123
|
-
|
|
4114
|
+
logger.info({
|
|
4124
4115
|
module: 'requirement_clarifier',
|
|
4125
4116
|
message: "\u5904\u7406\u7528\u6237\u8F93\u5165",
|
|
4126
4117
|
data: {
|
|
@@ -4134,7 +4125,7 @@ const requirementClarifier = {
|
|
|
4134
4125
|
context = removeImagesFromMarkdown(markdownContent);
|
|
4135
4126
|
}
|
|
4136
4127
|
const analysisContent = await getAiAnalysis(context);
|
|
4137
|
-
|
|
4128
|
+
logger.info({
|
|
4138
4129
|
module: 'requirement_clarifier',
|
|
4139
4130
|
message: "\u6536\u5230AI\u5206\u6790\u7ED3\u679C",
|
|
4140
4131
|
context,
|
|
@@ -4153,7 +4144,7 @@ const requirementClarifier = {
|
|
|
4153
4144
|
if (subContents.length > 0) {
|
|
4154
4145
|
jumpLinks = await saveSubAnalysisFiles(mdDir, subContents);
|
|
4155
4146
|
finalContent = addJumpLinks(analysisContent, jumpLinks);
|
|
4156
|
-
|
|
4147
|
+
logger.info({
|
|
4157
4148
|
module: 'requirement_clarifier',
|
|
4158
4149
|
message: `\u{6210}\u{529F}\u{5904}\u{7406}${subContents.length}\u{4E2A}\u{7EC6}\u{5206}\u{9879}`,
|
|
4159
4150
|
jumpLinks: jumpLinks.map((link)=>({
|
|
@@ -4163,7 +4154,7 @@ const requirementClarifier = {
|
|
|
4163
4154
|
});
|
|
4164
4155
|
}
|
|
4165
4156
|
await promises_default().writeFile(mdPath, finalContent, 'utf8');
|
|
4166
|
-
|
|
4157
|
+
logger.info({
|
|
4167
4158
|
module: 'requirement_clarifier',
|
|
4168
4159
|
message: "\u9700\u6C42\u5206\u6790\u6587\u4EF6\u5DF2\u4FDD\u5B58",
|
|
4169
4160
|
path: mdPathResolved,
|
|
@@ -4172,7 +4163,7 @@ const requirementClarifier = {
|
|
|
4172
4163
|
return formatAnalysisPrompt(user_input, finalContent, mdPathResolved);
|
|
4173
4164
|
} catch (error) {
|
|
4174
4165
|
const errorMsg = `\u{9700}\u{6C42}\u{5206}\u{6790}\u{5931}\u{8D25}: ${error instanceof Error ? error.message : String(error)}`;
|
|
4175
|
-
|
|
4166
|
+
logger.error({
|
|
4176
4167
|
module: 'requirement_clarifier',
|
|
4177
4168
|
message: errorMsg,
|
|
4178
4169
|
stack: error instanceof Error ? error.stack : void 0
|
|
@@ -4215,7 +4206,7 @@ const getSubAnalysis = async (content)=>{
|
|
|
4215
4206
|
return response.outputs.result;
|
|
4216
4207
|
} catch (error) {
|
|
4217
4208
|
const errorMsg = `\u{7EC6}\u{5206}\u{5206}\u{6790}\u{8BF7}\u{6C42}\u{5931}\u{8D25}: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`;
|
|
4218
|
-
|
|
4209
|
+
logger.error({
|
|
4219
4210
|
module: 'requirement_clarifier',
|
|
4220
4211
|
message: errorMsg,
|
|
4221
4212
|
stack: error instanceof Error ? error.stack : void 0
|
|
@@ -4238,14 +4229,14 @@ const saveSubAnalysisFiles = async (mainDir, contentArray)=>{
|
|
|
4238
4229
|
title,
|
|
4239
4230
|
path: filePath
|
|
4240
4231
|
});
|
|
4241
|
-
|
|
4232
|
+
logger.debug({
|
|
4242
4233
|
module: 'requirement_clarifier',
|
|
4243
4234
|
message: "\u7EC6\u5206\u5206\u6790\u6587\u4EF6\u5DF2\u4FDD\u5B58",
|
|
4244
4235
|
path: filePath,
|
|
4245
4236
|
title
|
|
4246
4237
|
});
|
|
4247
4238
|
} catch (error) {
|
|
4248
|
-
|
|
4239
|
+
logger.error({
|
|
4249
4240
|
module: 'requirement_clarifier',
|
|
4250
4241
|
message: `\u{4FDD}\u{5B58}\u{7EC6}\u{5206}\u{6587}\u{4EF6}\u{5931}\u{8D25}: ${error instanceof Error ? error.message : String(error)}`,
|
|
4251
4242
|
filePath,
|
|
@@ -4509,7 +4500,7 @@ async function packProject() {
|
|
|
4509
4500
|
await promises_default().mkdir(mdDir, {
|
|
4510
4501
|
recursive: true
|
|
4511
4502
|
});
|
|
4512
|
-
|
|
4503
|
+
logger.info(`\u{1F4C2} \u{6B63}\u{5728}\u{5206}\u{6790}\u{5F53}\u{524D}\u{672C}\u{5730}\u{9879}\u{76EE}`);
|
|
4513
4504
|
const mdPath = external_path_default().join(mdDir, `\u{9879}\u{76EE}\u{67B6}\u{6784}\u{5206}\u{6790}.md`);
|
|
4514
4505
|
const options = {
|
|
4515
4506
|
output: mdPath,
|
|
@@ -4667,7 +4658,7 @@ const architectureDesignerTool = {
|
|
|
4667
4658
|
storage.saveRequirements(requirements_utils_currentRequirements);
|
|
4668
4659
|
return architecture_design;
|
|
4669
4660
|
} catch (error) {
|
|
4670
|
-
|
|
4661
|
+
logger.error(`\u{274C} \u{67B6}\u{6784}\u{8BBE}\u{8BA1}\u{751F}\u{6210}\u{5931}\u{8D25}: ${error instanceof Error ? error.message : String(error)}`);
|
|
4671
4662
|
throw new Error(`\u{67B6}\u{6784}\u{8BBE}\u{8BA1}\u{751F}\u{6210}\u{5931}\u{8D25}: ${error instanceof Error ? error.message : String(error)}`);
|
|
4672
4663
|
}
|
|
4673
4664
|
}
|
|
@@ -4828,20 +4819,6 @@ const Word2MdParams = objectType({
|
|
|
4828
4819
|
strict_mode: booleanType().optional().default(false).describe("\u4E25\u683C\u6A21\u5F0F\uFF08\u4FDD\u7559\u66F4\u591A\u683C\u5F0F\uFF09")
|
|
4829
4820
|
}).optional().default({}).describe("\u8F6C\u6362\u9009\u9879")
|
|
4830
4821
|
});
|
|
4831
|
-
function word2md_validateFilePath(filePath) {
|
|
4832
|
-
const normalized = external_path_default().normalize(filePath);
|
|
4833
|
-
const resolved = external_path_default().resolve(normalized);
|
|
4834
|
-
const cwd = process.cwd();
|
|
4835
|
-
if (!resolved.startsWith(cwd)) {
|
|
4836
|
-
logger_logger.warn(`\u{6587}\u{4EF6}\u{8BBF}\u{95EE}\u{8D85}\u{51FA}\u{5DE5}\u{4F5C}\u{76EE}\u{5F55}: ${filePath}`);
|
|
4837
|
-
return false;
|
|
4838
|
-
}
|
|
4839
|
-
if (!resolved.toLowerCase().endsWith('.docx')) {
|
|
4840
|
-
logger_logger.warn(`\u{4EC5}\u{652F}\u{6301}.docx\u{683C}\u{5F0F}\u{6587}\u{4EF6}: ${filePath}`);
|
|
4841
|
-
return false;
|
|
4842
|
-
}
|
|
4843
|
-
return true;
|
|
4844
|
-
}
|
|
4845
4822
|
const word2mdTool = {
|
|
4846
4823
|
name: "word2md",
|
|
4847
4824
|
description: "\u5C06Word\u6587\u6863(.docx)\u8F6C\u6362\u4E3AMarkdown\u683C\u5F0F",
|
|
@@ -4849,13 +4826,12 @@ const word2mdTool = {
|
|
|
4849
4826
|
execute: async (args)=>{
|
|
4850
4827
|
const { file_path } = args;
|
|
4851
4828
|
try {
|
|
4852
|
-
if (!word2md_validateFilePath(file_path)) throw new Error(`\u{6587}\u{4EF6}\u{8DEF}\u{5F84}\u{65E0}\u{6548}: ${file_path}`);
|
|
4853
4829
|
const resolvedPath = await validateAndResolvePath(file_path);
|
|
4854
4830
|
const buffer = await promises_namespaceObject.readFile(resolvedPath);
|
|
4855
4831
|
const htmlResult = await external_mammoth_namespaceObject.convertToHtml({
|
|
4856
4832
|
buffer
|
|
4857
4833
|
});
|
|
4858
|
-
if (htmlResult.messages && htmlResult.messages.length > 0)
|
|
4834
|
+
if (htmlResult.messages && htmlResult.messages.length > 0) logger.warn("Word\u8F6C\u6362\u8B66\u544A", {
|
|
4859
4835
|
file: file_path,
|
|
4860
4836
|
warnings: htmlResult.messages
|
|
4861
4837
|
});
|
|
@@ -4882,7 +4858,7 @@ const word2mdTool = {
|
|
|
4882
4858
|
`;
|
|
4883
4859
|
} catch (error) {
|
|
4884
4860
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
4885
|
-
|
|
4861
|
+
logger.error(`Word\u{8F6C}\u{6362}\u{5931}\u{8D25}: ${errorMsg}`, {
|
|
4886
4862
|
tool: "word2md",
|
|
4887
4863
|
file_path
|
|
4888
4864
|
});
|
|
@@ -4909,7 +4885,7 @@ const intentRecognizer = {
|
|
|
4909
4885
|
const { user_input, context = "" } = args;
|
|
4910
4886
|
if (!user_input || user_input.trim().length < 3) throw new Error("\u8F93\u5165\u65E0\u6548\uFF1A\u81F3\u5C11\u9700\u89813\u4E2A\u5B57\u7B26");
|
|
4911
4887
|
if (!context) throw new Error("\u8BF7\u4ECE\u4E0A\u4E00\u6B65\u63D0\u70BC\u51FA\u4E0A\u4E0B\u6587\u518D\u91CD\u65B0\u6267\u884C");
|
|
4912
|
-
|
|
4888
|
+
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}`);
|
|
4913
4889
|
return `
|
|
4914
4890
|
# \u{4EFB}\u{52A1}\u{89C4}\u{5212}\u{FF1A}
|
|
4915
4891
|
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}
|
|
@@ -4933,7 +4909,7 @@ server.addTool(requirementManagerTool);
|
|
|
4933
4909
|
server.addTool(architectureDesignerTool);
|
|
4934
4910
|
server.addTool(exportFinalDocumentTool);
|
|
4935
4911
|
server.addTool(viewRequirementsStatusTool);
|
|
4936
|
-
|
|
4912
|
+
logger.info(`\u{1F680} \u{542F}\u{52A8}${SERVICE_CONFIG.name}\u{6210}\u{529F}`);
|
|
4937
4913
|
server.start({
|
|
4938
4914
|
transportType: "stdio"
|
|
4939
4915
|
});
|
package/dist/index.js
CHANGED
|
@@ -189,7 +189,7 @@ const transports = [
|
|
|
189
189
|
level: 'info'
|
|
190
190
|
})
|
|
191
191
|
];
|
|
192
|
-
const
|
|
192
|
+
const logger = winston.createLogger({
|
|
193
193
|
level: 'debug',
|
|
194
194
|
levels,
|
|
195
195
|
format: winston.format.combine(winston.format.errors({
|
|
@@ -218,7 +218,7 @@ const logger_logger = winston.createLogger({
|
|
|
218
218
|
]
|
|
219
219
|
});
|
|
220
220
|
process.on('SIGINT', ()=>{
|
|
221
|
-
|
|
221
|
+
logger.end(()=>{
|
|
222
222
|
console.log("\u65E5\u5FD7\u5DF2\u5173\u95ED");
|
|
223
223
|
process.exit(0);
|
|
224
224
|
});
|
|
@@ -4083,19 +4083,10 @@ async function validateAndResolvePath(filePath) {
|
|
|
4083
4083
|
if ('win32' === process.platform && filePath.startsWith('\\\\')) filePath = '\\\\?\\UNC\\' + filePath.substring(2);
|
|
4084
4084
|
const normalized = path_0.normalize(filePath);
|
|
4085
4085
|
const resolved = path_0.resolve(normalized);
|
|
4086
|
-
const cwd = process.cwd();
|
|
4087
|
-
if (!resolved.startsWith(cwd)) {
|
|
4088
|
-
logger_logger.warn(`\u{6587}\u{4EF6}\u{8BBF}\u{95EE}\u{8D85}\u{51FA}\u{5DE5}\u{4F5C}\u{76EE}\u{5F55}: ${filePath}`);
|
|
4089
|
-
throw new Error(`\u{6587}\u{4EF6}\u{8BBF}\u{95EE}\u{8D85}\u{51FA}\u{5DE5}\u{4F5C}\u{76EE}\u{5F55}: ${filePath}`);
|
|
4090
|
-
}
|
|
4091
|
-
if (!resolved.toLowerCase().endsWith('.docx')) {
|
|
4092
|
-
logger_logger.warn(`\u{4EC5}\u{652F}\u{6301}.docx\u{683C}\u{5F0F}\u{6587}\u{4EF6}: ${filePath}`);
|
|
4093
|
-
throw new Error(`\u{4EC5}\u{652F}\u{6301}.docx\u{683C}\u{5F0F}\u{6587}\u{4EF6}: ${filePath}`);
|
|
4094
|
-
}
|
|
4095
4086
|
try {
|
|
4096
4087
|
await promises.access(resolved, promises.constants.R_OK);
|
|
4097
4088
|
} catch (error) {
|
|
4098
|
-
|
|
4089
|
+
logger.warn(`\u{6587}\u{4EF6}\u{4E0D}\u{5B58}\u{5728}\u{6216}\u{4E0D}\u{53EF}\u{8BFB}: ${resolved}`, error);
|
|
4099
4090
|
throw new Error(`\u{6587}\u{4EF6}\u{4E0D}\u{5B58}\u{5728}\u{6216}\u{4E0D}\u{53EF}\u{8BFB}: ${resolved}`);
|
|
4100
4091
|
}
|
|
4101
4092
|
return resolved;
|
|
@@ -4107,7 +4098,7 @@ const requirementClarifier = {
|
|
|
4107
4098
|
execute: async (args)=>{
|
|
4108
4099
|
const { user_input, file_path = "" } = args;
|
|
4109
4100
|
try {
|
|
4110
|
-
|
|
4101
|
+
logger.info({
|
|
4111
4102
|
module: 'requirement_clarifier',
|
|
4112
4103
|
message: "\u5904\u7406\u7528\u6237\u8F93\u5165",
|
|
4113
4104
|
data: {
|
|
@@ -4121,7 +4112,7 @@ const requirementClarifier = {
|
|
|
4121
4112
|
context = removeImagesFromMarkdown(markdownContent);
|
|
4122
4113
|
}
|
|
4123
4114
|
const analysisContent = await getAiAnalysis(context);
|
|
4124
|
-
|
|
4115
|
+
logger.info({
|
|
4125
4116
|
module: 'requirement_clarifier',
|
|
4126
4117
|
message: "\u6536\u5230AI\u5206\u6790\u7ED3\u679C",
|
|
4127
4118
|
context,
|
|
@@ -4140,7 +4131,7 @@ const requirementClarifier = {
|
|
|
4140
4131
|
if (subContents.length > 0) {
|
|
4141
4132
|
jumpLinks = await saveSubAnalysisFiles(mdDir, subContents);
|
|
4142
4133
|
finalContent = addJumpLinks(analysisContent, jumpLinks);
|
|
4143
|
-
|
|
4134
|
+
logger.info({
|
|
4144
4135
|
module: 'requirement_clarifier',
|
|
4145
4136
|
message: `\u{6210}\u{529F}\u{5904}\u{7406}${subContents.length}\u{4E2A}\u{7EC6}\u{5206}\u{9879}`,
|
|
4146
4137
|
jumpLinks: jumpLinks.map((link)=>({
|
|
@@ -4150,7 +4141,7 @@ const requirementClarifier = {
|
|
|
4150
4141
|
});
|
|
4151
4142
|
}
|
|
4152
4143
|
await fs_promises.writeFile(mdPath, finalContent, 'utf8');
|
|
4153
|
-
|
|
4144
|
+
logger.info({
|
|
4154
4145
|
module: 'requirement_clarifier',
|
|
4155
4146
|
message: "\u9700\u6C42\u5206\u6790\u6587\u4EF6\u5DF2\u4FDD\u5B58",
|
|
4156
4147
|
path: mdPathResolved,
|
|
@@ -4159,7 +4150,7 @@ const requirementClarifier = {
|
|
|
4159
4150
|
return formatAnalysisPrompt(user_input, finalContent, mdPathResolved);
|
|
4160
4151
|
} catch (error) {
|
|
4161
4152
|
const errorMsg = `\u{9700}\u{6C42}\u{5206}\u{6790}\u{5931}\u{8D25}: ${error instanceof Error ? error.message : String(error)}`;
|
|
4162
|
-
|
|
4153
|
+
logger.error({
|
|
4163
4154
|
module: 'requirement_clarifier',
|
|
4164
4155
|
message: errorMsg,
|
|
4165
4156
|
stack: error instanceof Error ? error.stack : void 0
|
|
@@ -4202,7 +4193,7 @@ const getSubAnalysis = async (content)=>{
|
|
|
4202
4193
|
return response.outputs.result;
|
|
4203
4194
|
} catch (error) {
|
|
4204
4195
|
const errorMsg = `\u{7EC6}\u{5206}\u{5206}\u{6790}\u{8BF7}\u{6C42}\u{5931}\u{8D25}: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`;
|
|
4205
|
-
|
|
4196
|
+
logger.error({
|
|
4206
4197
|
module: 'requirement_clarifier',
|
|
4207
4198
|
message: errorMsg,
|
|
4208
4199
|
stack: error instanceof Error ? error.stack : void 0
|
|
@@ -4225,14 +4216,14 @@ const saveSubAnalysisFiles = async (mainDir, contentArray)=>{
|
|
|
4225
4216
|
title,
|
|
4226
4217
|
path: filePath
|
|
4227
4218
|
});
|
|
4228
|
-
|
|
4219
|
+
logger.debug({
|
|
4229
4220
|
module: 'requirement_clarifier',
|
|
4230
4221
|
message: "\u7EC6\u5206\u5206\u6790\u6587\u4EF6\u5DF2\u4FDD\u5B58",
|
|
4231
4222
|
path: filePath,
|
|
4232
4223
|
title
|
|
4233
4224
|
});
|
|
4234
4225
|
} catch (error) {
|
|
4235
|
-
|
|
4226
|
+
logger.error({
|
|
4236
4227
|
module: 'requirement_clarifier',
|
|
4237
4228
|
message: `\u{4FDD}\u{5B58}\u{7EC6}\u{5206}\u{6587}\u{4EF6}\u{5931}\u{8D25}: ${error instanceof Error ? error.message : String(error)}`,
|
|
4238
4229
|
filePath,
|
|
@@ -4495,7 +4486,7 @@ async function packProject() {
|
|
|
4495
4486
|
await fs_promises.mkdir(mdDir, {
|
|
4496
4487
|
recursive: true
|
|
4497
4488
|
});
|
|
4498
|
-
|
|
4489
|
+
logger.info(`\u{1F4C2} \u{6B63}\u{5728}\u{5206}\u{6790}\u{5F53}\u{524D}\u{672C}\u{5730}\u{9879}\u{76EE}`);
|
|
4499
4490
|
const mdPath = path_0.join(mdDir, `\u{9879}\u{76EE}\u{67B6}\u{6784}\u{5206}\u{6790}.md`);
|
|
4500
4491
|
const options = {
|
|
4501
4492
|
output: mdPath,
|
|
@@ -4653,7 +4644,7 @@ const architectureDesignerTool = {
|
|
|
4653
4644
|
storage.saveRequirements(requirements_utils_currentRequirements);
|
|
4654
4645
|
return architecture_design;
|
|
4655
4646
|
} catch (error) {
|
|
4656
|
-
|
|
4647
|
+
logger.error(`\u{274C} \u{67B6}\u{6784}\u{8BBE}\u{8BA1}\u{751F}\u{6210}\u{5931}\u{8D25}: ${error instanceof Error ? error.message : String(error)}`);
|
|
4657
4648
|
throw new Error(`\u{67B6}\u{6784}\u{8BBE}\u{8BA1}\u{751F}\u{6210}\u{5931}\u{8D25}: ${error instanceof Error ? error.message : String(error)}`);
|
|
4658
4649
|
}
|
|
4659
4650
|
}
|
|
@@ -4811,20 +4802,6 @@ const Word2MdParams = objectType({
|
|
|
4811
4802
|
strict_mode: booleanType().optional().default(false).describe("\u4E25\u683C\u6A21\u5F0F\uFF08\u4FDD\u7559\u66F4\u591A\u683C\u5F0F\uFF09")
|
|
4812
4803
|
}).optional().default({}).describe("\u8F6C\u6362\u9009\u9879")
|
|
4813
4804
|
});
|
|
4814
|
-
function word2md_validateFilePath(filePath) {
|
|
4815
|
-
const normalized = path_0.normalize(filePath);
|
|
4816
|
-
const resolved = path_0.resolve(normalized);
|
|
4817
|
-
const cwd = process.cwd();
|
|
4818
|
-
if (!resolved.startsWith(cwd)) {
|
|
4819
|
-
logger_logger.warn(`\u{6587}\u{4EF6}\u{8BBF}\u{95EE}\u{8D85}\u{51FA}\u{5DE5}\u{4F5C}\u{76EE}\u{5F55}: ${filePath}`);
|
|
4820
|
-
return false;
|
|
4821
|
-
}
|
|
4822
|
-
if (!resolved.toLowerCase().endsWith('.docx')) {
|
|
4823
|
-
logger_logger.warn(`\u{4EC5}\u{652F}\u{6301}.docx\u{683C}\u{5F0F}\u{6587}\u{4EF6}: ${filePath}`);
|
|
4824
|
-
return false;
|
|
4825
|
-
}
|
|
4826
|
-
return true;
|
|
4827
|
-
}
|
|
4828
4805
|
const word2mdTool = {
|
|
4829
4806
|
name: "word2md",
|
|
4830
4807
|
description: "\u5C06Word\u6587\u6863(.docx)\u8F6C\u6362\u4E3AMarkdown\u683C\u5F0F",
|
|
@@ -4832,13 +4809,12 @@ const word2mdTool = {
|
|
|
4832
4809
|
execute: async (args)=>{
|
|
4833
4810
|
const { file_path } = args;
|
|
4834
4811
|
try {
|
|
4835
|
-
if (!word2md_validateFilePath(file_path)) throw new Error(`\u{6587}\u{4EF6}\u{8DEF}\u{5F84}\u{65E0}\u{6548}: ${file_path}`);
|
|
4836
4812
|
const resolvedPath = await validateAndResolvePath(file_path);
|
|
4837
4813
|
const buffer = await readFile(resolvedPath);
|
|
4838
4814
|
const htmlResult = await convertToHtml({
|
|
4839
4815
|
buffer
|
|
4840
4816
|
});
|
|
4841
|
-
if (htmlResult.messages && htmlResult.messages.length > 0)
|
|
4817
|
+
if (htmlResult.messages && htmlResult.messages.length > 0) logger.warn("Word\u8F6C\u6362\u8B66\u544A", {
|
|
4842
4818
|
file: file_path,
|
|
4843
4819
|
warnings: htmlResult.messages
|
|
4844
4820
|
});
|
|
@@ -4865,7 +4841,7 @@ const word2mdTool = {
|
|
|
4865
4841
|
`;
|
|
4866
4842
|
} catch (error) {
|
|
4867
4843
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
4868
|
-
|
|
4844
|
+
logger.error(`Word\u{8F6C}\u{6362}\u{5931}\u{8D25}: ${errorMsg}`, {
|
|
4869
4845
|
tool: "word2md",
|
|
4870
4846
|
file_path
|
|
4871
4847
|
});
|
|
@@ -4892,7 +4868,7 @@ const intentRecognizer = {
|
|
|
4892
4868
|
const { user_input, context = "" } = args;
|
|
4893
4869
|
if (!user_input || user_input.trim().length < 3) throw new Error("\u8F93\u5165\u65E0\u6548\uFF1A\u81F3\u5C11\u9700\u89813\u4E2A\u5B57\u7B26");
|
|
4894
4870
|
if (!context) throw new Error("\u8BF7\u4ECE\u4E0A\u4E00\u6B65\u63D0\u70BC\u51FA\u4E0A\u4E0B\u6587\u518D\u91CD\u65B0\u6267\u884C");
|
|
4895
|
-
|
|
4871
|
+
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}`);
|
|
4896
4872
|
return `
|
|
4897
4873
|
# \u{4EFB}\u{52A1}\u{89C4}\u{5212}\u{FF1A}
|
|
4898
4874
|
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}
|
|
@@ -4916,7 +4892,7 @@ server.addTool(requirementManagerTool);
|
|
|
4916
4892
|
server.addTool(architectureDesignerTool);
|
|
4917
4893
|
server.addTool(exportFinalDocumentTool);
|
|
4918
4894
|
server.addTool(viewRequirementsStatusTool);
|
|
4919
|
-
|
|
4895
|
+
logger.info(`\u{1F680} \u{542F}\u{52A8}${SERVICE_CONFIG.name}\u{6210}\u{529F}`);
|
|
4920
4896
|
server.start({
|
|
4921
4897
|
transportType: "stdio"
|
|
4922
4898
|
});
|
package/dist/utils/common.d.ts
CHANGED
|
@@ -6,10 +6,6 @@ export declare const sanitizeFileName: (input: string) => string;
|
|
|
6
6
|
* @returns 不含图片的纯文本Markdown
|
|
7
7
|
*/
|
|
8
8
|
export declare function removeImagesFromMarkdown(content: string): string;
|
|
9
|
-
/**
|
|
10
|
-
* 验证文件路径安全性
|
|
11
|
-
*/
|
|
12
|
-
export declare function validateFilePath(filePath: string): boolean;
|
|
13
9
|
/**
|
|
14
10
|
* 安全验证并标准化路径 (新增)
|
|
15
11
|
*/
|