@bangdao-ai/acw-tools 1.3.7 → 1.3.8

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.
@@ -23,6 +23,7 @@ if (DEBUG_MODE && !fs.existsSync(DEBUG_LOG_DIR)) {
23
23
  /**
24
24
  * DEBUG 日志函数
25
25
  * 仅在 DEBUG_MODE 启用时输出详细日志到文件
26
+ * 日志格式设计:方便贴给AI分析问题
26
27
  */
27
28
  function debugLog(message, data = null) {
28
29
  if (!DEBUG_MODE) return;
@@ -31,7 +32,7 @@ function debugLog(message, data = null) {
31
32
  const timestamp = now.toISOString().replace('T', ' ').replace('Z', '');
32
33
  const logFile = path.join(DEBUG_LOG_DIR, `acw-mcp-debug-${now.toISOString().split('T')[0]}.log`);
33
34
 
34
- let logLine = `${timestamp} [DEBUG] ${message}`;
35
+ let logLine = `[${timestamp}] ${message}`;
35
36
  if (data !== null) {
36
37
  if (typeof data === 'object') {
37
38
  logLine += '\n' + JSON.stringify(data, null, 2);
@@ -237,6 +238,18 @@ function extractAdditionalInfo(composerData, bubbles, markdownContent = '') {
237
238
  duration = Math.max(0, duration);
238
239
  }
239
240
 
241
+ // DEBUG 模式:记录解析开始
242
+ if (DEBUG_MODE) {
243
+ debugLog(`\n========== [开始解析会话] ==========`);
244
+ debugLog(`composerId: ${composerData?.composerId}`);
245
+ debugLog(`会话名称: ${composerData?.name || '无'}`);
246
+ debugLog(`bubble总数: ${bubbles.length}`);
247
+ // 统计有 timingInfo 的 bubble 数量
248
+ const bubblesWithTimingInfo = bubbles.filter(b => b.type === 2 && b.timingInfo);
249
+ debugLog(`其中AI bubble有timingInfo的数量: ${bubblesWithTimingInfo.length}`);
250
+ debugLog(`====================================`);
251
+ }
252
+
240
253
  const additionalInfo = {
241
254
  // 会话元数据
242
255
  metadata: {
@@ -342,39 +355,39 @@ function extractAdditionalInfo(composerData, bubbles, markdownContent = '') {
342
355
  const tokenCount = bubble.tokenCount || {};
343
356
  const modelInfo = bubble.modelInfo || {};
344
357
 
345
- // DEBUG: 输出原始 bubble.timingInfo 情况
346
- const hasRawTimingInfo = !!bubble.timingInfo;
358
+ // DEBUG: 只记录有 timingInfo 的 bubble(这才是关键数据)
359
+ const hasTimingInfo = !!bubble.timingInfo;
347
360
  const hasClientRpcSendTime = !!(bubble.timingInfo && bubble.timingInfo.clientRpcSendTime);
348
361
  const hasClientSettleTime = !!(bubble.timingInfo && bubble.timingInfo.clientSettleTime);
349
362
 
350
- // DEBUG 模式:记录每个 AI bubble timingInfo 详情
351
- if (DEBUG_MODE) {
352
- debugLog(`[AI Bubble] bubbleId=${bubble.bubbleId}`, {
353
- hasTimingInfo: hasRawTimingInfo,
354
- hasClientRpcSendTime,
355
- hasClientSettleTime,
356
- rawTimingInfo: bubble.timingInfo,
357
- modelName: modelInfo.modelName,
358
- tokenCount: tokenCount
363
+ // DEBUG 模式:只打印有 timingInfobubble,并输出完整 value
364
+ if (DEBUG_MODE && hasTimingInfo) {
365
+ debugLog(`━━━ [有timingInfo的Bubble] ━━━`);
366
+ debugLog(`bubbleId: ${bubble.bubbleId}`);
367
+ debugLog(`timingInfo原始值:`, bubble.timingInfo);
368
+ debugLog(`解析过程:`, {
369
+ step1_hasTimingInfo: hasTimingInfo,
370
+ step2_hasClientRpcSendTime: hasClientRpcSendTime,
371
+ step3_hasClientSettleTime: hasClientSettleTime,
372
+ step4_clientRpcSendTime: aiTimingInfo.clientRpcSendTime,
373
+ step5_clientSettleTime: aiTimingInfo.clientSettleTime,
374
+ step6_计算executionTime: hasClientRpcSendTime && hasClientSettleTime
375
+ ? `${aiTimingInfo.clientSettleTime} - ${aiTimingInfo.clientRpcSendTime} = ${aiTimingInfo.clientSettleTime - aiTimingInfo.clientRpcSendTime}ms`
376
+ : '缺少必要字段,无法计算'
359
377
  });
360
-
361
- // 如果缺少 timingInfo,输出完整的 bubble 数据用于排查
362
- if (!hasRawTimingInfo || !hasClientRpcSendTime || !hasClientSettleTime) {
363
- debugLog(`[AI Bubble 缺少 timingInfo] 完整 bubble 数据:`, {
364
- bubbleId: bubble.bubbleId,
365
- type: bubble.type,
366
- createdAt: bubble.createdAt,
367
- // 输出 bubble 的所有顶级字段(排除可能很大的 text/richText)
368
- bubbleKeys: Object.keys(bubble),
369
- // 完整的 bubble 数据(用于深度排查)
370
- fullBubble: {
371
- ...bubble,
372
- // 截断可能很长的文本字段
373
- text: bubble.text ? `[长度: ${bubble.text.length}] ${bubble.text.substring(0, 200)}...` : null,
374
- richText: bubble.richText ? `[长度: ${bubble.richText.length}]` : null
375
- }
376
- });
377
- }
378
+ // 输出完整 bubble(排除超长文本)
379
+ debugLog(`bubble完整数据:`, {
380
+ bubbleId: bubble.bubbleId,
381
+ type: bubble.type,
382
+ createdAt: bubble.createdAt,
383
+ timingInfo: bubble.timingInfo,
384
+ tokenCount: bubble.tokenCount,
385
+ modelInfo: bubble.modelInfo,
386
+ toolFormerData: bubble.toolFormerData ? { name: bubble.toolFormerData.name } : null,
387
+ // 其他字段(排除大文本)
388
+ otherKeys: Object.keys(bubble).filter(k => !['text', 'richText', 'timingInfo', 'tokenCount', 'modelInfo', 'toolFormerData', 'bubbleId', 'type', 'createdAt'].includes(k))
389
+ });
390
+ debugLog(`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`);
378
391
  }
379
392
 
380
393
  let executionTime = 0;
@@ -469,20 +482,34 @@ function extractAdditionalInfo(composerData, bubbles, markdownContent = '') {
469
482
  additionalInfo.performance.minExecutionTime = 0;
470
483
  }
471
484
 
472
- // DEBUG 模式:输出 timingInfo 统计汇总
485
+ // DEBUG 模式:输出 timingInfo 解析结果汇总
473
486
  if (DEBUG_MODE) {
474
- debugLog(`[timingInfo 统计汇总] composerId=${composerData?.composerId}`, {
475
- totalAiExecutions: additionalInfo.performance.aiExecutionCount,
476
- withTimingInfo: aiExecutionsWithTimingInfo,
477
- withoutTimingInfo: aiExecutionsWithoutTimingInfo,
478
- validExecutionCount: validAiExecutionCount,
479
- totalExecutionTime: additionalInfo.performance.totalExecutionTime,
480
- averageExecutionTime: additionalInfo.performance.averageExecutionTime,
481
- // 列出所有缺少 timingInfo 的 AI execution
482
- missingTimingInfoBubbles: additionalInfo.performance.executions
483
- .filter(e => e.type === 'ai' && !e.timingInfo)
484
- .map(e => ({ bubbleId: e.bubbleId, modelName: e.modelName, timestamp: e.timestamp }))
487
+ debugLog(`\n========== [会话解析完成] ==========`);
488
+ debugLog(`composerId: ${composerData?.composerId}`);
489
+ debugLog(`会话名称: ${composerData?.name || '无'}`);
490
+ debugLog(`解析结果汇总:`, {
491
+ 总AI_bubble数: additionalInfo.performance.aiExecutionCount,
492
+ 有timingInfo的数量: aiExecutionsWithTimingInfo,
493
+ 无timingInfo的数量: aiExecutionsWithoutTimingInfo,
494
+ 有效执行时间的数量: validAiExecutionCount,
495
+ 总执行时间ms: additionalInfo.performance.totalExecutionTime,
496
+ 平均执行时间ms: Math.round(additionalInfo.performance.averageExecutionTime)
485
497
  });
498
+ // 列出所有解析出的 execution(带 timingInfo 的)
499
+ const executionsWithTiming = additionalInfo.performance.executions
500
+ .filter(e => e.type === 'ai' && e.timingInfo);
501
+ if (executionsWithTiming.length > 0) {
502
+ debugLog(`有timingInfo的execution列表 (共${executionsWithTiming.length}个):`,
503
+ executionsWithTiming.map(e => ({
504
+ bubbleId: e.bubbleId,
505
+ executionTime: e.executionTime,
506
+ timingInfo: e.timingInfo
507
+ }))
508
+ );
509
+ } else {
510
+ debugLog(`⚠️ 警告: 该会话没有任何带timingInfo的AI bubble!`);
511
+ }
512
+ debugLog(`====================================\n`);
486
513
  }
487
514
 
488
515
  // 分离executions数组
package/manifest.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ACW工具集",
3
3
  "description": "ACW平台工具集:智能下载规则到项目、初始化Common Admin模板项目",
4
- "version": "1.3.7",
4
+ "version": "1.3.8",
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bangdao-ai/acw-tools",
3
- "version": "1.3.7",
3
+ "version": "1.3.8",
4
4
  "type": "module",
5
5
  "description": "MCP (Model Context Protocol) tools for ACW - download rules and initialize Common Admin projects",
6
6
  "main": "index.js",