@stalfh233/omc-cli 0.6.84 → 0.6.85

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.
@@ -0,0 +1,477 @@
1
+ import { z } from "zod";
2
+ import { createArtifact } from "../artifacts.js";
3
+ import { capabilityArg, environmentArg } from "../args.js";
4
+ import { governedRead } from "../read.js";
5
+ import { canonicalForVerify, deepDiff } from "../rollback-spec.js";
6
+ import { defineTool, ToolInputError } from "../tool-types.js";
7
+ import { ENDPOINTS } from "../endpoints.js";
8
+ import { wireCall } from "../wire.js";
9
+ import { getWorkflowDraftOrNull, isWorkflowAbsent, resolveWorkflowArg, workflowCompactProjection } from "./workflow.js";
10
+ import { readFormOrNull } from "../form-support.js";
11
+ import { parseControlCodes, resolveSheetCode } from "./form.js";
12
+ import { WORKFLOW_LANE_CONTRACT } from "./workflow-contract.js";
13
+ /**
14
+ * `config.diff` — draft↔published triage for ONE configuration target
15
+ * (R88 #1). The first move for symptom asks like 「按钮不见了 / 规则没生效 /
16
+ * 表单没更新」: it answers WHICH face is behind before anyone edits anything.
17
+ *
18
+ * Domain adapters instead of two tools (byte budget: one registry row):
19
+ * - workflow: get_draft vs get_published templates, diffed on the SAME
20
+ * compact summary projection get_draft/get_published already return (single
21
+ * source for activities/edges + the THREE binding faces), plus a canonical
22
+ * raw-template deep scan so deep-field drift (notify/callback bodies) can
23
+ * never hide behind the projection.
24
+ * - form: bizsheet/get's draft*Json vs published*Json, parsed and diffed per
25
+ * control key — never a text diff of the six JSON strings.
26
+ *
27
+ * Honesty contract: one face absent is answered as `changed:null` + verdict,
28
+ * never as an empty diff; `totalKnown` is the exact difference count (the
29
+ * engine never stops at the inline cap); the full diff and both face
30
+ * snapshots live in a 0600 artifact (participants/scripts are sensitive).
31
+ */
32
+ const CONFIG_DIFF_TOOLS = WORKFLOW_LANE_CONTRACT.tools;
33
+ const PREVIEW_BUDGET = 140;
34
+ const DEFAULT_LIMIT = 20;
35
+ const MAX_LIMIT = 200;
36
+ /** Entries kept in the ARTIFACT's semanticDiff — bounded, but far past the inline cap. */
37
+ const ARTIFACT_LIMIT = 500;
38
+ function previewValue(value) {
39
+ if (value === null || value === undefined)
40
+ return value;
41
+ const text = typeof value === "string" ? value : JSON.stringify(value);
42
+ if (text === undefined)
43
+ return value;
44
+ return text.length > PREVIEW_BUDGET ? `${text.slice(0, PREVIEW_BUDGET)}…(${text.length}B,全量在 diffArtifactId)` : value;
45
+ }
46
+ /**
47
+ * Inline slice of a full report: entries are in deterministic walk order, so
48
+ * slicing the ARTIFACT_LIMIT report equals re-walking with the smaller limit
49
+ * — one walk serves both the receipt and the artifact.
50
+ *
51
+ * DIRECTION: every diff here runs published → draft, so `before` is the
52
+ * CURRENT (live) face and `after` is what publishing would make it. A row that
53
+ * exists only in the draft therefore reads `[+code]` ("would be added"), and
54
+ * content the draft dropped reads `[-code]`. Reversing this would make the
55
+ * receipt claim the published face is about to change backwards.
56
+ */
57
+ function inlineSlice(report, limit) {
58
+ const changes = report.entries.slice(0, limit).map((entry) => ({ path: entry.path, before: previewValue(entry.before), after: previewValue(entry.current) }));
59
+ return { changes, truncated: report.totalKnown > changes.length, remaining: report.totalKnown - changes.length };
60
+ }
61
+ function inlineShapeWarnings(report) {
62
+ return report.shapeWarnings.length > 0
63
+ ? { shapeWarnings: report.shapeWarnings, ...(report.shapeWarningsOmitted !== undefined ? { shapeWarningsOmitted: report.shapeWarningsOmitted } : {}) }
64
+ : {};
65
+ }
66
+ function writeDiffArtifact(ctx, payload) {
67
+ const artifact = createArtifact(ctx.artifactsDir, `${JSON.stringify(payload, null, 2)}\n`);
68
+ return { diffArtifactId: artifact.artifactId, diffSha256: artifact.sha256 };
69
+ }
70
+ /* ── workflow domain ───────────────────────────────────────────────────── */
71
+ /**
72
+ * The diffable form of `workflowSummary`: the projection already normalizes
73
+ * activities/edges and separates the three binding faces; here the rows get
74
+ * STABLE business keys so deepDiff aligns by identity instead of position,
75
+ * and derived/face-marker keys (index, ruleBindingCount, templateType) drop
76
+ * out so they cannot manufacture noise.
77
+ */
78
+ function diffableWorkflowSummary(data) {
79
+ const summary = workflowCompactProjection({ data }).workflowSummary;
80
+ if (summary === undefined)
81
+ return {};
82
+ const rest = { ...summary };
83
+ delete rest.templateType;
84
+ delete rest.ruleBindingCount;
85
+ if (Array.isArray(rest.activities)) {
86
+ rest.activities = rest.activities.map((node) => {
87
+ const kept = { ...node };
88
+ delete kept.index;
89
+ return kept;
90
+ });
91
+ }
92
+ if (Array.isArray(rest.edges)) {
93
+ rest.edges = rest.edges.map((edge) => ({ code: `${String(edge.from)}->${String(edge.to)}`, ...edge }));
94
+ }
95
+ if (Array.isArray(rest.ruleBindings)) {
96
+ rest.ruleBindings = rest.ruleBindings.map((row) => ({ code: String(row.handler ?? ""), ...row }));
97
+ }
98
+ if (Array.isArray(rest.nodeRuleBindings)) {
99
+ rest.nodeRuleBindings = rest.nodeRuleBindings.map((row) => ({ code: `${String(row.activityCode ?? "")}.${String(row.nodeEvent ?? "")}`, ...row }));
100
+ }
101
+ // The projection OMITS empty binding arrays; normalizing to [] makes a
102
+ // draft-only binding report as nodeRuleBindings[+Activity2.endActivity]
103
+ // instead of one coarse whole-key entry (per-rule granularity for triage).
104
+ for (const key of ["ruleBindings", "nodeRuleBindings", "systemRuleBindings"]) {
105
+ if (!Array.isArray(rest[key]))
106
+ rest[key] = [];
107
+ }
108
+ return rest;
109
+ }
110
+ /** canonical raw template minus the face markers themselves (templateType; published/workflowVersion are volatile keys already dropped). */
111
+ function canonicalFace(template) {
112
+ if (template === null)
113
+ return null;
114
+ const canonical = canonicalForVerify(parseJsonStringsDeep(template));
115
+ delete canonical.templateType;
116
+ // `refIds` is materialized by the platform's own save path (observed: draft
117
+ // gains `refIds: null` after a plain workflow.update while the published
118
+ // snapshot has no such key). Absent ≡ null ≡ [] — a derived reference index,
119
+ // not authored configuration; keep a NON-empty list comparable.
120
+ if (canonical.refIds === null || (Array.isArray(canonical.refIds) && canonical.refIds.length === 0))
121
+ delete canonical.refIds;
122
+ return canonical;
123
+ }
124
+ /** Cheap triage: binding counts per face class, both sides. */
125
+ function bindingFaceCounts(draftSummary, publishedSummary) {
126
+ const faces = {};
127
+ for (const key of ["ruleBindings", "nodeRuleBindings", "systemRuleBindings"]) {
128
+ const draft = Array.isArray(draftSummary[key]) ? draftSummary[key].length : 0;
129
+ const published = Array.isArray(publishedSummary[key]) ? publishedSummary[key].length : 0;
130
+ if (draft > 0 || published > 0)
131
+ faces[key] = { draft, published };
132
+ }
133
+ return faces;
134
+ }
135
+ async function diffWorkflow(session, args) {
136
+ const workflowCode = await resolveWorkflowArg(session, args);
137
+ if (workflowCode === null)
138
+ return {
139
+ kind: "verdict",
140
+ receipt: {
141
+ domain: "workflow",
142
+ target: { schemaCode: args.schemaCode ?? null, workflowCode: null },
143
+ draft: { present: false },
144
+ published: { present: false },
145
+ changed: null,
146
+ changes: [],
147
+ verdict: "absent",
148
+ note: "该模型没有流程(isworkflow=false)——没有可比的双面;先 workflow.create",
149
+ },
150
+ };
151
+ const target = { schemaCode: args.schemaCode ?? null, workflowCode };
152
+ const draft = await getWorkflowDraftOrNull(session, workflowCode);
153
+ let publishedData = null;
154
+ try {
155
+ publishedData = ((await wireCall(session, { path: ENDPOINTS.workflowGetPublished, query: { workflowCode } })).data ?? null);
156
+ }
157
+ catch (error) {
158
+ if (!isWorkflowAbsent(error))
159
+ throw error;
160
+ }
161
+ const draftPresent = draft !== null;
162
+ // The platform answers the DRAFT shape on get_published for an UNPUBLISHED
163
+ // workflow — data presence is not publish evidence; only the markers are.
164
+ const publishedPresent = publishedData !== null && (publishedData.templateType === "PUBLISH" || publishedData.published === true);
165
+ const base = {
166
+ domain: "workflow",
167
+ target,
168
+ draft: { present: draftPresent },
169
+ published: { present: publishedPresent },
170
+ ...(publishedData !== null && !publishedPresent
171
+ ? { publishedNote: "平台对未发布流程在 get_published 仍回草稿形态——按 present:false 处理,此读回不是已发布证据" }
172
+ : {}),
173
+ };
174
+ if (draft === null || publishedData === null || !publishedPresent) {
175
+ const verdict = draft !== null ? "draft-only" : publishedPresent ? "published-only" : "absent";
176
+ return {
177
+ kind: "verdict",
178
+ receipt: {
179
+ ...base,
180
+ changed: null,
181
+ changes: [],
182
+ verdict,
183
+ note: verdict === "draft-only"
184
+ ? "草稿面存在、发布面不存在——所有草稿改动都未生效;确认草稿后 workflow.publish"
185
+ : verdict === "published-only"
186
+ ? "发布面存在、草稿面不存在——发布面就是现行配置;要改先 workflow.update 重建草稿基线"
187
+ : "双面都不存在(get_draft/get_published 均缺席)——先 workflow.create",
188
+ },
189
+ };
190
+ }
191
+ const draftSummary = diffableWorkflowSummary(draft);
192
+ const publishedSummary = diffableWorkflowSummary(publishedData);
193
+ // published → draft: before = 现行发布面,after = 发布后会变成的草稿面。
194
+ const semantic = deepDiff(publishedSummary, draftSummary, { limit: ARTIFACT_LIMIT });
195
+ // Coarse coverage of everything the projection does not expand (notify
196
+ // bodies, lifecycle-callback configs, btnConfigList internals): the same
197
+ // canonicalization rollback verification uses, so "what counts as the same
198
+ // durable config" has ONE definition across the CLI.
199
+ const deepScan = deepDiff(canonicalFace(publishedData), canonicalFace(draft), { limit: 5 });
200
+ return { kind: "diff", base, semantic, deepScan, faces: bindingFaceCounts(draftSummary, publishedSummary), draft, publishedData, target };
201
+ }
202
+ /* ── form domain ───────────────────────────────────────────────────────── */
203
+ const FORM_FACE_PAIRS = [
204
+ { key: "view", draftKey: "draftViewJson", publishedKey: "publishedViewJson" },
205
+ { key: "attributes", draftKey: "draftAttributesJson", publishedKey: "publishedAttributesJson" },
206
+ { key: "html", draftKey: "draftHtmlJson", publishedKey: "publishedHtmlJson" },
207
+ { key: "actions", draftKey: "draftActionsJson", publishedKey: "publishedActionsJson" },
208
+ ];
209
+ /** Parse a stored JSON face; a parse failure returns the raw string so deepDiff's jsonProbe names it as a shapeWarning. */
210
+ function parseJsonFace(value) {
211
+ if (typeof value !== "string")
212
+ return null;
213
+ try {
214
+ return JSON.parse(value);
215
+ }
216
+ catch {
217
+ return value;
218
+ }
219
+ }
220
+ function isEmptyFace(value) {
221
+ if (value === null)
222
+ return true;
223
+ if (Array.isArray(value))
224
+ return value.length === 0;
225
+ return typeof value === "object" && Object.keys(value).length === 0;
226
+ }
227
+ /**
228
+ * Null ≡ "[]" ≡ "{}" for ONE face pair: the platform stores absent faces as
229
+ * null and cleared/never-authored faces as empty JSON, and publish stamps
230
+ * publishedActionsJson:"[]" while the draft column stays null — that
231
+ * spelling difference is not a configuration change.
232
+ */
233
+ function normalizeEmptyPair(draft, published) {
234
+ return isEmptyFace(draft) && isEmptyFace(published) ? [null, null] : [draft, published];
235
+ }
236
+ function nonEmptyView(value) {
237
+ return typeof value === "string" && value.trim() !== "" && value.trim() !== "[]";
238
+ }
239
+ /**
240
+ * A face is present when ANY of the four stored columns carries content — a
241
+ * form that only holds an Online-JS script (html) or only toolbar actions is a
242
+ * real face, not an absent one. Presence is judged per side, never by the
243
+ * `published` flag (that flag is the stale-face trap this tool exists to
244
+ * bypass).
245
+ */
246
+ function formFacePresent(sheet, side) {
247
+ const suffix = side === "draft" ? "draft" : "published";
248
+ const codes = parseControlCodes(sheet[`${suffix}AttributesJson`]);
249
+ return codes.length > 0
250
+ || nonEmptyView(sheet[`${suffix}ViewJson`])
251
+ || nonEmptyView(sheet[`${suffix}HtmlJson`])
252
+ || nonEmptyView(sheet[`${suffix}ActionsJson`]);
253
+ }
254
+ /**
255
+ * Control-map faces (`attributesJson`) are keyed by control code. Turn the
256
+ * map into rows carrying `code` so deepDiff aligns by control identity:
257
+ * additions read `attributes[+extra_ctrl]`, edits read
258
+ * `attributes[amount].options.visible` — never a whole-blob text diff, and
259
+ * never index noise when the designer reorders controls.
260
+ */
261
+ function controlRows(face) {
262
+ if (face === null || typeof face !== "object" || Array.isArray(face))
263
+ return face;
264
+ return Object.entries(face)
265
+ .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
266
+ .map(([code, control]) => control !== null && typeof control === "object" && !Array.isArray(control) ? { code, ...control } : { code, value: control });
267
+ }
268
+ /**
269
+ * Normalize "stored as a JSON string" vs "stored as the structure itself".
270
+ * The platform writes several config columns as stringified JSON (form faces,
271
+ * `name_i18n`, option maps); the SAME logical value can therefore sit as a
272
+ * string on one face and as an object on the other. Comparing the raw text
273
+ * would manufacture a difference the platform does not consider one. Strings
274
+ * that do not parse are left alone (deepDiff names them via shapeWarning).
275
+ */
276
+ function parseJsonStringsDeep(value) {
277
+ if (typeof value === "string") {
278
+ const trimmed = value.trim();
279
+ if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
280
+ try {
281
+ return parseJsonStringsDeep(JSON.parse(trimmed));
282
+ }
283
+ catch {
284
+ return value;
285
+ }
286
+ }
287
+ return value;
288
+ }
289
+ if (Array.isArray(value))
290
+ return value.map(parseJsonStringsDeep);
291
+ if (value !== null && typeof value === "object") {
292
+ const out = {};
293
+ for (const [key, item] of Object.entries(value))
294
+ out[key] = parseJsonStringsDeep(item);
295
+ return out;
296
+ }
297
+ return value;
298
+ }
299
+ /** Composite of the four parsed faces for one side, canonicalized (control-key aligned by object identity). */
300
+ function formFaceComposite(sheet, side) {
301
+ const composite = {};
302
+ for (const pair of FORM_FACE_PAIRS) {
303
+ const [draft, published] = normalizeEmptyPair(canonicalForVerify(parseJsonStringsDeep(parseJsonFace(sheet[pair.draftKey]))), canonicalForVerify(parseJsonStringsDeep(parseJsonFace(sheet[pair.publishedKey]))));
304
+ const face = side === "draft" ? draft : published;
305
+ composite[pair.key] = pair.key === "attributes" ? controlRows(face) : face;
306
+ }
307
+ return composite;
308
+ }
309
+ function rawFormFaces(sheet) {
310
+ const faces = {};
311
+ for (const pair of FORM_FACE_PAIRS)
312
+ faces[pair.key] = { draft: sheet[pair.draftKey] ?? null, published: sheet[pair.publishedKey] ?? null };
313
+ return faces;
314
+ }
315
+ /* ── tool ──────────────────────────────────────────────────────────────── */
316
+ export function registerConfigDiffTool(tools) {
317
+ tools.push(defineTool({
318
+ name: "config.diff",
319
+ search: {
320
+ intents: [
321
+ "草稿和发布差在哪",
322
+ "改了没生效",
323
+ "发布后没变化",
324
+ "规则没生效",
325
+ "表单没更新",
326
+ "按钮不见了",
327
+ "哪些改动还没发布",
328
+ "草稿发布不一致",
329
+ ],
330
+ },
331
+ layer: "low",
332
+ kind: "read",
333
+ lane: WORKFLOW_LANE_CONTRACT.lane,
334
+ scope: CONFIG_DIFF_TOOLS["config.diff"].scope,
335
+ description: CONFIG_DIFF_TOOLS["config.diff"].description,
336
+ inputSchema: {
337
+ environment: environmentArg,
338
+ domain: z.enum(["workflow", "form"]).describe("workflow=流程模板;form=表单布局;rule 域不做"),
339
+ schemaCode: z.string().min(1).optional().describe("模型 code:form 域必填;workflow 可与 workflowCode 二选一"),
340
+ workflowCode: z.string().min(1).optional().describe("流程 code(省略按 schemaCode 解析)"),
341
+ sheetCode: z.string().min(1).optional().describe("表单槽位码(省略=默认 schemaCode)"),
342
+ limit: z.number().int().min(1).max(MAX_LIMIT).optional().describe(`内联上限(默认 ${DEFAULT_LIMIT};totalKnown 精确)`),
343
+ full: z.boolean().optional().describe(`内联全部(≤${MAX_LIMIT};快照在 diffArtifactId)`),
344
+ capability: capabilityArg,
345
+ },
346
+ handler: async (ctx, args, self) => governedRead(ctx, self, args, async (session) => {
347
+ if (args.domain === "form" && !args.schemaCode)
348
+ throw new ToolInputError({ status: "error", blocker: "tool-input-invalid", tool: "config.diff", message: "domain=form 需要 schemaCode(表单按模型+槽位定位);多表单模型另传 sheetCode" });
349
+ const limit = args.full === true ? MAX_LIMIT : args.limit ?? DEFAULT_LIMIT;
350
+ if (args.domain === "workflow") {
351
+ const outcome = await diffWorkflow(session, { workflowCode: args.workflowCode, schemaCode: args.schemaCode });
352
+ // One/both faces absent: the honest verdict receipt, no artifact.
353
+ if (outcome.kind === "verdict")
354
+ return outcome.receipt;
355
+ const { base, semantic, deepScan, faces, draft, publishedData, target } = outcome;
356
+ const changed = semantic.totalKnown > 0 || deepScan.totalKnown > 0;
357
+ const inline = inlineSlice(semantic, limit);
358
+ const artifact = changed || args.full === true
359
+ ? writeDiffArtifact(ctx, {
360
+ tool: "config.diff",
361
+ domain: "workflow",
362
+ target,
363
+ semanticDiff: semantic,
364
+ deepScan,
365
+ faces: { draft, published: publishedData },
366
+ })
367
+ : null;
368
+ return {
369
+ ...base,
370
+ changed,
371
+ ...(changed ? {} : { inSync: true }),
372
+ changes: inline.changes,
373
+ totalKnown: semantic.totalKnown,
374
+ truncated: inline.truncated,
375
+ ...(inline.truncated ? { remaining: inline.remaining } : {}),
376
+ ...inlineShapeWarnings(semantic),
377
+ ...(Object.keys(faces).length > 0 ? { bindingFaces: faces } : {}),
378
+ ...(deepScan.totalKnown > 0
379
+ ? {
380
+ deepScan: {
381
+ changed: true,
382
+ totalKnown: deepScan.totalKnown,
383
+ samplePaths: deepScan.entries.map((entry) => entry.path),
384
+ note: "摘要面之外的深层模板字段(通知/回调原文等)存在差异——样例路径给定位,逐条差异与双面原文在 diffArtifactId",
385
+ },
386
+ }
387
+ : { deepScan: { changed: false, totalKnown: 0 } }),
388
+ ...(artifact
389
+ ? { ...artifact, fetch: `omc artifact get ${artifact.diffArtifactId}(--jq semanticDiff / --jq faces 看差异或双面原文)` }
390
+ : {}),
391
+ hint: changed
392
+ ? "草稿与发布面有差异:确认草稿内容后用 workflow.publish 使发布面追平;排查绑定看 bindingFaces 三类计数与 changes 里的 ruleBindings/nodeRuleBindings/systemRuleBindings 路径"
393
+ : "双面一致(含深层 canonical 复核)——症状不在草稿/发布差,查运行面(rulelog.search / workitem.list)或按钮所在节点的 buttonPermission",
394
+ };
395
+ }
396
+ // domain === "form"
397
+ const schemaCode = args.schemaCode;
398
+ const sheetCode = resolveSheetCode(schemaCode, args.sheetCode);
399
+ const sheet = await readFormOrNull(session, schemaCode, sheetCode);
400
+ if (sheet === null)
401
+ return {
402
+ domain: "form",
403
+ target: { schemaCode, sheetCode },
404
+ present: false,
405
+ draft: { present: false },
406
+ published: { present: false },
407
+ changed: null,
408
+ changes: [],
409
+ verdict: "absent",
410
+ note: "表单不存在(bizsheet/get 无行)——没有可比的双面;先 form.draft / form.publish 建默认表单",
411
+ };
412
+ const draftCodes = parseControlCodes(sheet.draftAttributesJson);
413
+ const publishedCodes = parseControlCodes(sheet.publishedAttributesJson);
414
+ const draftPresent = formFacePresent(sheet, "draft");
415
+ const publishedPresent = formFacePresent(sheet, "published");
416
+ const base = {
417
+ domain: "form",
418
+ target: { schemaCode, sheetCode },
419
+ present: true,
420
+ draft: { present: draftPresent, ...(draftPresent ? { controlCount: draftCodes.length } : {}) },
421
+ published: { present: publishedPresent, ...(publishedPresent ? { controlCount: publishedCodes.length } : {}) },
422
+ };
423
+ if (!draftPresent || !publishedPresent) {
424
+ const verdict = draftPresent ? "draft-only" : publishedPresent ? "published-only" : "both-empty";
425
+ return {
426
+ ...base,
427
+ changed: null,
428
+ changes: [],
429
+ verdict,
430
+ note: verdict === "draft-only"
431
+ ? "只有草稿面——草稿改动全部未发布;确认草稿后 form.publish"
432
+ : verdict === "published-only"
433
+ ? "只有发布面(草稿被清空或从未保存)——发布面即现行配置;要改先 form.draft 重建草稿基线"
434
+ : "两面内容都为空(布局被清空或从未草稿)——present 只说明面缺,不代表没有按钮;先 form.draft",
435
+ };
436
+ }
437
+ const draftComposite = formFaceComposite(sheet, "draft");
438
+ const publishedComposite = formFaceComposite(sheet, "published");
439
+ // published → draft: before = 现行发布面,after = 发布后会变成的草稿面。
440
+ const semantic = deepDiff(publishedComposite, draftComposite, { limit: ARTIFACT_LIMIT });
441
+ const changed = semantic.totalKnown > 0;
442
+ const inline = inlineSlice(semantic, limit);
443
+ const artifact = changed || args.full === true
444
+ ? writeDiffArtifact(ctx, {
445
+ tool: "config.diff",
446
+ domain: "form",
447
+ target: { schemaCode, sheetCode },
448
+ semanticDiff: semantic,
449
+ faces: rawFormFaces(sheet),
450
+ })
451
+ : null;
452
+ return {
453
+ ...base,
454
+ changed,
455
+ ...(changed ? {} : { inSync: true }),
456
+ changes: inline.changes,
457
+ totalKnown: semantic.totalKnown,
458
+ truncated: inline.truncated,
459
+ ...(inline.truncated ? { remaining: inline.remaining } : {}),
460
+ ...inlineShapeWarnings(semantic),
461
+ ...(artifact
462
+ ? { ...artifact, fetch: `omc artifact get ${artifact.diffArtifactId}(--jq semanticDiff / --jq faces 看差异或双面原文)` }
463
+ : {}),
464
+ hint: changed
465
+ ? "表单草稿与发布面有差异(按控件/字段 key 对齐,路径前缀 view/attributes/html/actions);确认草稿后 form.publish 使发布面追平"
466
+ : "双面布局一致——「表单没更新」不来自草稿/发布差;查流程节点 buttonPermission(workflow.get_draft 的 formButtons)或在线 JS(onlinejs.get)",
467
+ };
468
+ }, {
469
+ target: `config.diff:${args.domain}:${args.workflowCode ?? args.schemaCode ?? ""}${args.sheetCode !== undefined ? `:${args.sheetCode}` : ""}`,
470
+ // Identity compact: the receipt is already inline-capped by `limit`;
471
+ // the generic diet would fold `changes` into a count and hide the
472
+ // paths — the whole point of this tool.
473
+ compact: (result) => result,
474
+ }),
475
+ }));
476
+ }
477
+ //# sourceMappingURL=config-diff.js.map
@@ -47,7 +47,7 @@ function layoutHasCustomScript(face) {
47
47
  * explicit case is a real caller decision; omitting means "the model's default
48
48
  * sheet". Multi-sheet models still pass sheetCode explicitly.
49
49
  */
50
- function resolveSheetCode(schemaCode, sheetCode) {
50
+ export function resolveSheetCode(schemaCode, sheetCode) {
51
51
  return sheetCode ?? schemaCode;
52
52
  }
53
53
  /** Control codes present in a form attributes JSON face (sorted, stable). */
@@ -70,7 +70,7 @@ function parseLayoutRows(face) {
70
70
  return undefined;
71
71
  }
72
72
  }
73
- function parseControlCodes(face) {
73
+ export function parseControlCodes(face) {
74
74
  if (typeof face !== "string")
75
75
  return [];
76
76
  try {
@@ -159,6 +159,11 @@ export const WORKFLOW_LANE_CONTRACT = Object.freeze({
159
159
  scope: WORKFLOW_SCOPE,
160
160
  description: "Read the current PUBLISHED workflow template (`/api/api/workflow/get_published`). **默认返回 workflowSummary(activities + ruleBindings),不是整份正文**;节点级规则绑定按活动投影在 `workflowSummary.activities[].bizActions`({节点事件:[规则码]};流程级看 ruleBindings),SYSTEM_ACTIVITY 顶层绑定(规则绑在系统活动节点本身、激活时执行)看 `activities[].systemBizActions`——三个面看完再下「没绑」结论。完整正文加 --full,或 `--jq 'data.activities[code=<活动>].<节点事件>.bizActions'` 这类**叶子**路径——对父节点 data.activities 取值会再次被折叠。在 workflow.publish / workflow.bindRule 之后用它确认发布后的绑定点。",
161
161
  }),
162
+ // R88 #1:草稿↔发布排查面(域参数化单工具;form 域复用 form-support 读原语)。
163
+ "config.diff": Object.freeze({
164
+ scope: "draft published face semantic diff (workflow|form)",
165
+ description: "只读:草稿↔发布差异。workflow:get_draft/get_published 语义 diff——activities[+code]、edges[from->to]、三类绑定分报 ruleBindings/nodeRuleBindings[活动.事件]/SYSTEM_ACTIVITY systemRuleBindings;深层字段 deepScan 复核。form:draft*Json/published*Json 按控件 key 对齐(view/attributes/html/actions)。一面缺失回 changed:null + verdict(draft-only/published-only/absent);changes ≤limit,totalKnown 精确,截断 truncated;全量在 diffArtifactId(0600)。rule 域不做。",
166
+ }),
162
167
  // R79 三期 T-A:应用内流程清单(注意:不能放在 tools 的首位——
163
168
  // lane-contracts 的 assertDescriptionsDerive 用首个 tool 的 scope 匹配契约
164
169
  // markdown,首位必须是 workflow.get_draft 的 WORKFLOW_SCOPE)。
@@ -264,6 +269,18 @@ export function assertWorkflowContract() {
264
269
  assertDescriptionCarries(WORKFLOW_LANE_CONTRACT, "workflow.get_draft", ["get_draft", "endEventHandler"]);
265
270
  assertDescriptionCarries(WORKFLOW_LANE_CONTRACT, "workflow.list", ["模型为索引", "exists:false", "ruleBindingCount", "50", "kind=rule", "partial"]);
266
271
  assertDescriptionCarries(WORKFLOW_LANE_CONTRACT, "workflow.get_published", ["get_published", "workflow.publish"]);
272
+ assertDescriptionCarries(WORKFLOW_LANE_CONTRACT, "config.diff", [
273
+ "get_draft",
274
+ "get_published",
275
+ "ruleBindings",
276
+ "nodeRuleBindings",
277
+ "systemRuleBindings",
278
+ "draft*Json",
279
+ "published*Json",
280
+ "changed:null",
281
+ "diffArtifactId",
282
+ "0600",
283
+ ]);
267
284
  assertDescriptionCarries(WORKFLOW_LANE_CONTRACT, "workflow.create", ["workflow/create", "workflow.update", "workflow.publish"]);
268
285
  assertDescriptionCarries(WORKFLOW_LANE_CONTRACT, "workflow.update", ["workflow/update", "template", "rules", "activityType", "propertyPermissions", "CLI_ARGS_MAX_BYTES", "workflow-merge-would-drop-routes"]);
269
286
  assertDescriptionCarries(WORKFLOW_LANE_CONTRACT, "workflow.publish", ["workflow/publish", "template"]);
@@ -82,5 +82,16 @@ export const WORKFLOW_COVERAGE = declareLaneCoverage(WORKFLOW_LANE_CONTRACT.lane
82
82
  ],
83
83
  tools: [claim("org.role.list", T["org.role.list"].scope), claim("org.department.list", T["org.department.list"].scope), claim("org.user.search", T["org.user.search"].scope)],
84
84
  },
85
+ {
86
+ // R88 #1:草稿↔发布排查面。跨 workflow/form 两域的只读 diff,单工具域参数化;
87
+ // 引擎语义(totalKnown/尾部增删/shapeWarning)见 rollback-spec deepDiff。
88
+ capability: "draft-published configuration diff (config.diff)",
89
+ evidence: [
90
+ "packages/omc-cli/src/lanes/config-diff.ts",
91
+ "packages/omc-cli/test/config-diff.test.ts",
92
+ "packages/omc-cli/src/rollback-spec.ts",
93
+ ],
94
+ tools: [claim("config.diff", T["config.diff"].scope)],
95
+ },
85
96
  ]);
86
97
  //# sourceMappingURL=workflow-coverage.js.map