@stalfh233/omc-cli 0.6.37 → 0.6.39

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.
@@ -10,6 +10,8 @@ import { PROGRAMMING_LANE_CONTRACT, PROGRAMMING_WIRE } from "./programming-contr
10
10
  import { readModelRecord } from "../model-record.js";
11
11
  const LANE = PROGRAMMING_LANE_CONTRACT.lane;
12
12
  const TOOLS = PROGRAMMING_LANE_CONTRACT.tools;
13
+ const PUBLISH_WARNING = "发布不可逆:首次发布将把该规则永久切到在线编码模式,平台不提供退回图形化的端点,无法退回图形化;删除规则会连源码一起删,不是还原。";
14
+ const PUBLISH_RECOVERY = "如需退回默认行为:把源码改为仅调用 super.<method>(...) 并重新 publish(保留规则记录);平台无删除即还原的能力。这只是恢复默认行为,不会恢复图形化模式。";
13
15
  /** metadata.app.CodeType is the NUMERIC index on the wire (8.6.26 source). */
14
16
  const CODE_TYPE_BUSINESS_RULE = 0;
15
17
  /**
@@ -403,6 +405,7 @@ export function registerProgrammingLane(tools) {
403
405
  : presented.errors,
404
406
  platformErrors: presented.platformErrors,
405
407
  userErrors: presented.userErrors,
408
+ evidenceHint: "compile 回执只在本命令 stdout,不落 journal/artifact;对照实验需留证请重定向到文件(> file.json)",
406
409
  ...(result.diagnostics.platformCompilerDegraded ? { platformCompilerDegraded: true, platformCompilerNote: result.diagnostics.platformCompilerNote } : {}),
407
410
  ...(result.success
408
411
  ? {}
@@ -572,7 +575,7 @@ export function registerProgrammingLane(tools) {
572
575
  const publishStatusRaw = readbackRule?.publishStatus;
573
576
  return {
574
577
  performed: { errcode: 0, code, contentSha256: sha256(content), contentBytes: Buffer.byteLength(content, "utf8"), compiled: true },
575
- rollbackReceipt: { supported: false, reason: "无图形化回退端点;rollback plan 亦标 irreversible" },
578
+ rollbackReceipt: { supported: false, reason: "无图形化回退端点;rollback plan 亦标 irreversible", recovery: PUBLISH_RECOVERY },
576
579
  runtimeVerification: { note: "自定义规则无调用响应体读面;验证须写副作用后用 data.load 读取" },
577
580
  readback: {
578
581
  present: readbackSource.present,
@@ -581,6 +584,7 @@ export function registerProgrammingLane(tools) {
581
584
  enabled,
582
585
  authoritative: "developmentMode+enabled",
583
586
  runtimeEffective,
587
+ effectiveDelayHint: "发布有 30-60s 刷新延迟:runtimeEffective:published ≠ 立即生效。验证前等 30-60s 或连打两次同一请求;首次执行跑旧逻辑别急着改代码(r53 真机实测)",
584
588
  ...(publishStatusRaw === undefined
585
589
  ? {}
586
590
  : publishStatusRaw === null
@@ -617,7 +621,14 @@ export function registerProgrammingLane(tools) {
617
621
  const compiled = await compileSource(session, code, content);
618
622
  if (!compiled.success)
619
623
  throw new ToolRefusalError({ status: "refused", blocker: "programming-compile-failed", message: "编译失败,拒绝 dry-run(真写也会拒绝发布)。", errors: compiled.presented.errors ?? compiled.errors, userErrors: compiled.presented.userErrors, platformErrors: compiled.presented.platformErrors });
620
- return { code, contentSha256: sha256(content), contentBytes: Buffer.byteLength(content, "utf8"), note: "dry-run 与真写执行相同的规则存在、模板形状、编译 preflight;不会写入或切 CODING。" };
624
+ return {
625
+ code,
626
+ contentSha256: sha256(content),
627
+ contentBytes: Buffer.byteLength(content, "utf8"),
628
+ warning: PUBLISH_WARNING,
629
+ rollback: { supported: false, reason: "无图形化回退端点;删除规则才会连源码一起删", recovery: PUBLISH_RECOVERY },
630
+ note: "dry-run 与真写执行相同的规则存在、模板形状、编译 preflight;不会写入或切 CODING。",
631
+ };
621
632
  },
622
633
  rollback: publishRollback(),
623
634
  });
@@ -40,7 +40,7 @@ export function ruleDisableDescription() {
40
40
  * and the rule's UPDATE node really rewrote the row's field.
41
41
  */
42
42
  export function ruleRunDescription() {
43
- return `手动执行一条【自定义触发】业务规则(平台按钮同款面:\`POST /api/api/launcher/domain_service_runtime/<schemaCode>/<ruleCode>\`,body \`{schemaCode, ids:[bizObjectId…], ruleCode, consolidation}\`)。用于端到端验证按钮/自定义规则——**列表或表单按钮(\`listview.configure\` 的 \`buttons\` + \`bindAction:BUSINESS_RULE\`)点击时发给平台的就是这笔请求**(Playwright 抓包 + 容器日志双证,1.1.25)。前提:规则必须是**自定义 code**(\`defaultRule:false\`,图里有 CUSTOM_NODE 触发节点)且 **enabled:true**——禁用规则按钮不可用,工具回 \`rule-run-disabled\` 并指向 \`rule.enable\`;预置触发码(Create/Update/…)由数据事件分发,按钮选择器不提供,工具回 \`rule-run-preset-rule\`。**返回的 data 是执行前快照**(前端发 reacquireDataFromDb:false),规则的副作用要用 \`data.load\`/\`data.list\` 另行读回。\`302045\` = 数据被占用(有人正在编辑该行),稍后重试。`;
43
+ return `手动执行一条【自定义触发】业务规则(平台按钮同款面:\`POST /api/api/launcher/domain_service_runtime/<schemaCode>/<ruleCode>\`,body \`{schemaCode, ids:[bizObjectId…], ruleCode, consolidation}\`)。用于端到端验证按钮/自定义规则——**列表或表单按钮(\`listview.configure\` 的 \`buttons\` + \`bindAction:BUSINESS_RULE\`)点击时发给平台的就是这笔请求**(Playwright 抓包 + 容器日志双证,1.1.25)。前提:规则必须是**自定义 code**(\`defaultRule:false\`,图里有 CUSTOM_NODE 触发节点)且 **enabled:true**——禁用规则按钮不可用,工具回 \`rule-run-disabled\` 并指向 \`rule.enable\`;预置触发码(Create/Update/…)由数据事件分发,按钮选择器不提供,工具回 \`rule-run-preset-rule\`。**返回的 data 是执行前快照**(前端发 reacquireDataFromDb:false),规则的副作用要用 \`data.load\`/\`data.list\` 另行读回;本面不回 handle 的返回值,要拿返回值走 v2 invoke(/api/api/v2/businessRule/invoke)。\`302045\` = 数据被占用(有人正在编辑该行),稍后重试。`;
44
44
  }
45
45
  export const RULE_LIFECYCLE_LANE_CONTRACT = Object.freeze({
46
46
  lane: LANES.ruleLifecycle,
@@ -3,10 +3,11 @@ import { ENDPOINTS } from "../endpoints.js";
3
3
  import { capabilityArg, environmentArg } from "../args.js";
4
4
  import { governedRead } from "../read.js";
5
5
  import { defineTool } from "../tool-types.js";
6
- import { wireCall } from "../wire.js";
6
+ import { wireCall, wireRows } from "../wire.js";
7
7
  import { RULELOG_LANE_CONTRACT } from "./rulelog-contract.js";
8
8
  const path = (template, schemaCode) => template.replace("{schemaCode}", encodeURIComponent(schemaCode));
9
- const notes = ["日志异步落库约 5 秒,未见不等于未触发", "成功/失败日志按平台配置天数清理,历史有限", "CODING 模式在线开发 Java 规则不记日志"];
9
+ const codingNote = "CODING 模式在线开发 Java 规则不记日志";
10
+ const notes = [codingNote, "日志异步落库约 5 秒,未见不等于未触发", "成功/失败日志按平台配置天数清理,历史有限"];
10
11
  export function registerRuleLogLane(tools) {
11
12
  tools.push(defineTool({
12
13
  name: "rulelog.search", layer: "low", kind: "read", lane: RULELOG_LANE_CONTRACT.lane,
@@ -19,6 +20,23 @@ export function registerRuleLogLane(tools) {
19
20
  },
20
21
  handler: async (ctx, args, self) => governedRead(ctx, self, args, async (session) => {
21
22
  const requestedPage = args.page ?? 0, requestedSize = args.size ?? 20;
23
+ let coding = false;
24
+ if (args.ruleCode) {
25
+ try {
26
+ const rules = wireRows((await wireCall(session, { path: ENDPOINTS.businessRuleListBySchemaCode, query: { schemaCode: args.schemaCode } })).data);
27
+ const rule = rules.find((row) => row.code === args.ruleCode);
28
+ // The list face can omit mode; read the same detail face as rule.get.
29
+ const detail = rule?.developmentMode === undefined && rule?.id
30
+ ? (await wireCall(session, { path: ENDPOINTS.businessRuleGet, query: { id: String(rule.id) } })).data
31
+ : rule;
32
+ const mode = detail?.developmentMode;
33
+ coding = mode === 1 || mode === "1" || mode === "CODING";
34
+ }
35
+ catch {
36
+ // Metadata failure must not hide available logs; the first note warns
37
+ // about the CODING blind spot without claiming this rule is CODING.
38
+ }
39
+ }
22
40
  const fetch = async (page, size) => {
23
41
  const body = { page, size };
24
42
  for (const [key, value] of [["startTime", args.since], ["endTime", args.until], ["ruleCode", args.ruleCode], ["status", args.status]])
@@ -68,7 +86,7 @@ export function registerRuleLogLane(tools) {
68
86
  }
69
87
  return log;
70
88
  }));
71
- return { index: { schemaCode: args.schemaCode, page: requestedPage, size: requestedSize, totalElements: data.totalElements ?? logs.length, totalPages: data.totalPages ?? 0, ...(rowFilter ? { rowFilter } : {}) }, logs, notes: ["status=true 表示成功,status=false 表示失败", ...notes, ...(args.includeNodes === true ? ["节点 VO 不提供 targetBizObjectId,节点行级 id 不可得;仅前 3 条命中日志拉取节点链", "QUERY 节点日志不记录命中数:matchedUnknown=true;0 行与成功同形,请用 data.load 比对目标行"] : [])] };
89
+ return { ...(coding ? { traceable: false, traceNote: "该规则为 CODING 模式,平台不记规则日志;执行痕迹用 data.load 比对业务字段或看容器日志" } : {}), index: { schemaCode: args.schemaCode, page: requestedPage, size: requestedSize, totalElements: data.totalElements ?? logs.length, totalPages: data.totalPages ?? 0, ...(rowFilter ? { rowFilter } : {}) }, logs, notes: [...notes, "status=true 表示成功,status=false 表示失败", ...(args.includeNodes === true ? ["节点 VO 不提供 targetBizObjectId,节点行级 id 不可得;仅前 3 条命中日志拉取节点链", "QUERY 节点日志不记录命中数:matchedUnknown=true;0 行与成功同形,请用 data.load 比对目标行"] : [])] };
72
90
  }, { target: `rulelog.search:${args.schemaCode}:${JSON.stringify(args)}` }),
73
91
  }));
74
92
  }
@@ -13,6 +13,7 @@ import { closestMatch } from "../closest-match.js";
13
13
  import { getReplayToken, listInstanceActivities, searchWorkItems, wireString } from "../workflow-support.js";
14
14
  import { PLATFORM_ADMIN_START_BYPASS, resolvePermissionActor } from "../identity.js";
15
15
  import { ENGINE_OWNED_KEYS, RUNTIME_DATA_LANE_CONTRACT, RUNTIME_DATA_WIRE, runtimeFormDataArg, } from "./runtime-data-contract.js";
16
+ import { SYSTEM_FIELD_CODES } from "../field-families.js";
16
17
  import { applicationResolutionOf, resolveApplicationScope } from "../support.js";
17
18
  /** r29b F8: keep ids/itemsPreview through governedRead's compact diet. */
18
19
  const DATA_LIST_PREVIEW_LIMIT = 20;
@@ -288,6 +289,26 @@ const RUNTIME_ENGINE_RECORD_KEYS = new Set([
288
289
  "owner", "creater", "modifier", "createdDeptId", "ownerDeptId", "ownerDeptQueryCode",
289
290
  "createdBy", "modifiedBy",
290
291
  ]);
292
+ // Same reserved catalogue as field.list, plus runtime identity/time aliases
293
+ // and staff/dept keys removed by compactRuntimeRecord. Flow internals end in _.
294
+ const RUNTIME_SYSTEM_FIELD_CODES = new Set([
295
+ ...SYSTEM_FIELD_CODES, ...RUNTIME_ENGINE_RECORD_KEYS,
296
+ "bizObjectId", "schemaCode", "updatedTime", "creator", "updater", "parentId", "sortKey",
297
+ ]);
298
+ function emptyBusinessProjection(items) {
299
+ let businessColumns = 0;
300
+ for (const item of items) {
301
+ for (const [key, value] of Object.entries(item.fields)) {
302
+ if (RUNTIME_SYSTEM_FIELD_CODES.has(key) || key.endsWith("_"))
303
+ continue;
304
+ businessColumns += 1;
305
+ if (value !== null && value !== undefined)
306
+ return false;
307
+ }
308
+ }
309
+ return items.length > 0 && businessColumns > 0;
310
+ }
311
+ const VIEW_PROJECTION_HINT = "该面仅回视图投影列;业务字段全 null 不代表未写入,真值用 data.load,或用 listview.configure 配列。";
291
312
  /**
292
313
  * Default-compact a runtime record: drop only KNOWN engine noise — `*_` keys are
293
314
  * flow-engine internals (`activityName_`, `participants_`, …) and the staff/dept
@@ -367,9 +388,34 @@ function projectReadbackRecord(record, args) {
367
388
  * while `data.load` a moment later had every business field). Without a note the
368
389
  * caller reads that as "the write dropped my data" and writes again.
369
390
  */
391
+ function submittedBusinessFields(formData) {
392
+ return Object.entries(formData).filter(([key]) => !RUNTIME_SYSTEM_FIELD_CODES.has(key) && !key.endsWith("_"));
393
+ }
394
+ function ignoredNullDiagnostic(formData) {
395
+ const ignoredNull = submittedBusinessFields(formData).filter(([, value]) => value === null).map(([key]) => key);
396
+ return ignoredNull.length > 0 ? {
397
+ ignoredNull,
398
+ ignoredNullNote: "这些字段传了 null:平台写面把 null 当「未提交」,不会清空;当前版本无已验证的通用清空语义,不要把成功回执当作清空成功(r53 真机复现)",
399
+ } : {};
400
+ }
401
+ function unknownFieldDiagnostic(formData, fieldCodes, childCodes, schemaLoaded) {
402
+ if (!schemaLoaded || !fieldCodes)
403
+ return schemaLoaded ? {} : {
404
+ unknownFieldKeysNote: "未能读取已发布 field.list,本次未覆盖未知字段键;子表行键也未检查。需要时用 model.inspect/field.list 核对 fieldCodes",
405
+ };
406
+ const known = new Set(fieldCodes);
407
+ const children = new Set(childCodes ?? []);
408
+ const unknownFieldKeys = Object.entries(formData)
409
+ .filter(([key, value]) => value !== null && !RUNTIME_SYSTEM_FIELD_CODES.has(key) && !key.endsWith("_") && !known.has(key) && !children.has(key) && !(value && typeof value === "object" && !Array.isArray(value) && key === "id"))
410
+ .map(([key]) => key);
411
+ return unknownFieldKeys.length > 0 ? {
412
+ unknownFieldKeys,
413
+ unknownFieldKeysNote: "这些键不在模型 schema 里,平台写面会静默丢弃(errcode 0)——多半是驼峰/下划线或字段编码写错;对照 model.inspect 的 fieldCodes 改键名。子表 row 内部键未检查(需另读子表 schema)",
414
+ } : {};
415
+ }
370
416
  function readbackEmptyFields(formData, record) {
371
417
  const source = record !== null && typeof record === "object" && !Array.isArray(record) ? record : {};
372
- return Object.entries(formData)
418
+ return submittedBusinessFields(formData)
373
419
  .filter(([key, value]) => value !== null && value !== undefined && (source[key] === null || source[key] === undefined))
374
420
  .map(([key]) => key);
375
421
  }
@@ -782,7 +828,7 @@ async function prepareRuntimeFormData(session, schemaCode, formData, opts) {
782
828
  if (loaded)
783
829
  assertRuntimeFieldValueShapes(loaded.meta, formData, loaded.childCodes, { schemaCode, isUpdate: opts.isUpdate });
784
830
  const stamped = await stampChildRowStatuses(session, schemaCode, formData, loaded);
785
- return { formData: stamped.formData, childCodes: stamped.childCodes, serialNumberCodes: loaded ? [...loaded.meta].filter(([, field]) => field.serialNumber).map(([code]) => code) : [] };
831
+ return { formData: stamped.formData, childCodes: stamped.childCodes, serialNumberCodes: loaded ? [...loaded.meta].filter(([, field]) => field.serialNumber).map(([code]) => code) : [], fieldCodes: loaded ? [...loaded.meta.keys()] : undefined, schemaLoaded: loaded !== null };
786
832
  }
787
833
  /**
788
834
  * Translate a platform DATE options.format into a validator regex. The format
@@ -1042,8 +1088,8 @@ export function registerRuntimeDataLane(tools) {
1042
1088
  orders: z.array(z.object({ field: z.string().min(1), dir: z.enum(["ASC", "DESC"]) })).optional().describe("运行面 query/list 不支持服务端排序;排序请用 listview.configure 的 sorts(视图级)或在本地对 items 排序"),
1043
1089
  mobile: z.boolean().optional(),
1044
1090
  showTotal: z.boolean().default(true),
1045
- page: z.number().int().min(0).default(0),
1046
- size: z.number().int().min(1).max(200).default(10),
1091
+ page: z.number().int().min(0).default(0).describe("页码,从 0 开始(不是每页条数);每页条数用 size"),
1092
+ size: z.number().int().min(1).max(200).default(10).describe("每页条数,默认 10、上限 200;页码用 page(从 0 开始)"),
1047
1093
  all: z.boolean().optional().describe("true 时自动翻页聚合全部结果(size=200 逐页,上限 1000 行,超出 resultTruncated:true);与 page 互斥;默认 size=10,视图 pagingSetting.pageSize 不生效"),
1048
1094
  full: z.boolean().optional().describe("内联完整列表结果;默认大结果只返回计数与 detailFile"),
1049
1095
  // r31 (2026-10-31 real machine): agents pass `query: {field: value}` as a
@@ -1286,6 +1332,7 @@ export function registerRuntimeDataLane(tools) {
1286
1332
  itemsReturned: collected.length,
1287
1333
  resultTruncated: truncatedByCap,
1288
1334
  itemsExternalized: false,
1335
+ ...(emptyBusinessProjection(items) ? { viewProjectionOnly: true, hint: VIEW_PROJECTION_HINT } : {}),
1289
1336
  // r29b F8 的 ids/itemsPreview 由 compact(外置时)现算,不在这里内联——
1290
1337
  // 内联会让小结果越过 2048B 外置阈值,反而把 items 挤成 []。
1291
1338
  ...(truncatedByCap
@@ -1378,8 +1425,7 @@ export function registerRuntimeDataLane(tools) {
1378
1425
  // back null while `data.load` shows the real values. That reads as
1379
1426
  // "the write failed". Detect an all-null business projection (items
1380
1427
  // present, zero non-null business values) and say so.
1381
- const businessKeys = fields ?? Object.keys(items[0]?.fields ?? {}).filter((field) => !["id", "bizObjectId", "schemaCode", "sequenceStatus", "createdTime", "updatedTime", "creator", "updater", "name"].includes(field));
1382
- const projectionEmpty = items.length > 0 && businessKeys.length > 0 && items.every((item) => businessKeys.every((key) => item.fields[key] === null || item.fields[key] === undefined));
1428
+ const projectionEmpty = emptyBusinessProjection(items);
1383
1429
  const preview = dataListItemPreview(items);
1384
1430
  const requestedPage = args.page ?? 0;
1385
1431
  // r31b F9: an out-of-range page can answer total:0 / totalPages:1 (platform),
@@ -1399,7 +1445,8 @@ export function registerRuntimeDataLane(tools) {
1399
1445
  });
1400
1446
  const probePage = extractBizObjectPage(probe.data);
1401
1447
  total = probePage.total;
1402
- totalPages = probePage.totalPages;
1448
+ // Probe uses size:1; its totalPages is NOT the requested page size.
1449
+ totalPages = Math.ceil(Number(total ?? 0) / (args.size ?? 10));
1403
1450
  pageOutOfRange = Number(probePage.total ?? 0) > 0 || (probePage.totalPages > 0 && requestedPage >= probePage.totalPages);
1404
1451
  }
1405
1452
  else if (totalPages > 0 && requestedPage >= totalPages) {
@@ -1424,6 +1471,7 @@ export function registerRuntimeDataLane(tools) {
1424
1471
  schemaCode: args.schemaCode,
1425
1472
  ...application,
1426
1473
  ...(projectionEmpty ? { projectionWarning: { reason: "business-columns-null", hint: "模型可能未配置列表视图:data.list 只投影列表列,业务列会全为 null;核对写入结果请用 data.load(或先建列表视图)" } } : {}),
1474
+ ...(projectionEmpty ? { viewProjectionOnly: true, hint: VIEW_PROJECTION_HINT } : {}),
1427
1475
  ...(args.queryCode !== undefined ? { queryCode: args.queryCode } : {}),
1428
1476
  total,
1429
1477
  // This branch is the non-`all` read. `excludedDraft` used to be
@@ -1457,7 +1505,7 @@ export function registerRuntimeDataLane(tools) {
1457
1505
  itemsExternalized: false,
1458
1506
  page: page.page ?? requestedPage,
1459
1507
  size: page.size ?? args.size ?? 20,
1460
- ...(pageOutOfRange ? { pageOutOfRange: true, emptyPage: true } : {}),
1508
+ ...(pageOutOfRange ? { pageOutOfRange: true, emptyPage: true, hint: `page 从 0 开始,当前传了 ${requestedPage};合法范围 0..${Math.max(0, totalPages - 1)}。` } : {}),
1461
1509
  // r29b F8 的 ids/itemsPreview 由 compact(外置时)现算,见 dataListCompactProjection。
1462
1510
  items,
1463
1511
  };
@@ -1572,7 +1620,9 @@ export function registerRuntimeDataLane(tools) {
1572
1620
  const { sheetCode, resolvedFrom } = await resolveFormSheetCode(session, { schemaCode: args.schemaCode, sheetCode: args.sheetCode });
1573
1621
  const rawSaveData = args.formData;
1574
1622
  const saveIsUpdate = typeof rawSaveData.id === "string" && rawSaveData.id.trim().length > 0;
1575
- const formData = (await prepareRuntimeFormData(session, args.schemaCode, rawSaveData, { isUpdate: saveIsUpdate })).formData;
1623
+ const prepared = await prepareRuntimeFormData(session, args.schemaCode, rawSaveData, { isUpdate: saveIsUpdate });
1624
+ const formData = prepared.formData;
1625
+ const writeDiagnostics = { ...ignoredNullDiagnostic(formData), ...unknownFieldDiagnostic(formData, prepared.fieldCodes, prepared.childCodes, prepared.schemaLoaded) };
1576
1626
  // issue#9 C1 + issue#10 勘误:提交面(submit:true / data.submit)的人员字段
1577
1627
  // 两种已知形状都不安全——对象数组有历史 50000 证据(UserBizField.fillClientContent,
1578
1628
  // 本闸拦截),字符串 id 数组在 8.6.41 实测同样 50000(#10 D)。可靠链路只有一条:
@@ -1675,7 +1725,7 @@ export function registerRuntimeDataLane(tools) {
1675
1725
  sequenceStatus = extractSequenceStatus((readbackData ?? {}));
1676
1726
  return {
1677
1727
  performed: { errcode: performed.errcode, ...application, bizObjectId: returnedId, workflowInstanceId, workItemId, workItemSource, sheetCode, resolvedFrom, formType: "save-draft-workflow" },
1678
- readback: { ...application, authoritative: projectReadbackRecord(normalizeLoadedRecord((readbackData ?? {})), args), sequenceStatus, expectedSequenceStatus: "DRAFT" },
1728
+ readback: { ...application, ...writeDiagnostics, authoritative: projectReadbackRecord(normalizeLoadedRecord((readbackData ?? {})), args), sequenceStatus, expectedSequenceStatus: "DRAFT" },
1679
1729
  };
1680
1730
  }
1681
1731
  let performed;
@@ -1704,12 +1754,17 @@ export function registerRuntimeDataLane(tools) {
1704
1754
  const savedRecord = normalizeLoadedRecord((readbackData ?? {}));
1705
1755
  const savedEmptyFields = readbackEmptyFields(formData, savedRecord);
1706
1756
  const dataWarnings = await runtimeDataWarnings(session, args.schemaCode, sheetCode, formData, 1);
1757
+ const publishedWorkflow = await resolvePublishedWorkflowCode(session, args.schemaCode);
1758
+ const workflowDraftHint = publishedWorkflow
1759
+ ? `本模型有已发布流程 ${publishedWorkflow},不能用 submit:true 一调完成态;要走三段:① data.save {schemaCode:"${args.schemaCode}", workflowCode:"${publishedWorkflow}", formData:{...}} 新建流程草稿 → ② 从回执 performed 取 bizObjectId / workItemId / workflowInstanceId → ③ data.submit {schemaCode:"${args.schemaCode}", bizObjectId:"<bizObjectId>", workItemId:"<workItemId>", workflowInstanceId:"<workflowInstanceId>"} 提交起始待办(后续审批用 workitem 面;不保证立即完成态);本次无实例草稿不能原地起流程`
1760
+ : null;
1707
1761
  const plainReadback = {
1708
1762
  ...application,
1763
+ ...writeDiagnostics,
1709
1764
  authoritative: projectReadbackRecord(savedRecord, args),
1710
1765
  ...(savedEmptyFields.length > 0 ? { readbackWarning: readbackWarningFor(savedEmptyFields, "data.save") } : {}),
1711
1766
  ...(dataWarnings.length > 0 ? { warnings: dataWarnings } : {}),
1712
- draftRuleHint: "草稿态(DRAFT)保存不触发业务规则——DRAFT 行跳过 Create/Update 分发(DomainServiceImpl.java:240-248);要一调完成态本调用加 submit:true;已存草稿直提形状:data.submit {schemaCode, bizObjectId: 本读回的 bizObjectId, formData}(submit 自持久化)",
1767
+ draftRuleHint: workflowDraftHint ?? "草稿态(DRAFT)保存不触发业务规则——DRAFT 行跳过 Create/Update 分发(DomainServiceImpl.java:240-248);要一调完成态本调用加 submit:true;已存草稿直提形状:data.submit {schemaCode, bizObjectId: 本读回的 bizObjectId, formData}(submit 自持久化)",
1713
1768
  };
1714
1769
  // r18 retro (G3): one-call COMPLETED creation — the agent goal is usually
1715
1770
  // "record AND rule effect", not "a draft". Chain the no-flow submit in
@@ -1719,7 +1774,6 @@ export function registerRuntimeDataLane(tools) {
1719
1774
  // (resolvePublishedWorkflowCode → formType 1 → PROCESSING, not
1720
1775
  // COMPLETED) — the one-call chain's ruleHint would lie. Workflow-
1721
1776
  // backed models keep the two-phase chain.
1722
- const publishedWorkflow = await resolvePublishedWorkflowCode(session, args.schemaCode);
1723
1777
  if (publishedWorkflow) {
1724
1778
  return {
1725
1779
  performed: { errcode: performed.errcode, bizObjectId, sheetCode, resolvedFrom, submitted: false },
@@ -1728,7 +1782,7 @@ export function registerRuntimeDataLane(tools) {
1728
1782
  submitRefused: {
1729
1783
  blocker: "submit-model-has-workflow",
1730
1784
  workflowCode: publishedWorkflow,
1731
- message: `本模型有已发布流程 ${publishedWorkflow}:submit:true 的直提只适用无流程模型(流程模型会自动起流程得到 PROCESSING 而非完成态,Create 规则语义也不同)。草稿已保存;正确链路 = data.save {workflowCode} 建流程草稿(返回 workItemId)→ data.submit {bizObjectId, workflowInstanceId, workItemId}(见 describe data.submit --example workflow-backed-data-submit)`,
1785
+ message: `草稿已保存;${workflowDraftHint}(见 describe data.submit --example workflow-backed-data-submit)`,
1732
1786
  },
1733
1787
  },
1734
1788
  };
@@ -1751,6 +1805,7 @@ export function registerRuntimeDataLane(tools) {
1751
1805
  performed: { errcode: performed.errcode, bizObjectId, sheetCode, resolvedFrom, submitted: true },
1752
1806
  readback: {
1753
1807
  ...okOutcome.readback,
1808
+ ...writeDiagnostics,
1754
1809
  submitted: true,
1755
1810
  ruleHint: "已直提 COMPLETED——Create 业务规则本次已分发;规则效果以本读回字段值为准",
1756
1811
  },
@@ -1795,6 +1850,7 @@ export function registerRuntimeDataLane(tools) {
1795
1850
  }
1796
1851
  const prepared = await prepareRuntimeFormData(session, args.schemaCode, args.formData, { isUpdate: true });
1797
1852
  const formData = prepared.formData;
1853
+ const writeDiagnostics = { ...ignoredNullDiagnostic(formData), ...unknownFieldDiagnostic(formData, prepared.fieldCodes, prepared.childCodes, prepared.schemaLoaded) };
1798
1854
  const existingRecord = normalizeLoadedRecord(existing);
1799
1855
  // r29b F6: 少传行 ≠ 删除。写前比一次,缺 Deleted 时只给 warning。
1800
1856
  const omitWarnings = childRowsNotDeletedWarnings(formData, existingRecord ?? undefined, prepared.childCodes);
@@ -1826,6 +1882,7 @@ export function registerRuntimeDataLane(tools) {
1826
1882
  // both faces.
1827
1883
  readback: {
1828
1884
  authoritative: projectReadbackRecord(updatedRecord, args),
1885
+ ...writeDiagnostics,
1829
1886
  sequenceStatus,
1830
1887
  ...(updatedEmptyFields.length > 0 ? { readbackWarning: readbackWarningFor(updatedEmptyFields, "data.update") } : {}),
1831
1888
  ...(omitWarnings.length > 0 ? { warnings: omitWarnings } : {}),
@@ -1862,7 +1919,7 @@ export function registerRuntimeDataLane(tools) {
1862
1919
  lane: RUNTIME_LANE,
1863
1920
  scope: RUNTIME_TOOLS["data.delete"].scope,
1864
1921
  description: RUNTIME_TOOLS["data.delete"].description,
1865
- inputSchema: { schemaCode: z.string().min(1), sheetCode: z.string().optional(), bizObjectId: z.string().min(1).optional(), bizObjectIds: z.array(z.string().min(1)).optional().describe("批量删除多个业务对象 id(等价于逐个 data.delete,但只花一次往返;返回 deleted 列表)") },
1922
+ inputSchema: { schemaCode: z.string().min(1), sheetCode: z.string().optional(), bizObjectId: z.string().min(1).optional(), bizObjectIds: z.array(z.string().min(1)).optional().describe("批量删除多个业务对象 id。⚠ 1.1.x 真机实证批量是**假成功**(回执说删了、行仍在)——本工具会直接拒绝并要求逐条 bizObjectId 单删;别先撞一次") },
1866
1923
  // r29b F10: dry-run 也必须拦 1.1.x 批量假成功,否则「计划能过、执行不能过」。
1867
1924
  dryRunPayload: async (session, args) => {
1868
1925
  const ids = args.bizObjectIds && args.bizObjectIds.length > 0 ? args.bizObjectIds : args.bizObjectId ? [args.bizObjectId] : [];
@@ -372,7 +372,7 @@ function describeScaffoldPlan(options) {
372
372
  `field.create ×${options.fields.length}(含子表挂载)`,
373
373
  ...childTables.map((field) => `child field.create ×${scaffoldChildrenOf(field).length} on ${field.code}`),
374
374
  "field.publish(主模型;子表列随主模型一起校验)",
375
- ...(options.publishForm ? [`form.publish ${options.code} --rebuild`] : []),
375
+ ...(options.publishForm ? [`form.publish ${options.code} --rebuild(会重发布单控件 id,回不到原 id)`] : []),
376
376
  ],
377
377
  };
378
378
  }
@@ -232,6 +232,7 @@ const PATH_KEY_ALIASES = Object.freeze({
232
232
  application: "applications",
233
233
  app: "applications",
234
234
  models: "items",
235
+ items: "models",
235
236
  rows: "items",
236
237
  list: "items",
237
238
  content: "publishedContent",
@@ -468,7 +469,29 @@ export function projectResultExtract(result, paths, keysOnly) {
468
469
  // r27 真机:多路径时每条 miss 都带 695 B 完整语法 → 3 条 2 KB 说同一件事。
469
470
  // 单路径照旧带完整提示(只出现一次,最有用);多路径逐条只给定位,语法放顶层一次。
470
471
  const multiPath = paths.length > 1;
471
- const missHintFor = (at, available) => multiPath ? pathMissEntryHint(at, available) : PATH_MISS_HINT;
472
+ const missHintFor = (path, at, available) => {
473
+ const fallback = multiPath ? pathMissEntryHint(at, available) : PATH_MISS_HINT;
474
+ const candidate = pathMissDidYouMean(at, available);
475
+ if (candidate === undefined || at === undefined)
476
+ return fallback;
477
+ // Replace only the missed segment, retaining array mapping and suffixes.
478
+ const leaf = at.split(/[./\[]/).filter(Boolean).pop();
479
+ if (leaf === undefined)
480
+ return fallback;
481
+ let replaced = false;
482
+ const corrected = path.replace(/[^.[\]/]+/g, (segment, offset) => {
483
+ const prefix = path.slice(0, offset + segment.length).replace(/^[.$/]+/, "");
484
+ if (replaced || segment !== leaf || (at !== leaf && prefix !== at))
485
+ return segment;
486
+ replaced = true;
487
+ return candidate;
488
+ });
489
+ // A similar key is useful only if the complete proposed path resolves.
490
+ if (corrected === path || projectPathOnSource(projectionSource, corrected).projected.missed)
491
+ return fallback;
492
+ const quoted = corrected.replace(/'/g, "'\\''");
493
+ return `路径未命中:在 "${at}" 断开;最接近的是 ${candidate}。可试:--jq '${quoted}'`;
494
+ };
472
495
  out.extract = paths.map((path) => {
473
496
  // r28f F2:对象构造 / 函数调用不是 pathMiss——先识别,别伪装成键缺失。
474
497
  const unsupported = detectUnsupportedJqSyntax(path);
@@ -502,7 +525,7 @@ export function projectResultExtract(result, paths, keysOnly) {
502
525
  missedEntries: fan.missedEntries,
503
526
  ...(didYouMean !== undefined ? { didYouMean } : {}),
504
527
  ...(readFromArtifact ? resultLayerNote(result, path) ?? {} : {}),
505
- hint: missHintFor(fan.at, fan.available),
528
+ hint: missHintFor(path, fan.at, fan.available),
506
529
  };
507
530
  }
508
531
  return {
@@ -538,7 +561,7 @@ export function projectResultExtract(result, paths, keysOnly) {
538
561
  available: single.available,
539
562
  ...(didYouMean !== undefined ? { didYouMean } : {}),
540
563
  ...(readFromArtifact ? resultLayerNote(result, path) ?? {} : {}),
541
- hint: missHintFor(single.at, single.available),
564
+ hint: missHintFor(path, single.at, single.available),
542
565
  };
543
566
  }
544
567
  return {
@@ -580,9 +603,8 @@ export function projectResultExtract(result, paths, keysOnly) {
580
603
  out.rowCount = rowCount;
581
604
  // Deliberately NO top-level `content` on multi-path — that was the duplicate.
582
605
  }
583
- // Keep one machine-readable shape for artifact/call consumers. `content` on
584
- // the single-path branch remains as a backwards-compatible convenience.
585
- out.projections = extracts;
606
+ // extract[] is canonical for call projections. Artifact get retains its
607
+ // projections[] face; do not inline the same values twice here.
586
608
  // A projection that missed is not an answer. `status` stays `ok` (adding a
587
609
  // new status value would fall through classifyResult to error/exit 15 and
588
610
  // change the exit contract), but the envelope now says so out loud.
@@ -94,7 +94,30 @@ const TOOL_INPUT_ALIASES = Object.freeze({
94
94
  // `bizObjectId: Required`). On this tool `id` unambiguously names the same
95
95
  // business object, so fill the canonical key rather than fail.
96
96
  "data.load": Object.freeze({ bizObjectId: ["id"] }),
97
+ // r54 C② F2:同一个「规则」概念在 rule.* 族叫 ruleCode、在 programming.* 族叫
98
+ // businessRuleCode——探针跨族调用时习惯性带 ruleCode(一次被拒一次就改对,但
99
+ // 本可零轮)。规则族命名对齐(与 workflow/field 家族同模式)。
100
+ "programming.get": Object.freeze({ businessRuleCode: ["ruleCode"] }),
101
+ "programming.compile": Object.freeze({ businessRuleCode: ["ruleCode"] }),
102
+ "programming.save": Object.freeze({ businessRuleCode: ["ruleCode"] }),
103
+ "programming.publish": Object.freeze({ businessRuleCode: ["ruleCode"] }),
97
104
  });
105
+ /**
106
+ * r54 C② F2:该工具在 TOOL_INPUT_ALIASES 里声明的**同义词键**(调用方可能拿来
107
+ * 替代规范键的名字,工具层会归一化)。CLI 的读面未知键门(r29f F7 硬拒)需要
108
+ * 把它们当 recognized——否则同概念跨族改名(如 rule.* 的 ruleCode → programming.*
109
+ * 的 businessRuleCode)在读面先被拒,工具层的归一化根本没机会跑(写面走 zod
110
+ * safeParse(normalized) 天然认别名,读面没有这层)。
111
+ */
112
+ export function inputAliasSynonymKeys(toolName) {
113
+ const aliases = TOOL_INPUT_ALIASES[toolName];
114
+ if (!aliases)
115
+ return [];
116
+ const synonyms = [];
117
+ for (const list of Object.values(aliases))
118
+ synonyms.push(...list);
119
+ return synonyms;
120
+ }
98
121
  function applyInputAliases(tool, input) {
99
122
  const aliases = TOOL_INPUT_ALIASES[tool.name];
100
123
  if (!aliases)
@@ -194,6 +217,9 @@ const CONTEXTUAL_KEY_GUIDANCE = Object.freeze({
194
217
  const SIBLING_TOOL_KEY_HINTS = Object.freeze({
195
218
  "app.update": Object.freeze({ name: '"name" 是 app.create 的入参;app.update 不收它' }),
196
219
  "model.create": Object.freeze({ fields: '"fields" 是 configure_model 的入参;model.create 不收它' }),
220
+ // r53 场景03 F8:记录标识在 data.* 族叫 bizObjectId、在 rule.run 叫 ids(数组)——
221
+ // 两边零字符串相似度,最近匹配只能报「无相近键」。
222
+ "rule.run": Object.freeze({ bizObjectId: "rule.run 的记录标识是 ids(字符串数组,如 ids:[\"<bizObjectId>\"])" }),
197
223
  });
198
224
  function closestSchemaKey(key, schemaKeys) {
199
225
  if (schemaKeys.has(key))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stalfh233/omc-cli",
3
- "version": "0.6.37",
3
+ "version": "0.6.39",
4
4
  "description": "CloudPivot 8.6 configuration capability CLI — governed, fail-closed, coverage-manifest bounded.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -55,7 +55,7 @@
55
55
  },
56
56
  "dependencies": {
57
57
  "commander": "14.0.3",
58
- "omc-core": "0.6.37",
58
+ "omc-core": "0.6.39",
59
59
  "proper-lockfile": "4.1.2",
60
60
  "write-file-atomic": "6.0.0",
61
61
  "zod": "^3.23.8",
@@ -73,6 +73,6 @@
73
73
  "directory": "packages/omc-cli"
74
74
  },
75
75
  "optionalDependencies": {
76
- "@stalfh233/omc-fake-platform": "0.6.37"
76
+ "@stalfh233/omc-fake-platform": "0.6.39"
77
77
  }
78
78
  }