@stalfh233/omc-cli 0.6.49 → 0.6.51

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.
@@ -259,7 +259,7 @@ export const CAPABILITY_SCENARIOS = Object.freeze({
259
259
  */
260
260
  export const CAPABILITY_CUES = Object.freeze({
261
261
  environment: ["环境", "指纹", "版本", "连接", "登录", "就绪", "发现"],
262
- app: ["应用", "门户", "分组"],
262
+ app: ["应用", "门户"],
263
263
  dictionary: ["字典", "选项来源", "选项", "键值", "树型"],
264
264
  model: ["模型", "对象", "主数据", "物理删除", "汇总表", "统计表", "汇总对象", "月度汇总表", "汇总模型"],
265
265
  field: ["字段", "属性", "子表", "明细", "下拉", "单选", "多选", "附件", "人员", "部门", "日期", "数值", "文本", "关联", "公式", "计算", "计算字段", "求和", "汇总", "合计", "回主表", "超链接", "地址", "单据号", "流水号", "编号自动生成", "表单层", "必填", "只读", "条件必填", "恒必填", "条件只读", "恒只读", "表单必填", "表单只读"],
@@ -649,7 +649,8 @@ export function executableCapabilityBundle(registry, id) {
649
649
  * `--compact` keeps the mid-width shape (id/lane/intent/coverage/toolCount) it
650
650
  * has had since HANDOFF §三.3-7, so existing callers do not move.
651
651
  *
652
- * `legacy` (OMC_LEGACY_DISCOVERY=1) restores the pre-M2 default exactly.
652
+ * (r61)`legacy`(OMC_LEGACY_DISCOVERY)回滚档已按计划移除——M2 面经 R60
653
+ * 三路探针真机验证后退役。
653
654
  */
654
655
  export function compactCapabilities(registry, options = {}) {
655
656
  const index = capabilityRouteIndex(registry);
@@ -658,7 +659,7 @@ export function compactCapabilities(registry, options = {}) {
658
659
  // `omc capability <id>` 按需取。压缩档因此把 tools 换成 toolCount,并**明说**
659
660
  // 省略了工具名,不让读者误以为该能力没有工具。
660
661
  const compact = options.compact === true;
661
- const full = options.full === true || options.legacy === true || compact;
662
+ const full = options.full === true || compact;
662
663
  if (!full) {
663
664
  // Lean index. A single `id:toolCount` line instead of 18 objects: the
664
665
  // decision this face answers is "which family do I need", and the family's
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 { artifactPathMissHint, nullProjectionHint, partialPathMissHint, projectJsonPath, projectJsonPathFanout, projectResultExtract } from "./path-projection.js";
28
28
  import { basename, join, resolve } from "node:path";
29
- import { writeFileSync } from "node:fs";
29
+ import { existsSync, readFileSync, writeFileSync } from "node:fs";
30
30
  import { buildToolRegistry } from "./tools.js";
31
31
  import { acquireWriteLock, writeLockHeldFace } from "./write-lock.js";
32
32
  import { cmdCompute } from "./compute.js";
@@ -1297,7 +1297,7 @@ function cmdDiscovery(kind, transport, value, options = {}) {
1297
1297
  // catalogue must be requested with `commands --json` (round-9 heavy-task: an
1298
1298
  // agent paid 4×54 KB on the default face before any hint could land).
1299
1299
  if (options.json !== true && options.compact !== true && !scoped) {
1300
- result = commandIndex(registry, { legacy: legacyDiscovery() });
1300
+ result = commandIndex(registry);
1301
1301
  return emitProjectedResult({ status: "ok", ...result }, transport, options.jq);
1302
1302
  }
1303
1303
  const inventory = commandInventory(registry, { compact: options.compact === true });
@@ -1445,7 +1445,7 @@ function cmdDiscovery(kind, transport, value, options = {}) {
1445
1445
  }
1446
1446
  }
1447
1447
  else {
1448
- result = describeTool(registry, value ?? "", { legacy: legacyDiscovery() });
1448
+ result = describeTool(registry, value ?? "");
1449
1449
  // r28b 账本(2026-10-28):describe rule.save×11 / form.publish×9——firstCall 教学后
1450
1450
  // 仍反复全量 describe。同参数近期已 ok 时附降载提示,引导 --param/--example 精准取。
1451
1451
  // 无项目 ledger(golden/repo 测试/一次性运行)时 priorIdenticalSuccess 返回
@@ -1522,10 +1522,40 @@ function cmdNext(goal, transport) {
1522
1522
  * every other shape stays one envelope.
1523
1523
  */
1524
1524
  async function cmdPlan(goal, options, transport) {
1525
+ // r60c-F4(真机复现):`call`/`doctor` 都能从 .omc-env 自解环境,唯独 plan 缺
1526
+ // --env 直接报错——同项目内一次纯粹的错误往返。缺省时按**项目绑定面**解析
1527
+ // (OMC_ENV > cwd 的 .omc-env);刻意不落全局 default——plan 会解析平台 id,
1528
+ // 对错环境规划比多问一次 --env 更糟(沙盒纪律是 .omc-env 作用域)。
1529
+ let environmentSource;
1530
+ let environment;
1525
1531
  if (options.env === undefined || options.env.trim() === "") {
1526
- return emitInvalid(transport, {
1527
- message: "`omc plan` 必须指定 --env <环境>:规划要读平台解析 schemaCode/字段 code,没有环境只能给路线(那正是 omc next)。离线形状用 --env <env> --offline(零 wire)",
1528
- });
1532
+ const bound = process.env.OMC_ENV?.trim() || (() => {
1533
+ try {
1534
+ const path = defaultPaths().projectEnvPath;
1535
+ return existsSync(path) ? readFileSync(path, "utf8").trim() : "";
1536
+ }
1537
+ catch {
1538
+ return "";
1539
+ }
1540
+ })();
1541
+ if (!bound) {
1542
+ return emitInvalid(transport, {
1543
+ message: "`omc plan` 必须指定 --env <环境>:规划要读平台解析 schemaCode/字段 code,没有环境只能给路线(那正是 omc next)。本目录没有可用的 .omc-env/OMC_ENV 绑定(刻意不落全局 default——对错环境规划更糟)。离线形状用 --env <env> --offline(零 wire)",
1544
+ });
1545
+ }
1546
+ environment = bound;
1547
+ environmentSource = process.env.OMC_ENV ? "OMC_ENV" : ".omc-env";
1548
+ // 与 call 同一道治理:显式名过 known/scope 校验(unknown environment 在这里
1549
+ // 就拒,而不是等探针阶段回 uncertain)。
1550
+ try {
1551
+ new ConfigStore(defaultPaths()).resolveEnvironment(bound);
1552
+ }
1553
+ catch (error) {
1554
+ return emitInvalid(transport, { message: error instanceof Error ? error.message : String(error) });
1555
+ }
1556
+ }
1557
+ else {
1558
+ environment = options.env;
1529
1559
  }
1530
1560
  if (options.planOut !== undefined) {
1531
1561
  try {
@@ -1535,7 +1565,6 @@ async function cmdPlan(goal, options, transport) {
1535
1565
  return emitInvalid(transport, { message: error instanceof Error ? error.message : String(error) });
1536
1566
  }
1537
1567
  }
1538
- const environment = options.env;
1539
1568
  let target;
1540
1569
  if (options.recipe !== undefined) {
1541
1570
  const [toolName, recipeId, ...rest] = options.recipe.split("/");
@@ -1592,7 +1621,7 @@ async function cmdPlan(goal, options, transport) {
1592
1621
  console.log(line);
1593
1622
  return 0;
1594
1623
  }
1595
- return emitResult(plan, transport);
1624
+ return emitResult({ ...plan, ...(environmentSource !== undefined ? { environmentSource } : {}) }, transport);
1596
1625
  }
1597
1626
  /**
1598
1627
  * Ticket 125 — `omc capabilities` / `omc capability <id>`: the Configuration
@@ -1600,20 +1629,9 @@ async function cmdPlan(goal, options, transport) {
1600
1629
  * the tool registry, the coverage manifest, and the intent capability registry.
1601
1630
  */
1602
1631
  function cmdCapabilities(transport, options = {}, jq) {
1603
- const result = compactCapabilities(buildToolRegistry(), { ...options, legacy: legacyDiscovery() });
1632
+ const result = compactCapabilities(buildToolRegistry(), options);
1604
1633
  return emitProjectedResult({ status: "ok", ...result }, transport, jq);
1605
1634
  }
1606
- /**
1607
- * `OMC_LEGACY_DISCOVERY=1` — the 0.6.48 rollback switch (EXECUTION-PLAN §十).
1608
- *
1609
- * It restores the pre-M2 default faces byte-for-byte: bare `commands` with all
1610
- * rows, `capabilities` with the full projection, and the wide `describe`. The
1611
- * explicit flags (`--json`, `--full`, `--capability`) are unaffected — only the
1612
- * defaults move, so a caller that names what it wants never sees a difference.
1613
- */
1614
- function legacyDiscovery() {
1615
- return process.env.OMC_LEGACY_DISCOVERY === "1";
1616
- }
1617
1635
  function cmdCapability(id, transport, executable = false, jq) {
1618
1636
  const registry = buildToolRegistry();
1619
1637
  const resolved = resolveCapabilityId(id);
@@ -1737,7 +1755,7 @@ function intentDigest(intent) {
1737
1755
  };
1738
1756
  }
1739
1757
  /** Ticket 118 — `omc intent plan <file> --env <env>`: read-only baseline -> compile -> immutable plan. */
1740
- async function cmdIntentPlan(file, environment, planOut, transport) {
1758
+ async function cmdIntentPlan(file, environment, planOut, transport, summary = false) {
1741
1759
  const read = readIntentOrInvalid(file, transport);
1742
1760
  if (read.kind === "exit")
1743
1761
  return read.code;
@@ -1749,7 +1767,28 @@ async function cmdIntentPlan(file, environment, planOut, transport) {
1749
1767
  return emitInvalid(transport, { message: error instanceof Error ? error.message : String(error) });
1750
1768
  }
1751
1769
  }
1752
- return emitResult(await planIntent(read.intent, environment, planOut), transport);
1770
+ const result = await planIntent(read.intent, environment, planOut);
1771
+ // a-F12(r60a-F12,r61):--summary 档只回决策字段 + 逐项变更(tool+reason+资源
1772
+ // 键,去 args/baselineFingerprint)。内联完整 plan 一个真实需求 ~20KB、含基线
1773
+ // 50–60KB——探针只要「会改什么」时被整块计费。要 apply 仍用完整 plan(不带
1774
+ // --summary,或 --plan-out 写复核文件)。
1775
+ if (summary) {
1776
+ const plan = result.plan;
1777
+ if (plan !== undefined && Array.isArray(plan.changes)) {
1778
+ return emitResult({
1779
+ ...result,
1780
+ plan: undefined,
1781
+ changesBrief: plan.changes.map((change) => ({
1782
+ tool: change.tool,
1783
+ ...(change.reason !== undefined ? { reason: change.reason } : {}),
1784
+ resource: change.args?.schemaCode ?? change.args?.code ?? null,
1785
+ })),
1786
+ summaryNote: "--summary 只回变更清单(去 args/基线);apply 用完整 plan(不带 --summary 或 --plan-out <file>)",
1787
+ }, transport);
1788
+ }
1789
+ // 已外置/已写文件的分支本就是决策字段面——原样返回。
1790
+ }
1791
+ return emitResult(result, transport);
1753
1792
  }
1754
1793
  /** Ticket 120 — `omc intent readback <file> --env <env>`: decode the live baseline back into intent shape and verify equivalence. */
1755
1794
  async function cmdIntentReadback(file, environment, transport) {
@@ -2305,6 +2344,8 @@ function joinSplitFlagValues(raw, flags) {
2305
2344
  }
2306
2345
  return out;
2307
2346
  }
2347
+ /** r60b-F7:最近一次 commander 帮助输出(configureOutput 的写通道暂存)。 */
2348
+ let lastHelpChunk = "";
2308
2349
  async function main() {
2309
2350
  let commandExitCode = 0;
2310
2351
  // stderr is the diagnostics stream: apply the same Windows code-page policy
@@ -2312,6 +2353,13 @@ async function main() {
2312
2353
  installCodePageSafeStderr();
2313
2354
  beginUsage(argv);
2314
2355
  const command = new Command();
2356
+ // r60b-F7:helpDisplayed 不区分「根帮助」与「子命令帮助」——两者都走同一个
2357
+ // exitOverride 回调。暂存**累计**帮助输出(addHelpText 的 after 块晚于主帮助
2358
+ // 块单独写出,覆盖式暂存会把含 Usage 行的主块冲掉),用 Usage 行区分:
2359
+ // 子命令帮助的 Usage 是 `omc <子命令> …`,根帮助是 `omc [options] [command]`。
2360
+ const stashHelp = (text) => {
2361
+ lastHelpChunk = (lastHelpChunk + text).slice(-8000);
2362
+ };
2315
2363
  const ownPackageVersion = () => {
2316
2364
  try {
2317
2365
  // ESM 下读自身包根的 package.json(安装形态与源码形态都成立)
@@ -2330,7 +2378,7 @@ async function main() {
2330
2378
  return CLI_EXIT_CODES.invalidInput;
2331
2379
  }
2332
2380
  command.exitOverride();
2333
- command.configureOutput({ writeOut: (text) => process.stderr.write(text), writeErr: (text) => process.stderr.write(text) });
2381
+ command.configureOutput({ writeOut: (text) => { stashHelp(text); process.stderr.write(text); }, writeErr: (text) => { stashHelp(text); process.stderr.write(text); } });
2334
2382
  command.name("omc").showHelpAfterError().showSuggestionAfterError(true);
2335
2383
  // --version 短路:commander 的 version 走 process.exit,会被 exitOverride 包成
2336
2384
  // invalid-input 信封(exit 10);cpdocs --omc-global 的探测要干净的 exit 0。
@@ -2820,8 +2868,8 @@ async function main() {
2820
2868
  const intentCommand = command.command("intent");
2821
2869
  intentCommand.command("schema").option("--example [id]").action((options) => { commandExitCode = cmdIntentSchema({ request, maxOutputBytes: CLI_DEFAULT_OUTPUT_BYTES }, typeof options.example === "string" ? options.example : undefined, options.example !== undefined); });
2822
2870
  intentCommand.command("validate <file>").option("--show-intent").action((file, options) => { commandExitCode = cmdIntentValidate(file, { request, maxOutputBytes: CLI_DEFAULT_OUTPUT_BYTES }, options.showIntent === true); });
2823
- intentCommand.command("plan <file>").option("--env <environment>").option("--plan-out <file>").option("--max-output-bytes <bytes>").action(async (file, options) => {
2824
- commandExitCode = await withTransport(options, request, (transport) => cmdIntentPlan(file, options.env, options.planOut, transport));
2871
+ intentCommand.command("plan <file>").option("--env <environment>").option("--plan-out <file>").option("--summary", "只回变更清单(tool+reason+资源键,去 args/基线)——复核用;apply 仍需完整 plan").option("--max-output-bytes <bytes>").action(async (file, options) => {
2872
+ commandExitCode = await withTransport(options, request, (transport) => cmdIntentPlan(file, options.env, options.planOut, transport, options.summary === true));
2825
2873
  });
2826
2874
  intentCommand.command("apply <file>").option("--env <environment>").option("--dry-run").option("--no-verify").option("--confirm-production").option("--wait <milliseconds>", "写锁冲突时的有界排队毫秒数(同 `omc call --wait`,默认 0=立刻拒绝)").option("--max-output-bytes <bytes>").action(async (file, options) => {
2827
2875
  const waitRaw = options.wait === undefined ? 0 : Number(options.wait);
@@ -2962,7 +3010,34 @@ main().then((code) => {
2962
3010
  }, (error) => {
2963
3011
  // commander prints `--help` / `-h` usage to stderr and signals success with
2964
3012
  // this code; it is not an error and must not grow a spurious error envelope.
2965
- if (error instanceof CommanderError && error.code === "commander.helpDisplayed") {
3013
+ // `commander.help`(commander 14):showHelpAfterError 的错误上下文路径——
3014
+ // 未知命令 + `--help` 时 unknownCommand 错误被帮助输出替换成这个 code,
3015
+ // 原有 unknownCommand 分支因此永远接不到(r60b-F7 真机)。
3016
+ if (error instanceof CommanderError && (error.code === "commander.helpDisplayed" || error.code === "commander.help")) {
3017
+ // r60b-F7(真机复现):`omc configure_workflow --help` 里 commander 先短路
3018
+ // --help、后校验子命令,未知命令吃到了根帮助 + exit 0——探针一度以为
3019
+ // 命令存在只是参数没显示。根帮助(Usage: omc [options] [command])+ 非
3020
+ // help 的位置参数 = 未知命令;子命令帮助(Usage: omc <子命令>)正常 exit 0。
3021
+ const usageLine = (/^Usage:\s*omc[^\n]*/m.exec(lastHelpChunk) ?? [""])[0];
3022
+ const isRootHelp = /^Usage:\s*omc\s+\[options\]\s*\[command\]/.test(usageLine);
3023
+ const positional = argv.slice(2).filter((entry) => entry !== "--").find((entry) => !entry.startsWith("-"));
3024
+ if (isRootHelp && positional !== undefined && positional !== "help") {
3025
+ let isTool = false;
3026
+ try {
3027
+ isTool = buildToolRegistry().some((tool) => tool.name === positional);
3028
+ }
3029
+ catch {
3030
+ isTool = false;
3031
+ }
3032
+ const message = isTool
3033
+ ? `未知顶层命令 "${positional}"——它是工具名不是 CLI 子命令:形状用 omc describe ${positional}(含可运行示例),执行用 omc call ${positional} --env <env> --args '<json>'(顶层命令见 omc help commands)`
3034
+ : `未知顶层命令 "${positional}"(顶层命令见 omc help commands;工具清单 omc commands;工具形状 omc describe <tool>)`;
3035
+ const parsed = errorEnvelope(new Error(message), "invalid-input", CLI_EXIT_CODES.invalidInput, request);
3036
+ writeEnvelope(parsed.envelope);
3037
+ completeUsage(parsed.exitCode);
3038
+ finish(parsed.exitCode);
3039
+ return;
3040
+ }
2966
3041
  completeUsage(0);
2967
3042
  finish(0);
2968
3043
  return;
@@ -11,20 +11,39 @@ export function closestMatch(input, candidates) {
11
11
  const wanted = input.toUpperCase().replace(/[\s_-]/g, "");
12
12
  if (wanted.length < 2)
13
13
  return undefined;
14
+ // r60c-F6(真机复现):`contract_amount` 拼错时建议了 `contract_name`(比例距离
15
+ // 达标)而真目标是 `amount`——它是输入的**尾部 token**,三个接受形都不认。
16
+ // 加第四形:分隔符 token 相等(≥4 字符)按强信号计(距离 0),并补后缀包含。
17
+ // r60c-F6(真机复现):`contract_amount` 拼错时建议了 `contract_name`(比例距离
18
+ // 达标)而真目标是 `amount`——它是输入的**尾部 token**,三个接受形都不认。
19
+ // 加 token 覆盖形:候选的 token 全部被输入 token 解释(amount ⊆ contract_amount)
20
+ // 按强信号计(距离 0)。**只对 ≥2 个 token 的输入启用**——TEXT/DATETIME 这类
21
+ // 单 token 短输入的歧义语义(故意不猜、DATETIME→DATE 而非 TIME)保持不变。
22
+ const inputTokens = input.toUpperCase().split(/[\s_-]+/u).filter((token) => token.length >= 4);
23
+ const wantedTokens = new Set(inputTokens);
24
+ const multiTokenInput = inputTokens.length >= 2;
14
25
  let best;
15
26
  for (const name of candidates) {
16
27
  const candidate = name.toUpperCase().replace(/[\s_-]/g, "");
17
28
  // 1. prefix containment (STAFF→STAFF_SELECTOR, DATETIME→DATE)
18
29
  const contained = (candidate.startsWith(wanted) || wanted.startsWith(candidate)) && Math.min(wanted.length, candidate.length) >= 4;
30
+ // token 覆盖:候选的 token(≥4 字)全部出现在输入 token 里。部分命中
31
+ // (contract_name 只共享 CONTRACT)弱于全覆盖——平局会让先出现的候选赢。
32
+ const candidateTokens = name.toUpperCase().split(/[\s_-]+/u).filter((token) => token.length >= 4);
33
+ const matchedTokens = candidateTokens.filter((token) => wantedTokens.has(token));
34
+ const fullTokenCoverage = multiTokenInput && candidateTokens.length > 0 && matchedTokens.length === candidateTokens.length;
35
+ const partialTokenHit = multiTokenInput && matchedTokens.length > 0;
19
36
  // 2. small edit distance (NUMERIC→NUMERICAL, SHORTTEXT→SHORT_TEXT)
20
37
  const distance = editDistance(wanted, candidate);
21
38
  const nearMiss = distance <= 2;
22
39
  // 3. shared prefix + proportional distance (NUMBER→NUMERICAL, the live-measured case)
23
40
  const sharedPrefix = commonPrefixLength(wanted, candidate);
24
41
  const proportional = sharedPrefix >= 3 && wanted.length >= 5 && distance / Math.max(wanted.length, candidate.length) <= 0.58;
25
- const accepted = contained || nearMiss || proportional;
26
- if (accepted && (!best || distance < best.distance))
27
- best = { name, distance };
42
+ // 全 token 覆盖 0 < 部分 token 2 < 常规距离。
43
+ const effectiveDistance = fullTokenCoverage ? 0 : partialTokenHit ? 2 : distance;
44
+ const accepted = contained || fullTokenCoverage || partialTokenHit || nearMiss || proportional;
45
+ if (accepted && (!best || effectiveDistance < best.distance))
46
+ best = { name, distance: effectiveDistance };
28
47
  }
29
48
  return best?.name;
30
49
  }
package/dist/discovery.js CHANGED
@@ -111,24 +111,15 @@ export function commandInventory(registry, options = {}) {
111
111
  export function filterTools(registry, query) {
112
112
  return scoreTools(registry, query).map(({ name, via, score }) => ({ name, via, score }));
113
113
  }
114
- export function commandIndex(registry, options = {}) {
114
+ export function commandIndex(registry) {
115
115
  const byLane = new Map();
116
116
  for (const tool of registry) {
117
117
  const lane = tool.lane ?? "(unbound)";
118
118
  byLane.set(lane, (byLane.get(lane) ?? 0) + 1);
119
119
  }
120
120
  const lanes = [...byLane.entries()].sort((left, right) => left[0].localeCompare(right[0]));
121
- // `OMC_LEGACY_DISCOVERY=1` restores the pre-M2 face byte-for-byte (patch
122
- // rollback for 0.6.48, removed in 0.6.50 — EXECUTION-PLAN §十).
123
- if (options.legacy === true) {
124
- return {
125
- discovery: { authoritative: DISCOVERY_AUTHORITY.authoritative, route: DISCOVERY_AUTHORITY.route },
126
- toolCount: registry.length,
127
- lanes: lanes.map(([lane, tools]) => ({ lane, tools })),
128
- tools: registry.map((tool) => ({ name: tool.name, lane: tool.lane ?? null, kind: tool.kind })),
129
- hint: "裸 `commands` 是有界索引(name/lane/kind)。全量行用 `omc commands --json`;单能力用 `omc commands --json --compact --lane <lane>`;关键词用 `--filter <word>`;目标→路线优先 `omc next \"<目标>\"`。",
130
- };
131
- }
121
+ // (r61)`OMC_LEGACY_DISCOVERY` 回滚开关已按计划移除——M2 新面经 R60 三路探针
122
+ // 真机验证(plan 第一跳 8 次 / 全量目录 0 次),pre-M2 面不再保留。
132
123
  const routeCount = capabilityRouteIndex(registry).routes.length;
133
124
  return {
134
125
  discovery: { authoritative: DISCOVERY_AUTHORITY.authoritative, route: DISCOVERY_AUTHORITY.route },
@@ -507,7 +498,7 @@ const DATA_PARAMETER_NAMES = [
507
498
  * a missing param NAME costs an invalid_input round, and the R2 gate says bytes
508
499
  * must never be bought with rounds.
509
500
  */
510
- export function describeTool(registry, name, options = {}) {
501
+ export function describeTool(registry, name) {
511
502
  const tool = registry.find((entry) => entry.name === name);
512
503
  if (!tool)
513
504
  return undefined;
@@ -515,8 +506,6 @@ export function describeTool(registry, name, options = {}) {
515
506
  const { required, params } = compactParams(schema);
516
507
  const hasRecipe = (tool.executionMetadata?.recipes.length ?? 0) > 0;
517
508
  const firstCall = firstCallFor(tool);
518
- if (options.legacy === true)
519
- return legacyDescribeTool(tool, required, params, hasRecipe, firstCall);
520
509
  const recipes = tool.executionMetadata?.recipes ?? [];
521
510
  // Titles are how a caller picks among recipes; keep them while the list is
522
511
  // short, because above that the title text alone is the payload.
@@ -595,29 +584,6 @@ function leanFirstCall(firstCall) {
595
584
  readMore: firstCall.readMore,
596
585
  };
597
586
  }
598
- /** `OMC_LEGACY_DISCOVERY=1`: the pre-M2 default face, byte-for-byte. */
599
- function legacyDescribeTool(tool, required, params, hasRecipe, firstCall) {
600
- return {
601
- name: tool.name,
602
- lane: tool.lane ?? null,
603
- kind: tool.kind,
604
- summary: summarizeDescription(tool.description),
605
- required,
606
- params,
607
- examples: exampleList(tool),
608
- ...(firstCall !== undefined ? { firstCall } : {}),
609
- ...(hasRecipe ? { exampleHint: `可运行参数用 --example <id>(~1–2KB);单参数用 --param <name>;仅当二者都缺形状才 --full` } : {}),
610
- ...(!hasRecipe ? { exampleHint: `无静态 recipe:required + params 已够常规调用;单参数说明用 --param <name>;仅当需要全部参数注释/拒绝形状才 --full(5–20KB)` } : {}),
611
- ...(documentedParamNames(tool).length > 0
612
- ? { paramDocs: { available: documentedParamNames(tool), read: largeParamDocsHint(tool) } }
613
- : {}),
614
- ...(tool.paramEnums !== undefined ? { paramEnums: tool.paramEnums } : {}),
615
- ...(returnsFace(tool.name) ?? {}),
616
- ...(tool.kind === "write" ? { writeLock: "写锁=环境级:同一环境的并发写,后到的直接回 write-lock-held(不排队)。可带 --wait <ms> 让 CLI 内部排队(CLI 开关,不是本工具参数);不要写 shell 重试循环" } : {}),
617
- ...(tool.name.startsWith("data.") ? { parameterNames: DATA_PARAMETER_NAMES } : {}),
618
- full: `omc describe ${tool.name} --full(5–20KB;先试 --example/--param)`,
619
- };
620
- }
621
587
  /** Param names whose schema entry carries a `.describe()` (documented params). */
622
588
  function documentedParamNames(tool) {
623
589
  const shape = (tool.inputSchema ?? {});
package/dist/goal-plan.js CHANGED
@@ -82,6 +82,27 @@ async function planReadAsk(registry, goal, environment, options, base, match, ca
82
82
  });
83
83
  continue;
84
84
  }
85
+ // c-F12(r60c-F12,r61):点名对象在环境里**不存在**(rows 有但全不匹配)——
86
+ // 这是「替代口径需人裁决」的岔路,不是「从清单里选一个」。非交互 agent
87
+ // 没有提问通道,blocker 必须自带可复制的问句 + 互斥选项,让它能被当
88
+ // 「待裁决项」交回(探针 r60c-Q5 曾被迫两条路都跑:76 次 rule.list)。
89
+ if (hint.trim() !== "") {
90
+ // 问句短语截到「这类/的」为止(「差旅申请这类模型的单据…」→「差旅申请」),
91
+ // 问句要可辨识,不要整句复读。
92
+ const namedPhrase = hint.trim().replace(/(?:这类|这种|这些|一样的).*$/, "").replace(/的.*$/, "").slice(0, 16) || hint.trim().slice(0, 16);
93
+ blockers.push({
94
+ type: "needs-decision",
95
+ param: key,
96
+ reason: `目标句点名的「${namedPhrase}」在本环境不匹配任何模型(现有 ${rows.length} 个)——替代口径需人裁决`,
97
+ question: `「${namedPhrase}」在本环境不存在。要怎么处理?`,
98
+ options: [
99
+ `按最接近的现有模型替代回答(候选:${rows.slice(0, 3).map((row) => row.code).join("、")})`,
100
+ `全量扫 ${rows.length} 个模型的对应面(逐模型调用,输出全集)`,
101
+ `就报「不存在」,不做替代`,
102
+ ],
103
+ });
104
+ continue;
105
+ }
85
106
  ambiguities.push({ param: key, candidates: rows.slice(0, 10), question: "目标句里没有能对上平台的模型,选哪个?" });
86
107
  continue;
87
108
  }
@@ -98,14 +119,25 @@ async function planReadAsk(registry, goal, environment, options, base, match, ca
98
119
  // Query SEMANTICS: `data.list {schemaCode}` is schema-valid and would run, but it
99
120
  // returns the whole table — not what 「金额大于一万」 asked for. `ready=true` must
100
121
  // not overclaim, so a stated condition with no filter set is a missing input.
122
+ // r60c-F5:reason 回显**问句原文里的条件短语**(≤24 字窗口),不再硬编码
123
+ // 「金额大于一万」——问 10 万回一万,agent 只能再跑一次真调用验证语义。
101
124
  const statesCondition = /大于|小于|等于|超过|低于|介于|不等|包含|开头|结尾|为空|不为空|等于|是\s|不是|>|<|>=|<=|=/.test(goal);
102
125
  const hasFilterValue = ["filter", "filters", "filterGroup", "query", "rawCondition"].some((key) => args[key] !== undefined);
103
126
  if (statesCondition && !hasFilterValue) {
104
127
  const target = ["filter", "filters", "filterGroup"].find((key) => key in tool.inputSchema);
105
128
  if (target !== undefined) {
129
+ // P0-4b(r60c-F5 复验发现):20 字符前置窗口**硬截会把 token 撕裂**——
130
+ // 「crm_contract 里 contract_amount 大于」回显成「t 里 contract_amount 大于」,
131
+ // 谜语回显等于没回显。先试「分隔符定界」形(短语以空白/标点边界开始,
132
+ // 取到完整 token),无分隔符的纯中文短句再回退自由形。尾窗排除「的」,
133
+ // 让「…的单据有哪些」不进窗口(.replace 兜底保留)。
134
+ const conditionWindow = goal.match(/[\s;;,,。、((][^\s;;,,。、((]{1,24}\s*(?:大于|小于|等于|超过|低于|介于|不等|包含|为空|不为空)[^;;,,。的]{0,12}/) ??
135
+ goal.match(/[^;;,,。]{0,20}(?:大于|小于|等于|超过|低于|介于|不等|包含|为空|不为空|>|<|>=|<=|=)[^;;,,。的]{0,12}/);
136
+ const conditionEcho = conditionWindow !== null ? conditionWindow[0].trim().replace(/\s*的.*$/u, "") : "问句里的筛选条件";
137
+ const rangeOp = /大于|超过|>|>=|低于|小于|</.test(conditionEcho);
106
138
  missing[target] = {
107
- reason: "问句里有筛选条件,但 filter DSL 需要把「金额大于一万」翻译成 {op,field,value};本计划不替你猜字段 code 与取值语义",
108
- source: `omc describe ${tool.name} --example ${tool.executionMetadata?.recipes[0]?.id ?? "<recipe>"}`,
139
+ reason: `问句里有筛选条件,但 filter DSL 需要把「${conditionEcho}」翻译成 {op,field,value}(${rangeOp ? "大于/超过→gt、大于等于→gte、低于/小于→lt" : "等值→eq、包含→like、为空→isnull"},op 全表:eq/neq/gt/lt/gte/lte/like/notlike/in/notin/between/notbetween/isnull/isnotnull);本计划不替你猜字段 code 与取值语义`,
140
+ source: `omc describe ${tool.name} --example ${rangeOp ? "list-filter-equality(等值示例;op 换成上面对应的比较符即可)" : tool.executionMetadata?.recipes[0]?.id ?? "<recipe>"}`,
109
141
  };
110
142
  }
111
143
  }
@@ -199,6 +231,50 @@ function collectPlaceholders(value, path = "") {
199
231
  walk(value, path);
200
232
  return out;
201
233
  }
234
+ /**
235
+ * r60b-F4/F5(真机复现):配方示例值不是 `<...>` 模板,collectPlaceholders 认不出,
236
+ * 于是以**具体值**混进 steps 且 validated.ok=true——「给模型 r60b_leave 配两级审批流」
237
+ * 的 plan 里 s1 get_draft 拿着占位 workflowCode "purchaseWorkflow"、s3 的
238
+ * schemaCode 是 "omc_recipe_model"、participant.corpId 写死 "other"(真实 corpId 是
239
+ * 租户 id,照抄会写进已发布流程且 get_published 肉眼难发现)。扫描已编译步骤,
240
+ * 命中残留的 step 标 needsSubstitution:true 并产 warnings;不拦截 ready(有些
241
+ * 残留对存量环境恰好成立),但绝不静默放行。
242
+ */
243
+ const RECIPE_EXAMPLE_RESIDUE = Object.freeze([
244
+ { pattern: /purchaseWorkflow/, note: "purchaseWorkflow 是配方示例流程 code,本环境需换成真实/新建的流程 code" },
245
+ { pattern: /^SYS_1000000$/, note: "SYS_1000000 是配方示例角色 code,用 org.role.list 取真实角色" },
246
+ { pattern: /"corpId"\s*:\s*"other"/, note: "participant.corpId 写死 \"other\"——真实 corpId 取自 org.role.list 回执(照抄会写入错误 corpId)" },
247
+ { pattern: /<[a-zA-Z][^<>]{2,60}>/, note: "串内占位符 <…>(如 <roleId-from-org.role.list>)——执行前用真实值替换" },
248
+ { pattern: /omc_recipe_/, note: "omc_recipe_* 是配方占位模型 code,需先建模型再替换" },
249
+ ]);
250
+ function markRecipeResidue(steps) {
251
+ const warnings = [];
252
+ const marked = steps.map((step) => {
253
+ const hits = [];
254
+ const walk = (node, at) => {
255
+ if (typeof node === "string") {
256
+ for (const residue of RECIPE_EXAMPLE_RESIDUE)
257
+ if (residue.pattern.test(node))
258
+ hits.push(`${at || "(root)"}=${node.length > 40 ? `${node.slice(0, 40)}…` : node}(${residue.note})`);
259
+ return;
260
+ }
261
+ if (Array.isArray(node)) {
262
+ node.forEach((entry, index) => walk(entry, `${at}[${index}]`));
263
+ return;
264
+ }
265
+ if (node !== null && typeof node === "object") {
266
+ for (const [key, entry] of Object.entries(node))
267
+ walk(entry, at === "" ? key : `${at}.${key}`);
268
+ }
269
+ };
270
+ walk(step.args, "");
271
+ if (hits.length === 0)
272
+ return step;
273
+ warnings.push(`${step.id} ${step.tool} 含配方示例值残留(执行前必须替换):${hits.slice(0, 4).join(";")}${hits.length > 4 ? `;等 ${hits.length} 处` : ""}`);
274
+ return { ...step, needsSubstitution: true };
275
+ });
276
+ return [marked, warnings];
277
+ }
202
278
  /**
203
279
  * Type-appropriate sample for a placeholder, used ONLY to run the local schema
204
280
  * gate: the plan must prove the shape is otherwise valid, without pretending the
@@ -864,6 +940,9 @@ export async function planGoal(registry, goal, options = {}) {
864
940
  const blockers = [];
865
941
  const probes = [];
866
942
  let probeFailure;
943
+ // b-F1(r60b-F1):问句点名「建模型 X」而 X 不存在时,建模不是拦路 blocker 而
944
+ // 是计划的第一步——s0 脚手架(model.create + field.publish),后续步骤照常用 X。
945
+ let scaffold;
867
946
  // ---- resolve one slot at a time -------------------------------------------------
868
947
  for (const [key, value] of Object.entries(rawArgs)) {
869
948
  // The environment is never a probe: `--env` already is the answer, and the
@@ -972,6 +1051,20 @@ export async function planGoal(registry, goal, options = {}) {
972
1051
  if (!needsValue) {
973
1052
  ambiguities.push({ param: key, candidates: rows.slice(0, 10), question: `配方示例值「${hints[0]}」在本环境不存在,选哪个 ${key}?` });
974
1053
  }
1054
+ else if (key === "schemaCode" && outcome.reason === "model-not-found" && scaffold === undefined &&
1055
+ /(?:建|新建|创建|搭建).{0,8}模型/.test(goal) &&
1056
+ scaffoldCodeFrom(goal) !== undefined) {
1057
+ // b-F1:多步链路的发现成本不能全落在人身上——「建 X 并配 Y」被 Y 的配方
1058
+ // 命中而 X 不存在时,老行为只回 blocker(探针被迫另起两轮找建模入口)。
1059
+ // 插 s0 建模脚手架,主步骤照常编译;字段清单是需求本体(needs-authoring
1060
+ // 语义),计划不猜——warning 指路 field.create。code 取问句里的 ASCII
1061
+ // 标识(hintCandidates 只出中文短语,认不出 r60b_leave 这类 code)。
1062
+ const scaffoldCode = scaffoldCodeFrom(goal);
1063
+ scaffold = { code: scaffoldCode };
1064
+ args[key] = scaffoldCode;
1065
+ warnings.push(`schemaCode: 目标模型 ${scaffoldCode} 尚不存在——已排 s0 建模脚手架(model.create + field.publish 模型级一次发布);业务字段清单按需求补 field.create(本计划不猜字段)`);
1066
+ continue;
1067
+ }
975
1068
  else {
976
1069
  blockers.push({ type: "blocked", param: key, reason: outcome.reason ?? "平台无匹配" });
977
1070
  }
@@ -1033,7 +1126,7 @@ export async function planGoal(registry, goal, options = {}) {
1033
1126
  kind: tool.kind === "write" ? "write" : "read",
1034
1127
  purpose: recipe.title,
1035
1128
  args,
1036
- dependsOn: [...dependencies],
1129
+ dependsOn: scaffold !== undefined ? [...dependencies, "s0p"] : [...dependencies],
1037
1130
  validated,
1038
1131
  dryRun: dryRunFor(tool.name, args, tool),
1039
1132
  ...(() => {
@@ -1049,7 +1142,36 @@ export async function planGoal(registry, goal, options = {}) {
1049
1142
  const uncertain = probeFailure !== undefined;
1050
1143
  // Uncertain ⇒ NOTHING executable. The risk the review called out: a plan that
1051
1144
  // half-resolved ids still looks runnable, and a write lands against the wrong model.
1052
- const compiled = uncertain ? [] : [...priorCompiled.steps, mainStep];
1145
+ // b-F1(r60b-F1):scaffold 在最前——model.create(命名沿用问句原词)→ field.publish
1146
+ // (模型级一次发布),主步骤与 priors 的 dependsOn 声明指向 s0。
1147
+ const modelCreateTool = registry.find((entry) => entry.name === "model.create");
1148
+ const fieldPublishTool = registry.find((entry) => entry.name === "field.publish");
1149
+ const scaffoldStepCreate = scaffold === undefined || modelCreateTool === undefined
1150
+ ? undefined
1151
+ : {
1152
+ id: "s0",
1153
+ tool: "model.create",
1154
+ kind: "write",
1155
+ purpose: "b-F1 前置链:问句点名新建的模型不存在——建模是计划第一步(字段清单按需求补 field.create)",
1156
+ args: { ...(environment !== null ? { environment } : {}), name: scaffold.code, code: scaffold.code },
1157
+ dependsOn: [],
1158
+ validated: { ok: true, issues: [] },
1159
+ dryRun: { supported: true, command: `omc call model.create --dry-run --args '{"name":"${scaffold.code}","code":"${scaffold.code}"}'` },
1160
+ };
1161
+ const scaffoldStepPublish = scaffold === undefined || fieldPublishTool === undefined
1162
+ ? undefined
1163
+ : {
1164
+ id: "s0p",
1165
+ tool: "field.publish",
1166
+ kind: "write",
1167
+ purpose: "b-F1 前置链:模型级发布(发布全部草稿字段;流程/视图/规则面依赖已发布字段)",
1168
+ args: { ...(environment !== null ? { environment } : {}), schemaCode: scaffold.code },
1169
+ dependsOn: ["s0"],
1170
+ validated: { ok: true, issues: [] },
1171
+ dryRun: { supported: true, command: `omc call field.publish --dry-run --args '{"schemaCode":"${scaffold.code}"}'` },
1172
+ };
1173
+ const scaffoldSteps = [scaffoldStepCreate, scaffoldStepPublish].filter((step) => step !== undefined);
1174
+ const compiled = uncertain ? [] : [...scaffoldSteps, ...priorCompiled.steps, mainStep];
1053
1175
  // M4-2: dependencies are declared, so the order must be PROVEN, not assumed.
1054
1176
  const sorted = topoSort(compiled);
1055
1177
  if (sorted.cycle !== undefined) {
@@ -1066,6 +1188,9 @@ export async function planGoal(registry, goal, options = {}) {
1066
1188
  };
1067
1189
  }
1068
1190
  const steps = attachCaptures(sorted.ordered);
1191
+ // r60b-F4/F5:配方示例值残留标认(详见 PlanStep.needsSubstitution 注释)。
1192
+ const [markedSteps, residueWarnings] = markRecipeResidue(steps);
1193
+ warnings.push(...residueWarnings);
1069
1194
  const ready = !uncertain
1070
1195
  && Object.keys(missing).length === 0
1071
1196
  && Object.keys(unverified).length === 0
@@ -1095,7 +1220,7 @@ export async function planGoal(registry, goal, options = {}) {
1095
1220
  ...(capability !== undefined ? { capability } : {}),
1096
1221
  ...(lane !== undefined ? { lane } : {}),
1097
1222
  ...(intentAlternative !== undefined ? { intentAlternative } : {}),
1098
- steps,
1223
+ steps: markedSteps,
1099
1224
  missing,
1100
1225
  unverified,
1101
1226
  warnings,
@@ -1171,6 +1296,19 @@ function hintFromGoal(goal, rawArgs) {
1171
1296
  * Several candidates are returned because the ask may name the object loosely;
1172
1297
  * the caller tries each against the platform's rows and takes the first unique hit.
1173
1298
  */
1299
+ /**
1300
+ * b-F1(r60b-F1):从问句提取「点名要新建的模型 code」。hintCandidates 只出
1301
+ * 中文短语,认不出 `r60b_leave` 这类 ASCII code——这里取问句里最长的 ASCII
1302
+ * 标识词,排除配方占位(omc_recipe_*)。无 ASCII 标识 → undefined(不成脚手架)。
1303
+ */
1304
+ export function scaffoldCodeFrom(goal) {
1305
+ const codes = [...goal.matchAll(/[A-Za-z][A-Za-z0-9_]{2,39}/g)]
1306
+ .map((match) => match[0])
1307
+ .filter((code) => !code.startsWith("omc_recipe_"));
1308
+ if (codes.length === 0)
1309
+ return undefined;
1310
+ return codes.reduce((best, code) => (code.length > best.length ? code : best));
1311
+ }
1174
1312
  export function hintCandidates(goal) {
1175
1313
  const quoted = goal.match(/[「"]([^」"]{2,20})[」"]/);
1176
1314
  const out = [];
@@ -12,7 +12,7 @@ import { listSkills, readSkillSection } from "./skills.js";
12
12
  */
13
13
  const SCOUT_CUES = ["能不能", "能不能够", "能否", "是否支持", "支持吗", "支持不支持", "可不可以", "有没有办法", "有没有可能", "怎么实现", "如何实现", "怎么写", "怎么配置"];
14
14
  const MODIFY_CUES = ["修改", "调整", "更新", "重命名", "改名", "编辑", "删除", "去掉", "移除", "改为", "改成"];
15
- const READ_CUES = ["查看", "读回", "盘点", "现状", "列出", "有哪些", "有没有", "检查", "审计", "导出", "只读", "看看", "看下", "查一下", "查询一下", "查一查", "梳理", "清点", "给我一份", "哪些", "是什么", "是否", "是否正确", "现有", "已有"];
15
+ const READ_CUES = ["查看", "读回", "盘点", "现状", "列出", "有哪些", "有没有", "检查", "审计", "导出", "只读", "看看", "看下", "查一下", "查询一下", "查一查", "梳理", "清点", "给我一份", "哪些", "是什么", "是否", "是否正确", "现有", "已有", "条数", "多少条", "数一下"];
16
16
  const BUILD_CUES = ["新建", "创建", "搭建", "从零", "从无到有", "做", "建", "加", "实现", "生成", "新增", "保存", "启用", "录入", "添加", "造", "填报", "打卡", "录"];
17
17
  /** Whole-application asks — a single-model atom is the wrong shape for these. */
18
18
  const WHOLE_APP_CUES = ["应用", "系统", "整套", "从零", "从无到有", "端到端", "一条龙", "一整套", "业务应用", "平台"];
@@ -744,6 +744,42 @@ function goalRouteInner(registry, goal) {
744
744
  const availableTopics = new Set(listSkills().map((topic) => topic.name));
745
745
  const mode = detectMode(goal);
746
746
  const readish = mode === "read" || mode === "scout";
747
+ // r60c-F8(真机复现):「按状态分组统计单据条数」被 cue「分组」误路由到 app
748
+ // 写面(app.create/update/delete,write:true)——纯读问句拿到写工具是危险误路由。
749
+ // 聚合/计数问句的正确答案:data 能力**没有 group-by 工具**,诚实指路
750
+ // data.list 拉全量 + `--jq` 投影自行计数;跨模型/大结果集才涉及报表章节。
751
+ // 放在能力打分前,聚合词不再落进任何写阶梯(cue「分组」已从 app 移除)。
752
+ if (readish && /(统计|分组|汇总|聚合|计数|条数|多少条|数一下)/.test(goal) && !WRITE_DESTINATION.test(goal)) {
753
+ const dataRoute = routeById.get("data");
754
+ if (dataRoute !== undefined) {
755
+ const readTools = readToolsInLane(registry, dataRoute.lane);
756
+ const action = readTools.includes("data.list") ? "omc call data.list --args '{\"schemaCode\":\"<模型code>\",\"size\":200}' --jq '.result.items[]'" : "omc commands --capability data";
757
+ return {
758
+ status: "ok",
759
+ goal,
760
+ confident: true,
761
+ mode: "read",
762
+ write: false,
763
+ match: { kind: "capability", ref: "data", title: "运行数据(聚合/计数读路径)", capabilities: ["data"] },
764
+ route: {
765
+ capability: "data",
766
+ lane: dataRoute.lane,
767
+ note: "平台没有 group-by/聚合工具:小结果集用 data.list 拉全量(filter 收窄 + --jq 投影取分组列)后自行计数;跨模型汇总/定时聚合才涉及 report 章节或字段计算(datarule type2)。本路由只读。",
768
+ readTools,
769
+ readiness: DISCOVERY_AUTHORITY.readiness,
770
+ firstCommands: [action],
771
+ write: false,
772
+ readback: true,
773
+ },
774
+ firstAnswer: {
775
+ state: "needs-input",
776
+ question: "要统计哪个模型(schemaCode 或业务名)?按哪个字段分组?",
777
+ action,
778
+ why: "聚合/计数是纯读问句:data 能力无 group-by 工具,data.list 拉全量 + --jq 投影后本地计数是正路(大结果集见 report 章节)",
779
+ },
780
+ };
781
+ }
782
+ }
747
783
  // Known absence only: field-families exposes list/create/update/publish/delete,
748
784
  // with no unpublish endpoint or update status bit (local 1.1.25 probe, 2026-11-11).
749
785
  // Do not infer other absences from tool names: rollback is a top-level command,
@@ -832,7 +868,20 @@ function goalRouteInner(registry, goal) {
832
868
  // 触发词面:条件必填/必填条件/条件显隐/显示条件/隐藏条件/条件只读/只读条件 +
833
869
  // 配置/设置/改成/修改/加上 等写动词,或直接点名 requiredFormula/displayFormula/
834
870
  // readonlyCondition。不提「子表/控件」(那是上一条表单 attributes 的专项路由)。
871
+ // r60a-F1/F2(真机复现):这些 modify 专项路由此前会劫持**整包 build** 问句——
872
+ // 「建模型 …detail 子表(item/qty/price);…列表视图显示…;建字段级规则…」里
873
+ // 「子表…显示…规则」跨三个子句被 /子表.*显示.*规则/ 串成一次命中,整包需求
874
+ // 被当成「改已有表单控件」路由(steps:[],还要一个不存在的 schemaCode)。
875
+ // 护栏一:绿地/整包 build 问句(建模型/新建应用/从零…)不进 modify 专项。
876
+ // 护栏二:关键词必须**同子句**出现(子句内无分隔符、跨度 ≤30 字),
877
+ // 不允许跨「;/,/。」把不同需求缝到一起。
878
+ const greenfieldBuildAsk = /建模型|新建模型|创建模型|搭建|从零|从无到有|一条龙|端到端/.test(goal);
879
+ const clauseLocal = (pattern) => {
880
+ const source = pattern.replace(/\.\*/g, "[^;;,,。]{0,30}");
881
+ return new RegExp(source);
882
+ };
835
883
  if (!/子表/.test(goal)
884
+ && !greenfieldBuildAsk
836
885
  && !/查看|有哪些|是什么|怎么|列出|看看|查询|检查|确认/.test(goal)
837
886
  && (/条件必填|必填条件|条件显隐|显隐条件|显示条件|条件显示|隐藏条件|条件隐藏|条件只读|只读条件|requiredFormula|displayFormula|readonlyCondition/.test(goal))
838
887
  && /配置|设置|改成|修改|加上|加一个|做个|做一|变必填|控制|当.*时/.test(goal)) {
@@ -863,7 +912,7 @@ function goalRouteInner(registry, goal) {
863
912
  },
864
913
  };
865
914
  }
866
- if (/子表|控件/.test(goal) && /子表.*(显示|隐藏|只读|显隐).*(条件|公式|规则)|displayFormula|readonlyFormula/.test(goal)) {
915
+ if (!greenfieldBuildAsk && /子表|控件/.test(goal) && (clauseLocal("子表.*(显示|隐藏|只读|显隐).*(条件|公式|规则)").test(goal) || /displayFormula|readonlyFormula/.test(goal))) {
867
916
  return {
868
917
  status: "ok",
869
918
  goal,
@@ -893,7 +942,14 @@ function goalRouteInner(registry, goal) {
893
942
  // r28c F2: authored recipe aliases beat composers. A short goal like
894
943
  // "按比例赋值" has no capability cue and would otherwise fall through;
895
944
  // "条件成立时按公式赋值" would be stolen by the rule-when composer.
896
- if (!readish) {
945
+ // "按比例赋值" has no capability cue and would otherwise fall through;
946
+ // "条件成立时按公式赋值" would be stolen by the rule-when composer.
947
+ // r31c-F27 回归护栏(r60 P1-11 引入):**显式整包措辞**(从零/一条龙/一整套…)
948
+ // 的问句不能被单配方别名抢走——一条配方代表不了其余能力面。只看
949
+ // WHOLE_APP_CUES 而不用「≥4 能力面」:单配方措辞(「配一条 Create 规则:
950
+ // 调服务按客户名查信用回写」)天然扫过 模型/规则/服务 多个能力面,按面数拦
951
+ // 会把真别名路由也拦掉(bizservice-recipes 别名测试实证)。
952
+ if (!readish && !WHOLE_APP_CUES.some((cue) => goal.includes(cue))) {
897
953
  const aliasHit = bestAliasRecipe(registry, goal);
898
954
  if (aliasHit) {
899
955
  const action = `omc describe ${aliasHit.tool} --example ${aliasHit.recipe}`;
@@ -74,6 +74,12 @@ function expectedFieldOptions(schemaCode, field) {
74
74
  * (observed 2026-09-27: `field.list` briefly reported options:null for a row
75
75
  * that had them, and the final readback called the intent equivalent) is
76
76
  * reported as converged — the agent then discovers it at runtime instead.
77
+ *
78
+ * r60a-F8 guard: the expected side is what the WRITE SEAM would send. When a
79
+ * declared key is absent from that projection (seam drops it — e.g. the
80
+ * CHILD_TABLE parent row carries no options at all) the old null==null
81
+ * comparison called the intent equivalent while nothing landed. Such keys now
82
+ * emit `field-option-unwritable` instead of comparing two nulls.
77
83
  */
78
84
  function compareFieldOptions(schemaCode, field, live, emit) {
79
85
  const keys = declaredOptionKeys(field);
@@ -82,6 +88,13 @@ function compareFieldOptions(schemaCode, field, live, emit) {
82
88
  const resource = `field:${schemaCode}.${field.code}`;
83
89
  const expected = expectedFieldOptions(schemaCode, field);
84
90
  const liveOptions = (live.options ?? {});
91
+ // r60a-F8 防假等价:声明的 options 键若写入缝根本不会发送(expected 缺该键,
92
+ // 或整形状被写缝拒绝 → expected undefined),「声明了但没落地」不能判等价——
93
+ // 此前 expected/live 双 null 相等,把静默丢键当成了已达标。
94
+ if (expected === undefined) {
95
+ emit.difference("field-option-unwritable", resource, `字段 ${resource} 声明了 options(${keys.join("、")}),但写入缝拒绝该形状(族形状校验未过)——声明不会落地,readback 不判等价`);
96
+ return;
97
+ }
85
98
  for (const key of keys) {
86
99
  if (key === "optionsSet") {
87
100
  const customCodes = (value) => {
@@ -94,6 +107,10 @@ function compareFieldOptions(schemaCode, field, live, emit) {
94
107
  emit.difference("field-options-mismatch", resource, `字段 ${resource} 的 choices 与 live 不一致(live=${canonicalJson(got)} intent=${canonicalJson(want)})`);
95
108
  continue;
96
109
  }
110
+ if (!(key in expected)) {
111
+ emit.difference("field-option-unwritable", resource, `字段 ${resource} 声明了 options.${key},但写入缝不会发送该键(子表父行/族形状不接受)——声明不会落地;门户条件走表单面(form.draft 改控件 attributes 后 form.publish)`);
112
+ continue;
113
+ }
97
114
  if (canonicalJson(expected?.[key] ?? null) !== canonicalJson(liveOptions[key] ?? null))
98
115
  emit.difference("field-options-mismatch", resource, `字段 ${resource} 的 options.${key} 与 live 不一致(live=${canonicalJson(liveOptions[key] ?? null)} intent=${canonicalJson(expected?.[key] ?? null)})`);
99
116
  }
@@ -365,6 +382,13 @@ export const fieldCapability = {
365
382
  if (relationField && relativeValue === undefined && !(optionsNode?.kind === "map" && toPlain(optionsNode).relativeCode !== undefined))
366
383
  pushError(ctx, "intent-field-relativecode-required", `关联字段(${fieldType})必须给 relativeCode(目标模型 code);可写在字段顶层或 options.relativeCode`, `${fieldBase}.relativeCode`, "value");
367
384
  const explicitOptions = optionsNode?.kind === "map" ? toPlain(optionsNode) : {};
385
+ // r60a-F8(真机实测):CHILD_TABLE 父行的 options 在写入缝被整体丢弃
386
+ // (prepareFieldChange 子表分支返回 options:{},wire body 不带 options 键),
387
+ // 而 readback 的 expected 同样为空 → null==null 假等价。离线拒绝,
388
+ // 并把真正可行的通道(表单 attributes 面)写进消息。
389
+ if (fieldType === "CHILD_TABLE" && Object.keys(explicitOptions).length > 0) {
390
+ pushError(ctx, "intent-field-option-unsupported", `子表字段(CHILD_TABLE)父行不接受 options(声明了 ${Object.keys(explicitOptions).join("、")})——平台建列时整体丢弃,且 readback 判等会漏检(r60a-F8)。门户条件(requiredFormula/readonlyFormula/displayFormula)走表单面:form.get --controls 读 draftAttributesJson 定位控件 → form.draft 改该控件 → form.publish;子表**列级** options 写在各子列的 options`, `${fieldBase}.options`, "value");
391
+ }
368
392
  // A choice family's allowed values live in TOP-LEVEL `choices` (the
369
393
  // compiler synthesizes the platform's optionsSet). Callers habitually
370
394
  // try `options.items` / `options.choices`, which the option passthrough
@@ -43,16 +43,23 @@ export function intentWarnings(intent) {
43
43
  // control had no requiredFormula; the live portal did not require it). The
44
44
  // portal-facing condition must be declared in `fields[].options`.
45
45
  for (const datarule of model.datarules ?? []) {
46
- if ([3, 4, 5].includes(datarule.dataRuleType))
46
+ const field = model.fields.find((candidate) => candidate.code === datarule.propertyCode);
47
+ if ([3, 4, 5].includes(datarule.dataRuleType)) {
48
+ // r60a-F11(真机复现):propertyCode 是 CHILD_TABLE 父字段时,下面那句
49
+ // 「写到 fields[].options」是死路——子表父行不接受 options(写入缝整体
50
+ // 丢弃,readback 还会假等价,r60a-F8)。按字段类型分叉给真通道。
51
+ const childTableTarget = field?.type === "CHILD_TABLE";
47
52
  warnings.push({
48
53
  resource: `datarule:${model.code}.${datarule.propertyCode}`,
49
54
  code: "datarule-not-portal-facing",
50
- message: `字段级数据规则 type ${datarule.dataRuleType}(${datarule.dataRuleType === 4 ? "条件必填" : datarule.dataRuleType === 5 ? "条件只读" : "文本拼接"})不驱动门户表单控件:平台把它存成 bizdatarule、只镜像进控件 historyOpt,而运行时门户读控件 options(真机复核:规则已存但发布控件无该字段、门户不拦)。要让门户生效,把条件写到字段的 options 里(fields[].options.requiredFormula / readonlyCondition / shortTextStitch)——这条路径已真机验证可穿透到发布控件;datarule 只留给服务端字段级引擎(校验/计算)。`,
55
+ message: childTableTarget
56
+ ? `字段级数据规则 type ${datarule.dataRuleType}(${datarule.dataRuleType === 4 ? "条件必填" : datarule.dataRuleType === 5 ? "条件只读" : "文本拼接"})不驱动门户表单控件;且 ${datarule.propertyCode} 是子表(CHILD_TABLE)父字段——fields[].options 对子表父行**不生效**(写入缝丢弃,真机 r60a-F8)。门户条件走表单 attributes 面:form.get --controls 读 draftAttributesJson 定位控件 → form.draft 改该控件的 requiredFormula/readonlyFormula/displayFormula → form.publish。`
57
+ : `字段级数据规则 type ${datarule.dataRuleType}(${datarule.dataRuleType === 4 ? "条件必填" : datarule.dataRuleType === 5 ? "条件只读" : "文本拼接"})不驱动门户表单控件:平台把它存成 bizdatarule、只镜像进控件 historyOpt,而运行时门户读控件 options(真机复核:规则已存但发布控件无该字段、门户不拦)。要让门户生效,把条件写到字段的 options 里(fields[].options.requiredFormula / readonlyCondition / shortTextStitch)——这条路径已真机验证可穿透到发布控件;datarule 只留给服务端字段级引擎(校验/计算)。`,
51
58
  });
59
+ }
52
60
  // Dual-write advisory (dogfood R1): when the SAME field already declares
53
61
  // the portal-facing condition in `fields[].options`, the datarule row is
54
62
  // redundant. Surface it rather than silently writing both.
55
- const field = model.fields.find((candidate) => candidate.code === datarule.propertyCode);
56
63
  const fieldOptions = field?.options ?? {};
57
64
  const duplicateKey = datarule.dataRuleType === 4 ? "requiredFormula" : datarule.dataRuleType === 5 ? "readonlyCondition" : undefined;
58
65
  if (duplicateKey !== undefined && fieldOptions[duplicateKey] !== undefined)
@@ -64,6 +64,29 @@ export const RUNNABLE_EXAMPLES = Object.freeze([
64
64
  "",
65
65
  ].join("\n"),
66
66
  },
67
+ {
68
+ id: "child-table-subfields",
69
+ title: "子表 CHILD_TABLE(subFields 声明子列;父字段不接受 options——r60a-F8 真机,控件条件走 form.draft)",
70
+ yaml: [
71
+ "intentVersion: 1",
72
+ "models:",
73
+ " - code: exClaim",
74
+ " name: 报销单",
75
+ " fields:",
76
+ " - { code: claimNo, name: 单号, type: SHORT_TEXT }",
77
+ " - { code: amount, name: 金额, type: NUMERICAL, options: { scale: 2 } }",
78
+ " - code: detail # 子表父字段:只声明 code/name/type/subFields",
79
+ " name: 明细",
80
+ " type: CHILD_TABLE",
81
+ " subFields:",
82
+ " - { code: item, name: 项目, type: SHORT_TEXT }",
83
+ " - { code: qty, name: 数量, type: NUMERICAL, options: { scale: 0 } }",
84
+ " - { code: price, name: 单价, type: NUMERICAL, options: { scale: 2 } }",
85
+ " form: { publish: true }",
86
+ " listview: { fieldCodes: [claimNo, amount] } # 子表列不进列表视图",
87
+ "",
88
+ ].join("\n"),
89
+ },
67
90
  {
68
91
  id: "rule-actions-when-filter",
69
92
  title: "规则紧凑 actions:一条规则可挂多个异构 action;when=执行门(满足才执行,只支持字面量比较),filter=定位要改的行(省略则默认当前行 id=id),跨模型回写用 filter from",
@@ -120,7 +143,7 @@ export function intentSchemaBlock() {
120
143
  "choices 只用于选择族 RADIO / CHECKBOX / DROPDOWN_BOX / DROPDOWN_MULTI_BOX(顶层 choices,不是 options.items/choices)",
121
144
  "WORK_SHEET / MULT_WORK_SHEET 用顶层 relativeCode=<目标模型 code>;显示列用 options.displayField",
122
145
  "CHILD_TABLE 用 subFields[{code,name,type[,choices]}]; 子列族仅标量",
123
- "门户层条件(必填/只读/显示)写在 options:options.requiredFormula / readonlyFormula / readonlyCondition / displayFormula",
146
+ "门户层条件(必填/只读/显示)写在 options:options.requiredFormula / readonlyFormula / readonlyCondition / displayFormula;**子表(CHILD_TABLE)父字段例外**——不接受 options(写入缝丢弃,r60a-F8 真机),子表控件的条件走 form.get --controls → form.draft → form.publish",
124
147
  ],
125
148
  },
126
149
  form: { required: ["publish"], optional: ["fieldCodes"] },
@@ -162,6 +162,15 @@ export function registerBusinessRuleLane(tools) {
162
162
  statusNote: "本面 status 是 PUBLISH 投影列,与 rule.get 的 ruleStatus 可不同;运行时是否生效以 rule.get/enable 为准",
163
163
  }),
164
164
  ...(args.onlyCustom === true ? { filtered: { onlyCustom: true, total: rows.length, returned: visible.length } } : {}),
165
+ // r60c-F7(真机复现):默认面把 7 条平台预置触发行一起返回——任何模型都
166
+ // 「有规则」,「哪些模型配了业务规则」会误判成全都有。默认面带上
167
+ // customCount + 一句判定口径;判定自建规则直接 onlyCustom:true。
168
+ ...(args.onlyCustom !== true
169
+ ? {
170
+ customCount: rows.filter((row) => row.defaultRule !== true).length,
171
+ presetHint: "默认含平台预置触发行(preset:true,如 Available/Cancel/Create/Delete/GetList/Load/Update);判定「有没有人写过规则」看 customCount(=0 即全是预置),或直接 onlyCustom:true",
172
+ }
173
+ : {}),
165
174
  ...(endpointFamily ? { endpointFamily } : {}),
166
175
  rules: visible.map((row) => ({
167
176
  code: row.code,
@@ -333,6 +333,12 @@ export function registerFieldLane(tools) {
333
333
  inputSchema: { environment: environmentArg, schemaCode: z.string(), published: z.boolean().default(false), code: z.string().optional(), fields: z.array(z.string()).optional(), full: z.boolean().optional().describe("行内联完整 options/subSchema;默认清单面只有 code/name/type/typeName(+conditions 信号/shapeWarning),验证 options 用 code/fields 选择器或 full:true;平台读面带回 propertyEmpty 时一并输出(不回则省略,不塞 false)"), all: z.boolean().optional().describe("默认只返业务字段(过滤 SYSTEM_FIELD_CODES 的 13 个平台字段:id/name/sequenceNo/createdTime/creater/sequenceStatus/…);true 连系统字段一起返"), capability: capabilityArg },
334
334
  handler: async (ctx, args, self) => governedRead(ctx, self, args, async (session) => {
335
335
  const rows = wireRows((await wireCall(session, { path: ENDPOINTS.fieldList, query: { schemaCode: args.schemaCode, isPublish: args.published ? "true" : "false" } })).data);
336
+ // r61 a-F9(r60a-F9):draft 面此前不报字段的发布态,行级缺 published 键
337
+ // 被读成「未发布」(null 三态歧义:未发布 vs 本面不返回)。多拉一次发布面
338
+ // code 集做行级双面比对——agent 一次清单就能回答「这个字段发布了吗」,
339
+ // 不必再跑 published:true 交叉核对。
340
+ const publishedCodes = new Set(wireRows((await wireCall(session, { path: ENDPOINTS.fieldList, query: { schemaCode: args.schemaCode, isPublish: "true" } })).data)
341
+ .map((row) => String(row.code ?? row.propertyCode)));
336
342
  const mapped = rows.map((row) => {
337
343
  const type = Number(row.type ?? row.propertyType);
338
344
  const typeLabel = fieldTypeLabel(row.type ?? row.propertyType);
@@ -345,6 +351,9 @@ export function registerFieldLane(tools) {
345
351
  return {
346
352
  code: fieldCode,
347
353
  name: row.name,
354
+ // r61 a-F9:行级发布态(双面比对)——true=已出现在发布面;false=仅草稿。
355
+ // 面级 `face` 是查询面选择器,与此行级键不同义。
356
+ published: publishedCodes.has(String(fieldCode)),
348
357
  ...(redundantNameI18n(row.name_i18n, row.name) ? {} : typeof row.name_i18n === "string" ? { name_i18n: row.name_i18n } : {}),
349
358
  type: row.type ?? row.propertyType,
350
359
  ...(typeLabel !== undefined ? { typeName: typeLabel } : {}),
@@ -411,6 +420,9 @@ export function registerFieldLane(tools) {
411
420
  type: field.type,
412
421
  ...(field.typeName !== undefined ? { typeName: field.typeName } : {}),
413
422
  ...(field.name !== undefined ? { name: field.name } : {}),
423
+ // r61 a-F9:inventory 面也带行级发布态(双面比对真值,一次清单
424
+ // 回答「这个字段发布了吗」)。
425
+ ...(field.published !== undefined ? { published: field.published } : {}),
414
426
  // Inventory answers "which columns did I author?" — system
415
427
  // columns are reported as a count, not mixed into the list.
416
428
  ...(businessCodes !== undefined ? { subColumnCodes: businessCodes } : {}),
@@ -434,6 +446,9 @@ export function registerFieldLane(tools) {
434
446
  // r45: 这是"本次查询的面选择器"回显(draft/published),不是字段发布状态——
435
447
  // 曾被误读为"字段未发布"。改名 face 消歧义;要查发布态用 field.publish 回读或详情面。
436
448
  face: args.published === true ? "published" : "draft",
449
+ // r61 a-F9:行级 `published`(true/false)是双面比对出的**字段发布态**;
450
+ // `face` 只是本次查询的面选择器——两键不同义,别再拿 face 推断发布态。
451
+ publishedNote: "行级 published=该字段是否已出现在发布面(双面比对);face=本次查询面(draft/published),不是字段发布态",
437
452
  ...(selector.length > 0 ? { selected: selector } : {}),
438
453
  ...(args.all !== true ? { businessOnly: true } : {}),
439
454
  fields: projected,
@@ -490,6 +505,8 @@ export function registerFieldLane(tools) {
490
505
  type: field.type,
491
506
  ...(field.typeName !== undefined ? { typeName: field.typeName } : {}),
492
507
  ...(field.name !== undefined ? { name: field.name } : {}),
508
+ // r61 a-F9:选择器面同样保留行级发布态(双面比对真值)。
509
+ ...(field.published !== undefined ? { published: field.published } : {}),
493
510
  ...(Array.isArray(field.subColumns) ? { subColumns: field.subColumns } : {}),
494
511
  ...(conditions.length > 0 ? { conditions } : {}),
495
512
  ...(field.shapeWarning !== undefined ? { shapeWarning: field.shapeWarning } : {}),
@@ -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: "(**列汇总**:数值列 `sumType` wire 为整数——0=不统计/1=求和/2=平均/3=最小/4=最大/5=计数,写进 presentation.columnsJson 的列对象,8.6.26 反编译 SumType 实证)配置列表视图(code 指向**自定义业务视图**——业务展示用 listview.create 建的自定义视图,**不在系统自动生成的默认视图(code=schemaCode)上配业务列/筛选**;仅当明确要改默认视图时才省略 code)。在既有(默认)列表视图上配置列、排序、查询条件、行/列表按钮、呈现、自定义按钮、视图头扩展选项与视图类型:读回 query,按 `fieldCodes` 追加缺失列或**原地修正**已存在列的 name/propertyType/displayFormat/visible(不再跳过既有列),置为可见;数值列 displayFormat 由字段 0 基 `options.scale` 推导(0=整数,1=1位,2=2位,3=3位…8=8位;实测 scale 2 → displayFormat 3 = 两位小数)、日期列由 `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 字符串解码;写后条件回读等价校验给出 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` 后回读(`query/get` 自动注入的默认动作、平台 sortKey 重排与 schemaRelations 派生需还原)。`code` 省略时用默认视图(=schemaCode)。`queryConditionMap` 为只读派生(query/get 带 formCode 子表条件时才出现),非配置输入。**发布语义**:`query/update` 自动置 publish=TRUE——视图无草稿/发布两态、无需独立发布步骤(与表单/规则的 draft→publish 不同)。**依赖顺序**:视图与表单脚手架都依赖**已发布字段**,规范顺序 model.create → field.create → field.publish(模型级)→ form.draft → form.publish → listview.create(自定义业务视图)→ listview.configure(code 指向它)→ rule.save → rule.enable → workflow。",
129
+ description: "(**列汇总**:数值列 `sumType` wire 为整数——0=不统计/1=求和/2=平均/3=最小/4=最大/5=计数,写进 presentation.columnsJson 的列对象,8.6.26 反编译 SumType 实证)配置列表视图。**code 语义(与配方 configure-default-list 同口径,r60a-F13 真机对齐 2026-11-13)**:省略 `code`(或 code=schemaCode)= 配置**默认视图**——默认视图在 model.create 时由平台自动生成、是正规的配置对象,日常配列/排序就用它,**不要先 listview.create**(那会多出一个自定义视图);`listview.create` 只在确实需要**第二个**视图时使用,此时 listview.configure 带 code 指向它。在既有(默认)列表视图上配置列、排序、查询条件、行/列表按钮、呈现、自定义按钮、视图头扩展选项与视图类型:读回 query,按 `fieldCodes` 追加缺失列或**原地修正**已存在列的 name/propertyType/displayFormat/visible(不再跳过既有列),置为可见;数值列 displayFormat 由字段 0 基 `options.scale` 推导(0=整数,1=1位,2=2位,3=3位…8=8位;实测 scale 2 → displayFormat 3 = 两位小数)、日期列由 `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 字符串解码;写后条件回读等价校验给出 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` 后回读(`query/get` 自动注入的默认动作、平台 sortKey 重排与 schemaRelations 派生需还原)。`code` 省略时用默认视图(=schemaCode)。`queryConditionMap` 为只读派生(query/get 带 formCode 子表条件时才出现),非配置输入。**发布语义**:`query/update` 自动置 publish=TRUE——视图无草稿/发布两态、无需独立发布步骤(与表单/规则的 draft→publish 不同)。**依赖顺序**:视图与表单脚手架都依赖**已发布字段**,规范顺序 model.create → field.create → field.publish(模型级)→ form.draft → form.publish →(需要第二视图时 listview.create)→ listview.configure → rule.save → rule.enable → workflow。",
130
130
  }),
131
131
  "listview.delete": Object.freeze({
132
132
  scope: LIST_VIEW_SCOPE,
@@ -814,12 +814,29 @@ export function registerListViewLane(tools) {
814
814
  }
815
815
  const after = await wireCall(session, { path: ENDPOINTS.listQueryGet, query: { schemaCode: args.schemaCode, code, clientType: "PC" } });
816
816
  const afterModel = (after.data ?? {});
817
+ // r61 a-F14(r60a-F14 真机定性):`queryColumns` 列树**不回 sumType**(投影恒
818
+ // null),列汇总真值在呈现层 `queryPresentation.columnsJson`——写入面也是它。
819
+ // 两面各说各话曾让探针为对账「合计配上了吗」拉全量 presentation(26KB
820
+ // artifact 的根因)。这里把真值按 propertyCode 合并进列投影,单面即可对账;
821
+ // 仅当呈现层该列无 sumType 时才回退列树值(保持 null=不统计的可读性)。
822
+ const sumTypeByCode = new Map();
823
+ const rawPresentation = afterModel.queryPresentation;
824
+ if (rawPresentation && typeof rawPresentation === "object") {
825
+ const decodedColumns = decodePresentation(rawPresentation).columnsJson;
826
+ if (Array.isArray(decodedColumns)) {
827
+ for (const column of decodedColumns) {
828
+ if (column && typeof column === "object" && typeof column.propertyCode === "string" && typeof column.sumType === "number") {
829
+ sumTypeByCode.set(String(column.propertyCode), column.sumType);
830
+ }
831
+ }
832
+ }
833
+ }
817
834
  const afterCols = readArray(afterModel, "queryColumns").map((c) => ({
818
835
  propertyCode: c.propertyCode,
819
836
  propertyType: c.propertyType,
820
837
  displayFormat: c.displayFormat ?? null,
821
838
  visible: c.visible ?? null,
822
- sumType: c.sumType ?? null,
839
+ sumType: sumTypeByCode.get(String(c.propertyCode)) ?? c.sumType ?? null,
823
840
  }));
824
841
  const sorts = readArray(afterModel, "querySorts")
825
842
  .map(decodeSortRow)
@@ -645,15 +645,20 @@ async function personFieldShapeViolations(session, schemaCode, formData) {
645
645
  */
646
646
  async function portalRequiredViolations(session, schemaCode, sheetCode, formData) {
647
647
  const sheet = ((await wireCall(session, { path: ENDPOINTS.sheetGet, query: { schemaCode, sheetCode } })).data ?? {});
648
- const face = typeof sheet.publishedAttributesJson === "string" ? sheet.publishedAttributesJson : typeof sheet.draftAttributesJson === "string" ? sheet.draftAttributesJson : undefined;
648
+ // r61 a-F15(r60a-F15):空数组有三态歧义——「表单无必填」「必填面读不到」
649
+ // 「必填但都填了」全回 []。探测面不可得时明说,别让 agent 把「读不到」
650
+ // 当「无必填」而跳过校验。
651
+ const publishedJson = typeof sheet.publishedAttributesJson === "string" ? sheet.publishedAttributesJson : undefined;
652
+ const draftJson = typeof sheet.draftAttributesJson === "string" ? sheet.draftAttributesJson : undefined;
653
+ const face = publishedJson ?? draftJson;
649
654
  if (!face)
650
- return { requiredFields: [], missingRequired: [] };
655
+ return { requiredFields: [], missingRequired: [], requiredFace: "unavailable" };
651
656
  let parsed;
652
657
  try {
653
658
  parsed = JSON.parse(face);
654
659
  }
655
660
  catch {
656
- return { requiredFields: [], missingRequired: [] };
661
+ return { requiredFields: [], missingRequired: [], requiredFace: "unavailable" };
657
662
  }
658
663
  const requiredFields = Object.entries(parsed)
659
664
  .filter(([, control]) => control?.options?.required === true || typeof control?.options?.requiredFormula === "string")
@@ -662,7 +667,7 @@ async function portalRequiredViolations(session, schemaCode, sheetCode, formData
662
667
  const value = formData[code];
663
668
  return value === null || value === undefined || (typeof value === "string" && value.trim() === "");
664
669
  });
665
- return { requiredFields, missingRequired };
670
+ return { requiredFields, missingRequired, requiredFace: publishedJson !== undefined ? "published" : "draft" };
666
671
  }
667
672
  /** 提交面:formData 里出现任何非空人员字段值即返回(issue#10:两种形状都可能 50000,可靠链路是提交省略)。 */
668
673
  async function staffFieldsPresent(session, schemaCode, formData) {
@@ -1188,8 +1193,40 @@ export function registerRuntimeDataLane(tools) {
1188
1193
  const catalog = await publishedFields();
1189
1194
  const codes = catalog.map((row) => row.code);
1190
1195
  const sample = catalog.slice(0, FILTER_FIELD_SAMPLE_LIMIT);
1196
+ // r60c-F6(真机复现):`contract_amount` 拼错 + `gt` 过滤时建议了
1197
+ // `contract_name`(SHORT_TEXT)——名字最像,类型全错,照抄得到类型错
1198
+ // 或空结果。didYouMean 按「名字相似 × 类型匹配」重排:数值比较族
1199
+ // op(gt/lt/gte/lte/between)优先推 NUMERICAL/DATE 字段。
1200
+ const opByField = new Map();
1201
+ const walkLeaves = (node) => {
1202
+ if (Array.isArray(node)) {
1203
+ node.forEach(walkLeaves);
1204
+ return;
1205
+ }
1206
+ if (node === null || typeof node !== "object")
1207
+ return;
1208
+ const leaf = node;
1209
+ if (typeof leaf.field === "string" && leaf.field && typeof leaf.op === "string")
1210
+ opByField.set(leaf.field, String(leaf.op).toLowerCase());
1211
+ Object.values(leaf).forEach(walkLeaves);
1212
+ };
1213
+ walkLeaves(condition);
1214
+ const NUMERIC_OPS = new Set(["gt", "lt", "gte", "lte", "between", "notbetween"]);
1215
+ const NUMERICISH_TYPES = new Set([2, 3]); // NUMERICAL, DATE
1191
1216
  const didYouMean = Object.fromEntries(injected.missing
1192
- .map((code) => [code, closestMatch(code, codes)])
1217
+ .map((code) => {
1218
+ let suggestion = closestMatch(code, codes);
1219
+ const op = opByField.get(code);
1220
+ if (suggestion !== undefined && op !== undefined && NUMERIC_OPS.has(op)) {
1221
+ const suggestedType = catalog.find((row) => row.code === suggestion)?.type;
1222
+ if (suggestedType !== undefined && !NUMERICISH_TYPES.has(suggestedType)) {
1223
+ const typeMatched = catalog.find((row) => NUMERICISH_TYPES.has(row.type) && closestMatch(code, [row.code]) === row.code);
1224
+ if (typeMatched !== undefined)
1225
+ suggestion = typeMatched.code;
1226
+ }
1227
+ }
1228
+ return [code, suggestion];
1229
+ })
1193
1230
  .filter((entry) => entry[1] !== undefined));
1194
1231
  const didYouMeanHint = Object.entries(didYouMean).map(([from, to]) => `;${from} 是否想写 ${to}`).join("");
1195
1232
  // r26b 读回体积审计(2026-11-05):目录此前在**同一个信封里被写三遍**
@@ -2168,7 +2205,7 @@ export function registerRuntimeDataLane(tools) {
2168
2205
  `确要在提交携带人员字段(个别平台构建接受),显式带 allowStaffOnSubmit:true 自担。`,
2169
2206
  });
2170
2207
  }
2171
- const validation = await portalRequiredViolations(session, args.schemaCode, sheetCode, args.formData ?? {}).catch(() => ({ requiredFields: [], missingRequired: [] }));
2208
+ const validation = await portalRequiredViolations(session, args.schemaCode, sheetCode, args.formData ?? {}).catch(() => ({ requiredFields: [], missingRequired: [], requiredFace: "unavailable" }));
2172
2209
  // Directive: a workflow-backed model's submit must START the workflow, not
2173
2210
  // merely save a sheet row. When the caller names no workflow params, detect
2174
2211
  // the model's workflow and start it (formType=1 + workflowCode); a model
@@ -2670,11 +2707,26 @@ export function registerRuntimeDataLane(tools) {
2670
2707
  portalRulesNote: "portalRulesExecuted 只指门户客户端的必填/控件校验未在 REST 提交时执行;服务端业务规则(含流程 end 规则)照常运行。",
2671
2708
  requiredFields: validation.requiredFields,
2672
2709
  missingRequired: validation.missingRequired,
2710
+ requiredFace: validation.requiredFace,
2711
+ ...(validation.requiredFace === "unavailable"
2712
+ ? {
2713
+ requiredFieldsNote: "requiredFields:[] 是「必填面读不到」(sheetGet 未回 published/draftAttributesJson——模型未配自定义表单时常态),**不是「无必填」**:平台门户必填可能仍拦截运行时提交。要真值用 form.get --controls 读表单面。",
2714
+ }
2715
+ : {}),
2673
2716
  ...(validation.missingRequired.length > 0
2674
2717
  ? {
2675
2718
  portalValidationWarning: `已提交但**未执行门户必填校验**:${validation.missingRequired.join("、")} 在发布表单里是必填,本次 formData 为空/缺省。REST runtime/form/submit 不跑门户客户端校验;如需真正阻断,请在提交前自行校验,或在服务端规则里加必填约束。`,
2676
2719
  }
2677
2720
  : {}),
2721
+ // r61 a-F16(r60a-F16):无 id 提交=平台隐式 INSERT 新行——回执此前不
2722
+ // 区分「新建了一行」和「推进已有行」,对账(期望 N 条 vs 实际 N+1 条)
2723
+ // 只能靠 data.list 复核。显式点名新建路径,新行 id 就在 readback.objectId。
2724
+ ...(!hasWorkItem && args.bizObjectId === undefined
2725
+ ? {
2726
+ createdRow: true,
2727
+ createdNote: "无 id/workItem 提交=新建并提交(一调完成):本次 INSERT 了新记录行,readback.objectId 即新行 id。更新已有行用 data.save(带 id)或审批链 data.submit(带 workItemId)。",
2728
+ }
2729
+ : {}),
2678
2730
  // Round 16b (dogfood R1-R3): a submit can leave BOTH a draft row and a
2679
2731
  // committed row, and deleting only the committed id leaves the draft
2680
2732
  // behind (data.list still counts it). Name both ids so cleanup does not
@@ -108,7 +108,7 @@ const workflowConditionalTwoLevel = Object.freeze({
108
108
  id: "workflow-conditional-two-level-approval",
109
109
  title: "金额>阈值走两级审批,否则一级(分叉再汇合)",
110
110
  status: "requires-prior-readback",
111
- aliases: ["两级审批", "条件两级", "金额大于", "一级或两级", "分叉再汇合"],
111
+ aliases: ["两级审批", "条件两级", "金额大于", "一级或两级", "分叉再汇合", "条件审批", "条件分支", "按条件审批", "条件流程"],
112
112
  tool: "workflow.update",
113
113
  args: {
114
114
  environment,
@@ -85,6 +85,12 @@ const TOOL_INPUT_ALIASES = Object.freeze({
85
85
  "workflow.update": Object.freeze({ code: ["workflowCode"] }),
86
86
  "workflow.publish": Object.freeze({ code: ["workflowCode"] }),
87
87
  "workflow.delete": Object.freeze({ code: ["workflowCode"] }),
88
+ // r60b-F6(真机复现):同一个流程 code 写面叫 `code`、读面叫 `workflowCode`——
89
+ // `workflow.update` 刚成功,紧随的 `workflow.get_published` 就把同一字段名拒了
90
+ // (tool-input-unknown-keys)。读面把 `code` 归一成 `workflowCode`(这两个读面
91
+ // 没有自己的 `code` 参数,无歧义)。
92
+ "workflow.get_draft": Object.freeze({ workflowCode: ["code"] }),
93
+ "workflow.get_published": Object.freeze({ workflowCode: ["code"] }),
88
94
  // field family: the platform's own column key is `propertyCode`; the tool's is
89
95
  // `code`. Same field, so the alias is safe either direction.
90
96
  "field.create": Object.freeze({ code: ["propertyCode"] }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stalfh233/omc-cli",
3
- "version": "0.6.49",
3
+ "version": "0.6.51",
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.49",
59
+ "omc-core": "0.6.51",
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.49"
77
+ "@stalfh233/omc-fake-platform": "0.6.51"
78
78
  }
79
79
  }
@@ -206,6 +206,7 @@ only the section for the capability you need —
206
206
 
207
207
  - **能做哪些事**:业务记录列出、加载、保存、更新、删除、提交(工作流)。
208
208
  - **工具**:`data.list`、`data.load`、`data.save`、`data.update`、`data.delete`、`data.submit`
209
+ - **聚合/分组/计数(10 秒答案)**:`data.*` **没有 group-by/聚合工具**——小结果集(≤几百条)用 `data.list` 拉 filter 收窄后的全量 + `--jq '.result.items[].fields.<分组列>'` 投影,本地计数即可;跨模型汇总/大结果集/定时聚合才涉及 report 章节或字段计算(datarule type2 / formula 聚合),**不要**为「数一下条数」引入 report(r60c-F11 真机 2026-11-13:统计问句的正路一句话就该给全)。
209
210
  - **recipe**:
210
211
  - `omc describe data.save --example workflow-backed-data-save`
211
212
  - `omc describe data.submit --example workflow-backed-data-submit`(有流程)
@@ -94,7 +94,7 @@ omc help omc-write-hazards
94
94
  ## 子表
95
95
 
96
96
  - 一个主表可以有多个 `CHILD_TABLE`,子表不能嵌套 `CHILD_TABLE`。
97
- - **子表控件(type 201)的显示/只读条件(displayFormula/readonlyFormula)不在字段面**:`field.update` 对子表父控件必拒(只管子表**列**)。可行路径是表单 attributes:`form.get --controls` 读 `draftAttributesJson` 定位控件 → `form.draft` 改该控件条件 → `form.publish`(`omc next "子表控件显示条件"` 已路由到该链)。
97
+ - **子表控件(type 201)的显示/只读/必填条件(displayFormula/readonlyFormula/requiredFormula)不在字段面**:`field.update` 对子表父控件必拒(只管子表**列**);intent 的 `fields[].options` 对子表父行同样**不生效**(写入缝整体丢弃且 readback 曾假等价,r60a-F8 真机 2026-11-13)。可行路径是表单 attributes:`form.get --controls` 读 `draftAttributesJson` 定位控件(attributes 形如 `{控件code:{key,type,options}}`)→ `form.draft` 改该控件 `options` 里的条件键(三个键名:`requiredFormula`/`readonlyFormula`/`displayFormula`)→ `form.publish`(`omc next "子表控件显示条件"` 已路由到该链)。改 attributes 用 `--args-file` 落完整 JSON 后整串传入,不要在 shell 里内联转义。
98
98
  - **直调 `runtime/form/save` 更新既有记录时主键放 `data.id`**:`bizObject.bizObjectId` 不被保存逻辑识别——接口仍回 `errcode:0` 但 `objectId` 是**新 id**(静默新增孤儿数据,券商 issue 2026-10-27 实证 2 条)。用 `omc call data.update` 则无此坑(`bizObjectId` 在顶层参数位)。
99
99
  - 子列是子表字段 code 对应 schema 上的普通字段:
100
100