@stalfh233/omc-cli 0.6.31 → 0.6.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +5 -5
- package/dist/goal-routes.js +46 -11
- package/dist/lanes/model-contract.js +1 -1
- package/dist/lanes/perm-contract.js +1 -1
- package/dist/lanes/perm-coverage.js +1 -1
- package/dist/lanes/perm.js +73 -28
- package/dist/path-projection.js +1 -1
- package/dist/residue.js +8 -1
- package/package.json +3 -3
package/dist/cli.js
CHANGED
|
@@ -532,7 +532,7 @@ async function cmdCall(store, args) {
|
|
|
532
532
|
if (described) {
|
|
533
533
|
console.error(`工具:${toolName}`);
|
|
534
534
|
console.error(`输出预算:--max-output-bytes 默认 65536(只约束最终 stdout 信封;读面 diet ~2048 独立外置 detailArtifactId);artifact get 内联上限 8192`);
|
|
535
|
-
console.error(`投影:--jq/--extract 相对 result(不要写 result. 前缀;误写会自动剥并标 autoStripped);先投影再判预算`);
|
|
535
|
+
console.error(`投影:--jq 不是 jq,仅路径选择器;--jq/--extract 相对 result(不要写 result. 前缀;误写会自动剥并标 autoStripped);先投影再判预算`);
|
|
536
536
|
return emitTransportResult({ status: "ok", ...described, helpNote: "来自 omc describe;完整面用 omc describe <tool> [--full|--param|--example]" }, { request, maxOutputBytes });
|
|
537
537
|
}
|
|
538
538
|
}
|
|
@@ -812,7 +812,7 @@ async function cmdCall(store, args) {
|
|
|
812
812
|
const unsupported = result.extract.filter((entry) => entry.unsupportedSyntax === true);
|
|
813
813
|
if (unsupported.length > 0) {
|
|
814
814
|
const first = unsupported[0];
|
|
815
|
-
const message = `--jq
|
|
815
|
+
const message = `--jq 不是 jq:仅路径选择器,不支持对象构造或管道语法(${String(first?.path ?? "")})。可运行示例:--jq 'fields[].code,fields[].typeName'`;
|
|
816
816
|
const invalid = { status: "error", blocker: "tool-input-invalid", unsupportedSyntax: true, paths: unsupported.map((entry) => entry.path), message, nextCommand: "omc call <tool> --args '<json>' --jq 'fields[].code,fields[].typeName'" };
|
|
817
817
|
return emit("error", invalid, CLI_EXIT_CODES.invalidInput);
|
|
818
818
|
}
|
|
@@ -2147,7 +2147,7 @@ async function main() {
|
|
|
2147
2147
|
const described = describeTool(registry, toolName);
|
|
2148
2148
|
console.error(`工具:${toolName}`);
|
|
2149
2149
|
console.error(`输出预算:--max-output-bytes 默认 2048(超则回 artifact 指针 + sha256);artifact get 内联上限 8192`);
|
|
2150
|
-
console.error(`投影:--jq/--extract 相对 result(不要写 result. 前缀;误写会自动剥并标 autoStripped)`);
|
|
2150
|
+
console.error(`投影:--jq 不是 jq,仅路径选择器;--jq/--extract 相对 result(不要写 result. 前缀;误写会自动剥并标 autoStripped)`);
|
|
2151
2151
|
if (described) {
|
|
2152
2152
|
writeEnvelope(envelope("ok", { ...described, helpNote: "来自 omc describe;完整面用 omc describe <tool> [--full|--param|--example]" }, request));
|
|
2153
2153
|
return CLI_EXIT_CODES.ok;
|
|
@@ -2535,9 +2535,9 @@ async function main() {
|
|
|
2535
2535
|
pureKeys: (options.keys === true || bareJq) && options.summary !== true, ...(typeof options.keys === "string" ? { keys: options.keys } : {}), full: options.full === true }));
|
|
2536
2536
|
});
|
|
2537
2537
|
command.command("bench").option("--live-sample").option("--env <environment>").action(async (options) => { commandExitCode = await cmdBench([...(options.liveSample ? ["--live-sample"] : []), ...(options.env ? ["--env", options.env] : [])]); });
|
|
2538
|
-
command.command("residue <prefix>").description("跨面前缀残留扫描(model 全租户/folder/custompage;默认 deep 再查命中模型的 rule/datarule/onlinejs)——收尾「删净」一次证明,clean:true 即零残留。清理入口:omc model-purge --code <schemaCode>(按依赖倒序,默认 dry-run)。只读零写入;report 面暂停维护未扫描").option("--env <environment>", "环境名(默认按 cwd 的 .omc-env 解析)").option("--apps <codes>", "all(默认,全租户)或逗号分隔应用码").option("--no-deep", "只扫 model/folder/custompage,不深查命中模型").option("--all-faces", "列出全部应用×面(含 count:0;默认只回非零面+byFace/userResidues 紧凑形)").option("--max-output-bytes <bytes>").action(async (prefix, options) => { commandExitCode = await withTransport(options, request, (transport) => cmdResidue(prefix, { env: options.env, apps: options.apps, ...(options.deep === false ? { noDeep: true } : {}), ...(options.allFaces ? { allFaces: true } : {}) }, transport)); });
|
|
2538
|
+
command.command("residue <prefix>").description("跨面前缀残留扫描(model 全租户/folder/custompage;默认 deep 再查命中模型的 rule/datarule/onlinejs)——收尾「删净」一次证明,clean:true 即零残留。清理入口:omc model-purge --code <schemaCode>(按依赖倒序,默认 dry-run)。只读零写入;report 面暂停维护未扫描").option("--env <environment>", "环境名(默认按 cwd 的 .omc-env 解析)").option("--apps <codes>", "all(默认,全租户)或逗号分隔应用码").option("--no-deep", "只扫 model/folder/custompage,不深查命中模型").option("--all-faces", "列出全部应用×面(含 count:0;默认只回非零面+byFace/userResidues 紧凑形)").option("--max-output-bytes <bytes>").addOption(new Option("--jq [path]", "--jq 不是 jq,仅路径选择器(与 call --jq 同 DSL;可逗号多路径;裸 --jq 列顶层键)").argParser((value, previous = []) => [...previous, value]).default([])).action(async (prefix, options) => { commandExitCode = await withTransport(options, request, (transport) => cmdResidue(prefix, { env: options.env, apps: options.apps, ...(options.deep === false ? { noDeep: true } : {}), ...(options.allFaces ? { allFaces: true } : {}), ...(options.jq !== undefined ? { jq: options.jq } : {}) }, transport)); });
|
|
2539
2539
|
command.command("track <schemaCode> <bizObjectId>").description("读取单条业务数据的行级变更留痕(只读;平台来源枚举含 BUSINESS_RULE 时原样回传)").option("--env <environment>").option("--property-code <code>").option("--max-output-bytes <bytes>").action(async (schemaCode, bizObjectId, options) => { commandExitCode = await withTransport(options, request, (transport) => cmdTrack(schemaCode, bizObjectId, { env: options.env, propertyCode: options.propertyCode }, transport)); });
|
|
2540
|
-
const jqOption = () => new Option("--jq [path]", "
|
|
2540
|
+
const jqOption = () => new Option("--jq [path]", "--jq 不是 jq,仅路径选择器(与 call --jq 同 DSL;可逗号多路径;裸 --jq 列顶层键)").argParser((value, previous = []) => [...previous, value]).default([]);
|
|
2541
2541
|
command.command("commands").option("--json").option("--compact").option("--filter <keyword>").option("--lane <id>").option("--max-output-bytes <bytes>").addOption(jqOption()).action(async (options) => { commandExitCode = await withTransport(options, request, (transport) => cmdDiscovery("commands", transport, undefined, { json: options.json === true, compact: options.compact === true, ...(options.filter ? { filter: options.filter } : {}), ...(options.lane ? { lane: options.lane } : {}), ...(options.jq !== undefined ? { jq: options.jq } : {}) })); });
|
|
2542
2542
|
command.command("describe <tool>").option("--full").option("--cache-ok", "允许 --full 在同会话重复读时短路为 artifact 指针(默认每次回全文)").option("--schema-only").option("--param <name>").option("--example [id]").option("--max-output-bytes <bytes>").addOption(jqOption()).action(async (tool, options) => {
|
|
2543
2543
|
commandExitCode = await withTransport(options, request, (transport) => cmdDiscovery("describe", transport, tool, { full: options.full === true, cacheOk: options.cacheOk === true, schemaOnly: options.schemaOnly === true, ...(options.param ? { param: options.param } : {}), ...(options.example ? { example: options.example } : {}), ...(options.jq !== undefined ? { jq: options.jq } : {}) }));
|
package/dist/goal-routes.js
CHANGED
|
@@ -571,6 +571,19 @@ function wholePackageRoute(registry, goal, index, hitCapabilities) {
|
|
|
571
571
|
capability: id,
|
|
572
572
|
why: capabilityWhy(id, goal),
|
|
573
573
|
}));
|
|
574
|
+
const intentCovered = ordered.every((id) => (index.nodeById.get(id)?.intent.level ?? "none") !== "none");
|
|
575
|
+
const atomicLadder = ordered.map((id) => {
|
|
576
|
+
const capability = routeById.get(id);
|
|
577
|
+
const recipe = bestRecipe(registry, id, capability.lane, goal) ?? defaultRecipeFor(registry, id, capability.lane);
|
|
578
|
+
return {
|
|
579
|
+
capability: id,
|
|
580
|
+
lane: capability.lane,
|
|
581
|
+
tools: stepTools(registry, capability.lane),
|
|
582
|
+
...(recipe
|
|
583
|
+
? { recipe: { tool: recipe.tool, id: recipe.recipe, command: `omc describe ${recipe.tool} --example ${recipe.recipe}` } }
|
|
584
|
+
: { firstCommand: `omc commands --json --compact --lane ${capability.lane}` }),
|
|
585
|
+
};
|
|
586
|
+
});
|
|
574
587
|
const greenfield = looksGreenfield(goal);
|
|
575
588
|
return {
|
|
576
589
|
status: "ok",
|
|
@@ -579,10 +592,16 @@ function wholePackageRoute(registry, goal, index, hitCapabilities) {
|
|
|
579
592
|
mode: "whole-package",
|
|
580
593
|
match: { kind: "whole-package", ref: ordered.join("→"), capabilities: ordered },
|
|
581
594
|
route: {
|
|
582
|
-
primary: "intent",
|
|
595
|
+
primary: intentCovered ? "intent" : "atomic",
|
|
596
|
+
...(intentCovered ? {} : {
|
|
597
|
+
note: "命中能力中有 intent.level=none 的面,声明式 intent 不覆盖全部需求,走原子工具阶梯;intent 仅作可用能力补充提示",
|
|
598
|
+
ladder: atomicLadder,
|
|
599
|
+
}),
|
|
583
600
|
faceCount: faces.length,
|
|
584
601
|
atomicSupplement: {
|
|
585
|
-
note:
|
|
602
|
+
note: intentCovered
|
|
603
|
+
? "intent 已覆盖下列能力的创建;原子工具只用于 intent 未覆盖面(删除/生命周期/运行数据/精确 patch)"
|
|
604
|
+
: "intent 仅覆盖下列能力中的部分面;未覆盖能力必须走原子工具",
|
|
586
605
|
capabilities: ordered,
|
|
587
606
|
// round16b: 这是**指针**(capability + why),不是第二套执行阶梯——
|
|
588
607
|
// 每步都不带 tools,否则就等于把 atomic ladder 又内联一遍。
|
|
@@ -592,22 +611,31 @@ function wholePackageRoute(registry, goal, index, hitCapabilities) {
|
|
|
592
611
|
// r19 ticket 04: readiness (discover_environment) left firstCommands —
|
|
593
612
|
// the probe executed it 0 times in 184 calls; it rides its own field now.
|
|
594
613
|
readiness: DISCOVERY_AUTHORITY.readiness,
|
|
595
|
-
firstCommands:
|
|
614
|
+
firstCommands: intentCovered
|
|
615
|
+
? ["omc intent schema", "omc help omc-playbook --section 采购申请"]
|
|
616
|
+
: atomicLadder.flatMap((step) => "firstCommand" in step ? [step.firstCommand] : step.recipe ? [step.recipe.command] : []).slice(0, 3),
|
|
596
617
|
write: true,
|
|
597
618
|
},
|
|
598
619
|
write: true,
|
|
599
620
|
intent: intentGuidance(),
|
|
600
|
-
firstAnswer: greenfield
|
|
621
|
+
firstAnswer: intentCovered && greenfield
|
|
601
622
|
? {
|
|
602
623
|
state: "ready",
|
|
603
624
|
action: "omc intent schema",
|
|
604
625
|
why: "从零整包:模型还不存在——先看 intent 键位/示例,再按 starter 写 YAML(validate → plan → apply);不要先问已有 schemaCode",
|
|
605
626
|
}
|
|
606
|
-
:
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
627
|
+
: intentCovered
|
|
628
|
+
? {
|
|
629
|
+
state: "ready",
|
|
630
|
+
action: "omc intent schema",
|
|
631
|
+
why: "整包需求走声明式意图:先看 intent YAML 的键位与可运行示例,再按 starter 写文件(validate → plan → apply)",
|
|
632
|
+
}
|
|
633
|
+
: {
|
|
634
|
+
state: "needs-input",
|
|
635
|
+
action: atomicLadder.find((step) => "firstCommand" in step)?.firstCommand,
|
|
636
|
+
question: "第一步要操作哪个对象?给我 schemaCode(或模型业务名,我列清单核对)",
|
|
637
|
+
why: "命中能力包含 intent 未覆盖面,不能把整包需求主推到声明式 intent;先按原子工具阶梯执行",
|
|
638
|
+
},
|
|
611
639
|
};
|
|
612
640
|
}
|
|
613
641
|
/** A configuration read-back ask that names no capability ("给我一份现状说明"). */
|
|
@@ -633,6 +661,9 @@ function readOverviewRoute(registry, goal, index) {
|
|
|
633
661
|
}
|
|
634
662
|
export function goalRoute(registry, goal) {
|
|
635
663
|
const index = capabilityRouteIndex(registry);
|
|
664
|
+
// r49 F1(探针复现):whole-package 主推 intent 前必须确认命中能力的 intent 覆盖——
|
|
665
|
+
// intent.level=none 的能力(如 perm)主推 intent 是把用户推向走不通的路。
|
|
666
|
+
const intentCoveredOf = (ids) => ids.every((id) => (index.nodeById.get(id)?.intent.level ?? "none") !== "none");
|
|
636
667
|
const routeById = new Map(index.routes.map((route) => [route.id, route]));
|
|
637
668
|
const registryTools = new Map(registry.map((tool) => [tool.name, tool]));
|
|
638
669
|
const availableTopics = new Set(listSkills().map((topic) => topic.name));
|
|
@@ -975,7 +1006,9 @@ export function goalRoute(registry, goal) {
|
|
|
975
1006
|
mode: whole ? "whole-package" : mode,
|
|
976
1007
|
match: { kind: readish ? "read-ladder" : "ladder", ref: `${ordered.join("→")}${ordered.includes("businessrule") && /累加|联动|审计|规则触发|自动累加|自动回写/.test(goal) ? "(规则面不在本阶梯)" : ""}`, capabilities: ordered },
|
|
977
1008
|
route: {
|
|
978
|
-
...(whole ?
|
|
1009
|
+
...(whole ? (intentCoveredOf(ordered)
|
|
1010
|
+
? { primary: "intent", atomicSupplement }
|
|
1011
|
+
: { primary: "atomic", note: "命中能力中有 intent.level=none 的面,声明式 intent 不覆盖全部需求,走原子工具阶梯", ladder }) : { ladder }),
|
|
979
1012
|
// r28e F2(真机复现 2026-11-05):`next "建表单布局、在线JS、表单按钮"`
|
|
980
1013
|
// 命中的是 model→form→listview→businessrule→onlinejs 的整包 ladder,
|
|
981
1014
|
// 其中只有 businessrule 有配方 —— 于是 firstCommands 唯一一条变成了
|
|
@@ -1067,7 +1100,9 @@ export function goalRoute(registry, goal) {
|
|
|
1067
1100
|
route: {
|
|
1068
1101
|
capability: capabilityId,
|
|
1069
1102
|
lane: route.lane,
|
|
1070
|
-
...(whole ?
|
|
1103
|
+
...(whole ? (intentCoveredOf([capabilityId])
|
|
1104
|
+
? { primary: "intent" }
|
|
1105
|
+
: { primary: "atomic", note: "该能力无声明式面(intent.level=none),走原子工具" }) : {}),
|
|
1071
1106
|
...(readish ? { readTools: readToolsInLane(registry, route.lane) } : { tools: route.tools }),
|
|
1072
1107
|
...routeReads(sectionPointersFor([capabilityId]), recipe !== undefined),
|
|
1073
1108
|
readiness: DISCOVERY_AUTHORITY.readiness,
|
|
@@ -100,7 +100,7 @@ export const MODEL_LANE_CONTRACT = Object.freeze({
|
|
|
100
100
|
tools: Object.freeze({
|
|
101
101
|
"model.list": Object.freeze({
|
|
102
102
|
scope: MODEL_SCOPE,
|
|
103
|
-
description: "List the models in an application (apppackage/trees, type==='BizModel') as a stable `{code,schemaCode,name[,legacyString]}` inventory (never a bare `code|name` string — diet 也保对象形). Fills the gap where enumerating models otherwise required discover_environment + an artifact read. `applicationCode` optional
|
|
103
|
+
description: "List the models in an application (apppackage/trees, type==='BizModel') as a stable `{code,schemaCode,name[,legacyString]}` inventory (never a bare `code|name` string — diet 也保对象形). Fills the gap where enumerating models otherwise required discover_environment + an artifact read. `applicationCode` optional(即 `appCode`;configured/default app; unknown → app-not-found); `filter`/`search`/`query` are interchangeable substring matches on code/name."
|
|
104
104
|
}),
|
|
105
105
|
"model.inspect": Object.freeze({
|
|
106
106
|
scope: MODEL_SCOPE,
|
|
@@ -4,7 +4,7 @@ export const PERM_TOOLS = Object.freeze({
|
|
|
4
4
|
"perm.groups": { scope: "permission group list/detail/auth read", description: "读取应用权限包、权限组及按模型的权限摘要。" },
|
|
5
5
|
"perm.user": { scope: "merged user permission config read", description: "读取用户合并后的配置层权限摘要;不冒充运行时单值判定。" },
|
|
6
6
|
"perm.assign": { scope: "permission group member assign/revoke", description: "授权或撤销权限组成员并读回成员真值,回执包含 roles/departments 成员前后对比。" },
|
|
7
|
-
"perm.auth": { scope: "permission group auth merge with diff", description: "按声明式 grants 合并保存权限组模型权限:模型可见使用 visibleConfig,行级使用 dataPermissionType/conditions
|
|
7
|
+
"perm.auth": { scope: "permission group auth merge with diff", description: "按声明式 grants 合并保存权限组模型权限:模型可见使用 visibleConfig,行级使用 dataPermissionType/conditions(1=全部可见、2=本部门、3=仅自己、4=自定义须 conditions、5=角色管理范围、6=均不可见),字段级使用 propertityPermissionGroups 的 visible/writeAble/decryptAble(property.schemaCode 可省略并继承 grants.schemaCode),模型动作使用 customButtonViewPerm/customButtonFormPerm;字段表采用整表合并保护,避免平台覆盖未声明字段。editable/creatable 等扁平字段不支持。" },
|
|
8
8
|
"perm.group": { scope: "permission group CRUD and status", description: "创建、更新、删除权限组并切换启停状态。" },
|
|
9
9
|
});
|
|
10
10
|
// r48a 接线(2026-11-09):LaneContractShape 使 `omc contract B3-perm` 可解析
|
|
@@ -2,7 +2,7 @@ import { claim, declareLaneCoverage } from "./coverage-declaration.js";
|
|
|
2
2
|
import { PERM_LANE, PERM_TOOLS } from "./perm-contract.js";
|
|
3
3
|
export const PERM_COVERAGE = declareLaneCoverage(PERM_LANE, [{
|
|
4
4
|
capability: "Permission package/group CRUD, merged user access, assignment, and auth merge",
|
|
5
|
-
evidence: ["packages/omc-cli/src/lanes/perm.ts", "packages/omc-cli/test/perm.test.ts", ".scratch/r48-perm/TASK-r48a.md"],
|
|
5
|
+
evidence: ["packages/omc-cli/src/lanes/perm.ts", "packages/omc-cli/test/perm.test.ts", ".scratch/r48-perm/TASK-r48a.md", ".scratch/r48-perm/FORENSIC-update-function-silent.md", ".scratch/r49-scenarios/perm-acceptance/TRIAGE.md"],
|
|
6
6
|
tools: Object.entries(PERM_TOOLS).map(([name, value]) => claim(name, value.scope)),
|
|
7
7
|
}]);
|
|
8
8
|
//# sourceMappingURL=perm-coverage.js.map
|
package/dist/lanes/perm.js
CHANGED
|
@@ -72,12 +72,14 @@ export function projectMembers(data) {
|
|
|
72
72
|
}
|
|
73
73
|
function mergePropertyPermissions(existing, requested, schemaCode) {
|
|
74
74
|
const current = rows(existing).map((item) => ({ ...item }));
|
|
75
|
-
const byCode = new Map(current.map((item) => [String(item.propertyCode ?? ""), item]));
|
|
76
75
|
for (const property of requested ?? []) {
|
|
77
|
-
const
|
|
76
|
+
const code = String(property.propertyCode ?? "");
|
|
77
|
+
const index = current.findIndex((item) => String(item.propertyCode ?? "") === code && String(item.schemaCode ?? schemaCode) === String(property.schemaCode ?? schemaCode));
|
|
78
|
+
const prior = index >= 0 ? current[index] : undefined;
|
|
78
79
|
const merged = { ...(prior ?? {}), propertyCode: property.propertyCode, schemaCode: property.schemaCode ?? schemaCode, ...(property.visible !== undefined ? { visible: property.visible } : {}), ...(property.writeAble !== undefined ? { writeAble: property.writeAble } : {}), ...(property.decryptAble !== undefined ? { decryptAble: property.decryptAble } : {}) };
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
if (index >= 0)
|
|
81
|
+
current[index] = merged;
|
|
82
|
+
else
|
|
81
83
|
current.push(merged);
|
|
82
84
|
}
|
|
83
85
|
return current;
|
|
@@ -110,14 +112,45 @@ function authProjection(record) {
|
|
|
110
112
|
formActions: rows(first(record, "customButtonFormPerm")).map((c) => ({ containerCode: c.containerCode ?? null, actions: rows(first(c, "customBtns", "actionPermissions")).map((b) => ({ code: b.code ?? null, enabled: b.enabled ?? b.enable ?? false })) })),
|
|
111
113
|
};
|
|
112
114
|
}
|
|
113
|
-
function changedProjection(before, after) {
|
|
114
|
-
const
|
|
115
|
-
const
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
115
|
+
function changedProjection(before, after, grant) {
|
|
116
|
+
const changes = [];
|
|
117
|
+
const beforeVisible = first(before, "visibleConfig");
|
|
118
|
+
const afterVisible = first(after, "visibleConfig");
|
|
119
|
+
if (grant.visible !== undefined && JSON.stringify(beforeVisible) !== JSON.stringify(afterVisible))
|
|
120
|
+
changes.push({ schemaCode: grant.schemaCode, field: "visibleConfig", before: beforeVisible ?? null, after: afterVisible ?? null });
|
|
121
|
+
if (grant.rowLevel !== undefined) {
|
|
122
|
+
const beforeRow = first(before, "dataPermissionType", "permissionType");
|
|
123
|
+
const afterRow = first(after, "dataPermissionType", "permissionType");
|
|
124
|
+
if (JSON.stringify(beforeRow) !== JSON.stringify(afterRow))
|
|
125
|
+
changes.push({ schemaCode: grant.schemaCode, field: "rowLevel", before: beforeRow ?? null, after: afterRow ?? null, dataPermissionTypeName: permissionType(afterRow) });
|
|
126
|
+
if (grant.rowLevel.conditions !== undefined && JSON.stringify(before.conditions ?? []) !== JSON.stringify(after.conditions ?? []))
|
|
127
|
+
changes.push({ schemaCode: grant.schemaCode, field: "rowLevel", before: before.conditions ?? [], after: after.conditions ?? [], dataPermissionTypeName: permissionType(afterRow) });
|
|
128
|
+
}
|
|
129
|
+
const beforeProperties = rows(first(before, "propertityPermissionGroups"));
|
|
130
|
+
const afterProperties = rows(first(after, "propertityPermissionGroups"));
|
|
131
|
+
for (const property of grant.properties ?? []) {
|
|
132
|
+
const code = String(property.propertyCode ?? "");
|
|
133
|
+
const schema = String(property.schemaCode ?? grant.schemaCode);
|
|
134
|
+
const find = (items) => items.find((item) => String(item.propertyCode ?? "") === code && String(item.schemaCode ?? grant.schemaCode) === schema);
|
|
135
|
+
const b = find(beforeProperties);
|
|
136
|
+
const a = find(afterProperties);
|
|
137
|
+
const beforeValue = b ? { visible: b.visible, writeAble: b.writeAble, decryptAble: b.decryptAble } : null;
|
|
138
|
+
const afterValue = a ? { visible: a.visible, writeAble: a.writeAble, decryptAble: a.decryptAble } : null;
|
|
139
|
+
if (JSON.stringify(beforeValue) !== JSON.stringify(afterValue))
|
|
140
|
+
changes.push({ schemaCode: grant.schemaCode, field: `property:${code}`, before: beforeValue, after: afterValue });
|
|
141
|
+
}
|
|
142
|
+
for (const [kind, requested] of [["view", grant.actions?.view], ["form", grant.actions?.form]]) {
|
|
143
|
+
for (const code of requested ?? []) {
|
|
144
|
+
const read = (record) => rows(first(record, kind === "view" ? "customButtonViewPerm" : "customButtonFormPerm")).flatMap((container) => rows(first(container, "customBtns", "actionPermissions"))).find((button) => String(button.code ?? "") === code);
|
|
145
|
+
const b = read(before);
|
|
146
|
+
const a = read(after);
|
|
147
|
+
const bv = b?.enabled ?? b?.enable ?? false;
|
|
148
|
+
const av = a?.enabled ?? a?.enable ?? false;
|
|
149
|
+
if (bv !== av)
|
|
150
|
+
changes.push({ schemaCode: grant.schemaCode, field: `action:${kind}:${code}`, before: bv, after: av });
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return changes;
|
|
121
154
|
}
|
|
122
155
|
function validateGrants(grants) {
|
|
123
156
|
if (!Array.isArray(grants))
|
|
@@ -127,8 +160,8 @@ function validateGrants(grants) {
|
|
|
127
160
|
throw new ToolRefusalError({ status: "refused", blocker: "permission-grant-schema-required", message: "每个 grant 必须提供 schemaCode" });
|
|
128
161
|
const grant = raw;
|
|
129
162
|
for (const property of grant.properties ?? []) {
|
|
130
|
-
if (!property.propertyCode || typeof property.propertyCode !== "string"
|
|
131
|
-
throw new ToolRefusalError({ status: "refused", blocker: "permission-property-schema-required", message: "properties 元素必须提供 propertyCode
|
|
163
|
+
if (!property.propertyCode || typeof property.propertyCode !== "string")
|
|
164
|
+
throw new ToolRefusalError({ status: "refused", blocker: "permission-property-schema-required", message: "properties 元素必须提供 propertyCode;schemaCode 可省略并继承 grants.schemaCode" });
|
|
132
165
|
if (property.visible !== undefined && typeof property.visible !== "boolean" || property.writeAble !== undefined && typeof property.writeAble !== "boolean" || property.decryptAble !== undefined && typeof property.decryptAble !== "boolean")
|
|
133
166
|
throw new ToolRefusalError({ status: "refused", blocker: "permission-property-boolean-invalid", message: "字段 visible/writeAble/decryptAble 必须是布尔值,不能传 null 或其它类型" });
|
|
134
167
|
if (property.writeAble === true && property.visible !== true)
|
|
@@ -146,18 +179,16 @@ function validateGrants(grants) {
|
|
|
146
179
|
throw new ToolRefusalError({ status: "refused", blocker: "permission-action-unknown", message: `未知表单动作码:${code}` });
|
|
147
180
|
}
|
|
148
181
|
}
|
|
149
|
-
function authSummary(data) {
|
|
182
|
+
export function authSummary(data) {
|
|
150
183
|
const r = (data && typeof data === "object" ? data : {});
|
|
151
|
-
const
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
members: first(r, "members", "units") ?? [],
|
|
160
|
-
};
|
|
184
|
+
const records = rows(first(r, "dataPermissionGroups"));
|
|
185
|
+
const legacyFields = rows(first(r, "fields", "dataPermissions", "propertyPermissions"));
|
|
186
|
+
const legacyModels = rows(first(r, "models", "schemaPermissions", "objectPermissions"));
|
|
187
|
+
const source = records.length ? records : legacyModels;
|
|
188
|
+
const models = source.map((m) => ({ schemaCode: first(m, "schemaCode", "code"), visibleConfig: first(m, "visibleConfig") ?? null, dataPermissionType: first(m, "dataPermissionType", "permissionType") ?? null }));
|
|
189
|
+
const fields = records.length ? records.flatMap((record) => rows(first(record, "propertityPermissionGroups")).map((f) => ({ schemaCode: first(f, "schemaCode") ?? first(record, "schemaCode"), propertyCode: first(f, "propertyCode", "code"), visible: bool(first(f, "visible", "v")), writeAble: bool(first(f, "writeAble", "editable", "e")), decryptAble: bool(first(f, "decryptAble", "decrypt", "d")) }))) : legacyFields.map((f) => ({ schemaCode: first(f, "schemaCode"), propertyCode: first(f, "propertyCode", "code"), visible: bool(first(f, "visible", "v")), writeAble: bool(first(f, "writeAble", "editable", "e")), decryptAble: bool(first(f, "decryptAble", "decrypt", "d")) }));
|
|
190
|
+
const rowLevel = records.length ? records.map((record) => ({ schemaCode: first(record, "schemaCode"), dataPermissionType: first(record, "dataPermissionType", "permissionType") ?? null, dataPermissionTypeName: permissionType(first(record, "dataPermissionType", "permissionType")) })) : { dataPermissionType: permissionType(first(r, "dataPermissionType", "permissionType")), ...(r.conditionsDigest !== undefined ? { conditionsDigest: r.conditionsDigest } : {}) };
|
|
191
|
+
return { models, fields, rowLevel, ...(first(r, "menus", "menuPermissions") !== undefined ? { menus: first(r, "menus", "menuPermissions") } : {}), ...(first(r, "buttons", "buttonPermissions") !== undefined ? { buttons: first(r, "buttons", "buttonPermissions") } : {}), ...(first(r, "members", "units") !== undefined ? { members: first(r, "members", "units") } : {}) };
|
|
161
192
|
}
|
|
162
193
|
function scopesFor(data) { return rows(data); }
|
|
163
194
|
export function registerPermLane(tools) {
|
|
@@ -165,7 +196,21 @@ export function registerPermLane(tools) {
|
|
|
165
196
|
if (args.groupId || !args.unitId) {
|
|
166
197
|
const path = args.groupId ? ENDPOINTS.permissionGroup : ENDPOINTS.permissionAppPackage;
|
|
167
198
|
const query = args.groupId ? { id: args.groupId, appCode: args.appCode } : { appCode: args.appCode };
|
|
168
|
-
|
|
199
|
+
let data;
|
|
200
|
+
try {
|
|
201
|
+
data = (await wireCall(session, { path, method: "GET", query })).data;
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
// A deleted UUID is reported as business 50000 by 1.1.25. Only
|
|
205
|
+
// normalize it after the application package proves the id is gone.
|
|
206
|
+
if (args.groupId && /^(?:[0-9a-f]{32}|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/i.test(String(args.groupId)) && error instanceof WireError && error.kind === "business" && error.errcode === 50000) {
|
|
207
|
+
const pkg = (await wireCall(session, { path: ENDPOINTS.permissionAppPackage, method: "GET", query: { appCode: args.appCode } })).data;
|
|
208
|
+
const present = permissionGroupRows(pkg).some((group) => String(groupView(group).id) === String(args.groupId));
|
|
209
|
+
if (!present)
|
|
210
|
+
return { appCode: args.appCode, group: { id: args.groupId }, absent: true, note: "已删除或不存在(经组清单复核)" };
|
|
211
|
+
}
|
|
212
|
+
throw error;
|
|
213
|
+
}
|
|
169
214
|
if (args.schemaCode) {
|
|
170
215
|
const bySchema = (await wireCall(session, { path: ENDPOINTS.permissionGroupBySchema, method: "GET", query: { schemaCode: args.schemaCode } })).data;
|
|
171
216
|
return { appCode: args.appCode, schemaCode: args.schemaCode, groups: permissionGroupRows(bySchema).map(groupView), data: bySchema };
|
|
@@ -244,7 +289,7 @@ export function registerPermLane(tools) {
|
|
|
244
289
|
return { userId: args.userId, appCode: args.appCode, adminBypass, ...(adminBypass ? { adminNotice: "管理员会话恒通过,不代表普通用户;本回执是管理员旁路标记。" } : {}), app: { visible: bool(first(data, "visible", "appVisible")), administrator: bool(first(data, "administrator", "isAdministrator")), allVisible: bool(first(data, "allVisible")) }, models: authSummary(data).models, fields: args.schemaCode ? authSummary(data).fields : [], rowLevel: authSummary(data).rowLevel, layers: { configResolvable: true, runtimeSessionRequired: "真实 load/write 判定受对象权限/业务调用/临时流程授权影响——本工具拒绝单值 allow/deny;验证走目标用户会话或 data.load 双读" } };
|
|
245
290
|
}) }));
|
|
246
291
|
writeTool({ tools, name: "perm.assign", lane: PERM_LANE, scope: PERM_TOOLS["perm.assign"].scope, description: PERM_TOOLS["perm.assign"].description, inputSchema: { appCode: z.string().min(1), groupId: z.string().min(1), units: z.array(z.object({ type: z.enum(["DEPT", "ROLE", "USER"]), id: z.string().min(1), name: z.string().optional() })).min(1), mode: z.enum(["assign", "revoke"]) }, execute: async (session, args) => { const unitType = { DEPT: 1, ROLE: 2, USER: 3 }[args.units[0].type]; const units = args.units.map((u) => ({ unitId: u.id, unitType: { DEPT: 1, ROLE: 2, USER: 3 }[u.type], name: u.name ?? "", corpId: session.enterpriseId(), appCode: args.appCode, groupId: args.groupId })); const body = args.mode === "assign" ? { permissionGroupUnits: units, permGroupInfos: [{ appCode: args.appCode, permGroupId: args.groupId }] } : { permGroupIds: [args.groupId], unitIds: args.units.map((u) => u.id), permissionGroupUnits: units, permGroupInfos: [{ appCode: args.appCode, permGroupId: args.groupId }] }; const before = (await wireCall(session, { path: ENDPOINTS.permissionGroup, method: "GET", query: { id: args.groupId, appCode: args.appCode } })).data; const performed = await wireCall(session, { path: args.mode === "assign" ? ENDPOINTS.permissionAssign : ENDPOINTS.permissionRevoke, method: "POST", body }); const after = (await wireCall(session, { path: ENDPOINTS.permissionGroup, method: "GET", query: { id: args.groupId, appCode: args.appCode } })).data; const listAfter = (await wireCall(session, { path: ENDPOINTS.permissionGroupUnits, method: "POST", body: { ...units[0], unitType, appCode: args.appCode, corpId: session.enterpriseId() } })).data; return { performed: { errcode: performed.errcode, mode: args.mode }, readback: { groups: permissionGroupRows(listAfter).map(groupView), source: "post-write listPermissionGroups readback (not write echo)", diff: { before: projectMembers(before), after: projectMembers(after) } } }; } });
|
|
247
|
-
writeTool({ tools, name: "perm.auth", lane: PERM_LANE, scope: PERM_TOOLS["perm.auth"].scope, description: PERM_TOOLS["perm.auth"].description, inputSchema: { appCode: z.string().min(1), groupId: z.string().min(1), grants: z.array(z.object({ schemaCode: z.string().min(1), visible: z.object({ pc: z.boolean(), mobile: z.boolean() }).optional(), rowLevel: z.object({ type: z.number().int().min(1).max(6), conditions: z.array(z.array(z.unknown())).optional() }).optional(), properties: z.array(z.object({ propertyCode: z.string().optional(), schemaCode: z.string().optional(), visible: z.boolean().optional(), writeAble: z.boolean().optional(), decryptAble: z.boolean().optional() })).optional(), actions: z.object({ view: z.array(z.string()).optional(), form: z.array(z.string()).optional() }).optional() })).min(1), mode: z.enum(["merge"]).default("merge") }, preflight: (args) => validateGrants(args.grants), execute: async (session, args) => { const group = (await wireCall(session, { path: ENDPOINTS.permissionGroup, method: "GET", query: { id: args.groupId, appCode: args.appCode } })).data; const existing = permissionRecords(group); const mergedRecords = []; const beforeRecords = []; for (const grant of args.grants) {
|
|
292
|
+
writeTool({ tools, name: "perm.auth", lane: PERM_LANE, scope: PERM_TOOLS["perm.auth"].scope, description: PERM_TOOLS["perm.auth"].description, inputSchema: { appCode: z.string().min(1), groupId: z.string().min(1), grants: z.array(z.object({ schemaCode: z.string().min(1), visible: z.object({ pc: z.boolean(), mobile: z.boolean() }).optional(), rowLevel: z.object({ type: z.number().int().min(1).max(6).describe("1=全部可见,2=本部门,3=仅自己,4=自定义(须 conditions),5=角色管理范围,6=均不可见"), conditions: z.array(z.array(z.unknown())).optional() }).optional(), properties: z.array(z.object({ propertyCode: z.string().optional(), schemaCode: z.string().optional().describe("可省略,继承 grants.schemaCode"), visible: z.boolean().optional(), writeAble: z.boolean().optional(), decryptAble: z.boolean().optional() })).optional(), actions: z.object({ view: z.array(z.string()).optional(), form: z.array(z.string()).optional() }).optional() })).min(1), mode: z.enum(["merge"]).default("merge") }, preflight: (args) => validateGrants(args.grants), execute: async (session, args) => { const group = (await wireCall(session, { path: ENDPOINTS.permissionGroup, method: "GET", query: { id: args.groupId, appCode: args.appCode } })).data; const existing = permissionRecords(group); const mergedRecords = []; const beforeRecords = []; for (const grant of args.grants) {
|
|
248
293
|
const prior = existing.find((record) => String(first(record, "schemaCode", "functionCode") ?? "") === grant.schemaCode);
|
|
249
294
|
if (!prior)
|
|
250
295
|
throw new ToolRefusalError({ status: "refused", blocker: "permission-target-model-unknown", message: `权限组中不存在模型 ${grant.schemaCode};候选:${existing.map((record) => String(first(record, "schemaCode", "functionCode") ?? "")).filter(Boolean).join(", ")}` });
|
|
@@ -264,6 +309,6 @@ export function registerPermLane(tools) {
|
|
|
264
309
|
if (grant.actions?.form !== undefined)
|
|
265
310
|
merged.customButtonFormPerm = mergeActions(prior.customButtonFormPerm, grant.actions.form, FORM_ACTIONS);
|
|
266
311
|
mergedRecords.push(merged);
|
|
267
|
-
} const performed = await wireCall(session, { path: PERMISSION_UPDATE_FUNCTION, method: "POST", body: mergedRecords }); const refreshed = (await wireCall(session, { path: ENDPOINTS.permissionGroup, method: "GET", query: { id: args.groupId, appCode: args.appCode } })).data; const afterRecords = permissionRecords(refreshed); const afterBySchema = new Map(afterRecords.map((record) => [String(first(record, "schemaCode", "functionCode") ?? ""), record])); const afterRecordsForDiff = args.grants.map((grant) => afterBySchema.get(grant.schemaCode) ?? mergedRecords.find((record) => record.schemaCode === grant.schemaCode)); return { performed: { errcode: performed.errcode, endpoint: PERMISSION_UPDATE_FUNCTION }, readback: { data: refreshed, diff: {
|
|
312
|
+
} const performed = await wireCall(session, { path: PERMISSION_UPDATE_FUNCTION, method: "POST", body: mergedRecords }); const refreshed = (await wireCall(session, { path: ENDPOINTS.permissionGroup, method: "GET", query: { id: args.groupId, appCode: args.appCode } })).data; const afterRecords = permissionRecords(refreshed); const afterBySchema = new Map(afterRecords.map((record) => [String(first(record, "schemaCode", "functionCode") ?? ""), record])); const afterRecordsForDiff = args.grants.map((grant) => afterBySchema.get(grant.schemaCode) ?? mergedRecords.find((record) => record.schemaCode === grant.schemaCode)); return { performed: { errcode: performed.errcode, endpoint: PERMISSION_UPDATE_FUNCTION }, readback: { data: refreshed, diff: { changed: beforeRecords.flatMap((before, index) => changedProjection(before, afterRecordsForDiff[index], args.grants[index])) } } }; } });
|
|
268
313
|
}
|
|
269
314
|
//# sourceMappingURL=perm.js.map
|
package/dist/path-projection.js
CHANGED
|
@@ -7,7 +7,7 @@ import { closestMatch } from "./closest-match.js";
|
|
|
7
7
|
* 拆路径后会伪装成两条 pathMiss(available=键列表),误导下一轮。先识别再
|
|
8
8
|
* 报「不支持」——别让调用方以为键不存在。
|
|
9
9
|
*/
|
|
10
|
-
export const UNSUPPORTED_JQ_OBJECT_HINT = "
|
|
10
|
+
export const UNSUPPORTED_JQ_OBJECT_HINT = "--jq 不是 jq:投影 DSL 不支持对象构造 `{a,b}`;单列请写 `.x[].a`,多列用逗号分隔(--jq \".x[].a,.x[].b\")或重复传 --jq";
|
|
11
11
|
export function detectUnsupportedJqSyntax(path) {
|
|
12
12
|
if (/[{}]/.test(path))
|
|
13
13
|
return UNSUPPORTED_JQ_OBJECT_HINT;
|
package/dist/residue.js
CHANGED
|
@@ -6,6 +6,7 @@ import { ConfigStore, defaultPaths } from "./config-store.js";
|
|
|
6
6
|
import { SessionManager } from "./session-manager.js";
|
|
7
7
|
import { makeToolContext } from "./context.js";
|
|
8
8
|
import { emitInvalid, emitResult } from "./command-transport.js";
|
|
9
|
+
import { projectResultExtract } from "./path-projection.js";
|
|
9
10
|
const MAX_ITEMS = 20;
|
|
10
11
|
const SYSTEM_RULE_NAMES = new Set(["Available", "Cancel", "Create", "Delete", "GetList", "Load", "Update"]);
|
|
11
12
|
function residueOrigin(row, faceName) {
|
|
@@ -128,7 +129,13 @@ export async function cmdResidue(prefix, options, transport) {
|
|
|
128
129
|
try {
|
|
129
130
|
const context = makeToolContext({ sessions: new SessionManager(new ConfigStore(defaultPaths())) });
|
|
130
131
|
const session = await context.sessions.session(options.env);
|
|
131
|
-
|
|
132
|
+
const result = await scanResidues(session, prefix, { apps: options.apps, deep: options.noDeep !== true, allFaces: options.allFaces });
|
|
133
|
+
// r49 F12:Commander 的 optional-value 裸 --jq 传 true(不经 argParser)——归一为数组。
|
|
134
|
+
// 类型声明是数组,但 Commander 运行时对裸 optional value 会给布尔 true,断言放开比较。
|
|
135
|
+
const jqRaw = Array.isArray(options.jq) ? options.jq : options.jq === true ? [true] : options.jq !== undefined && options.jq !== null ? [String(options.jq)] : [];
|
|
136
|
+
const keysOnly = jqRaw.some((entry) => entry === true);
|
|
137
|
+
const paths = jqRaw.filter((entry) => typeof entry === "string").flatMap((path) => path.split(",")).map((path) => path.trim()).filter(Boolean);
|
|
138
|
+
return emitResult((paths.length > 0 || keysOnly ? projectResultExtract(result, paths, keysOnly) : result) ?? result, transport);
|
|
132
139
|
}
|
|
133
140
|
catch (error) {
|
|
134
141
|
return emitResult({ status: "error", blocker: "residue-scan-failed", message: error instanceof Error ? error.message : String(error) }, transport);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stalfh233/omc-cli",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.32",
|
|
4
4
|
"description": "CloudPivot 8.6 configuration capability CLI — governed, fail-closed, coverage-manifest bounded.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"commander": "14.0.3",
|
|
58
|
-
"omc-core": "0.6.
|
|
58
|
+
"omc-core": "0.6.32",
|
|
59
59
|
"proper-lockfile": "4.1.2",
|
|
60
60
|
"write-file-atomic": "6.0.0",
|
|
61
61
|
"zod": "^3.23.8",
|
|
@@ -73,6 +73,6 @@
|
|
|
73
73
|
"directory": "packages/omc-cli"
|
|
74
74
|
},
|
|
75
75
|
"optionalDependencies": {
|
|
76
|
-
"@stalfh233/omc-fake-platform": "0.6.
|
|
76
|
+
"@stalfh233/omc-fake-platform": "0.6.32"
|
|
77
77
|
}
|
|
78
78
|
}
|