@stalfh233/omc-cli 0.8.15 → 0.8.16

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
@@ -59,7 +59,7 @@ import { SEARCH_MARGIN_THRESHOLD } from "./tool-search.js";
59
59
  import { commandCapabilitySlice, commandIndex, commandInventory, commandKindIndex, describeContract, describeContractFull, describeContractTool, describeExample, describeParam, describeSchemaOnly, describeTool, describeToolFull, filterTools } from "./discovery.js";
60
60
  import { locatorMetaFor } from "./read-shapes.js";
61
61
  import { surfaceRefFor } from "./surface-ref.js";
62
- import { KEY_ALIAS_HINTS, inputAliasSynonymKeys } from "./tool-types.js";
62
+ import { KEY_ALIAS_HINTS, TOOL_KEY_ALTERNATIVES, inputAliasSynonymKeys } from "./tool-types.js";
63
63
  import { repeatFullDescribe } from "./describe-cache.js";
64
64
  import { buildCapabilityOverview, capabilityCandidatesFor, capabilityDetail, capabilityRouteForTool, capabilityRouteIndex, compactCapabilities, executableCapabilityBundle, resolveCapabilityId, DISCOVERY_AUTHORITY } from "./capability-overview.js";
65
65
  import { goalRoute } from "./goal-routes.js";
@@ -806,8 +806,13 @@ async function cmdCall(store, args) {
806
806
  const otherUnknown = unknownKeys.filter((key) => !APP_SCOPE_ARG_KEYS.has(key));
807
807
  if (tool.kind !== "write" && otherUnknown.length > 0) {
808
808
  if (!lenientArgs) {
809
+ // 探针 J F4/F5:可执行替代由 TOOL_KEY_ALTERNATIVES 提供(tool+key 显式
810
+ // 登记),替代出现在 suggestions[].replaceWith/hint/nextCommand;没有
811
+ // 登记的键沿用旧口径({key} 只表「被拒」,不编造改名——见 0.8.4 C1)。
809
812
  const suggestions = otherUnknown.map((key) => ({ key, ...suggestArgumentKey(key, [...schemaKeys], toolName) }));
810
813
  const pairs = suggestions.map((entry) => {
814
+ if (entry.replaceWith !== undefined)
815
+ return `${entry.key}→${entry.replaceWith}${entry.hint !== undefined ? `(${entry.hint})` : ""}`;
811
816
  if (entry.hint)
812
817
  return `${entry.key}(${entry.hint})`;
813
818
  if (entry.closest)
@@ -816,6 +821,7 @@ async function cmdCall(store, args) {
816
821
  return `${entry.key}(本工具没有 ${entry.absentInTool})`;
817
822
  return entry.key;
818
823
  });
824
+ const explicitNext = suggestions.find((entry) => entry.nextCommand !== undefined)?.nextCommand;
819
825
  const result = {
820
826
  status: "error",
821
827
  blocker: "tool-input-unknown-keys",
@@ -826,14 +832,18 @@ async function cmdCall(store, args) {
826
832
  // describe),脚本可零解析消费。
827
833
  expectedKeys: [...schemaKeys],
828
834
  suggestions,
829
- // 有拼写近邻时直达该参数的 describe;否则退回整份参数表。
830
- ...(suggestions.some((entry) => entry.closest !== undefined)
831
- ? { nextCommand: `omc describe ${toolName} --param ${suggestions.find((entry) => entry.closest !== undefined).closest}` }
832
- : { nextCommand: `omc describe ${toolName}` }),
835
+ // 显式替代(探针 J)优先给可复制命令;其次有拼写近邻时直达该参数的
836
+ // describe;否则退回整份参数表。
837
+ ...(explicitNext !== undefined
838
+ ? { nextCommand: explicitNext }
839
+ : suggestions.some((entry) => entry.closest !== undefined)
840
+ ? { nextCommand: `omc describe ${toolName} --param ${suggestions.find((entry) => entry.closest !== undefined).closest}` }
841
+ : { nextCommand: `omc describe ${toolName}` }),
833
842
  message: `读面不接受未知键(与写面对齐):${pairs.join("、")}。` +
834
843
  // C1(0.8.4):没有可信的改写建议时,不编造改名——直接把该工具的
835
- // 真实参数名列出来,让人按名字挑。
836
- `${suggestions.every((entry) => entry.closest === undefined && entry.hint === undefined && entry.absentInTool === undefined) ? `本工具的真实参数:${[...schemaKeys].join("、")}。` : ""}` +
844
+ // 真实参数名列出来,让人按名字挑。探针 J:混合键里只要有一个键
845
+ // 没拿到替代(如 all 有 replaceWith、zzz 没有),仍要列真实参数。
846
+ `${suggestions.some((entry) => entry.closest === undefined && entry.hint === undefined && entry.absentInTool === undefined && entry.replaceWith === undefined) ? `本工具的真实参数:${[...schemaKeys].join("、")}。` : ""}` +
837
847
  `改用合法键后重试;确需宽松忽略传 lenientArgs:true。参数表:omc describe ${toolName}`,
838
848
  };
839
849
  return emit("error", result, CLI_EXIT_CODES.invalidInput);
@@ -1153,6 +1163,12 @@ function applyReadArgAliases(toolName, schemaKeys, input) {
1153
1163
  * 「改名建议」表达——建议无法携带方向/换算信息。
1154
1164
  */
1155
1165
  export function suggestArgumentKey(key, schemaKeys, toolName) {
1166
+ // 探针 J F4/F5:按 tool+key 的显式替代优先于拼写猜测(见
1167
+ // TOOL_KEY_ALTERNATIVES)。命中的是「语义改写」而不是「拼错」,所以
1168
+ // closest/编辑距离不参与,避免把原键再建议一次。
1169
+ const alternative = toolName !== undefined ? TOOL_KEY_ALTERNATIVES[toolName]?.[key] : undefined;
1170
+ if (alternative !== undefined)
1171
+ return { ...alternative };
1156
1172
  const known = new Set(schemaKeys);
1157
1173
  const paginationKeys = new Set(["page", "pagesize", "size", "pageindex", "pagenumber", "pageno", "offset", "limit"]);
1158
1174
  if (paginationKeys.has(key.toLowerCase()) && !schemaKeys.some((name) => paginationKeys.has(name.toLowerCase()))) {
@@ -3025,7 +3041,7 @@ function cmdHelpSearch(topic, query, transport, searchMode, limit) {
3025
3041
  returnedMatches: entries.length,
3026
3042
  truncated: truncated || entries.some((entry) => entry.sectionComplete === false),
3027
3043
  matches: entries,
3028
- ...(result.total === 0 ? { message: "没有匹配章节;换更短的字面词(错误码、字段名、命令名)或加 --search-mode any" } : {}),
3044
+ ...(result.total === 0 ? { message: "没有匹配章节;换更短的字面词(错误码、字段名、命令名)或加 --search-mode any。格式常量/参数用 `omc describe <tool> --param <name>` 或 `omc contract <lane>` 查(例:omc describe field.create --param options)" } : {}),
3029
3045
  ...(result.total > 0 && entries.length === 0 ? { message: "命中存在但连指针都放不进预算;加 --limit 1 或换更短的查询" } : {}),
3030
3046
  });
3031
3047
  let truncating = false;
@@ -4075,7 +4091,7 @@ async function main() {
4075
4091
  }));
4076
4092
  });
4077
4093
  command.command("bench").option("--live-sample").option("--env <environment>").action(async (options) => { commandExitCode = await cmdBench([...(options.liveSample ? ["--live-sample"] : []), ...(options.env ? ["--env", options.env] : [])]); });
4078
- command.command("residue <prefix>").description("跨面前缀残留扫描(model 全租户/folder/custompage;默认 deep 再查命中模型的 rule/datarule/onlinejs)——收尾「删净」一次证明,clean:true 即零残留。清理入口:omc model-purge --code <schemaCode>(按依赖倒序,默认 dry-run)。只读零写入;report 面暂停维护未扫描").option("--env <environment>", "环境名(默认按 cwd 的 .omc-env 解析)").option("--apps <codes>", "all(默认,全租户)或逗号分隔应用码").option("--no-deep", "只扫 model/folder/custompage,不深查命中模型").option("--all-faces", "列出全部应用×面(含 count:0;默认只回非零面+byFace/userResidues 紧凑形)").option("--max-output-bytes <bytes>").addOption(new Option("--jq [path]", "--jq 不是 jq,仅路径选择器(与 call --jq 同 DSL;可逗号多路径;裸 --jq 列顶层键)").argParser((value, previous = []) => [...previous, value]).default([])).action(async (prefix, options) => { commandExitCode = await withTransport(options, request, (transport) => cmdResidue(prefix, { env: options.env, apps: options.apps, ...(options.deep === false ? { noDeep: true } : {}), ...(options.allFaces ? { allFaces: true } : {}), ...(options.jq !== undefined ? { jq: options.jq } : {}) }, transport)); });
4094
+ command.command("residue <prefix>").description("跨面前缀残留扫描(model 全租户/folder/custompage;默认 deep 再查命中模型的 rule/datarule/onlinejs)——收尾「删净」一次证明,clean:true 仅指已扫描面零残留(cleanScope:\"scanned-faces\";report 面未扫描,用 report.tree 复核)。清理入口:omc model-purge --code <schemaCode>(按依赖倒序,默认 dry-run)。只读零写入;report 面暂停维护未扫描").option("--env <environment>", "环境名(默认按 cwd 的 .omc-env 解析)").option("--apps <codes>", "all(默认,全租户)或逗号分隔应用码").option("--no-deep", "只扫 model/folder/custompage,不深查命中模型").option("--all-faces", "列出全部应用×面(含 count:0;默认只回非零面+byFace/userResidues 紧凑形)").option("--max-output-bytes <bytes>").addOption(new Option("--jq [path]", "--jq 不是 jq,仅路径选择器(与 call --jq 同 DSL;可逗号多路径;裸 --jq 列顶层键)").argParser((value, previous = []) => [...previous, value]).default([])).action(async (prefix, options) => { commandExitCode = await withTransport(options, request, (transport) => cmdResidue(prefix, { env: options.env, apps: options.apps, ...(options.deep === false ? { noDeep: true } : {}), ...(options.allFaces ? { allFaces: true } : {}), ...(options.jq !== undefined ? { jq: options.jq } : {}) }, transport)); });
4079
4095
  command.command("track <schemaCode> <bizObjectId>").description("读取单条业务数据的行级变更留痕(只读;平台来源枚举含 BUSINESS_RULE 时原样回传)").option("--env <environment>").option("--property-code <code>").option("--max-output-bytes <bytes>").action(async (schemaCode, bizObjectId, options) => { commandExitCode = await withTransport(options, request, (transport) => cmdTrack(schemaCode, bizObjectId, { env: options.env, propertyCode: options.propertyCode }, transport)); });
4080
4096
  const jqOption = () => new Option("--jq [path]", "--jq 不是 jq,仅路径选择器(与 call --jq 同 DSL;可逗号多路径;裸 --jq 列顶层键)").argParser((value, previous = []) => [...previous, value]).default([]);
4081
4097
  // C6(0.8.4):--jq 的 miss 默认只回结论;排查载荷(available/correctPath/
@@ -894,8 +894,8 @@ export function assertLayoutRequestConflicts(args) {
894
894
  schemaCode: String(args.schemaCode ?? ""),
895
895
  sheetCode: String(args.sheetCode ?? args.schemaCode ?? ""),
896
896
  conflictKeys,
897
- message: `layout 与 ${conflictKeys.join("、")} 互斥:layout 是增量面(以已发布表单为基线,只改这些控件的行分组与 span),不要同时回传整包 attrs/view、不要重建;二选一。${conflictKeys.includes("childColumns")
898
- ? "子表列要先物化进已发布表单,正确顺序:① 先 `form.publish {rebuild:true}` 把子表列物化进已发布表单;② 再 `form.draft {layout}`(baseline=published);③ 再 `form.publish`。"
897
+ message: `layout 与 ${conflictKeys.join("、")} 互斥:layout 是增量面(以草稿为基线,只改这些控件的行分组与 span),不要同时回传整包 attrs/view、不要重建;二选一。${conflictKeys.includes("childColumns")
898
+ ? "子表列走的是另一个只写草稿的增量面,正确顺序:① 先 `form.draft {childColumns}` 把子表列绑进草稿;② 再 `form.draft {layout}`(以草稿为基线,不动刚绑的列);③ 再 `form.publish`。"
899
899
  : ""}`,
900
900
  });
901
901
  }
@@ -910,11 +910,17 @@ export async function composeFormLayoutDraft(session, args) {
910
910
  const decode = (value) => decodeJsonObjectColumn(value, { invalid: "undefined", array: "reject", object: "accept" });
911
911
  const publishedAttrs = sheet === null ? undefined : decode(sheet.publishedAttributesJson);
912
912
  const draftAttrs = sheet === null ? undefined : decode(sheet.draftAttributesJson);
913
- const baseline = publishedAttrs !== undefined && Object.keys(publishedAttrs).length > 0
914
- ? "published"
915
- : draftAttrs !== undefined && Object.keys(draftAttrs).length > 0
916
- ? "draft"
917
- : undefined;
913
+ const usable = (face) => face !== undefined && Object.keys(face).length > 0;
914
+ const publishedUsable = usable(publishedAttrs);
915
+ const draftUsable = usable(draftAttrs);
916
+ // 探针 J P1(0.8.16):草稿是下一次发布的对象,`childColumns` 只写草稿——layout
917
+ // 必须以草稿为基线,否则第二次写会把第一次写进草稿的子表列/新控件整包覆盖掉。
918
+ // 草稿为空(设计器 Save 会清成 "{}")或与已发布面逐字相同(刚发布完,内容等价)
919
+ // 时退回 published,保持「无草稿 → published」的老行为不变。
920
+ const draftDifferences = sheet !== null &&
921
+ (sheet.draftAttributesJson !== sheet.publishedAttributesJson ||
922
+ (typeof sheet.draftViewJson === "string" && sheet.draftViewJson !== sheet.publishedViewJson));
923
+ const baseline = draftUsable && (!publishedUsable || draftDifferences) ? "draft" : publishedUsable ? "published" : draftUsable ? "draft" : undefined;
918
924
  if (sheet === null || baseline === undefined) {
919
925
  throw new ToolRefusalError({
920
926
  status: "refused",
@@ -1068,7 +1074,12 @@ export async function composeFormLayoutDraft(session, args) {
1068
1074
  });
1069
1075
  }
1070
1076
  // 基线行分组(保留未点名控件):去非法 cell/重复 cell,空行丢弃。
1071
- const parsedBaseline = layoutRowsOf(baseline === "published" ? sheet.publishedViewJson : sheet.draftViewJson) ?? [];
1077
+ // 草稿 attrs 有控件但草稿 view 是空/"[]"(只写过 draftAttributesJson)时,
1078
+ // 行分组退回已发布 view:attrs 以草稿为准(新控件不丢),行分组沿用发布面。
1079
+ const draftRows = layoutRowsOf(sheet.draftViewJson);
1080
+ const publishedRows = layoutRowsOf(sheet.publishedViewJson);
1081
+ const rowsFace = baseline === "published" ? "published" : draftRows !== undefined && draftRows.length > 0 ? "draft" : publishedRows !== undefined && publishedRows.length > 0 ? "published" : "draft";
1082
+ const parsedBaseline = layoutRowsOf(rowsFace === "published" ? sheet.publishedViewJson : sheet.draftViewJson) ?? [];
1072
1083
  const seenCell = new Set();
1073
1084
  const baselineRows = [];
1074
1085
  const droppedCells = [];
@@ -1155,13 +1166,53 @@ export async function composeFormLayoutDraft(session, args) {
1155
1166
  }
1156
1167
  const warnings = violations.filter((violation) => !touchesCaller(violation));
1157
1168
  const preserved = attrCodes.filter((code) => !namedSet.has(code));
1169
+ // 草稿基线可能比已发布面**少**控件或**少子表列**(设计器 Save 非无损 / 历史
1170
+ // layout 已被整包覆盖 / 草稿来自陈旧读面)。这时不静默:如实点名,说明发布会
1171
+ // 撞 form-publish-degrade 或 childColumnsNotInForm 与恢复路径。
1172
+ const draftMissingPublishedControls = baseline === "draft" && publishedUsable ? Object.keys(publishedAttrs).filter((code) => !attrSet.has(code)) : [];
1173
+ // 子表列不在顶层控件面:它们在父 Sheet201 控件的 columns[] 里(childTableColumns
1174
+ // 注释)。layout 只重排不改列,所以「草稿比发布面少列」会原样被带去发布面。
1175
+ const columnKeysOf = (control) => {
1176
+ if (control === null || typeof control !== "object")
1177
+ return [];
1178
+ const columns = control.columns;
1179
+ return Array.isArray(columns) ? columns.map((column) => String(column?.key ?? "")).filter((key) => key.length > 0) : [];
1180
+ };
1181
+ const draftMissingPublishedChildColumns = [];
1182
+ if (baseline === "draft" && publishedUsable) {
1183
+ for (const [parent, publishedControl] of Object.entries(publishedAttrs)) {
1184
+ const publishedColumns = columnKeysOf(publishedControl);
1185
+ if (publishedColumns.length === 0)
1186
+ continue;
1187
+ // 父控件整体缺失已由 draftMissingPublishedControls 点名(列跟着控件走)。
1188
+ if (attrs[parent] === undefined)
1189
+ continue;
1190
+ const bound = new Set(columnKeysOf(attrs[parent]));
1191
+ const absent = publishedColumns.filter((key) => !bound.has(key));
1192
+ if (absent.length > 0)
1193
+ draftMissingPublishedChildColumns.push({ parent, fieldCodes: absent });
1194
+ }
1195
+ }
1158
1196
  const receipt = {
1159
1197
  baseline,
1198
+ ...(rowsFace !== baseline ? { rowsBaseline: rowsFace } : {}),
1160
1199
  rows: finalRows.length,
1161
1200
  named,
1162
1201
  preserved,
1163
1202
  ...(appended.length > 0 ? { appended } : {}),
1164
1203
  ...(droppedCells.length > 0 ? { droppedCells: [...new Set(droppedCells)] } : {}),
1204
+ ...(draftMissingPublishedControls.length > 0
1205
+ ? {
1206
+ draftMissingPublishedControls,
1207
+ draftShortfallNote: `草稿控件面比已发布面少 ${draftMissingPublishedControls.length} 个(${draftMissingPublishedControls.join("、")}):本次写入以草稿为基线,这些控件不会回到草稿;发布会被 form-publish-degrade 拒。恢复路径:表单版本历史 /api/api/app/bizsheet/history/list 取回完好草稿,或 form.draft {rebuild:true}。`,
1208
+ }
1209
+ : {}),
1210
+ ...(draftMissingPublishedChildColumns.length > 0
1211
+ ? {
1212
+ draftMissingPublishedChildColumns,
1213
+ draftChildColumnsShortfallNote: `草稿比发布面少这些子表列(${draftMissingPublishedChildColumns.map((entry) => `${entry.parent}.${entry.fieldCodes.join("/")}`).join("、")}):layout 只重排行/span、不改 Sheet201 的 columns,发布面会因此缺列(form.publish 回执会点名 childColumnsNotInForm)——要补就 form.draft {childColumns} 后重跑 publish,或从版本历史取回完好草稿。`,
1214
+ }
1215
+ : {}),
1165
1216
  spans,
1166
1217
  includeSystem: layout.includeSystem === true,
1167
1218
  note: "只改 rows 分组与这些控件的 span;其它控件属性/HTML 逐键保留,未列入 rows 的控件保留基线行(锚定在被点名控件周围)",
@@ -1242,6 +1293,80 @@ export function assertPublishNotDegrading(draftAttributesJson, publishedAttribut
1242
1293
  message: `草稿面控件数(${draftControls})少于已发布面(${publishedControls})——拒绝降级提拔。平台设计器 Save 会清空草稿(非无损);恢复路径是表单版本历史 /api/api/app/bizsheet/history/list 取回完好版本的 view/attributes 原文重写草稿后再发布。确要减少控件请显式传 allowDegrade:true`,
1243
1294
  });
1244
1295
  }
1296
+ /**
1297
+ * 探针 J P1(0.8.16):发布面「子表列缺失」诊断(只读、尽力而为)。
1298
+ *
1299
+ * 子表列不在顶层控件面也不在 viewJson:它们是父 Sheet201 控件的 `columns`
1300
+ * (见 childTableColumns 的注释)。子表字段已发布但父控件 columns 里没有它时,
1301
+ * 业务页面看不到——`field.publish` 的 formBinding 早就按此判
1302
+ * (src/lanes/field.ts formBindingAdvisory),`form.publish` 过去只看控件数,
1303
+ * 于是「历史 layout 整包覆盖了子表列」也能报 published:true。
1304
+ *
1305
+ * 判据来源与 formBindingAdvisory / insertChildColumnsIntoLayout 同源:
1306
+ * `field.list(isPublish=true)` 的 CHILD_TABLE 行 `subSchema.properties`。
1307
+ * 读不到字段面 → undefined(不做诊断,也不编造「没有缺失」)。
1308
+ *
1309
+ * 登记(未抽公共函数):`src/lanes/field.ts:2095-2102`(formBindingAdvisory)是同一
1310
+ * 判据的**另一份内联实现**——差别有两点且都是刻意的:① field.publish 的清单按
1311
+ * 「模型里有哪些子表列」判(父控件缺席时也算缺列,用于提示先绑父字段);本函数
1312
+ * 只看**表单里存在**的父控件(父控件缺席已由顶层控件缺失面覆盖)。② 本函数多一次
1313
+ * `field.list` wire,只在 publish/layout 回执里跑。两点语义差异让「一行抽取」反而
1314
+ * 需要参数化「父控件缺席时是否算缺列」,收益不抵改动面;若后续两处要再收敛,
1315
+ * 目标签名是 `childColumnsMissing(rows, attributes, {includeAbsentParents})`。
1316
+ */
1317
+ export async function childColumnsMissingFromForm(session, args) {
1318
+ if (typeof args.attributesJson !== "string")
1319
+ return undefined;
1320
+ let attributes;
1321
+ try {
1322
+ const parsed = JSON.parse(args.attributesJson);
1323
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed))
1324
+ return undefined;
1325
+ attributes = parsed;
1326
+ }
1327
+ catch {
1328
+ return undefined;
1329
+ }
1330
+ let rows;
1331
+ try {
1332
+ rows = wireRows((await wireCall(session, { path: ENDPOINTS.fieldList, query: { schemaCode: args.schemaCode, isPublish: "true" } })).data);
1333
+ }
1334
+ catch {
1335
+ return undefined;
1336
+ }
1337
+ const missing = [];
1338
+ for (const row of rows) {
1339
+ if (Number(row.type ?? row.propertyType) !== 8)
1340
+ continue;
1341
+ const parent = String(row.code ?? row.propertyCode ?? "");
1342
+ const control = attributes[parent];
1343
+ // 父控件本身不在表单里 = 顶层控件缺失(field.publish 的 notInFormLayout),
1344
+ // 不是子表列问题;在这里点名会误导成「绑 childColumns 就好」。
1345
+ if (control === undefined || control === null || typeof control !== "object")
1346
+ continue;
1347
+ const columns = Array.isArray(control.columns) ? control.columns : [];
1348
+ const bound = new Set(columns.map((column) => String(column.key ?? "")).filter((key) => key.length > 0));
1349
+ const absent = childColumnsOf(row.subSchema)
1350
+ .filter((column) => column.system !== true)
1351
+ .map((column) => column.code)
1352
+ .filter((code) => !bound.has(code));
1353
+ if (absent.length > 0)
1354
+ missing.push({ parent, fieldCodes: absent });
1355
+ }
1356
+ return missing;
1357
+ }
1358
+ /** 发布面缺子表列时的一句诊断(write 与 dry-run 同一句)。 */
1359
+ export const CHILD_COLUMNS_NOT_IN_FORM_NOTE = "子表字段已发布,但表单 Sheet201 控件的 columns 里没有它——业务页面看不到(发布照常成功,不等于可见)。用 configure_form 的 childColumns 增量绑定(不动其它控件/布局)后重跑发布";
1360
+ /** 发布面缺子表列时的回执片段(写路径 / already-published 短路 / dry-run 共用一份形状)。 */
1361
+ function childColumnsGapReadback(gaps, schemaCode, sheetCode) {
1362
+ if (gaps === undefined || gaps.length === 0)
1363
+ return {};
1364
+ return {
1365
+ childColumnsNotInForm: gaps,
1366
+ childColumnsNote: CHILD_COLUMNS_NOT_IN_FORM_NOTE,
1367
+ nextCommand: `omc call configure_form --args '${JSON.stringify({ schemaCode, ...(sheetCode !== schemaCode ? { sheetCode } : {}), childColumns: gaps })}'`,
1368
+ };
1369
+ }
1245
1370
  /**
1246
1371
  * `form.publish --dry-run` 的只读预览:不建草稿、不提拔,只回答两件事——
1247
1372
  * ① 当前草稿会不会被降级门拒(与真写同一函数);② 这次发布是否真的会改东西。
@@ -1265,6 +1390,9 @@ export async function lintFormPublishReadOnly(session, args) {
1265
1390
  if (!hasDraft)
1266
1391
  return { wouldChange: true, sheetPresent: true, draftPresent: false, publishedControlCount: publishedControls, note: "当前无草稿:真写会先按已发布字段造草稿再提拔(预览不建草稿)" };
1267
1392
  assertPublishNotDegrading(sheet.draftAttributesJson, sheet.publishedAttributesJson, { schemaCode: args.schemaCode, sheetCode, ...(args.allowDegrade !== undefined ? { allowDegrade: args.allowDegrade } : {}) });
1393
+ // 提拔是逐字复制草稿 → 发布面,所以「发布面缺子表列」=「草稿面缺子表列」,
1394
+ // 预览用草稿面算同一份清单(真写用发布后的回读面复核)。
1395
+ const childColumnGaps = await childColumnsMissingFromForm(session, { schemaCode: args.schemaCode, attributesJson: sheet.draftAttributesJson });
1268
1396
  const draftEqualsPublished = sheet.draftViewJson === sheet.publishedViewJson &&
1269
1397
  sheet.draftAttributesJson === sheet.publishedAttributesJson &&
1270
1398
  (sheet.draftHtmlJson === undefined || sheet.draftHtmlJson === sheet.publishedHtmlJson);
@@ -1276,6 +1404,7 @@ export async function lintFormPublishReadOnly(session, args) {
1276
1404
  publishedControlCount: publishedControls,
1277
1405
  draftEqualsPublished,
1278
1406
  alreadyPublished: sheet.published === true && draftEqualsPublished,
1407
+ ...childColumnsGapReadback(childColumnGaps, args.schemaCode, sheetCode),
1279
1408
  note: "降级门与真写同一函数;alreadyPublished:true 时真写会短路(不改发布面)",
1280
1409
  };
1281
1410
  }
@@ -1821,9 +1950,10 @@ export async function executeFormDraftWrite(session, args) {
1821
1950
  if (args.draftHtmlJson !== undefined) {
1822
1951
  assertHtmlRender(args.draftHtmlJson, { schemaCode: args.schemaCode, sheetCode: args.sheetCode, face: "draftHtmlJson" });
1823
1952
  }
1824
- // 增量布局面:以已发布(无则草稿)控件面为基线组合出完整 viewJson/attributesJson。
1825
- // 组合失败(无基线/未知控件/系统控件/span 不自洽)就在任何 wire 之前拒;dry-run 走
1826
- // 同一个 composeFormLayoutDraft(见 form.draft 的 writeLint),两边答案逐字相同。
1953
+ // 增量布局面:以草稿(空/与发布面逐字相同则已发布)控件面为基线组合出完整
1954
+ // viewJson/attributesJson。组合失败(无基线/未知控件/系统控件/span 不自洽)就在
1955
+ // 任何 wire 之前拒;dry-run 走同一个 composeFormLayoutDraft(见 form.draft 的
1956
+ // writeLint),两边答案逐字相同。
1827
1957
  let layoutReceipt;
1828
1958
  let composedLayoutWarnings = [];
1829
1959
  if (layoutRequest !== undefined) {
@@ -2394,8 +2524,19 @@ export async function executeFormPublishWrite(session, args) {
2394
2524
  const draftEqualsPublished = typeof pre.draftViewJson === "string" && pre.draftViewJson === pre.publishedViewJson &&
2395
2525
  typeof pre.draftAttributesJson === "string" && pre.draftAttributesJson === pre.publishedAttributesJson &&
2396
2526
  (pre.draftHtmlJson === undefined || pre.draftHtmlJson === pre.publishedHtmlJson);
2397
- if (pre.published === true && draftEqualsPublished && !forcePromote)
2398
- return { performed: { skipped: "already-published" }, readback: { published: true, draftMatchesPublished: true } };
2527
+ if (pre.published === true && draftEqualsPublished && !forcePromote) {
2528
+ // 短路也是回执:已发布 ≠ 页面可见。历史 layout 覆盖掉的子表列要在这里点名,
2529
+ // 否则重跑 form.publish 会得到「published:true」的假确认。
2530
+ const publishedGaps = await childColumnsMissingFromForm(session, { schemaCode: args.schemaCode, attributesJson: pre.publishedAttributesJson });
2531
+ return {
2532
+ performed: { skipped: "already-published" },
2533
+ readback: {
2534
+ published: true,
2535
+ draftMatchesPublished: true,
2536
+ ...childColumnsGapReadback(publishedGaps, args.schemaCode, args.sheetCode),
2537
+ },
2538
+ };
2539
+ }
2399
2540
  if (!hasDraft(pre))
2400
2541
  throw new WireError("business", "form publish requires a saved draft (draftViewJson/draftAttributesJson)", 302020);
2401
2542
  if (pre.draftHtmlJson !== "[]")
@@ -2439,11 +2580,16 @@ export async function executeFormPublishWrite(session, args) {
2439
2580
  const readback = await wireCall(session, { path: ENDPOINTS.sheetGet, query: { schemaCode: args.schemaCode, sheetCode: args.sheetCode } });
2440
2581
  const sheet = (readback.data ?? {});
2441
2582
  const formButtons = readFormButtons(sheet.options);
2583
+ // 探针 J P1(0.8.16):发布成功 ≠ 页面可见。子表列不在顶层控件面/viewJson,
2584
+ // 只在父 Sheet201 控件的 columns 里;历史 layout 覆盖掉的列、或子表字段新发布
2585
+ // 而没绑进表单时,这里逐条点名(读不到字段面则不诊断)。
2586
+ const childColumnGaps = await childColumnsMissingFromForm(session, { schemaCode: args.schemaCode, attributesJson: sheet.publishedAttributesJson });
2442
2587
  return {
2443
2588
  performed: { errcode: performed.errcode },
2444
2589
  readback: {
2445
2590
  published: sheet.published === true,
2446
2591
  publishedHtmlJsonPresent: typeof sheet.publishedHtmlJson === "string",
2592
+ ...childColumnsGapReadback(childColumnGaps, args.schemaCode, args.sheetCode),
2447
2593
  ...(formButtons !== null
2448
2594
  ? {
2449
2595
  formButtons,
@@ -294,11 +294,13 @@ function phraseOf(tool, args, outcome) {
294
294
  // F8(w63):平台按模型「数据标题」覆盖显式传入的 name,摘要行必须抬头。
295
295
  const nameNote = readbackNoteClause(outcome, "nameOverwrittenNote");
296
296
  if (args.submit === true && submitRefused !== undefined) {
297
+ // P1(w132 探针 J):这是**部分完成**——草稿已落库、提交未完成。摘要
298
+ // 必须先说清这个事实,再说被拒原因,避免调用方读成「已提交」。
297
299
  // 更新行不得复用「重建流程草稿」口径(会诱导多建一行)。
298
300
  if (workflowUpdateNote !== undefined) {
299
- return `保存数据(模型 ${schemaCode ?? "?"})——submit:true 被拒(${submitRefused.blocker ?? "?"}):更新既有行,不会创建/改动流程实例;推进用 workitem.list → data.submit 三件套;指引进 readback.workflowUpdateNote${nameNote}`;
301
+ return `保存数据(模型 ${schemaCode ?? "?"})——草稿已保存,提交未完成:submit:true 被拒(${submitRefused.blocker ?? "?"});更新既有行,不会创建/改动流程实例;推进用 workitem.list → data.submit 三件套;指引进 readback.workflowUpdateNote${nameNote}`;
300
302
  }
301
- return `保存数据(模型 ${schemaCode ?? "?"})——submit:true 被拒(${submitRefused.blocker ?? "?"}):模型有已发布流程,行保持草稿 DRAFT;重建流程草稿的指引进 readback.submitRefused${nameNote}`;
303
+ return `保存数据(模型 ${schemaCode ?? "?"})——草稿已保存,提交未完成:submit:true 被拒(${submitRefused.blocker ?? "?"});模型有已发布流程,行保持草稿 DRAFT;重建流程草稿的指引进 readback.submitRefused${nameNote}`;
302
304
  }
303
305
  if (workflowUpdateNote !== undefined) {
304
306
  return `保存数据(模型 ${schemaCode ?? "?"})——更新既有行,不创建/改动流程实例;流程模型上保存的直提标志会被拒,推进该行用 workitem.list → data.submit 三件套(不要为触发规则/推进流程再 data.save)${nameNote}`;
@@ -580,7 +580,7 @@ export function registerFormLane(tools) {
580
580
  includeSystem: z.boolean().optional(),
581
581
  })
582
582
  .optional()
583
- .describe("增量布局(推荐):{rows:[[\"a\",\"b\"],[\"c\"]],spans?:{a:12},includeSystem?}。以已发布(无则草稿)表单为基线,只改 rows 行分组与这些控件 span,**不必回传整包 attrs**;未列入 rows 的控件保留原行,系统控件须 includeSystem:true 才动。与 draftViewJson/draftAttributesJson/rebuild/fieldCodes/childColumns/refreshFromFields/fromReadback 互斥"),
583
+ .describe("增量布局(推荐):{rows:[[\"a\",\"b\"],[\"c\"]],spans?:{a:12},includeSystem?}。以当前草稿为基线(草稿为空时退回已发布),只改 rows 行分组与这些控件 span,**不必回传整包 attrs**;未列入 rows 的控件保留原行,系统控件须 includeSystem:true 才动。与 draftViewJson/draftAttributesJson/rebuild/fieldCodes/childColumns/refreshFromFields/fromReadback 互斥"),
584
584
  allowTypeMismatch: z.boolean().optional().describe("放行控件 type 与字段 propertyType 不匹配(默认拒 form-control-type-mismatch;仅平台模板明确要求特殊控件时用)"),
585
585
  draftHtmlJson: z.string().optional(),
586
586
  fieldCodes: z.array(z.string().min(1)).optional().describe("脚手架绑定的已发布字段(按此顺序);由 configure_form/intent 显式传入。子表列写「父字段.子列」等价于 childColumns"),
@@ -126,7 +126,7 @@ export const LIST_VIEW_LANE_CONTRACT = Object.freeze({
126
126
  }),
127
127
  "listview.configure": Object.freeze({
128
128
  scope: LIST_VIEW_SCOPE,
129
- description: "配置列表视图(列、排序、查询条件、行/列表按钮、呈现、自定义按钮、视图头扩展选项与视图类型)。**code 语义**:省略 `code`(或 code=schemaCode)= 配置**默认视图**(code = 模型 code,8.6.41 起默认视图同样可 configure),日常配列就用它,**不要先 listview.create**(会多一个视图);改默认视图影响所有用户;仅需第二个视图时才 listview.create(configure 带 code 指向它)。`fieldCodes` 可省略——**省略=不动列**(只改排序/筛选/动作时不必重发列集合;`replaceColumns:true` 仍必须带 fieldCodes,全空参数零写入拒)。读回 query,按 `fieldCodes` 追加缺失列或**原地修正**已存在列的 name/propertyType/displayFormat/visible(不再跳过既有列),置为可见;数值列 displayFormat 由字段 0 基 `options.scale` 推导(0=整数,1=1位,2=2位,3=3位…8=8位)、日期列由 `options.format` 推导(1/2/3/4),回显 `columns` 为完整列对象并给出 `added`/`updated`;`sorts`→querySorts(direction ASC/DESC)、`conditions`→queryConditions(**比较符是 `filterType`(QueryFilterType 字符串枚举 Eq/NotEq/…;别名 operator/op;省略时按 propertyType 取平台默认)**、displayType/choiceType/options 字符串解码;2.1.5 树视图过滤组三键 `treeLimitScopeType`/`treeLimitConditionGroup`/`treeDefaultConditionGroup` 原样透传(值不同默认拒 `listview-tree-conditions-changed`,确认改写传 `allowTreeConditionChange:true`;缺键拒 `listview-tree-conditions-would-be-lost`);写后条件回读等价校验给出 conditionReadback)、`actions`→queryActions(queryActionType QUERY(1)…BATCH_SUBMIT(23)、associationType BIZSHEET(0)/WORKFLOW(1))、`presentation`→queryPresentation(htmlJson/actionsJson/columnsJson/queryViewDataSource/schemaRelations/options 均为 JSON 字符串,合法 JSON 读回解码)、`buttons`→customButtons(写面 customButtonJson JSON 数组字符串;bindAction/useLocation/operateType/showPermType 以枚举名发送;triggerType 强制 QUERY、triggerCode=视图 code、sortKey 按数组位,缺省回传读面 customButtons 有效集;ADD_DATA/FORM 目标绑定走 actionConfig——schemaCodeVal+formListData+configureList,targetCode/targetObjCode 对其无效会被拒;高层参数 targetModel/targetForm/configureList 从读回元数据展开,未解析即 listview-button-target-unresolved 零副作用拒)、`options`→视图头 BizQueryOption(`pagingSetting`{pageSize,showTotal} 分页、`listViewModeSetting`{mode,canSwitch} 列表模式,缺省回传读面有效 options、提供时整体替换,rowColorSetting 无 8.6.26 类证据故对象形态拒绝)与 `presentationType`→QueryPresentationType(LIST/BOARD/CALENDAR/GANTT,缺省回传读面有效值;GANTT 必须同时提供 `gantt`→queryGanttModel 且 startTimePropertyCode/endTimePropertyCode/titlePropertyCode 非空,缺省不触碰既有 gantt)与 `queryLayer`→层级展示(BizQueryLayer[] 数组原样发送)及 `multiTableHeaderConfig`→多级表头(HeaderConfig[] JSON 字符串;缺省回传读面有效值、提供时整体替换)省略时不触碰既有值,提供时整体替换并经出门前 dry-lint;`query/update` 后回读。`queryConditionMap` 为只读派生(query/get 带 formCode 子表条件时才出现),非配置输入。**发布语义**:`query/update` 自动置 publish=TRUE——视图无草稿/发布两态、无需独立发布步骤。**依赖顺序**:视图与表单脚手架都依赖**已发布字段**,规范顺序 model.create → field.create → field.publish(模型级)→ form.draft → form.publish →(需要第二视图时 listview.create)→ listview.configure → rule.save → rule.enable → workflow。",
129
+ description: "配置列表视图(列、排序、查询条件、行/列表按钮、呈现、自定义按钮、视图头扩展选项与视图类型)。**code 语义**:省略 `code`(或 code=schemaCode)= 配置**默认视图**(code = 模型 code,8.6.41 起默认视图同样可 configure),日常配列就用它,**不要先 listview.create**(会多一个视图);改默认视图影响所有用户;仅需第二个视图时才 listview.create(configure 带 code 指向它)。`fieldCodes` 可省略——**省略=不动列**(只改排序/筛选/动作时不必重发列集合;`replaceColumns:true` 仍必须带 fieldCodes,全空参数零写入拒)。读回 query,按 `fieldCodes` 追加缺失列或**原地修正**已存在列的 name/propertyType/displayFormat/visible(不再跳过既有列),置为可见;数值列 displayFormat 由字段 0 基 `options.scale` 推导(0=整数,1=1位,2=2位,3=3位…8=8位)、日期列由 `options.format` 推导(1/2/3/4),回显 `columns` 为完整列对象并给出 `added`/`updated`;`sorts`→querySorts(direction ASC/DESC)、`conditions`→queryConditions(**比较符是 `filterType`(QueryFilterType 字符串枚举 Eq/NotEq/…;别名 operator/op;省略时按 propertyType 取平台默认)**、displayType/choiceType/options 字符串解码;2.1.5 树视图过滤组三键 `treeLimitScopeType`/`treeLimitConditionGroup`/`treeDefaultConditionGroup` 原样透传(值不同默认拒 `listview-tree-conditions-changed`,确认改写传 `allowTreeConditionChange:true`;缺键拒 `listview-tree-conditions-would-be-lost`);写后条件回读等价校验给出 conditionReadback)、`actions`→queryActions(queryActionType QUERY(1)…BATCH_SUBMIT(23)、associationType BIZSHEET(0)/WORKFLOW(1))、`presentation`→queryPresentation(htmlJson/actionsJson/columnsJson/queryViewDataSource/schemaRelations/options 均为 JSON 字符串,合法 JSON 读回解码)、`buttons`→customButtons(写面 customButtonJson JSON 数组字符串;bindAction/useLocation/operateType/showPermType 以枚举名发送;triggerType 强制 QUERY、triggerCode=视图 code、sortKey 按数组位,缺省回传读面 customButtons 有效集;ADD_DATA/FORM 目标绑定走 actionConfig——schemaCodeVal+formListData+configureList,targetCode/targetObjCode 对其无效会被拒;高层参数 targetModel/targetForm/configureList 从读回元数据展开,未解析即 listview-button-target-unresolved 零副作用拒)、`options`→视图头 BizQueryOption(`pagingSetting`{pageSize,showTotal} 分页、`listViewModeSetting`{mode,canSwitch} 列表模式,缺省回传读面有效 options、提供时整体替换,rowColorSetting 无 8.6.26 类证据故对象形态拒绝)与 `presentationType`→QueryPresentationType(LIST/BOARD/CALENDAR/GANTT,缺省回传读面有效值;GANTT 必须同时提供 `gantt`→queryGanttModel 且 startTimePropertyCode/endTimePropertyCode/titlePropertyCode 非空,缺省不触碰既有 gantt)与 `queryLayer`→层级展示(BizQueryLayer[] 数组原样发送)及 `multiTableHeaderConfig`→多级表头(HeaderConfig[] JSON 字符串;缺省回传读面有效值、提供时整体替换)省略时不触碰既有值,提供时整体替换并经出门前 dry-lint;`query/update` 后回读。`queryConditionMap` 为只读派生(query/get 带 formCode 子表条件时才出现),非配置输入。**发布语义**:`query/update` 自动置 publish=TRUE——视图无草稿/发布两态、无需独立发布步骤。**依赖顺序**:视图与表单脚手架都依赖**已发布字段**,规范顺序 model.create → field.create → field.publish(模型级)→ form.draft → form.publish →(需要第二视图时 listview.create)→ listview.configure → rule.save → rule.enable → workflow。**条件验收**:配置面用 `listview.get` 回读 conditions;固定条件只在门户运行时生效,无 REST 验证入口(`data.list --queryCode` 不应用),数据侧用 `data.list` 显式 `filter`。",
130
130
  }),
131
131
  "listview.delete": Object.freeze({
132
132
  scope: LIST_VIEW_SCOPE,
@@ -17,6 +17,28 @@ import { assertListViewConfigureShape, decodeActionRow, decodeButtonRow, decodeC
17
17
  export { assertListViewConfigureShape } from "./list-view-shapes.js";
18
18
  const LIST_VIEW_LANE = LIST_VIEW_LANE_CONTRACT.lane;
19
19
  const LIST_VIEW_TOOLS = LIST_VIEW_LANE_CONTRACT.tools;
20
+ /**
21
+ * F6(0.8.16):视图条件的 `filterType`(QueryFilterType 枚举名)→ `data.list`
22
+ * `filter.op` 的 DSL 别名。只映射 data.list 真正支持的算子;Of/NotOf 等没有
23
+ * 等价 DSL 时不伪造 op,改给 `dataSideTemplate`。大小写不敏感由 data.list 侧
24
+ * resolveSimpleOp 兜底,但 NotEq→noteq 不在别名表里,所以必须显式映射。
25
+ */
26
+ const DATA_LIST_OP_BY_FILTER_TYPE = {
27
+ Eq: "eq",
28
+ NotEq: "neq",
29
+ Gt: "gt",
30
+ Lt: "lt",
31
+ Gte: "gte",
32
+ Lte: "lte",
33
+ Like: "like",
34
+ NotLike: "notlike",
35
+ IsNull: "isNull",
36
+ IsNotNull: "isNotNull",
37
+ In: "in",
38
+ NotIn: "notin",
39
+ Between: "between",
40
+ NotBetween: "notbetween",
41
+ };
20
42
  /**
21
43
  * r62a-F5 / r61 a-F14:列汇总(sumType)真值在呈现层 queryPresentation.columnsJson
22
44
  * ——queryColumns 列树不回它。listview.get 与 listview.configure 的读回共用这个
@@ -1222,6 +1244,35 @@ export function registerListViewLane(tools) {
1222
1244
  "视图条件的运行时过滤语义未取证:REST `data.list --queryCode <本视图>` 实测不应用固定条件(r35:读回 Gte/5000 正确、返回未过滤 4 条)。别用 queryCode 断言过滤生效;REST 侧过滤用 `data.list` 显式 `filter`。";
1223
1245
  if (conditions.length > 0)
1224
1246
  readback.viewConditionsAppliedRest = false;
1247
+ // F6(0.8.16 探针 J):conditionRuntimeNote 只说「不行」,探针要一个可执行
1248
+ // 的验收入口。配置面验收 = listview.get 回读 conditions(propertyCode/
1249
+ // filterType/defaultValue);运行时面没有 REST 验证入口(固定条件只在门户
1250
+ // 生效),数据侧只能用 data.list 显式 filter 自行过滤。不新增假验证。
1251
+ if (conditions.length > 0) {
1252
+ const firstCondition = conditions.find((condition) => String(condition.propertyCode ?? "").length > 0);
1253
+ const firstConditionCode = String(firstCondition?.propertyCode ?? "<propertyCode>");
1254
+ const firstFilterType = typeof firstCondition?.filterType === "string" ? firstCondition.filterType : "";
1255
+ const dataListOp = firstFilterType.length > 0 ? DATA_LIST_OP_BY_FILTER_TYPE[firstFilterType] : undefined;
1256
+ const dataSideArgs = {
1257
+ schemaCode: args.schemaCode,
1258
+ filter: { op: dataListOp ?? "<op>", field: firstConditionCode, value: "<value>" },
1259
+ };
1260
+ readback.conditionVerification = {
1261
+ configFace: "配置面验收:listview.get 回读 conditions(propertyCode/filterType/defaultValue);本次提交了 conditions 时 conditionReadback 已比对",
1262
+ command: `omc call listview.get --env <env> --args '${JSON.stringify({ schemaCode: args.schemaCode, code })}'`,
1263
+ runtimeRunnable: false,
1264
+ runtimeNote: "视图固定条件只在门户运行时生效;平台没有 REST 验证入口(REST data.list --queryCode 不应用固定条件)。不要用 data.list --queryCode 断言过滤生效。",
1265
+ ...(dataListOp !== undefined
1266
+ ? {
1267
+ dataSideAlternative: `omc call data.list --env <env> --args '${JSON.stringify(dataSideArgs)}'`,
1268
+ dataSideNote: `数据侧替代:data.list 显式 filter(op 由条件 filterType ${firstFilterType} 映射为 ${dataListOp});它按该条件取数,但不是对视图固定条件的运行时验证。`,
1269
+ }
1270
+ : {
1271
+ dataSideTemplate: `omc call data.list --env <env> --args '${JSON.stringify(dataSideArgs)}'`,
1272
+ dataSideNote: `数据侧模板:条件 filterType ${firstFilterType || "未知"} 没有 data.list 等价 op,先把 <op> 换成 data.list 支持的算子(eq/neq/gte/lte/like/between/in…);这不是视图条件验证,也不声称按同一条件取数。`,
1273
+ }),
1274
+ };
1275
+ }
1225
1276
  // Post-write semantic readback (dogfood R2): the platform MODELS a list
1226
1277
  // condition as a filter CONTROL definition, so a requested condition whose
1227
1278
  // propertyCode does not survive the round-trip was lost. Surface that as
@@ -113,6 +113,16 @@ export async function inboundModelReferences(session, targets, treeRows, options
113
113
  left.via.localeCompare(right.via) ||
114
114
  (left.childTable?.code ?? "").localeCompare(right.childTable?.code ?? ""));
115
115
  }
116
+ /**
117
+ * Stable receipt label for one dependency step (`field.delete:<schema>.<code>`
118
+ * / `<tool>:<schema>`). Shared by `deletionOrderFromSteps`, the purge executor
119
+ * and the self-reference split so the three cannot drift.
120
+ */
121
+ export function deletionStepLabel(step) {
122
+ const schemaCode = String(step.args.schemaCode ?? "");
123
+ const code = typeof step.args.code === "string" ? step.args.code : "";
124
+ return step.tool === "field.delete" ? `field.delete:${schemaCode}.${code}` : `${step.tool}:${schemaCode}`;
125
+ }
116
126
  /**
117
127
  * The executable dependency order derived from `deletionSteps` — one entry per
118
128
  * distinct target, in the order the caller must execute them. A model that
@@ -131,9 +141,7 @@ export function deletionOrderFromSteps(steps) {
131
141
  const seen = new Set();
132
142
  const order = [];
133
143
  for (const step of steps) {
134
- const schemaCode = String(step.args.schemaCode ?? "");
135
- const code = typeof step.args.code === "string" ? step.args.code : "";
136
- const target = step.tool === "field.delete" ? `field.delete:${schemaCode}.${code}` : `${step.tool}:${schemaCode}`;
144
+ const target = deletionStepLabel(step);
137
145
  if (seen.has(target))
138
146
  continue;
139
147
  seen.add(target);
@@ -141,6 +149,17 @@ export function deletionOrderFromSteps(steps) {
141
149
  }
142
150
  return order;
143
151
  }
152
+ /**
153
+ * `omc model-purge --apply` without the destructive flag: the one-command form
154
+ * for a model whose only inbound references are SELF references (`selfReference`
155
+ * — its own child-table column pointing back at it). 0.8.16 F7: those columns
156
+ * belong to the model being deleted, so the purge tears them down automatically
157
+ * (field.delete → field.publish); only cross-model references still require the
158
+ * explicit `--unbind-references` opt-in.
159
+ */
160
+ export function modelPurgeCommand(schemaCode, options = {}) {
161
+ return `omc model-purge --code ${schemaCode}${options.purgeInstances === true ? " --purge-instances" : ""} --apply`;
162
+ }
144
163
  /**
145
164
  * `omc model-purge --unbind-references --apply` — the ONE command that executes
146
165
  * the same `field.delete → field.publish` unlink steps and then lets