@stalfh233/omc-cli 0.8.1 → 0.8.3
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/bench/call-face-eval.js +1 -1
- package/dist/bench/scenario.js +3 -3
- package/dist/cli-contract.js +55 -2
- package/dist/cli-output.js +59 -8
- package/dist/cli.js +338 -59
- package/dist/field-families.js +19 -9
- package/dist/form-layout.js +19 -4
- package/dist/form-support.js +78 -9
- package/dist/graph.js +151 -29
- package/dist/lanes/app.js +34 -6
- package/dist/lanes/field.js +136 -10
- package/dist/lanes/form.js +18 -4
- package/dist/lanes/runtime-data.js +308 -46
- package/dist/lanes/workflow-contract.js +1 -1
- package/dist/lanes/workflow.js +187 -39
- package/dist/path-projection.js +25 -14
- package/dist/read.js +132 -3
- package/dist/refusal-guidance.js +14 -0
- package/dist/session.js +30 -2
- package/dist/support.js +3 -1
- package/dist/wire-failure.js +120 -0
- package/dist/wire.js +109 -5
- package/dist/workflow-support.js +41 -0
- package/package.json +3 -3
package/dist/cli.js
CHANGED
|
@@ -22,16 +22,18 @@ import { cmdFieldAdd } from "./field-add.js";
|
|
|
22
22
|
import { cmdModelPurge } from "./model-purge.js";
|
|
23
23
|
import { cmdProgrammingAdopt, cmdProgrammingApply, cmdProgrammingPull, cmdProgrammingStatus, cmdProgrammingTest } from "./programming-workflow.js";
|
|
24
24
|
import { environmentWritable, requiresProductionConfirmation } from "./environment-policy.js";
|
|
25
|
-
import { CLI_EXIT_CODES, classifyResult, envelope, errorEnvelope, humanUtf8, installCodePageSafeStderr, refusalText, requestId } from "./cli-contract.js";
|
|
25
|
+
import { CLI_EXIT_CODES, asciiStdout, classifyResult, envelope, errorEnvelope, humanUtf8, installCodePageSafeStderr, refusalText, requestId } from "./cli-contract.js";
|
|
26
26
|
import { ownsStdout } from "./cli-stdout.js";
|
|
27
27
|
import { formatDoctorHumanSummary, unsupportedCapabilities } from "./version-family-gaps.js";
|
|
28
|
-
import { beginWriteFace, configureOutput, endWriteFace, humanSummary, maybeWarnMergedStreams, stripOutputFlags, writeEnvelope } from "./cli-output.js";
|
|
28
|
+
import { beginWriteFace, configureOutput, endWriteFace, humanSummary, maybeWarnMergedStreams, noteOutProjection, stripOutputFlags, writeEnvelope } from "./cli-output.js";
|
|
29
29
|
import { beginUsage, completeUsage, currentUsageArgsDigest, ensureProjectIgnore, priorIdenticalSuccess, recordUsageOutput, usageReport } from "./usage-log.js";
|
|
30
30
|
import { artifactFetchHint, artifactRoot, boundResult, emitInvalid, emitResult, emitThrown, emitTransportResult, outputBudget, readArtifact, withTransport, } from "./command-transport.js";
|
|
31
31
|
import { CLI_DEFAULT_OUTPUT_BYTES, assertSafeOutputPath, pruneArtifacts } from "./artifacts.js";
|
|
32
32
|
import { sessionAccountForEnvironment } from "./session-account.js";
|
|
33
33
|
import { closeWritableWindow, openWritableWindow, parseWritableTtl, sweepWritableWindowsAtStartup, validateWritableReason, writableWindowStatus, WRITABLE_WINDOW_DEFAULT_TTL_MINUTES, WRITABLE_WINDOW_LOG, WRITABLE_WINDOW_MAX_TTL_MINUTES, WritableWindowInputError } from "./writable-window.js";
|
|
34
|
-
import { artifactPathMissHint, nullProjectionHint, PATH_MISS_HELP_REF, partialPathMissHint, pathMissCopyableHint, pathMissCopyablePaths, pathMissCrossFaceCorrection, pathMissDidYouMean, projectJsonPath, projectJsonPathFanout, projectResultExtract, shapeOf, SHAPE_MAX_DEPTH, unwrapSinglePathProjection } from "./path-projection.js";
|
|
34
|
+
import { artifactPathMissHint, nullProjectionHint, PATH_MISS_HELP_REF, UNSUPPORTED_JQ_OBJECT_HINT, partialPathMissHint, pathMissCopyableHint, pathMissCopyablePaths, pathMissCrossFaceCorrection, pathMissDidYouMean, projectJsonPath, projectJsonPathFanout, projectResultExtract, shapeOf, SHAPE_MAX_DEPTH, unwrapSinglePathProjection } from "./path-projection.js";
|
|
35
|
+
import { isUncertainWireError } from "./support.js";
|
|
36
|
+
import { containerKeyOf } from "./read.js";
|
|
35
37
|
import { basename, dirname, join, resolve } from "node:path";
|
|
36
38
|
import { existsSync, readFileSync, writeFileSync, chmodSync, mkdirSync } from "node:fs";
|
|
37
39
|
import { buildToolRegistry } from "./tools.js";
|
|
@@ -56,7 +58,6 @@ import { SEARCH_MARGIN_THRESHOLD } from "./tool-search.js";
|
|
|
56
58
|
import { commandCapabilitySlice, commandIndex, commandInventory, commandKindIndex, describeContract, describeContractFull, describeContractTool, describeExample, describeParam, describeSchemaOnly, describeTool, describeToolFull, filterTools } from "./discovery.js";
|
|
57
59
|
import { locatorMetaFor } from "./read-shapes.js";
|
|
58
60
|
import { surfaceRefFor } from "./surface-ref.js";
|
|
59
|
-
import { closestMatches } from "./closest-match.js";
|
|
60
61
|
import { KEY_ALIAS_HINTS, inputAliasSynonymKeys } from "./tool-types.js";
|
|
61
62
|
import { repeatFullDescribe } from "./describe-cache.js";
|
|
62
63
|
import { buildCapabilityOverview, capabilityCandidatesFor, capabilityDetail, capabilityRouteForTool, capabilityRouteIndex, compactCapabilities, executableCapabilityBundle, resolveCapabilityId, DISCOVERY_AUTHORITY } from "./capability-overview.js";
|
|
@@ -69,7 +70,8 @@ import { planIntent, readbackIntent, applyIntent, intentWarnings } from "./inten
|
|
|
69
70
|
import { listSkills, readSkill, readSkillOutline, readSkillSection, searchSkills, suggestHelpTopics } from "./skills.js";
|
|
70
71
|
import { parseToolInput, ToolInputError } from "./tool-types.js";
|
|
71
72
|
import { WireError, wireCall } from "./wire.js";
|
|
72
|
-
import {
|
|
73
|
+
import { describeWireFailure } from "./wire-failure.js";
|
|
74
|
+
import { DEFAULT_PULL_CONCURRENCY, GraphIndexAmbiguousError, GraphIndexError, GraphIndexUnreadableError, GraphPullLockHeldError, GraphPullTimeoutError, DEFAULT_GRAPH_PULL_TIMEOUT_MS, MAX_GRAPH_PULL_TIMEOUT_MS, MAX_PULL_CONCURRENCY, graphDbPath, graphRoot, impactGraph, listGraphIndexes, publishGraphPull, queryGraphReferences, queryGraphReferencesBatch, queryGraphEdges, readGraphStatus, searchGraphRules, } from "./graph.js";
|
|
73
75
|
import { cmdResidue } from "./residue.js";
|
|
74
76
|
import { cmdTrack } from "./track.js";
|
|
75
77
|
import { ENDPOINTS } from "./endpoints.js";
|
|
@@ -190,7 +192,7 @@ async function cmdSetup(store, args) {
|
|
|
190
192
|
}
|
|
191
193
|
return 0;
|
|
192
194
|
}
|
|
193
|
-
async function cmdDoctor(store, environment, serviceCode, freshLogin = false) {
|
|
195
|
+
async function cmdDoctor(store, environment, serviceCode, freshLogin = false, jq, explain = false) {
|
|
194
196
|
const manifest = loadCoverageManifest();
|
|
195
197
|
const steps = [];
|
|
196
198
|
let ok = true;
|
|
@@ -362,12 +364,27 @@ async function cmdDoctor(store, environment, serviceCode, freshLogin = false) {
|
|
|
362
364
|
// 补一个空 `ok` 信封(失败路径还补过谎报 `internal` 的)。现在它自己写**一个**
|
|
363
365
|
// 信封:体检行 + 冷启动锚点 + 已知能力缺口。冷启动锚点从 stderr 移到这里
|
|
364
366
|
// (r26b:stderr 给了 agent 也读不到结构化字段,而锚点是每会话都要用的指引)。
|
|
365
|
-
|
|
367
|
+
const doctorResult = {
|
|
366
368
|
checks: steps.map(parseDoctorStep),
|
|
367
369
|
...(loginSource !== undefined ? { loginSource } : {}),
|
|
368
370
|
anchor: doctorAnchor(),
|
|
369
371
|
unsupportedCapabilities: unsupportedCapabilities(manifest, detectedVersion),
|
|
370
|
-
}
|
|
372
|
+
};
|
|
373
|
+
// C2(0.8.4):`doctor --jq 'checks[].area'` 此前是 unknown option——通用 flag
|
|
374
|
+
// 在体检面上缺席。这里与 call/发现面共用同一投影层(相对 result,单路径解包
|
|
375
|
+
// 与否由 projectResultExtract 的既有契约决定,不另造一套)。
|
|
376
|
+
let doctorPayload = doctorResult;
|
|
377
|
+
if (jq !== undefined) {
|
|
378
|
+
const keysOnly = jq.some((entry) => entry === true);
|
|
379
|
+
const paths = jq
|
|
380
|
+
.filter((entry) => typeof entry === "string")
|
|
381
|
+
.flatMap((path) => path.split(","))
|
|
382
|
+
.map((path) => path.trim())
|
|
383
|
+
.filter(Boolean);
|
|
384
|
+
if (paths.length > 0 || keysOnly)
|
|
385
|
+
doctorPayload = projectResultExtract(doctorResult, paths, keysOnly, undefined, explain) ?? doctorResult;
|
|
386
|
+
}
|
|
387
|
+
writeEnvelope(envelope(ok ? "ok" : "failed", doctorPayload, requestId()));
|
|
371
388
|
return ok ? 0 : 1;
|
|
372
389
|
}
|
|
373
390
|
/**
|
|
@@ -623,6 +640,9 @@ async function cmdCall(store, args) {
|
|
|
623
640
|
// `artifact get` uses `--keys`; `call` only had `--extract-keys`, so the muscle
|
|
624
641
|
// memory failed with "unknown option '--keys'" (r16 P7). Accept both.
|
|
625
642
|
const extractKeys = args.includes("--extract-keys") || args.includes("--keys") || args.some((token, index) => token === "--jq" && (args[index + 1] === undefined || args[index + 1].startsWith("--")));
|
|
643
|
+
// C6(0.8.4):pathMiss 默认只回结论(≤300B),完整排查载荷(available/
|
|
644
|
+
// correctPath/nextCommand/hint)只在显式 --explain 时给。
|
|
645
|
+
const explainProjection = args.includes("--explain");
|
|
626
646
|
const dryRun = args.includes("--dry-run");
|
|
627
647
|
const waitValue = flag("--wait");
|
|
628
648
|
let waitMs = 0;
|
|
@@ -706,6 +726,27 @@ async function cmdCall(store, args) {
|
|
|
706
726
|
}
|
|
707
727
|
const registry = buildToolRegistry();
|
|
708
728
|
const tool = registry.find((definition) => definition.name === toolName);
|
|
729
|
+
// C1(0.8.4):同义参数**先换算**再校验——未知键表里那两行(onlyCustom→all、
|
|
730
|
+
// pageSize→page)是语义不等价的改名,照做会拿到相反/更少的结果。这里接受
|
|
731
|
+
// 真实语义别名并回执 aliasesApplied,而不是把人引到另一个键。
|
|
732
|
+
let aliasesApplied = {};
|
|
733
|
+
// 只对读面换算:写面参数静默改写会改掉真实载荷,写面继续走严格未知键拒绝。
|
|
734
|
+
if (tool && tool.kind !== "write") {
|
|
735
|
+
const aliased = applyReadArgAliases(tool.name, new Set(Object.keys(tool.inputSchema)), parsedArgs);
|
|
736
|
+
if (aliased.conflict !== undefined) {
|
|
737
|
+
const conflict = {
|
|
738
|
+
status: "refused",
|
|
739
|
+
blocker: "read-arg-alias-conflict",
|
|
740
|
+
tool: toolName,
|
|
741
|
+
alias: aliased.conflict.alias,
|
|
742
|
+
canonicalKey: aliased.conflict.canonical,
|
|
743
|
+
message: `同时传了 ${aliased.conflict.alias} 与 ${aliased.conflict.canonical}:${aliased.conflict.alias} 是 ${aliased.conflict.canonical} 的同义别名,二者只能留一个(名字里的语义不同——${aliased.conflict.alias} 不会静默覆盖显式给的 ${aliased.conflict.canonical})`,
|
|
744
|
+
};
|
|
745
|
+
return emit("refused", conflict, CLI_EXIT_CODES.policyRefused);
|
|
746
|
+
}
|
|
747
|
+
parsedArgs = aliased.args;
|
|
748
|
+
aliasesApplied = aliased.applied;
|
|
749
|
+
}
|
|
709
750
|
// r29f F7:读面未知参数默认硬拒(与写面 tool-input-unknown-keys 对齐);
|
|
710
751
|
// 显式 `lenientArgs:true` 才回退到旧的 ignoredArgs 回显。
|
|
711
752
|
//
|
|
@@ -786,6 +827,9 @@ async function cmdCall(store, args) {
|
|
|
786
827
|
? { nextCommand: `omc describe ${toolName} --param ${suggestions.find((entry) => entry.closest !== undefined).closest}` }
|
|
787
828
|
: { nextCommand: `omc describe ${toolName}` }),
|
|
788
829
|
message: `读面不接受未知键(与写面对齐):${pairs.join("、")}。` +
|
|
830
|
+
// C1(0.8.4):没有可信的改写建议时,不编造改名——直接把该工具的
|
|
831
|
+
// 真实参数名列出来,让人按名字挑。
|
|
832
|
+
`${suggestions.every((entry) => entry.closest === undefined && entry.hint === undefined && entry.absentInTool === undefined) ? `本工具的真实参数:${[...schemaKeys].join("、")}。` : ""}` +
|
|
789
833
|
`改用合法键后重试;确需宽松忽略传 lenientArgs:true。参数表:omc describe ${toolName}`,
|
|
790
834
|
};
|
|
791
835
|
return emit("error", result, CLI_EXIT_CODES.invalidInput);
|
|
@@ -870,6 +914,10 @@ async function cmdCall(store, args) {
|
|
|
870
914
|
}
|
|
871
915
|
let unwrappedBody;
|
|
872
916
|
let resultMeta;
|
|
917
|
+
// C7(0.8.4):结果容器键自描述——`items`/`models`/`rules`/`logs`/`fields` 各面
|
|
918
|
+
// 不同,每个工具首次使用都要先探一次键名。在**投影前**的原始结果上判定,
|
|
919
|
+
// 挂到信封 resultMeta(result 本体与 --jq 路径零改动)。
|
|
920
|
+
const container = containerKeyOf(result);
|
|
873
921
|
if (extractPaths.length > 0 || extractKeys) {
|
|
874
922
|
// F1(retro 22,ticket 138):把调用上下文交给投影层——pathMiss 能推导出
|
|
875
923
|
// correctPath 时,拼一条含 --env/--args/--jq 的完整可复制命令(nextCommand)。
|
|
@@ -878,7 +926,7 @@ async function cmdCall(store, args) {
|
|
|
878
926
|
tool: toolName,
|
|
879
927
|
...(environment !== undefined && environment.length > 0 ? { environment } : {}),
|
|
880
928
|
argsJson: rawArgs !== undefined ? rawArgs : JSON.stringify(parsedArgs),
|
|
881
|
-
});
|
|
929
|
+
}, explainProjection);
|
|
882
930
|
if (projected !== undefined)
|
|
883
931
|
result = projected;
|
|
884
932
|
// Projected reads are represented by extract[] (and rows[] for multi-path).
|
|
@@ -947,16 +995,39 @@ async function cmdCall(store, args) {
|
|
|
947
995
|
},
|
|
948
996
|
};
|
|
949
997
|
}
|
|
998
|
+
// C1(0.8.4):同义参数换算的说明与 ignoredArgs 同层——放在投影**之后**,
|
|
999
|
+
// 否则被 --jq 的窄投影吞掉;单路径解包时随 resultMeta 走。
|
|
1000
|
+
if (Object.keys(aliasesApplied).length > 0) {
|
|
1001
|
+
if (unwrappedBody !== undefined)
|
|
1002
|
+
resultMeta = { ...(resultMeta ?? {}), aliasesApplied };
|
|
1003
|
+
else if (typeof result === "object" && result !== null)
|
|
1004
|
+
result = { ...result, aliasesApplied };
|
|
1005
|
+
}
|
|
950
1006
|
const classified = classifyResult(result);
|
|
951
1007
|
try {
|
|
952
1008
|
// 单路径 --jq 命中:emit 的是节点本体(可能不是对象),元信息在信封旁。
|
|
953
1009
|
// body 自带 `status`/`blocker` 时(如 --jq 直接取回整包),信封的 error 仍以
|
|
954
1010
|
// **投影前**的 classified 为准——别让 payload 里的字段改写本调用的结论。
|
|
955
1011
|
const emitValue = unwrappedBody !== undefined ? unwrappedBody : result;
|
|
1012
|
+
// C4(0.8.4):`--out` + `--jq` 同用——把「投影后的值」交给输出层,由它先落盘
|
|
1013
|
+
// 投影 JSON、再在 stdout 回执里带上投影值(此前投影只影响 stdout 的 result、
|
|
1014
|
+
// --out 只回 {out,bytes},提取值在两边都拿不到)。未命中不解包,投影回执
|
|
1015
|
+
// (pathMiss 等纠错载荷)本身就是这里要回显的值,不静默。
|
|
1016
|
+
// 裸 `--jq` / `--keys`(键清单)也是投影(同一套 omit 语义):一并交给输出层,
|
|
1017
|
+
// 免得「带 --jq 值」与「带 --jq 不带值」在 --out 下又分两套。
|
|
1018
|
+
if (extractPaths.length > 0 || extractKeys) {
|
|
1019
|
+
const projectionValue = unwrappedBody !== undefined ? unwrappedBody : result;
|
|
1020
|
+
const unanswered = projectionValue !== null && typeof projectionValue === "object" && !Array.isArray(projectionValue)
|
|
1021
|
+
&& projectionValue.unanswered === true;
|
|
1022
|
+
noteOutProjection({ paths: extractPaths, value: projectionValue, hit: !unanswered, budget: maxOutputBytes });
|
|
1023
|
+
}
|
|
956
1024
|
// A2(r89 契约层):跨面键名对照(read-shapes 单一声明)挂信封 resultMeta.locator——
|
|
957
1025
|
// 成功读回才有定位意义;result 本体与 --jq 路径零改动。
|
|
958
1026
|
const locatorExtra = classified.status === "ok" ? locatorMetaFor(toolName) : undefined;
|
|
959
|
-
const
|
|
1027
|
+
const containerExtra = classified.status === "ok" && container !== undefined
|
|
1028
|
+
? { containerKey: container.key, ...(container.path !== undefined ? { containerPath: container.path } : {}) }
|
|
1029
|
+
: undefined;
|
|
1030
|
+
const mergedMeta = { ...(locatorExtra ?? {}), ...(containerExtra ?? {}), ...(resultMeta ?? {}) };
|
|
960
1031
|
const extras = unwrappedBody !== undefined
|
|
961
1032
|
? { error: classified.error, ...(Object.keys(mergedMeta).length > 0 ? { resultMeta: mergedMeta } : {}) }
|
|
962
1033
|
: Object.keys(mergedMeta).length > 0 ? { resultMeta: mergedMeta } : undefined;
|
|
@@ -981,11 +1052,80 @@ function argvValues(args, name) {
|
|
|
981
1052
|
}
|
|
982
1053
|
/** F6:应用级范围键。被工具 schema 忽略时必须拒绝,不能静默回落到默认应用。 */
|
|
983
1054
|
const APP_SCOPE_ARG_KEYS = new Set(["appCode", "applicationCode", "application"]);
|
|
1055
|
+
/** 归一化编辑距离(去分隔符 + 统一大小写),用于「拼写级」改名判定。 */
|
|
1056
|
+
function normalizedEditDistance(a, b) {
|
|
1057
|
+
const left = a.toUpperCase().replace(/[\s._-]/g, "");
|
|
1058
|
+
const right = b.toUpperCase().replace(/[\s._-]/g, "");
|
|
1059
|
+
const row = Array.from({ length: right.length + 1 }, (_, index) => index);
|
|
1060
|
+
for (let i = 1; i <= left.length; i += 1) {
|
|
1061
|
+
let previous = row[0];
|
|
1062
|
+
row[0] = i;
|
|
1063
|
+
for (let j = 1; j <= right.length; j += 1) {
|
|
1064
|
+
const temp = row[j];
|
|
1065
|
+
row[j] = Math.min(row[j] + 1, row[j - 1] + 1, previous + (left[i - 1] === right[j - 1] ? 0 : 1));
|
|
1066
|
+
previous = temp;
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
return row[right.length];
|
|
1070
|
+
}
|
|
1071
|
+
/**
|
|
1072
|
+
* C1(0.8.4):**语义**别名(不是拼写)——只在目标键真实存在时换算,且回执
|
|
1073
|
+
* 写明换算结果(aliasesApplied),不让调用方以为原名生效了。
|
|
1074
|
+
*
|
|
1075
|
+
* 两条别名的语义边界不同:
|
|
1076
|
+
* - `pageSize` 与分页工具的 `size`(每页条数)是同一件事,任何有 `size` 的工具都换算。
|
|
1077
|
+
* 平台依据:`/api/runtime/query/list` 的 `QueryDataVO{page,size}` 在
|
|
1078
|
+
* `QueryRuntimeController` 里按 `new PageableImpl(page * size, size)` 落到分页
|
|
1079
|
+
* (8.6.26 QueryRuntimeController.java:3304/3945;2.1.5 同名文件:3658/4187),
|
|
1080
|
+
* 即 `size` = 每页条数、`page` = 页序号;前端列表页也是
|
|
1081
|
+
* `page:this.curPage-1, size:this.pageSize`(8.6.26 frontend-dist
|
|
1082
|
+
* portal-app/js/17491.eed01ae7.js:1、31275.a9b046c8.js:1)。
|
|
1083
|
+
* - `onlyCustom` 与 `all` **方向相反**(`all:true` = 连系统字段一起返)。只有
|
|
1084
|
+
* field.list 的 `all` 是「包含系统字段」的客户端过滤(lanes/field.ts:453 用
|
|
1085
|
+
* isSystemFieldCode 过滤),系统字段本身由平台 `defaultProperty=true` 标注
|
|
1086
|
+
* (BizProperty.isSystem(),8.6.26 shared/BizProperty.java:257-259;
|
|
1087
|
+
* 2.1.5 contracts/BizProperty.java:262-264)。**不扩展到 data.list**:那里的
|
|
1088
|
+
* `all` 是「自动翻页聚合全部」,换算过去只会拿错结果集。
|
|
1089
|
+
* 其余同名键(如 model.inspect 的 `all`)没有被实测误用证据,宁可不加。
|
|
1090
|
+
*/
|
|
1091
|
+
const ONLY_CUSTOM_TO_ALL_TOOLS = new Set(["field.list"]);
|
|
1092
|
+
function applyReadArgAliases(toolName, schemaKeys, input) {
|
|
1093
|
+
const args = { ...input };
|
|
1094
|
+
const applied = {};
|
|
1095
|
+
const move = (alias, canonical, transform, describe) => {
|
|
1096
|
+
if (args[alias] === undefined || schemaKeys.has(alias) || !schemaKeys.has(canonical))
|
|
1097
|
+
return undefined;
|
|
1098
|
+
if (args[canonical] !== undefined)
|
|
1099
|
+
return { args, applied, conflict: { alias, canonical } };
|
|
1100
|
+
const next = transform(args[alias]);
|
|
1101
|
+
if (next === undefined)
|
|
1102
|
+
return undefined; // 类型不符:交给正常参数校验,不做半截换算
|
|
1103
|
+
args[canonical] = next;
|
|
1104
|
+
delete args[alias];
|
|
1105
|
+
applied[alias] = describe(next);
|
|
1106
|
+
return { args, applied };
|
|
1107
|
+
};
|
|
1108
|
+
const pageSize = move("pageSize", "size", (value) => (typeof value === "number" && Number.isFinite(value) ? value : undefined), (next) => `size=${String(next)}`);
|
|
1109
|
+
if (pageSize !== undefined)
|
|
1110
|
+
return pageSize;
|
|
1111
|
+
if (ONLY_CUSTOM_TO_ALL_TOOLS.has(toolName)) {
|
|
1112
|
+
const onlyCustom = move("onlyCustom", "all", (value) => (typeof value === "boolean" ? !value : undefined), (next) => `all=${String(next)}`);
|
|
1113
|
+
if (onlyCustom !== undefined)
|
|
1114
|
+
return onlyCustom;
|
|
1115
|
+
}
|
|
1116
|
+
return { args, applied };
|
|
1117
|
+
}
|
|
984
1118
|
/**
|
|
985
1119
|
* 读面「拼错键」建议(r25 真机实证,2026-11-04):`limt:5` 曾按编辑距离被指到
|
|
986
1120
|
* `filter`——两者共享 "fi" 片段就过阈值,但语义完全不同(取 5 条 vs 按条件过滤)。
|
|
987
1121
|
* 短键(≤5 字符)靠距离算不准,这里先查显式缩写表(与 tool-types 的 KEY_ALIAS_HINTS
|
|
988
|
-
*
|
|
1122
|
+
* 同源),命中且参数真实存在才用;否则只认**拼写级**近似(编辑距离 ≤2)。
|
|
1123
|
+
*
|
|
1124
|
+
* C1(0.8.4):最后一步此前是 closestMatches 的「least-bad」兜底——它总会挑一个
|
|
1125
|
+
* 名字,于是 `onlyCustom` 被建议到语义相反的 `all`、`pageSize` 被建议到 `page`。
|
|
1126
|
+
* 改名建议只在**拼错**(编辑距离 ≤2)或上面人工核过的同义表里给;其余宁可不猜
|
|
1127
|
+
* (回执仍列全部真实参数 expectedKeys)。语义别名走 applyReadArgAliases,不用
|
|
1128
|
+
* 「改名建议」表达——建议无法携带方向/换算信息。
|
|
989
1129
|
*/
|
|
990
1130
|
export function suggestArgumentKey(key, schemaKeys, toolName) {
|
|
991
1131
|
const known = new Set(schemaKeys);
|
|
@@ -1014,8 +1154,17 @@ export function suggestArgumentKey(key, schemaKeys, toolName) {
|
|
|
1014
1154
|
// 返回 absentInTool,让回执直说「本工具没有这个参数」。
|
|
1015
1155
|
if (aliases.length > 0)
|
|
1016
1156
|
return { absentInTool: aliases[0] };
|
|
1017
|
-
|
|
1018
|
-
|
|
1157
|
+
// 拼写级近似:距离 ≤2 才算「同一个名字写错了」;更远的一律不猜。
|
|
1158
|
+
let closest;
|
|
1159
|
+
let closestDistance = Number.POSITIVE_INFINITY;
|
|
1160
|
+
for (const candidate of schemaKeys) {
|
|
1161
|
+
const distance = normalizedEditDistance(key, candidate);
|
|
1162
|
+
if (distance < closestDistance) {
|
|
1163
|
+
closest = candidate;
|
|
1164
|
+
closestDistance = distance;
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
return closest !== undefined && closestDistance <= 2 ? { closest } : {};
|
|
1019
1168
|
}
|
|
1020
1169
|
function resolvedDefaultEnvironment(store) {
|
|
1021
1170
|
try {
|
|
@@ -1061,16 +1210,11 @@ function artifactDefaultMetadata(id, bytes, content, depth) {
|
|
|
1061
1210
|
fullCommand: `omc artifact get ${id} --full`,
|
|
1062
1211
|
};
|
|
1063
1212
|
}
|
|
1064
|
-
/**
|
|
1065
|
-
* `artifact get --jq`: one path walk, with `[]` fan-out (same syntax as
|
|
1066
|
-
* `omc call --jq`). Returns the envelope fields so both the `--summary` and the
|
|
1067
|
-
* plain branch stay identical.
|
|
1068
|
-
*/
|
|
1069
1213
|
function projectArtifactPath(value, path) {
|
|
1070
1214
|
if (!path.includes("[]")) {
|
|
1071
1215
|
const projected = projectJsonPath(value, path);
|
|
1072
1216
|
return projected.missed
|
|
1073
|
-
? { missed: true, ...(projected.at !== undefined ? { at: projected.at } : {}), ...(projected.available !== undefined ? { available: projected.available } : {}), ...(projected.availableAll !== undefined ? { availableAll: projected.availableAll } : {}), ...(projected.availableTruncated !== undefined ? { availableTruncated: projected.availableTruncated } : {}) }
|
|
1217
|
+
? { missed: true, ...(projected.unsupportedSyntax === true ? { unsupportedSyntax: true } : {}), ...(projected.at !== undefined ? { at: projected.at } : {}), ...(projected.available !== undefined ? { available: projected.available } : {}), ...(projected.availableAll !== undefined ? { availableAll: projected.availableAll } : {}), ...(projected.availableTruncated !== undefined ? { availableTruncated: projected.availableTruncated } : {}) }
|
|
1074
1218
|
: { missed: false, content: projected.value ?? null };
|
|
1075
1219
|
}
|
|
1076
1220
|
const fanout = projectJsonPathFanout(value, path);
|
|
@@ -1078,6 +1222,34 @@ function projectArtifactPath(value, path) {
|
|
|
1078
1222
|
? { missed: true, ...(fanout.at !== undefined ? { at: fanout.at } : {}), ...(fanout.available !== undefined ? { available: fanout.available } : {}), ...(fanout.availableAll !== undefined ? { availableAll: fanout.availableAll } : {}), ...(fanout.availableTruncated !== undefined ? { availableTruncated: fanout.availableTruncated } : {}) }
|
|
1079
1223
|
: { missed: false, content: fanout.values, mapped: fanout.values.length, ...(fanout.missedEntries > 0 ? { missedEntries: fanout.missedEntries } : {}), nullEntries: fanout.nullEntries, nonNullEntries: fanout.nonNullEntries };
|
|
1080
1224
|
}
|
|
1225
|
+
/**
|
|
1226
|
+
* C3(0.8.4):artifact 面**唯一**的 miss 条目构造器——`call` 面(projectResultExtract
|
|
1227
|
+
* 的 extract[])同形:路径未命中 → `path`/`content:null`/`pathMiss`/`missedAt`/
|
|
1228
|
+
* (didYouMean|helpRef)(--explain 才带 available/correctPath/nextCommand/hint);
|
|
1229
|
+
* 不支持语法 → `pathMiss:false` + `unsupportedSyntax:true`(不是「键不存在」)。
|
|
1230
|
+
* 三处(裸 --jq / --summary --jq / --shape <path>)此前各写一份,容易再分叉。
|
|
1231
|
+
*/
|
|
1232
|
+
function artifactMissEntry(path, projected, content, artifactId, explainMiss) {
|
|
1233
|
+
if (projected.unsupportedSyntax === true) {
|
|
1234
|
+
return {
|
|
1235
|
+
path,
|
|
1236
|
+
content: null,
|
|
1237
|
+
pathMiss: false,
|
|
1238
|
+
unsupportedSyntax: true,
|
|
1239
|
+
unanswered: true,
|
|
1240
|
+
available: projected.available,
|
|
1241
|
+
hint: UNSUPPORTED_JQ_OBJECT_HINT,
|
|
1242
|
+
};
|
|
1243
|
+
}
|
|
1244
|
+
return {
|
|
1245
|
+
path,
|
|
1246
|
+
content: null,
|
|
1247
|
+
pathMiss: true,
|
|
1248
|
+
...(projected.at !== undefined ? { missedAt: projected.at } : {}),
|
|
1249
|
+
...artifactMissFields(projected, explainMiss),
|
|
1250
|
+
...(explainMiss ? artifactMissCorrection(content, path, projected.at, artifactId) : {}),
|
|
1251
|
+
};
|
|
1252
|
+
}
|
|
1081
1253
|
/**
|
|
1082
1254
|
* F1/F2(retro 21/22,ticket 138):artifact 面 pathMiss 的机器可读纠错面——
|
|
1083
1255
|
* `correctPath`(已验证可解析)+ `helpRef`(教程指针)+ 可整段复制的重跑命令。
|
|
@@ -1153,14 +1325,26 @@ function extractArtifactGetOutFlag(argv) {
|
|
|
1153
1325
|
return undefined;
|
|
1154
1326
|
}
|
|
1155
1327
|
/** artifact 面 pathMiss 的 didYouMean/截断计数附加字段(r75:与 call 面一致)。 */
|
|
1156
|
-
|
|
1328
|
+
/**
|
|
1329
|
+
* C6(0.8.4):artifact 面 miss 的默认载荷与 call 面同口径——只留
|
|
1330
|
+
* `didYouMean` + `helpRef`;`available`(该层全部键)/`availableTruncated`
|
|
1331
|
+
* 只在显式 `--explain` 时给(排查载荷不再每次吃 600–1200B)。
|
|
1332
|
+
*/
|
|
1333
|
+
function artifactMissFields(projected, explain) {
|
|
1157
1334
|
const didYouMean = pathMissDidYouMean(projected.at, projected.available, projected.availableAll);
|
|
1158
1335
|
return {
|
|
1159
|
-
...(projected.availableTruncated !== undefined ? { availableTruncated: projected.availableTruncated } : {}),
|
|
1160
1336
|
...(didYouMean !== undefined ? { didYouMean } : {}),
|
|
1337
|
+
helpRef: PATH_MISS_HELP_REF,
|
|
1338
|
+
...(explain
|
|
1339
|
+
? {
|
|
1340
|
+
available: projected.available,
|
|
1341
|
+
...(projected.availableTruncated !== undefined ? { availableTruncated: projected.availableTruncated } : {}),
|
|
1342
|
+
}
|
|
1343
|
+
: {}),
|
|
1161
1344
|
};
|
|
1162
1345
|
}
|
|
1163
1346
|
async function cmdArtifactGet(id, transport, options = {}) {
|
|
1347
|
+
const explainMiss = options.explain === true;
|
|
1164
1348
|
try {
|
|
1165
1349
|
if (options.depth !== undefined && (!Number.isInteger(options.depth) || options.depth < 1 || options.depth > SHAPE_MAX_DEPTH)) {
|
|
1166
1350
|
const parsed = errorEnvelope(new Error(`--depth 必须是 1-${SHAPE_MAX_DEPTH} 的整数(默认 2;再深就成了正文复刻,字节失控)`), "artifact-depth-invalid", CLI_EXIT_CODES.invalidInput, transport.request);
|
|
@@ -1229,7 +1413,7 @@ async function cmdArtifactGet(id, transport, options = {}) {
|
|
|
1229
1413
|
// `--shape <path>`:在命中的子树上出骨架(同 --jq 的路径 DSL,含 [] 与 [code=X])。
|
|
1230
1414
|
const projected = projectArtifactPath(artifact.content.toString("utf8") === "" ? undefined : content, options.shape);
|
|
1231
1415
|
if (projected.missed) {
|
|
1232
|
-
return emitTransportResult({ status: "ok", artifactId: id, sha256: artifact.sha256, ...artifactProjectionMetadata(content),
|
|
1416
|
+
return emitTransportResult({ status: "ok", artifactId: id, sha256: artifact.sha256, ...artifactProjectionMetadata(content), ...artifactMissEntry(options.shape, projected, content, id, explainMiss), unanswered: true, ...(explainMiss && projected.unsupportedSyntax !== true ? { hint: artifactPathMissHint(projected.at, pathMissCopyableHint(content, options.shape, projected.at)) } : {}) }, transport);
|
|
1233
1417
|
}
|
|
1234
1418
|
return emitTransportResult({ status: "ok", artifactId: id, sha256: artifact.sha256, bytes: artifact.content.length, path: options.shape, depth, shape: shapeOf(projected.content, depth), fetch: artifactFetchHint(id) }, transport);
|
|
1235
1419
|
}
|
|
@@ -1272,7 +1456,10 @@ async function cmdArtifactGet(id, transport, options = {}) {
|
|
|
1272
1456
|
// 一层 `projection:{path,content}`——`artifact get --jq` 与 `--summary --jq`
|
|
1273
1457
|
// 因此同形(顶层 path/content),换读面不用重新探根键。
|
|
1274
1458
|
return emitTransportResult(projected.missed
|
|
1275
|
-
?
|
|
1459
|
+
? (() => {
|
|
1460
|
+
const miss = artifactMissEntry(options.jq, projected, content, id, explainMiss);
|
|
1461
|
+
return { status: "ok", artifactId: id, sha256: artifact.sha256, bytes: artifact.content.length, ...artifactProjectionMetadata(content), keys, ...miss, projections: [miss], unanswered: true, ...(explainMiss && projected.unsupportedSyntax !== true ? { hint: artifactPathMissHint(projected.at, pathMissCopyableHint(content, options.jq, projected.at)) } : {}) };
|
|
1462
|
+
})()
|
|
1276
1463
|
: {
|
|
1277
1464
|
status: "ok",
|
|
1278
1465
|
artifactId: id,
|
|
@@ -1325,14 +1512,14 @@ async function cmdArtifactGet(id, transport, options = {}) {
|
|
|
1325
1512
|
const projections = jqPaths.map((path) => {
|
|
1326
1513
|
const projected = projectArtifactPath(artifactContent, path);
|
|
1327
1514
|
return projected.missed
|
|
1328
|
-
?
|
|
1515
|
+
? artifactMissEntry(path, projected, artifactContent, id, explainMiss)
|
|
1329
1516
|
: { path, content: projected.content ?? null, ...(projected.mapped !== undefined ? { mapped: projected.mapped } : {}), ...(projected.missedEntries !== undefined ? { missedEntries: projected.missedEntries } : {}), ...(projected.nullEntries !== undefined && projected.nullEntries > 0 ? { nullEntries: projected.nullEntries } : {}), ...(projected.nonNullEntries !== undefined ? { nonNullEntries: projected.nonNullEntries } : {}), ...(artifactNullHint(projected.content, projected.nullEntries) !== undefined ? { hint: artifactNullHint(projected.content, projected.nullEntries) } : {}) };
|
|
1330
1517
|
});
|
|
1331
1518
|
return emitTransportResult({ status: "ok", artifactId: id, sha256: artifact.sha256, ...artifactProjectionMetadata(content), projections, ...(projections.some((entry) => entry.pathMiss) ? { unanswered: true, hint: partialPathMissHint() } : {}) }, transport);
|
|
1332
1519
|
}
|
|
1333
1520
|
const projected = projectArtifactPath(artifactContent, options.jq);
|
|
1334
1521
|
return emitTransportResult(projected.missed
|
|
1335
|
-
? { status: "ok", artifactId: id, sha256: artifact.sha256, ...artifactProjectionMetadata(content),
|
|
1522
|
+
? { status: "ok", artifactId: id, sha256: artifact.sha256, ...artifactProjectionMetadata(content), ...artifactMissEntry(options.jq, projected, artifactContent, id, explainMiss), unanswered: true, ...(explainMiss && projected.unsupportedSyntax !== true ? { hint: artifactPathMissHint(projected.at, pathMissCopyableHint(artifactContent, options.jq, projected.at)) } : {}) }
|
|
1336
1523
|
: { status: "ok", artifactId: id, sha256: artifact.sha256, ...artifactProjectionMetadata(content), path: options.jq, projections: [{ path: options.jq, content: projected.content ?? null, ...(projected.mapped !== undefined ? { mapped: projected.mapped } : {}), ...(projected.missedEntries !== undefined ? { missedEntries: projected.missedEntries } : {}), ...(projected.nullEntries !== undefined && projected.nullEntries > 0 ? { nullEntries: projected.nullEntries } : {}), ...(projected.nonNullEntries !== undefined ? { nonNullEntries: projected.nonNullEntries } : {}) }], ...(projected.mapped !== undefined ? { mapped: projected.mapped } : {}), ...(projected.missedEntries !== undefined ? { missedEntries: projected.missedEntries } : {}), ...(projected.nullEntries !== undefined && projected.nullEntries > 0 ? { nullEntries: projected.nullEntries } : {}), ...(projected.nonNullEntries !== undefined ? { nonNullEntries: projected.nonNullEntries } : {}), ...(artifactNullHint(projected.content, projected.nullEntries) !== undefined ? { hint: artifactNullHint(projected.content, projected.nullEntries) } : {}) }, transport);
|
|
1337
1524
|
}
|
|
1338
1525
|
// r6-onboarding 2026-10-21: 47 artifact fetches, 0 used a projection; the 10
|
|
@@ -1461,7 +1648,7 @@ async function cmdBench(args) {
|
|
|
1461
1648
|
return failedSteps === 0 && dims.intent.passed === dims.intent.cases ? 0 : 1;
|
|
1462
1649
|
}
|
|
1463
1650
|
/** r29f F8:discovery 面复用同一投影层(相对本命令 result,不是 call 信封)。 */
|
|
1464
|
-
function emitProjectedResult(result, transport, jq) {
|
|
1651
|
+
function emitProjectedResult(result, transport, jq, explain = false) {
|
|
1465
1652
|
const raw = Array.isArray(jq) ? jq : jq === undefined ? [] : [jq];
|
|
1466
1653
|
const keysOnly = raw.some((entry) => entry === true) || (raw.length === 0 && jq === true);
|
|
1467
1654
|
const paths = raw
|
|
@@ -1471,7 +1658,7 @@ function emitProjectedResult(result, transport, jq) {
|
|
|
1471
1658
|
.filter(Boolean);
|
|
1472
1659
|
if (paths.length === 0 && !keysOnly)
|
|
1473
1660
|
return emitTransportResult(result, transport);
|
|
1474
|
-
const projected = projectResultExtract(result, paths, keysOnly);
|
|
1661
|
+
const projected = projectResultExtract(result, paths, keysOnly, undefined, explain);
|
|
1475
1662
|
return emitTransportResult(projected ?? result, transport);
|
|
1476
1663
|
}
|
|
1477
1664
|
function enrichDescribeParamMiss(registry, toolName, param, miss) {
|
|
@@ -1645,7 +1832,7 @@ function cmdDiscovery(kind, transport, value, options = {}) {
|
|
|
1645
1832
|
const available = capabilityRouteIndex(registry).routes.map((route) => route.id).join("、");
|
|
1646
1833
|
return emitInvalid(transport, { message: `未知 capability "${options.capability}";合法取值:${available}(清单见 omc capabilities)` });
|
|
1647
1834
|
}
|
|
1648
|
-
return emitProjectedResult({ status: "ok", ...slice }, transport, options.jq);
|
|
1835
|
+
return emitProjectedResult({ status: "ok", ...slice }, transport, options.jq, options.explain === true);
|
|
1649
1836
|
}
|
|
1650
1837
|
const scoped = options.filter !== undefined || options.lane !== undefined || kindFilter !== undefined || pagingActive;
|
|
1651
1838
|
// Bare `commands` is the bounded index (see commandIndex): the full 54 KB
|
|
@@ -1653,13 +1840,13 @@ function cmdDiscovery(kind, transport, value, options = {}) {
|
|
|
1653
1840
|
// agent paid 4×54 KB on the default face before any hint could land).
|
|
1654
1841
|
if (options.json !== true && options.compact !== true && !scoped) {
|
|
1655
1842
|
result = commandIndex(registry);
|
|
1656
|
-
return emitProjectedResult({ status: "ok", ...result }, transport, options.jq);
|
|
1843
|
+
return emitProjectedResult({ status: "ok", ...result }, transport, options.jq, options.explain === true);
|
|
1657
1844
|
}
|
|
1658
1845
|
// issue 03:`commands --kind read` 的默认面是索引(能力 → 工具+必填参数),
|
|
1659
1846
|
// 与裸 `commands` 同判例——完整行是一步 `--json`。一次 2.6KB 列全 65 个
|
|
1660
1847
|
// 读工具,替代 7 轮 --filter 试词(≈21.7KB)。
|
|
1661
1848
|
if (kindFilter !== undefined && options.json !== true && options.compact !== true && options.filter === undefined && options.lane === undefined && !pagingActive) {
|
|
1662
|
-
return emitProjectedResult({ status: "ok", ...commandKindIndex(registry, kindFilter) }, transport, options.jq);
|
|
1849
|
+
return emitProjectedResult({ status: "ok", ...commandKindIndex(registry, kindFilter) }, transport, options.jq, options.explain === true);
|
|
1663
1850
|
}
|
|
1664
1851
|
const inventory = commandInventory(registry, { compact: options.compact === true });
|
|
1665
1852
|
// r19 ticket 05: above this many hits a filter word is "broad" — the filtered
|
|
@@ -1936,7 +2123,7 @@ function cmdDiscovery(kind, transport, value, options = {}) {
|
|
|
1936
2123
|
const textNote = byText.length > 0 ? `;didYouMeanByText: ${byText.join("、")}` : "";
|
|
1937
2124
|
return emitInvalid(transport, { message: `${kind} target not found: "${requested}"${shown.length > 0 ? `; did you mean: ${shown.join("、")}` : ""}${textNote}${absence}${approvalPointer}${intentPointer}${formPointer}${pointer}` });
|
|
1938
2125
|
}
|
|
1939
|
-
return emitProjectedResult({ status: "ok", ...result }, transport, options.jq);
|
|
2126
|
+
return emitProjectedResult({ status: "ok", ...result }, transport, options.jq, options.explain === true);
|
|
1940
2127
|
}
|
|
1941
2128
|
function cmdUsage(transport, options = {}) {
|
|
1942
2129
|
return emitTransportResult(usageReport(undefined, { records: options.records === true, top: options.top, resolveLikeWriter: true }), transport);
|
|
@@ -2065,11 +2252,11 @@ async function cmdPlan(goal, options, transport) {
|
|
|
2065
2252
|
* capability overview. Read-only, zero environment contact; a projection of
|
|
2066
2253
|
* the tool registry, the coverage manifest, and the intent capability registry.
|
|
2067
2254
|
*/
|
|
2068
|
-
function cmdCapabilities(transport, options = {}, jq) {
|
|
2255
|
+
function cmdCapabilities(transport, options = {}, jq, explain = false) {
|
|
2069
2256
|
const result = compactCapabilities(buildToolRegistry(), options);
|
|
2070
|
-
return emitProjectedResult({ status: "ok", ...result }, transport, jq);
|
|
2257
|
+
return emitProjectedResult({ status: "ok", ...result }, transport, jq, explain);
|
|
2071
2258
|
}
|
|
2072
|
-
function cmdCapability(id, transport, executable = false, jq) {
|
|
2259
|
+
function cmdCapability(id, transport, executable = false, jq, explain = false) {
|
|
2073
2260
|
const registry = buildToolRegistry();
|
|
2074
2261
|
const resolved = resolveCapabilityId(id);
|
|
2075
2262
|
if (!resolved) {
|
|
@@ -2080,7 +2267,7 @@ function cmdCapability(id, transport, executable = false, jq) {
|
|
|
2080
2267
|
const bundle = executableCapabilityBundle(registry, resolved);
|
|
2081
2268
|
if (!bundle)
|
|
2082
2269
|
return emitInvalid(transport, { message: `capability "${id}" 没有可执行 bundle` });
|
|
2083
|
-
return emitProjectedResult({ status: "ok", capability: bundle }, transport, jq);
|
|
2270
|
+
return emitProjectedResult({ status: "ok", capability: bundle }, transport, jq, explain);
|
|
2084
2271
|
}
|
|
2085
2272
|
const detail = capabilityDetail(registry, resolved);
|
|
2086
2273
|
if (!detail)
|
|
@@ -2093,7 +2280,7 @@ function cmdCapability(id, transport, executable = false, jq) {
|
|
|
2093
2280
|
...detail,
|
|
2094
2281
|
...(appScopeMatrix !== undefined ? { appScopeArgs: appScopeMatrix } : {}),
|
|
2095
2282
|
},
|
|
2096
|
-
}, transport, jq);
|
|
2283
|
+
}, transport, jq, explain);
|
|
2097
2284
|
}
|
|
2098
2285
|
/**
|
|
2099
2286
|
* r29a F4:跨 app/folder/model/rule 的「工具 → 应用参数名(主/别名)」小表。
|
|
@@ -2242,23 +2429,37 @@ async function cmdIntentReadback(file, environment, transport) {
|
|
|
2242
2429
|
* registry or `commands --json`. Results are candidate pointers only — plan /
|
|
2243
2430
|
* apply / readback keep reading the live baseline.
|
|
2244
2431
|
*/
|
|
2245
|
-
async function cmdGraphPull(environment, concurrency, transport, path, applicationCodes, allApplications = false) {
|
|
2432
|
+
async function cmdGraphPull(environment, concurrency, transport, path, applicationCodes, allApplications = false, timeoutMs) {
|
|
2246
2433
|
const workers = concurrency ?? DEFAULT_PULL_CONCURRENCY;
|
|
2247
2434
|
if (!Number.isSafeInteger(workers) || workers < 1 || workers > MAX_PULL_CONCURRENCY)
|
|
2248
2435
|
return emitInvalid(transport, { message: `--concurrency 必须是 1–${MAX_PULL_CONCURRENCY} 的整数(平台负载有界;默认 ${DEFAULT_PULL_CONCURRENCY})` });
|
|
2249
2436
|
const context = makeToolContext({ sessions: new SessionManager(new ConfigStore(defaultPaths())) });
|
|
2437
|
+
// B4:总超时(默认 120s,--timeout-ms 覆盖)。进度行只走 stderr——stdout 仍是
|
|
2438
|
+
// 一个信封;agent 不必靠轮询索引文件大小猜进度。
|
|
2439
|
+
const totalTimeoutMs = timeoutMs ?? DEFAULT_GRAPH_PULL_TIMEOUT_MS;
|
|
2440
|
+
if (!Number.isSafeInteger(totalTimeoutMs) || totalTimeoutMs < 1 || totalTimeoutMs > MAX_GRAPH_PULL_TIMEOUT_MS)
|
|
2441
|
+
return emitInvalid(transport, { message: `--timeout-ms 必须是 1–${MAX_GRAPH_PULL_TIMEOUT_MS} 的整数(毫秒;默认 ${DEFAULT_GRAPH_PULL_TIMEOUT_MS})` });
|
|
2442
|
+
const progress = (line) => { process.stderr.write(`${line}\n`); };
|
|
2250
2443
|
try {
|
|
2251
2444
|
const session = await context.sessions.session(environment);
|
|
2252
2445
|
let selected = applicationCodes;
|
|
2253
2446
|
if (allApplications) {
|
|
2447
|
+
progress("[graph] listing tenant applications");
|
|
2254
2448
|
const apps = (await wireCall(session, { path: ENDPOINTS.applicationList, query: {} })).data;
|
|
2255
2449
|
const rows = Array.isArray(apps) ? apps : (apps && typeof apps === "object" && Array.isArray(apps.data) ? apps.data : []);
|
|
2256
2450
|
selected = rows.map((row) => String(row.appCode ?? row.code ?? "")).filter(Boolean);
|
|
2451
|
+
const listed = selected;
|
|
2452
|
+
progress(`[graph] tenant applications=${listed.length}${listed.length > 0 ? ` codes=${listed.join(",")}` : ""}`);
|
|
2257
2453
|
}
|
|
2258
|
-
const data = await publishGraphPull(session, workers, {
|
|
2454
|
+
const data = await publishGraphPull(session, workers, {
|
|
2455
|
+
...(selected ? { applicationCodes: selected } : {}),
|
|
2456
|
+
timeoutMs: totalTimeoutMs,
|
|
2457
|
+
progress,
|
|
2458
|
+
});
|
|
2259
2459
|
// issue#9 C4:扫到 0 模型仍回 ok,让调用者误以为索引就绪(随后 search 报
|
|
2260
2460
|
// graph-index-absent 才发现)。0 模型 fail-fast,点名 env/applicationCode
|
|
2261
2461
|
// 与解析来源,把「索引没建成」和「建成了但为空」分开。
|
|
2462
|
+
const failedApps = data.failedApps ?? [];
|
|
2262
2463
|
if (data.scanned.models === 0) {
|
|
2263
2464
|
const resolution = data.meta.applicationResolution;
|
|
2264
2465
|
return emitResult({
|
|
@@ -2267,7 +2468,8 @@ async function cmdGraphPull(environment, concurrency, transport, path, applicati
|
|
|
2267
2468
|
environment: data.meta.environmentName,
|
|
2268
2469
|
applicationCode: data.meta.applicationCode,
|
|
2269
2470
|
applicationResolution: resolution,
|
|
2270
|
-
|
|
2471
|
+
...(failedApps.length > 0 ? { failedApps, failedAppsCount: failedApps.length } : {}),
|
|
2472
|
+
message: `graph pull 解析到应用 ${data.meta.applicationCode ?? "?"}(来源:${resolution?.source ?? "unknown"}${resolution?.applicationCount !== undefined ? `,租户共 ${resolution.applicationCount} 个应用` : ""})后扫描到 0 个模型——索引未建立,graph search/references 会持续 graph-index-absent。检查:①应用里确实有模型?②applicationCode 配置是否指向了空应用(omc setup 里的 应用= 字段);③多应用租户须显式指定(graph pull --env <env> 的环境配置里写对 applicationCode)。${failedApps.length > 0 ? `另有 ${failedApps.length} 个应用读取失败(见 failedApps[])。` : ""}`,
|
|
2271
2473
|
nextCommand: `omc setup --list`,
|
|
2272
2474
|
}, transport);
|
|
2273
2475
|
}
|
|
@@ -2278,7 +2480,20 @@ async function cmdGraphPull(environment, concurrency, transport, path, applicati
|
|
|
2278
2480
|
for (const gap of data.gaps)
|
|
2279
2481
|
gapsByKind[gap.kind] = (gapsByKind[gap.kind] ?? 0) + 1;
|
|
2280
2482
|
return emitResult({
|
|
2281
|
-
|
|
2483
|
+
// B4:单应用失败不整轮静默——索引已发布(覆盖成功应用),但退出码非 0
|
|
2484
|
+
// (partial → exit 1),failedApps[] 逐条点名;`indexStillUsable` 明说
|
|
2485
|
+
// 已成功部分仍可查,避免被读成「整轮白跑」。
|
|
2486
|
+
status: failedApps.length > 0 ? "partial" : "ok",
|
|
2487
|
+
...(failedApps.length > 0
|
|
2488
|
+
? {
|
|
2489
|
+
blocker: "graph-pull-partial-applications",
|
|
2490
|
+
message: `graph pull 完成但 ${failedApps.length}/${data.meta.coverage.applicationCodes.length + failedApps.length} 个应用失败(见 failedApps[]);已成功的应用已写入索引,graph references/impact/search 仍可查这些应用,失败应用的引用不会被回答。`,
|
|
2491
|
+
indexStillUsable: true,
|
|
2492
|
+
failedApps,
|
|
2493
|
+
failedAppsCount: failedApps.length,
|
|
2494
|
+
nextCommand: `omc graph pull --env ${data.meta.environmentName} --application-codes ${failedApps.map((entry) => entry.applicationCode).join(",")}`,
|
|
2495
|
+
}
|
|
2496
|
+
: {}),
|
|
2282
2497
|
environment: data.meta.environmentName,
|
|
2283
2498
|
applicationCode: data.meta.applicationCode,
|
|
2284
2499
|
// The index covers ONE application. Echo where it came from, so a
|
|
@@ -2306,8 +2521,36 @@ async function cmdGraphPull(environment, concurrency, transport, path, applicati
|
|
|
2306
2521
|
catch (error) {
|
|
2307
2522
|
if (error instanceof GraphPullLockHeldError)
|
|
2308
2523
|
return emitResult({ status: "refused", blocker: "graph-pull-lock-held", message: error.message, nextCommand: "omc graph status" }, transport);
|
|
2309
|
-
if (error instanceof
|
|
2310
|
-
|
|
2524
|
+
if (error instanceof GraphPullTimeoutError) {
|
|
2525
|
+
// B4:总超时不是「静默空转」——明确 blocker + 已拉数量 + 恢复指引;
|
|
2526
|
+
// 索引未发布(lock/staging 已清理),退出码非 0(refused → 12)。
|
|
2527
|
+
return emitResult({
|
|
2528
|
+
status: "refused",
|
|
2529
|
+
blocker: "graph-pull-timeout",
|
|
2530
|
+
environment: environment ?? null,
|
|
2531
|
+
elapsedMs: error.elapsedMs,
|
|
2532
|
+
timeoutMs: error.timeoutMs,
|
|
2533
|
+
pulled: {
|
|
2534
|
+
applicationsDone: error.progressSnapshot.applicationsDone,
|
|
2535
|
+
applicationsTotal: error.progressSnapshot.applicationsTotal,
|
|
2536
|
+
...(error.progressSnapshot.currentApplication !== undefined ? { currentApplication: error.progressSnapshot.currentApplication } : {}),
|
|
2537
|
+
},
|
|
2538
|
+
indexPublished: false,
|
|
2539
|
+
message: `${error.message} 进度行在 stderr([graph] n/N app=…);不要靠轮询索引文件判断进度。`,
|
|
2540
|
+
nextCommand: `omc graph pull --env ${environment ?? "<env>"} --application-codes <a,b>`,
|
|
2541
|
+
}, transport);
|
|
2542
|
+
}
|
|
2543
|
+
if (error instanceof WireError || isUncertainWireError(error)) {
|
|
2544
|
+
const facts = describeWireFailure(error);
|
|
2545
|
+
return emitResult({
|
|
2546
|
+
status: "uncertain",
|
|
2547
|
+
reason: "wire-transport",
|
|
2548
|
+
message: `graph pull 中断(${error instanceof Error ? error.message : String(error)});索引未发布,重跑 omc graph pull --env <env>`,
|
|
2549
|
+
...(facts.endpoint !== undefined ? { endpoint: facts.endpoint } : {}),
|
|
2550
|
+
lastFailureKind: facts.failureKind,
|
|
2551
|
+
...(facts.causeCode !== undefined ? { lastFailureCause: facts.causeCode } : {}),
|
|
2552
|
+
}, transport);
|
|
2553
|
+
}
|
|
2311
2554
|
return emitThrown(error, transport);
|
|
2312
2555
|
}
|
|
2313
2556
|
}
|
|
@@ -2603,8 +2846,20 @@ function shellQuote(value) {
|
|
|
2603
2846
|
console.error("用法:omc help <topic> | omc help --topic <name> | omc help --search \"<词>\"(跨 topic 检索,命中节正文随结果返回)");
|
|
2604
2847
|
console.error("权威路线:omc help omc-start-here(随包 skills/,不是分发镜像)");
|
|
2605
2848
|
console.error("环境就绪:omc call discover_environment --env <env> --args '{}'");
|
|
2849
|
+
// C5(0.8.4,issue 2026-11-25):--utf8 之前只藏在 omc-start-here 正文里,
|
|
2850
|
+
// `omc help` 面看不到。一行说清三件事:--utf8 只管人类诊断文本、stdout 的
|
|
2851
|
+
// JSON 信封仍保持 \uXXXX 转义(任何代码页都能解析)、--out 落盘始终 UTF-8。
|
|
2852
|
+
console.error("编码:--utf8 让人类诊断/散文(stderr)按 UTF-8 原文输出;stdout 的 JSON 信封仍保持 \\uXXXX 转义(任何代码页都可 JSON.parse)。--out <path> 落盘始终是 UTF-8 原文——读面要中文明文又不想改控制台,就用 --out。Windows 还想在控制台看中文:chcp 65001 + [Console]::OutputEncoding=[Text.Encoding]::UTF8。(需 Windows 真机验证)");
|
|
2606
2853
|
console.error(`命令:${commands.join("、")}`);
|
|
2607
2854
|
console.error(`方法论 topic:${topics.map((entry) => entry.name).join("、")}`);
|
|
2855
|
+
// 仅在「管道 + 非 UTF-8 代码页」自动判定成立且未显式关转义时,补一次
|
|
2856
|
+
// 机器可读的英文提示(stderr 本身在 ascii 模式也被转义,故用纯 ASCII)。
|
|
2857
|
+
if (process.env.OMC_UTF8_HINT === "1" && asciiStdout() && !humanUtf8()) {
|
|
2858
|
+
console.error("[omc] legacy console code page + pipe detected: the JSON envelope stays \\u-escaped (parseable in any code page).\n"
|
|
2859
|
+
+ " --utf8 de-escapes HUMAN diagnostics only (stderr); it never changes the envelope.\n"
|
|
2860
|
+
+ " --out <path> always writes raw UTF-8, so read the file instead of the pipe when you need readable Chinese.\n"
|
|
2861
|
+
+ " For readable console output: chcp 65001 (then read stdout as UTF-8). [needs Windows live verification]");
|
|
2862
|
+
}
|
|
2608
2863
|
return emitTransportResult({
|
|
2609
2864
|
status: "ok",
|
|
2610
2865
|
usage: "omc help <topic> | omc help --topic <name>",
|
|
@@ -3192,7 +3447,21 @@ async function main() {
|
|
|
3192
3447
|
commandExitCode = CLI_EXIT_CODES.invalidInput;
|
|
3193
3448
|
return;
|
|
3194
3449
|
}
|
|
3195
|
-
const
|
|
3450
|
+
const visibleEnvironments = store.listEnvironments();
|
|
3451
|
+
const allEnvironments = store.listEnvironments({ all: true });
|
|
3452
|
+
const hiddenEnvironmentCount = Math.max(0, allEnvironments.length - visibleEnvironments.length);
|
|
3453
|
+
const rows = visibleEnvironments.map((item) => ({ name: item.name, baseUrl: item.profile.baseUrl, applicationCode: item.profile.applicationCode, isDefault: item.profile.isDefault === true, writable: item.profile.writable !== false, credential: store.hasCredential(item.name) ? "ok" : "missing" }));
|
|
3454
|
+
// C8(0.8.4):env 清单是 **cwd 相关**的(项目 .omc-env/.omc-envs 决定可见集)。
|
|
3455
|
+
// 从用户目录跑只看到 default 时,输出必须自己说清「这不是全部」——真机会话据此
|
|
3456
|
+
// 误判过"只有 1 个环境"两次。全可见时不加任何键(输出形状保持不变)。
|
|
3457
|
+
const scopeNote = hiddenEnvironmentCount > 0
|
|
3458
|
+
? {
|
|
3459
|
+
scope: "project",
|
|
3460
|
+
visible: rows.length,
|
|
3461
|
+
total: allEnvironments.length,
|
|
3462
|
+
hint: `当前只列到本项目可见的 ${rows.length} 个环境(配置里共 ${allEnvironments.length} 个):清单随 cwd 变——在含 .omc-env/.omc-envs 的仓库根运行才会列出全部;换目录会换集合。明细:omc env list --json`,
|
|
3463
|
+
}
|
|
3464
|
+
: undefined;
|
|
3196
3465
|
// issue 2026-11 F5:清单来源(配置根 + 项目根)不回显时,同一条命令在不同
|
|
3197
3466
|
// cwd 语义不同、且会静默落到机器全局 default——真机会话因此白打错环境。
|
|
3198
3467
|
const paths = store.configPaths;
|
|
@@ -3200,7 +3469,7 @@ async function main() {
|
|
|
3200
3469
|
const projectRoot = dirname(paths.projectEnvPath);
|
|
3201
3470
|
const binding = { configRoot, projectRoot, bindingFiles: { ".omc-env": paths.projectEnvPath, ".omc-envs": paths.projectEnvsPath }, note: "环境集合由「项目根」的 .omc-env/.omc-envs + 配置根的 omc.config.json 共同决定;换目录会换集合" };
|
|
3202
3471
|
if (options.json)
|
|
3203
|
-
process.stdout.write(JSON.stringify({ ok: true, configRoot, projectRoot, environments: rows, binding }, null, 2) + "\n");
|
|
3472
|
+
process.stdout.write(JSON.stringify({ ok: true, configRoot, projectRoot, environments: rows, binding, ...(scopeNote ?? {}) }, null, 2) + "\n");
|
|
3204
3473
|
else if (rows.length === 0)
|
|
3205
3474
|
console.error(`(none configured; run omc setup)\n配置根:${configRoot}\n项目根:${projectRoot}`);
|
|
3206
3475
|
// A5(GitLab #15):credential: missing 的环境列得出、调不通(auth-config)——
|
|
@@ -3213,13 +3482,15 @@ async function main() {
|
|
|
3213
3482
|
// 700+ 字符坏 3 次——正道 `env export` 在所有 skill/文档里零露出。列环境时顺手
|
|
3214
3483
|
// 指路(CLI 自更新直达存量项目,比 AGENTS.md 重装传播可靠)。
|
|
3215
3484
|
console.error(`联调/token/headers 一律走 omc env export --env <env> --example curl|node(CLI 自己登录;凭据只从这条取)`);
|
|
3485
|
+
if (scopeNote !== undefined)
|
|
3486
|
+
console.error(scopeNote.hint);
|
|
3216
3487
|
}
|
|
3217
3488
|
commandExitCode = CLI_EXIT_CODES.ok;
|
|
3218
3489
|
});
|
|
3219
|
-
command.command("doctor").option("--environment <environment>").option("--env <environment>").option("--service <serviceCode>", "可选:体检单个业务集成服务的鉴权参数形状(掩码/占位/全 0 检出,WARN 非致命)").option("--fresh-login", "忽略 token 缓存,做一次完整登录握手(默认复用缓存,登录请求 0 次;回执 loginSource 标明来源)").action(async (options) => { commandExitCode = await cmdDoctor(new ConfigStore(defaultPaths()), options.environment ?? options.env, options.service, options.freshLogin === true); });
|
|
3220
|
-
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("--reason <text>", "写入原因(审计面,仅写操作):记入本次写 journal 行的 reason;不是工具参数(写 schema 拒未知键),也不参与任何门禁").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) => {
|
|
3490
|
+
command.command("doctor").option("--environment <environment>").option("--env <environment>").option("--service <serviceCode>", "可选:体检单个业务集成服务的鉴权参数形状(掩码/占位/全 0 检出,WARN 非致命)").option("--fresh-login", "忽略 token 缓存,做一次完整登录握手(默认复用缓存,登录请求 0 次;回执 loginSource 标明来源)").addOption(new Option("--jq [path]", "--jq 不是 jq,仅路径选择器(与 call --jq 同 DSL;可逗号多路径;裸 --jq 列顶层键),相对回执 result(checks/anchor/unsupportedCapabilities)").argParser((value, previous = []) => [...previous, value]).default([])).option("--explain", "--jq 未命中时给出完整排查载荷(available/correctPath/成因 hint);默认 miss 只回 missedAt/didYouMean/helpRef").action(async (options) => { commandExitCode = await cmdDoctor(new ConfigStore(defaultPaths()), options.environment ?? options.env, options.service, options.freshLogin === true, Array.isArray(options.jq) ? options.jq : [], options.explain === true); });
|
|
3491
|
+
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("--reason <text>", "写入原因(审计面,仅写操作):记入本次写 journal 行的 reason;不是工具参数(写 schema 拒未知键),也不参与任何门禁").option("--timeout-ms <milliseconds>").option("--wait <milliseconds>", "仅 `omc call` / `omc intent apply` 支持;写锁冲突时有界排队(0=立刻拒绝)").option("--dry-run").option("--explain", "--jq 未命中时给出完整排查载荷(available 该层全部键、correctPath、nextCommand、成因 hint);默认 miss 只回 missedAt/didYouMean/helpRef(≤300B)").addHelpText("after", `\n${onboardingHelp()}\n`).action(async (tool, options) => {
|
|
3221
3492
|
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"] : []),
|
|
3222
|
-
...(options.keys ? ["--keys"] : []), ...(options.maxOutputBytes !== undefined ? ["--max-output-bytes", options.maxOutputBytes] : []), ...(options.requestId ? ["--request-id", options.requestId] : []), ...(options.reason !== undefined ? ["--reason", options.reason] : []), ...(options.timeoutMs !== undefined ? ["--timeout-ms", options.timeoutMs] : []), ...(options.wait !== undefined ? ["--wait", options.wait] : []), ...(options.dryRun ? ["--dry-run"] : [])];
|
|
3493
|
+
...(options.keys ? ["--keys"] : []), ...(options.maxOutputBytes !== undefined ? ["--max-output-bytes", options.maxOutputBytes] : []), ...(options.requestId ? ["--request-id", options.requestId] : []), ...(options.reason !== undefined ? ["--reason", options.reason] : []), ...(options.timeoutMs !== undefined ? ["--timeout-ms", options.timeoutMs] : []), ...(options.wait !== undefined ? ["--wait", options.wait] : []), ...(options.dryRun ? ["--dry-run"] : []), ...(options.explain ? ["--explain"] : [])];
|
|
3223
3494
|
commandExitCode = await cmdCall(new ConfigStore(defaultPaths()), rest);
|
|
3224
3495
|
});
|
|
3225
3496
|
command.command("compute").option("--schema <schemaCode>").option("--schema-code <schemaCode>").option("--target <propertyCode>").option("--property <propertyCode>").option("--formula <formula>").option("--where <condition>", "条件聚合:\"<子列code> = <值>\",与 --formula \"{<子表code>.<子列code>}\" 配合编译为 COUNTIF/SUMIF").option("--aggregate <count|sum>", "条件聚合用哪种:count(默认,→COUNTIF)/ sum(→SUMIF)").option("--allow-unfiltered", "显式接受「对整个子表列无条件聚合」;不给则拒绝(会把不符合条件的行也算进去)").option("--name <name>").option("--env <environment>").option("--environment <environment>").option("--apply").addHelpText("after", "\n字段计算规则拼装器:公式 {字段} 引用 → datarule type2 完整形状(editorText/editorMark 自动生成)。默认 dry-run,--apply 写入。条件聚合用 --formula \"{子表.子列}\" --where \"子列 = 值\"。复杂场景(条件分支/跨模型)走 omc next 的 recipe 路径。\n").action(async (options) => {
|
|
@@ -3534,7 +3805,7 @@ async function main() {
|
|
|
3534
3805
|
console.error(`已清理 ${result.removed} 个读回产物,释放 ${formatBytes(result.freedBytes)};保留 ${result.kept} 个(${formatBytes(result.keptBytes)})`);
|
|
3535
3806
|
commandExitCode = CLI_EXIT_CODES.ok;
|
|
3536
3807
|
});
|
|
3537
|
-
artifactCommand.command("get <id>").addOption(new Option("--jq [path]", "路径选择器(非 jq);支持 [] 映射与逗号多路径;裸 --jq 列顶层键").argParser((value, previous = []) => [...previous, value]).default([])).
|
|
3808
|
+
artifactCommand.command("get <id>").addOption(new Option("--jq [path]", "路径选择器(非 jq);支持 [] 映射与逗号多路径;裸 --jq 列顶层键").argParser((value, previous = []) => [...previous, value]).default([])).addOption(new Option("--extract <path>", "同 --jq(与 omc call 的 --extract 同名,省一次命名切换);可重复,与 --jq 等价合并(--jq 的路径在前)").argParser((value, previous = []) => [...previous, value]).default([])).option("--explain", "--jq/--shape 未命中时给出完整排查载荷(available 该层全部键、correctPath、nextCommand、成因 hint);默认 miss 只回 missedAt/didYouMean/helpRef").option("--path-only").option("--shape [path]", "回执形状先验:深度受限骨架(键/类型/数组长度/≤40 字符示例值),一次看全嵌套路径图再 --jq;裸 --shape = 整棵根,--shape <path> = 命中子树(同 --jq 的路径 DSL);与 >8KB 默认 outline 同一实现").option("--depth <n>", "骨架深度 1-4(默认 2;--shape 与 >8KB 默认 outline 消费)").option("--summary").option("--keys [a,b]").option("--meta", "只回元数据,不回正文").option("--full", "整包返回正文(默认:正文超过 8KB 时只回深度 2 骨架 outline,按需 --shape/--jq/--keys 定向取值)").option("--out <path>", "把 artifact 原始正文全量写到配置根内文件(0600;写文件不走 stdout 限额,大对象一次落盘备份;回执只给 {out,bytes,sha256} 不回正文。根内父目录自动创建;配置根外(含系统临时目录)拒绝,拒绝错误里带可用的根内示例路径。stdout 管道提取用两步:--out <根内路径> 后 cat 该文件——`--out -` 会破坏单信封契约,不支持)").option("--max-output-bytes <bytes>").action(async (id, options) => {
|
|
3538
3809
|
// A bare `--jq`/`--keys` is a key-inventory request, not a missing argument:
|
|
3539
3810
|
// commander's "argument missing" (invalid-input + retry) is a dead end the
|
|
3540
3811
|
// caller cannot fix without already knowing the flag takes a value (r11
|
|
@@ -3543,9 +3814,12 @@ async function main() {
|
|
|
3543
3814
|
// 重复 --jq 的多路径合并为逗号路径透传(r34c-F8:此前静默只留最后一个)。
|
|
3544
3815
|
// r73 #7:--out 在 configureOutput 之前被 extractArtifactGetOutFlag 截获
|
|
3545
3816
|
//(commander 永远收不到它),这里读的是 main() 截下的值。
|
|
3817
|
+
// C3(0.8.4):`--jq` 与 `--extract` 是**同一个**路径选择器的两个名字(call 面
|
|
3818
|
+
// 也是这么合并且不覆盖):按「--jq 在前、--extract 在后」合并;两者都可重复,
|
|
3819
|
+
// 逗号多路径照旧。此前 --extract 只收一个值(重复给会静默只剩最后一个)。
|
|
3546
3820
|
const jqPaths = [
|
|
3547
3821
|
...(Array.isArray(options.jq) ? options.jq.filter((v) => typeof v === "string") : []),
|
|
3548
|
-
...(typeof options.extract === "string" ? [options.extract] : []),
|
|
3822
|
+
...(Array.isArray(options.extract) ? options.extract.filter((v) => typeof v === "string") : typeof options.extract === "string" ? [options.extract] : []),
|
|
3549
3823
|
];
|
|
3550
3824
|
const bareJq = options.jq === true;
|
|
3551
3825
|
// r75:显式 --shape 优先于 --summary/--keys/--jq(形状先验在取值之前)。
|
|
@@ -3558,21 +3832,25 @@ async function main() {
|
|
|
3558
3832
|
...(depthValue !== undefined ? { depth: depthValue } : {}),
|
|
3559
3833
|
summary: options.summary === true || options.keys === true || bareJq,
|
|
3560
3834
|
meta: options.meta === true,
|
|
3561
|
-
pureKeys: (options.keys === true || bareJq) && options.summary !== true, ...(typeof options.keys === "string" ? { keys: options.keys } : {}), full: options.full === true, ...(artifactGetOutPath !== undefined ? { out: artifactGetOutPath } : {})
|
|
3835
|
+
pureKeys: (options.keys === true || bareJq) && options.summary !== true, ...(typeof options.keys === "string" ? { keys: options.keys } : {}), full: options.full === true, explain: options.explain === true, ...(artifactGetOutPath !== undefined ? { out: artifactGetOutPath } : {})
|
|
3562
3836
|
}));
|
|
3563
3837
|
});
|
|
3564
3838
|
command.command("bench").option("--live-sample").option("--env <environment>").action(async (options) => { commandExitCode = await cmdBench([...(options.liveSample ? ["--live-sample"] : []), ...(options.env ? ["--env", options.env] : [])]); });
|
|
3565
3839
|
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)); });
|
|
3566
3840
|
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)); });
|
|
3567
3841
|
const jqOption = () => new Option("--jq [path]", "--jq 不是 jq,仅路径选择器(与 call --jq 同 DSL;可逗号多路径;裸 --jq 列顶层键)").argParser((value, previous = []) => [...previous, value]).default([]);
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3842
|
+
// C6(0.8.4):--jq 的 miss 默认只回结论;排查载荷(available/correctPath/
|
|
3843
|
+
// 成因 hint)统一由 --explain 开关,call/artifact get/发现面同口径。
|
|
3844
|
+
const explainOption = () => new Option("--explain", "--jq 未命中时给出完整排查载荷(available 该层全部键、correctPath、nextCommand、成因 hint);默认 miss 只回 missedAt/didYouMean/helpRef");
|
|
3845
|
+
command.command("commands").description("路由索引(不是目录):工具计数+展开梯子;--kind read 一屏列全部只读工具与必填参数;--json 才是全量目录").option("--json").option("--compact").option("--inline", "commands --json 超过 32KiB 时仍内联").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()).addOption(explainOption()).action(async (options) => { commandExitCode = await withTransport(options, request, (transport) => cmdDiscovery("commands", transport, undefined, { json: options.json === true, compact: options.compact === true, inline: options.inline === 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 } : {}), explain: options.explain === true })); }); // C2(0.8.4):describe 是零环境接触的发现面,但 `--env` 是"人人都以为通用"的
|
|
3846
|
+
// flag——与 `next` 同处理:接受并忽略(不因反射性传参被 unknown option 打回)。
|
|
3847
|
+
command.command("describe <tool>").option("--env <environment>", "接受并忽略:describe 零环境接触(参数表与运行时无关)").option("--environment <environment>", "同 --env(接受并忽略)").option("--full").option("--cache-ok", "允许 --full 在同会话重复读时短路为 artifact 指针(默认每次回全文)").option("--schema-only").option("--param <name>").option("--example [id]").option("--max-output-bytes <bytes>").addOption(jqOption()).addOption(explainOption()).action(async (tool, options) => {
|
|
3848
|
+
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 } : {}), explain: options.explain === true }));
|
|
3571
3849
|
});
|
|
3572
|
-
command.command("contract <lane>").option("--full").option("--tool <name>").option("--max-output-bytes <bytes>").addOption(jqOption()).action(async (lane, options) => { commandExitCode = await withTransport(options, request, (transport) => cmdDiscovery("contract", transport, lane, { full: options.full === true, ...(options.tool ? { tool: options.tool } : {}), ...(options.jq !== undefined ? { jq: options.jq } : {}) })); });
|
|
3850
|
+
command.command("contract <lane>").option("--full").option("--tool <name>").option("--max-output-bytes <bytes>").addOption(jqOption()).addOption(explainOption()).action(async (lane, options) => { commandExitCode = await withTransport(options, request, (transport) => cmdDiscovery("contract", transport, lane, { full: options.full === true, ...(options.tool ? { tool: options.tool } : {}), ...(options.jq !== undefined ? { jq: options.jq } : {}), explain: options.explain === true })); });
|
|
3573
3851
|
// 2026-11-05 用户实测:`commands --json` 存在,于是大家自然写 `capabilities --json`
|
|
3574
3852
|
// ——旧实现报 `unknown option`(退出码 10)。输出本来就是 JSON 信封,接受它做兼容别名。
|
|
3575
|
-
command.command("capabilities").option("--compact").option("--full", "完整投影(id/标题/别名/工具/依赖)——默认只是能力索引").option("--json", "兼容别名:输出本就是 JSON 信封(与 commands --json 对齐)").option("--max-output-bytes <bytes>").addOption(jqOption()).action(async (options) => { commandExitCode = await withTransport(options, request, (transport) => cmdCapabilities(transport, { compact: options.compact === true, full: options.full === true }, options.jq)); });
|
|
3853
|
+
command.command("capabilities").option("--compact").option("--full", "完整投影(id/标题/别名/工具/依赖)——默认只是能力索引").option("--json", "兼容别名:输出本就是 JSON 信封(与 commands --json 对齐)").option("--max-output-bytes <bytes>").addOption(jqOption()).addOption(explainOption()).action(async (options) => { commandExitCode = await withTransport(options, request, (transport) => cmdCapabilities(transport, { compact: options.compact === true, full: options.full === true }, options.jq, options.explain === true)); });
|
|
3576
3854
|
// `--env` is accepted but ignored: `next` is a zero-environment-contact route
|
|
3577
3855
|
// solver, and a caller who reflexively passes `--env` should not be refused
|
|
3578
3856
|
// (round 15 dogfood: `next "<goal>" --env local` → unknown option, one round).
|
|
@@ -3592,8 +3870,8 @@ async function main() {
|
|
|
3592
3870
|
...(Number.isFinite(parsedTop) && parsedTop > 0 ? { top: parsedTop } : {}),
|
|
3593
3871
|
}));
|
|
3594
3872
|
});
|
|
3595
|
-
command.command("capability <id>").option("--executable").option("--max-output-bytes <bytes>").addOption(jqOption()).action(async (id, options) => {
|
|
3596
|
-
commandExitCode = await withTransport(options, request, (transport) => cmdCapability(id, transport, options.executable === true, options.jq));
|
|
3873
|
+
command.command("capability <id>").option("--executable").option("--max-output-bytes <bytes>").addOption(jqOption()).addOption(explainOption()).action(async (id, options) => {
|
|
3874
|
+
commandExitCode = await withTransport(options, request, (transport) => cmdCapability(id, transport, options.executable === true, options.jq, options.explain === true));
|
|
3597
3875
|
});
|
|
3598
3876
|
const intentCommand = command.command("intent").description("声明式意图面(Spec 107):intent.yaml → validate → plan → apply → readback。**intent/plan 文件必须位于配置根内**(与 --args-file 同规则:配置根外的文件一律拒绝,防携带凭据被收进会话产物;根外内容请先拷入或经 stdin)").addHelpText("after", "\n意图文件(validate/plan/readback 的 <file>)与 plan 产物(--plan-out)都解析到配置根内——配置根外一律 invalid-input(与 call --args-file 同规则)。\n");
|
|
3599
3877
|
intentCommand.command("schema").option("--example [id]").action((options) => { commandExitCode = cmdIntentSchema({ request, maxOutputBytes: CLI_DEFAULT_OUTPUT_BYTES }, typeof options.example === "string" ? options.example : undefined, options.example !== undefined); });
|
|
@@ -3635,12 +3913,13 @@ async function main() {
|
|
|
3635
3913
|
// ADR-0008: local derived rule-graph index — CLI management face, not a call
|
|
3636
3914
|
// tool (so it stays out of `commands --json`/coverage by construction).
|
|
3637
3915
|
const graphCommand = command.command("graph").description("本地派生规则图索引(ADR-0008)");
|
|
3638
|
-
graphCommand.command("pull").option("--env <environment>").option("--environment <environment>").option("--path <dir>").option("--application-codes <codes>").option("--all-applications").option("--concurrency <n>").option("--max-output-bytes <bytes>").action(async (options) => {
|
|
3916
|
+
graphCommand.command("pull").option("--env <environment>").option("--environment <environment>").option("--path <dir>").option("--application-codes <codes>").option("--all-applications").option("--concurrency <n>").option("--timeout-ms <milliseconds>", `总超时(默认 ${DEFAULT_GRAPH_PULL_TIMEOUT_MS};1–${MAX_GRAPH_PULL_TIMEOUT_MS})——超时回 graph-pull-timeout、非零退出、索引不发布`).option("--max-output-bytes <bytes>").addHelpText("after", "\n进度行走 stderr(每应用一行 `[graph] 3/13 app=xxx start|done|failed …`),stdout 仍是单个 JSON 信封;不要靠轮询索引文件大小判断进度。单应用失败进 failedApps[],已成功应用照常发布,退出码 1。\n").action(async (options) => {
|
|
3639
3917
|
const parsed = options.concurrency === undefined ? undefined : Number.parseInt(String(options.concurrency), 10);
|
|
3640
3918
|
if (options.path)
|
|
3641
3919
|
process.env.OMC_GRAPH_PATH = options.path;
|
|
3642
3920
|
const codes = options.applicationCodes ? String(options.applicationCodes).split(",").map((code) => code.trim()).filter(Boolean) : undefined;
|
|
3643
|
-
|
|
3921
|
+
const timeoutMs = options.timeoutMs === undefined ? undefined : Number(options.timeoutMs);
|
|
3922
|
+
commandExitCode = await withTransport(options, request, (transport) => cmdGraphPull(options.environment ?? options.env, parsed, transport, options.path, codes, options.allApplications === true, timeoutMs));
|
|
3644
3923
|
});
|
|
3645
3924
|
// Read-side selection is symmetric with `pull` (2026-11-13): every offline
|
|
3646
3925
|
// subcommand takes --path (which project root) and --env (which environment's
|