@stalfh233/omc-cli 0.6.96 → 0.6.98
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/cli.js +62 -7
- package/dist/environment-policy.js +1 -1
- package/dist/lanes/businessrule-contract.js +1 -1
- package/dist/lanes/businessrule.js +70 -6
- package/dist/lanes/datarule-contract.js +1 -1
- package/dist/lanes/datarule.js +2 -2
- package/dist/lanes/environment.js +17 -19
- package/dist/lanes/perm.js +292 -32
- package/dist/lanes/runtime-data-contract.js +3 -3
- package/dist/lanes/runtime-data.js +28 -2
- package/dist/lanes/workflow-contract.js +1 -1
- package/dist/lanes/workflow.js +76 -10
- package/dist/path-projection.js +1 -1
- package/dist/read-shapes.js +3 -3
- package/dist/read.js +17 -2
- package/dist/rollback.js +33 -2
- package/dist/session.js +79 -38
- package/dist/write.js +5 -0
- package/package.json +3 -3
package/dist/cli.js
CHANGED
|
@@ -27,7 +27,7 @@ import { CLI_DEFAULT_OUTPUT_BYTES, assertSafeOutputPath, pruneArtifacts } from "
|
|
|
27
27
|
import { sessionAccountForEnvironment } from "./session-account.js";
|
|
28
28
|
import { closeWritableWindow, openWritableWindow, parseWritableTtl, sweepWritableWindowsAtStartup, validateWritableReason, writableWindowStatus, WRITABLE_WINDOW_DEFAULT_TTL_MINUTES, WRITABLE_WINDOW_LOG, WRITABLE_WINDOW_MAX_TTL_MINUTES, WritableWindowInputError } from "./writable-window.js";
|
|
29
29
|
import { artifactPathMissHint, nullProjectionHint, PATH_MISS_HELP_REF, partialPathMissHint, pathMissCopyableHint, pathMissCopyablePaths, pathMissCrossFaceCorrection, pathMissDidYouMean, projectJsonPath, projectJsonPathFanout, projectResultExtract, shapeOf, SHAPE_MAX_DEPTH, unwrapSinglePathProjection } from "./path-projection.js";
|
|
30
|
-
import { basename, join, resolve } from "node:path";
|
|
30
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
31
31
|
import { existsSync, readFileSync, writeFileSync, chmodSync } from "node:fs";
|
|
32
32
|
import { buildToolRegistry } from "./tools.js";
|
|
33
33
|
import { parseDurationMs } from "./duration.js";
|
|
@@ -1015,6 +1015,30 @@ function resolvedDefaultEnvironment(store) {
|
|
|
1015
1015
|
* template re-read three times is 81 KB of the session.
|
|
1016
1016
|
*/
|
|
1017
1017
|
const ARTIFACT_INLINE_CEILING_BYTES = 8192;
|
|
1018
|
+
/** commands --json 的上下文预算;当前目录约 31.5KiB,留出兼容窗口。 */
|
|
1019
|
+
const COMMANDS_JSON_INLINE_CEILING_BYTES = 32 * 1024;
|
|
1020
|
+
/** 超过这个体积就提醒走更窄的面(不改变返回值)。 */
|
|
1021
|
+
const COMMANDS_JSON_HINT_BYTES = 16 * 1024;
|
|
1022
|
+
/**
|
|
1023
|
+
* issue 2026-11 F3:默认骨架不是限流——同一句话必须同时出现在 `hint` 与顶层
|
|
1024
|
+
* `message`(并列通道同源),否则只看 message 的程序化消费方会误判。
|
|
1025
|
+
*/
|
|
1026
|
+
function artifactOutlineHint(id, bytes, depth) {
|
|
1027
|
+
return `正文 ${Math.round(bytes / 1024)}KB 超过内联上限 ${ARTIFACT_INLINE_CEILING_BYTES}B,默认只回深度 ${depth} 骨架(键/类型/数组长度/示例值),不是输出限流。加深:--depth ≤${SHAPE_MAX_DEPTH};子树骨架:--shape <path>;取键:--keys <a,b>;取路径:--jq '<path>';整包:--full 或 --out <配置根内路径>;只元数据:--meta。`;
|
|
1028
|
+
}
|
|
1029
|
+
function artifactDefaultMetadata(id, bytes, content, depth) {
|
|
1030
|
+
return {
|
|
1031
|
+
status: "ok",
|
|
1032
|
+
artifactId: id,
|
|
1033
|
+
bytes,
|
|
1034
|
+
outline: true,
|
|
1035
|
+
depth,
|
|
1036
|
+
shape: shapeOf(content, depth),
|
|
1037
|
+
hint: artifactOutlineHint(id, bytes, depth),
|
|
1038
|
+
message: artifactOutlineHint(id, bytes, depth),
|
|
1039
|
+
fullCommand: `omc artifact get ${id} --full`,
|
|
1040
|
+
};
|
|
1041
|
+
}
|
|
1018
1042
|
/**
|
|
1019
1043
|
* `artifact get --jq`: one path walk, with `[]` fan-out (same syntax as
|
|
1020
1044
|
* `omc call --jq`). Returns the envelope fields so both the `--summary` and the
|
|
@@ -1162,6 +1186,17 @@ async function cmdArtifactGet(id, transport, options = {}) {
|
|
|
1162
1186
|
// command instead, which is the portable way to reach the body.
|
|
1163
1187
|
if (options.pathOnly)
|
|
1164
1188
|
return emitTransportResult({ status: "ok", artifactId: id, sha256: artifact.sha256, fetch: artifactFetchHint(id) }, transport);
|
|
1189
|
+
// --meta is the stable metadata-only choice. It deliberately never returns
|
|
1190
|
+
// the body, including for small artifacts whose default face is inline.
|
|
1191
|
+
if (options.meta === true) {
|
|
1192
|
+
const depth = options.depth ?? 2;
|
|
1193
|
+
return emitTransportResult({
|
|
1194
|
+
...artifactDefaultMetadata(id, artifact.content.length, content, depth),
|
|
1195
|
+
sha256: artifact.sha256,
|
|
1196
|
+
projectionRule: "投影要写到叶子(数组元素里的字段);取值用 --jq <path> 或 --keys <a,b>",
|
|
1197
|
+
projectionExample: `omc artifact get ${id} --jq '<path>'`,
|
|
1198
|
+
}, transport);
|
|
1199
|
+
}
|
|
1165
1200
|
// r75 调查C:`--shape [path]` 回执形状先验——深度受限骨架(默认 2,--depth 可
|
|
1166
1201
|
// 到 4)。--summary 是预算事实(多大/会不会截断),--shape 是导航图(嵌套骨架
|
|
1167
1202
|
// 到哪层有哪些键);>8KB 默认 outline 与本分支共用同一份 shapeOf(单一真相源,
|
|
@@ -1300,7 +1335,8 @@ async function cmdArtifactGet(id, transport, options = {}) {
|
|
|
1300
1335
|
outline: true,
|
|
1301
1336
|
depth,
|
|
1302
1337
|
shape: shapeOf(content, depth),
|
|
1303
|
-
hint:
|
|
1338
|
+
hint: artifactOutlineHint(id, artifact.content.length, depth),
|
|
1339
|
+
message: artifactOutlineHint(id, artifact.content.length, depth),
|
|
1304
1340
|
projectionRule: "投影要写到叶子(数组元素里的字段);写整棵父节点(如 data.activities)会因总量超限再次被外置",
|
|
1305
1341
|
...(() => {
|
|
1306
1342
|
const rec = content && typeof content === "object" && !Array.isArray(content) ? content : undefined;
|
|
@@ -1311,7 +1347,7 @@ async function cmdArtifactGet(id, transport, options = {}) {
|
|
|
1311
1347
|
fullCommand: `omc artifact get ${id} --full`,
|
|
1312
1348
|
}, transport);
|
|
1313
1349
|
}
|
|
1314
|
-
const result = { status: "ok", artifactId: id, sha256: artifact.sha256, content };
|
|
1350
|
+
const result = { status: "ok", artifactId: id, sha256: artifact.sha256, content, fullCommand: `omc artifact get ${id}`, projectionExample: `omc artifact get ${id} --jq '<path>'` };
|
|
1315
1351
|
if (Buffer.byteLength(JSON.stringify(result), "utf8") > transport.maxOutputBytes) {
|
|
1316
1352
|
// 2026-11-04 r70: `--full` used to fall back to the same bare `fetch`
|
|
1317
1353
|
// pointer it had just been asked to bypass — re-running `--full` re-hits
|
|
@@ -1770,6 +1806,17 @@ function cmdDiscovery(kind, transport, value, options = {}) {
|
|
|
1770
1806
|
}
|
|
1771
1807
|
}
|
|
1772
1808
|
result = inventory;
|
|
1809
|
+
if (options.json === true && options.compact !== true) {
|
|
1810
|
+
const inventoryBytes = Buffer.byteLength(JSON.stringify({ status: "ok", ...inventory }), "utf8");
|
|
1811
|
+
// issue 2026-11 F10:全量目录一行就是 30KB+。超预算外置成 artifact 指针
|
|
1812
|
+
// (--inline 强制内联);尚未超预算但已偏大时给一句指路,别再无声灌上下文。
|
|
1813
|
+
if (options.inline !== true && inventoryBytes > COMMANDS_JSON_INLINE_CEILING_BYTES)
|
|
1814
|
+
return emitTransportResult(boundResult({ status: "ok", ...inventory }, COMMANDS_JSON_INLINE_CEILING_BYTES), transport);
|
|
1815
|
+
// 不往 stdout 加字段:`commands --json` 的字节是 golden 钉死面(新能力必须
|
|
1816
|
+
// opt-in)。指路走 stderr(人类通道),程序化消费者字节不变。
|
|
1817
|
+
if (inventoryBytes > COMMANDS_JSON_HINT_BYTES)
|
|
1818
|
+
console.error(`全量目录 ${Math.round(inventoryBytes / 1024)}KB(单行);找工具用 --compact / --filter / --lane / --kind,确实要全量再加 --inline(当前未超 ${Math.round(COMMANDS_JSON_INLINE_CEILING_BYTES / 1024)}KiB 外置门)`);
|
|
1819
|
+
}
|
|
1773
1820
|
}
|
|
1774
1821
|
else if (kind === "contract") {
|
|
1775
1822
|
if (options.tool !== undefined) {
|
|
@@ -2974,13 +3021,20 @@ async function main() {
|
|
|
2974
3021
|
return;
|
|
2975
3022
|
}
|
|
2976
3023
|
const rows = store.listEnvironments().map((item) => ({ name: item.name, baseUrl: item.profile.baseUrl, applicationCode: item.profile.applicationCode, isDefault: item.profile.isDefault === true, writable: item.profile.writable !== false, credential: store.hasCredential(item.name) ? "ok" : "missing" }));
|
|
3024
|
+
// issue 2026-11 F5:清单来源(配置根 + 项目根)不回显时,同一条命令在不同
|
|
3025
|
+
// cwd 语义不同、且会静默落到机器全局 default——真机会话因此白打错环境。
|
|
3026
|
+
const paths = store.configPaths;
|
|
3027
|
+
const configRoot = dirname(paths.configPath);
|
|
3028
|
+
const projectRoot = dirname(paths.projectEnvPath);
|
|
3029
|
+
const binding = { configRoot, projectRoot, bindingFiles: { ".omc-env": paths.projectEnvPath, ".omc-envs": paths.projectEnvsPath }, note: "环境集合由「项目根」的 .omc-env/.omc-envs + 配置根的 omc.config.json 共同决定;换目录会换集合" };
|
|
2977
3030
|
if (options.json)
|
|
2978
|
-
process.stdout.write(JSON.stringify({ ok: true, environments: rows }, null, 2) + "\n");
|
|
3031
|
+
process.stdout.write(JSON.stringify({ ok: true, configRoot, projectRoot, environments: rows, binding }, null, 2) + "\n");
|
|
2979
3032
|
else if (rows.length === 0)
|
|
2980
|
-
console.error(
|
|
3033
|
+
console.error(`(none configured; run omc setup)\n配置根:${configRoot}\n项目根:${projectRoot}`);
|
|
2981
3034
|
// A5(GitLab #15):credential: missing 的环境列得出、调不通(auth-config)——
|
|
2982
3035
|
// 标注出来,防把"没凭据"误判成"参数写错"。
|
|
2983
3036
|
else {
|
|
3037
|
+
console.error(`配置根:${configRoot} 项目根:${projectRoot}(环境集合由这两处决定,换目录会换集合)`);
|
|
2984
3038
|
for (const row of rows)
|
|
2985
3039
|
console.error(`${row.name}${row.isDefault ? " (default)" : ""} ${row.baseUrl} app=${row.applicationCode}${row.writable ? "" : " [read-only]"}${row.credential === "ok" ? "" : " [credential: missing → omc setup]"}`);
|
|
2986
3040
|
// r55(2026-11-11 Windows 真机联调摩擦):agent 为拿 token 花 7 轮、用户手粘
|
|
@@ -3284,7 +3338,7 @@ async function main() {
|
|
|
3284
3338
|
console.error(`已清理 ${result.removed} 个读回产物,释放 ${formatBytes(result.freedBytes)};保留 ${result.kept} 个(${formatBytes(result.keptBytes)})`);
|
|
3285
3339
|
commandExitCode = CLI_EXIT_CODES.ok;
|
|
3286
3340
|
});
|
|
3287
|
-
artifactCommand.command("get <id>").addOption(new Option("--jq [path]", "路径选择器(非 jq);支持 [] 映射与逗号多路径;裸 --jq 列顶层键").argParser((value, previous = []) => [...previous, value]).default([])).option("--extract <path>", "同 --jq(与 omc call 的 --extract 同名,省一次命名切换)").option("--path-only").option("--shape [path]", "回执形状先验:深度受限骨架(键/类型/数组长度/≤40 字符示例值),一次看全嵌套路径图再 --jq;裸 --shape = 整棵根,--shape <path> = 命中子树(同 --jq 的路径 DSL);与 >8KB 默认 outline 同一实现").option("--depth <n>", "骨架深度 1-4(默认 2;--shape 与 >8KB 默认 outline 消费)").option("--summary").option("--keys [a,b]").option("--full", "整包返回正文(默认:正文超过 8KB 时只回深度 2 骨架 outline,按需 --shape/--jq/--keys 定向取值)").option("--out <path>", "把 artifact 原始正文全量写到配置根内文件(0600;写文件不走 stdout 限额,大对象一次落盘备份;回执只给 {out,bytes,sha256} 不回正文。根内父目录自动创建;配置根外(含系统临时目录)拒绝,拒绝错误里带可用的根内示例路径。stdout 管道提取用两步:--out <根内路径> 后 cat 该文件——`--out -` 会破坏单信封契约,不支持)").option("--max-output-bytes <bytes>").action(async (id, options) => {
|
|
3341
|
+
artifactCommand.command("get <id>").addOption(new Option("--jq [path]", "路径选择器(非 jq);支持 [] 映射与逗号多路径;裸 --jq 列顶层键").argParser((value, previous = []) => [...previous, value]).default([])).option("--extract <path>", "同 --jq(与 omc call 的 --extract 同名,省一次命名切换)").option("--path-only").option("--shape [path]", "回执形状先验:深度受限骨架(键/类型/数组长度/≤40 字符示例值),一次看全嵌套路径图再 --jq;裸 --shape = 整棵根,--shape <path> = 命中子树(同 --jq 的路径 DSL);与 >8KB 默认 outline 同一实现").option("--depth <n>", "骨架深度 1-4(默认 2;--shape 与 >8KB 默认 outline 消费)").option("--summary").option("--keys [a,b]").option("--meta", "只回元数据,不回正文").option("--full", "整包返回正文(默认:正文超过 8KB 时只回深度 2 骨架 outline,按需 --shape/--jq/--keys 定向取值)").option("--out <path>", "把 artifact 原始正文全量写到配置根内文件(0600;写文件不走 stdout 限额,大对象一次落盘备份;回执只给 {out,bytes,sha256} 不回正文。根内父目录自动创建;配置根外(含系统临时目录)拒绝,拒绝错误里带可用的根内示例路径。stdout 管道提取用两步:--out <根内路径> 后 cat 该文件——`--out -` 会破坏单信封契约,不支持)").option("--max-output-bytes <bytes>").action(async (id, options) => {
|
|
3288
3342
|
// A bare `--jq`/`--keys` is a key-inventory request, not a missing argument:
|
|
3289
3343
|
// commander's "argument missing" (invalid-input + retry) is a dead end the
|
|
3290
3344
|
// caller cannot fix without already knowing the flag takes a value (r11
|
|
@@ -3307,6 +3361,7 @@ async function main() {
|
|
|
3307
3361
|
...(shapeValue !== undefined ? { shape: shapeValue } : {}),
|
|
3308
3362
|
...(depthValue !== undefined ? { depth: depthValue } : {}),
|
|
3309
3363
|
summary: options.summary === true || options.keys === true || bareJq,
|
|
3364
|
+
meta: options.meta === true,
|
|
3310
3365
|
pureKeys: (options.keys === true || bareJq) && options.summary !== true, ...(typeof options.keys === "string" ? { keys: options.keys } : {}), full: options.full === true, ...(artifactGetOutPath !== undefined ? { out: artifactGetOutPath } : {})
|
|
3311
3366
|
}));
|
|
3312
3367
|
});
|
|
@@ -3314,7 +3369,7 @@ async function main() {
|
|
|
3314
3369
|
command.command("residue <prefix>").description("跨面前缀残留扫描(model 全租户/folder/custompage;默认 deep 再查命中模型的 rule/datarule/onlinejs)——收尾「删净」一次证明,clean:true 即零残留。清理入口:omc model-purge --code <schemaCode>(按依赖倒序,默认 dry-run)。只读零写入;report 面暂停维护未扫描").option("--env <environment>", "环境名(默认按 cwd 的 .omc-env 解析)").option("--apps <codes>", "all(默认,全租户)或逗号分隔应用码").option("--no-deep", "只扫 model/folder/custompage,不深查命中模型").option("--all-faces", "列出全部应用×面(含 count:0;默认只回非零面+byFace/userResidues 紧凑形)").option("--max-output-bytes <bytes>").addOption(new Option("--jq [path]", "--jq 不是 jq,仅路径选择器(与 call --jq 同 DSL;可逗号多路径;裸 --jq 列顶层键)").argParser((value, previous = []) => [...previous, value]).default([])).action(async (prefix, options) => { commandExitCode = await withTransport(options, request, (transport) => cmdResidue(prefix, { env: options.env, apps: options.apps, ...(options.deep === false ? { noDeep: true } : {}), ...(options.allFaces ? { allFaces: true } : {}), ...(options.jq !== undefined ? { jq: options.jq } : {}) }, transport)); });
|
|
3315
3370
|
command.command("track <schemaCode> <bizObjectId>").description("读取单条业务数据的行级变更留痕(只读;平台来源枚举含 BUSINESS_RULE 时原样回传)").option("--env <environment>").option("--property-code <code>").option("--max-output-bytes <bytes>").action(async (schemaCode, bizObjectId, options) => { commandExitCode = await withTransport(options, request, (transport) => cmdTrack(schemaCode, bizObjectId, { env: options.env, propertyCode: options.propertyCode }, transport)); });
|
|
3316
3371
|
const jqOption = () => new Option("--jq [path]", "--jq 不是 jq,仅路径选择器(与 call --jq 同 DSL;可逗号多路径;裸 --jq 列顶层键)").argParser((value, previous = []) => [...previous, value]).default([]);
|
|
3317
|
-
command.command("commands").description("路由索引(不是目录):工具计数+展开梯子;--kind read 一屏列全部只读工具与必填参数;--json 才是全量目录").option("--json").option("--compact").option("--filter <keyword>").option("--capability <id>").option("--lane <id>").option("--kind <kind>", "按读写维度过滤:read|write|meta(read = 只读工具索引)").option("--read-only", "等价 --kind read(与 --kind 互斥)").option("--limit <n>", "分页:最多 n 行(1..200;给定即关闭宽词分组)").option("--offset <n>", "分页起点(默认 0;未给 --limit 时按 50)").option("--max-output-bytes <bytes>").addOption(jqOption()).action(async (options) => { commandExitCode = await withTransport(options, request, (transport) => cmdDiscovery("commands", transport, undefined, { json: options.json === true, compact: options.compact === true, ...(options.filter ? { filter: options.filter } : {}), ...(options.capability ? { capability: options.capability } : {}), ...(options.lane ? { lane: options.lane } : {}), ...(options.kind !== undefined ? { kind: options.kind } : {}), ...(options.readOnly === true ? { readOnly: true } : {}), ...(options.limit !== undefined ? { limit: options.limit } : {}), ...(options.offset !== undefined ? { offset: options.offset } : {}), ...(options.jq !== undefined ? { jq: options.jq } : {}) })); });
|
|
3372
|
+
command.command("commands").description("路由索引(不是目录):工具计数+展开梯子;--kind read 一屏列全部只读工具与必填参数;--json 才是全量目录").option("--json").option("--compact").option("--inline", "commands --json 超过 32KiB 时仍内联").option("--filter <keyword>").option("--capability <id>").option("--lane <id>").option("--kind <kind>", "按读写维度过滤:read|write|meta(read = 只读工具索引)").option("--read-only", "等价 --kind read(与 --kind 互斥)").option("--limit <n>", "分页:最多 n 行(1..200;给定即关闭宽词分组)").option("--offset <n>", "分页起点(默认 0;未给 --limit 时按 50)").option("--max-output-bytes <bytes>").addOption(jqOption()).action(async (options) => { commandExitCode = await withTransport(options, request, (transport) => cmdDiscovery("commands", transport, undefined, { json: options.json === true, compact: options.compact === true, inline: options.inline === true, ...(options.filter ? { filter: options.filter } : {}), ...(options.capability ? { capability: options.capability } : {}), ...(options.lane ? { lane: options.lane } : {}), ...(options.kind !== undefined ? { kind: options.kind } : {}), ...(options.readOnly === true ? { readOnly: true } : {}), ...(options.limit !== undefined ? { limit: options.limit } : {}), ...(options.offset !== undefined ? { offset: options.offset } : {}), ...(options.jq !== undefined ? { jq: options.jq } : {}) })); });
|
|
3318
3373
|
command.command("describe <tool>").option("--full").option("--cache-ok", "允许 --full 在同会话重复读时短路为 artifact 指针(默认每次回全文)").option("--schema-only").option("--param <name>").option("--example [id]").option("--max-output-bytes <bytes>").addOption(jqOption()).action(async (tool, options) => {
|
|
3319
3374
|
commandExitCode = await withTransport(options, request, (transport) => cmdDiscovery("describe", transport, tool, { full: options.full === true, cacheOk: options.cacheOk === true, schemaOnly: options.schemaOnly === true, ...(options.param ? { param: options.param } : {}), ...(options.example ? { example: options.example } : {}), ...(options.jq !== undefined ? { jq: options.jq } : {}) }));
|
|
3320
3375
|
});
|
|
@@ -37,7 +37,7 @@ export function versionEvidenceOf(input) {
|
|
|
37
37
|
return {
|
|
38
38
|
detectedVersion: detected,
|
|
39
39
|
inAnchorFamily: detected.startsWith(`${input.versionFamily}.`),
|
|
40
|
-
versionSource: "system-config",
|
|
40
|
+
versionSource: input.versionSource ?? "system-config",
|
|
41
41
|
anchorVersion: input.anchorVersion,
|
|
42
42
|
versionFamily: input.versionFamily,
|
|
43
43
|
...(input.versionNotice ? { versionNotice: input.versionNotice } : {}),
|
|
@@ -168,7 +168,7 @@ export const BUSINESSRULE_LANE_CONTRACT = Object.freeze({
|
|
|
168
168
|
// 295,400B,HEAD 4c524b83 实测 295,331 仅余 69B——加对照句即红门)。对照
|
|
169
169
|
// 教学住 read-shapes 的 notes[0](默认 describe 面即回,不进 tools/list);
|
|
170
170
|
// MCP 面的同款对照由 omc_graph_explore 的 description 承担。
|
|
171
|
-
description: "跨规则引用检索:一次调用替代 agent 逐 schema×ruleCode 全平台枚举 rule.get(删服务/模型/字段/规则前的影响面)。kind=service 查 BIZ_ACTION 的 methodMapping.serviceCode;kind=model 查 CREATE/UPDATE/DELETE 的 targetObjectCode 与 methodMapping.schemaCode(删模型前的影响面);kind=field 查 dataActions.targetDataItem、inputMappings/outputMappings 的 bizCode、规则条件叶子(filterCondition/BRANCH 出口等,只认主模型字段)与 datarule(propertyCodes + options 文本;字段 code 跨模型不唯一,建议配 schemaCodes 限范围);kind=rule 查流程事件绑定(flow 级 handler 与节点级 nodeEvent 的 bizActions,按模型枚举流程面)。kind:\"trigger\" 按 schemaCode
|
|
171
|
+
description: "跨规则引用检索:一次调用替代 agent 逐 schema×ruleCode 全平台枚举 rule.get(删服务/模型/字段/规则前的影响面)。kind=service 查 BIZ_ACTION 的 methodMapping.serviceCode;kind=model 查 CREATE/UPDATE/DELETE 的 targetObjectCode 与 methodMapping.schemaCode(删模型前的影响面);kind=field 查 dataActions.targetDataItem、inputMappings/outputMappings 的 bizCode、规则条件叶子(filterCondition/BRANCH 出口等,只认主模型字段)与 datarule(propertyCodes + options 文本;字段 code 跨模型不唯一,建议配 schemaCodes 限范围);kind=rule 查流程事件绑定(flow 级 handler 与节点级 nodeEvent 的 bizActions,按模型枚举流程面)。kind:\"trigger\" 按 schemaCode 列全触发点(流程三面/表单按钮/规则/预置事件/数据规则/在线 JS)。实现为客户端聚合(应用树模型清单→逐模型 rule.list/rule.get 或 get_published),输出只回命中行;各 kind 的覆盖面与协议局限见回执 coverage。",
|
|
172
172
|
}),
|
|
173
173
|
"rule.save": Object.freeze({
|
|
174
174
|
scope: "dead-state CRUD conditional node graphs",
|
|
@@ -14,6 +14,7 @@ import { readFormButtons, readFormOrNull } from "../form-support.js";
|
|
|
14
14
|
import { scanModelWorkflowBindings } from "./workflow.js";
|
|
15
15
|
import { listOtherScriptSources, readCustomScriptSource } from "./online-js.js";
|
|
16
16
|
import { decodeButtonScript } from "./list-view.js";
|
|
17
|
+
import { decodeDataRule, listDataRules } from "./datarule.js";
|
|
17
18
|
import { wireCall, wireCallWith404Fallback, wireRows } from "../wire.js";
|
|
18
19
|
import { readModelRecord } from "../model-record.js";
|
|
19
20
|
import { BUSINESSRULE_LANE_CONTRACT } from "./businessrule-contract.js";
|
|
@@ -791,6 +792,36 @@ const RULE_BIZ_TYPE_TIMING = 2;
|
|
|
791
792
|
* 「多久跑一次、从哪取数」。
|
|
792
793
|
*/
|
|
793
794
|
const TRIGGER_SCHEDULER_KEYS = ["triggerTimeType", "cycleType", "execCycle", "hour", "minute", "startTime", "dataSourceType"];
|
|
795
|
+
/**
|
|
796
|
+
* 数据规则(BizDataRule)在服务端**新增/更新**时执行(8.6.26 反编译:
|
|
797
|
+
* BizObjectManagerImpl.insertBizObject:372-378 / updateBizObject:418-425 →
|
|
798
|
+
* BizDataRuleManagerImpl.executeDataRule;type2 计算走 CalculateHandler)。
|
|
799
|
+
* 所以它是模型的自动化面,不是「表单里才生效」的 UI 配置。
|
|
800
|
+
*
|
|
801
|
+
* 真机采样(local,2026-11-23):多数模型的规则是字段创建时平台自动生成的
|
|
802
|
+
* `dataRuleType:1 + checkType:4` 长度上限(某模型 35 条全是)。逐条列会把真
|
|
803
|
+
* 自动化淹没——这类聚合成一行计数,其余逐条列。
|
|
804
|
+
*/
|
|
805
|
+
const DATARULE_TRIGGER_TYPE_NAMES = Object.freeze({ 1: "校验", 2: "计算", 3: "显示", 4: "必填", 5: "只读" });
|
|
806
|
+
const DATARULE_TRIGGER_CHECK_NAMES = Object.freeze({ 1: "正则", 2: "提交校验", 3: "空行", 4: "最大长度", 5: "重复" });
|
|
807
|
+
const TRIGGER_DATARULE_MAX_ROWS = 30;
|
|
808
|
+
function isAutoMaxLengthRule(row) {
|
|
809
|
+
return Number(row.dataRuleType) === 1 && Number(row.checkType) === 4;
|
|
810
|
+
}
|
|
811
|
+
function dataRuleTriggerRow(row) {
|
|
812
|
+
const dataRuleType = Number(row.dataRuleType);
|
|
813
|
+
const checkType = row.checkType === null || row.checkType === undefined ? null : Number(row.checkType);
|
|
814
|
+
return {
|
|
815
|
+
via: "datarule",
|
|
816
|
+
group: "rule",
|
|
817
|
+
name: typeof row.name === "string" ? row.name : null,
|
|
818
|
+
...(Number.isFinite(dataRuleType) ? { dataRuleType, typeName: DATARULE_TRIGGER_TYPE_NAMES[dataRuleType] ?? "未知" } : {}),
|
|
819
|
+
checkType,
|
|
820
|
+
...(checkType !== null ? { checkName: DATARULE_TRIGGER_CHECK_NAMES[checkType] ?? null } : {}),
|
|
821
|
+
childRule: row.childRule === true,
|
|
822
|
+
propertyCodes: Array.isArray(row.propertyCodes) ? row.propertyCodes.map((code) => String(code)) : [],
|
|
823
|
+
};
|
|
824
|
+
}
|
|
794
825
|
/**
|
|
795
826
|
* 在线 JS 触发点的**文本**匹配:每行至多一条(优先级 axios → fetch( → /api/)。
|
|
796
827
|
* 可能漏动态拼 URL、可能命中注释——这是协议局限,回执标 scanMode:"text"。
|
|
@@ -925,7 +956,7 @@ async function scanSchemaTriggers(session, args) {
|
|
|
925
956
|
const unreadableScriptButtons = [];
|
|
926
957
|
const buttonRows = [];
|
|
927
958
|
if (activityCodeFilter !== undefined) {
|
|
928
|
-
notScanned.push("activityCode
|
|
959
|
+
notScanned.push("activityCode 过滤:表单按钮/规则/预置事件/数据规则/在线 JS 未扫描(只看该流程节点的绑定)");
|
|
929
960
|
}
|
|
930
961
|
else {
|
|
931
962
|
try {
|
|
@@ -1066,6 +1097,37 @@ async function scanSchemaTriggers(session, args) {
|
|
|
1066
1097
|
}
|
|
1067
1098
|
}
|
|
1068
1099
|
}
|
|
1100
|
+
// 4c. 数据规则:服务端新增/更新时执行(见 DATARULE_TRIGGER_TYPE_NAMES 注释)。
|
|
1101
|
+
// 一次 list(+1 wire)。type1/checkType4 是字段创建时自动生成的长度规则,
|
|
1102
|
+
// 聚合一行计数;其余逐条(>30 条截断并点名)。读失败不连坐,进 notScanned。
|
|
1103
|
+
let scannedDataRules = 0;
|
|
1104
|
+
const dataRuleRows = [];
|
|
1105
|
+
if (activityCodeFilter === undefined) {
|
|
1106
|
+
try {
|
|
1107
|
+
const decodedRows = (await listDataRules(session, schemaCode)).map(decodeDataRule);
|
|
1108
|
+
scannedDataRules = decodedRows.length;
|
|
1109
|
+
const autoMaxLength = decodedRows.filter(isAutoMaxLengthRule);
|
|
1110
|
+
const explicitRows = decodedRows.filter((row) => !isAutoMaxLengthRule(row));
|
|
1111
|
+
for (const row of explicitRows.slice(0, TRIGGER_DATARULE_MAX_ROWS))
|
|
1112
|
+
dataRuleRows.push(dataRuleTriggerRow(row));
|
|
1113
|
+
if (explicitRows.length > TRIGGER_DATARULE_MAX_ROWS)
|
|
1114
|
+
notScanned.push(`数据规则 ${explicitRows.length} 条 > ${TRIGGER_DATARULE_MAX_ROWS}:第 ${TRIGGER_DATARULE_MAX_ROWS + 1} 条起未列出(omc call datarule.list --args '{"schemaCode":"${schemaCode}"}' 读全量)`);
|
|
1115
|
+
if (autoMaxLength.length > 0)
|
|
1116
|
+
dataRuleRows.push({
|
|
1117
|
+
via: "datarule",
|
|
1118
|
+
group: "maxLength",
|
|
1119
|
+
count: autoMaxLength.length,
|
|
1120
|
+
dataRuleType: 1,
|
|
1121
|
+
typeName: "校验",
|
|
1122
|
+
checkType: 4,
|
|
1123
|
+
checkName: "最大长度",
|
|
1124
|
+
note: "字段长度上限(平台随字段创建自动生成)——逐条字段与上限见 omc call datarule.list,不是业务自动化",
|
|
1125
|
+
});
|
|
1126
|
+
}
|
|
1127
|
+
catch (error) {
|
|
1128
|
+
notScanned.push(`数据规则读取失败(${error instanceof Error ? error.message : String(error)}):datarule 未扫描`);
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1069
1131
|
// 5. 在线 JS 文本匹配(零 wire;表单 customScript + SCRIPT 按钮脚本。无脚本时
|
|
1070
1132
|
// 第 3 步已记 notScanned)。
|
|
1071
1133
|
const onlineRows = [];
|
|
@@ -1093,7 +1155,7 @@ async function scanSchemaTriggers(session, args) {
|
|
|
1093
1155
|
// 触发视图后仍逐面交叉核对 datarule/programming/视图——因为回执只说了"扫了什么",
|
|
1094
1156
|
// 没说"哪些面本来就不在这里"。把未覆盖面按入口点名列出来,省掉这轮盲目核对;
|
|
1095
1157
|
// 视图/权限不是动作触发点,单独说明"不适用",避免继续查。
|
|
1096
|
-
notScanned.push(
|
|
1158
|
+
notScanned.push(`数据规则只查主模型 schemaCode(${schemaCode}):子表规则多数在主表范围可见,公式镜像行/子表独有规则用 datarule.list --schemaCode <子表code> 复核`, `数据规则的动作内容(公式/校验条件/长度上限)不在本视图: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)");
|
|
1097
1159
|
// 6. 并集 + action/activityCode 过滤(分组顺序:workflow → button → rule → preset → onlinejs)。
|
|
1098
1160
|
let triggers;
|
|
1099
1161
|
if (activityCodeFilter !== undefined) {
|
|
@@ -1107,11 +1169,13 @@ async function scanSchemaTriggers(session, args) {
|
|
|
1107
1169
|
triggers = [
|
|
1108
1170
|
...ruleRows.filter((row) => bound.has(row.ruleCode) || row.ruleCode.toLowerCase() === action),
|
|
1109
1171
|
...presetRows.filter((row) => row.trigger.toLowerCase() === action),
|
|
1172
|
+
// 数据规则在服务端 insert/update 时执行(delete 不跑):create/update 视图带上,delete 不带。
|
|
1173
|
+
...(action === "delete" ? [] : dataRuleRows),
|
|
1110
1174
|
...onlineRows,
|
|
1111
1175
|
];
|
|
1112
1176
|
}
|
|
1113
1177
|
else {
|
|
1114
|
-
triggers = [...workflowRows, ...buttonRows, ...ruleRows, ...presetRows, ...onlineRows];
|
|
1178
|
+
triggers = [...workflowRows, ...buttonRows, ...ruleRows, ...presetRows, ...dataRuleRows, ...onlineRows];
|
|
1115
1179
|
}
|
|
1116
1180
|
const filterNote = action !== undefined && action !== "flow"
|
|
1117
1181
|
? `;action:"${action}" 的规则绑定判据=workflow 行的 activityCode/nodeEvent/handler 或按钮的 buttonCode/targetCode 含「${action}」,或规则 code 就是 ${action}(不区分大小写,启发式;完整清单去掉 action)`
|
|
@@ -1123,10 +1187,10 @@ async function scanSchemaTriggers(session, args) {
|
|
|
1123
1187
|
action: action ?? null,
|
|
1124
1188
|
mode,
|
|
1125
1189
|
triggers,
|
|
1126
|
-
scanned: { workflows, rules: scannedRules, buttons: scannedButtons, buttonScripts: scriptButtonCount, onlinejsBytes, buttonScriptBytes, schedulerReads, schedulerReadFailed },
|
|
1190
|
+
scanned: { workflows, rules: scannedRules, buttons: scannedButtons, buttonScripts: scriptButtonCount, onlinejsBytes, buttonScriptBytes, datarules: scannedDataRules, schedulerReads, schedulerReadFailed },
|
|
1127
1191
|
notScanned,
|
|
1128
1192
|
scanMode: "source",
|
|
1129
|
-
note: "
|
|
1193
|
+
note: "零命中=本次扫描未命中触发点,不代表没有触发;数据规则在服务端新增/更新时执行(1 校验/2 计算/3 显示/4 必填/5 只读;type1+checkType4 的字段长度规则聚合计数);在线 JS(表单 customScript + SCRIPT 按钮脚本)是文本匹配,可能漏动态拼 URL、可能命中注释(命中行带 target;抽不到字面量目标标 targetUnresolved)" + schedulerNote + filterNote,
|
|
1130
1194
|
...(activityCodeFilter !== undefined ? { activityCode: activityCodeFilter } : {}),
|
|
1131
1195
|
applicationResolution: { ...applicationResolutionOf(scope), mode: "trigger", models: 1 },
|
|
1132
1196
|
};
|
|
@@ -1216,7 +1280,7 @@ export function registerBusinessRuleLane(tools) {
|
|
|
1216
1280
|
description: RULE_TOOLS["rule.references"].description,
|
|
1217
1281
|
inputSchema: {
|
|
1218
1282
|
environment: environmentArg,
|
|
1219
|
-
kind: z.enum(["service", "model", "field", "rule", "trigger"]).describe("按什么找引用:service=BIZ_ACTION methodMapping.serviceCode(service 行带 serviceMethodCode);model=CREATE/UPDATE/DELETE targetObjectCode 与 methodMapping.schemaCode;field=dataActions.targetDataItem、映射 bizCode、规则条件叶子与 datarule;rule=流程事件绑定的规则码(flow 级 handler + 节点级 nodeEvent,扫应用内模型的流程面);trigger
|
|
1283
|
+
kind: z.enum(["service", "model", "field", "rule", "trigger"]).describe("按什么找引用:service=BIZ_ACTION methodMapping.serviceCode(service 行带 serviceMethodCode);model=CREATE/UPDATE/DELETE targetObjectCode 与 methodMapping.schemaCode;field=dataActions.targetDataItem、映射 bizCode、规则条件叶子与 datarule;rule=流程事件绑定的规则码(flow 级 handler + 节点级 nodeEvent,扫应用内模型的流程面);trigger=一个模型的全部触发点(流程/按钮/规则/预置/数据规则/在线 JS;code 是 schemaCode,不是规则码)"),
|
|
1220
1284
|
code: z.string().min(1).describe("要查引用的编码(服务/模型/字段 code);kind=field 可用 schemaCode.field 消歧"),
|
|
1221
1285
|
schemaCodes: z.union([z.array(z.string().min(1)), z.string()]).optional().describe("只扫这些模型(省 wire 读);省略=全平台模型"),
|
|
1222
1286
|
action: z.enum(["create", "update", "delete", "flow"]).optional().describe("仅 kind=trigger:动作过滤,省略=全量"),
|
|
@@ -90,7 +90,7 @@ export const DATARULE_LANE_CONTRACT = Object.freeze({
|
|
|
90
90
|
"**类型3/4/5 条件串协议(平台 create 不校验,坏形状落库即雷,工具按此协议拒绝)**:`{字段code} 操作符 [值]`。操作符取 **bizdatarule 词表**(与字段 options 的表单交互引擎不同——那是符号式):**中文** 等于/不等于/大于/小于/大于等于/小于等于/包含/不包含/包含全部/不包含全部/包含任意一个/不包含任意一个/等于任意一个/属于/不属于/介于/为空/不为空,也接受符号 `==` `!=` `>` `<` `>=` `<=` `Contains` `IsEmpty` 等。为空/不为空**不带值**(`{field} 不为空`);其余带值(JSON 对象或标量)。多条件 ` && `、多组 ` || `。示例 type4:`options:{requiredFormula:\"{amount} 等于 {\\\"valueType\\\":\\\"specifyOption\\\",\\\"value\\\":\\\"A\\\"}\"}`。**字段绑定用 `propertyCodes`(数组)**,工具自动把 `options.propertyCodes` 也补上。",
|
|
91
91
|
"`options` is a JSON object sent to the wire as a JSON string(逐类型必读键见 `options` 参数面)。",
|
|
92
92
|
"类型2(计算/拼接):`options.shortTextStitch`(或 `value`)的值**必须是含 `formula` 的 JSON 对象字符串**,裸串会被工具拒绝(否则引擎返回 null → 误报 305003 死循环);顶层没有 `expression` 键——它只是该嵌套 JSON 内部的字段名(可照抄 `--example field-compute-rule`)。",
|
|
93
|
-
"Missing type or schemaCode is refused before any write.",
|
|
93
|
+
"Missing type or schemaCode is refused before any write. 同字段同类型已存在时零写入拒绝(blocker `datarule-duplicate-property-type`,回执带现有 `id` 与改走 `datarule.update` 的命令)——批量造规则不必先 list 自查。",
|
|
94
94
|
"根因提示:类型2 CALCULATE 在未发布应用上会报假死循环 305003——工具反推后拒 app-not-published;类型 3/4/5 不受影响(误判机制见 `--example field-compute-rule`)。",
|
|
95
95
|
]),
|
|
96
96
|
}),
|
package/dist/lanes/datarule.js
CHANGED
|
@@ -115,7 +115,7 @@ function storedTargetCodes(row) {
|
|
|
115
115
|
const single = row.propertyCode;
|
|
116
116
|
return single !== undefined && single !== null && String(single).length > 0 ? [String(single)] : [];
|
|
117
117
|
}
|
|
118
|
-
function decodeDataRule(row) {
|
|
118
|
+
export function decodeDataRule(row) {
|
|
119
119
|
const options = parseOptions(row.options);
|
|
120
120
|
const codes = storedTargetCodes(row);
|
|
121
121
|
const decoded = {
|
|
@@ -670,7 +670,7 @@ function dataRuleChanges(before, after) {
|
|
|
670
670
|
changedFields.push(field);
|
|
671
671
|
return { changedFields, unexpectedChanges: changedFields.filter((field) => !["options", "checkType", "childRule", "name", "sortKey", "propertyCode", "propertyCodes", "dataRuleType"].includes(field)) };
|
|
672
672
|
}
|
|
673
|
-
async function listDataRules(session, schemaCode, dataRuleType) {
|
|
673
|
+
export async function listDataRules(session, schemaCode, dataRuleType) {
|
|
674
674
|
const query = { schemaCode };
|
|
675
675
|
if (dataRuleType !== undefined)
|
|
676
676
|
query.dataRuleType = String(dataRuleType);
|
|
@@ -17,6 +17,7 @@ function versionEvidenceFor(ctx, session) {
|
|
|
17
17
|
const notice = detected ? versionFamilyNotice(ctx.manifest, detected) : undefined;
|
|
18
18
|
return versionEvidenceOf({
|
|
19
19
|
detectedVersion: detected,
|
|
20
|
+
versionSource: session.versionEvidenceSource(),
|
|
20
21
|
versionFamily: ctx.manifest.version_family,
|
|
21
22
|
anchorVersion: ctx.manifest.anchor_version,
|
|
22
23
|
...(notice ? { versionNotice: notice } : {}),
|
|
@@ -39,28 +40,25 @@ function versionEvidenceFor(ctx, session) {
|
|
|
39
40
|
*/
|
|
40
41
|
const EXTENSION_SHA_UNAVAILABLE = "平台没有暴露扩展/前端构件 build sha 的端点(8.6.26 与 1.1.25 反编译 + 真机均无);版本判断只能用 productVersion";
|
|
41
42
|
async function platformVersionBlock(session) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
catch {
|
|
56
|
-
// fall through to the system/config face — the license face is 8.6-only
|
|
57
|
-
}
|
|
43
|
+
// F7:license 载荷在登录期已经探测过(session.licenseInfo),这里复用它,不再
|
|
44
|
+
// 为展示面重复打一次 wire;字段口径与 r86 一致(buildTime 只有平台回传才带)。
|
|
45
|
+
const license = session.licenseInfo();
|
|
46
|
+
const licenseVersion = license && typeof license.systemVersion === "string" && license.systemVersion.trim() ? license.systemVersion.trim() : undefined;
|
|
47
|
+
if (licenseVersion !== undefined && license !== undefined)
|
|
48
|
+
return {
|
|
49
|
+
productVersion: licenseVersion,
|
|
50
|
+
...(typeof license.buildTime === "string" && license.buildTime ? { buildTime: license.buildTime } : {}),
|
|
51
|
+
...(license.licenseType !== undefined && license.licenseType !== null ? { licenseType: license.licenseType } : {}),
|
|
52
|
+
...(typeof license.expiration === "string" && license.expiration ? { licenseExpiration: license.expiration } : {}),
|
|
53
|
+
source: "license/info",
|
|
54
|
+
extensionBuildShaUnavailable: EXTENSION_SHA_UNAVAILABLE,
|
|
55
|
+
};
|
|
58
56
|
const raw = session.rawSystemVersion();
|
|
59
57
|
if (raw !== undefined)
|
|
60
58
|
return {
|
|
61
59
|
productVersion: raw,
|
|
62
60
|
source: "public/system-config systemVersion",
|
|
63
|
-
licenseFaceUnavailable: "license/info 不可达(真机 1.1.25:未认证 401
|
|
61
|
+
licenseFaceUnavailable: "license/info 不可达(真机 1.1.25:未认证 401、管理员 404——该产品线不挂载);buildTime 只在平台回传时才有",
|
|
64
62
|
extensionBuildShaUnavailable: EXTENSION_SHA_UNAVAILABLE,
|
|
65
63
|
};
|
|
66
64
|
// 登录缓存沿用(老缓存只存了点号版本、没有原串):用 detectedVersion 兜底——
|
|
@@ -79,10 +77,10 @@ async function platformVersionBlock(session) {
|
|
|
79
77
|
function platformVersionBlockFromSession(session) {
|
|
80
78
|
const cached = session.rawSystemVersion();
|
|
81
79
|
if (cached !== undefined)
|
|
82
|
-
return { productVersion: cached, source: "public/system-config
|
|
80
|
+
return { productVersion: cached, source: session.versionEvidenceSource() ?? "public/system-config", extensionBuildShaUnavailable: EXTENSION_SHA_UNAVAILABLE };
|
|
83
81
|
const detected = session.detectedVersion();
|
|
84
82
|
if (detected !== undefined)
|
|
85
|
-
return { productVersion: detected, source: "token-cache
|
|
83
|
+
return { productVersion: detected, source: session.versionEvidenceSource() ?? "token-cache", extensionBuildShaUnavailable: EXTENSION_SHA_UNAVAILABLE };
|
|
86
84
|
return { versionUnavailable: "缓存命中面零 wire:license/info 未查,登录缓存也没有版本证据(refresh:true 重查)" };
|
|
87
85
|
}
|
|
88
86
|
export function registerEnvironmentLane(tools) {
|