intention-coding 0.0.8 → 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 +30 -34
- package/dist/index.js +37 -41
- package/dist/utils/common.d.ts +2 -2
- 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
|
});
|
|
@@ -4090,6 +4090,18 @@ function removeImagesFromMarkdown(content) {
|
|
|
4090
4090
|
cleaned = cleaned.replace(/\n{3,}/g, '\n\n');
|
|
4091
4091
|
return cleaned.trim();
|
|
4092
4092
|
}
|
|
4093
|
+
async function validateAndResolvePath(filePath) {
|
|
4094
|
+
if ('win32' === process.platform && filePath.startsWith('\\\\')) filePath = '\\\\?\\UNC\\' + filePath.substring(2);
|
|
4095
|
+
const normalized = external_path_default().normalize(filePath);
|
|
4096
|
+
const resolved = external_path_default().resolve(normalized);
|
|
4097
|
+
try {
|
|
4098
|
+
await external_fs_namespaceObject.promises.access(resolved, external_fs_namespaceObject.promises.constants.R_OK);
|
|
4099
|
+
} catch (error) {
|
|
4100
|
+
logger.warn(`\u{6587}\u{4EF6}\u{4E0D}\u{5B58}\u{5728}\u{6216}\u{4E0D}\u{53EF}\u{8BFB}: ${resolved}`, error);
|
|
4101
|
+
throw new Error(`\u{6587}\u{4EF6}\u{4E0D}\u{5B58}\u{5728}\u{6216}\u{4E0D}\u{53EF}\u{8BFB}: ${resolved}`);
|
|
4102
|
+
}
|
|
4103
|
+
return resolved;
|
|
4104
|
+
}
|
|
4093
4105
|
const promises_namespaceObject = require("fs/promises");
|
|
4094
4106
|
var promises_default = /*#__PURE__*/ __webpack_require__.n(promises_namespaceObject);
|
|
4095
4107
|
const requirementClarifier = {
|
|
@@ -4099,7 +4111,7 @@ const requirementClarifier = {
|
|
|
4099
4111
|
execute: async (args)=>{
|
|
4100
4112
|
const { user_input, file_path = "" } = args;
|
|
4101
4113
|
try {
|
|
4102
|
-
|
|
4114
|
+
logger.info({
|
|
4103
4115
|
module: 'requirement_clarifier',
|
|
4104
4116
|
message: "\u5904\u7406\u7528\u6237\u8F93\u5165",
|
|
4105
4117
|
data: {
|
|
@@ -4113,7 +4125,7 @@ const requirementClarifier = {
|
|
|
4113
4125
|
context = removeImagesFromMarkdown(markdownContent);
|
|
4114
4126
|
}
|
|
4115
4127
|
const analysisContent = await getAiAnalysis(context);
|
|
4116
|
-
|
|
4128
|
+
logger.info({
|
|
4117
4129
|
module: 'requirement_clarifier',
|
|
4118
4130
|
message: "\u6536\u5230AI\u5206\u6790\u7ED3\u679C",
|
|
4119
4131
|
context,
|
|
@@ -4132,7 +4144,7 @@ const requirementClarifier = {
|
|
|
4132
4144
|
if (subContents.length > 0) {
|
|
4133
4145
|
jumpLinks = await saveSubAnalysisFiles(mdDir, subContents);
|
|
4134
4146
|
finalContent = addJumpLinks(analysisContent, jumpLinks);
|
|
4135
|
-
|
|
4147
|
+
logger.info({
|
|
4136
4148
|
module: 'requirement_clarifier',
|
|
4137
4149
|
message: `\u{6210}\u{529F}\u{5904}\u{7406}${subContents.length}\u{4E2A}\u{7EC6}\u{5206}\u{9879}`,
|
|
4138
4150
|
jumpLinks: jumpLinks.map((link)=>({
|
|
@@ -4142,7 +4154,7 @@ const requirementClarifier = {
|
|
|
4142
4154
|
});
|
|
4143
4155
|
}
|
|
4144
4156
|
await promises_default().writeFile(mdPath, finalContent, 'utf8');
|
|
4145
|
-
|
|
4157
|
+
logger.info({
|
|
4146
4158
|
module: 'requirement_clarifier',
|
|
4147
4159
|
message: "\u9700\u6C42\u5206\u6790\u6587\u4EF6\u5DF2\u4FDD\u5B58",
|
|
4148
4160
|
path: mdPathResolved,
|
|
@@ -4151,7 +4163,7 @@ const requirementClarifier = {
|
|
|
4151
4163
|
return formatAnalysisPrompt(user_input, finalContent, mdPathResolved);
|
|
4152
4164
|
} catch (error) {
|
|
4153
4165
|
const errorMsg = `\u{9700}\u{6C42}\u{5206}\u{6790}\u{5931}\u{8D25}: ${error instanceof Error ? error.message : String(error)}`;
|
|
4154
|
-
|
|
4166
|
+
logger.error({
|
|
4155
4167
|
module: 'requirement_clarifier',
|
|
4156
4168
|
message: errorMsg,
|
|
4157
4169
|
stack: error instanceof Error ? error.stack : void 0
|
|
@@ -4194,7 +4206,7 @@ const getSubAnalysis = async (content)=>{
|
|
|
4194
4206
|
return response.outputs.result;
|
|
4195
4207
|
} catch (error) {
|
|
4196
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"}`;
|
|
4197
|
-
|
|
4209
|
+
logger.error({
|
|
4198
4210
|
module: 'requirement_clarifier',
|
|
4199
4211
|
message: errorMsg,
|
|
4200
4212
|
stack: error instanceof Error ? error.stack : void 0
|
|
@@ -4217,14 +4229,14 @@ const saveSubAnalysisFiles = async (mainDir, contentArray)=>{
|
|
|
4217
4229
|
title,
|
|
4218
4230
|
path: filePath
|
|
4219
4231
|
});
|
|
4220
|
-
|
|
4232
|
+
logger.debug({
|
|
4221
4233
|
module: 'requirement_clarifier',
|
|
4222
4234
|
message: "\u7EC6\u5206\u5206\u6790\u6587\u4EF6\u5DF2\u4FDD\u5B58",
|
|
4223
4235
|
path: filePath,
|
|
4224
4236
|
title
|
|
4225
4237
|
});
|
|
4226
4238
|
} catch (error) {
|
|
4227
|
-
|
|
4239
|
+
logger.error({
|
|
4228
4240
|
module: 'requirement_clarifier',
|
|
4229
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)}`,
|
|
4230
4242
|
filePath,
|
|
@@ -4488,7 +4500,7 @@ async function packProject() {
|
|
|
4488
4500
|
await promises_default().mkdir(mdDir, {
|
|
4489
4501
|
recursive: true
|
|
4490
4502
|
});
|
|
4491
|
-
|
|
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}`);
|
|
4492
4504
|
const mdPath = external_path_default().join(mdDir, `\u{9879}\u{76EE}\u{67B6}\u{6784}\u{5206}\u{6790}.md`);
|
|
4493
4505
|
const options = {
|
|
4494
4506
|
output: mdPath,
|
|
@@ -4646,7 +4658,7 @@ const architectureDesignerTool = {
|
|
|
4646
4658
|
storage.saveRequirements(requirements_utils_currentRequirements);
|
|
4647
4659
|
return architecture_design;
|
|
4648
4660
|
} catch (error) {
|
|
4649
|
-
|
|
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)}`);
|
|
4650
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)}`);
|
|
4651
4663
|
}
|
|
4652
4664
|
}
|
|
@@ -4807,20 +4819,6 @@ const Word2MdParams = objectType({
|
|
|
4807
4819
|
strict_mode: booleanType().optional().default(false).describe("\u4E25\u683C\u6A21\u5F0F\uFF08\u4FDD\u7559\u66F4\u591A\u683C\u5F0F\uFF09")
|
|
4808
4820
|
}).optional().default({}).describe("\u8F6C\u6362\u9009\u9879")
|
|
4809
4821
|
});
|
|
4810
|
-
function word2md_validateFilePath(filePath) {
|
|
4811
|
-
const normalized = external_path_default().normalize(filePath);
|
|
4812
|
-
const resolved = external_path_default().resolve(normalized);
|
|
4813
|
-
const cwd = process.cwd();
|
|
4814
|
-
if (!resolved.startsWith(cwd)) {
|
|
4815
|
-
logger_logger.warn(`\u{6587}\u{4EF6}\u{8BBF}\u{95EE}\u{8D85}\u{51FA}\u{5DE5}\u{4F5C}\u{76EE}\u{5F55}: ${filePath}`);
|
|
4816
|
-
return false;
|
|
4817
|
-
}
|
|
4818
|
-
if (!resolved.toLowerCase().endsWith('.docx')) {
|
|
4819
|
-
logger_logger.warn(`\u{4EC5}\u{652F}\u{6301}.docx\u{683C}\u{5F0F}\u{6587}\u{4EF6}: ${filePath}`);
|
|
4820
|
-
return false;
|
|
4821
|
-
}
|
|
4822
|
-
return true;
|
|
4823
|
-
}
|
|
4824
4822
|
const word2mdTool = {
|
|
4825
4823
|
name: "word2md",
|
|
4826
4824
|
description: "\u5C06Word\u6587\u6863(.docx)\u8F6C\u6362\u4E3AMarkdown\u683C\u5F0F",
|
|
@@ -4828,14 +4826,12 @@ const word2mdTool = {
|
|
|
4828
4826
|
execute: async (args)=>{
|
|
4829
4827
|
const { file_path } = args;
|
|
4830
4828
|
try {
|
|
4831
|
-
|
|
4832
|
-
const
|
|
4833
|
-
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}`);
|
|
4834
|
-
const buffer = await promises_namespaceObject.readFile(file_path);
|
|
4829
|
+
const resolvedPath = await validateAndResolvePath(file_path);
|
|
4830
|
+
const buffer = await promises_namespaceObject.readFile(resolvedPath);
|
|
4835
4831
|
const htmlResult = await external_mammoth_namespaceObject.convertToHtml({
|
|
4836
4832
|
buffer
|
|
4837
4833
|
});
|
|
4838
|
-
if (htmlResult.messages && htmlResult.messages.length > 0)
|
|
4834
|
+
if (htmlResult.messages && htmlResult.messages.length > 0) logger.warn("Word\u8F6C\u6362\u8B66\u544A", {
|
|
4839
4835
|
file: file_path,
|
|
4840
4836
|
warnings: htmlResult.messages
|
|
4841
4837
|
});
|
|
@@ -4862,7 +4858,7 @@ const word2mdTool = {
|
|
|
4862
4858
|
`;
|
|
4863
4859
|
} catch (error) {
|
|
4864
4860
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
4865
|
-
|
|
4861
|
+
logger.error(`Word\u{8F6C}\u{6362}\u{5931}\u{8D25}: ${errorMsg}`, {
|
|
4866
4862
|
tool: "word2md",
|
|
4867
4863
|
file_path
|
|
4868
4864
|
});
|
|
@@ -4889,7 +4885,7 @@ const intentRecognizer = {
|
|
|
4889
4885
|
const { user_input, context = "" } = args;
|
|
4890
4886
|
if (!user_input || user_input.trim().length < 3) throw new Error("\u8F93\u5165\u65E0\u6548\uFF1A\u81F3\u5C11\u9700\u89813\u4E2A\u5B57\u7B26");
|
|
4891
4887
|
if (!context) throw new Error("\u8BF7\u4ECE\u4E0A\u4E00\u6B65\u63D0\u70BC\u51FA\u4E0A\u4E0B\u6587\u518D\u91CD\u65B0\u6267\u884C");
|
|
4892
|
-
|
|
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}`);
|
|
4893
4889
|
return `
|
|
4894
4890
|
# \u{4EFB}\u{52A1}\u{89C4}\u{5212}\u{FF1A}
|
|
4895
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}
|
|
@@ -4913,7 +4909,7 @@ server.addTool(requirementManagerTool);
|
|
|
4913
4909
|
server.addTool(architectureDesignerTool);
|
|
4914
4910
|
server.addTool(exportFinalDocumentTool);
|
|
4915
4911
|
server.addTool(viewRequirementsStatusTool);
|
|
4916
|
-
|
|
4912
|
+
logger.info(`\u{1F680} \u{542F}\u{52A8}${SERVICE_CONFIG.name}\u{6210}\u{529F}`);
|
|
4917
4913
|
server.start({
|
|
4918
4914
|
transportType: "stdio"
|
|
4919
4915
|
});
|
package/dist/index.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { FastMCP } from "fastmcp";
|
|
3
3
|
import winston from "winston";
|
|
4
4
|
import winston_daily_rotate_file from "winston-daily-rotate-file";
|
|
5
|
-
import fs_0, { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
5
|
+
import fs_0, { existsSync, mkdirSync, promises, readFileSync, writeFileSync } from "fs";
|
|
6
6
|
import path_0, { join } from "path";
|
|
7
|
-
import
|
|
7
|
+
import fs_promises, { mkdir, readFile, writeFile } from "fs/promises";
|
|
8
8
|
import { runCli as external_aico_pack_runCli } from "aico-pack";
|
|
9
9
|
import { convertToHtml } from "mammoth";
|
|
10
10
|
import html_to_md from "html-to-md";
|
|
@@ -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
|
});
|
|
@@ -4079,6 +4079,18 @@ function removeImagesFromMarkdown(content) {
|
|
|
4079
4079
|
cleaned = cleaned.replace(/\n{3,}/g, '\n\n');
|
|
4080
4080
|
return cleaned.trim();
|
|
4081
4081
|
}
|
|
4082
|
+
async function validateAndResolvePath(filePath) {
|
|
4083
|
+
if ('win32' === process.platform && filePath.startsWith('\\\\')) filePath = '\\\\?\\UNC\\' + filePath.substring(2);
|
|
4084
|
+
const normalized = path_0.normalize(filePath);
|
|
4085
|
+
const resolved = path_0.resolve(normalized);
|
|
4086
|
+
try {
|
|
4087
|
+
await promises.access(resolved, promises.constants.R_OK);
|
|
4088
|
+
} catch (error) {
|
|
4089
|
+
logger.warn(`\u{6587}\u{4EF6}\u{4E0D}\u{5B58}\u{5728}\u{6216}\u{4E0D}\u{53EF}\u{8BFB}: ${resolved}`, error);
|
|
4090
|
+
throw new Error(`\u{6587}\u{4EF6}\u{4E0D}\u{5B58}\u{5728}\u{6216}\u{4E0D}\u{53EF}\u{8BFB}: ${resolved}`);
|
|
4091
|
+
}
|
|
4092
|
+
return resolved;
|
|
4093
|
+
}
|
|
4082
4094
|
const requirementClarifier = {
|
|
4083
4095
|
name: "requirement_clarifier",
|
|
4084
4096
|
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",
|
|
@@ -4086,7 +4098,7 @@ const requirementClarifier = {
|
|
|
4086
4098
|
execute: async (args)=>{
|
|
4087
4099
|
const { user_input, file_path = "" } = args;
|
|
4088
4100
|
try {
|
|
4089
|
-
|
|
4101
|
+
logger.info({
|
|
4090
4102
|
module: 'requirement_clarifier',
|
|
4091
4103
|
message: "\u5904\u7406\u7528\u6237\u8F93\u5165",
|
|
4092
4104
|
data: {
|
|
@@ -4096,11 +4108,11 @@ const requirementClarifier = {
|
|
|
4096
4108
|
});
|
|
4097
4109
|
let context = user_input;
|
|
4098
4110
|
if (file_path) {
|
|
4099
|
-
const markdownContent = await
|
|
4111
|
+
const markdownContent = await fs_promises.readFile(file_path, 'utf8');
|
|
4100
4112
|
context = removeImagesFromMarkdown(markdownContent);
|
|
4101
4113
|
}
|
|
4102
4114
|
const analysisContent = await getAiAnalysis(context);
|
|
4103
|
-
|
|
4115
|
+
logger.info({
|
|
4104
4116
|
module: 'requirement_clarifier',
|
|
4105
4117
|
message: "\u6536\u5230AI\u5206\u6790\u7ED3\u679C",
|
|
4106
4118
|
context,
|
|
@@ -4108,7 +4120,7 @@ const requirementClarifier = {
|
|
|
4108
4120
|
});
|
|
4109
4121
|
const fileName = sanitizeFileName(analysisContent.length > 10 ? analysisContent.substring(0, 10) : `analysis_${Date.now()}`);
|
|
4110
4122
|
const mdDir = path_0.join(getStorageDir(), 'prd');
|
|
4111
|
-
await
|
|
4123
|
+
await fs_promises.mkdir(mdDir, {
|
|
4112
4124
|
recursive: true
|
|
4113
4125
|
});
|
|
4114
4126
|
const mdPath = path_0.join(mdDir, `${fileName}.md`);
|
|
@@ -4119,7 +4131,7 @@ const requirementClarifier = {
|
|
|
4119
4131
|
if (subContents.length > 0) {
|
|
4120
4132
|
jumpLinks = await saveSubAnalysisFiles(mdDir, subContents);
|
|
4121
4133
|
finalContent = addJumpLinks(analysisContent, jumpLinks);
|
|
4122
|
-
|
|
4134
|
+
logger.info({
|
|
4123
4135
|
module: 'requirement_clarifier',
|
|
4124
4136
|
message: `\u{6210}\u{529F}\u{5904}\u{7406}${subContents.length}\u{4E2A}\u{7EC6}\u{5206}\u{9879}`,
|
|
4125
4137
|
jumpLinks: jumpLinks.map((link)=>({
|
|
@@ -4128,8 +4140,8 @@ const requirementClarifier = {
|
|
|
4128
4140
|
}))
|
|
4129
4141
|
});
|
|
4130
4142
|
}
|
|
4131
|
-
await
|
|
4132
|
-
|
|
4143
|
+
await fs_promises.writeFile(mdPath, finalContent, 'utf8');
|
|
4144
|
+
logger.info({
|
|
4133
4145
|
module: 'requirement_clarifier',
|
|
4134
4146
|
message: "\u9700\u6C42\u5206\u6790\u6587\u4EF6\u5DF2\u4FDD\u5B58",
|
|
4135
4147
|
path: mdPathResolved,
|
|
@@ -4138,7 +4150,7 @@ const requirementClarifier = {
|
|
|
4138
4150
|
return formatAnalysisPrompt(user_input, finalContent, mdPathResolved);
|
|
4139
4151
|
} catch (error) {
|
|
4140
4152
|
const errorMsg = `\u{9700}\u{6C42}\u{5206}\u{6790}\u{5931}\u{8D25}: ${error instanceof Error ? error.message : String(error)}`;
|
|
4141
|
-
|
|
4153
|
+
logger.error({
|
|
4142
4154
|
module: 'requirement_clarifier',
|
|
4143
4155
|
message: errorMsg,
|
|
4144
4156
|
stack: error instanceof Error ? error.stack : void 0
|
|
@@ -4181,7 +4193,7 @@ const getSubAnalysis = async (content)=>{
|
|
|
4181
4193
|
return response.outputs.result;
|
|
4182
4194
|
} catch (error) {
|
|
4183
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"}`;
|
|
4184
|
-
|
|
4196
|
+
logger.error({
|
|
4185
4197
|
module: 'requirement_clarifier',
|
|
4186
4198
|
message: errorMsg,
|
|
4187
4199
|
stack: error instanceof Error ? error.stack : void 0
|
|
@@ -4199,19 +4211,19 @@ const saveSubAnalysisFiles = async (mainDir, contentArray)=>{
|
|
|
4199
4211
|
const safeFileName = `${sanitizeFileName(title)}.md`;
|
|
4200
4212
|
const filePath = path_0.join(mainDir, safeFileName);
|
|
4201
4213
|
try {
|
|
4202
|
-
await
|
|
4214
|
+
await fs_promises.writeFile(filePath, content, 'utf8');
|
|
4203
4215
|
subFiles.push({
|
|
4204
4216
|
title,
|
|
4205
4217
|
path: filePath
|
|
4206
4218
|
});
|
|
4207
|
-
|
|
4219
|
+
logger.debug({
|
|
4208
4220
|
module: 'requirement_clarifier',
|
|
4209
4221
|
message: "\u7EC6\u5206\u5206\u6790\u6587\u4EF6\u5DF2\u4FDD\u5B58",
|
|
4210
4222
|
path: filePath,
|
|
4211
4223
|
title
|
|
4212
4224
|
});
|
|
4213
4225
|
} catch (error) {
|
|
4214
|
-
|
|
4226
|
+
logger.error({
|
|
4215
4227
|
module: 'requirement_clarifier',
|
|
4216
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)}`,
|
|
4217
4229
|
filePath,
|
|
@@ -4471,10 +4483,10 @@ const requirementManagerTool = {
|
|
|
4471
4483
|
};
|
|
4472
4484
|
async function packProject() {
|
|
4473
4485
|
const mdDir = path_0.join(getStorageDir(), 'tech');
|
|
4474
|
-
await
|
|
4486
|
+
await fs_promises.mkdir(mdDir, {
|
|
4475
4487
|
recursive: true
|
|
4476
4488
|
});
|
|
4477
|
-
|
|
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}`);
|
|
4478
4490
|
const mdPath = path_0.join(mdDir, `\u{9879}\u{76EE}\u{67B6}\u{6784}\u{5206}\u{6790}.md`);
|
|
4479
4491
|
const options = {
|
|
4480
4492
|
output: mdPath,
|
|
@@ -4632,7 +4644,7 @@ const architectureDesignerTool = {
|
|
|
4632
4644
|
storage.saveRequirements(requirements_utils_currentRequirements);
|
|
4633
4645
|
return architecture_design;
|
|
4634
4646
|
} catch (error) {
|
|
4635
|
-
|
|
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)}`);
|
|
4636
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)}`);
|
|
4637
4649
|
}
|
|
4638
4650
|
}
|
|
@@ -4790,20 +4802,6 @@ const Word2MdParams = objectType({
|
|
|
4790
4802
|
strict_mode: booleanType().optional().default(false).describe("\u4E25\u683C\u6A21\u5F0F\uFF08\u4FDD\u7559\u66F4\u591A\u683C\u5F0F\uFF09")
|
|
4791
4803
|
}).optional().default({}).describe("\u8F6C\u6362\u9009\u9879")
|
|
4792
4804
|
});
|
|
4793
|
-
function word2md_validateFilePath(filePath) {
|
|
4794
|
-
const normalized = path_0.normalize(filePath);
|
|
4795
|
-
const resolved = path_0.resolve(normalized);
|
|
4796
|
-
const cwd = process.cwd();
|
|
4797
|
-
if (!resolved.startsWith(cwd)) {
|
|
4798
|
-
logger_logger.warn(`\u{6587}\u{4EF6}\u{8BBF}\u{95EE}\u{8D85}\u{51FA}\u{5DE5}\u{4F5C}\u{76EE}\u{5F55}: ${filePath}`);
|
|
4799
|
-
return false;
|
|
4800
|
-
}
|
|
4801
|
-
if (!resolved.toLowerCase().endsWith('.docx')) {
|
|
4802
|
-
logger_logger.warn(`\u{4EC5}\u{652F}\u{6301}.docx\u{683C}\u{5F0F}\u{6587}\u{4EF6}: ${filePath}`);
|
|
4803
|
-
return false;
|
|
4804
|
-
}
|
|
4805
|
-
return true;
|
|
4806
|
-
}
|
|
4807
4805
|
const word2mdTool = {
|
|
4808
4806
|
name: "word2md",
|
|
4809
4807
|
description: "\u5C06Word\u6587\u6863(.docx)\u8F6C\u6362\u4E3AMarkdown\u683C\u5F0F",
|
|
@@ -4811,14 +4809,12 @@ const word2mdTool = {
|
|
|
4811
4809
|
execute: async (args)=>{
|
|
4812
4810
|
const { file_path } = args;
|
|
4813
4811
|
try {
|
|
4814
|
-
|
|
4815
|
-
const
|
|
4816
|
-
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}`);
|
|
4817
|
-
const buffer = await readFile(file_path);
|
|
4812
|
+
const resolvedPath = await validateAndResolvePath(file_path);
|
|
4813
|
+
const buffer = await readFile(resolvedPath);
|
|
4818
4814
|
const htmlResult = await convertToHtml({
|
|
4819
4815
|
buffer
|
|
4820
4816
|
});
|
|
4821
|
-
if (htmlResult.messages && htmlResult.messages.length > 0)
|
|
4817
|
+
if (htmlResult.messages && htmlResult.messages.length > 0) logger.warn("Word\u8F6C\u6362\u8B66\u544A", {
|
|
4822
4818
|
file: file_path,
|
|
4823
4819
|
warnings: htmlResult.messages
|
|
4824
4820
|
});
|
|
@@ -4845,7 +4841,7 @@ const word2mdTool = {
|
|
|
4845
4841
|
`;
|
|
4846
4842
|
} catch (error) {
|
|
4847
4843
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
4848
|
-
|
|
4844
|
+
logger.error(`Word\u{8F6C}\u{6362}\u{5931}\u{8D25}: ${errorMsg}`, {
|
|
4849
4845
|
tool: "word2md",
|
|
4850
4846
|
file_path
|
|
4851
4847
|
});
|
|
@@ -4872,7 +4868,7 @@ const intentRecognizer = {
|
|
|
4872
4868
|
const { user_input, context = "" } = args;
|
|
4873
4869
|
if (!user_input || user_input.trim().length < 3) throw new Error("\u8F93\u5165\u65E0\u6548\uFF1A\u81F3\u5C11\u9700\u89813\u4E2A\u5B57\u7B26");
|
|
4874
4870
|
if (!context) throw new Error("\u8BF7\u4ECE\u4E0A\u4E00\u6B65\u63D0\u70BC\u51FA\u4E0A\u4E0B\u6587\u518D\u91CD\u65B0\u6267\u884C");
|
|
4875
|
-
|
|
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}`);
|
|
4876
4872
|
return `
|
|
4877
4873
|
# \u{4EFB}\u{52A1}\u{89C4}\u{5212}\u{FF1A}
|
|
4878
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}
|
|
@@ -4896,7 +4892,7 @@ server.addTool(requirementManagerTool);
|
|
|
4896
4892
|
server.addTool(architectureDesignerTool);
|
|
4897
4893
|
server.addTool(exportFinalDocumentTool);
|
|
4898
4894
|
server.addTool(viewRequirementsStatusTool);
|
|
4899
|
-
|
|
4895
|
+
logger.info(`\u{1F680} \u{542F}\u{52A8}${SERVICE_CONFIG.name}\u{6210}\u{529F}`);
|
|
4900
4896
|
server.start({
|
|
4901
4897
|
transportType: "stdio"
|
|
4902
4898
|
});
|
package/dist/utils/common.d.ts
CHANGED
|
@@ -7,6 +7,6 @@ export declare const sanitizeFileName: (input: string) => string;
|
|
|
7
7
|
*/
|
|
8
8
|
export declare function removeImagesFromMarkdown(content: string): string;
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* 安全验证并标准化路径 (新增)
|
|
11
11
|
*/
|
|
12
|
-
export declare function
|
|
12
|
+
export declare function validateAndResolvePath(filePath: string): Promise<string>;
|