weaver-work-cli 0.1.52 → 0.1.54
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-MBYYSQIX.js → attachment-content-2EPEI4HV.js} +3 -3
- package/dist/chunks/{chunk-DZOC77ZD.js → chunk-6LGLI46Q.js} +1 -1
- package/dist/chunks/{chunk-RWFRZSIP.js → chunk-7KKI5KDY.js} +2 -2
- package/dist/chunks/{chunk-KLZ3ULQQ.js → chunk-CNVZETM5.js} +1 -1
- package/dist/chunks/{chunk-RPRFIG6I.js → chunk-FE3CQAAM.js} +23 -23
- package/dist/chunks/{chunk-ZRHKGQRQ.js → chunk-JJRIT2ZN.js} +2 -2
- package/dist/chunks/{chunk-LTRLF6MM.js → chunk-LYOFRYC4.js} +4 -4
- package/dist/chunks/{chunk-7UOXOGFL.js → chunk-O6RIBG5E.js} +4 -4
- package/dist/chunks/{chunk-LM2H7SZI.js → chunk-QUDHSMG3.js} +37 -25
- package/dist/chunks/{chunk-IRMA3GVP.js → chunk-XHMJBRLZ.js} +1 -1
- package/dist/chunks/{chunk-LALWNK6M.js → chunk-XPQN4E5O.js} +41 -19
- package/dist/chunks/{chunk-D3TDNRFE.js → chunk-Z7B7QSR2.js} +7 -7
- package/dist/chunks/{conflict-D2HYKBMH.js → conflict-K2IAKKFR.js} +2 -2
- package/dist/chunks/{contract-MFOFMM2J.js → contract-LJRAXVZU.js} +5448 -1857
- package/dist/chunks/{create-flow-7ZATJVTM.js → create-flow-UL37MZGP.js} +6 -6
- package/dist/chunks/{env-5DO4YENS.js → env-BZDB5OVZ.js} +2 -2
- package/dist/chunks/{factory-3M7D7WJC.js → factory-VD3YI6N7.js} +1 -1
- package/dist/chunks/{group-chat-B2HT5NEO.js → group-chat-DHNVO76L.js} +3 -3
- package/dist/chunks/{meeting-HZOX3CBB.js → meeting-OWG4O2XH.js} +10 -10
- package/dist/chunks/{registry-SJHSBO5G.js → registry-ASYCWF2U.js} +10 -10
- package/dist/chunks/{registry-KYPFFQIH.js → registry-CJOVECZD.js} +1 -1
- package/dist/chunks/{room-recommend-5AHR4YQV.js → room-recommend-LSVAMGKV.js} +4 -4
- package/dist/chunks/{schedule-KZPJUPC2.js → schedule-7QOPRUU4.js} +4 -4
- package/dist/chunks/{smart-extract-IXHCZE4R.js → smart-extract-FOUYNIG3.js} +44 -8
- package/dist/chunks/{workflow-UHKCZJMY.js → workflow-YHXFIU63.js} +1 -1
- package/dist/index.js +4 -4
- package/dist/shortcuts/contract/manifest.js +105 -5
- package/dist/shortcuts/contract/ooxml/docx-table.js +233 -0
- package/dist/shortcuts/contract/operations/card-action.js +597 -17
- package/dist/shortcuts/contract/operations/card-ebdf-list.js +258 -2
- package/dist/shortcuts/contract/operations/card.js +6 -5
- package/dist/shortcuts/contract/operations/docx-fillfromquote.js +532 -0
- package/dist/shortcuts/contract/operations/docx-verify.js +258 -0
- package/dist/shortcuts/contract/operations/elements-build.js +47 -0
- package/dist/shortcuts/contract/operations/first-screen.js +28 -3
- package/dist/shortcuts/contract/operations/ledger.js +438 -0
- package/dist/shortcuts/contract/operations/performance.js +104 -3
- package/dist/shortcuts/contract/operations/quotescreen.js +529 -0
- package/dist/shortcuts/contract/operations/registry.js +10 -0
- package/dist/shortcuts/contract/operations/triage.js +1100 -0
- package/dist/shortcuts/meeting/operations/eb/create-flow.js +21 -0
- package/dist/shortcuts/smart-extract/operations/fill.js +10 -7
- package/dist/shortcuts/smart-extract/operations/validate.js +49 -3
- package/dist/shortcuts/workflow/operations/form.js +68 -33
- package/docs/smart-extract.md +5 -5
- package/package.json +1 -1
- package/skills/weaver-e10-jinchengda/SKILL.md +139 -99
- package/skills/weaver-e10-jinchengda/references/contract-action-card.md +43 -482
- package/skills/weaver-e10-jinchengda/references/contract-action-engine.md +7 -8
- package/skills/weaver-e10-jinchengda/references/contract-agent-entry.md +3 -3
- package/skills/weaver-e10-jinchengda/references/contract-ai-assistant.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +32 -16
- package/skills/weaver-e10-jinchengda/references/contract-card-render-internals.md +478 -0
- package/skills/weaver-e10-jinchengda/references/contract-command-index.md +4 -4
- package/skills/weaver-e10-jinchengda/references/contract-disabled-capabilities.md +2 -2
- package/skills/weaver-e10-jinchengda/references/contract-doc-triage.md +39 -61
- package/skills/weaver-e10-jinchengda/references/contract-element-save-record.md +13 -9
- package/skills/weaver-e10-jinchengda/references/contract-execution-rules.md +2 -2
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-new-customer.md +2 -2
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +3 -3
- package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +3 -3
- package/skills/weaver-e10-jinchengda/references/contract-ledger-catalog.md +263 -0
- package/skills/weaver-e10-jinchengda/references/contract-ledger-query-playbook.md +525 -0
- package/skills/weaver-e10-jinchengda/references/contract-ledger-rules.md +36 -0
- package/skills/weaver-e10-jinchengda/references/contract-modeltext-library.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-multi-file.md +3 -6
- package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +80 -54
- package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +53 -76
- package/skills/weaver-e10-jinchengda/references/contract-template-selector.md +19 -21
- package/skills/weaver-e10-jinchengda/references/orchestration.md +12 -12
- package/skills/weaver-e10-jinchengda/references/source-manifest.json +1 -6
- package/skills/weaver-e10-jinchengda/scripts/fill_plan.py +2 -1
- package/skills/weaver-e10-meeting/SKILL.md +2 -1
- package/skills/weaver-e10-smart-extract/SKILL.md +15 -4
- package/skills/weaver-e10-smart-extract/references/result-format.md +2 -2
- package/skills/weaver-e10-smart-extract/references/troubleshooting.md +2 -1
- package/skills/weaver-e10-workflow/references/workflow-create.md +6 -5
- package/skills/weaver-e10-workflow/references/workflow-edit.md +1 -1
- package/skills/weaver-e10-jinchengda/scripts/contract_first_screen.py +0 -200
- package/skills/weaver-e10-jinchengda/scripts/fill_contract_from_quote.py +0 -572
- package/skills/weaver-e10-jinchengda/scripts/quote_screen.py +0 -560
- package/skills/weaver-e10-jinchengda/scripts/triage_contract.py +0 -894
- package/skills/weaver-e10-jinchengda/scripts/validate_action_card.py +0 -598
- package/skills/weaver-e10-jinchengda/scripts/verify_docx_placeholders.py +0 -118
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { contractValidationError } from '../errors.js';
|
|
4
|
+
import { readZip } from '../ooxml/zip.js';
|
|
5
|
+
/**
|
|
6
|
+
* docx 占位符与结构校验(2026-11-13 第八批下沉)。
|
|
7
|
+
*
|
|
8
|
+
* 合并自两处**重复实现**:
|
|
9
|
+
* - `scripts/verify_docx_placeholders.py`(独立校验入口)
|
|
10
|
+
* - `scripts/fill_contract_from_quote.py` 的 `validate()`
|
|
11
|
+
*
|
|
12
|
+
* 两者做的是同一件事:读 word/*.xml 全量文本 + 可见文本交叉比对,
|
|
13
|
+
* 检查占位符残留、标题出现次数、标题是否重复、表格结构是否损坏。
|
|
14
|
+
* 合并后只保留一份口径,避免「两套校验给出不同结论」。
|
|
15
|
+
*
|
|
16
|
+
* 原实现依赖 python-docx 取「可见文本」与「表格结构」;
|
|
17
|
+
* 这里改为直接解析 document.xml:可见文本取 `<w:t>` 文本节点(python-docx 的
|
|
18
|
+
* paragraph.text 也只看 w:t,不含 instrText),表格结构按 `<w:tbl>` 深度扫描,
|
|
19
|
+
* 合并单元格与嵌套表格都不会让计数漂移。
|
|
20
|
+
*/
|
|
21
|
+
const DEFAULT_PATTERNS = [
|
|
22
|
+
'xxx公司',
|
|
23
|
+
'XXX公司',
|
|
24
|
+
'***有限公司',
|
|
25
|
+
'***',
|
|
26
|
+
'年 月 日',
|
|
27
|
+
'年 月 日',
|
|
28
|
+
'【】',
|
|
29
|
+
'____',
|
|
30
|
+
'{{',
|
|
31
|
+
'}}',
|
|
32
|
+
];
|
|
33
|
+
const XML_ENTITIES = [
|
|
34
|
+
[/</gu, '<'],
|
|
35
|
+
[/>/gu, '>'],
|
|
36
|
+
[/"/gu, '"'],
|
|
37
|
+
[/'/gu, "'"],
|
|
38
|
+
[/&/gu, '&'],
|
|
39
|
+
];
|
|
40
|
+
function decodeEntities(text) {
|
|
41
|
+
let out = text;
|
|
42
|
+
for (const [pattern, value] of XML_ENTITIES)
|
|
43
|
+
out = out.replace(pattern, value);
|
|
44
|
+
return out;
|
|
45
|
+
}
|
|
46
|
+
function stripTags(xml) {
|
|
47
|
+
return decodeEntities(xml.replace(/<[^>]+>/gu, ''));
|
|
48
|
+
}
|
|
49
|
+
/** 统计子串出现次数(按字面量,不用正则,避免占位符里的特殊字符)。 */
|
|
50
|
+
function countOccurrences(haystack, needle) {
|
|
51
|
+
if (!needle)
|
|
52
|
+
return 0;
|
|
53
|
+
let count = 0;
|
|
54
|
+
let index = haystack.indexOf(needle);
|
|
55
|
+
while (index !== -1) {
|
|
56
|
+
count += 1;
|
|
57
|
+
index = haystack.indexOf(needle, index + needle.length);
|
|
58
|
+
}
|
|
59
|
+
return count;
|
|
60
|
+
}
|
|
61
|
+
/** 按 `<w:tbl>` 深度扫描取顶层表格的行列数与 0 格行。 */
|
|
62
|
+
function extractTables(documentXml) {
|
|
63
|
+
const tables = [];
|
|
64
|
+
const openRe = /<w:tbl(?:\s[^>]*)?>/gu;
|
|
65
|
+
const tokens = /<w:tbl(?:\s[^>]*)?>|<\/w:tbl>|<w:tr(?:\s[^>]*)?>|<\/w:tr>|<w:tc(?:\s[^>]*)?>|<w:gridCol(?:\s[^>]*)?\/?>/gu;
|
|
66
|
+
let searchFrom = 0;
|
|
67
|
+
let tableIndex = 0;
|
|
68
|
+
for (;;) {
|
|
69
|
+
openRe.lastIndex = searchFrom;
|
|
70
|
+
const open = openRe.exec(documentXml);
|
|
71
|
+
if (!open)
|
|
72
|
+
break;
|
|
73
|
+
// 从该 <w:tbl 起做深度扫描,找到配对的 </w:tbl>
|
|
74
|
+
tokens.lastIndex = open.index;
|
|
75
|
+
let depth = 0;
|
|
76
|
+
let rows = 0;
|
|
77
|
+
let cols = 0;
|
|
78
|
+
let inRow = false;
|
|
79
|
+
let rowCells = 0;
|
|
80
|
+
const zeroRows = [];
|
|
81
|
+
let endIndex = documentXml.length;
|
|
82
|
+
let token;
|
|
83
|
+
while ((token = tokens.exec(documentXml)) !== null) {
|
|
84
|
+
const value = token[0];
|
|
85
|
+
if (value.startsWith('<w:tbl')) {
|
|
86
|
+
depth += 1;
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (value === '</w:tbl>') {
|
|
90
|
+
depth -= 1;
|
|
91
|
+
if (depth === 0) {
|
|
92
|
+
endIndex = token.index + value.length;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
// 只统计最外层表格自身的行/列,跳过嵌套表格内容
|
|
98
|
+
if (depth !== 1)
|
|
99
|
+
continue;
|
|
100
|
+
if (value.startsWith('<w:tr')) {
|
|
101
|
+
inRow = true;
|
|
102
|
+
rowCells = 0;
|
|
103
|
+
}
|
|
104
|
+
else if (value === '</w:tr>') {
|
|
105
|
+
if (inRow) {
|
|
106
|
+
if (rowCells === 0)
|
|
107
|
+
zeroRows.push(`T${tableIndex}R${rows}`);
|
|
108
|
+
rows += 1;
|
|
109
|
+
inRow = false;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
else if (value.startsWith('<w:tc')) {
|
|
113
|
+
rowCells += 1;
|
|
114
|
+
}
|
|
115
|
+
else if (value.startsWith('<w:gridCol')) {
|
|
116
|
+
cols += 1;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
tables.push({
|
|
120
|
+
index: tableIndex,
|
|
121
|
+
rows,
|
|
122
|
+
cols: cols || 0,
|
|
123
|
+
zeroCellRows: zeroRows,
|
|
124
|
+
});
|
|
125
|
+
tableIndex += 1;
|
|
126
|
+
searchFrom = endIndex > open.index ? endIndex : open.index + open[0].length;
|
|
127
|
+
}
|
|
128
|
+
return tables;
|
|
129
|
+
}
|
|
130
|
+
/** 可见文本:逐段落取 `<w:t>` 文本(等价 python-docx 的 paragraph.text / cell.text)。 */
|
|
131
|
+
function visibleText(documentXml) {
|
|
132
|
+
const lines = [];
|
|
133
|
+
for (const chunk of documentXml.split(/<\/w:p>/u)) {
|
|
134
|
+
const parts = [];
|
|
135
|
+
for (const match of chunk.matchAll(/<w:t(?:\s[^>]*)?>([\s\S]*?)<\/w:t>/gu)) {
|
|
136
|
+
parts.push(decodeEntities(match[1] ?? ''));
|
|
137
|
+
}
|
|
138
|
+
if (parts.length > 0)
|
|
139
|
+
lines.push(parts.join(''));
|
|
140
|
+
}
|
|
141
|
+
return lines.join('\n');
|
|
142
|
+
}
|
|
143
|
+
export const contractDocxVerifyOperations = [
|
|
144
|
+
{
|
|
145
|
+
name: 'contract.docx.verify',
|
|
146
|
+
async execute(input) {
|
|
147
|
+
const pathInput = typeof input.path === 'string' ? input.path.trim() : '';
|
|
148
|
+
if (!pathInput)
|
|
149
|
+
throw contractValidationError('path_required', 'path 必须是 docx 绝对路径');
|
|
150
|
+
const path = resolve(pathInput);
|
|
151
|
+
if (!existsSync(path)) {
|
|
152
|
+
throw contractValidationError('file_not_found', `找不到文件:${path}`);
|
|
153
|
+
}
|
|
154
|
+
const patterns = Array.isArray(input.patterns) && input.patterns.length > 0
|
|
155
|
+
? input.patterns.map((item, index) => {
|
|
156
|
+
if (typeof item !== 'string' || !item) {
|
|
157
|
+
throw contractValidationError('patterns_invalid', `patterns[${index}] 必须是非空字符串`);
|
|
158
|
+
}
|
|
159
|
+
return item;
|
|
160
|
+
})
|
|
161
|
+
: DEFAULT_PATTERNS;
|
|
162
|
+
const title = typeof input.title === 'string' ? input.title.trim() : '';
|
|
163
|
+
const titleCountRaw = input.titleCount;
|
|
164
|
+
const titleCount = typeof titleCountRaw === 'number' && Number.isFinite(titleCountRaw) && titleCountRaw >= 0
|
|
165
|
+
? Math.floor(titleCountRaw)
|
|
166
|
+
: null;
|
|
167
|
+
let entries;
|
|
168
|
+
try {
|
|
169
|
+
entries = readZip(readFileSync(path));
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
throw contractValidationError('unreadable_docx', `docx 无法解析(可能是损坏或加密文件):${error instanceof Error ? error.message : String(error)}`);
|
|
173
|
+
}
|
|
174
|
+
const documentEntry = entries.find((entry) => entry.name === 'word/document.xml');
|
|
175
|
+
if (!documentEntry) {
|
|
176
|
+
throw contractValidationError('unreadable_docx', 'docx 内未找到 word/document.xml,不是有效的 Word 文档');
|
|
177
|
+
}
|
|
178
|
+
const documentXml = documentEntry.data.toString('utf8');
|
|
179
|
+
// XML 全量:word/ 下所有 xml(正文、页眉页脚、批注、脚注,含文本框)
|
|
180
|
+
const fullText = entries
|
|
181
|
+
.filter((entry) => entry.name.startsWith('word/') && entry.name.endsWith('.xml'))
|
|
182
|
+
.map((entry) => stripTags(entry.data.toString('utf8')))
|
|
183
|
+
.join('\n');
|
|
184
|
+
const visible = visibleText(documentXml);
|
|
185
|
+
const residue = {};
|
|
186
|
+
const crossCheck = {};
|
|
187
|
+
const inconsistent = [];
|
|
188
|
+
for (const pattern of patterns) {
|
|
189
|
+
const xmlCount = countOccurrences(fullText, pattern);
|
|
190
|
+
const visibleCount = countOccurrences(visible, pattern);
|
|
191
|
+
crossCheck[pattern] = { xml: xmlCount, docx: visibleCount };
|
|
192
|
+
if (xmlCount > 0)
|
|
193
|
+
residue[pattern] = xmlCount;
|
|
194
|
+
// 可见文本比 XML 全量还多,说明遍历方式有问题,结论不可信
|
|
195
|
+
if (visibleCount > xmlCount)
|
|
196
|
+
inconsistent.push(pattern);
|
|
197
|
+
}
|
|
198
|
+
const titleHits = title ? countOccurrences(fullText, title) : null;
|
|
199
|
+
let titleOk = true;
|
|
200
|
+
let titleRule = 'not_checked';
|
|
201
|
+
if (title) {
|
|
202
|
+
if (titleCount !== null) {
|
|
203
|
+
titleOk = titleHits === titleCount;
|
|
204
|
+
titleRule = `equals:${titleCount}`;
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
titleOk = (titleHits ?? 0) >= 1;
|
|
208
|
+
titleRule = 'at_least:1';
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
const titleDoubled = Boolean(title) && fullText.includes(`${title}${title}`);
|
|
212
|
+
const tables = extractTables(documentXml);
|
|
213
|
+
const zeroCellRows = tables.flatMap((table) => table.zeroCellRows);
|
|
214
|
+
const ok = Object.keys(residue).length === 0 &&
|
|
215
|
+
inconsistent.length === 0 &&
|
|
216
|
+
titleOk &&
|
|
217
|
+
!titleDoubled &&
|
|
218
|
+
zeroCellRows.length === 0;
|
|
219
|
+
const fails = [];
|
|
220
|
+
if (Object.keys(residue).length > 0) {
|
|
221
|
+
fails.push(`占位符残留:${Object.entries(residue).map(([k, v]) => `${k}×${v}`).join('、')}`);
|
|
222
|
+
}
|
|
223
|
+
if (inconsistent.length > 0)
|
|
224
|
+
fails.push(`可见文本计数大于 XML 全量:${inconsistent.join('、')}`);
|
|
225
|
+
if (!titleOk)
|
|
226
|
+
fails.push(`标题出现次数 ${titleHits} 不符合期望(${titleRule})`);
|
|
227
|
+
if (titleDoubled)
|
|
228
|
+
fails.push('标题连续出现两次(疑似重复写入)');
|
|
229
|
+
if (zeroCellRows.length > 0)
|
|
230
|
+
fails.push(`存在 0 格行:${zeroCellRows.join('、')}`);
|
|
231
|
+
const data = {
|
|
232
|
+
ok,
|
|
233
|
+
docx: path,
|
|
234
|
+
residue,
|
|
235
|
+
crossCheck,
|
|
236
|
+
inconsistent,
|
|
237
|
+
title: title || null,
|
|
238
|
+
titleHits,
|
|
239
|
+
titleOk,
|
|
240
|
+
titleRule,
|
|
241
|
+
titleDoubled,
|
|
242
|
+
tables: tables.map((table) => ({ index: table.index, rows: table.rows, cols: table.cols })),
|
|
243
|
+
zeroCellRows,
|
|
244
|
+
fails,
|
|
245
|
+
note: ok
|
|
246
|
+
? '通过:无占位符残留、标题唯一、表格结构完好'
|
|
247
|
+
: '不通过:见 fails / residue / inconsistent / zeroCellRows',
|
|
248
|
+
};
|
|
249
|
+
const outInput = typeof input.out === 'string' ? input.out.trim() : '';
|
|
250
|
+
let outPath = null;
|
|
251
|
+
if (outInput) {
|
|
252
|
+
outPath = resolve(outInput);
|
|
253
|
+
writeFileSync(outPath, JSON.stringify(data, null, 2), 'utf8');
|
|
254
|
+
}
|
|
255
|
+
return { status: 'COMPLETE', data: { ...data, ...(outPath ? { out: outPath } : {}) } };
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
];
|
|
@@ -353,6 +353,52 @@ function makePayload(spec, flow, fileId, results, subtables = []) {
|
|
|
353
353
|
};
|
|
354
354
|
}
|
|
355
355
|
/** 新客户流程:完整 23 项语义映射。 */
|
|
356
|
+
/**
|
|
357
|
+
* 专项方案法定名称(references/contract-field-extract-new-customer.md §5.2 的 15 项)。
|
|
358
|
+
*
|
|
359
|
+
* 为什么固化到 CLI:专项名称只允许这 15 项,原名不得改写、缩写或自创。
|
|
360
|
+
* 过去完全依赖模型先读完 24 KB 文档再逐项对照——漏读或记错时会**静默写入错误名称**,
|
|
361
|
+
* 表单照样保存、页面不报错,事后极难发现;而且「读不全 → 再读一次」本身要白跑工具往返。
|
|
362
|
+
* 固化后非法值当场报错并回传 allowed 全量清单,模型无需预读文档即可自纠。
|
|
363
|
+
*
|
|
364
|
+
* 维护红线:与 §5.2 表格严格一一对应;新增/改名必须先改 reference 再改这里。
|
|
365
|
+
*/
|
|
366
|
+
export const SOLUTION_NAMES = [
|
|
367
|
+
'文书定-档案管理',
|
|
368
|
+
'聚才林-人事管理',
|
|
369
|
+
'采知连-文档管理',
|
|
370
|
+
'今承达-合同管理',
|
|
371
|
+
'齐业成-费控管理',
|
|
372
|
+
'千里聆-业务流程自动化',
|
|
373
|
+
'京桥通-采购管理',
|
|
374
|
+
'九氚汇-营销管理',
|
|
375
|
+
'事井然-项目管理',
|
|
376
|
+
'易秒办-即时通讯',
|
|
377
|
+
'令信通-统一身份',
|
|
378
|
+
'资管家-资产管理',
|
|
379
|
+
'业票通-数电票管理',
|
|
380
|
+
'数智大脑-小e',
|
|
381
|
+
'青蓝阁-学习考试',
|
|
382
|
+
];
|
|
383
|
+
/**
|
|
384
|
+
* 校验专项方案名称是否都在白名单内。
|
|
385
|
+
*
|
|
386
|
+
* 一次收集全部非法值再抛错(而不是遇到第一个就抛),让调用方一轮就能看全问题。
|
|
387
|
+
* `details.allowed` 回传完整清单,这是本校验的核心价值:调用方不必再去读文档确认合法值。
|
|
388
|
+
*/
|
|
389
|
+
export function assertSolutionNames(solutions) {
|
|
390
|
+
const received = [];
|
|
391
|
+
for (const item of solutions) {
|
|
392
|
+
const name = truthyText(item?.name);
|
|
393
|
+
if (!name)
|
|
394
|
+
continue;
|
|
395
|
+
if (!SOLUTION_NAMES.includes(name))
|
|
396
|
+
received.push(name);
|
|
397
|
+
}
|
|
398
|
+
if (!received.length)
|
|
399
|
+
return;
|
|
400
|
+
throw contractValidationError('invalid_solution', `专项方案名称不在法定清单内:${received.join(' / ')}。合法值仅 ${SOLUTION_NAMES.length} 项(见 allowed);未命中的专项整行不要输出,禁止自创或改写名称`, { allowed: SOLUTION_NAMES, received });
|
|
401
|
+
}
|
|
356
402
|
export function buildNewCustomer({ triage, fileId, flow, lines, sourceMap, fileIds }) {
|
|
357
403
|
const spec = NEW_CUSTOMER;
|
|
358
404
|
const fields = spec.fields;
|
|
@@ -421,6 +467,7 @@ export function buildNewCustomer({ triage, fileId, flow, lines, sourceMap, fileI
|
|
|
421
467
|
const subtables = [];
|
|
422
468
|
const solutions = Array.isArray(elements.solutions) ? elements.solutions : [];
|
|
423
469
|
if (solutions.length && spec.subFormId) {
|
|
470
|
+
assertSolutionNames(solutions);
|
|
424
471
|
const rows = [];
|
|
425
472
|
solutions.forEach((item) => {
|
|
426
473
|
const name = truthyText(item?.name);
|
|
@@ -4,6 +4,7 @@ import { contractValidationError } from '../errors.js';
|
|
|
4
4
|
import { BUILTIN } from './elements-spec.js';
|
|
5
5
|
import { buildMinimal, buildPayload, loadSourceLines, loadSourceMap } from './elements-build.js';
|
|
6
6
|
import { resolveOperation } from './op-resolver.js';
|
|
7
|
+
import { verifyBrowsertoolText } from './card-action.js';
|
|
7
8
|
/**
|
|
8
9
|
* 合同首屏第 2 轮编排(本地,零依赖)。
|
|
9
10
|
*
|
|
@@ -523,6 +524,11 @@ export const contractFirstScreenOperation = {
|
|
|
523
524
|
step('render_action_card', false, '未生成 card.html');
|
|
524
525
|
warnings.push('卡片渲染未产出文件');
|
|
525
526
|
}
|
|
527
|
+
// 自检结论随卡片一起回传:首屏同样是交付口,判据必须与 contract.card.action 一致,
|
|
528
|
+
// 否则调用方无法确认这张卡到底过没过校验。
|
|
529
|
+
result.selfCheck = Array.isArray(cardData.selfCheck) ? cardData.selfCheck : [];
|
|
530
|
+
result.selfCheckChecks = Array.isArray(cardData.selfCheckChecks) ? cardData.selfCheckChecks : [];
|
|
531
|
+
result.selfCheckPassed = cardData.noCard === true ? null : cardData.selfCheckPassed === true;
|
|
526
532
|
}
|
|
527
533
|
catch (error) {
|
|
528
534
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -532,16 +538,35 @@ export const contractFirstScreenOperation = {
|
|
|
532
538
|
}
|
|
533
539
|
// 卡片失败不得被摘要产物掩盖
|
|
534
540
|
result.ok = result.cardOk === false ? false : Boolean(result.cardHtml || result.summaryHtml);
|
|
541
|
+
// 成品文本校验:对象合规不等于文本可解析。手改少一层转义时,
|
|
542
|
+
// 只有这里能拦住;不通过就不回传内容,避免坏卡片被下游原样输出。
|
|
543
|
+
const cardRaw = result.cardHtml && isFile(result.cardHtml) ? readFileSync(result.cardHtml, 'utf8') : '';
|
|
544
|
+
if (cardRaw) {
|
|
545
|
+
const textCheck = verifyBrowsertoolText(cardRaw);
|
|
546
|
+
result.textCheck = textCheck.problems;
|
|
547
|
+
result.textPassed = textCheck.passed;
|
|
548
|
+
if (textCheck.passed) {
|
|
549
|
+
step('verify_browsertool', true, `${textCheck.bytes} bytes`);
|
|
550
|
+
}
|
|
551
|
+
else {
|
|
552
|
+
result.cardOk = false;
|
|
553
|
+
result.ok = false;
|
|
554
|
+
step('verify_browsertool', false, textCheck.problems.join(' / ').slice(0, 300));
|
|
555
|
+
warnings.push(`卡片成品文本校验未通过,已停止回传:${textCheck.problems.join(' / ').slice(0, 600)}`);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
535
558
|
const resultPath = join(outDir, 'first_screen_result.json');
|
|
536
559
|
writeFileSync(resultPath, JSON.stringify(result, null, 2), 'utf8');
|
|
537
|
-
const cardHtmlContent = input.printCard === true && result.
|
|
538
|
-
? readFileSync(result.cardHtml, 'utf8')
|
|
539
|
-
: undefined;
|
|
560
|
+
const cardHtmlContent = input.printCard === true && result.cardOk === true && cardRaw ? cardRaw : undefined;
|
|
540
561
|
return {
|
|
541
562
|
status: 'COMPLETE',
|
|
542
563
|
data: {
|
|
543
564
|
ok: result.ok,
|
|
544
565
|
cardOk: result.cardOk ?? null,
|
|
566
|
+
selfCheck: result.selfCheck ?? [],
|
|
567
|
+
selfCheckPassed: result.selfCheckPassed ?? null,
|
|
568
|
+
selfCheckChecks: result.selfCheckChecks ?? [],
|
|
569
|
+
textCheck: result.textCheck ?? [],
|
|
545
570
|
prefill: result.prefill,
|
|
546
571
|
aiExtraId: result.aiExtraId,
|
|
547
572
|
cardHtml: result.cardHtml,
|