@stalfh233/omc-cli 0.8.21 → 0.8.24

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.
@@ -97,6 +97,155 @@ export const RESTFUL_AUTH_PARAMETER_DEFINITIONS = Object.freeze({
97
97
  { code: "oauth_path", name: "获取token地址", description: "", required: true },
98
98
  ]),
99
99
  });
100
+ /** 每个适配器在设计器里真实提供的鉴权(平台 adapter_config.authList 的离线基线)。 */
101
+ export const ADAPTER_BUILTIN_AUTH_CODES = Object.freeze({
102
+ RESTFUL: Object.freeze(["basic", "oauth_password", "oauth_client", "customer"]),
103
+ INTERNAL: Object.freeze(["basic", "oauth_password", "oauth_client", "customer"]),
104
+ SOAP: Object.freeze(["basic", "customer"]),
105
+ });
106
+ /**
107
+ * 鉴权参数从哪来(探针 P/Q 的根因:agent 知道 code,但不知道每个 value 该填什么)。
108
+ * 这是 CLI 的教学文案,不是平台契约;平台权威清单始终是 adapter_config.authList。
109
+ */
110
+ export const AUTH_PARAMETER_PROVENANCE = Object.freeze({
111
+ basic: Object.freeze({
112
+ username: "目标系统的账号(由对方系统提供,不是 CloudPivot 账号)",
113
+ password: "该账号的密码(由对方系统提供)",
114
+ }),
115
+ oauth_password: Object.freeze({
116
+ client_id: "目标系统 OAuth 应用注册后发放的客户端 ID",
117
+ client_secret: "同一 OAuth 应用的客户端密钥",
118
+ username: "资源所有者账号(目标系统里的用户,不是 CloudPivot 账号)",
119
+ password: "该资源所有者账号的密码",
120
+ oauth_path: "目标系统的 token 端点(如 https://host/oauth/token;平台用它换 Bearer token)",
121
+ }),
122
+ oauth_client: Object.freeze({
123
+ client_id: "目标系统 OAuth 应用注册后发放的客户端 ID",
124
+ client_secret: "同一 OAuth 应用的客户端密钥",
125
+ oauth_path: "目标系统的 token 端点(client_credentials 模式换 Bearer token 的地址)",
126
+ }),
127
+ customer: Object.freeze({}),
128
+ });
129
+ /** 平台 adapter_config 的 authList → Map(发现驱动的唯一来源;扩展鉴权也走这里)。 */
130
+ export function adapterAuthDefinitions(adapters, adapterCode) {
131
+ if (!Array.isArray(adapters))
132
+ return undefined;
133
+ const row = adapters.find((entry) => isRecord(entry) && entry.code === adapterCode);
134
+ if (!isRecord(row) || !isRecord(row.config) || !Array.isArray(row.config.authList))
135
+ return undefined;
136
+ const map = new Map();
137
+ for (const auth of row.config.authList) {
138
+ if (!isRecord(auth) || typeof auth.code !== "string" || !auth.code)
139
+ continue;
140
+ const parameters = Array.isArray(auth.parameterlist)
141
+ ? auth.parameterlist.flatMap((param) => isRecord(param) && typeof param.code === "string" && param.code
142
+ ? [{
143
+ code: param.code,
144
+ required: param.required !== false,
145
+ ...(typeof param.name === "string" ? { name: param.name } : {}),
146
+ ...(typeof param.description === "string" ? { description: param.description } : {}),
147
+ }]
148
+ : [])
149
+ : [];
150
+ map.set(auth.code, {
151
+ code: auth.code,
152
+ ...(typeof auth.name === "string" ? { name: auth.name } : {}),
153
+ ...(typeof auth.description === "string" ? { description: auth.description } : {}),
154
+ parameters,
155
+ });
156
+ }
157
+ return map;
158
+ }
159
+ /** 参数来源提示(只对内置 4 种有文案;扩展鉴权用平台 authList 的 name/description)。 */
160
+ export function authParameterProvenance(authCode, parameterCode) {
161
+ return AUTH_PARAMETER_PROVENANCE[authCode]?.[parameterCode];
162
+ }
163
+ function provenanceLine(authCode, parameterCode) {
164
+ const source = authParameterProvenance(authCode, parameterCode);
165
+ return source !== undefined ? `${parameterCode}=${source}` : parameterCode;
166
+ }
167
+ function validateAuthItems(adapterCode, auth, authCode, expected) {
168
+ if (!Array.isArray(auth.parameterlist))
169
+ refuse(BIZSERVICE_CONFIG_BLOCKERS.serviceConfigInvalid, `${adapterCode} 服务 auth.parameterlist 必须是数组`, { key: "auth.parameterlist" });
170
+ const allowed = new Set(expected.map((param) => param.code));
171
+ const required = expected.filter((param) => param.required).map((param) => param.code);
172
+ const seen = new Set();
173
+ for (const [index, item] of auth.parameterlist.entries()) {
174
+ if (!isRecord(item) || typeof item.code !== "string" || !item.code || typeof item.value !== "string" || !item.value)
175
+ refuse(BIZSERVICE_CONFIG_BLOCKERS.serviceConfigInvalid, `${adapterCode} auth.parameterlist[${index}] 必须含 code/name?/value 非空字符串;敏感 value 只透传不记录`, { key: `auth.parameterlist[${index}]` });
176
+ if (item.name !== undefined && typeof item.name !== "string")
177
+ refuse(BIZSERVICE_CONFIG_BLOCKERS.serviceConfigInvalid, `${adapterCode} auth.parameterlist[${index}].name 必须是字符串`, { key: `auth.parameterlist[${index}].name` });
178
+ if (item.description !== undefined && typeof item.description !== "string")
179
+ refuse(BIZSERVICE_CONFIG_BLOCKERS.serviceConfigInvalid, `${adapterCode} auth.parameterlist[${index}].description 必须是字符串`, { key: `auth.parameterlist[${index}].description` });
180
+ if (item.required !== undefined && item.required !== true)
181
+ refuse(BIZSERVICE_CONFIG_BLOCKERS.serviceConfigInvalid, `${adapterCode} auth.parameterlist[${index}].required 必须为 true(前端 AdapterConfigParam.Param 定义)`, { key: `auth.parameterlist[${index}].required` });
182
+ if (seen.has(item.code))
183
+ refuse(BIZSERVICE_CONFIG_BLOCKERS.serviceConfigInvalid, `${adapterCode} auth.parameterlist 不允许重复参数 ${item.code}`, { key: "auth.parameterlist" });
184
+ seen.add(item.code);
185
+ if (!allowed.has(item.code))
186
+ refuse(BIZSERVICE_CONFIG_BLOCKERS.serviceConfigInvalid, `${adapterCode} auth=${authCode} 不允许参数 ${item.code};平台该鉴权的参数:${[...allowed].join(",") || "无"}`, { key: `auth.parameterlist[${index}].code` });
187
+ }
188
+ const missing = required.filter((code) => !seen.has(code));
189
+ if (missing.length > 0)
190
+ refuse(BIZSERVICE_CONFIG_BLOCKERS.serviceConfigInvalid, `${adapterCode} auth=${authCode} 缺少参数:${missing.join(",")}。参数来源:${missing.map((code) => provenanceLine(authCode, code)).join(";")}。平台权威清单:omc call service.adapter_config --args '{"adapterCode":"${adapterCode}"}'`, { key: "auth.parameterlist", missing, provenance: Object.fromEntries(missing.map((code) => [code, authParameterProvenance(authCode, code) ?? null])) });
191
+ }
192
+ function validateDynamicAuthShape(adapterCode, auth) {
193
+ if (!Array.isArray(auth.parameterlist))
194
+ refuse(BIZSERVICE_CONFIG_BLOCKERS.serviceConfigInvalid, `${adapterCode} 服务 auth.parameterlist 必须是数组`, { key: "auth.parameterlist" });
195
+ const seen = new Set();
196
+ for (const [index, item] of auth.parameterlist.entries()) {
197
+ if (!isRecord(item) || typeof item.code !== "string" || !item.code || typeof item.value !== "string" || !item.value)
198
+ refuse(BIZSERVICE_CONFIG_BLOCKERS.serviceConfigInvalid, `${adapterCode} auth.parameterlist[${index}] 必须含 code/name?/value 非空字符串;敏感 value 只透传不记录`, { key: `auth.parameterlist[${index}]` });
199
+ if (seen.has(item.code))
200
+ refuse(BIZSERVICE_CONFIG_BLOCKERS.serviceConfigInvalid, `${adapterCode} auth.parameterlist 不允许重复参数 ${item.code}`, { key: "auth.parameterlist" });
201
+ seen.add(item.code);
202
+ }
203
+ // 空 parameterlist 合法:某些扩展鉴权(SPI)无参数。离线只校验结构,
204
+ // 参数集合仍交由在线预检按 authList 判定(多给/少给都由平台定义兜底)。
205
+ }
206
+ function validateAuthBase(auth) {
207
+ if (!isRecord(auth))
208
+ refuse(BIZSERVICE_CONFIG_BLOCKERS.serviceConfigInvalid, "服务 auth 必须是对象", { key: "auth" });
209
+ if (typeof auth.code !== "string" || !auth.code)
210
+ refuse(BIZSERVICE_CONFIG_BLOCKERS.serviceConfigInvalid, "auth.code 必须是非空字符串(RESTFUL/INTERNAL 内置 customer/basic/oauth_password/oauth_client;SOAP 内置 basic/customer;扩展鉴权仅在 adapter_config 列出时可用)", { key: "auth.code" });
211
+ if (typeof auth.name !== "undefined" && typeof auth.name !== "string")
212
+ refuse(BIZSERVICE_CONFIG_BLOCKERS.serviceConfigInvalid, "auth.name 必须是字符串", { key: "auth.name" });
213
+ if (typeof auth.description !== "undefined" && typeof auth.description !== "string")
214
+ refuse(BIZSERVICE_CONFIG_BLOCKERS.serviceConfigInvalid, "auth.description 必须是字符串", { key: "auth.description" });
215
+ }
216
+ /**
217
+ * 按适配器校验鉴权(发现驱动):
218
+ * - 传入 `definitions`(平台 adapter_config.authList 的映射)时,code/参数必须与平台完全一致;
219
+ * - 不传时用离线基线(RESTFUL/INTERNAL 4 种、SOAP 2 种)。
220
+ */
221
+ export function validateAuthForAdapter(adapterCode, auth, definitions, options = {}) {
222
+ validateAuthBase(auth);
223
+ const authCode = auth.code;
224
+ if (definitions !== undefined) {
225
+ const definition = definitions.get(authCode);
226
+ if (definition === undefined)
227
+ refuse(BIZSERVICE_CONFIG_BLOCKERS.serviceConfigInvalid, `${adapterCode} 的鉴权 ${authCode} 不在平台 adapter_config.authList 里;本环境可用:${[...definitions.keys()].join("、") || "无"}。平台权威清单:omc call service.adapter_config --args '{"adapterCode":"${adapterCode}"}'`, { key: "auth.code", adapterCode, availableAuth: [...definitions.keys()] });
228
+ validateAuthItems(adapterCode, auth, authCode, definition.parameters);
229
+ return;
230
+ }
231
+ const builtinCodes = ADAPTER_BUILTIN_AUTH_CODES[adapterCode];
232
+ // 离线 dry-lint(无环境)遇到未列出的 code:RESTFUL/INTERNAL 可能是环境里装了
233
+ // 扩展鉴权,只校验结构,留到真写/--dry-run 的在线预检按 adapter_config 判定。
234
+ if (options.allowDynamicAuth === true && definitions === undefined
235
+ && (adapterCode === "RESTFUL" || adapterCode === "INTERNAL")
236
+ && builtinCodes !== undefined && !builtinCodes.includes(authCode)) {
237
+ validateDynamicAuthShape(adapterCode, auth);
238
+ return;
239
+ }
240
+ if (builtinCodes === undefined || !builtinCodes.includes(authCode)) {
241
+ if (builtinCodes !== undefined)
242
+ refuse(BIZSERVICE_CONFIG_BLOCKERS.serviceConfigInvalid, `${adapterCode} 的鉴权只能是 ${builtinCodes.join("/")}(平台 adapter_config 未提供 ${authCode})`, { key: "auth.code", adapterCode, availableAuth: builtinCodes });
243
+ else
244
+ refuse(BIZSERVICE_CONFIG_BLOCKERS.serviceConfigInvalid, `RESTFUL auth.code 必须是 customer/basic/oauth_password/oauth_client,动态扩展鉴权需先确认平台 adapter_config 列出`, { key: "auth.code" });
245
+ }
246
+ const parameters = RESTFUL_AUTH_PARAMETER_DEFINITIONS[authCode] ?? [];
247
+ validateAuthItems(adapterCode, auth, authCode, parameters.map((param) => ({ code: param.code, required: param.required, name: param.name, description: param.description })));
248
+ }
100
249
  export function validateRestfulAuth(auth) {
101
250
  if (!isRecord(auth))
102
251
  refuse(BIZSERVICE_CONFIG_BLOCKERS.serviceConfigInvalid, "RESTFUL 服务 auth 必须是对象", { key: "auth" });
@@ -219,15 +368,15 @@ function scanAuthParameterlistForPlaceholders(parameterlist, adapterCode) {
219
368
  refuse(BIZSERVICE_CONFIG_BLOCKERS.serviceConfigInvalid, `${adapterCode} 服务鉴权凭据 ${finding.code} 包含${finding.reason}——平台 service/create 不校验凭据内容,注册成功但运行时自调必败(r6-onlinejs 真机:全 0 corpId 注册成功、自调 401/500)。凭据必须从任务环境事实取真值(如 doctor 显示的 corpId、任务提供的 client_secret)。`, { key: `auth.parameterlist.${finding.code}`, value: finding.valueKind });
220
369
  }
221
370
  }
222
- function requireAuthAndUrl(serviceConfig, adapterCode) {
371
+ function requireAuthAndUrl(serviceConfig, adapterCode, authDefinitions, options = {}) {
223
372
  const auth = serviceConfig.auth;
224
373
  // T05:掩码/占位分类先于结构校验——结构化掩码对象 {masked:true}(读回形状回灌)
225
374
  // 在 string-only 的 validateRestfulAuth 之前就能拿到专属拒因,而不是笼统的
226
375
  // "必须是非空字符串"。两道防线都保留(INTERNAL 路径只依赖本扫描)。
227
376
  if (isRecord(auth) && Array.isArray(auth.parameterlist))
228
377
  scanAuthParameterlistForPlaceholders(auth.parameterlist, adapterCode);
229
- if (adapterCode === "RESTFUL" || adapterCode === "SOAP")
230
- validateRestfulAuth(auth);
378
+ if (adapterCode === "RESTFUL" || adapterCode === "SOAP" || adapterCode === "INTERNAL")
379
+ validateAuthForAdapter(adapterCode, auth, authDefinitions, options);
231
380
  if (!isRecord(auth) || typeof auth.code !== "string" || !auth.code || !Array.isArray(auth.parameterlist))
232
381
  refuse(BIZSERVICE_CONFIG_BLOCKERS.serviceConfigInvalid, `${adapterCode} 服务 configJson 需要 auth {code, parameterlist[]}`, { key: "auth" });
233
382
  if (!commonlistValue(serviceConfig, "url"))
@@ -254,12 +403,12 @@ function validateSapMethod(methodConfig) {
254
403
  * Validate a structured service config against the adapter's source-evidenced
255
404
  * required keys. Service configJson is plaintext on the wire for every adapter.
256
405
  */
257
- export function compileServiceConfig(adapterCode, serviceConfig) {
406
+ export function compileServiceConfig(adapterCode, serviceConfig, authDefinitions, options = {}) {
258
407
  assertStructuredConfig(serviceConfig, "serviceConfig");
259
408
  if (!isRecord(serviceConfig))
260
409
  refuse(BIZSERVICE_CONFIG_BLOCKERS.serviceConfigInvalid, "serviceConfig 必须是结构化对象", { adapterCode });
261
410
  if (adapterCode === "RESTFUL" || adapterCode === "INTERNAL" || adapterCode === "SOAP")
262
- requireAuthAndUrl(serviceConfig, adapterCode);
411
+ requireAuthAndUrl(serviceConfig, adapterCode, authDefinitions, options);
263
412
  if (adapterCode === "DATA_SQL" || adapterCode === "DATA_TABLE") {
264
413
  requireEmptyAuth(serviceConfig, adapterCode);
265
414
  requireCommonlist(serviceConfig, "databaseConnectionPoolCode", adapterCode);
package/dist/call.js CHANGED
@@ -276,7 +276,9 @@ function humanResultLine(result) {
276
276
  // F4(w153):写面 summary 已存在时,mappingSnapshotGap 的同一句仍要进
277
277
  // 人类行——探针只读 stderr 的首屏,不能让它埋在 JSON 里。
278
278
  const gapNote = mappingSnapshotGapNote(result);
279
- return gapNote !== undefined ? `${result.summary};${gapNote}` : result.summary;
279
+ const mappingNote = mappingRuntimeNoteOf(result);
280
+ const extra = [gapNote, mappingNote].filter((note) => note !== undefined);
281
+ return extra.length > 0 ? `${result.summary};${extra.join(";")}` : result.summary;
280
282
  }
281
283
  if (status === "ok" || status === "dry-run")
282
284
  return readDiagnosticLine(result);
@@ -309,8 +311,21 @@ function readDiagnosticLine(result) {
309
311
  const mappingGapNote = mappingSnapshotGapNote(result);
310
312
  if (mappingGapNote !== undefined)
311
313
  notes.push(mappingGapNote);
314
+ const mappingNote = mappingRuntimeNoteOf(result);
315
+ if (mappingNote !== undefined)
316
+ notes.push(mappingNote);
312
317
  return notes.length > 0 ? notes.join(";") : null;
313
318
  }
319
+ /**
320
+ * 探针 Q F8(0.8.23,P1):`mappingRuntimeNote` 只活在 JSON 的 readback 里,只看
321
+ * stderr 首屏会把「手填快照」误当成「映射生效」。同一句进人类行——配置面 vs 运行面
322
+ * 的分界必须在第一屏可见。
323
+ */
324
+ function mappingRuntimeNoteOf(result) {
325
+ const nested = result.readback !== null && typeof result.readback === "object" ? result.readback : undefined;
326
+ const note = result.mappingRuntimeNote ?? nested?.mappingRuntimeNote;
327
+ return typeof note === "string" && note.length > 0 ? note : undefined;
328
+ }
314
329
  /**
315
330
  * F4(w153):写面「映射配了但快照空」的人话行——JSON 里 mappingSnapshotGap
316
331
  * 同一份证据,stderr 让调用方在写回执的第一屏就看到具体行/字段。
package/dist/cli.js CHANGED
@@ -2363,12 +2363,19 @@ function cmdDiscovery(kind, transport, value, options = {}) {
2363
2363
  // F7:前缀候选之外,按 description/scope 意图词补 1–2 个(排在原候选之后)。
2364
2364
  const byText = toolsByTextIntent(requested, registry, 2).filter((name) => !candidates.includes(name));
2365
2365
  const shown = [...candidates, ...byText];
2366
+ // 探针 Q F12(0.8.23):model-purge / model-scaffold 等是 CLI 命令,不是 call
2367
+ // 工具;describe 应直接指 --help。命令清单取**权威来源**(调用方传入的
2368
+ // commander 命令名),并排除同名工具(doctor 等以工具优先)——不维护第二份清单。
2369
+ const commandNames = new Set((options.commands ?? []).filter((name) => !registry.some((tool) => tool.name === name)));
2370
+ const commandPointer = commandNames.has(requested)
2371
+ ? `;${requested} 是 CLI 命令(不是 call 工具):用法用 \`omc ${requested} --help\`,参数/破坏性语义同理`
2372
+ : "";
2366
2373
  const pointer = candidates.length === 0 && byText.length === 0 && (kind === "describe" || kind === "contract")
2367
2374
  ? `;describe 的目标是工具名(如 rule.save);图/模板/节点形状用 describe <tool> --full 或 contract <lane>,工具清单用 omc next "<目标>" / omc commands --json --compact`
2368
2375
  : "";
2369
2376
  const absence = absencePointer(requested);
2370
2377
  const textNote = byText.length > 0 ? `;didYouMeanByText: ${byText.join("、")}` : "";
2371
- return emitInvalid(transport, { message: `${kind} target not found: "${requested}"${shown.length > 0 ? `; did you mean: ${shown.join("、")}` : ""}${textNote}${absence}${approvalPointer}${intentPointer}${formPointer}${pointer}` });
2378
+ return emitInvalid(transport, { message: `${kind} target not found: "${requested}"${shown.length > 0 ? `; did you mean: ${shown.join("、")}` : ""}${textNote}${commandPointer}${absence}${approvalPointer}${intentPointer}${formPointer}${pointer}` });
2372
2379
  }
2373
2380
  return emitProjectedResult({ status: "ok", ...result }, transport, options.jq, options.explain === true);
2374
2381
  }
@@ -3031,6 +3038,26 @@ function cmdHelpSearch(topic, query, transport, searchMode, limit) {
3031
3038
  if (query.trim() === "")
3032
3039
  return emitInvalid(transport, { message: `--search 需要一个非空查询词(例:omc help --search "40000")` });
3033
3040
  const result = searchSkills(query, { mode, limit: rawLimit });
3041
+ // 探针 Q F3(0.8.23):help 检索只扫方法论;但「两列」的答案在工具配方里
3042
+ // (form.draft --example two-column-layout)。零命中时把配方标题/别名/index 也搜一遍,
3043
+ // 直接给可复制的 describe 命令。
3044
+ const recipeMatches = result.total === 0
3045
+ ? (() => {
3046
+ const needle = query.trim().toLowerCase();
3047
+ const out = [];
3048
+ for (const tool of buildToolRegistry()) {
3049
+ for (const recipe of tool.executionMetadata?.recipes ?? []) {
3050
+ const haystack = `${recipe.id} ${recipe.title} ${(recipe.aliases ?? []).join(" ")}`.toLowerCase();
3051
+ if (!haystack.includes(needle))
3052
+ continue;
3053
+ out.push({ tool: tool.name, example: recipe.id, title: recipe.title, command: `omc describe ${tool.name} --example ${recipe.id}` });
3054
+ if (out.length >= 5)
3055
+ return out;
3056
+ }
3057
+ }
3058
+ return out;
3059
+ })()
3060
+ : [];
3034
3061
  // A hit bigger than this is a book, not an answer: inlining it would recreate
3035
3062
  // the 12 KB sections agents already pay for. Name the exact `--section`
3036
3063
  // command instead and say the body is not included.
@@ -3061,7 +3088,14 @@ function cmdHelpSearch(topic, query, transport, searchMode, limit) {
3061
3088
  returnedMatches: entries.length,
3062
3089
  truncated: truncated || entries.some((entry) => entry.sectionComplete === false),
3063
3090
  matches: entries,
3064
- ...(result.total === 0 ? { message: "没有匹配章节;换更短的字面词(错误码、字段名、命令名)或加 --search-mode any。格式常量/参数用 `omc describe <tool> --param <name>` 或 `omc contract <lane>` 查(例:omc describe field.create --param options)" } : {}),
3091
+ ...(result.total === 0
3092
+ ? {
3093
+ message: recipeMatches.length > 0
3094
+ ? "没有匹配章节,但工具配方命中(见 recipeMatches):可直接 describe --example 取形状;章节检索换更短的字面词或加 --search-mode any。"
3095
+ : "没有匹配章节;换更短的字面词(错误码、字段名、命令名)或加 --search-mode any。格式常量/参数用 `omc describe <tool> --param <name>` 或 `omc contract <lane>` 查(例:omc describe field.create --param options)",
3096
+ ...(recipeMatches.length > 0 ? { recipeMatches } : {}),
3097
+ }
3098
+ : {}),
3065
3099
  ...(result.total > 0 && entries.length === 0 ? { message: "命中存在但连指针都放不进预算;加 --limit 1 或换更短的查询" } : {}),
3066
3100
  });
3067
3101
  let truncating = false;
@@ -3159,7 +3193,7 @@ function shellQuote(value) {
3159
3193
  for (const requested of requestedSections) {
3160
3194
  const sliced = readSkillSection(topic, requested);
3161
3195
  if (sliced?.section)
3162
- found.push({ section: sliced.heading ?? requested, ...(sliced.heading !== requested ? { requested } : {}), ...(sliced.matchType === "partial" ? { matchType: "partial" } : {}), content: sliced.section, chars: sliced.section.length, bytes: Buffer.byteLength(sliced.section, "utf8") });
3196
+ found.push({ section: sliced.heading ?? requested, ...(sliced.heading !== requested ? { requested } : {}), ...(sliced.matchType === "partial" ? { matchType: "partial" } : {}), ...(sliced.sectionHint !== undefined ? { sectionHint: sliced.sectionHint } : {}), content: sliced.section, chars: sliced.section.length, bytes: Buffer.byteLength(sliced.section, "utf8") });
3163
3197
  else
3164
3198
  missing.push(requested);
3165
3199
  }
@@ -3196,6 +3230,7 @@ function shellQuote(value) {
3196
3230
  section: sliced.heading ?? singleSection,
3197
3231
  ...(sliced.heading !== singleSection || sliced.matchType === "partial" ? { requested: singleSection } : {}),
3198
3232
  ...(sliced.matchType === "partial" ? { matchType: "partial" } : {}),
3233
+ ...(sliced.sectionHint !== undefined ? { sectionHint: sliced.sectionHint } : {}),
3199
3234
  chars: sliced.section.length,
3200
3235
  bytes: Buffer.byteLength(sliced.section, "utf8"),
3201
3236
  complete: true,
@@ -4120,7 +4155,7 @@ async function main() {
4120
4155
  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>", "按 lane 过滤(完整 id 大小写不敏感;也接受能力 id/别名如 data、list-view;多候选会列出)").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` 是"人人都以为通用"的
4121
4156
  // flag——与 `next` 同处理:接受并忽略(不因反射性传参被 unknown option 打回)。
4122
4157
  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) => {
4123
- 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 }));
4158
+ 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, commands: command.commands.map((entry) => entry.name()) }));
4124
4159
  });
4125
4160
  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 })); });
4126
4161
  // 2026-11-05 用户实测:`commands --json` 存在,于是大家自然写 `capabilities --json`
package/dist/coverage.js CHANGED
@@ -125,10 +125,9 @@ function citationFor(item, requestedScope) {
125
125
  export function versionFamilyNotice(manifest, detectedVersion) {
126
126
  if (detectedVersion.startsWith(manifest.version_family + "."))
127
127
  return undefined;
128
- return (`兼容模式:检测到 CloudPivot ${detectedVersion},不在 OMC 锚定的 ${manifest.version_family} 族` +
129
- `(锚点 ${manifest.anchor_version})。OMC 基于 8.6 构建,非 8.6 环境按兼容支持,部分能力面可能不适用。` +
130
- `取证口径:以本环境真机实测为准,8.6 文档与反编译结论仅作参考。` +
131
- `族差异清单见 docs/platform-contracts/2.1-delta.md(逐条带 file:line;未登记的条目按实测,不臆断同形或不同形)。`);
128
+ // 探针 P F9(0.8.22):每次回执约 400B 的固定噪声压到一句;细节留在族差异文档。
129
+ return (`兼容模式:检测到 CloudPivot ${detectedVersion}(不在锚定的 ${manifest.version_family} 族,锚点 ${manifest.anchor_version});` +
130
+ `按兼容支持放行,以本环境真机实测为准,族差异见 docs/platform-contracts/2.1-delta.md。`);
132
131
  }
133
132
  /**
134
133
  * 无版本证据时的兼容提示(2026-11-24 产品口径)。
package/dist/field-add.js CHANGED
@@ -185,7 +185,7 @@ export async function cmdFieldAdd(args, contextForTest) {
185
185
  inputJson = readFileSync(assertSafeInputPath(root, fieldsFile, "--fields-file"), "utf8");
186
186
  }
187
187
  catch (error) {
188
- return invalid(`--fields-file 读取失败:${error instanceof Error ? error.message : String(error)}`);
188
+ return invalid(`--fields-file 读取失败:${error instanceof Error ? error.message : String(error)}${/must be inside the configuration root/.test(error instanceof Error ? error.message : String(error)) ? "。把参数文件放到配置根内(如配置根/args.json)再用 --fields-file 引用;不想落盘可直接用 stdin:--fields - < <文件>" : ""}`);
189
189
  }
190
190
  }
191
191
  if (inputJson === undefined)
@@ -186,7 +186,7 @@ export const B2_LANE_CONTRACT = Object.freeze({
186
186
  }),
187
187
  "service.adapter_config": Object.freeze({
188
188
  scope: "readback",
189
- description: "适配器配置发现(设计器同源):`/bizservice/service/adapter_config` 返回 JSON 字符串(已解码),每个适配器 {code,name,config:{authList,commonList,serviceActionList,methodActionList}}——commonList/authList 的 code+required 就是 service.register 预检所依据的必需键(同源无漂移)。顶栏恒带 adapterCodes 摘要;compact:true 只回 code/name/description(选型)。RESTFUL:url 必填 + basic/oauth_password/oauth_client/customer 鉴权面;DATA_SQL:databaseConnectionPoolCode 必填、无服务级鉴权(sqlConfigEnabled 开启时平台会移除 DATA_SQL/DATA_TABLE,读回原样)。纯只读。",
189
+ description: "适配器配置发现(设计器同源):`/bizservice/service/adapter_config` 返回 JSON 字符串(已解码),每个适配器 {code,name,config:{authList,commonList,serviceActionList,methodActionList}}——commonList/authList 的 code+required 就是 service.register 预检所依据的必需键(同源无漂移)。顶栏恒带 adapterCodes 摘要;compact:true 只回 code/name/description(选型)。RESTFUL:url 必填 + basic/oauth_password/oauth_client/customer 鉴权面;DATA_SQL:databaseConnectionPoolCode 必填、无服务级鉴权(sqlConfigEnabled 开启时平台会移除 DATA_SQL/DATA_TABLE,读回原样)。完整面另给 authGuide(每种鉴权的参数及各参数来源)。纯只读。",
190
190
  }),
191
191
  "service.table_list": Object.freeze({
192
192
  scope: "readback",
@@ -13,7 +13,7 @@ import { wireCall, wireRows, wireDownloadBuffer, wireUploadFile, WireError } fro
13
13
  import { parameterFaceCovers, serviceStatusSegment } from "../service-support.js";
14
14
  import { ZipFormatError, readZipEntries, zipEntryByBasename } from "../zip.js";
15
15
  import { B2_LANE_CONTRACT } from "./b2-registration-contract.js";
16
- import { BIZSERVICE_WRITE_ADAPTERS, assertBizServiceAdapterWhitelisted, assertStructuredConfig, compileMethodConfigPlain, compileParameterFace, compileServiceConfig, maskServiceConfigSecrets, normalizeMethodConfigReadback, normalizeParameterFaceReadback, parseIeManifest, iePackageSummary, } from "../bizservice-config.js";
16
+ import { BIZSERVICE_WRITE_ADAPTERS, assertBizServiceAdapterWhitelisted, assertStructuredConfig, compileMethodConfigPlain, compileParameterFace, compileServiceConfig, adapterAuthDefinitions, authParameterProvenance, maskServiceConfigSecrets, normalizeMethodConfigReadback, normalizeParameterFaceReadback, parseIeManifest, iePackageSummary, } from "../bizservice-config.js";
17
17
  import { omcCore } from "../omc-core-lazy.js";
18
18
  const B2_LANE = B2_LANE_CONTRACT.lane;
19
19
  const B2_TOOLS = B2_LANE_CONTRACT.tools;
@@ -202,6 +202,41 @@ function poolReadbackFace(pool) {
202
202
  ...(pool.externInfo !== undefined && pool.externInfo !== null ? { externInfo: pool.externInfo } : {}),
203
203
  };
204
204
  }
205
+ /**
206
+ * 探针 P/Q(0.8.24):鉴权面以平台 `adapter_config.authList` 为唯一来源——只有
207
+ * 平台列出的 code 才能写,参数集合也按平台定义核对(离线基线内嵌 4 种,在线读平台)。
208
+ * 平台证据:RestProtocolAdapterServiceImpl.java:50-90(2.1.5 :49-72)内置 4 种并追加
209
+ * 扩展 RestAuthenticationService.getAuthConfig();SOAP 只有 basic/customer
210
+ * (SoapProtocolAdapterServiceImpl.java:44-45);authList 由
211
+ * /bizservice/service/adapter_config 原样返回(BizServiceFacadeImpl.java:322-328)。
212
+ */
213
+ const AUTH_ADAPTERS = new Set(["RESTFUL", "INTERNAL", "SOAP"]);
214
+ async function loadAdapterAuthDefinitions(session, adapterCode) {
215
+ const result = await wireCall(session, { path: ENDPOINTS.bizServiceAdapterConfig });
216
+ let adapters = null;
217
+ if (typeof result.data === "string" && result.data.trim()) {
218
+ try {
219
+ adapters = JSON.parse(result.data);
220
+ }
221
+ catch {
222
+ adapters = null;
223
+ }
224
+ }
225
+ const definitions = adapterAuthDefinitions(adapters, adapterCode);
226
+ if (definitions !== undefined)
227
+ return definitions;
228
+ const codes = Array.isArray(adapters)
229
+ ? adapters.flatMap((row) => row !== null && typeof row === "object" && typeof row.code === "string" ? [String(row.code)] : [])
230
+ : [];
231
+ throw new ToolRefusalError({
232
+ status: "refused",
233
+ blocker: "bizservice-adapter-not-listed",
234
+ adapterCode,
235
+ availableAdapters: codes,
236
+ message: `平台 adapter_config 里没有适配器 ${adapterCode}(本环境:${codes.join("、") || "读取失败"})——鉴权面无法按平台定义校验,拒绝在未知适配器上写鉴权配置`,
237
+ nextCommand: "omc call service.adapter_config --args '{}'",
238
+ });
239
+ }
205
240
  /**
206
241
  * Ticket 104 — fail-closed DATA_SQL/DATA_TABLE binding preflight. The
207
242
  * platform stores commonlist.databaseConnectionPoolCode with no existence
@@ -1226,7 +1261,35 @@ export function registerB2Lane(tools) {
1226
1261
  ...(row.description !== undefined ? { description: row.description } : {}),
1227
1262
  }))
1228
1263
  : adapters;
1229
- return { adapters: face, adapterCodes, rawPresent: typeof result.data === "string", ...(args.compact === true ? { compact: true } : {}) };
1264
+ // 探针 P/Q(0.8.24):鉴权参数从哪来——把平台 authList 与来源提示合成只读指引。
1265
+ // 只在完整面给(compact 选型不付这份字节)。
1266
+ const authGuide = args.compact === true
1267
+ ? undefined
1268
+ : rows.flatMap((row) => {
1269
+ const adapterCode = typeof row.code === "string" ? row.code : "";
1270
+ if (!adapterCode)
1271
+ return [];
1272
+ const definitions = adapterAuthDefinitions(rows, adapterCode);
1273
+ if (definitions === undefined || definitions.size === 0)
1274
+ return [];
1275
+ return [{
1276
+ adapterCode,
1277
+ auths: [...definitions.values()].map((definition) => ({
1278
+ code: definition.code,
1279
+ ...(definition.name !== undefined ? { name: definition.name } : {}),
1280
+ ...(definition.description !== undefined ? { description: definition.description } : {}),
1281
+ parameters: definition.parameters.map((parameter) => ({
1282
+ code: parameter.code,
1283
+ required: parameter.required,
1284
+ ...(parameter.name !== undefined ? { name: parameter.name } : {}),
1285
+ ...(authParameterProvenance(definition.code, parameter.code) !== undefined
1286
+ ? { source: authParameterProvenance(definition.code, parameter.code) }
1287
+ : {}),
1288
+ })),
1289
+ })),
1290
+ }];
1291
+ });
1292
+ return { adapters: face, adapterCodes, rawPresent: typeof result.data === "string", ...(authGuide !== undefined && authGuide.length > 0 ? { authGuide } : {}), ...(args.compact === true ? { compact: true } : {}) };
1230
1293
  }, {
1231
1294
  // 2026-11-01 读门 2048:适配器面本身就是这个工具的存在意义(注册预检的
1232
1295
  // 同源依据)——compact 保留 adapters 本体,不折码表。r28f F5:顶栏
@@ -1293,7 +1356,7 @@ export function registerB2Lane(tools) {
1293
1356
  name: z.string().min(1).describe("服务名称(设计器必填;非空,中文≤50,服务端同样强制)"),
1294
1357
  adapterCode: z.string().min(1).describe("适配器编码(设计器必填):RESTFUL/DATA_SQL/DATA_TABLE/SAP/KAFKA/SOAP。自定义 Java 方法体(扩展接口)的常规做法是用 RESTFUL 指向扩展端点,不要用 INTERNAL/custom_protocol"),
1295
1358
  serviceCategoryId: z.string().min(1).describe("所属目录 id(设计器必填;用 service.category.list 解析,「全部」是空 id 虚拟项不可用,必要时 service.category.create 新建)"),
1296
- serviceConfig: z.record(z.string(), z.unknown()).optional().describe("结构化服务 configJson(明文落库;原生适配器按 adapterCode 校验)。RESTFUL/SOAP 鉴权 auth.code 仅接受 customer(parameterlist=[])、basic(username/password)、oauth_password(client_id/client_secret/username/password/oauth_path)、oauth_client(client_id/client_secret/oauth_path);每项为 code/name?/value 字符串,值只透传不记录;DATA_SQL/DATA_TABLE/SAP/KAFKA 不使用服务级鉴权,auth 只能为空对象或省略"),
1359
+ serviceConfig: z.record(z.string(), z.unknown()).optional().describe("结构化服务 configJson(明文落库;原生适配器按 adapterCode 校验)。鉴权 auth.code:RESTFUL/INTERNAL 内置 customer(parameterlist=[])、basic(username/password)、oauth_password(client_id/client_secret/username/password/oauth_path)、oauth_client(client_id/client_secret/oauth_path),SOAP 仅 basic/customer;每项为 code/name?/value 字符串,值只透传不记录;DATA_SQL/DATA_TABLE/SAP/KAFKA 不使用服务级鉴权,auth 只能为空对象或省略"),
1297
1360
  methodName: z.string().optional(),
1298
1361
  methodConfig: z.record(z.string(), z.unknown()).optional().describe("结构化方法 configJson(工具 AES-128-ECB+Base64 加密后上送;明文会被平台静默存 NULL)。RESTFUL 必填 httpType/requestBodyType/url/frontEndExtensionEnable,枚举可用名字(httpType: Post/Get/Put/Patch/Delete;requestBodyType: Form-urlencoded/JSON/Text),工具会编码成平台整数索引。DATA_SQL/DATA_TABLE 需要 sql/returnType(returnType: Void/SingleObject/List)。RESTFUL/DATA_SQL/DATA_TABLE/SAP/KAFKA 带 methodName 时必填;SOAP 方法由 WSDL 动态发现、无固定方法 configJson"),
1299
1362
  methodInputParameters: z.union([z.array(z.record(z.string(), z.unknown())), z.string()]).optional().describe("方法输入参数声明([{code,name,…}] 数组或 JSON 字符串)→ inputParametersJson;绑定校验按 code 对账;RESTFUL 每参数需 configJson.position"),
@@ -1326,7 +1389,10 @@ export function registerB2Lane(tools) {
1326
1389
  // Ticket 103: the platform never validates serviceCategoryId — refuse a
1327
1390
  // dangling id before any write (read-only resolution precedes this).
1328
1391
  await assertCategoryResolves(session, args.serviceCategoryId);
1329
- const serviceConfigJson = args.serviceConfig !== undefined ? compileServiceConfig(adapterCode, args.serviceConfig) : undefined;
1392
+ const authDefinitions = args.serviceConfig !== undefined && AUTH_ADAPTERS.has(adapterCode)
1393
+ ? await loadAdapterAuthDefinitions(session, adapterCode)
1394
+ : undefined;
1395
+ const serviceConfigJson = args.serviceConfig !== undefined ? compileServiceConfig(adapterCode, args.serviceConfig, authDefinitions) : undefined;
1330
1396
  // Ticket 104: a DATA_SQL/DATA_TABLE binding must reference an existing
1331
1397
  // connection pool before any write (the platform stores it unvalidated).
1332
1398
  if (serviceConfigJson !== undefined && (adapterCode === "DATA_SQL" || adapterCode === "DATA_TABLE")) {
@@ -1406,6 +1472,35 @@ export function registerB2Lane(tools) {
1406
1472
  }),
1407
1473
  };
1408
1474
  },
1475
+ dryRunPayload: async (session, args) => {
1476
+ // dry-run 与真写同门(本仓硬规则):重复 code / 分类 / 平台鉴权面 / 连接池
1477
+ // 全部在只读阶段跑一遍;这里不写任何东西。
1478
+ const adapterCode = String(args.adapterCode ?? "");
1479
+ const existing = await wireCall(session, { path: ENDPOINTS.bizServiceGetByCode, query: { serviceCode: args.serviceCode } }).then((res) => res.data).catch(() => null);
1480
+ if (existing != null)
1481
+ return { wouldChange: false, servicePresent: true, summary: `业务服务 ${args.serviceCode} 已存在——真写会回 duplicate-service(零写入)` };
1482
+ await assertCategoryResolves(session, String(args.serviceCategoryId ?? ""));
1483
+ const authDefinitions = args.serviceConfig !== undefined && AUTH_ADAPTERS.has(adapterCode)
1484
+ ? await loadAdapterAuthDefinitions(session, adapterCode)
1485
+ : undefined;
1486
+ const serviceConfigJson = args.serviceConfig !== undefined ? compileServiceConfig(adapterCode, args.serviceConfig, authDefinitions) : undefined;
1487
+ if (serviceConfigJson !== undefined && (adapterCode === "DATA_SQL" || adapterCode === "DATA_TABLE")) {
1488
+ const poolCode = dbConnPoolCodeOf(args.serviceConfig);
1489
+ if (poolCode !== undefined)
1490
+ await assertDbConnPoolResolves(session, poolCode);
1491
+ }
1492
+ const auth = args.serviceConfig?.auth;
1493
+ return {
1494
+ wouldChange: true,
1495
+ serviceCode: args.serviceCode,
1496
+ adapterCode,
1497
+ summary: `即将注册业务服务 ${args.serviceCode}(adapter=${adapterCode})${args.methodName !== undefined ? ` + 方法 ${args.methodName}` : ""};分类/鉴权面/连接池/配置必需键已按真写同门校验`,
1498
+ ...(auth !== undefined && typeof auth.code === "string"
1499
+ ? { auth: { code: auth.code, parameterCodes: Array.isArray(auth.parameterlist) ? auth.parameterlist.flatMap((item) => item !== null && typeof item === "object" && typeof item.code === "string" ? [String(item.code)] : []) : [] } }
1500
+ : {}),
1501
+ ...(args.methodName !== undefined ? { methodCode: args.methodName } : {}),
1502
+ };
1503
+ },
1409
1504
  preflight: (args) => {
1410
1505
  // Dry-lint (zero wire). `omc call` bypasses zod, so every schema-level
1411
1506
  // required is re-enforced here BEFORE the write permission gate.
@@ -1424,7 +1519,9 @@ export function registerB2Lane(tools) {
1424
1519
  // methods from WSDL via its native refresh path.
1425
1520
  if (args.serviceConfig === undefined)
1426
1521
  throw new ToolRefusalError({ status: "refused", blocker: "bizservice-service-config-invalid", message: `${adapterCode} 服务必须携带结构化 serviceConfig(设计器同款必填)` });
1427
- compileServiceConfig(adapterCode, args.serviceConfig);
1522
+ // 离线 dry-lint:RESTFUL/INTERNAL 未列出的 code 可能是环境里的扩展鉴权,
1523
+ // 这里只校验结构;真写/--dry-run 由 adapter_config 在线预检判定。
1524
+ compileServiceConfig(adapterCode, args.serviceConfig, undefined, { allowDynamicAuth: true });
1428
1525
  if (args.methodName !== undefined && adapterCode === "SOAP")
1429
1526
  throw new ToolRefusalError({ status: "refused", blocker: "bizservice-method-config-invalid", message: "SOAP 方法由 WSDL 动态发现,没有固定 methodConfig;请使用平台原生 SOAP refresh/方法发现接口,不伪造方法体" });
1430
1527
  if (args.methodName !== undefined && args.methodConfig === undefined)
@@ -1457,7 +1554,10 @@ export function registerB2Lane(tools) {
1457
1554
  await assertCategoryResolves(session, args.serviceCategoryId);
1458
1555
  // A structured serviceConfig targets the designer write face: the same
1459
1556
  // adapter whitelist + required-key preflight as register (ticket 92).
1460
- const serviceConfigJson = args.serviceConfig !== undefined ? compileServiceConfig(assertBizServiceAdapterWhitelisted(adapterCode), args.serviceConfig) : undefined;
1557
+ const authDefinitions = args.serviceConfig !== undefined && AUTH_ADAPTERS.has(adapterCode)
1558
+ ? await loadAdapterAuthDefinitions(session, adapterCode)
1559
+ : undefined;
1560
+ const serviceConfigJson = args.serviceConfig !== undefined ? compileServiceConfig(assertBizServiceAdapterWhitelisted(adapterCode), args.serviceConfig, authDefinitions) : undefined;
1461
1561
  // Ticket 104: a DATA_SQL/DATA_TABLE binding must reference an existing
1462
1562
  // connection pool before the update write.
1463
1563
  if (serviceConfigJson !== undefined && (adapterCode === "DATA_SQL" || adapterCode === "DATA_TABLE")) {
@@ -1030,11 +1030,16 @@ export function registerFieldLane(tools) {
1030
1030
  String(args.propertyType) === "RADIO" ||
1031
1031
  String(args.propertyType) === "CHECKBOX" ||
1032
1032
  String(args.propertyType) === "SELECTION";
1033
+ const createdRow = rows.find((row) => (row.code ?? row.propertyCode) === args.code);
1034
+ const createdOptions = createdRow?.options !== undefined && createdRow.options !== null ? parseFieldOptionsForReadback(createdRow.options) : undefined;
1033
1035
  return {
1034
1036
  performed: { errcode: performed.errcode },
1035
1037
  readback: {
1036
1038
  face: "draft",
1037
- draftFieldPresent: rows.some((row) => (row.code ?? row.propertyCode) === args.code),
1039
+ draftFieldPresent: createdRow !== undefined,
1040
+ // 探针 P F5(0.8.22):写回执回显**生效值**(scale/format/mappings 等只在
1041
+ // options 里的语义),省掉一次 field.get 才能核对单位/精度/映射方向。
1042
+ ...(createdOptions !== undefined ? { options: createdOptions } : {}),
1038
1043
  ...(prepared.normalized ? { normalized: prepared.normalized } : {}),
1039
1044
  ...(textLike
1040
1045
  ? {
@@ -2075,7 +2080,7 @@ function relationMappingsEmptyWarnings(publishedRows) {
2075
2080
  .filter((code) => code.length > 0);
2076
2081
  if (empty.length === 0)
2077
2082
  return undefined;
2078
- return [{ code: "relation-mappings-empty", fields: empty, hint: "选中时不回填副本列;配 options.mappings 后再 field.publish" }];
2083
+ return [{ code: "relation-mappings-empty", fields: empty, hint: "该字段的 mappings 为显式留空(若你本就不打算回填副本列,可忽略这条);需要回填时配 options.mappings 后再 field.publish" }];
2079
2084
  }
2080
2085
  async function formBindingAdvisory(session, schemaCode, publishedRows) {
2081
2086
  const dictionaryStale = await dictionaryStaleAdvisory(session, publishedRows);
@@ -56,7 +56,7 @@ export function dataSubmitDescription() {
56
56
  /** Runtime business-object data keyed by field code. */
57
57
  export const runtimeFormDataArg = z
58
58
  .record(z.string(), z.unknown())
59
- .describe('business-object data keyed by field code, e.g. { name:"...", omc_x_amount:123, omc_x_rel:"<target objectId>" }. Relation value SHAPE depends on the field type (live 2026-09-24): a SINGLE relation (WORK_SHEET, propertyType 9) takes the target object id string or an object { id, name? } — an ARRAY here makes runtime/form/save answer 50000; a MULTI relation (propertyType 11) takes an array. STAFF/ORG fields (propertyType 50/51/60/61) take an array of selection objects `[{ id, type, name }]` where `type` is MANDATORY (BizField.parseFromClient casts `type` to Integer and calls intValue(); omitting it answers 50000) — `type` is the UnitType index: USER=3, DEPARTMENT=1. When unsure, prefer "id" or { id }. Field `mappings` are applied by the form RUNTIME when a user picks a value — a server-side data.save does NOT copy source→target, so API callers must set the mapped fields themselves.');
59
+ .describe('business-object data keyed by field code, e.g. { name:"...", omc_x_amount:123, omc_x_rel:"<target objectId>" }. Relation value SHAPE depends on the field type (live 2026-09-24): a SINGLE relation (WORK_SHEET, propertyType 9) takes the target object id string or an object { id, name? } — an ARRAY here makes runtime/form/save answer 50000; a MULTI relation (propertyType 11) is written as a semicolon-joined string "id1;id2" (the array is the readback shape). STAFF/ORG fields (propertyType 50/51/60/61) take an array of selection objects `[{ id, type, name }]` where `type` is MANDATORY (BizField.parseFromClient casts `type` to Integer and calls intValue(); omitting it answers 50000) — `type` is the UnitType index: USER=3, DEPARTMENT=1. When unsure, prefer "id" or { id }. 子表字段(CHILD_TABLE)用字段 code 直接作键:`"<子表字段code>": [{<子列code>:value}]`(不是固定 items;行内关联/人员形状与顶层字段写侧一致)。 Field `mappings` are applied by the form RUNTIME when a user picks a value — a server-side data.save does NOT copy source→target, so API callers must set the mapped fields themselves.');
60
60
  export const RUNTIME_DATA_LANE_CONTRACT = Object.freeze({
61
61
  lane: LANES.runtimeData,
62
62
  family: CONTRACT_FAMILY,
@@ -2627,6 +2627,17 @@ export function registerRuntimeDataLane(tools) {
2627
2627
  ...(projectionMissAll.length > 0 ? { projectionMiss: projectionMissAll } : {}),
2628
2628
  ...(columnsNotProjected.length > 0 ? { columnsNotProjected } : {}),
2629
2629
  ...(columnsOutsideView.length > 0 ? { columnsOutsideView, columnsNarrowingOnly: true, columnsNote: DATA_LIST_COLUMNS_NARROWING_NOTE } : {}),
2630
+ // 探针 P F7(0.8.22):请求列全在视图外时 items[].fields 必然为空——不是
2631
+ // 数据丢失。给一句结论 + 单条真值的可复制命令。
2632
+ ...(itemsFinal.length > 0 && fields !== undefined && fields.length > 0 && viewEvidence?.viewColumnCodes !== undefined
2633
+ && fields.every((code) => columnsOutsideView.includes(code))
2634
+ ? {
2635
+ projectionEmptyNote: "本次 --fields 的列都没有出现在结果行(不在视图列或未被投影):items[].fields 为空是投影结果,不是数据丢失。单条真值用 data.load(见下方 nextCommand);列表要看这些列请核对视图列配置。",
2636
+ ...(typeof itemsFinal[0]?.id === "string"
2637
+ ? { projectionEmptyNextCommand: `omc call data.load --env <env> --args '${JSON.stringify({ schemaCode: args.schemaCode, bizObjectId: itemsFinal[0].id })}'` }
2638
+ : {}),
2639
+ }
2640
+ : {}),
2630
2641
  ...(dateReadbackNote !== undefined ? { dateReadbackNote } : {}),
2631
2642
  items: itemsFinal,
2632
2643
  };
@@ -2847,6 +2858,16 @@ export function registerRuntimeDataLane(tools) {
2847
2858
  ...(projectionMissPaged.length > 0 ? { projectionMiss: projectionMissPaged } : {}),
2848
2859
  ...(columnsNotProjected.length > 0 ? { columnsNotProjected } : {}),
2849
2860
  ...(columnsOutsideView.length > 0 ? { columnsOutsideView, columnsNarrowingOnly: true, columnsNote: DATA_LIST_COLUMNS_NARROWING_NOTE } : {}),
2861
+ // 探针 P F7(0.8.22):请求列全在视图外时 items[].fields 必然为空——不是数据丢失。
2862
+ ...(itemsFinal.length > 0 && fields !== undefined && fields.length > 0 && viewEvidence?.viewColumnCodes !== undefined
2863
+ && fields.every((code) => columnsOutsideView.includes(code))
2864
+ ? {
2865
+ projectionEmptyNote: "本次 --fields 的列都没有出现在结果行(不在视图列或未被投影):items[].fields 为空是投影结果,不是数据丢失。单条真值用 data.load(见下方 nextCommand);列表要看这些列请核对视图列配置。",
2866
+ ...(typeof itemsFinal[0]?.id === "string"
2867
+ ? { projectionEmptyNextCommand: `omc call data.load --env <env> --args '${JSON.stringify({ schemaCode: args.schemaCode, bizObjectId: itemsFinal[0].id })}'` }
2868
+ : {}),
2869
+ }
2870
+ : {}),
2850
2871
  ...(dateReadbackNote !== undefined ? { dateReadbackNote } : {}),
2851
2872
  totalPages,
2852
2873
  itemsCount: items.length,
@@ -3638,7 +3659,7 @@ export function registerRuntimeDataLane(tools) {
3638
3659
  // 券商 issue 1.3(cpdocs 2026-10-27):更新既有记录的主键契约——平台
3639
3660
  // BizObjectModel.getId() 只读 bizObject.data.id;顶层 bizObject.bizObjectId
3640
3661
  // 被保存逻辑忽略,errcode:0 但 objectId 是新 id(静默新建孤儿行)。
3641
- 'business-object data keyed by field code(关联/人员形状同默认描述)。**单选关联 WORK_SHEET 9=id 串或 `{id}`;MULT_WORK_SHEET 11/人员/组织 50/51 才数组;人员/组织元素 `{id,type,name}`,type 必填**。引擎拥有键(sequenceStatus 等)会被剥离——读改写的 sequenceStatus 不会把行钉回旧状态。新建时子表行缺 sortKey 会按数组下标补 1..n(平台读回按 sortKey ASC;更新既有记录请显式带 sortKey)。mappings 仅门户回填;子表快照字段为空会回 mappingSnapshotGap 点名行/字段;字典-backed 不校验取值(不存在/已停用码也会落库,要拦请配数据规则)。**`name` 是平台数据标题(模型可配置 summary,常见如 创建人+模型名+时间),传入会被覆盖;业务标识用自建字段**。既有记录更新:主键必须放 formData.id(顶层 bizObject.bizObjectId 被平台忽略会静默新建孤儿行——直调 REST 同理,cpdocs issue §1.3);id 无对应行会被拒(save-update-target-absent),新建请省略 id。'),
3662
+ 'business-object data keyed by field code(关联/人员形状同默认描述)。**单选关联 WORK_SHEET 9=id 串或 `{id}`;MULT_WORK_SHEET 11 写侧是分号串 `"id1;id2"`(数组是读回形状);人员/组织 50/51 写侧数组,元素 `{id,type,name}`,type 必填**;**子表用「子表字段 code」直接作键:`"<子表字段code>": [{<子列code>: value}]`(不是固定 items;行内关联/人员形状与顶层字段写侧一致,见 omc-write-hazards)**。引擎拥有键(sequenceStatus 等)会被剥离——读改写的 sequenceStatus 不会把行钉回旧状态。新建时子表行缺 sortKey 会按数组下标补 1..n(平台读回按 sortKey ASC;更新既有记录请显式带 sortKey)。mappings 仅门户回填;子表快照字段为空会回 mappingSnapshotGap 点名行/字段;字典-backed 不校验取值(不存在/已停用码也会落库,要拦请配数据规则)。**`name` 是平台数据标题(模型可配置 summary,常见如 创建人+模型名+时间),传入会被覆盖;业务标识用自建字段**。既有记录更新:主键必须放 formData.id(顶层 bizObject.bizObjectId 被平台忽略会静默新建孤儿行——直调 REST 同理,cpdocs issue §1.3);id 无对应行会被拒(save-update-target-absent),新建请省略 id。'),
3642
3663
  workflowCode: z.string().optional().describe("portal draft-save shape: create the row AND a DRAFT workflow instance + start workItem (finishStart=FALSE); submit later via data.submit with the returned workItemId. formData must NOT carry an id — in-place workflow start has no REST surface in 8.6.26。发起语义阶梯:本参数=发起停在第一节点(行/实例双 DRAFT,首办待办=发起人);到第一个审批节点用 data.submit 三件套;无流程模型用 submit:true 一调完成态;代他人发起(可选发起人)唯一路径=业务规则 CREATE+startWorkflow(完成态发起,不留草稿待办)"),
3643
3664
  submit: z.boolean().optional().describe("true=保存后立即直提(无流程模型 DRAFT→COMPLETED,触发 Create 规则);与 workflowCode 互斥。**按业务约定正式数据优先直接 data.submit(无 id=新建并提交一调完成)——本参数是便捷别名,save 的定位是草稿/暂存**"),
3644
3665
  allowStaffOnSubmit: z.boolean().optional().describe("submit:true 时显式允许携带人员字段(issue#10:人员字段提交面两种形状都可能 50000,可靠链路是 save 落库后提交时省略;个别平台构建接受提交面携带,自担风险)"),
@@ -119,7 +119,7 @@ export async function cmdModelScaffold(args) {
119
119
  const detail = error instanceof Error ? error.message : String(error);
120
120
  // F2(0.8.6):越界报错要能直接照做——旧文案只说「必须在配置根内」,
121
121
  // 不给路径。与 --args-file(cli.ts)同配方:给根内示例文件路径。
122
- return invalid(`--fields-file 读取失败:${detail}${/must be inside the configuration root/.test(detail) ? `。把参数文件放到 ${root} 之下(如 ${join(root, "args.json")}),再用 --fields-file 引用` : ""}`);
122
+ return invalid(`--fields-file 读取失败:${detail}${/must be inside the configuration root/.test(detail) ? `。把参数文件放到 ${root} 之下(如 ${join(root, "args.json")})再用 --fields-file 引用;不想落盘可直接用 stdin:--fields - < <文件>` : ""}`);
123
123
  }
124
124
  }
125
125
  if (inputJson === undefined)
@@ -369,6 +369,10 @@ const PATH_KEY_ALIASES = Object.freeze({
369
369
  content: "publishedContent",
370
370
  data: "fields",
371
371
  props: "properties",
372
+ // 探针 Q F4/F7:form.get 的布局在 draftRows/publishedRows(不是 layout);
373
+ // data.load 的记录在 data(不是 record)。
374
+ layout: "publishedRows",
375
+ record: "data",
372
376
  });
373
377
  export function pathMissDidYouMean(at, available, availableAll) {
374
378
  if (at === undefined || at.length === 0)
@@ -21,7 +21,8 @@ const restfulQueryService = Object.freeze({
21
21
  },
22
22
  preconditions: ["serviceCategoryId 由 service.category.list 解析(「全部」是空 id 虚拟项不可用);RESTFUL 服务 configJson 需要 auth 与 commonlist[url];带 methodName 时必须有 methodConfig"],
23
23
  conditionalRequirements: [
24
- "RESTFUL auth.code ∈ customer(parameterlist=[]) / basic(client… username/password) / oauth_password / oauth_client;parameterlist 每项 {code,value} 且必须与 auth.code 期望参数完全一致",
24
+ "鉴权只有平台内置 4 种:customer(无,parameterlist=[]) / basic(username/password) / oauth_password(client_id/client_secret/username/password/oauth_path) / oauth_client(client_id/client_secret/oauth_path);SOAP 只有 basic/customer。parameterlist 每项 {code,value},code 必须与平台 adapter_config.authList 完全一致",
25
+ "参数从哪来:username/password=目标系统账号与密码(不是 CloudPivot 账号);client_id/client_secret=目标系统 OAuth 应用注册后发放;oauth_path=目标系统的 token 端点(换 Bearer token 的地址)。每条鉴权的权威参数清单+来源:omc call service.adapter_config(authGuide);写失败时回执也会逐参数点名来源",
25
26
  "RESTFUL 方法 configJson 必需键:httpType(Post/Get/Put/Patch/Delete)、requestBodyType(Form-urlencoded/JSON/Text)、url、frontEndExtensionEnable(布尔)",
26
27
  "RESTFUL 每个输入/输出参数必须带 configJson.position ∈ QUERY_PARAMS/REQUEST_HEADER/REQUEST_BODY/PATH_PARAMS(URL_VARIABLE 被运行时拒 501007)",
27
28
  "每个输入/输出参数必须带 bizPropertyType(如 SHORT_TEXT/NUMERICAL)——缺它提交即被 bizservice-parameter-face-invalid 拒(r19-p7 首拒根因,2026-10-26 修正本配方)",
package/dist/skills.js CHANGED
@@ -303,7 +303,26 @@ export function readSkillSection(name, requested) {
303
303
  if (start < 0)
304
304
  return { document, section: "", headings };
305
305
  const startEntry = scanned.find((entry) => entry.index === start);
306
- return { document, section: sliceSectionText(lines, startEntry.index, startEntry.level), headings, heading: startEntry.heading, matchType };
306
+ // 探针 P F1(0.8.22):数字按**标题序号**匹配,不是文档第 N 篇。文档常有未编号的
307
+ // 前置节(omc-start-here 的「最小路径」),`--section 1` 会落到「1. Task → …」。
308
+ // 行为不变(序号语义有既有用户),但回执点明位置与第一篇,省一次重试。
309
+ // 复核:position 只数 level-2 篇(H1/H3 不算),并**不**生成带引号的复制命令
310
+ // (标题里可能有 `"`,截断前缀会拼出坏命令)。
311
+ const level2 = scanned.filter((entry) => entry.level === 2);
312
+ const position = level2.findIndex((entry) => entry.index === start) + 1;
313
+ const firstSection = level2[0] ?? scanned[0];
314
+ const ordinalMismatch = requestedOrdinal !== undefined && position > 0 && position !== Number(requestedOrdinal);
315
+ const sectionHint = ordinalMismatch && firstSection !== undefined
316
+ ? `--section 数字按**标题序号**匹配(本次命中文档第 ${position} 篇「${startEntry.heading}」),不是文档第 ${requestedOrdinal} 篇「${firstSection.heading}」;想按位置读请用标题前缀:--section '<该篇标题或前缀>'。`
317
+ : undefined;
318
+ return {
319
+ document,
320
+ section: sliceSectionText(lines, startEntry.index, startEntry.level),
321
+ headings,
322
+ heading: startEntry.heading,
323
+ matchType,
324
+ ...(sectionHint !== undefined ? { sectionHint } : {}),
325
+ };
307
326
  }
308
327
  /**
309
328
  * The "shape" of a topic: every heading with the bytes it would cost to read.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stalfh233/omc-cli",
3
- "version": "0.8.21",
3
+ "version": "0.8.24",
4
4
  "description": "CloudPivot 8.6 configuration capability CLI — governed, fail-closed, coverage-manifest bounded.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -58,7 +58,7 @@
58
58
  },
59
59
  "dependencies": {
60
60
  "commander": "14.0.3",
61
- "omc-core": "0.8.21",
61
+ "omc-core": "0.8.24",
62
62
  "proper-lockfile": "4.1.2",
63
63
  "write-file-atomic": "6.0.0",
64
64
  "zod": "^3.23.8",
@@ -76,6 +76,6 @@
76
76
  "directory": "packages/omc-cli"
77
77
  },
78
78
  "optionalDependencies": {
79
- "@stalfh233/omc-fake-platform": "0.8.21"
79
+ "@stalfh233/omc-fake-platform": "0.8.24"
80
80
  }
81
81
  }