weaver-work-cli 0.1.64 → 0.1.65
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/chunks/{attachment-content-JQDW3BIB.js → attachment-content-QUM27QNB.js} +3 -3
- package/dist/chunks/{chunk-I3MOFD6Q.js → chunk-6AW5LW4T.js} +4 -4
- package/dist/chunks/{chunk-SCMHG23G.js → chunk-CUY64WP4.js} +38 -38
- package/dist/chunks/{chunk-AGSO3PIK.js → chunk-D6SWOUUP.js} +2 -2
- package/dist/chunks/{chunk-3PCXBG4H.js → chunk-E3OQSNF5.js} +1 -1
- package/dist/chunks/{chunk-RMOH2GMF.js → chunk-F4ME3CGS.js} +2 -2
- package/dist/chunks/{chunk-KDFEHDIB.js → chunk-IJDZ7VDC.js} +2 -2
- package/dist/chunks/{chunk-YTFNMQO4.js → chunk-IT3SB7RV.js} +88 -15
- package/dist/chunks/{chunk-4AFWOGOV.js → chunk-JDZOYHAL.js} +1 -1
- package/dist/chunks/{chunk-5QQKLR6H.js → chunk-LRK7YND4.js} +7 -7
- package/dist/chunks/{chunk-XHSEK2VM.js → chunk-NZLFKBEM.js} +6 -6
- package/dist/chunks/{chunk-INVYKG4I.js → chunk-QT7GGCSY.js} +32 -32
- package/dist/chunks/{chunk-KYDXWYFB.js → chunk-ZV3TYANI.js} +1 -1
- package/dist/chunks/{conflict-UUC7AFUI.js → conflict-76ZUL3E7.js} +2 -2
- package/dist/chunks/{create-flow-YOR4QTAJ.js → create-flow-7WGKLRHH.js} +6 -6
- package/dist/chunks/{entry-mode-S2ENJ6GZ.js → entry-mode-3UMMMK6Z.js} +3 -3
- package/dist/chunks/{env-ZSAXU5PJ.js → env-7EGXNZR2.js} +2 -2
- package/dist/chunks/{factory-N76QQA53.js → factory-BDERKTYX.js} +1 -1
- package/dist/chunks/{group-chat-UM665WDZ.js → group-chat-4E7EZMTJ.js} +3 -3
- package/dist/chunks/{meeting-MMTYDHXA.js → meeting-2FMYZXG5.js} +11 -11
- package/dist/chunks/{minute-doc-LCSBWGJ3.js → minute-doc-3DHMYMBE.js} +2 -2
- package/dist/chunks/{registry-BAWCWV4D.js → registry-6UGQO35C.js} +1 -1
- package/dist/chunks/{registry-FNI5E76J.js → registry-XXFMYPBM.js} +11 -11
- package/dist/chunks/{room-recommend-I7QQRHEL.js → room-recommend-7LD2OHL5.js} +4 -4
- package/dist/chunks/{schedule-3P7EWGNZ.js → schedule-ZAYMZKTQ.js} +4 -4
- package/dist/chunks/{workflow-U2KKTVQY.js → workflow-NYJJIT3D.js} +1 -1
- package/dist/index.js +2 -2
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.categoryCounts.js +64 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.collect.js +15 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.core.js +4 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.js +4 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.prepareQuery.js +4 -0
- package/package.json +1 -1
- package/skills/weaver-e10-workflow/SKILL.md +40 -16
- package/skills/weaver-e10-workflow/aigroup/default.json +1 -1
- package/skills/weaver-e10-workflow/references/todo-dialogue.md +30 -27
- package/skills/weaver-e10-workflow/references/todo-smart-convert.md +90 -22
- package/skills/weaver-e10-workflow/references/workflow-view.md +18 -2
- package/skills/weaver-e10-workflow/tools/todo-summary.cjs +240 -43
|
@@ -115,6 +115,7 @@ function cliEnv() {
|
|
|
115
115
|
// schema 不可用时使用既有协议;业务阶段仍只执行一次,失败直接交给原有错误处理。
|
|
116
116
|
let outputModeCapability;
|
|
117
117
|
let prepareQueryCapability = false;
|
|
118
|
+
let categoryCountsCapability = false;
|
|
118
119
|
function supportsOutputMode() {
|
|
119
120
|
if (outputModeCapability !== undefined) return outputModeCapability;
|
|
120
121
|
outputModeCapability = false;
|
|
@@ -134,6 +135,7 @@ function supportsOutputMode() {
|
|
|
134
135
|
outputModeCapability = Array.isArray(modes) && modes.includes('query') && modes.includes('summary');
|
|
135
136
|
prepareQueryCapability = Array.isArray(schema?.properties?.stage?.enum)
|
|
136
137
|
&& schema.properties.stage.enum.includes('prepareQuery');
|
|
138
|
+
categoryCountsCapability = schema?.properties?.includeCategoryCounts?.type === 'boolean';
|
|
137
139
|
}
|
|
138
140
|
} catch {
|
|
139
141
|
// 仅 schema 读取失败允许兼容既有协议;不要捕获或重试任何真实业务调用。
|
|
@@ -324,9 +326,11 @@ function resolveBaseUrl(state, dir) {
|
|
|
324
326
|
|
|
325
327
|
/**
|
|
326
328
|
* 把最终三键对象包成 browsertool 组件载荷(用户 2026-10-27 要求;2026-11-13 改为 id 传参)。
|
|
327
|
-
* -
|
|
329
|
+
* - 每轮组件使用唯一 callId/panelKey;本轮工作流分布、分类及全部链接共用 callId,
|
|
330
|
+
* 按过滤目标派生不同 panelKey,更新已注册实例;
|
|
331
|
+
* toolId 固定 fill_form;
|
|
328
332
|
* - `arguments` 层新增 `displayMode: "tabs"` 与 `panelKey`(2026-11-10 用户要求,层级同 title/src):
|
|
329
|
-
* panelKey = `todo_summary_
|
|
333
|
+
* panelKey = `todo_summary_<当前时间戳>_<随机串>`,独立查询使用不同面板;
|
|
330
334
|
* - 摘要的 `params.data` 带 `{"id": "<smartgroup/add 落库返回的主键>"}`(2026-11-13 用户定稿,
|
|
331
335
|
* 取代旧的 `params.data.dataSource` 本地服务地址)。id 按服务端响应的**原样数字串**内嵌
|
|
332
336
|
* (字符串形态,防雪花 id 超出 JS Number 安全整数范围丢精度);组件侧拿 id 走服务端读回链路;
|
|
@@ -336,13 +340,20 @@ function resolveBaseUrl(state, dir) {
|
|
|
336
340
|
*/
|
|
337
341
|
function wrapBrowseToolPayload(baseUrl, smartGroupId, title = '待办摘要汇总', options = {}) {
|
|
338
342
|
const src = `${String(baseUrl).replace(/\/+$/, '')}/workflow/list/todo`;
|
|
339
|
-
const panelKey = `todo_summary_${Date.now()}`;
|
|
343
|
+
const panelKey = `todo_summary_${Date.now()}_${Math.random().toString(36).slice(2, 10).padEnd(8, '0')}`;
|
|
340
344
|
const data = smartGroupId && typeof smartGroupId === 'object' ? smartGroupId : { id: String(smartGroupId) };
|
|
345
|
+
const compConfig = {};
|
|
346
|
+
for (const key of ['queryName', 'queryScope']) {
|
|
347
|
+
if (typeof options[key] === 'string' && options[key].trim()) compConfig[key] = options[key].trim();
|
|
348
|
+
}
|
|
349
|
+
if (['browser', 'tabs'].includes(options.detailOpenMode)) compConfig.detailOpenMode = options.detailOpenMode;
|
|
350
|
+
if (typeof options.autoOpenWfAIAssistant === 'boolean') compConfig.autoOpenWfAIAssistant = options.autoOpenWfAIAssistant;
|
|
351
|
+
const queryName = Object.keys(compConfig).length > 0;
|
|
341
352
|
const inline = Number.isInteger(options.totalCount) && options.totalCount >= 0 && options.totalCount < 5;
|
|
342
353
|
const text = [
|
|
343
354
|
'{',
|
|
344
355
|
' "version": "1.0",',
|
|
345
|
-
|
|
356
|
+
` "callId": ${JSON.stringify(panelKey)},`,
|
|
346
357
|
' "toolId": "fill_form",',
|
|
347
358
|
' "arguments": {',
|
|
348
359
|
' "type": "e10",',
|
|
@@ -359,7 +370,8 @@ function wrapBrowseToolPayload(baseUrl, smartGroupId, title = '待办摘要汇
|
|
|
359
370
|
' "params_pc": { "app": "@weapp/workflow", "compName": "Comp.WflTodoSummary", "clientType": "pc" },',
|
|
360
371
|
' "params_mobile": { "app": "@weapp/workflow", "compName": "Comp.WflTodoSummary", "clientType": "mobile" },',
|
|
361
372
|
' "params": {',
|
|
362
|
-
` "data": ${JSON.stringify(data)}`,
|
|
373
|
+
` "data": ${JSON.stringify(data)}${queryName ? ',' : ''}`,
|
|
374
|
+
...(queryName ? [` "compConfig": ${JSON.stringify(compConfig)}`] : []),
|
|
363
375
|
' }',
|
|
364
376
|
' }',
|
|
365
377
|
' }',
|
|
@@ -369,6 +381,64 @@ function wrapBrowseToolPayload(baseUrl, smartGroupId, title = '待办摘要汇
|
|
|
369
381
|
return `${text}\n`;
|
|
370
382
|
}
|
|
371
383
|
|
|
384
|
+
/** 对话分布只输出经过转义的纯文本名称。 */
|
|
385
|
+
function componentWorkflowLink(browserTool, workflowId, label) {
|
|
386
|
+
return String(label ?? '').replace(/[\r\n\t]+/g, ' ')
|
|
387
|
+
.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"')
|
|
388
|
+
.replace(/[|\\\x60*_[\]]/g, value => `&#${value.charCodeAt(0)};`);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/** 分类切换复用本轮 callId 和标准请求,按分类区分 panelKey;丢弃上一范围旧数据。 */
|
|
392
|
+
function componentCategoryLink(browserTool, listQuery, limit, tabid, label) {
|
|
393
|
+
const text = String(label ?? '').replace(/[\r\n\t]+/g, ' ')
|
|
394
|
+
.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"')
|
|
395
|
+
.replace(/[|\\`*_[\]]/g, value => `&#${value.charCodeAt(0)};`);
|
|
396
|
+
const linkPayload = JSON.parse(JSON.stringify(browserTool));
|
|
397
|
+
const basePanelKey = browserTool.arguments.panelKey || `e10-link:${browserTool.callId}`;
|
|
398
|
+
linkPayload.arguments.panelKey = `${basePanelKey}_category_${tabid}`;
|
|
399
|
+
const queryBody = JSON.parse(JSON.stringify(listQuery));
|
|
400
|
+
queryBody.params = { ...queryBody.params, tabid: String(tabid) };
|
|
401
|
+
delete queryBody.params.flowSpareType;
|
|
402
|
+
queryBody.customDisplayPage = { ...queryBody.customDisplayPage, current: 1, size: 500 };
|
|
403
|
+
const sdkOptions = linkPayload.arguments.sdkOptions;
|
|
404
|
+
const params = { ...sdkOptions.params, data: { listQuery: queryBody, limit } };
|
|
405
|
+
// 这些旧顶层输入会使组件继续优先展示摘要/旧数据,或复用上一范围的总数。
|
|
406
|
+
for (const key of ['id', 'dataSource', 'wfIdGroup', 'smartSummaryTitle', 'totalCount']) delete params[key];
|
|
407
|
+
params.compConfig = { ...params.compConfig };
|
|
408
|
+
if (params.compConfig.type === 'summary') delete params.compConfig.type;
|
|
409
|
+
delete params.compConfig.queryName;
|
|
410
|
+
const queryName = { '7': '待处理流程', '5': '待阅流程', '8': '被退回流程', '6': '超时流程', '1': '未读流程' }[String(tabid)];
|
|
411
|
+
if (queryName) params.compConfig.queryName = queryName;
|
|
412
|
+
sdkOptions.params = params;
|
|
413
|
+
const query = new URLSearchParams({ browsertool: JSON.stringify(linkPayload) });
|
|
414
|
+
return `[${text}](xiaoe://e10?${query.toString()})`;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/** 没有完整标准请求,或存在未由请求表达的本地排除时,不生成会扩大范围的入口。 */
|
|
418
|
+
function buildCategoryNavigation() {
|
|
419
|
+
return '';
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/** 初始普通查询只从已解析的单工作流条件或实际分类取展示名,不按提示词猜测。 */
|
|
423
|
+
function resolveQueryName(data, state = {}) {
|
|
424
|
+
const listQuery = data?.listQuery ?? state.queryMeta?.listQuery;
|
|
425
|
+
if (!listQuery || typeof listQuery !== 'object' || Array.isArray(listQuery)) return '';
|
|
426
|
+
const searchParams = listQuery.searchParams;
|
|
427
|
+
const conditions = searchParams?.formDatas?.workflowid;
|
|
428
|
+
if (searchParams?.type !== 'or' && Array.isArray(conditions) && conditions.length === 1
|
|
429
|
+
&& conditions[0]?.term === 'in' && Array.isArray(conditions[0].browserDatas)) {
|
|
430
|
+
const entries = conditions[0].browserDatas;
|
|
431
|
+
const valid = entries.length > 0 && entries.every(entry => entry
|
|
432
|
+
&& ((typeof entry.id === 'string' && entry.id.trim()) || Number.isSafeInteger(entry.id))
|
|
433
|
+
&& typeof entry.name === 'string' && entry.name.trim() && entry.name.trim() !== '未提供名称');
|
|
434
|
+
if (valid && new Set(entries.map(entry => String(entry.id).trim())).size === 1) {
|
|
435
|
+
const name = entries[0].name.replace(/[\r\n\t]+/g, ' ').trim();
|
|
436
|
+
return name.endsWith('流程') ? name : `${name}流程`;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
return { '7': '待处理流程', '5': '待阅流程', '8': '被退回流程', '6': '超时流程', '1': '未读流程' }[String(listQuery.params?.tabid)] || '';
|
|
440
|
+
}
|
|
441
|
+
|
|
372
442
|
/** 仅使用与交付范围一致的真实总数;已读取条数不能证明已覆盖全部。 */
|
|
373
443
|
function resolveMatchingTotal(state, displayedCount) {
|
|
374
444
|
if (state.dropped > 0) return null;
|
|
@@ -388,7 +458,7 @@ function resolveMatchingTotal(state, displayedCount) {
|
|
|
388
458
|
* ① 总数/降级说明行 —— 总数取 collect 首轮 getTodoListTotal 的结果(state.degrade.steps[0].total);
|
|
389
459
|
* 新模式由 windowDays / terminal 和最后一步 scope 描述实际范围(最低近7天);
|
|
390
460
|
* 历史无上述字段时保留 level=5 对应近1个月终点级的解释;
|
|
391
|
-
* ②
|
|
461
|
+
* ② 优先组条目表格:流程标题 + 操作,查看详情链接带 data-xiaoe-open="external";
|
|
392
462
|
* 超过5条截前5条并在标题提示「(前5条)」,不超过不带括号;
|
|
393
463
|
* ③ 工作流分组表格:排除优先组,只有多个工作流时展示,按组内条数降序。
|
|
394
464
|
*/
|
|
@@ -458,21 +528,73 @@ function buildReplyPrologue(state, payload, opts) {
|
|
|
458
528
|
}
|
|
459
529
|
}
|
|
460
530
|
if (priorityRows.length > 0) {
|
|
461
|
-
//
|
|
531
|
+
// 摘要正文展示标题和浏览器详情入口;只改正文,不改组件数据。
|
|
462
532
|
const capText = priorityRows.length > 5 ? '(前 5 条)' : '';
|
|
463
533
|
lines.push('', `**建议您优先处理**${capText}:`, '');
|
|
464
|
-
lines.push('| 流程标题 |', '| --- |');
|
|
534
|
+
lines.push('| 流程标题 | 操作 |', '| --- | --- |');
|
|
535
|
+
const linkBase = String(opts.baseUrl || '').replace(/\/+$/, '');
|
|
536
|
+
const escapeHtml = (text) => String(text).replace(/&/g, '&').replace(/"/g, '"')
|
|
537
|
+
.replace(/</g, '<').replace(/>/g, '>');
|
|
465
538
|
const clean = (text) => String(text ?? '').replace(/\s+/g, ' ').replace(/[[\]]/g, '').trim();
|
|
466
539
|
priorityRows.slice(0, 5).forEach((row) => {
|
|
467
|
-
const requestId = String(row.requestId || '');
|
|
540
|
+
const requestId = String(row.requestId || '').trim();
|
|
541
|
+
const userMasterId = String(row.userMasterId || '').trim();
|
|
542
|
+
const link = requestId && /^https?:\/\//i.test(linkBase)
|
|
543
|
+
? `${linkBase}/sp/workflow/flowpage/view/${encodeURIComponent(requestId)}`
|
|
544
|
+
+ (userMasterId ? `?secondEmpId=${encodeURIComponent(userMasterId)}&requestId=${encodeURIComponent(requestId)}` : '')
|
|
545
|
+
: '';
|
|
468
546
|
const title = clean(row.requestNameTitle) || requestId || '—';
|
|
469
|
-
|
|
547
|
+
const action = link ? `<a href="${escapeHtml(link)}" data-xiaoe-open="external" style="cursor: pointer;">查看详情</a>` : '—';
|
|
548
|
+
lines.push(`| ${escapeHtml(title).replace(/\|/g, '\\|')} | ${action} |`);
|
|
470
549
|
});
|
|
471
550
|
}
|
|
472
551
|
|
|
473
|
-
|
|
552
|
+
// 摘要可按同名合组,分布筛选必须回到每条流程的真实工作流 ID。
|
|
553
|
+
const workflowRows = new Map((Array.isArray(opts.workflowRows) ? opts.workflowRows : [])
|
|
554
|
+
.filter(row => row && row.requestId)
|
|
555
|
+
.map(row => [String(row.requestId).trim(), row]));
|
|
556
|
+
const requests = new Map();
|
|
557
|
+
let missingRequestId = false;
|
|
558
|
+
for (const group of groups) {
|
|
559
|
+
for (const item of group.displayItems || []) {
|
|
560
|
+
const rows = item.type === 'request' ? [item.requestData] : (item.requestDatas || []);
|
|
561
|
+
for (const row of rows) {
|
|
562
|
+
const requestId = String(row?.requestId || '').trim();
|
|
563
|
+
if (!requestId) {
|
|
564
|
+
missingRequestId = true;
|
|
565
|
+
continue;
|
|
566
|
+
}
|
|
567
|
+
const known = workflowRows.get(requestId) || {};
|
|
568
|
+
const workflowId = String(row.workflowId || known.workflowId || '').trim();
|
|
569
|
+
const workflowName = String(row.workflowName || known.workflowName || '').trim();
|
|
570
|
+
const groupTitle = isPriority(group) ? '' : String(group.title || '').trim();
|
|
571
|
+
const existing = requests.get(requestId);
|
|
572
|
+
if (existing) {
|
|
573
|
+
if (!existing.workflowId) existing.workflowId = workflowId;
|
|
574
|
+
if (!existing.workflowName) existing.workflowName = workflowName;
|
|
575
|
+
if (!existing.groupTitle) existing.groupTitle = groupTitle;
|
|
576
|
+
} else requests.set(requestId, { workflowId, workflowName, groupTitle });
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
const hasWorkflowMetadata = !missingRequestId && requests.size > 0 && requests.size === totalCount
|
|
581
|
+
&& [...requests.values()].every(row => row.workflowId);
|
|
582
|
+
const distribution = new Map();
|
|
583
|
+
if (hasWorkflowMetadata) {
|
|
584
|
+
for (const row of requests.values()) {
|
|
585
|
+
const title = row.workflowName || row.groupTitle || '未提供名称';
|
|
586
|
+
const key = row.workflowName && row.workflowName !== '未提供名称' ? `name:${row.workflowName}` : `id:${row.workflowId}`;
|
|
587
|
+
const existing = distribution.get(key);
|
|
588
|
+
if (existing) {
|
|
589
|
+
existing.count += 1;
|
|
590
|
+
if (existing.title === '未提供名称' && title !== '未提供名称') existing.title = title;
|
|
591
|
+
} else distribution.set(key, { title, count: 1 });
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
// 老成品缺少标识时保留原统计,不把分组 ID 猜成工作流 ID。
|
|
595
|
+
const tableRows = (hasWorkflowMetadata ? [...distribution.values()] : groups
|
|
474
596
|
.filter((g) => !isPriority(g))
|
|
475
|
-
.map((g) => ({ title: String(g.title || ''), count: Number(g.count) || 0 }))
|
|
597
|
+
.map((g) => ({ title: String(g.title || ''), count: Number(g.count) || 0 })))
|
|
476
598
|
.sort((a, b) => b.count - a.count);
|
|
477
599
|
if (tableRows.length > 1) {
|
|
478
600
|
// 2026-11-11 用户定稿:①表格加标题(与「建议您优先处理」同一样式的粗体标题行,15:53 定稿文案
|
|
@@ -483,12 +605,15 @@ function buildReplyPrologue(state, payload, opts) {
|
|
|
483
605
|
lines.push('', opts.tablesOnly ? '**工作流分布情况(本次展示)**:' : `**工作流分布情况${scope}**:`);
|
|
484
606
|
lines.push('| 工作流 | 总数 |', '| --- | --- |');
|
|
485
607
|
for (const row of tableRows.slice(0, 10)) {
|
|
486
|
-
|
|
608
|
+
const label = componentWorkflowLink(row.workflowId ? opts.browserTool : undefined, row.workflowId, row.title);
|
|
609
|
+
lines.push(`| ${label} | ${row.count} |`);
|
|
487
610
|
}
|
|
488
611
|
if (tableRows.length > 10) {
|
|
489
612
|
const restCount = tableRows.slice(10).reduce((sum, row) => sum + row.count, 0);
|
|
490
613
|
lines.push(`| 其它 | ${restCount} |`);
|
|
491
614
|
}
|
|
615
|
+
const coveredCount = hasWorkflowMetadata ? requests.size : totalCount;
|
|
616
|
+
lines.push(`| ${componentWorkflowLink(opts.browserTool, undefined, '全部')} | ${coveredCount} |`);
|
|
492
617
|
}
|
|
493
618
|
return lines;
|
|
494
619
|
}
|
|
@@ -660,6 +785,7 @@ function exportFinal(result, dir, state, kept, opts = {}) {
|
|
|
660
785
|
// 产物落库(2026-11-13 用户定稿):三键 JSON 不落物理文件,经 CLI stage=smartGroupAdd 调
|
|
661
786
|
// POST /api/workflow/list/smartgroup/add 存 E10 服务端,拿回落库主键 id 给组件载荷用。
|
|
662
787
|
// 失败口径:不降级、不回退——CLI 抛错即 exit 1,skill 不再继续(2026-11-13 用户定稿)。
|
|
788
|
+
const queryScope = buildQueryScope(state, payload.totalCount);
|
|
663
789
|
let smartGroupId = '';
|
|
664
790
|
try {
|
|
665
791
|
smartGroupId = persistPayload(payload, dir, opts.queryPrompt);
|
|
@@ -671,11 +797,19 @@ function exportFinal(result, dir, state, kept, opts = {}) {
|
|
|
671
797
|
}
|
|
672
798
|
// 交付正文与 stdout 共用同一份;`params.data.id` = 落库主键(原样数字串,保雪花精度)。
|
|
673
799
|
const knownTotal = resolveMatchingTotal(state, payload.totalCount);
|
|
674
|
-
const finalText = wrapBrowseToolPayload(baseUrl, smartGroupId, '待办摘要汇总', {
|
|
800
|
+
const finalText = wrapBrowseToolPayload(baseUrl, smartGroupId, '待办摘要汇总', {
|
|
801
|
+
totalCount: knownTotal, queryScope, detailOpenMode: state.detailOpenMode,
|
|
802
|
+
autoOpenWfAIAssistant: state.autoOpenWfAIAssistant,
|
|
803
|
+
});
|
|
675
804
|
// 交付 = 回复正文(总数/降级说明 + 优先组前 5 列表 + 工作流表格 + <browsertool> 块)。
|
|
676
805
|
// 2026-11-10 用户定稿:正文不再是只有组件块,前段由脚本产出、模型原样粘贴(勿增删改写)。
|
|
806
|
+
const browserTool = JSON.parse(finalText);
|
|
677
807
|
const delivery = `<browsertool>\n${finalText.trimEnd()}\n</browsertool>`;
|
|
678
|
-
const prologueLines = buildReplyPrologue(state, payload, {
|
|
808
|
+
const prologueLines = buildReplyPrologue(state, payload, {
|
|
809
|
+
tablesOnly: false, baseUrl, browserTool, workflowRows: kept,
|
|
810
|
+
});
|
|
811
|
+
const categoryNavigation = buildCategoryNavigation(browserTool, state);
|
|
812
|
+
if (categoryNavigation) prologueLines.splice(1, 0, '', categoryNavigation);
|
|
679
813
|
const replyBody = [...prologueLines, '', delivery].join('\n');
|
|
680
814
|
fs.writeFileSync(path.join(dir, 'reply.md'), replyBody);
|
|
681
815
|
console.log('\n[JSON_BEGIN]');
|
|
@@ -924,6 +1058,7 @@ function readOutputLimit(args, outputMode) {
|
|
|
924
1058
|
|
|
925
1059
|
function cmdPrep(args) {
|
|
926
1060
|
const outputMode = args._query === true ? 'query' : 'summary';
|
|
1061
|
+
const presentation = readPresentationArgs(args);
|
|
927
1062
|
const limit = readOutputLimit(args, outputMode);
|
|
928
1063
|
const days = Number(args.days || 0);
|
|
929
1064
|
const exclude = args.exclude && args.exclude !== true ? String(args.exclude).split(',').map((x) => x.trim()).filter(Boolean) : [];
|
|
@@ -943,6 +1078,7 @@ function cmdPrep(args) {
|
|
|
943
1078
|
|
|
944
1079
|
const startedAt = nowIso();
|
|
945
1080
|
const input = { stage: args._prepareQuery === true ? 'prepareQuery' : 'collect', outputMode, limit };
|
|
1081
|
+
supportsOutputMode();
|
|
946
1082
|
// 2026-11-11 用户定稿:排除清单必须进 CLI 查询条件——首轮 getTodoListTotal 要带上
|
|
947
1083
|
// 提示词中的**完整条件**(含排除项),否则交付正文的「您共 X 条待办」与实际纳入条数
|
|
948
1084
|
// 口径对不上(实测 223 vs 53)。本地剔除保留作兜底(正常情况下 CLI 已排除,dropped=0)。
|
|
@@ -1126,7 +1262,9 @@ function cmdPrep(args) {
|
|
|
1126
1262
|
}
|
|
1127
1263
|
|
|
1128
1264
|
fs.writeFileSync(path.join(dir, 'state.json'), JSON.stringify({
|
|
1129
|
-
dir, startedAt, outputMode, limit, days, from: args.from || null, to: args.to || null, exclude,
|
|
1265
|
+
dir, startedAt, outputMode, ...presentation, limit, days, from: args.from || null, to: args.to || null, exclude,
|
|
1266
|
+
localWorkflowExclusion: Boolean(hasLocalWorkflowExclusion(args)),
|
|
1267
|
+
subCategory: input.subCategory || null, collectMs, collectWallMs,
|
|
1130
1268
|
// 记录本次取数实际能力,降级范围仍以 queryMeta/degrade 为准。后续进程会重新探测入口。
|
|
1131
1269
|
cliCapabilities: { outputMode: supportsOutputMode() },
|
|
1132
1270
|
// 编排标记(2026-11-16 入口自检):build/finish 只允许消费由本脚本 run 产出的目录;
|
|
@@ -1249,6 +1387,7 @@ function cmdBuild(args) {
|
|
|
1249
1387
|
guardOrchestrated(args, dir, 'build');
|
|
1250
1388
|
const planFile = args.plan !== undefined && args.plan !== true ? String(args.plan) : '';
|
|
1251
1389
|
const state = readJson(path.join(dir, 'state.json'));
|
|
1390
|
+
Object.assign(state, readPresentationArgs(args, state));
|
|
1252
1391
|
const kept = readJson(path.join(dir, 'items.json'));
|
|
1253
1392
|
const planGroups = state.planGroups || [];
|
|
1254
1393
|
const countById = new Map(planGroups.map((g) => [g.groupId, g.count]));
|
|
@@ -1340,6 +1479,11 @@ function cmdFinish(args) {
|
|
|
1340
1479
|
const dir = String(args.dir);
|
|
1341
1480
|
guardOrchestrated(args, dir, 'finish');
|
|
1342
1481
|
const state = readJson(path.join(dir, 'state.json'));
|
|
1482
|
+
const presentation = readPresentationArgs(args, state);
|
|
1483
|
+
if (Object.keys(presentation).length) {
|
|
1484
|
+
Object.assign(state, presentation);
|
|
1485
|
+
fs.writeFileSync(path.join(dir, 'state.json'), JSON.stringify(state));
|
|
1486
|
+
}
|
|
1343
1487
|
const kept = readJson(path.join(dir, 'items.json'));
|
|
1344
1488
|
// `aiGroups.json` 可能不存在(build 没传 --plan 时就是确定性分组),此时按「未传 aiGroups」处理。
|
|
1345
1489
|
const planPath = path.join(dir, 'aiGroups.json');
|
|
@@ -1467,6 +1611,7 @@ function cmdFinish(args) {
|
|
|
1467
1611
|
* 有待写摘要时会停下并打印素材:那部分必须模型写,写完跑 `finish` 即可,不用重跑取数与分组。
|
|
1468
1612
|
*/
|
|
1469
1613
|
function cmdRun(args) {
|
|
1614
|
+
readPresentationArgs(args);
|
|
1470
1615
|
const dir = args.out && args.out !== true
|
|
1471
1616
|
? String(args.out)
|
|
1472
1617
|
: fs.mkdtempSync(path.join(os.tmpdir(), 'todo-summary-'));
|
|
@@ -1557,26 +1702,31 @@ function hasLocalWorkflowExclusion(args) {
|
|
|
1557
1702
|
}
|
|
1558
1703
|
|
|
1559
1704
|
/** 仅将确定性计数放入会话正文,不改变组件数据源或生成 AI 分组。 */
|
|
1560
|
-
function buildQueryDistribution(distribution, total) {
|
|
1705
|
+
function buildQueryDistribution(distribution, total, browserTool) {
|
|
1561
1706
|
if (!distribution || !Array.isArray(distribution.items)) return [];
|
|
1562
|
-
const
|
|
1563
|
-
|
|
1564
|
-
.
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
const
|
|
1572
|
-
|
|
1573
|
-
const
|
|
1574
|
-
|
|
1575
|
-
|
|
1707
|
+
const merged = new Map();
|
|
1708
|
+
for (const row of distribution.items) {
|
|
1709
|
+
if (!row || !Number.isInteger(row.count) || row.count <= 0) continue;
|
|
1710
|
+
const name = typeof row.workflowName === 'string' ? row.workflowName.trim() : '';
|
|
1711
|
+
const key = name && name !== '未提供名称' ? `name:${name}` : `id:${String(row.workflowId || merged.size)}`;
|
|
1712
|
+
const previous = merged.get(key);
|
|
1713
|
+
if (previous) previous.count += row.count;
|
|
1714
|
+
else merged.set(key, { title: name || '未提供名称', count: row.count });
|
|
1715
|
+
}
|
|
1716
|
+
const rows = [...merged.values()].sort((a, b) => b.count - a.count);
|
|
1717
|
+
if (rows.length <= 1) return [];
|
|
1718
|
+
const counted = rows.reduce((count, row) => count + row.count, 0);
|
|
1719
|
+
const readCount = Number.isInteger(distribution.readCount) && distribution.readCount >= counted ? distribution.readCount : counted;
|
|
1720
|
+
const complete = distribution.complete === true && distribution.truncated !== true && total !== null && readCount === total && counted === readCount;
|
|
1721
|
+
const lines = ['', complete ? '**工作流分布情况**:' : `**工作流分布情况(本次读取${readCount}条)**:`, '| 工作流 | 总数 |', '| --- | --- |'];
|
|
1722
|
+
for (const row of rows.slice(0, 10)) lines.push(`| ${componentWorkflowLink(undefined, undefined, row.title)} | ${row.count} |`);
|
|
1723
|
+
if (rows.length > 10) lines.push(`| 其它 | ${rows.slice(10).reduce((count, row) => count + row.count, 0)} |`);
|
|
1724
|
+
lines.push(`| 全部 | ${counted} |`);
|
|
1576
1725
|
return lines;
|
|
1577
1726
|
}
|
|
1578
1727
|
|
|
1579
1728
|
function cmdQuery(args) {
|
|
1729
|
+
const presentation = readPresentationArgs(args);
|
|
1580
1730
|
const limit = readOutputLimit(args, 'query');
|
|
1581
1731
|
const dir = args.out && args.out !== true
|
|
1582
1732
|
? String(args.out)
|
|
@@ -1595,7 +1745,7 @@ function cmdQuery(args) {
|
|
|
1595
1745
|
}
|
|
1596
1746
|
const totalValue = Object.prototype.hasOwnProperty.call(prepared.data, 'totalCount')
|
|
1597
1747
|
? prepared.data.totalCount : query.totalAvailable;
|
|
1598
|
-
const state = { outputMode: 'query', queryMeta: { ...query, totalAvailable: totalValue } };
|
|
1748
|
+
const state = { outputMode: 'query', ...presentation, queryMeta: { ...query, totalAvailable: totalValue } };
|
|
1599
1749
|
const total = resolveMatchingTotal(state, 0);
|
|
1600
1750
|
const warnings = Array.isArray(prepared.data.warnings)
|
|
1601
1751
|
? prepared.data.warnings.filter(value => typeof value === 'string' && value.trim()).map(value => `注意:${value.trim()}`) : [];
|
|
@@ -1607,8 +1757,7 @@ function cmdQuery(args) {
|
|
|
1607
1757
|
const data = { listQuery: query.listQuery, limit, ...(total === null ? {} : { totalCount: total }) };
|
|
1608
1758
|
const lines = [...warnings, total === null ? `待办列表如下,本次最多展示${limit}条。`
|
|
1609
1759
|
: `本次共匹配${total}条待办${total > limit ? `,本次最多展示${limit}条` : ''},清单如下:`];
|
|
1610
|
-
lines
|
|
1611
|
-
deliverQuery(data, state, dir, total, lines);
|
|
1760
|
+
deliverQuery(data, state, dir, total, lines, prepared.data.distribution);
|
|
1612
1761
|
}
|
|
1613
1762
|
|
|
1614
1763
|
/** 旧 CLI 缺少准备查询阶段时保留原交付,业务失败不重试或切换路径。 */
|
|
@@ -1672,16 +1821,15 @@ function cmdLegacyQuery(args, dir, limit) {
|
|
|
1672
1821
|
if (existing) existing.count += 1;
|
|
1673
1822
|
else distribution.set(workflowId, { workflowId, workflowName: requestData.workflowName, count: 1 });
|
|
1674
1823
|
}
|
|
1675
|
-
lines.push(...buildQueryDistribution({ items: [...distribution.values()], readCount: count,
|
|
1676
|
-
complete: total === count, truncated: state.truncated > 0 }, total));
|
|
1677
1824
|
const nativeQuery = !hasLocalWorkflowExclusion(args) && state.queryMeta?.listQuery;
|
|
1678
1825
|
const data = nativeQuery ? { listQuery: nativeQuery, limit, ...(total === null ? {} : { totalCount: total }) }
|
|
1679
1826
|
: persistPayload(payload, dir, state.prompt);
|
|
1680
1827
|
fs.writeFileSync(path.join(dir, 'final.data.json'), JSON.stringify(payload));
|
|
1681
|
-
deliverQuery(data, state, dir, total, lines)
|
|
1828
|
+
deliverQuery(data, state, dir, total, lines, { items: [...distribution.values()], readCount: count,
|
|
1829
|
+
complete: total === count, truncated: state.truncated > 0 });
|
|
1682
1830
|
}
|
|
1683
1831
|
|
|
1684
|
-
function deliverQuery(data, state, dir, total, lines) {
|
|
1832
|
+
function deliverQuery(data, state, dir, total, lines, distribution) {
|
|
1685
1833
|
const listQuery = data?.listQuery;
|
|
1686
1834
|
if (listQuery?.params && typeof listQuery.params === 'object' && !Array.isArray(listQuery.params)) {
|
|
1687
1835
|
const params = { ...listQuery.params };
|
|
@@ -1689,13 +1837,60 @@ function deliverQuery(data, state, dir, total, lines) {
|
|
|
1689
1837
|
data = { ...data, listQuery: { ...listQuery, params } };
|
|
1690
1838
|
}
|
|
1691
1839
|
const baseUrl = resolveBaseUrl(state, dir);
|
|
1692
|
-
const
|
|
1693
|
-
|
|
1840
|
+
const finalText = wrapBrowseToolPayload(baseUrl, data, '待办列表', {
|
|
1841
|
+
totalCount: total, queryName: resolveQueryName(data, state), queryScope: buildQueryScope(state), detailOpenMode: state.detailOpenMode,
|
|
1842
|
+
autoOpenWfAIAssistant: state.autoOpenWfAIAssistant,
|
|
1843
|
+
});
|
|
1844
|
+
const browserTool = JSON.parse(finalText);
|
|
1845
|
+
const categoryNavigation = buildCategoryNavigation(browserTool, state);
|
|
1846
|
+
const categoryLines = categoryNavigation ? ['', categoryNavigation] : [];
|
|
1847
|
+
const distributionLines = buildQueryDistribution(distribution, total, browserTool);
|
|
1848
|
+
const delivery = `<browsertool>\n${finalText.trimEnd()}\n</browsertool>`;
|
|
1849
|
+
const replyBody = [...lines, ...categoryLines, ...distributionLines, '', delivery].join('\n');
|
|
1694
1850
|
fs.writeFileSync(path.join(dir, 'reply.md'), replyBody);
|
|
1695
1851
|
console.log('\n[JSON_BEGIN]\n%s\n[JSON_END]', replyBody);
|
|
1696
1852
|
console.log('交付正文已落盘:%s(原样粘贴正文与 browsertool,勿改写为旧卡片列表)', path.join(dir, 'reply.md'));
|
|
1697
1853
|
}
|
|
1698
1854
|
|
|
1855
|
+
function normalizeQueryScope(value) {
|
|
1856
|
+
if (typeof value !== 'string') throw Error('--query-scope 必填,请提供实际筛选范围');
|
|
1857
|
+
let scope = value.replace(/\s+/g, ' ').trim();
|
|
1858
|
+
while (/^筛选范围\s*[::]/u.test(scope)) scope = scope.replace(/^筛选范围\s*[::]\s*/u, '').trim();
|
|
1859
|
+
if (!scope || scope === '筛选范围') throw Error('--query-scope 不能为空或只有前缀,请提供实际筛选范围');
|
|
1860
|
+
return scope;
|
|
1861
|
+
}
|
|
1862
|
+
|
|
1863
|
+
function readPresentationArgs(args, state = {}) {
|
|
1864
|
+
const presentation = {
|
|
1865
|
+
queryScope: normalizeQueryScope(args['query-scope'] === undefined ? state.queryScope : args['query-scope']),
|
|
1866
|
+
};
|
|
1867
|
+
if (args['detail-open-mode'] !== undefined) {
|
|
1868
|
+
if (!['browser', 'tabs'].includes(args['detail-open-mode'])) throw Error('--detail-open-mode 仅支持 browser 或 tabs');
|
|
1869
|
+
presentation.detailOpenMode = args['detail-open-mode'];
|
|
1870
|
+
}
|
|
1871
|
+
const autoOpenWfAIAssistant = args['auto-open-wf-ai-assistant'];
|
|
1872
|
+
if (autoOpenWfAIAssistant !== undefined) {
|
|
1873
|
+
if (autoOpenWfAIAssistant !== 'true' && autoOpenWfAIAssistant !== 'false') {
|
|
1874
|
+
throw Error('--auto-open-wf-ai-assistant 仅支持 true 或 false');
|
|
1875
|
+
}
|
|
1876
|
+
presentation.autoOpenWfAIAssistant = autoOpenWfAIAssistant === 'true';
|
|
1877
|
+
} else if (typeof state.autoOpenWfAIAssistant === 'boolean') {
|
|
1878
|
+
presentation.autoOpenWfAIAssistant = state.autoOpenWfAIAssistant;
|
|
1879
|
+
}
|
|
1880
|
+
return presentation;
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1883
|
+
function buildQueryScope(state = {}, count) {
|
|
1884
|
+
const parts = [normalizeQueryScope(state.queryScope)];
|
|
1885
|
+
if (state.degrade?.applied) parts.push(`实际${state.outputMode === 'summary' ? '摘要' : '查询'}范围:${describeDegradeWindow(state.degrade)}`);
|
|
1886
|
+
if (state.outputMode === 'summary' && Number.isInteger(count) && count >= 0) {
|
|
1887
|
+
const total = resolveMatchingTotal(state, count);
|
|
1888
|
+
if ((total !== null && total > count) || state.truncated > 0) parts.push(`本次仅汇总前${count}条${total === null ? '' : `(匹配${total}条)`}`);
|
|
1889
|
+
else if (total === null && Number.isInteger(state.limit) && count >= state.limit) parts.push(`本次已汇总${count}条,尚未确认覆盖全部`);
|
|
1890
|
+
}
|
|
1891
|
+
return `筛选范围:${parts.join(';')}`;
|
|
1892
|
+
}
|
|
1893
|
+
|
|
1699
1894
|
const args = parseArgs(process.argv.slice(2));
|
|
1700
1895
|
const cmd = args._[0];
|
|
1701
1896
|
if (cmd === 'query') cmdQuery(args);
|
|
@@ -1705,11 +1900,13 @@ else if (cmd === 'finish') cmdFinish(args);
|
|
|
1705
1900
|
else if (cmd === 'run') cmdRun(args);
|
|
1706
1901
|
else {
|
|
1707
1902
|
console.log('用法:node ' + path.basename(__filename) + ' <query|run|prep|build|finish> [options]');
|
|
1708
|
-
console.log(' query [--limit 1000] [筛选条件] [--out DIR] [--prompt "用户完整提示词"] # 标题清单组件,每页500条;不生成 AI 摘要或二次分组;limit 为 1~1000,默认 1000');
|
|
1709
|
-
console.log(' run [--days N | --from A --to B] [--limit 100] [--out DIR] [--timing-report] [--prompt "用户完整提示词"] # 摘要默认/最多100条,沿用原工作流规则');
|
|
1710
|
-
console.log(' prep --limit 100 [--exclude 内部留言] [--days 1460] [--sub-category 待处理] [--tabid 7] [--isremarks 1,2] [--out DIR] # 小分类:--sub-category/--tabid(显式 tabid 优先);isremarks=备注筛选(数字逗号拼接)');
|
|
1903
|
+
console.log(' query --query-scope "本轮有效筛选范围" [--limit 1000] [筛选条件] [--out DIR] [--prompt "用户完整提示词"] # 标题清单组件,每页500条;不生成 AI 摘要或二次分组;limit 为 1~1000,默认 1000');
|
|
1904
|
+
console.log(' run --query-scope "本轮有效筛选范围" [--days N | --from A --to B] [--limit 100] [--out DIR] [--timing-report] [--prompt "用户完整提示词"] # 摘要默认/最多100条,沿用原工作流规则');
|
|
1905
|
+
console.log(' prep --query-scope "本轮有效筛选范围" --limit 100 [--exclude 内部留言] [--days 1460] [--sub-category 待处理] [--tabid 7] [--isremarks 1,2] [--out DIR] # 小分类:--sub-category/--tabid(显式 tabid 优先);isremarks=备注筛选(数字逗号拼接)');
|
|
1711
1906
|
console.log(' build --dir DIR [--plan aiGroups.json] # aiGroups 可先落盘(不传也行):build 只做首次分组+平铺,二次分组在 finish');
|
|
1712
1907
|
console.log(' finish --dir DIR [--summaries aiSummaries.json] [--group-summaries aiGroupSummaries.json] [--timing-report]');
|
|
1908
|
+
console.log(' 筛选范围:只描述实际生效条件;无额外筛选传“全部待办”。finish/build 复用已存范围,旧材料缺少时用 --query-scope 补填,不重新取数。');
|
|
1909
|
+
console.log(' 详情助手:--auto-open-wf-ai-assistant true|false,仅控制组件详情URL是否带助手参数;缺省沿用开启,finish/build 复用已存配置。');
|
|
1713
1910
|
console.log(' 规则新鲜度:finish 导出前比对 aigroup 指纹——规则在取数后被改过即拦截(新规则+旧数据出不了文件);确要带旧口径出文件加 --allow-stale-rules');
|
|
1714
1911
|
console.log(' 待写摘要素材:build/ run 停下时写 <out>/need-summaries.json(无损),控制台只留批次索引;写 aiSummaries.json 后 finish --summaries 回填');
|
|
1715
1912
|
console.log(' 组摘要未回填:以 exit 0 + NEEDS_GROUP_SUMMARIES 返回(不导出),完整素材在 <out>/need-group-summaries.json;');
|