@bangdao-ai/acw-tools 1.3.5 → 1.3.6-beta.1
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/cursorConversationParser.js +3 -24
- package/index.js +9 -32
- package/manifest.json +1 -1
- package/package.json +1 -1
- package/postinstall.js +7 -30
|
@@ -41,11 +41,9 @@ function decompressData(data) {
|
|
|
41
41
|
return data;
|
|
42
42
|
} catch (error) {
|
|
43
43
|
// 如果解压失败,尝试直接返回字符串
|
|
44
|
-
console.error('[decompressData] 解压失败,尝试直接返回字符串:', error.message);
|
|
45
44
|
try {
|
|
46
45
|
return data.toString('utf-8');
|
|
47
46
|
} catch (e) {
|
|
48
|
-
console.error('[decompressData] 转换字符串也失败:', e.message);
|
|
49
47
|
return null;
|
|
50
48
|
}
|
|
51
49
|
}
|
|
@@ -238,9 +236,8 @@ function extractAdditionalInfo(composerData, bubbles, markdownContent = '') {
|
|
|
238
236
|
for (const bubble of bubbles) {
|
|
239
237
|
const bubbleType = bubble.type || 0;
|
|
240
238
|
|
|
241
|
-
// 跳过没有bubbleId的bubble
|
|
239
|
+
// 跳过没有bubbleId的bubble
|
|
242
240
|
if (!bubble.bubbleId) {
|
|
243
|
-
console.error('[WARN] bubble缺少bubbleId,跳过:', { type: bubbleType, createdAt: bubble.createdAt });
|
|
244
241
|
continue;
|
|
245
242
|
}
|
|
246
243
|
|
|
@@ -319,9 +316,6 @@ function extractAdditionalInfo(composerData, bubbles, markdownContent = '') {
|
|
|
319
316
|
if (aiTimingInfo.clientRpcSendTime && aiTimingInfo.clientSettleTime) {
|
|
320
317
|
executionTime = aiTimingInfo.clientSettleTime - aiTimingInfo.clientRpcSendTime;
|
|
321
318
|
additionalInfo.performance.totalExecutionTime += executionTime;
|
|
322
|
-
} else if (hasRawTimingInfo) {
|
|
323
|
-
// 有 timingInfo 但缺少必要字段,输出警告
|
|
324
|
-
console.error(`[timingInfo警告] bubbleId: ${bubble.bubbleId}, hasTimingInfo: ${hasRawTimingInfo}, hasClientRpcSendTime: ${hasClientRpcSendTime}, hasClientSettleTime: ${hasClientSettleTime}, rawTimingInfo: ${JSON.stringify(bubble.timingInfo)}`);
|
|
325
319
|
}
|
|
326
320
|
|
|
327
321
|
// 构建execution对象(timestamp已在上面统一处理)
|
|
@@ -398,11 +392,6 @@ function extractAdditionalInfo(composerData, bubbles, markdownContent = '') {
|
|
|
398
392
|
}
|
|
399
393
|
}
|
|
400
394
|
|
|
401
|
-
// 输出 timingInfo 统计日志(帮助排查问题)
|
|
402
|
-
if (aiExecutionsWithoutTimingInfo > 0) {
|
|
403
|
-
console.error(`[timingInfo统计] AI执行总数: ${additionalInfo.performance.aiExecutionCount}, 有timingInfo: ${aiExecutionsWithTimingInfo}, 无timingInfo: ${aiExecutionsWithoutTimingInfo}, 有效executionTime: ${validAiExecutionCount}`);
|
|
404
|
-
}
|
|
405
|
-
|
|
406
395
|
// 计算平均执行时间
|
|
407
396
|
if (validAiExecutionCount > 0) {
|
|
408
397
|
additionalInfo.performance.averageExecutionTime = validTotalExecutionTime / validAiExecutionCount;
|
|
@@ -638,7 +627,6 @@ function extractConversationCore(composerId, outputPath, db) {
|
|
|
638
627
|
try {
|
|
639
628
|
const decompressed = decompressData(row.value);
|
|
640
629
|
if (!decompressed) {
|
|
641
|
-
console.error(`[bubble解析] 解压失败,跳过 key: ${row.key}`);
|
|
642
630
|
continue;
|
|
643
631
|
}
|
|
644
632
|
const data = JSON.parse(decompressed);
|
|
@@ -668,23 +656,15 @@ function extractConversationCore(composerId, outputPath, db) {
|
|
|
668
656
|
skippedEmptyBubbles++;
|
|
669
657
|
}
|
|
670
658
|
} catch (parseError) {
|
|
671
|
-
|
|
659
|
+
// JSON解析失败,跳过
|
|
672
660
|
}
|
|
673
661
|
}
|
|
674
662
|
}
|
|
675
663
|
|
|
676
|
-
// 使用 console.error 输出到 stderr,避免污染 MCP 的 stdout 通道
|
|
677
664
|
const sessionName = composerData?.name || 'Unnamed';
|
|
678
|
-
console.error(`[会话: ${sessionName}] (ID: ${composerId})`);
|
|
679
|
-
console.error(` fullConversationHeadersOnly 中有 ${validBubbleIds.size} 个bubble`);
|
|
680
|
-
console.error(` 已跳过 ${skippedNotInHeaderBubbles} 个不在fullConversationHeadersOnly中的bubble`);
|
|
681
|
-
console.error(` 已过滤 ${skippedEmptyBubbles} 个空bubble,保留 ${bubbles.length} 个有效bubble`);
|
|
682
665
|
|
|
683
|
-
//
|
|
666
|
+
// 检查是否为空(所有数据都不存在或被清理)
|
|
684
667
|
if (bubbles.length === 0) {
|
|
685
|
-
console.error(`⚠️ 对话 ${composerId} 没有有效的bubble数据,跳过生成Markdown`);
|
|
686
|
-
console.error(` 原因: fullConversationHeadersOnly有${validBubbleIds.size}个引用,但实际bubble数据都不存在`);
|
|
687
|
-
console.error(` 这通常是因为对话已被Cursor清理或删除`);
|
|
688
668
|
return {
|
|
689
669
|
success: false,
|
|
690
670
|
error: 'empty_conversation',
|
|
@@ -1449,7 +1429,6 @@ function extractConversationCore(composerId, outputPath, db) {
|
|
|
1449
1429
|
}
|
|
1450
1430
|
};
|
|
1451
1431
|
} catch (error) {
|
|
1452
|
-
console.error('提取对话失败:', error);
|
|
1453
1432
|
throw error;
|
|
1454
1433
|
}
|
|
1455
1434
|
}
|
package/index.js
CHANGED
|
@@ -41,12 +41,8 @@ try {
|
|
|
41
41
|
|
|
42
42
|
dbEngineType = 'better-sqlite3';
|
|
43
43
|
chatGrabAvailable = true;
|
|
44
|
-
console.error('[OK] 使用 better-sqlite3 引擎(原生模块,性能优异)');
|
|
45
|
-
console.error(' 对话抓取功能正常可用');
|
|
46
44
|
} catch (betterSqlite3Error) {
|
|
47
|
-
|
|
48
|
-
console.error(' 原因: ' + betterSqlite3Error.message);
|
|
49
|
-
console.error(' 规则下载功能不受影响');
|
|
45
|
+
// better-sqlite3 加载失败,静默降级
|
|
50
46
|
}
|
|
51
47
|
|
|
52
48
|
/**
|
|
@@ -159,8 +155,7 @@ function rotateLogFile() {
|
|
|
159
155
|
}
|
|
160
156
|
}
|
|
161
157
|
} catch (error) {
|
|
162
|
-
//
|
|
163
|
-
console.error(`日志滚动失败: ${error.message}`);
|
|
158
|
+
// 滚动失败不影响主流程,静默处理
|
|
164
159
|
}
|
|
165
160
|
}
|
|
166
161
|
|
|
@@ -206,19 +201,11 @@ function log(level, message, data = null) {
|
|
|
206
201
|
// 日志已经写入文件,可以通过文件查看
|
|
207
202
|
}
|
|
208
203
|
|
|
209
|
-
//
|
|
204
|
+
// 便捷的日志方法(只写入文件,不输出到控制台)
|
|
210
205
|
const logger = {
|
|
211
206
|
info: (message, data) => log('INFO', message, data),
|
|
212
|
-
warn: (message, data) =>
|
|
213
|
-
|
|
214
|
-
// WARN 级别也输出到 stderr,方便用户在控制台看到警告
|
|
215
|
-
console.error(`[WARN] ${message}`, data ? JSON.stringify(data) : '');
|
|
216
|
-
},
|
|
217
|
-
error: (message, data) => {
|
|
218
|
-
log('ERROR', message, data);
|
|
219
|
-
// ERROR 级别输出到 stderr,方便用户在控制台看到错误
|
|
220
|
-
console.error(`[ERROR] ${message}`, data ? JSON.stringify(data) : '');
|
|
221
|
-
},
|
|
207
|
+
warn: (message, data) => log('WARN', message, data),
|
|
208
|
+
error: (message, data) => log('ERROR', message, data),
|
|
222
209
|
debug: (message, data) => log('DEBUG', message, data)
|
|
223
210
|
};
|
|
224
211
|
|
|
@@ -328,14 +315,16 @@ try {
|
|
|
328
315
|
}
|
|
329
316
|
|
|
330
317
|
// 启动时记录日志位置(必须在版本初始化之后)
|
|
331
|
-
console.error(`[INFO] ACW MCP
|
|
318
|
+
console.error(`[INFO] ACW MCP v${CURRENT_MCP_VERSION}`);
|
|
332
319
|
logger.info('ACW MCP 工具启动', {
|
|
333
320
|
mcpVersion: CURRENT_MCP_VERSION,
|
|
334
321
|
logFile: getCurrentLogFile(),
|
|
335
322
|
nodeVersion: process.version,
|
|
336
323
|
platform: os.platform(),
|
|
337
324
|
maxLogSize: '10MB',
|
|
338
|
-
maxLogFiles: MAX_LOG_FILES
|
|
325
|
+
maxLogFiles: MAX_LOG_FILES,
|
|
326
|
+
dbEngine: dbEngineType,
|
|
327
|
+
chatGrabAvailable
|
|
339
328
|
});
|
|
340
329
|
|
|
341
330
|
// ==================== 对话抓取配置 ====================
|
|
@@ -890,17 +879,6 @@ async function uploadExecutions(sessionId, executionsList) {
|
|
|
890
879
|
// 保存requestBody供后续日志使用
|
|
891
880
|
requestBodyForLog = requestBody;
|
|
892
881
|
|
|
893
|
-
// 统计 timingInfo 情况(仅在有异常时输出警告)
|
|
894
|
-
const aiExecs = executions.filter(e => e.type === 'ai');
|
|
895
|
-
const aiExecCount = aiExecs.length;
|
|
896
|
-
const execWithTimingInfo = aiExecs.filter(e => e.timingInfo).length;
|
|
897
|
-
const execWithExecutionTime = aiExecs.filter(e => e.executionTime > 0).length;
|
|
898
|
-
|
|
899
|
-
// 仅当AI执行中有缺失timingInfo时才输出警告日志
|
|
900
|
-
if (aiExecCount > 0 && execWithTimingInfo < aiExecCount) {
|
|
901
|
-
console.error(`[timingInfo警告] sessionId: ${sessionId}, AI执行: ${aiExecCount}, 有timingInfo: ${execWithTimingInfo}, 缺失: ${aiExecCount - execWithTimingInfo}`);
|
|
902
|
-
}
|
|
903
|
-
|
|
904
882
|
const apiUrl = `${BASE_URL}/api/noauth/conversation/executions/batch`;
|
|
905
883
|
|
|
906
884
|
// 计算请求体大小(字节)
|
|
@@ -2123,7 +2101,6 @@ Tips:当返回多个匹配时,请使用返回列表中的完整规则名称
|
|
|
2123
2101
|
async function main() {
|
|
2124
2102
|
const transport = new StdioServerTransport();
|
|
2125
2103
|
await server.connect(transport);
|
|
2126
|
-
console.error(`[INFO] ACW工具MCP服务已启动 - 版本: ${CURRENT_MCP_VERSION}`);
|
|
2127
2104
|
logger.info("ACW工具MCP服务已启动", {
|
|
2128
2105
|
mcpVersion: CURRENT_MCP_VERSION,
|
|
2129
2106
|
baseUrl: BASE_URL,
|
package/manifest.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ACW工具集",
|
|
3
3
|
"description": "ACW平台工具集:智能下载规则到项目、初始化Common Admin模板项目",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.6",
|
|
5
5
|
"author": "邦道科技 - 产品技术中心",
|
|
6
6
|
"homepage": "https://www.npmjs.com/package/@bangdao-ai/acw-tools",
|
|
7
7
|
"repository": "https://www.npmjs.com/package/@bangdao-ai/acw-tools?activeTab=readme",
|
package/package.json
CHANGED
package/postinstall.js
CHANGED
|
@@ -24,43 +24,20 @@ import { fileURLToPath } from 'url';
|
|
|
24
24
|
// 忽略错误,使用默认值
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
console.log('ACW Tools MCP
|
|
28
|
-
console.log(
|
|
29
|
-
console.log('Node.js 版本:', process.version);
|
|
30
|
-
console.log('平台:', process.platform);
|
|
31
|
-
console.log('架构:', process.arch);
|
|
32
|
-
|
|
33
|
-
let engine = 'none';
|
|
34
|
-
let errorDetails = null;
|
|
27
|
+
console.log('ACW Tools MCP 安装后检查...');
|
|
28
|
+
console.log(`v${mcpVersion} | Node ${process.version} | ${process.platform}/${process.arch}`);
|
|
35
29
|
|
|
36
30
|
try {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
console.log('[OK] 数据库引擎: better-sqlite3 (原生模块,性能优异)');
|
|
42
|
-
console.log('[OK] 对话抓取功能已启用');
|
|
43
|
-
} catch (e1) {
|
|
44
|
-
errorDetails = e1;
|
|
45
|
-
console.warn('[WARN] better-sqlite3 模块加载失败');
|
|
46
|
-
console.warn(' 错误类型:', e1.name);
|
|
47
|
-
console.warn(' 错误消息:', e1.message);
|
|
48
|
-
if (e1.code) {
|
|
49
|
-
console.warn(' 错误代码:', e1.code);
|
|
50
|
-
}
|
|
51
|
-
if (e1.stack) {
|
|
52
|
-
const lines = e1.stack.split('\n');
|
|
53
|
-
console.warn(' 堆栈信息:', lines.slice(0, 3).join('\n'));
|
|
54
|
-
}
|
|
55
|
-
console.warn('[WARN] 无可用数据库引擎,对话抓取功能将被禁用');
|
|
56
|
-
console.warn('提示: 规则下载功能不受影响,仍可正常使用');
|
|
31
|
+
await import('better-sqlite3');
|
|
32
|
+
console.log('[OK] better-sqlite3');
|
|
33
|
+
} catch (e) {
|
|
34
|
+
console.warn('[WARN] better-sqlite3 不可用');
|
|
57
35
|
}
|
|
58
36
|
|
|
59
|
-
console.log('
|
|
37
|
+
console.log('检查完成');
|
|
60
38
|
} catch (error) {
|
|
61
39
|
// 捕获所有未预期的错误,确保不会导致安装失败
|
|
62
40
|
console.warn('[WARN] postinstall 脚本执行出错,但不影响安装:', error.message);
|
|
63
41
|
// 不抛出错误,让安装继续
|
|
64
42
|
}
|
|
65
43
|
})();
|
|
66
|
-
|