@stalfh233/omc-cli 0.6.90 → 0.6.91

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.
@@ -805,6 +805,33 @@ function triageHintFor(goal) {
805
805
  note: "config.diff 只读零写:changed:null=一面缺失(看 verdict,draft-only 即草稿全未发布),不是空 diff;差异全量与双面快照在 diffArtifactId。双面一致时症状不来自草稿/发布差——再查运行面(rulelog.search / workitem.list)或节点 buttonPermission。",
806
806
  };
807
807
  }
808
+ /**
809
+ * F6 工单 05a(2026-11-21):触发面指路。
810
+ *
811
+ * F6 实证:「模型有哪些触发点」→ agent 枚举了全平台服务(kind:"service"),
812
+ * 始终没找到 `rule.references kind:"trigger"`——触发面是**一个模型**的全部
813
+ * 自动化入口(流程三面/表单按钮/规则/预置事件/在线 JS),但不在 CAPABILITY_CUES
814
+ * 里,只能在这里补入口。保守触发:只认触发点/触发器/自动化/定时规则类的
815
+ * 盘点措辞;没有唯一 schemaCode 时给占位符命令(与 graphHint 同款处理),
816
+ * 不改原路由。
817
+ */
818
+ const TRIGGER_HINT_RE = /触发点|触发器|有哪些自动化|的自动化|(?:模型|数据|业务).{0,6}自动化|定时(?:规则|任务)/;
819
+ function triggerHintFor(goal) {
820
+ if (!TRIGGER_HINT_RE.test(goal))
821
+ return undefined;
822
+ const codes = [...new Set(goal.match(GRAPH_OBJECT_RE) ?? [])];
823
+ const code = codes.length === 1 ? codes[0] : "<schemaCode>";
824
+ const firstCommand = `omc call rule.references --args '{"kind":"trigger","code":"${code}"}'`;
825
+ return {
826
+ why: codes.length === 1 ? `问到「${codes[0]}」的触发点/自动化` : "问到触发点/自动化(未给出唯一 schemaCode)",
827
+ firstCommand,
828
+ commands: [
829
+ `${firstCommand}(一个模型的全部触发点:流程三面/表单按钮/规则/预置事件/在线 JS)`,
830
+ `omc call rule.references --args '{"kind":"trigger","code":"${code}","action":"create"}'(只看 create/update/delete/flow 某一动作)`,
831
+ ],
832
+ note: "触发面不在能力注册表里,入口是 rule.references 的 kind:\"trigger\"(code 是 schemaCode,不是规则码);只读零写。action/activityCode/sheetCode/mode 只对该 kind 有效。",
833
+ };
834
+ }
808
835
  function goalRouteInner(registry, goal) {
809
836
  const index = capabilityRouteIndex(registry);
810
837
  // r49 F1(探针复现):whole-package 主推 intent 前必须确认命中能力的 intent 覆盖——
@@ -1484,16 +1511,18 @@ export function goalRoute(registry, goal) {
1484
1511
  const base = goalRouteInner(registry, goal);
1485
1512
  const hint = graphHintFor(goal);
1486
1513
  const triage = triageHintFor(goal);
1514
+ const trigger = triggerHintFor(goal);
1487
1515
  const withGraph = hint === undefined ? base : { ...base, graphHint: hint };
1488
1516
  const withTriage = triage === undefined ? withGraph : { ...withGraph, triageHint: triage };
1517
+ const withTrigger = trigger === undefined ? withTriage : { ...withTriage, triggerHint: trigger };
1489
1518
  // A3:firstAnswer 的 action 指向 registry 工具(omc call <tool> / omc describe
1490
1519
  // <tool> --example)时附 surfaceRef——读 ladder 的起手工具、配方命中与
1491
1520
  // needs-input 的 resolver 都能一次拿到 firstCall/needs/returns/onRefusal。
1492
- const action = withTriage.firstAnswer?.action;
1521
+ const action = withTrigger.firstAnswer?.action;
1493
1522
  const surfaceRef = action === undefined
1494
1523
  ? undefined
1495
1524
  : surfaceRefFor(registry, toolOfAction(action), { via: "firstAnswer.action" });
1496
- return surfaceRef === undefined ? withTriage : { ...withTriage, surfaceRef };
1525
+ return surfaceRef === undefined ? withTrigger : { ...withTrigger, surfaceRef };
1497
1526
  }
1498
1527
  /** `omc call <tool> …` / `omc describe <tool> --example <id>` 里的工具名;其它形态返回空串(查不到即零字节)。 */
1499
1528
  function toolOfAction(action) {
@@ -896,13 +896,12 @@ export function registerB2Lane(tools) {
896
896
  requiresConfirmation: true,
897
897
  summary: "先解绑引用规则里的 BIZ_ACTION 节点,再删方法(需用户明确确认)",
898
898
  readFirst,
899
- steps: [
900
- "用 rule.get 读回完整 nodeGraph(保留其余节点、routes、schedulerSetting 等全部字段)",
901
- `只在图里去掉 methodMapping 指向 ${args.serviceCode}/${args.methodCode} 的 BIZ_ACTION 节点`,
902
- "omc call rule.save --args '<去掉该节点后的完整图>'(平台会铸新规则 id;未声明的节点逐字节保留)",
903
- "重新调用 method.delete",
904
- ],
905
- note: "本工具不会自动解绑;解绑是独立的高危写入,必须由用户确认后另行执行",
899
+ // Ticket 04(2026-11-21,F6 实证):这里**不再给解绑步骤**。F6 自主
900
+ // agent 把 steps 当操作手册逐步照做(rule.save 去 BIZ_ACTION →
901
+ // method.delete),`requiresConfirmation:true` 只是文档不是门。解绑
902
+ // 现在由 rule.save 的 confirmUnlink 硬门兜底:每一步怎么拼图不再由
903
+ // 拒绝回执教学,必须用户决策后另行执行。
904
+ note: "本工具不会自动解绑,也不提供解绑步骤;解绑是独立的高危写入(rule.save 需 confirmUnlink:true),必须由用户决策后另行执行",
906
905
  },
907
906
  ],
908
907
  nextCommand: `omc call rule.references --args '{"kind":"service","code":"${args.serviceCode}"}'`,
@@ -1106,7 +1106,7 @@ export function registerBusinessRuleLane(tools) {
1106
1106
  }));
1107
1107
  tools.push(defineTool({
1108
1108
  name: "rule.references",
1109
- search: { intents: ["规则引用", "查规则引用", "谁用了规则"] },
1109
+ search: { intents: ["规则引用", "查规则引用", "谁用了规则", "触发点", "有哪些触发", "触发器清单", "模型的自动化", "定时规则在哪"] },
1110
1110
  layer: "low",
1111
1111
  kind: "read",
1112
1112
  lane: RULE_LANE,
@@ -1769,6 +1769,7 @@ export function registerBusinessRuleLane(tools) {
1769
1769
  allowAdvisory: z.boolean().optional().describe("调查逃生口;默认 false"),
1770
1770
  allowAbsentMappingFields: z.boolean().optional().describe("逃生阀:codeType:1 映射 bizCode 不在来源模型已发布字段时仍保存(回执 absentMappingFieldsAllowed 点名);默认拒 rule-mapping-field-absent(平台侧不保证拦,运行时静默 null→10005)"),
1771
1771
  allowDesignerTextOverwrite: z.boolean().optional().describe("逃生阀:覆盖映射现存的设计器公式文本(editorText/editorMark);默认保留现存设计器文本只更新 formula(回执 preservedDesignerText 点名)"),
1772
+ confirmUnlink: z.boolean().optional().describe("确认解绑:本次保存会让现存图里的方法映射引用消失(BIZ_ACTION 节点被删或 methodMapping 被移除/改指向)。默认拒绝;解绑会降低对应方法的 count_mapping,可能让被引用方法变得可删——应由用户决策"),
1772
1773
  customTrigger: z.boolean().optional().describe("默认开:自定义 ruleCode + bizRuleType 0(非平台触发码 Create/Update/Delete/GetList/Load/Available/Cancel)即按钮/流程规则,工具在 START 后合成平台标准 CUSTOM_NODE「自定义按钮/流程触发」系统触发节点(nodeCode=ruleCode,live 布局 x558/y233);调用方已写 CUSTOM_NODE 则原样保留;显式 false 退回"),
1773
1774
  },
1774
1775
  execute: async (session, args) => executeRuleSaveWrite(session, args),
@@ -410,6 +410,29 @@ function compactRuntimeRecord(record) {
410
410
  }
411
411
  return compact;
412
412
  }
413
+ /**
414
+ * F6 工单 05b(2026-11-21):`data.list` 内联子表行后,agent 不知道有
415
+ * `data.aggregate child`,只能拉全量子行、再也不会想到计数/合计可以一次服务端
416
+ * 完成。检测「值是对象数组」的字段(子表字段 code 就是 childSchemaCode——与
417
+ * data.aggregate 的 child.childSchemaCode 同义),给出按需读取数面的指路。
418
+ * 只探测、不加 wire;每次回执至多一句。
419
+ */
420
+ function inlineChildRowsOf(fields, bizObjectId) {
421
+ const id = String(bizObjectId ?? "").trim();
422
+ if (id === "")
423
+ return undefined;
424
+ for (const [key, value] of Object.entries(fields)) {
425
+ if (key === "" || !Array.isArray(value) || value.length === 0)
426
+ continue;
427
+ if (!value.every((entry) => entry !== null && typeof entry === "object" && !Array.isArray(entry)))
428
+ continue;
429
+ return { childSchemaCode: key, bizObjectId: id };
430
+ }
431
+ return undefined;
432
+ }
433
+ function childRowsAggregateHint(hit, schemaCode, lead) {
434
+ return `${lead};只要子表**计数/合计**:omc call data.aggregate --args '{"schemaCode":"${schemaCode}","metric":"count","child":{"childSchemaCode":"${hit.childSchemaCode}","bizObjectId":"${hit.bizObjectId}"}}'(服务端计数零行内联,数值只拉目标列)`;
435
+ }
413
436
  /**
414
437
  * Round 3 (issue §D5): the write readback inlined the whole `authoritative`
415
438
  * record (owner/creater objects included), ~4 KB a row. Default is now the
@@ -1877,9 +1900,15 @@ export function registerRuntimeDataLane(tools) {
1877
1900
  const hasNullValue = items.some((item) => Object.values(item.fields).some((value) => value === null));
1878
1901
  const viewEvidence = hasNullValue ? await listViewProjectionEvidence(session, args.schemaCode, args.queryCode ?? args.schemaCode) : undefined;
1879
1902
  const projectionHintPaged = projectionHintFace(items, viewEvidence);
1903
+ // F6 工单 05b:只有本页行真的内联了子表数组才给一句(否则零字节);
1904
+ // 取第一条命中行,命令里的 schemaCode/childSchemaCode/bizObjectId 都是真值。
1905
+ const inlineChild = items
1906
+ .map((item) => inlineChildRowsOf(item.fields, item.id))
1907
+ .find((hit) => hit !== undefined);
1880
1908
  const readback = {
1881
1909
  schemaCode: args.schemaCode,
1882
1910
  ...application,
1911
+ ...(inlineChild !== undefined ? { childRowsHint: childRowsAggregateHint(inlineChild, args.schemaCode, "本页内联了子表行") } : {}),
1883
1912
  ...(projectionEmpty ? { projectionWarning: { reason: "business-columns-null", hint: "模型可能未配置列表视图:data.list 只投影列表列,业务列会全为 null;核对写入结果请用 data.load(或先建列表视图)" } } : {}),
1884
1913
  ...(projectionEmpty ? { viewProjectionOnly: true, hint: VIEW_PROJECTION_HINT } : {}),
1885
1914
  ...(args.queryCode !== undefined ? { queryCode: args.queryCode } : {}),
@@ -2660,7 +2689,12 @@ export function registerRuntimeDataLane(tools) {
2660
2689
  missingFields = missing;
2661
2690
  }
2662
2691
  }
2663
- return { schemaCode: args.schemaCode, bizObjectId: args.bizObjectId, exists: data != null, ...(missingFields ? { missingFields, availableFields: data && typeof data === "object" ? Object.keys(data) : [] } : {}), ...(includeSchema ? {} : { schemaCached: true }), data };
2692
+ // F6 工单 05b:读回记录里内联子表数组时给同一句指路(命令填真值);
2693
+ // 没有子表数组就零字节,不改变任何既有回执字段。
2694
+ const inlineChild = data && typeof data === "object" && !Array.isArray(data)
2695
+ ? inlineChildRowsOf(data, args.bizObjectId)
2696
+ : undefined;
2697
+ return { schemaCode: args.schemaCode, bizObjectId: args.bizObjectId, exists: data != null, ...(missingFields ? { missingFields, availableFields: data && typeof data === "object" ? Object.keys(data) : [] } : {}), ...(includeSchema ? {} : { schemaCached: true }), ...(inlineChild !== undefined ? { childRowsHint: childRowsAggregateHint(inlineChild, args.schemaCode, "本记录内联了子表行") } : {}), data };
2664
2698
  }, { full: args.full === true, target: `data.load:${args.schemaCode}:${args.bizObjectId}` });
2665
2699
  },
2666
2700
  }));
@@ -40,6 +40,37 @@ function mappedMethodNodeCodes(nodeColumn, serviceCode, methodCode) {
40
40
  }
41
41
  return nodeCodes;
42
42
  }
43
+ /**
44
+ * Ticket 04 (2026-11-21, F6) — every method mapping carried by one rule graph,
45
+ * as a deduped `"serviceCode/serviceMethodCode"` set. Accepts the `node` column
46
+ * shape directly (JSON string or array; same tolerance as
47
+ * `mappedMethodNodeCodes`). A mapping with a blank service or method code is
48
+ * not a reference (the platform maps nothing), so it is dropped.
49
+ *
50
+ * This is the single source for "which methods does this graph point at?" —
51
+ * `rule.save`'s unlink gate compares the live row's set with the new graph's
52
+ * set instead of re-walking nodes on its own.
53
+ */
54
+ export function methodMappingRefsOf(nodes) {
55
+ const decoded = decodeJsonColumn(nodes, JSON_COLUMN_NULL_COALESCE);
56
+ if (!Array.isArray(decoded))
57
+ return [];
58
+ const refs = [];
59
+ for (const entry of decoded) {
60
+ if (!entry || typeof entry !== "object" || Array.isArray(entry))
61
+ continue;
62
+ const mapping = entry.methodMapping;
63
+ if (!mapping || typeof mapping !== "object" || Array.isArray(mapping))
64
+ continue;
65
+ const mapped = mapping;
66
+ const serviceCode = String(mapped.serviceCode ?? "").trim();
67
+ const methodCode = String(mapped.serviceMethodCode ?? "").trim();
68
+ if (serviceCode === "" || methodCode === "")
69
+ continue;
70
+ refs.push(`${serviceCode}/${methodCode}`);
71
+ }
72
+ return [...new Set(refs)];
73
+ }
43
74
  /**
44
75
  * Best-effort reference identity: viewReference → schemaCodes (≤25) → per-model
45
76
  * rule list (≤50 rules) → per-rule graph read → methodMapping match
@@ -122,7 +153,7 @@ export async function scanMethodReferenceSites(session, serviceCode, methodCode)
122
153
  * `method.delete` and the intent warning append `methodReferenceIdentity`.
123
154
  */
124
155
  export function methodReferencedCoreMessage(serviceCode, methodCode, count) {
125
- return `业务方法 ${serviceCode}/${methodCode} 被 ${count} 条规则映射引用——平台删除会回 500108「业务方法已绑定默认方法,不可删除」(BizServiceMethodController.java:248-281),本次零写入:方法、规则与绑定保持原状。要删必须先解绑引用规则(rule.save 去掉对应 BIZ_ACTION 节点、保留其余节点/routes/schedulerSetting,重新发布)再删方法。不要自行解绑规则、不要改调度生效时间后再删方法——解绑属于高危写入,必须用户确认`;
156
+ return `业务方法 ${serviceCode}/${methodCode} 被 ${count} 条规则映射引用——平台删除会回 500108「业务方法已绑定默认方法,不可删除」(BizServiceMethodController.java:248-281),本次零写入:方法、规则与绑定保持原状。要删必须先解绑引用规则(rule.save(需 confirmUnlink:true)去掉对应 BIZ_ACTION 节点、保留其余节点/routes/schedulerSetting,重新发布)再删方法。不要自行解绑规则、不要改调度生效时间后再删方法——解绑属于高危写入,必须用户确认`;
126
157
  }
127
158
  /** Readable suffix for the reference scan: site identities, or a pointer when the scan hit nothing. */
128
159
  export function methodReferenceIdentity(sites, serviceCode) {
@@ -8,6 +8,7 @@ import { RULE_BIZ_RULE_TYPE_DESCRIPTION, RULE_CREATE_BODY, RULE_ROUTES_DESCRIPTI
8
8
  import { validateRuleNodeGraph, prepareRuleGraph, PLATFORM_TRIGGER_RULE_CODES, DEFAULT_SYSTEM_NODE_BY_RULE_CODE } from "./lanes/rule-graph.js";
9
9
  import { FORMULA_LINT_CODES } from "./formula-lint.js";
10
10
  import { compileMethodConfigPlain } from "./bizservice-config.js";
11
+ import { methodMappingRefsOf } from "./method-references.js";
11
12
  import { closestMatches } from "./closest-match.js";
12
13
  import { RESERVED_CODES } from "./code-rules.js";
13
14
  import { SYSTEM_FIELD_CODES } from "./field-families.js";
@@ -1188,7 +1189,7 @@ function collectEmptyMappings(nodes) {
1188
1189
  }
1189
1190
  return empty;
1190
1191
  }
1191
- export async function lintRuleSaveWrite(session, args) {
1192
+ export async function lintRuleSaveWrite(session, args, options = {}) {
1192
1193
  // r85(issue 03/08):幻影 schema 门提前到一切规则面 wire 之前(原在图 lint 后,
1193
1194
  // 而 computeCarriedNodeCodes 已会 list——提前只收紧不放松;后续 routes 沿用
1194
1195
  // 读取/设计器保读都以 schema 已证存在为前提)。
@@ -1233,6 +1234,43 @@ export async function lintRuleSaveWrite(session, args) {
1233
1234
  // the SAME lint now serves the real write AND `rule.node.update`'s
1234
1235
  // dryRunPayload, so a dry-run answers the same 能写/不能写 question.
1235
1236
  const { preparedGraph, blockers, lintWarnings, lintHazards, nodes, routes } = await lintRuleGraphForWrite(session, { ...args, nodeGraph: graph });
1237
+ // ── Ticket 04(2026-11-21,F6 实证):rule.save 解绑硬门 ──
1238
+ //
1239
+ // F6:0.6.90 的 `method.delete` 预检正确拒绝了被引用方法的删除,但拒绝回执里
1240
+ // 的 `options.unlink.steps` 被自主 agent 当操作手册逐步执行(rule.save 去掉
1241
+ // BIZ_ACTION 节点 → method.delete 成功)。`requiresConfirmation:true` 是文档,
1242
+ // 不是门。解绑本身是高风险写入(降低 count_mapping、打开方法删除门),必须由用户
1243
+ // 决策——所以 `rule.save` 在**保存 wire 之前**对比活行图与本图的方法映射引用:
1244
+ // 只**消失**的引用会拒绝(新增/改动映射参数/挪节点/只加绑定全部放行),除非
1245
+ // 调用方显式 `confirmUnlink:true`。零写入:本门在图 lint 之后、任何写 wire 之前。
1246
+ //
1247
+ // 已知边界:`rule.node.update` 的节点级 patch(含整组替换 methodMapping)不在
1248
+ // 本门覆盖范围——它是「单节点 patch」不是整图重画,mapping patch 本身不删节点;
1249
+ // 其 execute 以 origin.operation:"patch" 显式跳过本门(lintRuleSaveWrite options)。
1250
+ // 活行读不到(读面故障)时不做有罪推定:无法比较引用集合即放行,不新增一条
1251
+ // 「读不到就不让保存」的硬失败面。
1252
+ if (options.unlinkGate !== false && existing?.id) {
1253
+ const liveRow = await loadCurrentRow();
1254
+ if (liveRow) {
1255
+ const liveRefs = methodMappingRefsOf(liveRow.node);
1256
+ if (liveRefs.length > 0) {
1257
+ const nextRefs = new Set(methodMappingRefsOf(nodes));
1258
+ const disappearingRefs = liveRefs.filter((ref) => !nextRefs.has(ref));
1259
+ if (disappearingRefs.length > 0 && args.confirmUnlink !== true) {
1260
+ throw new ToolRefusalError({
1261
+ status: "refused",
1262
+ blocker: "rule-unbind-requires-confirmation",
1263
+ schemaCode: args.schemaCode,
1264
+ ruleCode: args.ruleCode,
1265
+ disappearingRefs,
1266
+ doNot: "不要为了删方法而解绑规则;这是影响生产行为的高危写入,必须用户决策",
1267
+ nextCommand: `omc call rule.save --args '{"schemaCode":"${args.schemaCode}","ruleCode":"${args.ruleCode}","name":"${args.name}","nodeGraph":<本次 nodeGraph 原样>,"confirmUnlink":true}'(确要解绑就带本次同参 + confirmUnlink:true 重发)`,
1268
+ message: `本次保存会让方法映射引用 ${disappearingRefs.join("、")} 从规则 ${args.schemaCode}.${args.ruleCode} 的图里消失(BIZ_ACTION 节点被删或 methodMapping 被移除/改指向)——保存后这些方法的 count_mapping 会下降,对应方法的删除门会因此打开。默认拒绝、零写入;确要解绑就带 confirmUnlink:true 重发(高危,必须用户决策)。`,
1269
+ });
1270
+ }
1271
+ }
1272
+ }
1273
+ }
1236
1274
  await assertCreateSelectionCompatibility(session, args.schemaCode, Array.isArray(nodes) ? nodes : []);
1237
1275
  // r85(issue 08):codeType:1 映射字段预检(QUERY 上游模型解析 + did-you-mean
1238
1276
  // + allowAbsentMappingFields 逃生阀)。r21 的同模型门已并入本门。
@@ -1517,7 +1555,7 @@ export function ruleStatusSegment(input) {
1517
1555
  }
1518
1556
  export async function executeRuleSaveWrite(session, args, origin = { operation: "save" }) {
1519
1557
  // 与 dry-run 同源:同一套只读门先跑,然后才写。
1520
- const { lintWarnings, lintHazards, bizMethodChecks, existing, customTriggerApplied, isPresetRule, bizRuleType, nodeJson, routeJson, schedulerField, schedulerSetting, nodes, routesSource, emptyMappings, preservedDesignerText, designerTextOverwritten, mappingFieldChecks, absentMappingFields, } = await lintRuleSaveWrite(session, args);
1558
+ const { lintWarnings, lintHazards, bizMethodChecks, existing, customTriggerApplied, isPresetRule, bizRuleType, nodeJson, routeJson, schedulerField, schedulerSetting, nodes, routesSource, emptyMappings, preservedDesignerText, designerTextOverwritten, mappingFieldChecks, absentMappingFields, } = await lintRuleSaveWrite(session, args, { unlinkGate: origin.operation !== "patch" });
1521
1559
  // r85(retro 2026-11-19):dry-run 与真写共用的回执增量(routes 沿用 / 空映射 /
1522
1560
  // 设计器文本保读 / 映射字段预检)。
1523
1561
  const r85Readback = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stalfh233/omc-cli",
3
- "version": "0.6.90",
3
+ "version": "0.6.91",
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.90",
59
+ "omc-core": "0.6.91",
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.90"
77
+ "@stalfh233/omc-fake-platform": "0.6.91"
78
78
  }
79
79
  }