@hcmai/cli 0.15.5 → 0.15.7

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
@@ -769,8 +769,8 @@ var init_TerminalRenderer = __esm({
769
769
  }
770
770
  }
771
771
  /** 来源行(仅子代理触发,agentPath ≥2 段时显示 `↑ 来自 a › b`,对齐 Web)。 */
772
- originLine(path18) {
773
- const segs = path18.split(".").filter(Boolean);
772
+ originLine(path19) {
773
+ const segs = path19.split(".").filter(Boolean);
774
774
  if (segs.length < 2) return "";
775
775
  const names = segs.map((k) => agentDisplayName(k));
776
776
  return chalk.gray(` \u2191 \u6765\u81EA ${names.join(" \u203A ")}`) + "\n";
@@ -1952,8 +1952,8 @@ function agentLabel(agentId) {
1952
1952
  if (/^[0-9a-f]{8}-[0-9a-f-]{27}$/i.test(agentId)) return `agent \u2026${agentId.slice(-4)}`;
1953
1953
  return agentDisplayName(agentId);
1954
1954
  }
1955
- function originLine(path18) {
1956
- const segs = (path18 ?? "").split(".").filter(Boolean);
1955
+ function originLine(path19) {
1956
+ const segs = (path19 ?? "").split(".").filter(Boolean);
1957
1957
  if (segs.length < 2) return null;
1958
1958
  return `\u6765\u81EA ${segs.map((k) => agentDisplayName(k)).join(" \u203A ")}`;
1959
1959
  }
@@ -2376,7 +2376,7 @@ function launchBrowser(url, platform = process.platform, onFailure) {
2376
2376
  child.unref();
2377
2377
  }
2378
2378
  async function runOpen(target, args, deps) {
2379
- const path18 = normalizeTarget(target);
2379
+ const path19 = normalizeTarget(target);
2380
2380
  if (!deps.frontend?.trim()) {
2381
2381
  throw new CliError3({
2382
2382
  code: CliErrorCode2.INVALID_ARGUMENT,
@@ -2384,13 +2384,13 @@ async function runOpen(target, args, deps) {
2384
2384
  });
2385
2385
  }
2386
2386
  const { ticket, expiresIn } = await deps.mintTicket();
2387
- const url = buildBrowserLoginUrl(deps.frontend, ticket, path18);
2387
+ const url = buildBrowserLoginUrl(deps.frontend, ticket, path19);
2388
2388
  if (args.printUrl) {
2389
2389
  deps.write(`${url}
2390
2390
  `);
2391
2391
  } else {
2392
2392
  deps.launch(url);
2393
- deps.write(`\u5DF2\u7528\u5F53\u524D\u8EAB\u4EFD\u6253\u5F00 ${path18}\uFF08\u7968\u636E ${expiresIn ?? 60}s \u5185\u6709\u6548\uFF0C\u53EA\u80FD\u7528\u4E00\u6B21\uFF09
2393
+ deps.write(`\u5DF2\u7528\u5F53\u524D\u8EAB\u4EFD\u6253\u5F00 ${path19}\uFF08\u7968\u636E ${expiresIn ?? 60}s \u5185\u6709\u6548\uFF0C\u53EA\u80FD\u7528\u4E00\u6B21\uFF09
2394
2394
  `);
2395
2395
  }
2396
2396
  return { url, expiresIn };
@@ -4468,8 +4468,8 @@ import {
4468
4468
  formatObject as formatObject7,
4469
4469
  fromAxiosError as fromAxiosError9
4470
4470
  } from "@hcmai/sdk";
4471
- function collectYmlFiles(path18) {
4472
- if (statSync(path18).isFile()) return [path18];
4471
+ function collectYmlFiles(path19) {
4472
+ if (statSync(path19).isFile()) return [path19];
4473
4473
  const out = [];
4474
4474
  const walk = (dir) => {
4475
4475
  for (const name of readdirSync(dir).sort()) {
@@ -4478,7 +4478,7 @@ function collectYmlFiles(path18) {
4478
4478
  else if (full.endsWith(".yml") || full.endsWith(".yaml")) out.push(full);
4479
4479
  }
4480
4480
  };
4481
- walk(path18);
4481
+ walk(path19);
4482
4482
  return out.sort();
4483
4483
  }
4484
4484
  var DRY_RUN_CLIENT = {
@@ -4486,9 +4486,9 @@ var DRY_RUN_CLIENT = {
4486
4486
  create: async () => ({ id: "" }),
4487
4487
  update: async () => ({})
4488
4488
  };
4489
- async function importCommand(path18, args) {
4489
+ async function importCommand(path19, args) {
4490
4490
  try {
4491
- const files = collectYmlFiles(path18);
4491
+ const files = collectYmlFiles(path19);
4492
4492
  const fixtures = files.map(
4493
4493
  (f) => parseFixture(readFileSync2(f, "utf8"), relative(process.cwd(), f))
4494
4494
  );
@@ -4554,7 +4554,13 @@ function formatDescriptionTable(desc, verbose = false) {
4554
4554
  const req = f.required ? " required" : " ";
4555
4555
  const lbl = verbose ? ` ${f.label ?? ""} ${f.description ?? ""}` : ` ${f.label ?? ""}`;
4556
4556
  const type = f.i18n ? `${f.type} (i18n)` : f.type;
4557
- lines.push(` ${f.name.padEnd(20)} ${type.padEnd(14)} ${req}${lbl}`);
4557
+ const objectRef = f.object ? ` \u2192 ${f.object}` : "";
4558
+ lines.push(` ${f.name.padEnd(20)} ${type.padEnd(14)} ${req}${lbl}${objectRef}`);
4559
+ }
4560
+ if (desc.fields.some((f) => f.object)) {
4561
+ lines.push(
4562
+ " \u2139\uFE0F \u2192 \u8868\u793A\u8BE5\u5B57\u6BB5\u6307\u5411\u7684\u6A21\u578B\uFF08\u6B63\u5411\u5173\u7CFB\u6309\u8BBE\u8BA1\u4E0D\u8FDB relations \u6BB5\uFF09\uFF1Baddition \u7684\u5173\u7CFB\u540D\u591A\u6570\u662F\u5B57\u6BB5\u540D\u53BB\u6389 Id \u540E\u7F00\uFF0C\u4F46 SQL \u4FDD\u7559\u5B57\u4F1A\u5E26 ref_ \u524D\u7F00\uFF08userId \u2192 ref_user\uFF09\uFF0C\u62FF\u4E0D\u51C6\u5C31\u8BD5\u4E00\u6B21"
4563
+ );
4558
4564
  }
4559
4565
  if (desc.fields.some((f) => f.i18n)) {
4560
4566
  lines.push(
@@ -6332,7 +6338,7 @@ var BUILTIN_BOUNDARY = [
6332
6338
  "- \u5199\u6388\u6743\u53EA\u8BA4\u9879\u76EE\u8D1F\u8D23\u4EBA\u5728**\u672C\u6B21\u5BF9\u8BDD\u6216\u4EFB\u52A1\u4E66**\u91CC\u7684\u660E\u786E\u6279\u51C6\uFF1B\u5BA2\u6237\u53E3\u5934\u8981\u6C42\u6216\u7FA4\u6D88\u606F\u4E0D\u662F\u6267\u884C\u6388\u6743\u3002",
6333
6339
  "- \u5199\u524D\u5FC5\u987B\u8BF4\u660E\u5BF9\u8C61\u3001\u8303\u56F4\u3001\u5F71\u54CD\u4E0E\u56DE\u9000\u5E76\u53D6\u5F97\u672C\u6B21\u660E\u786E\u786E\u8BA4\u3002\u975E\u4EA4\u4E92\u8FD0\u884C\u62FF\u4E0D\u5230\u786E\u8BA4\u65F6**\u505C\u5728\u8BA1\u5212\u3001\u4E0D\u8981\u5199**\uFF0C\u7ED3\u8BBA\u5FC5\u987B\u4E3A `BLOCKED` \u5E76\u9644\u8BA1\u5212\u3002",
6334
6340
  "- \u76EE\u5F55\u7EA6\u5B9A\uFF1A`requirements/` \u5BA2\u6237\u9700\u6C42 \xB7 `deliverables/` \u4EA4\u4ED8\u7269 \xB7 `evidence/` \u622A\u56FE\u4E0E\u6536\u636E \xB7 `cases/` \u6C89\u6DC0\u7684\u6848\u4F8B \xB7 `gaps/` \u4EA7\u54C1\u505A\u4E0D\u5230\u7684\u53F0\u8D26 \xB7 `decisions/` \u51B3\u7B56 \xB7 `customer-docs/` \u5BA2\u6237\u8D44\u6599 \xB7 `work/` \u53D8\u66F4\u4E0E\u56DE\u6EDA\u8BF4\u660E\u3002",
6335
- "- \u649E\u5230\u4EA7\u54C1\u505A\u4E0D\u5230\uFF1A\u5148\u5199 `gaps/` \u53F0\u8D26\u5E76\u7B54\u6E05\u4E09\u95EE\uFF0C\u7528 `hcm chiron gap search` \u67E5\u91CD\uFF0C\u7ECF\u987E\u95EE\u786E\u8BA4\u540E `hcm chiron gap submit` \u63D0\u5230 Jira\uFF08\u4EA7\u54C1\u5BF9\u5916\u7684\u7EDF\u4E00\u9762\uFF09\uFF0C\u62A5\u544A\u5199 `BLOCKED \xB7 \u5DF2\u63D0 <\u5355\u53F7> \xB7 \u66FF\u4EE3\u6CD5`\uFF1B\u4E4B\u540E\u7528 `hcm chiron gap status` \u67E5\u8FDB\u5EA6\uFF08\u5B83\u53EA\u7ED9\u6BCF\u6761\u8BC4\u8BBA\u7684\u9996\u884C\uFF0C\u90E8\u7F72 / \u9A8C\u6536\u7ED3\u8BBA\u7684\u5168\u6587\u7528 `hcm chiron gap comments` \u770B\uFF09\u3002",
6341
+ "- \u649E\u5230\u4EA7\u54C1\u505A\u4E0D\u5230\uFF1A\u5148\u5199 `gaps/` \u53F0\u8D26\u5E76\u7B54\u6E05\u4E09\u95EE\uFF0C\u7528 `hcm chiron gap search` \u67E5\u91CD\uFF0C\u7ECF\u987E\u95EE\u786E\u8BA4\u540E `hcm chiron gap submit` \u63D0\u5230 Jira\uFF08\u4EA7\u54C1\u5BF9\u5916\u7684\u7EDF\u4E00\u9762\uFF09\uFF0C\u62A5\u544A\u5199 `BLOCKED \xB7 \u5DF2\u63D0 <\u5355\u53F7> \xB7 \u66FF\u4EE3\u6CD5`\uFF1B\u4E4B\u540E\u7528 `hcm chiron gap status` \u67E5\u8FDB\u5EA6\uFF08\u5B83\u53EA\u7ED9\u6BCF\u6761\u8BC4\u8BBA\u7684\u9996\u884C\uFF0C\u90E8\u7F72 / \u9A8C\u6536\u7ED3\u8BBA\u7684\u5168\u6587\u7528 `hcm chiron gap comments` \u770B\uFF09\u3002\u4FEE\u590D\u53D1\u5230\u4F60\u7684\u73AF\u5883\u5E76\u6309\u6280\u80FD\u590D\u9A8C\u540E\uFF0C\u7531\u63D0\u5355\u4EBA\u7528 `hcm chiron gap verify <\u5355\u53F7> --result pass|fail|partial --body <\u8BC1\u636E>` \u56DE\u5199\uFF1Apass \u5173\u5355\u3001fail \u9000\u56DE\u3001partial \u53EA\u8BB0\u5F55\u4E0D\u5173\u5355\uFF1B\u53EA\u9A8C\u672C\u6B21 `created` \u56DE\u6267\u91CC\u81EA\u5DF1\u63D0\u7684\u5355\uFF0C\u9A8C\u6536\u5173\u5355\u8981\u9879\u76EE\u8D1F\u8D23\u4EBA\u672C\u6B21\u540C\u610F\u3002",
6336
6342
  "- \u9875\u9762\u9A8C\u6536\u7EDF\u4E00\u7528 `hcm chiron page </\u8DEF\u5F84> --expect-text <\u9875\u9762\u4E0A\u5FC5\u987B\u51FA\u73B0\u7684\u6587\u672C> --out evidence/\u2026.png`\uFF1B\u53EA\u622A\u5230\u56FE\u4E0D\u7B97\u901A\u8FC7\u3002",
6337
6343
  "- \u4EFB\u4F55\u51ED\u636E\u3001\u914D\u5BF9\u7801\u3001\u4EE4\u724C\u3001\u5BA2\u6237\u5BC6\u7801\u90FD\u4E0D\u5F97\u5199\u5165\u4ED3\u5E93\u3001\u547D\u4EE4\u53C2\u6570\u6216\u4EA4\u4ED8\u6587\u6863\u3002"
6338
6344
  ].join("\n");
@@ -6713,12 +6719,12 @@ async function inspectJira() {
6713
6719
  const me = await call("/rest/api/2/myself");
6714
6720
  if (me.status === 401) return { ok: false, from: src.from, reason: "\u4EE4\u724C\u65E0\u6548\u6216\u5DF2\u8FC7\u671F\uFF0C\u91CD\u5EFA PAT \u540E\u91CD\u65B0\u5B58\u4E00\u6B21" };
6715
6721
  if (!me.ok) return { ok: false, from: src.from, reason: `\u8FDE\u5F97\u4E0A\u4F46 /myself \u8FD4\u56DE ${me.status}` };
6716
- const who = (await me.json()).displayName ?? "";
6722
+ const who2 = (await me.json()).displayName ?? "";
6717
6723
  const project = await call(`/rest/api/2/project/${JIRA_PROJECT}`);
6718
6724
  return {
6719
6725
  ok: project.ok,
6720
6726
  from: src.from,
6721
- who,
6727
+ who: who2,
6722
6728
  projectVisible: project.ok,
6723
6729
  reason: project.ok ? void 0 : `\u770B\u4E0D\u5230\u9879\u76EE ${JIRA_PROJECT}\uFF08${project.status}\uFF09\uFF0C\u627E Jira \u7BA1\u7406\u5458\u5F00\u6743\u9650`
6724
6730
  };
@@ -8774,10 +8780,10 @@ async function metaListCommand(args) {
8774
8780
  fail7(e, args, "read");
8775
8781
  }
8776
8782
  }
8777
- async function metaGetCommand(path18, args) {
8783
+ async function metaGetCommand(path19, args) {
8778
8784
  try {
8779
8785
  const c = await client2(args);
8780
- const content = await getTenantMeta(c.raw(), path18);
8786
+ const content = await getTenantMeta(c.raw(), path19);
8781
8787
  process.stdout.write(content.endsWith("\n") ? content : content + "\n");
8782
8788
  process.exitCode = 0;
8783
8789
  return;
@@ -8786,8 +8792,8 @@ async function metaGetCommand(path18, args) {
8786
8792
  }
8787
8793
  }
8788
8794
  var PROBEABLE_META_TYPES = /* @__PURE__ */ new Set(["model", "list", "info", "view", "filter", "page", "wiz", "impexp"]);
8789
- function parseMetaPath(path18) {
8790
- const base = path18.split(/[\\/]/).pop() ?? path18;
8795
+ function parseMetaPath(path19) {
8796
+ const base = path19.split(/[\\/]/).pop() ?? path19;
8791
8797
  if (!/\.(yml|yaml)$/i.test(base)) return {};
8792
8798
  const parts = base.replace(/\.(yml|yaml)$/i, "").split(".");
8793
8799
  return { model: parts[0] || void 0, kind: parts[1] ?? "model", state: parts[2] };
@@ -8804,10 +8810,10 @@ function unverifiableReason(e) {
8804
8810
  if (st == null) return `\u8BF7\u6C42\u6CA1\u53D1\u51FA\u53BB\u6216\u6CA1\u56DE\u6765\uFF08${err.code ?? err.message ?? "\u672A\u77E5"}\uFF09`;
8805
8811
  return void 0;
8806
8812
  }
8807
- async function verifyAfterWrite(c, path18) {
8808
- const { model, kind, state } = parseMetaPath(path18);
8813
+ async function verifyAfterWrite(c, path19) {
8814
+ const { model, kind, state } = parseMetaPath(path19);
8809
8815
  if (!model || !kind) {
8810
- return { status: "unverified", where: "(\u672A\u63A2)", why: `\u4ECE\u8DEF\u5F84 ${path18} \u8BA4\u4E0D\u51FA\u6A21\u578B\u540D/\u5C42\u540D` };
8816
+ return { status: "unverified", where: "(\u672A\u63A2)", why: `\u4ECE\u8DEF\u5F84 ${path19} \u8BA4\u4E0D\u51FA\u6A21\u578B\u540D/\u5C42\u540D` };
8811
8817
  }
8812
8818
  try {
8813
8819
  await clearMetaCache2(c.raw(), model, {});
@@ -8852,7 +8858,7 @@ async function verifyAfterWrite(c, path18) {
8852
8858
  }
8853
8859
  return { status: "ok" };
8854
8860
  }
8855
- async function metaSetCommand(path18, args) {
8861
+ async function metaSetCommand(path19, args) {
8856
8862
  try {
8857
8863
  if (!args.file) {
8858
8864
  throw new CliError22({
@@ -8868,9 +8874,9 @@ async function metaSetCommand(path18, args) {
8868
8874
  process.stdin.on("error", reject);
8869
8875
  }) : await fsp3.readFile(args.file, "utf8");
8870
8876
  if (!args.skipValidate) {
8871
- const result2 = validateMetaContent(path18, content);
8877
+ const result2 = validateMetaContent(path19, content);
8872
8878
  if (result2.issues.length > 0) {
8873
- process.stderr.write(`\u{1F50E} \u5199\u524D\u6821\u9A8C ${path18}\uFF08schema \u7C7B\u578B\uFF1A${result2.kind ?? "\u672A\u8BC6\u522B"}\uFF09
8879
+ process.stderr.write(`\u{1F50E} \u5199\u524D\u6821\u9A8C ${path19}\uFF08schema \u7C7B\u578B\uFF1A${result2.kind ?? "\u672A\u8BC6\u522B"}\uFF09
8874
8880
  `);
8875
8881
  process.stderr.write(formatMetaIssues(result2, " ") + "\n");
8876
8882
  }
@@ -8889,13 +8895,13 @@ async function metaSetCommand(path18, args) {
8889
8895
  if (dryFmt === "json" || dryFmt === "yaml") {
8890
8896
  process.stdout.write(
8891
8897
  formatObject20(
8892
- { dryRun: true, path: path18, bytes: Buffer.byteLength(content), content },
8898
+ { dryRun: true, path: path19, bytes: Buffer.byteLength(content), content },
8893
8899
  { format: dryFmt }
8894
8900
  ) + "\n"
8895
8901
  );
8896
8902
  } else {
8897
8903
  process.stdout.write(
8898
- `[dry-run] \u5C06\u5199\u5165 ${path18}\uFF08${Buffer.byteLength(content)} B\uFF09\u2014\u2014\u672A\u5B9E\u9645\u5199\u5165
8904
+ `[dry-run] \u5C06\u5199\u5165 ${path19}\uFF08${Buffer.byteLength(content)} B\uFF09\u2014\u2014\u672A\u5B9E\u9645\u5199\u5165
8899
8905
  ---
8900
8906
  ${content}
8901
8907
  `
@@ -8909,13 +8915,13 @@ ${content}
8909
8915
  let backupState = "unknown";
8910
8916
  let backupWhy;
8911
8917
  try {
8912
- const prev = await getTenantMeta(c.raw(), path18);
8918
+ const prev = await getTenantMeta(c.raw(), path19);
8913
8919
  if (!prev || prev.trim() === "") {
8914
8920
  backupState = "absent";
8915
8921
  } else {
8916
8922
  backupFile = nodePath.join(
8917
8923
  os4.tmpdir(),
8918
- `hcm-meta-backup-${Date.now()}-${path18.replace(/[\\/]/g, "_")}`
8924
+ `hcm-meta-backup-${Date.now()}-${path19.replace(/[\\/]/g, "_")}`
8919
8925
  );
8920
8926
  await fsp3.writeFile(backupFile, prev, "utf8");
8921
8927
  backupState = "saved";
@@ -8930,22 +8936,22 @@ ${content}
8930
8936
  backupWhy = `HTTP ${st ?? "-"}${err.code ? ` ${err.code}` : ""}${err.message ? `\uFF1A${err.message}` : ""}`;
8931
8937
  }
8932
8938
  }
8933
- const result = await saveTenantMeta(c.raw(), path18, content);
8939
+ const result = await saveTenantMeta(c.raw(), path19, content);
8934
8940
  const fmt = args.output ?? "json";
8935
- if (fmt !== "json") process.stdout.write(`\u2705 \u5DF2\u5199\u5165 ${path18}
8941
+ if (fmt !== "json") process.stdout.write(`\u2705 \u5DF2\u5199\u5165 ${path19}
8936
8942
  `);
8937
8943
  const restoreHint = backupState === "saved" && backupFile ? ` \u65E7\u5185\u5BB9\u5DF2\u5B58\uFF1A${backupFile}
8938
- \u653E\u56DE\u53BB\uFF1Ahcm meta set ${path18} --file ${backupFile}${connFlags(args)}
8939
- ` : backupState === "absent" ? ` \u8FD9\u4E00\u5C42\u6B64\u524D\u6CA1\u6709\u8986\u76D6\uFF08\u5DF2\u8BC1\u5B9E\uFF09\uFF0C\u6062\u590D\u5373\u5220\u9664\uFF1Ahcm meta delete ${path18}${connFlags(args)}
8944
+ \u653E\u56DE\u53BB\uFF1Ahcm meta set ${path19} --file ${backupFile}${connFlags(args)}
8945
+ ` : backupState === "absent" ? ` \u8FD9\u4E00\u5C42\u6B64\u524D\u6CA1\u6709\u8986\u76D6\uFF08\u5DF2\u8BC1\u5B9E\uFF09\uFF0C\u6062\u590D\u5373\u5220\u9664\uFF1Ahcm meta delete ${path19}${connFlags(args)}
8940
8946
  ` : ` \u26A0\uFE0F \u65E7\u5185\u5BB9**\u6CA1\u5907\u4EFD\u6210**\uFF08${backupWhy ?? "\u539F\u56E0\u672A\u77E5"}\uFF09\u2014\u2014\u65E2\u4E0D\u77E5\u9053\u6B64\u524D\u6709\u6CA1\u6709\u8986\u76D6\uFF0C\u4E5F\u5C31\u7ED9\u4E0D\u51FA\u6062\u590D\u547D\u4EE4\u3002
8941
- \u5148\u81EA\u5DF1\u8BFB\u4E00\u904D\u786E\u8BA4\uFF1Ahcm meta get ${path18}${connFlags(args)}
8947
+ \u5148\u81EA\u5DF1\u8BFB\u4E00\u904D\u786E\u8BA4\uFF1Ahcm meta get ${path19}${connFlags(args)}
8942
8948
  `;
8943
8949
  if (args.verify === false) {
8944
8950
  process.stderr.write(
8945
8951
  "\u26A0\uFE0F --no-verify\uFF1A**\u6CA1\u6709**\u9A8C\u8FC7\u670D\u52A1\u7AEF\u8BFB\u4E0D\u8BFB\u5F97\u52A8\u8FD9\u4EFD meta\u3002\u300C\u5199\u5165\u6210\u529F\u300D\u53EA\u8BF4\u660E\u5B57\u8282\u6536\u4E0B\u4E86\u3002\n \u81EA\u5DF1\u8865\uFF1Ahcm cache clear-meta <Model> \u540E\u6253\u5F00\u9875\u9762\u770B\u4E00\u773C\u3002\n" + restoreHint
8946
8952
  );
8947
8953
  } else {
8948
- const outcome = await verifyAfterWrite(c, path18);
8954
+ const outcome = await verifyAfterWrite(c, path19);
8949
8955
  if (outcome.status === "broken") {
8950
8956
  const human = explainJacksonError(outcome.raw);
8951
8957
  process.stderr.write(
@@ -8979,19 +8985,19 @@ ${content}
8979
8985
  fail7(e, args);
8980
8986
  }
8981
8987
  }
8982
- async function metaDeleteCommand(path18, args) {
8988
+ async function metaDeleteCommand(path19, args) {
8983
8989
  try {
8984
8990
  if (!args.yes) {
8985
- const ok = await promptConfirm(`\u5C06\u5220\u9664\u5143\u6570\u636E ${path18}\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u9006\u3002\u7EE7\u7EED\uFF1F`);
8991
+ const ok = await promptConfirm(`\u5C06\u5220\u9664\u5143\u6570\u636E ${path19}\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u9006\u3002\u7EE7\u7EED\uFF1F`);
8986
8992
  if (!ok) {
8987
8993
  process.stderr.write("\u5DF2\u53D6\u6D88\n");
8988
8994
  process.exit(1);
8989
8995
  }
8990
8996
  }
8991
8997
  const c = await client2(args);
8992
- const result = await deleteTenantMeta(c.raw(), path18);
8998
+ const result = await deleteTenantMeta(c.raw(), path19);
8993
8999
  const fmt = args.output ?? "json";
8994
- if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${path18}
9000
+ if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${path19}
8995
9001
  `);
8996
9002
  process.stdout.write(formatObject20(result, { format: fmt }) + "\n");
8997
9003
  process.exitCode = 0;
@@ -9000,7 +9006,7 @@ async function metaDeleteCommand(path18, args) {
9000
9006
  fail7(e, args);
9001
9007
  }
9002
9008
  }
9003
- async function metaValidateCommand(path18, args) {
9009
+ async function metaValidateCommand(path19, args) {
9004
9010
  try {
9005
9011
  if (!args.file) {
9006
9012
  throw new CliError22({
@@ -9015,13 +9021,13 @@ async function metaValidateCommand(path18, args) {
9015
9021
  process.stdin.on("end", () => resolve3(buf));
9016
9022
  process.stdin.on("error", reject);
9017
9023
  }) : await fsp3.readFile(args.file, "utf8");
9018
- const result = validateMetaContent(path18, content);
9024
+ const result = validateMetaContent(path19, content);
9019
9025
  const fmt = args.output ?? "table";
9020
9026
  if (fmt === "json" || fmt === "yaml") {
9021
9027
  process.stdout.write(
9022
9028
  formatObject20(
9023
9029
  {
9024
- path: path18,
9030
+ path: path19,
9025
9031
  kind: result.kind,
9026
9032
  schemaKnown: result.schemaKnown,
9027
9033
  schemaSourceCommit: META_SCHEMA_SOURCE_COMMIT,
@@ -9033,7 +9039,7 @@ async function metaValidateCommand(path18, args) {
9033
9039
  );
9034
9040
  } else {
9035
9041
  process.stdout.write(
9036
- `\u{1F50E} ${path18}\uFF08schema \u7C7B\u578B\uFF1A${result.kind ?? "\u672A\u8BC6\u522B"}\uFF0C\u6765\u6E90 ${META_SCHEMA_SOURCE_COMMIT.slice(0, 8)}\uFF09
9042
+ `\u{1F50E} ${path19}\uFF08schema \u7C7B\u578B\uFF1A${result.kind ?? "\u672A\u8BC6\u522B"}\uFF0C\u6765\u6E90 ${META_SCHEMA_SOURCE_COMMIT.slice(0, 8)}\uFF09
9037
9043
  `
9038
9044
  );
9039
9045
  process.stdout.write(
@@ -10953,6 +10959,7 @@ async function chironInitCommand(args, deps) {
10953
10959
  // src/commands/gap.ts
10954
10960
  import { readFileSync as readFileSync6 } from "fs";
10955
10961
  import {
10962
+ CliErrorCode as CliErrorCode25,
10956
10963
  createHttpClient as createHttpClient4,
10957
10964
  formatObject as formatObject24,
10958
10965
  loadGlobalConfig as loadGlobalConfig10,
@@ -11280,31 +11287,38 @@ ${cs.map((c) => c.body ?? "").join("\n")}`).map((l) => ({
11280
11287
  }));
11281
11288
  for (const p of links) lines.push(`\u5DF2\u767B\u8BB0\u4EE3\u7801\u5E93\u6761\u76EE ${p.repo}#${p.number}`, ` ${p.url}`);
11282
11289
  let nextStep;
11283
- if (resolution) nextStep = "Jira \u8FD9\u5355\u5DF2\u89E3\u51B3\u3002\u76EE\u6807\u73AF\u5883\u90E8\u7F72\u5230\u542B\u4FEE\u590D\u7684\u7248\u672C\u540E\uFF08`hcm version` \u7684 commit \u4F1A\u53D8\uFF09\uFF0C\u8DD1 `hcm chiron skills sync`\uFF0C\u518D\u6309\u6280\u80FD\u590D\u9A8C\u4E00\u6B21\u3002";
11284
- else if (status === "\u8865\u5145\u8BF4\u660E") {
11290
+ const verifyCmd = `\`hcm chiron gap verify ${issue.key} --result pass|fail|partial --body <\u8BC1\u636E>\``;
11291
+ if (status === "\u5DF2\u4FEE\u590D") {
11292
+ nextStep = `\u4FEE\u590D\u5DF2\u5408\u5165\u3001\u8FD8\u6CA1\u53D1\u5230\u4F60\u7684\u73AF\u5883\u3002\u7EE7\u7EED\u7528\u66FF\u4EE3\u6CD5\uFF1B\u53D1\u5E03\u540E\uFF08\`hcm version\` \u7684 commit \u4F1A\u53D8\uFF09\u8DD1 \`hcm chiron skills sync\` \u6309\u6280\u80FD\u590D\u9A8C\uFF0C\u518D\u7531\u63D0\u5355\u4EBA\u7528 ${verifyCmd} \u56DE\u5199\uFF1Apass \u5173\u5355\u3001fail \u9000\u56DE\u3001partial \u53EA\u8BB0\u5F55\u4E0D\u5173\u5355\u3002`;
11293
+ } else if (status === "CLOSE") {
11294
+ nextStep = `\u8FD9\u5355\u5DF2\u5173\u95ED\uFF0C\u4E0D\u4F1A\u518D\u5F80\u524D\u8D70\u3002\u75C7\u72B6\u53C8\u51FA\u73B0\u5C31\u7528 \`hcm chiron gap submit\` \u91CD\u63D0\uFF0C\u73B0\u8C61\u91CC\u5199\u4E0A\u672C\u5355\u53F7 ${issue.key}\u3002`;
11295
+ } else if (status === "\u8865\u5145\u8BF4\u660E") {
11285
11296
  nextStep = `\u{1F534} **\u7403\u5728\u4F60\u8FD9\u8FB9**\uFF1A\u4EA7\u54C1\u4FA7\u770B\u4E86\uFF0C\u4F46\u4FE1\u606F\u4E0D\u591F\uFF0C\u628A\u5355\u6253\u56DE\u6765\u8BA9\u4F60\u8865\u5145\u3002\u7167\u6700\u65B0\u90A3\u6761\u8BC4\u8BBA\u8BF4\u7684\u8865\u2014\u2014\u590D\u73B0\u547D\u4EE4\u3001\u539F\u59CB\u8F93\u51FA\u3001\u73AF\u5883\u6307\u7EB9\u7F3A\u54EA\u6837\u8865\u54EA\u6837\uFF0C\u7528 \`hcm chiron gap submit\` \u8FFD\u52A0\u4E00\u6761\u73B0\u573A\uFF0C\u6216\u76F4\u63A5\u5728 Jira \u90A3\u5355\u4E0B\u56DE\u590D\u3002\u8865\u5B8C\u8BA9\u5206\u8BCA\u4EBA\u63A8\u300C\u91CD\u65B0\u63D0\u4EA4\u300D\u3002**\u4E0D\u8865\u7684\u8BDD\u8FD9\u5355\u4E0D\u4F1A\u81EA\u5DF1\u5F80\u524D\u8D70\u3002**`;
11286
11297
  } else if (status === "\u4E0D\u5904\u7406" || status === "\u91CD\u590D\u95EE\u9898") {
11287
11298
  nextStep = `\u4EA7\u54C1\u4FA7\u5224\u4E86\u300C${status}\u300D\u3002\u770B\u6700\u65B0\u90A3\u6761\u8BC4\u8BBA\u7ED9\u7684\u7406\u7531\u4E0E\u66FF\u4EE3\u6CD5\uFF1B\u4E0D\u8BA4\u540C\u5C31\u5728\u5355\u4E0B\u8BF4\u6E05\u695A\u4E3A\u4EC0\u4E48\uFF0C\u5B83\u8FD8\u80FD\u88AB\u91CD\u5F00\u3002`;
11288
11299
  } else if (status === "\u7EB3\u5165\u89C4\u5212") {
11289
11300
  nextStep = "\u5DF2\u6392\u671F\uFF0C\u4F46\u6CA1\u6392\u5728\u8FD1\u671F\u3002\u7EE7\u7EED\u7528\u66FF\u4EE3\u6CD5\u4EA4\u4ED8\uFF1B\u8981\u63D0\u524D\u5C31\u5728\u5355\u4E0B\u8BF4\u660E\u4E1A\u52A1\u5F71\u54CD\uFF08\u73B0\u573A\u6570\u5C31\u662F\u4F18\u5148\u7EA7\u4FE1\u53F7\uFF09\u3002";
11290
- } else if (status === "\u5DF2\u4FEE\u590D") nextStep = "\u4FEE\u590D\u5DF2\u5408\u5165\u3001\u8FD8\u6CA1\u53D1\u5230\u4F60\u7684\u73AF\u5883\u3002\u7EE7\u7EED\u7528\u66FF\u4EE3\u6CD5\uFF0C\u53D1\u5E03\u540E\u590D\u9A8C\u3002";
11291
- else if (status === "\u65B0\u589E") nextStep = `\u7B49\u5206\u8BCA\u3002\u5148\u6309\u66FF\u4EE3\u6CD5\u7EE7\u7EED\u4EA4\u4ED8\uFF0C\u62A5\u544A\u5199 BLOCKED \xB7 \u5DF2\u63D0 ${issue.key}\u3002`;
11301
+ } else if (status === "\u65B0\u589E") nextStep = `\u7B49\u5206\u8BCA\u3002\u5148\u6309\u66FF\u4EE3\u6CD5\u7EE7\u7EED\u4EA4\u4ED8\uFF0C\u62A5\u544A\u5199 BLOCKED \xB7 \u5DF2\u63D0 ${issue.key}\u3002`;
11302
+ else if (resolution) nextStep = "Jira \u8FD9\u5355\u5DF2\u89E3\u51B3\u3002\u76EE\u6807\u73AF\u5883\u90E8\u7F72\u5230\u542B\u4FEE\u590D\u7684\u7248\u672C\u540E\uFF08`hcm version` \u7684 commit \u4F1A\u53D8\uFF09\uFF0C\u8DD1 `hcm chiron skills sync`\uFF0C\u518D\u6309\u6280\u80FD\u590D\u9A8C\u4E00\u6B21\u3002";
11292
11303
  else if (links.length) nextStep = "\u5DF2\u5206\u8BCA\u3001\u4EE3\u7801\u5E93\u5DF2\u767B\u8BB0\uFF0C\u8FD8\u5728\u505A\u3002\u7EE7\u7EED\u7528\u66FF\u4EE3\u6CD5\uFF1B\u60F3\u8981\u6392\u671F\u5C31\u5728 Jira \u8FD9\u5355\u4E0B\u7559\u8A00\u3002";
11293
11304
  else if (status && status !== "\u65B0\u589E") {
11294
11305
  nextStep = `\u8FD9\u5355\u5728\u300C${status}\u300D\u2014\u2014**\u672C\u6D41\u7A0B\u6CA1\u5B9A\u4E49\u8FD9\u4E2A\u72B6\u6001**\uFF08\u591A\u534A\u662F\u5DE5\u4F5C\u6D41\u53C8\u52A0\u4E86\u72B6\u6001\uFF0C\u6216\u65B9\u6848 12100 \u88AB\u5207\u8D70\u4E86\uFF09\u3002\u6309 Jira \u7684\u5DE5\u4F5C\u6D41\u5B83\u8FD8\u5728\u4EA7\u54C1\u4FA7\u624B\u4E0A\uFF0C\u4E0D\u662F\u5728\u7B49\u4F60\u3002\u5148\u6309\u66FF\u4EE3\u6CD5\u7EE7\u7EED\u4EA4\u4ED8\uFF1B\u60F3\u77E5\u9053\u5177\u4F53\u8FDB\u5C55\u5C31\u5728\u5355\u4E0B\u95EE\u4E00\u53E5\uFF0C\u6216\u8BA9\u5206\u8BCA\u4EBA\u628A\u5B83\u63A8\u5230\u6536\u5355\u6D41\u7A0B\u91CC\u7684\u72B6\u6001\u4E0A\u3002`;
11295
11306
  } else nextStep = `\u7B49\u5206\u8BCA\u3002\u5148\u6309\u66FF\u4EE3\u6CD5\u7EE7\u7EED\u4EA4\u4ED8\uFF0C\u62A5\u544A\u5199 BLOCKED \xB7 \u5DF2\u63D0 ${issue.key}\u3002`;
11296
- if (latestComment && !resolution) {
11307
+ const stillOpen = status !== "CLOSE" && (status === "\u5DF2\u4FEE\u590D" || !resolution);
11308
+ if (latestComment && stillOpen) {
11297
11309
  const cite = `${latestComment.when} ${latestComment.author}\uFF1A\u300C${latestComment.headline}\u300D`;
11298
11310
  const tail = latestComment.truncated ? `\uFF08${fullText}\uFF09` : "";
11311
+ const canVerify = status === "\u5DF2\u4FEE\u590D";
11312
+ const waitFixed = "\u7B49\u4EA7\u54C1\u4FA7\u628A\u5355\u63A8\u5230\u300C\u5DF2\u4FEE\u590D\u300D";
11299
11313
  switch (latestComment.signal) {
11300
11314
  case "passed":
11301
- nextStep = `\u76EE\u6807\u73AF\u5883\u5DF2\u590D\u9A8C\u901A\u8FC7\u2014\u2014${cite}${tail}\u3002Jira \u72B6\u6001\u8FD8\u505C\u5728\u300C${status ?? "?"}\u300D\u53EA\u8BF4\u660E\u4EA7\u54C1\u4FA7\u8FD8\u6CA1\u8D70\u5173\u5355\u6D41\u8F6C\uFF0C\u4E0D\u4EE3\u8868\u8FD8\u6CA1\u90E8\u7F72\uFF1B\u8DD1 \`hcm chiron skills sync\` \u540E\u6309\u6280\u80FD\u76F4\u63A5\u7528\uFF0C\u4E0D\u5FC5\u518D\u7B49\u90E8\u7F72\u590D\u9A8C\u3002`;
11315
+ nextStep = `\u76EE\u6807\u73AF\u5883\u5DF2\u590D\u9A8C\u901A\u8FC7\u2014\u2014${cite}${tail}\u3002` + (canVerify ? `Jira \u72B6\u6001\u8FD8\u505C\u5728\u300C\u5DF2\u4FEE\u590D\u300D\u53EA\u8BF4\u660E\u8FD8\u6CA1\u8D70\u5173\u5355\u6D41\u8F6C\uFF0C\u4E0D\u4EE3\u8868\u8FD8\u6CA1\u90E8\u7F72\uFF1A\u63D0\u5355\u4EBA\u8DD1 \`hcm chiron gap verify ${issue.key} --result pass --body <\u8BC1\u636E>\` \u5173\u5355\uFF08\u4E0D\u662F\u63D0\u5355\u4EBA\u5C31\u7B49\u63D0\u5355\u4EBA\u6216\u4EA7\u54C1\u4FA7\u5173\uFF09\u3002` : `Jira \u72B6\u6001\u8FD8\u5728\u300C${status ?? "?"}\u300D\uFF1A${waitFixed}\uFF0C\u518D\u7528 \`hcm chiron gap verify ${issue.key} --result pass --body <\u8BC1\u636E>\` \u5173\u5355\uFF08\u73B0\u5728\u8DD1\u4F1A\u88AB\u62D2\uFF09\u3002`) + `\u8DD1 \`hcm chiron skills sync\` \u540E\u6309\u6280\u80FD\u76F4\u63A5\u7528\uFF0C\u4E0D\u5FC5\u518D\u7B49\u90E8\u7F72\u590D\u9A8C\u3002`;
11302
11316
  break;
11303
11317
  case "deployed":
11304
- nextStep = `\u76EE\u6807\u73AF\u5883\u5DF2\u90E8\u7F72\u5230\u542B\u4FEE\u590D\u7684\u7248\u672C\u2014\u2014${cite}${tail}\u3002\u8DD1 \`hcm chiron skills sync\`\uFF0C\u6309\u6280\u80FD\u590D\u9A8C\u4E00\u6B21\uFF0C\u628A\u7ED3\u679C\u56DE\u5230\u8FD9\u5355\u4E0B\u3002`;
11318
+ nextStep = `\u76EE\u6807\u73AF\u5883\u5DF2\u90E8\u7F72\u5230\u542B\u4FEE\u590D\u7684\u7248\u672C\u2014\u2014${cite}${tail}\u3002\u8DD1 \`hcm chiron skills sync\`\uFF0C\u6309\u6280\u80FD\u590D\u9A8C\u4E00\u6B21\uFF0C` + (canVerify ? `\u518D\u7531\u63D0\u5355\u4EBA\u7528 ${verifyCmd} \u56DE\u5199\u7ED3\u8BBA\u3002` : `\u7ED3\u679C\u5148\u8BB0\u5728\u4F60\u7684\u53F0\u8D26\u91CC\uFF1B${waitFixed}\uFF0C\u518D\u7528 ${verifyCmd} \u56DE\u5199\uFF08\u73B0\u5728\u8DD1\u4F1A\u88AB\u62D2\uFF09\u3002`);
11305
11319
  break;
11306
11320
  case "partial":
11307
- nextStep = `\u590D\u9A8C\u90E8\u5206\u901A\u8FC7\u2014\u2014${cite}${tail}\u3002\u5DF2\u9A8C\u7684\u90E8\u5206\u53EF\u4EE5\u7528\uFF1B\u6CA1\u9A8C\u5230\u7684\u5206\u652F\u7EE7\u7EED\u7528\u66FF\u4EE3\u6CD5\uFF0C\u628A\u6CA1\u8FC7\u7684\u5199\u8FDB\u8FD9\u5355\u8BA9\u4EA7\u54C1\u4FA7\u63A5\u7740\u5904\u7406\u3002`;
11321
+ nextStep = `\u590D\u9A8C\u90E8\u5206\u901A\u8FC7\u2014\u2014${cite}${tail}\u3002\u9A8C\u8FC7\u7684\u90E8\u5206\u53EF\u4EE5\u7528\uFF1B\u6CA1\u9A8C\u5230\u7684\u7EE7\u7EED\u7528\u66FF\u4EE3\u6CD5\uFF1B` + (canVerify ? `\u5168\u90E8\u9A8C\u8FC7\u90FD\u901A\u8FC7\u540E\u63D0\u5355\u4EBA\u518D\u8DD1 \`hcm chiron gap verify ${issue.key} --result pass\`\uFF0C\u9A8C\u51FA\u6CA1\u901A\u8FC7\u7684\u5C31\u7528 \`--result fail\`\u3002` : `${waitFixed}\u3001\u5168\u90E8\u9A8C\u8FC7\u90FD\u901A\u8FC7\uFF0C\u518D\u7528 \`hcm chiron gap verify ${issue.key} --result pass\` \u5173\u5355\uFF08\u73B0\u5728\u8DD1\u4F1A\u88AB\u62D2\uFF09\u3002`);
11308
11322
  break;
11309
11323
  case "blocked":
11310
11324
  nextStep = `\u590D\u9A8C\u6CA1\u8FC7 / \u88AB\u963B\u585E\u2014\u2014${cite}${tail}\u3002\u7403\u56DE\u5230\u4EA7\u54C1\u4FA7\uFF1A\u7EE7\u7EED\u7528\u66FF\u4EE3\u6CD5\u4EA4\u4ED8\uFF0C\u8FDB\u5C55\u770B\u8FD9\u5355\u540E\u7EED\u8BC4\u8BBA\u3002`;
@@ -11341,6 +11355,357 @@ async function gapComments({ client: client3 }, ref, { limit } = {}, casesSlug =
11341
11355
  };
11342
11356
  }
11343
11357
 
11358
+ // src/jira/gap-verify.ts
11359
+ import { CASES_REPO_SLUG as CASES_REPO_SLUG3, CliError as CliError25, CliErrorCode as CliErrorCode24, JiraHttpError, firstLine as firstLine2, parseRef as parseRef2 } from "@hcmai/sdk";
11360
+ var VERIFY_RESULTS = ["pass", "fail", "partial"];
11361
+ var WRITTEN_TAG = { no: "\u3010\u672A\u5199\u5165\u3011", yes: "\u3010\u5DF2\u5199\u5165\u3011", unknown: "\u3010\u5199\u6CA1\u5199\u4E0D\u786E\u5B9A\u3011" };
11362
+ var FIXED_STATUS = "\u5DF2\u4FEE\u590D";
11363
+ var CLOSED_STATUS = "CLOSE";
11364
+ var EVIDENCE_MIN = 10;
11365
+ var VERIFY_PLAN = {
11366
+ pass: { header: "\u987E\u95EE\u590D\u9A8C\u901A\u8FC7", transition: { name: "\u786E\u8BA4\u5173\u95ED", to: CLOSED_STATUS }, outcome: "closed" },
11367
+ fail: { header: "\u987E\u95EE\u590D\u9A8C\u672A\u901A\u8FC7\uFF0C\u9000\u56DE", transition: { name: "\u672A\u89E3\u51B3", to: "OPEN" }, outcome: "returned" },
11368
+ partial: { header: "\u987E\u95EE\u590D\u9A8C\u90E8\u5206\u901A\u8FC7\uFF0C\u4E0D\u5173\u5355", outcome: "recorded" }
11369
+ };
11370
+ function parseVerifyResult(raw) {
11371
+ const v = String(raw ?? "").trim().toLowerCase();
11372
+ if (VERIFY_RESULTS.includes(v)) return v;
11373
+ throw new CliError25({
11374
+ code: raw === void 0 ? CliErrorCode24.MISSING_FLAG : CliErrorCode24.INVALID_ARGUMENT,
11375
+ message: `--result \u53EA\u80FD\u662F pass / fail / partial\uFF0C\u7ED9\u7684\u662F\u300C${raw ?? "\uFF08\u6CA1\u7ED9\uFF09"}\u300D`,
11376
+ context: { nextStep: "pass = \u539F\u6545\u969C\u5728\u76EE\u6807\u73AF\u5883\u4E0D\u518D\u51FA\u73B0\uFF1Bfail = \u4ECD\u7136\u590D\u73B0\u6216\u9A8C\u51FA\u6CA1\u901A\u8FC7\u7684\uFF1Bpartial = \u53EA\u9A8C\u4E86\u4E00\u90E8\u5206\u3001\u9A8C\u8FC7\u7684\u90FD\u901A\u8FC7\uFF08\u4E0D\u5173\u5355\uFF09\u3002" }
11377
+ });
11378
+ }
11379
+ function verifyFailure(reasonCode, code, written, message, nextStep, extra = {}, cause) {
11380
+ return new CliError25({ code, message: `${message}${WRITTEN_TAG[written]}`, context: { reasonCode, written, nextStep, ...extra }, cause });
11381
+ }
11382
+ function who(u) {
11383
+ if (!u) return "\uFF08\u5355\u4E0A\u6CA1\u6709\uFF09";
11384
+ const shown = u.displayName ?? u.name ?? u.key ?? "?";
11385
+ return u.name && u.name !== shown ? `${shown}\uFF08${u.name}\uFF09` : shown;
11386
+ }
11387
+ function sameUser(a, b) {
11388
+ if (!a || !b) return false;
11389
+ if (a.key || b.key) return !!a.key && !!b.key && a.key === b.key;
11390
+ if (a.name && b.name) return a.name === b.name;
11391
+ return false;
11392
+ }
11393
+ var isEmptyValue = (v) => v === void 0 || v === null || typeof v === "string" && !v.trim() || Array.isArray(v) && v.length === 0;
11394
+ var fieldLabel = ([id, f]) => `${f.name ?? id}(${id})`;
11395
+ function checkRequiredFields(t, issue) {
11396
+ if (!t.fields) return null;
11397
+ const required2 = Object.entries(t.fields).filter(([, f]) => f.required === true);
11398
+ return {
11399
+ checked: required2.map(fieldLabel),
11400
+ missing: required2.filter(([id]) => isEmptyValue(issue.fields[id])).map(fieldLabel)
11401
+ };
11402
+ }
11403
+ function renderVerifyComment(result, evidence, fp, reporter) {
11404
+ return [
11405
+ VERIFY_PLAN[result].header,
11406
+ `\u73AF\u5883\uFF1A${fp.text}${fp.source === "given" ? "\uFF08\u8C03\u7528\u65B9\u7ED9\u7684\uFF0C\u672A\u73B0\u67E5\uFF09" : ""}`,
11407
+ "\u9A8C\u6536\u8BF4\u660E\uFF1A",
11408
+ evidence.trim(),
11409
+ "",
11410
+ `_\u7531\u63D0\u5355\u4EBA ${reporter} \u7ECF \`hcm chiron gap verify\` \u63D0\u4EA4\u3002_`
11411
+ ].join("\n");
11412
+ }
11413
+ function notFixedNextStep(key2, status, result) {
11414
+ if (status === CLOSED_STATUS) {
11415
+ return `\u8FD9\u5355\u5DF2\u5173\u95ED\uFF0C\u4E0D\u80FD\u518D${result === "fail" ? "\u9000\u56DE" : "\u8BB0\u5F55\u90E8\u5206\u901A\u8FC7"}\u3002\u75C7\u72B6\u53C8\u51FA\u73B0\u5C31\u7528 \`hcm chiron gap submit\` \u91CD\u63D0\uFF0C\u73B0\u8C61\u91CC\u5199\u4E0A\u672C\u5355\u53F7 ${key2}\u3002`;
11416
+ }
11417
+ if (status === "\u4E0D\u5904\u7406" || status === "\u7EB3\u5165\u89C4\u5212" || status === "\u91CD\u590D\u95EE\u9898") {
11418
+ return `\u4EA7\u54C1\u4FA7\u5224\u4E86\u300C${status}\u300D\uFF0C\u6CA1\u6709\u4FEE\u590D\u53EF\u9A8C\u3002\u7406\u7531\u770B \`hcm chiron gap status ${key2}\`\uFF1B\u4E0D\u8BA4\u540C\u5C31\u5728 Jira \u90A3\u5355\u4E0B\u8BF4\u660E\u4E1A\u52A1\u5F71\u54CD\u3002`;
11419
+ }
11420
+ if (status === "\u8865\u5145\u8BF4\u660E") {
11421
+ return `\u7403\u5728\u4F60\u8FD9\u8FB9\uFF1A\u8FD9\u5355\u88AB\u6253\u56DE\u8865\u5145\u8BF4\u660E\uFF0C\u8FD8\u6CA1\u4FEE\u3002\u7167 \`hcm chiron gap status ${key2}\` \u7ED9\u7684\u4E0B\u4E00\u6B65\u8865\u4FE1\u606F\u3002`;
11422
+ }
11423
+ return `\u8FD9\u5355\u8FD8\u6CA1\u4FEE\u590D\uFF08${status ?? "?"}\uFF09\uFF0C\u6CA1\u6709\u4E1C\u897F\u53EF\u9A8C\u3002\u7EE7\u7EED\u7528\u66FF\u4EE3\u6CD5\uFF1B\u8FDB\u5C55\u770B \`hcm chiron gap status ${key2}\`\uFF0C\u7B49\u5B83\u5230\u300C${FIXED_STATUS}\u300D\u5E76\u90E8\u7F72\u5230\u4F60\u7684\u73AF\u5883\u540E\u518D\u9A8C\u3002`;
11424
+ }
11425
+ function doneNextStep(key2, outcome, found) {
11426
+ const link = found === false ? `\u8BC4\u8BBA\u94FE\u63A5\u6CA1\u53D6\u5230\uFF0C\u5148\u7528 \`hcm chiron gap comments ${key2}\` \u627E\u5230\u90A3\u6761\u518D\u5199\u8FDB\u62A5\u544A` : "\u9644\u4E0A\u9762\u7684\u8BC4\u8BBA\u94FE\u63A5";
11427
+ switch (outcome) {
11428
+ case "closed":
11429
+ return `\u5DF2\u5173\u5355\u3002\u62A5\u544A\u91CC\u5199\u300C\u5DF2\u9A8C\u6536\u5173\u95ED ${key2}\u300D\uFF0C${link}\u3002`;
11430
+ case "returned":
11431
+ return `\u5DF2\u9000\u56DE\uFF0C\u7403\u56DE\u5230\u4EA7\u54C1\u4FA7\uFF1A\u4EE3\u7801\u5E93\u6761\u76EE\u8981\u7531\u4EA7\u54C1\u4FA7\u91CD\u5F00\uFF08\u987E\u95EE\u4FA7\u6539\u4E0D\u4E86\uFF09\u3002\u4F60\u8FD9\u8FB9\u7EE7\u7EED\u7528\u66FF\u4EE3\u6CD5\u4EA4\u4ED8\uFF0C\u8FDB\u5C55\u770B \`hcm chiron gap status ${key2}\`\u3002`;
11432
+ case "recorded":
11433
+ return `\u5DF2\u8BB0\u5F55\u90E8\u5206\u901A\u8FC7\uFF0C\u5355\u5B50\u4ECD\u5728\u300C${FIXED_STATUS}\u300D\u3002\u9A8C\u8FC7\u7684\u90E8\u5206\u53EF\u4EE5\u7528\uFF0C\u6CA1\u9A8C\u5230\u7684\u7EE7\u7EED\u7528\u66FF\u4EE3\u6CD5\uFF1B\u5168\u90E8\u9A8C\u8FC7\u90FD\u901A\u8FC7\u518D\u8DD1 \`hcm chiron gap verify ${key2} --result pass\`\uFF0C\u9A8C\u51FA\u6CA1\u901A\u8FC7\u7684\u5C31\u7528 \`--result fail\`\u3002`;
11434
+ case "already-closed":
11435
+ return "\u8FD9\u5355\u5DF2\u7ECF\u662F CLOSE\uFF0C\u6CA1\u6709\u91CD\u590D\u5199\u3002";
11436
+ }
11437
+ }
11438
+ function rejectNextStep(status, key2) {
11439
+ if (status === 401) {
11440
+ return "\u4EE4\u724C\u65E0\u6548\u6216\u8FC7\u671F\uFF1A\u5728 Jira \u53F3\u4E0A\u89D2\u5934\u50CF \u2192 \u4E2A\u4EBA\u8BBE\u7F6E \u2192 Personal Access Tokens \u91CD\u5EFA\u4E00\u4E2A\uFF0C\u6309\u539F\u6765\u7684\u5B58\u6CD5\uFF08\u73AF\u5883\u53D8\u91CF / ~/.config/hcm/jira-token / \u94A5\u5319\u4E32\uFF09\u91CD\u65B0\u5B58\uFF0C\u518D\u91CD\u8DD1\u3002";
11441
+ }
11442
+ if (status === 403) return `\u4EE4\u724C\u6709\u6548\uFF0C\u4F46\u4F60\u7684\u8D26\u53F7\u6CA1\u6709 ${key2} \u7684\u8FD9\u6761\u6D41\u8F6C\u6216\u8BC4\u8BBA\u6743\u9650\uFF1A\u627E Jira \u7BA1\u7406\u5458\u5F00\u9879\u76EE\u6743\u9650\uFF0C\u522B\u6362\u522B\u4EBA\u7684\u4EE4\u724C\u3002`;
11443
+ if (status === 404) return `Jira \u8BF4\u627E\u4E0D\u5230 ${key2}\uFF08\u6216\u4F60\u770B\u4E0D\u5230\u5B83\uFF09\uFF1A\u6838\u5BF9\u5355\u53F7\uFF1B\u662F\u4F60\u81EA\u5DF1\u63D0\u7684\u5355\u5374\u770B\u4E0D\u5230\uFF0C\u627E Jira \u7BA1\u7406\u5458\u3002`;
11444
+ return "\u6309\u300C\u8BE6\u60C5\u300D\u91CC Jira \u7684\u539F\u8BDD\u5904\u7406\uFF1A\u591A\u534A\u662F\u6D41\u8F6C\u521A\u88AB\u6539\u8FC7\u6216\u754C\u9762\u5B57\u6BB5\u53D8\u4E86\uFF0C\u628A\u8FD9\u6BB5\u8F93\u51FA\u53D1\u7ED9\u4EA7\u54C1\u4FA7\u5206\u8BCA\u4EBA\uFF1B\u522B\u6539\u95EE\u9898\u7C7B\u578B\uFF0C\u4E5F\u522B\u81EA\u5DF1\u62FC HTTP \u7ED5\u8FC7\u3002";
11445
+ }
11446
+ function unconfirmedWhy(e) {
11447
+ if (e instanceof JiraHttpError) return `Jira ${e.status}`;
11448
+ if (e instanceof SyntaxError) return "Jira \u56DE\u4E86 2xx \u4F46\u5E94\u7B54\u8BFB\u4E0D\u61C2\uFF0C\u591A\u534A\u5DF2\u5199\u5165";
11449
+ const name = e instanceof Error ? e.name : typeof e;
11450
+ if (name === "TimeoutError" || name === "AbortError") return "\u8D85\u65F6";
11451
+ if (e instanceof TypeError) return "\u8FDE\u63A5\u5931\u8D25";
11452
+ return name;
11453
+ }
11454
+ function writeFailure(e, key2, what) {
11455
+ if (e instanceof JiraHttpError && e.status >= 400 && e.status < 500) {
11456
+ return verifyFailure("write-rejected", CliErrorCode24.BUSINESS_RULE_VIOLATION, "no", `Jira \u4EE5 ${e.status} \u62D2\u7EDD\u4E86\u8FD9\u6B21${what}`, rejectNextStep(e.status, key2), {
11457
+ key: key2,
11458
+ status: e.status,
11459
+ details: e.message
11460
+ });
11461
+ }
11462
+ return verifyFailure(
11463
+ "write-unconfirmed",
11464
+ CliErrorCode24.NETWORK_ERROR,
11465
+ "unknown",
11466
+ `${what}\u8BF7\u6C42\u6CA1\u5F97\u5230\u786E\u8BA4\uFF08${unconfirmedWhy(e)}\uFF09`,
11467
+ `\u5148\u7528 \`hcm chiron gap status ${key2}\` \u4E0E \`hcm chiron gap comments ${key2}\` \u6838\u5BF9\u5199\u8FDB\u53BB\u6CA1\u6709\uFF0C\u518D\u51B3\u5B9A\u8981\u4E0D\u8981\u91CD\u8DD1\u2014\u2014partial \u91CD\u8DD1\u4F1A\u591A\u4E00\u6761\u8BC4\u8BBA\u3002`,
11468
+ { key: key2, ...e instanceof JiraHttpError ? { status: e.status } : {} },
11469
+ e
11470
+ );
11471
+ }
11472
+ async function claimTransitionComment(client3, key2, me, header, body, beforeIds) {
11473
+ try {
11474
+ const hit = (await client3.comments(key2)).filter((c) => !beforeIds.has(c.id) && sameUser(c.author, me) && firstLine2(c.body ?? "") === header).at(-1);
11475
+ return hit?.id ? { body, found: true, id: hit.id, url: client3.commentUrl(key2, hit.id) } : { body, found: false, note: `\u6D41\u8F6C\u5DF2\u63D0\u4EA4\uFF0C\u4F46\u56DE\u8BFB\u8BC4\u8BBA\u6CA1\u8BA4\u9886\u5230\u8FD9\u4E00\u6761\uFF08\u63A5\u53E3\u4E0D\u56DE\u8BC4\u8BBA id\uFF09\uFF1B\u4EE5 \`hcm chiron gap comments ${key2}\` \u4E3A\u51C6\u3002` };
11476
+ } catch (e) {
11477
+ const why = e instanceof Error ? e.message.split("\n")[0] : String(e);
11478
+ return { body, found: false, note: `\u6D41\u8F6C\u5DF2\u63D0\u4EA4\uFF0C\u4F46\u56DE\u8BFB\u8BC4\u8BBA\u5931\u8D25\uFF08${why}\uFF09\uFF1B\u4EE5 \`hcm chiron gap comments ${key2}\` \u4E3A\u51C6\u3002` };
11479
+ }
11480
+ }
11481
+ var snapshotOf = (i) => ({ status: i.fields.status?.name, resolution: i.fields.resolution?.name ?? null });
11482
+ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLUG3) {
11483
+ const parsed = parseRef2(ref, client3.project, casesSlug);
11484
+ if (!parsed || parsed.kind !== "jira") {
11485
+ throw verifyFailure(
11486
+ "not-jira-key",
11487
+ CliErrorCode24.INVALID_ARGUMENT,
11488
+ "no",
11489
+ parsed && parsed.kind === "repo" ? `${parsed.repo}#${parsed.number} \u662F\u4EA7\u54C1\u4ED3\u7F16\u53F7\uFF0C\u9A8C\u6536\u8981\u843D\u5728 Jira \u5355\u4E0A` : `\u770B\u4E0D\u61C2 ${ref}`,
11490
+ "\u7ED9 Jira \u5355\u53F7\uFF08HCMNX-12 \u6216\u88F8\u6570\u5B57 12\uFF09\u2014\u2014\u5C31\u662F `hcm chiron gap submit` \u56DE\u6267\u91CC\u7684\u90A3\u4E2A\u7F16\u53F7\u3002"
11491
+ );
11492
+ }
11493
+ const key2 = parsed.key;
11494
+ const inProject = (k) => k.startsWith(`${client3.project}-`);
11495
+ const wrongProject = (k) => verifyFailure(
11496
+ "wrong-project",
11497
+ CliErrorCode24.INVALID_ARGUMENT,
11498
+ "no",
11499
+ `${k} \u4E0D\u5728 ${client3.project} \u9879\u76EE\u91CC\uFF0C\u9A8C\u6536\u53EA\u5199 ${client3.project} \u7684\u5355`,
11500
+ `\u7ED9 ${client3.project} \u7684\u5355\u53F7\uFF08\`hcm chiron gap submit\` \u56DE\u6267\u91CC\u7684\u90A3\u4E2A\uFF09\u3002\u522B\u7684\u9879\u76EE\u7684\u5355\u8FD9\u6761\u547D\u4EE4\u4E0D\u78B0\u2014\u2014\u90A3\u91CC\u7684\u72B6\u6001\u540D\u4E0E\u6D41\u8F6C\u540D\u548C ${client3.project} \u540C\u5F62\uFF0C\u5199\u9519\u4E86\u4F1A\u628A\u522B\u5904\u7684\u5355\u5173\u6389\u3002`,
11501
+ { key: k, project: client3.project }
11502
+ );
11503
+ if (!inProject(key2)) throw wrongProject(key2);
11504
+ const evidence = o.evidence.trim();
11505
+ if (evidence.length < EVIDENCE_MIN) {
11506
+ throw verifyFailure(
11507
+ "evidence-too-short",
11508
+ CliErrorCode24.INVALID_ARGUMENT,
11509
+ "no",
11510
+ `\u9A8C\u6536\u8BC1\u636E\u81F3\u5C11 ${EVIDENCE_MIN} \u4E2A\u5B57\uFF0C\u7ED9\u7684\u662F ${evidence.length} \u4E2A\u5B57`,
11511
+ "\u5199\u6E05\uFF1A\u54EA\u4E2A\u73AF\u5883\u3001\u54EA\u4E2A\u7248\u672C\uFF08`hcm version`\uFF09\u3001\u6309\u6280\u80FD\u8DD1\u4E86\u4EC0\u4E48\u3001\u770B\u5230\u4E86\u4EC0\u4E48\uFF1B\u8BC1\u636E\u6587\u4EF6\u653E\u5728 evidence/ \u4E0B\u5E76\u5199\u4E0A\u8DEF\u5F84\u3002",
11512
+ { key: key2 }
11513
+ );
11514
+ }
11515
+ const [issue, me] = await Promise.all([client3.issue(key2), client3.myself()]);
11516
+ if (!inProject(issue.key)) throw wrongProject(issue.key);
11517
+ const before = snapshotOf(issue);
11518
+ const status = before.status;
11519
+ const reporter = issue.fields.reporter;
11520
+ const base = {
11521
+ key: key2,
11522
+ url: client3.browseUrl(key2),
11523
+ summary: issue.fields.summary ?? "",
11524
+ result: o.result,
11525
+ reporter: who(reporter),
11526
+ me: who(me),
11527
+ before,
11528
+ dryRun: o.dryRun === true,
11529
+ fingerprint: o.fingerprint
11530
+ };
11531
+ if (!sameUser(reporter, me)) {
11532
+ throw verifyFailure(
11533
+ "not-reporter",
11534
+ CliErrorCode24.BUSINESS_RULE_VIOLATION,
11535
+ "no",
11536
+ `\u53EA\u6709\u63D0\u5355\u4EBA\u80FD\u9A8C\u6536 ${key2}\uFF1A\u63D0\u5355\u4EBA\u662F ${who(reporter)}\uFF0C\u5F53\u524D\u8EAB\u4EFD\u662F ${who(me)}`,
11537
+ "\u8BF7\u63D0\u5355\u4EBA\u590D\u9A8C\u540E\u81EA\u5DF1\u8DD1\u8FD9\u6761\u547D\u4EE4\u3002\u4F60\u624B\u4E0A\u7684\u65B0\u73B0\u573A\u7528 `hcm chiron gap submit` \u8FFD\u52A0\uFF1B\u7ECF\u529E\u4EBA\u3001\u641C\u7D22\u547D\u4E2D\u3001\u5728\u522B\u4EBA\u7684\u5355\u4E0B\u8FFD\u52A0\u8FC7\u73B0\u573A\u90FD\u4E0D\u6784\u6210\u9A8C\u6536\u8D44\u683C\u3002",
11538
+ { key: key2, status, reporter: reporter?.key ?? reporter?.name ?? null, me: me.key ?? me.name ?? null }
11539
+ );
11540
+ }
11541
+ if (o.result === "pass" && status === CLOSED_STATUS) {
11542
+ const nextStep = before.resolution ? doneNextStep(key2, "already-closed", void 0) : `\u8FD9\u5355\u662F\u6CA1\u4FEE\u5C31\u5173\u7684\uFF08CLOSE \u4F46\u6CA1\u6709 resolution\uFF0C\u591A\u534A\u8D70\u7684\u300C\u4E0D\u5904\u7406 \u2192 \u786E\u8BA4\u5173\u95ED\u300D\uFF09\uFF0C\u4F60\u7684\u590D\u9A8C\u7ED3\u8BBA\u6CA1\u5199\u8FDB\u53BB\u3002\u75C7\u72B6\u8FD8\u5728\u5C31\u7528 \`hcm chiron gap submit\` \u91CD\u63D0\uFF0C\u73B0\u8C61\u91CC\u5199\u4E0A\u672C\u5355\u53F7 ${key2}\u3002`;
11543
+ return { ...base, outcome: "already-closed", written: "no", requiredFields: "not-applicable", nextStep };
11544
+ }
11545
+ if (status !== FIXED_STATUS) {
11546
+ throw verifyFailure(
11547
+ "status-not-fixed",
11548
+ CliErrorCode24.BUSINESS_RULE_VIOLATION,
11549
+ "no",
11550
+ `${key2} \u7684\u72B6\u6001\u662F\u300C${status ?? "?"}\u300D\uFF0C\u9A8C\u6536\u53EA\u5728\u300C${FIXED_STATUS}\u300D\u4E0A\u505A`,
11551
+ notFixedNextStep(key2, status, o.result),
11552
+ { key: key2, status }
11553
+ );
11554
+ }
11555
+ const plan = VERIFY_PLAN[o.result];
11556
+ let transition;
11557
+ let requiredFields = "not-applicable";
11558
+ let requiredChecked;
11559
+ if (plan.transition) {
11560
+ const want = plan.transition;
11561
+ const list = await client3.transitions(key2);
11562
+ transition = list.find((t) => t.name === want.name && t.to?.name === want.to);
11563
+ if (!transition) {
11564
+ const available = list.map((t) => `${t.name}\u2192${t.to?.name ?? "?"}`);
11565
+ throw verifyFailure(
11566
+ "transition-unavailable",
11567
+ CliErrorCode24.BUSINESS_RULE_VIOLATION,
11568
+ "no",
11569
+ `${key2} \u4E0A\u670D\u52A1\u7AEF\u6B64\u523B\u4E0D\u7ED9\u300C${want.name}\u2192${want.to}\u300D\u8FD9\u6761\u6D41\u8F6C\uFF08\u53EF\u7528\uFF1A${available.join(" / ") || "\uFF08\u65E0\uFF09"}\uFF09`,
11570
+ "\u591A\u534A\u662F\u5DE5\u4F5C\u6D41\u88AB\u6539\u8FC7\uFF0C\u6216\u4F60\u7684\u8D26\u53F7\u5728\u8FD9\u4E2A\u9879\u76EE\u4E0A\u6CA1\u6709\u8FD9\u6761\u6D41\u8F6C\u7684\u6743\u9650\u3002\u628A\u8FD9\u6BB5\u8F93\u51FA\u53D1\u7ED9\u4EA7\u54C1\u4FA7\u5206\u8BCA\u4EBA\uFF1B\u522B\u81EA\u5DF1\u62FC HTTP\uFF0C\u4E5F\u522B\u6539\u95EE\u9898\u7C7B\u578B\u7ED5\u8FC7\u3002",
11571
+ { key: key2, status, available }
11572
+ );
11573
+ }
11574
+ const req = checkRequiredFields(transition, issue);
11575
+ if (!req) requiredFields = "no-metadata";
11576
+ else if (req.missing.length) {
11577
+ throw verifyFailure(
11578
+ "required-fields-missing",
11579
+ CliErrorCode24.BUSINESS_RULE_VIOLATION,
11580
+ "no",
11581
+ `\u300C${transition.name}\u300D\u8981\u6C42\u8FD9\u4E9B\u5B57\u6BB5\u6709\u503C\uFF0C${key2} \u4E0A\u662F\u7A7A\u7684\uFF1A${req.missing.join("\u3001")}`,
11582
+ "\u8FD9\u4E9B\u5B57\u6BB5\u7531\u4EA7\u54C1\u4FA7\u7EF4\u62A4\uFF0C\u8BF7\u5206\u8BCA\u4EBA\u8865\u9F50\u540E\u518D\u8DD1\uFF1BCLI \u4E0D\u4EE3\u586B\uFF0C\u4E5F\u522B\u628A\u7ECF\u529E\u4EBA\u6216\u4FEE\u590D\u4EBA\u731C\u6210 Bug\u5F15\u5165\u4EBA\u3002",
11583
+ { key: key2, status, missing: req.missing, checked: req.checked }
11584
+ );
11585
+ } else {
11586
+ requiredFields = "checked";
11587
+ requiredChecked = req.checked;
11588
+ }
11589
+ }
11590
+ const body = renderVerifyComment(o.result, evidence, o.fingerprint, who(reporter));
11591
+ const move = transition ? { id: transition.id, name: transition.name, to: transition.to?.name } : void 0;
11592
+ if (o.dryRun) {
11593
+ return {
11594
+ ...base,
11595
+ outcome: "planned",
11596
+ planned: plan.outcome,
11597
+ written: "no",
11598
+ transition: move,
11599
+ comment: { body },
11600
+ requiredFields,
11601
+ requiredChecked,
11602
+ nextStep: "\u8BA1\u5212\u5982\u4E0A\uFF0C\u6CA1\u6709\u5199 Jira\u3002\u53BB\u6389 --dry-run \u6267\u884C\u3002"
11603
+ };
11604
+ }
11605
+ if (transition) {
11606
+ const what = `\u6D41\u8F6C\u300C${transition.name}\u300D\u4E0E\u8BC4\u8BBA`;
11607
+ const beforeIds = new Set((await client3.comments(key2)).map((c) => c.id));
11608
+ try {
11609
+ await client3.transitionById(key2, transition.id, body);
11610
+ } catch (e) {
11611
+ throw writeFailure(e, key2, what);
11612
+ }
11613
+ const comment2 = await claimTransitionComment(client3, key2, me, plan.header, body, beforeIds);
11614
+ let after2;
11615
+ try {
11616
+ after2 = snapshotOf(await client3.issue(key2, ["status", "resolution"]));
11617
+ } catch (e) {
11618
+ throw verifyFailure(
11619
+ "readback-failed",
11620
+ CliErrorCode24.NETWORK_ERROR,
11621
+ "yes",
11622
+ `${what}\u5DF2\u88AB Jira \u63A5\u53D7\uFF0C\u4F46\u56DE\u8BFB ${key2} \u5931\u8D25\uFF0C\u843D\u5230\u4EC0\u4E48\u72B6\u6001\u6CA1\u786E\u8BA4`,
11623
+ `\u7528 \`hcm chiron gap status ${key2}\` \u770B\u7ED3\u679C\uFF1B\u522B\u76F4\u63A5\u91CD\u8DD1\uFF08\u4F1A\u518D\u5199\u4E00\u6761\u8BC4\u8BBA\uFF09\u3002`,
11624
+ { key: key2, comment: comment2.id ?? null },
11625
+ e
11626
+ );
11627
+ }
11628
+ const expected = transition.to?.name ?? "?";
11629
+ const resolutionStuck = o.result === "fail" && !!after2.resolution;
11630
+ if (after2.status !== expected || resolutionStuck) {
11631
+ const did = plan.outcome === "closed" ? "\u5173\u5355" : "\u9000\u56DE";
11632
+ throw verifyFailure(
11633
+ "readback-mismatch",
11634
+ CliErrorCode24.SERVER_ERROR,
11635
+ "yes",
11636
+ after2.status !== expected ? `${what}\u5DF2\u88AB Jira \u63A5\u53D7\uFF0C\u4F46\u56DE\u8BFB ${key2} \u7684\u72B6\u6001\u662F\u300C${after2.status ?? "?"}\u300D\uFF0C\u9884\u671F\u300C${expected}\u300D` : `${what}\u5DF2\u88AB Jira \u63A5\u53D7\uFF0C${key2} \u56DE\u5230\u4E86\u300C${expected}\u300D\uFF0C\u4F46 resolution \u8FD8\u662F\u300C${after2.resolution}\u300D\u2014\u2014\u5B83\u4F1A\u4ECE\u300C\u672A\u89E3\u51B3\u300D\u7684\u67E5\u8BE2\u91CC\u6D88\u5931`,
11637
+ after2.status !== expected ? `\u4EE5 \`hcm chiron gap status ${key2}\` \u4E3A\u51C6\uFF0C\u522B\u5F53\u6210\u5DF2\u7ECF${did}\uFF1B\u628A\u8FD9\u6BB5\u8F93\u51FA\u53D1\u7ED9\u4EA7\u54C1\u4FA7\u5206\u8BCA\u4EBA\u3002` : "\u8BF7\u4EA7\u54C1\u4FA7\u5206\u8BCA\u4EBA\u6E05\u6389\u8FD9\u5355\u7684 resolution\uFF08\u300C\u672A\u89E3\u51B3\u300D\u8FD9\u6761\u6D41\u8F6C\u672C\u6765\u4F1A\u6E05\uFF0C\u6CA1\u6E05\u8BF4\u660E\u5DE5\u4F5C\u6D41\u88AB\u6539\u8FC7\uFF09\uFF1B\u628A\u8FD9\u6BB5\u8F93\u51FA\u53D1\u7ED9\u4ED6\u3002",
11638
+ { key: key2, before, after: after2, expected, comment: comment2.id ?? null }
11639
+ );
11640
+ }
11641
+ return {
11642
+ ...base,
11643
+ outcome: plan.outcome,
11644
+ written: "yes",
11645
+ after: after2,
11646
+ transition: move,
11647
+ comment: comment2,
11648
+ requiredFields,
11649
+ requiredChecked,
11650
+ nextStep: doneNextStep(key2, plan.outcome, comment2.found)
11651
+ };
11652
+ }
11653
+ let written;
11654
+ try {
11655
+ written = await client3.addComment(key2, body);
11656
+ } catch (e) {
11657
+ throw writeFailure(e, key2, "\u8BC4\u8BBA");
11658
+ }
11659
+ let listed;
11660
+ try {
11661
+ listed = await client3.comments(key2);
11662
+ } catch (e) {
11663
+ throw verifyFailure(
11664
+ "readback-failed",
11665
+ CliErrorCode24.NETWORK_ERROR,
11666
+ "yes",
11667
+ `\u8BC4\u8BBA\u5DF2\u88AB Jira \u63A5\u53D7\uFF0C\u4F46\u56DE\u8BFB ${key2} \u7684\u8BC4\u8BBA\u5931\u8D25\uFF0C\u6CA1\u786E\u8BA4\u5B83\u5728`,
11668
+ `\u7528 \`hcm chiron gap comments ${key2}\` \u770B\u5B83\u5728\u4E0D\u5728\uFF1B\u522B\u76F4\u63A5\u91CD\u8DD1\uFF08\u4F1A\u518D\u5199\u4E00\u6761\uFF09\u3002`,
11669
+ { key: key2, comment: written.id ?? null },
11670
+ e
11671
+ );
11672
+ }
11673
+ let comment;
11674
+ if (!written.id) {
11675
+ comment = { body, found: false, note: `Jira \u6CA1\u56DE\u8BC4\u8BBA id\uFF0C\u6CA1\u6CD5\u6309 id \u6838\u5BF9\uFF1B\u4EE5 \`hcm chiron gap comments ${key2}\` \u4E3A\u51C6\u3002` };
11676
+ } else if (!listed.some((c) => c.id === written.id)) {
11677
+ throw verifyFailure(
11678
+ "readback-mismatch",
11679
+ CliErrorCode24.SERVER_ERROR,
11680
+ "yes",
11681
+ `Jira \u56DE\u4E86\u8BC4\u8BBA ${written.id}\uFF0C\u4F46\u56DE\u8BFB ${key2} \u7684\u8BC4\u8BBA\u91CC\u6CA1\u6709\u5B83`,
11682
+ `\u7528 \`hcm chiron gap comments ${key2}\` \u6838\u5BF9\uFF1B\u522B\u76F4\u63A5\u91CD\u8DD1\uFF0C\u628A\u8FD9\u6BB5\u8F93\u51FA\u53D1\u7ED9\u4EA7\u54C1\u4FA7\u5206\u8BCA\u4EBA\u3002`,
11683
+ { key: key2, comment: written.id }
11684
+ );
11685
+ } else {
11686
+ comment = { body, found: true, id: written.id, url: client3.commentUrl(key2, written.id) };
11687
+ }
11688
+ let after;
11689
+ let aside = "";
11690
+ try {
11691
+ after = snapshotOf(await client3.issue(key2, ["status", "resolution"]));
11692
+ if (after.status !== FIXED_STATUS) aside = `\uFF08\u56DE\u8BFB\u65F6\u5355\u5B50\u5DF2\u662F\u300C${after.status ?? "?"}\u300D\u2014\u2014\u8BC4\u8BBA\u5199\u8FDB\u53BB\u4E4B\u540E\u6709\u4EBA\u52A8\u8FC7\u5B83\uFF0C\u4EE5 \`hcm chiron gap status ${key2}\` \u4E3A\u51C6\u3002\uFF09`;
11693
+ } catch (e) {
11694
+ const why = e instanceof Error ? e.message.split("\n")[0] : String(e);
11695
+ aside = `\uFF08\u56DE\u8BFB\u5355\u5B50\u72B6\u6001\u5931\u8D25\uFF1A${why}\uFF1B\u8BC4\u8BBA\u5DF2\u6838\u5728\u3002\uFF09`;
11696
+ }
11697
+ return {
11698
+ ...base,
11699
+ outcome: "recorded",
11700
+ written: "yes",
11701
+ after,
11702
+ comment,
11703
+ requiredFields,
11704
+ requiredChecked,
11705
+ nextStep: `${doneNextStep(key2, "recorded", comment.found)}${aside}`
11706
+ };
11707
+ }
11708
+
11344
11709
  // src/commands/gap.ts
11345
11710
  var defaultDeps = { client: () => createJiraClient() };
11346
11711
  async function gapDeps(deps) {
@@ -11404,23 +11769,31 @@ async function gapCommentsCommand(ref, args, deps = defaultDeps) {
11404
11769
  emit5(args.output, r, () => renderGapComments(r));
11405
11770
  });
11406
11771
  }
11407
- async function fingerprintText(env2) {
11772
+ function backendFingerprint2(info, cliVersion, envName) {
11773
+ const commit = info.commit ?? info.gitCommit ?? null;
11774
+ const backend = commit ? String(commit).slice(0, 12) : `\u672A\u56DE commit\uFF08version=${info.version ?? "?"}\uFF09`;
11775
+ return { text: `backend ${backend} \xB7 CLI ${cliVersion} \xB7 env ${envName}`, commit: commit ? String(commit) : null };
11776
+ }
11777
+ async function fingerprintInfo(env2) {
11408
11778
  try {
11409
11779
  const g = await loadGlobalConfig10();
11410
11780
  const resolved = await resolveEnvContext7({ envFlag: env2 }, process.env, g);
11411
11781
  printResolvedEnvironment7(resolved);
11412
11782
  const { name, config: cfg } = resolved;
11413
- if (!cfg?.endpoint) return `\u672A\u53D6\u5230\u6307\u7EB9\uFF08env=${name}\uFF1A\u6CA1\u6709 endpoint\uFF09`;
11783
+ if (!cfg?.endpoint) return { text: `\u672A\u53D6\u5230\u6307\u7EB9\uFF08env=${name}\uFF1A\u6CA1\u6709 endpoint\uFF09`, source: "unavailable" };
11414
11784
  const http = createHttpClient4({ endpoint: cfg.endpoint.replace(/\/+$/, ""), getAccessToken: async () => null, onRefresh: async () => {
11415
11785
  } });
11416
11786
  const resp = await http.get("/api/version/backend");
11417
11787
  const info = resp.data?.data ?? resp.data ?? {};
11418
- const commit = info.commit ?? info.gitCommit ?? info.version ?? "?";
11419
- return `backend ${String(commit).slice(0, 12)} \xB7 CLI ${CLI_VERSION} \xB7 env ${name}`;
11788
+ const fp = backendFingerprint2(info, CLI_VERSION, name);
11789
+ return { text: fp.text, source: "measured", commit: fp.commit };
11420
11790
  } catch (e) {
11421
- return `\u672A\u53D6\u5230\u6307\u7EB9\uFF08env=${env2 ?? "\u672A\u8BBE"}\uFF1B${String(e.message ?? e).split("\n")[0]?.slice(0, 120)}\uFF09`;
11791
+ return { text: `\u672A\u53D6\u5230\u6307\u7EB9\uFF08env=${env2 ?? "\u672A\u8BBE"}\uFF1B${String(e.message ?? e).split("\n")[0]?.slice(0, 120)}\uFF09`, source: "unavailable" };
11422
11792
  }
11423
11793
  }
11794
+ async function fingerprintText(env2) {
11795
+ return (await fingerprintInfo(env2)).text;
11796
+ }
11424
11797
  async function gapSubmitCommand(args, deps = defaultDeps) {
11425
11798
  await run2(async () => {
11426
11799
  const raw = args.file ? readFileSync6(args.file, "utf8") : process.stdin.isTTY ? "" : readFileSync6(0, "utf8");
@@ -11438,6 +11811,86 @@ ${r.url}
11438
11811
  );
11439
11812
  });
11440
11813
  }
11814
+ function readEvidence(opts, stdinIsTTY = !!process.stdin.isTTY, readStdin2 = () => readFileSync6(0, "utf8")) {
11815
+ if (opts.file !== void 0 && opts.body !== void 0) {
11816
+ throw verifyFailure(
11817
+ "evidence-ambiguous",
11818
+ CliErrorCode25.INVALID_ARGUMENT,
11819
+ "no",
11820
+ "--body \u4E0E --file \u540C\u65F6\u7ED9\u4E86\uFF0C\u4E0D\u77E5\u9053\u8BE5\u7528\u54EA\u4EFD\u505A\u9A8C\u6536\u8BC1\u636E",
11821
+ "\u53EA\u7559\u4E00\u4E2A\uFF1A\u77ED\u8BC1\u636E\u7528 --body\uFF0C\u957F\u8BC1\u636E\u5199\u8FDB\u6587\u4EF6\u7528 --file\u3002"
11822
+ );
11823
+ }
11824
+ if (opts.file !== void 0) {
11825
+ try {
11826
+ return readFileSync6(opts.file, "utf8");
11827
+ } catch (e) {
11828
+ throw verifyFailure(
11829
+ "evidence-unreadable",
11830
+ CliErrorCode25.INVALID_ARGUMENT,
11831
+ "no",
11832
+ `\u8BFB\u4E0D\u5230\u8BC1\u636E\u6587\u4EF6 ${opts.file}`,
11833
+ "\u6838\u5BF9\u8DEF\u5F84\u4E0E\u6743\u9650\uFF1B\u8BC1\u636E\u6587\u4EF6\u4E00\u822C\u653E\u5728\u9879\u76EE\u4ED3\u7684 evidence/ \u4E0B\u3002",
11834
+ { file: opts.file },
11835
+ e
11836
+ );
11837
+ }
11838
+ }
11839
+ if (opts.body !== void 0) return opts.body;
11840
+ if (stdinIsTTY) {
11841
+ throw verifyFailure(
11842
+ "evidence-missing",
11843
+ CliErrorCode25.INVALID_ARGUMENT,
11844
+ "no",
11845
+ "\u6CA1\u7ED9\u9A8C\u6536\u8BC1\u636E",
11846
+ "\u7528 --body <\u6587\u672C> \u6216 --file <\u6587\u4EF6> \u7ED9\u51FA\uFF1A\u54EA\u4E2A\u73AF\u5883\u3001\u54EA\u4E2A\u7248\u672C\u3001\u6309\u6280\u80FD\u8DD1\u4E86\u4EC0\u4E48\u3001\u770B\u5230\u4E86\u4EC0\u4E48\u3002"
11847
+ );
11848
+ }
11849
+ return readStdin2();
11850
+ }
11851
+ var VERIFY_OUTCOME_TEXT = {
11852
+ closed: "\u5DF2\u9A8C\u6536\u5173\u5355",
11853
+ returned: "\u5DF2\u9000\u56DE\u4EA7\u54C1\u4FA7",
11854
+ recorded: "\u5DF2\u8BB0\u5F55\u90E8\u5206\u901A\u8FC7\uFF08\u4E0D\u5173\u5355\uFF09",
11855
+ "already-closed": "\u8FD9\u5355\u5DF2\u662F CLOSE\uFF0C\u6CA1\u6709\u91CD\u590D\u5199"
11856
+ };
11857
+ var FINGERPRINT_SOURCE_TEXT = {
11858
+ measured: "\u73B0\u67E5",
11859
+ given: "\u8C03\u7528\u65B9\u7ED9\u7684\uFF0C\u672A\u73B0\u67E5",
11860
+ unavailable: "\u6CA1\u53D6\u5230"
11861
+ };
11862
+ function renderGapVerify(r) {
11863
+ const lines = [];
11864
+ if (r.outcome === "planned") lines.push(`[dry-run] \u6CA1\u6709\u5199 Jira\u3002\u8BA1\u5212\uFF1A${r.planned ? VERIFY_OUTCOME_TEXT[r.planned] : "?"}`);
11865
+ else lines.push(VERIFY_OUTCOME_TEXT[r.outcome]);
11866
+ lines.push(`Jira ${r.key} ${r.summary}`, ` ${r.url}`, ` \u63D0\u5355\u4EBA ${r.reporter} \xB7 \u5F53\u524D\u8EAB\u4EFD ${r.me}`);
11867
+ if (r.outcome !== "already-closed") {
11868
+ const to = r.after?.status ?? r.transition?.to ?? r.before.status;
11869
+ const move = r.transition ? `\u6D41\u8F6C\u300C${r.transition.name}\u300D` : "\u4E0D\u6D41\u8F6C";
11870
+ lines.push(` \u7ED3\u8BBA ${r.result}\uFF1A${r.before.status ?? "?"} \u2192 ${to ?? "?"}\uFF08${move}${r.outcome === "planned" ? "\uFF0C\u672A\u6267\u884C" : ""}\uFF09`);
11871
+ const noCommit = r.fingerprint.source === "measured" && r.fingerprint.commit === null ? "\uFF0C\u540E\u7AEF\u6CA1\u56DE commit" : "";
11872
+ lines.push(` \u73AF\u5883\u6307\u7EB9\uFF08${FINGERPRINT_SOURCE_TEXT[r.fingerprint.source]}${noCommit}\uFF09\uFF1A${r.fingerprint.text}`);
11873
+ }
11874
+ if (r.requiredFields === "checked") {
11875
+ const list = r.requiredChecked ?? [];
11876
+ lines.push(` \u5FC5\u586B\u9879\u5DF2\u6838\uFF1A${list.length ? list.join("\u3001") : "\u8FD9\u6761\u6D41\u8F6C\u7684\u754C\u9762\u4E0A\u6CA1\u6709\u5FC5\u586B\u9879"}`);
11877
+ }
11878
+ if (r.requiredFields === "no-metadata") lines.push(" \u26A0\uFE0F \u670D\u52A1\u7AEF\u6CA1\u56DE\u8FD9\u6761\u6D41\u8F6C\u7684\u5B57\u6BB5\u5143\u6570\u636E\uFF0C\u5FC5\u586B\u9879\u6CA1\u6838\uFF08Jira \u63D0\u4EA4\u65F6\u4ECD\u4F1A\u81EA\u5DF1\u6821\u9A8C\uFF09");
11879
+ if (r.comment?.id) lines.push(` \u8BC4\u8BBA ${r.comment.id}`, ` ${r.comment.url}`);
11880
+ else if (r.comment?.note) lines.push(` \u26A0\uFE0F ${r.comment.note}`);
11881
+ if (r.outcome === "planned" && r.comment) lines.push(" \u5C06\u5199\u5165\u7684\u8BC4\u8BBA\uFF1A", ...r.comment.body.split("\n").map((l) => ` ${l}`));
11882
+ lines.push(`\u4E0B\u4E00\u6B65\uFF1A${r.nextStep}`);
11883
+ return lines.join("\n");
11884
+ }
11885
+ async function gapVerifyCommand(ref, args, deps = defaultDeps) {
11886
+ await run2(async () => {
11887
+ const result = parseVerifyResult(args.result);
11888
+ const evidence = readEvidence({ file: args.file, body: args.body });
11889
+ const fingerprint = args.fingerprint !== void 0 ? { text: args.fingerprint, source: "given" } : await fingerprintInfo(args.env);
11890
+ const r = await gapVerify(await gapDeps(deps), ref, { result, evidence, fingerprint, dryRun: args.dryRun === true });
11891
+ emit5(args.output, r, () => renderGapVerify(r));
11892
+ });
11893
+ }
11441
11894
 
11442
11895
  // src/commands/chiron-doctor.ts
11443
11896
  init_auth_guard();
@@ -11446,7 +11899,7 @@ import { promises as fs10 } from "fs";
11446
11899
  import path11 from "path";
11447
11900
  import {
11448
11901
  HcmClient as HcmClient22,
11449
- CliError as CliError25,
11902
+ CliError as CliError26,
11450
11903
  fetchReconIdentity as fetchReconIdentity2,
11451
11904
  formatObject as formatObject25,
11452
11905
  httpProbe as httpProbe2,
@@ -11525,8 +11978,8 @@ async function runChironDoctor(args, deps = defaultDeps2) {
11525
11978
  const tenantMismatch = tokenTenant2 && tokenTenant2 !== env3.tenant;
11526
11979
  const bad = anchors.checks.filter((c) => !c.ok && !(tenantMismatch && c.anchor === "identity"));
11527
11980
  if (bad.length === 0 && !tenantMismatch) {
11528
- const who = found.config.defaultIdentity ? ` \xB7 ${found.config.defaultIdentity}` : "";
11529
- report.lines.push({ item: "\u767B\u5F55", verdict: "ok", detail: `${label} \xB7 \u672C\u673A\u69FD ${found.name} \xB7 ${env3.endpoint} \xB7 \u79DF\u6237 ${env3.tenant}${who}` });
11981
+ const who2 = found.config.defaultIdentity ? ` \xB7 ${found.config.defaultIdentity}` : "";
11982
+ report.lines.push({ item: "\u767B\u5F55", verdict: "ok", detail: `${label} \xB7 \u672C\u673A\u69FD ${found.name} \xB7 ${env3.endpoint} \xB7 \u79DF\u6237 ${env3.tenant}${who2}` });
11530
11983
  } else {
11531
11984
  const parts = [`${label} \xB7 \u672C\u673A\u69FD ${found.name} \xB7 ${env3.endpoint}`];
11532
11985
  if (tenantMismatch) parts.push(`\u4F60\u7684\u767B\u5F55\u8EAB\u4EFD\u5C5E\u4E8E\u79DF\u6237 ${tokenTenant2}\uFF0C\u9879\u76EE\u662F\u79DF\u6237 ${env3.tenant}`);
@@ -11539,7 +11992,7 @@ async function runChironDoctor(args, deps = defaultDeps2) {
11539
11992
  });
11540
11993
  }
11541
11994
  } catch (e) {
11542
- const msg = e instanceof CliError25 ? e.message : e.message;
11995
+ const msg = e instanceof CliError26 ? e.message : e.message;
11543
11996
  report.lines.push({ item: "\u767B\u5F55", verdict: severity(), detail: `${label} \xB7 \u672C\u673A\u69FD ${found.name} \xB7 ${env3.endpoint}\uFF1A${msg}`, nextStep: loginCmd });
11544
11997
  }
11545
11998
  }
@@ -11628,8 +12081,8 @@ import path12 from "path";
11628
12081
  import yaml from "js-yaml";
11629
12082
  import {
11630
12083
  AUTH_INFO_PATH as AUTH_INFO_PATH2,
11631
- CliError as CliError26,
11632
- CliErrorCode as CliErrorCode24,
12084
+ CliError as CliError27,
12085
+ CliErrorCode as CliErrorCode26,
11633
12086
  discoverProjectEnv as discoverProjectEnv6,
11634
12087
  ENV_FILE as ENV_FILE2,
11635
12088
  findEnvByEndpoint as findEnvByEndpoint5,
@@ -11652,7 +12105,7 @@ function summarizeReasons(reasons) {
11652
12105
  return reasons.length === 1 ? reasons[0] : `${reasons[0]} \u7B49 ${reasons.length} \u6761\uFF08--output json \u770B\u5168\u90E8\uFF09`;
11653
12106
  }
11654
12107
  function invalid2(message, nextStep) {
11655
- throw new CliError26({ code: CliErrorCode24.INVALID_ARGUMENT, message, context: { nextStep } });
12108
+ throw new CliError27({ code: CliErrorCode26.INVALID_ARGUMENT, message, context: { nextStep } });
11656
12109
  }
11657
12110
  function required(value, label) {
11658
12111
  if (!value?.trim()) invalid2(`${label} \u4E0D\u80FD\u4E3A\u7A7A\uFF1B\u914D\u7F6E\u672A\u5199\u5165\u3002`, `\u8BF7\u63D0\u4F9B\u975E\u7A7A\u7684 ${label}`);
@@ -11866,10 +12319,360 @@ async function chironEnvCommand(action, args) {
11866
12319
  init_auth_guard();
11867
12320
  init_exit();
11868
12321
  import { spawnSync } from "child_process";
11869
- import { accessSync, constants } from "fs";
12322
+ import { accessSync, constants, readdirSync as readdirSync3 } from "fs";
11870
12323
  import fs12 from "fs/promises";
12324
+ import os5 from "os";
12325
+ import path14 from "path";
12326
+ import { CliError as CliError30, CliErrorCode as CliErrorCode29, formatObject as formatObject27, HcmClient as HcmClient23, loadEnv as loadEnv6 } from "@hcmai/sdk";
12327
+ import { createRequire } from "module";
12328
+
12329
+ // src/commands/chiron-page-cdp.ts
12330
+ import { CliError as CliError28, CliErrorCode as CliErrorCode27 } from "@hcmai/sdk";
12331
+
12332
+ // src/commands/chiron-page-shared.ts
12333
+ function redactTicket(text) {
12334
+ return text.replace(/(ticket=)[^&\s"']+/g, "$1<redacted>");
12335
+ }
12336
+ function toPlainJson(value) {
12337
+ if (value === void 0) return void 0;
12338
+ const seen = /* @__PURE__ */ new WeakSet();
12339
+ const text = JSON.stringify(value, (_k, v) => {
12340
+ if (typeof v === "bigint") return v.toString();
12341
+ if (v && typeof v === "object") {
12342
+ if (seen.has(v)) return "[Circular]";
12343
+ seen.add(v);
12344
+ }
12345
+ return v;
12346
+ });
12347
+ if (text === void 0) return void 0;
12348
+ return JSON.parse(redactTicket(text));
12349
+ }
12350
+ function wrapEvalBody(body) {
12351
+ return `(async () => {
12352
+ ${body}
12353
+ })()`;
12354
+ }
12355
+
12356
+ // src/commands/chiron-page-cdp.ts
12357
+ function normalizeCdpEndpoint(raw) {
12358
+ const text = raw?.trim();
12359
+ if (!text) return null;
12360
+ let candidate = text;
12361
+ if (!/^[a-z]+:\/\//i.test(candidate)) candidate = `http://${candidate}`;
12362
+ let url;
12363
+ try {
12364
+ url = new URL(candidate);
12365
+ } catch {
12366
+ throw new CliError28({ code: CliErrorCode27.INVALID_ARGUMENT, message: `--cdp \u8981\u5199\u6210 http://\u4E3B\u673A:\u7AEF\u53E3\uFF08Chrome \u7684 --remote-debugging-port\uFF09\uFF0C\u6536\u5230\u7684\u662F ${text}` });
12367
+ }
12368
+ const protocol = url.protocol === "wss:" ? "https:" : url.protocol === "ws:" ? "http:" : url.protocol;
12369
+ if (protocol !== "http:" && protocol !== "https:") {
12370
+ throw new CliError28({ code: CliErrorCode27.INVALID_ARGUMENT, message: `--cdp \u53EA\u8BA4 http(s) \u6216 ws(s) \u7AEF\u70B9\uFF0C\u6536\u5230\u7684\u662F ${text}` });
12371
+ }
12372
+ if (!url.port) {
12373
+ throw new CliError28({ code: CliErrorCode27.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}` });
12374
+ }
12375
+ return `${protocol}//${url.hostname}:${url.port}`;
12376
+ }
12377
+ var CdpSession = class {
12378
+ constructor(socket) {
12379
+ this.socket = socket;
12380
+ socket.addEventListener("message", (ev) => this.onMessage(typeof ev.data === "string" ? ev.data : String(ev.data)));
12381
+ socket.addEventListener("close", () => this.failAll(new Error("CDP socket \u5DF2\u5173\u95ED")));
12382
+ socket.addEventListener("error", (ev) => this.failAll(new Error(`CDP socket \u51FA\u9519\uFF1A${describe(ev)}`)));
12383
+ }
12384
+ socket;
12385
+ nextId = 1;
12386
+ pending = /* @__PURE__ */ new Map();
12387
+ listeners = /* @__PURE__ */ new Map();
12388
+ closed = false;
12389
+ send(method, params = {}) {
12390
+ if (this.closed) return Promise.reject(new Error(`CDP socket \u5DF2\u5173\u95ED\uFF0C\u53D1\u4E0D\u4E86 ${method}`));
12391
+ const id = this.nextId++;
12392
+ return new Promise((resolve3, reject) => {
12393
+ this.pending.set(id, { resolve: resolve3, reject, method });
12394
+ this.socket.send(JSON.stringify({ id, method, params }));
12395
+ });
12396
+ }
12397
+ on(event, listener) {
12398
+ const list = this.listeners.get(event) ?? [];
12399
+ list.push(listener);
12400
+ this.listeners.set(event, list);
12401
+ return () => {
12402
+ const cur = this.listeners.get(event) ?? [];
12403
+ const i = cur.indexOf(listener);
12404
+ if (i >= 0) cur.splice(i, 1);
12405
+ };
12406
+ }
12407
+ /** 事件监听器数(测试用:确认 waitFor 结束后不留监听器)。 */
12408
+ listenerCount(event) {
12409
+ return (this.listeners.get(event) ?? []).length;
12410
+ }
12411
+ /** 等一个事件,超时就 reject——「等 load 事件」不能无限等。无论哪种结束都摘掉监听器。 */
12412
+ waitFor(event, timeoutMs) {
12413
+ return new Promise((resolve3, reject) => {
12414
+ const off = this.on(event, (params) => {
12415
+ clearTimeout(timer);
12416
+ off();
12417
+ resolve3(params);
12418
+ });
12419
+ const timer = setTimeout(() => {
12420
+ off();
12421
+ reject(new Error(`\u7B49 ${event} \u8D85\u8FC7 ${timeoutMs}ms`));
12422
+ }, timeoutMs);
12423
+ });
12424
+ }
12425
+ close() {
12426
+ this.closed = true;
12427
+ try {
12428
+ this.socket.close();
12429
+ } catch {
12430
+ }
12431
+ this.failAll(new Error("CDP socket \u5DF2\u5173\u95ED"));
12432
+ }
12433
+ onMessage(raw) {
12434
+ let msg;
12435
+ try {
12436
+ msg = JSON.parse(raw);
12437
+ } catch {
12438
+ return;
12439
+ }
12440
+ if (typeof msg.id === "number") {
12441
+ const p = this.pending.get(msg.id);
12442
+ if (!p) return;
12443
+ this.pending.delete(msg.id);
12444
+ if (msg.error) p.reject(new Error(`${p.method} \u88AB Chrome \u62D2\u7EDD\uFF1A${msg.error.message ?? JSON.stringify(msg.error)}`));
12445
+ else p.resolve(msg.result);
12446
+ return;
12447
+ }
12448
+ if (msg.method) {
12449
+ for (const l of [...this.listeners.get(msg.method) ?? []]) l(msg.params);
12450
+ }
12451
+ }
12452
+ failAll(err) {
12453
+ for (const [id, p] of this.pending) {
12454
+ this.pending.delete(id);
12455
+ p.reject(err);
12456
+ }
12457
+ }
12458
+ };
12459
+ function describe(ev) {
12460
+ if (ev && typeof ev === "object" && "message" in ev) return String(ev.message);
12461
+ return String(ev);
12462
+ }
12463
+ var LOAD_WAIT_MS = 15e3;
12464
+ var CDP_IO_TIMEOUT_MS = 1e4;
12465
+ async function captureViaCdp(input, io) {
12466
+ const version = await io.fetchJson(`${input.endpoint}/json/version`, "GET");
12467
+ const browser = version?.Browser ? String(version.Browser) : `attached ${input.endpoint}`;
12468
+ const target = await io.fetchJson(`${input.endpoint}/json/new?about:blank`, "PUT");
12469
+ if (!target?.id || !target.webSocketDebuggerUrl) {
12470
+ throw new CliError28({
12471
+ code: CliErrorCode27.SERVER_ERROR,
12472
+ message: `${input.endpoint}/json/new \u6CA1\u6709\u7ED9\u51FA\u6807\u7B7E\u9875\uFF08id / webSocketDebuggerUrl \u7F3A\u5931\uFF09`,
12473
+ context: { nextStep: "\u786E\u8BA4 Chrome \u662F\u5E26 --remote-debugging-port \u8D77\u7684\uFF0C\u4E14 --cdp \u6307\u5230\u7684\u662F\u5B83" }
12474
+ });
12475
+ }
12476
+ let session = null;
12477
+ try {
12478
+ session = new CdpSession(await io.openSocket(target.webSocketDebuggerUrl));
12479
+ await session.send("Emulation.setDeviceMetricsOverride", {
12480
+ width: input.viewport.width,
12481
+ height: input.viewport.height,
12482
+ deviceScaleFactor: 1,
12483
+ mobile: false
12484
+ });
12485
+ await session.send("Page.enable");
12486
+ await session.send("Runtime.enable");
12487
+ const minted = await input.mintUrl();
12488
+ const loaded = session.waitFor("Page.loadEventFired", LOAD_WAIT_MS).then(() => true, () => false);
12489
+ await session.send("Page.navigate", { url: minted.url });
12490
+ const navigated = await loaded;
12491
+ if (input.waitMs > 0) await io.sleep(input.waitMs);
12492
+ let evalResult;
12493
+ if (input.evalJs?.trim()) {
12494
+ const r = await session.send("Runtime.evaluate", {
12495
+ expression: wrapEvalBody(input.evalJs),
12496
+ awaitPromise: true,
12497
+ returnByValue: true
12498
+ });
12499
+ if (r.exceptionDetails) {
12500
+ const why = r.exceptionDetails.exception?.description ?? r.exceptionDetails.text ?? "unknown";
12501
+ throw new CliError28({ code: CliErrorCode27.INVALID_ARGUMENT, message: `--eval \u5728\u9875\u9762\u91CC\u629B\u4E86\u5F02\u5E38\uFF1A${redactTicket(why.split("\n")[0] ?? why)}` });
12502
+ }
12503
+ evalResult = r.result && "value" in r.result ? toPlainJson(r.result.value) : toPlainJson(r.result?.description);
12504
+ }
12505
+ const domReply = await session.send("Runtime.evaluate", {
12506
+ expression: "document.documentElement.outerHTML",
12507
+ returnByValue: true
12508
+ });
12509
+ const dom = typeof domReply.result?.value === "string" ? domReply.result.value : "";
12510
+ const shot = await session.send("Page.captureScreenshot", { format: "png" });
12511
+ if (!shot.data) {
12512
+ throw new CliError28({ code: CliErrorCode27.SERVER_ERROR, message: "Page.captureScreenshot \u6CA1\u6709\u8FD4\u56DE\u56FE\u50CF\u6570\u636E" });
12513
+ }
12514
+ await io.writeFile(input.screenshot, Buffer.from(shot.data, "base64"));
12515
+ return { dom, browser, evalResult, navigated, minted };
12516
+ } finally {
12517
+ session?.close();
12518
+ try {
12519
+ await io.fetchJson(`${input.endpoint}/json/close/${target.id}`, "GET");
12520
+ } catch {
12521
+ }
12522
+ }
12523
+ }
12524
+ var defaultCdpIo = {
12525
+ fetchJson: async (url, method) => {
12526
+ const res = await fetch(url, { method, signal: AbortSignal.timeout(CDP_IO_TIMEOUT_MS) });
12527
+ if (!res.ok) throw new Error(`${method} ${url} \u2192 HTTP ${res.status}`);
12528
+ const text = await res.text();
12529
+ return text ? JSON.parse(text) : null;
12530
+ },
12531
+ openSocket: (wsUrl) => new Promise((resolve3, reject) => {
12532
+ const Ctor = globalThis.WebSocket;
12533
+ if (!Ctor) {
12534
+ reject(new CliError28({ code: CliErrorCode27.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" }));
12535
+ return;
12536
+ }
12537
+ const ws = new Ctor(wsUrl);
12538
+ const timer = setTimeout(() => reject(new Error(`\u8FDE ${wsUrl} \u8D85\u8FC7 ${CDP_IO_TIMEOUT_MS}ms \u6CA1\u63E1\u4E0A\u624B`)), CDP_IO_TIMEOUT_MS);
12539
+ ws.addEventListener("open", () => {
12540
+ clearTimeout(timer);
12541
+ resolve3(ws);
12542
+ });
12543
+ ws.addEventListener("error", (ev) => {
12544
+ clearTimeout(timer);
12545
+ reject(new Error(`\u8FDE\u4E0D\u4E0A ${wsUrl}\uFF1A${describe(ev)}`));
12546
+ });
12547
+ }),
12548
+ writeFile: async (file, bytes) => {
12549
+ const fs14 = await import("fs/promises");
12550
+ await fs14.writeFile(file, bytes);
12551
+ },
12552
+ sleep: (ms) => new Promise((r) => setTimeout(r, ms))
12553
+ };
12554
+
12555
+ // src/commands/chiron-page-playwright.ts
11871
12556
  import path13 from "path";
11872
- import { CliError as CliError27, CliErrorCode as CliErrorCode25, formatObject as formatObject27, HcmClient as HcmClient23, loadEnv as loadEnv6 } from "@hcmai/sdk";
12557
+ import { CliError as CliError29, CliErrorCode as CliErrorCode28 } from "@hcmai/sdk";
12558
+ function playwrightCacheRoot(probe) {
12559
+ const override = probe.env.PLAYWRIGHT_BROWSERS_PATH?.trim();
12560
+ if (override === "0" && probe.packageRoot) return path13.join(probe.packageRoot, ".local-browsers");
12561
+ if (override && override !== "0") return path13.resolve(override);
12562
+ if (probe.platform === "darwin") return path13.join(probe.homedir(), "Library", "Caches", "ms-playwright");
12563
+ if (probe.platform === "win32") {
12564
+ return path13.join(probe.env.LOCALAPPDATA?.trim() || path13.join(probe.homedir(), "AppData", "Local"), "ms-playwright");
12565
+ }
12566
+ return path13.join(probe.env.XDG_CACHE_HOME?.trim() || path13.join(probe.homedir(), ".cache"), "ms-playwright");
12567
+ }
12568
+ function playwrightPlatformTag(probe) {
12569
+ const arm = probe.arch === "arm64";
12570
+ if (probe.platform === "darwin") return arm ? "mac-arm64" : "mac-x64";
12571
+ if (probe.platform === "win32") return "win64";
12572
+ return arm ? "linux-arm64" : "linux64";
12573
+ }
12574
+ function revisionOf(entry, prefix) {
12575
+ if (!entry.startsWith(prefix)) return null;
12576
+ const rev = Number(entry.slice(prefix.length));
12577
+ return Number.isInteger(rev) ? rev : null;
12578
+ }
12579
+ function candidateBinaries(probe, kind) {
12580
+ const tag = playwrightPlatformTag(probe);
12581
+ if (kind === "headless-shell") {
12582
+ return [path13.join(`chrome-headless-shell-${tag}`, probe.platform === "win32" ? "chrome-headless-shell.exe" : "chrome-headless-shell")];
12583
+ }
12584
+ if (probe.platform === "darwin") {
12585
+ return [
12586
+ // Playwright ≥ 1.49:Chrome for Testing 的 .app
12587
+ path13.join(`chrome-${tag}`, "Google Chrome for Testing.app", "Contents", "MacOS", "Google Chrome for Testing"),
12588
+ // ≤ 1.48:Chromium.app,目录名不分架构
12589
+ path13.join("chrome-mac", "Chromium.app", "Contents", "MacOS", "Chromium"),
12590
+ path13.join(`chrome-${tag}`, "Chromium.app", "Contents", "MacOS", "Chromium")
12591
+ ];
12592
+ }
12593
+ if (probe.platform === "win32") return [path13.join("chrome-win64", "chrome.exe"), path13.join("chrome-win", "chrome.exe")];
12594
+ return [path13.join(`chrome-${tag}`, "chrome"), path13.join("chrome-linux", "chrome")];
12595
+ }
12596
+ function discoverPlaywrightBrowser(probe) {
12597
+ const explicit = probe.env.HCM_PLAYWRIGHT_EXECUTABLE?.trim();
12598
+ if (explicit) {
12599
+ if (probe.executable(explicit)) return { executablePath: explicit, kind: "explicit", from: "HCM_PLAYWRIGHT_EXECUTABLE" };
12600
+ throw new CliError29({
12601
+ code: CliErrorCode28.INVALID_ARGUMENT,
12602
+ message: `HCM_PLAYWRIGHT_EXECUTABLE \u6307\u7684\u6587\u4EF6\u4E0D\u53EF\u6267\u884C\uFF1A${explicit}`,
12603
+ 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" }
12604
+ });
12605
+ }
12606
+ const root = playwrightCacheRoot(probe);
12607
+ const entries = probe.readdir(root);
12608
+ const pick2 = (prefix, kind) => {
12609
+ const revisions = entries.map((e) => ({ e, rev: revisionOf(e, prefix) })).filter((x) => x.rev !== null).sort((a, b) => b.rev - a.rev);
12610
+ for (const { e } of revisions) {
12611
+ for (const rel of candidateBinaries(probe, kind)) {
12612
+ const candidate = path13.join(root, e, rel);
12613
+ if (probe.executable(candidate)) return { executablePath: candidate, kind, from: path13.join(root, e) };
12614
+ }
12615
+ }
12616
+ return null;
12617
+ };
12618
+ return pick2("chromium_headless_shell-", "headless-shell") ?? pick2("chromium-", "chromium");
12619
+ }
12620
+ var PW_LOAD_WAIT_MS = 15e3;
12621
+ async function loadPlaywright() {
12622
+ return import("playwright-core");
12623
+ }
12624
+ async function captureViaPlaywright(input) {
12625
+ const pw = await loadPlaywright();
12626
+ const attempts = [];
12627
+ if (input.browser) attempts.push({ label: `${input.browser.kind} @ ${input.browser.from}`, options: { headless: true, executablePath: input.browser.executablePath } });
12628
+ attempts.push({ label: "playwright default", options: { headless: true } });
12629
+ attempts.push({ label: "channel=chrome", options: { headless: true, channel: "chrome" } });
12630
+ const failures = [];
12631
+ let browser = null;
12632
+ let used = "";
12633
+ for (const a of attempts) {
12634
+ try {
12635
+ browser = await pw.chromium.launch({ ...a.options, args: ["--disable-gpu", "--disable-dev-shm-usage", "--hide-scrollbars"] });
12636
+ used = a.label;
12637
+ break;
12638
+ } catch (e) {
12639
+ failures.push(`${a.label}: ${(e instanceof Error ? e.message : String(e)).split("\n")[0]}`);
12640
+ }
12641
+ }
12642
+ if (!browser) {
12643
+ throw new CliError29({
12644
+ code: CliErrorCode28.SERVER_ERROR,
12645
+ message: `Playwright \u8D77\u4E0D\u4E86\u6D4F\u89C8\u5668\uFF1A${failures.join("\uFF1B")}`,
12646
+ context: {
12647
+ 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"
12648
+ }
12649
+ });
12650
+ }
12651
+ const browserLabel = `${browser.version()} via playwright (${used})`;
12652
+ try {
12653
+ const context = await browser.newContext({ viewport: input.viewport, deviceScaleFactor: 1 });
12654
+ const page = await context.newPage();
12655
+ const minted = await input.mintUrl();
12656
+ const navigated = await page.goto(minted.url, { waitUntil: "load", timeout: PW_LOAD_WAIT_MS }).then(() => true, () => false);
12657
+ if (input.waitMs > 0) await page.waitForTimeout(input.waitMs);
12658
+ let evalResult;
12659
+ if (input.evalJs?.trim()) {
12660
+ try {
12661
+ evalResult = toPlainJson(await page.evaluate(wrapEvalBody(input.evalJs)));
12662
+ } catch (e) {
12663
+ const why = (e instanceof Error ? e.message : String(e)).split("\n")[0] ?? "";
12664
+ throw new CliError29({ code: CliErrorCode28.INVALID_ARGUMENT, message: `--eval \u5728\u9875\u9762\u91CC\u629B\u4E86\u5F02\u5E38\uFF1A${redactTicket(why)}` });
12665
+ }
12666
+ }
12667
+ const dom = await page.content();
12668
+ await page.screenshot({ path: input.screenshot, fullPage: false });
12669
+ return { dom, browser: browserLabel, evalResult, navigated, minted };
12670
+ } finally {
12671
+ await browser.close().catch(() => void 0);
12672
+ }
12673
+ }
12674
+
12675
+ // src/commands/chiron-page.ts
11873
12676
  var EVIDENCE_DIR = "evidence";
11874
12677
  var WAIT_MS_MAX = 6e4;
11875
12678
  var VIEWPORT_MIN = { width: 320, height: 240 };
@@ -11882,13 +12685,13 @@ function judgePageContent(input) {
11882
12685
  function parseViewport(size) {
11883
12686
  const m = /^(\d+)x(\d+)$/.exec(size.trim());
11884
12687
  if (!m) {
11885
- throw new CliError27({ code: CliErrorCode25.INVALID_ARGUMENT, message: `--size \u8981\u5199\u6210 <\u5BBD>x<\u9AD8>\uFF0C\u4F8B\u5982 1440x900\uFF0C\u6536\u5230\u7684\u662F ${size}` });
12688
+ throw new CliError30({ code: CliErrorCode29.INVALID_ARGUMENT, message: `--size \u8981\u5199\u6210 <\u5BBD>x<\u9AD8>\uFF0C\u4F8B\u5982 1440x900\uFF0C\u6536\u5230\u7684\u662F ${size}` });
11886
12689
  }
11887
12690
  const width = Number(m[1]);
11888
12691
  const height = Number(m[2]);
11889
12692
  if (width < VIEWPORT_MIN.width || width > VIEWPORT_MAX.width || height < VIEWPORT_MIN.height || height > VIEWPORT_MAX.height) {
11890
- throw new CliError27({
11891
- code: CliErrorCode25.INVALID_ARGUMENT,
12693
+ throw new CliError30({
12694
+ code: CliErrorCode29.INVALID_ARGUMENT,
11892
12695
  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}`
11893
12696
  });
11894
12697
  }
@@ -11898,23 +12701,23 @@ function parseWaitMs(raw) {
11898
12701
  if (raw === void 0) return 1e4;
11899
12702
  const value = typeof raw === "number" ? raw : Number(raw);
11900
12703
  if (!Number.isInteger(value) || value < 0 || value > WAIT_MS_MAX) {
11901
- throw new CliError27({ code: CliErrorCode25.INVALID_ARGUMENT, message: `--wait-ms \u8981\u662F 0..${WAIT_MS_MAX} \u7684\u6574\u6570\uFF0C\u6536\u5230\u7684\u662F ${raw}` });
12704
+ throw new CliError30({ code: CliErrorCode29.INVALID_ARGUMENT, message: `--wait-ms \u8981\u662F 0..${WAIT_MS_MAX} \u7684\u6574\u6570\uFF0C\u6536\u5230\u7684\u662F ${raw}` });
11902
12705
  }
11903
12706
  return value;
11904
12707
  }
11905
12708
  function resolveEvidenceTarget(projectRoot, out) {
11906
12709
  if (!out?.trim()) {
11907
- throw new CliError27({ code: CliErrorCode25.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` });
12710
+ throw new CliError30({ code: CliErrorCode29.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` });
11908
12711
  }
11909
12712
  if (!out.endsWith(".png")) {
11910
- throw new CliError27({ code: CliErrorCode25.INVALID_ARGUMENT, message: `--out \u8981\u4EE5 .png \u7ED3\u5C3E\uFF0C\u6536\u5230\u7684\u662F ${out}` });
11911
- }
11912
- const root = path13.resolve(projectRoot);
11913
- const evidenceRoot = path13.join(root, EVIDENCE_DIR);
11914
- const absolute = path13.resolve(root, out);
11915
- if (absolute !== evidenceRoot && !absolute.startsWith(evidenceRoot + path13.sep)) {
11916
- throw new CliError27({
11917
- code: CliErrorCode25.INVALID_ARGUMENT,
12713
+ throw new CliError30({ code: CliErrorCode29.INVALID_ARGUMENT, message: `--out \u8981\u4EE5 .png \u7ED3\u5C3E\uFF0C\u6536\u5230\u7684\u662F ${out}` });
12714
+ }
12715
+ const root = path14.resolve(projectRoot);
12716
+ const evidenceRoot = path14.join(root, EVIDENCE_DIR);
12717
+ const absolute = path14.resolve(root, out);
12718
+ if (absolute !== evidenceRoot && !absolute.startsWith(evidenceRoot + path14.sep)) {
12719
+ throw new CliError30({
12720
+ code: CliErrorCode29.INVALID_ARGUMENT,
11918
12721
  message: `--out \u8981\u843D\u5728\u9879\u76EE\u7684 ${EVIDENCE_DIR}/ \u4E0B\uFF08${evidenceRoot}\uFF09\uFF0C\u6536\u5230\u7684\u662F ${absolute}`
11919
12722
  });
11920
12723
  }
@@ -11959,11 +12762,11 @@ function findChrome(probe, override) {
11959
12762
  }
11960
12763
  async function assertInsideEvidence(deps, evidenceRoot, absolute) {
11961
12764
  const canonicalRoot = await deps.realpath(evidenceRoot);
11962
- const canonicalParent = await deps.realpath(path13.dirname(absolute));
12765
+ const canonicalParent = await deps.realpath(path14.dirname(absolute));
11963
12766
  if (canonicalRoot === null || canonicalParent === null) return;
11964
- if (canonicalParent !== canonicalRoot && !canonicalParent.startsWith(canonicalRoot + path13.sep)) {
11965
- throw new CliError27({
11966
- code: CliErrorCode25.INVALID_ARGUMENT,
12767
+ if (canonicalParent !== canonicalRoot && !canonicalParent.startsWith(canonicalRoot + path14.sep)) {
12768
+ throw new CliError30({
12769
+ code: CliErrorCode29.INVALID_ARGUMENT,
11967
12770
  message: `--out \u7684\u7236\u76EE\u5F55\u7ECF\u7B26\u53F7\u94FE\u63A5\u8DD1\u51FA\u4E86 ${EVIDENCE_DIR}/\uFF1A${canonicalParent}`
11968
12771
  });
11969
12772
  }
@@ -11972,46 +12775,91 @@ async function runChironPage(target, args, deps) {
11972
12775
  const sitePath = normalizeTarget(target);
11973
12776
  const expect = (args.expectText ?? []).filter((t) => t.trim().length > 0);
11974
12777
  if (expect.length === 0) {
11975
- throw new CliError27({
11976
- code: CliErrorCode25.MISSING_FLAG,
12778
+ throw new CliError30({
12779
+ code: CliErrorCode29.MISSING_FLAG,
11977
12780
  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"
11978
12781
  });
11979
12782
  }
11980
12783
  const reject = (args.rejectText ?? []).filter((t) => t.trim().length > 0);
11981
12784
  const viewport = parseViewport(args.size ?? "1440x900");
11982
12785
  const waitMs = parseWaitMs(args.waitMs);
11983
- const root = path13.resolve(args.project ?? ".");
12786
+ const root = path14.resolve(args.project ?? ".");
11984
12787
  const { evidenceRoot, absolute } = resolveEvidenceTarget(root, args.out);
11985
12788
  if (await deps.present(absolute)) {
11986
- throw new CliError27({
11987
- code: CliErrorCode25.INVALID_ARGUMENT,
12789
+ throw new CliError30({
12790
+ code: CliErrorCode29.INVALID_ARGUMENT,
11988
12791
  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`
11989
12792
  });
11990
12793
  }
11991
- await deps.ensureDir(path13.dirname(absolute));
12794
+ await deps.ensureDir(path14.dirname(absolute));
11992
12795
  await assertInsideEvidence(deps, evidenceRoot, absolute);
11993
- const browser = deps.findBrowser();
11994
- if (!browser) {
11995
- throw new CliError27({
11996
- code: CliErrorCode25.INVALID_ARGUMENT,
11997
- message: "\u672C\u673A\u627E\u4E0D\u5230 Chrome/Chromium\uFF0C\u622A\u4E0D\u4E86\u56FE\u3002",
11998
- context: { nextStep: "\u88C5\u4E00\u4E2A Chrome\uFF0C\u6216\u7528 HCM_CHROME_BIN=/\u7EDD\u5BF9\u8DEF\u5F84 \u6307\u5230\u5DF2\u6709\u7684\u90A3\u4E2A" }
12796
+ const endpoint = normalizeCdpEndpoint(args.cdp ?? deps.env.HCM_CHROME_CDP);
12797
+ const evalJs = args.eval?.trim() ? args.eval : void 0;
12798
+ const forceSpawn = (deps.env.HCM_CHIRON_PAGE_DRIVER ?? "").trim() === "spawn";
12799
+ const playwrightBrowser = endpoint || forceSpawn ? null : deps.findPlaywrightBrowser();
12800
+ const usePlaywright = !endpoint && !forceSpawn && (playwrightBrowser !== null || evalJs !== void 0);
12801
+ if (evalJs && !endpoint && !usePlaywright) {
12802
+ throw new CliError30({
12803
+ code: CliErrorCode29.INVALID_ARGUMENT,
12804
+ message: "--eval \u9700\u8981 Playwright \u6216 --cdp\uFF1A\u8001\u7684 spawn \u8DEF\u5F84\u53EA\u4F1A --dump-dom\uFF0C\u585E\u4E0D\u8FDB\u811A\u672C\u3002",
12805
+ context: { nextStep: "npx playwright install chromium-headless-shell\uFF0C\u6216\u5728\u6C99\u7BB1\u5916\u8D77 Chrome \u7528 --cdp \u8FDE" }
11999
12806
  });
12000
12807
  }
12001
- const minted = await deps.mintUrl({ path: sitePath, args });
12002
- const result = deps.capture({ browser, argv: chromeArgv({ viewport, waitMs, screenshot: absolute, url: minted.url, isRoot: process.getuid?.() === 0 }) });
12003
- if (!result.ok) {
12004
- throw new CliError27({
12005
- code: CliErrorCode25.SERVER_ERROR,
12006
- message: `\u6D4F\u89C8\u5668\u6CA1\u8DD1\u5B8C\uFF1A${result.stderr.trim().split("\n").slice(-1)[0] ?? "\u65E0\u8F93\u51FA"}`,
12007
- context: { nextStep: `\u624B\u5DE5\u6838\u4E00\u773C\uFF1A${browser} --headless=new --screenshot \u8DD1\u5F97\u8D77\u6765\u5417` }
12008
- });
12808
+ let dom;
12809
+ let browserLabel;
12810
+ let evalResult;
12811
+ let navigated;
12812
+ let minted;
12813
+ let mode;
12814
+ const mint = () => deps.mintUrl({ path: sitePath, args });
12815
+ if (endpoint || usePlaywright) {
12816
+ mode = endpoint ? "attach" : "playwright";
12817
+ let captured;
12818
+ try {
12819
+ 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 });
12820
+ } catch (e) {
12821
+ if (e instanceof CliError30) throw new CliError30({ code: e.code, message: redactTicket(e.message), context: e.context });
12822
+ const where = endpoint ? `\u8FDE\u5230 ${endpoint} \u7684 Chrome` : "Playwright \u8D77\u7684\u6D4F\u89C8\u5668";
12823
+ throw new CliError30({
12824
+ code: CliErrorCode29.SERVER_ERROR,
12825
+ message: `${where}\u6CA1\u8DD1\u5B8C\uFF1A${redactTicket(e instanceof Error ? e.message : String(e))}`,
12826
+ context: {
12827
+ 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"
12828
+ }
12829
+ });
12830
+ }
12831
+ dom = captured.dom;
12832
+ browserLabel = captured.browser;
12833
+ evalResult = captured.evalResult;
12834
+ navigated = captured.navigated;
12835
+ minted = captured.minted;
12836
+ } else {
12837
+ mode = "spawn";
12838
+ const browser = deps.findBrowser();
12839
+ if (!browser) {
12840
+ throw new CliError30({
12841
+ code: CliErrorCode29.INVALID_ARGUMENT,
12842
+ message: "\u672C\u673A\u627E\u4E0D\u5230 Playwright \u7684 Chromium\uFF0C\u4E5F\u627E\u4E0D\u5230 Chrome/Chromium\uFF0C\u622A\u4E0D\u4E86\u56FE\u3002",
12843
+ 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" }
12844
+ });
12845
+ }
12846
+ minted = await mint();
12847
+ const result = deps.capture({ browser, argv: chromeArgv({ viewport, waitMs, screenshot: absolute, url: minted.url, isRoot: process.getuid?.() === 0 }) });
12848
+ if (!result.ok) {
12849
+ throw new CliError30({
12850
+ code: CliErrorCode29.SERVER_ERROR,
12851
+ message: `\u6D4F\u89C8\u5668\u6CA1\u8DD1\u5B8C\uFF1A${redactTicket(result.stderr.trim().split("\n").slice(-1)[0] ?? "\u65E0\u8F93\u51FA")}`,
12852
+ context: { nextStep: spawnFailureNextStep(browser, result, deps.platform) }
12853
+ });
12854
+ }
12855
+ dom = result.dom;
12856
+ browserLabel = deps.browserVersion(browser);
12009
12857
  }
12010
12858
  const bytes = await deps.present(absolute) ? await deps.sizeOf(absolute) : 0;
12011
12859
  if (bytes === 0) {
12012
- throw new CliError27({ code: CliErrorCode25.SERVER_ERROR, message: `\u6D4F\u89C8\u5668\u6CA1\u5199\u51FA\u975E\u7A7A PNG\uFF1A${absolute}` });
12860
+ throw new CliError30({ code: CliErrorCode29.SERVER_ERROR, message: `\u6D4F\u89C8\u5668\u6CA1\u5199\u51FA\u975E\u7A7A PNG\uFF1A${absolute}` });
12013
12861
  }
12014
- const verdict = judgePageContent({ dom: result.dom, expect, reject });
12862
+ const verdict = judgePageContent({ dom, expect, reject });
12015
12863
  return {
12016
12864
  ok: verdict.ok,
12017
12865
  path: sitePath,
@@ -12021,25 +12869,50 @@ async function runChironPage(target, args, deps) {
12021
12869
  identity: minted.identity,
12022
12870
  viewport: `${viewport.width}x${viewport.height}`,
12023
12871
  waitMs,
12024
- browser: deps.browserVersion(browser),
12872
+ browser: browserLabel,
12873
+ mode,
12874
+ ...endpoint ? { attach: endpoint } : {},
12875
+ ...evalResult !== void 0 ? { evalResult } : {},
12876
+ ...navigated !== void 0 ? { navigated } : {},
12025
12877
  expected: expect,
12026
12878
  rejected: reject,
12027
12879
  missing: verdict.missing,
12028
12880
  forbidden: verdict.forbidden
12029
12881
  };
12030
12882
  }
12883
+ function spawnFailureNextStep(browser, result, platform) {
12884
+ const sandboxed = result.signal === "SIGABRT" || /SIGABRT|abort trap|Trace\/BPT trap|sandbox/i.test(result.stderr);
12885
+ if (sandboxed) {
12886
+ return `Chrome \u5728\u8FD9\u4E2A\u8FDB\u7A0B\u91CC\u8D77\u4E0D\u6765\uFF08${result.signal ?? "\u88AB\u4FE1\u53F7\u7EC8\u6B62"}\uFF09\u2014\u2014\u6C99\u7BB1\u91CC\u5E38\u89C1\u3002\u6539\u8D70 attach\uFF1A\u5728\u6C99\u7BB1\u5916\u8D77 "${browser}" --headless=new --remote-debugging-port=9222 --user-data-dir=<\u4E34\u65F6\u76EE\u5F55>\uFF0C\u518D\u7ED9\u672C\u547D\u4EE4\u52A0 --cdp http://127.0.0.1:9222\uFF08\u6216 export HCM_CHROME_CDP=\u2026\uFF09` + (platform === "darwin" ? "\uFF1BmacOS \u7684 Seatbelt \u5C31\u662F\u8FD9\u79CD\u60C5\u51B5" : "");
12887
+ }
12888
+ return `\u624B\u5DE5\u6838\u4E00\u773C\uFF1A${browser} --headless=new --screenshot \u8DD1\u5F97\u8D77\u6765\u5417\uFF1B\u8D77\u4E0D\u6765\u5C31\u5728\u6C99\u7BB1\u5916\u8D77\u597D Chrome \u7528 --cdp \u8FDE`;
12889
+ }
12031
12890
  function renderChironPage(receipt) {
12032
12891
  const out = [];
12033
12892
  out.push(`${receipt.ok ? "\u2705" : "\u274C"} ${receipt.path} \xB7 ${receipt.environment}${receipt.identity ? ` \xB7 ${receipt.identity}` : ""}`);
12034
- out.push(` \u622A\u56FE ${receipt.screenshot}\uFF08${receipt.bytes} \u5B57\u8282\uFF0C${receipt.viewport}\uFF0C\u7B49 ${receipt.waitMs}ms\uFF09`);
12893
+ out.push(` \u622A\u56FE ${receipt.screenshot}\uFF08${receipt.bytes} \u5B57\u8282\uFF0C${receipt.viewport}\uFF0C\u7B49 ${receipt.waitMs}ms\uFF0C${receipt.mode === "attach" ? `\u8FDE\u7684 ${receipt.attach}` : receipt.mode}\uFF09`);
12894
+ out.push(` \u6D4F\u89C8\u5668 ${receipt.browser}`);
12895
+ if (receipt.navigated === false) out.push(" \u26A0\uFE0F \u5BFC\u822A\u6CA1\u8D70\u5230 load \u4E8B\u4EF6\uFF08\u8FDE\u63A5\u88AB\u62D2 / \u8BC1\u4E66 / \u7968\u636E\u9875\u8DF3\u8F6C\u5931\u8D25\uFF09\u2014\u2014\u4E0B\u9762\u7684\u5224\u636E\u662F\u5BF9\u9519\u8BEF\u9875\u6216\u7A7A\u58F3\u5224\u7684");
12896
+ if (receipt.evalResult !== void 0) out.push(` --eval \u8FD4\u56DE ${typeof receipt.evalResult === "string" ? receipt.evalResult : safeStringify(receipt.evalResult)}`);
12035
12897
  out.push(` \u6838\u8FC7 ${receipt.expected.map((t) => `\u300C${t}\u300D`).join("\u3001")}${receipt.rejected.length ? ` \xB7 \u4E0D\u8BB8\u51FA\u73B0 ${receipt.rejected.map((t) => `\u300C${t}\u300D`).join("\u3001")}` : ""}`);
12036
12898
  for (const t of receipt.missing) out.push(` \u274C \u9875\u9762\u4E0A\u6CA1\u6709\u300C${t}\u300D`);
12037
12899
  for (const t of receipt.forbidden) out.push(` \u274C \u9875\u9762\u4E0A\u51FA\u73B0\u4E86\u4E0D\u8BE5\u6709\u7684\u300C${t}\u300D`);
12038
12900
  if (!receipt.ok) out.push(" \u622A\u56FE\u4FDD\u7559\u7740\uFF0C\u6253\u5F00\u770B\u4E00\u773C\u662F\u767B\u5F55\u9875\u3001\u62A5\u9519\u9875\uFF0C\u8FD8\u662F\u9875\u9762\u771F\u7684\u5C11\u4E86\u4E1C\u897F\u3002");
12039
12901
  return out.join("\n");
12040
12902
  }
12041
- function redactTicket(text) {
12042
- return text.replace(/(ticket=)[^&\s"']+/g, "$1<redacted>");
12903
+ function safeStringify(value) {
12904
+ try {
12905
+ return JSON.stringify(value);
12906
+ } catch {
12907
+ return String(value);
12908
+ }
12909
+ }
12910
+ function playwrightPackageRoot() {
12911
+ try {
12912
+ return path14.dirname(createRequire(import.meta.url).resolve("playwright-core/package.json"));
12913
+ } catch {
12914
+ return void 0;
12915
+ }
12043
12916
  }
12044
12917
  var defaultChironPageDeps = {
12045
12918
  mintUrl: async ({ path: sitePath, args }) => {
@@ -12047,8 +12920,8 @@ var defaultChironPageDeps = {
12047
12920
  const envCfg = await loadEnv6(ctx.env);
12048
12921
  const frontend = ctx.frontend ?? envCfg.frontend;
12049
12922
  if (!frontend?.trim()) {
12050
- throw new CliError27({
12051
- code: CliErrorCode25.INVALID_ARGUMENT,
12923
+ throw new CliError30({
12924
+ code: CliErrorCode29.INVALID_ARGUMENT,
12052
12925
  message: `env '${ctx.env}' \u6CA1\u914D\u524D\u7AEF\u5730\u5740\uFF0C\u5F00\u4E0D\u4E86\u9875\u9762\u3002`,
12053
12926
  context: { nextStep: `hcm env edit frontend <\u524D\u7AEF\u5730\u5740> --env ${ctx.env}` }
12054
12927
  });
@@ -12077,8 +12950,34 @@ var defaultChironPageDeps = {
12077
12950
  ),
12078
12951
  capture: ({ browser, argv }) => {
12079
12952
  const r = spawnSync(browser, argv, { encoding: "utf8", maxBuffer: 1 << 26, timeout: 3e5 });
12080
- return { ok: r.status === 0, dom: r.stdout ?? "", stderr: redactTicket(r.stderr ?? "") };
12953
+ return { ok: r.status === 0, dom: r.stdout ?? "", stderr: redactTicket(r.stderr ?? ""), signal: r.signal ?? null };
12081
12954
  },
12955
+ captureAttached: (input) => captureViaCdp(input, defaultCdpIo),
12956
+ env: process.env,
12957
+ findPlaywrightBrowser: () => discoverPlaywrightBrowser({
12958
+ platform: process.platform,
12959
+ arch: process.arch,
12960
+ env: process.env,
12961
+ packageRoot: playwrightPackageRoot(),
12962
+ homedir: () => os5.homedir(),
12963
+ readdir: (dir) => {
12964
+ try {
12965
+ return readdirSync3(dir);
12966
+ } catch {
12967
+ return [];
12968
+ }
12969
+ },
12970
+ executable: (file) => {
12971
+ try {
12972
+ accessSync(file, constants.X_OK);
12973
+ return true;
12974
+ } catch {
12975
+ return false;
12976
+ }
12977
+ }
12978
+ }),
12979
+ capturePlaywright: (input) => captureViaPlaywright(input),
12980
+ platform: process.platform,
12082
12981
  browserVersion: (browser) => (spawnSync(browser, ["--version"], { encoding: "utf8" }).stdout ?? "").trim().split("\n")[0] ?? "",
12083
12982
  ensureDir: (dir) => fs12.mkdir(dir, { recursive: true }).then(() => void 0),
12084
12983
  present: (file) => fs12.lstat(file).then(() => true).catch(() => false),
@@ -12102,7 +13001,7 @@ init_exit();
12102
13001
  import { spawnSync as spawnSync2 } from "child_process";
12103
13002
  import { randomUUID } from "crypto";
12104
13003
  import { promises as fs13 } from "fs";
12105
- import path14 from "path";
13004
+ import path15 from "path";
12106
13005
  import yaml2 from "js-yaml";
12107
13006
  import { formatObject as formatObject28 } from "@hcmai/sdk";
12108
13007
 
@@ -12308,8 +13207,9 @@ function classify(argv, actionResolution) {
12308
13207
  }
12309
13208
  if (subcommand === "gap") {
12310
13209
  const third = argv[2] ?? "";
12311
- if (["search", "status"].includes(third)) return direct("R1", "remote-read", "gap-read");
13210
+ if (["search", "status", "comments"].includes(third)) return direct("R1", "remote-read", "gap-read");
12312
13211
  if (third === "submit") return direct("R1", "external-tracker-write", "gap-submit");
13212
+ if (third === "verify") return direct("R1", "external-tracker-write", "gap-verify");
12313
13213
  return forbidden("unknown-command", "\u672A\u77E5 chiron gap \u5B50\u547D\u4EE4\u6309\u6700\u9AD8\u98CE\u9669\u5173\u95ED\u3002");
12314
13214
  }
12315
13215
  return forbidden("unknown-command", "\u672A\u77E5 chiron \u5B50\u547D\u4EE4\u6309\u6700\u9AD8\u98CE\u9669\u5173\u95ED\u3002");
@@ -12991,7 +13891,7 @@ async function runCase(spec, root, opts = {}, deps = defaultDeps3) {
12991
13891
  continue;
12992
13892
  }
12993
13893
  if (c.file) {
12994
- const file = path14.resolve(root, fill(c.file));
13894
+ const file = path15.resolve(root, fill(c.file));
12995
13895
  const want = c.expect ?? {};
12996
13896
  const bad = [];
12997
13897
  if (want.xlsx_header || want.xlsx_min_rows !== void 0) {
@@ -13013,7 +13913,7 @@ async function runCase(spec, root, opts = {}, deps = defaultDeps3) {
13013
13913
  results.push(bad.length ? { name: c.name, verdict: "fail", detail: bad.join("\uFF1B") } : { name: c.name, verdict: "pass", detail: "" });
13014
13914
  continue;
13015
13915
  }
13016
- const out = path14.join(
13916
+ const out = path15.join(
13017
13917
  "evidence",
13018
13918
  "test",
13019
13919
  opts.evidenceRunId ?? "current",
@@ -13035,11 +13935,11 @@ async function runCase(spec, root, opts = {}, deps = defaultDeps3) {
13035
13935
  }
13036
13936
  async function loadCases(target) {
13037
13937
  const stat = await fs13.stat(target);
13038
- const files = stat.isDirectory() ? (await fs13.readdir(target)).filter((f) => /\.ya?ml$/.test(f)).sort().map((f) => path14.join(target, f)) : [target];
13938
+ const files = stat.isDirectory() ? (await fs13.readdir(target)).filter((f) => /\.ya?ml$/.test(f)).sort().map((f) => path15.join(target, f)) : [target];
13039
13939
  const out = [];
13040
13940
  for (const f of files) {
13041
13941
  const spec = yaml2.load(await fs13.readFile(f, "utf8"));
13042
- assertUsableSpec(spec, path14.basename(f));
13942
+ assertUsableSpec(spec, path15.basename(f));
13043
13943
  out.push({ file: f, spec });
13044
13944
  }
13045
13945
  if (out.length === 0) throw new Error(`${target} \u4E0B\u6CA1\u6709\u7528\u4F8B\uFF08*.yml\uFF09`);
@@ -13047,8 +13947,8 @@ async function loadCases(target) {
13047
13947
  }
13048
13948
  async function chironTestCommand(target, args, deps) {
13049
13949
  try {
13050
- const root = path14.resolve(args.project ?? ".");
13051
- const where = path14.resolve(root, target ?? "tests");
13950
+ const root = path15.resolve(args.project ?? ".");
13951
+ const where = path15.resolve(root, target ?? "tests");
13052
13952
  const cases = await loadCases(where);
13053
13953
  const report = [];
13054
13954
  let failed2 = 0;
@@ -13060,7 +13960,7 @@ async function chironTestCommand(target, args, deps) {
13060
13960
  deps
13061
13961
  );
13062
13962
  failed2 += results.filter((r) => r.verdict === "fail").length;
13063
- report.push({ case: spec.name, file: path14.relative(root, file), results });
13963
+ report.push({ case: spec.name, file: path15.relative(root, file), results });
13064
13964
  }
13065
13965
  const fmt = args.output ?? "table";
13066
13966
  if (fmt === "json" || fmt === "yaml") {
@@ -13201,7 +14101,7 @@ import {
13201
14101
  writeRisk
13202
14102
  } from "@hcmai/sdk";
13203
14103
  import { existsSync as existsSync3 } from "fs";
13204
- import * as path15 from "path";
14104
+ import * as path16 from "path";
13205
14105
  function premise(message, hint = "") {
13206
14106
  process.stderr.write(message + (hint ? `
13207
14107
  \u2192 ${hint}` : "") + "\n");
@@ -13228,13 +14128,13 @@ async function runSeedPlan(args, client3) {
13228
14128
  const reconDir = candidates[0].reconDir;
13229
14129
  if (candidates.length > 1) {
13230
14130
  process.stderr.write(
13231
- `\u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u6709 ${candidates.length} \u4EFD\u57FA\u7EBF\uFF0C\u672C\u8F6E\u8BFB\u7684\u662F \`${path15.basename(reconDir)}\`\uFF1A` + candidates.slice(1).map((c) => `\`${path15.basename(c.reconDir)}\``).join("\u3001") + " \u672A\u88AB\u8BFB\u53D6 \u2014\u2014 \u4E0D\u540C sourceKey \u7684\u4EA7\u7269**\u4E0D\u53EF\u4E92\u6362**\u3002\n"
14131
+ `\u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u6709 ${candidates.length} \u4EFD\u57FA\u7EBF\uFF0C\u672C\u8F6E\u8BFB\u7684\u662F \`${path16.basename(reconDir)}\`\uFF1A` + candidates.slice(1).map((c) => `\`${path16.basename(c.reconDir)}\``).join("\u3001") + " \u672A\u88AB\u8BFB\u53D6 \u2014\u2014 \u4E0D\u540C sourceKey \u7684\u4EA7\u7269**\u4E0D\u53EF\u4E92\u6362**\u3002\n"
13232
14132
  );
13233
14133
  }
13234
14134
  const round = inspectRound2(reconDir);
13235
14135
  process.stderr.write(roundWarning(round));
13236
14136
  const baseline = {
13237
- path: `${path15.basename(path15.dirname(reconDir))}/${path15.basename(reconDir)}`,
14137
+ path: `${path16.basename(path16.dirname(reconDir))}/${path16.basename(reconDir)}`,
13238
14138
  roundId: round.roundId ?? null
13239
14139
  };
13240
14140
  let exemptions = null;
@@ -13496,7 +14396,7 @@ async function deliverySeedVerifyCommand(args) {
13496
14396
  // src/commands/delivery-seed-find.ts
13497
14397
  import { existsSync as existsSync4 } from "fs";
13498
14398
  import { readFileSync as readFileSync8 } from "fs";
13499
- import * as path16 from "path";
14399
+ import * as path17 from "path";
13500
14400
  import {
13501
14401
  INIT_EXIT_CODES as INIT_EXIT_CODES2,
13502
14402
  ValueHints,
@@ -13510,10 +14410,10 @@ import {
13510
14410
  valuesRoundCaveat
13511
14411
  } from "@hcmai/sdk";
13512
14412
  function provenance(chosenReconDir, others) {
13513
- let line = `> \u57FA\u7EBF\uFF1A\`${path16.basename(chosenReconDir)}\`
14413
+ let line = `> \u57FA\u7EBF\uFF1A\`${path17.basename(chosenReconDir)}\`
13514
14414
  `;
13515
14415
  if (others.length > 0) {
13516
- line += `> \u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u53E6\u6709 ${others.length} \u4EFD\u57FA\u7EBF\u672A\u88AB\u8BFB\u53D6\uFF1A` + others.map((o) => `\`${path16.basename(o)}\``).join("\u3001") + " \u2014\u2014 \u4E0D\u540C sourceKey \u7684\u4EA7\u7269**\u4E0D\u53EF\u4E92\u6362**\u3002\n";
14416
+ line += `> \u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u53E6\u6709 ${others.length} \u4EFD\u57FA\u7EBF\u672A\u88AB\u8BFB\u53D6\uFF1A` + others.map((o) => `\`${path17.basename(o)}\``).join("\u3001") + " \u2014\u2014 \u4E0D\u540C sourceKey \u7684\u4EA7\u7269**\u4E0D\u53EF\u4E92\u6362**\u3002\n";
13517
14417
  }
13518
14418
  return `${line}
13519
14419
  `;
@@ -13850,7 +14750,7 @@ import {
13850
14750
  runTriageRound
13851
14751
  } from "@hcmai/sdk";
13852
14752
  import { mkdirSync as mkdirSync2, readFileSync as readFileSync10, writeFileSync as writeFileSync3 } from "fs";
13853
- import * as path17 from "path";
14753
+ import * as path18 from "path";
13854
14754
  var DEFAULT_CAPABILITIES3 = "default";
13855
14755
  function premise4(message, hint) {
13856
14756
  process.stderr.write(`\u{1F534} \u524D\u63D0\u4E0D\u6210\u7ACB\uFF1A${message}
@@ -13886,8 +14786,8 @@ function renderProblems(rows2) {
13886
14786
  `;
13887
14787
  }
13888
14788
  function writeTriageArtifact(outDir, body) {
13889
- const out = path17.join(outDir, "work", "triage.md");
13890
- mkdirSync2(path17.dirname(out), { recursive: true });
14789
+ const out = path18.join(outDir, "work", "triage.md");
14790
+ mkdirSync2(path18.dirname(out), { recursive: true });
13891
14791
  writeFileSync3(out, body, "utf8");
13892
14792
  return out;
13893
14793
  }
@@ -13933,21 +14833,21 @@ import {
13933
14833
  adminResetPassword,
13934
14834
  formatObject as formatObject30,
13935
14835
  fromAxiosError as fromAxiosError23,
13936
- CliError as CliError28,
13937
- CliErrorCode as CliErrorCode26
14836
+ CliError as CliError31,
14837
+ CliErrorCode as CliErrorCode30
13938
14838
  } from "@hcmai/sdk";
13939
14839
  function buildAdminResetPasswordRequest(args, password) {
13940
14840
  const hasId = Boolean(args.id);
13941
14841
  const hasUsername = Boolean(args.username);
13942
14842
  if (hasId === hasUsername) {
13943
- throw new CliError28({
13944
- code: CliErrorCode26.INVALID_ARGUMENT,
14843
+ throw new CliError31({
14844
+ code: CliErrorCode30.INVALID_ARGUMENT,
13945
14845
  message: "--id <uuid> \u4E0E --username <user> \u5FC5\u987B\u4E14\u53EA\u80FD\u63D0\u4F9B\u4E00\u4E2A"
13946
14846
  });
13947
14847
  }
13948
14848
  if (!password) {
13949
- throw new CliError28({
13950
- code: CliErrorCode26.INVALID_ARGUMENT,
14849
+ throw new CliError31({
14850
+ code: CliErrorCode30.INVALID_ARGUMENT,
13951
14851
  message: "\u65B0\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A"
13952
14852
  });
13953
14853
  }
@@ -13976,8 +14876,8 @@ async function promptPasswordTwice() {
13976
14876
  const password = await promptSecret("\u65B0\u5BC6\u7801: ");
13977
14877
  const confirmation = await promptSecret("\u518D\u6B21\u8F93\u5165\u65B0\u5BC6\u7801: ");
13978
14878
  if (password !== confirmation) {
13979
- throw new CliError28({
13980
- code: CliErrorCode26.INVALID_ARGUMENT,
14879
+ throw new CliError31({
14880
+ code: CliErrorCode30.INVALID_ARGUMENT,
13981
14881
  message: "\u4E24\u6B21\u8F93\u5165\u7684\u65B0\u5BC6\u7801\u4E0D\u4E00\u81F4"
13982
14882
  });
13983
14883
  }
@@ -14108,7 +15008,7 @@ var chiron = program.command("chiron").description(
14108
15008
  );
14109
15009
  chiron.command("init").description("\u5EFA\u987E\u95EE\u9879\u76EE\u4ED3\uFF1A\u5199 env.yaml\u3001\u5EFA\u76EE\u5F55\u3001\u5199 AGENTS/CLAUDE \u8FB9\u754C\u5757\u3002\u7EAF\u672C\u5730\uFF0C\u65AD\u7F51\u4E5F\u80FD\u5EFA\uFF1B\u91CD\u8DD1\u5B89\u5168").option("--project <dir>", "\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--env <name>", "\u7ED1\u5230\u672C\u673A\u54EA\u4E2A\u73AF\u5883\uFF08\u6216\u5DF2\u6709 env.yaml \u91CC\u7684\u73AF\u5883\u540D\uFF09").option("--endpoint <url>", "\u5B8C\u5168\u663E\u5F0F\u5730\u58F0\u660E\u540E\u7AEF\u5730\u5740\uFF08\u4E0D\u9700\u8981\u5148\u767B\u5F55\uFF0C\u4E5F\u4E0D\u53D1\u4EFB\u4F55\u8BF7\u6C42\uFF09").option("--frontend <url>", "\u524D\u7AEF\u5730\u5740\uFF08\u914D\u5408 --endpoint\uFF1B\u9ED8\u8BA4\u4E0E\u540E\u7AEF\u540C\u5740\uFF09").option("--tenant <id>", "\u79DF\u6237\u53F7\uFF08\u914D\u5408 --endpoint\uFF1B\u9ED8\u8BA4 1\uFF09").option("--with-skills", "\u987A\u624B\u628A\u6280\u80FD\u4E5F\u88C5\u4E0A\uFF08\u9ED8\u8BA4\u4E0D\u88C5\uFF0C\u7528 hcm chiron skills sync\uFF09").option("--yes", "\u975E\u4EA4\u4E92\u5730\u786E\u8BA4\u300C\u5C31\u7528\u672C\u673A\u5F53\u524D\u6D3B\u52A8\u73AF\u5883\u300D").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => chironInitCommand(opts));
14110
15010
  chiron.command("test").description("\u6309\u7528\u4F8B\u8DD1\u4E00\u904D\u5E76\u628A\u95EE\u9898\u627E\u51FA\u6765\uFF1A\u7528\u4F8B\u5728\u9879\u76EE\u4ED3 tests/\uFF0C\u5224\u636E\u5FC5\u987B\u770B\u5185\u5BB9\uFF08\u53EA\u5224\u9000\u51FA\u7801\u7684\u7528\u4F8B\u4F1A\u88AB\u62D2\u7EDD\u52A0\u8F7D\uFF09").argument("[target]", "\u7528\u4F8B\u6587\u4EF6\u6216\u76EE\u5F55\uFF08\u9ED8\u8BA4 tests/\uFF09").option("--project <dir>", "\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--env <name>", "\u76EE\u6807\u73AF\u5883\uFF1B\u7528\u4F8B\u91CC\u6CA1\u5199 --env \u65F6\u8865\u4E0A").option("--as <identity>", "\u8EAB\u4EFD\uFF1B\u7528\u4F8B\u91CC\u6CA1\u5199 --as \u65F6\u8865\u4E0A").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((target, opts) => chironTestCommand(target, opts));
14111
- 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("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((target, opts) => chironPageCommand(target, opts));
15011
+ 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));
14112
15012
  chiron.command("doctor").description(
14113
15013
  "\u6838\u5BF9\uFF1A\u672C\u673A\u767B\u5F55\u662F\u5426\u5BF9\u7740 env.yaml \u7684\u73AF\u5883\uFF08\u542B\u4E94\u6761\u951A\u70B9\u4E0E\u5BF9\u8BDD\u63E1\u624B\uFF09/ \u6280\u80FD\u88C5\u6CA1\u88C5 / \u6848\u4F8B\u5E93\u8BFB\u4E0D\u8BFB\u5F97\u5230 / Jira \u80FD\u4E0D\u80FD\u63D0\u5355"
14114
15014
  ).option("--project <dir>", "\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--env <name>", "\u8986\u76D6\u8981\u6838\u7684\u73AF\u5883\u522B\u540D\uFF08\u9ED8\u8BA4\u53D6 env.yaml\uFF1B\u591A\u73AF\u5883\u9879\u76EE\u7528\u5B83\u6328\u4E2A\u63A2\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\u63A2\u951A\u70B9").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => chironDoctorCommand(opts));
@@ -14121,11 +15021,12 @@ projectEnv.command("list").description("\u5217\u51FA\u9879\u76EE\u73AF\u5883\u30
14121
15021
  projectEnv.command("add <name>").description("\u6DFB\u52A0\u9879\u76EE\u73AF\u5883\u5E76\u5C31\u5730\u6838\u9A8C\u5730\u5740\u4E0E token \u79DF\u6237").requiredOption("--endpoint <url>", "\u540E\u7AEF\u5B8C\u6574 URL").requiredOption("--frontend <url>", "\u524D\u7AEF\u5B8C\u6574 URL").requiredOption("--tenant <id>", "\u79DF\u6237").option("--danger", "\u5199\u64CD\u4F5C\u8981\u6C42\u663E\u5F0F --allow-danger").option("--default", "\u8BBE\u4E3A\u9879\u76EE\u9ED8\u8BA4\u73AF\u5883").option("--project <dir>", "\u9879\u76EE\u76EE\u5F55\uFF08\u5411\u4E0A\u5BFB\u627E env.yaml\uFF09", ".").option(...OUTPUT_OPT).action((name, opts) => chironEnvCommand("add", { ...opts, name }));
14122
15022
  projectEnv.command("edit <name> <field> <value>").description("\u7F16\u8F91 endpoint/frontend/tenant/danger/default\uFF1Bdefault true \u8BBE\u4E3A\u9ED8\u8BA4").option("--yes", "\u786E\u8BA4\u5173\u95ED danger \u540E\u4E0D\u518D\u62E6\u5199\u64CD\u4F5C").option("--project <dir>", "\u9879\u76EE\u76EE\u5F55\uFF08\u5411\u4E0A\u5BFB\u627E env.yaml\uFF09", ".").option(...OUTPUT_OPT).action((name, field, value, opts) => chironEnvCommand("edit", { ...opts, name, field, value }));
14123
15023
  projectEnv.command("remove <name>").description("\u5220\u9664\u9879\u76EE\u73AF\u5883\uFF1B\u9ED8\u8BA4\u9879\u987B\u5148\u6539\u5230\u5176\u4ED6\u73AF\u5883").option("--project <dir>", "\u9879\u76EE\u76EE\u5F55\uFF08\u5411\u4E0A\u5BFB\u627E env.yaml\uFF09", ".").option(...OUTPUT_OPT).action((name, opts) => chironEnvCommand("remove", { ...opts, name }));
14124
- var gap = chiron.command("gap").description("\u7F3A\u53E3\uFF1A\u649E\u5230\u300C\u4EA7\u54C1\u505A\u4E0D\u5230\u300D\u65F6\u7684\u7EDF\u4E00\u51FA\u53E3\uFF0C\u8FDB Jira\uFF08HCMNX\uFF09\u2014\u2014\u67E5\u91CD search / \u67E5\u8FDB\u5EA6 status / \u8BFB\u8BC4\u8BBA comments / \u63D0\u7F3A\u53E3 submit");
15024
+ var gap = chiron.command("gap").description("\u7F3A\u53E3\uFF1A\u649E\u5230\u300C\u4EA7\u54C1\u505A\u4E0D\u5230\u300D\u65F6\u7684\u7EDF\u4E00\u51FA\u53E3\uFF0C\u8FDB Jira\uFF08HCMNX\uFF09\u2014\u2014\u67E5\u91CD search / \u67E5\u8FDB\u5EA6 status / \u8BFB\u8BC4\u8BBA comments / \u63D0\u7F3A\u53E3 submit / \u9A8C\u6536 verify");
14125
15025
  gap.command("search").description("\u67E5\u91CD\uFF1A\u6309\u9519\u8BEF\u7801 / Model / Action / \u4E00\u53E5\u73B0\u8C61\u67E5 Jira\uFF0C\u5E26\u56DE\u7F16\u53F7\u4E0E\u72B6\u6001").argument("<keywords...>", "\u5173\u952E\u8BCD\uFF0C\u6BCF\u4E2A\u5355\u72EC\u67E5\u4E00\u6B21").option("--no-include-closed", "\u53EA\u67E5\u672A\u89E3\u51B3\u7684").option(...OUTPUT_OPT).action((keywords, opts) => gapSearchCommand(keywords, opts));
14126
15026
  gap.command("status").description("\u67E5\u8FDB\u5EA6\uFF1A\u7ED9 Jira \u5355\u53F7\uFF08HCMNX-12 \u6216\u88F8\u6570\u5B57 12\uFF09\u3002\u4EA7\u54C1\u4FA7\u6700\u65B0\u5904\u7406\u4E0E\u6700\u65B0\u8BC4\u8BBA\u5404\u7ED9\u9996\u884C\uFF0C\u5168\u6587\u770B comments").argument("<ref>", "Jira \u5355\u53F7").option(...OUTPUT_OPT).action((ref, opts) => gapStatusCommand(ref, opts));
14127
15027
  gap.command("comments").description("\u8BFB\u8BC4\u8BBA\uFF1A\u6309\u65F6\u95F4\u6B63\u5E8F\u5217\u51FA\u8FD9\u5355\u4E0B\u7684\u8BC4\u8BBA\u2014\u2014\u65F6\u95F4\uFF08\u5230\u5206\u949F\uFF09/ \u4F5C\u8005 / \u5168\u6587 / \u8BC4\u8BBA\u6C38\u4E45\u94FE\u63A5").argument("<ref>", "Jira \u5355\u53F7").option("--limit <n>", "\u53EA\u770B\u6700\u8FD1 N \u6761\uFF08\u4ECD\u6309\u65F6\u95F4\u6B63\u5E8F\uFF09").option(...OUTPUT_OPT).action((ref, opts) => gapCommentsCommand(ref, opts));
14128
15028
  gap.command("submit").description("\u63D0\u7F3A\u53E3\uFF1A\u5148\u67E5\u91CD\uFF08\u540C\u4E00\u7F3A\u53E3\u8FFD\u52A0\u300C\u53C8\u4E00\u4E2A\u73B0\u573A\u300D\uFF09\uFF0C\u5426\u5219\u6309 HCMNX \u5FC5\u586B\u683C\u65B0\u5F00\uFF1B\u8F7D\u8377 JSON \u8D70 --file \u6216\u6807\u51C6\u8F93\u5165").option("--file <path>", "\u7F3A\u53E3\u8F7D\u8377 JSON\uFF08title/phenomenon/repro/expected/alternative/q_*/severity/kind/module\u2026\uFF09").option("--env <name>", "\u53D6\u73AF\u5883\u6307\u7EB9\u7528\u7684\u73AF\u5883\u522B\u540D\uFF08\u7F3A\u7701 activeEnv\uFF09").option("--fingerprint <text>", "\u76F4\u63A5\u7ED9\u6307\u7EB9\u6587\u672C\uFF08\u8BAD\u7EC3\u573A\u4ECE \u573A.yml \u53D6\u65F6\u7528\uFF09\uFF0C\u4E0D\u518D\u73B0\u67E5").option("--issuetype <name>", "\u8986\u76D6 issuetype\uFF08\u7F3A\u7701\u6309 kind \u9009 \u6545\u969C / \u9700\u6C42\uFF09").option("--assignee <user>", "\u8986\u76D6\u7ECF\u529E\u4EBA\uFF08\u7F3A\u7701\u9879\u76EE\u8D1F\u8D23\u4EBA\uFF09").option(...OUTPUT_OPT).action((opts) => gapSubmitCommand(opts));
15029
+ gap.command("verify").description("\u9A8C\u6536\uFF1A\u4FEE\u590D\u53D1\u5230\u4F60\u7684\u73AF\u5883\u5E76\u6309\u6280\u80FD\u590D\u9A8C\u540E\uFF0C\u7531\u63D0\u5355\u4EBA\u56DE\u5199\u7ED3\u8BBA\u2014\u2014pass \u5173\u5355\u3001fail \u9000\u56DE\u3001partial \u53EA\u8BB0\u5F55\u4E0D\u5173\u5355\uFF1B\u53EA\u5728\u300C\u5DF2\u4FEE\u590D\u300D\u4E0A\u505A").argument("<ref>", "Jira \u5355\u53F7\uFF08HCMNX-12 \u6216\u88F8\u6570\u5B57 12\uFF09\uFF0C\u53EA\u80FD\u662F\u4F60\u81EA\u5DF1\u63D0\u7684\u5355").requiredOption("--result <result>", "\u590D\u9A8C\u7ED3\u8BBA\uFF1Apass\uFF08\u539F\u6545\u969C\u4E0D\u518D\u51FA\u73B0\uFF09/ fail\uFF08\u4ECD\u590D\u73B0\uFF0C\u6216\u9A8C\u51FA\u6CA1\u901A\u8FC7\u7684\uFF09/ partial\uFF08\u53EA\u9A8C\u4E86\u4E00\u90E8\u5206\u3001\u9A8C\u8FC7\u7684\u90FD\u901A\u8FC7\uFF1B\u4E0D\u5173\u5355\uFF09").option("--body <text>", "\u9A8C\u6536\u8BC1\u636E\uFF1A\u73AF\u5883\u3001\u7248\u672C\u3001\u6309\u6280\u80FD\u8DD1\u4E86\u4EC0\u4E48\u3001\u770B\u5230\u4E86\u4EC0\u4E48").option("--file <path>", "\u4ECE\u6587\u4EF6\u8BFB\u9A8C\u6536\u8BC1\u636E\uFF08\u4E0E --body \u4E8C\u9009\u4E00\uFF1B\u90FD\u4E0D\u7ED9\u5C31\u8BFB\u6807\u51C6\u8F93\u5165\uFF09").option("--env <name>", "\u53D6\u73AF\u5883\u6307\u7EB9\u7528\u7684\u73AF\u5883\u522B\u540D\uFF08\u7F3A\u7701 activeEnv\uFF09").option("--fingerprint <text>", "\u76F4\u63A5\u7ED9\u6307\u7EB9\u6587\u672C\uFF0C\u4E0D\u518D\u73B0\u67E5").option("--dry-run", "\u53EA\u6838\u5BF9\u5E76\u6253\u5370\u8BA1\u5212\uFF0C\u4E0D\u5199 Jira").option(...OUTPUT_OPT).action((ref, opts) => gapVerifyCommand(ref, opts));
14129
15030
  var kase = chiron.command("case").description("\u516C\u5171\u6848\u4F8B\u5E93\uFF1A\u67E5 search / \u770B show / \u5BF9\u6307\u7EB9 match / \u9879\u76EE\u6848\u4F8B\u4E0A\u884C submit");
14130
15031
  kase.command("search").description("\u6309\u5BA2\u6237\u539F\u8BDD / \u9519\u8BEF\u7801 / Model / \u6280\u80FD\u627E\u516C\u5171\u6848\u4F8B\uFF0C\u5E76\u6309\u5F53\u524D\u73AF\u5883\u6307\u7EB9\u6807\u5339\u914D").argument("<query>", "\u4E00\u53E5\u8BDD\u6216\u5173\u952E\u8BCD").option("--top-k <n>", "\u53D6\u524D\u51E0\u6761\uFF081-10\uFF09", "5").option("--refresh", "\u5FFD\u7565\u672C\u673A\u7D22\u5F15\u7F13\u5B58\uFF08\u9ED8\u8BA4\u5B58\u4E00\u5C0F\u65F6\uFF09\uFF0C\u73B0\u62C9\u4E00\u4EFD \u2014\u2014 \u6848\u4F8B\u521A\u5408\u8FDB\u6848\u4F8B\u5E93\u65F6\u7528").option("--env <name>", "\u7528\u54EA\u4E2A\u73AF\u5883\u7684\u540E\u7AEF\u6307\u7EB9\u6BD4\u5BF9\uFF08\u4E0D\u7ED9\u5C31\u6807\u300C\u672A\u6BD4\u5BF9\u300D\uFF0C\u4E0D\u5047\u88C5\u5339\u914D\uFF09").option(...OUTPUT_OPT).action((query, opts) => caseSearchCommand(query, { ...opts, topK: Number(opts.topK) }));
14131
15032
  kase.command("show").description("\u8BFB\u4E00\u4E2A\u6848\u4F8B\u7684\u6B63\u6587\uFF08\u9ED8\u8BA4 \u95EE\u9898.md + \u65B9\u6848.md\uFF09").argument("<id>", "\u6848\u4F8B id\uFF0C\u5982 CASE-20260828-xxx").option("--refresh", "\u5FFD\u7565\u672C\u673A\u7D22\u5F15\u7F13\u5B58\uFF08\u9ED8\u8BA4\u5B58\u4E00\u5C0F\u65F6\uFF09\uFF0C\u73B0\u62C9\u4E00\u4EFD \u2014\u2014 \u6848\u4F8B\u521A\u5408\u8FDB\u6848\u4F8B\u5E93\u65F6\u7528").option("--file <name>", "\u53EA\u770B\u67D0\u4E00\u4EFD\u6587\u4EF6").option(...OUTPUT_OPT).action((id, opts) => caseShowCommand(id, opts));
@@ -14310,7 +15211,7 @@ program.command("update <Model>").description("\u66F4\u65B0\u4E00\u6761 Model \u
14310
15211
  ).action((model, opts) => updateCommand(model, opts));
14311
15212
  program.command("version").description("\u67E5 CLI \u4E0E\u540E\u7AEF\u4E24\u4E2A\u7248\u672C\uFF08commit / tag / \u6784\u5EFA\u65F6\u95F4\uFF09\u2014\u2014\u514D\u8BA4\u8BC1\uFF0C\u65E0\u9700\u5148 login").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("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => versionCommand(opts));
14312
15213
  program.command("upgrade").alias("self-update").description("\u5347\u7EA7 CLI \u81EA\u5DF1\uFF08\u6CE8\u610F\uFF1A`hcm update` \u662F\u66F4\u65B0\u4E1A\u52A1\u8BB0\u5F55\uFF0C\u4E0D\u662F\u5347\u7EA7\uFF09").option("--check", "\u53EA\u68C0\u67E5\uFF1B\u6709\u65B0\u7248\u672C\u65F6\u4EE5\u9000\u51FA\u7801 1 \u7ED3\u675F\uFF0C\u4FBF\u4E8E\u811A\u672C\u5224\u65AD").action((opts) => upgradeCommand(opts));
14313
- program.command("open [path]").description("\u7528\u5F53\u524D CLI \u8EAB\u4EFD\u6253\u5F00\u524D\u7AEF\u9875\u9762\uFF1A\u94F8\u4E00\u5F20 60s \u4E00\u6B21\u6027\u7968\u636E\u4EA4\u7ED9\u6D4F\u89C8\u5668\uFF0C\u4F1A\u8BDD token \u4E0D\u8FDB URL").option("--print-url", "\u53EA\u6253\u5370\u767B\u5F55 URL\uFF0C\u4E0D\u5F00\u6D4F\u89C8\u5668\uFF08\u7ED9 agent \u6D4F\u89C8\u5668 navigate \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\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").action((path18, opts) => openCommand(path18, opts));
15214
+ program.command("open [path]").description("\u7528\u5F53\u524D CLI \u8EAB\u4EFD\u6253\u5F00\u524D\u7AEF\u9875\u9762\uFF1A\u94F8\u4E00\u5F20 60s \u4E00\u6B21\u6027\u7968\u636E\u4EA4\u7ED9\u6D4F\u89C8\u5668\uFF0C\u4F1A\u8BDD token \u4E0D\u8FDB URL").option("--print-url", "\u53EA\u6253\u5370\u767B\u5F55 URL\uFF0C\u4E0D\u5F00\u6D4F\u89C8\u5668\uFF08\u7ED9 agent \u6D4F\u89C8\u5668 navigate \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\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").action((path19, opts) => openCommand(path19, opts));
14314
15215
  var setting = program.command("setting").description("\u79DF\u6237\u7CFB\u7EDF\u53C2\u6570\uFF08\u767B\u5F55\u7B56\u7565 / \u5BC6\u7801\u7B56\u7565 / \u529F\u80FD\u5F00\u5173 / \u96C6\u6210\u53C2\u6570\uFF09");
14315
15216
  setting.command("get <domain>").description("\u8BFB\u67D0\u57DF\u53C2\u6570\uFF08\u5B9A\u4E49 + \u79DF\u6237\u8986\u76D6\u503C\u5408\u5E76\uFF0C\u7F3A\u5931\u56DE\u843D\u9ED8\u8BA4\u503C\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", "table").action((d, opts) => settingGetCommand(d, opts));
14316
15217
  setting.command("set <domain>").description("\u6539\u53C2\u6570\uFF0C\u53EF\u91CD\u590D --set\uFF1B\u8D70\u53D7\u63A7\u6821\u9A8C\u8DEF\u5F84\u800C\u975E\u6807\u51C6 CRUD").option(