@hcmai/cli 0.18.0 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -728,8 +728,8 @@ var init_TerminalRenderer = __esm({
728
728
  if (totalTokens) {
729
729
  const inTok = stats?.inputTokens ?? 0;
730
730
  const outTok = stats?.outputTokens ?? 0;
731
- const split = inTok > 0 || outTok > 0 ? ` (\u2191${inTok}/\u2193${outTok})` : "";
732
- segs.push(`${totalTokens} tok${split}`);
731
+ const split2 = inTok > 0 || outTok > 0 ? ` (\u2191${inTok}/\u2193${outTok})` : "";
732
+ segs.push(`${totalTokens} tok${split2}`);
733
733
  }
734
734
  if (stats?.toolCount) segs.push(`${stats.toolCount} \u5DE5\u5177`);
735
735
  if (stats?.delegationCount) segs.push(`${stats.delegationCount} \u59D4\u6D3E`);
@@ -1405,8 +1405,8 @@ function BlockView({ block: b }) {
1405
1405
  case "done": {
1406
1406
  const segs = [`${b.durMs}ms`];
1407
1407
  if (b.totalTokens) {
1408
- const split = b.inputTokens || b.outputTokens ? ` (\u2191${b.inputTokens ?? 0}/\u2193${b.outputTokens ?? 0})` : "";
1409
- segs.push(`${b.totalTokens} tok${split}`);
1408
+ const split2 = b.inputTokens || b.outputTokens ? ` (\u2191${b.inputTokens ?? 0}/\u2193${b.outputTokens ?? 0})` : "";
1409
+ segs.push(`${b.totalTokens} tok${split2}`);
1410
1410
  }
1411
1411
  if (b.toolCount) segs.push(`${b.toolCount} \u5DE5\u5177`);
1412
1412
  if (b.delegationCount) segs.push(`${b.delegationCount} \u59D4\u6D3E`);
@@ -1444,7 +1444,7 @@ import { useEffect, useRef, useState } from "react";
1444
1444
  import { Box as Box2, Text as Text2, useInput } from "ink";
1445
1445
  import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
1446
1446
  function MultilineInput(props) {
1447
- const { value, onChange, onSubmit, placeholder = "", prompt = "\u203A ", onHistoryUp, onHistoryDown, onEscapeClear, captureKey } = props;
1447
+ const { value, onChange, onSubmit, placeholder: placeholder2 = "", prompt = "\u203A ", onHistoryUp, onHistoryDown, onEscapeClear, captureKey } = props;
1448
1448
  const [cursor, setCursor] = useState(value.length);
1449
1449
  const selfEdit = useRef(false);
1450
1450
  useEffect(() => {
@@ -1518,8 +1518,8 @@ function MultilineInput(props) {
1518
1518
  if (!value) {
1519
1519
  return /* @__PURE__ */ jsxs2(Box2, { children: [
1520
1520
  /* @__PURE__ */ jsx2(Text2, { color: "cyan", children: prompt }),
1521
- /* @__PURE__ */ jsx2(Text2, { inverse: true, children: placeholder.charAt(0) || " " }),
1522
- /* @__PURE__ */ jsx2(Text2, { dimColor: true, children: placeholder.slice(1) })
1521
+ /* @__PURE__ */ jsx2(Text2, { inverse: true, children: placeholder2.charAt(0) || " " }),
1522
+ /* @__PURE__ */ jsx2(Text2, { dimColor: true, children: placeholder2.slice(1) })
1523
1523
  ] });
1524
1524
  }
1525
1525
  const lines = value.split("\n");
@@ -9201,7 +9201,7 @@ async function resolveAdminPassword(args) {
9201
9201
  return { pwd: await promptSecret("Admin password: "), stdinTaken: false };
9202
9202
  }
9203
9203
  async function resolveEndpoint2(args) {
9204
- if (args.endpoint) return args.endpoint;
9204
+ if (args.endpoint) return { endpoint: args.endpoint };
9205
9205
  const g = await loadGlobalConfig7();
9206
9206
  const resolved = await resolveEnvContext6({ envFlag: args.env }, process.env, g);
9207
9207
  printResolvedEnvironment5(resolved);
@@ -9212,27 +9212,55 @@ async function resolveEndpoint2(args) {
9212
9212
  message: "\u672A\u89E3\u6790\u5230 endpoint \u2014\u2014 \u4F20 --endpoint <url>\uFF0C\u6216\u5148 `hcm env add <name> --endpoint <url>`"
9213
9213
  });
9214
9214
  }
9215
- return env2.endpoint;
9215
+ return { endpoint: env2.endpoint, frontend: env2.frontend };
9216
+ }
9217
+ function bootstrapDisplayUrl(address, label) {
9218
+ try {
9219
+ const url = new URL(address);
9220
+ if (url.protocol !== "http:" && url.protocol !== "https:") throw new TypeError("unsupported protocol");
9221
+ url.username = "";
9222
+ url.password = "";
9223
+ url.search = "";
9224
+ url.hash = "";
9225
+ return url;
9226
+ } catch {
9227
+ throw new CliError22({
9228
+ code: CliErrorCode23.INVALID_ARGUMENT,
9229
+ message: `${label}\u5FC5\u987B\u662F\u5E26 http:// \u6216 https:// \u7684\u5B8C\u6574\u5730\u5740\uFF1B\u8BF7\u5148\u4FEE\u6B63\u914D\u7F6E\uFF0C\u518D\u5F00\u901A\u79DF\u6237\u3002`
9230
+ });
9231
+ }
9216
9232
  }
9217
9233
  async function tenantBootstrapCommand(args) {
9218
9234
  try {
9219
- if (!args.tenantId || !args.adminUsername) {
9235
+ if (!args.tenantId) {
9220
9236
  throw new CliError22({
9221
9237
  code: CliErrorCode23.MISSING_FLAG,
9222
- message: "--tenant-id \u4E0E --admin-username \u5FC5\u586B"
9238
+ message: "--tenant-id \u5FC5\u586B"
9239
+ });
9240
+ }
9241
+ const adminUsername = args.adminUsername ?? "admin";
9242
+ if (adminUsername !== "admin") {
9243
+ throw new CliError22({
9244
+ code: CliErrorCode23.INVALID_ARGUMENT,
9245
+ message: "\u670D\u52A1\u7AEF\u4EC5\u63A5\u53D7\u7BA1\u7406\u5458\u7528\u6237\u540D admin\uFF1B\u8BF7\u7701\u7565 --admin-username \u6216\u6307\u5B9A admin"
9223
9246
  });
9224
9247
  }
9225
- const endpoint = await resolveEndpoint2(args);
9248
+ const { endpoint, frontend: configuredFrontend } = await resolveEndpoint2(args);
9226
9249
  const project2 = await discoverProjectEnv4();
9250
+ const matchingFrontends = [...new Set(Object.values(project2?.config.environments ?? {}).filter((candidate) => candidate.endpoint === normalizeOrigin4(endpoint)).map((candidate) => candidate.frontend))];
9251
+ const frontend = configuredFrontend ?? (matchingFrontends.length === 1 ? matchingFrontends[0] : void 0);
9227
9252
  const protectedNames = project2 ? Object.entries(project2.config.environments).filter(([, candidate]) => candidate.danger && candidate.endpoint === normalizeOrigin4(endpoint)).map(([name]) => name) : [];
9228
9253
  assertDangerWrite4({ name: protectedNames.join(", "), danger: protectedNames.length > 0, allowDanger: args.allowDanger }, "\u5F00\u901A\u79DF\u6237");
9229
- if (args.endpoint) process.stderr.write(`\u2192 ${endpoint} \xB7 \u79DF\u6237 ${args.tenantId} \xB7 \u8EAB\u4EFD bootstrap key\uFF08\u6765\u81EA --endpoint\uFF09
9254
+ const endpointDisplay = bootstrapDisplayUrl(endpoint, "\u670D\u52A1\u5730\u5740\uFF08endpoint\uFF09");
9255
+ const loginUrl = bootstrapDisplayUrl(frontend ?? endpoint, frontend ? "\u524D\u7AEF\u5730\u5740\uFF08frontend\uFF09" : "\u670D\u52A1\u5730\u5740\uFF08endpoint\uFF09");
9256
+ loginUrl.pathname = `${loginUrl.pathname.replace(/\/+$/, "")}/login`;
9257
+ if (args.endpoint) process.stderr.write(`\u2192 ${endpointDisplay} \xB7 \u79DF\u6237 ${args.tenantId} \xB7 \u8EAB\u4EFD bootstrap key\uFF08\u6765\u81EA --endpoint\uFF09
9230
9258
  `);
9231
9259
  const { pwd, stdinTaken } = await resolveAdminPassword(args);
9232
9260
  const key2 = await resolveBootstrapKey(args, stdinTaken);
9233
9261
  if (!args.yes) {
9234
9262
  const ok = await promptConfirm(
9235
- `\u5C06\u5728 ${endpoint} \u521B\u5EFA\u79DF\u6237 "${args.tenantId}"\uFF08admin: ${args.adminUsername}\uFF09\u3002\u6B64\u64CD\u4F5C\u4E0D\u53EF\u9006\uFF0C\u7EE7\u7EED\uFF1F`
9263
+ `\u5C06\u5728 ${endpointDisplay} \u521B\u5EFA\u79DF\u6237 "${args.tenantId}"\uFF08admin: ${adminUsername}\uFF09\u3002\u6B64\u64CD\u4F5C\u4E0D\u53EF\u9006\uFF0C\u7EE7\u7EED\uFF1F`
9236
9264
  );
9237
9265
  if (!ok) {
9238
9266
  process.stderr.write("\u5DF2\u53D6\u6D88\n");
@@ -9247,19 +9275,19 @@ async function tenantBootstrapCommand(args) {
9247
9275
  });
9248
9276
  const result = await bootstrapTenant(http, key2, {
9249
9277
  tenantId: args.tenantId,
9250
- adminUsername: args.adminUsername,
9278
+ adminUsername,
9251
9279
  adminPassword: pwd,
9252
9280
  tenantName: args.tenantName
9253
9281
  });
9254
9282
  const fmt = args.output ?? "json";
9255
- if (fmt !== "json") {
9256
- process.stdout.write(
9257
- `\u2705 \u79DF\u6237 ${result.tenantId} \u5DF2\u5F00\u901A\uFF08adminUserId ${result.adminUserId ?? "-"}\uFF09
9258
- \u4E0B\u4E00\u6B65\uFF1Ahcm env add <name> --endpoint ${endpoint} && hcm login --env <name>
9259
- `
9260
- );
9261
- }
9262
9283
  process.stdout.write(formatObject20(result, { format: fmt }) + "\n");
9284
+ const addressSource = frontend ? "\u767B\u5F55\u5730\u5740" : "\u767B\u5F55\u5730\u5740\uFF08\u672A\u914D\u7F6E\u524D\u7AEF\u5730\u5740\uFF0C\u6309 API \u540C\u6E90\u63A8\u6D4B\uFF0C\u8BF7\u786E\u8BA4\uFF09";
9285
+ loginUrl.searchParams.set("tenantId", result.tenantId);
9286
+ process.stderr.write(
9287
+ `\u4E0B\u4E00\u6B65\uFF1A\u6253\u5F00${addressSource} ${loginUrl.toString()}\uFF0C\u4F7F\u7528 admin \u548C\u521D\u59CB\u5BC6\u7801\u767B\u5F55\u3002
9288
+ \u9996\u6B21\u767B\u5F55\u9700\u8981\u4FEE\u6539\u5BC6\u7801\uFF1B\u767B\u5F55\u540E\u524D\u5F80\u300C\u7CFB\u7EDF\u8BBE\u7F6E \u2192 \u96C6\u6210\u4E2D\u5FC3 \u2192 \u534F\u540C\u5E73\u53F0\u300D\u5F00\u901A\u4F01\u4E1A\u5FAE\u4FE1\u3002
9289
+ `
9290
+ );
9263
9291
  process.exitCode = 0;
9264
9292
  return;
9265
9293
  } catch (e) {
@@ -12476,19 +12504,19 @@ async function gapVerifyCommand(ref, args, deps = defaultDeps) {
12476
12504
  init_auth_guard();
12477
12505
  import { promises as fs12 } from "fs";
12478
12506
  import path14 from "path";
12479
- import axios8 from "axios";
12507
+ import axios9 from "axios";
12480
12508
  import {
12481
- CliError as CliError30,
12482
- CliErrorCode as CliErrorCode31,
12509
+ CliError as CliError31,
12510
+ CliErrorCode as CliErrorCode32,
12483
12511
  formatObject as formatObject28,
12484
12512
  httpProbe as httpProbe2,
12485
- loadGlobalConfig as loadGlobalConfig11,
12513
+ loadGlobalConfig as loadGlobalConfig12,
12486
12514
  loadIdentity as loadIdentity5,
12487
12515
  parseEnvYaml as parseEnvYaml3,
12488
12516
  releasePendingImpersonationSessions as releasePendingImpersonationSessions2,
12489
12517
  resolveActiveIdentity as resolveActiveIdentity2,
12490
- resolveEnvContext as resolveEnvContext8,
12491
- printResolvedEnvironment as printResolvedEnvironment8,
12518
+ resolveEnvContext as resolveEnvContext9,
12519
+ printResolvedEnvironment as printResolvedEnvironment9,
12492
12520
  conversationWebSocketEndpoint as conversationWebSocketEndpoint4,
12493
12521
  probeConversationHandshake
12494
12522
  } from "@hcmai/sdk";
@@ -14181,7 +14209,7 @@ function throttleNote(out) {
14181
14209
  const retryAfter = out.headers["retry-after"] || details?.retryAfter;
14182
14210
  return `${httpNote(out)} \xB7 ${retryAfter !== void 0 && retryAfter !== null ? `retryAfter=${retryAfter}` : "\u670D\u52A1\u7AEF\u672A\u63D0\u4F9B retryAfter"}${typeof error?.next_step === "string" ? `\uFF1B${error.next_step}` : ""}`;
14183
14211
  }
14184
- function reportEnvelopeError(body) {
14212
+ function reportEnvelopeError(body, platformOps = false) {
14185
14213
  if (!object(body)) return "\u6B63\u6587\u5FC5\u987B\u662F\u5BF9\u8C61";
14186
14214
  if (body.schemaVersion === void 0 || body.schemaVersion === null) return "\u7F3A\u5C11 schemaVersion";
14187
14215
  if (body.schemaVersion !== 1) return `schemaVersion=${String(body.schemaVersion)} \u4E0D\u53D7\u652F\u6301\uFF1B\u5347\u7EA7 CLI`;
@@ -14191,6 +14219,8 @@ function reportEnvelopeError(body) {
14191
14219
  if (!object(row) || typeof row.checkId !== "string") return `results[${i}].checkId \u5FC5\u987B\u662F\u5B57\u7B26\u4E32`;
14192
14220
  if (!["platform", "tenant"].includes(String(row.layer))) return `results[${i}].layer \u5FC5\u987B\u662F platform / tenant`;
14193
14221
  }
14222
+ if (platformOps && (!Array.isArray(body.checks) || !body.checks.every((row) => object(row) && typeof row.id === "string")))
14223
+ return "checks \u5FC5\u987B\u662F\u5E26\u5B57\u7B26\u4E32 id \u7684\u5BF9\u8C61\u6570\u7EC4";
14194
14224
  if (body.scope !== void 0 && !object(body.scope)) return "scope \u5FC5\u987B\u662F\u5BF9\u8C61";
14195
14225
  const disabled = object(body.scope) ? body.scope.policyDisabled : void 0;
14196
14226
  if (disabled !== void 0 && !Array.isArray(disabled)) return "scope.policyDisabled \u5FC5\u987B\u662F\u6570\u7EC4";
@@ -14238,12 +14268,13 @@ function verdictViolation(row) {
14238
14268
  if (v.level === "NOT_APPLICABLE" && !!c2 && c2.missing + c2.failed > 0) return "NOT_APPLICABLE \u5E26\u7F3A\u53E3";
14239
14269
  return void 0;
14240
14270
  }
14241
- function reconcileReport(ctx, env2, report, requested) {
14242
- const known = serverCatalogKnown(env2.catalog, report), changed = catalogChanged(env2.catalog, report);
14243
- const expected = known && !changed ? expectedServerIds(env2.catalog, report, requested) : new Set(report.scopeIds);
14271
+ function reconcileReport(ctx, env2, report, requested, platformOps) {
14272
+ const known = !platformOps && serverCatalogKnown(env2.catalog, report), changed = !platformOps && catalogChanged(env2.catalog, report);
14273
+ const expected = known && !changed ? expectedServerIds(env2.catalog, report, requested) : new Set(platformOps ? report.scopeIds.filter((id) => id.startsWith("platform.")) : report.scopeIds);
14244
14274
  const scope = new Set(report.scopeIds), rows2 = [];
14245
14275
  const issues = /* @__PURE__ */ new Map();
14246
14276
  const layerFor = (id) => {
14277
+ if (platformOps) return "platform";
14247
14278
  const layer2 = known ? env2.catalog?.checks.find((c2) => c2.id === id)?.spec?.layer : void 0;
14248
14279
  return layer2 === "platform" || layer2 === "tenant" ? layer2 : String(id).startsWith("platform.") ? "platform" : "tenant";
14249
14280
  };
@@ -14252,6 +14283,9 @@ function reconcileReport(ctx, env2, report, requested) {
14252
14283
  issue("platform", note);
14253
14284
  issue("tenant", note);
14254
14285
  };
14286
+ if (platformOps) {
14287
+ for (const id of report.scopeIds) if (!id.startsWith("platform.")) issue("platform", `${id}\uFF1A\u8FD0\u7EF4\u62A5\u544A\u8303\u56F4\u4E0D\u662F platform`);
14288
+ }
14255
14289
  const synthesize = (id, code2, note) => {
14256
14290
  env2.report.server.verdict = null;
14257
14291
  const catalogRow = known ? env2.catalog?.checks.find((c2) => c2.id === id) : void 0;
@@ -14294,6 +14328,10 @@ function reconcileReport(ctx, env2, report, requested) {
14294
14328
  for (const row of report.results) groups.set(row.checkId, [...groups.get(row.checkId) ?? [], row]);
14295
14329
  for (const [id, group] of groups) {
14296
14330
  const row = group[0];
14331
+ if (platformOps && row.layer !== "platform") {
14332
+ issue("platform", `${id}\uFF1A\u8FD0\u7EF4\u62A5\u544A\u7ED3\u679C\u5C42\u4E0D\u662F platform`);
14333
+ continue;
14334
+ }
14297
14335
  if (!changed && !scope.has(id)) {
14298
14336
  issue(row.layer, `${id}\uFF1A\u7ED3\u679C\u8D8A\u51FA\u672C\u6B21\u8303\u56F4`);
14299
14337
  continue;
@@ -14305,17 +14343,25 @@ function reconcileReport(ctx, env2, report, requested) {
14305
14343
  for (const id of expected) if (!rows2.some((row) => row.checkId === id))
14306
14344
  rows2.push(synthesize(id, "REPORT_ITEM_MISSING", "CLI \u8865\u9879\uFF1A\u670D\u52A1\u7AEF\u62A5\u544A\u91CC\u6CA1\u6709\u8FD9\u4E00\u9879"));
14307
14345
  }
14308
- const selected = (layer2) => (layer2 === "platform" || layer2 === "tenant") && (!ctx.scope || ctx.scope.serverLayers.has(layer2));
14346
+ const selected = (layer2) => (layer2 === "platform" || layer2 === "tenant") && (platformOps ? layer2 === "platform" : !ctx.scope || ctx.scope.serverLayers.has(layer2));
14309
14347
  const marks = /* @__PURE__ */ new Map();
14310
14348
  for (const [layer2, notes] of issues) {
14311
- const home = selected(layer2) ? layer2 : SERVER_PLACEHOLDERS.map((d) => d.layer).find(selected);
14349
+ const home = selected(layer2) ? layer2 : platformOps ? "platform" : SERVER_PLACEHOLDERS.map((d) => d.layer).find(selected);
14312
14350
  marks.set(home, [...marks.get(home) ?? [], ...notes.map((note) => home === layer2 ? note : `${String(layer2)} \u5C42\uFF08\u4E0D\u5728\u672C\u6B21\u8303\u56F4\uFF09\uFF1A${note}`)]);
14313
14351
  }
14314
- for (const [layer2, notes] of marks) rows2.push(...placeholderRows(
14315
- ctx,
14316
- env2,
14317
- unknown("REPORT_MALFORMED", "\u670D\u52A1\u7AEF\u4F53\u68C0\u62A5\u544A\u5BF9\u8D26\u4E0D\u7B26\uFF08CLI \u6807\u8BB0\uFF09", { reason: "EVALUATOR_ERROR", note: notes.join("\uFF1B") })
14318
- ).filter((r) => r.layer === layer2));
14352
+ for (const [layer2, notes] of marks) {
14353
+ env2.report.server.verdict = null;
14354
+ const observation = unknown("REPORT_MALFORMED", "\u670D\u52A1\u7AEF\u4F53\u68C0\u62A5\u544A\u5BF9\u8D26\u4E0D\u7B26\uFF08CLI \u6807\u8BB0\uFF09", { reason: "EVALUATOR_ERROR", note: notes.join("\uFF1B") });
14355
+ rows2.push(...platformOps ? [makeResult(
14356
+ platformOps.placeholder,
14357
+ observation,
14358
+ env2.name,
14359
+ true,
14360
+ ctx.requestedAt,
14361
+ 0,
14362
+ codeStep("REPORT_MALFORMED", env2.name)
14363
+ )] : placeholderRows(ctx, env2, observation).filter((r) => r.layer === layer2));
14364
+ }
14319
14365
  return rows2;
14320
14366
  }
14321
14367
  async function fetchServerReport(ctx, env2, dependencies, deadline, requested = fullScope) {
@@ -14374,8 +14420,8 @@ async function fetchServerReport(ctx, env2, dependencies, deadline, requested =
14374
14420
  env2.report.server.verdict = null;
14375
14421
  return [];
14376
14422
  }
14377
- const failure = failedReport(out, env2, ctx.as);
14378
- if (failure) return placeholderRows(ctx, env2, failure, Date.now() - started);
14423
+ const failure2 = failedReport(out, env2, ctx.as);
14424
+ if (failure2) return placeholderRows(ctx, env2, failure2, Date.now() - started);
14379
14425
  const report = out.body;
14380
14426
  env2.serverReport = report;
14381
14427
  Object.assign(env2.report.server, {
@@ -14592,6 +14638,8 @@ var CODE_TABLE = {
14592
14638
  HEALTH_API_ROUTE_MISSING: c("\u63A8\u65AD\u4F53\u68C0\u8DEF\u7531\u672A\u5230\u540E\u7AEF\uFF1B\u68C0\u67E5\u53CD\u4EE3\u653E\u884C\u4E0E\u54CD\u5E94\u5934"),
14593
14639
  REPORT_THROTTLED: c("\u670D\u52A1\u7AEF\u4F53\u68C0\u63A5\u53E3\u8BF7\u6C42\u88AB\u9650\u6D41\uFF1B\u6309 retryAfter \u7A0D\u540E\u91CD\u8BD5"),
14594
14640
  REPORT_UNAUTHORIZED: c("\u670D\u52A1\u7AEF\u4F53\u68C0\u63A5\u53E3\u8BF7\u6C42\u6743\u9650\u4E0D\u8DB3", "WARN", "FDE", login),
14641
+ HEALTH_OPS_KEY_INVALID: c("\u8FD0\u7EF4\u53EA\u8BFB\u5BC6\u94A5\u88AB\u62D2\uFF1A\u6CA1\u5E26\u3001\u4E0D\u5339\u914D\uFF0C\u6216\u670D\u52A1\u7AEF\u6CA1\u914D / \u5DF2\u505C\u7528", "WARN", "RND"),
14642
+ HEALTH_OPS_KEY_LOCKED: c("\u8BE5\u6765\u6E90\u8FD0\u7EF4\u5BC6\u94A5\u8FDE\u9519\u88AB\u9501\uFF1B\u6309 retryAfter \u7B49\u5F85\u540E\u7528\u6B63\u786E\u5BC6\u94A5\u91CD\u8BD5", "WARN", "RND"),
14595
14643
  REPORT_UNAVAILABLE: c("\u670D\u52A1\u7AEF\u4F53\u68C0\u63A5\u53E3\u6682\u4E0D\u53EF\u7528\uFF1B\u7A0D\u540E\u91CD\u8BD5"),
14596
14644
  REPORT_MALFORMED: c("\u670D\u52A1\u7AEF\u4F53\u68C0\u63A5\u53E3\u54CD\u5E94\u65E0\u6CD5\u89E3\u6790\uFF1B\u8054\u7CFB\u7814\u53D1\u6838\u5BF9\u534F\u8BAE", "WARN", "RND"),
14597
14645
  REPORT_ITEM_MISSING: c("\u670D\u52A1\u7AEF\u62A5\u544A\u91CC\u6CA1\u6709\u8FD9\u4E00\u9879", "WARN", "RND"),
@@ -14767,6 +14815,45 @@ function assembleReport(input) {
14767
14815
  if (level === "FOUND" && (grade === "CRITICAL" || grade === "WARN")) foundByGrade[grade]++;
14768
14816
  }
14769
14817
  const targetResults = input.results.filter((r) => r.env === null || r.env === input.targetEnv);
14818
+ if (input.platformOps) {
14819
+ const known2 = !!input.serverReport && input.serverReport.catalogRevision != null;
14820
+ const expected2 = new Set(input.serverReport?.scopeIds ?? []);
14821
+ const checked2 = targetResults.filter((r) => ["PASS", "FOUND", "NOT_APPLICABLE"].includes(r.verdict?.level) && (r.layer === "connect" || expected2.has(r.checkId))).length;
14822
+ const total2 = known2 ? targetResults.filter((r) => r.layer === "connect").length + expected2.size : null;
14823
+ const incomplete2 = /* @__PURE__ */ new Set([
14824
+ "platform-ops-view",
14825
+ ...!known2 ? ["server-catalog-unknown"] : [],
14826
+ ...input.scope?.only.length ? ["only"] : [],
14827
+ ...(input.scope?.skip ?? []).map((t) => `skip:${t}`),
14828
+ ...known2 && expected2.size === 0 ? ["empty-layer:platform"] : [],
14829
+ ...(input.serverReport?.scope?.incompleteBecause ?? []).filter((t) => t !== "only" && !t.startsWith("skip:") && !t.startsWith("empty-layer:"))
14830
+ ]);
14831
+ return {
14832
+ schemaVersion: 2,
14833
+ verdict: conclude(input.results, { total: total2, failOn: input.failOn }).verdict,
14834
+ counts,
14835
+ foundByGrade,
14836
+ coverage: { checked: checked2, total: total2 },
14837
+ scope: {
14838
+ stage: null,
14839
+ only: input.scope?.only ?? [],
14840
+ skip: input.scope?.skip ?? [],
14841
+ active: false,
14842
+ serverCatalogKnown: known2,
14843
+ addedPrerequisites: input.scope?.addedPrerequisites ?? [],
14844
+ policyDisabled: [],
14845
+ incompleteBecause: [...incomplete2],
14846
+ complete: false
14847
+ },
14848
+ cli: { version: input.cliVersion },
14849
+ project: null,
14850
+ targetEnv: input.targetEnv,
14851
+ generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
14852
+ durationMs: Date.now() - input.startedAt,
14853
+ environments: input.environments,
14854
+ results: input.results
14855
+ };
14856
+ }
14770
14857
  const requested = input.scope ? {
14771
14858
  stage: input.scope.stage,
14772
14859
  only: input.scope.forwardedOnly,
@@ -14863,15 +14950,27 @@ function renderChironDoctor(report) {
14863
14950
  const target = report.environments.find((env2) => env2.target);
14864
14951
  const version2 = target?.backend.version;
14865
14952
  const backend = !version2 || version2 === "unknown" ? "\u540E\u7AEF\u7248\u672C\u672A\u77E5" : `\u540E\u7AEF ${version2}`;
14953
+ const platformOps = report.scope.incompleteBecause.includes("platform-ops-view");
14866
14954
  const out = [
14867
14955
  `\u777F\u620E\u4F53\u68C0 \xB7 \u9879\u76EE ${report.project} \xB7 \u76EE\u6807 ${report.targetEnv ?? "\u672A\u89E3\u6790"}${report.scope.stage ? ` \xB7 \u9636\u6BB5 ${report.scope.stage}` : ""} \xB7 CLI ${report.cli.version} \xB7 ${backend}${target?.backend.commit ? `\uFF08commit ${target.backend.commit.slice(0, 7)}\uFF09` : ""}`,
14868
14956
  "\u4E0B\u4E00\u6B65\u547D\u4EE4\u5728\u9879\u76EE\u76EE\u5F55\u6267\u884C\u3002"
14869
14957
  ];
14870
- const groups = [
14958
+ if (platformOps) {
14959
+ out[0] = `\u777F\u620E\u4F53\u68C0 \xB7 \u8FD0\u7EF4\u89C6\u56FE \xB7 \u76EE\u6807 ${report.targetEnv ?? "\u672A\u89E3\u6790"} \xB7 CLI ${report.cli.version} \xB7 ${backend}${target?.backend.commit ? `\uFF08commit ${target.backend.commit.slice(0, 7)}\uFF09` : ""}`;
14960
+ out.pop();
14961
+ }
14962
+ const groups = platformOps ? [
14963
+ ["\u8FDE\u63A5", report.results.filter((r) => r.layer === "connect")],
14964
+ [
14965
+ `\u5E73\u53F0\u5E95\u5EA7 \xB7 ${target?.server.instance ? `\u5E94\u7B54\u5B9E\u4F8B ${String(target.server.instance.id ?? "\u672A\u77E5")} \xB7 ${String(target.server.instance.runtimeRole ?? "\u8FD0\u884C\u89D2\u8272\u672A\u77E5")}` : "\u672A\u53D6\u5230\u62A5\u544A"}`,
14966
+ report.results.filter((r) => r.layer === "platform"),
14967
+ "platform"
14968
+ ]
14969
+ ] : [
14871
14970
  ["\u672C\u673A\u5DE5\u4F4D", report.results.filter((r) => r.layer === "local")],
14872
14971
  ...report.environments.map((env2) => [`\u8FDE\u63A5\u4E0E\u8EAB\u4EFD \xB7 ${env2.name}${env2.target ? "\uFF08\u76EE\u6807\uFF09" : ""}`, report.results.filter((r) => r.layer === "connect" && r.env === env2.name)])
14873
14972
  ];
14874
- if (target) groups.push(
14973
+ if (target && !platformOps) groups.push(
14875
14974
  [`\u5E73\u53F0\u5E95\u5EA7 \xB7 ${target.name}${target.server.deploymentTenancy === "shared" ? "\uFF08\u5171\u4EAB\u5B9E\u4F8B\uFF1A\u5E73\u53F0\u5C42\u53EA\u5BF9\u5E73\u53F0\u8FD0\u7EF4\u5F00\u653E\uFF09" : ""}`, report.results.filter((r) => r.layer === "platform" && r.env === target.name), "platform"],
14876
14975
  [`\u79DF\u6237\u5C31\u7EEA \xB7 \u79DF\u6237 ${target.tenant}`, report.results.filter((r) => r.layer === "tenant" && r.env === target.name), "tenant"]
14877
14976
  );
@@ -14904,7 +15003,7 @@ function renderChironDoctor(report) {
14904
15003
  out.push(` ${mark} ${row.name}${row.requirement === "OPTIONAL" ? "\uFF08\u9009\u68C0\uFF09" : ""}${row.layer === "local" && row.env ? ` \xB7 ${row.env}` : ""} ${String(row.summary).replace(/\r?\n/g, "\n ")}`);
14905
15004
  }
14906
15005
  if (v?.note) out.push(indented(v.note));
14907
- if (v?.level !== "PASS" && row.nextStep && (v?.level !== "NOT_APPLICABLE" || row.nextStep.command)) out.push(indented(`\u2192 ${row.nextStep.command ?? "\u6309\u672C\u9879\u8BF4\u660E\u5904\u7406\u540E\u91CD\u8DD1 hcm chiron doctor"} [${row.nextStep.owner}]`));
15006
+ if (v?.level !== "PASS" && row.nextStep && (v?.level !== "NOT_APPLICABLE" || row.nextStep.command)) out.push(indented(`\u2192 ${row.nextStep.command ?? `\u6309\u672C\u9879\u8BF4\u660E\u5904\u7406\u540E\u91CD\u8DD1 hcm chiron doctor${platformOps ? " --platform-ops" : ""}`} [${row.nextStep.owner}]`));
14908
15007
  }
14909
15008
  }
14910
15009
  const active = report.results.filter(isOptIn).length;
@@ -14917,9 +15016,402 @@ function renderChironDoctor(report) {
14917
15016
  if (report.scope.incompleteBecause.includes("catalog-changed")) out.push("\u6838\u9A8C\u671F\u95F4\u68C0\u67E5\u76EE\u5F55\u53D1\u751F\u53D8\u5316\uFF0C\u7A0D\u540E\u91CD\u8DD1");
14918
15017
  const actions = firstActions(report.results);
14919
15018
  if (actions.length) out.push(`\u5148\u5904\u7406\uFF1A${actions.map((r) => `${r.checkId}${r.env ? `\uFF08${r.env}\uFF09` : ""}`).join("\u3001")}`);
15019
+ if (platformOps) {
15020
+ const note = target?.server?.note;
15021
+ if (note) out.push(note);
15022
+ out.push("\u672C\u62A5\u544A\u4EC5\u4EE3\u8868\u5E94\u7B54\u5B9E\u4F8B");
15023
+ }
14920
15024
  return out.join("\n");
14921
15025
  }
14922
15026
 
15027
+ // src/commands/doctor/platform-ops.ts
15028
+ import { createHash as createHash8 } from "crypto";
15029
+ import axios8 from "axios";
15030
+ import {
15031
+ classifyStatus as classifyStatus2,
15032
+ CliError as CliError30,
15033
+ CliErrorCode as CliErrorCode31,
15034
+ loadGlobalConfig as loadGlobalConfig11,
15035
+ printResolvedEnvironment as printResolvedEnvironment8,
15036
+ resolveEnvContext as resolveEnvContext8
15037
+ } from "@hcmai/sdk";
15038
+ var OPS_PATH = "/api/system/health/ops/report";
15039
+ var connectivity2 = CHECKS.find((row) => row.id === "connect.connectivity");
15040
+ var api = {
15041
+ ...CHECKS.find((row) => row.id === "connect.health-api"),
15042
+ dependsOn: ["connect.connectivity"],
15043
+ timeoutMs: 26e3,
15044
+ codes: [
15045
+ "BACKEND_UNSUPPORTED",
15046
+ "HEALTH_API_ROUTE_MISSING",
15047
+ "REPORT_UNAVAILABLE",
15048
+ "REPORT_MALFORMED",
15049
+ "BUDGET_EXHAUSTED"
15050
+ ],
15051
+ run: async (ctx, env2, execution) => {
15052
+ const remaining = (ctx.opsDeadline ?? Date.now()) - Date.now();
15053
+ if (remaining < 3e3) return unknown("BUDGET_EXHAUSTED", "\u9884\u7B97\u8017\u5C3D\uFF0C\u672A\u542F\u52A8", { note: "\u9884\u7B97\u8017\u5C3D\uFF0C\u672A\u542F\u52A8" });
15054
+ const timeoutMs = Math.min(25e3, remaining);
15055
+ let out;
15056
+ try {
15057
+ out = await ctx.services.opsReportRequest(
15058
+ env2.config.endpoint,
15059
+ ctx.opsKey,
15060
+ timeoutMs,
15061
+ Math.min(15e3, timeoutMs - 2e3),
15062
+ execution.signal,
15063
+ { only: ctx.scope?.forwardedOnly ?? [], skip: ctx.scope?.forwardedSkip ?? [] }
15064
+ );
15065
+ } catch (error) {
15066
+ const stopped = execution.signal.aborted || axios8.isAxiosError(error) && ["ECONNABORTED", "ETIMEDOUT"].includes(error.code ?? "") || ["ECONNABORTED", "ETIMEDOUT"].includes(String(error.code));
15067
+ return unknown(
15068
+ "REPORT_UNAVAILABLE",
15069
+ "\u670D\u52A1\u7AEF\u4F53\u68C0\u63A5\u53E3\u6682\u4E0D\u53EF\u7528\uFF1B\u7A0D\u540E\u91CD\u8BD5",
15070
+ { note: `HTTP \u672A\u53D6\u5F97\u54CD\u5E94\uFF1B${stopped ? "\u5DF2\u505C\u6B62\u7B49\u5F85" : safeError(error)}` }
15071
+ );
15072
+ }
15073
+ env2.opsOutcome = out;
15074
+ return classifyOpsApi(out, env2.config.endpoint, ctx.opsKey);
15075
+ }
15076
+ };
15077
+ var placeholder = {
15078
+ id: "platform.server-report",
15079
+ name: "\u5E73\u53F0\u4F53\u68C0\u62A5\u544A",
15080
+ layer: "platform",
15081
+ requirement: "REQUIRED",
15082
+ owner: "RND",
15083
+ dependsOn: ["connect.connectivity", "connect.health-api"],
15084
+ codes: [
15085
+ "BACKEND_UNSUPPORTED",
15086
+ "HEALTH_API_ROUTE_MISSING",
15087
+ "HEALTH_OPS_KEY_INVALID",
15088
+ "HEALTH_OPS_KEY_LOCKED",
15089
+ "REPORT_THROTTLED",
15090
+ "REPORT_UNAVAILABLE",
15091
+ "REPORT_MALFORMED",
15092
+ "REPORT_ITEM_MISSING",
15093
+ "SERVER_VERDICT_INVALID",
15094
+ "BUDGET_EXHAUSTED"
15095
+ ]
15096
+ };
15097
+ var OPS_DESCRIPTORS = [connectivity2, api, placeholder];
15098
+ var requestOpsReport = async (endpoint, key2, timeoutMs, budgetMs, signal, scope) => {
15099
+ const res = await axios8.get(OPS_PATH, {
15100
+ baseURL: endpoint,
15101
+ timeout: timeoutMs,
15102
+ signal,
15103
+ maxRedirects: 0,
15104
+ validateStatus: () => true,
15105
+ headers: { Accept: "application/json", "X-Platform-Ops-Key": key2 },
15106
+ params: {
15107
+ budgetMs,
15108
+ ...scope.only.length ? { only: scope.only.join(",") } : {},
15109
+ ...scope.skip.length ? { skip: scope.skip.join(",") } : {}
15110
+ }
15111
+ });
15112
+ return {
15113
+ status: res.status,
15114
+ body: res.data,
15115
+ error: classifyStatus2(res.status),
15116
+ headers: Object.fromEntries(Object.entries(res.headers).map(([name, value]) => [name.toLowerCase(), String(value)]))
15117
+ };
15118
+ };
15119
+ function opsKeyFingerprint(key2) {
15120
+ return key2 ? createHash8("sha256").update(key2, "utf8").digest("hex").slice(0, 16) : "none";
15121
+ }
15122
+ async function readPlatformOpsKey(args, io = {
15123
+ env: process.env.HCM_PLATFORM_OPS_KEY,
15124
+ isTTY: !!process.stdin.isTTY,
15125
+ readStdin,
15126
+ prompt: () => promptSecret("\u8FD0\u7EF4\u53EA\u8BFB\u5BC6\u94A5: ", process.stderr),
15127
+ stderr: (text) => process.stderr.write(text)
15128
+ }) {
15129
+ let source, key2;
15130
+ const fromEnv = io.env?.trim();
15131
+ if (fromEnv) {
15132
+ source = "env";
15133
+ key2 = fromEnv;
15134
+ } else if (args.platformOpsKeyStdin) {
15135
+ source = "stdin";
15136
+ key2 = await io.readStdin();
15137
+ } else if (io.isTTY) {
15138
+ source = "tty";
15139
+ key2 = await io.prompt();
15140
+ } else throw new CliError30({
15141
+ code: CliErrorCode31.INVALID_ARGUMENT,
15142
+ message: "\u7F3A\u5C11\u8FD0\u7EF4\u5BC6\u94A5\uFF1A\u8BBE\u7F6E HCM_PLATFORM_OPS_KEY\u3001\u4F7F\u7528 --platform-ops-key-stdin\uFF0C\u6216\u5728 TTY \u4EA4\u4E92\u8F93\u5165"
15143
+ });
15144
+ key2 = key2.trim();
15145
+ if (!key2) throw new CliError30({ code: CliErrorCode31.INVALID_ARGUMENT, message: "\u8FD0\u7EF4\u5BC6\u94A5\u4E3A\u7A7A" });
15146
+ io.stderr(`\u8FD0\u7EF4\u5BC6\u94A5\u6765\u6E90\uFF1A${source} \xB7 \u6307\u7EB9 ${opsKeyFingerprint(key2)}
15147
+ `);
15148
+ return { key: key2, source };
15149
+ }
15150
+ var split = (value) => (Array.isArray(value) ? value : value ? [value] : []).flatMap((item) => item.split(",")).map((item) => item.trim()).filter(Boolean);
15151
+ function scopeFor(args) {
15152
+ const only = split(args.only), skip = split(args.skip);
15153
+ for (const token of [...only, ...skip]) if (!("platform.".startsWith(token) || token.startsWith("platform.")))
15154
+ throw new CliError30({
15155
+ code: CliErrorCode31.INVALID_ARGUMENT,
15156
+ message: `\u8FD0\u7EF4\u89C6\u56FE\u53EA\u770B\u5E73\u53F0\u5C42\uFF1A--only / --skip \u53EA\u63A5\u53D7 platform \u524D\u7F00\uFF0C\u6536\u5230 ${token}`
15157
+ });
15158
+ if (skip.some((token) => "platform.".startsWith(token))) throw new CliError30({
15159
+ code: CliErrorCode31.INVALID_ARGUMENT,
15160
+ message: "\u6392\u9664\u4E86\u5E73\u53F0\u5C42\uFF0C\u8FD0\u7EF4\u89C6\u56FE\u6CA1\u6709\u53EF\u770B\u7684\u68C0\u67E5"
15161
+ });
15162
+ return {
15163
+ stage: null,
15164
+ only,
15165
+ skip,
15166
+ active: false,
15167
+ forwardedOnly: only,
15168
+ forwardedSkip: skip,
15169
+ serverIds: /* @__PURE__ */ new Set(),
15170
+ serverLayers: /* @__PURE__ */ new Set(["platform"]),
15171
+ serverRelevant: true,
15172
+ addedPrerequisites: only.length ? ["connect.connectivity", "connect.health-api"] : []
15173
+ };
15174
+ }
15175
+ function redact(text, key2) {
15176
+ const raw = typeof text === "string" ? text : JSON.stringify(text) ?? "";
15177
+ return raw.replaceAll(key2, "[redacted]").replace(/hcm\s+login/gi, "[login advice omitted]");
15178
+ }
15179
+ function classifyOpsApi(out, endpoint, key2) {
15180
+ const note = httpNote(out), error = object(out.body) && object(out.body.error) ? out.body.error : void 0;
15181
+ const wireCode = error?.code;
15182
+ if (out.status === 200) {
15183
+ if (object(out.body) || Array.isArray(out.body)) return pass("\u540E\u7AEF\u652F\u6301\u8FD0\u7EF4\u4F53\u68C0 API");
15184
+ if (/json/i.test(out.headers["content-type"] ?? "")) {
15185
+ if (typeof out.body === "string") {
15186
+ try {
15187
+ JSON.parse(out.body);
15188
+ } catch {
15189
+ return unknown(
15190
+ "REPORT_MALFORMED",
15191
+ "\u8FD0\u7EF4\u4F53\u68C0\u63A5\u53E3 JSON \u89E3\u6790\u5931\u8D25",
15192
+ { reason: "EVALUATOR_ERROR", note: `${note}\uFF1B${redact(out.body, key2).slice(0, 200)}` }
15193
+ );
15194
+ }
15195
+ }
15196
+ return pass("\u540E\u7AEF\u652F\u6301\u8FD0\u7EF4\u4F53\u68C0 API");
15197
+ }
15198
+ return found(
15199
+ "HEALTH_API_ROUTE_MISSING",
15200
+ void 0,
15201
+ { evidence: "INFERRED", note: `${note}\uFF1B\u6536\u5230\u975E JSON\uFF0C\u63A8\u65AD\u8DEF\u7531\u843D\u5230\u53CD\u4EE3\u6216\u524D\u7AEF SPA` }
15202
+ );
15203
+ }
15204
+ if (out.status === 403 && wireCode === "HEALTH_OPS_KEY_INVALID") return pass("\u8FD0\u7EF4\u4F53\u68C0 API \u5DF2\u5E94\u7B54");
15205
+ if (out.status === 429 && ["HEALTH_OPS_KEY_LOCKED", "HEALTH_REPORT_THROTTLED"].includes(String(wireCode)))
15206
+ return pass("\u8FD0\u7EF4\u4F53\u68C0 API \u5DF2\u5E94\u7B54");
15207
+ if (out.status === 401 && !out.headers["x-trace-id"]) return found(
15208
+ "HEALTH_API_ROUTE_MISSING",
15209
+ void 0,
15210
+ { evidence: "INFERRED", note: `${note}\uFF1B\u7F3A\u540E\u7AEF traceId\uFF0C\u63A8\u65AD\u7F51\u5173\u62E6\u622A\uFF1B\u4EE3\u7406\u4E5F\u53EF\u80FD\u5265\u6389\u54CD\u5E94\u5934` }
15211
+ );
15212
+ const requestPath = new URL(`${endpoint.replace(/\/+$/, "")}${OPS_PATH}`).pathname;
15213
+ if (out.status === 401 && out.headers["x-trace-id"] && object(out.body) && out.body.code === 401 && [requestPath, OPS_PATH].includes(String(out.body.path))) return found("BACKEND_UNSUPPORTED", void 0, { note });
15214
+ if (out.status === 404) {
15215
+ if (out.headers["x-trace-id"] && error && typeof error.code === "string" && typeof error.message === "string")
15216
+ return found("BACKEND_UNSUPPORTED", void 0, { note });
15217
+ if (!out.headers["x-trace-id"]) return found(
15218
+ "HEALTH_API_ROUTE_MISSING",
15219
+ void 0,
15220
+ { evidence: "INFERRED", note: `${note}\uFF1B\u7F3A\u540E\u7AEF traceId\uFF0C\u63A8\u65AD\u8DEF\u7531\u672A\u5230\u540E\u7AEF\uFF1B\u4EE3\u7406\u4E5F\u53EF\u80FD\u5265\u6389\u54CD\u5E94\u5934` }
15221
+ );
15222
+ }
15223
+ if (out.status >= 500 || out.error === "network") return unknown("REPORT_UNAVAILABLE", void 0, { note });
15224
+ return unknown(
15225
+ "REPORT_MALFORMED",
15226
+ "\u8FD0\u7EF4\u4F53\u68C0\u63A5\u53E3\u8FD4\u56DE\u975E\u9884\u671F\u72B6\u6001",
15227
+ { reason: "EVALUATOR_ERROR", note: `${note}\uFF1B${redact(out.body, key2).slice(0, 200)}` }
15228
+ );
15229
+ }
15230
+ function opsPlaceholder(ctx, env2, observation) {
15231
+ const row = CODE_TABLE[observation.code ?? ""];
15232
+ return makeResult(
15233
+ placeholder,
15234
+ {
15235
+ ...observation,
15236
+ grade: observation.grade ?? row?.grade,
15237
+ summary: observation.summary === observation.code && row ? row.summary : observation.summary
15238
+ },
15239
+ env2.name,
15240
+ true,
15241
+ ctx.requestedAt,
15242
+ 0,
15243
+ observation.code ? codeStep(observation.code, env2.name) : { owner: "RND" }
15244
+ );
15245
+ }
15246
+ function failure(ctx, env2, health, key2) {
15247
+ const out = env2.opsOutcome, code2 = health.code;
15248
+ if (!out) {
15249
+ if (code2 === "BUDGET_EXHAUSTED") return opsPlaceholder(ctx, env2, unknown("BUDGET_EXHAUSTED", "\u9884\u7B97\u8017\u5C3D\uFF0C\u672A\u542F\u52A8", { note: "\u9884\u7B97\u8017\u5C3D\uFF0C\u672A\u542F\u52A8" }));
15250
+ if (code2 === "REPORT_UNAVAILABLE") return opsPlaceholder(
15251
+ ctx,
15252
+ env2,
15253
+ unknown("REPORT_UNAVAILABLE", void 0, { note: health.verdict.note })
15254
+ );
15255
+ return opsPlaceholder(ctx, env2, {
15256
+ level: "NOT_RUN",
15257
+ code: "PREREQUISITE_NOT_MET",
15258
+ reason: "PREREQUISITE_NOT_MET",
15259
+ summary: "\u8FD0\u7EF4\u62A5\u544A\u672A\u6267\u884C\uFF1A\u524D\u7F6E\u68C0\u67E5\u672A\u901A\u8FC7",
15260
+ note: code2 ?? health.verdict.level
15261
+ });
15262
+ }
15263
+ const error = object(out.body) && object(out.body.error) ? out.body.error : void 0;
15264
+ const detail = object(error?.details) ? error.details : void 0;
15265
+ const next = typeof error?.next_step === "string" ? `\uFF1B${redact(error.next_step, key2)}` : "";
15266
+ const keyNote = `${httpNote(out)} \xB7 \u6307\u7EB9 ${opsKeyFingerprint(key2)}`;
15267
+ if (out.status === 403 && error?.code === "HEALTH_OPS_KEY_INVALID") return opsPlaceholder(
15268
+ ctx,
15269
+ env2,
15270
+ unknown("HEALTH_OPS_KEY_INVALID", void 0, { reason: "PERMISSION_DENIED", note: keyNote + next })
15271
+ );
15272
+ if (out.status === 429 && error?.code === "HEALTH_OPS_KEY_LOCKED") {
15273
+ const retry = out.headers["retry-after"] || detail?.retryAfter;
15274
+ return opsPlaceholder(ctx, env2, unknown(
15275
+ "HEALTH_OPS_KEY_LOCKED",
15276
+ void 0,
15277
+ { note: `${keyNote} \xB7 ${retry == null ? "\u670D\u52A1\u7AEF\u672A\u63D0\u4F9B retryAfter" : `retryAfter=${String(retry)}`}${next}` }
15278
+ ));
15279
+ }
15280
+ if (out.status === 429 && error?.code === "HEALTH_REPORT_THROTTLED") return opsPlaceholder(
15281
+ ctx,
15282
+ env2,
15283
+ unknown("REPORT_THROTTLED", void 0, { note: redact(throttleNote(out), key2) })
15284
+ );
15285
+ if (code2 === "BACKEND_UNSUPPORTED") return opsPlaceholder(
15286
+ ctx,
15287
+ env2,
15288
+ {
15289
+ level: "NOT_RUN",
15290
+ code: code2,
15291
+ reason: "CAPABILITY_UNSUPPORTED",
15292
+ summary: "\u540E\u7AEF\u4E0D\u652F\u6301\u8FD0\u7EF4\u4F53\u68C0\u62A5\u544A",
15293
+ note: `${health.verdict.note ?? ""}\uFF1B${env2.report.backend.commit ? `\u540E\u7AEF commit ${env2.report.backend.commit}` : "commit \u672A\u77E5"}`
15294
+ }
15295
+ );
15296
+ if (code2 === "HEALTH_API_ROUTE_MISSING") return opsPlaceholder(
15297
+ ctx,
15298
+ env2,
15299
+ unknown(code2, void 0, { note: health.verdict.note })
15300
+ );
15301
+ if (code2 === "REPORT_UNAVAILABLE") return opsPlaceholder(
15302
+ ctx,
15303
+ env2,
15304
+ unknown(code2, void 0, { note: health.verdict.note })
15305
+ );
15306
+ return opsPlaceholder(ctx, env2, unknown(
15307
+ "REPORT_MALFORMED",
15308
+ void 0,
15309
+ { reason: "EVALUATOR_ERROR", note: health.verdict.note ?? `${httpNote(out)}\uFF1B${redact(out.body, key2).slice(0, 200)}` }
15310
+ ));
15311
+ }
15312
+ var ENV_HINT = "hcm env list \u67E5\u770B\u53EF\u9009\u73AF\u5883\uFF1Bhcm env add <\u540D> --endpoint <url> \u767B\u8BB0";
15313
+ function resolverMessage(error) {
15314
+ if (error instanceof CliError30 && error.code === CliErrorCode31.NO_ACTIVE_ENV) return "\u672A\u9009\u5B9A\u73AF\u5883\uFF1A\u7528 --env <\u540D> \u6307\u5B9A";
15315
+ return (error instanceof Error ? error.message : safeError(error)).replace(/\s*(&&\s*)?hcm\s+login\b[^;;\n]*/gi, "");
15316
+ }
15317
+ async function runPlatformOps(args, services, readKey = readPlatformOpsKey, onReport) {
15318
+ const scope = scopeFor(args);
15319
+ let resolved;
15320
+ try {
15321
+ resolved = await resolveEnvContext8({ envFlag: args.env }, process.env, await loadGlobalConfig11());
15322
+ } catch (error2) {
15323
+ throw new CliError30({ code: CliErrorCode31.INVALID_ARGUMENT, message: `${resolverMessage(error2)}\uFF1B${ENV_HINT}` });
15324
+ }
15325
+ if (!resolved.config.endpoint) throw new CliError30({
15326
+ code: CliErrorCode31.INVALID_ARGUMENT,
15327
+ message: `\u672A\u89E3\u6790\u5230 endpoint\uFF1B${ENV_HINT}`
15328
+ });
15329
+ printResolvedEnvironment8(resolved);
15330
+ const { key: key2 } = await readKey(args);
15331
+ const startedAt = Date.now();
15332
+ const name = resolved.project?.name ?? resolved.name;
15333
+ const env2 = {
15334
+ name,
15335
+ config: { endpoint: resolved.config.endpoint },
15336
+ credential: async () => {
15337
+ throw new Error("\u8FD0\u7EF4\u89C6\u56FE\u4E0D\u5F97\u8BFB\u53D6\u8EAB\u4EFD");
15338
+ },
15339
+ report: {
15340
+ name,
15341
+ endpoint: resolved.config.endpoint,
15342
+ tenant: null,
15343
+ target: true,
15344
+ backend: { version: null, commit: null },
15345
+ server: {
15346
+ supported: null,
15347
+ deploymentTenancy: null,
15348
+ instance: null,
15349
+ verdict: null,
15350
+ catalogRevision: null
15351
+ }
15352
+ }
15353
+ };
15354
+ const ctx = {
15355
+ root: "",
15356
+ requestedAt: new Date(startedAt).toISOString(),
15357
+ cliVersion: CLI_VERSION,
15358
+ projectObservation: pass("\u8FD0\u7EF4\u73AF\u5883\u5DF2\u89E3\u6790"),
15359
+ targetEnv: name,
15360
+ environments: [env2],
15361
+ services,
15362
+ scope,
15363
+ opsKey: key2,
15364
+ opsDeadline: startedAt + 45e3
15365
+ };
15366
+ const results = await executeChecks(ctx, { checks: [connectivity2, api], fetchReport: false });
15367
+ const health = results.find((row) => row.checkId === "connect.health-api");
15368
+ const out = env2.opsOutcome;
15369
+ const error = out && object(out.body) && object(out.body.error) ? out.body.error : void 0;
15370
+ if (out?.status === 400 && error?.code === "HEALTH_REPORT_INVALID_PARAM") throw new CliError30({
15371
+ code: CliErrorCode31.INVALID_ARGUMENT,
15372
+ message: `${typeof error.message === "string" ? redact(error.message, key2) : "\u8FD0\u7EF4\u68C0\u67E5\u8303\u56F4\u65E0\u6548"}${scope.only.length || scope.skip.length ? "\uFF1B\u53BB\u6389 --only / --skip \u91CD\u8DD1 hcm chiron doctor --platform-ops \u53EF\u770B\u5230\u5168\u90E8\u5E73\u53F0\u68C0\u67E5" : ""}`
15373
+ });
15374
+ env2.report.server.supported = health.verdict.level === "PASS" ? true : health.code === "BACKEND_UNSUPPORTED" ? false : null;
15375
+ if (out?.status === 200 && health.verdict.level === "PASS") {
15376
+ const invalid3 = reportEnvelopeError(out.body, true);
15377
+ if (invalid3) results.push(opsPlaceholder(ctx, env2, unknown(
15378
+ "REPORT_MALFORMED",
15379
+ "\u670D\u52A1\u7AEF\u8FD0\u7EF4\u62A5\u544A\u4FE1\u5C01\u4E0D\u5408\u6CD5",
15380
+ { reason: "EVALUATOR_ERROR", note: `${httpNote(out)}\uFF1B${invalid3}` }
15381
+ )));
15382
+ else {
15383
+ const report = out.body;
15384
+ env2.serverReport = report;
15385
+ onReport?.(report);
15386
+ Object.assign(env2.report.server, {
15387
+ deploymentTenancy: report.deploymentTenancy ?? null,
15388
+ instance: report.instance ?? null,
15389
+ catalogRevision: report.catalogRevision ?? null,
15390
+ verdict: report.verdict ?? null,
15391
+ note: report.note
15392
+ });
15393
+ results.push(...reconcileReport(ctx, env2, report, {
15394
+ stage: null,
15395
+ only: scope.forwardedOnly,
15396
+ skip: scope.forwardedSkip,
15397
+ active: false
15398
+ }, { placeholder }));
15399
+ }
15400
+ } else results.push(failure(ctx, env2, health, key2));
15401
+ return assembleReport({
15402
+ results,
15403
+ environments: [env2.report],
15404
+ project: null,
15405
+ targetEnv: name,
15406
+ cliVersion: CLI_VERSION,
15407
+ startedAt,
15408
+ failOn: args.failOn ?? "blocked",
15409
+ scope,
15410
+ serverReport: env2.serverReport,
15411
+ platformOps: true
15412
+ });
15413
+ }
15414
+
14923
15415
  // src/commands/doctor/catalog.ts
14924
15416
  var localCriterion = {
14925
15417
  "local.project.env": "env.yaml \u5B58\u5728\u3001\u53EF\u89E3\u6790\uFF0C\u76EE\u6807\u73AF\u5883\u80FD\u89E3\u6790\u5230\u9879\u76EE\u73AF\u5883",
@@ -15009,20 +15501,20 @@ function explainCatalog(ctx, id, reason) {
15009
15501
  }),
15010
15502
  skill: null
15011
15503
  };
15012
- const placeholder = SERVER_PLACEHOLDERS.find((d) => d.id === id);
15013
- if (placeholder) return {
15504
+ const placeholder2 = SERVER_PLACEHOLDERS.find((d) => d.id === id);
15505
+ if (placeholder2) return {
15014
15506
  id,
15015
- layer: placeholder.layer,
15016
- name: placeholder.name,
15507
+ layer: placeholder2.layer,
15508
+ name: placeholder2.name,
15017
15509
  source: "cli",
15018
15510
  note: "\u5360\u4F4D\u884C\uFF1A\u670D\u52A1\u7AEF\u62A5\u544A\u7F3A\u5E2D\u6216\u5F02\u5E38\u65F6\u4EE3\u8868\u8BE5\u5C42\u8BF7\u6C42\u8303\u56F4\uFF0C\u4E0D\u662F\u670D\u52A1\u7AEF\u76EE\u5F55\u91CC\u7684\u53EF\u7B5B\u9009\u68C0\u67E5",
15019
- requirement: placeholder.requirement,
15020
- dependsOn: placeholder.dependsOn,
15021
- codes: placeholder.codes.map((key2) => ({
15511
+ requirement: placeholder2.requirement,
15512
+ dependsOn: placeholder2.dependsOn,
15513
+ codes: placeholder2.codes.map((key2) => ({
15022
15514
  code: key2,
15023
15515
  summaryTemplate: CODE_TABLE[key2]?.summary ?? key2,
15024
15516
  nextStep: CODE_TABLE[key2]?.command?.(env2) ?? null,
15025
- owner: CODE_TABLE[key2]?.owner ?? placeholder.owner
15517
+ owner: CODE_TABLE[key2]?.owner ?? placeholder2.owner
15026
15518
  }))
15027
15519
  };
15028
15520
  if (!id.startsWith("platform.") && !id.startsWith("tenant.")) throw new Error(`\u68C0\u67E5 id ${id} \u4E0D\u5B58\u5728\uFF1B\u53EF\u9009 id \u524D\u7F00\uFF1Alocal.\u3001connect.\u3001platform.\u3001tenant.`);
@@ -15065,6 +15557,72 @@ function explainCatalog(ctx, id, reason) {
15065
15557
  ...row.skill ? { skill: row.skill } : {}
15066
15558
  };
15067
15559
  }
15560
+ var opsCriteria = {
15561
+ "connect.connectivity": "\u514D\u8BA4\u8BC1\u8BFB\u53D6\u540E\u7AEF\u7248\u672C\u7AEF\u70B9\uFF0C\u786E\u8BA4\u540E\u7AEF\u53EF\u8FBE",
15562
+ "connect.health-api": "\u7528\u53EA\u8BFB\u8FD0\u7EF4\u5BC6\u94A5\u8BF7\u6C42\u8FD0\u7EF4\u4F53\u68C0\u62A5\u544A\uFF0C\u786E\u8BA4\u8FD0\u7EF4\u7AEF\u70B9\u53EF\u5E94\u7B54",
15563
+ "platform.server-report": "\u8FD0\u7EF4\u62A5\u544A\u7F3A\u5E2D\u6216\u5F02\u5E38\u65F6\u4EE3\u8868\u5E73\u53F0\u5C42\u8BF7\u6C42\u8303\u56F4\uFF1B\u4E0D\u662F\u53EF\u7B5B\u9009\u7684\u68C0\u67E5"
15564
+ };
15565
+ var opsReservedNote = "\u6587\u6848\u4E0E owner \u4EE5\u670D\u52A1\u7AEF\u4E3A\u51C6\uFF1B\u8FD0\u7EF4\u62A5\u544A\u4E0D\u4E0B\u53D1\u4FDD\u7559\u7801\u8868\uFF0C\u6301\u79DF\u6237\u8EAB\u4EFD\u53EF\u7528 `hcm chiron doctor --explain <id>` \u770B\u5B8C\u6574\u7801\u8868";
15566
+ function explainOpsCatalog(id, report) {
15567
+ const local = OPS_DESCRIPTORS.find((row2) => row2.id === id);
15568
+ if (local) return {
15569
+ id,
15570
+ layer: local.layer,
15571
+ name: local.name,
15572
+ source: "cli",
15573
+ criterion: opsCriteria[id],
15574
+ requirement: local.requirement,
15575
+ stages: "stages" in local ? local.stages : [],
15576
+ grade: id === "connect.connectivity" ? "CRITICAL" : "WARN",
15577
+ dependsOn: local.dependsOn,
15578
+ coverageForm: "coverageForm" in local ? local.coverageForm : void 0,
15579
+ coverageDomain: "coverageDomain" in local ? local.coverageDomain : void 0,
15580
+ timeoutMs: "timeoutMs" in local ? local.timeoutMs : void 0,
15581
+ codes: local.codes.map((key2) => ({
15582
+ code: key2,
15583
+ summaryTemplate: CODE_TABLE[key2]?.summary ?? key2,
15584
+ nextStep: CODE_TABLE[key2]?.command?.("<env>") ?? null,
15585
+ owner: CODE_TABLE[key2]?.owner ?? local.owner
15586
+ })),
15587
+ reservedCodes: RESERVED_CODES.map((code2) => ({ code: code2 })),
15588
+ reservedCodesNote: opsReservedNote,
15589
+ skill: null
15590
+ };
15591
+ const checks = report?.checks ?? [];
15592
+ const row = checks.find((item) => item.id === id);
15593
+ if (!row) throw new Error(`\u68C0\u67E5 id ${id} \u4E0D\u5728\u8FD0\u7EF4\u62A5\u544A\u91CC\uFF1B\u62A5\u544A\u4E2D\u7684 id\uFF1A${checks.map((item) => item.id).join("\u3001") || "\u65E0"}`);
15594
+ const spec = object2(row.spec) ? row.spec : {};
15595
+ return {
15596
+ id,
15597
+ layer: spec.layer,
15598
+ name: row.name,
15599
+ source: "server",
15600
+ criterion: row.description,
15601
+ requirement: row.requirement,
15602
+ stages: row.stages,
15603
+ grade: row.grade,
15604
+ ...row.gradeByStage !== void 0 ? { gradeByStage: row.gradeByStage } : {},
15605
+ dependsOn: row.dependsOn,
15606
+ ruleType: row.ruleType,
15607
+ evaluatorKey: row.evaluatorKey,
15608
+ ruleDsl: row.ruleDsl,
15609
+ coverageForm: spec.coverageForm,
15610
+ coverageDomain: spec.coverageDomain,
15611
+ queryMode: spec.queryMode,
15612
+ requiredPermission: spec.requiredPermission,
15613
+ timeout: spec.timeout,
15614
+ paramSchema: spec.paramSchema,
15615
+ enabled: row.enabled,
15616
+ policySource: row.policySource,
15617
+ definitionId: row.definitionId,
15618
+ by: row.by,
15619
+ at: row.at,
15620
+ codes: codeRows(spec.codes),
15621
+ reservedCodes: RESERVED_CODES.map((code2) => ({ code: code2 })),
15622
+ reservedCodesNote: opsReservedNote,
15623
+ ...row.skill ? { skill: row.skill } : {}
15624
+ };
15625
+ }
15068
15626
  function renderCatalogList(data) {
15069
15627
  const lines = [
15070
15628
  "\u68C0\u67E5 id \xB7 \u5C42 \xB7 \u540D\u79F0 \xB7 \u5FC5\u68C0/\u9009\u68C0 \xB7 \u9636\u6BB5",
@@ -15090,19 +15648,21 @@ function renderCatalogExplanation(item) {
15090
15648
  ];
15091
15649
  for (const item2 of [...codeRows(row.codes), ...codeRows(row.reservedCodes)])
15092
15650
  lines.push(` ${code(item2)} \xB7 ${item2.summaryTemplate ?? "\u65E0"} \xB7 \u4E0B\u4E00\u6B65\uFF1A${item2.nextStep ?? "\u65E0"} \xB7 owner\uFF1A${item2.owner ?? "\u65E0"}`);
15651
+ if (row.reservedCodesNote) lines.push(String(row.reservedCodesNote));
15093
15652
  return lines.join("\n");
15094
15653
  }
15095
15654
 
15096
15655
  // src/commands/chiron-doctor.ts
15097
15656
  var defaultServices = {
15098
15657
  reportRequest: requestServerReport,
15658
+ opsReportRequest: requestOpsReport,
15099
15659
  inspectCases: inspectCaseLibrary,
15100
15660
  inspectJira,
15101
15661
  inspectMethod: inspectMethodForDoctor,
15102
15662
  latestVersion: fetchLatestVersion,
15103
15663
  skillsFresh: inspectSkillsFresh,
15104
15664
  asAuth: (...args) => ensureAsAuth(...args),
15105
- probe: (endpoint, token, signal) => httpProbe2(axios8.create({
15665
+ probe: (endpoint, token, signal) => httpProbe2(axios9.create({
15106
15666
  baseURL: endpoint,
15107
15667
  timeout: 5e3,
15108
15668
  maxRedirects: 0,
@@ -15113,15 +15673,26 @@ var defaultServices = {
15113
15673
  };
15114
15674
  function validate(args) {
15115
15675
  for (const [key2, value, choices] of [["output", args.output, ["table", "json", "yaml"]], ["fail-on", args.failOn, ["blocked", "risks"]]])
15116
- if (value !== void 0 && !choices.includes(value)) throw new CliError30({
15117
- code: CliErrorCode31.INVALID_ARGUMENT,
15676
+ if (value !== void 0 && !choices.includes(value)) throw new CliError31({
15677
+ code: CliErrorCode32.INVALID_ARGUMENT,
15118
15678
  message: `--${key2} \u53EA\u63A5\u53D7 ${choices.join(" / ")}\uFF0C\u6536\u5230 ${value}`
15119
15679
  });
15120
15680
  const stages = ["handover", "baseline", "configure", "migrate", "integrate", "golive", "operate"];
15121
- if (args.stage !== void 0 && !stages.includes(args.stage.toLowerCase())) throw new CliError30({
15122
- code: CliErrorCode31.INVALID_ARGUMENT,
15681
+ if (args.stage !== void 0 && !stages.includes(args.stage.toLowerCase())) throw new CliError31({
15682
+ code: CliErrorCode32.INVALID_ARGUMENT,
15123
15683
  message: `--stage \u53EA\u63A5\u53D7 ${stages.join(" / ")}\uFF0C\u6536\u5230 ${args.stage}`
15124
15684
  });
15685
+ if (args.platformOpsKeyStdin && !args.platformOps) invalidScope("--platform-ops-key-stdin \u53EA\u80FD\u4E0E --platform-ops \u540C\u7528");
15686
+ if (args.platformOps) {
15687
+ for (const [flag, present] of [
15688
+ ["--active", args.active],
15689
+ ["--stage", args.stage !== void 0],
15690
+ ["--as", args.as !== void 0],
15691
+ ["--project", args.project !== void 0]
15692
+ ])
15693
+ if (present) invalidScope(`${flag} \u4E0E --platform-ops \u4E0D\u80FD\u540C\u7528\uFF1A\u8FD0\u7EF4\u89C6\u56FE\u53EA\u6709\u5E73\u53F0\u5C42\u88AB\u52A8\u68C0\u67E5\uFF0C\u6CA1\u6709\u9636\u6BB5\u4E0E\u8EAB\u4EFD\u4E4B\u5206`);
15694
+ if (args.list) invalidScope("--list \u4E0E --platform-ops \u4E0D\u80FD\u540C\u7528\uFF1A\u8FD0\u7EF4\u89C6\u56FE\u7684\u76EE\u5F55\u5C31\u662F\u62A5\u544A\u672C\u8EAB\uFF0C\u76F4\u63A5\u8DD1\u5373\u53EF");
15695
+ }
15125
15696
  if (args.list && args.explain) invalidScope("--list \u4E0E --explain \u4E0D\u80FD\u540C\u7528");
15126
15697
  if ((args.list || args.explain) && (args.stage !== void 0 || tokens(args.only).length || tokens(args.skip).length || args.active || args.failOn !== void 0)) invalidScope("--list / --explain \u4E0D\u80FD\u4E0E --stage / --only / --skip / --active / --fail-on \u540C\u7528");
15127
15698
  }
@@ -15129,9 +15700,9 @@ var tokens = (value) => (Array.isArray(value) ? value : value ? [value] : []).fl
15129
15700
  var matches = (id, only, skip) => (!only.length || only.some((t) => id.startsWith(t))) && !skip.some((t) => id.startsWith(t));
15130
15701
  var serverCandidate = (t) => ["platform.", "tenant."].some((prefix) => prefix.startsWith(t) || t.startsWith(prefix));
15131
15702
  function invalidScope(message) {
15132
- throw new CliError30({ code: CliErrorCode31.INVALID_ARGUMENT, message });
15703
+ throw new CliError31({ code: CliErrorCode32.INVALID_ARGUMENT, message });
15133
15704
  }
15134
- function scopeFor(args, catalog) {
15705
+ function scopeFor2(args, catalog) {
15135
15706
  const only = tokens(args.only), skip = tokens(args.skip), stage = args.stage?.toLowerCase() ?? null;
15136
15707
  const serverChecks = catalog?.checks ?? [];
15137
15708
  const valid = (t) => CHECKS.some((d) => d.id.startsWith(t)) || serverChecks.some((d) => d.id.startsWith(t)) || catalog?.tenantCatalog.available === false && (t.startsWith("tenant.") || "tenant.".startsWith(t)) || !catalog && serverCandidate(t);
@@ -15162,9 +15733,9 @@ function scopeFor(args, catalog) {
15162
15733
  async function readCredential(envFlag, root, as) {
15163
15734
  let resolved;
15164
15735
  try {
15165
- resolved = await resolveEnvContext8({ envFlag, cwd: root }, process.env, await loadGlobalConfig11());
15736
+ resolved = await resolveEnvContext9({ envFlag, cwd: root }, process.env, await loadGlobalConfig12());
15166
15737
  } catch (error) {
15167
- if (error instanceof CliError30 && error.code === CliErrorCode31.ENV_NOT_FOUND) return { resolved: null };
15738
+ if (error instanceof CliError31 && error.code === CliErrorCode32.ENV_NOT_FOUND) return { resolved: null };
15168
15739
  throw error;
15169
15740
  }
15170
15741
  if (as) return { resolved };
@@ -15173,14 +15744,14 @@ async function readCredential(envFlag, root, as) {
15173
15744
  try {
15174
15745
  identity3 = await resolveActiveIdentity2({}, process.env, resolved.name);
15175
15746
  } catch (error) {
15176
- if (error instanceof CliError30 && error.code === CliErrorCode31.IDENTITY_NOT_FOUND) return { resolved, error: found("IDENTITY_NOT_LOGGED_IN") };
15747
+ if (error instanceof CliError31 && error.code === CliErrorCode32.IDENTITY_NOT_FOUND) return { resolved, error: found("IDENTITY_NOT_LOGGED_IN") };
15177
15748
  throw error;
15178
15749
  }
15179
15750
  let meta2;
15180
15751
  try {
15181
15752
  meta2 = await loadIdentity5(identity3);
15182
15753
  } catch (error) {
15183
- if (error instanceof CliError30 && error.code === CliErrorCode31.IDENTITY_NOT_FOUND) return { resolved, identity: identity3, error: found("IDENTITY_META_INVALID", `\u8EAB\u4EFD ${identity3} \u7684\u5143\u6570\u636E\u4E0D\u5B58\u5728\uFF1B\u91CD\u65B0\u767B\u5F55\u4FEE\u590D`) };
15754
+ if (error instanceof CliError31 && error.code === CliErrorCode32.IDENTITY_NOT_FOUND) return { resolved, identity: identity3, error: found("IDENTITY_META_INVALID", `\u8EAB\u4EFD ${identity3} \u7684\u5143\u6570\u636E\u4E0D\u5B58\u5728\uFF1B\u91CD\u65B0\u767B\u5F55\u4FEE\u590D`) };
15184
15755
  throw error;
15185
15756
  }
15186
15757
  if (!meta2.env || meta2.env !== resolved.name) return {
@@ -15190,7 +15761,7 @@ async function readCredential(envFlag, root, as) {
15190
15761
  error: found("IDENTITY_META_INVALID", `\u8EAB\u4EFD ${identity3} \u7684 env ${meta2.env ?? "\u7F3A\u5931"} \u4E0E\u672C\u673A\u69FD ${resolved.name} \u4E0D\u7B26\uFF1B\u91CD\u65B0\u767B\u5F55\u4FEE\u590D`)
15191
15762
  };
15192
15763
  const token = await readStoredIdentityToken(identity3);
15193
- printResolvedEnvironment8(resolved, identity3, resolved.project?.environment.tenant);
15764
+ printResolvedEnvironment9(resolved, identity3, resolved.project?.environment.tenant);
15194
15765
  return { resolved, identity: identity3, meta: meta2, token };
15195
15766
  }
15196
15767
  async function prepareContext(args, deps) {
@@ -15212,7 +15783,7 @@ async function prepareContext(args, deps) {
15212
15783
  let explicitSlot;
15213
15784
  if (file && args.env && !Object.hasOwn(file.environments, args.env)) {
15214
15785
  try {
15215
- const resolved = await resolveEnvContext8({ envFlag: args.env, cwd: root }, process.env, await loadGlobalConfig11());
15786
+ const resolved = await resolveEnvContext9({ envFlag: args.env, cwd: root }, process.env, await loadGlobalConfig12());
15216
15787
  if (!resolved.project) throw new Error("\u672C\u673A\u69FD\u4E0D\u5C5E\u4E8E\u5F53\u524D\u9879\u76EE");
15217
15788
  targetEnv = resolved.project.name;
15218
15789
  explicitSlot = resolved.name;
@@ -15264,7 +15835,7 @@ async function runChironDoctor(args, deps = {}) {
15264
15835
  budgetMs: Math.max(0, 45e3 - (Date.now() - startedAt))
15265
15836
  }) : [];
15266
15837
  const targetBefore = ctx.environments.find((e) => e.report.target);
15267
- const scope2 = scopeFor(args, targetBefore?.catalog);
15838
+ const scope2 = scopeFor2(args, targetBefore?.catalog);
15268
15839
  const selectedLocal = CHECKS.filter((d) => d.layer === "local" && (!scope2.stage || d.stages.includes(scope2.stage)) && matches(d.id, scope2.only, scope2.skip));
15269
15840
  const selectedConnect = targetBefore ? CHECKS.filter((d) => d.layer === "connect" && (!scope2.stage || d.stages.includes(scope2.stage)) && matches(d.id, scope2.only, scope2.skip)) : [];
15270
15841
  if (!selectedLocal.length && !selectedConnect.length && !scope2.serverLayers.size) invalidScope(
@@ -15342,6 +15913,34 @@ async function runChironCatalog(args, deps) {
15342
15913
  }
15343
15914
  async function chironDoctorCommand(args, deps) {
15344
15915
  try {
15916
+ validate(args);
15917
+ if (args.platformOps) {
15918
+ if (args.explain) {
15919
+ let descriptorReport;
15920
+ const local = ["connect.connectivity", "connect.health-api", "platform.server-report"].includes(args.explain);
15921
+ if (!local) {
15922
+ const report3 = await runPlatformOps(args, { ...defaultServices, ...deps }, void 0, (value) => {
15923
+ descriptorReport = value;
15924
+ });
15925
+ if (!descriptorReport) {
15926
+ for (const id of ["connect.connectivity", "connect.health-api", "platform.server-report"]) {
15927
+ const row = report3.results.find((item) => item.checkId === id);
15928
+ if (row && (id !== "connect.connectivity" || row.verdict.level !== "PASS")) process.stderr.write(`${id}: ${row.verdict.level} \xB7 code=${row.code ?? "\u65E0"} \xB7 ${String(row.summary ?? "")} \xB7 note=${row.verdict.note ?? "\u65E0"}
15929
+ `);
15930
+ }
15931
+ throw new Error(`\u8FD0\u7EF4\u62A5\u544A\u672A\u53D6\u5230\uFF0C\u65E0\u6CD5\u8BF4\u660E ${args.explain}\uFF1B\u5148\u6392\u9664\u4E0A\u9762\u7684\u9519\u8BEF\u518D\u8BD5`);
15932
+ }
15933
+ }
15934
+ const data = explainOpsCatalog(args.explain, descriptorReport);
15935
+ process.stdout.write((args.output === "json" || args.output === "yaml" ? formatObject28(data, { format: args.output }) : renderCatalogExplanation(data)) + "\n");
15936
+ process.exitCode = 0;
15937
+ return;
15938
+ }
15939
+ const report2 = await runPlatformOps(args, { ...defaultServices, ...deps });
15940
+ process.stdout.write((args.output === "json" || args.output === "yaml" ? formatObject28(report2, { format: args.output }) : renderChironDoctor(report2)) + "\n");
15941
+ process.exitCode = conclude(report2.results, { total: report2.coverage.total, failOn: args.failOn ?? "blocked" }).exitCode;
15942
+ return;
15943
+ }
15345
15944
  if (args.list || args.explain) {
15346
15945
  validate(args);
15347
15946
  const data = await runChironCatalog(args, deps ?? {});
@@ -15372,11 +15971,11 @@ import { accessSync, constants, readdirSync as readdirSync3 } from "fs";
15372
15971
  import fs13 from "fs/promises";
15373
15972
  import os6 from "os";
15374
15973
  import path16 from "path";
15375
- import { CliError as CliError33, CliErrorCode as CliErrorCode34, formatObject as formatObject29, HcmClient as HcmClient24, loadEnv as loadEnv6 } from "@hcmai/sdk";
15974
+ import { CliError as CliError34, CliErrorCode as CliErrorCode35, formatObject as formatObject29, HcmClient as HcmClient24, loadEnv as loadEnv6 } from "@hcmai/sdk";
15376
15975
  import { createRequire } from "module";
15377
15976
 
15378
15977
  // src/commands/chiron-page-cdp.ts
15379
- import { CliError as CliError31, CliErrorCode as CliErrorCode32 } from "@hcmai/sdk";
15978
+ import { CliError as CliError32, CliErrorCode as CliErrorCode33 } from "@hcmai/sdk";
15380
15979
 
15381
15980
  // src/commands/chiron-page-shared.ts
15382
15981
  function redactTicket(text) {
@@ -15412,14 +16011,14 @@ function normalizeCdpEndpoint(raw) {
15412
16011
  try {
15413
16012
  url = new URL(candidate);
15414
16013
  } catch {
15415
- throw new CliError31({ code: CliErrorCode32.INVALID_ARGUMENT, message: `--cdp \u8981\u5199\u6210 http://\u4E3B\u673A:\u7AEF\u53E3\uFF08Chrome \u7684 --remote-debugging-port\uFF09\uFF0C\u6536\u5230\u7684\u662F ${text}` });
16014
+ throw new CliError32({ code: CliErrorCode33.INVALID_ARGUMENT, message: `--cdp \u8981\u5199\u6210 http://\u4E3B\u673A:\u7AEF\u53E3\uFF08Chrome \u7684 --remote-debugging-port\uFF09\uFF0C\u6536\u5230\u7684\u662F ${text}` });
15416
16015
  }
15417
16016
  const protocol = url.protocol === "wss:" ? "https:" : url.protocol === "ws:" ? "http:" : url.protocol;
15418
16017
  if (protocol !== "http:" && protocol !== "https:") {
15419
- throw new CliError31({ code: CliErrorCode32.INVALID_ARGUMENT, message: `--cdp \u53EA\u8BA4 http(s) \u6216 ws(s) \u7AEF\u70B9\uFF0C\u6536\u5230\u7684\u662F ${text}` });
16018
+ throw new CliError32({ code: CliErrorCode33.INVALID_ARGUMENT, message: `--cdp \u53EA\u8BA4 http(s) \u6216 ws(s) \u7AEF\u70B9\uFF0C\u6536\u5230\u7684\u662F ${text}` });
15420
16019
  }
15421
16020
  if (!url.port) {
15422
- throw new CliError31({ code: CliErrorCode32.INVALID_ARGUMENT, message: `--cdp \u8981\u5E26\u7AEF\u53E3\uFF08Chrome \u542F\u52A8\u65F6 --remote-debugging-port=<\u7AEF\u53E3> \u7684\u90A3\u4E2A\uFF09\uFF0C\u6536\u5230\u7684\u662F ${text}` });
16021
+ throw new CliError32({ code: CliErrorCode33.INVALID_ARGUMENT, message: `--cdp \u8981\u5E26\u7AEF\u53E3\uFF08Chrome \u542F\u52A8\u65F6 --remote-debugging-port=<\u7AEF\u53E3> \u7684\u90A3\u4E2A\uFF09\uFF0C\u6536\u5230\u7684\u662F ${text}` });
15423
16022
  }
15424
16023
  return `${protocol}//${url.hostname}:${url.port}`;
15425
16024
  }
@@ -15516,8 +16115,8 @@ async function captureViaCdp(input, io) {
15516
16115
  const browser = version2?.Browser ? String(version2.Browser) : `attached ${input.endpoint}`;
15517
16116
  const target = await io.fetchJson(`${input.endpoint}/json/new?about:blank`, "PUT");
15518
16117
  if (!target?.id || !target.webSocketDebuggerUrl) {
15519
- throw new CliError31({
15520
- code: CliErrorCode32.SERVER_ERROR,
16118
+ throw new CliError32({
16119
+ code: CliErrorCode33.SERVER_ERROR,
15521
16120
  message: `${input.endpoint}/json/new \u6CA1\u6709\u7ED9\u51FA\u6807\u7B7E\u9875\uFF08id / webSocketDebuggerUrl \u7F3A\u5931\uFF09`,
15522
16121
  context: { nextStep: "\u786E\u8BA4 Chrome \u662F\u5E26 --remote-debugging-port \u8D77\u7684\uFF0C\u4E14 --cdp \u6307\u5230\u7684\u662F\u5B83" }
15523
16122
  });
@@ -15547,7 +16146,7 @@ async function captureViaCdp(input, io) {
15547
16146
  });
15548
16147
  if (r.exceptionDetails) {
15549
16148
  const why = r.exceptionDetails.exception?.description ?? r.exceptionDetails.text ?? "unknown";
15550
- throw new CliError31({ code: CliErrorCode32.INVALID_ARGUMENT, message: `--eval \u5728\u9875\u9762\u91CC\u629B\u4E86\u5F02\u5E38\uFF1A${redactTicket(why.split("\n")[0] ?? why)}` });
16149
+ throw new CliError32({ code: CliErrorCode33.INVALID_ARGUMENT, message: `--eval \u5728\u9875\u9762\u91CC\u629B\u4E86\u5F02\u5E38\uFF1A${redactTicket(why.split("\n")[0] ?? why)}` });
15551
16150
  }
15552
16151
  evalResult = r.result && "value" in r.result ? toPlainJson(r.result.value) : toPlainJson(r.result?.description);
15553
16152
  }
@@ -15558,7 +16157,7 @@ async function captureViaCdp(input, io) {
15558
16157
  const dom = typeof domReply.result?.value === "string" ? domReply.result.value : "";
15559
16158
  const shot = await session.send("Page.captureScreenshot", { format: "png" });
15560
16159
  if (!shot.data) {
15561
- throw new CliError31({ code: CliErrorCode32.SERVER_ERROR, message: "Page.captureScreenshot \u6CA1\u6709\u8FD4\u56DE\u56FE\u50CF\u6570\u636E" });
16160
+ throw new CliError32({ code: CliErrorCode33.SERVER_ERROR, message: "Page.captureScreenshot \u6CA1\u6709\u8FD4\u56DE\u56FE\u50CF\u6570\u636E" });
15562
16161
  }
15563
16162
  await io.writeFile(input.screenshot, Buffer.from(shot.data, "base64"));
15564
16163
  return { dom, browser, evalResult, navigated, minted };
@@ -15580,7 +16179,7 @@ var defaultCdpIo = {
15580
16179
  openSocket: (wsUrl) => new Promise((resolve3, reject) => {
15581
16180
  const Ctor = globalThis.WebSocket;
15582
16181
  if (!Ctor) {
15583
- reject(new CliError31({ code: CliErrorCode32.SERVER_ERROR, message: "\u8FD9\u4E2A Node \u6CA1\u6709\u5168\u5C40 WebSocket\uFF08\u9700\u8981 Node \u2265 22.4\uFF1B22.0\u201322.3 \u8981\u52A0 --experimental-websocket\uFF09" }));
16182
+ reject(new CliError32({ code: CliErrorCode33.SERVER_ERROR, message: "\u8FD9\u4E2A Node \u6CA1\u6709\u5168\u5C40 WebSocket\uFF08\u9700\u8981 Node \u2265 22.4\uFF1B22.0\u201322.3 \u8981\u52A0 --experimental-websocket\uFF09" }));
15584
16183
  return;
15585
16184
  }
15586
16185
  const ws = new Ctor(wsUrl);
@@ -15603,7 +16202,7 @@ var defaultCdpIo = {
15603
16202
 
15604
16203
  // src/commands/chiron-page-playwright.ts
15605
16204
  import path15 from "path";
15606
- import { CliError as CliError32, CliErrorCode as CliErrorCode33 } from "@hcmai/sdk";
16205
+ import { CliError as CliError33, CliErrorCode as CliErrorCode34 } from "@hcmai/sdk";
15607
16206
  function playwrightCacheRoot(probe2) {
15608
16207
  const override = probe2.env.PLAYWRIGHT_BROWSERS_PATH?.trim();
15609
16208
  if (override === "0" && probe2.packageRoot) return path15.join(probe2.packageRoot, ".local-browsers");
@@ -15646,8 +16245,8 @@ function discoverPlaywrightBrowser(probe2) {
15646
16245
  const explicit = probe2.env.HCM_PLAYWRIGHT_EXECUTABLE?.trim();
15647
16246
  if (explicit) {
15648
16247
  if (probe2.executable(explicit)) return { executablePath: explicit, kind: "explicit", from: "HCM_PLAYWRIGHT_EXECUTABLE" };
15649
- throw new CliError32({
15650
- code: CliErrorCode33.INVALID_ARGUMENT,
16248
+ throw new CliError33({
16249
+ code: CliErrorCode34.INVALID_ARGUMENT,
15651
16250
  message: `HCM_PLAYWRIGHT_EXECUTABLE \u6307\u7684\u6587\u4EF6\u4E0D\u53EF\u6267\u884C\uFF1A${explicit}`,
15652
16251
  context: { nextStep: "\u6307\u5230 Playwright \u88C5\u7684 chrome-headless-shell / chrome \u4E8C\u8FDB\u5236\uFF0C\u6216\u53BB\u6389\u8FD9\u4E2A\u53D8\u91CF\u8BA9 CLI \u81EA\u5DF1\u627E" }
15653
16252
  });
@@ -15689,8 +16288,8 @@ async function captureViaPlaywright(input) {
15689
16288
  }
15690
16289
  }
15691
16290
  if (!browser) {
15692
- throw new CliError32({
15693
- code: CliErrorCode33.SERVER_ERROR,
16291
+ throw new CliError33({
16292
+ code: CliErrorCode34.SERVER_ERROR,
15694
16293
  message: `Playwright \u8D77\u4E0D\u4E86\u6D4F\u89C8\u5668\uFF1A${failures.join("\uFF1B")}`,
15695
16294
  context: {
15696
16295
  nextStep: "\u88C5\u4E00\u4EFD Playwright \u7684 Chromium\uFF1Anpx playwright install chromium-headless-shell\uFF08\u6216 chromium\uFF09\uFF1B\u5DF2\u7ECF\u88C5\u4E86\u4F46\u4E0D\u5728\u7F3A\u7701\u7F13\u5B58\u76EE\u5F55\u5C31 export PLAYWRIGHT_BROWSERS_PATH=<\u76EE\u5F55> \u6216 HCM_PLAYWRIGHT_EXECUTABLE=<\u4E8C\u8FDB\u5236>\uFF1B\u6C99\u7BB1\u8FDE headless shell \u90FD\u8D77\u4E0D\u4E86\u65F6\uFF0C\u5728\u6C99\u7BB1\u5916\u8D77 Chrome \u5E76\u7528 --cdp \u8FDE"
@@ -15710,7 +16309,7 @@ async function captureViaPlaywright(input) {
15710
16309
  evalResult = toPlainJson(await page.evaluate(wrapEvalBody(input.evalJs)));
15711
16310
  } catch (e) {
15712
16311
  const why = (e instanceof Error ? e.message : String(e)).split("\n")[0] ?? "";
15713
- throw new CliError32({ code: CliErrorCode33.INVALID_ARGUMENT, message: `--eval \u5728\u9875\u9762\u91CC\u629B\u4E86\u5F02\u5E38\uFF1A${redactTicket(why)}` });
16312
+ throw new CliError33({ code: CliErrorCode34.INVALID_ARGUMENT, message: `--eval \u5728\u9875\u9762\u91CC\u629B\u4E86\u5F02\u5E38\uFF1A${redactTicket(why)}` });
15714
16313
  }
15715
16314
  }
15716
16315
  const dom = await page.content();
@@ -15734,13 +16333,13 @@ function judgePageContent(input) {
15734
16333
  function parseViewport(size) {
15735
16334
  const m = /^(\d+)x(\d+)$/.exec(size.trim());
15736
16335
  if (!m) {
15737
- throw new CliError33({ code: CliErrorCode34.INVALID_ARGUMENT, message: `--size \u8981\u5199\u6210 <\u5BBD>x<\u9AD8>\uFF0C\u4F8B\u5982 1440x900\uFF0C\u6536\u5230\u7684\u662F ${size}` });
16336
+ throw new CliError34({ code: CliErrorCode35.INVALID_ARGUMENT, message: `--size \u8981\u5199\u6210 <\u5BBD>x<\u9AD8>\uFF0C\u4F8B\u5982 1440x900\uFF0C\u6536\u5230\u7684\u662F ${size}` });
15738
16337
  }
15739
16338
  const width = Number(m[1]);
15740
16339
  const height = Number(m[2]);
15741
16340
  if (width < VIEWPORT_MIN.width || width > VIEWPORT_MAX.width || height < VIEWPORT_MIN.height || height > VIEWPORT_MAX.height) {
15742
- throw new CliError33({
15743
- code: CliErrorCode34.INVALID_ARGUMENT,
16341
+ throw new CliError34({
16342
+ code: CliErrorCode35.INVALID_ARGUMENT,
15744
16343
  message: `--size \u8D85\u51FA\u8303\u56F4\uFF1A\u5BBD ${VIEWPORT_MIN.width}..${VIEWPORT_MAX.width}\u3001\u9AD8 ${VIEWPORT_MIN.height}..${VIEWPORT_MAX.height}\uFF0C\u6536\u5230\u7684\u662F ${size}`
15745
16344
  });
15746
16345
  }
@@ -15750,23 +16349,23 @@ function parseWaitMs(raw) {
15750
16349
  if (raw === void 0) return 1e4;
15751
16350
  const value = typeof raw === "number" ? raw : Number(raw);
15752
16351
  if (!Number.isInteger(value) || value < 0 || value > WAIT_MS_MAX) {
15753
- throw new CliError33({ code: CliErrorCode34.INVALID_ARGUMENT, message: `--wait-ms \u8981\u662F 0..${WAIT_MS_MAX} \u7684\u6574\u6570\uFF0C\u6536\u5230\u7684\u662F ${raw}` });
16352
+ throw new CliError34({ code: CliErrorCode35.INVALID_ARGUMENT, message: `--wait-ms \u8981\u662F 0..${WAIT_MS_MAX} \u7684\u6574\u6570\uFF0C\u6536\u5230\u7684\u662F ${raw}` });
15754
16353
  }
15755
16354
  return value;
15756
16355
  }
15757
16356
  function resolveEvidenceTarget(projectRoot, out) {
15758
16357
  if (!out?.trim()) {
15759
- throw new CliError33({ code: CliErrorCode34.MISSING_FLAG, message: `\u8981\u4F20 --out <${EVIDENCE_DIR}/\u2026/\u622A\u56FE.png>\uFF1A\u622A\u56FE\u843D\u5728\u54EA\u513F\u5FC5\u987B\u662F\u4F60\u5B9A\u7684\uFF0C\u4E0D\u7531\u547D\u4EE4\u731C` });
16358
+ throw new CliError34({ code: CliErrorCode35.MISSING_FLAG, message: `\u8981\u4F20 --out <${EVIDENCE_DIR}/\u2026/\u622A\u56FE.png>\uFF1A\u622A\u56FE\u843D\u5728\u54EA\u513F\u5FC5\u987B\u662F\u4F60\u5B9A\u7684\uFF0C\u4E0D\u7531\u547D\u4EE4\u731C` });
15760
16359
  }
15761
16360
  if (!out.endsWith(".png")) {
15762
- throw new CliError33({ code: CliErrorCode34.INVALID_ARGUMENT, message: `--out \u8981\u4EE5 .png \u7ED3\u5C3E\uFF0C\u6536\u5230\u7684\u662F ${out}` });
16361
+ throw new CliError34({ code: CliErrorCode35.INVALID_ARGUMENT, message: `--out \u8981\u4EE5 .png \u7ED3\u5C3E\uFF0C\u6536\u5230\u7684\u662F ${out}` });
15763
16362
  }
15764
16363
  const root = path16.resolve(projectRoot);
15765
16364
  const evidenceRoot = path16.join(root, EVIDENCE_DIR);
15766
16365
  const absolute = path16.resolve(root, out);
15767
16366
  if (absolute !== evidenceRoot && !absolute.startsWith(evidenceRoot + path16.sep)) {
15768
- throw new CliError33({
15769
- code: CliErrorCode34.INVALID_ARGUMENT,
16367
+ throw new CliError34({
16368
+ code: CliErrorCode35.INVALID_ARGUMENT,
15770
16369
  message: `--out \u8981\u843D\u5728\u9879\u76EE\u7684 ${EVIDENCE_DIR}/ \u4E0B\uFF08${evidenceRoot}\uFF09\uFF0C\u6536\u5230\u7684\u662F ${absolute}`
15771
16370
  });
15772
16371
  }
@@ -15814,8 +16413,8 @@ async function assertInsideEvidence(deps, evidenceRoot, absolute) {
15814
16413
  const canonicalParent = await deps.realpath(path16.dirname(absolute));
15815
16414
  if (canonicalRoot === null || canonicalParent === null) return;
15816
16415
  if (canonicalParent !== canonicalRoot && !canonicalParent.startsWith(canonicalRoot + path16.sep)) {
15817
- throw new CliError33({
15818
- code: CliErrorCode34.INVALID_ARGUMENT,
16416
+ throw new CliError34({
16417
+ code: CliErrorCode35.INVALID_ARGUMENT,
15819
16418
  message: `--out \u7684\u7236\u76EE\u5F55\u7ECF\u7B26\u53F7\u94FE\u63A5\u8DD1\u51FA\u4E86 ${EVIDENCE_DIR}/\uFF1A${canonicalParent}`
15820
16419
  });
15821
16420
  }
@@ -15824,8 +16423,8 @@ async function runChironPage(target, args, deps) {
15824
16423
  const sitePath = normalizeTarget(target);
15825
16424
  const expect = (args.expectText ?? []).filter((t) => t.trim().length > 0);
15826
16425
  if (expect.length === 0) {
15827
- throw new CliError33({
15828
- code: CliErrorCode34.MISSING_FLAG,
16426
+ throw new CliError34({
16427
+ code: CliErrorCode35.MISSING_FLAG,
15829
16428
  message: "\u81F3\u5C11\u8981\u4F20\u4E00\u6761 --expect-text\uFF08\u9875\u9762\u4E0A\u5FC5\u987B\u51FA\u73B0\u7684\u6587\u672C\uFF09\u3002\u53EA\u5224\u300C\u622A\u51FA\u56FE\u4E86\u300D\u4E0D\u7B97\u9A8C\u6536\uFF1A\u767B\u5F55\u9875\u3001\u62A5\u9519\u9875\u3001\u767D\u5C4F\u90FD\u80FD\u622A\u51FA\u56FE\u3002"
15830
16429
  });
15831
16430
  }
@@ -15835,8 +16434,8 @@ async function runChironPage(target, args, deps) {
15835
16434
  const root = path16.resolve(args.project ?? ".");
15836
16435
  const { evidenceRoot, absolute } = resolveEvidenceTarget(root, args.out);
15837
16436
  if (await deps.present(absolute)) {
15838
- throw new CliError33({
15839
- code: CliErrorCode34.INVALID_ARGUMENT,
16437
+ throw new CliError34({
16438
+ code: CliErrorCode35.INVALID_ARGUMENT,
15840
16439
  message: `\u622A\u56FE\u5DF2\u5B58\u5728\uFF0C\u4E0D\u8986\u76D6\uFF1A${absolute}\u3002\u6362\u4E2A --out\uFF0C\u6216\u5148\u628A\u65E7\u8BC1\u636E\u632A\u8D70\u3002`
15841
16440
  });
15842
16441
  }
@@ -15848,8 +16447,8 @@ async function runChironPage(target, args, deps) {
15848
16447
  const playwrightBrowser = endpoint || forceSpawn ? null : deps.findPlaywrightBrowser();
15849
16448
  const usePlaywright = !endpoint && !forceSpawn && (playwrightBrowser !== null || evalJs !== void 0);
15850
16449
  if (evalJs && !endpoint && !usePlaywright) {
15851
- throw new CliError33({
15852
- code: CliErrorCode34.INVALID_ARGUMENT,
16450
+ throw new CliError34({
16451
+ code: CliErrorCode35.INVALID_ARGUMENT,
15853
16452
  message: "--eval \u9700\u8981 Playwright \u6216 --cdp\uFF1A\u8001\u7684 spawn \u8DEF\u5F84\u53EA\u4F1A --dump-dom\uFF0C\u585E\u4E0D\u8FDB\u811A\u672C\u3002",
15854
16453
  context: { nextStep: "npx playwright install chromium-headless-shell\uFF0C\u6216\u5728\u6C99\u7BB1\u5916\u8D77 Chrome \u7528 --cdp \u8FDE" }
15855
16454
  });
@@ -15867,10 +16466,10 @@ async function runChironPage(target, args, deps) {
15867
16466
  try {
15868
16467
  captured = endpoint ? await deps.captureAttached({ endpoint, viewport, waitMs, evalJs, screenshot: absolute, mintUrl: mint }) : await deps.capturePlaywright({ viewport, waitMs, evalJs, screenshot: absolute, browser: playwrightBrowser, mintUrl: mint });
15869
16468
  } catch (e) {
15870
- if (e instanceof CliError33) throw new CliError33({ code: e.code, message: redactTicket(e.message), context: e.context });
16469
+ if (e instanceof CliError34) throw new CliError34({ code: e.code, message: redactTicket(e.message), context: e.context });
15871
16470
  const where = endpoint ? `\u8FDE\u5230 ${endpoint} \u7684 Chrome` : "Playwright \u8D77\u7684\u6D4F\u89C8\u5668";
15872
- throw new CliError33({
15873
- code: CliErrorCode34.SERVER_ERROR,
16471
+ throw new CliError34({
16472
+ code: CliErrorCode35.SERVER_ERROR,
15874
16473
  message: `${where}\u6CA1\u8DD1\u5B8C\uFF1A${redactTicket(e instanceof Error ? e.message : String(e))}`,
15875
16474
  context: {
15876
16475
  nextStep: endpoint ? `\u6838\u4E00\u773C ${endpoint}/json/version \u80FD\u4E0D\u80FD\u6253\u5F00\uFF1BChrome \u8981\u5E26 --remote-debugging-port \u8D77\uFF0C\u4E14\u6C99\u7BB1\u653E\u884C\u4E86\u8FD9\u4E2A\u7AEF\u53E3` : "npx playwright install chromium-headless-shell \u540E\u91CD\u8DD1\uFF1B\u6216 HCM_CHIRON_PAGE_DRIVER=spawn \u8D70\u8001\u8DEF\u5F84\u5BF9\u7167"
@@ -15886,8 +16485,8 @@ async function runChironPage(target, args, deps) {
15886
16485
  mode = "spawn";
15887
16486
  const browser = deps.findBrowser();
15888
16487
  if (!browser) {
15889
- throw new CliError33({
15890
- code: CliErrorCode34.INVALID_ARGUMENT,
16488
+ throw new CliError34({
16489
+ code: CliErrorCode35.INVALID_ARGUMENT,
15891
16490
  message: "\u672C\u673A\u627E\u4E0D\u5230 Playwright \u7684 Chromium\uFF0C\u4E5F\u627E\u4E0D\u5230 Chrome/Chromium\uFF0C\u622A\u4E0D\u4E86\u56FE\u3002",
15892
16491
  context: { nextStep: "npx playwright install chromium-headless-shell\uFF08\u6C99\u7BB1\u91CC\u4E5F\u80FD\u8DD1\uFF09\uFF1B\u6216\u88C5\u4E00\u4E2A Chrome / HCM_CHROME_BIN=/\u7EDD\u5BF9\u8DEF\u5F84\uFF1B\u6216\u5728\u6C99\u7BB1\u5916\u8D77 Chrome \u7528 --cdp \u8FDE" }
15893
16492
  });
@@ -15895,8 +16494,8 @@ async function runChironPage(target, args, deps) {
15895
16494
  minted = await mint();
15896
16495
  const result = deps.capture({ browser, argv: chromeArgv({ viewport, waitMs, screenshot: absolute, url: minted.url, isRoot: process.getuid?.() === 0 }) });
15897
16496
  if (!result.ok) {
15898
- throw new CliError33({
15899
- code: CliErrorCode34.SERVER_ERROR,
16497
+ throw new CliError34({
16498
+ code: CliErrorCode35.SERVER_ERROR,
15900
16499
  message: `\u6D4F\u89C8\u5668\u6CA1\u8DD1\u5B8C\uFF1A${redactTicket(result.stderr.trim().split("\n").slice(-1)[0] ?? "\u65E0\u8F93\u51FA")}`,
15901
16500
  context: { nextStep: spawnFailureNextStep(browser, result, deps.platform) }
15902
16501
  });
@@ -15906,7 +16505,7 @@ async function runChironPage(target, args, deps) {
15906
16505
  }
15907
16506
  const bytes = await deps.present(absolute) ? await deps.sizeOf(absolute) : 0;
15908
16507
  if (bytes === 0) {
15909
- throw new CliError33({ code: CliErrorCode34.SERVER_ERROR, message: `\u6D4F\u89C8\u5668\u6CA1\u5199\u51FA\u975E\u7A7A PNG\uFF1A${absolute}` });
16508
+ throw new CliError34({ code: CliErrorCode35.SERVER_ERROR, message: `\u6D4F\u89C8\u5668\u6CA1\u5199\u51FA\u975E\u7A7A PNG\uFF1A${absolute}` });
15910
16509
  }
15911
16510
  const verdict = judgePageContent({ dom, expect, reject });
15912
16511
  return {
@@ -15969,8 +16568,8 @@ var defaultChironPageDeps = {
15969
16568
  const envCfg = await loadEnv6(ctx.env);
15970
16569
  const frontend = ctx.frontend ?? envCfg.frontend;
15971
16570
  if (!frontend?.trim()) {
15972
- throw new CliError33({
15973
- code: CliErrorCode34.INVALID_ARGUMENT,
16571
+ throw new CliError34({
16572
+ code: CliErrorCode35.INVALID_ARGUMENT,
15974
16573
  message: `env '${ctx.env}' \u6CA1\u914D\u524D\u7AEF\u5730\u5740\uFF0C\u5F00\u4E0D\u4E86\u9875\u9762\u3002`,
15975
16574
  context: { nextStep: `hcm env edit frontend <\u524D\u7AEF\u5730\u5740> --env ${ctx.env}` }
15976
16575
  });
@@ -16059,7 +16658,7 @@ init_auth_guard();
16059
16658
  import { HcmClient as HcmClient25, classifyEffect } from "@hcmai/sdk";
16060
16659
 
16061
16660
  // src/commands/delivery.ts
16062
- import { createHash as createHash8 } from "crypto";
16661
+ import { createHash as createHash9 } from "crypto";
16063
16662
  import { LEDGER_ONLY_FLAG } from "@hcmai/sdk";
16064
16663
  var APPROVAL_BYPASS_FLAGS = /* @__PURE__ */ new Set(["-y", "--yes", "--force", "--auto-approve"]);
16065
16664
  var CREDENTIAL_FLAGS = /* @__PURE__ */ new Set([
@@ -16079,11 +16678,12 @@ var GUARDED_EXECUTOR_REASON_CODES = /* @__PURE__ */ new Set([
16079
16678
  "setting-write",
16080
16679
  "credential-reset",
16081
16680
  "action-write",
16082
- // 三态 effect 的 UNKNOWN / 未识别值都按最坏情况视作写操作,走与 WRITES
16681
+ // ACCOUNTING_ONLY、UNKNOWN、未识别值都走与 WRITES 同级的受控执行,原因各自留痕。
16083
16682
  // 完全相同的 prepare + execute 通道。分类函数已经返回 R2 guarded;这里漏登记
16084
16683
  // 会把 guardedExecutionAvailable 又翻回 false,造成 reason 与 modePolicy 自相矛盾。
16085
16684
  "action-effect-undetermined",
16086
16685
  "action-effect-unrecognized",
16686
+ "action-effect-accounting-only",
16087
16687
  "workspace-create",
16088
16688
  "workspace-activate",
16089
16689
  "workspace-deactivate",
@@ -16252,6 +16852,12 @@ function classify(argv, actionResolution) {
16252
16852
  effect: "external-probe-accounted",
16253
16853
  reasonCode: "chiron-doctor-active",
16254
16854
  reason: "\u4E3B\u52A8\u63A2\u6D4B\u771F\u8C03\u7B2C\u4E09\u65B9\u5E76\u8BB0\u8D26\uFF0C\u4E0D\u5199\u4E1A\u52A1\u6570\u636E\uFF1B\u6309\u9879\u76EE\u7684\u5199\u6388\u6743\u7EAA\u5F8B\u6267\u884C\u3002"
16855
+ } : hasFlag(argv, "--platform-ops") ? {
16856
+ risk: "R1",
16857
+ execution: "direct",
16858
+ effect: "remote-read",
16859
+ reasonCode: "chiron-doctor-platform-ops",
16860
+ reason: "\u53EA\u8BFB\u8FD0\u7EF4\u5BC6\u94A5\u8BFB\u5E73\u53F0\u5C42\uFF0C\u4E0D\u5199\u4EFB\u4F55\u4E1C\u897F\u3002"
16255
16861
  } : direct("R1", "remote-read", "chiron-doctor");
16256
16862
  if (subcommand === "init") return direct("R1", "managed-local-write", "chiron-project-scaffold");
16257
16863
  if (subcommand === "test") return direct("R1", "remote-read", "chiron-regression-test");
@@ -16521,7 +17127,7 @@ function guarded(effect, reasonCode) {
16521
17127
  };
16522
17128
  }
16523
17129
  function classifyAction(policy) {
16524
- if (policy.readOnly) {
17130
+ if (policy.readOnly && (policy.effect === void 0 || policy.effect === "read-only")) {
16525
17131
  return {
16526
17132
  risk: "R1",
16527
17133
  execution: "direct",
@@ -16539,13 +17145,22 @@ function classifyAction(policy) {
16539
17145
  reason: "\u4EA7\u54C1\u4FA7\u628A\u8FD9\u4E2A Action \u58F0\u660E\u6210 effect=UNKNOWN\uFF1A**\u6CA1\u4EBA\u5224\u8FC7**\u5B83\u5199\u4E0D\u5199\u5E93\u3002\u6309\u6700\u574F\u60C5\u51B5\u8D70\u53D7\u63A7\u6267\u884C\uFF08\u4E0E\u4F1A\u5199\u7684 Action \u540C\u4E00\u6761\u8DEF\u5F84\uFF09\uFF0C\u4F46\u5B83\u4E0D\u7B49\u4E8E\u300C\u786E\u8BA4\u4F1A\u5199\u300D\u3002next_step=\u53BB\u4EA7\u54C1\u4FA7\u7ED9\u8FD9\u4E2A @ClassAction/@ObjectAction \u628A effect \u5224\u6389\uFF08READ_ONLY / WRITES\uFF09\uFF0C\u800C\u4E0D\u662F\u5728 CLI \u8FD9\u8FB9\u653E\u5BBD\u3002"
16540
17146
  };
16541
17147
  }
17148
+ if (policy.effect === "accounting-only") {
17149
+ return {
17150
+ risk: "R2",
17151
+ execution: "guarded",
17152
+ effect: "accounting-only",
17153
+ reasonCode: "action-effect-accounting-only",
17154
+ reason: "Core \u5DF2\u5224\u5B9A\u8BE5 Action \u4E0D\u5199\u4E1A\u52A1\u6570\u636E\uFF0C\u4F46\u4F1A\u4EA7\u751F\u767B\u8BB0\u5728\u518C\u7684\u8BB0\u8D26\u7C7B\u526F\u4F5C\u7528\uFF08\u5982\u8C03\u7528\u5916\u90E8\u6A21\u578B\u8BA1\u5165\u79DF\u6237\u9884\u7B97\u3001\u5199\u4E00\u6761\u5BA1\u8BA1\uFF09\uFF1B\u672C\u901A\u9053\u53EA\u8DD1\u53EA\u8BFB\uFF0C\u6240\u4EE5\u6CA1\u6709\u6267\u884C\uFF0C\u4E5F\u4E0D\u80FD\u6309\u53EA\u8BFB\u76F4\u6267\u884C\u3002next_step=\u786E\u9700\u6267\u884C\u65F6\uFF0C\u8BF4\u660E\u8BB0\u8D26\u5F71\u54CD\u5E76\u53D6\u5F97\u672C\u6B21\u663E\u5F0F\u786E\u8BA4\u540E\uFF0C\u76F4\u63A5\u7528 hcm action <Model.Action> \u8C03\u7528\uFF08danger \u73AF\u5883\u53E6\u52A0 --allow-danger\uFF09\u3002"
17155
+ };
17156
+ }
16542
17157
  if (policy.effect === "unrecognized-effect") {
16543
17158
  return {
16544
17159
  risk: "R2",
16545
17160
  execution: "guarded",
16546
17161
  effect: "undetermined",
16547
17162
  reasonCode: "action-effect-unrecognized",
16548
- reason: `Core \u9001\u6765\u7684 effect \u53D6\u503C ${describeEffectRaw(policy.effectRaw)} \u4E0D\u5728 READ_ONLY / WRITES / UNKNOWN \u4E09\u6001\u5185\uFF08\u62FC\u5199\u6F02\u79FB\uFF1F\u670D\u52A1\u7AEF\u6BD4\u672C CLI \u65B0\u3001\u591A\u4E86\u4E00\u6001\uFF1F\uFF09\u3002fail-closed\uFF1A\u6309 UNKNOWN \u5904\u7F6E\u8D70\u53D7\u63A7\u6267\u884C\uFF0C\u4E0D\u731C\u6210\u53EA\u8BFB\u3002next_step=\u62FF\u8FD9\u4E2A\u539F\u503C\u53BB\u5BF9\u4EA7\u54C1\u4FA7\u7684 ActionEffect \u5B9A\u4E49\uFF0C\u5FC5\u8981\u65F6\u5347\u7EA7 CLI\u3002`
17163
+ reason: `Core \u9001\u6765\u7684 effect \u53D6\u503C ${describeEffectRaw(policy.effectRaw)} \u4E0D\u5728 READ_ONLY / WRITES / ACCOUNTING_ONLY / UNKNOWN \u56DB\u6863\u5185\uFF08\u62FC\u5199\u6F02\u79FB\uFF1F\u670D\u52A1\u7AEF\u6BD4\u672C CLI \u65B0\u3001\u591A\u4E86\u4E00\u6863\uFF1F\uFF09\u3002fail-closed\uFF1A\u6309 UNKNOWN \u5904\u7F6E\u8D70\u53D7\u63A7\u6267\u884C\uFF0C\u4E0D\u731C\u6210\u53EA\u8BFB\u3002next_step=\u62FF\u8FD9\u4E2A\u539F\u503C\u53BB\u5BF9\u4EA7\u54C1\u4FA7\u7684 ActionEffect \u5B9A\u4E49\uFF0C\u5FC5\u8981\u65F6\u5347\u7EA7 CLI\u3002`
16549
17164
  };
16550
17165
  }
16551
17166
  return guarded("tenant-write", "action-write");
@@ -16605,7 +17220,7 @@ function valuesAfterFlag(argv, flag) {
16605
17220
  return values;
16606
17221
  }
16607
17222
  function sha2564(value) {
16608
- return createHash8("sha256").update(value).digest("hex");
17223
+ return createHash9("sha256").update(value).digest("hex");
16609
17224
  }
16610
17225
  function isPlainObject(value) {
16611
17226
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -16671,7 +17286,7 @@ function policyFromActionMeta(action, request) {
16671
17286
  if (typeof action.readOnly !== "boolean") {
16672
17287
  return failed(
16673
17288
  "action-readonly-unclassified",
16674
- "Core \u672A\u8FD4\u56DE Action \u7684 effect \u4E09\u6001\u58F0\u660E\uFF0C\u4E5F\u6CA1\u6709\u56DE\u843D\u7528\u7684 readOnly \u5E03\u5C14\uFF0C\u6309\u5B89\u5168\u9ED8\u8BA4\u62D2\u7EDD\u6267\u884C\u3002"
17289
+ "Core \u672A\u8FD4\u56DE Action \u7684 effect \u58F0\u660E\uFF0C\u4E5F\u6CA1\u6709\u56DE\u843D\u7528\u7684 readOnly \u5E03\u5C14\uFF0C\u6309\u5B89\u5168\u9ED8\u8BA4\u62D2\u7EDD\u6267\u884C\u3002"
16675
17290
  );
16676
17291
  }
16677
17292
  return { status: "resolved", policy: { ...shape, readOnly: action.readOnly } };
@@ -17620,7 +18235,7 @@ import {
17620
18235
  VERIFY_CRASHED,
17621
18236
  VERIFY_WORDS,
17622
18237
  WorkLayout,
17623
- classifyStatus as classifyStatus2,
18238
+ classifyStatus as classifyStatus3,
17624
18239
  runActiveVerify,
17625
18240
  runMetaChange,
17626
18241
  seedWorkDir as seedWorkDir2
@@ -17805,7 +18420,7 @@ function metaClient(client3, ctx) {
17805
18420
  return {
17806
18421
  status: res.status,
17807
18422
  body: res.data,
17808
- error: classifyStatus2(res.status),
18423
+ error: classifyStatus3(res.status),
17809
18424
  headers: lowerCaseHeaders2(res.headers)
17810
18425
  };
17811
18426
  } catch (e) {
@@ -17816,7 +18431,7 @@ function metaClient(client3, ctx) {
17816
18431
  body: res?.data ?? null,
17817
18432
  // 🔴 `-1` **不是** HTTP 状态:网络层没走通与「服务端答了个 4xx」在处置上相反 ——
17818
18433
  // 改动轴正是靠这一格把「确认没写」与「不知道写没写」分开。
17819
- error: status === -1 ? "network" : classifyStatus2(status),
18434
+ error: status === -1 ? "network" : classifyStatus3(status),
17820
18435
  headers: lowerCaseHeaders2(res?.headers)
17821
18436
  };
17822
18437
  }
@@ -17940,21 +18555,21 @@ import {
17940
18555
  adminResetPassword,
17941
18556
  formatObject as formatObject32,
17942
18557
  fromAxiosError as fromAxiosError23,
17943
- CliError as CliError34,
17944
- CliErrorCode as CliErrorCode35
18558
+ CliError as CliError35,
18559
+ CliErrorCode as CliErrorCode36
17945
18560
  } from "@hcmai/sdk";
17946
18561
  function buildAdminResetPasswordRequest(args, password) {
17947
18562
  const hasId = Boolean(args.id);
17948
18563
  const hasUsername = Boolean(args.username);
17949
18564
  if (hasId === hasUsername) {
17950
- throw new CliError34({
17951
- code: CliErrorCode35.INVALID_ARGUMENT,
18565
+ throw new CliError35({
18566
+ code: CliErrorCode36.INVALID_ARGUMENT,
17952
18567
  message: "--id <uuid> \u4E0E --username <user> \u5FC5\u987B\u4E14\u53EA\u80FD\u63D0\u4F9B\u4E00\u4E2A"
17953
18568
  });
17954
18569
  }
17955
18570
  if (!password) {
17956
- throw new CliError34({
17957
- code: CliErrorCode35.INVALID_ARGUMENT,
18571
+ throw new CliError35({
18572
+ code: CliErrorCode36.INVALID_ARGUMENT,
17958
18573
  message: "\u65B0\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A"
17959
18574
  });
17960
18575
  }
@@ -17983,8 +18598,8 @@ async function promptPasswordTwice() {
17983
18598
  const password = await promptSecret("\u65B0\u5BC6\u7801: ");
17984
18599
  const confirmation = await promptSecret("\u518D\u6B21\u8F93\u5165\u65B0\u5BC6\u7801: ");
17985
18600
  if (password !== confirmation) {
17986
- throw new CliError34({
17987
- code: CliErrorCode35.INVALID_ARGUMENT,
18601
+ throw new CliError35({
18602
+ code: CliErrorCode36.INVALID_ARGUMENT,
17988
18603
  message: "\u4E24\u6B21\u8F93\u5165\u7684\u65B0\u5BC6\u7801\u4E0D\u4E00\u81F4"
17989
18604
  });
17990
18605
  }
@@ -18118,7 +18733,7 @@ chiron.command("test").description("\u6309\u7528\u4F8B\u8DD1\u4E00\u904D\u5E76\u
18118
18733
  chiron.command("page").description("\u6253\u5F00\u9875\u9762\u622A\u56FE\u5E76\u5BF9\u7740\u9875\u9762\u5185\u5BB9\u5224\u4E00\u6B21\uFF1A\u81F3\u5C11\u8981\u7ED9\u4E00\u6761 --expect-text\uFF0C\u53EA\u622A\u56FE\u4E0D\u7B97\u9A8C\u6536").argument("<\u8DEF\u5F84>", "\u7AD9\u5185\u8DEF\u5F84\uFF0C\u5982 /dashboard/xxx").requiredOption("--out <file>", "\u622A\u56FE\u843D\u70B9\uFF0C\u5FC5\u987B\u5728\u9879\u76EE\u7684 evidence/ \u4E0B\u4E14\u4EE5 .png \u7ED3\u5C3E").option("--expect-text <text...>", "\u9875\u9762\u4E0A\u5FC5\u987B\u51FA\u73B0\u7684\u6587\u672C\uFF08\u81F3\u5C11\u4E00\u6761\uFF09").option("--reject-text <text...>", "\u9875\u9762\u4E0A\u4E0D\u5F97\u51FA\u73B0\u7684\u6587\u672C").option("--project <dir>", "\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--env <name>", "\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--wait-ms <ms>", "\u9875\u9762\u6E32\u67D3\u9884\u7B97\u6BEB\u79D2\u6570", "10000").option("--size <WxH>", "\u89C6\u53E3\u5C3A\u5BF8", "1440x900").option("--cdp <endpoint>", "\u4E0D\u81EA\u5DF1\u8D77 Chrome\uFF0C\u8FDE\u5230\u5DF2\u5728\u8DD1\u7684 Chrome\uFF08--remote-debugging-port\uFF09\uFF1A\u6C99\u7BB1\u91CC\u8D77\u4E0D\u4E86 Chrome \u65F6\u7528\uFF1B\u4E5F\u8BFB HCM_CHROME_CDP").option("--eval <js>", "\u622A\u56FE\u524D\u5728\u9875\u9762\u91CC\u8DD1\u7684 JS\uFF08\u51FD\u6570\u4F53\uFF0C\u53EF await\uFF0C\u8FD4\u56DE\u503C\u8FDB\u56DE\u6267\uFF09\uFF1A\u70B9\u6309\u94AE\u3001\u586B\u8868\u3001\u8FFD\u95EE\u90FD\u9760\u5B83\uFF1B\u9700\u8981 Playwright \u6216 --cdp").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((target, opts) => chironPageCommand(target, opts));
18119
18734
  chiron.command("doctor").description(
18120
18735
  "\u4F53\u68C0\u672C\u673A 9 \u9879\u4E0E\u6BCF\u73AF\u5883\u8FDE\u63A5 7 \u9879\uFF1B\u7ED3\u8BBA READY / READY_WITH_RISKS / BLOCKED"
18121
- ).option("--project <dir>", "\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--env <name>", "\u9009\u5B9A\u76EE\u6807\u73AF\u5883\uFF08\u9ED8\u8BA4 env.yaml default\uFF09\uFF1B\u5176\u4F59\u73AF\u5883\u4ECD\u68C0\u67E5\uFF0C\u5931\u8D25\u8BB0\u98CE\u9669").option("--as <identity>", "\u4EE5\u6307\u5B9A\u8EAB\u4EFD\u4F53\u68C0\uFF08\u6CBF\u7528\u4E1A\u52A1\u547D\u4EE4\u7684\u4EE3\u7406\u56DE\u843D\uFF09").option("--stage <stage>", "\u9636\u6BB5\uFF1Ahandover | baseline | configure | migrate | integrate | golive | operate").option("--only <prefix>", "\u53EA\u68C0\u67E5\u8FD9\u4E9B id \u6216\u524D\u7F00\uFF0C\u9017\u53F7\u5206\u9694\uFF1B\u53EF\u91CD\u590D", (value, previous) => [...previous, value], []).option("--skip <prefix>", "\u6392\u9664\u8FD9\u4E9B id \u6216\u524D\u7F00\uFF0C\u9017\u53F7\u5206\u9694\uFF1B\u53EF\u91CD\u590D", (value, previous) => [...previous, value], []).option("--active", "\u5141\u8BB8\u4E3B\u52A8\u63A2\u6D4B\u7B2C\u4E09\u65B9\u5E76\u8BB0\u8D26").option("--list", "\u5217\u51FA\u672C\u673A\u4E0E\u670D\u52A1\u7AEF\u7684\u68C0\u67E5\u76EE\u5F55").option("--explain <id>", "\u8BF4\u660E\u6307\u5B9A\u68C0\u67E5\u7684\u5224\u636E\u3001\u4F9D\u8D56\u548C\u7801\u8868").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").option("--fail-on <level>", "\u975E\u96F6\u9000\u51FA\u9608\u503C\uFF1Ablocked | risks\uFF08\u9ED8\u8BA4 blocked\uFF09").action((opts) => chironDoctorCommand(opts));
18736
+ ).option("--project <dir>", "\u9879\u76EE\u6839\u76EE\u5F55\uFF08\u9ED8\u8BA4\u5F53\u524D\u76EE\u5F55\uFF09").option("--env <name>", "\u9009\u5B9A\u76EE\u6807\u73AF\u5883\uFF08\u9ED8\u8BA4 env.yaml default\uFF09\uFF1B\u5176\u4F59\u73AF\u5883\u4ECD\u68C0\u67E5\uFF0C\u5931\u8D25\u8BB0\u98CE\u9669").option("--as <identity>", "\u4EE5\u6307\u5B9A\u8EAB\u4EFD\u4F53\u68C0\uFF08\u6CBF\u7528\u4E1A\u52A1\u547D\u4EE4\u7684\u4EE3\u7406\u56DE\u843D\uFF09").option("--stage <stage>", "\u9636\u6BB5\uFF1Ahandover | baseline | configure | migrate | integrate | golive | operate").option("--only <prefix>", "\u53EA\u68C0\u67E5\u8FD9\u4E9B id \u6216\u524D\u7F00\uFF0C\u9017\u53F7\u5206\u9694\uFF1B\u53EF\u91CD\u590D", (value, previous) => [...previous, value], []).option("--skip <prefix>", "\u6392\u9664\u8FD9\u4E9B id \u6216\u524D\u7F00\uFF0C\u9017\u53F7\u5206\u9694\uFF1B\u53EF\u91CD\u590D", (value, previous) => [...previous, value], []).option("--active", "\u5141\u8BB8\u4E3B\u52A8\u63A2\u6D4B\u7B2C\u4E09\u65B9\u5E76\u8BB0\u8D26").option("--platform-ops", "\u53EA\u7528\u8FD0\u7EF4\u53EA\u8BFB\u5BC6\u94A5\u68C0\u67E5\u5E94\u7B54\u5B9E\u4F8B\u7684\u5E73\u53F0\u5C42").option("--platform-ops-key-stdin", "\u4ECE stdin \u8BFB\u53D6\u8FD0\u7EF4\u53EA\u8BFB\u5BC6\u94A5").option("--list", "\u5217\u51FA\u672C\u673A\u4E0E\u670D\u52A1\u7AEF\u7684\u68C0\u67E5\u76EE\u5F55").option("--explain <id>", "\u8BF4\u660E\u6307\u5B9A\u68C0\u67E5\u7684\u5224\u636E\u3001\u4F9D\u8D56\u548C\u7801\u8868").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").option("--fail-on <level>", "\u975E\u96F6\u9000\u51FA\u9608\u503C\uFF1Ablocked | risks\uFF08\u9ED8\u8BA4 blocked\uFF09").action((opts) => chironDoctorCommand(opts));
18122
18737
  var chironSkills = chiron.command("skills").description("\u8FD9\u4E2A\u9879\u76EE\u4ED3\u7684\u6280\u80FD\uFF1A\u8DDF\u76EE\u6807\u73AF\u5883\u5BF9\u9F50");
18123
18738
  chironSkills.command("sync").description("\u8BA9\u8FD9\u4E2A\u4ED3\u7684\u6280\u80FD\u8DDF\u76EE\u6807\u73AF\u5883\u5BF9\u9F50\uFF1A\u7B2C\u4E00\u6B21\u5C31\u88C5\u9F50\uFF0C\u4E4B\u540E\u6309\u4EA7\u54C1\u5F53\u524D\u5168\u96C6\u5BF9\u8D26\u3002\u5E42\u7B49\uFF0C\u4EA7\u54C1\u5347\u7EA7\u540E\u8DD1\u5B83").option("--only <id...>", "\u53EA\u8981\u8FD9\u51E0\u4E2A\u6280\u80FD\uFF08\u8FDE\u540C requires \u524D\u7F6E\uFF09\uFF0C\u4E0D\u8BA2\u9605\u5168\u96C6\uFF1B\u8BAD\u7EC3\u573A blind \u6863\u7528").option("--check", "\u53EA\u770B\u4F1A\u53D8\u4EC0\u4E48\uFF0C\u4E0D\u5199\u76D8").option("--target <agent>", "claude\uFF08.claude/skills/\uFF09| codex\uFF08hcm-skills/ + Agent \u7D22\u5F15\uFF09| auto", "auto").option("--global", "\u540C\u6B65\u7528\u6237\u7EA7\u76EE\u5F55\u800C\u975E\u5F53\u524D\u9879\u76EE").option("--dir <path>", "\u540C\u6B65\u6307\u5B9A\u76EE\u5F55").option("--from <dir>", "\u4ECE\u672C\u5730\u76EE\u5F55\u53D6\uFF08\u73B0\u573A\u6539\u8FC7\u7684\u7248\u672C\uFF09\uFF0C\u4E0D\u8D70\u7F51\u7EDC").option("--force", "\u8FDE\u672C\u5730\u6539\u8FC7\u7684\u6280\u80FD\u4E00\u8D77\u8986\u76D6\u6210\u4EA7\u54C1\u8FD9\u4E00\u7248").option("--prune-max <n>", `\u4E00\u8D9F\u6700\u591A\u6E05\u51E0\u4EFD\u4E0A\u6E38\u4E0D\u518D\u53D1\u7684\u6280\u80FD\uFF0C\u8D85\u4E86\u6574\u6279\u62D2\u7EDD\uFF1B0 = \u4E00\u4EFD\u90FD\u522B\u6E05\uFF08\u7F3A\u7701 ${PRUNE_DEFAULT_MAX}\uFF09`).option("--source <kind>", "\u8FD9\u4E00\u8D9F\u770B\u54EA\u4E9B\u6765\u6E90\uFF1Acli\uFF08\u53EA\u770B\u81EA\u5E26\uFF0C\u4E0D\u8FDE\u7F51\uFF09| chiron | all", "all").option("--endpoint <url>", "\u6280\u80FD\u5E93\u5730\u5740\uFF08\u9ED8\u8BA4\u53D6\u9879\u76EE\u73AF\u5883\u6216\u5B89\u88C5\u65F6\u8BB0\u5F55\u7684\u5730\u5740\uFF09").option("--env <name>", "\u4ECE\u8BE5 env \u89E3\u6790 endpoint").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => skillsSyncCommand(opts));
18124
18739
  chironSkills.command("path <id>").description("\u6253\u5370\u8FD9\u4E2A id \u5728\u672C\u9879\u76EE\u5B9E\u9645\u751F\u6548\u90A3\u4E00\u4EFD\u7684\u8DEF\u5F84\uFF08local/ \u906E\u853D sync/\uFF09\uFF0C\u4F9B\u6280\u80FD\u6B63\u6587\u5F15\u7528\uFF0C\u514D\u5F97\u6B63\u6587\u5199\u6B7B\u76EE\u5F55\u5C42\u6570").option("--refs", "\u8981 references/ \u7684\u843D\u70B9\uFF0C\u4E0D\u662F SKILL.md").option("--target <agent>", "claude | codex | auto", "auto").option("--global", "\u770B\u7528\u6237\u7EA7\u76EE\u5F55").option("--dir <path>", "\u770B\u6307\u5B9A\u76EE\u5F55").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((id, opts) => skillsPathCommand(id, opts));
@@ -18313,7 +18928,7 @@ datapackage.command("install <artifact>").description("\u4E0A\u4F20 .hcmpkg \u52
18313
18928
  datapackage.command("status <runId>").description("\u67E5\u770B\u88C5\u8F7D\u6D41\u6C34\u8FDB\u5EA6/\u7EC8\u6001\uFF08\u914D\u5408 install --no-wait \u6216\u7B49\u5F85\u8D85\u65F6\u540E\u4F7F\u7528\uFF09").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((runId, opts) => datapackageStatusCommand(runId, opts));
18314
18929
  var tenant = program.command("tenant").description("\u79DF\u6237\u5F00\u901A\u4E0E\u751F\u547D\u5468\u671F");
18315
18930
  tenant.command("reset").description("\u4EE5\u5F53\u524D\u79DF\u6237\u5185\u7F6E admin \u91CD\u7F6E PostgreSQL \u5230\u51FA\u5382\u57FA\u7EBF\uFF1B\u4E0D\u53EF\u9006\uFF0C\u975E PG \u672A\u5904\u7406\u672A\u6838\u9A8C").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4F7F\u7528\u8BE5\u73AF\u5883\u7684\u76F4\u63A5\u767B\u5F55\u8EAB\u4EFD\uFF0C\u4E0D\u63A5\u53D7\u4EE3\u7406").option("-y, --yes", "\u786E\u8BA4\u91CD\u7F6E\u5DF2\u6838\u9A8C\u7684\u5F53\u524D\u79DF\u6237\uFF0C\u8DF3\u8FC7\u4EA4\u4E92").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => tenantResetCommand(opts));
18316
- tenant.command("bootstrap").description("\u5F00\u901A\u65B0\u79DF\u6237\uFF08\u5EFA\u79DF\u6237 + admin \u7528\u6237 + \u7ED3\u6784 reconcile\uFF09\u2014\u2014\u4E0D\u53EF\u9006\uFF0C\u9ED8\u8BA4\u8FC7\u786E\u8BA4\u95F8").requiredOption("--tenant-id <id>", "\u79DF\u6237 ID").requiredOption("--admin-username <user>", "\u7BA1\u7406\u5458\u7528\u6237\u540D").option(
18931
+ tenant.command("bootstrap").description("\u5F00\u901A\u65B0\u79DF\u6237\uFF08\u5EFA\u79DF\u6237 + admin \u7528\u6237 + \u7ED3\u6784 reconcile\uFF09\u2014\u2014\u4E0D\u53EF\u9006\uFF0C\u9ED8\u8BA4\u8FC7\u786E\u8BA4\u95F8").requiredOption("--tenant-id <id>", "\u79DF\u6237 ID").option("--admin-username <user>", "\u7BA1\u7406\u5458\u7528\u6237\u540D\uFF08\u670D\u52A1\u7AEF\u4EC5\u63A5\u53D7 admin\uFF09", "admin").option(
18317
18932
  "--admin-password <pwd>",
18318
18933
  "\u7BA1\u7406\u5458\u5BC6\u7801\uFF08\u4F1A\u6CC4\u6F0F\u5230 history/ps\uFF0C\u5EFA\u8BAE --admin-password-stdin\uFF09"
18319
18934
  ).option("--admin-password-stdin", "\u4ECE\u6807\u51C6\u8F93\u5165\u8BFB\u7BA1\u7406\u5458\u5BC6\u7801\uFF08\u63A8\u8350\uFF09").option("--tenant-name <name>", "\u79DF\u6237\u540D\u79F0\uFF08\u9ED8\u8BA4\u53D6 tenantId\uFF09").option("--bootstrap-key <key>", "bootstrap \u5BC6\u94A5\uFF08\u5EFA\u8BAE\u7528 HCM_BOOTSTRAP_KEY \u73AF\u5883\u53D8\u91CF\uFF09").option("--bootstrap-key-stdin", "\u4ECE\u6807\u51C6\u8F93\u5165\u8BFB bootstrap \u5BC6\u94A5").option("--endpoint <url>", "\u540E\u7AEF\u5730\u5740\uFF08\u9ED8\u8BA4\u53D6\u9879\u76EE\u73AF\u5883\u6216 activeEnv \u7684 endpoint\uFF09").option("--env <name>", "\u4ECE\u8BE5 env \u89E3\u6790 endpoint").option("-y, --yes", "\u8DF3\u8FC7\u786E\u8BA4\uFF08CI \u7528\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => tenantBootstrapCommand(opts));