@stalfh233/omc-cli 0.6.94 → 0.6.96
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/goal-routes.js +62 -3
- package/dist/lanes/businessrule.js +115 -18
- package/dist/lanes/online-js.js +11 -0
- package/dist/tool-types.js +172 -2
- package/package.json +3 -3
package/dist/goal-routes.js
CHANGED
|
@@ -829,7 +829,62 @@ function triggerHintFor(goal) {
|
|
|
829
829
|
`${firstCommand}(一个模型的全部触发点:流程三面/表单按钮/规则/预置事件/在线 JS)`,
|
|
830
830
|
`omc call rule.references --args '{"kind":"trigger","code":"${code}","action":"create"}'(只看 create/update/delete/flow 某一动作)`,
|
|
831
831
|
],
|
|
832
|
-
note: "触发面不在能力注册表里,入口是 rule.references 的 kind:\"trigger\"(code 是 schemaCode,不是规则码);只读零写。action/activityCode/sheetCode/mode 只对该 kind
|
|
832
|
+
note: "触发面不在能力注册表里,入口是 rule.references 的 kind:\"trigger\"(code 是 schemaCode,不是规则码);只读零写。action/activityCode/sheetCode/mode 只对该 kind 有效。定时任务(定时器)属于业务规则面(本指路已覆盖);数据规则(datarule)是另一件事,见 datarule 指路。",
|
|
833
|
+
};
|
|
834
|
+
}
|
|
835
|
+
/**
|
|
836
|
+
* F5 返工(2026-11-22):子表/明细聚合指路。
|
|
837
|
+
*
|
|
838
|
+
* 「报修单的用件合计是多少」把「用件/子表」判给 field 能力、「合计」又不在
|
|
839
|
+
* `data` 的 AGGREGATE_ASK(统计/分组/汇总/聚合/计数/条数/多少条/有几条/数一下)
|
|
840
|
+
* 里,于是回执既没有聚合直达也没有任何子表入口——agent 只能自己去猜
|
|
841
|
+
* `data.aggregate` 的 `child` 参数。词面**双条件**才触发(子表词 × 聚合词),
|
|
842
|
+
* 避免「客户名称是什么」这类只有子表词(「明细」)的读问句被误加聚合指路。
|
|
843
|
+
*/
|
|
844
|
+
const CHILD_TABLE_CUES = ["子表", "明细", "用件", "行项目", "台账明细"];
|
|
845
|
+
const CHILD_AGGREGATE_CUES = ["合计", "求和", "总计", "几条", "多少条", "数量", "计数", "平均", "最大", "最小"];
|
|
846
|
+
function childAggregateHintFor(goal) {
|
|
847
|
+
if (!CHILD_TABLE_CUES.some((cue) => goal.includes(cue)))
|
|
848
|
+
return undefined;
|
|
849
|
+
if (!CHILD_AGGREGATE_CUES.some((cue) => goal.includes(cue)))
|
|
850
|
+
return undefined;
|
|
851
|
+
const codes = [...new Set(goal.match(GRAPH_OBJECT_RE) ?? [])];
|
|
852
|
+
const schemaCode = codes.length === 1 ? codes[0] : "<schemaCode>";
|
|
853
|
+
const child = `"child":{"childSchemaCode":"<childSchemaCode>","bizObjectId":"<bizObjectId>"}`;
|
|
854
|
+
const countCommand = `omc call data.aggregate --args '{"schemaCode":"${schemaCode}","metric":"count",${child}}'`;
|
|
855
|
+
const sumCommand = `omc call data.aggregate --args '{"schemaCode":"${schemaCode}","metric":"sum","field":"<数值列>",${child}}'`;
|
|
856
|
+
return {
|
|
857
|
+
why: `子表词 + 聚合词同时在场(${CHILD_TABLE_CUES.filter((cue) => goal.includes(cue))[0]} × ${CHILD_AGGREGATE_CUES.filter((cue) => goal.includes(cue))[0]}):子表聚合走 data.aggregate 的 child`,
|
|
858
|
+
firstCommand: countCommand,
|
|
859
|
+
commands: [
|
|
860
|
+
`${countCommand} # 子表计数走服务端 totalElements,零行内联`,
|
|
861
|
+
`${sumCommand} # 数值和/平均/最大最小:只拉目标列分页折叠;childSchemaCode 是模型里 CHILD_TABLE 字段的 code,bizObjectId 来自 data.list`,
|
|
862
|
+
],
|
|
863
|
+
note: "先 `data.list` 按业务键找到主记录 id;子表分组(groupBy)暂不支持",
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
/**
|
|
867
|
+
* F5 返工(2026-11-22):数据规则(datarule)指路。
|
|
868
|
+
*
|
|
869
|
+
* 数据规则(字段联动/赋值/校验,按字段/记录条件触发)与业务规则(rule)、
|
|
870
|
+
* 流程绑定是三个不同面;「这个模型有哪些数据规则」的第一动作是只读清单。
|
|
871
|
+
* 与其它 hint 同形:只追加指路,不改 route/confident/firstAnswer。
|
|
872
|
+
*/
|
|
873
|
+
const DATARULE_HINT_RE = /数据规则|\bdatarules?\b|字段联动|赋值规则/i;
|
|
874
|
+
function dataruleHintFor(goal) {
|
|
875
|
+
if (!DATARULE_HINT_RE.test(goal))
|
|
876
|
+
return undefined;
|
|
877
|
+
const codes = [...new Set(goal.match(GRAPH_OBJECT_RE) ?? [])];
|
|
878
|
+
const schemaCode = codes.length === 1 ? codes[0] : "<schemaCode>";
|
|
879
|
+
const firstCommand = `omc call datarule.list --args '{"schemaCode":"${schemaCode}"}'`;
|
|
880
|
+
return {
|
|
881
|
+
why: codes.length === 1 ? `问到「${codes[0]}」的数据规则` : "问到数据规则(未给出唯一 schemaCode)",
|
|
882
|
+
firstCommand,
|
|
883
|
+
commands: [
|
|
884
|
+
`${firstCommand} # 只读:该模型全部数据规则(type/字段/条件/启用状态)`,
|
|
885
|
+
`omc describe datarule.create --example field-compute-rule # 字段计算/赋值/校验的创建形状`,
|
|
886
|
+
],
|
|
887
|
+
note: "数据规则按字段/记录条件触发,与业务规则(rule)和流程绑定是不同面;入口是 datarule.list(只读),写入走 datarule.create/update/delete。",
|
|
833
888
|
};
|
|
834
889
|
}
|
|
835
890
|
function goalRouteInner(registry, goal) {
|
|
@@ -1512,17 +1567,21 @@ export function goalRoute(registry, goal) {
|
|
|
1512
1567
|
const hint = graphHintFor(goal);
|
|
1513
1568
|
const triage = triageHintFor(goal);
|
|
1514
1569
|
const trigger = triggerHintFor(goal);
|
|
1570
|
+
const childAggregate = childAggregateHintFor(goal);
|
|
1571
|
+
const datarule = dataruleHintFor(goal);
|
|
1515
1572
|
const withGraph = hint === undefined ? base : { ...base, graphHint: hint };
|
|
1516
1573
|
const withTriage = triage === undefined ? withGraph : { ...withGraph, triageHint: triage };
|
|
1517
1574
|
const withTrigger = trigger === undefined ? withTriage : { ...withTriage, triggerHint: trigger };
|
|
1575
|
+
const withChildAggregate = childAggregate === undefined ? withTrigger : { ...withTrigger, childAggregateHint: childAggregate };
|
|
1576
|
+
const withDatarule = datarule === undefined ? withChildAggregate : { ...withChildAggregate, dataruleHint: datarule };
|
|
1518
1577
|
// A3:firstAnswer 的 action 指向 registry 工具(omc call <tool> / omc describe
|
|
1519
1578
|
// <tool> --example)时附 surfaceRef——读 ladder 的起手工具、配方命中与
|
|
1520
1579
|
// needs-input 的 resolver 都能一次拿到 firstCall/needs/returns/onRefusal。
|
|
1521
|
-
const action =
|
|
1580
|
+
const action = withDatarule.firstAnswer?.action;
|
|
1522
1581
|
const surfaceRef = action === undefined
|
|
1523
1582
|
? undefined
|
|
1524
1583
|
: surfaceRefFor(registry, toolOfAction(action), { via: "firstAnswer.action" });
|
|
1525
|
-
return surfaceRef === undefined ?
|
|
1584
|
+
return surfaceRef === undefined ? withDatarule : { ...withDatarule, surfaceRef };
|
|
1526
1585
|
}
|
|
1527
1586
|
/** `omc call <tool> …` / `omc describe <tool> --example <id>` 里的工具名;其它形态返回空串(查不到即零字节)。 */
|
|
1528
1587
|
function toolOfAction(action) {
|
|
@@ -12,7 +12,8 @@ import { extractDataRuleEdges, extractReferenceEdges } from "../graph.js";
|
|
|
12
12
|
import { DEFAULT_SCAN_CONCURRENCY, mapWithConcurrency } from "../concurrency.js";
|
|
13
13
|
import { readFormButtons, readFormOrNull } from "../form-support.js";
|
|
14
14
|
import { scanModelWorkflowBindings } from "./workflow.js";
|
|
15
|
-
import { readCustomScriptSource } from "./online-js.js";
|
|
15
|
+
import { listOtherScriptSources, readCustomScriptSource } from "./online-js.js";
|
|
16
|
+
import { decodeButtonScript } from "./list-view.js";
|
|
16
17
|
import { wireCall, wireCallWith404Fallback, wireRows } from "../wire.js";
|
|
17
18
|
import { readModelRecord } from "../model-record.js";
|
|
18
19
|
import { BUSINESSRULE_LANE_CONTRACT } from "./businessrule-contract.js";
|
|
@@ -799,8 +800,39 @@ const ONLINEJS_TRIGGER_PATTERNS = [
|
|
|
799
800
|
{ kind: "fetch", test: /fetch\(/ },
|
|
800
801
|
{ kind: "/api/", test: /\/api\// },
|
|
801
802
|
];
|
|
802
|
-
|
|
803
|
+
/**
|
|
804
|
+
* sites 模式每个脚本源的命中行上限。read.ts 的 smallRowSet 只按 triggers **行数**
|
|
805
|
+
* ≤30 放行、不看字节——不设上限时一条 onlinejs 行能把整个回执顶出 2048B 折叠门
|
|
806
|
+
* 直接全量内联(评审必改 3)。hitCount 仍是真实总数。
|
|
807
|
+
*/
|
|
808
|
+
const ONLINEJS_HITS_CAP = 20;
|
|
809
|
+
/**
|
|
810
|
+
* 命中行的「打到哪个接口」抽取:只做**同行字面量**,不做语法分析。
|
|
811
|
+
* - `axios.post('/x')` → `POST /x`;`fetch('/x')` → `/x`(fetch 默认 GET,不编造 method)
|
|
812
|
+
* - 模板串含 `${…}`、变量拼接、`axios({url:…})` 配置式 → 抽不到目标,标 `targetUnresolved`
|
|
813
|
+
* 注释行仍可能命中(scanMode:"text" 的既有局限)。
|
|
814
|
+
*/
|
|
815
|
+
const ONLINEJS_TARGET_PATTERNS = [
|
|
816
|
+
{
|
|
817
|
+
test: /axios\s*\.\s*(post|get|put|delete|patch)\s*\(\s*(["'`])([^"'`]*)\2/,
|
|
818
|
+
build: (match) => match[3].includes("${") ? { target: `${match[1].toUpperCase()} ${match[3]}`, targetUnresolved: true } : { target: `${match[1].toUpperCase()} ${match[3]}` },
|
|
819
|
+
},
|
|
820
|
+
{
|
|
821
|
+
test: /fetch\s*\(\s*(["'`])([^"'`]*)\1/,
|
|
822
|
+
build: (match) => (match[2].includes("${") ? { target: match[2], targetUnresolved: true } : { target: match[2] }),
|
|
823
|
+
},
|
|
824
|
+
];
|
|
825
|
+
function onlineJsHitTarget(line) {
|
|
826
|
+
for (const pattern of ONLINEJS_TARGET_PATTERNS) {
|
|
827
|
+
const match = pattern.test.exec(line);
|
|
828
|
+
if (match !== null)
|
|
829
|
+
return pattern.build(match);
|
|
830
|
+
}
|
|
831
|
+
return { targetUnresolved: true };
|
|
832
|
+
}
|
|
833
|
+
function onlineJsTriggerSites(script) {
|
|
803
834
|
const hits = [];
|
|
835
|
+
let hitCount = 0;
|
|
804
836
|
script.split("\n").forEach((raw, index) => {
|
|
805
837
|
const line = raw.trim();
|
|
806
838
|
if (line === "")
|
|
@@ -808,10 +840,13 @@ function onlineJsTriggerHits(script) {
|
|
|
808
840
|
const matched = ONLINEJS_TRIGGER_PATTERNS.find((pattern) => pattern.test.test(line));
|
|
809
841
|
if (matched === undefined)
|
|
810
842
|
return;
|
|
843
|
+
hitCount += 1;
|
|
844
|
+
if (hits.length >= ONLINEJS_HITS_CAP)
|
|
845
|
+
return;
|
|
811
846
|
// excerpt ≤120 字(含截断省略号本身)。
|
|
812
|
-
hits.push({ line: index + 1, excerpt: line.length > 120 ? `${line.slice(0, 119)}…` : line, kind: matched.kind });
|
|
847
|
+
hits.push({ line: index + 1, excerpt: line.length > 120 ? `${line.slice(0, 119)}…` : line, kind: matched.kind, ...onlineJsHitTarget(line) });
|
|
813
848
|
});
|
|
814
|
-
return hits;
|
|
849
|
+
return { hits, hitCount };
|
|
815
850
|
}
|
|
816
851
|
/**
|
|
817
852
|
* `action:"create"|"update"|"delete"` 的「绑定到该事件的自定义规则」反推:
|
|
@@ -880,6 +915,14 @@ async function scanSchemaTriggers(session, args) {
|
|
|
880
915
|
let scannedButtons = 0;
|
|
881
916
|
let onlinejsBytes = 0;
|
|
882
917
|
let script = null;
|
|
918
|
+
// 评审必改 1(2026-11-23):SCRIPT 按钮的脚本与表单 customScript 同属「在线 JS
|
|
919
|
+
// 触发面」——数据已在同一次 bizsheet/get 里(options.customButtonJson),零额外
|
|
920
|
+
// wire。actionConfig 可能是对象也可能是 legacy JSON 字符串,解码走
|
|
921
|
+
// decodeButtonScript(与 form.get buttonScripts 同一实现)。
|
|
922
|
+
let scriptButtonCount = 0;
|
|
923
|
+
let buttonScriptBytes = 0;
|
|
924
|
+
const scriptButtonSources = [];
|
|
925
|
+
const unreadableScriptButtons = [];
|
|
883
926
|
const buttonRows = [];
|
|
884
927
|
if (activityCodeFilter !== undefined) {
|
|
885
928
|
notScanned.push("activityCode 过滤:表单按钮/规则/预置事件/在线 JS 未扫描(只看该流程节点的绑定)");
|
|
@@ -894,9 +937,25 @@ async function scanSchemaTriggers(session, args) {
|
|
|
894
937
|
const buttons = readFormButtons(sheet.options) ?? [];
|
|
895
938
|
scannedButtons = buttons.length;
|
|
896
939
|
for (const button of buttons) {
|
|
897
|
-
//
|
|
898
|
-
|
|
940
|
+
// BUSINESS_RULE 绑定是规则触发点;SCRIPT 按钮的脚本走文本匹配(下方
|
|
941
|
+
// onlineRows,source:"button");其它按钮(流程动作/页面等)只计数。
|
|
942
|
+
if (button.bindAction !== "BUSINESS_RULE") {
|
|
943
|
+
if (button.bindAction !== "SCRIPT")
|
|
944
|
+
continue;
|
|
945
|
+
const code = typeof button.code === "string" ? button.code : null;
|
|
946
|
+
const decoded = decodeButtonScript(button);
|
|
947
|
+
const source = typeof decoded.scriptData === "string" ? decoded.scriptData : null;
|
|
948
|
+
if (source === null || source.trim() === "") {
|
|
949
|
+
// 聚合点名(不逐个 push):notScanned 有 2000B 内联上限。
|
|
950
|
+
unreadableScriptButtons.push(code ?? "(无 code)");
|
|
951
|
+
continue;
|
|
952
|
+
}
|
|
953
|
+
// 只计「实际完成文本扫描」的按钮;不可读的由 notScanned 点名。
|
|
954
|
+
scriptButtonCount += 1;
|
|
955
|
+
buttonScriptBytes += Buffer.byteLength(source, "utf8");
|
|
956
|
+
scriptButtonSources.push({ code, name: typeof button.name === "string" ? button.name : null, script: source });
|
|
899
957
|
continue;
|
|
958
|
+
}
|
|
900
959
|
buttonRows.push({
|
|
901
960
|
via: "button",
|
|
902
961
|
sheetCode,
|
|
@@ -906,9 +965,30 @@ async function scanSchemaTriggers(session, args) {
|
|
|
906
965
|
targetCode: typeof button.targetCode === "string" ? button.targetCode : null,
|
|
907
966
|
});
|
|
908
967
|
}
|
|
909
|
-
|
|
968
|
+
if (unreadableScriptButtons.length > 0) {
|
|
969
|
+
// 真机 notScanned 已 ~1.3KB/2.0KB 内联上限(超了会被 compact 折成
|
|
970
|
+
// {count,sha256,omitted},0.6.93 的坑)——按钮名最多点 8 个,其余只报数。
|
|
971
|
+
const named = unreadableScriptButtons.slice(0, 8).join("、");
|
|
972
|
+
const rest = unreadableScriptButtons.length > 8 ? ` 等 ${unreadableScriptButtons.length} 个` : "";
|
|
973
|
+
notScanned.push(`SCRIPT 按钮的脚本不可读(${named}${rest}):actionConfig 缺失/不是合法 JSON 或 scriptData 为空——这些按钮的脚本未扫描`);
|
|
974
|
+
}
|
|
975
|
+
if (scriptButtonCount > 0) {
|
|
976
|
+
// 评审必改 2:读的是授权面(options),运行面用的是发布时物化的
|
|
977
|
+
// h_biz_button(ModelManagementFacadeImpl.publishBizForm)。不声明就会把
|
|
978
|
+
// 「草稿里刚改的脚本」报成现状。
|
|
979
|
+
notScanned.push("按钮脚本读的是表单 options 授权面(发布时才物化为 h_biz_button):草稿里未发布的脚本改动会被当作现状,运行面实际执行上一次发布的版本");
|
|
980
|
+
if (sheet.published !== true)
|
|
981
|
+
notScanned.push(`表单 ${sheetCode} 的 published 旗标=${String(sheet.published)}(部分构建该旗标滞后):运行面是否已有这些按钮以发布态为准`);
|
|
982
|
+
}
|
|
983
|
+
const publishedHtmlJson = typeof sheet.publishedHtmlJson === "string" ? sheet.publishedHtmlJson : null;
|
|
984
|
+
script = readCustomScriptSource(publishedHtmlJson).script;
|
|
910
985
|
if (script === null)
|
|
911
|
-
notScanned.push(`在线 JS:表单 ${sheetCode} 的发布面无 customScript
|
|
986
|
+
notScanned.push(`在线 JS:表单 ${sheetCode} 的发布面无 customScript 脚本(表单级在线 JS 未扫描;SCRIPT 按钮的脚本单独扫,见 triggers 里 source:"button" 的行)`);
|
|
987
|
+
// 评审必改 5:把「before/after 恒空」从经验断言变成自校验——真出现非空
|
|
988
|
+
// 的其它 script 元素就点名(而不是静默漏扫)。
|
|
989
|
+
const strayScripts = listOtherScriptSources(publishedHtmlJson);
|
|
990
|
+
if (strayScripts.length > 0)
|
|
991
|
+
notScanned.push(`布局里除 customScript 外还有非空 script 元素(${strayScripts.map((item) => `${item.id ?? "(无 id)"} ${item.bytes}B`).join("、")})未扫描——8.6.x 实测 before/after 恒空,出现即异常形态`);
|
|
912
992
|
}
|
|
913
993
|
}
|
|
914
994
|
catch (error) {
|
|
@@ -986,17 +1066,34 @@ async function scanSchemaTriggers(session, args) {
|
|
|
986
1066
|
}
|
|
987
1067
|
}
|
|
988
1068
|
}
|
|
989
|
-
// 5. 在线 JS 文本匹配(零 wire
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
const
|
|
993
|
-
|
|
994
|
-
|
|
1069
|
+
// 5. 在线 JS 文本匹配(零 wire;表单 customScript + SCRIPT 按钮脚本。无脚本时
|
|
1070
|
+
// 第 3 步已记 notScanned)。
|
|
1071
|
+
const onlineRows = [];
|
|
1072
|
+
const pushOnlineRow = (input) => {
|
|
1073
|
+
const sites = onlineJsTriggerSites(input.script);
|
|
1074
|
+
if (sites.hitCount === 0)
|
|
1075
|
+
return;
|
|
1076
|
+
onlineRows.push({
|
|
1077
|
+
via: "onlinejs",
|
|
1078
|
+
source: input.source,
|
|
1079
|
+
sheetCode,
|
|
1080
|
+
...(input.source === "button" ? { buttonCode: input.buttonCode ?? null, buttonName: input.buttonName ?? null } : {}),
|
|
1081
|
+
scanMode: "text",
|
|
1082
|
+
hitCount: sites.hitCount,
|
|
1083
|
+
...(mode === "sites" ? { hits: sites.hits, ...(sites.hitCount > sites.hits.length ? { hitsTruncated: true } : {}) } : {}),
|
|
1084
|
+
});
|
|
1085
|
+
};
|
|
1086
|
+
if (script !== null) {
|
|
1087
|
+
onlinejsBytes = Buffer.byteLength(script, "utf8");
|
|
1088
|
+
pushOnlineRow({ source: "form", script });
|
|
1089
|
+
}
|
|
1090
|
+
for (const button of scriptButtonSources)
|
|
1091
|
+
pushOnlineRow({ source: "button", buttonCode: button.code, buttonName: button.name, script: button.script });
|
|
995
1092
|
// P4(2026-11-22,F6b):**覆盖面自述**。F6b 转录:任务说「别漏」时,agent 拿到
|
|
996
1093
|
// 触发视图后仍逐面交叉核对 datarule/programming/视图——因为回执只说了"扫了什么",
|
|
997
1094
|
// 没说"哪些面本来就不在这里"。把未覆盖面按入口点名列出来,省掉这轮盲目核对;
|
|
998
1095
|
// 视图/权限不是动作触发点,单独说明"不适用",避免继续查。
|
|
999
|
-
notScanned.push(`数据规则(datarule)不在本视图:按字段/记录条件触发的数据规则走 omc call datarule.list --args '{"schemaCode":"${schemaCode}"}'`, `后端在线开发(programming
|
|
1096
|
+
notScanned.push(`数据规则(datarule)不在本视图:按字段/记录条件触发的数据规则走 omc call datarule.list --args '{"schemaCode":"${schemaCode}"}'`, `后端在线开发(programming)是规则/方法的**动作实现**,不是触发点:要看实现走 omc call programming.sources --args '{"schemaCode":"${schemaCode}"}'`, "自定义页面(custompage)是页面级配置、不挂模型(schemaCode),不在模型触发视图范围", `多表单模型只扫一个槽位(本次 ${sheetCode};省略 sheetCode 时=模型码):其它槽位的按钮与在线 JS 未扫——用 omc call form.list --args '{"schemaCode":"${schemaCode}"}' 列槽位后按 sheetCode 逐个查`, "视图(listview)/字段权限/流程权限不是动作触发点(只影响显示与可达性),无需扫描", "只扫当前应用;跨应用流程与规则需显式换应用(workflow.list --applicationCode)");
|
|
1000
1097
|
// 6. 并集 + action/activityCode 过滤(分组顺序:workflow → button → rule → preset → onlinejs)。
|
|
1001
1098
|
let triggers;
|
|
1002
1099
|
if (activityCodeFilter !== undefined) {
|
|
@@ -1026,10 +1123,10 @@ async function scanSchemaTriggers(session, args) {
|
|
|
1026
1123
|
action: action ?? null,
|
|
1027
1124
|
mode,
|
|
1028
1125
|
triggers,
|
|
1029
|
-
scanned: { workflows, rules: scannedRules, buttons: scannedButtons, onlinejsBytes, schedulerReads, schedulerReadFailed },
|
|
1126
|
+
scanned: { workflows, rules: scannedRules, buttons: scannedButtons, buttonScripts: scriptButtonCount, onlinejsBytes, buttonScriptBytes, schedulerReads, schedulerReadFailed },
|
|
1030
1127
|
notScanned,
|
|
1031
1128
|
scanMode: "source",
|
|
1032
|
-
note: "零命中=本次扫描未命中触发点,不代表没有触发;在线 JS
|
|
1129
|
+
note: "零命中=本次扫描未命中触发点,不代表没有触发;在线 JS(表单 customScript + SCRIPT 按钮脚本)是文本匹配,可能漏动态拼 URL、可能命中注释(命中行带 target;抽不到字面量目标标 targetUnresolved)" + schedulerNote + filterNote,
|
|
1033
1130
|
...(activityCodeFilter !== undefined ? { activityCode: activityCodeFilter } : {}),
|
|
1034
1131
|
applicationResolution: { ...applicationResolutionOf(scope), mode: "trigger", models: 1 },
|
|
1035
1132
|
};
|
|
@@ -1125,7 +1222,7 @@ export function registerBusinessRuleLane(tools) {
|
|
|
1125
1222
|
action: z.enum(["create", "update", "delete", "flow"]).optional().describe("仅 kind=trigger:动作过滤,省略=全量"),
|
|
1126
1223
|
activityCode: z.string().min(1).optional().describe("仅 kind=trigger:只看该流程节点的绑定(与 action 互斥)"),
|
|
1127
1224
|
sheetCode: z.string().min(1).optional().describe("仅 kind=trigger:多表单模型指定槽位;省略=默认槽位"),
|
|
1128
|
-
mode: z.enum(["summary", "sites"]).optional().describe("仅 kind=trigger:summary=默认,在线 JS
|
|
1225
|
+
mode: z.enum(["summary", "sites"]).optional().describe("仅 kind=trigger:summary=默认,在线 JS(表单 customScript + SCRIPT 按钮脚本)只回计数;sites=回命中行(带 target)"),
|
|
1129
1226
|
capability: capabilityArg,
|
|
1130
1227
|
},
|
|
1131
1228
|
handler: async (ctx, args, self) => governedRead(ctx, self, args, async (session) => {
|
package/dist/lanes/online-js.js
CHANGED
|
@@ -55,6 +55,17 @@ export function readCustomScriptSource(rawHtml) {
|
|
|
55
55
|
? { present: true, script, sha256: createHash("sha256").update(script, "utf8").digest("hex"), elementCount: elements.length }
|
|
56
56
|
: { present: false, script: null, sha256: "", elementCount: elements.length, notCollected: true, notCollectedReason: "customScript 不存在,无法计算脚本哈希" };
|
|
57
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* 2026-11-23(评审必改 5):把「脚本骨架固定 6 元素、before/after 恒空」从经验
|
|
60
|
+
* 断言变成**自校验**——列出布局里除 customScript 外非空的 script 元素。调用方
|
|
61
|
+
* 非空即在 notScanned 点名,避免把「没见过的形态」静默当成「没有脚本」。
|
|
62
|
+
*/
|
|
63
|
+
export function listOtherScriptSources(rawHtml) {
|
|
64
|
+
return parseLayoutElements(rawHtml)
|
|
65
|
+
.filter((element) => element.tagName === "script" && element.id !== "customScript")
|
|
66
|
+
.filter((element) => typeof element.innerHTML === "string" && element.innerHTML.trim() !== "")
|
|
67
|
+
.map((element) => ({ id: typeof element.id === "string" ? element.id : null, bytes: Buffer.byteLength(String(element.innerHTML), "utf8") }));
|
|
68
|
+
}
|
|
58
69
|
/**
|
|
59
70
|
* R75-B(2026-11-18):compose 的两道门都是「读面可判、但在 execute 里」——
|
|
60
71
|
* dry-run 绿灯、真写拒(investigate-B E2 实证)。抽成共享函数,dry-run 与真写
|
package/dist/tool-types.js
CHANGED
|
@@ -317,6 +317,176 @@ function closestSchemaKey(key, schemaKeys) {
|
|
|
317
317
|
}
|
|
318
318
|
return bestScore >= 0.4 ? best : undefined;
|
|
319
319
|
}
|
|
320
|
+
/**
|
|
321
|
+
* F5 返工(2026-11-22):参数校验拒绝中文化(tool-input-invalid)。
|
|
322
|
+
*
|
|
323
|
+
* 真机实测:`rule.save` 的 name 传空 → `"name: String must contain at least 1
|
|
324
|
+
* character(s)"`——英文 zod 原文,既没说这是「规则名称」,也没提示服务名/方法名
|
|
325
|
+
* 在别的工具(F5 的 S1「把服务名改空」就是在这里绕 62/258 次调用)。
|
|
326
|
+
* 翻译只作用于 zod 校验(本仓库 authored 的 ToolRefusalError 与平台 wire 错误
|
|
327
|
+
* 本来就是中文/结构化,不经过这里)。
|
|
328
|
+
*/
|
|
329
|
+
const ZOD_EXPECTED_TYPE_ZH = Object.freeze({
|
|
330
|
+
string: "字符串",
|
|
331
|
+
number: "数字",
|
|
332
|
+
integer: "整数",
|
|
333
|
+
boolean: "布尔值",
|
|
334
|
+
bigint: "整数",
|
|
335
|
+
object: "对象",
|
|
336
|
+
array: "数组",
|
|
337
|
+
null: "null",
|
|
338
|
+
function: "函数",
|
|
339
|
+
});
|
|
340
|
+
const ZOD_STRING_VALIDATION_ZH = Object.freeze({
|
|
341
|
+
email: "不是合法邮箱",
|
|
342
|
+
url: "不是合法 URL",
|
|
343
|
+
uuid: "不是合法 UUID",
|
|
344
|
+
cuid: "不是合法 cuid",
|
|
345
|
+
cuid2: "不是合法 cuid2",
|
|
346
|
+
ulid: "不是合法 ulid",
|
|
347
|
+
regex: "格式不符合要求(见该参数 describe)",
|
|
348
|
+
datetime: "不是合法的日期时间",
|
|
349
|
+
date: "不是合法的日期",
|
|
350
|
+
time: "不是合法的时间",
|
|
351
|
+
duration: "不是合法的时长",
|
|
352
|
+
ip: "不是合法 IP",
|
|
353
|
+
emoji: "不是合法的 emoji",
|
|
354
|
+
});
|
|
355
|
+
/** zod 3 的默认英文文案前缀(作者没写自定义 message 时才会出现)。 */
|
|
356
|
+
const ZOD_DEFAULT_MESSAGE_PREFIX = /^(Required$|Invalid |Expected |Number must |String must |Array must |Unrecognized key|Too small|Too big|Input not |Function input|Discriminator|Value must)/;
|
|
357
|
+
/**
|
|
358
|
+
* 作者在 schema 上写死的中文 message(例如 `bizObjectId` 的 required_error:
|
|
359
|
+
* 「bizObjectId 必填(参数名就是 bizObjectId——不是 id 也不是 objectId…)」,
|
|
360
|
+
* r44 真机教学)。这些是作者文案,比通用翻译更有信息量,原样保留。
|
|
361
|
+
* zod 默认文案是英文,但枚举默认文案里可能夹带中文取值(`Expected '高' | …`),
|
|
362
|
+
* 所以「含中文」还不够,必须同时不是默认前缀。
|
|
363
|
+
*/
|
|
364
|
+
function authoredMessageZh(message) {
|
|
365
|
+
if (typeof message !== "string")
|
|
366
|
+
return undefined;
|
|
367
|
+
const text = message.trim();
|
|
368
|
+
if (text.length === 0)
|
|
369
|
+
return undefined;
|
|
370
|
+
if (!/[\u4e00-\u9fff]/.test(text))
|
|
371
|
+
return undefined;
|
|
372
|
+
if (ZOD_DEFAULT_MESSAGE_PREFIX.test(text))
|
|
373
|
+
return undefined;
|
|
374
|
+
return text;
|
|
375
|
+
}
|
|
376
|
+
/** 单个 zod issue → 中文原因(不带字段路径,不带参数 describe)。 */
|
|
377
|
+
function zodIssueReasonZh(issue) {
|
|
378
|
+
switch (issue.code) {
|
|
379
|
+
case "too_small": {
|
|
380
|
+
const minimum = issue.minimum;
|
|
381
|
+
const limit = typeof minimum === "bigint" ? minimum.toString() : String(minimum);
|
|
382
|
+
const inclusive = issue.inclusive !== false;
|
|
383
|
+
if (issue.type === "string")
|
|
384
|
+
return inclusive && limit === "1" ? "不能为空" : `至少 ${limit} 个字符`;
|
|
385
|
+
if (issue.type === "array" || issue.type === "set")
|
|
386
|
+
return `至少 ${limit} 项`;
|
|
387
|
+
if (issue.type === "date")
|
|
388
|
+
return inclusive ? `不能早于 ${limit}` : `必须晚于 ${limit}`;
|
|
389
|
+
return inclusive ? `不能小于 ${limit}` : `必须大于 ${limit}`;
|
|
390
|
+
}
|
|
391
|
+
case "too_big": {
|
|
392
|
+
const maximum = issue.maximum;
|
|
393
|
+
const limit = typeof maximum === "bigint" ? maximum.toString() : String(maximum);
|
|
394
|
+
const inclusive = issue.inclusive !== false;
|
|
395
|
+
if (issue.type === "string")
|
|
396
|
+
return `最多 ${limit} 个字符`;
|
|
397
|
+
if (issue.type === "array" || issue.type === "set")
|
|
398
|
+
return `最多 ${limit} 项`;
|
|
399
|
+
if (issue.type === "date")
|
|
400
|
+
return inclusive ? `不能晚于 ${limit}` : `必须早于 ${limit}`;
|
|
401
|
+
return inclusive ? `不能大于 ${limit}` : `必须小于 ${limit}`;
|
|
402
|
+
}
|
|
403
|
+
case "invalid_type": {
|
|
404
|
+
const { expected, received } = issue;
|
|
405
|
+
const wanted = ZOD_EXPECTED_TYPE_ZH[expected] ?? expected;
|
|
406
|
+
if (received === "undefined" || received === "NaN")
|
|
407
|
+
return received === "undefined" ? `需要${wanted},未提供` : `需要${wanted},收到非数字`;
|
|
408
|
+
const actual = ZOD_EXPECTED_TYPE_ZH[received] ?? received;
|
|
409
|
+
return `需要${wanted},收到${actual}`;
|
|
410
|
+
}
|
|
411
|
+
case "invalid_enum_value": {
|
|
412
|
+
const options = issue.options ?? [];
|
|
413
|
+
return `取值必须是 ${options.map((value) => String(value)).join(" / ")} 之一`;
|
|
414
|
+
}
|
|
415
|
+
case "invalid_literal": {
|
|
416
|
+
const expected = issue.expected;
|
|
417
|
+
const values = Array.isArray(expected) ? expected : [expected];
|
|
418
|
+
return `取值必须是 ${values.map((value) => JSON.stringify(value)).join(" / ")} 之一`;
|
|
419
|
+
}
|
|
420
|
+
case "invalid_string": {
|
|
421
|
+
const validation = issue.validation;
|
|
422
|
+
if (typeof validation === "string")
|
|
423
|
+
return ZOD_STRING_VALIDATION_ZH[validation] ?? "格式不合法(见该参数 describe)";
|
|
424
|
+
if (validation !== null && typeof validation === "object")
|
|
425
|
+
return "格式不符合要求(见该参数 describe)";
|
|
426
|
+
return "格式不合法(见该参数 describe)";
|
|
427
|
+
}
|
|
428
|
+
case "invalid_union":
|
|
429
|
+
case "invalid_union_discriminator":
|
|
430
|
+
return "形状不匹配(可用写法见该参数 describe)";
|
|
431
|
+
case "unrecognized_keys": {
|
|
432
|
+
// 写面的未知键 fail-closed 在 parseToolInput 前半段就拒绝了;这里只兜
|
|
433
|
+
// 嵌套 strict 对象(如有)——沿用既有中文口径,不改那段处理。
|
|
434
|
+
const keys = issue.keys ?? [];
|
|
435
|
+
return `未知键${keys.length > 0 ? `(${keys.join("、")})` : ""};写面工具不接受未知键`;
|
|
436
|
+
}
|
|
437
|
+
case "invalid_date":
|
|
438
|
+
return "不是合法的日期";
|
|
439
|
+
case "invalid_intersection_types":
|
|
440
|
+
return "交叉类型无法合并(见该参数 describe)";
|
|
441
|
+
case "not_multiple_of": {
|
|
442
|
+
const multipleOf = issue.multipleOf;
|
|
443
|
+
return `必须是 ${typeof multipleOf === "bigint" ? multipleOf.toString() : String(multipleOf)} 的倍数`;
|
|
444
|
+
}
|
|
445
|
+
case "not_finite":
|
|
446
|
+
return "必须是有限数字";
|
|
447
|
+
case "custom":
|
|
448
|
+
// 业务自定义校验的 message 是作者写的中文,原样透出。
|
|
449
|
+
return issue.message;
|
|
450
|
+
default:
|
|
451
|
+
return issue.message;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* 参数语义:`tool.inputSchema[<field>].description`(zod schema 上就有)。
|
|
456
|
+
* 取不到(未写 describe / 非顶层键)时省略括号部分。
|
|
457
|
+
*/
|
|
458
|
+
function inputParamDescription(tool, key) {
|
|
459
|
+
const schema = tool.inputSchema[key];
|
|
460
|
+
const description = typeof schema?.description === "string" ? schema.description.trim() : "";
|
|
461
|
+
return description.length > 0 ? description : undefined;
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* 消歧钩子(关键,F5 S1):`name` 在不同能力面指的不是同一个东西——业务规则
|
|
465
|
+
* 的 name 是规则名称,而「改服务名」要走 service.update、「改方法名」要走
|
|
466
|
+
* method.update。只对 `name` 字段按工具所属 lane 追加一句,其它字段不加。
|
|
467
|
+
*/
|
|
468
|
+
const NAME_DISAMBIGUATION_ZH = Object.freeze({
|
|
469
|
+
"B1-businessrule": "本参数是规则名称;服务名用 service.update、方法名用 method.update",
|
|
470
|
+
"B2-registration": "服务名用 service.create/update,方法名用 method.create/update",
|
|
471
|
+
});
|
|
472
|
+
/** 一条 issue 的中文回执:`字段路径:原因(参数 describe;消歧)` + 既有键名提示。 */
|
|
473
|
+
function inputIssueMessageZh(tool, issue, input) {
|
|
474
|
+
const path = issue.path.join(".") || "args";
|
|
475
|
+
const parts = [];
|
|
476
|
+
const first = issue.path[0];
|
|
477
|
+
const key = typeof first === "string" ? first : undefined;
|
|
478
|
+
if (key !== undefined) {
|
|
479
|
+
const description = inputParamDescription(tool, key);
|
|
480
|
+
if (description !== undefined)
|
|
481
|
+
parts.push(description);
|
|
482
|
+
const disambiguation = key === "name" ? NAME_DISAMBIGUATION_ZH[tool.lane ?? ""] : undefined;
|
|
483
|
+
if (disambiguation !== undefined)
|
|
484
|
+
parts.push(disambiguation);
|
|
485
|
+
}
|
|
486
|
+
const semantic = parts.length > 0 ? `(${parts.join(";")})` : "";
|
|
487
|
+
const reason = authoredMessageZh(issue.message) ?? zodIssueReasonZh(issue);
|
|
488
|
+
return `${path}:${reason}${semantic}${keyRenameHint(issue.path, input, tool) ?? ""}`;
|
|
489
|
+
}
|
|
320
490
|
export function parseToolInput(tool, input) {
|
|
321
491
|
const normalized = applyInputAliases(tool, input);
|
|
322
492
|
// r30 引出、r42/r43 再证:静默丢弃错键是头号返工源(dictionary.save items
|
|
@@ -396,8 +566,8 @@ export function parseToolInput(tool, input) {
|
|
|
396
566
|
status: "error",
|
|
397
567
|
blocker: "tool-input-invalid",
|
|
398
568
|
tool: tool.name,
|
|
399
|
-
message: result.error.issues.map((issue) =>
|
|
400
|
-
issues: result.error.issues.map((issue) => ({ path: issue.path, code: issue.code, message: issue
|
|
569
|
+
message: result.error.issues.map((issue) => inputIssueMessageZh(tool, issue, normalized)).join("; "),
|
|
570
|
+
issues: result.error.issues.map((issue) => ({ path: issue.path, code: issue.code, message: inputIssueMessageZh(tool, issue, normalized), ...(keyRenameHint(issue.path, normalized, tool) ? { hint: keyRenameHint(issue.path, normalized, tool) } : {}) })),
|
|
401
571
|
...(Object.keys(acceptedValues).length > 0 ? { acceptedValues } : {}),
|
|
402
572
|
...(firstPath !== undefined ? { nextCommand: `omc describe ${tool.name} --param ${firstPath.split(".")[0]}` } : {}),
|
|
403
573
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stalfh233/omc-cli",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.96",
|
|
4
4
|
"description": "CloudPivot 8.6 configuration capability CLI — governed, fail-closed, coverage-manifest bounded.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"commander": "14.0.3",
|
|
59
|
-
"omc-core": "0.6.
|
|
59
|
+
"omc-core": "0.6.96",
|
|
60
60
|
"proper-lockfile": "4.1.2",
|
|
61
61
|
"write-file-atomic": "6.0.0",
|
|
62
62
|
"zod": "^3.23.8",
|
|
@@ -74,6 +74,6 @@
|
|
|
74
74
|
"directory": "packages/omc-cli"
|
|
75
75
|
},
|
|
76
76
|
"optionalDependencies": {
|
|
77
|
-
"@stalfh233/omc-fake-platform": "0.6.
|
|
77
|
+
"@stalfh233/omc-fake-platform": "0.6.96"
|
|
78
78
|
}
|
|
79
79
|
}
|