@stalfh233/omc-cli 0.7.0 → 0.8.0

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 (46) hide show
  1. package/coverage/m1-coverage-manifest-v1.json +88 -2
  2. package/dist/capability-overview.js +16 -4
  3. package/dist/cli.js +12 -5
  4. package/dist/contract-resources.js +2 -0
  5. package/dist/coverage-registry.js +4 -0
  6. package/dist/coverage.js +16 -2
  7. package/dist/endpoints.js +65 -0
  8. package/dist/environment-policy.js +15 -1
  9. package/dist/field-change.js +9 -2
  10. package/dist/field-families.js +27 -6
  11. package/dist/governed-execution.js +18 -12
  12. package/dist/human-summary.js +8 -0
  13. package/dist/intent/capabilities/field.js +6 -0
  14. package/dist/lanes/environment.js +3 -0
  15. package/dist/lanes/field-contract.js +117 -6
  16. package/dist/lanes/file-contract.js +69 -0
  17. package/dist/lanes/file-coverage.js +16 -0
  18. package/dist/lanes/file.js +257 -0
  19. package/dist/lanes/lane-ids.js +1 -0
  20. package/dist/lanes/list-view-contract.js +3 -3
  21. package/dist/lanes/list-view-shapes.js +56 -0
  22. package/dist/lanes/list-view.js +40 -5
  23. package/dist/lanes/meta.js +4 -3
  24. package/dist/lanes/model.js +8 -4
  25. package/dist/lanes/org-query-contract.js +62 -0
  26. package/dist/lanes/org-query-coverage.js +27 -0
  27. package/dist/lanes/org-query.js +610 -0
  28. package/dist/lanes/organization.js +44 -11
  29. package/dist/lanes/runtime-data.js +228 -59
  30. package/dist/lanes/workflow-contract.js +100 -1
  31. package/dist/lanes/workflow-coverage.js +13 -0
  32. package/dist/lanes/workflow.js +599 -13
  33. package/dist/package.js +3 -1
  34. package/dist/read-shapes.js +3 -3
  35. package/dist/recipes/runtime-data.js +8 -6
  36. package/dist/refusal-guidance.js +1 -1
  37. package/dist/rule-support.js +15 -17
  38. package/dist/session.js +16 -1
  39. package/dist/tool-types.js +15 -1
  40. package/dist/tools.js +7 -0
  41. package/dist/version-family-gaps.js +8 -1
  42. package/dist/version-partition.js +633 -0
  43. package/dist/wire.js +8 -2
  44. package/dist/write.js +11 -2
  45. package/package.json +1 -1
  46. package/skills/omc-capabilities.md +8 -1
@@ -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 = {
@@ -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