@stalfh233/omc-cli 0.6.74 → 0.6.75
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/coverage/m1-coverage-manifest-v1.json +4 -0
- package/dist/capability-overview.js +1 -1
- package/dist/cli-output.js +91 -3
- package/dist/cli.js +212 -30
- package/dist/discovery.js +48 -2
- package/dist/graph.js +124 -1
- package/dist/lanes/b2-registration-contract.js +8 -0
- package/dist/lanes/b2-registration-coverage.js +1 -0
- package/dist/lanes/b2-registration.js +99 -0
- package/dist/lanes/businessrule-contract.js +4 -4
- package/dist/lanes/businessrule.js +251 -60
- package/dist/lanes/form-contract.js +7 -2
- package/dist/lanes/form-coverage.js +1 -0
- package/dist/lanes/form.js +248 -5
- package/dist/lanes/model.js +102 -15
- package/dist/lanes/rule-graph.js +25 -2
- package/dist/lanes/workflow-contract.js +1 -1
- package/dist/lanes/workflow.js +48 -8
- package/dist/mcp-graph.js +43 -4
- package/dist/path-projection.js +53 -0
- package/dist/read-shapes.js +21 -6
- package/dist/recipes/businessrule.js +2 -1
- package/package.json +3 -3
- package/skills/omc-capabilities.md +2 -2
- package/skills/omc-write-hazards.md +3 -1
|
@@ -865,6 +865,7 @@
|
|
|
865
865
|
],
|
|
866
866
|
"lane": "form-publish-chain",
|
|
867
867
|
"tools": [
|
|
868
|
+
"form.list",
|
|
868
869
|
"form.get",
|
|
869
870
|
"form.draft",
|
|
870
871
|
"form.publish",
|
|
@@ -872,6 +873,7 @@
|
|
|
872
873
|
"form.runButton"
|
|
873
874
|
],
|
|
874
875
|
"scopes": [
|
|
876
|
+
"sheet list projection",
|
|
875
877
|
"publishedHtmlJson authoritative readback",
|
|
876
878
|
"draft publish publishedHtmlJson readback",
|
|
877
879
|
"form toolbar button execution"
|
|
@@ -1111,6 +1113,7 @@
|
|
|
1111
1113
|
"service.register",
|
|
1112
1114
|
"service.update",
|
|
1113
1115
|
"method.get",
|
|
1116
|
+
"method.list",
|
|
1114
1117
|
"method.create",
|
|
1115
1118
|
"method.update",
|
|
1116
1119
|
"method.delete",
|
|
@@ -1132,6 +1135,7 @@
|
|
|
1132
1135
|
"create readback delete",
|
|
1133
1136
|
"update readback",
|
|
1134
1137
|
"method readback",
|
|
1138
|
+
"method list projection",
|
|
1135
1139
|
"method create readback",
|
|
1136
1140
|
"method update readback",
|
|
1137
1141
|
"method delete readback",
|
|
@@ -80,7 +80,7 @@ const SURFACES = [
|
|
|
80
80
|
title: "默认表单",
|
|
81
81
|
lane: LANES.form,
|
|
82
82
|
description: "表单发布链:draft-first 布局、发布、publishedHtmlJson 绑定读回。",
|
|
83
|
-
operations: ["get", "draft", "publish"],
|
|
83
|
+
operations: ["list", "get", "draft", "publish"],
|
|
84
84
|
intent: { level: "partial", note: "draft/publish 已声明式;get 为读回面。" },
|
|
85
85
|
// 券商 issue 1.1(cpdocs 2026-10-27):子表控件的条件不在字段面——能力面
|
|
86
86
|
// 说清走法,agents 从 capabilities 进入(而非 next)时也能拿到同一条路由。
|
package/dist/cli-output.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { accessSync, constants, existsSync, lstatSync, statSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
|
+
import { sync as writeFileAtomicSync } from "write-file-atomic";
|
|
5
|
+
import { isWithinRoot } from "./artifacts.js";
|
|
2
6
|
import { asciiStdout, serializeEnvelope } from "./cli-contract.js";
|
|
3
7
|
import { currentUsageCommand, priorRepeatedFailures, recordUsageOutput } from "./usage-log.js";
|
|
4
8
|
let options = { quiet: false, verbose: false };
|
|
@@ -38,7 +42,7 @@ export function maybeWarnMergedStreams() {
|
|
|
38
42
|
}
|
|
39
43
|
/** Test seam: the exact hint line (no trailing newline). */
|
|
40
44
|
export const PIPE_MERGE_HINT_FOR_TEST = PIPE_MERGE_HINT;
|
|
41
|
-
/** Parse `--quiet`, `--verbose
|
|
45
|
+
/** Parse `--quiet`, `--verbose`, `--out <file>` and `--out-file <path>` from the raw argv once, before dispatch. */
|
|
42
46
|
export function configureOutput(argv) {
|
|
43
47
|
const outIndex = argv.indexOf("--out");
|
|
44
48
|
let outFile;
|
|
@@ -50,13 +54,56 @@ export function configureOutput(argv) {
|
|
|
50
54
|
throw new Error("--out requires a file path");
|
|
51
55
|
outFile = value;
|
|
52
56
|
}
|
|
57
|
+
const strictIndex = argv.indexOf("--out-file");
|
|
58
|
+
let outFileStrict = false;
|
|
59
|
+
if (strictIndex >= 0) {
|
|
60
|
+
if (outIndex >= 0)
|
|
61
|
+
throw new Error("--out and --out-file are mutually exclusive(--out-file 是新写法:完整信封 UTF-8 落盘 + sha256 回执)");
|
|
62
|
+
const value = argv[strictIndex + 1];
|
|
63
|
+
if (value === undefined || value.startsWith("--"))
|
|
64
|
+
throw new Error("--out-file requires a file path");
|
|
65
|
+
outFile = assertOutFilePath(value);
|
|
66
|
+
outFileStrict = true;
|
|
67
|
+
}
|
|
53
68
|
options = {
|
|
54
69
|
quiet: argv.includes("--quiet"),
|
|
55
70
|
verbose: argv.includes("--verbose"),
|
|
56
71
|
...(outFile ? { outFile } : {}),
|
|
72
|
+
...(outFileStrict ? { outFileStrict } : {}),
|
|
57
73
|
};
|
|
58
74
|
return options;
|
|
59
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* `--out-file` 的路径安全(issue 2026-11-18 §08.2):允许绝对路径(Windows 调用方
|
|
78
|
+
* 常用 `D:\tmp\x.json`),但**拒绝**写进配置根内的 `credentials`(凭据文件/目录),
|
|
79
|
+
* 并拒绝符号链接、目录与非正规文件——失败即 invalid-input(configureOutput 抛错
|
|
80
|
+
* 由 main 的 catch 转成 exit 10),不会先产出信封再报错。
|
|
81
|
+
*/
|
|
82
|
+
export function assertOutFilePath(candidate) {
|
|
83
|
+
const normalized = resolve(candidate);
|
|
84
|
+
const configRoot = resolve(process.env.OMC_CONFIG_HOME ?? process.cwd());
|
|
85
|
+
const credentials = resolve(configRoot, "credentials");
|
|
86
|
+
if (normalized === credentials || isWithinRoot(credentials, normalized))
|
|
87
|
+
throw new Error(`--out-file 拒绝写入配置根内的 credentials(${credentials}):凭据与 token 不得被复制进产物/文档。请换一个普通路径,如 --out-file ~/omc-envelope.json`);
|
|
88
|
+
if (existsSync(normalized)) {
|
|
89
|
+
if (lstatSync(normalized).isSymbolicLink())
|
|
90
|
+
throw new Error("--out-file cannot be a symbolic link");
|
|
91
|
+
if (!statSync(normalized).isFile())
|
|
92
|
+
throw new Error("--out-file must be a regular file path");
|
|
93
|
+
}
|
|
94
|
+
const parent = resolve(normalized, "..");
|
|
95
|
+
if (!existsSync(parent))
|
|
96
|
+
throw new Error(`--out-file parent directory does not exist(${parent})`);
|
|
97
|
+
if (!statSync(parent).isDirectory())
|
|
98
|
+
throw new Error("--out-file parent must be a directory");
|
|
99
|
+
try {
|
|
100
|
+
accessSync(parent, constants.W_OK);
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
throw new Error(`--out-file parent directory is not writable(${parent})`);
|
|
104
|
+
}
|
|
105
|
+
return normalized;
|
|
106
|
+
}
|
|
60
107
|
/**
|
|
61
108
|
* Remove the global output flags from argv before commander parses it, so they
|
|
62
109
|
* are consumed once here instead of being declared on every subcommand.
|
|
@@ -92,6 +139,10 @@ export function stripOutputFlags(argv) {
|
|
|
92
139
|
index += 1;
|
|
93
140
|
continue;
|
|
94
141
|
}
|
|
142
|
+
if (token === "--out-file") {
|
|
143
|
+
index += 1;
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
95
146
|
out.push(token);
|
|
96
147
|
}
|
|
97
148
|
return out;
|
|
@@ -112,7 +163,11 @@ function compactForOutput(value) {
|
|
|
112
163
|
const record = value;
|
|
113
164
|
if (record.error !== null && record.error !== undefined)
|
|
114
165
|
return value;
|
|
115
|
-
|
|
166
|
+
// issue 2026-11-18 §05:单路径 --jq 解包把路径/产物元信息放在信封的
|
|
167
|
+
// `resultMeta`;成功信封瘦身时它必须留下(否则 sha256/来源信息丢失)。
|
|
168
|
+
return record.resultMeta !== undefined
|
|
169
|
+
? { ok: record.ok, result: record.result, resultMeta: record.resultMeta }
|
|
170
|
+
: { ok: record.ok, result: record.result };
|
|
116
171
|
}
|
|
117
172
|
/**
|
|
118
173
|
* Write the single stdout envelope. When `--out` is set, the identical bytes are
|
|
@@ -186,6 +241,39 @@ function withRepeatWarning(value) {
|
|
|
186
241
|
return { ...envelope, repeatWarning };
|
|
187
242
|
}
|
|
188
243
|
export function writeEnvelope(value) {
|
|
244
|
+
// `--out-file`(issue 2026-11-18 §08.2):完整信封以 raw UTF-8 原子落盘,
|
|
245
|
+
// stdout 只回小回执。它在 compactForOutput 之前分叉——文件里必须是**完整**
|
|
246
|
+
// 信封(status/requestId/error 都在),stdout 的小回执固定保留 status。
|
|
247
|
+
if (options.outFileStrict && options.outFile) {
|
|
248
|
+
const rawValue = withRepeatWarning(value);
|
|
249
|
+
const raw = rawValue && typeof rawValue === "object" ? rawValue : {};
|
|
250
|
+
// JSON.stringify never \u-escapes non-ASCII (only control chars), so the file
|
|
251
|
+
// is UTF-8 regardless of the console code page. That is the whole point.
|
|
252
|
+
const pretty = `${JSON.stringify(rawValue, null, 2)}\n`;
|
|
253
|
+
const bytes = Buffer.from(pretty, "utf8");
|
|
254
|
+
const sha256 = createHash("sha256").update(bytes).digest("hex");
|
|
255
|
+
const failure = raw.error !== null && raw.error !== undefined;
|
|
256
|
+
try {
|
|
257
|
+
writeFileAtomicSync(options.outFile, pretty, { mode: 0o600 });
|
|
258
|
+
}
|
|
259
|
+
catch (error) {
|
|
260
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
261
|
+
const failed = { ok: false, status: "error", result: { outFile: options.outFile }, error: { code: "invalid-input", message: `--out-file 写入失败(${message});换一个可写路径重试,或去掉 --out-file 让信封走 stdout`, retryable: true } };
|
|
262
|
+
process.stdout.write(serializeEnvelope(failed));
|
|
263
|
+
recordUsageOutput(failed, Buffer.byteLength(serializeEnvelope(failed), "utf8"));
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
const confirmation = {
|
|
267
|
+
ok: raw.ok ?? !failure,
|
|
268
|
+
status: typeof raw.status === "string" ? raw.status : failure ? "error" : "ok",
|
|
269
|
+
result: { outFile: options.outFile, bytes: bytes.length, sha256 },
|
|
270
|
+
...(failure ? { error: raw.error } : {}),
|
|
271
|
+
};
|
|
272
|
+
const text = serializeEnvelope(confirmation);
|
|
273
|
+
recordUsageOutput(rawValue, Buffer.byteLength(text, "utf8"), bytes.length);
|
|
274
|
+
process.stdout.write(text);
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
189
277
|
const outputValue = compactForOutput(withRepeatWarning(value));
|
|
190
278
|
const text = serializeEnvelope(outputValue);
|
|
191
279
|
if (asciiStdout())
|
package/dist/cli.js
CHANGED
|
@@ -24,7 +24,7 @@ import { beginWriteFace, configureOutput, endWriteFace, humanSummary, maybeWarnM
|
|
|
24
24
|
import { beginUsage, completeUsage, currentUsageArgsDigest, ensureProjectIgnore, priorIdenticalSuccess, recordUsageOutput, usageReport } from "./usage-log.js";
|
|
25
25
|
import { artifactFetchHint, artifactRoot, boundResult, emitInvalid, emitResult, emitThrown, emitTransportResult, outputBudget, readArtifact, withTransport, } from "./command-transport.js";
|
|
26
26
|
import { CLI_DEFAULT_OUTPUT_BYTES, assertSafeOutputPath, pruneArtifacts } from "./artifacts.js";
|
|
27
|
-
import { artifactPathMissHint, nullProjectionHint, partialPathMissHint, pathMissDidYouMean, projectJsonPath, projectJsonPathFanout, projectResultExtract, shapeOf, SHAPE_MAX_DEPTH } from "./path-projection.js";
|
|
27
|
+
import { artifactPathMissHint, nullProjectionHint, partialPathMissHint, pathMissDidYouMean, projectJsonPath, projectJsonPathFanout, projectResultExtract, shapeOf, SHAPE_MAX_DEPTH, unwrapSinglePathProjection } from "./path-projection.js";
|
|
28
28
|
import { basename, join, resolve } from "node:path";
|
|
29
29
|
import { existsSync, readFileSync, writeFileSync, chmodSync } from "node:fs";
|
|
30
30
|
import { buildToolRegistry } from "./tools.js";
|
|
@@ -45,11 +45,11 @@ else if (process.env.OMC_ASCII_STDOUT !== "0" && process.argv.some((arg) => arg
|
|
|
45
45
|
process.env.OMC_UTF8_HINT = "1";
|
|
46
46
|
}
|
|
47
47
|
import { SEARCH_MARGIN_THRESHOLD } from "./tool-search.js";
|
|
48
|
-
import { commandCapabilitySlice, commandIndex, commandInventory, describeContract, describeContractFull, describeContractTool, describeExample, describeParam, describeSchemaOnly, describeTool, describeToolFull, filterTools } from "./discovery.js";
|
|
48
|
+
import { commandCapabilitySlice, commandIndex, commandInventory, commandKindIndex, describeContract, describeContractFull, describeContractTool, describeExample, describeParam, describeSchemaOnly, describeTool, describeToolFull, filterTools } from "./discovery.js";
|
|
49
49
|
import { closestMatches } from "./closest-match.js";
|
|
50
50
|
import { KEY_ALIAS_HINTS, inputAliasSynonymKeys } from "./tool-types.js";
|
|
51
51
|
import { repeatFullDescribe } from "./describe-cache.js";
|
|
52
|
-
import { buildCapabilityOverview, capabilityCandidatesFor, capabilityDetail, capabilityRouteIndex, compactCapabilities, executableCapabilityBundle, resolveCapabilityId, DISCOVERY_AUTHORITY } from "./capability-overview.js";
|
|
52
|
+
import { buildCapabilityOverview, capabilityCandidatesFor, capabilityDetail, capabilityRouteForTool, capabilityRouteIndex, compactCapabilities, executableCapabilityBundle, resolveCapabilityId, DISCOVERY_AUTHORITY } from "./capability-overview.js";
|
|
53
53
|
import { goalRoute } from "./goal-routes.js";
|
|
54
54
|
import { absencePointer } from "./capability-absences.js";
|
|
55
55
|
import { intentConfigRoot, readIntentFile, validateIntentText } from "./intent/cli.js";
|
|
@@ -491,7 +491,12 @@ async function cmdBatchCall(store, toolName, rawList, options) {
|
|
|
491
491
|
result = projected;
|
|
492
492
|
}
|
|
493
493
|
const classified = classifyResult(result);
|
|
494
|
-
|
|
494
|
+
// 与 `omc call --jq` 同一契约(issue 2026-11-18 §05):单路径命中时 result 是本体。
|
|
495
|
+
const unwrapped = preflightPaths.length === 1 && !preflightKeys && Array.isArray(result.extract)
|
|
496
|
+
? unwrapSinglePathProjection(result)
|
|
497
|
+
: undefined;
|
|
498
|
+
const envelopeValue = envelope(classified.status, unwrapped !== undefined ? unwrapped.result : result, request, classified.error);
|
|
499
|
+
writeEnvelope(unwrapped !== undefined ? { ...envelopeValue, resultMeta: unwrapped.resultMeta } : envelopeValue);
|
|
495
500
|
return failures.length > 0 ? 1 : 0;
|
|
496
501
|
}
|
|
497
502
|
const batched = await runBatchCall({
|
|
@@ -516,11 +521,14 @@ async function cmdCall(store, args) {
|
|
|
516
521
|
writeEnvelope(envelope("error", {}, request, { code: "invalid-input", message, retryable: false }));
|
|
517
522
|
return CLI_EXIT_CODES.invalidInput;
|
|
518
523
|
}
|
|
519
|
-
const emit = (status, result, exitCode) => {
|
|
520
|
-
if (status === "uncertain" && result.nextAction === undefined)
|
|
524
|
+
const emit = (status, result, exitCode, extra) => {
|
|
525
|
+
if (status === "uncertain" && result !== null && typeof result === "object" && !Array.isArray(result) && result.nextAction === undefined)
|
|
521
526
|
result = { ...result, nextAction: "read back the requestId before retrying; retry only after the outcome is established" };
|
|
522
527
|
const classified = classifyResult(result);
|
|
523
|
-
|
|
528
|
+
const envelopeValue = envelope(status, boundResult(result, maxOutputBytes), request, classified.error);
|
|
529
|
+
// issue 2026-11-18 §05:单路径 --jq 解包后,`result` 是目标节点本体(可能是
|
|
530
|
+
// 数组/标量,装不进结果对象),路径来源等元信息放信封旁的 `resultMeta`。
|
|
531
|
+
writeEnvelope(extra !== undefined ? { ...envelopeValue, ...extra } : envelopeValue);
|
|
524
532
|
maybeWarnMergedStreams();
|
|
525
533
|
return exitCode;
|
|
526
534
|
};
|
|
@@ -807,6 +815,8 @@ async function cmdCall(store, args) {
|
|
|
807
815
|
await lock.release();
|
|
808
816
|
}
|
|
809
817
|
}
|
|
818
|
+
let unwrappedBody;
|
|
819
|
+
let resultMeta;
|
|
810
820
|
if (extractPaths.length > 0 || extractKeys) {
|
|
811
821
|
const projected = projectResultExtract(result, extractPaths, extractKeys);
|
|
812
822
|
if (projected !== undefined)
|
|
@@ -819,15 +829,27 @@ async function cmdCall(store, args) {
|
|
|
819
829
|
// projection with a null value. Keep the path engine's detailed hint but
|
|
820
830
|
// make the CLI contract actionable and machine-classifiable.
|
|
821
831
|
if (typeof result === "object" && result !== null && Array.isArray(result.extract)) {
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
const unsupported = result.extract.filter((entry) => entry.unsupportedSyntax === true);
|
|
832
|
+
const extracts = result.extract;
|
|
833
|
+
const unsupported = extracts.filter((entry) => entry.unsupportedSyntax === true);
|
|
825
834
|
if (unsupported.length > 0) {
|
|
826
835
|
const first = unsupported[0];
|
|
827
|
-
const
|
|
836
|
+
const detail = typeof first?.hint === "string" ? first.hint : "投影 DSL 只做路径选择(点式 / [] 映射 / [key=value] / 切片)";
|
|
837
|
+
const message = `--jq 不是 jq:仅路径选择器,${detail}(${String(first?.path ?? "")})。可运行示例:--jq 'fields[].code,fields[].typeName'`;
|
|
828
838
|
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'" };
|
|
829
839
|
return emit("error", invalid, CLI_EXIT_CODES.invalidInput);
|
|
830
840
|
}
|
|
841
|
+
// issue 2026-11-18 §05:单路径命中 → 信封的 result 直接是节点本体,元信息
|
|
842
|
+
// 走 resultMeta(形状与不带 --jq 时的 result 同层级,只是被裁剪)。
|
|
843
|
+
// 未命中/不支持语法不解包:pathMiss/available/hint 留在 result 顶层才能自愈。
|
|
844
|
+
if (extractPaths.length === 1 && !extractKeys) {
|
|
845
|
+
const unwrapped = unwrapSinglePathProjection(result);
|
|
846
|
+
if (unwrapped !== undefined) {
|
|
847
|
+
unwrappedBody = unwrapped.result;
|
|
848
|
+
resultMeta = unwrapped.resultMeta;
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
for (const entry of extracts)
|
|
852
|
+
delete entry.autoStripped;
|
|
831
853
|
}
|
|
832
854
|
// `extract[]` is the canonical multi-path result. Do not emit the second
|
|
833
855
|
// row-alignment copy: callers can align the explicitly named path values.
|
|
@@ -835,7 +857,19 @@ async function cmdCall(store, args) {
|
|
|
835
857
|
delete result.rows;
|
|
836
858
|
}
|
|
837
859
|
// 读面未知键的非阻断回显:放在投影**之后**,否则会被 --jq 的窄投影吞掉。
|
|
838
|
-
|
|
860
|
+
// 单路径解包后 result 是节点本体(可能是数组/标量),不能再往本体上加键——
|
|
861
|
+
// 这类元信息跟着 resultMeta 走,确保「本体就是本体」。
|
|
862
|
+
if (ignoredReadKeys.length > 0 && unwrappedBody !== undefined) {
|
|
863
|
+
const pairs = ignoredReadKeys.map((entry) => entry.hint ? `${entry.key}(${entry.hint})` : entry.closest ? `${entry.key}→${entry.closest}` : entry.key);
|
|
864
|
+
resultMeta = {
|
|
865
|
+
...(resultMeta ?? {}),
|
|
866
|
+
ignoredArgs: {
|
|
867
|
+
keys: ignoredReadKeys,
|
|
868
|
+
hint: `这些参数本工具不认识,已被忽略(没有生效):${pairs.join("、")}。若是拼写问题按 → 改;要确认完整参数表用 \`omc describe ${toolName}\``,
|
|
869
|
+
},
|
|
870
|
+
};
|
|
871
|
+
}
|
|
872
|
+
else if (ignoredReadKeys.length > 0 && typeof result === "object" && result !== null) {
|
|
839
873
|
const pairs = ignoredReadKeys.map((entry) => {
|
|
840
874
|
if (entry.hint)
|
|
841
875
|
return `${entry.key}(${entry.hint})`;
|
|
@@ -855,7 +889,14 @@ async function cmdCall(store, args) {
|
|
|
855
889
|
}
|
|
856
890
|
const classified = classifyResult(result);
|
|
857
891
|
try {
|
|
858
|
-
|
|
892
|
+
// 单路径 --jq 命中:emit 的是节点本体(可能不是对象),元信息在信封旁。
|
|
893
|
+
// body 自带 `status`/`blocker` 时(如 --jq 直接取回整包),信封的 error 仍以
|
|
894
|
+
// **投影前**的 classified 为准——别让 payload 里的字段改写本调用的结论。
|
|
895
|
+
const emitValue = unwrappedBody !== undefined ? unwrappedBody : result;
|
|
896
|
+
const extras = unwrappedBody !== undefined
|
|
897
|
+
? { error: classified.error, ...(resultMeta !== undefined ? { resultMeta } : {}) }
|
|
898
|
+
: resultMeta !== undefined ? { resultMeta } : undefined;
|
|
899
|
+
return emit(classified.status, emitValue, classified.exitCode, extras);
|
|
859
900
|
}
|
|
860
901
|
finally {
|
|
861
902
|
if (toolKind === "write")
|
|
@@ -1194,6 +1235,13 @@ async function cmdArtifactGet(id, transport, options = {}) {
|
|
|
1194
1235
|
depth,
|
|
1195
1236
|
shape: shapeOf(content, depth),
|
|
1196
1237
|
hint: `正文 ${Math.round(artifact.content.length / 1024)}KB 超过内联上限 ${ARTIFACT_INLINE_CEILING_BYTES}B,默认只回深度 ${depth} 骨架(键/类型/数组长度/示例值)。加深:--depth ≤${SHAPE_MAX_DEPTH};子树骨架:--shape <path>;要某几个键:--keys <a,b>;要某个路径:--jq '<path>'(支持 .rules[code=Create].name 这类数组选择器);确实需要整包:--full,或 --out <配置根内路径> 整包落盘(不走 stdout 限额)。`,
|
|
1238
|
+
projectionRule: "投影要写到叶子(数组元素里的字段);写整棵父节点(如 data.activities)会因总量超限再次被外置",
|
|
1239
|
+
...(() => {
|
|
1240
|
+
const rec = content && typeof content === "object" && !Array.isArray(content) ? content : undefined;
|
|
1241
|
+
const data = rec && rec.data && typeof rec.data === "object" && !Array.isArray(rec.data) ? rec.data : undefined;
|
|
1242
|
+
const leaf = data && Array.isArray(data.activities) ? "data.activities[].bizActions" : undefined;
|
|
1243
|
+
return leaf ? { projectionExample: `omc artifact get ${id} --jq '${leaf}'` } : {};
|
|
1244
|
+
})(),
|
|
1197
1245
|
fullCommand: `omc artifact get ${id} --full`,
|
|
1198
1246
|
}, transport);
|
|
1199
1247
|
}
|
|
@@ -1347,6 +1395,72 @@ function enrichDescribeParamMiss(registry, toolName, param, miss) {
|
|
|
1347
1395
|
: `本工具没有参数 "${param}"——available 是本工具的合法参数(已截断)`,
|
|
1348
1396
|
};
|
|
1349
1397
|
}
|
|
1398
|
+
/** issue 03 — `commands --kind/--read-only` + `--filter` 显式分页的边界常量。 */
|
|
1399
|
+
const COMMAND_KIND_VALUES = ["read", "write", "governance", "meta"];
|
|
1400
|
+
const PAGE_DEFAULT_LIMIT = 50;
|
|
1401
|
+
const PAGE_MAX_LIMIT = 200;
|
|
1402
|
+
const PAGE_MAX_OFFSET = 10000;
|
|
1403
|
+
/**
|
|
1404
|
+
* `--kind <read|write|meta>` 是「按读写维度筛」,`--read-only` 是 `--kind read`
|
|
1405
|
+
* 的别名。两者**同时出现一律 invalid-input**(不静默取一个——调用方写错时
|
|
1406
|
+
* 应该听到拒绝,而不是拿到另一半的结果)。
|
|
1407
|
+
*/
|
|
1408
|
+
function resolveKindFilter(raw, readOnly) {
|
|
1409
|
+
if (raw !== undefined && readOnly) {
|
|
1410
|
+
return { error: "--read-only 与 --kind 互斥:--read-only 等价 --kind read,二选一(同传会静默吞掉其中一个,故拒绝)" };
|
|
1411
|
+
}
|
|
1412
|
+
const requested = readOnly ? "read" : raw;
|
|
1413
|
+
if (requested === undefined)
|
|
1414
|
+
return {};
|
|
1415
|
+
const normalized = requested.trim().toLowerCase();
|
|
1416
|
+
if (!COMMAND_KIND_VALUES.includes(normalized)) {
|
|
1417
|
+
return { error: `未知 kind "${requested}";合法取值:read|write|governance|meta(read = 全部只读工具索引,--read-only 等价)` };
|
|
1418
|
+
}
|
|
1419
|
+
return { kind: normalized };
|
|
1420
|
+
}
|
|
1421
|
+
/** `--limit 1..200` / `--offset 0..10000`,整数显式校验(非法值不猜)。 */
|
|
1422
|
+
function parsePageCount(raw, flag, min, max) {
|
|
1423
|
+
if (raw === undefined)
|
|
1424
|
+
return {};
|
|
1425
|
+
const trimmed = raw.trim();
|
|
1426
|
+
const range = `--limit 1..${PAGE_MAX_LIMIT},--offset 0..${PAGE_MAX_OFFSET}`;
|
|
1427
|
+
if (!/^\d+$/.test(trimmed))
|
|
1428
|
+
return { error: `${flag} 必须是整数(当前 "${raw}"):${range}` };
|
|
1429
|
+
const value = Number.parseInt(trimmed, 10);
|
|
1430
|
+
if (value < min || value > max)
|
|
1431
|
+
return { error: `${flag} 超出合法区间(当前 ${value}):${range}` };
|
|
1432
|
+
return { value };
|
|
1433
|
+
}
|
|
1434
|
+
/** 分页的续页命令:把本次的筛选条件原样带上,只推进 `--offset`。 */
|
|
1435
|
+
function pageableCommand(query, lane, kind, options) {
|
|
1436
|
+
const parts = ["omc commands"];
|
|
1437
|
+
if (query !== undefined)
|
|
1438
|
+
parts.push(`--filter ${query}`);
|
|
1439
|
+
if (lane !== undefined)
|
|
1440
|
+
parts.push(`--lane ${lane}`);
|
|
1441
|
+
if (kind !== undefined)
|
|
1442
|
+
parts.push(`--kind ${kind}`);
|
|
1443
|
+
if (options.json === true)
|
|
1444
|
+
parts.push("--json");
|
|
1445
|
+
if (options.compact === true)
|
|
1446
|
+
parts.push("--compact");
|
|
1447
|
+
return parts.join(" ");
|
|
1448
|
+
}
|
|
1449
|
+
/**
|
|
1450
|
+
* ambiguous 的出口(issue 03):命中 >10 且头部近平局时,除了「行已按分数排序」
|
|
1451
|
+
* 还要给一条真能跑的收窄命令。级联:top3 同能力 → --capability;同 kind →
|
|
1452
|
+
* --filter <词> --kind <kind>;否则 → 显式分页拿完整行。
|
|
1453
|
+
*/
|
|
1454
|
+
function narrowCommand(query, hits, registry) {
|
|
1455
|
+
const top = hits.slice(0, 3);
|
|
1456
|
+
const capabilities = new Set(top.map((hit) => capabilityRouteForTool(registry, hit.name)?.id));
|
|
1457
|
+
if (capabilities.size === 1 && [...capabilities][0] !== undefined)
|
|
1458
|
+
return `omc commands --capability ${[...capabilities][0]}`;
|
|
1459
|
+
const kinds = new Set(top.map((hit) => registry.find((tool) => tool.name === hit.name)?.kind));
|
|
1460
|
+
if (kinds.size === 1 && [...kinds][0] !== undefined)
|
|
1461
|
+
return `omc commands --filter ${query} --kind ${[...kinds][0]}`;
|
|
1462
|
+
return `omc commands --filter ${query} --limit ${PAGE_DEFAULT_LIMIT}`;
|
|
1463
|
+
}
|
|
1350
1464
|
function cmdDiscovery(kind, transport, value, options = {}) {
|
|
1351
1465
|
const registry = buildToolRegistry();
|
|
1352
1466
|
let result;
|
|
@@ -1367,21 +1481,38 @@ function cmdDiscovery(kind, transport, value, options = {}) {
|
|
|
1367
1481
|
return emitTransportResult({ status: "ok", ...intentSchemaBlock() }, transport);
|
|
1368
1482
|
}
|
|
1369
1483
|
if (kind === "commands") {
|
|
1484
|
+
// issue 03:`--kind <read|write|meta>` 是读写维度的查询面(`--read-only`
|
|
1485
|
+
// 是 read 的别名)。校验放在所有早退之前——非法值/互斥组合必须听到
|
|
1486
|
+
// invalid-input,而不是静默落到别的面上。
|
|
1487
|
+
const kindResolution = resolveKindFilter(options.kind, options.readOnly === true);
|
|
1488
|
+
if (kindResolution.error !== undefined)
|
|
1489
|
+
return emitInvalid(transport, { message: kindResolution.error });
|
|
1490
|
+
const kindFilter = kindResolution.kind;
|
|
1491
|
+
const limitParse = parsePageCount(options.limit, "--limit", 1, PAGE_MAX_LIMIT);
|
|
1492
|
+
if (limitParse.error !== undefined)
|
|
1493
|
+
return emitInvalid(transport, { message: limitParse.error });
|
|
1494
|
+
const offsetParse = parsePageCount(options.offset, "--offset", 0, PAGE_MAX_OFFSET);
|
|
1495
|
+
if (offsetParse.error !== undefined)
|
|
1496
|
+
return emitInvalid(transport, { message: offsetParse.error });
|
|
1497
|
+
// `--offset` 单独出现时按默认页宽生效(否则「跳过前 N 个」无处落地)。
|
|
1498
|
+
const pagingActive = options.limit !== undefined || options.offset !== undefined;
|
|
1499
|
+
const pageLimit = limitParse.value ?? (options.offset !== undefined ? PAGE_DEFAULT_LIMIT : undefined);
|
|
1370
1500
|
// r59 M2-1: one capability family as a bounded tool index. Resolved before
|
|
1371
1501
|
// the scoped check so `--capability` never falls through to the full
|
|
1372
|
-
// catalogue; `--capability` and `--lane/--filter` are
|
|
1502
|
+
// catalogue; `--capability` and `--lane/--filter/--limit/--offset` are
|
|
1503
|
+
// mutually exclusive(`--kind` 允许:它只在本能力族里按读写切片)。
|
|
1373
1504
|
if (options.capability !== undefined) {
|
|
1374
|
-
if (options.filter !== undefined || options.lane !== undefined) {
|
|
1375
|
-
return emitInvalid(transport, { message: "--capability 与 --filter/--lane 互斥:先按能力取工具名,再用 --filter 在结果里找,或直接 --capability <id
|
|
1505
|
+
if (options.filter !== undefined || options.lane !== undefined || pagingActive) {
|
|
1506
|
+
return emitInvalid(transport, { message: "--capability 与 --filter/--lane/--limit/--offset 互斥:先按能力取工具名,再用 --filter 在结果里找,或直接 --capability <id>(--kind 可与 --capability 组合,只切片不换面)" });
|
|
1376
1507
|
}
|
|
1377
|
-
const slice = commandCapabilitySlice(registry, options.capability);
|
|
1508
|
+
const slice = commandCapabilitySlice(registry, options.capability, kindFilter === undefined ? {} : { kind: kindFilter });
|
|
1378
1509
|
if (!slice) {
|
|
1379
1510
|
const available = capabilityRouteIndex(registry).routes.map((route) => route.id).join("、");
|
|
1380
1511
|
return emitInvalid(transport, { message: `未知 capability "${options.capability}";合法取值:${available}(清单见 omc capabilities)` });
|
|
1381
1512
|
}
|
|
1382
1513
|
return emitProjectedResult({ status: "ok", ...slice }, transport, options.jq);
|
|
1383
1514
|
}
|
|
1384
|
-
const scoped = options.filter !== undefined || options.lane !== undefined;
|
|
1515
|
+
const scoped = options.filter !== undefined || options.lane !== undefined || kindFilter !== undefined || pagingActive;
|
|
1385
1516
|
// Bare `commands` is the bounded index (see commandIndex): the full 54 KB
|
|
1386
1517
|
// catalogue must be requested with `commands --json` (round-9 heavy-task: an
|
|
1387
1518
|
// agent paid 4×54 KB on the default face before any hint could land).
|
|
@@ -1389,6 +1520,12 @@ function cmdDiscovery(kind, transport, value, options = {}) {
|
|
|
1389
1520
|
result = commandIndex(registry);
|
|
1390
1521
|
return emitProjectedResult({ status: "ok", ...result }, transport, options.jq);
|
|
1391
1522
|
}
|
|
1523
|
+
// issue 03:`commands --kind read` 的默认面是索引(能力 → 工具+必填参数),
|
|
1524
|
+
// 与裸 `commands` 同判例——完整行是一步 `--json`。一次 2.6KB 列全 65 个
|
|
1525
|
+
// 读工具,替代 7 轮 --filter 试词(≈21.7KB)。
|
|
1526
|
+
if (kindFilter !== undefined && options.json !== true && options.compact !== true && options.filter === undefined && options.lane === undefined && !pagingActive) {
|
|
1527
|
+
return emitProjectedResult({ status: "ok", ...commandKindIndex(registry, kindFilter) }, transport, options.jq);
|
|
1528
|
+
}
|
|
1392
1529
|
const inventory = commandInventory(registry, { compact: options.compact === true });
|
|
1393
1530
|
// r19 ticket 05: above this many hits a filter word is "broad" — the filtered
|
|
1394
1531
|
// face groups names by capability instead of shipping full rows (a 39-tool
|
|
@@ -1404,7 +1541,9 @@ function cmdDiscovery(kind, transport, value, options = {}) {
|
|
|
1404
1541
|
}
|
|
1405
1542
|
// `commands --json` is the programmatic selection entry: filtering server-side
|
|
1406
1543
|
// keeps the caller from pulling the whole >50 KB inventory to find one lane.
|
|
1407
|
-
|
|
1544
|
+
// issue 03:`--kind` 是同一层筛选(行形状零改动),`--limit/--offset` 是
|
|
1545
|
+
// 显式分页——三者都能单独触发这个面。
|
|
1546
|
+
if (options.filter !== undefined || options.lane !== undefined || kindFilter !== undefined || pagingActive) {
|
|
1408
1547
|
const tools = inventory.tools;
|
|
1409
1548
|
// r19 ticket 05: semantic filter — capability language(聚合/字典/业务集成)
|
|
1410
1549
|
// must locate tools, not dead-end on a name-substring miss.
|
|
@@ -1417,6 +1556,8 @@ function cmdDiscovery(kind, transport, value, options = {}) {
|
|
|
1417
1556
|
const matched = tools.filter((tool) => {
|
|
1418
1557
|
if (options.lane !== undefined && tool.lane !== options.lane)
|
|
1419
1558
|
return false;
|
|
1559
|
+
if (kindFilter !== undefined && tool.kind !== kindFilter)
|
|
1560
|
+
return false;
|
|
1420
1561
|
if (semanticByName === undefined)
|
|
1421
1562
|
return true;
|
|
1422
1563
|
return semanticByName.has(String(tool.name));
|
|
@@ -1427,17 +1568,49 @@ function cmdDiscovery(kind, transport, value, options = {}) {
|
|
|
1427
1568
|
if (semanticByName !== undefined) {
|
|
1428
1569
|
matched.sort((left, right) => scoreOf(String(right.name)) - scoreOf(String(left.name)) || String(left.name).localeCompare(String(right.name)));
|
|
1429
1570
|
}
|
|
1430
|
-
inventory.filtered = {
|
|
1571
|
+
inventory.filtered = {
|
|
1572
|
+
filter: options.filter ?? null,
|
|
1573
|
+
lane: options.lane ?? null,
|
|
1574
|
+
// issue 03:只在有 --kind/--read-only 时出现(无 kind 的既有面逐字节不变)。
|
|
1575
|
+
...(kindFilter !== undefined ? { kind: kindFilter } : {}),
|
|
1576
|
+
matched: matched.length,
|
|
1577
|
+
total: tools.length,
|
|
1578
|
+
};
|
|
1431
1579
|
// r59 v3 (margin): when the head of the ranking is a near-tie, say so —
|
|
1432
1580
|
// the caller should weigh top options (or ask) instead of trusting top1.
|
|
1433
1581
|
// 评审 P1-1:margin/top 必须基于 **lane 过滤后** 的排名——`--filter 加字段 --lane b2`
|
|
1434
1582
|
// 时全局 top1/2 都在别的 lane,拿全局算会把单结果误标 ambiguous、把别的 lane
|
|
1435
1583
|
// 的工具列进 top。
|
|
1436
1584
|
const scoped = semantic === undefined ? [] : semantic.filter((hit) => matched.some((tool) => String(tool.name) === hit.name));
|
|
1437
|
-
|
|
1438
|
-
|
|
1585
|
+
const margin = scoped.length >= 2 ? scoped[0].score - scoped[1].score : undefined;
|
|
1586
|
+
const ambiguous = margin !== undefined && margin < SEARCH_MARGIN_THRESHOLD;
|
|
1587
|
+
// 宽词分组会隐藏行;显式分页(--limit/--offset)必须能看到行,故关分组。
|
|
1588
|
+
// 分组只对「有筛选词/lane」的查询有意义——`--kind read` 是「列全部读工具」,
|
|
1589
|
+
// 它的 65 行就是答案,不是宽词噪声。
|
|
1590
|
+
const groupedFace = matched.length > BROAD_FILTER_TOOL_THRESHOLD &&
|
|
1591
|
+
!isCapabilityIdQuery(registry, options.filter ?? "") &&
|
|
1592
|
+
!pagingActive &&
|
|
1593
|
+
(options.filter !== undefined || options.lane !== undefined);
|
|
1594
|
+
if (ambiguous) {
|
|
1595
|
+
const filtered = inventory.filtered;
|
|
1596
|
+
filtered.ambiguous = true;
|
|
1597
|
+
// issue 03:ambiguous 不再是无出口的标签——候选(top3)+ 可执行的下一跳。
|
|
1598
|
+
// top 只在非分组面写(分组面 :1545 自己给),避免同值写两次。
|
|
1599
|
+
if (!groupedFace)
|
|
1600
|
+
filtered.top = scoped.slice(0, 3).map((hit) => hit.name);
|
|
1601
|
+
filtered.ambiguousHint = `头部近平局(top1/top2 分差 <${SEARCH_MARGIN_THRESHOLD}):行已按分数排序,top 不唯一`;
|
|
1602
|
+
}
|
|
1603
|
+
// issue 03:`filtered.matched` 保持**筛后总数**(未分页),`paging` 说明本页切片;
|
|
1604
|
+
// 尾页 nextOffset:null,续页命令带上本次全部筛选条件。
|
|
1605
|
+
const pageOffset = pagingActive ? Math.min(offsetParse.value ?? 0, matched.length) : 0;
|
|
1606
|
+
const page = pagingActive ? matched.slice(pageOffset, pageOffset + (pageLimit ?? PAGE_DEFAULT_LIMIT)) : matched;
|
|
1607
|
+
inventory.tools = page;
|
|
1608
|
+
if (pagingActive) {
|
|
1609
|
+
const nextOffset = pageOffset + page.length < matched.length ? pageOffset + page.length : null;
|
|
1610
|
+
inventory.filtered.paging = { returned: page.length, offset: pageOffset, nextOffset };
|
|
1611
|
+
if (nextOffset !== null)
|
|
1612
|
+
inventory.nextCommand = `${pageableCommand(options.filter, options.lane, kindFilter, options)} --limit ${pageLimit ?? PAGE_DEFAULT_LIMIT} --offset ${nextOffset}`;
|
|
1439
1613
|
}
|
|
1440
|
-
inventory.tools = matched;
|
|
1441
1614
|
if (semanticByName !== undefined)
|
|
1442
1615
|
for (const tool of inventory.tools)
|
|
1443
1616
|
tool.matchedVia = semanticByName.get(String(tool.name))?.via;
|
|
@@ -1467,7 +1640,7 @@ function cmdDiscovery(kind, transport, value, options = {}) {
|
|
|
1467
1640
|
inventory.filtered.candidates = capabilityCandidatesFor(registry, options.filter ?? "", 3);
|
|
1468
1641
|
inventory.note = "零命中:没有能力短语匹配这个问法;候选是能力(不是工具名),先按 id 展开该能力的工具,或换能力词(如 聚合/子表/字典/报表/业务集成/定时任务),或 omc next \"<目标>\" 按任务路由;全量目录仍走 commands --json";
|
|
1469
1642
|
}
|
|
1470
|
-
else if (
|
|
1643
|
+
else if (groupedFace) {
|
|
1471
1644
|
// A broad word("数据" 39 hits / 8 KB)is half a catalogue: keep every
|
|
1472
1645
|
// NAME (nothing is hidden) but group them by capability instead of
|
|
1473
1646
|
// shipping full rows — the agent narrows with a specific word or --lane
|
|
@@ -1495,7 +1668,16 @@ function cmdDiscovery(kind, transport, value, options = {}) {
|
|
|
1495
1668
|
inventory.groups = [...groups.values()]
|
|
1496
1669
|
.sort((left, right) => right.score - left.score || right.tools.length - left.tools.length || left.capability.localeCompare(right.capability))
|
|
1497
1670
|
.map(({ score: _score, ...group }) => group);
|
|
1498
|
-
|
|
1671
|
+
// issue 03:散文换成可复制的分页命令——「想看完整行」是一步,不是猜。
|
|
1672
|
+
const reprint = options.filter !== undefined
|
|
1673
|
+
? `${pageableCommand(options.filter, undefined, kindFilter, options)} --limit ${PAGE_DEFAULT_LIMIT}`
|
|
1674
|
+
: `${pageableCommand(undefined, options.lane, kindFilter, options)} --limit ${PAGE_DEFAULT_LIMIT}`;
|
|
1675
|
+
inventory.note = `命中 ${matched.length} 个工具(宽词):已按能力分组只列名字(top3 已单列);全行:${reprint}(含 requiredArgs/recipes)`;
|
|
1676
|
+
}
|
|
1677
|
+
// issue 03:ambiguous 的出口。分页已在跑时续页命令优先(否则会把调用方
|
|
1678
|
+
// 从第 2 页踢回第 1 页);分组面已在 note 里给了全行命令,不重复。
|
|
1679
|
+
if (ambiguous && matched.length > 0 && !groupedFace && !pagingActive) {
|
|
1680
|
+
inventory.nextCommand = narrowCommand(options.filter ?? "", scoped, registry);
|
|
1499
1681
|
}
|
|
1500
1682
|
}
|
|
1501
1683
|
result = inventory;
|
|
@@ -2393,12 +2575,12 @@ function shellQuote(value) {
|
|
|
2393
2575
|
function onboardingHelp() {
|
|
2394
2576
|
return [
|
|
2395
2577
|
"首次使用、或不确定从哪开始:omc help omc-start-here(随包权威 topic 路线);被拒或状态异常:omc help omc-refusals。",
|
|
2396
|
-
"中文可读输出:任何命令加 --utf8——它让人类可读诊断(stderr/散文)按 UTF-8 原文输出。stdout 的 JSON 信封在非 UTF-8 代码页下仍保持 \\uXXXX 转义(保证 JSON.parse/ConvertFrom-Json
|
|
2578
|
+
"中文可读输出:任何命令加 --utf8——它让人类可读诊断(stderr/散文)按 UTF-8 原文输出。stdout 的 JSON 信封在非 UTF-8 代码页下仍保持 \\uXXXX 转义(保证 JSON.parse/ConvertFrom-Json 一定可解析,这是有意为之)。Windows 控制台要显示中文还需 `chcp 65001` + `[Console]::OutputEncoding=[Text.Encoding]::UTF8`(PowerShell:先执行这两条再跑 omc);只设 OMC_ASCII_STDOUT=0 是关写出端转义、不改管道解码,在 cp936 管道下会把信封解码坏。要彻底绕开控制台编码:加 `--out-file <path>`(完整信封以 UTF-8 原子写文件,不转义;stdout 只回 {outFile,bytes,sha256} 小回执)。",
|
|
2397
2579
|
"方法论按需读:omc help <topic>(或 omc help --topic <name>)默认只回节索引(每节字节数);用 --section \"<标题>\" 取正文(可重复),确需整篇才 --all。找具体事实(错误码/字段名/命令名)不要整篇 dump:omc help --search \"<词>\"(跨 topic,命中节正文随结果返回)。",
|
|
2398
2580
|
"目标→工具一步定位:omc next \"<你要做什么>\"(离线、只读,给能力/说明/首批命令;不确定会明说并回退到 omc-requirement-analysis)。",
|
|
2399
2581
|
// r30f F20:写清两道门——读面 diet(~2048) 与 stdout 预算(--max-output-bytes,默认 64KiB) 不是一回事。
|
|
2400
2582
|
"输出预算:`--max-output-bytes` 默认 65536(64KiB;超则回 artifact 指针 + sha256),只约束最终 stdout 信封(投影/--jq 之后);`artifact get` 内联上限 8192。读面另有独立 diet 门(~2048)会先外置 detailArtifactId——抬高 --max-output-bytes 不会把已 diet 的大表重新内联。",
|
|
2401
|
-
"投影:--jq 是路径选择器(非 jq
|
|
2583
|
+
"投影:--jq 是路径选择器(非 jq 表达式):不做管道/对象构造,[..] 不是 jq 的 filter。读面回 detailArtifactId 时,用 omc call <tool> … --jq <path>(可重复;`[]` 映射数组)或 --extract/--extract-keys,省掉再跑一次 omc artifact get。单路径命中时 result 直接是节点本体(路径/产物信息在信封旁 resultMeta);多路径/多条 --jq 仍是 extract[]。可复制示例:`omc call model.list --env <env> --jq models`、`omc call rule.list --env <env> --args '{\"schemaCode\":\"m\"}' --jq rules[].code`、`omc call workflow.get_published --env <env> --args '{\"code\":\"f\"}' --jq activities[].bizActions`。commands/capabilities/describe 也支持 --jq。批量形状预检用 --args-list … --preflight(零 wire、零写入,一次报全)。",
|
|
2402
2584
|
// r25 真机(2026-11-04):探针连跑同一读面 2–3 次想验证「第二次是否 unchanged」,
|
|
2403
2585
|
// 结果三次都是全量,还去 describe 找 dedupe 参数(多花 3 轮)。读面确实不做跨调用
|
|
2404
2586
|
// 结果去重——**明说**比留白强,省掉一次探索。
|
|
@@ -2630,8 +2812,8 @@ async function main() {
|
|
|
2630
2812
|
commandExitCode = CLI_EXIT_CODES.ok;
|
|
2631
2813
|
});
|
|
2632
2814
|
command.command("doctor").option("--environment <environment>").option("--env <environment>").option("--service <serviceCode>", "可选:体检单个业务集成服务的鉴权参数形状(掩码/占位/全 0 检出,WARN 非致命)").action(async (options) => { commandExitCode = await cmdDoctor(new ConfigStore(defaultPaths()), options.environment ?? options.env, options.service); });
|
|
2633
|
-
command.command("call <tool>").option("--env <environment>", "环境名;项目白名单按当前 cwd 解析,须在含 .omc-env 的目录内运行").option("--environment <environment>").option("--args <json>").option("--args-file <path>", "从文件读参数 JSON。**必须位于配置根内**(数组批量请改用 --args-list;跨目录/系统临时文件会被拒);免落盘用 `--args -`(stdin)").option("--args-list <json-array>", '同一工具跑 N 次(JSON 数组,每条一个 args 对象,最多 200 条);超过上限请分批,或用 omc script 读文件。逐条执行、默认不中断,最后回 succeeded/failed 汇总。适合批量建字段等').option("--preflight", "与 --args-list 一起用:只跑参数校验 + 写前语义闸(零 wire、零写入),一次报全所有形状问题").option("--keys", "与 artifact get 的 --keys 同义(= --extract-keys):列出本次结果 artifact 的顶层键与体积").addOption(new Option("--extract <path>", "在本次结果的 artifact 内取一个路径的值(可重复;省掉一次 artifact get)").argParser((value, previous = []) => [...previous, value]).default([])).addOption(new Option("--jq [path]", "路径选择器(非 jq
|
|
2634
|
-
const rest = [tool, ...(options.env ? ["--env", options.env] : []), ...(options.environment ? ["--environment", options.environment] : []), ...(options.args !== undefined ? ["--args", options.args] : []), ...(options.argsFile !== undefined ? ["--args-file", options.argsFile] : []), ...(options.argsList !== undefined ? ["--args-list", options.argsList] : []), ...(options.preflight ? ["--preflight"] : []), ...(Array.isArray(options.extract) ? options.extract.flatMap((path) => ["--extract", path]) : []), ...(Array.isArray(options.jq) ? options.jq.flatMap((path) => path === true ? ["--jq"] : ["--jq", path]) : []), ...(options.extractKeys ? ["--extract-keys"] : []),
|
|
2815
|
+
command.command("call <tool>").option("--env <environment>", "环境名;项目白名单按当前 cwd 解析,须在含 .omc-env 的目录内运行").option("--environment <environment>").option("--args <json>").option("--args-file <path>", "从文件读参数 JSON。**必须位于配置根内**(数组批量请改用 --args-list;跨目录/系统临时文件会被拒);免落盘用 `--args -`(stdin)").option("--args-list <json-array>", '同一工具跑 N 次(JSON 数组,每条一个 args 对象,最多 200 条);超过上限请分批,或用 omc script 读文件。逐条执行、默认不中断,最后回 succeeded/failed 汇总。适合批量建字段等').option("--preflight", "与 --args-list 一起用:只跑参数校验 + 写前语义闸(零 wire、零写入),一次报全所有形状问题").option("--keys", "与 artifact get 的 --keys 同义(= --extract-keys):列出本次结果 artifact 的顶层键与体积").addOption(new Option("--extract <path>", "在本次结果的 artifact 内取一个路径的值(可重复;省掉一次 artifact get)").argParser((value, previous = []) => [...previous, value]).default([])).addOption(new Option("--jq [path]", "路径选择器(非 jq)——不是 jq 表达式,不支持管道;[] 映射如 items[].fields.planNo;裸 --jq 列顶层键。单路径命中时 result 直接是节点本体。示例:omc call model.list --env e --jq models · omc call rule.list --env e --args '{\"schemaCode\":\"m\"}' --jq rules[].code · omc call workflow.get_published --env e --args '{\"code\":\"f\"}' --jq activities[].bizActions").argParser((value, previous = []) => [...previous, value]).default([])).option("--extract-keys", "列出本次结果 artifact 的顶层键与体积(省掉一次 artifact get --keys)").option("--max-output-bytes <bytes>", "最终 stdout 信封预算;默认 65536(投影/--jq 之后再判);读面 diet(~2048) 独立外置 detailArtifactId,抬高本参数不会把已 diet 的大表重新内联;artifact get 内联上限 8192").option("--request-id <requestId>").option("--timeout-ms <milliseconds>").option("--wait <milliseconds>", "仅 `omc call` / `omc intent apply` 支持;写锁冲突时有界排队(0=立刻拒绝)").option("--dry-run").addHelpText("after", `\n${onboardingHelp()}\n`).action(async (tool, options) => {
|
|
2816
|
+
const rest = [tool, ...(options.env ? ["--env", options.env] : []), ...(options.environment ? ["--environment", options.environment] : []), ...(options.args !== undefined ? ["--args", options.args] : []), ...(options.argsFile !== undefined ? ["--args-file", options.argsFile] : []), ...(options.argsList !== undefined ? ["--args-list", options.argsList] : []), ...(options.preflight ? ["--preflight"] : []), ...(Array.isArray(options.extract) ? options.extract.flatMap((path) => ["--extract", path]) : []), ...(options.jq === true ? ["--jq"] : Array.isArray(options.jq) ? options.jq.flatMap((path) => path === true ? ["--jq"] : ["--jq", path]) : []), ...(options.extractKeys ? ["--extract-keys"] : []),
|
|
2635
2817
|
...(options.keys ? ["--keys"] : []), ...(options.maxOutputBytes !== undefined ? ["--max-output-bytes", options.maxOutputBytes] : []), ...(options.requestId ? ["--request-id", options.requestId] : []), ...(options.timeoutMs !== undefined ? ["--timeout-ms", options.timeoutMs] : []), ...(options.wait !== undefined ? ["--wait", options.wait] : []), ...(options.dryRun ? ["--dry-run"] : [])];
|
|
2636
2818
|
commandExitCode = await cmdCall(new ConfigStore(defaultPaths()), rest);
|
|
2637
2819
|
});
|
|
@@ -2953,7 +3135,7 @@ async function main() {
|
|
|
2953
3135
|
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)); });
|
|
2954
3136
|
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)); });
|
|
2955
3137
|
const jqOption = () => new Option("--jq [path]", "--jq 不是 jq,仅路径选择器(与 call --jq 同 DSL;可逗号多路径;裸 --jq 列顶层键)").argParser((value, previous = []) => [...previous, value]).default([]);
|
|
2956
|
-
command.command("commands").option("--json").option("--compact").option("--filter <keyword>").option("--capability <id>").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.capability ? { capability: options.capability } : {}), ...(options.lane ? { lane: options.lane } : {}), ...(options.jq !== undefined ? { jq: options.jq } : {}) })); });
|
|
3138
|
+
command.command("commands").description("路由索引(不是目录):工具计数+展开梯子;--kind read 一屏列全部只读工具与必填参数;--json 才是全量目录").option("--json").option("--compact").option("--filter <keyword>").option("--capability <id>").option("--lane <id>").option("--kind <kind>", "按读写维度过滤:read|write|meta(read = 只读工具索引)").option("--read-only", "等价 --kind read(与 --kind 互斥)").option("--limit <n>", "分页:最多 n 行(1..200;给定即关闭宽词分组)").option("--offset <n>", "分页起点(默认 0;未给 --limit 时按 50)").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.capability ? { capability: options.capability } : {}), ...(options.lane ? { lane: options.lane } : {}), ...(options.kind !== undefined ? { kind: options.kind } : {}), ...(options.readOnly === true ? { readOnly: true } : {}), ...(options.limit !== undefined ? { limit: options.limit } : {}), ...(options.offset !== undefined ? { offset: options.offset } : {}), ...(options.jq !== undefined ? { jq: options.jq } : {}) })); });
|
|
2957
3139
|
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) => {
|
|
2958
3140
|
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 } : {}) }));
|
|
2959
3141
|
});
|