@stalfh233/omc-cli 0.6.51 → 0.6.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1775,13 +1775,15 @@ async function cmdIntentPlan(file, environment, planOut, transport, summary = fa
1775
1775
  if (summary) {
1776
1776
  const plan = result.plan;
1777
1777
  if (plan !== undefined && Array.isArray(plan.changes)) {
1778
+ // r62c-F3(P0-4):resource 用编译器的资源标识(`field:model.code`),不从
1779
+ // args 猜——猜会降级成模型 code,3 个 field.create 无法区分(探针真机撞上)。
1778
1780
  return emitResult({
1779
1781
  ...result,
1780
1782
  plan: undefined,
1781
1783
  changesBrief: plan.changes.map((change) => ({
1782
1784
  tool: change.tool,
1783
1785
  ...(change.reason !== undefined ? { reason: change.reason } : {}),
1784
- resource: change.args?.schemaCode ?? change.args?.code ?? null,
1786
+ ...(change.resource !== undefined ? { resource: change.resource } : {}),
1785
1787
  })),
1786
1788
  summaryNote: "--summary 只回变更清单(去 args/基线);apply 用完整 plan(不带 --summary 或 --plan-out <file>)",
1787
1789
  }, transport);
package/dist/goal-plan.js CHANGED
@@ -1062,7 +1062,11 @@ export async function planGoal(registry, goal, options = {}) {
1062
1062
  const scaffoldCode = scaffoldCodeFrom(goal);
1063
1063
  scaffold = { code: scaffoldCode };
1064
1064
  args[key] = scaffoldCode;
1065
- warnings.push(`schemaCode: 目标模型 ${scaffoldCode} 尚不存在——已排 s0 建模脚手架(model.create + field.publish 模型级一次发布);业务字段清单按需求补 field.create(本计划不猜字段)`);
1065
+ // r62a-F1(P0-3):s0→s0p 中间没有字段步骤——发布的是**空模型**。
1066
+ // 计划看起来完整、实际中间是空的(探针真机:得自己插 CREATE 才能跑通)。
1067
+ // 字段清单是需求本体(needs-authoring),计划不猜;但必须明说空心,
1068
+ // 并指路 intent(一次编译全链,含字段)。
1069
+ warnings.push(`schemaCode: 目标模型 ${scaffoldCode} 尚不存在——已排 s0 建模脚手架,但 s0p 此刻发布的是**空模型**(本计划不替你猜字段清单):要么先补 field.create 再发布,要么整包需求改走声明式面(omc intent schema → validate → plan --env),字段/规则/流程一次编译`);
1066
1070
  continue;
1067
1071
  }
1068
1072
  else {
@@ -1164,7 +1168,7 @@ export async function planGoal(registry, goal, options = {}) {
1164
1168
  id: "s0p",
1165
1169
  tool: "field.publish",
1166
1170
  kind: "write",
1167
- purpose: "b-F1 前置链:模型级发布(发布全部草稿字段;流程/视图/规则面依赖已发布字段)",
1171
+ purpose: "b-F1 前置链:模型级发布——注意此刻模型是空的(r62a-F1):字段清单是需求本体,先补 field.create 再发布,或改走 intent 声明式面一次编译全链",
1168
1172
  args: { ...(environment !== null ? { environment } : {}), schemaCode: scaffold.code },
1169
1173
  dependsOn: ["s0"],
1170
1174
  validated: { ok: true, issues: [] },
@@ -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 = ["应用", "系统", "整套", "从零", "从无到有", "端到端", "一条龙", "一整套", "业务应用", "平台"];
@@ -749,7 +749,7 @@ function goalRouteInner(registry, goal) {
749
749
  // 聚合/计数问句的正确答案:data 能力**没有 group-by 工具**,诚实指路
750
750
  // data.list 拉全量 + `--jq` 投影自行计数;跨模型/大结果集才涉及报表章节。
751
751
  // 放在能力打分前,聚合词不再落进任何写阶梯(cue「分组」已从 app 移除)。
752
- if (readish && /(统计|分组|汇总|聚合|计数|条数|多少条|数一下)/.test(goal) && !WRITE_DESTINATION.test(goal)) {
752
+ if (readish && /(统计|分组|汇总|聚合|计数|条数|多少条|有几条|数一下)/.test(goal) && !WRITE_DESTINATION.test(goal)) {
753
753
  const dataRoute = routeById.get("data");
754
754
  if (dataRoute !== undefined) {
755
755
  const readTools = readToolsInLane(registry, dataRoute.lane);
@@ -951,7 +951,18 @@ function goalRouteInner(registry, goal) {
951
951
  // 会把真别名路由也拦掉(bizservice-recipes 别名测试实证)。
952
952
  if (!readish && !WHOLE_APP_CUES.some((cue) => goal.includes(cue))) {
953
953
  const aliasHit = bestAliasRecipe(registry, goal);
954
- if (aliasHit) {
954
+ // r62b-F1(真机复现,P0-1 第三层防御):「合同里金额大于50万的单据有几条」
955
+ // 被配方别名「金额大于」抢到 workflow 写配方——纯读问句拿到写工具,照做
956
+ // 会改生产流程。cue 词表(detectMode)是第一层,但问法无穷(「有几条/
957
+ // 名单/分布/给我拉一份」都可能是漏网的新词)。别名分支自身再判一次:
958
+ // 命中的配方是写工具、而问句带读尾缀时,别名不抢——落回正常能力阶梯
959
+ // (readish 路径会给读工具 + 聚合护栏的诚实指路)。
960
+ const READ_TAIL = /(几条|几个|几笔|多少|哪些|名单|分布|给我|拉一份|导出|统计|汇总|计数|条数)/;
961
+ const aliasToolKind = aliasHit === undefined ? undefined : registry.find((tool) => tool.name === aliasHit.tool)?.kind;
962
+ if (aliasHit && aliasToolKind === "write" && READ_TAIL.test(goal)) {
963
+ // fall through:读意图问句不带写别名路由
964
+ }
965
+ else if (aliasHit) {
955
966
  const action = `omc describe ${aliasHit.tool} --example ${aliasHit.recipe}`;
956
967
  return {
957
968
  status: "ok",
@@ -4,7 +4,7 @@ import { capabilityArg, environmentArg } from "../args.js";
4
4
  import { governedRead } from "../read.js";
5
5
  import { writeTool } from "../write.js";
6
6
  import { decodeJsonColumn, JSON_COLUMN_NULL_COALESCE } from "../json-column.js";
7
- import { applicationResolutionOf, applicationScopeHint, flattenTreeRows, resolveApplicationScope } from "../support.js";
7
+ import { applicationResolutionOf, applicationScopeHint, flattenTreeRows, resolveApplicationScope, suggestModelNames } from "../support.js";
8
8
  import { executeRuleSaveWrite, ruleNodeGraphArg } from "../rule-support.js";
9
9
  import { defineTool, ToolInputError, ToolRefusalError } from "../tool-types.js";
10
10
  import { resolveRuleRowId } from "../identity.js";
@@ -117,11 +117,20 @@ export function registerBusinessRuleLane(tools) {
117
117
  // 直接回 modelPresent:false + rules:[],**不发 list 请求**。
118
118
  const modelRecord = await readModelRecord(session, args.schemaCode);
119
119
  if (modelRecord === null) {
120
+ // r62b-F2(P1-5):带近名候选 + 可转发问句(plan 面 needs-decision 的
121
+ // call 面同款)——探针此前得自己翻 model.list 编问句。
122
+ const suggested = await suggestModelNames(session, args.schemaCode);
120
123
  return {
121
124
  schemaCode: args.schemaCode,
122
125
  modelPresent: false,
123
126
  rules: [],
124
127
  rulesCount: 0,
128
+ ...(suggested !== null
129
+ ? {
130
+ suggestedModels: suggested,
131
+ needsDecision: `未找到「${args.schemaCode}」,是否指 ${suggested.map((model) => `${model.code}(${model.name ?? model.code})`).join(" / ")}?`,
132
+ }
133
+ : {}),
125
134
  hint: "模型不存在(bizmodels/get_all 空)——未发 rule.list 请求(避免补建 7 条不可删预置);判定模型面用 model.inspect",
126
135
  };
127
136
  }
@@ -10,6 +10,7 @@ import { defineTool } from "../tool-types.js";
10
10
  import { resolveDataRuleRow } from "../identity.js";
11
11
  import { wireCall, wireRows, WireError } from "../wire.js";
12
12
  import { runtimeWriteWithAppMapping } from "../runtime-support.js";
13
+ import { suggestModelNames } from "../support.js";
13
14
  import { DATARULE_LANE_CONTRACT, DATARULE_TYPE_OPTION_KEYS } from "./datarule-contract.js";
14
15
  import { normalizeAggregationFormula } from "../field-families.js";
15
16
  import { CONDITION_PROTOCOL_EXAMPLES, dataRuleOptionsShapeError } from "./datarule-protocol.js";
@@ -809,12 +810,20 @@ export function registerDataRuleLane(tools) {
809
810
  // 不把平台 601003 原样 refused(三种读面反应不一致)。
810
811
  const modelRecord = await readModelRecord(session, args.schemaCode);
811
812
  if (modelRecord === null) {
813
+ // r62b-F2(P1-5):与 rule.list 同款近名候选 + 可转发问句。
814
+ const suggested = await suggestModelNames(session, args.schemaCode);
812
815
  return {
813
816
  schemaCode: args.schemaCode,
814
817
  dataRuleType: args.dataRuleType ?? null,
815
818
  modelPresent: false,
816
819
  rules: [],
817
820
  rulesCount: 0,
821
+ ...(suggested !== null
822
+ ? {
823
+ suggestedModels: suggested,
824
+ needsDecision: `未找到「${args.schemaCode}」,是否指 ${suggested.map((model) => `${model.code}(${model.name ?? model.code})`).join(" / ")}?`,
825
+ }
826
+ : {}),
818
827
  hint: "模型不存在(bizmodels/get_all 空)——空规则不是「已清干净的证据」也不是错误;判定模型面用 model.inspect",
819
828
  };
820
829
  }
@@ -865,7 +874,7 @@ export function registerDataRuleLane(tools) {
865
874
  writeTool({
866
875
  tools,
867
876
  name: "datarule.create",
868
- search: { intents: ["字段级校验", "给字段加校验", "给金额字段加校验", "校验规则", "提交校验", "字段校验", "金额校验"] },
877
+ search: { intents: ["字段级校验", "给字段加校验", "给金额字段加校验", "校验规则", "提交校验", "字段校验", "金额校验", "必填才能提交", "必须填", "不填不让提交"] },
869
878
  lane: DATARULE_LANE,
870
879
  scope: DATARULE_TOOLS["datarule.create"].scope,
871
880
  description: DATARULE_TOOLS["datarule.create"].description,
@@ -17,6 +17,26 @@ import { assertListViewConfigureShape, decodeActionRow, decodeButtonRow, decodeC
17
17
  export { assertListViewConfigureShape } from "./list-view-shapes.js";
18
18
  const LIST_VIEW_LANE = LIST_VIEW_LANE_CONTRACT.lane;
19
19
  const LIST_VIEW_TOOLS = LIST_VIEW_LANE_CONTRACT.tools;
20
+ /**
21
+ * r62a-F5 / r61 a-F14:列汇总(sumType)真值在呈现层 queryPresentation.columnsJson
22
+ * ——queryColumns 列树不回它。listview.get 与 listview.configure 的读回共用这个
23
+ * 合并映射,任何读面对同一配置给同一个答案(双面一致)。
24
+ */
25
+ function sumTypeByCodeFromPresentation(model) {
26
+ const out = new Map();
27
+ const rawPresentation = model.queryPresentation;
28
+ if (!rawPresentation || typeof rawPresentation !== "object")
29
+ return out;
30
+ const decodedColumns = decodePresentation(rawPresentation).columnsJson;
31
+ if (!Array.isArray(decodedColumns))
32
+ return out;
33
+ for (const column of decodedColumns) {
34
+ if (column && typeof column === "object" && typeof column.propertyCode === "string" && typeof column.sumType === "number") {
35
+ out.set(String(column.propertyCode), column.sumType);
36
+ }
37
+ }
38
+ return out;
39
+ }
20
40
  function fieldOptions(options) {
21
41
  if (typeof options === "string") {
22
42
  try {
@@ -284,11 +304,16 @@ export function registerListViewLane(tools) {
284
304
  return { schemaCode: args.schemaCode, code, present: false, note: "视图不存在(query/get 空或 302025);先 listview.create 或 listview.configure" };
285
305
  if (args.full === true)
286
306
  return { schemaCode: args.schemaCode, code, present: true, data: model };
307
+ // r62a-F5(P0-2):queryColumns 列树不含 sumType(恒 null/缺键),列汇总
308
+ // 真值在呈现层 queryPresentation.columnsJson——与 listview.configure 的
309
+ // 读回同规则合并,get 面不再逼探针翻 full 原始报文。
310
+ const sumTypeByCode = sumTypeByCodeFromPresentation(model);
287
311
  const columns = readArray(model, "queryColumns").map((column) => ({
288
312
  propertyCode: column.propertyCode,
289
313
  propertyType: column.propertyType,
290
314
  displayFormat: column.displayFormat,
291
315
  visible: column.visible,
316
+ sumType: sumTypeByCode.get(String(column.propertyCode)) ?? column.sumType ?? null,
292
317
  }));
293
318
  // Direction is decoded to the enum NAME (ASC/DESC) — the same shape
294
319
  // `listview.configure` reads back, so a get→configure round-trip does not
@@ -814,23 +839,11 @@ export function registerListViewLane(tools) {
814
839
  }
815
840
  const after = await wireCall(session, { path: ENDPOINTS.listQueryGet, query: { schemaCode: args.schemaCode, code, clientType: "PC" } });
816
841
  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
- }
842
+ // r61 a-F14(r60a-F14 真机定性)+ r62a-F5(P0-2):`queryColumns` 列树**不回
843
+ // sumType**(投影恒 null),列汇总真值在呈现层 `queryPresentation.columnsJson`
844
+ // ——写入面也是它。两面各说各话曾让探针为对账「合计配上了吗」拉全量
845
+ // presentation(26KB artifact 的根因)。get 与 configure 共用合并映射。
846
+ const sumTypeByCode = sumTypeByCodeFromPresentation(afterModel);
834
847
  const afterCols = readArray(afterModel, "queryColumns").map((c) => ({
835
848
  propertyCode: c.propertyCode,
836
849
  propertyType: c.propertyType,
@@ -289,7 +289,7 @@ export function registerPermLane(tools) {
289
289
  return { userId: args.userId, appCode: args.appCode, adminBypass, ...(adminBypass ? { adminNotice: "管理员会话恒通过,不代表普通用户;本回执是管理员旁路标记。" } : {}), app: { visible: bool(first(data, "visible", "appVisible")), administrator: bool(first(data, "administrator", "isAdministrator")), allVisible: bool(first(data, "allVisible")) }, models: authSummary(data).models, fields: args.schemaCode ? authSummary(data).fields : [], rowLevel: authSummary(data).rowLevel, layers: { configResolvable: true, runtimeSessionRequired: "真实 load/write 判定受对象权限/业务调用/临时流程授权影响——本工具拒绝单值 allow/deny;验证走目标用户会话或 data.load 双读" } };
290
290
  }) }));
291
291
  writeTool({ tools, name: "perm.assign", lane: PERM_LANE, scope: PERM_TOOLS["perm.assign"].scope, description: PERM_TOOLS["perm.assign"].description, search: { intents: ["把部门加到权限组", "授权权限组", "给权限组加成员"] }, inputSchema: { appCode: z.string().min(1), groupId: z.string().min(1), units: z.array(z.object({ type: z.enum(["DEPT", "ROLE", "USER"]), id: z.string().min(1), name: z.string().optional() })).min(1), mode: z.enum(["assign", "revoke"]) }, execute: async (session, args) => { const unitType = { DEPT: 1, ROLE: 2, USER: 3 }[args.units[0].type]; const units = args.units.map((u) => ({ unitId: u.id, unitType: { DEPT: 1, ROLE: 2, USER: 3 }[u.type], name: u.name ?? "", corpId: session.enterpriseId(), appCode: args.appCode, groupId: args.groupId })); const body = args.mode === "assign" ? { permissionGroupUnits: units, permGroupInfos: [{ appCode: args.appCode, permGroupId: args.groupId }] } : { permGroupIds: [args.groupId], unitIds: args.units.map((u) => u.id), permissionGroupUnits: units, permGroupInfos: [{ appCode: args.appCode, permGroupId: args.groupId }] }; const before = (await wireCall(session, { path: ENDPOINTS.permissionGroup, method: "GET", query: { id: args.groupId, appCode: args.appCode } })).data; const performed = await wireCall(session, { path: args.mode === "assign" ? ENDPOINTS.permissionAssign : ENDPOINTS.permissionRevoke, method: "POST", body }); const after = (await wireCall(session, { path: ENDPOINTS.permissionGroup, method: "GET", query: { id: args.groupId, appCode: args.appCode } })).data; const listAfter = (await wireCall(session, { path: ENDPOINTS.permissionGroupUnits, method: "POST", body: { ...units[0], unitType, appCode: args.appCode, corpId: session.enterpriseId() } })).data; return { performed: { errcode: performed.errcode, mode: args.mode }, readback: { groups: permissionGroupRows(listAfter).map(groupView), source: "post-write listPermissionGroups readback (not write echo)", diff: { before: projectMembers(before), after: projectMembers(after) } } }; } });
292
- writeTool({ tools, name: "perm.auth", lane: PERM_LANE, scope: PERM_TOOLS["perm.auth"].scope, description: PERM_TOOLS["perm.auth"].description, search: { intents: ["配模型权限", "设行级权限", "配数据权限"] }, inputSchema: { appCode: z.string().min(1), groupId: z.string().min(1), grants: z.array(z.object({ schemaCode: z.string().min(1), visible: z.object({ pc: z.boolean(), mobile: z.boolean() }).optional(), rowLevel: z.object({ type: z.number().int().min(1).max(6).describe("1=全部可见,2=本部门,3=仅自己,4=自定义(须 conditions),5=角色管理范围,6=均不可见"), conditions: z.array(z.array(z.unknown())).optional() }).optional(), properties: z.array(z.object({ propertyCode: z.string().optional(), schemaCode: z.string().optional().describe("可省略,继承 grants.schemaCode"), visible: z.boolean().optional(), writeAble: z.boolean().optional(), decryptAble: z.boolean().optional() })).optional(), actions: z.object({ view: z.array(z.string()).optional(), form: z.array(z.string()).optional() }).optional() })).min(1), mode: z.enum(["merge"]).default("merge") }, preflight: (args) => validateGrants(args.grants), execute: async (session, args) => { const group = (await wireCall(session, { path: ENDPOINTS.permissionGroup, method: "GET", query: { id: args.groupId, appCode: args.appCode } })).data; const existing = permissionRecords(group); const mergedRecords = []; const beforeRecords = []; for (const grant of args.grants) {
292
+ writeTool({ tools, name: "perm.auth", lane: PERM_LANE, scope: PERM_TOOLS["perm.auth"].scope, description: PERM_TOOLS["perm.auth"].description, search: { intents: ["配模型权限", "设行级权限", "配数据权限", "只能看自己的", "别让他看到", "只能看到自己提的"] }, inputSchema: { appCode: z.string().min(1), groupId: z.string().min(1), grants: z.array(z.object({ schemaCode: z.string().min(1), visible: z.object({ pc: z.boolean(), mobile: z.boolean() }).optional(), rowLevel: z.object({ type: z.number().int().min(1).max(6).describe("1=全部可见,2=本部门,3=仅自己,4=自定义(须 conditions),5=角色管理范围,6=均不可见"), conditions: z.array(z.array(z.unknown())).optional() }).optional(), properties: z.array(z.object({ propertyCode: z.string().optional(), schemaCode: z.string().optional().describe("可省略,继承 grants.schemaCode"), visible: z.boolean().optional(), writeAble: z.boolean().optional(), decryptAble: z.boolean().optional() })).optional(), actions: z.object({ view: z.array(z.string()).optional(), form: z.array(z.string()).optional() }).optional() })).min(1), mode: z.enum(["merge"]).default("merge") }, preflight: (args) => validateGrants(args.grants), execute: async (session, args) => { const group = (await wireCall(session, { path: ENDPOINTS.permissionGroup, method: "GET", query: { id: args.groupId, appCode: args.appCode } })).data; const existing = permissionRecords(group); const mergedRecords = []; const beforeRecords = []; for (const grant of args.grants) {
293
293
  const prior = existing.find((record) => String(first(record, "schemaCode", "functionCode") ?? "") === grant.schemaCode);
294
294
  if (!prior)
295
295
  throw new ToolRefusalError({ status: "refused", blocker: "permission-target-model-unknown", message: `权限组中不存在模型 ${grant.schemaCode};候选:${existing.map((record) => String(first(record, "schemaCode", "functionCode") ?? "")).filter(Boolean).join(", ")}` });
@@ -1065,7 +1065,7 @@ async function diagnoseDbException(session, schemaCode, error) {
1065
1065
  export function registerRuntimeDataLane(tools) {
1066
1066
  tools.push(defineTool({
1067
1067
  name: "data.list",
1068
- search: { intents: ["查业务数据", "查询数据", "查数据", "查记录", "查单据"] },
1068
+ search: { intents: ["查业务数据", "查询数据", "查数据", "查记录", "查单据", "统计数据", "汇总数据", "分组统计", "数条数", "总条数", "导出数据", "多少条", "有几条"] },
1069
1069
  layer: "low",
1070
1070
  kind: "read",
1071
1071
  lane: RUNTIME_LANE,
@@ -1860,7 +1860,7 @@ export function registerRuntimeDataLane(tools) {
1860
1860
  writeTool({
1861
1861
  tools,
1862
1862
  name: "data.update",
1863
- search: { intents: ["改一条记录", "编辑单据", "更新业务数据"] },
1863
+ search: { intents: ["改一条记录", "编辑单据", "更新业务数据", "改数据", "录错了改回来", "修正数据"] },
1864
1864
  lane: RUNTIME_LANE,
1865
1865
  scope: RUNTIME_TOOLS["data.update"].scope,
1866
1866
  description: RUNTIME_TOOLS["data.update"].description,
@@ -2425,6 +2425,8 @@ export function registerRuntimeDataLane(tools) {
2425
2425
  schemaCode: typeof performedData.schemaCode === "string" ? performedData.schemaCode : args.schemaCode,
2426
2426
  formCode: typeof performedData.formCode === "string" ? performedData.formCode : sheetCode,
2427
2427
  sequenceStatus,
2428
+ // r62a-F7:无流程模型不存在待办——显式说明,null 不再歧义。
2429
+ workItemState: "none-no-workflow",
2428
2430
  ...(sequenceStatus === null ? { missingSequenceStatus: true } : {}),
2429
2431
  // r28b F2(真机 2026-11-05 复现):模型没配业务流水号时,平台把
2430
2432
  // `sequenceNo` 直接回填成 objectId 本身——32 位 hex 长得像单号,
@@ -2434,6 +2436,21 @@ export function registerRuntimeDataLane(tools) {
2434
2436
  ? { sequenceNoSource: "object-id", sequenceNoNote: "本模型未配置业务流水号:sequenceNo 回填的是 objectId 本身(不是生成的单号)。要单号请在模型上配序列号字段。" }
2435
2437
  : {}),
2436
2438
  submittedData: projectReadbackRecord(record, args),
2439
+ // r62a-F10(P1-9):无流程分支的 name 覆盖检测(与 approval 分支同款)——
2440
+ // 真机实证无流程模型也会把传入 name 换成「发起人+模型名+时间」标题。
2441
+ ...(() => {
2442
+ const wanted = (formData ?? {});
2443
+ const wantedName = typeof wanted.name === "string" && wanted.name.trim() !== "" ? wanted.name : null;
2444
+ const landedNameRaw = typeof record.name === "string"
2445
+ ? record.name
2446
+ : typeof (record.fields ?? {}).name === "string"
2447
+ ? String(record.fields.name)
2448
+ : null;
2449
+ const landedName = landedNameRaw !== null && landedNameRaw.trim() !== "" ? landedNameRaw : null;
2450
+ if (wantedName === null || landedName === null || landedName === wantedName)
2451
+ return {};
2452
+ return { nameOverridden: { wanted: wantedName, landed: landedName, note: "name 是平台数据标题(自动生成优先):传入值被覆盖,业务字段请用自有 code(如 title/subject)" } };
2453
+ })(),
2437
2454
  ...(serialGenerationFailed.length > 0
2438
2455
  ? { serialGenerationFailed, serialGenerationWarning: SERIAL_GENERATION_FAILURE_NOTE }
2439
2456
  : {}),
@@ -2484,8 +2501,32 @@ export function registerRuntimeDataLane(tools) {
2484
2501
  // The submit response often has no workItemId; when the engine created
2485
2502
  // the next todo, its first item is the authoritative continuation id.
2486
2503
  workItemId: typeof performedData.workItemId === "string" ? performedData.workItemId : null,
2504
+ // r62a-F7(P1-8):workItemId 裸 null 有三态歧义——「没有待办」「待办
2505
+ // 不在我名下(真答案曾只藏在 flowWarning 文案里)」「流程已走完」。
2506
+ // workItemState 显式判别,null 时读这个键。
2507
+ workItemState: sequenceStatus === "COMPLETED" ? "none-flow-completed"
2508
+ : hasWorkItem ? "consumed-by-this-submit"
2509
+ : "pending-or-none",
2487
2510
  sequenceStatus,
2488
2511
  submittedData: approvalDelta ? projectApprovalReadback(loadedRecord, Object.keys(formData ?? {})) : projectReadbackRecord(loadedRecord, args),
2512
+ // r62a-F10(P1-9):formData.name 是平台数据标题的**建议值**——引擎按
2513
+ // 「发起人+模型名+时间」生成标题时,传的 name 被静默替换且无告警(探针
2514
+ // 传「r62a_差旅-短程」得到「付文彬的差旅申请 2026-11-13 …」)。检测
2515
+ // 覆盖并点名,别让调用方以为标题没生效是 bug。
2516
+ ...(() => {
2517
+ const wanted = (formData ?? {});
2518
+ const landed = (loadedRecord ?? {});
2519
+ // data.load 的行形状 name 可能平铺或在 fields.name——两形都认。
2520
+ const landedFields = (landed.fields ?? {});
2521
+ const wantedName = typeof wanted.name === "string" && wanted.name.trim() !== "" ? wanted.name : null;
2522
+ const landedNameRaw = typeof landed.name === "string" ? landed.name : typeof landedFields.name === "string" ? landedFields.name : null;
2523
+ const landedName = landedNameRaw !== null && landedNameRaw.trim() !== "" ? landedNameRaw : null;
2524
+ if (wantedName === null || landedName === null || landedName === wantedName)
2525
+ return {};
2526
+ return {
2527
+ nameOverridden: { wanted: wantedName, landed: landedName, note: "name 是平台数据标题(自动生成优先):传入值被覆盖,业务字段请用自有 code(如 title/subject),不要用 name 承载业务语义" },
2528
+ };
2529
+ })(),
2489
2530
  ...(approvalDelta
2490
2531
  ? { readbackShape: "approval-delta", readbackHint: "审批提交默认只回 sequenceStatus + 本次提交的字段;要整条记录(含子表/系统字段)加 full:true,要指定字段加 fields:[...]" }
2491
2532
  : {}),
@@ -2570,6 +2611,8 @@ export function registerRuntimeDataLane(tools) {
2570
2611
  .map((person) => person.name ?? person.id)
2571
2612
  .filter((value) => typeof value === "string" && value.length > 0);
2572
2613
  const holders = holderNames.length > 0 ? holderNames.join("、") : "(参与人未回显)";
2614
+ // r62a-F7:主键同步——「待办在别处」从 flowWarning 文案提升为主键判别值。
2615
+ readback.workItemState = "pending-elsewhere";
2573
2616
  if (rejected) {
2574
2617
  readback.returnedTo = { activityCode: first.activityCode, activityName: first.activityName };
2575
2618
  readback.nextSubmit = {
@@ -2585,6 +2628,9 @@ export function registerRuntimeDataLane(tools) {
2585
2628
  activityCode: first.activityCode,
2586
2629
  activityName: first.activityName,
2587
2630
  participants: first.participants,
2631
+ // r62a-F7:主键 workItemState 同步改写——探针读主键就能判「在别处」,
2632
+ // 不必解析 warning 文案。
2633
+ workItemState: "pending-elsewhere",
2588
2634
  checks: [
2589
2635
  `omc call workflow.instanceActivity --args '{"workflowInstanceId":"${effectiveInstanceId}"}'`,
2590
2636
  `omc call workitem.list --args '{"workflowInstanceId":"${effectiveInstanceId}","participant":"<持有人 id>"}'`,
@@ -2695,6 +2695,9 @@ export function registerWorkflowLane(tools) {
2695
2695
  });
2696
2696
  const body = await mergedTemplateBody(session, args.schemaCode, args.code, template, merge);
2697
2697
  validateWorkflowRender(body, "workflow.update");
2698
+ // r62a-F2(P1-6):条件枚举校验必须在 dry-run 同门跑——GE/GT= 这类直觉
2699
+ // 缩写此前只有真写才拒,dry-run 假绿(wouldChange:true 无 issues)。
2700
+ validateWorkflowRouteConditions(body, "workflow.update");
2698
2701
  const edgeKeys = (rules) => (Array.isArray(rules) ? rules : []).map((rule) => `${String(rule.preActivityCode ?? "")}->${String(rule.postActivityCode ?? "")}`);
2699
2702
  const beforeEdges = edgeKeys(draft.rules);
2700
2703
  const afterEdges = edgeKeys(body.rules);
@@ -3216,6 +3219,11 @@ export function registerWorkflowLane(tools) {
3216
3219
  .optional()
3217
3220
  .describe("可选:发布后绑定业务规则;每项 {handler?,ruleCodes[]},handler 取 start|cancel|activate|end(缺省 end)"),
3218
3221
  },
3222
+ // r62a-F2(P1-6):条件枚举校验进 preflight——semanticGate 在 dry-run 与真写
3223
+ // 都跑(r29c F1b 同门原则),GE/GT= 这类直觉缩写此前 dry-run 假绿、真写才拒。
3224
+ preflight: (args) => {
3225
+ validateWorkflowRouteConditions((args.template ?? {}), "configure_workflow");
3226
+ },
3219
3227
  plan: (args) => {
3220
3228
  const actions = [
3221
3229
  { tool: "workflow.create", args: { schemaCode: args.schemaCode, name: args.name, code: args.code } },
package/dist/plan.js CHANGED
@@ -27,8 +27,11 @@ export function planFingerprint(plan) {
27
27
  /**
28
28
  * r28g F8(真机 2026-11-05):dry-run 的 `*Summary` 只给键名 + sha256,把**最该
29
29
  * 自查的那段**(三层转义后的条件串)整个遮住——校验通过的结论看得见,被校验的
30
- * 内容看不见。这里补一个 `*Preview`:把**小**的字符串叶子原样列出(总长 ≤400B),
30
+ * 内容看不见。这里补一个 `*Preview`:把**小**的标量叶子原样列出(总长 ≤400B),
31
31
  * 超了就不给(还是回到摘要)。目的是"可自查形状",不是把正文搬回来。
32
+ * r62a-F10(P1-9):只收 string 会把数值/布尔叶子吞掉——探针 dry-run 提交
33
+ * {days:2, amount:1200.5} 时 formDataPreview 只见字符串字段,提交前无法核对
34
+ * 数值解析。扩展为全部标量(string/number/boolean)。
32
35
  */
33
36
  function smallStringPreview(value) {
34
37
  if (value === null || typeof value !== "object" || Array.isArray(value))
@@ -36,9 +39,9 @@ function smallStringPreview(value) {
36
39
  const out = {};
37
40
  let budget = 400;
38
41
  for (const [key, entry] of Object.entries(value)) {
39
- if (typeof entry !== "string")
42
+ if (typeof entry !== "string" && typeof entry !== "number" && typeof entry !== "boolean")
40
43
  continue;
41
- const bytes = Buffer.byteLength(entry, "utf8");
44
+ const bytes = Buffer.byteLength(String(entry), "utf8");
42
45
  if (bytes > budget)
43
46
  continue;
44
47
  budget -= bytes;
package/dist/read.js CHANGED
@@ -169,6 +169,23 @@ function compactReadback(result) {
169
169
  compact[key] = value.map(activityOfEntry).filter((entry) => entry !== undefined);
170
170
  compact[`${key}Count`] = value.length;
171
171
  }
172
+ else if (key === "rules" && Array.isArray(value)) {
173
+ // r62b-F3(P1-10):rules 折叠成 `rules:[]`+artifact 曾逼探针二次取回——
174
+ // 9 条规则连名字都看不到。瘦身版 [{code,name,enabled,defaultRule}] ~40B/条,
175
+ // **≤12 条**内联(~500B,回答「配了哪些规则/几条自建几条预置」);更大的
176
+ // 清单保持外置语义(readback-diet 的 token 经济不变),正文仍在 artifact。
177
+ if (value.length <= 12) {
178
+ const slim = value
179
+ .map((rule) => ({
180
+ code: typeof rule.code === "string" ? rule.code : null,
181
+ name: typeof rule.name === "string" ? rule.name : null,
182
+ ...(rule.enabled !== undefined ? { enabled: rule.enabled } : {}),
183
+ ...(rule.defaultRule !== undefined ? { defaultRule: rule.defaultRule } : {}),
184
+ }));
185
+ compact[key] = slim;
186
+ }
187
+ compact[`${key}Count`] = value.length;
188
+ }
172
189
  else if (BULKY_READ_KEYS.has(key)) {
173
190
  compact[`${key}Count`] = Array.isArray(value) ? value.length : value && typeof value === "object" ? Object.keys(value).length : 0;
174
191
  }
package/dist/support.js CHANGED
@@ -165,4 +165,55 @@ export async function mapBounded(items, limit, worker) {
165
165
  await Promise.all(runners);
166
166
  return results;
167
167
  }
168
+ /**
169
+ * r62b-F2(P1-5):call 面判定「模型不存在」时的近名候选(top3)。
170
+ * plan 面已有 needs-decision blocker(c-F12),call 面(rule.list / datarule.list
171
+ * 的 modelPresent:false)此前只回一句判定——探针为编一个可转发的问句得自己翻
172
+ * model.list 清单。计分用双向子串 + 共享 2-gram(不引编辑距离库,call 面只需
173
+ * 「最接近的几个」)。候选是加分项:树拉不到就回 null,绝不阻塞主判定。
174
+ */
175
+ export async function suggestModelNames(session, asked) {
176
+ try {
177
+ const scope = await resolveApplicationScope(session);
178
+ const tree = flattenTreeRows(wireRows((await wireCall(session, { path: ENDPOINTS.applicationTree, query: { appCode: scope.code } })).data));
179
+ const models = tree
180
+ .filter((row) => row.type === "BizModel" && typeof row.code === "string" && row.code)
181
+ .map((row) => ({ code: String(row.code), name: typeof row.name === "string" ? row.name : typeof row.text === "string" ? row.text : null }));
182
+ const needle = asked.trim().toLowerCase();
183
+ if (needle === "" || models.length === 0)
184
+ return null;
185
+ const bigrams = (text) => {
186
+ const normalized = text.toLowerCase();
187
+ const out = new Set();
188
+ for (let i = 0; i + 2 <= normalized.length; i++)
189
+ out.add(normalized.slice(i, i + 2));
190
+ return out;
191
+ };
192
+ const askedBigrams = bigrams(asked);
193
+ const scored = models
194
+ .map((model) => {
195
+ const haystack = `${model.code} ${model.name ?? ""}`.toLowerCase();
196
+ let score = 0;
197
+ if (haystack.includes(needle))
198
+ score += 10;
199
+ if (model.name !== null && needle.includes(model.name.toLowerCase()) && model.name.length >= 2)
200
+ score += 8;
201
+ const modelBigrams = bigrams(`${model.code}${model.name ?? ""}`);
202
+ let shared = 0;
203
+ for (const gram of askedBigrams)
204
+ if (modelBigrams.has(gram))
205
+ shared++;
206
+ score += shared;
207
+ return { model, score };
208
+ })
209
+ .filter((entry) => entry.score >= 2)
210
+ .sort((left, right) => right.score - left.score)
211
+ .slice(0, 3)
212
+ .map((entry) => entry.model);
213
+ return scored.length > 0 ? scored : null;
214
+ }
215
+ catch {
216
+ return null;
217
+ }
218
+ }
168
219
  //# sourceMappingURL=support.js.map
@@ -91,6 +91,13 @@ const TOOL_INPUT_ALIASES = Object.freeze({
91
91
  // 没有自己的 `code` 参数,无歧义)。
92
92
  "workflow.get_draft": Object.freeze({ workflowCode: ["code"] }),
93
93
  "workflow.get_published": Object.freeze({ workflowCode: ["code"] }),
94
+ // r62a-F4(P1-7):workflow.validate 是同族读面——写面(update/publish)用
95
+ // `code`、读面用 `workflowCode`,从 update 抄参数过来就被 unknown-keys 拒。
96
+ "workflow.validate": Object.freeze({ workflowCode: ["code"] }),
97
+ // r62c-F6(P1-7):模型 code 的键名分裂——model-purge 收 `--code`、
98
+ // model.delete/model.list 收 `schemaCode`、model.inspect 也收 `schemaCode`。
99
+ // 同一个概念(模型的 code)在读写面间换了名字,读面归一。
100
+ "model.inspect": Object.freeze({ schemaCode: ["code"] }),
94
101
  // field family: the platform's own column key is `propertyCode`; the tool's is
95
102
  // `code`. Same field, so the alias is safe either direction.
96
103
  "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.51",
3
+ "version": "0.6.52",
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.51",
59
+ "omc-core": "0.6.52",
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.51"
77
+ "@stalfh233/omc-fake-platform": "0.6.52"
78
78
  }
79
79
  }
@@ -1,27 +0,0 @@
1
- import { claim, declareLaneCoverage } from "./coverage-declaration.js";
2
- import { LANES } from "./lane-ids.js";
3
- /**
4
- * Organization writes (role group / role / members / management scope) sit on
5
- * the same live-proven template lane; the scopes below are claimed here so the
6
- * runtime gate can resolve them without a second manifest item.
7
- */
8
- export const ORGANIZATION_COVERAGE = declareLaneCoverage(LANES.workflow, [
9
- {
10
- capability: "W7 S29 greenfield workflow authoring",
11
- evidence: [
12
- "packages/omc-cli/src/lanes/organization.ts",
13
- "OpenAPI /api/v3/api-docs (1.1.25): organization/role/add_role, add_role_user, update_ouscope",
14
- ],
15
- tools: [
16
- claim("org.role.users", "organization role member read (role/users)"),
17
- claim("org.role.userScope", "organization role member management scope read (role/get_ouscope)"),
18
- claim("org.roleGroup.create", "organization role group create (role/add_role_group)"),
19
- claim("org.role.create", "organization role create (role/add_role)"),
20
- claim("org.role.update", "organization role update (role/modify_role)"),
21
- claim("org.role.addUsers", "organization role member add (role/add_role_user)"),
22
- claim("org.role.removeUsers", "organization role member remove (role/strike_out_role_user)"),
23
- claim("org.role.setUserScope", "organization role member scope update (role/update_ouscope)"),
24
- ],
25
- },
26
- ]);
27
- //# sourceMappingURL=organization-coverage.js.map