@stalfh233/omc-cli 0.7.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/coverage/m1-coverage-manifest-v1.json +88 -2
  2. package/dist/bootstrap.js +49 -0
  3. package/dist/call.js +23 -8
  4. package/dist/capability-overview.js +16 -4
  5. package/dist/cli.js +36 -16
  6. package/dist/contract-resources.js +2 -0
  7. package/dist/coverage-registry.js +4 -0
  8. package/dist/coverage.js +16 -2
  9. package/dist/endpoints.js +65 -0
  10. package/dist/environment-policy.js +15 -1
  11. package/dist/field-change.js +9 -2
  12. package/dist/field-families.js +27 -6
  13. package/dist/governed-execution.js +18 -12
  14. package/dist/human-summary.js +8 -0
  15. package/dist/intent/capabilities/field.js +6 -0
  16. package/dist/lanes/environment.js +3 -0
  17. package/dist/lanes/field-contract.js +117 -6
  18. package/dist/lanes/file-contract.js +69 -0
  19. package/dist/lanes/file-coverage.js +16 -0
  20. package/dist/lanes/file.js +257 -0
  21. package/dist/lanes/lane-ids.js +1 -0
  22. package/dist/lanes/list-view-contract.js +3 -3
  23. package/dist/lanes/list-view-shapes.js +56 -0
  24. package/dist/lanes/list-view.js +40 -5
  25. package/dist/lanes/meta.js +5 -4
  26. package/dist/lanes/model.js +8 -4
  27. package/dist/lanes/org-query-contract.js +62 -0
  28. package/dist/lanes/org-query-coverage.js +27 -0
  29. package/dist/lanes/org-query.js +610 -0
  30. package/dist/lanes/organization.js +44 -11
  31. package/dist/lanes/runtime-data.js +228 -59
  32. package/dist/lanes/workflow-contract.js +110 -1
  33. package/dist/lanes/workflow-coverage.js +13 -0
  34. package/dist/lanes/workflow.js +710 -13
  35. package/dist/omc-core-lazy.js +37 -1
  36. package/dist/package.js +3 -1
  37. package/dist/read-shapes.js +3 -3
  38. package/dist/recipes/runtime-data.js +8 -6
  39. package/dist/refusal-guidance.js +2 -1
  40. package/dist/rule-support.js +15 -17
  41. package/dist/session-manager.js +9 -3
  42. package/dist/session.js +70 -11
  43. package/dist/token-cache.js +5 -0
  44. package/dist/tool-types.js +15 -1
  45. package/dist/tools.js +18 -0
  46. package/dist/version-family-gaps.js +8 -1
  47. package/dist/version-partition.js +633 -0
  48. package/dist/wire.js +8 -2
  49. package/dist/write.js +11 -2
  50. package/package.json +3 -3
  51. package/skills/omc-capabilities.md +9 -2
  52. package/skills/omc-refusals.md +18 -0
  53. package/skills/omc-write-hazards.md +8 -0
@@ -0,0 +1,257 @@
1
+ import { chmodSync, existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
2
+ import { createHash } from "node:crypto";
3
+ import { basename, dirname, isAbsolute, join, resolve } from "node:path";
4
+ import { homedir } from "node:os";
5
+ import { z } from "zod";
6
+ import { capabilityArg, environmentArg } from "../args.js";
7
+ import { governedRead } from "../read.js";
8
+ import { writeTool } from "../write.js";
9
+ import { defineTool, ToolRefusalError } from "../tool-types.js";
10
+ import { wireUploadFile, WireError } from "../wire.js";
11
+ import { FILE_ENDPOINTS, FILE_LANE_CONTRACT } from "./file-contract.js";
12
+ const LANE = FILE_LANE_CONTRACT.lane;
13
+ const TOOLS = FILE_LANE_CONTRACT.tools;
14
+ /**
15
+ * One-shot teaching shared by both tools: the refId→filename cache entry is
16
+ * removed by a consuming download (`delete=true`), so a refId that worked for
17
+ * one server-side flow may be dead on the next call.
18
+ */
19
+ const ONE_SHOT_NOTE = "refId 可能是一次性的:平台消费型下载(业务集成 check/import 等 delete=true)取完就删除 refId→文件名缓存,之后不可复用——重试请重新上传,不要假定同一 refId 能反复消费。";
20
+ const UPLOAD_DRY_RUN_REFUSAL = {
21
+ status: "refused",
22
+ blocker: "file-upload-dry-run-unsupported",
23
+ message: "file.upload 不支持 --dry-run:上传本身是取回 refId 的唯一途径,不上传就不存在可用的 refId(且上传会在平台对象存储留下一个真实对象),预览无法诚实给出 wouldChange。参数预检请用 --preflight;确认执行时去掉 --dry-run。",
24
+ };
25
+ function expandHome(value) {
26
+ if (value === "~")
27
+ return homedir();
28
+ if (value.startsWith("~/") || value.startsWith("~\\"))
29
+ return join(homedir(), value.slice(2));
30
+ return value;
31
+ }
32
+ function absolute(value) {
33
+ const expanded = expandHome(value);
34
+ return isAbsolute(expanded) ? resolve(expanded) : resolve(process.cwd(), expanded);
35
+ }
36
+ /**
37
+ * The platform's checkFileType inspects only the filename: it must contain a
38
+ * non-empty suffix after the last dot, must not contain `..`, and the suffix
39
+ * must be on the deployment's allow_file_types list (a platform setting we
40
+ * cannot read offline). Preflight the two locally-decidable rules.
41
+ */
42
+ function uploadPreflight(args) {
43
+ const source = absolute(args.path);
44
+ if (!existsSync(source))
45
+ throw new ToolRefusalError({
46
+ status: "refused",
47
+ blocker: "file-upload-source-missing",
48
+ path: source,
49
+ message: `本地文件不存在:${source}。file.upload 只上传本机可读的普通文件(路径不存在即拒绝,零上传)。`,
50
+ });
51
+ const stats = statSync(source);
52
+ if (!stats.isFile())
53
+ throw new ToolRefusalError({
54
+ status: "refused",
55
+ blocker: "file-upload-source-not-file",
56
+ path: source,
57
+ message: `${source} 不是普通文件(目录/设备/管道均不支持)。请指向具体文件。`,
58
+ });
59
+ const remoteName = args.name ?? basename(source);
60
+ if (/[\\/]/.test(remoteName) || remoteName.includes(".."))
61
+ throw new ToolRefusalError({
62
+ status: "refused",
63
+ blocker: "file-upload-name-invalid",
64
+ name: remoteName,
65
+ message: `上传文件名 ${JSON.stringify(remoteName)} 含路径分隔符或 ".."——平台 checkFileType 会拒(文件名只能是裸名);用 name 指定一个不含目录的名字。`,
66
+ });
67
+ const lastDot = remoteName.lastIndexOf(".");
68
+ if (lastDot < 0 || lastDot === remoteName.length - 1)
69
+ throw new ToolRefusalError({
70
+ status: "refused",
71
+ blocker: "file-upload-name-invalid",
72
+ name: remoteName,
73
+ message: `上传文件名 ${JSON.stringify(remoteName)} 没有扩展名——平台 checkFileType 取最后一个 "." 之后的 suffix,空 suffix 直接拒(FILE_TYPE_ILLEGAL)。用 name 补一个真实扩展名。`,
74
+ hint: "扩展名还必须在平台设置的 allow_file_types 白名单里;白名单是环境配置,本地不可预知,被平台拒时按平台返回的类型清单调整。",
75
+ });
76
+ }
77
+ /**
78
+ * Decode the two download channels into bytes.
79
+ *
80
+ * - attachment: 200 + {errcode,errmsg} is how the platform refuses (the
81
+ * attachment must resolve through AttachmentModel/AttachmentCache).
82
+ * - stored: the controller swallows every failure and answers 200 with an
83
+ * EMPTY body (QueryRuntimeController.java:2868-2890), so empty == refusal.
84
+ * Its body is a raw storage object, so it is never envelope-sniffed — a
85
+ * downloaded .json must round-trip byte-for-byte.
86
+ */
87
+ async function wireFileBytes(session, source, refId) {
88
+ const path = source === "attachment" ? FILE_ENDPOINTS.attachmentDownload : FILE_ENDPOINTS.storedDownload;
89
+ const response = source === "attachment"
90
+ ? await session.request({ path, method: "GET", query: { refId }, responseType: "buffer" })
91
+ : await session.request({ path, method: "POST", body: { fileName: refId }, responseType: "buffer" });
92
+ if (response.status < 200 || response.status >= 300)
93
+ throw new WireError("http-status", `HTTP ${response.status} for ${path} (${source} download, refId=${refId})`, undefined, { httpStatus: response.status });
94
+ const body = Buffer.isBuffer(response.body)
95
+ ? response.body
96
+ : typeof response.body === "string"
97
+ ? Buffer.from(response.body, "utf8")
98
+ : undefined;
99
+ if (body === undefined)
100
+ throw new WireError("malformed-envelope", `${path} answered no bytes for refId=${refId} (${source} download)`);
101
+ if (body.length === 0)
102
+ throw new ToolRefusalError({
103
+ status: "refused",
104
+ blocker: "file-ref-unavailable",
105
+ refId,
106
+ source,
107
+ message: `refId ${JSON.stringify(refId)} 没有取到任何字节:它可能已被消费、已过期,或根本不属于本租户。${ONE_SHOT_NOTE} 来源通道也要对:file.upload 的临时 refId 用 source:"stored",表单附件 refId 用 source:"attachment"。`,
108
+ });
109
+ if (source === "attachment" && body[0] === 0x7b) {
110
+ let parsed;
111
+ try {
112
+ parsed = JSON.parse(body.toString("utf8"));
113
+ }
114
+ catch {
115
+ parsed = undefined;
116
+ }
117
+ if (parsed !== null && typeof parsed === "object") {
118
+ const envelope = parsed;
119
+ if (typeof envelope.errcode === "number") {
120
+ if (envelope.errcode !== 0)
121
+ throw new ToolRefusalError({
122
+ status: "refused",
123
+ blocker: "file-ref-unavailable",
124
+ refId,
125
+ source,
126
+ errcode: envelope.errcode,
127
+ message: `平台拒绝下载 refId ${JSON.stringify(refId)}(errcode ${envelope.errcode}${typeof envelope.errmsg === "string" ? `:${envelope.errmsg}` : ""})。attachment 通道要求 refId 能在附件表/附件缓存解析;若是 file.upload 返回的临时 refId,改用 source:"stored"。${ONE_SHOT_NOTE}`,
128
+ hint: "若这是普通附件却用错了 refId(多附件字段里混入了别的对象 id),先用 data.load 读该字段的 refId 列表。",
129
+ });
130
+ throw new WireError("malformed-envelope", `${path} answered an errcode-0 JSON envelope instead of an attachment stream`);
131
+ }
132
+ }
133
+ }
134
+ return body;
135
+ }
136
+ function safeFileName(value) {
137
+ const cleaned = basename(value).replaceAll(/[<>:"/\\|?*\u0000-\u001f]/g, "_").replaceAll(/\s+/g, " ").trim();
138
+ const withoutLeadingDots = cleaned.replace(/^\.+/, "");
139
+ return withoutLeadingDots.length > 0 ? withoutLeadingDots : "download.bin";
140
+ }
141
+ /** `path` may be a file path or an existing directory (trailing separator counts). */
142
+ function downloadTarget(args) {
143
+ if (args.fileName !== undefined && args.fileName !== basename(args.fileName))
144
+ throw new ToolRefusalError({
145
+ status: "refused",
146
+ blocker: "file-download-name-invalid",
147
+ fileName: args.fileName,
148
+ message: `fileName ${JSON.stringify(args.fileName)} 只能是裸文件名(不能带目录);目录用 path 指定。`,
149
+ });
150
+ const suggested = safeFileName(args.fileName ?? basename(args.refId));
151
+ if (args.path === undefined)
152
+ return join(process.cwd(), suggested);
153
+ const raw = absolute(args.path);
154
+ const looksLikeDir = existsSync(raw) ? statSync(raw).isDirectory() : /[\\/]$/.test(args.path);
155
+ return looksLikeDir ? join(raw, suggested) : raw;
156
+ }
157
+ export function registerFileLane(tools) {
158
+ writeTool({
159
+ tools,
160
+ name: "file.upload",
161
+ search: { intents: ["上传文件", "传文件到平台", "拿文件引用", "附件上传", "multipart 上传"] },
162
+ lane: LANE,
163
+ scope: TOOLS["file.upload"].scope,
164
+ description: TOOLS["file.upload"].description,
165
+ inputSchema: {
166
+ path: z.string().min(1).describe("本地文件路径(绝对路径或相对当前目录;~ 会展开)"),
167
+ name: z.string().min(1).optional().describe("上传后的文件名(默认取本地 basename);必须保留真实扩展名,不能带目录或 `..`"),
168
+ },
169
+ preflight: (args) => uploadPreflight(args),
170
+ // The upload IS the operation: there is no honest zero-write preview that
171
+ // yields a usable refId. Refuse instead of faking a green plan.
172
+ dryRunPayload: async () => {
173
+ throw new ToolRefusalError(UPLOAD_DRY_RUN_REFUSAL);
174
+ },
175
+ execute: async (session, args) => {
176
+ const source = absolute(args.path);
177
+ const remoteName = args.name ?? basename(source);
178
+ const bytes = readFileSync(source);
179
+ const refId = await wireUploadFile(session, FILE_ENDPOINTS.upload, remoteName, bytes, "application/octet-stream");
180
+ return {
181
+ performed: { uploaded: true, filename: remoteName, bytes: bytes.length },
182
+ readback: {
183
+ refId,
184
+ refIdKind: "plain-string",
185
+ oneShot: true,
186
+ // Honest verification stamp: upload_file is the only refId metadata
187
+ // face — there is no read-by-refId endpoint, so the byte count is
188
+ // local truth (stat/body), not a server readback.
189
+ verified: false,
190
+ verification: "upload_file 只回纯字符串 refId(无按 refId 读元数据的端点);这里核对的是本地上传字节数,不是服务端回读。",
191
+ },
192
+ };
193
+ },
194
+ });
195
+ tools.push(defineTool({
196
+ name: "file.download",
197
+ search: { intents: ["下载文件", "按 refId 下载", "把平台文件存到本地", "附件下载", "导出附件"] },
198
+ layer: "low",
199
+ kind: "read",
200
+ lane: LANE,
201
+ scope: TOOLS["file.download"].scope,
202
+ description: TOOLS["file.download"].description,
203
+ inputSchema: {
204
+ environment: environmentArg,
205
+ capability: capabilityArg,
206
+ refId: z.string().min(1).describe("平台文件引用(附件 refId,或 file.upload 返回的临时 refId)"),
207
+ source: z.enum(["attachment", "stored"]).default("attachment").describe("attachment=表单附件通道(默认,走附件权限);stored=upload_file 临时对象的存储键通道(失败回空 body)"),
208
+ path: z.string().min(1).optional().describe("本地目标文件路径,或已存在/以分隔符结尾的目录(默认当前目录)"),
209
+ fileName: z.string().min(1).optional().describe("落盘文件名(仅裸名;默认取 refId 的 basename)"),
210
+ overwrite: z.boolean().default(false).describe("目标已存在时是否覆盖(默认拒绝,零写入)"),
211
+ },
212
+ handler: async (ctx, args, self) => governedRead(ctx, self, args, async (session) => {
213
+ const target = downloadTarget(args);
214
+ const existed = existsSync(target);
215
+ if (existsSync(target) && statSync(target).isDirectory())
216
+ throw new ToolRefusalError({
217
+ status: "refused",
218
+ blocker: "file-download-target-exists",
219
+ path: target,
220
+ message: `${target} 是目录——path 指向目录时会被当作目录拼接 fileName,但这里解析出的最终目标仍是目录。请给出明确文件名。`,
221
+ });
222
+ if (existsSync(target) && args.overwrite !== true)
223
+ throw new ToolRefusalError({
224
+ status: "refused",
225
+ blocker: "file-download-target-exists",
226
+ path: target,
227
+ existingBytes: statSync(target).size,
228
+ message: `目标文件已存在:${target}(${statSync(target).size}B)。默认不覆盖(避免把用户文件当下载缓存);确认覆盖传 overwrite:true,或换 path/fileName。`,
229
+ });
230
+ const bytes = await wireFileBytes(session, args.source, args.refId);
231
+ mkdirSync(dirname(target), { recursive: true });
232
+ writeFileSync(target, bytes, { mode: 0o600 });
233
+ // writeFileSync's mode only applies on creation; an overwrite keeps the
234
+ // old bits. Make 0600 true where the platform supports it (Windows
235
+ // exposes only the write bit; a restricted FS must not fail the download).
236
+ try {
237
+ chmodSync(target, 0o600);
238
+ }
239
+ catch {
240
+ // best-effort on file systems without POSIX modes
241
+ }
242
+ const sha256 = createHash("sha256").update(bytes).digest("hex");
243
+ return {
244
+ refId: args.refId,
245
+ source: args.source,
246
+ path: target,
247
+ fileName: basename(target),
248
+ size: bytes.length,
249
+ sha256,
250
+ overwritten: existed && args.overwrite === true,
251
+ note: "二进制已落盘(0600),未内联到 stdout;sha256 是落盘字节的摘要,可直接用于完整性校验。",
252
+ ...(args.source === "stored" ? { channelNote: "stored 通道不校验附件权限,只证明该存储键可取;refId 失效时平台回空 body(已按 file-ref-unavailable 拒绝)。" } : {}),
253
+ };
254
+ }),
255
+ }));
256
+ }
257
+ //# sourceMappingURL=file.js.map
@@ -29,6 +29,7 @@ export const LANES = Object.freeze({
29
29
  listView: "W1-list-view",
30
30
  report: "R1-report",
31
31
  perm: "B3-perm",
32
+ file: "file-transfer",
32
33
  });
33
34
  export const LANE_IDS = Object.freeze(Object.values(LANES));
34
35
  export function isLaneId(value) {
@@ -12,7 +12,7 @@ export const LIST_VIEW_WIRE = Object.freeze({
12
12
  configureDefault: "code omitted means the default view (code=schemaCode)",
13
13
  configureColumns: "query/get then query/update: for each fieldCodes entry, append a missing column as visible, or repair an existing column's name/propertyType/displayFormat/visible in place (never skip an already-present column), then query/get readback; propertyType comes from published field metadata; NUMERICAL displayFormat is derived from the field's 0-based `options.scale` (0=integer,1=1dp,2=2dp,3=3dp…8=8dp) through the platform parseNumber table ({0:1,1:2,2:3,3:11,4:12,23:…, percent 0..:4/5/6/13/14/27..30, currency ¥ 2dp..:7/15/16/31..34} — verified live: scale 2 → displayFormat 3 = 2 decimals) and DATE displayFormat from options.format (1=yyyy-MM-dd,2=datetime,3=minute,4=yyyy-MM); the readback columns array carries {propertyCode,propertyType,displayFormat,visible,sumType} and added/updated name the fieldCodes touched",
14
14
  configureSorts: "sorts -> querySorts [{propertyCode,propertyType,direction,sortKey,clientType}]; direction SortDirectionType numeric ASC(1)/DESC(2); omitted leaves the existing sorts untouched, provided replaces them",
15
- configureConditions: "conditions -> queryConditions [{propertyCode,propertyType,displayType,filterType,defaultValue,options,startValue,endValue,shortcutFilter,choiceType,dateType,accurateSearch,showNull,includeSubData,buildTreeBy,visible}]; minimum --param shape: {\"conditions\":[{\"propertyCode\":\"<code>\",\"filterType\":\"Eq\",\"defaultValue\":<value>}]}; filterType is the comparison OPERATOR (QueryFilterType STRING enum: Eq/NotEq/Gt/Lt/Gte/Lte/Like/NotLike/IsNull/IsNotNull/In/NotIn/Between/NotBetween/Of/NotOf/…; omitted → the platform default for the propertyType; aliases operator/op and legacy options.op); displayType INPUT(0)/RADIO(1)/CHECKBOX(2)/SELECT(3)/RANGE(4); choiceType SELECT(1)/POPUP(2)/TREE_LEFT(3); options is a JSON string (decoded on readback); conditionReadback is equivalent only for field-by-field equality, otherwise coerced with from/to details; viewConditionsAppliedRest:false records that REST data.list --queryCode does not apply fixed conditions",
15
+ configureConditions: "conditions -> queryConditions [{propertyCode,propertyType,displayType,filterType,defaultValue,options,startValue,endValue,shortcutFilter,choiceType,dateType,accurateSearch,showNull,includeSubData,buildTreeBy,visible,treeLimitScopeType,treeLimitConditionGroup,treeDefaultConditionGroup}]; minimum --param shape: {\"conditions\":[{\"propertyCode\":\"<code>\",\"filterType\":\"Eq\",\"defaultValue\":<value>}]}; filterType is the comparison OPERATOR (QueryFilterType STRING enum: Eq/NotEq/Gt/Lt/Gte/Lte/Like/NotLike/IsNull/IsNotNull/In/NotIn/Between/NotBetween/Of/NotOf/…; omitted → the platform default for the propertyType; aliases operator/op and legacy options.op); displayType INPUT(0)/RADIO(1)/CHECKBOX(2)/SELECT(3)/RANGE(4); choiceType SELECT(1)/POPUP(2)/TREE_LEFT(3); options is a JSON string (decoded on readback); the 2.1.5 tree-view triple treeLimitScopeType/treeLimitConditionGroup/treeDefaultConditionGroup is read as List<List<BizQueryDataRangeCondition>> [[{propertyCode,propertyType,operatorType,valueType,value,dynamicValue}]] and passed through verbatim: a baseline key with a DIFFERENT value refuses with listview-tree-conditions-changed (nextAction allowTreeConditionChange:true) and a baseline key omitted from the submitted row refuses with listview-tree-conditions-would-be-lost; value equality canonicalises JSON text vs object, object key order, and numeric propertyType/operatorType (\"1\"==1) but keeps value/dynamicValue string-strict; readback compares all three keys whenever either side carries one and reports the drift as a coercion; conditionReadback is equivalent only for field-by-field equality, otherwise coerced with from/to details; viewConditionsAppliedRest:false records that REST data.list --queryCode does not apply fixed conditions",
16
16
  configureConditionMap: "queryConditionMap {<schemaCode>: queryConditions[]} is read-derived (query/get with a formCode child-table filter); BizQueryDetailConfig persists queryConditions/querySorts only, so the map is not a configure input",
17
17
  configureActions: "actions -> queryActions [{actionCode,name,icon,queryActionType,systemAction,serviceCode,serviceMethod,customService,associationCode,associationType,sortKey}]; queryActionType QueryActionType numeric QUERY(1)/ADD(2)/.../BATCH_SUBMIT(23); associationType QueryActionRelativeType numeric BIZSHEET(0)/WORKFLOW(1); associationCode/associationType are the JSON names of the DTO fields relativeCode/queryActionRelativeType (@JsonProperty); omitted leaves the existing actions untouched, provided MERGES into the effective set by actionCode (live 2026-09-17: query/update replaces-then-re-adds the submitted list, so a merge keeps the platform's built-in 新增/删除/导入/导出 and updates a matching actionCode — replaceActions:true restores the authoritative full set, defaultActions:true re-seeds the platform default set); query/get auto-injects default actions (qr_code/batch_print/batch_update/import_attachment/export_attachment/batch_submit) and query/update resets sortKey to i+1",
18
18
  configurePresentation: "presentation -> queryPresentation {clientType,htmlJson,actionsJson,columnsJson,queryViewDataSource,schemaRelations,options}; htmlJson/actionsJson/columnsJson JSON strings are decoded once before render-shape validation (html element tagName+attrs, action actionCode/name/icon, column propertyCode/propertyType); invalid input refuses with listview-presentation-render-invalid before wire and is never double-encoded; clientType is forced to PC by query/update; schemaRelations is platform-derived from the queryColumns tree (resolveRelations) and overwrites your input; a non-empty htmlJson updates the environment record, which query/delete cleans up; omitted leaves the existing presentation untouched (the read-face object must be echoed, because saveBizQueryDetail removes every presentation whose clientType matches before re-adding), provided replaces it",
@@ -126,7 +126,7 @@ export const LIST_VIEW_LANE_CONTRACT = Object.freeze({
126
126
  }),
127
127
  "listview.configure": Object.freeze({
128
128
  scope: LIST_VIEW_SCOPE,
129
- description: "配置列表视图(列、排序、查询条件、行/列表按钮、呈现、自定义按钮、视图头扩展选项与视图类型)。**code 语义**:省略 `code`(或 code=schemaCode)= 配置**默认视图**(code = 模型 code,8.6.41 起默认视图同样可 configure),日常配列就用它,**不要先 listview.create**(会多一个视图);改默认视图影响所有用户;仅需第二个视图时才 listview.create(configure 带 code 指向它)。读回 query,按 `fieldCodes` 追加缺失列或**原地修正**已存在列的 name/propertyType/displayFormat/visible(不再跳过既有列),置为可见;数值列 displayFormat 由字段 0 基 `options.scale` 推导(0=整数,1=1位,2=2位,3=3位…8=8位)、日期列由 `options.format` 推导(1/2/3/4),回显 `columns` 为完整列对象并给出 `added`/`updated`;`sorts`→querySorts(direction ASC/DESC)、`conditions`→queryConditions(**比较符是 `filterType`(QueryFilterType 字符串枚举 Eq/NotEq/…;别名 operator/op;省略时按 propertyType 取平台默认)**、displayType/choiceType/options 字符串解码;写后条件回读等价校验给出 conditionReadback)、`actions`→queryActions(queryActionType QUERY(1)…BATCH_SUBMIT(23)、associationType BIZSHEET(0)/WORKFLOW(1))、`presentation`→queryPresentation(htmlJson/actionsJson/columnsJson/queryViewDataSource/schemaRelations/options 均为 JSON 字符串,合法 JSON 读回解码)、`buttons`→customButtons(写面 customButtonJson JSON 数组字符串;bindAction/useLocation/operateType/showPermType 以枚举名发送;triggerType 强制 QUERY、triggerCode=视图 code、sortKey 按数组位,缺省回传读面 customButtons 有效集;ADD_DATA/FORM 目标绑定走 actionConfig——schemaCodeVal+formListData+configureList,targetCode/targetObjCode 对其无效会被拒;高层参数 targetModel/targetForm/configureList 从读回元数据展开,未解析即 listview-button-target-unresolved 零副作用拒)、`options`→视图头 BizQueryOption(`pagingSetting`{pageSize,showTotal} 分页、`listViewModeSetting`{mode,canSwitch} 列表模式,缺省回传读面有效 options、提供时整体替换,rowColorSetting 无 8.6.26 类证据故对象形态拒绝)与 `presentationType`→QueryPresentationType(LIST/BOARD/CALENDAR/GANTT,缺省回传读面有效值;GANTT 必须同时提供 `gantt`→queryGanttModel 且 startTimePropertyCode/endTimePropertyCode/titlePropertyCode 非空,缺省不触碰既有 gantt)与 `queryLayer`→层级展示(BizQueryLayer[] 数组原样发送)及 `multiTableHeaderConfig`→多级表头(HeaderConfig[] JSON 字符串;缺省回传读面有效值、提供时整体替换)省略时不触碰既有值,提供时整体替换并经出门前 dry-lint;`query/update` 后回读。`queryConditionMap` 为只读派生(query/get 带 formCode 子表条件时才出现),非配置输入。**发布语义**:`query/update` 自动置 publish=TRUE——视图无草稿/发布两态、无需独立发布步骤。**依赖顺序**:视图与表单脚手架都依赖**已发布字段**,规范顺序 model.create → field.create → field.publish(模型级)→ form.draft → form.publish →(需要第二视图时 listview.create)→ listview.configure → rule.save → rule.enable → workflow。",
129
+ description: "配置列表视图(列、排序、查询条件、行/列表按钮、呈现、自定义按钮、视图头扩展选项与视图类型)。**code 语义**:省略 `code`(或 code=schemaCode)= 配置**默认视图**(code = 模型 code,8.6.41 起默认视图同样可 configure),日常配列就用它,**不要先 listview.create**(会多一个视图);改默认视图影响所有用户;仅需第二个视图时才 listview.create(configure 带 code 指向它)。读回 query,按 `fieldCodes` 追加缺失列或**原地修正**已存在列的 name/propertyType/displayFormat/visible(不再跳过既有列),置为可见;数值列 displayFormat 由字段 0 基 `options.scale` 推导(0=整数,1=1位,2=2位,3=3位…8=8位)、日期列由 `options.format` 推导(1/2/3/4),回显 `columns` 为完整列对象并给出 `added`/`updated`;`sorts`→querySorts(direction ASC/DESC)、`conditions`→queryConditions(**比较符是 `filterType`(QueryFilterType 字符串枚举 Eq/NotEq/…;别名 operator/op;省略时按 propertyType 取平台默认)**、displayType/choiceType/options 字符串解码;2.1.5 树视图过滤组三键 `treeLimitScopeType`/`treeLimitConditionGroup`/`treeDefaultConditionGroup` 原样透传(值不同默认拒 `listview-tree-conditions-changed`,确认改写传 `allowTreeConditionChange:true`;缺键拒 `listview-tree-conditions-would-be-lost`);写后条件回读等价校验给出 conditionReadback)、`actions`→queryActions(queryActionType QUERY(1)…BATCH_SUBMIT(23)、associationType BIZSHEET(0)/WORKFLOW(1))、`presentation`→queryPresentation(htmlJson/actionsJson/columnsJson/queryViewDataSource/schemaRelations/options 均为 JSON 字符串,合法 JSON 读回解码)、`buttons`→customButtons(写面 customButtonJson JSON 数组字符串;bindAction/useLocation/operateType/showPermType 以枚举名发送;triggerType 强制 QUERY、triggerCode=视图 code、sortKey 按数组位,缺省回传读面 customButtons 有效集;ADD_DATA/FORM 目标绑定走 actionConfig——schemaCodeVal+formListData+configureList,targetCode/targetObjCode 对其无效会被拒;高层参数 targetModel/targetForm/configureList 从读回元数据展开,未解析即 listview-button-target-unresolved 零副作用拒)、`options`→视图头 BizQueryOption(`pagingSetting`{pageSize,showTotal} 分页、`listViewModeSetting`{mode,canSwitch} 列表模式,缺省回传读面有效 options、提供时整体替换,rowColorSetting 无 8.6.26 类证据故对象形态拒绝)与 `presentationType`→QueryPresentationType(LIST/BOARD/CALENDAR/GANTT,缺省回传读面有效值;GANTT 必须同时提供 `gantt`→queryGanttModel 且 startTimePropertyCode/endTimePropertyCode/titlePropertyCode 非空,缺省不触碰既有 gantt)与 `queryLayer`→层级展示(BizQueryLayer[] 数组原样发送)及 `multiTableHeaderConfig`→多级表头(HeaderConfig[] JSON 字符串;缺省回传读面有效值、提供时整体替换)省略时不触碰既有值,提供时整体替换并经出门前 dry-lint;`query/update` 后回读。`queryConditionMap` 为只读派生(query/get 带 formCode 子表条件时才出现),非配置输入。**发布语义**:`query/update` 自动置 publish=TRUE——视图无草稿/发布两态、无需独立发布步骤。**依赖顺序**:视图与表单脚手架都依赖**已发布字段**,规范顺序 model.create → field.create → field.publish(模型级)→ form.draft → form.publish →(需要第二视图时 listview.create)→ listview.configure → rule.save → rule.enable → workflow。",
130
130
  }),
131
131
  "listview.delete": Object.freeze({
132
132
  scope: LIST_VIEW_SCOPE,
@@ -172,7 +172,7 @@ export function assertListViewContract() {
172
172
  // without a round trip through the artifact.
173
173
  assertDescriptionCarries(LIST_VIEW_LANE_CONTRACT, "listview.get", ["query/get", "code", "默认视图", "present"]);
174
174
  assertDescriptionCarries(LIST_VIEW_LANE_CONTRACT, "listview.list", ["query/list", "code"]);
175
- assertDescriptionCarries(LIST_VIEW_LANE_CONTRACT, "listview.configure", ["query/update", "fieldCodes", "默认视图", "querySorts", "queryConditions", "queryActions", "queryActionType", "associationType", "options", "queryPresentation", "htmlJson", "schemaRelations", "customButtons", "customButtonJson", "bindAction", "useLocation", "operateType", "showPermType", "QUERY", "pagingSetting", "listViewModeSetting", "presentationType", "queryGanttModel", "GANTT", "queryLayer", "multiTableHeaderConfig", "publish=TRUE", "field.publish", "rule.enable", "actionConfig", "targetModel", "listview-button-target-unresolved"]);
175
+ assertDescriptionCarries(LIST_VIEW_LANE_CONTRACT, "listview.configure", ["query/update", "fieldCodes", "默认视图", "querySorts", "queryConditions", "queryActions", "queryActionType", "associationType", "options", "queryPresentation", "htmlJson", "schemaRelations", "customButtons", "customButtonJson", "bindAction", "useLocation", "operateType", "showPermType", "QUERY", "pagingSetting", "listViewModeSetting", "presentationType", "queryGanttModel", "GANTT", "queryLayer", "multiTableHeaderConfig", "publish=TRUE", "field.publish", "rule.enable", "actionConfig", "targetModel", "listview-button-target-unresolved", "treeLimitScopeType", "listview-tree-conditions-changed", "allowTreeConditionChange"]);
176
176
  assertDescriptionCarries(LIST_VIEW_LANE_CONTRACT, "listview.delete", ["query/delete", "absence"]);
177
177
  }
178
178
  //# sourceMappingURL=list-view-contract.js.map
@@ -426,6 +426,62 @@ export function treeConditionKeysPresent(row) {
426
426
  return value !== undefined && value !== null && !(typeof value === "string" && value.trim() === "");
427
427
  });
428
428
  }
429
+ /** DTO 数字字段:`BizQueryDataRangeCondition.propertyType/operatorType`。 */
430
+ const TREE_NUMERIC_KEYS = new Set(["propertyType", "operatorType"]);
431
+ /**
432
+ * T22:树过滤组值的规范化。平台类型是 `List<List<BizQueryDataRangeCondition>>`
433
+ * (`BizQueryDataRangeCondition.java:13-23`),读面给对象/数组,调用方可能给同一结构
434
+ * 的 JSON 文本(意图面)且键序不保证。规范化:字符串 trim 后以 `[`/`{` 开头则尝试
435
+ * `JSON.parse`;对象按键排序递归;数组逐项递归。`propertyType`/`operatorType` 只做
436
+ * 数字归一(平台 numeric,`"1"` 与 `1` 同值);`value`/`dynamicValue` 保持字符串
437
+ * 严格比较(`"01"` ≠ `"1"`)。
438
+ */
439
+ export function canonicalTreeValue(value, keyHint) {
440
+ if (typeof value === "string") {
441
+ const trimmed = value.trim();
442
+ if (trimmed.startsWith("[") || trimmed.startsWith("{")) {
443
+ try {
444
+ return canonicalTreeValue(JSON.parse(trimmed), keyHint);
445
+ }
446
+ catch {
447
+ // 不是 JSON:按原字符串比较(不把普通文本当结构改写)
448
+ }
449
+ }
450
+ if (keyHint !== undefined && TREE_NUMERIC_KEYS.has(keyHint) && trimmed !== "" && Number.isFinite(Number(trimmed)))
451
+ return Number(trimmed);
452
+ return value;
453
+ }
454
+ if (Array.isArray(value))
455
+ return value.map((entry) => canonicalTreeValue(entry));
456
+ if (value !== null && typeof value === "object") {
457
+ const record = value;
458
+ return Object.fromEntries(Object.keys(record).sort().map((key) => [key, canonicalTreeValue(record[key], key)]));
459
+ }
460
+ return value;
461
+ }
462
+ /** T22:树过滤组值等价(规范化后 JSON 比较;键序与 JSON 文本/对象差异不算变化)。 */
463
+ export function treeConditionValueEqual(left, right) {
464
+ return JSON.stringify(canonicalTreeValue(left)) === JSON.stringify(canonicalTreeValue(right));
465
+ }
466
+ /**
467
+ * T22:基线 → 提交的树过滤组逐键差异。`missing` = 基线有值、提交缺键(会被整体
468
+ * 替换静默清掉);`changed` = 两侧都有值但不等。基线没有的键不算漂移(普通视图
469
+ * 与 8.6 因此零影响)。
470
+ */
471
+ export function diffTreeConditionKeys(baseline, submitted) {
472
+ const missing = [];
473
+ const changed = [];
474
+ const supplied = treeConditionKeysPresent(submitted);
475
+ for (const key of treeConditionKeysPresent(baseline)) {
476
+ if (!supplied.includes(key)) {
477
+ missing.push(key);
478
+ continue;
479
+ }
480
+ if (!treeConditionValueEqual(baseline[key], submitted[key]))
481
+ changed.push({ key, from: baseline[key], to: submitted[key] });
482
+ }
483
+ return { missing, changed };
484
+ }
429
485
  /**
430
486
  * The keys a list-view condition (a filter CONTROL definition) accepts. Mirrors
431
487
  * `com.authine.cloudpivot.metadata.bizquery.BizQueryConditionModel` (8.6.26) at
@@ -11,7 +11,7 @@ import { QUERY_ACTION_TYPE } from "omc-core/list-view-wire";
11
11
  import { resolveModelTreeNode } from "./model.js";
12
12
  import { NUMERICAL_FORMAT_DECIMALS, SYSTEM_FIELD_CODES, canonicalNumericalFormat } from "../field-families.js";
13
13
  import { LIST_VIEW_LANE_CONTRACT } from "./list-view-contract.js";
14
- import { assertListViewConfigureShape, decodeActionRow, decodeButtonRow, decodeConditionRow, decodeGantt, decodePresentation, decodeSortRow, listViewActionArg, listViewButtonArg, listViewConditionArg, listViewGanttArg, listViewMultiTableHeaderArg, listViewOptionsArg, listViewPresentationArg, listViewQueryLayerArg, listViewSortArg, mergeActions, PLATFORM_DEFAULT_LIST_ACTIONS, normalizeActions, normalizeButtons, normalizeConditions, normalizeGantt, normalizePresentation, normalizeSorts, parseConditionOptions, presentationTypeArg, queryLayerSummary, readArray, resolveFieldRef, treeConditionKeysPresent, buttonsRenderCompat, columnsRenderCompat, } from "./list-view-shapes.js";
14
+ import { assertListViewConfigureShape, decodeActionRow, decodeButtonRow, decodeConditionRow, decodeGantt, decodePresentation, decodeSortRow, diffTreeConditionKeys, LISTVIEW_TREE_CONDITION_KEYS, listViewActionArg, listViewButtonArg, listViewConditionArg, listViewGanttArg, listViewMultiTableHeaderArg, listViewOptionsArg, listViewPresentationArg, listViewQueryLayerArg, listViewSortArg, mergeActions, PLATFORM_DEFAULT_LIST_ACTIONS, normalizeActions, normalizeButtons, normalizeConditions, normalizeGantt, normalizePresentation, normalizeSorts, parseConditionOptions, presentationTypeArg, queryLayerSummary, readArray, resolveFieldRef, treeConditionKeysPresent, treeConditionValueEqual, buttonsRenderCompat, columnsRenderCompat, } from "./list-view-shapes.js";
15
15
  // Ticket 53: every shape (enum/zod/encode/decode/lint) lives once in
16
16
  // ./list-view-shapes.ts and is re-exported for existing import paths.
17
17
  export { assertListViewConfigureShape } from "./list-view-shapes.js";
@@ -732,7 +732,8 @@ export function registerListViewLane(tools) {
732
732
  hideDefaultSystemFields: z.boolean().optional().describe("是否隐藏平台默认系统列(createdTime/creater/name/sequenceNo 等);平台 update 按提交列集合决定,不能靠 visible:false"),
733
733
  replaceColumns: z.boolean().optional().describe("把 fieldCodes 当作列集合的权威全集:未列出的已有列(含系统列)全部移除,最终列 = fieldCodes(按给定顺序)。默认 false 为增量(保留已有列)。系统列与业务列一视同仁——想要 createdTime/sequenceNo 就把它写进 fieldCodes"),
734
734
  sorts: z.array(listViewSortArg).optional().describe("querySorts; omitted leaves the existing sorts untouched, provided replaces them"),
735
- conditions: z.array(listViewConditionArg).optional().describe("queryConditions; omitted leaves the existing conditions untouched, provided replaces them"),
735
+ conditions: z.array(listViewConditionArg).optional().describe("queryConditions; omitted leaves the existing conditions untouched, provided replaces them(2.1.5 树视图三键原样带回;值变化默认拒 listview-tree-conditions-changed)"),
736
+ allowTreeConditionChange: z.boolean().optional().describe("仅当确认要改写树过滤组时传 true:允许提交值与基线的 treeLimitScopeType/treeLimitConditionGroup/treeDefaultConditionGroup 不同(新值原样写入);默认 false 时值不同即拒 listview-tree-conditions-changed。本参数只放行值差异,不放行缺键——基线有值而提交行没带仍拒 listview-tree-conditions-would-be-lost。"),
736
737
  actions: z.array(listViewActionArg).optional().describe("queryActions; omitted leaves the existing actions untouched, provided MERGES into the effective set by actionCode (existing platform defaults like 新增/删除/导入/导出 are preserved, a matching actionCode is updated). Use replaceActions:true for the authoritative full set"),
737
738
  replaceActions: z.boolean().optional().describe("把 actions 当作权威全集:未列出的已有动作(含平台内置的 add/删除/导入/导出/修改拥有者)全部移除。默认 false 为合并(保留内置动作,按 actionCode 更新/追加)"),
738
739
  defaultActions: z.boolean().optional().describe("先并入平台对 PC LIST 视图的默认动作集(add/delete/batch_update/batch_submit/import/export/batch_print/qr_code/editowner/import_attachment/export_attachment,常用于把被替换掉的内置按钮找回),再叠加 actions"),
@@ -781,8 +782,7 @@ export function registerListViewLane(tools) {
781
782
  if (required.length === 0)
782
783
  return [];
783
784
  const propertyCode = String(row.propertyCode ?? "");
784
- const supplied = treeConditionKeysPresent(submittedByCode.get(propertyCode) ?? {});
785
- const missing = required.filter((key) => !supplied.includes(key));
785
+ const missing = diffTreeConditionKeys(row, submittedByCode.get(propertyCode) ?? {}).missing;
786
786
  return missing.length > 0 ? [{ propertyCode, keys: missing }] : [];
787
787
  });
788
788
  if (lost.length > 0)
@@ -798,6 +798,29 @@ export function registerListViewLane(tools) {
798
798
  "2.1.5 的 BizQueryConditionModel.java:90,92,94 有 treeLimitScopeType/treeLimitConditionGroup/treeDefaultConditionGroup 三键," +
799
799
  "提交行未原样带回即随整表替换丢失(平台仍回 200,树过滤组消失)。把这三键原样带进对应条件行,或本次不要改 conditions。",
800
800
  });
801
+ // T22:键带齐但值被改写同样是静默漂移(平台把树过滤组换掉仍然 200)。
802
+ // 键存在性由上面的 lost 闸负责;这里只比值,且只在调用方显式允许时才放行。
803
+ if (args.allowTreeConditionChange !== true) {
804
+ const changed = readArray(model, "queryConditions").flatMap((row) => {
805
+ if (treeConditionKeysPresent(row).length === 0)
806
+ return [];
807
+ const propertyCode = String(row.propertyCode ?? "");
808
+ const diff = diffTreeConditionKeys(row, submittedByCode.get(propertyCode) ?? {}).changed;
809
+ return diff.length > 0 ? [{ propertyCode, changed: diff }] : [];
810
+ });
811
+ if (changed.length > 0)
812
+ throw new ToolRefusalError({
813
+ status: "refused",
814
+ blocker: "listview-tree-conditions-changed",
815
+ schemaCode: args.schemaCode,
816
+ code,
817
+ changed,
818
+ nextAction: "确认要改写树的过滤组就加 allowTreeConditionChange:true 重试(新值会原样写入);只想保留基线就把 treeLimitScopeType/treeLimitConditionGroup/treeDefaultConditionGroup 照抄基线再提交",
819
+ message: "conditions 是整体替换:基线里的树过滤组值被改写了。" +
820
+ `受影响条件:${changed.map((entry) => `${entry.propertyCode}(${entry.changed.map((item) => item.key).join("/")})`).join("、")}。` +
821
+ "默认拒绝值漂移;确认要改就显式传 allowTreeConditionChange:true。",
822
+ });
823
+ }
801
824
  }
802
825
  let sortKey = columns.reduce((max, c) => Math.max(max, Number(c.sortKey) || 0), 0);
803
826
  const added = [];
@@ -1100,7 +1123,19 @@ export function registerListViewLane(tools) {
1100
1123
  ["startValue", spec.requested.startValue, stored.startValue],
1101
1124
  ["endValue", spec.requested.endValue, stored.endValue],
1102
1125
  ];
1103
- return fields.filter(([, from]) => from !== undefined).filter(([, from, to]) => !conditionValueEqual(from, to)).map(([field, from, to]) => ({ propertyCode: spec.propertyCode, field, from, to }));
1126
+ const fieldCoercions = fields
1127
+ .filter(([, from]) => from !== undefined)
1128
+ .filter(([, from, to]) => !conditionValueEqual(from, to))
1129
+ .map(([field, from, to]) => ({ propertyCode: spec.propertyCode, field, from, to }));
1130
+ // T22:树过滤组三键纳入写后等价(任一侧有值就比较;两侧都没有时零键、
1131
+ // 8.6 回执不多一个字节)。值比较走树值规范化:键序/JSON 文本差异不算
1132
+ // 平台改写,只有真实值变化才进 coercions。
1133
+ const requestedTreeKeys = treeConditionKeysPresent(spec.requested);
1134
+ const storedTreeKeys = treeConditionKeysPresent(stored);
1135
+ const treeCoercions = LISTVIEW_TREE_CONDITION_KEYS.filter((key) => requestedTreeKeys.includes(key) || storedTreeKeys.includes(key))
1136
+ .filter((key) => !treeConditionValueEqual(spec.requested[key], stored[key]))
1137
+ .map((key) => ({ propertyCode: spec.propertyCode, field: key, from: spec.requested[key], to: stored[key] }));
1138
+ return [...fieldCoercions, ...treeCoercions];
1104
1139
  });
1105
1140
  const equivalent = missingConditions.length === 0 && coercions.length === 0;
1106
1141
  readback.conditionReadback = {
@@ -295,7 +295,7 @@ export function registerMetaLane(tools) {
295
295
  try {
296
296
  const session = await ctx.sessions.session(args.environment);
297
297
  const version = session.detectedVersion();
298
- steps.push({ step: "登录", ok: true, enterpriseId: session.enterpriseId(), administrator: session.administrator() });
298
+ steps.push({ step: "登录", ok: true, enterpriseId: session.enterpriseId(), administrator: session.administrator(), loginSource: session.loginSource() });
299
299
  // A deployment whose system/config carries an unusual/absent `client`
300
300
  // blob still logs in (client_secret is optional). Report it as a WARN
301
301
  // instead of letting it read as a failed self-check.
@@ -305,12 +305,13 @@ export function registerMetaLane(tools) {
305
305
  const familyOk = version ? version.startsWith(ctx.manifest.version_family + ".") : null;
306
306
  steps.push({
307
307
  step: "版本族",
308
- // Outside the anchor family is advisory (WARN), not a failed write gate.
309
- ok: familyOk === null ? false : familyOk ? true : null,
308
+ // 无证据 / 非锚点族都只是 WARN:版本不是写门(2026-11-24 口径)。
309
+ ok: familyOk === null ? null : familyOk ? true : null,
310
310
  version: version ?? null,
311
311
  expectedFamily: ctx.manifest.version_family,
312
312
  anchor: ctx.manifest.anchor_version,
313
- note: familyOk === null ? "缺少版本证据;写入将保守拒绝" : versionFamilyNotice(ctx.manifest, version) ?? "兼容",
313
+ ...(version === undefined ? { versionEvidence: "absent" } : {}),
314
+ note: familyOk === null ? "缺少版本证据:写入按兼容模式放行(versionEvidence=absent),平台是最终门" : versionFamilyNotice(ctx.manifest, version) ?? "兼容",
314
315
  });
315
316
  steps.push({ step: "环境指纹", ok: true, fingerprint: session.environmentFingerprint() });
316
317
  // T09 — optional per-service credential shape probe (non-fatal).
@@ -1476,8 +1476,11 @@ export function registerModelLane(tools) {
1476
1476
  throw new ToolRefusalError({ status: "refused", blocker: "business-code-invalid", message: "code 未过出门前校验;按 validation 修正(长度/风格/保留字)", validation: violations });
1477
1477
  for (const entry of entries)
1478
1478
  assertSelectionChoicesAllowed(entry);
1479
+ // Preflight runs before a session exists → no version evidence. Defer the
1480
+ // DATE family decision to the session-aware write seam (same as
1481
+ // assertFieldFamilyAllowed); everything else is still fully gated here.
1479
1482
  for (const entry of entries)
1480
- prepareFieldChange(fieldChangeInputOf(args.code, entry));
1483
+ prepareFieldChange(fieldChangeInputOf(args.code, entry, { deferDateFormatFamily: true }));
1481
1484
  },
1482
1485
  plan: (args) => {
1483
1486
  const entries = fieldEntriesOf(args);
@@ -1593,7 +1596,7 @@ export function registerModelLane(tools) {
1593
1596
  }
1594
1597
  const configureTargetVersion = session.detectedVersion();
1595
1598
  for (const entry of entries) {
1596
- const input = fieldChangeInputOf(args.code, entry, configureTargetVersion);
1599
+ const input = fieldChangeInputOf(args.code, entry, { targetVersion: configureTargetVersion });
1597
1600
  failed = await run(results.length, "field.create", async () => {
1598
1601
  const existing = existingFields.get(entry.code);
1599
1602
  if (existing !== undefined) {
@@ -1726,13 +1729,14 @@ function fieldEntriesOf(args) {
1726
1729
  assertFieldFamilyAllowed(legacy);
1727
1730
  return [legacy];
1728
1731
  }
1729
- function fieldChangeInputOf(schemaCode, entry, targetVersion) {
1732
+ function fieldChangeInputOf(schemaCode, entry, scope = {}) {
1730
1733
  return {
1731
1734
  schemaCode,
1732
1735
  code: entry.code,
1733
1736
  name: entry.name,
1734
1737
  propertyType: entry.propertyType,
1735
- ...(targetVersion ? { targetVersion } : {}),
1738
+ ...(scope.targetVersion ? { targetVersion: scope.targetVersion } : {}),
1739
+ ...(scope.deferDateFormatFamily ? { deferDateFormatFamily: true } : {}),
1736
1740
  ...(entry.options ? { options: entry.options } : {}),
1737
1741
  ...(entry.choices ? { choices: entry.choices } : {}),
1738
1742
  ...(entry.relativeCode ? { relativeCode: entry.relativeCode } : {}),
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Wire facts for the organization "light query" read faces
3
+ * (`org.searchUnits` / `org.department.search` / `org.visibleDepartments` /
4
+ * `org.departmentTree` / `org.users`). They mirror the platform MCP organization
5
+ * tool set (`InternalMcpOrganizationToolSet`: organization_search_units /
6
+ * organization_query_visible_departments / organization_query_department_tree /
7
+ * organization_query_simple_users + organization_query_detailed_users) but ride
8
+ * the **session (cookie/bearer) controller face**, not the openapi v3 face.
9
+ *
10
+ * Why not `/openapi/v3/organization/*` — those controllers call
11
+ * `OpenapiPermissionAspect.openapiAspect()`, which reads the OAuth2 client id
12
+ * (`AuthUtils.getClientId()`) and refuses with 「获取到客户端id为空」 when the
13
+ * caller is a normal logged-in user (`OpenapiPermissionAspect.java:97-104`).
14
+ * The CLI has no OAuth2 client credentials, so the equivalent session endpoints
15
+ * are the source of truth here.
16
+ *
17
+ * Paths are kept in this lane module instead of `../endpoints.ts` because that
18
+ * file is owned by a parallel change; **待收编** into `ENDPOINTS` once it lands
19
+ * (values verified against both 8.6.26 and 2.1.5 controllers).
20
+ */
21
+ export const ORG_QUERY_ENDPOINTS = Object.freeze({
22
+ /** `POST` body `{wd,page,size}` → `PageVO<UserVO>`; `wd` required (empty answers 10005). */
23
+ userSearch: "/api/api/organization/user/search",
24
+ /** `POST` body `{wd}` → `DepartmentModel[]`; unpaged. */
25
+ userSearchDepartments: "/api/api/organization/user/searchDepartments",
26
+ /** `POST` body `{userName,deptIds,roleIds,userIds,page,size}` → `PageVO<UserInfoVO>`; pageable ignored server-side. */
27
+ userSearchCondition: "/api/api/organization/user/searchCondiction",
28
+ /** `GET ?id=` → `[{deptId,isMain,deptName}]`. */
29
+ userDepartments: "/api/api/organization/user/departments",
30
+ /** `GET ?deptIds=` → `{departmentList,myDepartment}`; one level below `deptIds`, roots when empty. */
31
+ departmentTree: "/api/api/organization/department/tree",
32
+ /** `GET ?corpId=` → `DepartmentModel` (corp root). */
33
+ corpRootDepartment: "/api/api/organization/department/get_corp_root_dept_info",
34
+ /** `GET ?deptId=` → direct members (`UserSelectionVO[]`). */
35
+ departmentMembers: "/api/api/organization/department/list_user",
36
+ /** `GET ?deptId=` → `DeptVO` carrying `scopeModel` (selection visibility scope). */
37
+ departmentScopeDetail: "/api/api/organization/department/search_dept_detail",
38
+ });
39
+ /**
40
+ * Coverage scopes. All four tools resolve organization units and people, which
41
+ * is what the `W7-S29-greenfield` manifest item "workflow participant
42
+ * resolution (org roles/departments)" already covers for
43
+ * `org.role.list` / `org.department.list` / `org.user.search`; the claims live
44
+ * in `org-query-coverage.ts` so that forbidden-to-touch `workflow-coverage.ts`
45
+ * stays untouched.
46
+ */
47
+ export const ORG_QUERY_SCOPES = Object.freeze({
48
+ searchUnits: "org directory read: search users and departments by name",
49
+ departmentSearch: "org directory read: search departments by name (paged)",
50
+ visibleDepartments: "org directory read: department selection visibility scope",
51
+ departmentTree: "org directory read: direct child departments of a parent",
52
+ users: "org directory read: in-service user paging (simple/detailed projection)",
53
+ });
54
+ /** The manifest capability these read faces are claimed under. */
55
+ export const ORG_QUERY_CAPABILITY = "organization lightweight queries (search/visible/tree/users)";
56
+ /** Evidence anchors; at least one must be present in the manifest item's ledger. */
57
+ export const ORG_QUERY_EVIDENCE = Object.freeze([
58
+ "packages/omc-cli/src/lanes/org-query.ts",
59
+ "packages/omc-cli/src/lanes/org-query-contract.ts",
60
+ "packages/omc-cli/test/org-query.test.ts",
61
+ ]);
62
+ //# sourceMappingURL=org-query-contract.js.map
@@ -0,0 +1,27 @@
1
+ import { claim, declareLaneCoverage } from "./coverage-declaration.js";
2
+ import { LANES } from "./lane-ids.js";
3
+ import { ORG_QUERY_CAPABILITY, ORG_QUERY_EVIDENCE, ORG_QUERY_SCOPES } from "./org-query-contract.js";
4
+ /**
5
+ * Coverage claims for the organization light-query read faces.
6
+ *
7
+ * They carry their own manifest capability (same lane, distinct title) instead
8
+ * of extending "workflow participant resolution (org roles/departments)": a
9
+ * manifest item holds exactly one generated tool list, so two declarations
10
+ * sharing a title would overwrite each other's claim. The declaration also
11
+ * lives in its own module because `workflow-coverage.ts` is owned by a parallel
12
+ * change.
13
+ */
14
+ export const ORG_QUERY_COVERAGE = declareLaneCoverage(LANES.workflow, [
15
+ {
16
+ capability: ORG_QUERY_CAPABILITY,
17
+ evidence: ORG_QUERY_EVIDENCE,
18
+ tools: [
19
+ claim("org.searchUnits", ORG_QUERY_SCOPES.searchUnits),
20
+ claim("org.department.search", ORG_QUERY_SCOPES.departmentSearch),
21
+ claim("org.visibleDepartments", ORG_QUERY_SCOPES.visibleDepartments),
22
+ claim("org.departmentTree", ORG_QUERY_SCOPES.departmentTree),
23
+ claim("org.users", ORG_QUERY_SCOPES.users),
24
+ ],
25
+ },
26
+ ]);
27
+ //# sourceMappingURL=org-query-coverage.js.map