@stalfh233/omc-cli 0.6.74 → 0.6.75
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/coverage/m1-coverage-manifest-v1.json +4 -0
- package/dist/capability-overview.js +1 -1
- package/dist/cli-output.js +91 -3
- package/dist/cli.js +212 -30
- package/dist/discovery.js +48 -2
- package/dist/graph.js +124 -1
- package/dist/lanes/b2-registration-contract.js +8 -0
- package/dist/lanes/b2-registration-coverage.js +1 -0
- package/dist/lanes/b2-registration.js +99 -0
- package/dist/lanes/businessrule-contract.js +4 -4
- package/dist/lanes/businessrule.js +251 -60
- package/dist/lanes/form-contract.js +7 -2
- package/dist/lanes/form-coverage.js +1 -0
- package/dist/lanes/form.js +248 -5
- package/dist/lanes/model.js +102 -15
- package/dist/lanes/rule-graph.js +25 -2
- package/dist/lanes/workflow-contract.js +1 -1
- package/dist/lanes/workflow.js +48 -8
- package/dist/mcp-graph.js +43 -4
- package/dist/path-projection.js +53 -0
- package/dist/read-shapes.js +21 -6
- package/dist/recipes/businessrule.js +2 -1
- package/package.json +3 -3
- package/skills/omc-capabilities.md +2 -2
- package/skills/omc-write-hazards.md +3 -1
package/dist/lanes/form.js
CHANGED
|
@@ -8,10 +8,37 @@ import { writeTool } from "../write.js";
|
|
|
8
8
|
import { registerPackageTool } from "../package-tool.js";
|
|
9
9
|
import { writeSummary } from "../human-summary.js";
|
|
10
10
|
import { defineTool } from "../tool-types.js";
|
|
11
|
-
import { wireCall } from "../wire.js";
|
|
11
|
+
import { wireCall, wireRows, WireError } from "../wire.js";
|
|
12
12
|
import { FORM_LANE_CONTRACT } from "./form-contract.js";
|
|
13
13
|
const FORM_LANE = FORM_LANE_CONTRACT.lane;
|
|
14
14
|
const FORM_TOOLS = FORM_LANE_CONTRACT.tools;
|
|
15
|
+
/**
|
|
16
|
+
* r79-w2b(issue 06):`/api/api/app/bizsheet/list` 是 header-only 的**表单清单**
|
|
17
|
+
* 面(BizFormController.java:137-152 → ModelManagementFacadeImpl.getBizForms:481-488),
|
|
18
|
+
* 平台事实与形状钉在 contract 的 `sheetListFace`。端点字面量留在本 lane 内:
|
|
19
|
+
* `src/endpoints.ts` 由 discovery 片持有,本轮不新增 ENDPOINTS 键(w2 设计 §3.5
|
|
20
|
+
* 的所有权划分)——单一真相仍是 contract 的 wire 事实。
|
|
21
|
+
*/
|
|
22
|
+
const FORM_SHEET_LIST_PATH = "/api/api/app/bizsheet/list";
|
|
23
|
+
/** BizFormType.getIndex()(BizFormType.java:13-15,45-48);未知索引原样透传、不猜。 */
|
|
24
|
+
const FORM_TYPE_NAMES = Object.freeze({ 0: "DEFAULT_SHEET", 1: "CUSTOMIZE_SHEET", 2: "PRINT_TEMPLATE" });
|
|
25
|
+
const FORM_LIST_MAX_SHEETS = 12;
|
|
26
|
+
/** 布局面里有没有真正的 customScript 内容(id 精确匹配;before/after 是空壳同名 tagName)。 */
|
|
27
|
+
function layoutHasCustomScript(face) {
|
|
28
|
+
if (typeof face !== "string" || face.trim() === "")
|
|
29
|
+
return false;
|
|
30
|
+
try {
|
|
31
|
+
const parsed = JSON.parse(face);
|
|
32
|
+
if (!Array.isArray(parsed))
|
|
33
|
+
return false;
|
|
34
|
+
const element = parsed.find((entry) => entry !== null && typeof entry === "object" && !Array.isArray(entry) && entry.id === "customScript");
|
|
35
|
+
const html = element === undefined ? "" : element.innerHTML;
|
|
36
|
+
return typeof html === "string" && html.trim() !== "";
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
15
42
|
/**
|
|
16
43
|
* The default form slot is named after the model: every observed
|
|
17
44
|
* `configure_form`/`form.draft`/`form.publish` success used sheetCode ===
|
|
@@ -54,6 +81,35 @@ function parseControlCodes(face) {
|
|
|
54
81
|
return [];
|
|
55
82
|
}
|
|
56
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* issue 04:`publishedActionsJson` 是真实的 bizsheet 列(ticket 100),默认面
|
|
86
|
+
* 此前整列不可见 ⇒ 读成「没有表单按钮动作」。默认面只给计数 + 编码(不给正文);
|
|
87
|
+
* 解析失败如实报 parseError,**不要**回 0——假 0 正是这次摩擦的根因。
|
|
88
|
+
*/
|
|
89
|
+
function parseActionEntries(face) {
|
|
90
|
+
if (typeof face !== "string" || face.trim() === "")
|
|
91
|
+
return { count: 0, codes: [] };
|
|
92
|
+
let parsed;
|
|
93
|
+
try {
|
|
94
|
+
parsed = JSON.parse(face);
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return { parseError: true };
|
|
98
|
+
}
|
|
99
|
+
if (parsed === null)
|
|
100
|
+
return { count: 0, codes: [] };
|
|
101
|
+
const rows = Array.isArray(parsed)
|
|
102
|
+
? parsed
|
|
103
|
+
: parsed && typeof parsed === "object" && Array.isArray(parsed.actions)
|
|
104
|
+
? parsed.actions
|
|
105
|
+
: undefined;
|
|
106
|
+
if (rows === undefined)
|
|
107
|
+
return { parseError: true };
|
|
108
|
+
const codes = rows
|
|
109
|
+
.map((entry) => (entry && typeof entry === "object" ? entry.code : undefined))
|
|
110
|
+
.filter((code) => typeof code === "string" && code !== "");
|
|
111
|
+
return { count: rows.length, codes };
|
|
112
|
+
}
|
|
57
113
|
/**
|
|
58
114
|
* `--full` 的小体量布局摘要(控件码 + 行分组)。只在**加起来很小**时才给:
|
|
59
115
|
* 目的本来是"省一次默认面往返",一旦它自己变大就成了新的负担。
|
|
@@ -85,7 +141,7 @@ export function registerFormLane(tools) {
|
|
|
85
141
|
kind: "read",
|
|
86
142
|
lane: FORM_LANE,
|
|
87
143
|
scope: FORM_TOOLS["form.get"].scope,
|
|
88
|
-
description: FORM_TOOLS["form.get"].description
|
|
144
|
+
description: `${FORM_TOOLS["form.get"].description} 默认紧凑面已含按钮计数(formButtonCount 恒回,0 也给;publishedActionCount 解析自 publishedActionsJson,解析失败给 publishedActionParseError)——要按钮/动作**正文**才用 full:true / buttonScripts:true;表单不存在回 present:false + hint。`,
|
|
89
145
|
inputSchema: {
|
|
90
146
|
environment: environmentArg,
|
|
91
147
|
schemaCode: z.string().min(1),
|
|
@@ -100,9 +156,17 @@ export function registerFormLane(tools) {
|
|
|
100
156
|
},
|
|
101
157
|
handler: async (ctx, args, self) => governedRead(ctx, self, args, async (session) => {
|
|
102
158
|
const sheetCode = resolveSheetCode(args.schemaCode, args.sheetCode);
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
159
|
+
// issue 04:缺失表单统一回 present:false + hint(与 onlinejs.get 同形)。
|
|
160
|
+
// 裸 wireCall 会把 302024 变成工具错误、把「没有这个表单」读成「没有按钮」。
|
|
161
|
+
const sheet = await readFormOrNull(session, args.schemaCode, sheetCode);
|
|
162
|
+
if (!sheet) {
|
|
163
|
+
return {
|
|
164
|
+
schemaCode: args.schemaCode,
|
|
165
|
+
sheetCode,
|
|
166
|
+
present: false,
|
|
167
|
+
hint: "表单不存在(bizsheet/get 无行或 302024)——present:false 只说明默认表单还没建,不代表没有按钮/动作;先 form.draft(或 configure_form)建默认表单再 form.publish。",
|
|
168
|
+
};
|
|
169
|
+
}
|
|
106
170
|
// r28e F8(真机复现 2026-11-05,CloudPivot 1.1.25):publish → form.draft
|
|
107
171
|
// 之后,平台 bizsheet/get 的 `published`/`existDraft` 两个布尔**都回 false**,
|
|
108
172
|
// 而 `draftViewJson`/`publishedViewJson`/`draftAttributesJson`/
|
|
@@ -205,8 +269,14 @@ export function registerFormLane(tools) {
|
|
|
205
269
|
// readback never needs the artifact just to see which buttons exist.
|
|
206
270
|
const formButtons = readFormButtons(sheet.options) ?? [];
|
|
207
271
|
const withScripts = args.buttonScripts === true;
|
|
272
|
+
// issue 04:publishedActionsJson(表单级按钮动作列)默认面此前整列不可见。
|
|
273
|
+
// 只给计数/编码,正文(列原文)仍只在 full:true 的 artifact 里。
|
|
274
|
+
const publishedActions = parseActionEntries(sheet.publishedActionsJson);
|
|
208
275
|
return {
|
|
209
276
|
...base,
|
|
277
|
+
// 恒回计数(0 也给):`formButtonCount:0` 是"确实没有按钮"的证据,
|
|
278
|
+
// 键消失则会被读成"没读到"。formButtonCodes/formButtons 仍在非空时给明细。
|
|
279
|
+
formButtonCount: formButtons.length,
|
|
210
280
|
...(formButtons.length > 0
|
|
211
281
|
? {
|
|
212
282
|
formButtonCodes: formButtons.map((button) => String(button.code ?? "")),
|
|
@@ -221,6 +291,12 @@ export function registerFormLane(tools) {
|
|
|
221
291
|
}),
|
|
222
292
|
}
|
|
223
293
|
: {}),
|
|
294
|
+
...("parseError" in publishedActions
|
|
295
|
+
? { publishedActionParseError: true }
|
|
296
|
+
: {
|
|
297
|
+
publishedActionCount: publishedActions.count,
|
|
298
|
+
...(publishedActions.codes.length > 0 ? { publishedActionCodes: publishedActions.codes } : {}),
|
|
299
|
+
}),
|
|
224
300
|
draftControlCodes: draftControls,
|
|
225
301
|
publishedControlCodes: publishedControls,
|
|
226
302
|
// r28e F4:默认面只有控件码集合(字母序),证明不了「两列 / 末行整宽」。
|
|
@@ -286,6 +362,173 @@ export function registerFormLane(tools) {
|
|
|
286
362
|
},
|
|
287
363
|
}),
|
|
288
364
|
}));
|
|
365
|
+
tools.push(defineTool({
|
|
366
|
+
name: "form.list",
|
|
367
|
+
search: { intents: ["表单清单", "有哪些表单", "列出表单", "多表单", "打印模板"] },
|
|
368
|
+
layer: "low",
|
|
369
|
+
kind: "read",
|
|
370
|
+
lane: FORM_LANE,
|
|
371
|
+
scope: FORM_TOOLS["form.list"].scope,
|
|
372
|
+
description: FORM_TOOLS["form.list"].description,
|
|
373
|
+
inputSchema: {
|
|
374
|
+
environment: environmentArg,
|
|
375
|
+
schemaCode: z.string().min(1),
|
|
376
|
+
detail: z.boolean().optional().describe("true=逐面 bizsheet/get 补 existDraft/controlCount/buttonCount/publishedActionCount/hasCustomScript/faces(+N wire);默认 1 wire 且不伪造这些键"),
|
|
377
|
+
maxSheets: z.number().int().min(1).max(50).optional().describe(`detail 面逐面读取上限(默认 ${FORM_LIST_MAX_SHEETS});超出回 partial:true + omittedSheets`),
|
|
378
|
+
capability: capabilityArg,
|
|
379
|
+
},
|
|
380
|
+
handler: async (ctx, args, self) => governedRead(ctx, self, args, async (session) => {
|
|
381
|
+
let rows = null;
|
|
382
|
+
let modelPresent = true;
|
|
383
|
+
let sheetListUnavailable = false;
|
|
384
|
+
try {
|
|
385
|
+
rows = wireRows((await wireCall(session, { path: FORM_SHEET_LIST_PATH, query: { schemaCode: args.schemaCode } })).data);
|
|
386
|
+
}
|
|
387
|
+
catch (error) {
|
|
388
|
+
// 601003 业务模型不存在:与 rule.list/datarule.list 同口径——「没有这个
|
|
389
|
+
// 模型」不是「模型没有表单」,也不重试。
|
|
390
|
+
if (error instanceof WireError && error.kind === "business" && error.errcode === 601003) {
|
|
391
|
+
modelPresent = false;
|
|
392
|
+
rows = [];
|
|
393
|
+
}
|
|
394
|
+
else if (error instanceof WireError && error.kind === "http-status" && error.diagnostic?.httpStatus === 404) {
|
|
395
|
+
// 版本族没有 /list:只能验证默认槽。明确标注是推断,不伪装成清单。
|
|
396
|
+
sheetListUnavailable = true;
|
|
397
|
+
}
|
|
398
|
+
else
|
|
399
|
+
throw error;
|
|
400
|
+
}
|
|
401
|
+
const textOrNull = (value) => (typeof value === "string" && value !== "" ? value : null);
|
|
402
|
+
const decoded = [];
|
|
403
|
+
for (const row of rows ?? []) {
|
|
404
|
+
const sheetCode = textOrNull(row.code) ?? textOrNull(row.sheetCode);
|
|
405
|
+
if (sheetCode === null)
|
|
406
|
+
continue;
|
|
407
|
+
const formTypeIndex = typeof row.formType === "number" && Number.isInteger(row.formType) ? row.formType : null;
|
|
408
|
+
decoded.push({
|
|
409
|
+
sheetCode,
|
|
410
|
+
name: textOrNull(row.name),
|
|
411
|
+
formType: formTypeIndex !== null ? (FORM_TYPE_NAMES[formTypeIndex] ?? null) : textOrNull(row.formType),
|
|
412
|
+
formTypeIndex,
|
|
413
|
+
published: typeof row.published === "boolean" ? row.published : null,
|
|
414
|
+
createdTime: typeof row.createdTime === "number" ? row.createdTime : 0,
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
const byCode = new Map();
|
|
418
|
+
const duplicateSheetCodes = [];
|
|
419
|
+
for (const row of decoded) {
|
|
420
|
+
const existing = byCode.get(row.sheetCode);
|
|
421
|
+
if (!existing) {
|
|
422
|
+
byCode.set(row.sheetCode, row);
|
|
423
|
+
continue;
|
|
424
|
+
}
|
|
425
|
+
duplicateSheetCodes.push(row.sheetCode);
|
|
426
|
+
if (row.createdTime >= existing.createdTime)
|
|
427
|
+
byCode.set(row.sheetCode, row);
|
|
428
|
+
}
|
|
429
|
+
const listed = [...byCode.values()];
|
|
430
|
+
const sheets = sheetListUnavailable
|
|
431
|
+
? [{ sheetCode: args.schemaCode, name: null, formType: "DEFAULT_SHEET", formTypeIndex: 0, published: null, inferred: true }]
|
|
432
|
+
: listed.map(({ createdTime: _createdTime, ...sheet }) => sheet);
|
|
433
|
+
const defaultSheetCode = sheetListUnavailable
|
|
434
|
+
? args.schemaCode
|
|
435
|
+
: (listed.find((sheet) => sheet.formType === "DEFAULT_SHEET" && sheet.sheetCode === args.schemaCode)?.sheetCode ??
|
|
436
|
+
listed.find((sheet) => sheet.sheetCode === args.schemaCode)?.sheetCode ??
|
|
437
|
+
null);
|
|
438
|
+
const base = {
|
|
439
|
+
schemaCode: args.schemaCode,
|
|
440
|
+
modelPresent,
|
|
441
|
+
count: sheets.length,
|
|
442
|
+
...(duplicateSheetCodes.length > 0 ? { duplicateRows: true, duplicateSheetCodes: [...new Set(duplicateSheetCodes)] } : {}),
|
|
443
|
+
defaultSheetCode,
|
|
444
|
+
defaultSheetBasis: "formType=DEFAULT_SHEET 且 sheetCode===schemaCode;本键由清单推导(form.get 只认显式 sheetCode)",
|
|
445
|
+
facesNote: "published 是平台旗标位;判「有没有发布面内容」用 detail:true(faces.published.present)",
|
|
446
|
+
emptyNote: "sheets:[] 只代表该模型还没有表单行(bizsheet/list 已回),不是读不到",
|
|
447
|
+
...(sheetListUnavailable
|
|
448
|
+
? {
|
|
449
|
+
sheetListUnavailable: true,
|
|
450
|
+
hint: "该版本无 app/bizsheet/list——只能验证默认槽(上面这一行是推断,不是清单);多表单面请显式 sheetCode 用 form.get",
|
|
451
|
+
}
|
|
452
|
+
: {}),
|
|
453
|
+
...(modelPresent ? {} : { hint: "业务模型不存在(601003)——先确认 schemaCode,不要把它读成「模型没有表单」" }),
|
|
454
|
+
};
|
|
455
|
+
if (args.detail !== true || sheetListUnavailable)
|
|
456
|
+
return { ...base, sheets };
|
|
457
|
+
// detail:true —— 1 + N wire(N ≤ maxSheets)。内容推导全部复用既有函数;
|
|
458
|
+
// 单面读失败不中断(partial + readFailures 点名),绝不把失败折成空面。
|
|
459
|
+
const maxSheets = args.maxSheets ?? FORM_LIST_MAX_SHEETS;
|
|
460
|
+
const targets = listed.slice(0, maxSheets);
|
|
461
|
+
const omittedSheets = listed.slice(maxSheets).map((sheet) => sheet.sheetCode);
|
|
462
|
+
const readFailures = [];
|
|
463
|
+
const detailed = [];
|
|
464
|
+
for (const sheet of targets) {
|
|
465
|
+
const { createdTime: _createdTime, ...publicSheet } = sheet;
|
|
466
|
+
let record;
|
|
467
|
+
try {
|
|
468
|
+
record = await readFormOrNull(session, args.schemaCode, sheet.sheetCode);
|
|
469
|
+
}
|
|
470
|
+
catch (error) {
|
|
471
|
+
readFailures.push({ sheetCode: sheet.sheetCode, reason: error instanceof Error ? error.message : String(error) });
|
|
472
|
+
continue;
|
|
473
|
+
}
|
|
474
|
+
if (!record) {
|
|
475
|
+
readFailures.push({ sheetCode: sheet.sheetCode, reason: "form-absent" });
|
|
476
|
+
detailed.push({ ...publicSheet, present: false });
|
|
477
|
+
continue;
|
|
478
|
+
}
|
|
479
|
+
const draftCodes = parseControlCodes(record.draftAttributesJson);
|
|
480
|
+
const publishedCodes = parseControlCodes(record.publishedAttributesJson);
|
|
481
|
+
const draftPresent = draftCodes.length > 0 || (typeof record.draftViewJson === "string" && record.draftViewJson.trim() !== "" && record.draftViewJson.trim() !== "[]");
|
|
482
|
+
const publishedPresent = publishedCodes.length > 0 || (typeof record.publishedViewJson === "string" && record.publishedViewJson.trim() !== "" && record.publishedViewJson.trim() !== "[]");
|
|
483
|
+
const buttons = readFormButtons(record.options) ?? [];
|
|
484
|
+
const publishedActions = parseActionEntries(record.publishedActionsJson);
|
|
485
|
+
const flagMismatch = (record.published === true) !== publishedPresent || (record.existDraft === true) !== draftPresent;
|
|
486
|
+
detailed.push({
|
|
487
|
+
...publicSheet,
|
|
488
|
+
present: true,
|
|
489
|
+
existDraft: record.existDraft === true,
|
|
490
|
+
controlCount: draftCodes.length,
|
|
491
|
+
buttonCount: buttons.length,
|
|
492
|
+
...("parseError" in publishedActions ? { publishedActionParseError: true } : { publishedActionCount: publishedActions.count }),
|
|
493
|
+
hasCustomScript: layoutHasCustomScript(record.draftHtmlJson) || layoutHasCustomScript(record.publishedHtmlJson),
|
|
494
|
+
faces: {
|
|
495
|
+
draft: { present: draftPresent, controlCount: draftCodes.length },
|
|
496
|
+
published: { present: publishedPresent, controlCount: publishedCodes.length },
|
|
497
|
+
inSync: draftPresent && publishedPresent ? record.draftViewJson === record.publishedViewJson : null,
|
|
498
|
+
},
|
|
499
|
+
...(flagMismatch
|
|
500
|
+
? {
|
|
501
|
+
flagMismatch: true,
|
|
502
|
+
flagNote: "平台旗标与内容不一致:published/existDraft 来自 bizsheet/get 的标记位,faces 由两份布局内容推导。判「现在有几面」以 faces 为准;判「运行时能否读到」以 published 为准",
|
|
503
|
+
}
|
|
504
|
+
: {}),
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
return {
|
|
508
|
+
...base,
|
|
509
|
+
sheets: detailed,
|
|
510
|
+
...(omittedSheets.length > 0 || readFailures.length > 0
|
|
511
|
+
? {
|
|
512
|
+
partial: true,
|
|
513
|
+
...(omittedSheets.length > 0 ? { omittedSheets, partialNote: `detail 面逐面读取上限 maxSheets=${maxSheets};未读的表单面见 omittedSheets(清单本身完整)` } : {}),
|
|
514
|
+
...(readFailures.length > 0 ? { readFailures } : {}),
|
|
515
|
+
}
|
|
516
|
+
: {}),
|
|
517
|
+
};
|
|
518
|
+
}, {
|
|
519
|
+
// `sheets` 命中 read.ts 的 CODE_LIST_KEYS(>2048B 会被压成裸码表,丢掉
|
|
520
|
+
// formType/published)——自带 compact 保行;>20 行才外置并明说。
|
|
521
|
+
compact: (result) => {
|
|
522
|
+
const rows = Array.isArray(result.sheets) ? result.sheets : [];
|
|
523
|
+
const keep = rows.length <= 20;
|
|
524
|
+
return {
|
|
525
|
+
...result,
|
|
526
|
+
...(keep ? {} : { sheetsOmitted: true, omittedSheetsCount: rows.length, sheetsNote: "表单行超过内联预算(20 行)——完整清单(含 detail 面)在 detailArtifactId" }),
|
|
527
|
+
sheets: keep ? rows : [],
|
|
528
|
+
};
|
|
529
|
+
},
|
|
530
|
+
}),
|
|
531
|
+
}));
|
|
289
532
|
writeTool({
|
|
290
533
|
tools,
|
|
291
534
|
name: "form.draft",
|
package/dist/lanes/model.js
CHANGED
|
@@ -39,6 +39,9 @@ function modelListCompact(result) {
|
|
|
39
39
|
code,
|
|
40
40
|
schemaCode: String(row.schemaCode ?? code),
|
|
41
41
|
name,
|
|
42
|
+
// allApplications 合并面:每项必须保留归属应用,否则跨应用结果
|
|
43
|
+
// 被压成一张无出处的清单(issue 02 的下一步就是按应用重查)。
|
|
44
|
+
...(row.applicationCode !== undefined ? { applicationCode: String(row.applicationCode) } : {}),
|
|
42
45
|
legacyString: name ? `${code}|${name}` : code,
|
|
43
46
|
};
|
|
44
47
|
}
|
|
@@ -53,6 +56,13 @@ function modelListCompact(result) {
|
|
|
53
56
|
compact.modelsCount = value.length;
|
|
54
57
|
continue;
|
|
55
58
|
}
|
|
59
|
+
// allApplications 的部分成功证据不能被数组降载成 failedCount 一个数:
|
|
60
|
+
// 每个失败应用的 applicationCode/reason 是「哪块没读到」的唯一线索。
|
|
61
|
+
if (key === "failed" && Array.isArray(value)) {
|
|
62
|
+
compact.failed = value.slice(0, 10);
|
|
63
|
+
compact.failedCount = value.length;
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
56
66
|
if (value !== null && typeof value === "object" && !Array.isArray(value)
|
|
57
67
|
&& Object.keys(value).length <= 4
|
|
58
68
|
&& Buffer.byteLength(JSON.stringify(value), "utf8") <= 200) {
|
|
@@ -242,10 +252,17 @@ export function registerModelLane(tools) {
|
|
|
242
252
|
kind: "read",
|
|
243
253
|
lane: MODEL_LANE,
|
|
244
254
|
scope: MODEL_TOOLS["model.list"].scope,
|
|
245
|
-
|
|
255
|
+
// issue 02:默认面只扫当前应用(filter 零命中给 scopeClipped);跨应用
|
|
256
|
+
// 合并靠 allApplications:true。契约里那句「List the models in an application」
|
|
257
|
+
// 在前,补一句可执行提示(不重复契约已钉的 filter/search/query 事实)。
|
|
258
|
+
description: `${MODEL_TOOLS["model.list"].description} 跨应用:默认只扫当前应用,filter 零命中时回 scopeClipped/clippedBy(不代表租户没有);传 allApplications:true 一次枚举租户全部应用并合并,每项带 applicationCode,单应用读失败进 failed[] 仍部分成功。`,
|
|
246
259
|
inputSchema: {
|
|
247
260
|
environment: environmentArg,
|
|
248
261
|
applicationCode: z.string().optional().describe("应用 code;省略用配置/默认应用"),
|
|
262
|
+
allApplications: z
|
|
263
|
+
.boolean()
|
|
264
|
+
.optional()
|
|
265
|
+
.describe("true=枚举租户全部应用并合并模型(每项带 applicationCode;单应用读取失败进 failed[],不整体失败)。默认只扫当前应用"),
|
|
249
266
|
filter: z.string().optional().describe("子串过滤:code 或 name 含该词才保留"),
|
|
250
267
|
search: z.string().optional().describe("filter 的别名(集合读统一关键字手感;org.role.list/service.list 也用 search)"),
|
|
251
268
|
// r29b F12:探针传 `query` 被静默忽略(仅 ignoredArgs 提示)。接受为 filter 别名,
|
|
@@ -256,37 +273,107 @@ export function registerModelLane(tools) {
|
|
|
256
273
|
handler: async (ctx, args, self) => governedRead(ctx, self, args, async (session) => {
|
|
257
274
|
const scope = await resolveValidatedApplicationScope(session, args.applicationCode);
|
|
258
275
|
const applicationCode = scope.code;
|
|
276
|
+
const needle = (args.filter ?? args.search ?? args.query)?.trim();
|
|
277
|
+
const needleApplied = needle !== undefined && needle !== "";
|
|
278
|
+
const matches = (model) => !needleApplied || String(model.code ?? "").includes(needle) || String(model.name ?? "").includes(needle);
|
|
259
279
|
// r29f F6:显式/配置的 applicationCode 若不在 app.list 里,旧路径会把拼写错误
|
|
260
280
|
// 伪装成「该应用没有模型」。先核对租户应用表,未命中即拒(与 discover 的
|
|
261
|
-
// applicationResolution.status
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
281
|
+
// applicationResolution.status 同构)——resolveValidatedApplicationScope 已做。
|
|
282
|
+
// `schemaCode` is the parameter name every other tool takes; `code` is
|
|
283
|
+
// the tree row's key. Echo both so `--jq 'models[].schemaCode'` works
|
|
284
|
+
// (r15 P6: the alias was missing and the path missed).
|
|
285
|
+
const modelsIn = async (appCode) => {
|
|
286
|
+
const tree = flattenTreeRows(wireRows((await wireCall(session, { path: ENDPOINTS.applicationTree, query: { appCode } })).data));
|
|
287
|
+
return tree
|
|
288
|
+
.filter((row) => row.type === "BizModel" && typeof row.code === "string" && row.code)
|
|
289
|
+
.map((row) => ({ code: row.code, schemaCode: row.code, name: row.name ?? row.text ?? null }));
|
|
290
|
+
};
|
|
291
|
+
// issue 02(2026-11-18 真机摩擦):`filter:"order"` 只在租户首个应用里扫,
|
|
292
|
+
// 14 个应用 / 7 个订单模型的环境回 count:0,第一读感是「没有模型」。
|
|
293
|
+
// allApplications:true 一次合并全租户;单应用失败不拖垮整体(部分成功)。
|
|
294
|
+
if (args.allApplications === true) {
|
|
295
|
+
const appRows = wireRows((await wireCall(session, { path: ENDPOINTS.applicationList, query: {} })).data);
|
|
296
|
+
const seen = new Set();
|
|
297
|
+
const appCodes = [];
|
|
298
|
+
for (const row of appRows) {
|
|
299
|
+
const code = String(row.appCode ?? row.code ?? "");
|
|
300
|
+
if (code && !seen.has(code)) {
|
|
301
|
+
seen.add(code);
|
|
302
|
+
appCodes.push(code);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
// 空 app.list 不能把跨应用读变成静默的 0:退回已解析应用(唯一可命名的范围)。
|
|
306
|
+
if (appCodes.length === 0)
|
|
307
|
+
appCodes.push(applicationCode);
|
|
308
|
+
const failed = [];
|
|
309
|
+
const scanned = await mapBounded(appCodes, 4, async (code) => {
|
|
310
|
+
try {
|
|
311
|
+
return { applicationCode: code, models: await modelsIn(code) };
|
|
312
|
+
}
|
|
313
|
+
catch (error) {
|
|
314
|
+
const wire = error instanceof WireError
|
|
315
|
+
? `wire-${error.kind}${typeof error.errcode === "number" ? `:${error.errcode}` : ""} `
|
|
316
|
+
: "";
|
|
317
|
+
failed.push({ applicationCode: code, reason: `${wire}${error instanceof Error ? error.message : String(error)}`.slice(0, 300) });
|
|
318
|
+
return { applicationCode: code, models: [] };
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
const all = scanned.flatMap((entry) => entry.models.map((model) => ({ ...model, applicationCode: entry.applicationCode })));
|
|
322
|
+
const models = all.filter(matches);
|
|
323
|
+
return {
|
|
324
|
+
allApplications: true,
|
|
325
|
+
applicationCode,
|
|
326
|
+
applicationResolution: { status: "resolved", ...applicationResolutionOf(scope) },
|
|
327
|
+
applicationsScanned: appCodes.length,
|
|
328
|
+
// 部分成功是显式契约:failed[] 逐应用点名原因,整体仍 ok。
|
|
329
|
+
...(failed.length > 0 ? { applicationsFailed: failed.length, failed } : {}),
|
|
330
|
+
count: models.length,
|
|
331
|
+
totalBeforeFilter: all.length,
|
|
332
|
+
filterApplied: needleApplied,
|
|
333
|
+
...(needleApplied ? { filter: needle } : {}),
|
|
334
|
+
scopeHint: `本次跨 ${appCodes.length} 个应用扫描(allApplications:true),无应用边界裁剪${failed.length > 0 ? `;${failed.length} 个应用读取失败见 failed[](部分成功,零命中不代表这些应用没有)` : ""}。`,
|
|
335
|
+
models,
|
|
336
|
+
...(models.length === 0
|
|
337
|
+
? {
|
|
338
|
+
hint: failed.length > 0
|
|
339
|
+
? `已扫的 ${appCodes.length - failed.length} 个应用共 ${all.length} 个模型没有命中;另有 ${failed.length} 个应用读取失败(见 failed[])——先按 reason 重查失败应用,勿读成租户级不存在。`
|
|
340
|
+
: `全部 ${appCodes.length} 个应用共 ${all.length} 个模型都没有命中${needleApplied ? `「${needle}」` : ""};filter 是 code/name 子串匹配,核对拼写或去掉 filter 看全量。`,
|
|
341
|
+
}
|
|
342
|
+
: {}),
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
const all = await modelsIn(applicationCode);
|
|
346
|
+
const models = all.filter(matches);
|
|
271
347
|
// `filterApplied` disambiguates an empty result: it distinguishes "the
|
|
272
348
|
// filter ran and matched nothing" from "the filter was not applied"
|
|
273
349
|
// (dogfood R1: count:0 alone gave no signal).
|
|
274
350
|
// `applicationResolution` says WHY this application was scanned: the
|
|
275
351
|
// implicit fallback to the tenant's first application narrows the scan to
|
|
276
352
|
// 1-of-N, so `count: 0` must never read as tenant-wide absence.
|
|
353
|
+
// scopeClipped(issue 02):默认应用(未显式传 applicationCode)里 filter
|
|
354
|
+
// 零命中时,把「被应用边界裁掉」做成结构化键 + 两条可执行下一步,
|
|
355
|
+
// 不让它只藏在 scopeHint 散文里。
|
|
356
|
+
const scopeClipped = scope.source !== "explicit" && needleApplied && models.length === 0;
|
|
277
357
|
return {
|
|
278
358
|
applicationCode,
|
|
279
359
|
applicationResolution: { status: "resolved", ...applicationResolutionOf(scope) },
|
|
280
360
|
count: models.length,
|
|
281
361
|
totalBeforeFilter: all.length,
|
|
282
|
-
filterApplied:
|
|
283
|
-
...(
|
|
362
|
+
filterApplied: needleApplied,
|
|
363
|
+
...(needleApplied ? { filter: needle } : {}),
|
|
284
364
|
scopeHint: applicationScopeNotice(scope),
|
|
365
|
+
...(scopeClipped ? { scopeClipped: true, clippedBy: { applicationCode } } : {}),
|
|
285
366
|
models,
|
|
286
|
-
...(models.length === 0
|
|
367
|
+
...(models.length === 0
|
|
368
|
+
? {
|
|
369
|
+
hint: scopeClipped
|
|
370
|
+
? `filter「${needle}」在应用「${applicationCode}」内零命中——这不代表租户里没有。下一步二选一:① 先 app.list 取目标应用,再 model.list {applicationCode:"<code>", filter:"${needle}"};② 一次跨应用扫描:model.list {allApplications:true, filter:"${needle}"}。`
|
|
371
|
+
: applicationScopeHint(scope, "模型"),
|
|
372
|
+
}
|
|
373
|
+
: {}),
|
|
287
374
|
};
|
|
288
375
|
}, {
|
|
289
|
-
target: `model.list:${args.applicationCode ?? ""}:${args.filter ?? args.search ?? args.query ?? ""}`,
|
|
376
|
+
target: `model.list:${args.applicationCode ?? ""}:${args.allApplications === true ? "all" : ""}:${args.filter ?? args.search ?? args.query ?? ""}`,
|
|
290
377
|
// r29a F12:默认 compactReadback 把 models 压成「code|name」字符串,小应用
|
|
291
378
|
// 不过 diet 门仍回对象 → 同一工具元素类型不稳定。自定义 compact 恒回对象,
|
|
292
379
|
// 并附 legacyString 兼容旧解析。
|
package/dist/lanes/rule-graph.js
CHANGED
|
@@ -736,7 +736,7 @@ export function prepareRuleGraph(ruleCode, graph, customTrigger, schemaCode) {
|
|
|
736
736
|
return element;
|
|
737
737
|
const row = element;
|
|
738
738
|
if (row.codeType !== 0)
|
|
739
|
-
return row;
|
|
739
|
+
return row; // codeType:7(EXPRESSION) must keep expressionValue verbatim — never moved into bizCode
|
|
740
740
|
const hasBizCode = typeof row.bizCode === "string" && row.bizCode.trim().length > 0;
|
|
741
741
|
if (hasBizCode)
|
|
742
742
|
return row;
|
|
@@ -980,7 +980,7 @@ export const RULE_NODE_TEMPLATES = Object.freeze({
|
|
|
980
980
|
},
|
|
981
981
|
},
|
|
982
982
|
BIZ_ACTION: {
|
|
983
|
-
description: "BizMethod 绑定(二开动作路径):`execConditionGroups` = **满足条件时执行业务方法**(条件组与 filterCondition 同构:[[{targetSchemaDataItem,ruleConditionType,ruleValueType,...}]])。serviceType:\"BIZ_METHOD\" + methodMapping{schemaCode,serviceCode,serviceName?,serviceMethodCode,serviceMethodName?,methodCode?,inputMappings[],outputMappings[]};serviceCode+serviceMethodCode 指向集成服务方法(存在性校验用这对),methodCode 是模型级 BizMethod 注册槽。映射元素 = 8.6.26 MappingModel{propertyName,bizCode,bizPropertyType?,externParameterType?,codeType,serviceMethodParameterCode,subParameters?,expressionValue?},codeType 按 int 序列化:0=CONST 常量 / 1=PROPERTY 字段(须带 bizCode;quote 只消费 PROPERTY 的 bizCode+propertyName)/ 2-7=LIST/OBJECT/RULE_VARIABLE/MAIN_TABLE/SYSTEM/EXPRESSION。**常量值放 `bizCode`**:codeType=0(CONST) 时平台 `MapOps` 取 `mapping.getBizCode()`、设计器写 `componentValue=bizCode`——**不要用 value/expressionValue**(平台对 CONST 不读它们,运行时静默变字面 null;expressionValue 仅 codeType=7 EXPRESSION
|
|
983
|
+
description: "BizMethod 绑定(二开动作路径):`execConditionGroups` = **满足条件时执行业务方法**(条件组与 filterCondition 同构:[[{targetSchemaDataItem,ruleConditionType,ruleValueType,...}]])。serviceType:\"BIZ_METHOD\" + methodMapping{schemaCode,serviceCode,serviceName?,serviceMethodCode,serviceMethodName?,methodCode?,inputMappings[],outputMappings[]};serviceCode+serviceMethodCode 指向集成服务方法(存在性校验用这对),methodCode 是模型级 BizMethod 注册槽。映射元素 = 8.6.26 MappingModel{propertyName,bizCode,bizPropertyType?,externParameterType?,codeType,serviceMethodParameterCode,subParameters?,expressionValue?},codeType 按 int 序列化:0=CONST 常量 / 1=PROPERTY 字段(须带 bizCode;quote 只消费 PROPERTY 的 bizCode+propertyName)/ 2-7=LIST/OBJECT/RULE_VARIABLE/MAIN_TABLE/SYSTEM/EXPRESSION。**常量值放 `bizCode`**:codeType=0(CONST) 时平台 `MapOps` 取 `mapping.getBizCode()`、设计器写 `componentValue=bizCode`——**不要用 value/expressionValue**(平台对 CONST 不读它们,运行时静默变字面 null;expressionValue 仅 codeType=7 EXPRESSION 用)。**入参计算规则 = codeType:7 + `bizCode`(JSON 字符串)**:值形如 `bizCode:\"{\"formula\":\"{amount}*0.8\"}\"`(`{字段code}` 引用;不是 `expressionValue`,也不是对象);平台按 `JSON.parse(bizCode).formula` 求值后作为该入参传给服务——r79 真机实证常量/字段/表达式三行入参分别收到 `C1` / `3` / `21.00`。缺失、空串、非 JSON、缺非空 formula 一律拒 `rule-graph-bizaction-expression-missing`;常量(0)/字段(1)/计算规则(7) 三选一。映射元素只校验语义键,其余键原样透传(工具不按版本增删);`required` 以方法参数面为权威自动镜像(面缺席则映射保持缺席)。**codeType=1 的 `bizCode` 必须是当前模型的源字段 code(不是 schemaCode!)**。**outputMappings 落库(真机 2026-10-06)**:方法出参经 SYSTEM_UPDATE 回写时,映射元素的 `serviceMethodParameterCode` 必须**同时**命中①集成服务方法已声明的出参 code、②扩展接口响应**根级**键;`bizCode` 是目标字段 code。三者任一不符平台以 550018「业务模型字段不存在」类错误拒绝(真机:把响应根级键 `cumOutput` 写成别的键、或目标字段 code 与声明出参不一致都被拒)。注意 Controller 若用 `getOkResponseResult` 返回 `ResponseResult{errcode,data}` 信封,出参被包在 `data` 里、根级无业务键 ⇒ **静默不回写**;要走出参映射回写,接口需根级平铺业务键,或改用「服务内部自回写」由 Java 直接落库(后者不依赖 outputMappings)。**另观察到(真机两次复现,2026-10-06)**:目标字段 code 含 `output`(如 `big_cum_output`、`big_total_output`)作规则写入目标时被平台以 550018 拒,改名去掉 `output`(如 `big_prod_sum`)后通过——语义未明;遇 550018 且目标字段 code 含 `output` 时,优先改名排查(源码字段 code 与目标字段 code 都试)。平台设计器产出的范例形状(真机核验,供对齐;缺 serviceName/serviceMethodName/methodCode/bizCodeName+bizPropertyType 时设计器「绑定业务方法」弹窗可能显示空映射):node 级带 nodeName:\"业务方法\"、nodeCategory:\"actionNode\"、serviceType:\"BIZ_METHOD\"、invoiceBusiness:\"\"、invoiceSetting:null;映射元素带 index/propertyName(字段类型名)/bizPropertyType/displayName/required/bizCodeName(源字段名)。证据 8.6.26 BizActionNode.java:19 + BizMethodMappingModel.java + MappingModel.java:19-34 + CodeType.java:23-31 + MapOps.java(getBizMethodValue)。",
|
|
984
984
|
template: {
|
|
985
985
|
nodeCode: "BizAction_1", nodeName: "业务方法", nodeType: "BIZ_ACTION", nodeCategory: "actionNode", inputParam: "_input",
|
|
986
986
|
serviceType: "BIZ_METHOD", invoiceBusiness: "", invoiceSetting: null,
|
|
@@ -1402,6 +1402,29 @@ export function validateMethodMapping(mapping, nodeCode) {
|
|
|
1402
1402
|
// arrive as literal "null" at runtime).
|
|
1403
1403
|
if (row.codeType === 0 && !(typeof row.bizCode === "string" && row.bizCode.trim()) && row.value === undefined && row.expressionValue === undefined)
|
|
1404
1404
|
blockers.push({ code: "rule-graph-bizaction-mapping-const-value", nodeCode, key: `methodMapping.${listKey}[${index}].bizCode`, message: `${listKey}[${index}].codeType=0(CONST) 缺常量值——放 bizCode(或 value,工具会移入 bizCode);平台 CONST 只读 bizCode,缺值运行时会取到字面 null` });
|
|
1405
|
+
// EXPRESSION(7) — 入参「计算规则」:MapOps INPUT 方向对 CodeType.CONST /
|
|
1406
|
+
// CodeType.EXPRESSION 都取 `getBizMethodValue`/`getExpressionValue`
|
|
1407
|
+
// (MapOps.java:510-541),Mapping.expressionValue 是 Object、平台原样透传。
|
|
1408
|
+
// 值缺失/空串时方法收到 null,故 fail closed;公式语法**不解析**(求值是
|
|
1409
|
+
// 平台侧的事),字符串或 {formula:"..."} 两种形状都原样透传。
|
|
1410
|
+
// r79 真机(本地 1.1.25,echo 服务实证):计算规则放 **bizCode**,值必须是
|
|
1411
|
+
// JSON 字符串(如 '{"formula":"{qty}*{price}"}'),运行时按 JSON.parse(bizCode).formula
|
|
1412
|
+
// 求值后作为该入参传给服务;`expressionValue` 是前端公式编辑器的内部状态,
|
|
1413
|
+
// 不是 wire 键——早前把它当 wire 键的写法在真机 BIZ_ACTION 必 EXCEPTION。
|
|
1414
|
+
// 常量→codeType:0(bizCode 字面量)、字段→codeType:1(bizCode=字段 code)、
|
|
1415
|
+
// 计算规则→codeType:7(bizCode=JSON 字符串),三选一。
|
|
1416
|
+
if (row.codeType === 7) {
|
|
1417
|
+
let expression;
|
|
1418
|
+
try {
|
|
1419
|
+
expression = typeof row.bizCode === "string" ? JSON.parse(row.bizCode) : undefined;
|
|
1420
|
+
}
|
|
1421
|
+
catch {
|
|
1422
|
+
expression = undefined;
|
|
1423
|
+
}
|
|
1424
|
+
const formula = expression && typeof expression === "object" && !Array.isArray(expression) ? expression.formula : undefined;
|
|
1425
|
+
if (typeof row.bizCode !== "string" || !row.bizCode.trim() || typeof formula !== "string" || !formula.trim())
|
|
1426
|
+
blockers.push({ code: "rule-graph-bizaction-expression-missing", nodeCode, key: `methodMapping.${listKey}[${index}].bizCode`, message: `${listKey}[${index}].codeType=7(EXPRESSION) 必须把计算规则放在 bizCode 字符串中:bizCode:'{"formula":"{amount}*0.8"}'(不是 expressionValue,也不是对象)。平台按 JSON.parse(bizCode).formula 求值;r79 真机实证:三个入参 常量/字段/表达式 → 服务收到 {"p_const":"C1","p_field":3,"p_expr":"21.00"}` });
|
|
1427
|
+
}
|
|
1405
1428
|
// Ticket 113: restore unknown-key POSITIONING without touching the v2
|
|
1406
1429
|
// passthrough semantics — keys outside the evidenced union surface as
|
|
1407
1430
|
// a warning (never gates the write), so typos like "codeTyp" are seen
|
|
@@ -151,7 +151,7 @@ export const WORKFLOW_LANE_CONTRACT = Object.freeze({
|
|
|
151
151
|
}),
|
|
152
152
|
"workflow.get_published": Object.freeze({
|
|
153
153
|
scope: WORKFLOW_SCOPE,
|
|
154
|
-
description: "Read the current PUBLISHED workflow template (`/api/api/workflow/get_published`). **默认返回 workflowSummary(activities + ruleBindings
|
|
154
|
+
description: "Read the current PUBLISHED workflow template (`/api/api/workflow/get_published`). **默认返回 workflowSummary(activities + ruleBindings),不是整份正文**;节点级规则绑定按活动投影在 `workflowSummary.activities[].bizActions`({节点事件:[规则码]};流程级看 ruleBindings)。完整正文加 --full,或 `--jq 'data.activities[code=<活动>].<节点事件>.bizActions'` 这类**叶子**路径——对父节点 data.activities 取值会再次被折叠。在 workflow.publish / workflow.bindRule 之后用它确认发布后的绑定点。",
|
|
155
155
|
}),
|
|
156
156
|
"workflow.create": Object.freeze({
|
|
157
157
|
scope: WORKFLOW_SCOPE,
|