weaver-work-cli 0.1.65 → 0.1.67
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-QUM27QNB.js → attachment-content-7SDA6WER.js} +3 -3
- package/dist/chunks/{chunk-IJDZ7VDC.js → chunk-33ANTJWB.js} +2 -2
- package/dist/chunks/{chunk-LRK7YND4.js → chunk-4PYLZORW.js} +7 -7
- package/dist/chunks/{chunk-SHX7XBYR.js → chunk-4WCVRDC5.js} +83 -33
- package/dist/chunks/{chunk-ZV3TYANI.js → chunk-6ZOSVKMT.js} +1 -1
- package/dist/chunks/{chunk-NZLFKBEM.js → chunk-DTJZOAO6.js} +6 -6
- package/dist/chunks/{chunk-F4ME3CGS.js → chunk-JU5OPHSY.js} +2 -2
- package/dist/chunks/{chunk-CUY64WP4.js → chunk-KS6LXSCA.js} +38 -38
- package/dist/chunks/{chunk-IT3SB7RV.js → chunk-LNWFHNVK.js} +2448 -318
- package/dist/chunks/{chunk-QT7GGCSY.js → chunk-MRYKV5HN.js} +32 -32
- package/dist/chunks/{chunk-K7QKQRSL.js → chunk-NP3ZZFGI.js} +24 -24
- package/dist/chunks/{chunk-E3OQSNF5.js → chunk-R6GGDZ2C.js} +1 -1
- package/dist/chunks/{chunk-6AW5LW4T.js → chunk-RU7ZZQQQ.js} +4 -4
- package/dist/chunks/{chunk-D6SWOUUP.js → chunk-TXXO4TJT.js} +2 -2
- package/dist/chunks/{chunk-JDZOYHAL.js → chunk-XARLZK6C.js} +1 -1
- package/dist/chunks/{conflict-76ZUL3E7.js → conflict-DYCSX7CN.js} +2 -2
- package/dist/chunks/{contract-INMS7SYQ.js → contract-N5WNHKHI.js} +94 -30
- package/dist/chunks/{create-flow-7WGKLRHH.js → create-flow-PABAGCK2.js} +6 -6
- package/dist/chunks/{entry-mode-3UMMMK6Z.js → entry-mode-C2WPJQJM.js} +3 -3
- package/dist/chunks/{env-7EGXNZR2.js → env-SEEXUXZF.js} +2 -2
- package/dist/chunks/{factory-BDERKTYX.js → factory-WNLDOLJZ.js} +1 -1
- package/dist/chunks/{group-chat-4E7EZMTJ.js → group-chat-DOS4XWUN.js} +3 -3
- package/dist/chunks/{invoice-MOGNB6HN.js → invoice-SMODTN2D.js} +7 -2
- package/dist/chunks/{lazy-dispatch-4WOIL3ZQ.js → lazy-dispatch-K25LTKQY.js} +2 -2
- package/dist/chunks/{meeting-2FMYZXG5.js → meeting-2IWXP5IL.js} +11 -11
- package/dist/chunks/{minute-doc-3DHMYMBE.js → minute-doc-N4OR5OLP.js} +2 -2
- package/dist/chunks/{registry-6UGQO35C.js → registry-ABKBGGGK.js} +2 -2
- package/dist/chunks/{registry-XXFMYPBM.js → registry-XOUVCSV4.js} +11 -11
- package/dist/chunks/{room-recommend-7LD2OHL5.js → room-recommend-TWIEVY44.js} +4 -4
- package/dist/chunks/{schedule-ZAYMZKTQ.js → schedule-XZ4UUX4E.js} +4 -4
- package/dist/chunks/{smart-extract-FOBSVNYW.js → smart-extract-DEBLJPCQ.js} +11 -11
- package/dist/chunks/{workflow-NYJJIT3D.js → workflow-D7LBN5MZ.js} +2 -2
- package/dist/cmd/refs/index.js +24 -23
- package/dist/core/output.js +134 -41
- package/dist/index.js +8 -8
- package/dist/shortcuts/contract/manifest.js +11 -4
- package/dist/shortcuts/contract/operations/first-screen.js +41 -19
- package/dist/shortcuts/contract/operations/flow.js +2 -0
- package/dist/shortcuts/contract/operations/ledger.js +58 -8
- package/dist/shortcuts/contract/operations/quote-recognize.js +31 -9
- package/dist/shortcuts/contract/operations/quote-submit.js +4 -1
- package/dist/shortcuts/contract/operations/upload.js +21 -1
- package/dist/shortcuts/contract/upload-cache.js +2 -2
- package/dist/shortcuts/invoice/manifest.js +1 -1
- package/dist/shortcuts/invoice/operations/get.js +2 -0
- package/dist/shortcuts/invoice/operations/shared.js +2 -0
- package/dist/shortcuts/invoice/projection.js +4 -1
- package/dist/shortcuts/smart-extract/operations/fill.js +14 -14
- package/dist/shortcuts/workflow/endpoints.js +2 -0
- package/dist/shortcuts/workflow/index.js +2 -2
- package/dist/shortcuts/workflow/operations/aiDeepRead/collect.js +1735 -0
- package/dist/shortcuts/workflow/operations/aiDeepRead/render.js +562 -0
- package/dist/shortcuts/workflow/operations/deepRead.js +447 -0
- package/dist/shortcuts/workflow/operations/form.js +28 -4
- package/dist/shortcuts/workflow/operations/read.js +18 -4
- package/dist/shortcuts/workflow/operations/registry.js +4 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.collect.js +9 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.core.js +3 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.js +5 -0
- package/docs/agent-io-channel-design.md +21 -10
- package/docs/invoice.md +2 -0
- package/docs/smart-extract.md +1 -1
- package/docs/todo-smart-convert/data-contract.md +1 -1
- package/package.json +1 -1
- package/scripts/package-skill.mjs +13 -2
- package/skills/weaver-e10-jinchengda/SKILL.md +67 -31
- package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +18 -18
- package/skills/weaver-e10-jinchengda/references/contract-clause-insert.md +4 -4
- package/skills/weaver-e10-jinchengda/references/contract-clause-library-crud.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-command-index.md +2 -2
- package/skills/weaver-e10-jinchengda/references/contract-compare-report.md +6 -6
- package/skills/weaver-e10-jinchengda/references/contract-credit-page.md +3 -3
- package/skills/weaver-e10-jinchengda/references/contract-disabled-capabilities.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-doc-compare.md +6 -6
- package/skills/weaver-e10-jinchengda/references/contract-doc-triage.md +7 -7
- package/skills/weaver-e10-jinchengda/references/contract-element-save-record.md +9 -9
- package/skills/weaver-e10-jinchengda/references/contract-execution-rules.md +3 -3
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-new-customer.md +11 -11
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +18 -18
- package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +4 -4
- package/skills/weaver-e10-jinchengda/references/contract-ledger-catalog.md +18 -15
- package/skills/weaver-e10-jinchengda/references/contract-ledger-query-playbook.md +51 -28
- package/skills/weaver-e10-jinchengda/references/contract-ledger-rules.md +6 -6
- package/skills/weaver-e10-jinchengda/references/contract-modeltext-library.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-multi-file.md +20 -9
- package/skills/weaver-e10-jinchengda/references/contract-object-detect.md +18 -18
- package/skills/weaver-e10-jinchengda/references/contract-open-web-pages.md +9 -9
- package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +4 -4
- package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +42 -30
- package/skills/weaver-e10-jinchengda/references/contract-template-recommend.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-type-fingerprints.md +8 -8
- package/skills/weaver-e10-jinchengda/references/contract-workflow-discovery.md +1 -1
- package/skills/weaver-e10-jinchengda/references/orchestration.md +2 -2
- package/skills/weaver-e10-jucailin/references/recruit-interview-overview.md +1 -1
- package/skills/weaver-e10-shared/references/json-output-contract.md +4 -3
- package/skills/weaver-e10-smart-extract/SKILL.md +1 -1
- package/skills/weaver-e10-workflow/SKILL.md +15 -3
- package/skills/weaver-e10-workflow/aiDeepRead/config.json +151 -0
- package/skills/weaver-e10-workflow/aiDeepRead/templates//345/215/225/345/215/241/347/211/207-demo.html +64 -0
- package/skills/weaver-e10-workflow/aiDeepRead/templates//346/261/207/346/200/273/345/256/241/346/211/271-demo.html +310 -0
- package/skills/weaver-e10-workflow/references/todo-smart-convert.md +4 -2
- package/skills/weaver-e10-workflow/references/workflow-deep-read.md +201 -0
- package/skills/weaver-e10-workflow/tools/ai-deep-read.cjs +80 -0
- package/skills/weaver-e10-workflow/tools/todo-summary.cjs +80 -6
- package/skills/weaver-e10-yepiaotong/SKILL.md +30 -2
- package/skills/weaver-e10-yepiaotong/references/invoice-detail.md +2 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-enterprise-list.md +2 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-output-view.md +1 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-personal-list.md +2 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +4 -4
- package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +16 -2
- package/skills/weaver-e10-yepiaotong/references/reim-examples.md +44 -9
- package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +3 -1
- package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +16 -2
- package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +61 -2
|
@@ -0,0 +1,562 @@
|
|
|
1
|
+
// E10 工作流「AI 详读」第三阶段渲染 operation —— workflow.aiDeepReadRender(2026-11-18 用户定稿)。
|
|
2
|
+
//
|
|
3
|
+
// 背景:实测 3 条数据端到端 2 分 30 秒,其中 agent 手写 HTML 约 30s(复制模板+逐段替换),
|
|
4
|
+
// 是除模型推理外最大的可优化项。定稿口径:**HTML 生成移到 CLI**——agent 只产出结构化结论,
|
|
5
|
+
// CLI 按 skill 模板机械替换生成 HTML(秒级、样式永不走样、agent 无需读模板全文)。
|
|
6
|
+
//
|
|
7
|
+
// 分工:
|
|
8
|
+
// - collect(workflow.aiDeepRead):取数 + 清洗 + grouping,落主缓存(grouping 随缓存持久化);
|
|
9
|
+
// - AI 详读(agent):读批次文件,产出每条的两段结论(详情结论/意见结论,2026-11-18 二次定稿:摘要段取消,结论承载全部细节)
|
|
10
|
+
// 与 ai 模式字段的归类结果(aiAssignments);
|
|
11
|
+
// - render(本 operation):读主缓存 + agent 结论 JSON,按模板生成自包含 HTML。
|
|
12
|
+
//
|
|
13
|
+
// 模板规则(沿用 2026-11-18 定稿口径):
|
|
14
|
+
// - 数据同源铁律:筛选条 chip 计数与卡片 data-buckets 全部来自主缓存里持久化的 grouping
|
|
15
|
+
// (ai 字段由本次入参 aiAssignments 补全归类后重算 counts),禁止手写/猜测;
|
|
16
|
+
// - 计数为 0 的桶不渲染 chip(某字段全部桶为 0 时整行不渲染;grouping 未命中不加筛选条);
|
|
17
|
+
// - 分类条(2026-11-23 用户定稿;2026-11-24 布局定稿:每类筛选条件独立成行——分类名 + 本类
|
|
18
|
+
// chip 包在 filter-row 里,filter-bar 纵向排布各行,行内流式换行):「工作流」行仅数据含多个 workflowName 时渲染;
|
|
19
|
+
// 「数据维度」行固定渲染(条目来自 config dataDimension.entries,isremark 未命中归
|
|
20
|
+
// 「其他」);每行带「全部」chip(默认选中=不过滤)。多工作流时主题分类(grouping)
|
|
21
|
+
// 初始隐藏、选中指定工作流才联动显示,计数随当前工作流+维度筛选动态重算(模板 JS);
|
|
22
|
+
// - 卡片分组数据写 ASCII 属性 data-buckets 的 JSON(禁止中文属性名,dataset 不解析);
|
|
23
|
+
// - 多选 toggle(点击卡片)、底部提交面板等交互 JS 由模板自带;**布局固定一行一列,
|
|
24
|
+
// 右上角「一行两列/一行一列」切换与「全选/全部取消」已移除(2026-11-23 用户定稿)**;
|
|
25
|
+
// - 卡片 meta 区(2026-11-23 用户定稿)**只保留:发起人 / 发起时间 / 已停留 / 当前节点**
|
|
26
|
+
// (网格最多两列),接收时间/状态/重要程度不再渲染;agent 传的 metaExtra(如「最晚解决」)
|
|
27
|
+
// 属上下文补充信息,继续追加在网格尾部;
|
|
28
|
+
// - 阶段耗时只在对话中输出,HTML 产物不再渲染耗时面板(2026-11-19 定稿);0 计数桶规则同样适用于 ai 字段的类目。
|
|
29
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs';
|
|
30
|
+
import { dirname, join } from 'node:path';
|
|
31
|
+
import { workflowSuccess, schemaOf } from '../types.js';
|
|
32
|
+
import { workflowValidationError } from '../../errors.js';
|
|
33
|
+
import { asString } from '../shared.js';
|
|
34
|
+
import { resolveSkillDir } from '../todoSmartConvert/summaryCache.js';
|
|
35
|
+
import { normalizeDataDimension, dimensionKeyOf } from './collect.js';
|
|
36
|
+
// ---------------------------------------------------------------------------
|
|
37
|
+
// HTML 组装
|
|
38
|
+
// ---------------------------------------------------------------------------
|
|
39
|
+
function escapeHtml(s) {
|
|
40
|
+
return String(s ?? '')
|
|
41
|
+
.replace(/&/g, '&')
|
|
42
|
+
.replace(/</g, '<')
|
|
43
|
+
.replace(/>/g, '>')
|
|
44
|
+
.replace(/"/g, '"');
|
|
45
|
+
}
|
|
46
|
+
export function renderFilterBarHtml(grouping, fieldsState, categories = [], multiWf = false) {
|
|
47
|
+
const catRowsHtml = [];
|
|
48
|
+
for (const row of categories) {
|
|
49
|
+
const chips = [
|
|
50
|
+
` <button class="chip active" data-cat="${escapeHtml(row.cat)}" data-value="__all__" onclick="toggleCategory(this)">全部<span class="cnt">${row.totalCount}</span></button>`,
|
|
51
|
+
...row.chips
|
|
52
|
+
.filter((c) => c.count > 0)
|
|
53
|
+
.map((c) => ` <button class="chip" data-cat="${escapeHtml(row.cat)}" data-value="${escapeHtml(c.label)}" onclick="toggleCategory(this)">${escapeHtml(c.label)}<span class="cnt">${c.count}</span></button>`),
|
|
54
|
+
];
|
|
55
|
+
// 每类筛选条件独立成行(2026-11-24 用户定稿):分类名 + 本类 chip 包在 filter-row 里,
|
|
56
|
+
// filter-bar 纵向排布各行,行内横向流式换行。
|
|
57
|
+
catRowsHtml.push(` <div class="filter-row">\n <span class="filter-field">${escapeHtml(row.label)}</span>\n${chips.join('\n')}\n </div>`);
|
|
58
|
+
}
|
|
59
|
+
const rowsHtml = [];
|
|
60
|
+
for (const f of fieldsState) {
|
|
61
|
+
const chips = f.buckets
|
|
62
|
+
.map((b) => ({ label: b, count: f.counts[b] ?? 0 }))
|
|
63
|
+
.filter((c) => c.count > 0);
|
|
64
|
+
if (chips.length === 0)
|
|
65
|
+
continue;
|
|
66
|
+
const chipsHtml = chips
|
|
67
|
+
.map((c) => ` <button class="chip" data-field="${escapeHtml(f.field)}" data-bucket="${escapeHtml(c.label)}" onclick="toggleChip(this)">${escapeHtml(c.label)}<span class="cnt">${c.count}</span></button>`)
|
|
68
|
+
.join('\n');
|
|
69
|
+
rowsHtml.push(` <div class="filter-row">\n <span class="filter-field">${escapeHtml(f.field)}</span>\n${chipsHtml}\n </div>`);
|
|
70
|
+
}
|
|
71
|
+
// 主题分组(2026-11-23 用户定稿):多工作流时初始隐藏(选中指定工作流才联动显示),
|
|
72
|
+
// data-multi-wf="1" 供模板 JS 判定;单工作流时直接可见。
|
|
73
|
+
const topicGroup = rowsHtml.length > 0
|
|
74
|
+
? ` <div class="topic-group" id="topicGroup"${multiWf ? ' data-multi-wf="1" style="display:none"' : ''}>\n${rowsHtml.join('\n')}\n </div>`
|
|
75
|
+
: '';
|
|
76
|
+
if (catRowsHtml.length === 0 && !topicGroup)
|
|
77
|
+
return '';
|
|
78
|
+
return ` <div class="filter-bar" id="filterBar">
|
|
79
|
+
${[...catRowsHtml, topicGroup].filter(Boolean).join('\n')}
|
|
80
|
+
<button class="filter-clear" onclick="clearFilters()">清除筛选</button>
|
|
81
|
+
</div>
|
|
82
|
+
<div class="no-match" id="noMatch">当前筛选条件下没有卡片</div>`;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* 停留时长文案(当前时间 - 接收时间,2026-11-18 用户定稿):
|
|
86
|
+
* <1 小时 → 「N 分钟」;<24 小时 → 「N 小时」;≥24 小时 → 「N 天 M 小时」(M=0 省略)。
|
|
87
|
+
* 接收时间缺失或无法解析返回 undefined(不渲染该格)。
|
|
88
|
+
*/
|
|
89
|
+
export function stayDurationText(receivedTime, now = new Date()) {
|
|
90
|
+
const raw = String(receivedTime ?? '').trim();
|
|
91
|
+
if (!raw)
|
|
92
|
+
return undefined;
|
|
93
|
+
const start = new Date(raw.includes('T') ? raw : raw.replace(' ', 'T'));
|
|
94
|
+
if (isNaN(start.getTime()))
|
|
95
|
+
return undefined;
|
|
96
|
+
const diffMs = Math.max(0, now.getTime() - start.getTime());
|
|
97
|
+
const minutes = Math.floor(diffMs / 60000);
|
|
98
|
+
if (minutes < 60)
|
|
99
|
+
return `${minutes} 分钟`;
|
|
100
|
+
const hours = Math.floor(minutes / 60);
|
|
101
|
+
if (hours < 24)
|
|
102
|
+
return `${hours} 小时`;
|
|
103
|
+
const days = Math.floor(hours / 24);
|
|
104
|
+
const restHours = hours % 24;
|
|
105
|
+
return restHours > 0 ? `${days} 天 ${restHours} 小时` : `${days} 天`;
|
|
106
|
+
}
|
|
107
|
+
function summaryLogLine(detail) {
|
|
108
|
+
const items = Array.isArray(detail?.requestLog?.items) ? detail.requestLog.items : [];
|
|
109
|
+
if (items.length === 0)
|
|
110
|
+
return '无签字意见';
|
|
111
|
+
const first = items[0] ?? {};
|
|
112
|
+
const who = String(first.commentor?.username ?? first.username ?? '').trim();
|
|
113
|
+
const time = String(first.addTime ?? '').trim();
|
|
114
|
+
const action = String(first.commentName ?? '').trim();
|
|
115
|
+
const text = String(first.machiningRemark ?? '').trim();
|
|
116
|
+
const head = [who, time, action].filter(Boolean).join(' ');
|
|
117
|
+
return `${items.length} 条签字意见:${head}${text ? `「${text}」` : ''}`.trim();
|
|
118
|
+
}
|
|
119
|
+
function buildCardHtml(card, con, buckets, logLine, hasFilterBar) {
|
|
120
|
+
const badgeMark = card.requestMark ? ` <span class="badge">编号 ${escapeHtml(card.requestMark)}</span>` : '';
|
|
121
|
+
const badgeWarn = con?.titleBadge ? `<span class="badge warn">${escapeHtml(con.titleBadge)}</span>` : '';
|
|
122
|
+
// meta 区字段收敛(2026-11-23 用户定稿):只保留 发起人/发起时间/已停留/当前节点(网格最多两列),
|
|
123
|
+
// 接收时间/状态/重要程度不再渲染;metaExtra 为 agent 上下文补充(如「最晚解决」),继续追加。
|
|
124
|
+
const meta = [
|
|
125
|
+
{ label: '发起人', value: card.creatorName },
|
|
126
|
+
{ label: '发起时间', value: card.createdAt },
|
|
127
|
+
{ label: '已停留', value: stayDurationText(card.receivedTime) },
|
|
128
|
+
{ label: '当前节点', value: card.currentNode },
|
|
129
|
+
...(con?.metaExtra ?? []),
|
|
130
|
+
].filter((m) => m.value !== undefined && m.value !== null && String(m.value).trim() !== '');
|
|
131
|
+
const metaHtml = meta.map((m) => ` <span><span class="label">${escapeHtml(m.label)}</span>${escapeHtml(String(m.value))}</span>`).join('\n');
|
|
132
|
+
const bucketsAttr = hasFilterBar && Object.keys(buckets).length > 0
|
|
133
|
+
? ` data-buckets='${escapeHtml(JSON.stringify(buckets))}'`
|
|
134
|
+
: '';
|
|
135
|
+
const miss = (s) => (s && String(s).trim() !== '' ? escapeHtml(String(s).trim()) : '(该条未详读,结论缺失)');
|
|
136
|
+
return ` <div class="card" data-requestid="${escapeHtml(card.requestId)}"${bucketsAttr} onclick="toggleCard(this)">
|
|
137
|
+
<div class="card-title"><span class="card-check"></span>${miss(card.title)}${badgeMark}${badgeWarn}</div>
|
|
138
|
+
<div class="meta-grid">
|
|
139
|
+
${metaHtml}
|
|
140
|
+
</div>
|
|
141
|
+
<div class="section-title">详情摘要</div>
|
|
142
|
+
<div class="conclusion-bar">${miss(con?.detailConclusion)}</div>
|
|
143
|
+
<div class="section-title">意见摘要</div>
|
|
144
|
+
<div class="conclusion-bar">${miss(con?.opinionConclusion)}</div>
|
|
145
|
+
<div class="log-count">${escapeHtml(logLine ?? '无签字意见')}</div>
|
|
146
|
+
</div>`;
|
|
147
|
+
}
|
|
148
|
+
/** 单卡片(byRequest)正文:标题+元信息+两段结论+意见输入框(无时间线区块,2026-11-18 定稿)。
|
|
149
|
+
* meta 字段与汇总审批卡片同口径(2026-11-23 用户定稿:发起人/发起时间/已停留/当前节点 + metaExtra)。 */
|
|
150
|
+
function buildSingleCardInner(card, con) {
|
|
151
|
+
const meta = [
|
|
152
|
+
{ label: '发起人', value: card.creatorName },
|
|
153
|
+
{ label: '发起时间', value: card.createdAt },
|
|
154
|
+
{ label: '已停留', value: stayDurationText(card.receivedTime) },
|
|
155
|
+
{ label: '当前节点', value: card.currentNode },
|
|
156
|
+
...(con?.metaExtra ?? []),
|
|
157
|
+
].filter((m) => m.value !== undefined && m.value !== null && String(m.value).trim() !== '');
|
|
158
|
+
const metaHtml = meta.map((m) => ` <span><span class="label">${escapeHtml(m.label)}</span>${escapeHtml(String(m.value))}</span>`).join('\n');
|
|
159
|
+
const rid = escapeHtml(card.requestId);
|
|
160
|
+
const miss = (s) => (s && String(s).trim() !== '' ? escapeHtml(String(s).trim()) : '(该条未详读,结论缺失)');
|
|
161
|
+
return ` <div class="card-title">${miss(card.title)}</div>
|
|
162
|
+
<div class="meta-grid">
|
|
163
|
+
${metaHtml}
|
|
164
|
+
</div>
|
|
165
|
+
|
|
166
|
+
<div class="section-title">详情摘要</div>
|
|
167
|
+
<div class="conclusion-bar">${miss(con?.detailConclusion)}</div>
|
|
168
|
+
|
|
169
|
+
<div class="section-title">意见摘要</div>
|
|
170
|
+
<div class="conclusion-bar">${miss(con?.opinionConclusion)}</div>
|
|
171
|
+
|
|
172
|
+
<textarea class="op-textarea" placeholder="填写意见"></textarea>
|
|
173
|
+
<div class="op-buttons">
|
|
174
|
+
<button class="btn" onclick="alert('退回(演示):requestId=${rid}')">退回</button>
|
|
175
|
+
<button class="btn primary" onclick="alert('批准(演示):requestId=${rid}')">批准</button>
|
|
176
|
+
</div>`;
|
|
177
|
+
}
|
|
178
|
+
/** grouping(含 ai 归类合并后)→ 渲染用字段状态(桶顺序 + 重算计数)。 */
|
|
179
|
+
export function mergedFieldState(grouping, aiAssignments) {
|
|
180
|
+
const aiByField = new Map();
|
|
181
|
+
for (const a of Array.isArray(aiAssignments) ? aiAssignments : []) {
|
|
182
|
+
if (!a || !a.requestId || !a.field || !a.bucket)
|
|
183
|
+
continue;
|
|
184
|
+
if (!aiByField.has(a.field))
|
|
185
|
+
aiByField.set(a.field, new Map());
|
|
186
|
+
aiByField.get(a.field).set(String(a.requestId), String(a.bucket));
|
|
187
|
+
}
|
|
188
|
+
return grouping.fields.map((f) => {
|
|
189
|
+
if (f.mode === 'rule') {
|
|
190
|
+
const counts = {};
|
|
191
|
+
for (const b of f.buckets)
|
|
192
|
+
counts[b] = 0;
|
|
193
|
+
for (const a of f.assignment)
|
|
194
|
+
counts[a.bucket] = (counts[a.bucket] ?? 0) + 1;
|
|
195
|
+
const byId = new Map(f.assignment.map((a) => [a.requestId, a.bucket]));
|
|
196
|
+
return { field: f.field, mode: 'rule', buckets: f.buckets, counts, bucketsOf: (rid) => byId.get(rid) };
|
|
197
|
+
}
|
|
198
|
+
// ai:合并 agent 归类(缺失的 requestId 不计入 counts,归类口径「其他」由 agent 显式给出)
|
|
199
|
+
const counts = {};
|
|
200
|
+
for (const c of [...f.categories, '其他'])
|
|
201
|
+
counts[c] = 0;
|
|
202
|
+
const byId = new Map();
|
|
203
|
+
for (const [rid, bucket] of aiByField.get(f.field) ?? []) {
|
|
204
|
+
byId.set(rid, bucket);
|
|
205
|
+
counts[bucket] = (counts[bucket] ?? 0) + 1;
|
|
206
|
+
}
|
|
207
|
+
const buckets = [...f.categories, ...(counts['其他'] > 0 ? ['其他'] : [])];
|
|
208
|
+
return { field: f.field, mode: 'ai', buckets, counts, bucketsOf: (rid) => byId.get(rid) };
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
function loadTemplate(mode) {
|
|
212
|
+
const skillDir = resolveSkillDir();
|
|
213
|
+
if (!skillDir) {
|
|
214
|
+
throw workflowValidationError('deep_read_template_missing', '未解析到 skill 目录:无法读取 aiDeepRead/templates/ 模板(必须经 tools/ai-deep-read.cjs 调用)。');
|
|
215
|
+
}
|
|
216
|
+
// byTodo(全局汇总审批,2026-11-23)与 byWorkflow 同用「汇总审批」卡片平铺模板。
|
|
217
|
+
const templateFile = join(skillDir, 'aiDeepRead', 'templates', mode === 'byRequest' ? '单卡片-demo.html' : '汇总审批-demo.html');
|
|
218
|
+
if (!existsSync(templateFile)) {
|
|
219
|
+
throw workflowValidationError('deep_read_template_missing', `模板缺失:${templateFile}`);
|
|
220
|
+
}
|
|
221
|
+
return { html: readFileSync(templateFile, 'utf-8'), templateFile };
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* 读取 config fetch.workflowNames(2026-11-24 用户定稿):汇总审批 HTML 副标题展示
|
|
225
|
+
* 真实工作流名名单(替代字面「fetch.workflowNames」)。未配置 / 解析失败返回空数组
|
|
226
|
+
* (副标题回落字面「fetch.workflowNames」)。读取失败静默——不影响渲染主流程。
|
|
227
|
+
*/
|
|
228
|
+
function loadFetchWorkflowNames() {
|
|
229
|
+
try {
|
|
230
|
+
const skillDir = resolveSkillDir();
|
|
231
|
+
if (!skillDir)
|
|
232
|
+
return [];
|
|
233
|
+
const configFile = join(skillDir, 'aiDeepRead', 'config.json');
|
|
234
|
+
if (!existsSync(configFile))
|
|
235
|
+
return [];
|
|
236
|
+
const parsed = JSON.parse(readFileSync(configFile, 'utf-8'));
|
|
237
|
+
const names = parsed?.fetch?.workflowNames;
|
|
238
|
+
return Array.isArray(names)
|
|
239
|
+
? names.map((v) => String(v).trim()).filter(Boolean)
|
|
240
|
+
: [];
|
|
241
|
+
}
|
|
242
|
+
catch {
|
|
243
|
+
return [];
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* 渲染成功后清理 collect 中转文件(2026-11-19 用户定稿:temp 目录用后即删)。
|
|
248
|
+
* 从 cacheFile 文件名提取 stamp(aiDeepRead-collect-<stamp>.json),删除同 stamp 的
|
|
249
|
+
* 主缓存与全部批次文件(aiDeepRead-batch-<stamp>-NN.json);同目录其他任务文件不动。
|
|
250
|
+
* 删除失败仅记录、不抛错——不影响 HTML 已交付的事实。
|
|
251
|
+
*/
|
|
252
|
+
export function cleanupTempArtifacts(cacheFile) {
|
|
253
|
+
const removed = [];
|
|
254
|
+
try {
|
|
255
|
+
const base = cacheFile.split('/').pop() ?? '';
|
|
256
|
+
const m = base.match(/^aiDeepRead-collect-(\d{14})\.json$/);
|
|
257
|
+
if (!m)
|
|
258
|
+
return removed;
|
|
259
|
+
const stamp = m[1];
|
|
260
|
+
const dir = dirname(cacheFile);
|
|
261
|
+
for (const name of readdirSync(dir)) {
|
|
262
|
+
if (name === `aiDeepRead-collect-${stamp}.json` || name.match(new RegExp(`^aiDeepRead-batch-${stamp}-\\d{2}\\.json$`))) {
|
|
263
|
+
try {
|
|
264
|
+
rmSync(join(dir, name), { force: true });
|
|
265
|
+
removed.push(name);
|
|
266
|
+
}
|
|
267
|
+
catch {
|
|
268
|
+
// 单个文件删除失败:跳过,不拖垮整体
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
catch {
|
|
274
|
+
// 目录读取失败:忽略
|
|
275
|
+
}
|
|
276
|
+
return removed;
|
|
277
|
+
}
|
|
278
|
+
/** 汇总审批版渲染:替换 sub / 筛选条注释块 / 卡片列表。 */
|
|
279
|
+
export function renderSummaryHtml(templateHtml, opts) {
|
|
280
|
+
let html = templateHtml;
|
|
281
|
+
// 1) title 与 sub
|
|
282
|
+
html = html.replace(/<title>[\s\S]*?<\/title>/, `<title>汇总审批</title>`);
|
|
283
|
+
html = html.replace(/<div class="sub">[\s\S]*?<\/div>/, `<div class="sub">${escapeHtml(opts.subtitle)}</div>`);
|
|
284
|
+
// 2) 筛选条注释块(从注释起到收尾 --> 为止)整体替换
|
|
285
|
+
const filterStart = html.indexOf('<!-- ======== 顶部筛选条');
|
|
286
|
+
const filterEndMarker = '-->';
|
|
287
|
+
if (filterStart >= 0) {
|
|
288
|
+
const filterEnd = html.indexOf(filterEndMarker, filterStart);
|
|
289
|
+
if (filterEnd >= 0) {
|
|
290
|
+
html = html.slice(0, filterStart) + opts.filterBarHtml + html.slice(filterEnd + filterEndMarker.length);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
// 3) 卡片列表:#cardList 开标签到「底部:提交」注释之间整体替换
|
|
294
|
+
// 开标签不带布局 class:布局固定一行一列(2026-11-23 用户定稿,模板 #cardList CSS
|
|
295
|
+
// 直接 grid-template-columns:1fr,切换控件已移除)
|
|
296
|
+
const listStart = html.search(/<div id="cardList"[^>]*>/);
|
|
297
|
+
const listEndAnchor = html.indexOf('<!-- ======== 底部:提交');
|
|
298
|
+
if (listStart >= 0 && listEndAnchor > listStart) {
|
|
299
|
+
html = html.slice(0, listStart) + '<div id="cardList">\n' + opts.cardsHtml + '\n </div>\n\n ' + html.slice(listEndAnchor);
|
|
300
|
+
}
|
|
301
|
+
return html;
|
|
302
|
+
}
|
|
303
|
+
/** 单卡片版渲染:head 保留(title 替换),body 整体重建。 */
|
|
304
|
+
export function renderSingleHtml(templateHtml, opts) {
|
|
305
|
+
let html = templateHtml;
|
|
306
|
+
html = html.replace(/<title>[\s\S]*?<\/title>/, `<title>ai详读 · ${escapeHtml(opts.title)}</title>`);
|
|
307
|
+
const bodyStart = html.indexOf('<body>');
|
|
308
|
+
const head = html.slice(0, bodyStart + '<body>'.length);
|
|
309
|
+
return `${head}
|
|
310
|
+
<div class="page">
|
|
311
|
+
<div class="card">
|
|
312
|
+
${opts.cardInner}
|
|
313
|
+
</div>
|
|
314
|
+
</div>
|
|
315
|
+
</body>
|
|
316
|
+
</html>
|
|
317
|
+
`;
|
|
318
|
+
}
|
|
319
|
+
// ---------------------------------------------------------------------------
|
|
320
|
+
// operation 定义
|
|
321
|
+
// ---------------------------------------------------------------------------
|
|
322
|
+
export function workflowDeepReadRenderOperations() {
|
|
323
|
+
return [
|
|
324
|
+
{
|
|
325
|
+
name: 'workflow.aiDeepReadRender',
|
|
326
|
+
resource: 'workflow',
|
|
327
|
+
method: 'aiDeepReadRender',
|
|
328
|
+
action: 'workflow.aiDeepReadRender',
|
|
329
|
+
summary: 'AI 详读第三阶段渲染(CLI 机械生成 HTML):输入 collect 主缓存路径 + agent 两段结论(每条 详情结论/意见结论,2026-11-18 二次定稿)+ ai 分组归类 + 阶段耗时行,按 skill 模板生成自包含 HTML。筛选条计数与卡片分桶同源于缓存中的 grouping,0 计数桶不渲染',
|
|
330
|
+
capability: 'view',
|
|
331
|
+
risk: 'read',
|
|
332
|
+
inputSchema: schemaOf({
|
|
333
|
+
cacheFile: {
|
|
334
|
+
type: 'string',
|
|
335
|
+
minLength: 1,
|
|
336
|
+
description: 'collect 主缓存文件绝对路径(workflow.aiDeepRead envelope 的 data.collect.cacheFile)。',
|
|
337
|
+
},
|
|
338
|
+
conclusions: {
|
|
339
|
+
type: 'array',
|
|
340
|
+
description: 'agent 详读产出的每条结论(两段必填:detailConclusion/opinionConclusion,结论详细、字数多;detailSummary/opinionSummary 已废弃可选)。',
|
|
341
|
+
items: {
|
|
342
|
+
type: 'object',
|
|
343
|
+
properties: {
|
|
344
|
+
requestId: { type: 'string' },
|
|
345
|
+
detailSummary: { type: 'string' },
|
|
346
|
+
detailConclusion: { type: 'string' },
|
|
347
|
+
opinionSummary: { type: 'string' },
|
|
348
|
+
opinionConclusion: { type: 'string' },
|
|
349
|
+
titleBadge: { type: 'string', description: '可选标题警示徽标(如 明天到期)' },
|
|
350
|
+
metaExtra: {
|
|
351
|
+
type: 'array',
|
|
352
|
+
items: { type: 'object', properties: { label: { type: 'string' }, value: { type: 'string' } }, required: ['label', 'value'] },
|
|
353
|
+
},
|
|
354
|
+
},
|
|
355
|
+
required: ['requestId', 'detailConclusion', 'opinionConclusion'],
|
|
356
|
+
},
|
|
357
|
+
},
|
|
358
|
+
aiAssignments: {
|
|
359
|
+
type: 'array',
|
|
360
|
+
description: 'grouping ai 模式字段的归类结果(grouping 命中且存在 ai 字段时必传)。',
|
|
361
|
+
items: {
|
|
362
|
+
type: 'object',
|
|
363
|
+
properties: {
|
|
364
|
+
requestId: { type: 'string' },
|
|
365
|
+
field: { type: 'string' },
|
|
366
|
+
bucket: { type: 'string' },
|
|
367
|
+
},
|
|
368
|
+
required: ['requestId', 'field', 'bucket'],
|
|
369
|
+
},
|
|
370
|
+
},
|
|
371
|
+
timingRows: {
|
|
372
|
+
type: 'array',
|
|
373
|
+
description: '阶段耗时表行(2026-11-19 定稿:仅供对话侧「阶段耗时」一节统计,HTML 产物不再渲染耗时面板;含 任务总耗时(墙钟)与 未归集 两行)。',
|
|
374
|
+
items: {
|
|
375
|
+
type: 'object',
|
|
376
|
+
properties: {
|
|
377
|
+
stage: { type: 'string' },
|
|
378
|
+
desc: { type: 'string' },
|
|
379
|
+
ms: { type: 'number' },
|
|
380
|
+
text: { type: 'string' },
|
|
381
|
+
highlight: { type: 'boolean' },
|
|
382
|
+
},
|
|
383
|
+
required: ['stage'],
|
|
384
|
+
},
|
|
385
|
+
},
|
|
386
|
+
outputFile: {
|
|
387
|
+
type: 'string',
|
|
388
|
+
minLength: 1,
|
|
389
|
+
description: '输出 HTML 绝对路径(可选;默认写到主缓存同目录 aiDeepRead-render-<时间戳>.html)。',
|
|
390
|
+
},
|
|
391
|
+
}, { required: ['cacheFile'] }),
|
|
392
|
+
handler: async (args, _env) => {
|
|
393
|
+
const started = Date.now();
|
|
394
|
+
const cacheFile = asString(args.cacheFile)?.trim();
|
|
395
|
+
if (!cacheFile) {
|
|
396
|
+
throw workflowValidationError('deep_read_render_input_missing', 'cacheFile 必传:collect 主缓存的绝对路径(envelope data.collect.cacheFile)。');
|
|
397
|
+
}
|
|
398
|
+
if (!existsSync(cacheFile)) {
|
|
399
|
+
throw workflowValidationError('deep_read_render_cache_missing', `主缓存不存在:${cacheFile}(先执行 workflow.aiDeepRead collect)`);
|
|
400
|
+
}
|
|
401
|
+
let cache;
|
|
402
|
+
try {
|
|
403
|
+
cache = JSON.parse(readFileSync(cacheFile, 'utf-8'));
|
|
404
|
+
}
|
|
405
|
+
catch (e) {
|
|
406
|
+
throw workflowValidationError('deep_read_render_cache_invalid', `主缓存不是合法 JSON:${cacheFile}(${e?.message ?? e})`);
|
|
407
|
+
}
|
|
408
|
+
const mode = cache.mode === 'byRequest'
|
|
409
|
+
? 'byRequest'
|
|
410
|
+
: cache.mode === 'byTodo' ? 'byTodo' : 'byWorkflow';
|
|
411
|
+
const rows = Array.isArray(cache.rows) ? cache.rows : [];
|
|
412
|
+
const detailById = new Map();
|
|
413
|
+
for (const d of Array.isArray(cache.details) ? cache.details : []) {
|
|
414
|
+
if (d?.requestId)
|
|
415
|
+
detailById.set(String(d.requestId), d.detail ?? {});
|
|
416
|
+
}
|
|
417
|
+
const grouping = cache.grouping ?? { matched: false, fields: [] };
|
|
418
|
+
const warnings = [];
|
|
419
|
+
const conclusions = Array.isArray(args.conclusions) ? args.conclusions : [];
|
|
420
|
+
const conByRid = new Map();
|
|
421
|
+
for (const c of conclusions) {
|
|
422
|
+
if (!c?.requestId) {
|
|
423
|
+
warnings.push('conclusions 中有一条缺少 requestId,已忽略');
|
|
424
|
+
continue;
|
|
425
|
+
}
|
|
426
|
+
const rid = String(c.requestId);
|
|
427
|
+
conByRid.set(rid, c);
|
|
428
|
+
// 2026-11-19 修复:两段结论必填字段缺失/为空时显式告警(此前 schema required 但未强校验,静默降级成占位文案)
|
|
429
|
+
const missing = ['detailConclusion', 'opinionConclusion']
|
|
430
|
+
.filter((k) => !(typeof c[k] === 'string' && String(c[k]).trim() !== ''));
|
|
431
|
+
if (missing.length > 0) {
|
|
432
|
+
warnings.push(`requestId ${rid} 的结论缺字段:${missing.join('/')}——卡片会渲染「(该条未详读,结论缺失)」占位,需补详读后重新渲染`);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
for (const rid of conByRid.keys()) {
|
|
436
|
+
if (!detailById.has(rid))
|
|
437
|
+
warnings.push(`结论里的 requestId ${rid} 不在主缓存中,已忽略`);
|
|
438
|
+
}
|
|
439
|
+
const fieldsState = mergedFieldState(grouping, args.aiAssignments ?? []);
|
|
440
|
+
const hasFilterBar = fieldsState.some((f) => f.buckets.some((b) => (f.counts[b] ?? 0) > 0));
|
|
441
|
+
const cardSourceOf = (row) => {
|
|
442
|
+
const bi = detailById.get(String(row.requestId))?.basicInfo ?? {};
|
|
443
|
+
return {
|
|
444
|
+
requestId: String(row.requestId),
|
|
445
|
+
title: String(bi.requestTitle ?? row.requestNameTitle ?? '').trim() || String(row.requestId),
|
|
446
|
+
requestMark: String(bi.requestMark ?? '').trim() || undefined,
|
|
447
|
+
creatorName: String(bi.creatorName ?? row.createrName ?? '').trim() || undefined,
|
|
448
|
+
createdAt: String(bi.createdAt ?? '').trim() || undefined,
|
|
449
|
+
receivedTime: String(row.receivedTime ?? row.receiveDateTime ?? '').trim() || undefined,
|
|
450
|
+
currentNode: String(bi.currentNode ?? '').trim() || undefined,
|
|
451
|
+
flowStatus: String(bi.flowStatus ?? row.flowStatus ?? '').trim() || undefined,
|
|
452
|
+
requestLevel: String(bi.requestLevel ?? row.requestLevelShow ?? '').trim() || undefined,
|
|
453
|
+
};
|
|
454
|
+
};
|
|
455
|
+
const { html: templateHtml, templateFile } = loadTemplate(mode);
|
|
456
|
+
// timingRows 仅作为对话侧耗时统计口径入参保留,HTML 产物不再渲染耗时面板(2026-11-19 定稿)
|
|
457
|
+
const stamp = new Date().toISOString().replace(/[-:T]/g, '').slice(0, 14);
|
|
458
|
+
const outputFile = asString(args.outputFile)?.trim()
|
|
459
|
+
|| join(dirname(cacheFile), `aiDeepRead-render-${stamp}.html`);
|
|
460
|
+
let html;
|
|
461
|
+
let cardCount = 0;
|
|
462
|
+
if (mode === 'byRequest') {
|
|
463
|
+
const row = rows[0] ?? { requestId: [...detailById.keys()][0] ?? '' };
|
|
464
|
+
const card = cardSourceOf(row);
|
|
465
|
+
const con = conByRid.get(card.requestId);
|
|
466
|
+
html = renderSingleHtml(templateHtml, {
|
|
467
|
+
title: card.title,
|
|
468
|
+
cardInner: buildSingleCardInner(card, con),
|
|
469
|
+
});
|
|
470
|
+
cardCount = 1;
|
|
471
|
+
}
|
|
472
|
+
else {
|
|
473
|
+
// 分类条数据(2026-11-23 用户定稿):
|
|
474
|
+
// 工作流分类——rows 里 workflowName 去重 >1 个才渲染(计数=条数,按首现顺序);
|
|
475
|
+
// 数据维度分类——固定渲染,entries 来自 cache.dimensions(config dataDimension),
|
|
476
|
+
// 按 rows.isremark 归类,未命中任何条目 → 「其他」(计数 0 不渲染 chip)。
|
|
477
|
+
const dimEntries = normalizeDataDimension(cache.dimensions).entries;
|
|
478
|
+
const wfCountMap = new Map();
|
|
479
|
+
const dimCountMap = new Map();
|
|
480
|
+
for (const row of rows) {
|
|
481
|
+
const wfName = String(row.workflowName ?? '').trim();
|
|
482
|
+
if (wfName)
|
|
483
|
+
wfCountMap.set(wfName, (wfCountMap.get(wfName) ?? 0) + 1);
|
|
484
|
+
const dimKey = dimensionKeyOf(row.isremark, dimEntries);
|
|
485
|
+
dimCountMap.set(dimKey, (dimCountMap.get(dimKey) ?? 0) + 1);
|
|
486
|
+
}
|
|
487
|
+
const multiWf = wfCountMap.size > 1;
|
|
488
|
+
const categories = [];
|
|
489
|
+
if (multiWf) {
|
|
490
|
+
categories.push({
|
|
491
|
+
cat: 'wf',
|
|
492
|
+
label: '工作流',
|
|
493
|
+
chips: [...wfCountMap.entries()].map(([label, count]) => ({ label, count })),
|
|
494
|
+
totalCount: rows.length,
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
if (dimEntries.length > 0) {
|
|
498
|
+
const otherCount = dimCountMap.get('其他') ?? 0;
|
|
499
|
+
categories.push({
|
|
500
|
+
cat: 'dim',
|
|
501
|
+
label: '数据维度',
|
|
502
|
+
chips: [
|
|
503
|
+
...dimEntries.map((e) => ({ label: e.key, count: dimCountMap.get(e.key) ?? 0 })),
|
|
504
|
+
...(otherCount > 0 ? [{ label: '其他', count: otherCount }] : []),
|
|
505
|
+
],
|
|
506
|
+
totalCount: rows.length,
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
const hasCategoryBar = categories.length > 0;
|
|
510
|
+
const cardsHtml = rows.map((row) => {
|
|
511
|
+
const card = cardSourceOf(row);
|
|
512
|
+
const con = conByRid.get(card.requestId);
|
|
513
|
+
if (!con)
|
|
514
|
+
warnings.push(`requestId ${card.requestId} 无结论(详读缺失或批次跳过),卡片以占位文案渲染`);
|
|
515
|
+
const buckets = {};
|
|
516
|
+
for (const f of fieldsState) {
|
|
517
|
+
const b = f.bucketsOf(card.requestId);
|
|
518
|
+
if (b)
|
|
519
|
+
buckets[f.field] = b;
|
|
520
|
+
}
|
|
521
|
+
// 分类分桶(ASCII 键):__wf 仅多工作流时写入(单工作流不渲染工作流分类条);
|
|
522
|
+
// __dim 数据维度始终写入(维度条固定渲染)。
|
|
523
|
+
if (multiWf && String(row.workflowName ?? '').trim())
|
|
524
|
+
buckets.__wf = String(row.workflowName).trim();
|
|
525
|
+
if (dimEntries.length > 0)
|
|
526
|
+
buckets.__dim = dimensionKeyOf(row.isremark, dimEntries);
|
|
527
|
+
return buildCardHtml(card, con, buckets, summaryLogLine(detailById.get(card.requestId)), hasFilterBar || hasCategoryBar);
|
|
528
|
+
}).join('\n\n');
|
|
529
|
+
const filterBarHtml = renderFilterBarHtml(grouping, fieldsState, categories, multiWf);
|
|
530
|
+
// 副标题(2026-11-24 用户定稿):固定为数据统计范围说明,待办条数/排序/生成时间/
|
|
531
|
+
// 多选操作指引等其他信息一律不体现;workflowNames 展示 config 真实名单
|
|
532
|
+
// (2026-11-24 用户二次定稿:未配置时回落字面「fetch.workflowNames」)。
|
|
533
|
+
const wfNames = loadFetchWorkflowNames();
|
|
534
|
+
const scopeLabel = wfNames.length > 0 ? wfNames.join('、') : 'fetch.workflowNames';
|
|
535
|
+
const subtitle = `当前数据统计范围:${scopeLabel}下的数据,不包括:草稿、被退回及详情存在必填字段`;
|
|
536
|
+
html = renderSummaryHtml(templateHtml, { subtitle, cardsHtml, filterBarHtml });
|
|
537
|
+
cardCount = rows.length;
|
|
538
|
+
}
|
|
539
|
+
mkdirSync(dirname(outputFile), { recursive: true });
|
|
540
|
+
writeFileSync(outputFile, html, 'utf-8');
|
|
541
|
+
const bytes = Buffer.byteLength(html, 'utf-8');
|
|
542
|
+
// 渲染成功后清理 collect 中转文件(2026-11-19 用户定稿:temp 目录用后即删)。
|
|
543
|
+
// 渲染已读入全部所需数据(grouping + 详情),HTML 落盘后主缓存/批次文件不再有用;
|
|
544
|
+
// 清理失败不影响交付(envelope 仅提示)。渲染失败(异常)不会走到这里,可重试渲染。
|
|
545
|
+
const cleaned = cleanupTempArtifacts(cacheFile);
|
|
546
|
+
return workflowSuccess('workflow.aiDeepReadRender', {
|
|
547
|
+
status: 'RENDER_READY',
|
|
548
|
+
statusNote: `HTML 已生成:${outputFile}(${cardCount} 条卡片,${bytes} 字节,模板 ${templateFile})。用 present_files 打开预览即可交付。渲染为 CLI 机械替换(同源 grouping + agent 结论),无需再人工核对样式。`,
|
|
549
|
+
mode,
|
|
550
|
+
outputFile,
|
|
551
|
+
bytes,
|
|
552
|
+
cardCount,
|
|
553
|
+
hasFilterBar,
|
|
554
|
+
timingRowsReceived: (args.timingRows ?? []).length,
|
|
555
|
+
renderMs: Date.now() - started,
|
|
556
|
+
tempCleaned: cleaned,
|
|
557
|
+
warnings,
|
|
558
|
+
});
|
|
559
|
+
},
|
|
560
|
+
},
|
|
561
|
+
];
|
|
562
|
+
}
|