@bangdao-ai/acw-tools 1.2.10 → 1.3.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 +73 -37
- package/index.js +15 -2
- package/manifest.json +1 -1
- package/package.json +1 -1
|
@@ -41,7 +41,13 @@ function decompressData(data) {
|
|
|
41
41
|
return data;
|
|
42
42
|
} catch (error) {
|
|
43
43
|
// 如果解压失败,尝试直接返回字符串
|
|
44
|
-
|
|
44
|
+
console.error('[decompressData] 解压失败,尝试直接返回字符串:', error.message);
|
|
45
|
+
try {
|
|
46
|
+
return data.toString('utf-8');
|
|
47
|
+
} catch (e) {
|
|
48
|
+
console.error('[decompressData] 转换字符串也失败:', e.message);
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
45
51
|
}
|
|
46
52
|
}
|
|
47
53
|
|
|
@@ -341,6 +347,12 @@ function extractAdditionalInfo(composerData, bubbles, markdownContent = '') {
|
|
|
341
347
|
execution.codeChanges = codeChanges;
|
|
342
348
|
}
|
|
343
349
|
|
|
350
|
+
// 提取工具调用名称(toolFormerData.name)
|
|
351
|
+
const toolFormerData = bubble.toolFormerData || {};
|
|
352
|
+
if (toolFormerData.name) {
|
|
353
|
+
execution.toolName = toolFormerData.name;
|
|
354
|
+
}
|
|
355
|
+
|
|
344
356
|
additionalInfo.performance.executions.push(execution);
|
|
345
357
|
}
|
|
346
358
|
}
|
|
@@ -348,25 +360,41 @@ function extractAdditionalInfo(composerData, bubbles, markdownContent = '') {
|
|
|
348
360
|
// 计算平均执行时间、最大执行时间和最小执行时间(只统计type='ai'且executionTime>0的)
|
|
349
361
|
let validAiExecutionCount = 0;
|
|
350
362
|
let validTotalExecutionTime = 0;
|
|
363
|
+
let aiExecutionsWithTimingInfo = 0;
|
|
364
|
+
let aiExecutionsWithoutTimingInfo = 0;
|
|
351
365
|
|
|
352
366
|
// 遍历executions计算平均值、最大值和最小值(只统计type='ai'且executionTime>0的)
|
|
353
367
|
for (const execution of additionalInfo.performance.executions) {
|
|
354
|
-
if (execution.type === 'ai'
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
additionalInfo.performance.maxExecutionTime = execution.executionTime;
|
|
368
|
+
if (execution.type === 'ai') {
|
|
369
|
+
// 统计 timingInfo 情况
|
|
370
|
+
if (execution.timingInfo) {
|
|
371
|
+
aiExecutionsWithTimingInfo++;
|
|
372
|
+
} else {
|
|
373
|
+
aiExecutionsWithoutTimingInfo++;
|
|
361
374
|
}
|
|
362
375
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
376
|
+
if (execution.executionTime > 0) {
|
|
377
|
+
validAiExecutionCount++;
|
|
378
|
+
validTotalExecutionTime += execution.executionTime;
|
|
379
|
+
|
|
380
|
+
// 更新最大值
|
|
381
|
+
if (execution.executionTime > additionalInfo.performance.maxExecutionTime) {
|
|
382
|
+
additionalInfo.performance.maxExecutionTime = execution.executionTime;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// 更新最小值
|
|
386
|
+
if (execution.executionTime < additionalInfo.performance.minExecutionTime) {
|
|
387
|
+
additionalInfo.performance.minExecutionTime = execution.executionTime;
|
|
388
|
+
}
|
|
366
389
|
}
|
|
367
390
|
}
|
|
368
391
|
}
|
|
369
392
|
|
|
393
|
+
// 输出 timingInfo 统计日志(帮助排查问题)
|
|
394
|
+
if (aiExecutionsWithoutTimingInfo > 0) {
|
|
395
|
+
console.error(`[timingInfo统计] AI执行总数: ${additionalInfo.performance.aiExecutionCount}, 有timingInfo: ${aiExecutionsWithTimingInfo}, 无timingInfo: ${aiExecutionsWithoutTimingInfo}, 有效executionTime: ${validAiExecutionCount}`);
|
|
396
|
+
}
|
|
397
|
+
|
|
370
398
|
// 计算平均执行时间
|
|
371
399
|
if (validAiExecutionCount > 0) {
|
|
372
400
|
additionalInfo.performance.averageExecutionTime = validTotalExecutionTime / validAiExecutionCount;
|
|
@@ -599,32 +627,40 @@ function extractConversationCore(composerId, outputPath, db) {
|
|
|
599
627
|
|
|
600
628
|
for (const row of bubbleRows) {
|
|
601
629
|
if (row.value) {
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
data.
|
|
622
|
-
data.
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
630
|
+
try {
|
|
631
|
+
const decompressed = decompressData(row.value);
|
|
632
|
+
if (!decompressed) {
|
|
633
|
+
console.error(`[bubble解析] 解压失败,跳过 key: ${row.key}`);
|
|
634
|
+
continue;
|
|
635
|
+
}
|
|
636
|
+
const data = JSON.parse(decompressed);
|
|
637
|
+
|
|
638
|
+
// 只处理在 fullConversationHeadersOnly 中的bubble
|
|
639
|
+
if (!validBubbleIds.has(data.bubbleId)) {
|
|
640
|
+
skippedNotInHeaderBubbles++;
|
|
641
|
+
continue;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
// 过滤掉完全空的bubble(没有text、没有toolResults、没有其他有用信息)
|
|
645
|
+
const hasText = data.text && data.text.trim().length > 0;
|
|
646
|
+
const hasToolResults = data.toolResults && data.toolResults.length > 0;
|
|
647
|
+
const hasSuggestedCode = data.suggestedCodeBlocks && data.suggestedCodeBlocks.length > 0;
|
|
648
|
+
const hasDiffs = data.assistantSuggestedDiffs && data.assistantSuggestedDiffs.length > 0;
|
|
649
|
+
const hasRichText = data.richText && data.richText.trim && data.richText.trim().length > 0;
|
|
650
|
+
const hasToolFormerData = data.toolFormerData && Object.keys(data.toolFormerData).length > 0;
|
|
651
|
+
|
|
652
|
+
// 保留有完整timingInfo的bubble(即使没有内容,也包含性能数据)
|
|
653
|
+
const hasCompleteTimingInfo = data.timingInfo &&
|
|
654
|
+
data.timingInfo.clientRpcSendTime &&
|
|
655
|
+
data.timingInfo.clientSettleTime;
|
|
656
|
+
|
|
657
|
+
if (hasText || hasToolResults || hasSuggestedCode || hasDiffs || hasRichText || hasToolFormerData || hasCompleteTimingInfo) {
|
|
658
|
+
bubbles.push(data);
|
|
659
|
+
} else {
|
|
660
|
+
skippedEmptyBubbles++;
|
|
661
|
+
}
|
|
662
|
+
} catch (parseError) {
|
|
663
|
+
console.error(`[bubble解析] JSON解析失败,跳过 key: ${row.key}`, parseError.message);
|
|
628
664
|
}
|
|
629
665
|
}
|
|
630
666
|
}
|
package/index.js
CHANGED
|
@@ -209,8 +209,16 @@ function log(level, message, data = null) {
|
|
|
209
209
|
// 便捷的日志方法
|
|
210
210
|
const logger = {
|
|
211
211
|
info: (message, data) => log('INFO', message, data),
|
|
212
|
-
warn: (message, data) =>
|
|
213
|
-
|
|
212
|
+
warn: (message, data) => {
|
|
213
|
+
log('WARN', message, data);
|
|
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
|
+
},
|
|
214
222
|
debug: (message, data) => log('DEBUG', message, data)
|
|
215
223
|
};
|
|
216
224
|
|
|
@@ -852,6 +860,11 @@ async function uploadExecutions(sessionId, executionsList) {
|
|
|
852
860
|
data.timingInfo = JSON.stringify(exec.timingInfo);
|
|
853
861
|
}
|
|
854
862
|
|
|
863
|
+
// 添加工具调用名称(仅type=ai时)
|
|
864
|
+
if (exec.type === 'ai' && exec.toolName) {
|
|
865
|
+
data.toolName = exec.toolName;
|
|
866
|
+
}
|
|
867
|
+
|
|
855
868
|
// 初始化additionalInfo为空对象(确保字段不为NULL)
|
|
856
869
|
const additionalInfo = {};
|
|
857
870
|
|
package/manifest.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ACW工具集",
|
|
3
3
|
"description": "ACW平台工具集:智能下载规则到项目、初始化Common Admin模板项目",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.3.1",
|
|
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