@stalfh233/omc-cli 0.6.87 → 0.6.88

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 CHANGED
@@ -26,7 +26,7 @@ import { artifactFetchHint, artifactRoot, boundResult, emitInvalid, emitResult,
26
26
  import { CLI_DEFAULT_OUTPUT_BYTES, assertSafeOutputPath, pruneArtifacts } from "./artifacts.js";
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
- import { artifactPathMissHint, nullProjectionHint, partialPathMissHint, pathMissCopyableHint, pathMissDidYouMean, projectJsonPath, projectJsonPathFanout, projectResultExtract, shapeOf, SHAPE_MAX_DEPTH, unwrapSinglePathProjection } from "./path-projection.js";
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
30
  import { basename, join, resolve } from "node:path";
31
31
  import { existsSync, readFileSync, writeFileSync, chmodSync } from "node:fs";
32
32
  import { buildToolRegistry } from "./tools.js";
@@ -493,7 +493,7 @@ async function cmdBatchCall(store, toolName, rawList, options) {
493
493
  .flatMap((path) => path.split(",")).map((path) => path.trim()).filter(Boolean);
494
494
  const preflightKeys = options.args.includes("--extract-keys") || options.args.includes("--keys") || options.args.some((token, index) => token === "--jq" && (options.args[index + 1] === undefined || options.args[index + 1].startsWith("--")));
495
495
  if (preflightPaths.length > 0 || preflightKeys) {
496
- const projected = projectResultExtract(result, preflightPaths, preflightKeys);
496
+ const projected = projectResultExtract(result, preflightPaths, preflightKeys, { tool: toolName, ...(options.environment !== undefined ? { environment: options.environment } : {}) });
497
497
  if (projected !== undefined)
498
498
  result = projected;
499
499
  }
@@ -764,7 +764,15 @@ async function cmdCall(store, args) {
764
764
  blocker: "tool-input-unknown-keys",
765
765
  tool: toolName,
766
766
  unknownKeys: otherUnknown,
767
+ // F1(retro 22,ticket 138):与写面同款机器字段——被拒键 + 合法键全集
768
+ // 成对给出;nextCommand 指向「最接近的合法键」的参数面(而非整份
769
+ // describe),脚本可零解析消费。
770
+ expectedKeys: [...schemaKeys],
767
771
  suggestions,
772
+ // 有拼写近邻时直达该参数的 describe;否则退回整份参数表。
773
+ ...(suggestions.some((entry) => entry.closest !== undefined)
774
+ ? { nextCommand: `omc describe ${toolName} --param ${suggestions.find((entry) => entry.closest !== undefined).closest}` }
775
+ : { nextCommand: `omc describe ${toolName}` }),
768
776
  message: `读面不接受未知键(与写面对齐):${pairs.join("、")}。` +
769
777
  `改用合法键后重试;确需宽松忽略传 lenientArgs:true。参数表:omc describe ${toolName}`,
770
778
  };
@@ -847,7 +855,14 @@ async function cmdCall(store, args) {
847
855
  let unwrappedBody;
848
856
  let resultMeta;
849
857
  if (extractPaths.length > 0 || extractKeys) {
850
- const projected = projectResultExtract(result, extractPaths, extractKeys);
858
+ // F1(retro 22,ticket 138):把调用上下文交给投影层——pathMiss 能推导出
859
+ // correctPath 时,拼一条含 --env/--args/--jq 的完整可复制命令(nextCommand)。
860
+ // args 用调用方**原始** JSON(未归一化),>500B 时投影层放弃拼命令(不截断造假)。
861
+ const projected = projectResultExtract(result, extractPaths, extractKeys, {
862
+ tool: toolName,
863
+ ...(environment !== undefined && environment.length > 0 ? { environment } : {}),
864
+ argsJson: rawArgs !== undefined ? rawArgs : JSON.stringify(parsedArgs),
865
+ });
851
866
  if (projected !== undefined)
852
867
  result = projected;
853
868
  // Projected reads are represented by extract[] (and rows[] for multi-path).
@@ -1015,7 +1030,24 @@ function projectArtifactPath(value, path) {
1015
1030
  const fanout = projectJsonPathFanout(value, path);
1016
1031
  return fanout.missed
1017
1032
  ? { missed: true, ...(fanout.at !== undefined ? { at: fanout.at } : {}), ...(fanout.available !== undefined ? { available: fanout.available } : {}), ...(fanout.availableAll !== undefined ? { availableAll: fanout.availableAll } : {}), ...(fanout.availableTruncated !== undefined ? { availableTruncated: fanout.availableTruncated } : {}) }
1018
- : { missed: false, content: fanout.values, mapped: fanout.values.length, ...(fanout.missedEntries > 0 ? { missedEntries: fanout.missedEntries } : {}), nullEntries: fanout.nullEntries };
1033
+ : { missed: false, content: fanout.values, mapped: fanout.values.length, ...(fanout.missedEntries > 0 ? { missedEntries: fanout.missedEntries } : {}), nullEntries: fanout.nullEntries, nonNullEntries: fanout.nonNullEntries };
1034
+ }
1035
+ /**
1036
+ * F1/F2(retro 21/22,ticket 138):artifact 面 pathMiss 的机器可读纠错面——
1037
+ * `correctPath`(已验证可解析)+ `helpRef`(教程指针)+ 可整段复制的重跑命令。
1038
+ * 与 call 面(projectResultExtract)同一套推导(拼写近似走 didYouMean 字段,
1039
+ * 这里只补跨面改写与同名键两条**全路径**推导),推导不出就全部缺席(不编造)。
1040
+ */
1041
+ function artifactMissCorrection(content, path, at, artifactId) {
1042
+ const correction = pathMissCrossFaceCorrection(content, path, at) ?? (() => {
1043
+ const copyable = pathMissCopyablePaths(content, path, at, 1);
1044
+ return copyable.length > 0 ? { correctPath: copyable[0] } : undefined;
1045
+ })();
1046
+ return {
1047
+ ...(correction !== undefined ? { correctPath: correction.correctPath } : {}),
1048
+ helpRef: PATH_MISS_HELP_REF,
1049
+ ...(correction !== undefined ? { nextCommand: `omc artifact get ${artifactId} --jq '${correction.correctPath.replace(/'/g, "'\\''")}'` } : {}),
1050
+ };
1019
1051
  }
1020
1052
  /** Preserve source completeness/count facts on every artifact projection. */
1021
1053
  function artifactProjectionMetadata(value) {
@@ -1140,7 +1172,7 @@ async function cmdArtifactGet(id, transport, options = {}) {
1140
1172
  // `--shape <path>`:在命中的子树上出骨架(同 --jq 的路径 DSL,含 [] 与 [code=X])。
1141
1173
  const projected = projectArtifactPath(artifact.content.toString("utf8") === "" ? undefined : content, options.shape);
1142
1174
  if (projected.missed) {
1143
- return emitTransportResult({ status: "ok", artifactId: id, sha256: artifact.sha256, ...artifactProjectionMetadata(content), path: options.shape, content: null, pathMiss: true, missedAt: projected.at, available: projected.available, ...artifactMissExtras(projected), unanswered: true, hint: artifactPathMissHint(projected.at, pathMissCopyableHint(content, options.shape, projected.at)) }, transport);
1175
+ return emitTransportResult({ status: "ok", artifactId: id, sha256: artifact.sha256, ...artifactProjectionMetadata(content), path: options.shape, content: null, pathMiss: true, missedAt: projected.at, available: projected.available, ...artifactMissExtras(projected), unanswered: true, ...artifactMissCorrection(content, options.shape, projected.at, id), hint: artifactPathMissHint(projected.at, pathMissCopyableHint(content, options.shape, projected.at)) }, transport);
1144
1176
  }
1145
1177
  return emitTransportResult({ status: "ok", artifactId: id, sha256: artifact.sha256, bytes: artifact.content.length, path: options.shape, depth, shape: shapeOf(projected.content, depth), fetch: artifactFetchHint(id) }, transport);
1146
1178
  }
@@ -1183,7 +1215,7 @@ async function cmdArtifactGet(id, transport, options = {}) {
1183
1215
  // 一层 `projection:{path,content}`——`artifact get --jq` 与 `--summary --jq`
1184
1216
  // 因此同形(顶层 path/content),换读面不用重新探根键。
1185
1217
  return emitTransportResult(projected.missed
1186
- ? { status: "ok", artifactId: id, sha256: artifact.sha256, bytes: artifact.content.length, ...artifactProjectionMetadata(content), keys, path: options.jq, content: null, projections: [{ path: options.jq, content: null, pathMiss: true, missedAt: projected.at, available: projected.available, ...artifactMissExtras(projected) }], pathMiss: true, missedAt: projected.at, available: projected.available, ...artifactMissExtras(projected), unanswered: true, hint: artifactPathMissHint(projected.at, pathMissCopyableHint(content, options.jq, projected.at)) }
1218
+ ? { status: "ok", artifactId: id, sha256: artifact.sha256, bytes: artifact.content.length, ...artifactProjectionMetadata(content), keys, path: options.jq, content: null, projections: [{ path: options.jq, content: null, pathMiss: true, missedAt: projected.at, available: projected.available, ...artifactMissExtras(projected) }], pathMiss: true, missedAt: projected.at, available: projected.available, ...artifactMissExtras(projected), unanswered: true, ...artifactMissCorrection(content, options.jq, projected.at, id), hint: artifactPathMissHint(projected.at, pathMissCopyableHint(content, options.jq, projected.at)) }
1187
1219
  : {
1188
1220
  status: "ok",
1189
1221
  artifactId: id,
@@ -1192,9 +1224,10 @@ async function cmdArtifactGet(id, transport, options = {}) {
1192
1224
  ...artifactProjectionMetadata(content),
1193
1225
  keys,
1194
1226
  path: options.jq,
1195
- projections: [{ path: options.jq, content: projected.content ?? null, ...(projected.mapped !== undefined ? { mapped: projected.mapped } : {}), ...(projected.missedEntries !== undefined ? { missedEntries: projected.missedEntries } : {}), ...(projected.nullEntries !== undefined && projected.nullEntries > 0 ? { nullEntries: projected.nullEntries } : {}) }],
1227
+ projections: [{ path: options.jq, content: projected.content ?? null, ...(projected.mapped !== undefined ? { mapped: projected.mapped } : {}), ...(projected.missedEntries !== undefined ? { missedEntries: projected.missedEntries } : {}), ...(projected.nullEntries !== undefined && projected.nullEntries > 0 ? { nullEntries: projected.nullEntries } : {}), ...(projected.nonNullEntries !== undefined ? { nonNullEntries: projected.nonNullEntries } : {}) }],
1196
1228
  ...(projected.mapped !== undefined ? { mapped: projected.mapped } : {}),
1197
1229
  ...(projected.nullEntries !== undefined && projected.nullEntries > 0 ? { nullEntries: projected.nullEntries } : {}),
1230
+ ...(projected.nonNullEntries !== undefined ? { nonNullEntries: projected.nonNullEntries } : {}),
1198
1231
  ...(projected.missedEntries !== undefined ? { missedEntries: projected.missedEntries } : {}),
1199
1232
  ...(artifactNullHint(projected.content, projected.nullEntries) !== undefined ? { hint: artifactNullHint(projected.content, projected.nullEntries) } : {}),
1200
1233
  }, transport);
@@ -1235,15 +1268,15 @@ async function cmdArtifactGet(id, transport, options = {}) {
1235
1268
  const projections = jqPaths.map((path) => {
1236
1269
  const projected = projectArtifactPath(artifactContent, path);
1237
1270
  return projected.missed
1238
- ? { path, content: null, pathMiss: true, missedAt: projected.at, available: projected.available, ...artifactMissExtras(projected) }
1239
- : { path, content: projected.content ?? null, ...(projected.mapped !== undefined ? { mapped: projected.mapped } : {}), ...(projected.missedEntries !== undefined ? { missedEntries: projected.missedEntries } : {}), ...(projected.nullEntries !== undefined && projected.nullEntries > 0 ? { nullEntries: projected.nullEntries } : {}), ...(artifactNullHint(projected.content, projected.nullEntries) !== undefined ? { hint: artifactNullHint(projected.content, projected.nullEntries) } : {}) };
1271
+ ? { path, content: null, pathMiss: true, missedAt: projected.at, available: projected.available, ...artifactMissExtras(projected), ...artifactMissCorrection(artifactContent, path, projected.at, id) }
1272
+ : { path, content: projected.content ?? null, ...(projected.mapped !== undefined ? { mapped: projected.mapped } : {}), ...(projected.missedEntries !== undefined ? { missedEntries: projected.missedEntries } : {}), ...(projected.nullEntries !== undefined && projected.nullEntries > 0 ? { nullEntries: projected.nullEntries } : {}), ...(projected.nonNullEntries !== undefined ? { nonNullEntries: projected.nonNullEntries } : {}), ...(artifactNullHint(projected.content, projected.nullEntries) !== undefined ? { hint: artifactNullHint(projected.content, projected.nullEntries) } : {}) };
1240
1273
  });
1241
1274
  return emitTransportResult({ status: "ok", artifactId: id, sha256: artifact.sha256, ...artifactProjectionMetadata(content), projections, ...(projections.some((entry) => entry.pathMiss) ? { unanswered: true, hint: partialPathMissHint() } : {}) }, transport);
1242
1275
  }
1243
1276
  const projected = projectArtifactPath(artifactContent, options.jq);
1244
1277
  return emitTransportResult(projected.missed
1245
- ? { status: "ok", artifactId: id, sha256: artifact.sha256, ...artifactProjectionMetadata(content), path: options.jq, content: null, pathMiss: true, missedAt: projected.at, available: projected.available, ...artifactMissExtras(projected), unanswered: true, hint: artifactPathMissHint(projected.at, pathMissCopyableHint(artifactContent, options.jq, projected.at)) }
1246
- : { status: "ok", artifactId: id, sha256: artifact.sha256, ...artifactProjectionMetadata(content), path: options.jq, projections: [{ path: options.jq, content: projected.content ?? null, ...(projected.mapped !== undefined ? { mapped: projected.mapped } : {}), ...(projected.missedEntries !== undefined ? { missedEntries: projected.missedEntries } : {}), ...(projected.nullEntries !== undefined && projected.nullEntries > 0 ? { nullEntries: projected.nullEntries } : {}) }], ...(projected.mapped !== undefined ? { mapped: projected.mapped } : {}), ...(projected.missedEntries !== undefined ? { missedEntries: projected.missedEntries } : {}), ...(projected.nullEntries !== undefined && projected.nullEntries > 0 ? { nullEntries: projected.nullEntries } : {}), ...(artifactNullHint(projected.content, projected.nullEntries) !== undefined ? { hint: artifactNullHint(projected.content, projected.nullEntries) } : {}) }, transport);
1278
+ ? { status: "ok", artifactId: id, sha256: artifact.sha256, ...artifactProjectionMetadata(content), path: options.jq, content: null, pathMiss: true, missedAt: projected.at, available: projected.available, ...artifactMissExtras(projected), unanswered: true, ...artifactMissCorrection(artifactContent, options.jq, projected.at, id), hint: artifactPathMissHint(projected.at, pathMissCopyableHint(artifactContent, options.jq, projected.at)) }
1279
+ : { status: "ok", artifactId: id, sha256: artifact.sha256, ...artifactProjectionMetadata(content), path: options.jq, projections: [{ path: options.jq, content: projected.content ?? null, ...(projected.mapped !== undefined ? { mapped: projected.mapped } : {}), ...(projected.missedEntries !== undefined ? { missedEntries: projected.missedEntries } : {}), ...(projected.nullEntries !== undefined && projected.nullEntries > 0 ? { nullEntries: projected.nullEntries } : {}), ...(projected.nonNullEntries !== undefined ? { nonNullEntries: projected.nonNullEntries } : {}) }], ...(projected.mapped !== undefined ? { mapped: projected.mapped } : {}), ...(projected.missedEntries !== undefined ? { missedEntries: projected.missedEntries } : {}), ...(projected.nullEntries !== undefined && projected.nullEntries > 0 ? { nullEntries: projected.nullEntries } : {}), ...(projected.nonNullEntries !== undefined ? { nonNullEntries: projected.nonNullEntries } : {}), ...(artifactNullHint(projected.content, projected.nullEntries) !== undefined ? { hint: artifactNullHint(projected.content, projected.nullEntries) } : {}) }, transport);
1247
1280
  }
1248
1281
  // r6-onboarding 2026-10-21: 47 artifact fetches, 0 used a projection; the 10
1249
1282
  // large ones (up to 55 KB) pulled whole workflow templates just to read one
@@ -176,7 +176,7 @@ export const BUSINESSRULE_LANE_CONTRACT = Object.freeze({
176
176
  }),
177
177
  "rule.node.update": Object.freeze({
178
178
  scope: "dead-state CRUD conditional node graphs",
179
- description: "精确改一个节点:按 schemaCode+ruleCode 读当前图,把 patch 浅合并到 nodeCode 对应的节点,再走与 rule.save 相同的保存 seam(所有图门禁与读回一致)。用来改一个分支阈值/条件/动作而不必重发整图。nodeCode/nodeType 不可改(平台按 nodeCode 连路由、节点类型不可变);改完默认只存草稿,生效仍需 rule.enable(publish:true 可顺带发布)。",
179
+ description: "精确改一个节点:按 schemaCode+ruleCode 读当前图,把 patch 浅合并到 nodeCode 对应的节点,再走与 rule.save 相同的保存 seam(所有图门禁与读回一致)。用来改一个分支阈值/条件/动作而不必重发整图。mapping 面可只改一条映射(按稳定标识唯一定位,命中≠1 即拒绝)。nodeCode/nodeType 不可改(平台按 nodeCode 连路由、节点类型不可变);改完默认只存草稿,生效仍需 rule.enable(publish:true 可顺带发布)。",
180
180
  }),
181
181
  }),
182
182
  });
@@ -188,7 +188,7 @@ export function assertBusinessRuleContract() {
188
188
  if (!String(BUSINESSRULE_LANE_CONTRACT.wire.compatibilityMatrix).includes("CREATE -> dictionary-backed selection"))
189
189
  throw new Error("businessrule contract must expose the evidence-backed compatibility matrix");
190
190
  assertDescriptionCarries(BUSINESSRULE_LANE_CONTRACT, "rule.get", ["inputParam", "node/route", "nodeDigests", "ruleCodes"]);
191
- assertDescriptionCarries(BUSINESSRULE_LANE_CONTRACT, "rule.node.update", ["schemaCode", "ruleCode", "nodeCode", "patch", "rule.save", "rule.enable"]);
191
+ assertDescriptionCarries(BUSINESSRULE_LANE_CONTRACT, "rule.node.update", ["schemaCode", "ruleCode", "nodeCode", "patch", "mapping", "rule.save", "rule.enable"]);
192
192
  assertDescriptionCarries({ tools: { "rule.nodeGraph": { scope: "node graph", description: ruleNodeGraphDescription() } } }, "rule.nodeGraph", [
193
193
  "inputParam",
194
194
  "_input",
@@ -1504,6 +1504,119 @@ export function registerBusinessRuleLane(tools) {
1504
1504
  // 读法/合并法(loadRuleNodePatchGraph)——dry-run 读存量行 → 浅合并 patch →
1505
1505
  // 全图 lint(lintRuleGraphForWrite,与真写同门)。读失败(规则/节点不存在、
1506
1506
  // 不可变键)按 execute 同款 refusal 抛出,绝不静默放行。
1507
+ //
1508
+ // ── F3(friction-first PLAN §8;retro 19/20「规则读→改写」):单条 mapping 局部 patch ──
1509
+ //
1510
+ // 摩擦:改一条映射(换个源字段/改个常量)此前只能整图 rule.save 重发,或 node 级
1511
+ // patch 重发整个 dataActions/inputMappings 数组——未选中的 mappings/routes/
1512
+ // editorText/未知字段全凭调用方自觉拼回。本面在既有入口上加 mapping-selector:
1513
+ // list(方向/数组)+ select(稳定标识)唯一定位**一条**映射,patch 只浅合并进那
1514
+ // 一条;其余条目、节点其余键、routes、x/y/width/height/points、未知字段逐字节
1515
+ // 保留。底层仍是「读整图→合并→整图保存」:executeRuleSaveWrite 与 rule.save 同
1516
+ // 一 seam,wire(method/path/query/body 形状)完全一致,不新增平台端点。
1517
+ //
1518
+ // 平台证据(存储/执行/设计器三侧,8.6.26 反编译树 + 前端源码):
1519
+ // - 存储:节点列是 writer-managed 原始 JSON,按节点类型反序列化
1520
+ // (BusinessRuleParser.java:74-102 的 parseMapToBean 分发表);
1521
+ // dataActions 挂 DataUpdateNode.java:23(CREATE 同族),
1522
+ // 方法映射挂 BizActionNode.java:28 → BizMethodMappingModel.java:31-33
1523
+ // (inputMappings/outputMappings 两个 List<MappingModel>)。
1524
+ // - 执行(「一条映射」的平台侧稳定标识从这里来):
1525
+ // dataActions 逐条按 targetDataItem 定位目标字段,按 ruleValueType/value/
1526
+ // currentDataItemValue 取值(ServiceExecutorImpl.mappingUpdatedData:74-88,
1527
+ // 目标字段不存在抛 BUSINESS_RULE_PROPERTY_NOEXIT);
1528
+ // 方法映射逐条按 serviceMethodParameterCode 对账方法参数表并作为传参键
1529
+ // (MapOps.java:497、525-528、689——constMap.put(serviceMethodParameterCode,…))。
1530
+ // —— selector 用这两个键,不用数组下标猜;identity 撞重时只接受显式 index。
1531
+ // - 设计器写入面:admin 前端类型就是 bizCode + serviceMethodParameterCode +
1532
+ // inputMappings(frontend-src .../admin/src/typings/biz-method.d.ts:35-57);
1533
+ // 映射元素的设计器键(index/displayName/required/bizCodeName)是非语义键,
1534
+ // 工具原样透传不增删(MappingModel.java:26-40 只有语义键,Ticket 96 判例)。
1535
+ // 设计器保存走同一 businessrule/update 整行 seam——本面不引入第二种写路径。
1536
+ // (注:LIST/OBJECT(codeType 2/3) 的 subParameters 嵌套映射未做真机采样,
1537
+ // 本轮 selector 只覆盖顶层数组元素。)
1538
+ const RULE_MAPPING_IDENTITY = Object.freeze({
1539
+ dataActions: "targetDataItem",
1540
+ "methodMapping.inputMappings": "serviceMethodParameterCode",
1541
+ "methodMapping.outputMappings": "serviceMethodParameterCode",
1542
+ });
1543
+ /**
1544
+ * Pure merge: shallow-merge `face.patch` into exactly ONE element of the
1545
+ * selected mapping array. Every refusal is fail-closed BEFORE any wire call:
1546
+ * selector 不合法 / 数组不存在 / 命中 0 条 / 命中 >1 条 / index 越界,全部
1547
+ * 拒绝并给候选/现况——宁可拒绝也不猜一条。
1548
+ */
1549
+ const applyRuleMappingPatch = (node, face) => {
1550
+ const identityKey = RULE_MAPPING_IDENTITY[face.list];
1551
+ const selectKeys = Object.keys(face.select ?? {});
1552
+ if (selectKeys.length !== 1 || (selectKeys[0] !== identityKey && selectKeys[0] !== "index"))
1553
+ throw new ToolRefusalError({
1554
+ status: "refused",
1555
+ blocker: "rule-mapping-selector-key",
1556
+ message: `select 必须恰好一个键:${face.list} 用 {"${identityKey}":"…"}(identity 撞重时 {"index":N},0 基按 rule.get 数组序);收到 ${JSON.stringify(face.select)}`,
1557
+ });
1558
+ // Resolve the array that holds the mappings.
1559
+ let holder;
1560
+ let listKey;
1561
+ if (face.list === "dataActions") {
1562
+ holder = node;
1563
+ listKey = "dataActions";
1564
+ }
1565
+ else {
1566
+ const mapping = node.methodMapping;
1567
+ if (mapping === null || typeof mapping !== "object" || Array.isArray(mapping))
1568
+ throw new ToolRefusalError({ status: "refused", blocker: "rule-mapping-list-absent", message: `节点没有 methodMapping 对象(${face.list} 不可达)——方法映射只存在于 BIZ_ACTION / GET_LIST(BIZ_SERVICE) 节点;节点现有键:${Object.keys(node).join(",")}` });
1569
+ holder = mapping;
1570
+ listKey = face.list.slice("methodMapping.".length);
1571
+ }
1572
+ const list = holder[listKey];
1573
+ if (!Array.isArray(list))
1574
+ throw new ToolRefusalError({ status: "refused", blocker: "rule-mapping-list-absent", message: `${face.list} 不是数组${list === undefined ? "(缺键)" : ""};${holder === node ? "节点" : "methodMapping"} 现有键:${Object.keys(holder).join(",")}` });
1575
+ const elements = list;
1576
+ const describeEntry = (index) => {
1577
+ const entry = elements[index];
1578
+ const value = entry !== null && typeof entry === "object" && !Array.isArray(entry) ? entry[identityKey] : undefined;
1579
+ return { index, [identityKey]: value === undefined ? null : String(value) };
1580
+ };
1581
+ const selectorKey = selectKeys[0];
1582
+ let index;
1583
+ if (selectorKey === "index") {
1584
+ const raw = face.select.index;
1585
+ if (typeof raw !== "number" || !Number.isInteger(raw) || raw < 0 || raw >= elements.length)
1586
+ throw new ToolRefusalError({ status: "refused", blocker: "rule-mapping-index-invalid", message: `select.index 必须是 0..${elements.length - 1} 的整数(${face.list} 现有 ${elements.length} 条);收到 ${JSON.stringify(raw)}。优先用 {"${identityKey}":"…"} 按稳定标识选` });
1587
+ index = raw;
1588
+ }
1589
+ else {
1590
+ const wanted = face.select[selectorKey];
1591
+ if (typeof wanted !== "string" || wanted.trim() === "")
1592
+ throw new ToolRefusalError({ status: "refused", blocker: "rule-mapping-selector-key", message: `select.${selectorKey} 必须是非空字符串;收到 ${JSON.stringify(wanted)}` });
1593
+ const hits = elements
1594
+ .map((entry, position) => ({ entry, position }))
1595
+ .filter(({ entry }) => entry !== null && typeof entry === "object" && !Array.isArray(entry) && String(entry[identityKey] ?? "") === wanted);
1596
+ if (hits.length === 0)
1597
+ throw new ToolRefusalError({ status: "refused", blocker: "rule-mapping-not-found", message: `${face.list} 没有 ${identityKey}=${wanted} 的映射;现有:${JSON.stringify(elements.map((_entry, position) => describeEntry(position)))}` });
1598
+ if (hits.length > 1)
1599
+ throw new ToolRefusalError({ status: "refused", blocker: "rule-mapping-ambiguous", message: `${face.list} 有 ${hits.length} 条 ${identityKey}=${wanted}(identity 撞重),拒绝猜一条;候选:${JSON.stringify(hits.map(({ position }) => describeEntry(position)))};确信目标时用 {"index":N} 显式定位` });
1600
+ index = hits[0].position;
1601
+ }
1602
+ const target = elements[index];
1603
+ if (target === null || typeof target !== "object" || Array.isArray(target))
1604
+ throw new ToolRefusalError({ status: "refused", blocker: "rule-mapping-element-not-object", message: `${face.list}[${index}] 不是对象,无法浅合并` });
1605
+ const merged = { ...target, ...face.patch };
1606
+ const nextList = elements.map((entry, position) => (position === index ? merged : entry));
1607
+ const nextNode = face.list === "dataActions"
1608
+ ? { ...node, dataActions: nextList }
1609
+ : { ...node, methodMapping: { ...node.methodMapping, [listKey]: nextList } };
1610
+ return {
1611
+ node: nextNode,
1612
+ receipt: {
1613
+ list: face.list,
1614
+ index,
1615
+ identity: { key: selectorKey, value: selectorKey === "index" ? index : String(face.select[selectorKey]) },
1616
+ patchedKeys: Object.keys(face.patch ?? {}),
1617
+ },
1618
+ };
1619
+ };
1507
1620
  const loadRuleNodePatchGraph = async (session, args) => {
1508
1621
  const id = await resolveRuleRowId(session, args.schemaCode, args.ruleCode);
1509
1622
  if (!id)
@@ -1511,9 +1624,16 @@ export function registerBusinessRuleLane(tools) {
1511
1624
  const record = (await wireCall(session, { path: ENDPOINTS.businessRuleGet, query: { id } })).data;
1512
1625
  if (!record)
1513
1626
  throw new ToolRefusalError({ status: "refused", blocker: "rule-absent", message: `规则 ${args.schemaCode}.${args.ruleCode}(id ${id})读回为空` });
1627
+ // F3:node 级 patch 与 mapping 级 patch 至少给一个(都不是 → 无操作,拒绝);
1628
+ // 同时给时不得指向同一数组(patch.dataActions vs mapping.list=dataActions 是
1629
+ // 自相矛盾的指令——整组替换与单条替换打架,拒绝而不是定隐式优先级)。
1630
+ if (args.patch === undefined && args.mapping === undefined)
1631
+ throw new ToolRefusalError({ status: "refused", blocker: "rule-node-patch-empty", message: "patch 与 mapping 至少给一个:patch=节点级浅合并,mapping=单条映射局部 patch(list+select+patch)" });
1514
1632
  for (const key of ["nodeCode", "nodeType"])
1515
- if (key in args.patch)
1633
+ if (args.patch !== undefined && key in args.patch)
1516
1634
  throw new ToolRefusalError({ status: "refused", blocker: "rule-node-immutable-key", message: `node patch 不允许改 ${key}(平台按 nodeCode 连接路由、节点类型不可变);要改名/改型请整图 rule.save` });
1635
+ if (args.patch !== undefined && args.mapping !== undefined && args.mapping.list.split(".")[0] in args.patch)
1636
+ throw new ToolRefusalError({ status: "refused", blocker: "rule-mapping-patch-conflict", message: `patch 与 mapping 同时写了 ${args.mapping.list.split(".")[0]}:node 级 patch 已整组替换该键,单条 mapping patch 无从定位;去掉 patch 里的这个键,或去掉 mapping` });
1517
1637
  // node/route are SEPARATE JSON-string columns (see rule.get): `node` is the
1518
1638
  // nodes array, `route` the routes array — not one {nodes,routes} object.
1519
1639
  const nodes = decodeJsonColumn(record.node, JSON_COLUMN_NULL_COALESCE);
@@ -1522,14 +1642,32 @@ export function registerBusinessRuleLane(tools) {
1522
1642
  const target = nodeList.find((node) => node.nodeCode === args.nodeCode);
1523
1643
  if (!target)
1524
1644
  throw new ToolRefusalError({ status: "refused", blocker: "rule-node-absent", message: `现有图中没有 nodeCode=${args.nodeCode};用 rule.get schemaCode+ruleCode 查看 nodeCode` });
1525
- const mergedNode = { ...target, ...args.patch };
1526
- const mergedGraph = { nodes: nodeList.map((node) => (node.nodeCode === args.nodeCode ? mergedNode : node)), ...(Array.isArray(routes) ? { routes } : {}) };
1527
- return { id, record, mergedGraph, ruleName: String(record.name ?? args.ruleCode) };
1645
+ let mergedNode = { ...target, ...(args.patch ?? {}) };
1646
+ let mappingReceipt;
1647
+ if (args.mapping !== undefined) {
1648
+ // F3:mapping 面作用于(可选 node patch 合并后的)目标节点;单条浅合并,
1649
+ // 其余元素/键逐字节保留——由 applyRuleMappingPatch 纯函数保证。
1650
+ const applied = applyRuleMappingPatch(mergedNode, args.mapping);
1651
+ mergedNode = applied.node;
1652
+ mappingReceipt = applied.receipt;
1653
+ }
1654
+ const mergedGraph = {
1655
+ nodes: nodeList.map((node) => (node.nodeCode === args.nodeCode ? mergedNode : node)),
1656
+ ...(Array.isArray(routes) ? { routes } : {}),
1657
+ // F5(2026-11-20 真机 R2/B):TIMING 规则的调度参数在**规则行**
1658
+ // schedulerSetting(JSON 字符串),不在 SCHEDULER 节点上。只重建
1659
+ // {nodes,routes} 会把它丢掉 → 出门 lint 拒 rule-graph-scheduler-setting-missing
1660
+ // (rule-graph.ts:1814),定时规则因此没法用节点/映射 patch。行级配置
1661
+ // 原样带回;bizRuleType 一并保留,避免定时规则被 prepareRuleGraph 降级。
1662
+ ...(record.schedulerSetting !== undefined && record.schedulerSetting !== null ? { schedulerSetting: record.schedulerSetting } : {}),
1663
+ ...(typeof record.bizRuleType === "number" ? { bizRuleType: record.bizRuleType } : {}),
1664
+ };
1665
+ return { id, record, mergedGraph, ruleName: String(record.name ?? args.ruleCode), ...(mappingReceipt !== undefined ? { mappingReceipt } : {}) };
1528
1666
  };
1529
1667
  writeTool({
1530
1668
  tools,
1531
1669
  name: "rule.node.update",
1532
- search: { intents: ["改规则节点", "改一个节点的条件", "调整规则里的节点", "改分支阈值"] },
1670
+ search: { intents: ["改规则节点", "改一个节点的条件", "调整规则里的节点", "改分支阈值", "改一条映射", "改字段映射"] },
1533
1671
  lane: RULE_LANE,
1534
1672
  scope: RULE_TOOLS["rule.node.update"].scope,
1535
1673
  description: RULE_TOOLS["rule.node.update"].description,
@@ -1537,7 +1675,17 @@ export function registerBusinessRuleLane(tools) {
1537
1675
  schemaCode: z.string().min(1),
1538
1676
  ruleCode: z.string().min(1),
1539
1677
  nodeCode: z.string().min(1).describe("要改的节点 nodeCode(在现有图里定位,不是新建)"),
1540
- patch: z.record(z.string(), z.unknown()).describe("浅合并到该节点的字段(如 exitConditionGroups/filterCondition/dataActions/nodeName);不允许改 nodeCode/nodeType"),
1678
+ patch: z.record(z.string(), z.unknown()).optional().describe("浅合并到该节点的字段(如 exitConditionGroups/filterCondition/nodeName);改 dataActions/methodMapping 里的单条映射优先用 mapping 面;不允许改 nodeCode/nodeType;与 mapping 至少给一个"),
1679
+ // F3:单条 mapping 局部 patch。嵌套 describe 不进 tools/list 字节预算
1680
+ // (toolsListBytes 只序列化顶层参数名+描述),语义细节放这里零成本。
1681
+ mapping: z
1682
+ .object({
1683
+ list: z.enum(["dataActions", "methodMapping.inputMappings", "methodMapping.outputMappings"]).describe("要 patch 的映射数组:dataActions=CREATE/UPDATE/ASSIGN 的字段映射叶;methodMapping.inputMappings/outputMappings=BIZ_ACTION 的方法入/出参映射"),
1684
+ select: z.record(z.string(), z.unknown()).describe('稳定标识唯一选中一条:dataActions→{"targetDataItem":"目标字段code"};入/出参→{"serviceMethodParameterCode":"参数code"};identity 撞重时 {"index":N}(0 基,按 rule.get 数组序)。命中 0 条或 >1 条都拒绝并列候选,绝不猜'),
1685
+ patch: z.record(z.string(), z.unknown()).describe("浅合并进选中那条映射的声明字段(如 bizCode/value/codeType/currentDataItemValue);未声明的键、其余条目、节点其余键、routes、设计器 layout 键(x/y/width/height/points)逐字节保留"),
1686
+ })
1687
+ .optional()
1688
+ .describe("单条映射局部 patch:只改 select 命中的那一条映射(与 patch 可并用,但不得与 patch 同时写同一数组)"),
1541
1689
  publish: z.boolean().optional().describe("改完同样顺带 publish(默认 false,仅存草稿;生效仍需 rule.enable)"),
1542
1690
  customTrigger: z.boolean().optional(),
1543
1691
  },
@@ -1545,7 +1693,10 @@ export function registerBusinessRuleLane(tools) {
1545
1693
  const base = await loadRuleNodePatchGraph(session, args);
1546
1694
  // A4:patch 入口的统一状态段——operation:"patch" + target.nodeCode(图仍是
1547
1695
  // 整图重存,graph.saved:true 报的是全图,与 rule.save 同构)。
1548
- return executeRuleSaveWrite(session, { schemaCode: args.schemaCode, ruleCode: args.ruleCode, name: base.ruleName, nodeGraph: base.mergedGraph, ...(args.publish === true ? { publish: true } : {}), ...(args.customTrigger === true ? { customTrigger: true } : {}) }, { operation: "patch", nodeCode: args.nodeCode });
1696
+ const result = await executeRuleSaveWrite(session, { schemaCode: args.schemaCode, ruleCode: args.ruleCode, name: base.ruleName, nodeGraph: base.mergedGraph, ...(args.publish === true ? { publish: true } : {}), ...(args.customTrigger === true ? { customTrigger: true } : {}) }, { operation: "patch", nodeCode: args.nodeCode });
1697
+ // F3:mapping 面的回执增量(选中数组/下标/标识/改了哪些键)——readback 顶层
1698
+ // additive 键;ruleStatus 共享形状不动,未选中的部分不变由整图合并语义保证。
1699
+ return base.mappingReceipt === undefined ? result : { ...result, readback: { ...result.readback, mappingPatch: { nodeCode: args.nodeCode, ...base.mappingReceipt } } };
1549
1700
  },
1550
1701
  // r73 #1(GitLab #40):dry-run 此前走 write.ts 通用 dry-run(只出 plan),不跑
1551
1702
  // 图 lint——非法 patch(如 CREATE 节点 originatorValue 置空)dry-run 过、真写
@@ -1559,7 +1710,8 @@ export function registerBusinessRuleLane(tools) {
1559
1710
  const linted = await lintRuleGraphForWrite(session, { schemaCode: args.schemaCode, ruleCode: args.ruleCode, nodeGraph: base.mergedGraph, ...(args.customTrigger === true ? { customTrigger: true } : {}) }, { validationRefusalMessage: "nodeGraph 未过出门前校验(dry lint,与真写同门);按 validation 逐项修正" });
1560
1711
  return {
1561
1712
  nodeCode: args.nodeCode,
1562
- patchedKeys: Object.keys(args.patch),
1713
+ patchedKeys: Object.keys(args.patch ?? {}),
1714
+ ...(base.mappingReceipt !== undefined ? { mapping: base.mappingReceipt } : {}),
1563
1715
  // 本次 dry-run 覆盖的是**全图** lint(patch 合并进存量图后整图过门),
1564
1716
  // 不是只验 patch 本身。`lintScope` 现在是 R75-B 的契约字段
1565
1717
  // (full/partial/plan,由 writeTool 声明)——图谱细节用独立键,避免同名双义。
@@ -93,6 +93,7 @@ export const RUNTIME_DATA_LANE_CONTRACT = Object.freeze({
93
93
  updateAbsentGuard: RUNTIME_DATA_WIRE.updateAbsentGuard,
94
94
  childRowStatusNote: RUNTIME_DATA_WIRE.childRowStatusNote,
95
95
  projectionHint: RUNTIME_DATA_WIRE.projectionHint,
96
+ projectionEvidence: RUNTIME_DATA_WIRE.projectionEvidence,
96
97
  }),
97
98
  wireBindings: Object.freeze({
98
99
  queryConditionShape: Object.freeze([emitterBinding("data-list-filter.toQueryCondition", assertRuntimeDataContract)]),
@@ -116,6 +117,9 @@ export const RUNTIME_DATA_LANE_CONTRACT = Object.freeze({
116
117
  updateAbsentGuard: Object.freeze([behaviorBinding("test/data-update.test.ts#data.update does NOT silently insert", assertRuntimeDataContract)]),
117
118
  childRowStatusNote: Object.freeze([behaviorBinding("test/data-update.test.ts#data.update stamps rowStatus on child-table rows", assertRuntimeDataContract)]),
118
119
  projectionHint: Object.freeze([behaviorBinding("test/data-list.test.ts#data.list appends projectionHint", assertRuntimeDataContract)]),
120
+ // F2(retro 24,ticket 138):未投影判定只在有 queryColumns 证据时给
121
+ // projectedFields/unprojected,否则 projectionKnown:false(mapped 原义不变)。
122
+ projectionEvidence: Object.freeze([behaviorBinding("test/ticket-138-f2-locator-provenance.test.ts#data.list classifies unprojected columns only with view evidence", assertRuntimeDataContract)]),
119
123
  }),
120
124
  evidence: Object.freeze([
121
125
  "ticket 01 B (2026-09-11): queryCondition must be List<List<List<FilterModel>>>; a 2-level array answers 10009 类型转换异常",
@@ -313,6 +313,70 @@ function emptyBusinessProjection(items) {
313
313
  return items.length > 0 && businessColumns > 0;
314
314
  }
315
315
  const VIEW_PROJECTION_HINT = "该面仅回视图投影列;业务字段全 null 不代表未写入,真值用 data.load,或用 listview.configure 配列。";
316
+ /**
317
+ * 从 items 里找「null 业务列」(跨行全 null;任何一行有值就算已投影有数据),
318
+ * 按视图列证据分类。无 null 业务列时返回 undefined(正常读取零噪音,与旧行为一致)。
319
+ */
320
+ export function projectionHintFace(items, evidence) {
321
+ const allNull = [];
322
+ const hasValue = new Set();
323
+ for (const item of items) {
324
+ for (const [key, value] of Object.entries(item.fields)) {
325
+ if (RUNTIME_SYSTEM_FIELD_CODES.has(key) || key.endsWith("_"))
326
+ continue;
327
+ if (value === null || value === undefined) {
328
+ if (!hasValue.has(key) && !allNull.includes(key))
329
+ allNull.push(key);
330
+ }
331
+ else {
332
+ hasValue.add(key);
333
+ }
334
+ }
335
+ }
336
+ const nullColumns = allNull.filter((key) => !hasValue.has(key));
337
+ if (items.length === 0 || nullColumns.length === 0)
338
+ return undefined;
339
+ const base = {
340
+ hint: "null 可能=未投影进视图列,判真值用 data.load --args {schemaCode,bizObjectId}",
341
+ projectionKnown: false,
342
+ ...(evidence !== undefined ? { viewColumnsCount: evidence.viewColumnsCount } : {}),
343
+ };
344
+ const codes = evidence?.viewColumnCodes;
345
+ if (codes === undefined)
346
+ return base;
347
+ const inView = new Set(codes);
348
+ const projectedFields = nullColumns.filter((code) => inView.has(code));
349
+ const unprojected = nullColumns.filter((code) => !inView.has(code));
350
+ return {
351
+ ...base,
352
+ projectionKnown: true,
353
+ ...(projectedFields.length > 0 ? { projectedFields } : {}),
354
+ ...(unprojected.length > 0 ? { unprojected } : {}),
355
+ };
356
+ }
357
+ /**
358
+ * data.list 的视图证据读取(query/get 失败/无视图 → undefined = 无证据)。
359
+ * 拿到 queryColumns 数组才算可判定证据;视图对象在但 queryColumns 非数组 →
360
+ * 只保留列数 0 的兼容口径(projectionKnown 仍 false)。
361
+ */
362
+ async function listViewProjectionEvidence(session, schemaCode, queryCode) {
363
+ try {
364
+ const view = (await wireCall(session, { path: ENDPOINTS.listQueryGet, query: { schemaCode, code: queryCode, clientType: "PC" } })).data;
365
+ if (view === null || typeof view !== "object")
366
+ return undefined;
367
+ if (Array.isArray(view.queryColumns)) {
368
+ const codes = view.queryColumns
369
+ .map((column) => String(column.propertyCode ?? ""))
370
+ .filter((code) => code.length > 0);
371
+ return { viewColumnsCount: codes.length, viewColumnCodes: codes };
372
+ }
373
+ return { viewColumnsCount: 0 };
374
+ }
375
+ catch {
376
+ // Projection diagnostics must never make data.list fail.
377
+ return undefined;
378
+ }
379
+ }
316
380
  /**
317
381
  * Default-compact a runtime record: drop only KNOWN engine noise — `*_` keys are
318
382
  * flow-engine internals (`activityName_`, `participants_`, …) and the staff/dept
@@ -1612,16 +1676,10 @@ export function registerRuntimeDataLane(tools) {
1612
1676
  });
1613
1677
  const preview = dataListItemPreview(items);
1614
1678
  const nullProjection = items.some((item) => Object.values(item.fields).some((value) => value === null));
1615
- let viewColumnsCount;
1616
- if (nullProjection) {
1617
- try {
1618
- const view = (await wireCall(session, { path: ENDPOINTS.listQueryGet, query: { schemaCode: args.schemaCode, code: args.queryCode ?? args.schemaCode, clientType: "PC" } })).data;
1619
- viewColumnsCount = Array.isArray(view?.queryColumns) ? view.queryColumns.length : 0;
1620
- }
1621
- catch {
1622
- // Projection diagnostics must never make data.list fail.
1623
- }
1624
- }
1679
+ // F2(retro 24):出现 null 业务列才读视图证据(正常读取零额外 wire);
1680
+ // 证据链见 projectionHintFace 的源码注释。
1681
+ const viewEvidence = nullProjection ? await listViewProjectionEvidence(session, args.schemaCode, args.queryCode ?? args.schemaCode) : undefined;
1682
+ const projectionHintAll = projectionHintFace(items, viewEvidence);
1625
1683
  return {
1626
1684
  schemaCode: args.schemaCode,
1627
1685
  ...application,
@@ -1668,7 +1726,7 @@ export function registerRuntimeDataLane(tools) {
1668
1726
  }),
1669
1727
  }
1670
1728
  : {}),
1671
- ...(nullProjection ? { projectionHint: { hint: "null 可能=未投影进视图列,判真值用 data.load --args {schemaCode,bizObjectId}", ...(viewColumnsCount !== undefined ? { viewColumnsCount } : {}) } } : {}),
1729
+ ...(projectionHintAll !== undefined ? { projectionHint: projectionHintAll } : {}),
1672
1730
  items,
1673
1731
  };
1674
1732
  }
@@ -1798,17 +1856,11 @@ export function registerRuntimeDataLane(tools) {
1798
1856
  const data = row.data && typeof row.data === "object" ? row.data : row;
1799
1857
  return String(data.sequenceStatus ?? row.sequenceStatus ?? "") === "DRAFT";
1800
1858
  }).length;
1801
- let viewColumnsCount;
1859
+ // F2(retro 24):出现 null 业务列才读视图证据;证据链与语义见
1860
+ // projectionHintFace / listViewProjectionEvidence 的源码注释。
1802
1861
  const hasNullValue = items.some((item) => Object.values(item.fields).some((value) => value === null));
1803
- if (hasNullValue) {
1804
- try {
1805
- const view = (await wireCall(session, { path: ENDPOINTS.listQueryGet, query: { schemaCode: args.schemaCode, code: args.queryCode ?? args.schemaCode, clientType: "PC" } })).data;
1806
- viewColumnsCount = Array.isArray(view?.queryColumns) ? view.queryColumns.length : 0;
1807
- }
1808
- catch {
1809
- // Keep the data read authoritative if the optional diagnostic read fails.
1810
- }
1811
- }
1862
+ const viewEvidence = hasNullValue ? await listViewProjectionEvidence(session, args.schemaCode, args.queryCode ?? args.schemaCode) : undefined;
1863
+ const projectionHintPaged = projectionHintFace(items, viewEvidence);
1812
1864
  const readback = {
1813
1865
  schemaCode: args.schemaCode,
1814
1866
  ...application,
@@ -1841,7 +1893,7 @@ export function registerRuntimeDataLane(tools) {
1841
1893
  return { filter: policy };
1842
1894
  })(),
1843
1895
  ...(choiceFilterFields.length > 0 && Number(total ?? 0) === 0 ? { filterValueHint: choiceFilterValueHint(choiceFilterFields) } : {}),
1844
- ...(hasNullValue ? { projectionHint: { hint: "null 可能=未投影进视图列,判真值用 data.load --args {schemaCode,bizObjectId}", ...(viewColumnsCount !== undefined ? { viewColumnsCount } : {}) } } : {}),
1896
+ ...(projectionHintPaged !== undefined ? { projectionHint: projectionHintPaged } : {}),
1845
1897
  totalPages,
1846
1898
  itemsCount: items.length,
1847
1899
  itemsReturned: items.length,
@@ -239,16 +239,16 @@ export function projectJsonPathFanout(value, path) {
239
239
  if (marker < 0) {
240
240
  const projected = projectJsonPath(value, path);
241
241
  return projected.missed
242
- ? { values: [], missed: true, ...(projected.at !== undefined ? { at: projected.at } : {}), ...(projected.available !== undefined ? { available: projected.available } : {}), ...(projected.availableAll !== undefined ? { availableAll: projected.availableAll } : {}), ...(projected.availableTruncated !== undefined ? { availableTruncated: projected.availableTruncated } : {}), missedEntries: 0, nullEntries: 0 }
243
- : { values: [projected.value], missed: false, missedEntries: 0, nullEntries: projected.value === null ? 1 : 0 };
242
+ ? { values: [], missed: true, ...(projected.at !== undefined ? { at: projected.at } : {}), ...(projected.available !== undefined ? { available: projected.available } : {}), ...(projected.availableAll !== undefined ? { availableAll: projected.availableAll } : {}), ...(projected.availableTruncated !== undefined ? { availableTruncated: projected.availableTruncated } : {}), missedEntries: 0, nullEntries: 0, nonNullEntries: 0 }
243
+ : { values: [projected.value], missed: false, missedEntries: 0, nullEntries: projected.value === null ? 1 : 0, nonNullEntries: projected.value === null ? 0 : 1 };
244
244
  }
245
245
  const before = path.slice(0, marker);
246
246
  const after = path.slice(marker + 2).replace(/^[./]+/, "");
247
247
  const base = projectJsonPath(value, before);
248
248
  if (base.missed)
249
- return { values: [], missed: true, ...(base.at !== undefined ? { at: base.at } : {}), ...(base.available !== undefined ? { available: base.available } : {}), ...(base.availableAll !== undefined ? { availableAll: base.availableAll } : {}), ...(base.availableTruncated !== undefined ? { availableTruncated: base.availableTruncated } : {}), missedEntries: 0, nullEntries: 0 };
249
+ return { values: [], missed: true, ...(base.at !== undefined ? { at: base.at } : {}), ...(base.available !== undefined ? { available: base.available } : {}), ...(base.availableAll !== undefined ? { availableAll: base.availableAll } : {}), ...(base.availableTruncated !== undefined ? { availableTruncated: base.availableTruncated } : {}), missedEntries: 0, nullEntries: 0, nonNullEntries: 0 };
250
250
  if (!Array.isArray(base.value))
251
- return { values: [], missed: true, at: before || "$", available: `该层不是数组(是 ${base.value === null ? "null" : typeof base.value});[] 只能映射数组,如 items[].fields.planNo`, missedEntries: 0, nullEntries: 0 };
251
+ return { values: [], missed: true, at: before || "$", available: `该层不是数组(是 ${base.value === null ? "null" : typeof base.value});[] 只能映射数组,如 items[].fields.planNo`, missedEntries: 0, nullEntries: 0, nonNullEntries: 0 };
252
252
  const values = [];
253
253
  let missedEntries = 0;
254
254
  let nullEntries = 0;
@@ -263,9 +263,9 @@ export function projectJsonPathFanout(value, path) {
263
263
  // array) — report the miss so the caller does not read an empty list as data.
264
264
  if (values.length === 0 && missedEntries > 0) {
265
265
  const first = projectJsonPathFanout(base.value[0], after);
266
- return { values: [], missed: true, ...(first.at !== undefined ? { at: `${before}[].${first.at}` } : {}), ...(first.available !== undefined ? { available: first.available } : {}), ...(first.availableAll !== undefined ? { availableAll: first.availableAll } : {}), ...(first.availableTruncated !== undefined ? { availableTruncated: first.availableTruncated } : {}), missedEntries, nullEntries: 0 };
266
+ return { values: [], missed: true, ...(first.at !== undefined ? { at: `${before}[].${first.at}` } : {}), ...(first.available !== undefined ? { available: first.available } : {}), ...(first.availableAll !== undefined ? { availableAll: first.availableAll } : {}), ...(first.availableTruncated !== undefined ? { availableTruncated: first.availableTruncated } : {}), missedEntries, nullEntries: 0, nonNullEntries: 0 };
267
267
  }
268
- return { values, missed: false, ...(missedEntries > 0 ? { missedEntries } : { missedEntries: 0 }), nullEntries };
268
+ return { values, missed: false, ...(missedEntries > 0 ? { missedEntries } : { missedEntries: 0 }), nullEntries, nonNullEntries: values.length - nullEntries };
269
269
  }
270
270
  /** Collect every value of a repeatable flag (`--extract a --extract b`). */
271
271
  function argvValues(args, name) {
@@ -284,9 +284,13 @@ function argvValues(args, name) {
284
284
  * (`projectResultExtract` 的 miss、`artifact get --summary --jq`、artifact 裸
285
285
  * `--jq`、逗号多路径部分 miss、以及 `artifact get` 的 fetch 提示),改一处忘一处
286
286
  * 就会出现"同一个错误两种说法"。现在语法句子只在这里定义,其余地方拼装。
287
+ *
288
+ * F1(retro 22,ticket 138):语法长句**不再内联**进任何 miss 回执——一次
289
+ * pathMiss 曾带 766–870B 教程、一个会话 6+ 次吃掉几 KB 上下文。回执只给
290
+ * `helpRef`(机器可读指针)+ ≤200B 的行动句;完整教程读 help 的权威一节。
287
291
  */
288
292
  export const JQ_PATH_SYNTAX = "可用写法:点式 a.b、下标 a[0]、切片 a[0:6]、数组映射 items[].fields.x、按键选择 rules[code=Create] 或 data.activities[code=A1](数组与 index→条目对象都支持;键名可省 activityCode/nodeCode 等别名;返回第一个匹配项)。";
289
- /** 非 jq 语言 + 一次取多列的写法。每一处 miss 提示都以它收尾。 */
293
+ /** 非 jq 语言 + 一次取多列的写法。只在 help 教程里出现,不进回执。 */
290
294
  export const JQ_PATH_RULES = "注意:本参数是路径选择器、不是 jq 语言(不支持 | 管道与对象构造);一次取多列用逗号分隔(--jq \"a.b,c.d\")或重复传 --jq。";
291
295
  /**
292
296
  * `call --extract/--jq` 专有的位置语义:路径相对 **result**,不是整个信封。
@@ -299,30 +303,37 @@ export const RESULT_RELATIVE_PATH_NOTE = "路径相对 **result**(不要写 re
299
303
  export const JQ_PATH_TOPIC = "omc-refusals";
300
304
  export const JQ_PATH_SECTION = "10. 投影路径(--jq / --extract)";
301
305
  export const JQ_PATH_HELP_POINTER = `语法详解:omc help ${JQ_PATH_TOPIC} --section 10(投影路径)。`;
306
+ /**
307
+ * F1(retro 22,ticket 138):miss 回执的**机器可读**教程指针。回执不再内联
308
+ * 766B+ 的语法长句(一次会话 6+ 次 miss 就是几 KB 噪声);要看教程的人/agent
309
+ * 按这个字段取 help 的权威一节。值为可直接执行的命令字符串。
310
+ */
311
+ export const PATH_MISS_HELP_REF = `omc help ${JQ_PATH_TOPIC} --section 10`;
302
312
  /** Shared wording for every projection miss, so every face teaches the same syntax. */
303
313
  // r66 ① readbackKeys(c-F2):R65 探针 3 次投影 miss 全靠 available 救回——键名
304
314
  // 无处可查。裸 --jq(不带路径)= 键清单这个姿势一直在(cli.ts extractKeys 分支),
305
315
  // 但没有任何一面教过它。miss 正是教学时机:撞过一次的人最听得进「先看全键再投影」。
306
316
  // r67-03(触达失败复检):R67 探针 4 次 pathMiss 无一注意这句教学——它此前被夹在
307
- // 语法长句(JQ_PATH_SYNTAX)之后的中段,读 hint 的人早被 available/语法淹没。
308
- // 行动句提前到 available 说明之后、JQ_PATH_SYNTAX 之前,并改成「下一步先列键」
309
- // 的动作式措辞:下一跳排在语法课前面,才会在注意力耗尽前被读到。
310
- export const PATH_MISS_HINT = `路径未命中(这一层没有该段)。${RESULT_RELATIVE_PATH_NOTE}available 是该层真实存在的键。下一步先列键:--jq 不带路径重跑 = 全部顶层键一览。${JQ_PATH_SYNTAX}${JQ_PATH_RULES}${JQ_PATH_HELP_POINTER}`;
317
+ // 语法长句(JQ_PATH_SYNTAX)之后的中段。行动句排在最前。
318
+ // F1(retro 22,ticket 138):压到 ≤200B——结论 + available 判读 + 一条下一步 +
319
+ // helpRef 指针,语法全集只在 help(旧版 766B → 新版 ≤200B,测试钉死上限)。
320
+ export const PATH_MISS_HINT = `路径未命中。available 是该层真实存在的键;下一步先列键:--jq 不带路径重跑 = 全部顶层键一览。语法教程:${PATH_MISS_HELP_REF}。`;
311
321
  /**
312
322
  * `artifact get` 面:产物内容的投影。区别只在开头——它已经把 miss 落在哪一段
313
323
  * (`missedAt`)和可用的键/范围一并返回,所以不必重复「这一层没有该段」。
324
+ * F1(retro 22):语法长句不内联,压成 定位 + 可复制路径 + --keys 教学 + helpRef。
314
325
  */
315
326
  export function artifactPathMissHint(at, copyable) {
316
327
  const lead = `路径未命中${at !== undefined ? `段 "${at}"` : "(这一层没有该段)"}`;
317
328
  // issue 19:命中同名键时先给可整段复制的完整路径(相对产物正文)。
318
329
  if (copyable !== undefined) {
319
- return `${lead}。${copyable}。想一次拿全部顶层键:--keys(或裸 --jq)。${JQ_PATH_SYNTAX}${JQ_PATH_RULES}${JQ_PATH_HELP_POINTER}`;
330
+ return `${lead}。${copyable}。想一次拿全部顶层键:--keys(或裸 --jq)。语法教程:${PATH_MISS_HELP_REF}。`;
320
331
  }
321
- return `${lead}——available 是该层真实存在的键/范围;方括号下标(a[0])与点式(a.0)等价;想一次拿全部顶层键:--keys(或裸 --jq)。${JQ_PATH_SYNTAX}${JQ_PATH_RULES}${JQ_PATH_HELP_POINTER}`;
332
+ return `${lead}——available 是该层真实存在的键/范围;想一次拿全部顶层键:--keys(或裸 --jq)。语法教程:${PATH_MISS_HELP_REF}。`;
322
333
  }
323
- /** 逗号多路径里只有部分 miss:给出定位方式 + 同一套语法。 */
334
+ /** 逗号多路径里只有部分 miss:给出定位方式 + helpRef(语法长句不内联)。 */
324
335
  export function partialPathMissHint() {
325
- return `逗号多路径中部分路径未命中(见各 projection.pathMiss/missedAt/available)。${JQ_PATH_SYNTAX}${JQ_PATH_HELP_POINTER}`;
336
+ return `逗号多路径中部分路径未命中(见各 projection.pathMiss/missedAt/available)。语法教程:${PATH_MISS_HELP_REF}。`;
326
337
  }
327
338
  /**
328
339
  * 逐条 miss 的**短**提示。r27 真机(2026-11-05)实证:一段 695 B 的完整语法在
@@ -481,12 +492,53 @@ export function pathMissCopyableHint(source, path, at, limit = 3) {
481
492
  return `这段的完整路径是 ${shown[0]}——可直接复制:${quoted}`;
482
493
  return `这段有多个位置——可直接复制其一:${quoted}`;
483
494
  }
495
+ const CROSS_FACE_LOAD_REASON = "data.load 平铺在 data.<code>,不套 fields";
496
+ const CROSS_FACE_LIST_REASON = "data.list 列在 items[].fields.<code>";
497
+ export function pathMissCrossFaceCorrection(source, path, at) {
498
+ if (at === undefined || at.length === 0)
499
+ return undefined;
500
+ const clean = path.replace(/^\$\.?/, "").replace(/^[.\/]+/, "");
501
+ // 只处理「首段就 miss」的 retro 21 形态(fields.x / data.x 写到对面根上);
502
+ // 更深层的 miss 由 didYouMean/同名键扫描接手。
503
+ const headMatch = /^([A-Za-z_][\w]*)((?:[.\[\/]).*)?$/.exec(clean);
504
+ if (headMatch === null)
505
+ return undefined;
506
+ const head = headMatch[1];
507
+ if (head !== at)
508
+ return undefined;
509
+ const rest = headMatch[2] ?? "";
510
+ if (head === "fields") {
511
+ const candidate = `data${rest}`;
512
+ if (copyableCandidateResolves(source, candidate))
513
+ return { correctPath: candidate, reason: CROSS_FACE_LOAD_REASON };
514
+ }
515
+ if (head === "data") {
516
+ const candidate = `items[].fields${rest}`;
517
+ if (copyableCandidateResolves(source, candidate))
518
+ return { correctPath: candidate, reason: CROSS_FACE_LIST_REASON };
519
+ }
520
+ return undefined;
521
+ }
522
+ const RETRY_ARGS_MAX_BYTES = 500;
523
+ const shellQuote = (value) => `'${value.replace(/'/g, "'\\''")}'`;
524
+ export function projectionRetryCommand(context, path) {
525
+ if (context === undefined || context.tool === undefined || context.tool.length === 0)
526
+ return undefined;
527
+ if (context.argsJson !== undefined && Buffer.byteLength(context.argsJson, "utf8") > RETRY_ARGS_MAX_BYTES)
528
+ return undefined;
529
+ return [
530
+ `omc call ${context.tool}`,
531
+ ...(context.environment !== undefined && context.environment.length > 0 ? [`--env ${context.environment}`] : []),
532
+ ...(context.argsJson !== undefined ? [`--args ${shellQuote(context.argsJson)}`] : []),
533
+ `--jq ${shellQuote(path)}`,
534
+ ].join(" ");
535
+ }
484
536
  /**
485
- * 多路径一次投影时的**唯一一份**语法说明(放结果顶层,不再逐条复制)。
486
- * 只给最要紧的三条:位置语义、映射写法、help 指针。
537
+ * 多路径一次投影时的**唯一一份**顶层说明。只给位置语义 + helpRef——
538
+ * F1(retro 22):语法长句不内联(教程只在 help)。
487
539
  */
488
540
  export function multiPathMissHint() {
489
- return `${RESULT_RELATIVE_PATH_NOTE}${JQ_PATH_SYNTAX}${JQ_PATH_HELP_POINTER}`;
541
+ return `${RESULT_RELATIVE_PATH_NOTE}语法教程:${PATH_MISS_HELP_REF}。`;
490
542
  }
491
543
  /**
492
544
  * T6(GitLab #17):`mapped` 只是"路径命中的条目数",值为 null 也算命中。
@@ -651,7 +703,7 @@ function projectPathOnSource(source, path) {
651
703
  }
652
704
  return { ...first };
653
705
  }
654
- export function projectResultExtract(result, paths, keysOnly) {
706
+ export function projectResultExtract(result, paths, keysOnly, retry) {
655
707
  const artifactId = typeof result.detailArtifactId === "string" ? result.detailArtifactId : typeof result.artifactId === "string" ? result.artifactId : undefined;
656
708
  // Tools hand an in-process artifact as `detailFile` (a local path);
657
709
  // command-transport later swaps it for detailArtifactId. Extraction runs
@@ -723,10 +775,18 @@ export function projectResultExtract(result, paths, keysOnly) {
723
775
  // r27 真机:多路径时每条 miss 都带 695 B 完整语法 → 3 条 2 KB 说同一件事。
724
776
  // 单路径照旧带完整提示(只出现一次,最有用);多路径逐条只给定位,语法放顶层一次。
725
777
  const multiPath = paths.length > 1;
726
- const missHintFor = (path, at, available, availableAll) => {
727
- const fallback = multiPath ? pathMissEntryHint(at, available) : PATH_MISS_HINT;
728
- const candidate = pathMissDidYouMean(at, available, availableAll);
729
- if (candidate !== undefined && at !== undefined) {
778
+ /**
779
+ * F1(retro 22,ticket 138):miss 的**结论优先**。能推导出已验证的正确路径就
780
+ * 给 `correctPath`(机器字段)+ 首行人话;推导不出才落回 PATH_MISS_HINT。
781
+ * 候选按优先级:①拼写近似(didYouMean,改写后必须真的可解析)②跨面形状
782
+ * 改写(fields↔data,retro 21)③真实结果树里的同名键(issue 19)。
783
+ * 三者都在**真实结果树**上验证过才返回——绝不编造可达路径。
784
+ */
785
+ const missCorrectionFor = (path, at, available, availableAll) => {
786
+ if (at === undefined)
787
+ return undefined;
788
+ const didYouMean = pathMissDidYouMean(at, available, availableAll);
789
+ if (didYouMean !== undefined) {
730
790
  // Replace only the missed segment, retaining array mapping and suffixes.
731
791
  const leaf = at.split(/[./\[]/).filter(Boolean).pop();
732
792
  if (leaf !== undefined) {
@@ -736,22 +796,32 @@ export function projectResultExtract(result, paths, keysOnly) {
736
796
  if (replaced || segment !== leaf || (at !== leaf && prefix !== at))
737
797
  return segment;
738
798
  replaced = true;
739
- return candidate;
799
+ return didYouMean;
740
800
  });
741
801
  // A similar key is useful only if the complete proposed path resolves.
742
802
  if (corrected !== path && !projectPathOnSource(projectionSource, corrected).projected.missed) {
743
- const quoted = corrected.replace(/'/g, "'\\''");
744
- return `路径未命中:在 "${at}" 断开;最接近的是 ${candidate}。可试:--jq '${quoted}'`;
803
+ return { correctPath: corrected };
745
804
  }
746
805
  }
747
806
  }
748
- // issue 19:没有拼写近似时,在真实结果树里找同名键,直接给可复制的完整
749
- // 路径(如 data.activities[].bizActions)——不再只描述「它在哪一层」。
750
- const copyable = pathMissCopyableHint(projectionSource, path, at);
751
- if (copyable !== undefined) {
752
- return multiPath ? `${copyable}。${pathMissEntryHint(at, available)}` : `${copyable}。${RESULT_RELATIVE_PATH_NOTE}`;
807
+ const crossFace = pathMissCrossFaceCorrection(projectionSource, path, at);
808
+ if (crossFace !== undefined)
809
+ return crossFace;
810
+ const copyable = pathMissCopyablePaths(projectionSource, path, at, 3);
811
+ if (copyable.length === 1)
812
+ return { correctPath: copyable[0] };
813
+ if (copyable.length > 1) {
814
+ return { correctPath: copyable[0], reason: `同名键另有 ${copyable.length - 1} 处:${copyable.slice(1).join("、")}` };
815
+ }
816
+ return undefined;
817
+ };
818
+ const missHintFor = (at, available, correction) => {
819
+ if (correction !== undefined) {
820
+ const quoted = correction.correctPath.replace(/'/g, "'\\''");
821
+ const lead = `正确路径:${correction.correctPath}${correction.reason !== undefined ? `(${correction.reason})` : ""}——可直接复制:--jq '${quoted}'。语法教程:${PATH_MISS_HELP_REF}。`;
822
+ return multiPath ? `${lead}${pathMissEntryHint(at, available)}` : lead;
753
823
  }
754
- return fallback;
824
+ return multiPath ? pathMissEntryHint(at, available) : PATH_MISS_HINT;
755
825
  };
756
826
  out.extract = paths.map((path) => {
757
827
  // r28f F2:对象构造 / 函数调用不是 pathMiss——先识别,别伪装成键缺失。
@@ -777,6 +847,8 @@ export function projectResultExtract(result, paths, keysOnly) {
777
847
  const fan = projected;
778
848
  if (fan.missed) {
779
849
  const didYouMean = pathMissDidYouMean(fan.at, fan.available, fan.availableAll);
850
+ const correction = missCorrectionFor(path, fan.at, fan.available, fan.availableAll);
851
+ const nextCommand = correction !== undefined ? projectionRetryCommand(retry, correction.correctPath) : undefined;
780
852
  return {
781
853
  path,
782
854
  content: null,
@@ -786,14 +858,18 @@ export function projectResultExtract(result, paths, keysOnly) {
786
858
  ...(fan.availableTruncated !== undefined ? { availableTruncated: fan.availableTruncated } : {}),
787
859
  missedEntries: fan.missedEntries,
788
860
  ...(didYouMean !== undefined ? { didYouMean } : {}),
861
+ ...(correction !== undefined ? { correctPath: correction.correctPath } : {}),
862
+ helpRef: PATH_MISS_HELP_REF,
863
+ ...(nextCommand !== undefined ? { nextCommand } : {}),
789
864
  ...(readFromArtifact ? resultLayerNote(result, path, projectionSource, fan.at) ?? {} : {}),
790
- hint: missHintFor(path, fan.at, fan.available, fan.availableAll),
865
+ hint: missHintFor(fan.at, fan.available, correction),
791
866
  };
792
867
  }
793
868
  return {
794
869
  path,
795
870
  content: fan.values,
796
871
  mapped: fan.values.length,
872
+ nonNullEntries: fan.nonNullEntries,
797
873
  ...(autoStripped !== undefined ? { autoStripped } : {}),
798
874
  ...(preferResult ? { from: "result" } : {}),
799
875
  ...(fan.nullEntries > 0 ? { nullEntries: fan.nullEntries } : {}),
@@ -815,6 +891,8 @@ export function projectResultExtract(result, paths, keysOnly) {
815
891
  };
816
892
  }
817
893
  const didYouMean = pathMissDidYouMean(single.at, single.available, single.availableAll);
894
+ const correction = missCorrectionFor(path, single.at, single.available, single.availableAll);
895
+ const nextCommand = correction !== undefined ? projectionRetryCommand(retry, correction.correctPath) : undefined;
818
896
  return {
819
897
  path,
820
898
  content: null,
@@ -823,8 +901,11 @@ export function projectResultExtract(result, paths, keysOnly) {
823
901
  available: single.available,
824
902
  ...(single.availableTruncated !== undefined ? { availableTruncated: single.availableTruncated } : {}),
825
903
  ...(didYouMean !== undefined ? { didYouMean } : {}),
904
+ ...(correction !== undefined ? { correctPath: correction.correctPath } : {}),
905
+ helpRef: PATH_MISS_HELP_REF,
906
+ ...(nextCommand !== undefined ? { nextCommand } : {}),
826
907
  ...(readFromArtifact ? resultLayerNote(result, path, projectionSource, single.at) ?? {} : {}),
827
- hint: missHintFor(path, single.at, single.available, single.availableAll),
908
+ hint: missHintFor(single.at, single.available, correction),
828
909
  };
829
910
  }
830
911
  return {
@@ -873,19 +954,21 @@ export function projectResultExtract(result, paths, keysOnly) {
873
954
  // change the exit contract), but the envelope now says so out loud.
874
955
  if (extracts.some((entry) => entry.pathMiss === true || entry.unsupportedSyntax === true)) {
875
956
  out.unanswered = true;
876
- // 多路径:语法说明给一次,不再逐条复制。不支持语法优先于 pathMiss 语法课。
957
+ // 多路径:说明给一次,不再逐条复制。不支持语法优先于 pathMiss 说明。
958
+ // F1(retro 22):语法长句不内联——顶层只留位置语义 + helpRef。
877
959
  if (extracts.some((entry) => entry.unsupportedSyntax === true)) {
878
960
  out.hint = UNSUPPORTED_JQ_OBJECT_HINT;
879
961
  }
880
962
  else if (multiPath) {
881
- out.hint = `${RESULT_RELATIVE_PATH_NOTE}${JQ_PATH_SYNTAX}多路径时用 extract[](逐条)或 rows[](列对齐);不再重复 content 映射。${JQ_PATH_HELP_POINTER}`;
963
+ out.helpRef = PATH_MISS_HELP_REF;
964
+ out.hint = `${RESULT_RELATIVE_PATH_NOTE}逐条定位见 extract[](或 rows[] 列对齐);语法教程:${PATH_MISS_HELP_REF}。`;
882
965
  }
883
966
  }
884
967
  }
885
968
  return out;
886
969
  }
887
970
  const SINGLE_PATH_META_KEYS = ["from", "artifactId", "sha256", "truncated", "truncatedKeys", "itemsCount", "total", "projectionHint"];
888
- const SINGLE_PATH_ENTRY_META_KEYS = ["mapped", "nullEntries", "missedEntries", "from", "autoStripped", "hint"];
971
+ const SINGLE_PATH_ENTRY_META_KEYS = ["mapped", "nullEntries", "nonNullEntries", "missedEntries", "from", "autoStripped", "hint"];
889
972
  export function unwrapSinglePathProjection(projected) {
890
973
  const extracts = projected.extract;
891
974
  if (!Array.isArray(extracts) || extracts.length !== 1)
@@ -42,6 +42,19 @@ const READ_SHAPES = {
42
42
  },
43
43
  "data.list": {
44
44
  // items are {id, fields:{<code>: value}} — business columns live under fields.
45
+ // F2(retro 21,ticket 138)locator:同一行业务列在 data.list 是 items[].fields.<code>,
46
+ // 在 data.load 是平铺 data.<code>;行标识在 data.load 的入参叫 bizObjectId。
47
+ // rides resultMeta.locator(信封侧),result 本体与 --jq 路径零改动。
48
+ // 平台证据:列 code 两面同名(list 行本体 BizObjectModel.data.<code>,CLI 包装成
49
+ // fields;load 面 FormDataVO.bizObject.data.<code> 平铺,见 path-projection.ts
50
+ // pathMissCrossFaceCorrection 注释的 file:line)。
51
+ locator: {
52
+ rowIdKey: "items[].id",
53
+ rowIdArg: "bizObjectId",
54
+ columnKey: "items[].fields.<code>",
55
+ peerTool: "data.load",
56
+ peerColumnKey: "data.<code>",
57
+ },
45
58
  keys: ["items:array<{id,fields:{<code>:value}}>", "total", "totalPages", "page", "size"],
46
59
  // r28i F4: agents try rows[] / items[].sku first; pin the real shape here too.
47
60
  notes: [
@@ -69,6 +82,19 @@ const READ_SHAPES = {
69
82
  notes: ["page.parentId 常为 null(/custom/get 不回 AppFunction 父节点);看 parentIdNote,落点用 folder.tree 按 code 核对"],
70
83
  },
71
84
  "data.load": {
85
+ // F2(retro 21,ticket 138)locator:本面业务列平铺在 data.<code>(不套 fields),
86
+ // 与 data.list 的 items[].fields.<code> 是同一事实两种包装;行定位入参 bizObjectId
87
+ // = data.list 的 items[].id。rides resultMeta.locator,result 本体零改动。
88
+ // 平台证据:FormRuntimeController.java:364-365(GET /api/runtime/form/load →
89
+ // FormDataVO)+ FormDataVO.java:27,62(bizObject.data 平铺业务列;CLI
90
+ // normalizeLoadedRecord 只解开 bizObject 包装,键名原样)。
91
+ locator: {
92
+ rowIdArg: "bizObjectId",
93
+ columnKey: "data.<code>",
94
+ peerTool: "data.list",
95
+ peerColumnKey: "items[].fields.<code>",
96
+ peerRowIdKey: "items[].id",
97
+ },
72
98
  keys: ["bizObjectId", "exists", "data:{...}"],
73
99
  // A1(同义事实对照):同一行业务列在两面包装不同——列表面套 fields,本面平铺。
74
100
  // 平台证据:行本体是 FormDataVO.data(GET /runtime/form_data/get_by_id 平铺业务列)。
@@ -362,6 +362,11 @@ export function parseToolInput(tool, input) {
362
362
  status: "error",
363
363
  blocker: "tool-input-unknown-keys",
364
364
  tool: tool.name,
365
+ // F1(retro 22,ticket 138):机器字段先行——被拒键与合法键全集成对给出,
366
+ // 脚本不必再从 message 里解析中文句子。issues[] 仍是逐键 diff 的单一
367
+ // 真相源(path/code/message),这里只是它的汇总面,不是第二套结构。
368
+ unknownKeys: unknown,
369
+ expectedKeys: [...schemaKeys],
365
370
  message: `写面工具不接受未知键(会被静默丢弃):${unknown.join("、")}。${twoStep.length > 0 ? twoStep.join(" ") : siblingHints.length > 0 ? siblingHints.join(";") : `${guidanceLines.length > 0 ? guidanceLines.join(";") : `最接近的合法键:${suggestions.join(";")}`}。参数表:${paramCommand}`}`,
366
371
  ...(twoStep.length > 0 || guidanceLines.length > 0 || siblingHints.length > 0 ? { nextCommand: `omc describe ${tool.name}` } : { nextCommand: paramCommand }),
367
372
  issues: unknown.map((key) => ({ path: [key], code: "unrecognized_key", message: issueHintFor(key) })),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stalfh233/omc-cli",
3
- "version": "0.6.87",
3
+ "version": "0.6.88",
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.87",
59
+ "omc-core": "0.6.88",
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.87"
77
+ "@stalfh233/omc-fake-platform": "0.6.88"
78
78
  }
79
79
  }
@@ -199,3 +199,4 @@ concurrency, not approval.
199
199
  - 多列:`--jq "a.b,c.d"` 或重复 `--jq`(结果在 `projections[]`);**不支持** `|` 与对象构造
200
200
  - miss 回 `pathMiss`+`missedAt`+`available`(`--extract` 另置 `unanswered`):未命中≠空值
201
201
  - `mapped`=命中数,`nullEntries`=其中 null 数;相等时看同次 `data.list` 的 `projectionHint` 或 `data.load`
202
+ - miss 机器字段:`correctPath`+`nextCommand`(能验证才给)、`helpRef`;`resultMeta.locator` 给 `items[].fields.<code>`↔`data.<code>`(行键↔`bizObjectId`)对照;`nonNullEntries`=mapped 中非 null 数;`projectionHint` 有 `queryColumns` 证据才给 `projectedFields`/`unprojected`,否则 `projectionKnown:false`