@stalfh233/omc-cli 0.8.6 → 0.8.8

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.
Files changed (40) hide show
  1. package/coverage/m1-coverage-manifest-v1.json +1 -0
  2. package/dist/approval-flow.js +49 -4
  3. package/dist/batch-call.js +21 -4
  4. package/dist/cli-stdout.js +1 -0
  5. package/dist/cli.js +84 -3
  6. package/dist/code-rules.js +35 -11
  7. package/dist/config-store.js +15 -1
  8. package/dist/endpoints.js +10 -0
  9. package/dist/form-layout.js +79 -0
  10. package/dist/form-support.js +111 -7
  11. package/dist/graph.js +38 -3
  12. package/dist/human-summary.js +19 -1
  13. package/dist/lanes/field-contract.js +5 -1
  14. package/dist/lanes/field-coverage.js +1 -0
  15. package/dist/lanes/field.js +20 -2
  16. package/dist/lanes/form-contract.js +1 -1
  17. package/dist/lanes/form.js +24 -2
  18. package/dist/lanes/list-view.js +104 -2
  19. package/dist/lanes/model-references.js +172 -0
  20. package/dist/lanes/model.js +206 -123
  21. package/dist/lanes/runtime-data-contract.js +4 -4
  22. package/dist/lanes/runtime-data.js +170 -7
  23. package/dist/lanes/workflow.js +213 -45
  24. package/dist/model-purge.js +106 -21
  25. package/dist/model-scaffold.js +52 -10
  26. package/dist/recipes/field.js +44 -1
  27. package/dist/recipes/form.js +33 -6
  28. package/dist/recipes/list-view.js +1 -1
  29. package/dist/reserved.js +28 -0
  30. package/dist/search-index.js +2 -0
  31. package/dist/tool-types.js +1 -0
  32. package/dist/write.js +12 -0
  33. package/package.json +3 -3
  34. package/skills/omc-business-configuration.md +6 -0
  35. package/skills/omc-capabilities.md +1 -1
  36. package/skills/omc-playbook.md +5 -0
  37. package/skills/omc-requirement-vocabulary.md +13 -0
  38. package/skills/omc-start-here.md +1 -1
  39. package/skills/omc-tool-selection.md +2 -0
  40. package/skills/omc-write-hazards.md +3 -0
@@ -4,7 +4,7 @@ import { decodeJsonObjectColumn } from "./json-column.js";
4
4
  import { ToolRefusalError } from "./tool-types.js";
5
5
  import { FIELD_CONTROL_TYPES, childColumnsOf, SYSTEM_FIELD_CODES, fieldControlOptions, relationDisplayField, relationMappings, } from "./field-families.js";
6
6
  import { deriveControlOptions } from "./capability-shape.js";
7
- import { hardLayoutViolations, validateFormLayoutShape } from "./form-layout.js";
7
+ import { hardLayoutViolations, validateFormLayoutShape, controlTypeMismatches, FORM_CONTROL_TYPE_HINT } from "./form-layout.js";
8
8
  /**
9
9
  * Propagate each relation field's `options.mappings` into its form control so
10
10
  * the form-fill carry is configured where the form renderer reads it. The
@@ -39,6 +39,41 @@ export function propagateRelationOptions(attributesJson, fields) {
39
39
  return JSON.stringify(attributes);
40
40
  }
41
41
  export const propagateRelationMappings = propagateRelationOptions;
42
+ /**
43
+ * The platform stores a form with NO custom HTML in one of several "empty"
44
+ * shapes, not just `undefined`:
45
+ * - `""` — the legacy designer's initial value (frontend-dist/admin/js/12404:
46
+ * `publishedHtmlJson:""` in the new-sheet default object);
47
+ * - `"{}"` — what a live 2.1.5 form returned from `form.get` for a published
48
+ * default form (0.8.7 real-machine probe C/F2);
49
+ * - `"[]"` — the designer's Save-cleared draft (Ticket 74) and the fake
50
+ * platform's publish default.
51
+ * The runtime renderer treats all of them as "no custom html": it parses and
52
+ * then guards `if (s && s.length > 0)` (frontend-dist/admin/js/19497,
53
+ * template.ebdab9f4, mobile/js/60404) — `{}` has no `.length`, so the block is
54
+ * skipped without touching `element.tagName`. Reporting them as a render
55
+ * violation was a false alarm: the published form renders fine.
56
+ */
57
+ function isEmptyHtmlShape(trimmed) {
58
+ if (trimmed === "" || trimmed === "[]" || trimmed === "{}")
59
+ return true;
60
+ try {
61
+ const parsed = JSON.parse(trimmed);
62
+ if (Array.isArray(parsed))
63
+ return parsed.length === 0;
64
+ return parsed !== null && typeof parsed === "object" && !Array.isArray(parsed) && Object.keys(parsed).length === 0;
65
+ }
66
+ catch {
67
+ return false;
68
+ }
69
+ }
70
+ function jsonTopLevelType(value) {
71
+ if (value === null)
72
+ return "null";
73
+ if (Array.isArray(value))
74
+ return "array";
75
+ return typeof value;
76
+ }
42
77
  /**
43
78
  * Parse-only JavaScript check for a `<script>` element body.
44
79
  *
@@ -68,18 +103,23 @@ function scriptSyntaxProblem(source) {
68
103
  export function validateHtmlRender(value, requirePlatformSkeleton = false) {
69
104
  if (value === undefined || value === null)
70
105
  return { ok: true, skipped: true };
71
- if (typeof value !== "string" || value.trim() === "") {
72
- return { ok: false, violations: [{ index: -1, problem: "html must be a non-empty JSON element array" }] };
106
+ if (typeof value !== "string") {
107
+ return { ok: false, violations: [{ index: -1, path: "html", problem: `html must be a JSON element array; got ${jsonTopLevelType(value)}` }] };
73
108
  }
109
+ const trimmed = value.trim();
110
+ // No custom HTML: `""` / `"{}"` / `"[]"` (and their parse-equivalents) are
111
+ // platform defaults, not a broken published form.
112
+ if (isEmptyHtmlShape(trimmed))
113
+ return { ok: true, skipped: true };
74
114
  let parsed;
75
115
  try {
76
- parsed = JSON.parse(value);
116
+ parsed = JSON.parse(trimmed);
77
117
  }
78
118
  catch {
79
- return { ok: false, violations: [{ index: -1, problem: "html must be valid JSON" }] };
119
+ return { ok: false, violations: [{ index: -1, path: "html", problem: "html must be valid JSON" }] };
80
120
  }
81
- if (!Array.isArray(parsed) || parsed.length === 0) {
82
- return { ok: false, violations: [{ index: -1, problem: "html must be a non-empty JSON element array" }] };
121
+ if (!Array.isArray(parsed)) {
122
+ return { ok: false, violations: [{ index: -1, path: "html", problem: `html must be a JSON element array; got ${jsonTopLevelType(parsed)}` }] };
83
123
  }
84
124
  const violations = [];
85
125
  const ids = new Set();
@@ -805,6 +845,46 @@ export function assertCallerFormLayout(args) {
805
845
  });
806
846
  }
807
847
  }
848
+ export async function lintFormControlTypes(session, args) {
849
+ if (typeof args.draftAttributesJson !== "string")
850
+ return undefined;
851
+ let attributes;
852
+ try {
853
+ attributes = JSON.parse(args.draftAttributesJson);
854
+ }
855
+ catch {
856
+ return undefined; // JSON errors are the caller's layout gate's business.
857
+ }
858
+ if (!attributes || typeof attributes !== "object" || Array.isArray(attributes))
859
+ return undefined;
860
+ let rows;
861
+ try {
862
+ rows = wireRows((await wireCall(session, { path: ENDPOINTS.fieldList, query: { schemaCode: args.schemaCode, isPublish: "true" } })).data);
863
+ }
864
+ catch {
865
+ // No published field face (absent schema / no fields yet): nothing to
866
+ // resolve against — do NOT guess and do NOT invent a new refusal.
867
+ return { mismatches: [], allowed: false, fieldListRead: false };
868
+ }
869
+ const mismatches = controlTypeMismatches(attributes, rows);
870
+ if (mismatches.length === 0)
871
+ return { mismatches, allowed: false, fieldListRead: true };
872
+ if (args.allowTypeMismatch === true)
873
+ return { mismatches, allowed: true, fieldListRead: true };
874
+ throw new ToolRefusalError({
875
+ status: "refused",
876
+ blocker: "form-control-type-mismatch",
877
+ schemaCode: args.schemaCode,
878
+ sheetCode: args.sheetCode,
879
+ mismatches,
880
+ hint: FORM_CONTROL_TYPE_HINT,
881
+ nextCommand: `omc call form.get --args '${JSON.stringify({ schemaCode: args.schemaCode, full: true })}'`,
882
+ message: `控件 type 用错了枚举:${mismatches.map((item) => `${item.code} 给了 ${item.givenType},按字段 ${item.fieldTypeName}(propertyType=${item.propertyType}) 应为 ${item.expectedType}`).join(";")}。` +
883
+ `${FORM_CONTROL_TYPE_HINT}改既有表单必须先 ` +
884
+ `\`form.get full:true\` 取 publishedAttributesJson 作基线(只改 rows/span,不手拼控件 type);` +
885
+ `确属平台模板要求的特殊控件才传 allowTypeMismatch:true。`,
886
+ });
887
+ }
808
888
  /** Ticket 74 — control count on an attributes JSON face (0 when unparsable/absent). */
809
889
  function controlCount(face) {
810
890
  if (typeof face !== "string")
@@ -1480,6 +1560,23 @@ export async function executeFormDraftWrite(session, args) {
1480
1560
  : `fieldCodes 引用了模型 ${args.schemaCode} 发布面上不存在的字段:${selectionUnknown.join("、")};先 field.create + field.publish 这些字段,或修正 fieldCodes`,
1481
1561
  });
1482
1562
  }
1563
+ // 控件 type 是**表单控件枚举**(BizFormPropertyType),不是字段 propertyType
1564
+ // (probe B F1,2.1.5 真机:已发布 customer=80 而字段 WORK_SHEET=9)。这条
1565
+ // 交叉校验放在创建/写入任何 wire 之前:错枚举的布局平台照存、回读不报错,
1566
+ // 只有渲染时才坏。`fromReadback:true` 是逐字回写平台面、`amendChildColumns`
1567
+ // 是工具从已存平台布局追加子表列——两者都不是手写布局,跳过;调用方显式
1568
+ // allowTypeMismatch:true 时降级为回执 warning(不偷偷改用户输入)。
1569
+ let controlTypeWarnings;
1570
+ if (args.draftAttributesJson !== undefined && args.fromReadback !== true && args.amendChildColumns !== true) {
1571
+ const typeLint = await lintFormControlTypes(session, {
1572
+ schemaCode: args.schemaCode,
1573
+ sheetCode: args.sheetCode,
1574
+ draftAttributesJson: args.draftAttributesJson,
1575
+ ...(args.allowTypeMismatch !== undefined ? { allowTypeMismatch: args.allowTypeMismatch } : {}),
1576
+ });
1577
+ if (typeLint !== undefined && typeLint.mismatches.length > 0)
1578
+ controlTypeWarnings = typeLint.mismatches;
1579
+ }
1483
1580
  // The default form may not exist yet on a freshly created model
1484
1581
  // (bizmodels/create seeds no form) — create it, then scaffold into it.
1485
1582
  let pre = await readFormOrNull(session, args.schemaCode, args.sheetCode);
@@ -1774,6 +1871,13 @@ export async function executeFormDraftWrite(session, args) {
1774
1871
  // stored column is the stringified form the form page refuses to render.
1775
1872
  ...(customButtonJsonStoredShape(sheet.options) === "string" ? { formButtonsShapeWarning: CUSTOM_BUTTON_JSON_STRING_SHAPE_WARNING } : {}),
1776
1873
  ...(mergedOptions !== undefined ? { customButtonJsonWritten: true } : {}),
1874
+ ...(controlTypeWarnings !== undefined
1875
+ ? {
1876
+ controlTypeMismatchAllowed: true,
1877
+ controlTypeMismatches: controlTypeWarnings,
1878
+ controlTypeNote: `allowTypeMismatch:true 显式放行;${FORM_CONTROL_TYPE_HINT}本工具不替你改控件 type。`,
1879
+ }
1880
+ : {}),
1777
1881
  ...(roundTripFaces.size > 0
1778
1882
  ? {
1779
1883
  layoutGate: "platform-roundtrip",
package/dist/graph.js CHANGED
@@ -1262,6 +1262,28 @@ function openGraphIndex(selector = {}) {
1262
1262
  throw error instanceof GraphIndexError ? error : new GraphIndexUnreadableError(`索引不可读(schema 不匹配或文件损坏):${error instanceof Error ? error.message : String(error)};重跑 omc graph pull`);
1263
1263
  }
1264
1264
  }
1265
+ /**
1266
+ * issue 07(2026-11-18 真机摩擦)CLI 面补齐:零命中 ≠ 无引用。
1267
+ *
1268
+ * 索引只到服务 code,业务规则里的 `methodMapping.serviceMethodCode`
1269
+ *(`addOrderLedger` 之流)不建边——探针曾据 `matches:[]` 差点判「没人调用、可删」。
1270
+ * MCP 面已在 `src/mcp-graph.ts:502` 给出 `granularityUnsupported`;本函数是 CLI
1271
+ * 面(references / impact)的**同源**构造:文案直接取自
1272
+ * `GRAPH_NOT_INDEXED_GRANULARITIES` 的 `service.method` 条目,不另起一套措辞。
1273
+ *
1274
+ * 只在 `kind === "service"` 时返回;调用方再叠加「零命中」条件,有命中时不出
1275
+ *(不给正常答案加噪声)。
1276
+ */
1277
+ export function serviceMethodGranularityUnsupported(kind) {
1278
+ if (kind !== "service")
1279
+ return undefined;
1280
+ const methodGranularity = GRAPH_NOT_INDEXED_GRANULARITIES.find((item) => item.face === "service.method");
1281
+ return {
1282
+ methodLevelIndexed: false,
1283
+ reason: `0 ≠ 无引用:${methodGranularity?.zh ?? "索引不覆盖服务方法级(methodMapping.serviceMethodCode)"}`,
1284
+ suggestion: methodGranularity?.how ?? "先 omc call rule.list 拿规则清单,再逐条 omc call rule.get 查 methodMapping.serviceMethodCode",
1285
+ };
1286
+ }
1265
1287
  export const GRAPH_NOT_INDEXED_GRANULARITIES = Object.freeze([
1266
1288
  Object.freeze({
1267
1289
  face: "service.method",
@@ -1534,6 +1556,8 @@ export function queryGraphReferences(kind, rawCode, selector = {}) {
1534
1556
  const unscopedFieldNote = kind === "field" && scoped === null && otherSchemas.length > 0
1535
1557
  ? `裸字段 code 会跨模型合并同名:本次命中来自 ${otherSchemas.join("、")}(各自的同名字段)。要只查某一个模型的该字段,写 <schemaCode>.<字段code>(如 crm_contract.${code})——datarule/listview 只能引用本模型字段,所以按宿主模型过滤是精确的。`
1536
1558
  : undefined;
1559
+ // issue 07(CLI 面):只在 service 零命中时出现(有命中 / 非 service 都不加)。
1560
+ const granularityUnsupported = matches.length === 0 ? serviceMethodGranularityUnsupported(kind) : undefined;
1537
1561
  return {
1538
1562
  kind,
1539
1563
  code: rawCode,
@@ -1544,13 +1568,17 @@ export function queryGraphReferences(kind, rawCode, selector = {}) {
1544
1568
  index: summary,
1545
1569
  ...(matches.length === 0
1546
1570
  ? {
1571
+ // issue 07(CLI 面):零命中≠无引用。service 方法级未索引,note 不再给
1572
+ // 「没有引用它」这种结论句;粒度边界由 granularityUnsupported 承接。
1547
1573
  note: (gapped
1548
1574
  ? "零命中,但索引存在扫描缺口——不可作为「无引用」证明;先 omc graph pull 重建再查"
1549
- : `零命中=scanned 面(规则/数据规则/视图/表单/流程)没有引用它;本索引覆盖应用:${summary.coverage.applicationCodes.join("、") || "(未知)"},不代表其他应用没有引用;workflow.bindings 与 onlinejs 未扫描,见 coverage.notScanned——不可据此判定可安全删除`) +
1575
+ : `零命中=scanned 面(规则/数据规则/视图/表单/流程)零命中;本索引覆盖应用:${summary.coverage.applicationCodes.join("、") || "(未知)"},不代表其他应用没有引用;workflow.bindings 与 onlinejs 未扫描,见 coverage.notScanned——不可据此判定可安全删除`) +
1576
+ (kind === "service" ? ";service 方法级未索引,见 granularityUnsupported" : "") +
1550
1577
  (zeroHitKindHint(db, kind, code, "references") ?? "") +
1551
1578
  (kind === "field" && scoped === null ? unresolvedScopedCodeNote(rawCode) ?? "" : ""),
1552
1579
  }
1553
1580
  : {}),
1581
+ ...(granularityUnsupported !== undefined ? { granularityUnsupported } : {}),
1554
1582
  ...(gapped
1555
1583
  ? { gapWarning: `索引有 ${summary.gaps.count} 个扫描缺口(${Object.entries(summary.gaps.byKind).map(([k, v]) => `${k}:${v}`).join(", ")});命中列表可能不完整` }
1556
1584
  : {}),
@@ -1809,6 +1837,9 @@ export function impactGraph(kind, rawCode, selector = {}) {
1809
1837
  return { schemaCode: row.schema_code, ruleCode: row.rule_code, name, matchedVia: via, touches };
1810
1838
  });
1811
1839
  const gapped = summary.gaps.count > 0;
1840
+ const zeroHit = hop1.length === 0 && dataruleHits.length === 0 && listViewHits.length === 0 && workflowHits.length === 0 && formHits.length === 0;
1841
+ // issue 07(CLI 面):只在 service 零命中时出现(有命中 / 非 service 都不加)。
1842
+ const granularityUnsupported = zeroHit ? serviceMethodGranularityUnsupported(kind) : undefined;
1812
1843
  return {
1813
1844
  kind,
1814
1845
  code: rawCode,
@@ -1821,15 +1852,19 @@ export function impactGraph(kind, rawCode, selector = {}) {
1821
1852
  index: summary,
1822
1853
  coverage: GRAPH_COVERAGE,
1823
1854
  ...(scoped !== null ? { resolvedScope: { schemaCode: scoped.schemaCode, code: scoped.code } } : {}),
1824
- ...(hop1.length === 0 && dataruleHits.length === 0 && listViewHits.length === 0 && workflowHits.length === 0 && formHits.length === 0
1855
+ ...(zeroHit
1825
1856
  ? {
1857
+ // issue 07(CLI 面):零命中≠无影响。service 方法级未索引,note 不再给
1858
+ // 「没有影响」这种结论句;粒度边界由 granularityUnsupported 承接。
1826
1859
  note: (gapped
1827
1860
  ? "零命中,但索引存在扫描缺口——不可作为「无影响」证明;先 omc graph pull 重建再查"
1828
- : "零命中=scanned 面(规则/数据规则/视图/表单/流程)没有影响;workflow.bindings 与 onlinejs 未扫描,见 coverage.notScanned——不可据此判定「删除无影响」") +
1861
+ : "零命中=scanned 面(规则/数据规则/视图/表单/流程)零命中;workflow.bindings 与 onlinejs 未扫描,见 coverage.notScanned——不可据此判定「删除无影响」") +
1862
+ (kind === "service" ? ";service 方法级未索引,见 granularityUnsupported" : "") +
1829
1863
  (zeroHitKindHint(db, kind, code, "impact") ?? "") +
1830
1864
  (kind === "field" && scoped === null ? unresolvedScopedCodeNote(rawCode) ?? "" : ""),
1831
1865
  }
1832
1866
  : {}),
1867
+ ...(granularityUnsupported !== undefined ? { granularityUnsupported } : {}),
1833
1868
  ...(capped || dataruleHits.length > 20 || listViewHits.length > 20 || workflowHits.length > 20 || formHits.length > 20
1834
1869
  ? { truncated: true, note: `命中超过上限已截断(规则 50/实际 ${hop1.length},数据规则 20/实际 ${dataruleHits.length},视图 20/实际 ${listViewHits.length},流程 20/实际 ${workflowHits.length},表单 20/实际 ${formHits.length});完整规则清单用 references` }
1835
1870
  : {}),
@@ -106,10 +106,20 @@ export function writeSummary(tool, args, outcome, phase = "done") {
106
106
  // F7(0.8.6):physically_delete 是平台异步任务(建删除历史后立即返回)。回执
107
107
  // `readback.absent=false` 表示级联仍在跑、记录面还查得到目标——zh 行首词必须是
108
108
  // 否定,照 data.delete 的既有先例;否则人/CI 把「已删除模型 X」当成已生效。
109
+ if (phase === "done" && tool === "model.delete" && outcome?.readback?.deleteTask?.taskStatus === "FAIL") {
110
+ const code = stringArg(args, "schemaCode") ?? stringArg(args, "code") ?? "?";
111
+ const message = (outcome?.readback?.deleteTask).message;
112
+ const waited = (outcome?.readback?.deleteTask).waitedMs;
113
+ return `未删除(平台删除任务失败)模型 ${code}:${typeof message === "string" && message.length > 0 ? message : "平台未返回 message"}${typeof waited === "number" ? `(已等 ${Math.round(waited / 1000)}s)` : ""}——这不是「级联中」,任务已以 FAIL 结束;按平台原文拆引用/清残留后重试`;
114
+ }
109
115
  if (phase === "done" && tool === "model.delete" && outcome?.readback?.absent === false) {
110
116
  const code = stringArg(args, "schemaCode") ?? stringArg(args, "code") ?? "?";
111
117
  return `未删净(级联中)模型 ${code}:平台异步删除任务未完成,记录面仍查得到——不要当作已删除;以 readback.absent=true 且应用树无该节点为准,稍后重跑 model.delete(幂等)复核`;
112
118
  }
119
+ if (phase === "done" && tool === "model.deleteMany" && outcome?.readback?.deleteTask?.taskStatus === "FAIL") {
120
+ const message = (outcome?.readback?.deleteTask).message;
121
+ return `未删除(平台删除任务失败)批量模型:${typeof message === "string" && message.length > 0 ? message : "平台未返回 message"}——任务已以 FAIL 结束,本批未删;按平台原文拆引用/清残留后重试 model.deleteMany`;
122
+ }
113
123
  if (phase === "done" && tool === "model.deleteMany" && outcome?.readback?.allAbsent === false) {
114
124
  const perCode = (outcome.readback.perCode ?? {});
115
125
  const pending = Object.entries(perCode).filter(([, value]) => value?.absent === false).map(([code]) => code);
@@ -274,7 +284,15 @@ function phraseOf(tool, args, outcome) {
274
284
  case "listview.configure": {
275
285
  const codes = Array.isArray(args.fieldCodes) ? args.fieldCodes.map(String).join("、") : "";
276
286
  const sections = ["sorts", "conditions", "actions", "buttons", "presentation", "options", "presentationType", "gantt", "queryLayer", "multiTableHeaderConfig"].filter((key) => args[key] !== undefined);
277
- return `配置列表视图 ${stringArg(args, "code") ?? schemaCode ?? "?"}(模型 ${schemaCode ?? "?"}):列 ${codes || "(未变)"}${sections.length > 0 ? `;同时配置 ${sections.join("、")}` : ""}`;
287
+ // F9(w44,2026-11-26 真机):视图固定条件只在门户运行面生效,REST 的
288
+ // data.list --queryCode 不应用。此前只有 JSON 回执尾部的
289
+ // conditionRuntimeNote/viewConditionsAppliedRest:false 说这件事,人类摘要
290
+ // 行不提,验收要读完整回执才知道。摘要行(stderr)与 plan 卡同源,这里
291
+ // 只加一句,不改 JSON 回执字段。
292
+ const conditionRuntimeLine = Array.isArray(args.conditions) && args.conditions.length > 0
293
+ ? ";视图固定条件只在门户运行面生效,REST `data.list --queryCode` 不应用——要在 API 侧过滤请显式传 `filter`"
294
+ : "";
295
+ return `配置列表视图 ${stringArg(args, "code") ?? schemaCode ?? "?"}(模型 ${schemaCode ?? "?"}):列 ${codes || "(未变)"}${sections.length > 0 ? `;同时配置 ${sections.join("、")}` : ""}${conditionRuntimeLine}`;
278
296
  }
279
297
  case "listview.delete":
280
298
  return `删除列表视图 ${stringArg(args, "code") ?? "?"}(${schemaCode ?? "?"})`;
@@ -267,7 +267,7 @@ export const FIELD_LANE_CONTRACT = Object.freeze({
267
267
  controlEmissionPolicy: "ticket 101: controls PHONE(24)/PHOTO(10) are blocked for creation (no BizPropertyType maps to them — BizPropertyType.java:27-54); Tab(500) is a layout container (DataModelInitUtils.java:61-75 recurses panels, never a field); CreatedDeptId(102) is a system-field projection (DefaultPropertyType.java:18-21 → DEPARTMENT_SELECTOR 60, BizMainSystemPropertyRegistry.java:88-101); the scaffold SKIPS any field type without a control mapping — unknown/blocked control types are never auto-created (fail-closed)",
268
268
  fieldRowDefaultPolicy: "ticket 108 determination (live 8.6.26 write+read 2026-09-15 + fwb 8.6.39 readback): the 2026-09-14 key unions are MULTI-FIELD UNIONS of designer rows, not per-field required keys — the platform accepts-and-persists minimal rows, so the minimal default + caller passthrough is the INTENTIONAL boundary. Selection families 12/13/14/15 MUST-FIXED to omit dictionaryData (designer rows carry none; live proves the platform merely accepts the extra key — omc_mcp_t108dd readback carried it only because we sent it). Families 0/1/2/9/11/17 keep the designer-carried {dictionaryData:\"\"}; DATE(3) keeps required format (BizObjectFacadeImpl.java:2949); ATTACHMENT(6) stays intentionally empty (system rows often have no options)",
269
269
  orgSelectorFieldRowOptions: "org-selector families STAFF_SELECTOR / STAFF_MULTI_SELECTOR / DEPARTMENT_SELECTOR / DEPARTMENT_MULTI_SELECTOR (5/50/51/60/61): the field-row options are a publish-safe shape observed on the yst/fwb publish face (2656 rows) — null or {defaultValue, mappings, virtualField[, noRepeat]}; single-select defaultValue \"\" and multi-select []; deptVisible/multi are FORM-CONTROL discriminator keys (read from control.options via disposeUpdateType/updateSelectionType) and never appear on the field row",
270
- relationMappingsSource: "the field row's options.mappings is the source of truth for relation carry-through; editing a form control's mappings is recomputed from the field and does not survive readback (live 2026-10-14 中冶). Update chain: field.update with the full options (change only mappings, keep queryCode/displayField/schemaCode/conditions… as-is) → field.publish → form.draft rebuild:false (keeps the existing layout and any online JS) → form.publish → readback. Do NOT use cascadeRepublish on a form that already carries a custom layout or online JS — it re-scaffolds the default form",
270
+ relationMappingsSource: "`options.mappings` 形如 `[{source:<关联目标字段/父模型字段>,target:<本模型字段>}]`(裸 code),是关联填充的事实源(字段行,不是表单控件:改控件映射会被重算覆盖,live 2026-10-14 中冶)。Update chain: field.update with the full options (change only mappings, keep queryCode/displayField/schemaCode/conditions… as-is) → field.publish → form.draft rebuild:false (keeps the existing layout and any online JS) → form.publish → readback. Do NOT use cascadeRepublish on a form that already carries a custom layout or online JS — it re-scaffolds the default form. 子表关联列取主表字段的完整配方:`omc describe field.create --example child-map-fill`",
271
271
  propertyEmptyReadback: "propertyEmpty overrides the data-model not-null declaration; false reopens a field the platform previously created wrongly (required/readonly belong to the form and workflow nodes). bizproperty/list rows do NOT carry propertyEmpty, so readback.propertyEmpty appears only when the draft face returns it — the CLI never fabricates it; readback.committed lists what actually went on the wire",
272
272
  listFace: "field.list default face inlines code/name/type(+typeName)/conditions signal/shapeWarning only; the whole choices package is not inlined (a selection field measured ~500B/row) — verify options/subSchema with the code/fields selectors or full:true",
273
273
  }),
@@ -309,6 +309,10 @@ export const FIELD_LANE_CONTRACT = Object.freeze({
309
309
  scope: "create publish readback",
310
310
  description: "List draft/published fields of a model. 默认面紧凑(整包 choices 不内联);验证 options/subSchema 用 code/fields 选择器或 full:true。",
311
311
  }),
312
+ "field.get": Object.freeze({
313
+ scope: "create publish readback",
314
+ description: "单字段读(= field.list + code 选择器,含 options/subSchema)。",
315
+ }),
312
316
  "field.create": Object.freeze({
313
317
  scope: "create publish readback",
314
318
  description: describeTool("Create a draft field on a model (bizproperty/create).", [
@@ -12,6 +12,7 @@ export const FIELD_COVERAGE = declareLaneCoverage(FIELD_LANE_CONTRACT.lane, [
12
12
  // assertToolSurfaceConsistent — exactly the duplicate that guard exists to
13
13
  // catch, so don't introduce one.
14
14
  claim("field.list", T["field.list"].scope),
15
+ claim("field.get", T["field.get"].scope),
15
16
  claim("field.create", T["field.create"].scope),
16
17
  claim("field.update", T["field.update"].scope),
17
18
  claim("field.publish", T["field.publish"].scope),
@@ -563,7 +563,7 @@ export async function lintFieldCreateWrite(session, input, options = {}) {
563
563
  return prepared;
564
564
  }
565
565
  export function registerFieldLane(tools) {
566
- tools.push(defineTool({
566
+ const fieldListTool = defineTool({
567
567
  name: "field.list",
568
568
  search: { intents: ["看字段", "查字段", "字段清单", "模型有哪些字段", "字段列表", "跳号"] },
569
569
  layer: "low",
@@ -786,7 +786,25 @@ export function registerFieldLane(tools) {
786
786
  };
787
787
  },
788
788
  }),
789
- }));
789
+ });
790
+ tools.push(fieldListTool);
791
+ // F10(0.8.7 探针 B):`field.get` 不存在时 `omc call field.get` 只回 unknown-tool
792
+ // + candidates,多一往返;单字段读的真身就是 field.list 的 code 选择器。这里
793
+ // 注册**薄别名**(同一 handler、同一栏/覆盖声明),不复制读取逻辑,也不改
794
+ // field.list 行为。
795
+ tools.push({
796
+ ...fieldListTool,
797
+ name: "field.get",
798
+ search: { intents: ["读一个字段", "单个字段", "字段详情", "这个字段配置", "字段 options", "查字段详情"] },
799
+ description: "单字段读(field.list 的 code 选择器)。返回该字段 options/subSchema 等详情。",
800
+ inputSchema: {
801
+ environment: environmentArg,
802
+ schemaCode: z.string(),
803
+ code: z.string(),
804
+ published: z.boolean().default(false),
805
+ capability: capabilityArg,
806
+ },
807
+ });
790
808
  writeTool({
791
809
  tools,
792
810
  name: "field.create",
@@ -20,7 +20,7 @@ export const FORM_WIRE = Object.freeze({
20
20
  sheetListFace: "form.list: GET /api/api/app/bizsheet/list?schemaCode= (BizFormController.java:137-152 → ModelManagementFacadeImpl.getBizForms:481-488) answers the BizFormHeaderModel HEADER projection only — code, name, schemaCode, published, formType, sortKey, icon. formType is the INTEGER index (@JsonValue getIndex(), BizFormType.java:45-48): 0 DEFAULT_SHEET / 1 CUSTOMIZE_SHEET / 2 PRINT_TEMPLATE — decoded to the name with formTypeIndex kept (ADR 0002). existDraft/buttonCount/hasCustomScript are NOT on this face, so the default read never fabricates them: detail:true pays 1+N bizsheet/get for the content-derived faces. published is the same platform flag bit (r79-04): publish→draft leaves it false while the content is intact — the flag is reported as-is, content judgement needs detail:true. HTTP 404 means the version family has no /list endpoint: the tool answers sheetListUnavailable:true + the default slot only, never a fabricated list; a 601003 业务模型不存在 refusal is modelPresent:false (zero retries)",
21
21
  });
22
22
  const FORM_GET_DESCRIPTION = '读取默认表单(bizsheet/get)的发布状态与控件清单(紧凑默认)。**发布态以返回的 `published` / `existDraft` 布尔为准**(`published:true`=已发布;`published:false,existDraft:true`=只有草稿,**未发布**)——不要用 `publishedControlCodes` 是否非空来推断(草稿字段会让它非空,误判为已发布)。**每个模型交付前其默认表单必须 `published:true`**:用 `configure_form` 或 `form.draft(rebuild:true)`+`form.publish` 发布,并逐模型 `form.get` 核对。`full:true` 还返回 `options` 与 `customButtonJson`(表单工具栏按钮,数组原样;库里是字符串脏形时附 `customButtonJsonShapeWarning`——线上 #38 前端按钮不渲染)。传 `controls:["code",…]` 只取指定控件的 options(如关联控件的 mappings);传 `full:true` 才返回 draft/published 的完整 view/attributes/html/actions JSON(actions 列为设计器保存/发布的表单级按钮动作)。体积大,仅在需要整体布局时用。';
23
- const FORM_DRAFT_DESCRIPTION = "Save the default-form DRAFT (bizsheet/update). Reads the current sheet, merges the caller's explicit draftViewJson/draftAttributesJson (or preserves the existing draft); when both are absent on a fresh default form, composes the designer-standard scaffold from the model's published fields. A redundant field (relation-mapping carry-through target) always stays bound; with no workflow it is hidden in the design (options.visible=false), with a workflow it stays visible for per-node propertyPermissions. Pass `draftHtmlJson` to thread custom online-script HTML through. Empty-layout guard: explicitly passing \"[]\"/\"{}\" view/attributes is refused (form-empty-layout) — the platform designer's Save is NOT lossless and clears drafts to exactly that shape; escape with allowEmptyLayout:true, and recover cleared drafts from the form version history (/api/api/app/bizsheet/history/list). **读回原样回写**:从 `form.get` 取回的 view/attributes 直接回传时加 `fromReadback:true`——工具会与已存草稿/发布面逐字比对,一致才放行(平台自身布局可能含子表列行/系统行默认宽度),被改动过的面照常按 validation 拒绝。**表单工具栏按钮**:`buttons`(数组)或 `customButtonJson`(原样字符串)写进 `biz_sheet.options.customButtonJson`(**数组+actionConfig 对象**,设计器同形——线上 #38:字符串形=双重编码,前端按钮不渲染,重写即自愈);**要到 form.publish 才生成 h_biz_button(triggerType=FORM)**,且表单页是否显示还取决于流程节点 `buttonPermission.customBtns[].enabled`(设计器「表单操作」勾选)。`useLocation` 用 FORM/ROW/LIST,表单工具栏按钮用 FORM。字段发布后如需刷新已发布表单的控件映射,用本工具 rebuild:false 重存(保留现有布局与在线JS)再 form.publish。";
23
+ const FORM_DRAFT_DESCRIPTION = "Save the default-form DRAFT (bizsheet/update). Reads the current sheet, merges the caller's explicit draftViewJson/draftAttributesJson (or preserves the existing draft); when both are absent on a fresh default form, composes the designer-standard scaffold from the model's published fields. A redundant field (relation-mapping carry-through target) always stays bound; with no workflow it is hidden in the design (options.visible=false), with a workflow it stays visible for per-node propertyPermissions. Pass `draftHtmlJson` to thread custom online-script HTML through. Empty-layout guard: explicitly passing \"[]\"/\"{}\" view/attributes is refused (form-empty-layout) — the platform designer's Save is NOT lossless and clears drafts to exactly that shape; escape with allowEmptyLayout:true, and recover cleared drafts from the form version history (/api/api/app/bizsheet/history/list). **读回原样回写**:从 `form.get` 取回的 view/attributes 直接回传时加 `fromReadback:true`——工具会与已存草稿/发布面逐字比对,一致才放行(平台自身布局可能含子表列行/系统行默认宽度),被改动过的面照常按 validation 拒绝。**表单工具栏按钮**:`buttons`(数组)或 `customButtonJson`(原样字符串)写进 `biz_sheet.options.customButtonJson`(**数组+actionConfig 对象**,设计器同形——线上 #38:字符串形=双重编码,前端按钮不渲染,重写即自愈);**要到 form.publish 才生成 h_biz_button(triggerType=FORM)**,且表单页是否显示还取决于流程节点 `buttonPermission.customBtns[].enabled`(设计器「表单操作」勾选)。`useLocation` 用 FORM/ROW/LIST,表单工具栏按钮用 FORM。字段发布后如需刷新已发布表单的控件映射,用本工具 rebuild:false 重存(保留现有布局与在线JS)再 form.publish。**改既有表单勿整表重写**:先 `form.get full:true` 取 `publishedAttributesJson` 作基线、只改 rows/span;只写业务字段会丢系统控件并撞 form-publish-degrade。";
24
24
  const FORM_PUBLISH_DESCRIPTION = "Publish the default form (bizsheet/publish, proven shape: draft*Json promoted to published*Json verbatim) with published-face readback. **不影响在线 JS**:本工具只提拔布局草稿;改 JS 请用 onlinejs.compose(它自己会连同整张表单一起发布,不必再调本工具)。 Degrade guard: refuses to promote a draft carrying FEWER controls than the published face (form-publish-degrade) — the designer's Save clears drafts non-losslessly; recover via the form version history (/api/api/app/bizsheet/history/list) and rewrite the draft first, or pass allowDegrade:true to force the reduction. rebuild:true is the one-call refresh: discard the existing draft, re-scaffold from the published fields (non-structural control options preserved), then force-promote — use it after a field shape change. **表单工具栏按钮**:传 `buttons`(或 `customButtonJson`)→ 写进 `options.customButtonJson` 并在本次 publish 生成 `h_biz_button(triggerType=FORM, triggerCode=<formCode>)`(平台 `publishBizForm:1022`);`options.customButtonJson` 以**数组**写入(条目 `actionConfig` 为对象,设计器同形——线上 #38:字符串形=双重编码,前端按钮不渲染,回执给 formButtonsShapeWarning);表单页是否显示再由流程节点 `buttonPermission.customBtns[].enabled` 过滤。";
25
25
  const FORM_RUN_BUTTON_DESCRIPTION = "执行表单工具栏按钮(平台同款面:`POST /api/api/runtime/form/executeCustomButton`,body `{bizButtonModel, bizObjectList:[<完整业务对象>], reacquireDataFromDb:true}`)。**与列表行按钮不同**:列表按钮发 `launcher/domain_service_runtime/<schema>/<rule>` + `ids[]`(用 `rule.run`),表单按钮带**整条记录**,不能互换。按钮来源 `GET /api/api/system/getCustomButtons`(只列 triggerType=FORM 的 h_biz_button)。前提:按钮已由 `form.publish` 的 `buttons`/`customButtonJson` 生成。返回是执行结果信封,规则副作用用 `data.load` 另读;被规则 UPDATE 的目标行须是 COMPLETED(引擎查不到 DRAFT)。`302045` = 数据被占用。**`10005` 换等价面 `rule.run`(见 contract form),勿反复重试。**";
26
26
  const CONFIGURE_FORM_DESCRIPTION = "High-level: bind fields into the default form and publish it (form.draft → form.publish), subject to the write permission gate. Delegates to the proven form.draft scaffold + form.publish paths so the real empty-form layout (and any caller-supplied draftHtmlJson) is persisted and promoted — never bypasses with a shortcut body. `sheetCode` is optional: omitted means the model's default sheet (sheetCode = schemaCode).";
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { ENDPOINTS } from "../endpoints.js";
3
3
  import { decodeButtonScript } from "./list-view.js";
4
- import { executeFormDraftWrite, executeFormPublishWrite, executeFormRunButtonWrite, lintFormPublishReadOnly, readFormButtons, readFormOrNull, refuseEmptyCallerLayout, validateHtmlRender, customButtonJsonStoredShape, CUSTOM_BUTTON_JSON_STRING_SHAPE_WARNING, FORM_FLAG_AUTHORITY_NOTE, compareFormFaces, resolveEffectiveFormFace } from "../form-support.js";
4
+ import { executeFormDraftWrite, executeFormPublishWrite, executeFormRunButtonWrite, lintFormPublishReadOnly, lintFormControlTypes, readFormButtons, readFormOrNull, refuseEmptyCallerLayout, validateHtmlRender, customButtonJsonStoredShape, CUSTOM_BUTTON_JSON_STRING_SHAPE_WARNING, FORM_FLAG_AUTHORITY_NOTE, compareFormFaces, resolveEffectiveFormFace } from "../form-support.js";
5
5
  import { capabilityArg, environmentArg } from "../args.js";
6
6
  import { governedRead } from "../read.js";
7
7
  import { writeTool } from "../write.js";
@@ -572,7 +572,8 @@ export function registerFormLane(tools) {
572
572
  schemaCode: z.string().min(1),
573
573
  sheetCode: z.string().min(1).optional().describe("表单槽位码;省略时默认 = schemaCode(模型码即默认表单槽位)"),
574
574
  draftViewJson: z.string().optional().describe("行分组:JSON 二维字符串数组 `[[\"codeA\",\"codeB\"],[\"codeC\"]]`——**一行几个 code 就是几列**(不是改 span 来改列数);末行只放一个 code 即整宽。每个 code 必须同时出现在 draftAttributesJson 里。现成样例:`omc describe form.draft --example two-column-layout`"),
575
- draftAttributesJson: z.string().optional().describe("控件表:JSON 对象 `{ \"codeA\": { key:\"codeA\", type: <控件类型号>, options:{ name:\"显示名\", span: 12 } } }`。`span` 是 24 栅格宽度:两列各 span:12、整宽 span:24(必须与 draftViewJson 的行分组一致,否则 layout_coverage_mismatch)。现成样例:`omc describe form.draft --example two-column-layout`"),
575
+ draftAttributesJson: z.string().optional().describe("控件表:JSON 对象 `{ \"codeA\": { key:\"codeA\", type: <表单控件类型号>, options:{ name:\"显示名\", span: 12 } } }`。**控件 type 是表单控件枚举,不是字段 propertyType**(80=关联单选/201=子表…);错枚举拒 `form-control-type-mismatch`。`span` 是 24 栅格宽度:两列各 span:12、整宽 span:24(须与 draftViewJson 行分组自洽)。样例:`omc describe form.draft --example two-column-layout`"),
576
+ allowTypeMismatch: z.boolean().optional().describe("放行控件 type 与字段 propertyType 不匹配(默认拒 form-control-type-mismatch;仅平台模板明确要求特殊控件时用)"),
576
577
  draftHtmlJson: z.string().optional(),
577
578
  fieldCodes: z.array(z.string().min(1)).optional().describe("脚手架绑定的已发布字段(按此顺序);由 configure_form/intent 显式传入。子表列写「父字段.子列」等价于 childColumns"),
578
579
  childColumns: z
@@ -598,6 +599,27 @@ export function registerFormLane(tools) {
598
599
  // governed pipeline — including the rollback before-capture read.
599
600
  refuseEmptyCallerLayout({ ...args, sheetCode: resolveSheetCode(args.schemaCode, args.sheetCode) });
600
601
  },
602
+ // R75-B seam: dry-run 与真写共用这一个 session 只读 lint(dry-run 直接跑它)。
603
+ // 控件 type 交叉校验需要 field.list(propertyType 是另一套枚举),纯参数门
604
+ // 拿不到;放进这里才能让 `--dry-run` 与真写同答案。executeFormDraftWrite 里
605
+ // 再跑同一函数,直调执行器的路径也绕不过去。
606
+ writeLint: async (session, args) => {
607
+ if (args.fromReadback === true)
608
+ return { controlTypeCheck: "skipped-fromReadback" };
609
+ const lint = await lintFormControlTypes(session, {
610
+ schemaCode: args.schemaCode,
611
+ sheetCode: resolveSheetCode(args.schemaCode, args.sheetCode),
612
+ ...(typeof args.draftAttributesJson === "string" ? { draftAttributesJson: args.draftAttributesJson } : {}),
613
+ ...(args.allowTypeMismatch !== undefined ? { allowTypeMismatch: args.allowTypeMismatch } : {}),
614
+ });
615
+ if (lint === undefined || lint.mismatches.length === 0)
616
+ return {};
617
+ return {
618
+ controlTypeMismatchAllowed: true,
619
+ controlTypeMismatches: lint.mismatches,
620
+ controlTypeNote: "allowTypeMismatch:true 显式放行;本工具不替你改控件 type。",
621
+ };
622
+ },
601
623
  rollback: {
602
624
  target: (args) => `form:${String(args.schemaCode ?? "")}/${String(args.sheetCode ?? args.schemaCode ?? "")}`,
603
625
  read: (session, args) => readFormOrNull(session, String(args.schemaCode), resolveSheetCode(String(args.schemaCode), args.sheetCode)),
@@ -409,19 +409,88 @@ export function decodeButtonScript(input) {
409
409
  * 306103(删除后将无可用视图)。平台要求**每个模型至少保留一个 PC 可见视图和
410
410
  * 一个 MOBILE 可见视图**;该码只在 2.1.5 出现(`ErrorCode.java:383`),8.6.26
411
411
  * 无 306103。导出以便回执文案被测试钉住(PC/MOBILE 各一条 + 正确出路)。
412
+ *
413
+ * `detail.localPrecheck:true` 表示本判定来自**写前本地预检**(零 wire 写入):
414
+ * 平台判据由两族源码合并而来 —— 2.1.5 BizQueryController.delete:215-227
415
+ * (扣掉目标后剩余视图里必须仍有 showOnPc=true 与 showOnMobile=true 各一条,
416
+ * null/false 都算不可见);8.6.26 同方法 :297-311 只禁删**第一行**视图
417
+ * (BIZ_QUERY_DEFAULT 303025)。两者取并集,宁拒绝不误删。
412
418
  */
413
- export function listviewLastVisibleRefusal(schemaCode, code) {
419
+ export function listviewLastVisibleRefusal(schemaCode, code, detail) {
420
+ const local = detail?.localPrecheck === true;
421
+ const reasons = detail?.reasons ?? [];
422
+ const platformRule = reasons.includes("default-view")
423
+ ? "8.6.26 BizQueryController.delete:297-311(bizList.get(0) 不可删,BIZ_QUERY_DEFAULT 303025)"
424
+ : "2.1.5 BizQueryController.delete:215-227(扣掉目标后 PC/MOBILE 各需至少一条可见视图,BIZ_QUERY_DELETE_LACK_PC_MOBILE_VIEWS 306103)";
414
425
  return new ToolRefusalError({
415
426
  status: "refused",
416
427
  blocker: "listview-last-visible",
417
428
  schemaCode,
418
429
  code,
430
+ ...(local
431
+ ? {
432
+ localPrecheck: true,
433
+ reasons,
434
+ platformRule,
435
+ ...(detail?.firstViewCode !== undefined ? { firstViewCode: detail.firstViewCode } : {}),
436
+ ...(detail?.remainingViewCodes !== undefined ? { remainingViewCodes: detail.remainingViewCodes } : {}),
437
+ }
438
+ : {}),
419
439
  nextCommand: `omc model-purge --code ${schemaCode}`,
420
- message: `不能删除视图 ${code}:平台要求**至少保留一个 PC 可见视图和一个 MOBILE 可见视图**(PC + MOBILE 各一条,306103)。` +
440
+ cleanupGuidance: `删视图在平台上不是独立清理步骤:要清视图就删模型(model-purge / model.delete 级联删除它的全部视图,含这条);` +
441
+ `listview.delete 只用于替换视图(先建/配好替代视图再删旧的),最后一条可见视图不可单删。`,
442
+ message: (local && !reasons.includes("last-visible")
443
+ ? `不能删除视图 ${code}:8.6.26 平台禁止删除默认(第一行)视图(BIZ_QUERY_DEFAULT 303025)。`
444
+ : `不能删除视图 ${code}:平台要求**至少保留一个 PC 可见视图和一个 MOBILE 可见视图**(PC + MOBILE 各一条,306103)。`) +
445
+ (local
446
+ ? `本条是**写前本地预检**(零写入,未发 delete wire):${reasons.includes("default-view") ? "目标是默认(第一行)视图,8.6.26 直接禁删;" : ""}${reasons.includes("last-visible") ? "扣掉它之后 PC/MOBILE 的可见视图不足各一条。" : ""}`
447
+ : "") +
421
448
  `单独删最后一条视图没有意义——删模型会级联删除它的所有视图。要继续用这个模型就**就地改**(listview.configure 省略 code 即改默认视图),` +
422
449
  `要整体清理就用 model-purge(默认 dry-run,先看计划)。`,
423
450
  });
424
451
  }
452
+ /**
453
+ * Local mirror of the platform delete gate (F8 0.8.8). Returns null when the
454
+ * delete is NOT locally known to be blocked — including whenever the read face
455
+ * cannot prove visibility (list wire failed / visibility keys not projected) or
456
+ * the target is absent from the list. In those cases the caller must keep the
457
+ * existing behaviour and let the platform refuse (never a false local allow).
458
+ */
459
+ export async function listviewDeleteLocalBlock(session, schemaCode, code) {
460
+ let rows;
461
+ try {
462
+ rows = wireRows((await wireCall(session, { path: ENDPOINTS.listQueryList, query: { schemaCode, clientType: "PC" } })).data);
463
+ }
464
+ catch {
465
+ return null;
466
+ }
467
+ if (rows.length === 0)
468
+ return null;
469
+ const index = rows.findIndex((row) => String(row.code ?? "") === code);
470
+ if (index < 0)
471
+ return null;
472
+ // Both flags must be projected by the read face. An ABSENT key is "unknown"
473
+ // (e.g. a proxy projection) — do not read it as false. A present null IS the
474
+ // platform's "not visible" (2.1.5 uses Boolean.TRUE.equals).
475
+ const known = (row, key) => key in row && (typeof row[key] === "boolean" || row[key] === null);
476
+ if (!rows.every((row) => known(row, "showOnPc") && known(row, "showOnMobile")))
477
+ return null;
478
+ const remaining = rows.filter((_, position) => position !== index);
479
+ const pcLeft = remaining.some((row) => row.showOnPc === true);
480
+ const mobileLeft = remaining.some((row) => row.showOnMobile === true);
481
+ const reasons = [];
482
+ if (index === 0)
483
+ reasons.push("default-view");
484
+ if (remaining.length === 0 || !pcLeft || !mobileLeft)
485
+ reasons.push("last-visible");
486
+ if (reasons.length === 0)
487
+ return null;
488
+ return {
489
+ reasons,
490
+ firstViewCode: String(rows[0]?.code ?? ""),
491
+ remainingViewCodes: remaining.map((row) => String(row.code ?? "")).filter(Boolean),
492
+ };
493
+ }
425
494
  export function registerListViewLane(tools) {
426
495
  tools.push(defineTool({
427
496
  name: "listview.get",
@@ -1297,10 +1366,43 @@ export function registerListViewLane(tools) {
1297
1366
  scope: LIST_VIEW_TOOLS["listview.delete"].scope,
1298
1367
  description: LIST_VIEW_TOOLS["listview.delete"].description,
1299
1368
  inputSchema: { schemaCode: z.string().min(1), code: z.string().min(1) },
1369
+ // F8(0.8.8):写前本地预检——平台在删「最后一条可见视图 / 默认视图」时拒绝
1370
+ // (2.1.5 :215-227 / 8.6.26 :297-311),本工具先读视图清单就地拒绝,零写入。
1371
+ // dry-run 与真写共用这一个函数;读面不足时返回 null → 照旧走平台 wire 拒绝。
1372
+ writeLint: async (session, args) => {
1373
+ const blocked = await listviewDeleteLocalBlock(session, args.schemaCode, args.code);
1374
+ if (blocked !== null)
1375
+ throw listviewLastVisibleRefusal(args.schemaCode, args.code, {
1376
+ localPrecheck: true,
1377
+ reasons: blocked.reasons,
1378
+ firstViewCode: blocked.firstViewCode,
1379
+ remainingViewCodes: blocked.remainingViewCodes,
1380
+ });
1381
+ return {
1382
+ wouldChange: true,
1383
+ summary: `即将删除列表视图 ${args.schemaCode}/${args.code}`,
1384
+ visibilityPrecheck: {
1385
+ locallyBlocked: false,
1386
+ note: "本地未命中「最后一条可见视图/默认视图」判据;平台 306103/303025 仍是最终门(读面不足时不做本地判定)",
1387
+ },
1388
+ };
1389
+ },
1300
1390
  execute: async (session, args) => {
1301
1391
  const before = await wireCall(session, { path: ENDPOINTS.listQueryGetHeader, query: { schemaCode: args.schemaCode, code: args.code } });
1302
1392
  if (before.data == null)
1303
1393
  return { performed: { skipped: "already-absent" }, readback: { absent: true, header: null } };
1394
+ // Local precheck (zero write): the platform refuses the last visible view
1395
+ // (2.1.5) / the default first-row view (8.6.26) with 306103/303025. When
1396
+ // the read face cannot prove visibility this returns null and the delete
1397
+ // proceeds to the platform wire, preserving today's refusal path.
1398
+ const blocked = await listviewDeleteLocalBlock(session, args.schemaCode, args.code);
1399
+ if (blocked !== null)
1400
+ throw listviewLastVisibleRefusal(args.schemaCode, args.code, {
1401
+ localPrecheck: true,
1402
+ reasons: blocked.reasons,
1403
+ firstViewCode: blocked.firstViewCode,
1404
+ remainingViewCodes: blocked.remainingViewCodes,
1405
+ });
1304
1406
  let performed;
1305
1407
  try {
1306
1408
  performed = await wireCall(session, { path: ENDPOINTS.listQueryDelete, method: "POST", query: { schemaCode: args.schemaCode, code: args.code } });