@hcmai/cli 0.18.0 → 0.19.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");
@@ -12476,19 +12476,19 @@ async function gapVerifyCommand(ref, args, deps = defaultDeps) {
12476
12476
  init_auth_guard();
12477
12477
  import { promises as fs12 } from "fs";
12478
12478
  import path14 from "path";
12479
- import axios8 from "axios";
12479
+ import axios9 from "axios";
12480
12480
  import {
12481
- CliError as CliError30,
12482
- CliErrorCode as CliErrorCode31,
12481
+ CliError as CliError31,
12482
+ CliErrorCode as CliErrorCode32,
12483
12483
  formatObject as formatObject28,
12484
12484
  httpProbe as httpProbe2,
12485
- loadGlobalConfig as loadGlobalConfig11,
12485
+ loadGlobalConfig as loadGlobalConfig12,
12486
12486
  loadIdentity as loadIdentity5,
12487
12487
  parseEnvYaml as parseEnvYaml3,
12488
12488
  releasePendingImpersonationSessions as releasePendingImpersonationSessions2,
12489
12489
  resolveActiveIdentity as resolveActiveIdentity2,
12490
- resolveEnvContext as resolveEnvContext8,
12491
- printResolvedEnvironment as printResolvedEnvironment8,
12490
+ resolveEnvContext as resolveEnvContext9,
12491
+ printResolvedEnvironment as printResolvedEnvironment9,
12492
12492
  conversationWebSocketEndpoint as conversationWebSocketEndpoint4,
12493
12493
  probeConversationHandshake
12494
12494
  } from "@hcmai/sdk";
@@ -14181,7 +14181,7 @@ function throttleNote(out) {
14181
14181
  const retryAfter = out.headers["retry-after"] || details?.retryAfter;
14182
14182
  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
14183
  }
14184
- function reportEnvelopeError(body) {
14184
+ function reportEnvelopeError(body, platformOps = false) {
14185
14185
  if (!object(body)) return "\u6B63\u6587\u5FC5\u987B\u662F\u5BF9\u8C61";
14186
14186
  if (body.schemaVersion === void 0 || body.schemaVersion === null) return "\u7F3A\u5C11 schemaVersion";
14187
14187
  if (body.schemaVersion !== 1) return `schemaVersion=${String(body.schemaVersion)} \u4E0D\u53D7\u652F\u6301\uFF1B\u5347\u7EA7 CLI`;
@@ -14191,6 +14191,8 @@ function reportEnvelopeError(body) {
14191
14191
  if (!object(row) || typeof row.checkId !== "string") return `results[${i}].checkId \u5FC5\u987B\u662F\u5B57\u7B26\u4E32`;
14192
14192
  if (!["platform", "tenant"].includes(String(row.layer))) return `results[${i}].layer \u5FC5\u987B\u662F platform / tenant`;
14193
14193
  }
14194
+ if (platformOps && (!Array.isArray(body.checks) || !body.checks.every((row) => object(row) && typeof row.id === "string")))
14195
+ return "checks \u5FC5\u987B\u662F\u5E26\u5B57\u7B26\u4E32 id \u7684\u5BF9\u8C61\u6570\u7EC4";
14194
14196
  if (body.scope !== void 0 && !object(body.scope)) return "scope \u5FC5\u987B\u662F\u5BF9\u8C61";
14195
14197
  const disabled = object(body.scope) ? body.scope.policyDisabled : void 0;
14196
14198
  if (disabled !== void 0 && !Array.isArray(disabled)) return "scope.policyDisabled \u5FC5\u987B\u662F\u6570\u7EC4";
@@ -14238,12 +14240,13 @@ function verdictViolation(row) {
14238
14240
  if (v.level === "NOT_APPLICABLE" && !!c2 && c2.missing + c2.failed > 0) return "NOT_APPLICABLE \u5E26\u7F3A\u53E3";
14239
14241
  return void 0;
14240
14242
  }
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);
14243
+ function reconcileReport(ctx, env2, report, requested, platformOps) {
14244
+ const known = !platformOps && serverCatalogKnown(env2.catalog, report), changed = !platformOps && catalogChanged(env2.catalog, report);
14245
+ const expected = known && !changed ? expectedServerIds(env2.catalog, report, requested) : new Set(platformOps ? report.scopeIds.filter((id) => id.startsWith("platform.")) : report.scopeIds);
14244
14246
  const scope = new Set(report.scopeIds), rows2 = [];
14245
14247
  const issues = /* @__PURE__ */ new Map();
14246
14248
  const layerFor = (id) => {
14249
+ if (platformOps) return "platform";
14247
14250
  const layer2 = known ? env2.catalog?.checks.find((c2) => c2.id === id)?.spec?.layer : void 0;
14248
14251
  return layer2 === "platform" || layer2 === "tenant" ? layer2 : String(id).startsWith("platform.") ? "platform" : "tenant";
14249
14252
  };
@@ -14252,6 +14255,9 @@ function reconcileReport(ctx, env2, report, requested) {
14252
14255
  issue("platform", note);
14253
14256
  issue("tenant", note);
14254
14257
  };
14258
+ if (platformOps) {
14259
+ for (const id of report.scopeIds) if (!id.startsWith("platform.")) issue("platform", `${id}\uFF1A\u8FD0\u7EF4\u62A5\u544A\u8303\u56F4\u4E0D\u662F platform`);
14260
+ }
14255
14261
  const synthesize = (id, code2, note) => {
14256
14262
  env2.report.server.verdict = null;
14257
14263
  const catalogRow = known ? env2.catalog?.checks.find((c2) => c2.id === id) : void 0;
@@ -14294,6 +14300,10 @@ function reconcileReport(ctx, env2, report, requested) {
14294
14300
  for (const row of report.results) groups.set(row.checkId, [...groups.get(row.checkId) ?? [], row]);
14295
14301
  for (const [id, group] of groups) {
14296
14302
  const row = group[0];
14303
+ if (platformOps && row.layer !== "platform") {
14304
+ issue("platform", `${id}\uFF1A\u8FD0\u7EF4\u62A5\u544A\u7ED3\u679C\u5C42\u4E0D\u662F platform`);
14305
+ continue;
14306
+ }
14297
14307
  if (!changed && !scope.has(id)) {
14298
14308
  issue(row.layer, `${id}\uFF1A\u7ED3\u679C\u8D8A\u51FA\u672C\u6B21\u8303\u56F4`);
14299
14309
  continue;
@@ -14305,17 +14315,25 @@ function reconcileReport(ctx, env2, report, requested) {
14305
14315
  for (const id of expected) if (!rows2.some((row) => row.checkId === id))
14306
14316
  rows2.push(synthesize(id, "REPORT_ITEM_MISSING", "CLI \u8865\u9879\uFF1A\u670D\u52A1\u7AEF\u62A5\u544A\u91CC\u6CA1\u6709\u8FD9\u4E00\u9879"));
14307
14317
  }
14308
- const selected = (layer2) => (layer2 === "platform" || layer2 === "tenant") && (!ctx.scope || ctx.scope.serverLayers.has(layer2));
14318
+ const selected = (layer2) => (layer2 === "platform" || layer2 === "tenant") && (platformOps ? layer2 === "platform" : !ctx.scope || ctx.scope.serverLayers.has(layer2));
14309
14319
  const marks = /* @__PURE__ */ new Map();
14310
14320
  for (const [layer2, notes] of issues) {
14311
- const home = selected(layer2) ? layer2 : SERVER_PLACEHOLDERS.map((d) => d.layer).find(selected);
14321
+ const home = selected(layer2) ? layer2 : platformOps ? "platform" : SERVER_PLACEHOLDERS.map((d) => d.layer).find(selected);
14312
14322
  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
14323
  }
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));
14324
+ for (const [layer2, notes] of marks) {
14325
+ env2.report.server.verdict = null;
14326
+ 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") });
14327
+ rows2.push(...platformOps ? [makeResult(
14328
+ platformOps.placeholder,
14329
+ observation,
14330
+ env2.name,
14331
+ true,
14332
+ ctx.requestedAt,
14333
+ 0,
14334
+ codeStep("REPORT_MALFORMED", env2.name)
14335
+ )] : placeholderRows(ctx, env2, observation).filter((r) => r.layer === layer2));
14336
+ }
14319
14337
  return rows2;
14320
14338
  }
14321
14339
  async function fetchServerReport(ctx, env2, dependencies, deadline, requested = fullScope) {
@@ -14374,8 +14392,8 @@ async function fetchServerReport(ctx, env2, dependencies, deadline, requested =
14374
14392
  env2.report.server.verdict = null;
14375
14393
  return [];
14376
14394
  }
14377
- const failure = failedReport(out, env2, ctx.as);
14378
- if (failure) return placeholderRows(ctx, env2, failure, Date.now() - started);
14395
+ const failure2 = failedReport(out, env2, ctx.as);
14396
+ if (failure2) return placeholderRows(ctx, env2, failure2, Date.now() - started);
14379
14397
  const report = out.body;
14380
14398
  env2.serverReport = report;
14381
14399
  Object.assign(env2.report.server, {
@@ -14592,6 +14610,8 @@ var CODE_TABLE = {
14592
14610
  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
14611
  REPORT_THROTTLED: c("\u670D\u52A1\u7AEF\u4F53\u68C0\u63A5\u53E3\u8BF7\u6C42\u88AB\u9650\u6D41\uFF1B\u6309 retryAfter \u7A0D\u540E\u91CD\u8BD5"),
14594
14612
  REPORT_UNAUTHORIZED: c("\u670D\u52A1\u7AEF\u4F53\u68C0\u63A5\u53E3\u8BF7\u6C42\u6743\u9650\u4E0D\u8DB3", "WARN", "FDE", login),
14613
+ 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"),
14614
+ 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
14615
  REPORT_UNAVAILABLE: c("\u670D\u52A1\u7AEF\u4F53\u68C0\u63A5\u53E3\u6682\u4E0D\u53EF\u7528\uFF1B\u7A0D\u540E\u91CD\u8BD5"),
14596
14616
  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
14617
  REPORT_ITEM_MISSING: c("\u670D\u52A1\u7AEF\u62A5\u544A\u91CC\u6CA1\u6709\u8FD9\u4E00\u9879", "WARN", "RND"),
@@ -14767,6 +14787,45 @@ function assembleReport(input) {
14767
14787
  if (level === "FOUND" && (grade === "CRITICAL" || grade === "WARN")) foundByGrade[grade]++;
14768
14788
  }
14769
14789
  const targetResults = input.results.filter((r) => r.env === null || r.env === input.targetEnv);
14790
+ if (input.platformOps) {
14791
+ const known2 = !!input.serverReport && input.serverReport.catalogRevision != null;
14792
+ const expected2 = new Set(input.serverReport?.scopeIds ?? []);
14793
+ const checked2 = targetResults.filter((r) => ["PASS", "FOUND", "NOT_APPLICABLE"].includes(r.verdict?.level) && (r.layer === "connect" || expected2.has(r.checkId))).length;
14794
+ const total2 = known2 ? targetResults.filter((r) => r.layer === "connect").length + expected2.size : null;
14795
+ const incomplete2 = /* @__PURE__ */ new Set([
14796
+ "platform-ops-view",
14797
+ ...!known2 ? ["server-catalog-unknown"] : [],
14798
+ ...input.scope?.only.length ? ["only"] : [],
14799
+ ...(input.scope?.skip ?? []).map((t) => `skip:${t}`),
14800
+ ...known2 && expected2.size === 0 ? ["empty-layer:platform"] : [],
14801
+ ...(input.serverReport?.scope?.incompleteBecause ?? []).filter((t) => t !== "only" && !t.startsWith("skip:") && !t.startsWith("empty-layer:"))
14802
+ ]);
14803
+ return {
14804
+ schemaVersion: 2,
14805
+ verdict: conclude(input.results, { total: total2, failOn: input.failOn }).verdict,
14806
+ counts,
14807
+ foundByGrade,
14808
+ coverage: { checked: checked2, total: total2 },
14809
+ scope: {
14810
+ stage: null,
14811
+ only: input.scope?.only ?? [],
14812
+ skip: input.scope?.skip ?? [],
14813
+ active: false,
14814
+ serverCatalogKnown: known2,
14815
+ addedPrerequisites: input.scope?.addedPrerequisites ?? [],
14816
+ policyDisabled: [],
14817
+ incompleteBecause: [...incomplete2],
14818
+ complete: false
14819
+ },
14820
+ cli: { version: input.cliVersion },
14821
+ project: null,
14822
+ targetEnv: input.targetEnv,
14823
+ generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
14824
+ durationMs: Date.now() - input.startedAt,
14825
+ environments: input.environments,
14826
+ results: input.results
14827
+ };
14828
+ }
14770
14829
  const requested = input.scope ? {
14771
14830
  stage: input.scope.stage,
14772
14831
  only: input.scope.forwardedOnly,
@@ -14863,15 +14922,27 @@ function renderChironDoctor(report) {
14863
14922
  const target = report.environments.find((env2) => env2.target);
14864
14923
  const version2 = target?.backend.version;
14865
14924
  const backend = !version2 || version2 === "unknown" ? "\u540E\u7AEF\u7248\u672C\u672A\u77E5" : `\u540E\u7AEF ${version2}`;
14925
+ const platformOps = report.scope.incompleteBecause.includes("platform-ops-view");
14866
14926
  const out = [
14867
14927
  `\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
14928
  "\u4E0B\u4E00\u6B65\u547D\u4EE4\u5728\u9879\u76EE\u76EE\u5F55\u6267\u884C\u3002"
14869
14929
  ];
14870
- const groups = [
14930
+ if (platformOps) {
14931
+ 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` : ""}`;
14932
+ out.pop();
14933
+ }
14934
+ const groups = platformOps ? [
14935
+ ["\u8FDE\u63A5", report.results.filter((r) => r.layer === "connect")],
14936
+ [
14937
+ `\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"}`,
14938
+ report.results.filter((r) => r.layer === "platform"),
14939
+ "platform"
14940
+ ]
14941
+ ] : [
14871
14942
  ["\u672C\u673A\u5DE5\u4F4D", report.results.filter((r) => r.layer === "local")],
14872
14943
  ...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
14944
  ];
14874
- if (target) groups.push(
14945
+ if (target && !platformOps) groups.push(
14875
14946
  [`\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
14947
  [`\u79DF\u6237\u5C31\u7EEA \xB7 \u79DF\u6237 ${target.tenant}`, report.results.filter((r) => r.layer === "tenant" && r.env === target.name), "tenant"]
14877
14948
  );
@@ -14904,7 +14975,7 @@ function renderChironDoctor(report) {
14904
14975
  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
14976
  }
14906
14977
  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}]`));
14978
+ 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
14979
  }
14909
14980
  }
14910
14981
  const active = report.results.filter(isOptIn).length;
@@ -14917,9 +14988,402 @@ function renderChironDoctor(report) {
14917
14988
  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
14989
  const actions = firstActions(report.results);
14919
14990
  if (actions.length) out.push(`\u5148\u5904\u7406\uFF1A${actions.map((r) => `${r.checkId}${r.env ? `\uFF08${r.env}\uFF09` : ""}`).join("\u3001")}`);
14991
+ if (platformOps) {
14992
+ const note = target?.server?.note;
14993
+ if (note) out.push(note);
14994
+ out.push("\u672C\u62A5\u544A\u4EC5\u4EE3\u8868\u5E94\u7B54\u5B9E\u4F8B");
14995
+ }
14920
14996
  return out.join("\n");
14921
14997
  }
14922
14998
 
14999
+ // src/commands/doctor/platform-ops.ts
15000
+ import { createHash as createHash8 } from "crypto";
15001
+ import axios8 from "axios";
15002
+ import {
15003
+ classifyStatus as classifyStatus2,
15004
+ CliError as CliError30,
15005
+ CliErrorCode as CliErrorCode31,
15006
+ loadGlobalConfig as loadGlobalConfig11,
15007
+ printResolvedEnvironment as printResolvedEnvironment8,
15008
+ resolveEnvContext as resolveEnvContext8
15009
+ } from "@hcmai/sdk";
15010
+ var OPS_PATH = "/api/system/health/ops/report";
15011
+ var connectivity2 = CHECKS.find((row) => row.id === "connect.connectivity");
15012
+ var api = {
15013
+ ...CHECKS.find((row) => row.id === "connect.health-api"),
15014
+ dependsOn: ["connect.connectivity"],
15015
+ timeoutMs: 26e3,
15016
+ codes: [
15017
+ "BACKEND_UNSUPPORTED",
15018
+ "HEALTH_API_ROUTE_MISSING",
15019
+ "REPORT_UNAVAILABLE",
15020
+ "REPORT_MALFORMED",
15021
+ "BUDGET_EXHAUSTED"
15022
+ ],
15023
+ run: async (ctx, env2, execution) => {
15024
+ const remaining = (ctx.opsDeadline ?? Date.now()) - Date.now();
15025
+ if (remaining < 3e3) return unknown("BUDGET_EXHAUSTED", "\u9884\u7B97\u8017\u5C3D\uFF0C\u672A\u542F\u52A8", { note: "\u9884\u7B97\u8017\u5C3D\uFF0C\u672A\u542F\u52A8" });
15026
+ const timeoutMs = Math.min(25e3, remaining);
15027
+ let out;
15028
+ try {
15029
+ out = await ctx.services.opsReportRequest(
15030
+ env2.config.endpoint,
15031
+ ctx.opsKey,
15032
+ timeoutMs,
15033
+ Math.min(15e3, timeoutMs - 2e3),
15034
+ execution.signal,
15035
+ { only: ctx.scope?.forwardedOnly ?? [], skip: ctx.scope?.forwardedSkip ?? [] }
15036
+ );
15037
+ } catch (error) {
15038
+ const stopped = execution.signal.aborted || axios8.isAxiosError(error) && ["ECONNABORTED", "ETIMEDOUT"].includes(error.code ?? "") || ["ECONNABORTED", "ETIMEDOUT"].includes(String(error.code));
15039
+ return unknown(
15040
+ "REPORT_UNAVAILABLE",
15041
+ "\u670D\u52A1\u7AEF\u4F53\u68C0\u63A5\u53E3\u6682\u4E0D\u53EF\u7528\uFF1B\u7A0D\u540E\u91CD\u8BD5",
15042
+ { note: `HTTP \u672A\u53D6\u5F97\u54CD\u5E94\uFF1B${stopped ? "\u5DF2\u505C\u6B62\u7B49\u5F85" : safeError(error)}` }
15043
+ );
15044
+ }
15045
+ env2.opsOutcome = out;
15046
+ return classifyOpsApi(out, env2.config.endpoint, ctx.opsKey);
15047
+ }
15048
+ };
15049
+ var placeholder = {
15050
+ id: "platform.server-report",
15051
+ name: "\u5E73\u53F0\u4F53\u68C0\u62A5\u544A",
15052
+ layer: "platform",
15053
+ requirement: "REQUIRED",
15054
+ owner: "RND",
15055
+ dependsOn: ["connect.connectivity", "connect.health-api"],
15056
+ codes: [
15057
+ "BACKEND_UNSUPPORTED",
15058
+ "HEALTH_API_ROUTE_MISSING",
15059
+ "HEALTH_OPS_KEY_INVALID",
15060
+ "HEALTH_OPS_KEY_LOCKED",
15061
+ "REPORT_THROTTLED",
15062
+ "REPORT_UNAVAILABLE",
15063
+ "REPORT_MALFORMED",
15064
+ "REPORT_ITEM_MISSING",
15065
+ "SERVER_VERDICT_INVALID",
15066
+ "BUDGET_EXHAUSTED"
15067
+ ]
15068
+ };
15069
+ var OPS_DESCRIPTORS = [connectivity2, api, placeholder];
15070
+ var requestOpsReport = async (endpoint, key2, timeoutMs, budgetMs, signal, scope) => {
15071
+ const res = await axios8.get(OPS_PATH, {
15072
+ baseURL: endpoint,
15073
+ timeout: timeoutMs,
15074
+ signal,
15075
+ maxRedirects: 0,
15076
+ validateStatus: () => true,
15077
+ headers: { Accept: "application/json", "X-Platform-Ops-Key": key2 },
15078
+ params: {
15079
+ budgetMs,
15080
+ ...scope.only.length ? { only: scope.only.join(",") } : {},
15081
+ ...scope.skip.length ? { skip: scope.skip.join(",") } : {}
15082
+ }
15083
+ });
15084
+ return {
15085
+ status: res.status,
15086
+ body: res.data,
15087
+ error: classifyStatus2(res.status),
15088
+ headers: Object.fromEntries(Object.entries(res.headers).map(([name, value]) => [name.toLowerCase(), String(value)]))
15089
+ };
15090
+ };
15091
+ function opsKeyFingerprint(key2) {
15092
+ return key2 ? createHash8("sha256").update(key2, "utf8").digest("hex").slice(0, 16) : "none";
15093
+ }
15094
+ async function readPlatformOpsKey(args, io = {
15095
+ env: process.env.HCM_PLATFORM_OPS_KEY,
15096
+ isTTY: !!process.stdin.isTTY,
15097
+ readStdin,
15098
+ prompt: () => promptSecret("\u8FD0\u7EF4\u53EA\u8BFB\u5BC6\u94A5: ", process.stderr),
15099
+ stderr: (text) => process.stderr.write(text)
15100
+ }) {
15101
+ let source, key2;
15102
+ const fromEnv = io.env?.trim();
15103
+ if (fromEnv) {
15104
+ source = "env";
15105
+ key2 = fromEnv;
15106
+ } else if (args.platformOpsKeyStdin) {
15107
+ source = "stdin";
15108
+ key2 = await io.readStdin();
15109
+ } else if (io.isTTY) {
15110
+ source = "tty";
15111
+ key2 = await io.prompt();
15112
+ } else throw new CliError30({
15113
+ code: CliErrorCode31.INVALID_ARGUMENT,
15114
+ 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"
15115
+ });
15116
+ key2 = key2.trim();
15117
+ if (!key2) throw new CliError30({ code: CliErrorCode31.INVALID_ARGUMENT, message: "\u8FD0\u7EF4\u5BC6\u94A5\u4E3A\u7A7A" });
15118
+ io.stderr(`\u8FD0\u7EF4\u5BC6\u94A5\u6765\u6E90\uFF1A${source} \xB7 \u6307\u7EB9 ${opsKeyFingerprint(key2)}
15119
+ `);
15120
+ return { key: key2, source };
15121
+ }
15122
+ var split = (value) => (Array.isArray(value) ? value : value ? [value] : []).flatMap((item) => item.split(",")).map((item) => item.trim()).filter(Boolean);
15123
+ function scopeFor(args) {
15124
+ const only = split(args.only), skip = split(args.skip);
15125
+ for (const token of [...only, ...skip]) if (!("platform.".startsWith(token) || token.startsWith("platform.")))
15126
+ throw new CliError30({
15127
+ code: CliErrorCode31.INVALID_ARGUMENT,
15128
+ message: `\u8FD0\u7EF4\u89C6\u56FE\u53EA\u770B\u5E73\u53F0\u5C42\uFF1A--only / --skip \u53EA\u63A5\u53D7 platform \u524D\u7F00\uFF0C\u6536\u5230 ${token}`
15129
+ });
15130
+ if (skip.some((token) => "platform.".startsWith(token))) throw new CliError30({
15131
+ code: CliErrorCode31.INVALID_ARGUMENT,
15132
+ message: "\u6392\u9664\u4E86\u5E73\u53F0\u5C42\uFF0C\u8FD0\u7EF4\u89C6\u56FE\u6CA1\u6709\u53EF\u770B\u7684\u68C0\u67E5"
15133
+ });
15134
+ return {
15135
+ stage: null,
15136
+ only,
15137
+ skip,
15138
+ active: false,
15139
+ forwardedOnly: only,
15140
+ forwardedSkip: skip,
15141
+ serverIds: /* @__PURE__ */ new Set(),
15142
+ serverLayers: /* @__PURE__ */ new Set(["platform"]),
15143
+ serverRelevant: true,
15144
+ addedPrerequisites: only.length ? ["connect.connectivity", "connect.health-api"] : []
15145
+ };
15146
+ }
15147
+ function redact(text, key2) {
15148
+ const raw = typeof text === "string" ? text : JSON.stringify(text) ?? "";
15149
+ return raw.replaceAll(key2, "[redacted]").replace(/hcm\s+login/gi, "[login advice omitted]");
15150
+ }
15151
+ function classifyOpsApi(out, endpoint, key2) {
15152
+ const note = httpNote(out), error = object(out.body) && object(out.body.error) ? out.body.error : void 0;
15153
+ const wireCode = error?.code;
15154
+ if (out.status === 200) {
15155
+ if (object(out.body) || Array.isArray(out.body)) return pass("\u540E\u7AEF\u652F\u6301\u8FD0\u7EF4\u4F53\u68C0 API");
15156
+ if (/json/i.test(out.headers["content-type"] ?? "")) {
15157
+ if (typeof out.body === "string") {
15158
+ try {
15159
+ JSON.parse(out.body);
15160
+ } catch {
15161
+ return unknown(
15162
+ "REPORT_MALFORMED",
15163
+ "\u8FD0\u7EF4\u4F53\u68C0\u63A5\u53E3 JSON \u89E3\u6790\u5931\u8D25",
15164
+ { reason: "EVALUATOR_ERROR", note: `${note}\uFF1B${redact(out.body, key2).slice(0, 200)}` }
15165
+ );
15166
+ }
15167
+ }
15168
+ return pass("\u540E\u7AEF\u652F\u6301\u8FD0\u7EF4\u4F53\u68C0 API");
15169
+ }
15170
+ return found(
15171
+ "HEALTH_API_ROUTE_MISSING",
15172
+ void 0,
15173
+ { evidence: "INFERRED", note: `${note}\uFF1B\u6536\u5230\u975E JSON\uFF0C\u63A8\u65AD\u8DEF\u7531\u843D\u5230\u53CD\u4EE3\u6216\u524D\u7AEF SPA` }
15174
+ );
15175
+ }
15176
+ if (out.status === 403 && wireCode === "HEALTH_OPS_KEY_INVALID") return pass("\u8FD0\u7EF4\u4F53\u68C0 API \u5DF2\u5E94\u7B54");
15177
+ if (out.status === 429 && ["HEALTH_OPS_KEY_LOCKED", "HEALTH_REPORT_THROTTLED"].includes(String(wireCode)))
15178
+ return pass("\u8FD0\u7EF4\u4F53\u68C0 API \u5DF2\u5E94\u7B54");
15179
+ if (out.status === 401 && !out.headers["x-trace-id"]) return found(
15180
+ "HEALTH_API_ROUTE_MISSING",
15181
+ void 0,
15182
+ { 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` }
15183
+ );
15184
+ const requestPath = new URL(`${endpoint.replace(/\/+$/, "")}${OPS_PATH}`).pathname;
15185
+ 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 });
15186
+ if (out.status === 404) {
15187
+ if (out.headers["x-trace-id"] && error && typeof error.code === "string" && typeof error.message === "string")
15188
+ return found("BACKEND_UNSUPPORTED", void 0, { note });
15189
+ if (!out.headers["x-trace-id"]) return found(
15190
+ "HEALTH_API_ROUTE_MISSING",
15191
+ void 0,
15192
+ { 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` }
15193
+ );
15194
+ }
15195
+ if (out.status >= 500 || out.error === "network") return unknown("REPORT_UNAVAILABLE", void 0, { note });
15196
+ return unknown(
15197
+ "REPORT_MALFORMED",
15198
+ "\u8FD0\u7EF4\u4F53\u68C0\u63A5\u53E3\u8FD4\u56DE\u975E\u9884\u671F\u72B6\u6001",
15199
+ { reason: "EVALUATOR_ERROR", note: `${note}\uFF1B${redact(out.body, key2).slice(0, 200)}` }
15200
+ );
15201
+ }
15202
+ function opsPlaceholder(ctx, env2, observation) {
15203
+ const row = CODE_TABLE[observation.code ?? ""];
15204
+ return makeResult(
15205
+ placeholder,
15206
+ {
15207
+ ...observation,
15208
+ grade: observation.grade ?? row?.grade,
15209
+ summary: observation.summary === observation.code && row ? row.summary : observation.summary
15210
+ },
15211
+ env2.name,
15212
+ true,
15213
+ ctx.requestedAt,
15214
+ 0,
15215
+ observation.code ? codeStep(observation.code, env2.name) : { owner: "RND" }
15216
+ );
15217
+ }
15218
+ function failure(ctx, env2, health, key2) {
15219
+ const out = env2.opsOutcome, code2 = health.code;
15220
+ if (!out) {
15221
+ 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" }));
15222
+ if (code2 === "REPORT_UNAVAILABLE") return opsPlaceholder(
15223
+ ctx,
15224
+ env2,
15225
+ unknown("REPORT_UNAVAILABLE", void 0, { note: health.verdict.note })
15226
+ );
15227
+ return opsPlaceholder(ctx, env2, {
15228
+ level: "NOT_RUN",
15229
+ code: "PREREQUISITE_NOT_MET",
15230
+ reason: "PREREQUISITE_NOT_MET",
15231
+ summary: "\u8FD0\u7EF4\u62A5\u544A\u672A\u6267\u884C\uFF1A\u524D\u7F6E\u68C0\u67E5\u672A\u901A\u8FC7",
15232
+ note: code2 ?? health.verdict.level
15233
+ });
15234
+ }
15235
+ const error = object(out.body) && object(out.body.error) ? out.body.error : void 0;
15236
+ const detail = object(error?.details) ? error.details : void 0;
15237
+ const next = typeof error?.next_step === "string" ? `\uFF1B${redact(error.next_step, key2)}` : "";
15238
+ const keyNote = `${httpNote(out)} \xB7 \u6307\u7EB9 ${opsKeyFingerprint(key2)}`;
15239
+ if (out.status === 403 && error?.code === "HEALTH_OPS_KEY_INVALID") return opsPlaceholder(
15240
+ ctx,
15241
+ env2,
15242
+ unknown("HEALTH_OPS_KEY_INVALID", void 0, { reason: "PERMISSION_DENIED", note: keyNote + next })
15243
+ );
15244
+ if (out.status === 429 && error?.code === "HEALTH_OPS_KEY_LOCKED") {
15245
+ const retry = out.headers["retry-after"] || detail?.retryAfter;
15246
+ return opsPlaceholder(ctx, env2, unknown(
15247
+ "HEALTH_OPS_KEY_LOCKED",
15248
+ void 0,
15249
+ { note: `${keyNote} \xB7 ${retry == null ? "\u670D\u52A1\u7AEF\u672A\u63D0\u4F9B retryAfter" : `retryAfter=${String(retry)}`}${next}` }
15250
+ ));
15251
+ }
15252
+ if (out.status === 429 && error?.code === "HEALTH_REPORT_THROTTLED") return opsPlaceholder(
15253
+ ctx,
15254
+ env2,
15255
+ unknown("REPORT_THROTTLED", void 0, { note: redact(throttleNote(out), key2) })
15256
+ );
15257
+ if (code2 === "BACKEND_UNSUPPORTED") return opsPlaceholder(
15258
+ ctx,
15259
+ env2,
15260
+ {
15261
+ level: "NOT_RUN",
15262
+ code: code2,
15263
+ reason: "CAPABILITY_UNSUPPORTED",
15264
+ summary: "\u540E\u7AEF\u4E0D\u652F\u6301\u8FD0\u7EF4\u4F53\u68C0\u62A5\u544A",
15265
+ note: `${health.verdict.note ?? ""}\uFF1B${env2.report.backend.commit ? `\u540E\u7AEF commit ${env2.report.backend.commit}` : "commit \u672A\u77E5"}`
15266
+ }
15267
+ );
15268
+ if (code2 === "HEALTH_API_ROUTE_MISSING") return opsPlaceholder(
15269
+ ctx,
15270
+ env2,
15271
+ unknown(code2, void 0, { note: health.verdict.note })
15272
+ );
15273
+ if (code2 === "REPORT_UNAVAILABLE") return opsPlaceholder(
15274
+ ctx,
15275
+ env2,
15276
+ unknown(code2, void 0, { note: health.verdict.note })
15277
+ );
15278
+ return opsPlaceholder(ctx, env2, unknown(
15279
+ "REPORT_MALFORMED",
15280
+ void 0,
15281
+ { reason: "EVALUATOR_ERROR", note: health.verdict.note ?? `${httpNote(out)}\uFF1B${redact(out.body, key2).slice(0, 200)}` }
15282
+ ));
15283
+ }
15284
+ var ENV_HINT = "hcm env list \u67E5\u770B\u53EF\u9009\u73AF\u5883\uFF1Bhcm env add <\u540D> --endpoint <url> \u767B\u8BB0";
15285
+ function resolverMessage(error) {
15286
+ if (error instanceof CliError30 && error.code === CliErrorCode31.NO_ACTIVE_ENV) return "\u672A\u9009\u5B9A\u73AF\u5883\uFF1A\u7528 --env <\u540D> \u6307\u5B9A";
15287
+ return (error instanceof Error ? error.message : safeError(error)).replace(/\s*(&&\s*)?hcm\s+login\b[^;;\n]*/gi, "");
15288
+ }
15289
+ async function runPlatformOps(args, services, readKey = readPlatformOpsKey, onReport) {
15290
+ const scope = scopeFor(args);
15291
+ let resolved;
15292
+ try {
15293
+ resolved = await resolveEnvContext8({ envFlag: args.env }, process.env, await loadGlobalConfig11());
15294
+ } catch (error2) {
15295
+ throw new CliError30({ code: CliErrorCode31.INVALID_ARGUMENT, message: `${resolverMessage(error2)}\uFF1B${ENV_HINT}` });
15296
+ }
15297
+ if (!resolved.config.endpoint) throw new CliError30({
15298
+ code: CliErrorCode31.INVALID_ARGUMENT,
15299
+ message: `\u672A\u89E3\u6790\u5230 endpoint\uFF1B${ENV_HINT}`
15300
+ });
15301
+ printResolvedEnvironment8(resolved);
15302
+ const { key: key2 } = await readKey(args);
15303
+ const startedAt = Date.now();
15304
+ const name = resolved.project?.name ?? resolved.name;
15305
+ const env2 = {
15306
+ name,
15307
+ config: { endpoint: resolved.config.endpoint },
15308
+ credential: async () => {
15309
+ throw new Error("\u8FD0\u7EF4\u89C6\u56FE\u4E0D\u5F97\u8BFB\u53D6\u8EAB\u4EFD");
15310
+ },
15311
+ report: {
15312
+ name,
15313
+ endpoint: resolved.config.endpoint,
15314
+ tenant: null,
15315
+ target: true,
15316
+ backend: { version: null, commit: null },
15317
+ server: {
15318
+ supported: null,
15319
+ deploymentTenancy: null,
15320
+ instance: null,
15321
+ verdict: null,
15322
+ catalogRevision: null
15323
+ }
15324
+ }
15325
+ };
15326
+ const ctx = {
15327
+ root: "",
15328
+ requestedAt: new Date(startedAt).toISOString(),
15329
+ cliVersion: CLI_VERSION,
15330
+ projectObservation: pass("\u8FD0\u7EF4\u73AF\u5883\u5DF2\u89E3\u6790"),
15331
+ targetEnv: name,
15332
+ environments: [env2],
15333
+ services,
15334
+ scope,
15335
+ opsKey: key2,
15336
+ opsDeadline: startedAt + 45e3
15337
+ };
15338
+ const results = await executeChecks(ctx, { checks: [connectivity2, api], fetchReport: false });
15339
+ const health = results.find((row) => row.checkId === "connect.health-api");
15340
+ const out = env2.opsOutcome;
15341
+ const error = out && object(out.body) && object(out.body.error) ? out.body.error : void 0;
15342
+ if (out?.status === 400 && error?.code === "HEALTH_REPORT_INVALID_PARAM") throw new CliError30({
15343
+ code: CliErrorCode31.INVALID_ARGUMENT,
15344
+ 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" : ""}`
15345
+ });
15346
+ env2.report.server.supported = health.verdict.level === "PASS" ? true : health.code === "BACKEND_UNSUPPORTED" ? false : null;
15347
+ if (out?.status === 200 && health.verdict.level === "PASS") {
15348
+ const invalid3 = reportEnvelopeError(out.body, true);
15349
+ if (invalid3) results.push(opsPlaceholder(ctx, env2, unknown(
15350
+ "REPORT_MALFORMED",
15351
+ "\u670D\u52A1\u7AEF\u8FD0\u7EF4\u62A5\u544A\u4FE1\u5C01\u4E0D\u5408\u6CD5",
15352
+ { reason: "EVALUATOR_ERROR", note: `${httpNote(out)}\uFF1B${invalid3}` }
15353
+ )));
15354
+ else {
15355
+ const report = out.body;
15356
+ env2.serverReport = report;
15357
+ onReport?.(report);
15358
+ Object.assign(env2.report.server, {
15359
+ deploymentTenancy: report.deploymentTenancy ?? null,
15360
+ instance: report.instance ?? null,
15361
+ catalogRevision: report.catalogRevision ?? null,
15362
+ verdict: report.verdict ?? null,
15363
+ note: report.note
15364
+ });
15365
+ results.push(...reconcileReport(ctx, env2, report, {
15366
+ stage: null,
15367
+ only: scope.forwardedOnly,
15368
+ skip: scope.forwardedSkip,
15369
+ active: false
15370
+ }, { placeholder }));
15371
+ }
15372
+ } else results.push(failure(ctx, env2, health, key2));
15373
+ return assembleReport({
15374
+ results,
15375
+ environments: [env2.report],
15376
+ project: null,
15377
+ targetEnv: name,
15378
+ cliVersion: CLI_VERSION,
15379
+ startedAt,
15380
+ failOn: args.failOn ?? "blocked",
15381
+ scope,
15382
+ serverReport: env2.serverReport,
15383
+ platformOps: true
15384
+ });
15385
+ }
15386
+
14923
15387
  // src/commands/doctor/catalog.ts
14924
15388
  var localCriterion = {
14925
15389
  "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 +15473,20 @@ function explainCatalog(ctx, id, reason) {
15009
15473
  }),
15010
15474
  skill: null
15011
15475
  };
15012
- const placeholder = SERVER_PLACEHOLDERS.find((d) => d.id === id);
15013
- if (placeholder) return {
15476
+ const placeholder2 = SERVER_PLACEHOLDERS.find((d) => d.id === id);
15477
+ if (placeholder2) return {
15014
15478
  id,
15015
- layer: placeholder.layer,
15016
- name: placeholder.name,
15479
+ layer: placeholder2.layer,
15480
+ name: placeholder2.name,
15017
15481
  source: "cli",
15018
15482
  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) => ({
15483
+ requirement: placeholder2.requirement,
15484
+ dependsOn: placeholder2.dependsOn,
15485
+ codes: placeholder2.codes.map((key2) => ({
15022
15486
  code: key2,
15023
15487
  summaryTemplate: CODE_TABLE[key2]?.summary ?? key2,
15024
15488
  nextStep: CODE_TABLE[key2]?.command?.(env2) ?? null,
15025
- owner: CODE_TABLE[key2]?.owner ?? placeholder.owner
15489
+ owner: CODE_TABLE[key2]?.owner ?? placeholder2.owner
15026
15490
  }))
15027
15491
  };
15028
15492
  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 +15529,72 @@ function explainCatalog(ctx, id, reason) {
15065
15529
  ...row.skill ? { skill: row.skill } : {}
15066
15530
  };
15067
15531
  }
15532
+ var opsCriteria = {
15533
+ "connect.connectivity": "\u514D\u8BA4\u8BC1\u8BFB\u53D6\u540E\u7AEF\u7248\u672C\u7AEF\u70B9\uFF0C\u786E\u8BA4\u540E\u7AEF\u53EF\u8FBE",
15534
+ "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",
15535
+ "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"
15536
+ };
15537
+ 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";
15538
+ function explainOpsCatalog(id, report) {
15539
+ const local = OPS_DESCRIPTORS.find((row2) => row2.id === id);
15540
+ if (local) return {
15541
+ id,
15542
+ layer: local.layer,
15543
+ name: local.name,
15544
+ source: "cli",
15545
+ criterion: opsCriteria[id],
15546
+ requirement: local.requirement,
15547
+ stages: "stages" in local ? local.stages : [],
15548
+ grade: id === "connect.connectivity" ? "CRITICAL" : "WARN",
15549
+ dependsOn: local.dependsOn,
15550
+ coverageForm: "coverageForm" in local ? local.coverageForm : void 0,
15551
+ coverageDomain: "coverageDomain" in local ? local.coverageDomain : void 0,
15552
+ timeoutMs: "timeoutMs" in local ? local.timeoutMs : void 0,
15553
+ codes: local.codes.map((key2) => ({
15554
+ code: key2,
15555
+ summaryTemplate: CODE_TABLE[key2]?.summary ?? key2,
15556
+ nextStep: CODE_TABLE[key2]?.command?.("<env>") ?? null,
15557
+ owner: CODE_TABLE[key2]?.owner ?? local.owner
15558
+ })),
15559
+ reservedCodes: RESERVED_CODES.map((code2) => ({ code: code2 })),
15560
+ reservedCodesNote: opsReservedNote,
15561
+ skill: null
15562
+ };
15563
+ const checks = report?.checks ?? [];
15564
+ const row = checks.find((item) => item.id === id);
15565
+ 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"}`);
15566
+ const spec = object2(row.spec) ? row.spec : {};
15567
+ return {
15568
+ id,
15569
+ layer: spec.layer,
15570
+ name: row.name,
15571
+ source: "server",
15572
+ criterion: row.description,
15573
+ requirement: row.requirement,
15574
+ stages: row.stages,
15575
+ grade: row.grade,
15576
+ ...row.gradeByStage !== void 0 ? { gradeByStage: row.gradeByStage } : {},
15577
+ dependsOn: row.dependsOn,
15578
+ ruleType: row.ruleType,
15579
+ evaluatorKey: row.evaluatorKey,
15580
+ ruleDsl: row.ruleDsl,
15581
+ coverageForm: spec.coverageForm,
15582
+ coverageDomain: spec.coverageDomain,
15583
+ queryMode: spec.queryMode,
15584
+ requiredPermission: spec.requiredPermission,
15585
+ timeout: spec.timeout,
15586
+ paramSchema: spec.paramSchema,
15587
+ enabled: row.enabled,
15588
+ policySource: row.policySource,
15589
+ definitionId: row.definitionId,
15590
+ by: row.by,
15591
+ at: row.at,
15592
+ codes: codeRows(spec.codes),
15593
+ reservedCodes: RESERVED_CODES.map((code2) => ({ code: code2 })),
15594
+ reservedCodesNote: opsReservedNote,
15595
+ ...row.skill ? { skill: row.skill } : {}
15596
+ };
15597
+ }
15068
15598
  function renderCatalogList(data) {
15069
15599
  const lines = [
15070
15600
  "\u68C0\u67E5 id \xB7 \u5C42 \xB7 \u540D\u79F0 \xB7 \u5FC5\u68C0/\u9009\u68C0 \xB7 \u9636\u6BB5",
@@ -15090,19 +15620,21 @@ function renderCatalogExplanation(item) {
15090
15620
  ];
15091
15621
  for (const item2 of [...codeRows(row.codes), ...codeRows(row.reservedCodes)])
15092
15622
  lines.push(` ${code(item2)} \xB7 ${item2.summaryTemplate ?? "\u65E0"} \xB7 \u4E0B\u4E00\u6B65\uFF1A${item2.nextStep ?? "\u65E0"} \xB7 owner\uFF1A${item2.owner ?? "\u65E0"}`);
15623
+ if (row.reservedCodesNote) lines.push(String(row.reservedCodesNote));
15093
15624
  return lines.join("\n");
15094
15625
  }
15095
15626
 
15096
15627
  // src/commands/chiron-doctor.ts
15097
15628
  var defaultServices = {
15098
15629
  reportRequest: requestServerReport,
15630
+ opsReportRequest: requestOpsReport,
15099
15631
  inspectCases: inspectCaseLibrary,
15100
15632
  inspectJira,
15101
15633
  inspectMethod: inspectMethodForDoctor,
15102
15634
  latestVersion: fetchLatestVersion,
15103
15635
  skillsFresh: inspectSkillsFresh,
15104
15636
  asAuth: (...args) => ensureAsAuth(...args),
15105
- probe: (endpoint, token, signal) => httpProbe2(axios8.create({
15637
+ probe: (endpoint, token, signal) => httpProbe2(axios9.create({
15106
15638
  baseURL: endpoint,
15107
15639
  timeout: 5e3,
15108
15640
  maxRedirects: 0,
@@ -15113,15 +15645,26 @@ var defaultServices = {
15113
15645
  };
15114
15646
  function validate(args) {
15115
15647
  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,
15648
+ if (value !== void 0 && !choices.includes(value)) throw new CliError31({
15649
+ code: CliErrorCode32.INVALID_ARGUMENT,
15118
15650
  message: `--${key2} \u53EA\u63A5\u53D7 ${choices.join(" / ")}\uFF0C\u6536\u5230 ${value}`
15119
15651
  });
15120
15652
  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,
15653
+ if (args.stage !== void 0 && !stages.includes(args.stage.toLowerCase())) throw new CliError31({
15654
+ code: CliErrorCode32.INVALID_ARGUMENT,
15123
15655
  message: `--stage \u53EA\u63A5\u53D7 ${stages.join(" / ")}\uFF0C\u6536\u5230 ${args.stage}`
15124
15656
  });
15657
+ if (args.platformOpsKeyStdin && !args.platformOps) invalidScope("--platform-ops-key-stdin \u53EA\u80FD\u4E0E --platform-ops \u540C\u7528");
15658
+ if (args.platformOps) {
15659
+ for (const [flag, present] of [
15660
+ ["--active", args.active],
15661
+ ["--stage", args.stage !== void 0],
15662
+ ["--as", args.as !== void 0],
15663
+ ["--project", args.project !== void 0]
15664
+ ])
15665
+ 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`);
15666
+ 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");
15667
+ }
15125
15668
  if (args.list && args.explain) invalidScope("--list \u4E0E --explain \u4E0D\u80FD\u540C\u7528");
15126
15669
  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
15670
  }
@@ -15129,9 +15672,9 @@ var tokens = (value) => (Array.isArray(value) ? value : value ? [value] : []).fl
15129
15672
  var matches = (id, only, skip) => (!only.length || only.some((t) => id.startsWith(t))) && !skip.some((t) => id.startsWith(t));
15130
15673
  var serverCandidate = (t) => ["platform.", "tenant."].some((prefix) => prefix.startsWith(t) || t.startsWith(prefix));
15131
15674
  function invalidScope(message) {
15132
- throw new CliError30({ code: CliErrorCode31.INVALID_ARGUMENT, message });
15675
+ throw new CliError31({ code: CliErrorCode32.INVALID_ARGUMENT, message });
15133
15676
  }
15134
- function scopeFor(args, catalog) {
15677
+ function scopeFor2(args, catalog) {
15135
15678
  const only = tokens(args.only), skip = tokens(args.skip), stage = args.stage?.toLowerCase() ?? null;
15136
15679
  const serverChecks = catalog?.checks ?? [];
15137
15680
  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 +15705,9 @@ function scopeFor(args, catalog) {
15162
15705
  async function readCredential(envFlag, root, as) {
15163
15706
  let resolved;
15164
15707
  try {
15165
- resolved = await resolveEnvContext8({ envFlag, cwd: root }, process.env, await loadGlobalConfig11());
15708
+ resolved = await resolveEnvContext9({ envFlag, cwd: root }, process.env, await loadGlobalConfig12());
15166
15709
  } catch (error) {
15167
- if (error instanceof CliError30 && error.code === CliErrorCode31.ENV_NOT_FOUND) return { resolved: null };
15710
+ if (error instanceof CliError31 && error.code === CliErrorCode32.ENV_NOT_FOUND) return { resolved: null };
15168
15711
  throw error;
15169
15712
  }
15170
15713
  if (as) return { resolved };
@@ -15173,14 +15716,14 @@ async function readCredential(envFlag, root, as) {
15173
15716
  try {
15174
15717
  identity3 = await resolveActiveIdentity2({}, process.env, resolved.name);
15175
15718
  } catch (error) {
15176
- if (error instanceof CliError30 && error.code === CliErrorCode31.IDENTITY_NOT_FOUND) return { resolved, error: found("IDENTITY_NOT_LOGGED_IN") };
15719
+ if (error instanceof CliError31 && error.code === CliErrorCode32.IDENTITY_NOT_FOUND) return { resolved, error: found("IDENTITY_NOT_LOGGED_IN") };
15177
15720
  throw error;
15178
15721
  }
15179
15722
  let meta2;
15180
15723
  try {
15181
15724
  meta2 = await loadIdentity5(identity3);
15182
15725
  } 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`) };
15726
+ 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
15727
  throw error;
15185
15728
  }
15186
15729
  if (!meta2.env || meta2.env !== resolved.name) return {
@@ -15190,7 +15733,7 @@ async function readCredential(envFlag, root, as) {
15190
15733
  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
15734
  };
15192
15735
  const token = await readStoredIdentityToken(identity3);
15193
- printResolvedEnvironment8(resolved, identity3, resolved.project?.environment.tenant);
15736
+ printResolvedEnvironment9(resolved, identity3, resolved.project?.environment.tenant);
15194
15737
  return { resolved, identity: identity3, meta: meta2, token };
15195
15738
  }
15196
15739
  async function prepareContext(args, deps) {
@@ -15212,7 +15755,7 @@ async function prepareContext(args, deps) {
15212
15755
  let explicitSlot;
15213
15756
  if (file && args.env && !Object.hasOwn(file.environments, args.env)) {
15214
15757
  try {
15215
- const resolved = await resolveEnvContext8({ envFlag: args.env, cwd: root }, process.env, await loadGlobalConfig11());
15758
+ const resolved = await resolveEnvContext9({ envFlag: args.env, cwd: root }, process.env, await loadGlobalConfig12());
15216
15759
  if (!resolved.project) throw new Error("\u672C\u673A\u69FD\u4E0D\u5C5E\u4E8E\u5F53\u524D\u9879\u76EE");
15217
15760
  targetEnv = resolved.project.name;
15218
15761
  explicitSlot = resolved.name;
@@ -15264,7 +15807,7 @@ async function runChironDoctor(args, deps = {}) {
15264
15807
  budgetMs: Math.max(0, 45e3 - (Date.now() - startedAt))
15265
15808
  }) : [];
15266
15809
  const targetBefore = ctx.environments.find((e) => e.report.target);
15267
- const scope2 = scopeFor(args, targetBefore?.catalog);
15810
+ const scope2 = scopeFor2(args, targetBefore?.catalog);
15268
15811
  const selectedLocal = CHECKS.filter((d) => d.layer === "local" && (!scope2.stage || d.stages.includes(scope2.stage)) && matches(d.id, scope2.only, scope2.skip));
15269
15812
  const selectedConnect = targetBefore ? CHECKS.filter((d) => d.layer === "connect" && (!scope2.stage || d.stages.includes(scope2.stage)) && matches(d.id, scope2.only, scope2.skip)) : [];
15270
15813
  if (!selectedLocal.length && !selectedConnect.length && !scope2.serverLayers.size) invalidScope(
@@ -15342,6 +15885,34 @@ async function runChironCatalog(args, deps) {
15342
15885
  }
15343
15886
  async function chironDoctorCommand(args, deps) {
15344
15887
  try {
15888
+ validate(args);
15889
+ if (args.platformOps) {
15890
+ if (args.explain) {
15891
+ let descriptorReport;
15892
+ const local = ["connect.connectivity", "connect.health-api", "platform.server-report"].includes(args.explain);
15893
+ if (!local) {
15894
+ const report3 = await runPlatformOps(args, { ...defaultServices, ...deps }, void 0, (value) => {
15895
+ descriptorReport = value;
15896
+ });
15897
+ if (!descriptorReport) {
15898
+ for (const id of ["connect.connectivity", "connect.health-api", "platform.server-report"]) {
15899
+ const row = report3.results.find((item) => item.checkId === id);
15900
+ 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"}
15901
+ `);
15902
+ }
15903
+ 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`);
15904
+ }
15905
+ }
15906
+ const data = explainOpsCatalog(args.explain, descriptorReport);
15907
+ process.stdout.write((args.output === "json" || args.output === "yaml" ? formatObject28(data, { format: args.output }) : renderCatalogExplanation(data)) + "\n");
15908
+ process.exitCode = 0;
15909
+ return;
15910
+ }
15911
+ const report2 = await runPlatformOps(args, { ...defaultServices, ...deps });
15912
+ process.stdout.write((args.output === "json" || args.output === "yaml" ? formatObject28(report2, { format: args.output }) : renderChironDoctor(report2)) + "\n");
15913
+ process.exitCode = conclude(report2.results, { total: report2.coverage.total, failOn: args.failOn ?? "blocked" }).exitCode;
15914
+ return;
15915
+ }
15345
15916
  if (args.list || args.explain) {
15346
15917
  validate(args);
15347
15918
  const data = await runChironCatalog(args, deps ?? {});
@@ -15372,11 +15943,11 @@ import { accessSync, constants, readdirSync as readdirSync3 } from "fs";
15372
15943
  import fs13 from "fs/promises";
15373
15944
  import os6 from "os";
15374
15945
  import path16 from "path";
15375
- import { CliError as CliError33, CliErrorCode as CliErrorCode34, formatObject as formatObject29, HcmClient as HcmClient24, loadEnv as loadEnv6 } from "@hcmai/sdk";
15946
+ import { CliError as CliError34, CliErrorCode as CliErrorCode35, formatObject as formatObject29, HcmClient as HcmClient24, loadEnv as loadEnv6 } from "@hcmai/sdk";
15376
15947
  import { createRequire } from "module";
15377
15948
 
15378
15949
  // src/commands/chiron-page-cdp.ts
15379
- import { CliError as CliError31, CliErrorCode as CliErrorCode32 } from "@hcmai/sdk";
15950
+ import { CliError as CliError32, CliErrorCode as CliErrorCode33 } from "@hcmai/sdk";
15380
15951
 
15381
15952
  // src/commands/chiron-page-shared.ts
15382
15953
  function redactTicket(text) {
@@ -15412,14 +15983,14 @@ function normalizeCdpEndpoint(raw) {
15412
15983
  try {
15413
15984
  url = new URL(candidate);
15414
15985
  } 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}` });
15986
+ 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
15987
  }
15417
15988
  const protocol = url.protocol === "wss:" ? "https:" : url.protocol === "ws:" ? "http:" : url.protocol;
15418
15989
  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}` });
15990
+ 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
15991
  }
15421
15992
  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}` });
15993
+ 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
15994
  }
15424
15995
  return `${protocol}//${url.hostname}:${url.port}`;
15425
15996
  }
@@ -15516,8 +16087,8 @@ async function captureViaCdp(input, io) {
15516
16087
  const browser = version2?.Browser ? String(version2.Browser) : `attached ${input.endpoint}`;
15517
16088
  const target = await io.fetchJson(`${input.endpoint}/json/new?about:blank`, "PUT");
15518
16089
  if (!target?.id || !target.webSocketDebuggerUrl) {
15519
- throw new CliError31({
15520
- code: CliErrorCode32.SERVER_ERROR,
16090
+ throw new CliError32({
16091
+ code: CliErrorCode33.SERVER_ERROR,
15521
16092
  message: `${input.endpoint}/json/new \u6CA1\u6709\u7ED9\u51FA\u6807\u7B7E\u9875\uFF08id / webSocketDebuggerUrl \u7F3A\u5931\uFF09`,
15522
16093
  context: { nextStep: "\u786E\u8BA4 Chrome \u662F\u5E26 --remote-debugging-port \u8D77\u7684\uFF0C\u4E14 --cdp \u6307\u5230\u7684\u662F\u5B83" }
15523
16094
  });
@@ -15547,7 +16118,7 @@ async function captureViaCdp(input, io) {
15547
16118
  });
15548
16119
  if (r.exceptionDetails) {
15549
16120
  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)}` });
16121
+ 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
16122
  }
15552
16123
  evalResult = r.result && "value" in r.result ? toPlainJson(r.result.value) : toPlainJson(r.result?.description);
15553
16124
  }
@@ -15558,7 +16129,7 @@ async function captureViaCdp(input, io) {
15558
16129
  const dom = typeof domReply.result?.value === "string" ? domReply.result.value : "";
15559
16130
  const shot = await session.send("Page.captureScreenshot", { format: "png" });
15560
16131
  if (!shot.data) {
15561
- throw new CliError31({ code: CliErrorCode32.SERVER_ERROR, message: "Page.captureScreenshot \u6CA1\u6709\u8FD4\u56DE\u56FE\u50CF\u6570\u636E" });
16132
+ throw new CliError32({ code: CliErrorCode33.SERVER_ERROR, message: "Page.captureScreenshot \u6CA1\u6709\u8FD4\u56DE\u56FE\u50CF\u6570\u636E" });
15562
16133
  }
15563
16134
  await io.writeFile(input.screenshot, Buffer.from(shot.data, "base64"));
15564
16135
  return { dom, browser, evalResult, navigated, minted };
@@ -15580,7 +16151,7 @@ var defaultCdpIo = {
15580
16151
  openSocket: (wsUrl) => new Promise((resolve3, reject) => {
15581
16152
  const Ctor = globalThis.WebSocket;
15582
16153
  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" }));
16154
+ 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
16155
  return;
15585
16156
  }
15586
16157
  const ws = new Ctor(wsUrl);
@@ -15603,7 +16174,7 @@ var defaultCdpIo = {
15603
16174
 
15604
16175
  // src/commands/chiron-page-playwright.ts
15605
16176
  import path15 from "path";
15606
- import { CliError as CliError32, CliErrorCode as CliErrorCode33 } from "@hcmai/sdk";
16177
+ import { CliError as CliError33, CliErrorCode as CliErrorCode34 } from "@hcmai/sdk";
15607
16178
  function playwrightCacheRoot(probe2) {
15608
16179
  const override = probe2.env.PLAYWRIGHT_BROWSERS_PATH?.trim();
15609
16180
  if (override === "0" && probe2.packageRoot) return path15.join(probe2.packageRoot, ".local-browsers");
@@ -15646,8 +16217,8 @@ function discoverPlaywrightBrowser(probe2) {
15646
16217
  const explicit = probe2.env.HCM_PLAYWRIGHT_EXECUTABLE?.trim();
15647
16218
  if (explicit) {
15648
16219
  if (probe2.executable(explicit)) return { executablePath: explicit, kind: "explicit", from: "HCM_PLAYWRIGHT_EXECUTABLE" };
15649
- throw new CliError32({
15650
- code: CliErrorCode33.INVALID_ARGUMENT,
16220
+ throw new CliError33({
16221
+ code: CliErrorCode34.INVALID_ARGUMENT,
15651
16222
  message: `HCM_PLAYWRIGHT_EXECUTABLE \u6307\u7684\u6587\u4EF6\u4E0D\u53EF\u6267\u884C\uFF1A${explicit}`,
15652
16223
  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
16224
  });
@@ -15689,8 +16260,8 @@ async function captureViaPlaywright(input) {
15689
16260
  }
15690
16261
  }
15691
16262
  if (!browser) {
15692
- throw new CliError32({
15693
- code: CliErrorCode33.SERVER_ERROR,
16263
+ throw new CliError33({
16264
+ code: CliErrorCode34.SERVER_ERROR,
15694
16265
  message: `Playwright \u8D77\u4E0D\u4E86\u6D4F\u89C8\u5668\uFF1A${failures.join("\uFF1B")}`,
15695
16266
  context: {
15696
16267
  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 +16281,7 @@ async function captureViaPlaywright(input) {
15710
16281
  evalResult = toPlainJson(await page.evaluate(wrapEvalBody(input.evalJs)));
15711
16282
  } catch (e) {
15712
16283
  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)}` });
16284
+ throw new CliError33({ code: CliErrorCode34.INVALID_ARGUMENT, message: `--eval \u5728\u9875\u9762\u91CC\u629B\u4E86\u5F02\u5E38\uFF1A${redactTicket(why)}` });
15714
16285
  }
15715
16286
  }
15716
16287
  const dom = await page.content();
@@ -15734,13 +16305,13 @@ function judgePageContent(input) {
15734
16305
  function parseViewport(size) {
15735
16306
  const m = /^(\d+)x(\d+)$/.exec(size.trim());
15736
16307
  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}` });
16308
+ 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
16309
  }
15739
16310
  const width = Number(m[1]);
15740
16311
  const height = Number(m[2]);
15741
16312
  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,
16313
+ throw new CliError34({
16314
+ code: CliErrorCode35.INVALID_ARGUMENT,
15744
16315
  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
16316
  });
15746
16317
  }
@@ -15750,23 +16321,23 @@ function parseWaitMs(raw) {
15750
16321
  if (raw === void 0) return 1e4;
15751
16322
  const value = typeof raw === "number" ? raw : Number(raw);
15752
16323
  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}` });
16324
+ 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
16325
  }
15755
16326
  return value;
15756
16327
  }
15757
16328
  function resolveEvidenceTarget(projectRoot, out) {
15758
16329
  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` });
16330
+ 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
16331
  }
15761
16332
  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}` });
16333
+ throw new CliError34({ code: CliErrorCode35.INVALID_ARGUMENT, message: `--out \u8981\u4EE5 .png \u7ED3\u5C3E\uFF0C\u6536\u5230\u7684\u662F ${out}` });
15763
16334
  }
15764
16335
  const root = path16.resolve(projectRoot);
15765
16336
  const evidenceRoot = path16.join(root, EVIDENCE_DIR);
15766
16337
  const absolute = path16.resolve(root, out);
15767
16338
  if (absolute !== evidenceRoot && !absolute.startsWith(evidenceRoot + path16.sep)) {
15768
- throw new CliError33({
15769
- code: CliErrorCode34.INVALID_ARGUMENT,
16339
+ throw new CliError34({
16340
+ code: CliErrorCode35.INVALID_ARGUMENT,
15770
16341
  message: `--out \u8981\u843D\u5728\u9879\u76EE\u7684 ${EVIDENCE_DIR}/ \u4E0B\uFF08${evidenceRoot}\uFF09\uFF0C\u6536\u5230\u7684\u662F ${absolute}`
15771
16342
  });
15772
16343
  }
@@ -15814,8 +16385,8 @@ async function assertInsideEvidence(deps, evidenceRoot, absolute) {
15814
16385
  const canonicalParent = await deps.realpath(path16.dirname(absolute));
15815
16386
  if (canonicalRoot === null || canonicalParent === null) return;
15816
16387
  if (canonicalParent !== canonicalRoot && !canonicalParent.startsWith(canonicalRoot + path16.sep)) {
15817
- throw new CliError33({
15818
- code: CliErrorCode34.INVALID_ARGUMENT,
16388
+ throw new CliError34({
16389
+ code: CliErrorCode35.INVALID_ARGUMENT,
15819
16390
  message: `--out \u7684\u7236\u76EE\u5F55\u7ECF\u7B26\u53F7\u94FE\u63A5\u8DD1\u51FA\u4E86 ${EVIDENCE_DIR}/\uFF1A${canonicalParent}`
15820
16391
  });
15821
16392
  }
@@ -15824,8 +16395,8 @@ async function runChironPage(target, args, deps) {
15824
16395
  const sitePath = normalizeTarget(target);
15825
16396
  const expect = (args.expectText ?? []).filter((t) => t.trim().length > 0);
15826
16397
  if (expect.length === 0) {
15827
- throw new CliError33({
15828
- code: CliErrorCode34.MISSING_FLAG,
16398
+ throw new CliError34({
16399
+ code: CliErrorCode35.MISSING_FLAG,
15829
16400
  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
16401
  });
15831
16402
  }
@@ -15835,8 +16406,8 @@ async function runChironPage(target, args, deps) {
15835
16406
  const root = path16.resolve(args.project ?? ".");
15836
16407
  const { evidenceRoot, absolute } = resolveEvidenceTarget(root, args.out);
15837
16408
  if (await deps.present(absolute)) {
15838
- throw new CliError33({
15839
- code: CliErrorCode34.INVALID_ARGUMENT,
16409
+ throw new CliError34({
16410
+ code: CliErrorCode35.INVALID_ARGUMENT,
15840
16411
  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
16412
  });
15842
16413
  }
@@ -15848,8 +16419,8 @@ async function runChironPage(target, args, deps) {
15848
16419
  const playwrightBrowser = endpoint || forceSpawn ? null : deps.findPlaywrightBrowser();
15849
16420
  const usePlaywright = !endpoint && !forceSpawn && (playwrightBrowser !== null || evalJs !== void 0);
15850
16421
  if (evalJs && !endpoint && !usePlaywright) {
15851
- throw new CliError33({
15852
- code: CliErrorCode34.INVALID_ARGUMENT,
16422
+ throw new CliError34({
16423
+ code: CliErrorCode35.INVALID_ARGUMENT,
15853
16424
  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
16425
  context: { nextStep: "npx playwright install chromium-headless-shell\uFF0C\u6216\u5728\u6C99\u7BB1\u5916\u8D77 Chrome \u7528 --cdp \u8FDE" }
15855
16426
  });
@@ -15867,10 +16438,10 @@ async function runChironPage(target, args, deps) {
15867
16438
  try {
15868
16439
  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
16440
  } catch (e) {
15870
- if (e instanceof CliError33) throw new CliError33({ code: e.code, message: redactTicket(e.message), context: e.context });
16441
+ if (e instanceof CliError34) throw new CliError34({ code: e.code, message: redactTicket(e.message), context: e.context });
15871
16442
  const where = endpoint ? `\u8FDE\u5230 ${endpoint} \u7684 Chrome` : "Playwright \u8D77\u7684\u6D4F\u89C8\u5668";
15872
- throw new CliError33({
15873
- code: CliErrorCode34.SERVER_ERROR,
16443
+ throw new CliError34({
16444
+ code: CliErrorCode35.SERVER_ERROR,
15874
16445
  message: `${where}\u6CA1\u8DD1\u5B8C\uFF1A${redactTicket(e instanceof Error ? e.message : String(e))}`,
15875
16446
  context: {
15876
16447
  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 +16457,8 @@ async function runChironPage(target, args, deps) {
15886
16457
  mode = "spawn";
15887
16458
  const browser = deps.findBrowser();
15888
16459
  if (!browser) {
15889
- throw new CliError33({
15890
- code: CliErrorCode34.INVALID_ARGUMENT,
16460
+ throw new CliError34({
16461
+ code: CliErrorCode35.INVALID_ARGUMENT,
15891
16462
  message: "\u672C\u673A\u627E\u4E0D\u5230 Playwright \u7684 Chromium\uFF0C\u4E5F\u627E\u4E0D\u5230 Chrome/Chromium\uFF0C\u622A\u4E0D\u4E86\u56FE\u3002",
15892
16463
  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
16464
  });
@@ -15895,8 +16466,8 @@ async function runChironPage(target, args, deps) {
15895
16466
  minted = await mint();
15896
16467
  const result = deps.capture({ browser, argv: chromeArgv({ viewport, waitMs, screenshot: absolute, url: minted.url, isRoot: process.getuid?.() === 0 }) });
15897
16468
  if (!result.ok) {
15898
- throw new CliError33({
15899
- code: CliErrorCode34.SERVER_ERROR,
16469
+ throw new CliError34({
16470
+ code: CliErrorCode35.SERVER_ERROR,
15900
16471
  message: `\u6D4F\u89C8\u5668\u6CA1\u8DD1\u5B8C\uFF1A${redactTicket(result.stderr.trim().split("\n").slice(-1)[0] ?? "\u65E0\u8F93\u51FA")}`,
15901
16472
  context: { nextStep: spawnFailureNextStep(browser, result, deps.platform) }
15902
16473
  });
@@ -15906,7 +16477,7 @@ async function runChironPage(target, args, deps) {
15906
16477
  }
15907
16478
  const bytes = await deps.present(absolute) ? await deps.sizeOf(absolute) : 0;
15908
16479
  if (bytes === 0) {
15909
- throw new CliError33({ code: CliErrorCode34.SERVER_ERROR, message: `\u6D4F\u89C8\u5668\u6CA1\u5199\u51FA\u975E\u7A7A PNG\uFF1A${absolute}` });
16480
+ throw new CliError34({ code: CliErrorCode35.SERVER_ERROR, message: `\u6D4F\u89C8\u5668\u6CA1\u5199\u51FA\u975E\u7A7A PNG\uFF1A${absolute}` });
15910
16481
  }
15911
16482
  const verdict = judgePageContent({ dom, expect, reject });
15912
16483
  return {
@@ -15969,8 +16540,8 @@ var defaultChironPageDeps = {
15969
16540
  const envCfg = await loadEnv6(ctx.env);
15970
16541
  const frontend = ctx.frontend ?? envCfg.frontend;
15971
16542
  if (!frontend?.trim()) {
15972
- throw new CliError33({
15973
- code: CliErrorCode34.INVALID_ARGUMENT,
16543
+ throw new CliError34({
16544
+ code: CliErrorCode35.INVALID_ARGUMENT,
15974
16545
  message: `env '${ctx.env}' \u6CA1\u914D\u524D\u7AEF\u5730\u5740\uFF0C\u5F00\u4E0D\u4E86\u9875\u9762\u3002`,
15975
16546
  context: { nextStep: `hcm env edit frontend <\u524D\u7AEF\u5730\u5740> --env ${ctx.env}` }
15976
16547
  });
@@ -16059,7 +16630,7 @@ init_auth_guard();
16059
16630
  import { HcmClient as HcmClient25, classifyEffect } from "@hcmai/sdk";
16060
16631
 
16061
16632
  // src/commands/delivery.ts
16062
- import { createHash as createHash8 } from "crypto";
16633
+ import { createHash as createHash9 } from "crypto";
16063
16634
  import { LEDGER_ONLY_FLAG } from "@hcmai/sdk";
16064
16635
  var APPROVAL_BYPASS_FLAGS = /* @__PURE__ */ new Set(["-y", "--yes", "--force", "--auto-approve"]);
16065
16636
  var CREDENTIAL_FLAGS = /* @__PURE__ */ new Set([
@@ -16252,6 +16823,12 @@ function classify(argv, actionResolution) {
16252
16823
  effect: "external-probe-accounted",
16253
16824
  reasonCode: "chiron-doctor-active",
16254
16825
  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"
16826
+ } : hasFlag(argv, "--platform-ops") ? {
16827
+ risk: "R1",
16828
+ execution: "direct",
16829
+ effect: "remote-read",
16830
+ reasonCode: "chiron-doctor-platform-ops",
16831
+ reason: "\u53EA\u8BFB\u8FD0\u7EF4\u5BC6\u94A5\u8BFB\u5E73\u53F0\u5C42\uFF0C\u4E0D\u5199\u4EFB\u4F55\u4E1C\u897F\u3002"
16255
16832
  } : direct("R1", "remote-read", "chiron-doctor");
16256
16833
  if (subcommand === "init") return direct("R1", "managed-local-write", "chiron-project-scaffold");
16257
16834
  if (subcommand === "test") return direct("R1", "remote-read", "chiron-regression-test");
@@ -16605,7 +17182,7 @@ function valuesAfterFlag(argv, flag) {
16605
17182
  return values;
16606
17183
  }
16607
17184
  function sha2564(value) {
16608
- return createHash8("sha256").update(value).digest("hex");
17185
+ return createHash9("sha256").update(value).digest("hex");
16609
17186
  }
16610
17187
  function isPlainObject(value) {
16611
17188
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -17620,7 +18197,7 @@ import {
17620
18197
  VERIFY_CRASHED,
17621
18198
  VERIFY_WORDS,
17622
18199
  WorkLayout,
17623
- classifyStatus as classifyStatus2,
18200
+ classifyStatus as classifyStatus3,
17624
18201
  runActiveVerify,
17625
18202
  runMetaChange,
17626
18203
  seedWorkDir as seedWorkDir2
@@ -17805,7 +18382,7 @@ function metaClient(client3, ctx) {
17805
18382
  return {
17806
18383
  status: res.status,
17807
18384
  body: res.data,
17808
- error: classifyStatus2(res.status),
18385
+ error: classifyStatus3(res.status),
17809
18386
  headers: lowerCaseHeaders2(res.headers)
17810
18387
  };
17811
18388
  } catch (e) {
@@ -17816,7 +18393,7 @@ function metaClient(client3, ctx) {
17816
18393
  body: res?.data ?? null,
17817
18394
  // 🔴 `-1` **不是** HTTP 状态:网络层没走通与「服务端答了个 4xx」在处置上相反 ——
17818
18395
  // 改动轴正是靠这一格把「确认没写」与「不知道写没写」分开。
17819
- error: status === -1 ? "network" : classifyStatus2(status),
18396
+ error: status === -1 ? "network" : classifyStatus3(status),
17820
18397
  headers: lowerCaseHeaders2(res?.headers)
17821
18398
  };
17822
18399
  }
@@ -17940,21 +18517,21 @@ import {
17940
18517
  adminResetPassword,
17941
18518
  formatObject as formatObject32,
17942
18519
  fromAxiosError as fromAxiosError23,
17943
- CliError as CliError34,
17944
- CliErrorCode as CliErrorCode35
18520
+ CliError as CliError35,
18521
+ CliErrorCode as CliErrorCode36
17945
18522
  } from "@hcmai/sdk";
17946
18523
  function buildAdminResetPasswordRequest(args, password) {
17947
18524
  const hasId = Boolean(args.id);
17948
18525
  const hasUsername = Boolean(args.username);
17949
18526
  if (hasId === hasUsername) {
17950
- throw new CliError34({
17951
- code: CliErrorCode35.INVALID_ARGUMENT,
18527
+ throw new CliError35({
18528
+ code: CliErrorCode36.INVALID_ARGUMENT,
17952
18529
  message: "--id <uuid> \u4E0E --username <user> \u5FC5\u987B\u4E14\u53EA\u80FD\u63D0\u4F9B\u4E00\u4E2A"
17953
18530
  });
17954
18531
  }
17955
18532
  if (!password) {
17956
- throw new CliError34({
17957
- code: CliErrorCode35.INVALID_ARGUMENT,
18533
+ throw new CliError35({
18534
+ code: CliErrorCode36.INVALID_ARGUMENT,
17958
18535
  message: "\u65B0\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A"
17959
18536
  });
17960
18537
  }
@@ -17983,8 +18560,8 @@ async function promptPasswordTwice() {
17983
18560
  const password = await promptSecret("\u65B0\u5BC6\u7801: ");
17984
18561
  const confirmation = await promptSecret("\u518D\u6B21\u8F93\u5165\u65B0\u5BC6\u7801: ");
17985
18562
  if (password !== confirmation) {
17986
- throw new CliError34({
17987
- code: CliErrorCode35.INVALID_ARGUMENT,
18563
+ throw new CliError35({
18564
+ code: CliErrorCode36.INVALID_ARGUMENT,
17988
18565
  message: "\u4E24\u6B21\u8F93\u5165\u7684\u65B0\u5BC6\u7801\u4E0D\u4E00\u81F4"
17989
18566
  });
17990
18567
  }
@@ -18118,7 +18695,7 @@ chiron.command("test").description("\u6309\u7528\u4F8B\u8DD1\u4E00\u904D\u5E76\u
18118
18695
  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
18696
  chiron.command("doctor").description(
18120
18697
  "\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));
18698
+ ).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
18699
  var chironSkills = chiron.command("skills").description("\u8FD9\u4E2A\u9879\u76EE\u4ED3\u7684\u6280\u80FD\uFF1A\u8DDF\u76EE\u6807\u73AF\u5883\u5BF9\u9F50");
18123
18700
  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
18701
  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));