@stalfh233/omc-cli 0.8.14 → 0.8.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/artifacts.js CHANGED
@@ -77,8 +77,9 @@ export function isWithinRoot(root, candidate) {
77
77
  /**
78
78
  * Resolve a WRITE target inside the configuration root (mirrors
79
79
  * assertSafeInputPath's containment rule, but the file need not exist yet).
80
- * `omc intent plan --plan-out` uses it so the written plan is readable by
81
- * `omc intent apply`, which enforces the same root.
80
+ * `omc intent plan --plan-out` uses it so the written plan is a normal file in
81
+ * the config root (the plan itself is a CLI product; `intent apply` also accepts
82
+ * plan files from outside the root, e.g. a `--out` envelope in /tmp).
82
83
  *
83
84
  * Issue 06(retro 2026-11-19):Windows 用户拿系统 temp 被拒后不知道往哪写——
84
85
  * ① 越界拒绝时错误直接给出根内**可用的绝对示例路径**(`<root>/artifacts-out/<原名>`),
@@ -6,6 +6,21 @@ import { isWithinRoot } from "./artifacts.js";
6
6
  import { asciiStdout, serializeEnvelope } from "./cli-contract.js";
7
7
  import { currentUsageCommand, priorRepeatedFailures, recordUsageOutput } from "./usage-log.js";
8
8
  let options = { quiet: false, verbose: false };
9
+ /**
10
+ * Probe I F1/F2(0.8.15):`--out` 是全局的「完整信封落盘」开关,stdout 只回
11
+ * `{out,bytes}` 小回执——调用方看不出落盘文件能不能直接用。由知道产物语义的
12
+ * 命令(如 `intent plan`)挂一句下一步,回执即可自解释。一次性消费(同
13
+ * noteOutProjection),避免同进程多次写回串味。
14
+ */
15
+ let outReceiptHint;
16
+ export function setOutReceiptHint(hint) {
17
+ outReceiptHint = hint;
18
+ }
19
+ function takeOutReceiptHint() {
20
+ const hint = outReceiptHint;
21
+ outReceiptHint = undefined;
22
+ return hint;
23
+ }
9
24
  let outProjectionNote;
10
25
  /** 记录一次「`--out` + 投影」的组合;下一个 writeEnvelope 消费它。 */
11
26
  export function noteOutProjection(note) {
@@ -262,6 +277,7 @@ export function writeEnvelope(value) {
262
277
  // 一次性消费:投影说明只属于**本次**调用,任何后续 writeEnvelope(批量/复合
263
278
  // 命令同进程多次写回)都必须回到既有的 `--out` 语义。
264
279
  const projection = takeOutProjection();
280
+ const receiptHint = takeOutReceiptHint();
265
281
  // `--out-file`(issue 2026-11-18 §08.2):完整信封以 raw UTF-8 原子落盘,
266
282
  // stdout 只回小回执。它在 compactForOutput 之前分叉——文件里必须是**完整**
267
283
  // 信封(status/requestId/error 都在),stdout 的小回执固定保留 status。
@@ -330,6 +346,7 @@ export function writeEnvelope(value) {
330
346
  ? {}
331
347
  : { jqNote: `投影值 ${inlineBytes}B 超过 stdout 预算 ${projection.budget}B:完整投影已写入 --out 文件(stdout 只回指针),要看值请读该文件或缩小 --jq 路径;要放大回执用 --max-output-bytes` }),
332
348
  },
349
+ ...(receiptHint !== undefined ? { hint: receiptHint } : {}),
333
350
  };
334
351
  const receiptText = serializeEnvelope(receipt);
335
352
  recordUsageOutput(value, Buffer.byteLength(receiptText, "utf8"), projectedBytes);
@@ -345,10 +362,12 @@ export function writeEnvelope(value) {
345
362
  result: { out: options.outFile, bytes: Buffer.byteLength(pretty, "utf8") },
346
363
  requestId: envelopeValue.requestId ?? null,
347
364
  error: envelopeValue.error ?? null,
365
+ ...(receiptHint !== undefined ? { hint: receiptHint } : {}),
348
366
  }
349
367
  : {
350
368
  ok: envelopeValue.ok ?? true,
351
369
  result: { out: options.outFile, bytes: Buffer.byteLength(pretty, "utf8") },
370
+ ...(receiptHint !== undefined ? { hint: receiptHint } : {}),
352
371
  };
353
372
  const confirmationText = serializeEnvelope(confirmation);
354
373
  recordUsageOutput(value, Buffer.byteLength(confirmationText, "utf8"), Buffer.byteLength(pretty, "utf8"));
package/dist/cli.js CHANGED
@@ -24,8 +24,9 @@ import { cmdProgrammingAdopt, cmdProgrammingApply, cmdProgrammingPull, cmdProgra
24
24
  import { environmentWritable, requiresProductionConfirmation } from "./environment-policy.js";
25
25
  import { CLI_EXIT_CODES, asciiStdout, classifyResult, envelope, errorEnvelope, humanUtf8, installCodePageSafeStderr, refusalText, requestId } from "./cli-contract.js";
26
26
  import { ownsStdout } from "./cli-stdout.js";
27
+ import { installStdoutPipeGuard } from "./stdout-pipe.js";
27
28
  import { formatDoctorHumanSummary, unsupportedCapabilities } from "./version-family-gaps.js";
28
- import { beginWriteFace, configureOutput, endWriteFace, humanSummary, maybeWarnMergedStreams, noteOutProjection, stripOutputFlags, writeEnvelope } from "./cli-output.js";
29
+ import { beginWriteFace, configureOutput, endWriteFace, humanSummary, maybeWarnMergedStreams, noteOutProjection, outputOptions, setOutReceiptHint, stripOutputFlags, writeEnvelope } from "./cli-output.js";
29
30
  import { beginUsage, completeUsage, currentUsageArgsDigest, ensureProjectIgnore, priorIdenticalSuccess, recordUsageOutput, usageReport } from "./usage-log.js";
30
31
  import { artifactFetchHint, artifactRoot, boundResult, emitInvalid, emitResult, emitThrown, emitTransportResult, outputBudget, readArtifact, withTransport, } from "./command-transport.js";
31
32
  import { CLI_DEFAULT_OUTPUT_BYTES, assertSafeOutputPath, pruneArtifacts } from "./artifacts.js";
@@ -34,7 +35,7 @@ import { closeWritableWindow, openWritableWindow, parseWritableTtl, sweepWritabl
34
35
  import { artifactPathMissHint, nullProjectionHint, PATH_MISS_HELP_REF, UNSUPPORTED_JQ_OBJECT_HINT, partialPathMissHint, pathMissCopyableHint, pathMissCopyablePaths, pathMissCrossFaceCorrection, pathMissDidYouMean, projectJsonPath, projectJsonPathFanout, projectResultExtract, shapeOf, SHAPE_MAX_DEPTH, unwrapSinglePathProjection } from "./path-projection.js";
35
36
  import { isUncertainWireError } from "./support.js";
36
37
  import { containerKeyOf } from "./read.js";
37
- import { basename, dirname, join, resolve } from "node:path";
38
+ import { dirname, join, resolve } from "node:path";
38
39
  import { existsSync, readFileSync, writeFileSync, chmodSync, mkdirSync } from "node:fs";
39
40
  import { buildToolRegistry } from "./tools.js";
40
41
  import { parseDurationMs } from "./duration.js";
@@ -58,7 +59,7 @@ import { SEARCH_MARGIN_THRESHOLD } from "./tool-search.js";
58
59
  import { commandCapabilitySlice, commandIndex, commandInventory, commandKindIndex, describeContract, describeContractFull, describeContractTool, describeExample, describeParam, describeSchemaOnly, describeTool, describeToolFull, filterTools } from "./discovery.js";
59
60
  import { locatorMetaFor } from "./read-shapes.js";
60
61
  import { surfaceRefFor } from "./surface-ref.js";
61
- import { KEY_ALIAS_HINTS, inputAliasSynonymKeys } from "./tool-types.js";
62
+ import { KEY_ALIAS_HINTS, TOOL_KEY_ALTERNATIVES, inputAliasSynonymKeys } from "./tool-types.js";
62
63
  import { repeatFullDescribe } from "./describe-cache.js";
63
64
  import { buildCapabilityOverview, capabilityCandidatesFor, capabilityDetail, capabilityRouteForTool, capabilityRouteIndex, compactCapabilities, executableCapabilityBundle, resolveCapabilityId, DISCOVERY_AUTHORITY } from "./capability-overview.js";
64
65
  import { goalRoute } from "./goal-routes.js";
@@ -719,10 +720,12 @@ async function cmdCall(store, args) {
719
720
  console.error(message);
720
721
  // The MACHINE envelope must carry the same actionable text: agents read
721
722
  // stdout, and the old envelope only repeated the English detail.
722
- // Keep the REJECTED path on stderr only: the machine envelope must not leak
723
- // host layout (ticket 103), so it carries the root plus the bare file name.
724
- const rejectedName = typeof argsFile === "string" ? basename(resolve(configRoot, argsFile)) : "";
725
- writeEnvelope({ ...envelope("error", {}, request, { code: "invalid-input", message: outOfRoot ? `--args-file 必须位于配置根内(配置根 ${configRoot}${rejectedName ? `;本次文件 ${rejectedName}` : ""})。免落盘替代:--args - 从 stdin 读 JSON(echo '<json>' | omc call <tool> --args -),或把文件放进配置根后再引用;限制是为了防参数文件携带凭据被收进会话产物` : argsFile !== undefined && /must be a JSON object/.test(detail) ? `${detail};批量数组请改用 --args-list(最多 200 条,可分批执行)` : detail, retryable: false, ...(outOfRoot ? { configurationRoot: configRoot } : {}) }), resultMeta: accountMeta() });
723
+ // Keep the FULL path the caller passed (resolved) in the envelope: the bare
724
+ // file name read like a relative path and sent the caller looking in cwd
725
+ // (F3, 0.8.15 probe I). The resolved path is the caller's own input, not a
726
+ // leaked host layout (ticket 103); it is what they must move into the root.
727
+ const rejectedPath = typeof argsFile === "string" ? resolve(configRoot, argsFile) : "";
728
+ writeEnvelope({ ...envelope("error", {}, request, { code: "invalid-input", message: outOfRoot ? `--args-file 必须位于配置根内(配置根 ${configRoot}${rejectedPath ? `;本次文件 ${rejectedPath}` : ""})。免落盘替代:--args - 从 stdin 读 JSON(echo '<json>' | omc call <tool> --args -),或把文件放进配置根后再引用;限制是为了防参数文件携带凭据被收进会话产物` : argsFile !== undefined && /must be a JSON object/.test(detail) ? `${detail};批量数组请改用 --args-list(最多 200 条,可分批执行)` : detail, retryable: false, ...(outOfRoot ? { configurationRoot: configRoot } : {}) }), resultMeta: accountMeta() });
726
729
  return CLI_EXIT_CODES.invalidInput;
727
730
  }
728
731
  const registry = buildToolRegistry();
@@ -803,8 +806,13 @@ async function cmdCall(store, args) {
803
806
  const otherUnknown = unknownKeys.filter((key) => !APP_SCOPE_ARG_KEYS.has(key));
804
807
  if (tool.kind !== "write" && otherUnknown.length > 0) {
805
808
  if (!lenientArgs) {
809
+ // 探针 J F4/F5:可执行替代由 TOOL_KEY_ALTERNATIVES 提供(tool+key 显式
810
+ // 登记),替代出现在 suggestions[].replaceWith/hint/nextCommand;没有
811
+ // 登记的键沿用旧口径({key} 只表「被拒」,不编造改名——见 0.8.4 C1)。
806
812
  const suggestions = otherUnknown.map((key) => ({ key, ...suggestArgumentKey(key, [...schemaKeys], toolName) }));
807
813
  const pairs = suggestions.map((entry) => {
814
+ if (entry.replaceWith !== undefined)
815
+ return `${entry.key}→${entry.replaceWith}${entry.hint !== undefined ? `(${entry.hint})` : ""}`;
808
816
  if (entry.hint)
809
817
  return `${entry.key}(${entry.hint})`;
810
818
  if (entry.closest)
@@ -813,6 +821,7 @@ async function cmdCall(store, args) {
813
821
  return `${entry.key}(本工具没有 ${entry.absentInTool})`;
814
822
  return entry.key;
815
823
  });
824
+ const explicitNext = suggestions.find((entry) => entry.nextCommand !== undefined)?.nextCommand;
816
825
  const result = {
817
826
  status: "error",
818
827
  blocker: "tool-input-unknown-keys",
@@ -823,14 +832,18 @@ async function cmdCall(store, args) {
823
832
  // describe),脚本可零解析消费。
824
833
  expectedKeys: [...schemaKeys],
825
834
  suggestions,
826
- // 有拼写近邻时直达该参数的 describe;否则退回整份参数表。
827
- ...(suggestions.some((entry) => entry.closest !== undefined)
828
- ? { nextCommand: `omc describe ${toolName} --param ${suggestions.find((entry) => entry.closest !== undefined).closest}` }
829
- : { nextCommand: `omc describe ${toolName}` }),
835
+ // 显式替代(探针 J)优先给可复制命令;其次有拼写近邻时直达该参数的
836
+ // describe;否则退回整份参数表。
837
+ ...(explicitNext !== undefined
838
+ ? { nextCommand: explicitNext }
839
+ : suggestions.some((entry) => entry.closest !== undefined)
840
+ ? { nextCommand: `omc describe ${toolName} --param ${suggestions.find((entry) => entry.closest !== undefined).closest}` }
841
+ : { nextCommand: `omc describe ${toolName}` }),
830
842
  message: `读面不接受未知键(与写面对齐):${pairs.join("、")}。` +
831
843
  // C1(0.8.4):没有可信的改写建议时,不编造改名——直接把该工具的
832
- // 真实参数名列出来,让人按名字挑。
833
- `${suggestions.every((entry) => entry.closest === undefined && entry.hint === undefined && entry.absentInTool === undefined) ? `本工具的真实参数:${[...schemaKeys].join("、")}。` : ""}` +
844
+ // 真实参数名列出来,让人按名字挑。探针 J:混合键里只要有一个键
845
+ // 没拿到替代(如 all 有 replaceWith、zzz 没有),仍要列真实参数。
846
+ `${suggestions.some((entry) => entry.closest === undefined && entry.hint === undefined && entry.absentInTool === undefined && entry.replaceWith === undefined) ? `本工具的真实参数:${[...schemaKeys].join("、")}。` : ""}` +
834
847
  `改用合法键后重试;确需宽松忽略传 lenientArgs:true。参数表:omc describe ${toolName}`,
835
848
  };
836
849
  return emit("error", result, CLI_EXIT_CODES.invalidInput);
@@ -1150,6 +1163,12 @@ function applyReadArgAliases(toolName, schemaKeys, input) {
1150
1163
  * 「改名建议」表达——建议无法携带方向/换算信息。
1151
1164
  */
1152
1165
  export function suggestArgumentKey(key, schemaKeys, toolName) {
1166
+ // 探针 J F4/F5:按 tool+key 的显式替代优先于拼写猜测(见
1167
+ // TOOL_KEY_ALTERNATIVES)。命中的是「语义改写」而不是「拼错」,所以
1168
+ // closest/编辑距离不参与,避免把原键再建议一次。
1169
+ const alternative = toolName !== undefined ? TOOL_KEY_ALTERNATIVES[toolName]?.[key] : undefined;
1170
+ if (alternative !== undefined)
1171
+ return { ...alternative };
1153
1172
  const known = new Set(schemaKeys);
1154
1173
  const paginationKeys = new Set(["page", "pagesize", "size", "pageindex", "pagenumber", "pageno", "offset", "limit"]);
1155
1174
  if (paginationKeys.has(key.toLowerCase()) && !schemaKeys.some((name) => paginationKeys.has(name.toLowerCase()))) {
@@ -2599,17 +2618,18 @@ async function cmdIntentPlan(file, environment, planOut, transport, summary = fa
2599
2618
  return emitInvalid(transport, { message: error instanceof Error ? error.message : String(error) });
2600
2619
  }
2601
2620
  }
2602
- const result = await planIntent(read.intent, environment, planOut);
2621
+ let result = await planIntent(read.intent, environment, planOut);
2603
2622
  // a-F12(r60a-F12,r61):--summary 档只回决策字段 + 逐项变更(tool+reason+资源
2604
2623
  // 键,去 args/baselineFingerprint)。内联完整 plan 一个真实需求 ~20KB、含基线
2605
2624
  // 50–60KB——探针只要「会改什么」时被整块计费。要 apply 仍用完整 plan(不带
2606
2625
  // --summary,或 --plan-out 写复核文件)。
2626
+ let summaryProjected = false;
2607
2627
  if (summary) {
2608
2628
  const plan = result.plan;
2609
2629
  if (plan !== undefined && Array.isArray(plan.changes)) {
2610
2630
  // r62c-F3(P0-4):resource 用编译器的资源标识(`field:model.code`),不从
2611
2631
  // args 猜——猜会降级成模型 code,3 个 field.create 无法区分(探针真机撞上)。
2612
- return emitResult({
2632
+ result = {
2613
2633
  ...result,
2614
2634
  plan: undefined,
2615
2635
  changesBrief: plan.changes.map((change) => ({
@@ -2618,10 +2638,29 @@ async function cmdIntentPlan(file, environment, planOut, transport, summary = fa
2618
2638
  ...(change.resource !== undefined ? { resource: change.resource } : {}),
2619
2639
  })),
2620
2640
  summaryNote: "--summary 只回变更清单(去 args/基线);apply 用完整 plan(不带 --summary 或 --plan-out <file>)",
2621
- }, transport);
2641
+ };
2642
+ summaryProjected = true;
2622
2643
  }
2623
2644
  // 已外置/已写文件的分支本就是决策字段面——原样返回。
2624
2645
  }
2646
+ // Probe I F1/F2(0.8.15):`--out` 落的是完整 CLI 信封,stdout 只有小回执。
2647
+ // 回执必须自解释——但必须在 summary 投影**之后**看 result:summary 会剥掉
2648
+ // plan(只留 changesBrief),此前分档会把摘要信封误称「自动取 result.plan」。
2649
+ // 大 plan 则只有 planFile/planArtifactId(result.plan 不存在),各成一档。
2650
+ const outFile = outputOptions().outFile;
2651
+ if (outFile !== undefined && result.status === "ok") {
2652
+ const receipt = result;
2653
+ const outPath = resolve(outFile);
2654
+ const planFile = typeof receipt.planFile === "string" ? receipt.planFile : undefined;
2655
+ const planArtifactId = typeof receipt.planArtifactId === "string" ? receipt.planArtifactId : undefined;
2656
+ setOutReceiptHint(summaryProjected
2657
+ ? `该信封是 --summary 摘要产物(不含 plan):apply 请去掉 --summary 重跑 intent plan,或用 result.planArtifactId(omc intent apply ${planArtifactId ?? planFile ?? "<planArtifactId>"})`
2658
+ : receipt.plan !== undefined
2659
+ ? `该文件是完整 CLI 信封,可直接 omc intent apply ${outPath}(apply 自动取 result.plan);要裸 plan 用 --plan-out`
2660
+ : planFile !== undefined || planArtifactId !== undefined
2661
+ ? `该信封里 plan 已外置(result.plan 不存在):直接 omc intent apply ${planFile ?? planArtifactId}${planFile !== undefined ? "(planFile 在 result.planFile)" : "(planArtifactId 在 result.planArtifactId)"}`
2662
+ : "该信封不含 plan:apply 请重跑 intent plan(不要 --summary);要落盘复核用 --plan-out");
2663
+ }
2625
2664
  return emitResult(result, transport);
2626
2665
  }
2627
2666
  /** Ticket 120 — `omc intent readback <file> --env <env>`: decode the live baseline back into intent shape and verify equivalence. */
@@ -2900,17 +2939,21 @@ async function cmdIntentApply(planPath, options, transport) {
2900
2939
  emit: (result) => emitResult(result, transport),
2901
2940
  invalid: (blocker, message, code = "invalid-input") => emitInvalid(transport, { message, blocker, code }),
2902
2941
  readIntent: (file) => {
2903
- let outcome;
2942
+ let text;
2904
2943
  try {
2905
- outcome = validateIntentText(readIntentFile(intentConfigRoot(), file));
2944
+ text = readIntentFile(intentConfigRoot(), file);
2906
2945
  }
2907
- catch {
2908
- return { kind: "exit", code: CLI_EXIT_CODES.invalidInput };
2946
+ catch (error) {
2947
+ // Probe I 复核:意图源(YAML)在配置根外时,先给根限制/可执行修法,
2948
+ // 不把 JSON.parse 的 `Unexpected token` 当主因(plan 文件可在根外)。
2949
+ return { kind: "invalid", message: `意图源 YAML 必须在配置根内(plan JSON 文件不受此限):${error instanceof Error ? error.message : String(error)}` };
2909
2950
  }
2951
+ const outcome = validateIntentText(text);
2910
2952
  if (!outcome.valid || outcome.intent === undefined) {
2911
2953
  for (const error of outcome.errors)
2912
2954
  console.error(`intent ${file}:${error.line}:${error.column} [${error.code}] ${error.message}`);
2913
- return { kind: "exit", code: CLI_EXIT_CODES.invalidInput };
2955
+ const detail = outcome.errors.map((error) => `${file}:${error.line}:${error.column} [${error.code}] ${error.message}`).join(";");
2956
+ return { kind: "invalid", message: `意图 YAML 校验失败:${detail}` };
2914
2957
  }
2915
2958
  return { kind: "ok", intent: outcome.intent };
2916
2959
  },
@@ -2998,7 +3041,7 @@ function cmdHelpSearch(topic, query, transport, searchMode, limit) {
2998
3041
  returnedMatches: entries.length,
2999
3042
  truncated: truncated || entries.some((entry) => entry.sectionComplete === false),
3000
3043
  matches: entries,
3001
- ...(result.total === 0 ? { message: "没有匹配章节;换更短的字面词(错误码、字段名、命令名)或加 --search-mode any" } : {}),
3044
+ ...(result.total === 0 ? { message: "没有匹配章节;换更短的字面词(错误码、字段名、命令名)或加 --search-mode any。格式常量/参数用 `omc describe <tool> --param <name>` 或 `omc contract <lane>` 查(例:omc describe field.create --param options)" } : {}),
3002
3045
  ...(result.total > 0 && entries.length === 0 ? { message: "命中存在但连指针都放不进预算;加 --limit 1 或换更短的查询" } : {}),
3003
3046
  });
3004
3047
  let truncating = false;
@@ -4048,7 +4091,7 @@ async function main() {
4048
4091
  }));
4049
4092
  });
4050
4093
  command.command("bench").option("--live-sample").option("--env <environment>").action(async (options) => { commandExitCode = await cmdBench([...(options.liveSample ? ["--live-sample"] : []), ...(options.env ? ["--env", options.env] : [])]); });
4051
- command.command("residue <prefix>").description("跨面前缀残留扫描(model 全租户/folder/custompage;默认 deep 再查命中模型的 rule/datarule/onlinejs)——收尾「删净」一次证明,clean:true 即零残留。清理入口:omc model-purge --code <schemaCode>(按依赖倒序,默认 dry-run)。只读零写入;report 面暂停维护未扫描").option("--env <environment>", "环境名(默认按 cwd 的 .omc-env 解析)").option("--apps <codes>", "all(默认,全租户)或逗号分隔应用码").option("--no-deep", "只扫 model/folder/custompage,不深查命中模型").option("--all-faces", "列出全部应用×面(含 count:0;默认只回非零面+byFace/userResidues 紧凑形)").option("--max-output-bytes <bytes>").addOption(new Option("--jq [path]", "--jq 不是 jq,仅路径选择器(与 call --jq 同 DSL;可逗号多路径;裸 --jq 列顶层键)").argParser((value, previous = []) => [...previous, value]).default([])).action(async (prefix, options) => { commandExitCode = await withTransport(options, request, (transport) => cmdResidue(prefix, { env: options.env, apps: options.apps, ...(options.deep === false ? { noDeep: true } : {}), ...(options.allFaces ? { allFaces: true } : {}), ...(options.jq !== undefined ? { jq: options.jq } : {}) }, transport)); });
4094
+ command.command("residue <prefix>").description("跨面前缀残留扫描(model 全租户/folder/custompage;默认 deep 再查命中模型的 rule/datarule/onlinejs)——收尾「删净」一次证明,clean:true 仅指已扫描面零残留(cleanScope:\"scanned-faces\";report 面未扫描,用 report.tree 复核)。清理入口:omc model-purge --code <schemaCode>(按依赖倒序,默认 dry-run)。只读零写入;report 面暂停维护未扫描").option("--env <environment>", "环境名(默认按 cwd 的 .omc-env 解析)").option("--apps <codes>", "all(默认,全租户)或逗号分隔应用码").option("--no-deep", "只扫 model/folder/custompage,不深查命中模型").option("--all-faces", "列出全部应用×面(含 count:0;默认只回非零面+byFace/userResidues 紧凑形)").option("--max-output-bytes <bytes>").addOption(new Option("--jq [path]", "--jq 不是 jq,仅路径选择器(与 call --jq 同 DSL;可逗号多路径;裸 --jq 列顶层键)").argParser((value, previous = []) => [...previous, value]).default([])).action(async (prefix, options) => { commandExitCode = await withTransport(options, request, (transport) => cmdResidue(prefix, { env: options.env, apps: options.apps, ...(options.deep === false ? { noDeep: true } : {}), ...(options.allFaces ? { allFaces: true } : {}), ...(options.jq !== undefined ? { jq: options.jq } : {}) }, transport)); });
4052
4095
  command.command("track <schemaCode> <bizObjectId>").description("读取单条业务数据的行级变更留痕(只读;平台来源枚举含 BUSINESS_RULE 时原样回传)").option("--env <environment>").option("--property-code <code>").option("--max-output-bytes <bytes>").action(async (schemaCode, bizObjectId, options) => { commandExitCode = await withTransport(options, request, (transport) => cmdTrack(schemaCode, bizObjectId, { env: options.env, propertyCode: options.propertyCode }, transport)); });
4053
4096
  const jqOption = () => new Option("--jq [path]", "--jq 不是 jq,仅路径选择器(与 call --jq 同 DSL;可逗号多路径;裸 --jq 列顶层键)").argParser((value, previous = []) => [...previous, value]).default([]);
4054
4097
  // C6(0.8.4):--jq 的 miss 默认只回结论;排查载荷(available/correctPath/
@@ -4089,7 +4132,7 @@ async function main() {
4089
4132
  command.command("capability <id>").option("--executable").option("--max-output-bytes <bytes>").addOption(jqOption()).addOption(explainOption()).action(async (id, options) => {
4090
4133
  commandExitCode = await withTransport(options, request, (transport) => cmdCapability(id, transport, options.executable === true, options.jq, options.explain === true));
4091
4134
  });
4092
- const intentCommand = command.command("intent").description("声明式意图面(Spec 107):intent.yaml → validate → plan → apply → readback。**intent/plan 文件必须位于配置根内**(与 --args-file 同规则:配置根外的文件一律拒绝,防携带凭据被收进会话产物;根外内容请先拷入或经 stdin)").addHelpText("after", "\n意图文件(validate/plan/readback 的 <file>)与 plan 产物(--plan-out)都解析到配置根内——配置根外一律 invalid-input(与 call --args-file 同规则)。\n");
4135
+ const intentCommand = command.command("intent").description("声明式意图面(Spec 107):intent.yaml → validate → plan → apply → readback。**意图源文件(validate/plan/readback)必须位于配置根内**(与 --args-file 同规则:根外一律拒绝);**plan 文件(apply 的输入)是 CLI 产物、不含凭据,可在任意路径**(含 /tmp 与 `--out` 落下的完整信封)").addHelpText("after", "\n意图源文件(validate/plan/readback 的 <file>)解析到配置根内——配置根外一律 invalid-input(与 call --args-file 同规则)。plan 文件不走该限制:apply 接受根外路径、裸 plan、以及 `intent plan ... --out <file>` 的完整信封(自动取 result.plan);`intent plan --plan-out` 仍写配置根内。\n");
4093
4136
  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); });
4094
4137
  intentCommand.command("validate <file>").option("--show-intent").action((file, options) => { commandExitCode = cmdIntentValidate(file, { request, maxOutputBytes: CLI_DEFAULT_OUTPUT_BYTES }, options.showIntent === true); });
4095
4138
  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) => {
@@ -4207,6 +4250,9 @@ function finish(code) {
4207
4250
  process.exitCode = code;
4208
4251
  setTimeout(() => process.exit(code), 1000).unref();
4209
4252
  }
4253
+ // F10(0.8.15):下游 `head`/`grep -q` 提前关闭管道时,EPIPE 是消费方叫停,
4254
+ // 不是故障——安静 exit 0,别让未处理的流错误在 `2>&1` 合流里变成假挂起。
4255
+ installStdoutPipeGuard();
4210
4256
  const request = requestId();
4211
4257
  main().then((code) => {
4212
4258
  // Commands that own their stdout never grow a trailing envelope. The list is
@@ -894,7 +894,9 @@ export function assertLayoutRequestConflicts(args) {
894
894
  schemaCode: String(args.schemaCode ?? ""),
895
895
  sheetCode: String(args.sheetCode ?? args.schemaCode ?? ""),
896
896
  conflictKeys,
897
- message: `layout 与 ${conflictKeys.join("、")} 互斥:layout 是增量面(以已发布表单为基线,只改这些控件的行分组与 span),不要同时回传整包 attrs/view、不要重建;二选一。`,
897
+ message: `layout 与 ${conflictKeys.join("、")} 互斥:layout 是增量面(以草稿为基线,只改这些控件的行分组与 span),不要同时回传整包 attrs/view、不要重建;二选一。${conflictKeys.includes("childColumns")
898
+ ? "子表列走的是另一个只写草稿的增量面,正确顺序:① 先 `form.draft {childColumns}` 把子表列绑进草稿;② 再 `form.draft {layout}`(以草稿为基线,不动刚绑的列);③ 再 `form.publish`。"
899
+ : ""}`,
898
900
  });
899
901
  }
900
902
  /**
@@ -908,11 +910,17 @@ export async function composeFormLayoutDraft(session, args) {
908
910
  const decode = (value) => decodeJsonObjectColumn(value, { invalid: "undefined", array: "reject", object: "accept" });
909
911
  const publishedAttrs = sheet === null ? undefined : decode(sheet.publishedAttributesJson);
910
912
  const draftAttrs = sheet === null ? undefined : decode(sheet.draftAttributesJson);
911
- const baseline = publishedAttrs !== undefined && Object.keys(publishedAttrs).length > 0
912
- ? "published"
913
- : draftAttrs !== undefined && Object.keys(draftAttrs).length > 0
914
- ? "draft"
915
- : undefined;
913
+ const usable = (face) => face !== undefined && Object.keys(face).length > 0;
914
+ const publishedUsable = usable(publishedAttrs);
915
+ const draftUsable = usable(draftAttrs);
916
+ // 探针 J P1(0.8.16):草稿是下一次发布的对象,`childColumns` 只写草稿——layout
917
+ // 必须以草稿为基线,否则第二次写会把第一次写进草稿的子表列/新控件整包覆盖掉。
918
+ // 草稿为空(设计器 Save 会清成 "{}")或与已发布面逐字相同(刚发布完,内容等价)
919
+ // 时退回 published,保持「无草稿 → published」的老行为不变。
920
+ const draftDifferences = sheet !== null &&
921
+ (sheet.draftAttributesJson !== sheet.publishedAttributesJson ||
922
+ (typeof sheet.draftViewJson === "string" && sheet.draftViewJson !== sheet.publishedViewJson));
923
+ const baseline = draftUsable && (!publishedUsable || draftDifferences) ? "draft" : publishedUsable ? "published" : draftUsable ? "draft" : undefined;
916
924
  if (sheet === null || baseline === undefined) {
917
925
  throw new ToolRefusalError({
918
926
  status: "refused",
@@ -1066,7 +1074,12 @@ export async function composeFormLayoutDraft(session, args) {
1066
1074
  });
1067
1075
  }
1068
1076
  // 基线行分组(保留未点名控件):去非法 cell/重复 cell,空行丢弃。
1069
- const parsedBaseline = layoutRowsOf(baseline === "published" ? sheet.publishedViewJson : sheet.draftViewJson) ?? [];
1077
+ // 草稿 attrs 有控件但草稿 view 是空/"[]"(只写过 draftAttributesJson)时,
1078
+ // 行分组退回已发布 view:attrs 以草稿为准(新控件不丢),行分组沿用发布面。
1079
+ const draftRows = layoutRowsOf(sheet.draftViewJson);
1080
+ const publishedRows = layoutRowsOf(sheet.publishedViewJson);
1081
+ const rowsFace = baseline === "published" ? "published" : draftRows !== undefined && draftRows.length > 0 ? "draft" : publishedRows !== undefined && publishedRows.length > 0 ? "published" : "draft";
1082
+ const parsedBaseline = layoutRowsOf(rowsFace === "published" ? sheet.publishedViewJson : sheet.draftViewJson) ?? [];
1070
1083
  const seenCell = new Set();
1071
1084
  const baselineRows = [];
1072
1085
  const droppedCells = [];
@@ -1153,13 +1166,53 @@ export async function composeFormLayoutDraft(session, args) {
1153
1166
  }
1154
1167
  const warnings = violations.filter((violation) => !touchesCaller(violation));
1155
1168
  const preserved = attrCodes.filter((code) => !namedSet.has(code));
1169
+ // 草稿基线可能比已发布面**少**控件或**少子表列**(设计器 Save 非无损 / 历史
1170
+ // layout 已被整包覆盖 / 草稿来自陈旧读面)。这时不静默:如实点名,说明发布会
1171
+ // 撞 form-publish-degrade 或 childColumnsNotInForm 与恢复路径。
1172
+ const draftMissingPublishedControls = baseline === "draft" && publishedUsable ? Object.keys(publishedAttrs).filter((code) => !attrSet.has(code)) : [];
1173
+ // 子表列不在顶层控件面:它们在父 Sheet201 控件的 columns[] 里(childTableColumns
1174
+ // 注释)。layout 只重排不改列,所以「草稿比发布面少列」会原样被带去发布面。
1175
+ const columnKeysOf = (control) => {
1176
+ if (control === null || typeof control !== "object")
1177
+ return [];
1178
+ const columns = control.columns;
1179
+ return Array.isArray(columns) ? columns.map((column) => String(column?.key ?? "")).filter((key) => key.length > 0) : [];
1180
+ };
1181
+ const draftMissingPublishedChildColumns = [];
1182
+ if (baseline === "draft" && publishedUsable) {
1183
+ for (const [parent, publishedControl] of Object.entries(publishedAttrs)) {
1184
+ const publishedColumns = columnKeysOf(publishedControl);
1185
+ if (publishedColumns.length === 0)
1186
+ continue;
1187
+ // 父控件整体缺失已由 draftMissingPublishedControls 点名(列跟着控件走)。
1188
+ if (attrs[parent] === undefined)
1189
+ continue;
1190
+ const bound = new Set(columnKeysOf(attrs[parent]));
1191
+ const absent = publishedColumns.filter((key) => !bound.has(key));
1192
+ if (absent.length > 0)
1193
+ draftMissingPublishedChildColumns.push({ parent, fieldCodes: absent });
1194
+ }
1195
+ }
1156
1196
  const receipt = {
1157
1197
  baseline,
1198
+ ...(rowsFace !== baseline ? { rowsBaseline: rowsFace } : {}),
1158
1199
  rows: finalRows.length,
1159
1200
  named,
1160
1201
  preserved,
1161
1202
  ...(appended.length > 0 ? { appended } : {}),
1162
1203
  ...(droppedCells.length > 0 ? { droppedCells: [...new Set(droppedCells)] } : {}),
1204
+ ...(draftMissingPublishedControls.length > 0
1205
+ ? {
1206
+ draftMissingPublishedControls,
1207
+ draftShortfallNote: `草稿控件面比已发布面少 ${draftMissingPublishedControls.length} 个(${draftMissingPublishedControls.join("、")}):本次写入以草稿为基线,这些控件不会回到草稿;发布会被 form-publish-degrade 拒。恢复路径:表单版本历史 /api/api/app/bizsheet/history/list 取回完好草稿,或 form.draft {rebuild:true}。`,
1208
+ }
1209
+ : {}),
1210
+ ...(draftMissingPublishedChildColumns.length > 0
1211
+ ? {
1212
+ draftMissingPublishedChildColumns,
1213
+ draftChildColumnsShortfallNote: `草稿比发布面少这些子表列(${draftMissingPublishedChildColumns.map((entry) => `${entry.parent}.${entry.fieldCodes.join("/")}`).join("、")}):layout 只重排行/span、不改 Sheet201 的 columns,发布面会因此缺列(form.publish 回执会点名 childColumnsNotInForm)——要补就 form.draft {childColumns} 后重跑 publish,或从版本历史取回完好草稿。`,
1214
+ }
1215
+ : {}),
1163
1216
  spans,
1164
1217
  includeSystem: layout.includeSystem === true,
1165
1218
  note: "只改 rows 分组与这些控件的 span;其它控件属性/HTML 逐键保留,未列入 rows 的控件保留基线行(锚定在被点名控件周围)",
@@ -1240,6 +1293,80 @@ export function assertPublishNotDegrading(draftAttributesJson, publishedAttribut
1240
1293
  message: `草稿面控件数(${draftControls})少于已发布面(${publishedControls})——拒绝降级提拔。平台设计器 Save 会清空草稿(非无损);恢复路径是表单版本历史 /api/api/app/bizsheet/history/list 取回完好版本的 view/attributes 原文重写草稿后再发布。确要减少控件请显式传 allowDegrade:true`,
1241
1294
  });
1242
1295
  }
1296
+ /**
1297
+ * 探针 J P1(0.8.16):发布面「子表列缺失」诊断(只读、尽力而为)。
1298
+ *
1299
+ * 子表列不在顶层控件面也不在 viewJson:它们是父 Sheet201 控件的 `columns`
1300
+ * (见 childTableColumns 的注释)。子表字段已发布但父控件 columns 里没有它时,
1301
+ * 业务页面看不到——`field.publish` 的 formBinding 早就按此判
1302
+ * (src/lanes/field.ts formBindingAdvisory),`form.publish` 过去只看控件数,
1303
+ * 于是「历史 layout 整包覆盖了子表列」也能报 published:true。
1304
+ *
1305
+ * 判据来源与 formBindingAdvisory / insertChildColumnsIntoLayout 同源:
1306
+ * `field.list(isPublish=true)` 的 CHILD_TABLE 行 `subSchema.properties`。
1307
+ * 读不到字段面 → undefined(不做诊断,也不编造「没有缺失」)。
1308
+ *
1309
+ * 登记(未抽公共函数):`src/lanes/field.ts:2095-2102`(formBindingAdvisory)是同一
1310
+ * 判据的**另一份内联实现**——差别有两点且都是刻意的:① field.publish 的清单按
1311
+ * 「模型里有哪些子表列」判(父控件缺席时也算缺列,用于提示先绑父字段);本函数
1312
+ * 只看**表单里存在**的父控件(父控件缺席已由顶层控件缺失面覆盖)。② 本函数多一次
1313
+ * `field.list` wire,只在 publish/layout 回执里跑。两点语义差异让「一行抽取」反而
1314
+ * 需要参数化「父控件缺席时是否算缺列」,收益不抵改动面;若后续两处要再收敛,
1315
+ * 目标签名是 `childColumnsMissing(rows, attributes, {includeAbsentParents})`。
1316
+ */
1317
+ export async function childColumnsMissingFromForm(session, args) {
1318
+ if (typeof args.attributesJson !== "string")
1319
+ return undefined;
1320
+ let attributes;
1321
+ try {
1322
+ const parsed = JSON.parse(args.attributesJson);
1323
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed))
1324
+ return undefined;
1325
+ attributes = parsed;
1326
+ }
1327
+ catch {
1328
+ return undefined;
1329
+ }
1330
+ let rows;
1331
+ try {
1332
+ rows = wireRows((await wireCall(session, { path: ENDPOINTS.fieldList, query: { schemaCode: args.schemaCode, isPublish: "true" } })).data);
1333
+ }
1334
+ catch {
1335
+ return undefined;
1336
+ }
1337
+ const missing = [];
1338
+ for (const row of rows) {
1339
+ if (Number(row.type ?? row.propertyType) !== 8)
1340
+ continue;
1341
+ const parent = String(row.code ?? row.propertyCode ?? "");
1342
+ const control = attributes[parent];
1343
+ // 父控件本身不在表单里 = 顶层控件缺失(field.publish 的 notInFormLayout),
1344
+ // 不是子表列问题;在这里点名会误导成「绑 childColumns 就好」。
1345
+ if (control === undefined || control === null || typeof control !== "object")
1346
+ continue;
1347
+ const columns = Array.isArray(control.columns) ? control.columns : [];
1348
+ const bound = new Set(columns.map((column) => String(column.key ?? "")).filter((key) => key.length > 0));
1349
+ const absent = childColumnsOf(row.subSchema)
1350
+ .filter((column) => column.system !== true)
1351
+ .map((column) => column.code)
1352
+ .filter((code) => !bound.has(code));
1353
+ if (absent.length > 0)
1354
+ missing.push({ parent, fieldCodes: absent });
1355
+ }
1356
+ return missing;
1357
+ }
1358
+ /** 发布面缺子表列时的一句诊断(write 与 dry-run 同一句)。 */
1359
+ export const CHILD_COLUMNS_NOT_IN_FORM_NOTE = "子表字段已发布,但表单 Sheet201 控件的 columns 里没有它——业务页面看不到(发布照常成功,不等于可见)。用 configure_form 的 childColumns 增量绑定(不动其它控件/布局)后重跑发布";
1360
+ /** 发布面缺子表列时的回执片段(写路径 / already-published 短路 / dry-run 共用一份形状)。 */
1361
+ function childColumnsGapReadback(gaps, schemaCode, sheetCode) {
1362
+ if (gaps === undefined || gaps.length === 0)
1363
+ return {};
1364
+ return {
1365
+ childColumnsNotInForm: gaps,
1366
+ childColumnsNote: CHILD_COLUMNS_NOT_IN_FORM_NOTE,
1367
+ nextCommand: `omc call configure_form --args '${JSON.stringify({ schemaCode, ...(sheetCode !== schemaCode ? { sheetCode } : {}), childColumns: gaps })}'`,
1368
+ };
1369
+ }
1243
1370
  /**
1244
1371
  * `form.publish --dry-run` 的只读预览:不建草稿、不提拔,只回答两件事——
1245
1372
  * ① 当前草稿会不会被降级门拒(与真写同一函数);② 这次发布是否真的会改东西。
@@ -1263,6 +1390,9 @@ export async function lintFormPublishReadOnly(session, args) {
1263
1390
  if (!hasDraft)
1264
1391
  return { wouldChange: true, sheetPresent: true, draftPresent: false, publishedControlCount: publishedControls, note: "当前无草稿:真写会先按已发布字段造草稿再提拔(预览不建草稿)" };
1265
1392
  assertPublishNotDegrading(sheet.draftAttributesJson, sheet.publishedAttributesJson, { schemaCode: args.schemaCode, sheetCode, ...(args.allowDegrade !== undefined ? { allowDegrade: args.allowDegrade } : {}) });
1393
+ // 提拔是逐字复制草稿 → 发布面,所以「发布面缺子表列」=「草稿面缺子表列」,
1394
+ // 预览用草稿面算同一份清单(真写用发布后的回读面复核)。
1395
+ const childColumnGaps = await childColumnsMissingFromForm(session, { schemaCode: args.schemaCode, attributesJson: sheet.draftAttributesJson });
1266
1396
  const draftEqualsPublished = sheet.draftViewJson === sheet.publishedViewJson &&
1267
1397
  sheet.draftAttributesJson === sheet.publishedAttributesJson &&
1268
1398
  (sheet.draftHtmlJson === undefined || sheet.draftHtmlJson === sheet.publishedHtmlJson);
@@ -1274,6 +1404,7 @@ export async function lintFormPublishReadOnly(session, args) {
1274
1404
  publishedControlCount: publishedControls,
1275
1405
  draftEqualsPublished,
1276
1406
  alreadyPublished: sheet.published === true && draftEqualsPublished,
1407
+ ...childColumnsGapReadback(childColumnGaps, args.schemaCode, sheetCode),
1277
1408
  note: "降级门与真写同一函数;alreadyPublished:true 时真写会短路(不改发布面)",
1278
1409
  };
1279
1410
  }
@@ -1819,9 +1950,10 @@ export async function executeFormDraftWrite(session, args) {
1819
1950
  if (args.draftHtmlJson !== undefined) {
1820
1951
  assertHtmlRender(args.draftHtmlJson, { schemaCode: args.schemaCode, sheetCode: args.sheetCode, face: "draftHtmlJson" });
1821
1952
  }
1822
- // 增量布局面:以已发布(无则草稿)控件面为基线组合出完整 viewJson/attributesJson。
1823
- // 组合失败(无基线/未知控件/系统控件/span 不自洽)就在任何 wire 之前拒;dry-run 走
1824
- // 同一个 composeFormLayoutDraft(见 form.draft 的 writeLint),两边答案逐字相同。
1953
+ // 增量布局面:以草稿(空/与发布面逐字相同则已发布)控件面为基线组合出完整
1954
+ // viewJson/attributesJson。组合失败(无基线/未知控件/系统控件/span 不自洽)就在
1955
+ // 任何 wire 之前拒;dry-run 走同一个 composeFormLayoutDraft(见 form.draft 的
1956
+ // writeLint),两边答案逐字相同。
1825
1957
  let layoutReceipt;
1826
1958
  let composedLayoutWarnings = [];
1827
1959
  if (layoutRequest !== undefined) {
@@ -2392,8 +2524,19 @@ export async function executeFormPublishWrite(session, args) {
2392
2524
  const draftEqualsPublished = typeof pre.draftViewJson === "string" && pre.draftViewJson === pre.publishedViewJson &&
2393
2525
  typeof pre.draftAttributesJson === "string" && pre.draftAttributesJson === pre.publishedAttributesJson &&
2394
2526
  (pre.draftHtmlJson === undefined || pre.draftHtmlJson === pre.publishedHtmlJson);
2395
- if (pre.published === true && draftEqualsPublished && !forcePromote)
2396
- return { performed: { skipped: "already-published" }, readback: { published: true, draftMatchesPublished: true } };
2527
+ if (pre.published === true && draftEqualsPublished && !forcePromote) {
2528
+ // 短路也是回执:已发布 ≠ 页面可见。历史 layout 覆盖掉的子表列要在这里点名,
2529
+ // 否则重跑 form.publish 会得到「published:true」的假确认。
2530
+ const publishedGaps = await childColumnsMissingFromForm(session, { schemaCode: args.schemaCode, attributesJson: pre.publishedAttributesJson });
2531
+ return {
2532
+ performed: { skipped: "already-published" },
2533
+ readback: {
2534
+ published: true,
2535
+ draftMatchesPublished: true,
2536
+ ...childColumnsGapReadback(publishedGaps, args.schemaCode, args.sheetCode),
2537
+ },
2538
+ };
2539
+ }
2397
2540
  if (!hasDraft(pre))
2398
2541
  throw new WireError("business", "form publish requires a saved draft (draftViewJson/draftAttributesJson)", 302020);
2399
2542
  if (pre.draftHtmlJson !== "[]")
@@ -2437,11 +2580,16 @@ export async function executeFormPublishWrite(session, args) {
2437
2580
  const readback = await wireCall(session, { path: ENDPOINTS.sheetGet, query: { schemaCode: args.schemaCode, sheetCode: args.sheetCode } });
2438
2581
  const sheet = (readback.data ?? {});
2439
2582
  const formButtons = readFormButtons(sheet.options);
2583
+ // 探针 J P1(0.8.16):发布成功 ≠ 页面可见。子表列不在顶层控件面/viewJson,
2584
+ // 只在父 Sheet201 控件的 columns 里;历史 layout 覆盖掉的列、或子表字段新发布
2585
+ // 而没绑进表单时,这里逐条点名(读不到字段面则不诊断)。
2586
+ const childColumnGaps = await childColumnsMissingFromForm(session, { schemaCode: args.schemaCode, attributesJson: sheet.publishedAttributesJson });
2440
2587
  return {
2441
2588
  performed: { errcode: performed.errcode },
2442
2589
  readback: {
2443
2590
  published: sheet.published === true,
2444
2591
  publishedHtmlJsonPresent: typeof sheet.publishedHtmlJson === "string",
2592
+ ...childColumnsGapReadback(childColumnGaps, args.schemaCode, args.sheetCode),
2445
2593
  ...(formButtons !== null
2446
2594
  ? {
2447
2595
  formButtons,
@@ -130,6 +130,16 @@ export function writeSummary(tool, args, outcome, phase = "done") {
130
130
  const pending = Object.entries(perCode).filter(([, value]) => value?.absent === false).map(([code]) => code);
131
131
  return `未删净(级联中)${pending.length > 0 ? pending.join("、") : "部分模型"}:平台异步删除任务未完成,记录面仍查得到——不要当作已删除;按 perCode 逐项复核,稍后重跑 model.deleteMany(幂等)`;
132
132
  }
133
+ // P1(探针 I,0.8.15):删前读不到 ≠ 已清理。schemaCode 写错时 id 实际在另一个
134
+ // 模型里,回执曾是 status:ok + already-absent。人类摘要必须同样以否定开头。
135
+ if (phase === "done" && tool === "data.delete" && outcome?.readback?.blocker === "delete-target-not-in-schema") {
136
+ const listed = Array.isArray(outcome.readback.notInSchema) ? outcome.readback.notInSchema.map(String) : [];
137
+ const ids = listed.length > 0
138
+ ? listed
139
+ : [(Array.isArray(args.bizObjectIds) ? String(args.bizObjectIds[0]) : undefined) ?? stringArg(args, "bizObjectId") ?? "?"];
140
+ const schema = stringArg(args, "schemaCode") ?? "?";
141
+ return `未确认删除(delete-target-not-in-schema)${ids.length} 条不属于 ${schema}:${ids.join("、")};本工具无法判定归属——先 model.list 取候选模型再逐个 data.list 核对(或问用户),别据此宣称已清理`;
142
+ }
133
143
  // r28b F11: data.delete already-absent must NOT read as「已删除…」— humans/CI
134
144
  // that skim stderr treat the leading verb as the outcome. Say「未删除」first.
135
145
  if (phase === "done" && tool === "data.delete" && outcome?.performed?.skipped === "already-absent") {
@@ -284,11 +294,13 @@ function phraseOf(tool, args, outcome) {
284
294
  // F8(w63):平台按模型「数据标题」覆盖显式传入的 name,摘要行必须抬头。
285
295
  const nameNote = readbackNoteClause(outcome, "nameOverwrittenNote");
286
296
  if (args.submit === true && submitRefused !== undefined) {
297
+ // P1(w132 探针 J):这是**部分完成**——草稿已落库、提交未完成。摘要
298
+ // 必须先说清这个事实,再说被拒原因,避免调用方读成「已提交」。
287
299
  // 更新行不得复用「重建流程草稿」口径(会诱导多建一行)。
288
300
  if (workflowUpdateNote !== undefined) {
289
- return `保存数据(模型 ${schemaCode ?? "?"})——submit:true 被拒(${submitRefused.blocker ?? "?"}):更新既有行,不会创建/改动流程实例;推进用 workitem.list → data.submit 三件套;指引进 readback.workflowUpdateNote${nameNote}`;
301
+ return `保存数据(模型 ${schemaCode ?? "?"})——草稿已保存,提交未完成:submit:true 被拒(${submitRefused.blocker ?? "?"});更新既有行,不会创建/改动流程实例;推进用 workitem.list → data.submit 三件套;指引进 readback.workflowUpdateNote${nameNote}`;
290
302
  }
291
- return `保存数据(模型 ${schemaCode ?? "?"})——submit:true 被拒(${submitRefused.blocker ?? "?"}):模型有已发布流程,行保持草稿 DRAFT;重建流程草稿的指引进 readback.submitRefused${nameNote}`;
303
+ return `保存数据(模型 ${schemaCode ?? "?"})——草稿已保存,提交未完成:submit:true 被拒(${submitRefused.blocker ?? "?"});模型有已发布流程,行保持草稿 DRAFT;重建流程草稿的指引进 readback.submitRefused${nameNote}`;
292
304
  }
293
305
  if (workflowUpdateNote !== undefined) {
294
306
  return `保存数据(模型 ${schemaCode ?? "?"})——更新既有行,不创建/改动流程实例;流程模型上保存的直提标志会被拒,推进该行用 workitem.list → data.submit 三件套(不要为触发规则/推进流程再 data.save)${nameNote}`;