@hcmai/cli 0.4.29 → 0.4.31

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
@@ -532,8 +532,8 @@ var init_TerminalRenderer = __esm({
532
532
  }
533
533
  }
534
534
  /** 来源行(仅子代理触发,agentPath ≥2 段时显示 `↑ 来自 a › b`,对齐 Web)。 */
535
- originLine(path18) {
536
- const segs = path18.split(".").filter(Boolean);
535
+ originLine(path19) {
536
+ const segs = path19.split(".").filter(Boolean);
537
537
  if (segs.length < 2) return "";
538
538
  const names = segs.map((k) => agentDisplayName(k));
539
539
  return chalk.gray(` \u2191 \u6765\u81EA ${names.join(" \u203A ")}`) + "\n";
@@ -1715,8 +1715,8 @@ function agentLabel(agentId) {
1715
1715
  if (/^[0-9a-f]{8}-[0-9a-f-]{27}$/i.test(agentId)) return `agent \u2026${agentId.slice(-4)}`;
1716
1716
  return agentDisplayName(agentId);
1717
1717
  }
1718
- function originLine(path18) {
1719
- const segs = (path18 ?? "").split(".").filter(Boolean);
1718
+ function originLine(path19) {
1719
+ const segs = (path19 ?? "").split(".").filter(Boolean);
1720
1720
  if (segs.length < 2) return null;
1721
1721
  return `\u6765\u81EA ${segs.map((k) => agentDisplayName(k)).join(" \u203A ")}`;
1722
1722
  }
@@ -3362,7 +3362,7 @@ function launchBrowser(url, platform = process.platform) {
3362
3362
  child.unref();
3363
3363
  }
3364
3364
  async function runOpen(target, args, deps) {
3365
- const path18 = normalizeTarget(target);
3365
+ const path19 = normalizeTarget(target);
3366
3366
  if (!deps.frontend?.trim()) {
3367
3367
  throw new CliError12({
3368
3368
  code: CliErrorCode11.INVALID_ARGUMENT,
@@ -3370,13 +3370,13 @@ async function runOpen(target, args, deps) {
3370
3370
  });
3371
3371
  }
3372
3372
  const { ticket, expiresIn } = await deps.mintTicket();
3373
- const url = buildBrowserLoginUrl(deps.frontend, ticket, path18);
3373
+ const url = buildBrowserLoginUrl(deps.frontend, ticket, path19);
3374
3374
  if (args.printUrl) {
3375
3375
  deps.write(`${url}
3376
3376
  `);
3377
3377
  } else {
3378
3378
  deps.launch(url);
3379
- 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
3379
+ 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
3380
3380
  `);
3381
3381
  }
3382
3382
  return { url, expiresIn };
@@ -3470,8 +3470,8 @@ import {
3470
3470
  formatObject as formatObject7,
3471
3471
  fromAxiosError as fromAxiosError9
3472
3472
  } from "@hcmai/sdk";
3473
- function collectYmlFiles(path18) {
3474
- if (statSync(path18).isFile()) return [path18];
3473
+ function collectYmlFiles(path19) {
3474
+ if (statSync(path19).isFile()) return [path19];
3475
3475
  const out = [];
3476
3476
  const walk = (dir) => {
3477
3477
  for (const name of readdirSync(dir).sort()) {
@@ -3480,7 +3480,7 @@ function collectYmlFiles(path18) {
3480
3480
  else if (full.endsWith(".yml") || full.endsWith(".yaml")) out.push(full);
3481
3481
  }
3482
3482
  };
3483
- walk(path18);
3483
+ walk(path19);
3484
3484
  return out.sort();
3485
3485
  }
3486
3486
  var DRY_RUN_CLIENT = {
@@ -3488,9 +3488,9 @@ var DRY_RUN_CLIENT = {
3488
3488
  create: async () => ({ id: "" }),
3489
3489
  update: async () => ({})
3490
3490
  };
3491
- async function importCommand(path18, args) {
3491
+ async function importCommand(path19, args) {
3492
3492
  try {
3493
- const files = collectYmlFiles(path18);
3493
+ const files = collectYmlFiles(path19);
3494
3494
  const fixtures = files.map(
3495
3495
  (f) => parseFixture(readFileSync2(f, "utf8"), relative(process.cwd(), f))
3496
3496
  );
@@ -4898,7 +4898,7 @@ async function datapackageInstallCommand(artifactPath, args) {
4898
4898
  }
4899
4899
  const timeoutMs = Math.max(1, Number(args.timeout ?? DEFAULT_INSTALL_WAIT_SECONDS)) * 1e3;
4900
4900
  const showProgress = human && process.stderr.isTTY === true;
4901
- const { run, timedOut } = await waitForInstallRun(client3, accepted.runId, {
4901
+ const { run: run2, timedOut } = await waitForInstallRun(client3, accepted.runId, {
4902
4902
  timeoutMs,
4903
4903
  onProgress: showProgress ? (r) => process.stderr.write(`\r${renderProgress(r)}`.padEnd(96)) : void 0
4904
4904
  });
@@ -4912,27 +4912,27 @@ async function datapackageInstallCommand(artifactPath, args) {
4912
4912
  }
4913
4913
  emit3({
4914
4914
  runId: accepted.runId,
4915
- status: run?.status ?? "RUNNING",
4916
- phase: run?.phase,
4917
- filesDone: run?.filesDone,
4918
- filesTotal: run?.filesTotal,
4919
- rowsDone: run?.rowsDone,
4915
+ status: run2?.status ?? "RUNNING",
4916
+ phase: run2?.phase,
4917
+ filesDone: run2?.filesDone,
4918
+ filesTotal: run2?.filesTotal,
4919
+ rowsDone: run2?.rowsDone,
4920
4920
  timedOut: true,
4921
4921
  next_step: `hcm datapackage status ${accepted.runId}`
4922
4922
  }, fmt);
4923
4923
  process.exitCode = 0;
4924
4924
  return;
4925
4925
  }
4926
- const failed2 = run?.status !== "SUCCESS";
4926
+ const failed2 = run2?.status !== "SUCCESS";
4927
4927
  if (human) {
4928
4928
  process.stdout.write(
4929
- `${failed2 ? "\u274C" : "\u2705"} ${run?.packageCode ?? accepted.packageName ?? "?"} v${run?.version ?? accepted.version ?? "?"} \u2192 ${run?.status ?? "?"}\uFF08rowCount=${run?.rowCount ?? 0}\uFF0C${Math.round((run?.durationMs ?? 0) / 1e3)}s\uFF09
4929
+ `${failed2 ? "\u274C" : "\u2705"} ${run2?.packageCode ?? accepted.packageName ?? "?"} v${run2?.version ?? accepted.version ?? "?"} \u2192 ${run2?.status ?? "?"}\uFF08rowCount=${run2?.rowCount ?? 0}\uFF0C${Math.round((run2?.durationMs ?? 0) / 1e3)}s\uFF09
4930
4930
  `
4931
4931
  );
4932
- if (run?.errorMessage) process.stdout.write(` \u539F\u56E0\uFF1A${run.errorMessage}
4932
+ if (run2?.errorMessage) process.stdout.write(` \u539F\u56E0\uFF1A${run2.errorMessage}
4933
4933
  `);
4934
4934
  }
4935
- emit3({ ...run ?? {}, runId: accepted.runId, documentId: accepted.documentId }, fmt);
4935
+ emit3({ ...run2 ?? {}, runId: accepted.runId, documentId: accepted.documentId }, fmt);
4936
4936
  process.exitCode = failed2 ? 1 : 0;
4937
4937
  return;
4938
4938
  } catch (e) {
@@ -4950,9 +4950,9 @@ async function datapackageStatusCommand(runId, args) {
4950
4950
  try {
4951
4951
  const ctx = await getActiveAuthContextFromCli(args);
4952
4952
  const client3 = HcmClient17.fromAuthContext(ctx);
4953
- const run = await fetchInstallRun(client3, runId);
4953
+ const run2 = await fetchInstallRun(client3, runId);
4954
4954
  const fmt = args.output ?? "json";
4955
- if (!run) {
4955
+ if (!run2) {
4956
4956
  if (fmt !== "json") {
4957
4957
  process.stdout.write(`\u23F3 \u6D41\u6C34 ${runId} \u8FD8\u6CA1\u51FA\u73B0\u2014\u2014\u521A\u53D7\u7406\u7684\u88C5\u8F7D\u4F1A\u6709\u51E0\u767E\u6BEB\u79D2\u7684\u7A7A\u7A97\u3002
4958
4958
  `);
@@ -4962,12 +4962,12 @@ async function datapackageStatusCommand(runId, args) {
4962
4962
  return;
4963
4963
  }
4964
4964
  if (fmt !== "json") {
4965
- process.stdout.write(`${renderProgress(run)}
4965
+ process.stdout.write(`${renderProgress(run2)}
4966
4966
  `);
4967
- if (run.errorMessage) process.stdout.write(` \u539F\u56E0\uFF1A${run.errorMessage}
4967
+ if (run2.errorMessage) process.stdout.write(` \u539F\u56E0\uFF1A${run2.errorMessage}
4968
4968
  `);
4969
4969
  }
4970
- emit3({ ...run, ...isTerminalRunStatus(run.status) ? {} : { next_step: `hcm datapackage status ${runId}` } }, fmt);
4970
+ emit3({ ...run2, ...isTerminalRunStatus(run2.status) ? {} : { next_step: `hcm datapackage status ${runId}` } }, fmt);
4971
4971
  process.exitCode = 0;
4972
4972
  return;
4973
4973
  } catch (e) {
@@ -4976,13 +4976,13 @@ async function datapackageStatusCommand(runId, args) {
4976
4976
  else exitWithError(e);
4977
4977
  }
4978
4978
  }
4979
- function renderProgress(run) {
4980
- if (!run) return "\u23F3 \u7B49\u5F85\u88C5\u8F7D\u6D41\u6C34\u51FA\u73B0\u2026";
4981
- const phase = run.phase ?? run.status ?? "?";
4982
- const files = run.filesTotal ? `${run.filesDone ?? 0}/${run.filesTotal} \u6587\u4EF6` : `${run.filesDone ?? 0} \u6587\u4EF6`;
4983
- const rows = run.rowsTotal ? `${run.rowsDone ?? 0}/${run.rowsTotal} \u884C` : `${run.rowsDone ?? 0} \u884C`;
4984
- const pct = run.rowsTotal ? ` ${Math.min(100, Math.round((run.rowsDone ?? 0) / run.rowsTotal * 100))}%` : "";
4985
- const file = run.currentFile ? ` ${truncateTail(run.currentFile, 42)}` : "";
4979
+ function renderProgress(run2) {
4980
+ if (!run2) return "\u23F3 \u7B49\u5F85\u88C5\u8F7D\u6D41\u6C34\u51FA\u73B0\u2026";
4981
+ const phase = run2.phase ?? run2.status ?? "?";
4982
+ const files = run2.filesTotal ? `${run2.filesDone ?? 0}/${run2.filesTotal} \u6587\u4EF6` : `${run2.filesDone ?? 0} \u6587\u4EF6`;
4983
+ const rows = run2.rowsTotal ? `${run2.rowsDone ?? 0}/${run2.rowsTotal} \u884C` : `${run2.rowsDone ?? 0} \u884C`;
4984
+ const pct = run2.rowsTotal ? ` ${Math.min(100, Math.round((run2.rowsDone ?? 0) / run2.rowsTotal * 100))}%` : "";
4985
+ const file = run2.currentFile ? ` ${truncateTail(run2.currentFile, 42)}` : "";
4986
4986
  return `\u23F3 ${phase}${pct} ${files} ${rows}${file}`;
4987
4987
  }
4988
4988
  function truncateTail(text, max) {
@@ -6606,10 +6606,10 @@ async function metaListCommand(args) {
6606
6606
  fail5(e, args);
6607
6607
  }
6608
6608
  }
6609
- async function metaGetCommand(path18, args) {
6609
+ async function metaGetCommand(path19, args) {
6610
6610
  try {
6611
6611
  const c = await client2(args);
6612
- const content = await getTenantMeta(c.raw(), path18);
6612
+ const content = await getTenantMeta(c.raw(), path19);
6613
6613
  process.stdout.write(content.endsWith("\n") ? content : content + "\n");
6614
6614
  process.exitCode = 0;
6615
6615
  return;
@@ -6618,8 +6618,8 @@ async function metaGetCommand(path18, args) {
6618
6618
  }
6619
6619
  }
6620
6620
  var PROBEABLE_META_TYPES = /* @__PURE__ */ new Set(["model", "list", "info", "view", "filter", "page", "wiz", "impexp"]);
6621
- function parseMetaPath(path18) {
6622
- const base = path18.split(/[\\/]/).pop() ?? path18;
6621
+ function parseMetaPath(path19) {
6622
+ const base = path19.split(/[\\/]/).pop() ?? path19;
6623
6623
  if (!/\.(yml|yaml)$/i.test(base)) return {};
6624
6624
  const parts = base.replace(/\.(yml|yaml)$/i, "").split(".");
6625
6625
  return { model: parts[0] || void 0, kind: parts[1] ?? "model", state: parts[2] };
@@ -6636,10 +6636,10 @@ function unverifiableReason(e) {
6636
6636
  if (st == null) return `\u8BF7\u6C42\u6CA1\u53D1\u51FA\u53BB\u6216\u6CA1\u56DE\u6765\uFF08${err.code ?? err.message ?? "\u672A\u77E5"}\uFF09`;
6637
6637
  return void 0;
6638
6638
  }
6639
- async function verifyAfterWrite(c, path18) {
6640
- const { model, kind, state } = parseMetaPath(path18);
6639
+ async function verifyAfterWrite(c, path19) {
6640
+ const { model, kind, state } = parseMetaPath(path19);
6641
6641
  if (!model || !kind) {
6642
- return { status: "unverified", where: "(\u672A\u63A2)", why: `\u4ECE\u8DEF\u5F84 ${path18} \u8BA4\u4E0D\u51FA\u6A21\u578B\u540D/\u5C42\u540D` };
6642
+ return { status: "unverified", where: "(\u672A\u63A2)", why: `\u4ECE\u8DEF\u5F84 ${path19} \u8BA4\u4E0D\u51FA\u6A21\u578B\u540D/\u5C42\u540D` };
6643
6643
  }
6644
6644
  try {
6645
6645
  await clearMetaCache2(c.raw(), model, {});
@@ -6670,21 +6670,21 @@ async function verifyAfterWrite(c, path18) {
6670
6670
  run: () => c.raw().get(`/api/models/${model}`, { params: { state: state ?? "default", size: 1 } })
6671
6671
  });
6672
6672
  }
6673
- for (const probe of probes) {
6673
+ for (const probe2 of probes) {
6674
6674
  try {
6675
- await probe.run();
6675
+ await probe2.run();
6676
6676
  } catch (e) {
6677
6677
  const why = unverifiableReason(e);
6678
- if (why) return { status: "unverified", where: probe.where, why };
6678
+ if (why) return { status: "unverified", where: probe2.where, why };
6679
6679
  const err = e;
6680
6680
  const body = err.response?.data;
6681
6681
  const raw = typeof body === "string" ? body : JSON.stringify(body ?? err.message ?? String(e));
6682
- return { status: "broken", where: probe.where, raw };
6682
+ return { status: "broken", where: probe2.where, raw };
6683
6683
  }
6684
6684
  }
6685
6685
  return { status: "ok" };
6686
6686
  }
6687
- async function metaSetCommand(path18, args) {
6687
+ async function metaSetCommand(path19, args) {
6688
6688
  try {
6689
6689
  if (!args.file) {
6690
6690
  throw new CliError19({
@@ -6700,9 +6700,9 @@ async function metaSetCommand(path18, args) {
6700
6700
  process.stdin.on("error", reject);
6701
6701
  }) : await fsp3.readFile(args.file, "utf8");
6702
6702
  if (!args.skipValidate) {
6703
- const result2 = validateMetaContent(path18, content);
6703
+ const result2 = validateMetaContent(path19, content);
6704
6704
  if (result2.issues.length > 0) {
6705
- process.stderr.write(`\u{1F50E} \u5199\u524D\u6821\u9A8C ${path18}\uFF08schema \u7C7B\u578B\uFF1A${result2.kind ?? "\u672A\u8BC6\u522B"}\uFF09
6705
+ process.stderr.write(`\u{1F50E} \u5199\u524D\u6821\u9A8C ${path19}\uFF08schema \u7C7B\u578B\uFF1A${result2.kind ?? "\u672A\u8BC6\u522B"}\uFF09
6706
6706
  `);
6707
6707
  process.stderr.write(formatMetaIssues(result2, " ") + "\n");
6708
6708
  }
@@ -6721,13 +6721,13 @@ async function metaSetCommand(path18, args) {
6721
6721
  if (dryFmt === "json" || dryFmt === "yaml") {
6722
6722
  process.stdout.write(
6723
6723
  formatObject18(
6724
- { dryRun: true, path: path18, bytes: Buffer.byteLength(content), content },
6724
+ { dryRun: true, path: path19, bytes: Buffer.byteLength(content), content },
6725
6725
  { format: dryFmt }
6726
6726
  ) + "\n"
6727
6727
  );
6728
6728
  } else {
6729
6729
  process.stdout.write(
6730
- `[dry-run] \u5C06\u5199\u5165 ${path18}\uFF08${Buffer.byteLength(content)} B\uFF09\u2014\u2014\u672A\u5B9E\u9645\u5199\u5165
6730
+ `[dry-run] \u5C06\u5199\u5165 ${path19}\uFF08${Buffer.byteLength(content)} B\uFF09\u2014\u2014\u672A\u5B9E\u9645\u5199\u5165
6731
6731
  ---
6732
6732
  ${content}
6733
6733
  `
@@ -6741,13 +6741,13 @@ ${content}
6741
6741
  let backupState = "unknown";
6742
6742
  let backupWhy;
6743
6743
  try {
6744
- const prev = await getTenantMeta(c.raw(), path18);
6744
+ const prev = await getTenantMeta(c.raw(), path19);
6745
6745
  if (!prev || prev.trim() === "") {
6746
6746
  backupState = "absent";
6747
6747
  } else {
6748
6748
  backupFile = nodePath.join(
6749
6749
  os3.tmpdir(),
6750
- `hcm-meta-backup-${Date.now()}-${path18.replace(/[\\/]/g, "_")}`
6750
+ `hcm-meta-backup-${Date.now()}-${path19.replace(/[\\/]/g, "_")}`
6751
6751
  );
6752
6752
  await fsp3.writeFile(backupFile, prev, "utf8");
6753
6753
  backupState = "saved";
@@ -6762,22 +6762,22 @@ ${content}
6762
6762
  backupWhy = `HTTP ${st ?? "-"}${err.code ? ` ${err.code}` : ""}${err.message ? `\uFF1A${err.message}` : ""}`;
6763
6763
  }
6764
6764
  }
6765
- const result = await saveTenantMeta(c.raw(), path18, content);
6765
+ const result = await saveTenantMeta(c.raw(), path19, content);
6766
6766
  const fmt = args.output ?? "json";
6767
- if (fmt !== "json") process.stdout.write(`\u2705 \u5DF2\u5199\u5165 ${path18}
6767
+ if (fmt !== "json") process.stdout.write(`\u2705 \u5DF2\u5199\u5165 ${path19}
6768
6768
  `);
6769
6769
  const restoreHint = backupState === "saved" && backupFile ? ` \u65E7\u5185\u5BB9\u5DF2\u5B58\uFF1A${backupFile}
6770
- \u653E\u56DE\u53BB\uFF1Ahcm meta set ${path18} --file ${backupFile}${connFlags(args)}
6771
- ` : 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)}
6770
+ \u653E\u56DE\u53BB\uFF1Ahcm meta set ${path19} --file ${backupFile}${connFlags(args)}
6771
+ ` : 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)}
6772
6772
  ` : ` \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
6773
- \u5148\u81EA\u5DF1\u8BFB\u4E00\u904D\u786E\u8BA4\uFF1Ahcm meta get ${path18}${connFlags(args)}
6773
+ \u5148\u81EA\u5DF1\u8BFB\u4E00\u904D\u786E\u8BA4\uFF1Ahcm meta get ${path19}${connFlags(args)}
6774
6774
  `;
6775
6775
  if (args.verify === false) {
6776
6776
  process.stderr.write(
6777
6777
  "\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
6778
6778
  );
6779
6779
  } else {
6780
- const outcome = await verifyAfterWrite(c, path18);
6780
+ const outcome = await verifyAfterWrite(c, path19);
6781
6781
  if (outcome.status === "broken") {
6782
6782
  const human = explainJacksonError(outcome.raw);
6783
6783
  process.stderr.write(
@@ -6810,19 +6810,19 @@ ${content}
6810
6810
  fail5(e, args);
6811
6811
  }
6812
6812
  }
6813
- async function metaDeleteCommand(path18, args) {
6813
+ async function metaDeleteCommand(path19, args) {
6814
6814
  try {
6815
6815
  if (!args.yes) {
6816
- const ok = await promptConfirm(`\u5C06\u5220\u9664\u5143\u6570\u636E ${path18}\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u9006\u3002\u7EE7\u7EED\uFF1F`);
6816
+ const ok = await promptConfirm(`\u5C06\u5220\u9664\u5143\u6570\u636E ${path19}\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u9006\u3002\u7EE7\u7EED\uFF1F`);
6817
6817
  if (!ok) {
6818
6818
  process.stderr.write("\u5DF2\u53D6\u6D88\n");
6819
6819
  process.exit(1);
6820
6820
  }
6821
6821
  }
6822
6822
  const c = await client2(args);
6823
- const result = await deleteTenantMeta(c.raw(), path18);
6823
+ const result = await deleteTenantMeta(c.raw(), path19);
6824
6824
  const fmt = args.output ?? "json";
6825
- if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${path18}
6825
+ if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${path19}
6826
6826
  `);
6827
6827
  process.stdout.write(formatObject18(result, { format: fmt }) + "\n");
6828
6828
  process.exitCode = 0;
@@ -6831,7 +6831,7 @@ async function metaDeleteCommand(path18, args) {
6831
6831
  fail5(e, args);
6832
6832
  }
6833
6833
  }
6834
- async function metaValidateCommand(path18, args) {
6834
+ async function metaValidateCommand(path19, args) {
6835
6835
  try {
6836
6836
  if (!args.file) {
6837
6837
  throw new CliError19({
@@ -6846,13 +6846,13 @@ async function metaValidateCommand(path18, args) {
6846
6846
  process.stdin.on("end", () => resolve4(buf));
6847
6847
  process.stdin.on("error", reject);
6848
6848
  }) : await fsp3.readFile(args.file, "utf8");
6849
- const result = validateMetaContent(path18, content);
6849
+ const result = validateMetaContent(path19, content);
6850
6850
  const fmt = args.output ?? "table";
6851
6851
  if (fmt === "json" || fmt === "yaml") {
6852
6852
  process.stdout.write(
6853
6853
  formatObject18(
6854
6854
  {
6855
- path: path18,
6855
+ path: path19,
6856
6856
  kind: result.kind,
6857
6857
  schemaKnown: result.schemaKnown,
6858
6858
  schemaSourceCommit: META_SCHEMA_SOURCE_COMMIT,
@@ -6864,7 +6864,7 @@ async function metaValidateCommand(path18, args) {
6864
6864
  );
6865
6865
  } else {
6866
6866
  process.stdout.write(
6867
- `\u{1F50E} ${path18}\uFF08schema \u7C7B\u578B\uFF1A${result.kind ?? "\u672A\u8BC6\u522B"}\uFF0C\u6765\u6E90 ${META_SCHEMA_SOURCE_COMMIT.slice(0, 8)}\uFF09
6867
+ `\u{1F50E} ${path19}\uFF08schema \u7C7B\u578B\uFF1A${result.kind ?? "\u672A\u8BC6\u522B"}\uFF0C\u6765\u6E90 ${META_SCHEMA_SOURCE_COMMIT.slice(0, 8)}\uFF09
6868
6868
  `
6869
6869
  );
6870
6870
  process.stdout.write(
@@ -6995,6 +6995,7 @@ async function workspaceActiveCommand(args) {
6995
6995
  activeWorkspaceKey,
6996
6996
  localWorkspaceKey: localContext?.workspaceKey ?? null,
6997
6997
  matchesLocal: activeWorkspaceKey && localContext?.workspaceKey ? activeWorkspaceKey === localContext.workspaceKey : null,
6998
+ nextCommand: workspaceActiveNextCommand(activeWorkspaceKey),
6998
6999
  profile: client3.profile,
6999
7000
  tenantId: client3.tenantId,
7000
7001
  endpoint: client3.endpoint,
@@ -8090,6 +8091,10 @@ function writeWorkspaceActiveResult(view, format) {
8090
8091
  }
8091
8092
  ];
8092
8093
  process.stdout.write(formatRows5(rows, { format: "table" }) + "\n");
8094
+ if (view.nextCommand) {
8095
+ process.stdout.write(`\u4E0B\u4E00\u6B65\uFF1A${view.nextCommand}
8096
+ `);
8097
+ }
8093
8098
  }
8094
8099
  function writeWorkspaceBindResult(context, rootDir, format) {
8095
8100
  if (format !== "table") {
@@ -8356,6 +8361,28 @@ async function setDevModeBinding(client3, workspaceKey) {
8356
8361
  workspaceKey
8357
8362
  });
8358
8363
  }
8364
+ function workspaceActiveNextCommand(activeWorkspaceKey) {
8365
+ return activeWorkspaceKey ? "hcm workspace deactivate" : null;
8366
+ }
8367
+ function unwrapWorkspaceActionPayload(response) {
8368
+ if (!response || typeof response !== "object") return response;
8369
+ const envelope = response;
8370
+ if (envelope.data && typeof envelope.data === "object") return envelope.data;
8371
+ if (envelope.result && typeof envelope.result === "object") return envelope.result;
8372
+ return response;
8373
+ }
8374
+ async function requestWorkspaceDeactivation(client3) {
8375
+ const response = await client3.action(
8376
+ "TenantExtensionWorkspace",
8377
+ "unbind-current-user",
8378
+ { method: "POST", scope: "class" }
8379
+ );
8380
+ const binding = unwrapWorkspaceActionPayload(response);
8381
+ if (!binding || typeof binding !== "object" || binding.enabled !== false) {
8382
+ throw new Error("workspace deactivate \u672A\u6536\u5230 enabled=false \u7684\u670D\u52A1\u7AEF\u56DE\u6267\uFF0C\u4E0D\u80FD\u786E\u8BA4\u5DF2\u9000\u51FA\u5F00\u53D1\u6A21\u5F0F");
8383
+ }
8384
+ return binding;
8385
+ }
8359
8386
  async function workspaceActivateCommand(workspaceKey, args) {
8360
8387
  try {
8361
8388
  const client3 = HcmClient19.fromAuthContext(await getActiveAuthContextFromCli(args));
@@ -8377,6 +8404,24 @@ async function workspaceActivateCommand(workspaceKey, args) {
8377
8404
  exitWorkspaceError(e, args.env ?? args.profile);
8378
8405
  }
8379
8406
  }
8407
+ async function workspaceDeactivateCommand(args) {
8408
+ try {
8409
+ const client3 = HcmClient19.fromAuthContext(await getActiveAuthContextFromCli(args));
8410
+ const binding = await requestWorkspaceDeactivation(client3);
8411
+ const result = { ...binding, deactivated: true };
8412
+ const fmt = args.output ?? "table";
8413
+ if (fmt === "table") {
8414
+ process.stdout.write("workspace deactivated\n");
8415
+ process.stdout.write("\u5F53\u524D\u8EAB\u4EFD\u5DF2\u9000\u51FA\u5F00\u53D1\u8005\u6A21\u5F0F\uFF1B\u5F00\u53D1\u7A7A\u95F4\u3001\u672C\u5730\u6587\u4EF6\u4E0E\u5DF2\u53D1\u5E03\u8D44\u4EA7\u5747\u672A\u5220\u9664\u3002\n");
8416
+ } else {
8417
+ process.stdout.write(formatObject19(result, { format: fmt }) + "\n");
8418
+ }
8419
+ process.exitCode = 0;
8420
+ return;
8421
+ } catch (e) {
8422
+ exitWorkspaceError(e, args.env ?? args.profile);
8423
+ }
8424
+ }
8380
8425
 
8381
8426
  // src/commands/identity.ts
8382
8427
  init_exit();
@@ -8538,6 +8583,7 @@ var GUARDED_EXECUTOR_REASON_CODES = /* @__PURE__ */ new Set([
8538
8583
  "action-effect-unrecognized",
8539
8584
  "workspace-create",
8540
8585
  "workspace-activate",
8586
+ "workspace-deactivate",
8541
8587
  // bind / add mini / rm 都是受控本地工作区变更;rm 暂存删除,push 再执行远端 DELETE。
8542
8588
  "workspace-local-change",
8543
8589
  // 这两个的载荷是**任意文件 / 整棵目录**,此前刻意不收——绑不住就意味着
@@ -8705,6 +8751,15 @@ function classify(argv, actionResolution) {
8705
8751
  if (subcommand === "test") return direct("R1", "remote-read", "chiron-regression-test");
8706
8752
  return forbidden("unknown-command", "\u672A\u77E5 chiron \u5B50\u547D\u4EE4\u6309\u6700\u9AD8\u98CE\u9669\u5173\u95ED\u3002");
8707
8753
  }
8754
+ if (name === "jira") {
8755
+ if (["probe", "open", "show", "audit", "search", "status"].includes(subcommand)) {
8756
+ return direct("R1", "remote-read", "jira-read");
8757
+ }
8758
+ if (["comment", "assign", "move", "to-issue", "sync", "verify-pass", "verify-fail", "submit"].includes(subcommand)) {
8759
+ return direct("R1", "external-tracker-write", "jira-tracker-write");
8760
+ }
8761
+ return forbidden("unknown-command", "\u672A\u77E5 jira \u5B50\u547D\u4EE4\u6309\u6700\u9AD8\u98CE\u9669\u5173\u95ED\u3002");
8762
+ }
8708
8763
  if (name === "skills") {
8709
8764
  if (subcommand === "list" || subcommand === "show") {
8710
8765
  return direct("R0", "product-discovery", "skill-discovery");
@@ -8768,6 +8823,7 @@ function classify(argv, actionResolution) {
8768
8823
  if (subcommand === "rm") return guarded("managed-local-write", "workspace-local-change");
8769
8824
  if (subcommand === "create") return guarded("tenant-write", "workspace-create");
8770
8825
  if (subcommand === "activate") return guarded("tenant-write", "workspace-activate");
8826
+ if (subcommand === "deactivate") return guarded("tenant-write", "workspace-deactivate");
8771
8827
  if (subcommand === "push") return guarded("tenant-write", "workspace-push");
8772
8828
  if (["deploy", "release", "promote", "publish"].includes(subcommand)) {
8773
8829
  return forbidden("publish", "\u90E8\u7F72\u5230 active \u5C5E\u4E8E R3\uFF0C\u987B\u8D70\u53D1\u5E03\u4E0E\u5BA1\u6279\u94FE\u8DEF\u3002");
@@ -9255,7 +9311,7 @@ function matchesRequest(action, request) {
9255
9311
  return action.name === request.action && action.httpMethod?.toUpperCase() === request.httpMethod && action.scope?.toLowerCase() === request.scope;
9256
9312
  }
9257
9313
  function parseActionRequest(inputArgv) {
9258
- const argv = inputArgv[0] === "--" ? inputArgv.slice(1) : [...inputArgv];
9314
+ const argv = normalizeAssessedArgv(inputArgv);
9259
9315
  const spec = argv[1] ?? "";
9260
9316
  const separator = spec.indexOf(".");
9261
9317
  if (separator <= 0 || separator === spec.length - 1) {
@@ -10060,9 +10116,9 @@ async function deliveryDoctorCommand(args) {
10060
10116
  try {
10061
10117
  const ctx = await getActiveAuthContextFromCli(args);
10062
10118
  const client3 = HcmClient21.fromAuthContext(ctx);
10063
- const probe = httpProbe(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES);
10064
- const identity2 = await fetchReconIdentity(probe, ctx.tenantId);
10065
- const report = await runDoctor(probe, identity2);
10119
+ const probe2 = httpProbe(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES);
10120
+ const identity2 = await fetchReconIdentity(probe2, ctx.tenantId);
10121
+ const report = await runDoctor(probe2, identity2);
10066
10122
  const fmt = args.output ?? "json";
10067
10123
  if (fmt !== "json") process.stdout.write(render2(report) + "\n");
10068
10124
  process.stdout.write(formatObject23(report, { format: fmt }) + "\n");
@@ -10079,8 +10135,8 @@ async function deliveryDoctorCommand(args) {
10079
10135
  // src/commands/chiron-init.ts
10080
10136
  init_auth_guard();
10081
10137
  init_exit();
10082
- import { promises as fs10 } from "fs";
10083
- import path10 from "path";
10138
+ import { promises as fs11 } from "fs";
10139
+ import path11 from "path";
10084
10140
  import {
10085
10141
  CliError as CliError21,
10086
10142
  CliErrorCode as CliErrorCode20,
@@ -10095,11 +10151,205 @@ import {
10095
10151
  } from "@hcmai/sdk";
10096
10152
 
10097
10153
  // src/commands/chiron-project.ts
10154
+ import { promises as fs10 } from "fs";
10155
+ import os5 from "os";
10156
+ import path10 from "path";
10157
+ import { spawnSync } from "child_process";
10158
+ import { hcmConfigDir, listEnvs as listEnvs3, listIdentities as listIdentities4, loadEnv as loadEnv10, loadGlobalConfig as loadGlobalConfig10 } from "@hcmai/sdk";
10159
+
10160
+ // src/jira/client.ts
10161
+ import { execFileSync } from "child_process";
10098
10162
  import { promises as fs9 } from "fs";
10099
10163
  import os4 from "os";
10100
10164
  import path9 from "path";
10101
- import { execFileSync, spawnSync } from "child_process";
10102
- import { hcmConfigDir, listEnvs as listEnvs3, listIdentities as listIdentities4, loadEnv as loadEnv10, loadGlobalConfig as loadGlobalConfig10 } from "@hcmai/sdk";
10165
+ var JIRA_BASE = (process.env.JIRA_BASE || "https://jira.hcmcloud.cn").replace(/\/+$/, "");
10166
+ var JIRA_PROJECT = process.env.JIRA_PROJECT || "HCMNX";
10167
+ var JIRA_KEYCHAIN = process.env.JIRA_KEYCHAIN_SERVICE || "jira-hcmcloud";
10168
+ var JIRA_TOKEN_FILE = () => process.env.JIRA_TOKEN_FILE || path9.join(os4.homedir(), ".config", "hcm", "jira-token");
10169
+ async function jiraTokenSource() {
10170
+ if (process.env.JIRA_TOKEN?.trim()) return { token: process.env.JIRA_TOKEN.trim(), from: "\u73AF\u5883\u53D8\u91CF JIRA_TOKEN" };
10171
+ const file = JIRA_TOKEN_FILE();
10172
+ try {
10173
+ const stat = await fs9.stat(file);
10174
+ const value = (await fs9.readFile(file, "utf8")).trim();
10175
+ if (value) {
10176
+ if (stat.mode & 63) process.stderr.write(`[jira] \u8B66\u544A\uFF1A${file} \u5BF9\u5176\u4ED6\u7528\u6237\u53EF\u8BFB\uFF08chmod 600 \u6536\u7D27\uFF09
10177
+ `);
10178
+ return { token: value, from: file };
10179
+ }
10180
+ } catch {
10181
+ }
10182
+ try {
10183
+ const out = execFileSync("security", ["find-generic-password", "-s", JIRA_KEYCHAIN, "-w"], {
10184
+ encoding: "utf8",
10185
+ stdio: ["ignore", "pipe", "ignore"]
10186
+ }).trim();
10187
+ if (out) return { token: out, from: `\u94A5\u5319\u4E32 ${JIRA_KEYCHAIN}` };
10188
+ } catch {
10189
+ }
10190
+ return null;
10191
+ }
10192
+ function jiraTokenHelp() {
10193
+ return `\u62FF\u4E0D\u5230 Jira \u4EE4\u724C\u3002next_step=\u5148\u5728 ${JIRA_BASE} \u53F3\u4E0A\u89D2\u5934\u50CF \u2192 \u4E2A\u4EBA\u8BBE\u7F6E \u2192 Personal Access Tokens \u5EFA\u4E00\u4E2A\uFF0C\u518D\u9009\u4E00\u79CD\u5B58\u6CD5\uFF08\u90FD\u4E0D\u4F1A\u8FDB\u4ED3\u5E93\uFF09\uFF1A
10194
+ \u2460 \u6587\u4EF6\uFF08\u63A8\u8350\uFF0C\u4E0D\u5F39\u7A97\uFF09\uFF1Amkdir -p ~/.config/hcm && (umask 177; cat > ${JIRA_TOKEN_FILE()}) \u7136\u540E\u7C98\u4EE4\u724C\u3001Ctrl-D
10195
+ \u2461 \u94A5\u5319\u4E32\uFF08\u514D\u5F39\u7A97\u8981\u5E26 -A\uFF09\uFF1Asecurity add-generic-password -a "$USER" -s ${JIRA_KEYCHAIN} -A -w
10196
+ \u2462 \u53EA\u7528\u4E00\u6B21\uFF1AJIRA_TOKEN=<\u4EE4\u724C> \u8DD1\u672C\u6B21\u547D\u4EE4`;
10197
+ }
10198
+ var JiraClient = class {
10199
+ base;
10200
+ project;
10201
+ token;
10202
+ fetchImpl;
10203
+ timeoutMs;
10204
+ constructor(o) {
10205
+ this.base = (o.base ?? JIRA_BASE).replace(/\/+$/, "");
10206
+ this.project = o.project ?? JIRA_PROJECT;
10207
+ this.token = o.token;
10208
+ this.fetchImpl = o.fetchImpl ?? fetch;
10209
+ this.timeoutMs = o.timeoutMs ?? 3e4;
10210
+ }
10211
+ browseUrl(key2) {
10212
+ return `${this.base}/browse/${key2}`;
10213
+ }
10214
+ /** 一次 REST 调用。失败时把 Jira 的 errorMessages 原样带出来,不吞。 */
10215
+ async api(p, init = {}) {
10216
+ const method = init.method ?? "GET";
10217
+ const url = p.startsWith("http") ? p : `${this.base}${p}`;
10218
+ const res = await this.fetchImpl(url, {
10219
+ method,
10220
+ headers: {
10221
+ Authorization: `Bearer ${this.token}`,
10222
+ Accept: "application/json",
10223
+ ...init.body !== void 0 ? { "Content-Type": "application/json" } : {}
10224
+ },
10225
+ body: init.body !== void 0 ? JSON.stringify(init.body) : void 0,
10226
+ signal: AbortSignal.timeout(this.timeoutMs)
10227
+ });
10228
+ const text = await res.text();
10229
+ if (!res.ok) {
10230
+ let detail = text.slice(0, 600);
10231
+ try {
10232
+ const j = JSON.parse(text);
10233
+ const msgs = [...j.errorMessages ?? [], ...Object.entries(j.errors ?? {}).map(([k, v]) => `${k}: ${v}`)];
10234
+ if (msgs.length) detail = msgs.join("\uFF1B");
10235
+ } catch {
10236
+ }
10237
+ const hint = res.status === 401 ? " next_step=\u4EE4\u724C\u65E0\u6548\u6216\u8FC7\u671F\uFF0C\u91CD\u5EFA PAT \u540E\u91CD\u65B0\u5B58\u4E00\u6B21" : res.status === 403 ? " next_step=\u4EE4\u724C\u6709\u6548\u4F46\u6CA1\u6709\u8FD9\u4E2A\u9879\u76EE\u7684\u6743\u9650\uFF0C\u627E Jira \u7BA1\u7406\u5458\u5F00\u6743\u9650" : "";
10238
+ throw new Error(`Jira ${method} ${p} \u2192 ${res.status}\uFF1A${detail}${hint}`);
10239
+ }
10240
+ return text ? JSON.parse(text) : null;
10241
+ }
10242
+ serverInfo() {
10243
+ return this.api("/rest/api/2/serverInfo");
10244
+ }
10245
+ myself() {
10246
+ return this.api("/rest/api/2/myself");
10247
+ }
10248
+ async search(jql, {
10249
+ fields = ["summary", "status", "priority", "created", "updated", "labels", "issuetype", "reporter", "resolution"],
10250
+ max = 30
10251
+ } = {}) {
10252
+ const q = new URLSearchParams({ jql, maxResults: String(max), fields: fields.join(",") });
10253
+ const r = await this.api(`/rest/api/2/search?${q}`);
10254
+ return r.issues ?? [];
10255
+ }
10256
+ issue(key2, fields) {
10257
+ return this.api(`/rest/api/2/issue/${encodeURIComponent(key2)}${fields ? `?fields=${fields.join(",")}` : ""}`);
10258
+ }
10259
+ async comments(key2) {
10260
+ const r = await this.api(
10261
+ `/rest/api/2/issue/${encodeURIComponent(key2)}/comment?maxResults=50`
10262
+ );
10263
+ return r.comments ?? [];
10264
+ }
10265
+ addComment(key2, body) {
10266
+ return this.api(`/rest/api/2/issue/${encodeURIComponent(key2)}/comment`, { method: "POST", body: { body } });
10267
+ }
10268
+ createIssue(fields) {
10269
+ return this.api("/rest/api/2/issue", { method: "POST", body: { fields } });
10270
+ }
10271
+ async transitions(key2) {
10272
+ const r = await this.api(
10273
+ `/rest/api/2/issue/${encodeURIComponent(key2)}/transitions?expand=transitions.fields`
10274
+ );
10275
+ return r.transitions ?? [];
10276
+ }
10277
+ /** 按流转 id / 流转名 / 目标状态名三种写法找;找不到把可用流转列出来,不猜。 */
10278
+ async transition(key2, nameOrId, comment) {
10279
+ const list = await this.transitions(key2);
10280
+ const hit = list.find((t) => t.id === String(nameOrId)) || list.find((t) => t.name === nameOrId) || list.find((t) => t.to?.name === nameOrId);
10281
+ if (!hit) {
10282
+ throw new Error(
10283
+ `${key2} \u4E0A\u6CA1\u6709\u5230\u300C${nameOrId}\u300D\u7684\u6D41\u8F6C\u3002\u53EF\u7528\uFF1A${list.map((t) => `${t.name}\u2192${t.to?.name}`).join(" / ") || "\uFF08\u65E0\uFF09"}`
10284
+ );
10285
+ }
10286
+ await this.api(`/rest/api/2/issue/${encodeURIComponent(key2)}/transitions`, {
10287
+ method: "POST",
10288
+ body: {
10289
+ transition: { id: hit.id },
10290
+ ...comment ? { update: { comment: [{ add: { body: comment } }] } } : {}
10291
+ }
10292
+ });
10293
+ return hit;
10294
+ }
10295
+ /**
10296
+ * 建单前先问 Jira:这个项目有哪些 issuetype、每种哪些字段必填、可选值是什么。
10297
+ *
10298
+ * 🔴 不写死 customfield 编号:同名字段在别的项目里编号不同,写死就是换个项目静默填错格。
10299
+ * Jira 9 起旧的 `createmeta?projectKeys=&expand=` 已移除(11.3.2 实测 404),用按 issuetype 分页的新接口。
10300
+ */
10301
+ async createMeta(project = this.project) {
10302
+ const list = await this.api(
10303
+ `/rest/api/2/issue/createmeta/${project}/issuetypes`
10304
+ );
10305
+ const types = list.values ?? list.issueTypes ?? [];
10306
+ const out = [];
10307
+ for (const t of types) {
10308
+ if (t.subtask) continue;
10309
+ const f = await this.api(`/rest/api/2/issue/createmeta/${project}/issuetypes/${t.id}`);
10310
+ out.push({ id: t.id, name: t.name, fields: f.values ?? [] });
10311
+ }
10312
+ return out;
10313
+ }
10314
+ projectInfo(project = this.project) {
10315
+ return this.api(`/rest/api/2/project/${project}`);
10316
+ }
10317
+ projectStatuses(project = this.project) {
10318
+ return this.api(`/rest/api/2/project/${project}/statuses`);
10319
+ }
10320
+ /**
10321
+ * 远程链接:把代码库的 issue 挂到 Jira 单的「链接」栏里,而不是埋在评论中。
10322
+ * 公司现有惯例就是这样(HF 的开发任务用链接挂到 HCR 的需求上),照它来。
10323
+ * globalId 用 URL 本身,重复调用是覆盖不是新增。
10324
+ */
10325
+ addRemoteLink(key2, url, title, relationship = "\u4EE3\u7801\u5E93\u6761\u76EE") {
10326
+ return this.api(`/rest/api/2/issue/${encodeURIComponent(key2)}/remotelink`, {
10327
+ method: "POST",
10328
+ body: {
10329
+ globalId: url,
10330
+ relationship,
10331
+ object: { url, title, icon: { url16x16: "https://cnb.cool/favicon.ico", title: "cnb" } }
10332
+ }
10333
+ });
10334
+ }
10335
+ async remoteLinks(key2) {
10336
+ try {
10337
+ return await this.api(`/rest/api/2/issue/${encodeURIComponent(key2)}/remotelink`) ?? [];
10338
+ } catch {
10339
+ return [];
10340
+ }
10341
+ }
10342
+ assign(key2, name) {
10343
+ return this.api(`/rest/api/2/issue/${encodeURIComponent(key2)}/assignee`, { method: "PUT", body: { name } });
10344
+ }
10345
+ };
10346
+ async function createJiraClient(opts = {}) {
10347
+ const src = opts.token ? { token: opts.token, from: "\u53C2\u6570" } : await jiraTokenSource();
10348
+ if (!src) throw new Error(jiraTokenHelp());
10349
+ return new JiraClient({ ...opts, token: src.token });
10350
+ }
10351
+
10352
+ // src/commands/chiron-project.ts
10103
10353
  var ENV_FILE = "env.yaml";
10104
10354
  var SKILLS_DIR = "hcm-skills";
10105
10355
  var CASES_REPO_URL = "https://cnb.cool/hcm/chiron-cases.git";
@@ -10198,13 +10448,13 @@ function mergeChironAgentInstructions(existing) {
10198
10448
  return upsertBlock(existing, AGENT_BEGIN, AGENT_END, renderChironAgentInstructions().trimEnd());
10199
10449
  }
10200
10450
  function caseLibraryDir() {
10201
- return path9.join(hcmConfigDir(), CASES_MCP_NAME);
10451
+ return path10.join(hcmConfigDir(), CASES_MCP_NAME);
10202
10452
  }
10203
10453
  function codexConfigFile() {
10204
- return path9.join(process.env.HOME ?? os4.homedir(), ".codex", "config.toml");
10454
+ return path10.join(process.env.HOME ?? os5.homedir(), ".codex", "config.toml");
10205
10455
  }
10206
10456
  function renderCodexMcpSection(repo, envName, binPath = process.env.PATH ?? "") {
10207
- const server = path9.join(repo, "mcp", "server.mjs");
10457
+ const server = path10.join(repo, "mcp", "server.mjs");
10208
10458
  const env2 = [
10209
10459
  `CASES_REPO = ${JSON.stringify(repo)}`,
10210
10460
  `HCM_ENV = ${JSON.stringify(envName)}`,
@@ -10267,13 +10517,13 @@ async function ensureCaseLibrary(envName, deps = defaultCaseLibraryDeps, paths =
10267
10517
  const repo = paths.repo ?? caseLibraryDir();
10268
10518
  const codexConfig = paths.codexConfig ?? codexConfigFile();
10269
10519
  const status = { ok: false, repo, step: "present", serverInstalled: false, codexWired: false };
10270
- const hasGit = await exists2(path9.join(repo, ".git"));
10520
+ const hasGit = await exists2(path10.join(repo, ".git"));
10271
10521
  if (hasGit) {
10272
10522
  const pull = deps.git(["pull", "--ff-only", "--quiet"], repo);
10273
10523
  status.step = pull.status === 0 ? "updated" : "present";
10274
10524
  if (pull.status !== 0) status.reason = `\u66F4\u65B0\u5931\u8D25\uFF0C\u6CBF\u7528\u672C\u5730\u7248\u672C\uFF1A${firstLine(pull.stderr, pull.error)}`;
10275
10525
  } else {
10276
- await fs9.mkdir(path9.dirname(repo), { recursive: true });
10526
+ await fs10.mkdir(path10.dirname(repo), { recursive: true });
10277
10527
  const clone = deps.git(["clone", "--depth", "1", "--quiet", CASES_REPO_URL, repo]);
10278
10528
  if (clone.status !== 0) {
10279
10529
  status.step = "clone-failed";
@@ -10282,13 +10532,13 @@ async function ensureCaseLibrary(envName, deps = defaultCaseLibraryDeps, paths =
10282
10532
  }
10283
10533
  status.step = "cloned";
10284
10534
  }
10285
- const mcpDir = path9.join(repo, "mcp");
10286
- if (!await exists2(path9.join(mcpDir, "server.mjs"))) {
10535
+ const mcpDir = path10.join(repo, "mcp");
10536
+ if (!await exists2(path10.join(mcpDir, "server.mjs"))) {
10287
10537
  status.step = "install-failed";
10288
10538
  status.reason = `\u6848\u4F8B\u5E93\u91CC\u6CA1\u6709 mcp/server.mjs\uFF1A${mcpDir}`;
10289
10539
  return status;
10290
10540
  }
10291
- if (!await exists2(path9.join(mcpDir, "node_modules", "@modelcontextprotocol"))) {
10541
+ if (!await exists2(path10.join(mcpDir, "node_modules", "@modelcontextprotocol"))) {
10292
10542
  const install = deps.npmInstall(mcpDir);
10293
10543
  if (install.status !== 0) {
10294
10544
  status.step = "install-failed";
@@ -10297,10 +10547,10 @@ async function ensureCaseLibrary(envName, deps = defaultCaseLibraryDeps, paths =
10297
10547
  }
10298
10548
  }
10299
10549
  status.serverInstalled = true;
10300
- await fs9.mkdir(path9.dirname(codexConfig), { recursive: true });
10301
- const existing = await fs9.readFile(codexConfig, "utf8").catch(() => "");
10550
+ await fs10.mkdir(path10.dirname(codexConfig), { recursive: true });
10551
+ const existing = await fs10.readFile(codexConfig, "utf8").catch(() => "");
10302
10552
  const next = mergeCodexMcpConfig(existing, renderCodexMcpSection(repo, envName));
10303
- if (next !== existing) await fs9.writeFile(codexConfig, next, "utf8");
10553
+ if (next !== existing) await fs10.writeFile(codexConfig, next, "utf8");
10304
10554
  status.codexWired = true;
10305
10555
  status.ok = true;
10306
10556
  return status;
@@ -10308,9 +10558,9 @@ async function ensureCaseLibrary(envName, deps = defaultCaseLibraryDeps, paths =
10308
10558
  async function inspectCaseLibrary(paths = {}) {
10309
10559
  const repo = paths.repo ?? caseLibraryDir();
10310
10560
  const codexConfig = paths.codexConfig ?? codexConfigFile();
10311
- const cloned = await exists2(path9.join(repo, ".git"));
10312
- const serverInstalled = cloned && await exists2(path9.join(repo, "mcp", "server.mjs")) && await exists2(path9.join(repo, "mcp", "node_modules", "@modelcontextprotocol"));
10313
- const codexWired = codexConfigHasCases(await fs9.readFile(codexConfig, "utf8").catch(() => ""));
10561
+ const cloned = await exists2(path10.join(repo, ".git"));
10562
+ const serverInstalled = cloned && await exists2(path10.join(repo, "mcp", "server.mjs")) && await exists2(path10.join(repo, "mcp", "node_modules", "@modelcontextprotocol"));
10563
+ const codexWired = codexConfigHasCases(await fs10.readFile(codexConfig, "utf8").catch(() => ""));
10314
10564
  return { repo, cloned, serverInstalled, codexWired };
10315
10565
  }
10316
10566
  function firstLine(stderr, error) {
@@ -10318,28 +10568,6 @@ function firstLine(stderr, error) {
10318
10568
  const line = stderr.split(/\r?\n/).map((l) => l.trim()).find(Boolean);
10319
10569
  return line ?? "\uFF08\u65E0\u8F93\u51FA\uFF09";
10320
10570
  }
10321
- var JIRA_BASE = (process.env.JIRA_BASE || "https://jira.hcmcloud.cn").replace(/\/+$/, "");
10322
- var JIRA_PROJECT = process.env.JIRA_PROJECT || "HCMNX";
10323
- var JIRA_TOKEN_FILE = () => path9.join(os4.homedir(), ".config", "hcm", "jira-token");
10324
- var JIRA_KEYCHAIN = "jira-hcmcloud";
10325
- async function jiraTokenSource() {
10326
- if (process.env.JIRA_TOKEN?.trim()) return { token: process.env.JIRA_TOKEN.trim(), from: "\u73AF\u5883\u53D8\u91CF JIRA_TOKEN" };
10327
- const file = process.env.JIRA_TOKEN_FILE || JIRA_TOKEN_FILE();
10328
- try {
10329
- const value = (await fs9.readFile(file, "utf8")).trim();
10330
- if (value) return { token: value, from: file };
10331
- } catch {
10332
- }
10333
- try {
10334
- const out = execFileSync("security", ["find-generic-password", "-s", JIRA_KEYCHAIN, "-w"], {
10335
- encoding: "utf8",
10336
- stdio: ["ignore", "pipe", "ignore"]
10337
- }).trim();
10338
- if (out) return { token: out, from: `\u94A5\u5319\u4E32 ${JIRA_KEYCHAIN}` };
10339
- } catch {
10340
- }
10341
- return null;
10342
- }
10343
10571
  async function inspectJira() {
10344
10572
  const src = await jiraTokenSource();
10345
10573
  if (!src) {
@@ -10374,7 +10602,7 @@ async function inspectJira() {
10374
10602
  }
10375
10603
  async function exists2(file) {
10376
10604
  try {
10377
- await fs9.access(file);
10605
+ await fs10.access(file);
10378
10606
  return true;
10379
10607
  } catch {
10380
10608
  return false;
@@ -10398,7 +10626,7 @@ var defaultChironInitDeps = {
10398
10626
  all: true,
10399
10627
  target: "codex",
10400
10628
  env: envName,
10401
- dir: path10.join(root, SKILLS_DIR),
10629
+ dir: path11.join(root, SKILLS_DIR),
10402
10630
  output: "table"
10403
10631
  });
10404
10632
  } finally {
@@ -10439,8 +10667,8 @@ async function resolveLoggedInEnv() {
10439
10667
  }
10440
10668
  async function scaffoldChironProject(root, env2, envName) {
10441
10669
  const result = { created: [], updated: [], preserved: [] };
10442
- const envFile = path10.join(root, ENV_FILE);
10443
- const existing = await fs10.readFile(envFile, "utf8").catch(() => null);
10670
+ const envFile = path11.join(root, ENV_FILE);
10671
+ const existing = await fs11.readFile(envFile, "utf8").catch(() => null);
10444
10672
  if (existing !== null) {
10445
10673
  const recorded = parseEnvYaml(existing);
10446
10674
  if (recorded.endpoint !== env2.endpoint) {
@@ -10460,32 +10688,32 @@ async function scaffoldChironProject(root, env2, envName) {
10460
10688
  }
10461
10689
  result.preserved.push(ENV_FILE);
10462
10690
  } else {
10463
- await fs10.writeFile(envFile, renderEnvYaml(env2), { encoding: "utf8", mode: 420, flag: "wx" });
10691
+ await fs11.writeFile(envFile, renderEnvYaml(env2), { encoding: "utf8", mode: 420, flag: "wx" });
10464
10692
  result.created.push(ENV_FILE);
10465
10693
  }
10466
10694
  for (const directory of CHIRON_PROJECT_DIRECTORIES) {
10467
- const absolute = path10.join(root, directory);
10695
+ const absolute = path11.join(root, directory);
10468
10696
  await ensureDirectory(absolute);
10469
- await writeIfAbsent(path10.join(absolute, ".gitkeep"), "", result, `${directory}/.gitkeep`);
10697
+ await writeIfAbsent(path11.join(absolute, ".gitkeep"), "", result, `${directory}/.gitkeep`);
10470
10698
  }
10471
- const deliveryDir = path10.join(root, ".hcm-delivery");
10699
+ const deliveryDir = path11.join(root, ".hcm-delivery");
10472
10700
  await ensureDirectory(deliveryDir);
10473
10701
  await writeIfAbsent(
10474
- path10.join(deliveryDir, "project.yml"),
10702
+ path11.join(deliveryDir, "project.yml"),
10475
10703
  renderProjectYml(envName, "plan-only"),
10476
10704
  result,
10477
10705
  ".hcm-delivery/project.yml"
10478
10706
  );
10479
- const pageAcceptanceFile = path10.join(root, "page-acceptance.sh");
10707
+ const pageAcceptanceFile = path11.join(root, "page-acceptance.sh");
10480
10708
  const created = await writeIfAbsent(pageAcceptanceFile, renderPageAcceptanceSh("evidence"), result, "page-acceptance.sh", 493);
10481
- if (created) await fs10.chmod(pageAcceptanceFile, 493);
10482
- await mergeManagedFile(path10.join(root, "AGENTS.md"), mergeChironAgentInstructions, result, "AGENTS.md");
10483
- await mergeManagedFile(path10.join(root, "CLAUDE.md"), mergeChironAgentInstructions, result, "CLAUDE.md");
10484
- await mergeManagedFile(path10.join(root, ".gitignore"), mergeDeliveryGitignore, result, ".gitignore");
10709
+ if (created) await fs11.chmod(pageAcceptanceFile, 493);
10710
+ await mergeManagedFile(path11.join(root, "AGENTS.md"), mergeChironAgentInstructions, result, "AGENTS.md");
10711
+ await mergeManagedFile(path11.join(root, "CLAUDE.md"), mergeChironAgentInstructions, result, "CLAUDE.md");
10712
+ await mergeManagedFile(path11.join(root, ".gitignore"), mergeDeliveryGitignore, result, ".gitignore");
10485
10713
  return result;
10486
10714
  }
10487
10715
  async function runChironInit(args, deps = defaultChironInitDeps) {
10488
- const root = path10.resolve(args.project ?? ".");
10716
+ const root = path11.resolve(args.project ?? ".");
10489
10717
  const { name, env: env2, identity: identity2 } = await resolveLoggedInEnv();
10490
10718
  if (isTempEnv3(name)) {
10491
10719
  throw new CliError21({
@@ -10556,8 +10784,8 @@ async function chironInitCommand(args, deps) {
10556
10784
  // src/commands/chiron-doctor.ts
10557
10785
  init_auth_guard();
10558
10786
  init_exit();
10559
- import { promises as fs11 } from "fs";
10560
- import path11 from "path";
10787
+ import { promises as fs12 } from "fs";
10788
+ import path12 from "path";
10561
10789
  import {
10562
10790
  HcmClient as HcmClient23,
10563
10791
  CliError as CliError22,
@@ -10570,9 +10798,9 @@ var defaultDeps = {
10570
10798
  anchors: async (envName, tenant2) => {
10571
10799
  const ctx = await getActiveAuthContextFromCli({ env: envName });
10572
10800
  const client3 = HcmClient23.fromAuthContext(ctx);
10573
- const probe = httpProbe3(client3.raw(), "default");
10574
- const identity2 = await fetchReconIdentity3(probe, tenant2);
10575
- return { report: await runDoctor2(probe, identity2), tokenTenant: identity2?.tenantId ? String(identity2.tenantId) : void 0 };
10801
+ const probe2 = httpProbe3(client3.raw(), "default");
10802
+ const identity2 = await fetchReconIdentity3(probe2, tenant2);
10803
+ return { report: await runDoctor2(probe2, identity2), tokenTenant: identity2?.tenantId ? String(identity2.tenantId) : void 0 };
10576
10804
  },
10577
10805
  fixSkills: (root, envName) => defaultChironInitDeps.installSkills(root, envName),
10578
10806
  fixCases: async (envName) => {
@@ -10582,9 +10810,9 @@ var defaultDeps = {
10582
10810
  inspectJira: () => inspectJira()
10583
10811
  };
10584
10812
  async function runChironDoctor(args, deps = defaultDeps) {
10585
- const root = path11.resolve(args.project ?? ".");
10813
+ const root = path12.resolve(args.project ?? ".");
10586
10814
  const report = { ok: false, project: root, env: null, envName: null, lines: [] };
10587
- const envText = await fs11.readFile(path11.join(root, ENV_FILE), "utf8").catch(() => null);
10815
+ const envText = await fs12.readFile(path12.join(root, ENV_FILE), "utf8").catch(() => null);
10588
10816
  if (envText === null) {
10589
10817
  report.lines.push({
10590
10818
  item: "\u767B\u5F55",
@@ -10633,7 +10861,7 @@ async function runChironDoctor(args, deps = defaultDeps) {
10633
10861
  }
10634
10862
  }
10635
10863
  const skillsLine = async () => {
10636
- const state = await readSkillsState(path11.join(root, SKILLS_DIR));
10864
+ const state = await readSkillsState(path12.join(root, SKILLS_DIR));
10637
10865
  if (!state) return { item: "\u6280\u80FD", verdict: "fail", detail: `${SKILLS_DIR}/ \u91CC\u6CA1\u6709\u5B89\u88C5\u6E05\u5355`, nextStep: "hcm chiron doctor --fix\uFF08\u6216 hcm chiron init\uFF09" };
10638
10866
  const count = Object.keys(state.skills).length;
10639
10867
  if (state.endpoint && normalizeOrigin(state.endpoint) !== env2.endpoint) {
@@ -10663,9 +10891,9 @@ async function runChironDoctor(args, deps = defaultDeps) {
10663
10891
  cases = await casesLine();
10664
10892
  }
10665
10893
  report.lines.push(cases);
10666
- const jira = await deps.inspectJira();
10894
+ const jira2 = await deps.inspectJira();
10667
10895
  report.lines.push(
10668
- jira.ok ? { item: "Jira", verdict: "ok", detail: `${jira.who || "\u5DF2\u8FDE\u63A5"} \xB7 \u770B\u5F97\u5230 ${JIRA_PROJECT}\uFF08\u4EE4\u724C\u6765\u81EA ${jira.from}\uFF09` } : { item: "Jira", verdict: "warn", detail: jira.reason ?? "\u4E0D\u53EF\u7528", nextStep: "\u73B0\u5728\u4E0D\u914D\u4E5F\u80FD\u4EA4\u4ED8\uFF1B\u649E\u5230\u300C\u4EA7\u54C1\u505A\u4E0D\u5230\u300D\u8981\u63D0\u5355\u65F6\u5FC5\u987B\u5148\u914D\u597D" }
10896
+ jira2.ok ? { item: "Jira", verdict: "ok", detail: `${jira2.who || "\u5DF2\u8FDE\u63A5"} \xB7 \u770B\u5F97\u5230 ${JIRA_PROJECT}\uFF08\u4EE4\u724C\u6765\u81EA ${jira2.from}\uFF09` } : { item: "Jira", verdict: "warn", detail: jira2.reason ?? "\u4E0D\u53EF\u7528", nextStep: "\u73B0\u5728\u4E0D\u914D\u4E5F\u80FD\u4EA4\u4ED8\uFF1B\u649E\u5230\u300C\u4EA7\u54C1\u505A\u4E0D\u5230\u300D\u8981\u63D0\u5355\u65F6\u5FC5\u987B\u5148\u914D\u597D" }
10669
10897
  );
10670
10898
  return finish(report);
10671
10899
  }
@@ -10699,8 +10927,8 @@ async function chironDoctorCommand(args, deps) {
10699
10927
  // src/commands/chiron-test.ts
10700
10928
  init_exit();
10701
10929
  import { spawnSync as spawnSync2 } from "child_process";
10702
- import { promises as fs12 } from "fs";
10703
- import path12 from "path";
10930
+ import { promises as fs13 } from "fs";
10931
+ import path13 from "path";
10704
10932
  import yaml2 from "js-yaml";
10705
10933
  import { formatObject as formatObject26 } from "@hcmai/sdk";
10706
10934
 
@@ -10901,7 +11129,7 @@ var defaultDeps2 = {
10901
11129
  return { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
10902
11130
  },
10903
11131
  readXlsx: (file) => xlsxRows(file),
10904
- readText: (file) => fs12.readFile(file, "utf8")
11132
+ readText: (file) => fs13.readFile(file, "utf8")
10905
11133
  };
10906
11134
  async function runCase(spec, root, opts = {}, deps = defaultDeps2) {
10907
11135
  const results = [];
@@ -10954,7 +11182,7 @@ async function runCase(spec, root, opts = {}, deps = defaultDeps2) {
10954
11182
  continue;
10955
11183
  }
10956
11184
  if (c.file) {
10957
- const file = path12.resolve(root, fill(c.file));
11185
+ const file = path13.resolve(root, fill(c.file));
10958
11186
  const want = c.expect ?? {};
10959
11187
  const bad = [];
10960
11188
  if (want.xlsx_header || want.xlsx_min_rows !== void 0) {
@@ -10970,7 +11198,7 @@ async function runCase(spec, root, opts = {}, deps = defaultDeps2) {
10970
11198
  results.push(bad.length ? { name: c.name, verdict: "fail", detail: bad.join("\uFF1B") } : { name: c.name, verdict: "pass", detail: "" });
10971
11199
  continue;
10972
11200
  }
10973
- const out = path12.join("evidence", "test", `${spec.name}-${c.name}`.replace(/[^\w一-龥-]+/g, "_") + ".png");
11201
+ const out = path13.join("evidence", "test", `${spec.name}-${c.name}`.replace(/[^\w一-龥-]+/g, "_") + ".png");
10974
11202
  const argv = ["--path", fill(c.page), "--out", out];
10975
11203
  if (opts.env) argv.push("--env", opts.env);
10976
11204
  const as = c.as ?? opts.as;
@@ -10986,12 +11214,12 @@ async function runCase(spec, root, opts = {}, deps = defaultDeps2) {
10986
11214
  return results;
10987
11215
  }
10988
11216
  async function loadCases(target) {
10989
- const stat = await fs12.stat(target);
10990
- const files = stat.isDirectory() ? (await fs12.readdir(target)).filter((f) => /\.ya?ml$/.test(f)).sort().map((f) => path12.join(target, f)) : [target];
11217
+ const stat = await fs13.stat(target);
11218
+ const files = stat.isDirectory() ? (await fs13.readdir(target)).filter((f) => /\.ya?ml$/.test(f)).sort().map((f) => path13.join(target, f)) : [target];
10991
11219
  const out = [];
10992
11220
  for (const f of files) {
10993
- const spec = yaml2.load(await fs12.readFile(f, "utf8"));
10994
- assertUsableSpec(spec, path12.basename(f));
11221
+ const spec = yaml2.load(await fs13.readFile(f, "utf8"));
11222
+ assertUsableSpec(spec, path13.basename(f));
10995
11223
  out.push({ file: f, spec });
10996
11224
  }
10997
11225
  if (out.length === 0) throw new Error(`${target} \u4E0B\u6CA1\u6709\u7528\u4F8B\uFF08*.yml\uFF09`);
@@ -10999,15 +11227,15 @@ async function loadCases(target) {
10999
11227
  }
11000
11228
  async function chironTestCommand(target, args, deps) {
11001
11229
  try {
11002
- const root = path12.resolve(args.project ?? ".");
11003
- const where = path12.resolve(root, target ?? "tests");
11230
+ const root = path13.resolve(args.project ?? ".");
11231
+ const where = path13.resolve(root, target ?? "tests");
11004
11232
  const cases = await loadCases(where);
11005
11233
  const report = [];
11006
11234
  let failed2 = 0;
11007
11235
  for (const { file, spec } of cases) {
11008
11236
  const results = await runCase(spec, root, { env: args.env, as: args.as }, deps);
11009
11237
  failed2 += results.filter((r) => r.verdict === "fail").length;
11010
- report.push({ case: spec.name, file: path12.relative(root, file), results });
11238
+ report.push({ case: spec.name, file: path13.relative(root, file), results });
11011
11239
  }
11012
11240
  const fmt = args.output ?? "table";
11013
11241
  if (fmt === "json" || fmt === "yaml") {
@@ -11036,6 +11264,763 @@ ${failed2} \u6761\u6CA1\u8FC7\u2014\u2014\u4E0A\u9762\u6BCF\u6761\u90FD\u5199\u4
11036
11264
  }
11037
11265
  }
11038
11266
 
11267
+ // src/commands/jira.ts
11268
+ import { readFileSync as readFileSync7 } from "fs";
11269
+ import {
11270
+ createHttpClient as createHttpClient4,
11271
+ formatObject as formatObject27,
11272
+ loadEnv as loadEnv12,
11273
+ loadGlobalConfig as loadGlobalConfig12,
11274
+ resolveActiveEnv as resolveActiveEnv6
11275
+ } from "@hcmai/sdk";
11276
+ init_exit();
11277
+
11278
+ // src/jira/refs.ts
11279
+ import { execFileSync as execFileSync2 } from "child_process";
11280
+ var defaultCnb = (args) => execFileSync2("cnb", args, { encoding: "utf8", maxBuffer: 1 << 26, stdio: ["ignore", "pipe", "pipe"] });
11281
+ var PRODUCT_REPOS = ["hcm/hcm_nx_core", "hcm/hcm_nx_cli", "hcm/hcm_nx_cloud"];
11282
+ var REF_RE = /hcm\/(hcm_nx_(?:core|cli|cloud))(?:#|\/-\/issues\/)(\d+)/g;
11283
+ function linkedRepoRefs(text) {
11284
+ const out = /* @__PURE__ */ new Map();
11285
+ for (const m of String(text ?? "").matchAll(REF_RE)) {
11286
+ out.set(`hcm/${m[1]}#${m[2]}`, { repo: `hcm/${m[1]}`, number: m[2] });
11287
+ }
11288
+ return [...out.values()];
11289
+ }
11290
+ var repoIssueUrl = (repo, number) => `https://cnb.cool/${repo}/-/issues/${number}`;
11291
+ function parseCnbIssueOutput(raw) {
11292
+ const fields = {};
11293
+ let status;
11294
+ for (const line of raw.split("\n")) {
11295
+ const head = line.match(/^status:\s*(\d+)\s*$/);
11296
+ if (head && status === void 0) {
11297
+ status = Number(head[1]);
11298
+ continue;
11299
+ }
11300
+ const m = line.match(/^\s+(number|title|state|state_reason|priority|url|htmlUrl|created_at|updated_at|closed_at):\s*(.*)$/);
11301
+ if (!m) continue;
11302
+ const key2 = m[1];
11303
+ if (fields[key2] !== void 0) continue;
11304
+ fields[key2] = m[2].trim().replace(/^"|"$/g, "");
11305
+ }
11306
+ return { status, fields };
11307
+ }
11308
+ function cnbIssueState(cnb, repo, number) {
11309
+ let raw;
11310
+ try {
11311
+ raw = cnb(["issues", "get-issue", "--repo", repo, "--number", String(number)]);
11312
+ } catch (e) {
11313
+ return { kind: "unreadable", repo, number, reason: firstLine2(e.message) };
11314
+ }
11315
+ const { status, fields } = parseCnbIssueOutput(raw);
11316
+ if (status === 404) return { kind: "not-issue", repo, number };
11317
+ if (status !== void 0 && status !== 200) {
11318
+ return { kind: "unreadable", repo, number, reason: `cnb \u8FD4\u56DE ${status}` };
11319
+ }
11320
+ if (!fields.state) return { kind: "unreadable", repo, number, reason: "cnb \u8F93\u51FA\u91CC\u6CA1\u6709 state \u5B57\u6BB5" };
11321
+ return {
11322
+ kind: "issue",
11323
+ repo,
11324
+ number,
11325
+ state: fields.state,
11326
+ reason: fields.state_reason || void 0,
11327
+ title: fields.title ?? "",
11328
+ priority: fields.priority || void 0,
11329
+ url: repoIssueUrl(repo, number)
11330
+ };
11331
+ }
11332
+ var describeIssueState = (s) => {
11333
+ if (s.kind === "issue") return `${s.repo}#${s.number} [${s.state}${s.reason ? "\xB7" + s.reason : ""}] ${s.title}`;
11334
+ if (s.kind === "not-issue") return `${s.repo}#${s.number} \uFF08\u4E0D\u662F issue\uFF0C\u53EF\u80FD\u662F PR \u53F7\uFF1B\u4E0D\u8BA1\u5165\uFF09`;
11335
+ return `${s.repo}#${s.number} \uFF08\u8BFB\u4E0D\u5230\uFF1A${s.reason}\uFF09`;
11336
+ };
11337
+ function parseCnbIssueList(raw, repo) {
11338
+ const out = [];
11339
+ let cur = null;
11340
+ for (const line of raw.split("\n")) {
11341
+ const m = line.match(/^\s*-?\s*(number|title|state|state_reason|priority):\s*(.*)$/);
11342
+ if (!m) continue;
11343
+ const key2 = m[1];
11344
+ const value = m[2].trim().replace(/^"|"$/g, "");
11345
+ if (key2 === "number") {
11346
+ if (cur?.number) out.push(finishRow(cur, repo));
11347
+ cur = { number: value };
11348
+ continue;
11349
+ }
11350
+ if (cur && cur[key2] === void 0) cur[key2] = value;
11351
+ }
11352
+ if (cur?.number) out.push(finishRow(cur, repo));
11353
+ return out;
11354
+ }
11355
+ function finishRow(p, repo) {
11356
+ return {
11357
+ repo,
11358
+ number: p.number,
11359
+ title: p.title ?? "",
11360
+ state: p.state ?? "",
11361
+ state_reason: p.state_reason,
11362
+ priority: p.priority,
11363
+ url: repoIssueUrl(repo, p.number)
11364
+ };
11365
+ }
11366
+ function searchRepoIssues(cnb, repo, keyword, state) {
11367
+ try {
11368
+ return parseCnbIssueList(
11369
+ cnb(["issues", "list-issues", "--repo", repo, "--keyword", keyword, "--state", state, "--page-size", "20"]),
11370
+ repo
11371
+ );
11372
+ } catch {
11373
+ return [];
11374
+ }
11375
+ }
11376
+ function parseRef(raw, project, casesSlug = "hcm/chiron-cases") {
11377
+ const r = String(raw ?? "").trim();
11378
+ let m = r.match(/^(?:hcm\/)?(?:hcm_nx_)?(core|cli|cloud)#(\d+)$/i);
11379
+ if (m) return { kind: "repo", repo: `hcm/hcm_nx_${m[1].toLowerCase()}`, number: m[2] };
11380
+ m = r.match(/^(?:chiron-)?cases#(\d+)$/i);
11381
+ if (m) return { kind: "repo", repo: casesSlug, number: m[1] };
11382
+ m = r.match(/^([A-Z][A-Z0-9_]+)-(\d+)$/i);
11383
+ if (m) return { kind: "jira", key: `${m[1].toUpperCase()}-${m[2]}` };
11384
+ m = r.match(/^(\d+)$/);
11385
+ if (m) return { kind: "jira", key: `${project}-${m[1]}` };
11386
+ return null;
11387
+ }
11388
+ var firstLine2 = (s) => String(s ?? "").split("\n").find((l) => l.trim())?.trim() ?? "";
11389
+
11390
+ // src/jira/gaps.ts
11391
+ var MIN_LEN = [
11392
+ ["title", 8],
11393
+ ["phenomenon", 20],
11394
+ ["repro", 10],
11395
+ ["expected", 10],
11396
+ ["alternative", 5],
11397
+ ["q_mechanism", 10],
11398
+ ["q_history", 10],
11399
+ ["q_skill", 10]
11400
+ ];
11401
+ function validateGapInput(x) {
11402
+ if (!x || typeof x !== "object") throw new Error("\u7F3A\u53E3\u8F7D\u8377\u5FC5\u987B\u662F\u4E00\u4E2A JSON \u5BF9\u8C61");
11403
+ const g = x;
11404
+ const problems = [];
11405
+ for (const [k, min] of MIN_LEN) {
11406
+ const v = g[k];
11407
+ if (typeof v !== "string" || v.trim().length < min) problems.push(`${k} \u81F3\u5C11 ${min} \u4E2A\u5B57`);
11408
+ }
11409
+ if (typeof g.title === "string" && g.title.length > 80) problems.push("title \u4E0D\u8D85\u8FC7 80 \u4E2A\u5B57");
11410
+ if (!["\u963B\u65AD", "\u6709\u66FF\u4EE3\u6CD5", "\u63AA\u8F9E\u7EA7"].includes(String(g.severity))) problems.push("severity \u53EA\u80FD\u662F \u963B\u65AD / \u6709\u66FF\u4EE3\u6CD5 / \u63AA\u8F9E\u7EA7");
11411
+ if (!["\u7F3A\u9677", "\u7F3A\u80FD\u529B"].includes(String(g.kind))) problems.push("kind \u53EA\u80FD\u662F \u7F3A\u9677\uFF08\u6545\u969C\uFF09/ \u7F3A\u80FD\u529B\uFF08\u9700\u6C42\uFF09");
11412
+ if (g.module !== void 0 && !["HCM-Core", "HCM-Cloud", "\u4EA7\u54C1\u652F\u6301"].includes(String(g.module))) problems.push("module \u53EA\u80FD\u662F HCM-Core / HCM-Cloud / \u4EA7\u54C1\u652F\u6301");
11413
+ if (problems.length) throw new Error(`\u7F3A\u53E3\u8F7D\u8377\u4E0D\u5408\u683C\uFF0C\u6CA1\u6709\u63D0\uFF1A
11414
+ ${problems.join("\n ")}`);
11415
+ return g;
11416
+ }
11417
+ var gapKeyTag = (g) => `\u3014${[g.model, g.action, g.error_code].filter(Boolean).join("\xB7") || "-"}\u3015`;
11418
+ var gapSummary = (g) => `\u7F3A\u53E3\uFF1A${g.title} ${gapKeyTag(g)}`;
11419
+ function renderGapDescription(g, fingerprintText2) {
11420
+ return [
11421
+ "h2. \u73B0\u8C61",
11422
+ g.phenomenon,
11423
+ "",
11424
+ "h2. \u590D\u73B0",
11425
+ "{code}",
11426
+ g.repro,
11427
+ "{code}",
11428
+ "",
11429
+ "h2. \u671F\u671B",
11430
+ g.expected,
11431
+ "",
11432
+ "h2. \u73AF\u5883\u6307\u7EB9",
11433
+ fingerprintText2,
11434
+ "",
11435
+ "h2. \u66FF\u4EE3\u6CD5",
11436
+ g.alternative,
11437
+ "",
11438
+ "h2. \u4E25\u91CD\u5EA6",
11439
+ `${g.severity}\uFF08\u987E\u95EE\u4FA7\u5224\u5B9A\uFF1A\u963B\u65AD=\u4EA4\u4ED8\u505C\u4E0B / \u6709\u66FF\u4EE3\u6CD5=\u80FD\u7ED5 / \u63AA\u8F9E\u7EA7=\u8F93\u51FA\u5DF2\u7ED9\u8DEF\u6807\uFF09`,
11440
+ "",
11441
+ "h2. \u4E09\u95EE\u81EA\u7B54",
11442
+ `# \u673A\u5236\u8FB9\u754C\uFF1A${g.q_mechanism}`,
11443
+ `# \u5386\u53F2\uFF1A${g.q_history}`,
11444
+ `# \u6280\u80FD\u6709\u6CA1\u6709\u6559\u9519\uFF1A${g.q_skill}`,
11445
+ "",
11446
+ "h2. \u5173\u952E\u8BCD",
11447
+ [g.error_code, g.model, g.action].filter(Boolean).join(" \xB7 ") || "\uFF08\u65E0\uFF09",
11448
+ "",
11449
+ "_\u7531\u987E\u95EE agent \u7ECF `hcm jira submit` \u63D0\u4EA4\u3002\u5206\u8BCA\u4E09\u53BB\u5411\uFF1A\u8F6C\u4EA7\u54C1\u4ED3 issue \u5E76\u56DE\u94FE / \u6539\u6280\u80FD\u5E76\u56DE\u590D / \u5408\u5E76\u8BA1\u6570\u3002\u5904\u7406\u529E\u6CD5\u89C1\u4EA7\u54C1\u4ED3\u6280\u80FD jira-triage\u3002_"
11450
+ ].join("\n");
11451
+ }
11452
+ function findDuplicateGap(open, summary, keyTag) {
11453
+ const bigrams = (t) => {
11454
+ const x = (t || "").replace(/〔.*?〕/g, "").replace(/[\s,。::、()()「」]/g, "");
11455
+ const out = /* @__PURE__ */ new Set();
11456
+ for (let i = 0; i + 1 < x.length; i++) out.add(x.slice(i, i + 2));
11457
+ return out;
11458
+ };
11459
+ const sim = (a, b) => {
11460
+ const A = bigrams(a);
11461
+ const B = bigrams(b);
11462
+ if (!A.size || !B.size) return 0;
11463
+ let n = 0;
11464
+ for (const s of A) if (B.has(s)) n++;
11465
+ return n / Math.min(A.size, B.size);
11466
+ };
11467
+ for (const i of open) {
11468
+ const t = i.fields.summary ?? "";
11469
+ if (keyTag !== "\u3014-\u3015" && t.includes(keyTag)) return i;
11470
+ if (sim(t, summary) >= 0.6) return i;
11471
+ }
11472
+ return null;
11473
+ }
11474
+ var KIND_TO_TYPE = { \u7F3A\u9677: ["\u6545\u969C", "Bug", "\u7F3A\u9677"], \u7F3A\u80FD\u529B: ["\u9700\u6C42", "Story", "New Feature"] };
11475
+ var KIND_TO_CATEGORY = { \u7F3A\u9677: "\u7A0B\u5E8FBug", \u7F3A\u80FD\u529B: "\u9700\u6C42" };
11476
+ var SEVERITY_TO_PRIORITY = {
11477
+ \u963B\u65AD: ["\u7D27\u6025", "Highest", "High", "\u9AD8"],
11478
+ \u6709\u66FF\u4EE3\u6CD5: ["Medium", "\u4E2D", "\u4E00\u822C", "High"],
11479
+ \u63AA\u8F9E\u7EA7: ["Low", "\u4F4E", "Lowest"]
11480
+ };
11481
+ var MODULE_DEFAULT_CHILD = { "HCM-Core": "\u57FA\u7840\u8BBE\u7F6E", "HCM-Cloud": "\u5F00\u53D1\u5E73\u53F0", \u4EA7\u54C1\u652F\u6301: "\u4EA7\u54C1\u652F\u6301" };
11482
+ function buildGapFields(g, ctx) {
11483
+ const wanted = KIND_TO_TYPE[g.kind] ?? [];
11484
+ const type = ctx.issuetypeOverride && ctx.types.find((t) => t.name === ctx.issuetypeOverride) || wanted.map((n) => ctx.types.find((t) => t.name === n)).find(Boolean);
11485
+ if (!type) {
11486
+ throw new Error(`\u9879\u76EE ${ctx.project} \u91CC\u6CA1\u6709\u300C${wanted.join(" / ")}\u300D\u8FD9\u7C7B issuetype\uFF0C\u5B9E\u9645\u6709\uFF1A${ctx.types.map((t) => t.name).join(" / ")}`);
11487
+ }
11488
+ const module = g.module ?? "HCM-Core";
11489
+ const keyTag = gapKeyTag(g);
11490
+ const byName = {
11491
+ \u6982\u8981: gapSummary(g),
11492
+ \u63CF\u8FF0: renderGapDescription(g, ctx.fingerprintText),
11493
+ \u95EE\u9898\u7C7B\u522B: KIND_TO_CATEGORY[g.kind],
11494
+ \u95EE\u9898\u6A21\u5757: module,
11495
+ \u4F18\u5148\u7EA7: SEVERITY_TO_PRIORITY[g.severity],
11496
+ \u62A5\u544A\u4EBA: ctx.me,
11497
+ \u7ECF\u529E\u4EBA: ctx.assignee,
11498
+ Bug\u53D1\u73B0\u4EBA: "\u987E\u95EE",
11499
+ Bug\u91CD\u73B0\u64CD\u4F5C\u6B65\u9AA4: g.repro,
11500
+ Bug\u9519\u8BEF\u53F7: g.error_code || "\u65E0\u9519\u8BEF\u7801\uFF08\u73B0\u8C61\u89C1\u63CF\u8FF0\uFF09"
11501
+ };
11502
+ const fields = { project: { key: ctx.project }, issuetype: { id: type.id } };
11503
+ const unfilled = [];
11504
+ const values = (f) => (f.allowedValues ?? []).map((v) => v.value ?? v.name).join("|");
11505
+ for (const f of type.fields ?? []) {
11506
+ if (["project", "issuetype"].includes(f.fieldId)) continue;
11507
+ const want = byName[f.name];
11508
+ if (want === void 0) {
11509
+ if (f.required) unfilled.push(`${f.name}(${f.fieldId})${f.allowedValues ? `=[${values(f)}]` : ""}`);
11510
+ continue;
11511
+ }
11512
+ if (f.schema?.type === "option-with-child") {
11513
+ const parent = (f.allowedValues ?? []).find((v) => (v.value ?? v.name) === want);
11514
+ if (!parent) {
11515
+ if (f.required) unfilled.push(`${f.name}(${f.fieldId}) \u60F3\u586B\u300C${String(want)}\u300D\u4F46\u53EF\u9009\u503C\u53EA\u6709 [${values(f)}]`);
11516
+ continue;
11517
+ }
11518
+ const childName = g.module_detail || MODULE_DEFAULT_CHILD[module];
11519
+ const child = (parent.children ?? []).find((c) => (c.value ?? c.name) === childName);
11520
+ if (!child && (parent.children ?? []).length) {
11521
+ unfilled.push(`${f.name}(${f.fieldId}) \u7684\u4E8C\u7EA7\u9879\u300C${childName}\u300D\u4E0D\u5728 [${(parent.children ?? []).map((c) => c.value ?? c.name).join("|")}] \u91CC`);
11522
+ continue;
11523
+ }
11524
+ fields[f.fieldId] = { id: parent.id, ...child ? { child: { id: child.id } } : {} };
11525
+ continue;
11526
+ }
11527
+ if (f.allowedValues) {
11528
+ const candidates = Array.isArray(want) ? want : [want];
11529
+ const hit = candidates.map((c) => f.allowedValues.find((v) => (v.name ?? v.value) === c)).find(Boolean);
11530
+ if (!hit) {
11531
+ if (f.required) unfilled.push(`${f.name}(${f.fieldId}) \u60F3\u586B\u300C${candidates.join("/")}\u300D\u4F46\u53EF\u9009\u503C\u53EA\u6709 [${values(f)}]`);
11532
+ continue;
11533
+ }
11534
+ fields[f.fieldId] = hit.id ? { id: hit.id } : { name: hit.name ?? hit.value };
11535
+ } else if (f.schema?.type === "user") {
11536
+ if (!want) {
11537
+ if (f.required) unfilled.push(`${f.name}(${f.fieldId}) \u53D6\u4E0D\u5230\u7528\u6237\u540D`);
11538
+ continue;
11539
+ }
11540
+ fields[f.fieldId] = { name: Array.isArray(want) ? want[0] : want };
11541
+ } else {
11542
+ fields[f.fieldId] = Array.isArray(want) ? want[0] : want;
11543
+ }
11544
+ }
11545
+ if ((type.fields ?? []).some((f) => f.fieldId === "labels")) {
11546
+ const sev = { \u963B\u65AD: "blocking", \u6709\u66FF\u4EE3\u6CD5: "workaround", \u63AA\u8F9E\u7EA7: "wording" }[g.severity];
11547
+ fields.labels = ["chiron-gap", `severity-${sev}`];
11548
+ }
11549
+ if (unfilled.length) {
11550
+ throw new Error(
11551
+ `\u8FD9\u53F0 Jira \u7684\u300C${type.name}\u300D\u6709\u6211\u586B\u4E0D\u4E0A\u7684\u5FC5\u586B\u5B57\u6BB5\uFF0C\u6CA1\u6709\u5EFA\u5355\uFF08\u4E0D\u66FF\u4F60\u731C\uFF09\uFF1A
11552
+ ${unfilled.join("\n ")}
11553
+ next_step=\u8BA9 Jira \u7BA1\u7406\u5458\u628A\u8FD9\u4E9B\u5B57\u6BB5\u6539\u6210\u975E\u5FC5\u586B\uFF0C\u6216\u544A\u8BC9\u6211\u8BE5\u586B\u4EC0\u4E48\u3001\u6211\u52A0\u8FDB\u6620\u5C04\u3002\u53F0\u8D26\u5DF2\u7ECF\u5728\u9879\u76EE\u4ED3\u91CC\uFF0C\u4E0D\u4F1A\u4E22\u3002`
11554
+ );
11555
+ }
11556
+ return { fields, type, keyTag, summary: gapSummary(g), module: `${module}/${g.module_detail || MODULE_DEFAULT_CHILD[module]}` };
11557
+ }
11558
+ async function gapSubmit({ client: client3 }, g, { fingerprintText: fingerprintText2, issuetypeOverride, assigneeOverride }) {
11559
+ const summary = gapSummary(g);
11560
+ const keyTag = gapKeyTag(g);
11561
+ const open = await client3.search(`project = ${client3.project} AND resolution = Unresolved ORDER BY created DESC`, { max: 100 });
11562
+ const dup = findDuplicateGap(open, summary, keyTag);
11563
+ if (dup) {
11564
+ const body = `\u53C8\u4E00\u4E2A\u73B0\u573A\uFF08${fingerprintText2}\uFF09
11565
+
11566
+ **\u73B0\u8C61**\uFF1A${g.phenomenon}
11567
+
11568
+ **\u590D\u73B0**\uFF1A
11569
+ {code}
11570
+ ${g.repro}
11571
+ {code}
11572
+
11573
+ **\u66FF\u4EE3\u6CD5**\uFF1A${g.alternative}
11574
+ \u4E25\u91CD\u5EA6\uFF1A${g.severity}`;
11575
+ await client3.addComment(dup.key, body);
11576
+ return { outcome: "appended", key: dup.key, url: client3.browseUrl(dup.key), summary: dup.fields.summary ?? "", alternative: g.alternative };
11577
+ }
11578
+ const [types, me, project] = await Promise.all([client3.createMeta(), client3.myself(), client3.projectInfo()]);
11579
+ const built = buildGapFields(g, {
11580
+ types,
11581
+ me: me.name ?? me.key ?? "",
11582
+ assignee: assigneeOverride || project.lead?.name || project.lead?.key,
11583
+ project: client3.project,
11584
+ fingerprintText: fingerprintText2,
11585
+ issuetypeOverride
11586
+ });
11587
+ const created = await client3.createIssue(built.fields);
11588
+ return { outcome: "created", key: created.key, url: client3.browseUrl(created.key), summary: built.summary, type: built.type.name, module: built.module, alternative: g.alternative };
11589
+ }
11590
+ async function gapSearch({ client: client3, cnb }, keywords, { includeClosed = true } = {}) {
11591
+ const rows = [];
11592
+ let jiraError;
11593
+ try {
11594
+ for (const kw of keywords) {
11595
+ const safe = kw.replace(/["\\]/g, " ").trim();
11596
+ const jql = `project = ${client3.project} AND text ~ "${safe}"${includeClosed ? "" : " AND resolution = Unresolved"} ORDER BY updated DESC`;
11597
+ for (const i of await client3.search(jql, { max: 15 })) {
11598
+ rows.push({ where: "Jira", id: i.key, title: i.fields.summary ?? "", state: i.fields.status?.name, resolution: i.fields.resolution?.name, url: client3.browseUrl(i.key) });
11599
+ }
11600
+ }
11601
+ if (!rows.length) {
11602
+ const open = await client3.search(`project = ${client3.project} AND resolution = Unresolved ORDER BY created DESC`, { max: 100 });
11603
+ for (const i of open) {
11604
+ if (keywords.some((k) => (i.fields.summary ?? "").includes(k))) {
11605
+ rows.push({ where: "Jira", id: i.key, title: i.fields.summary ?? "", state: i.fields.status?.name, url: client3.browseUrl(i.key) });
11606
+ }
11607
+ }
11608
+ }
11609
+ } catch (e) {
11610
+ jiraError = e.message;
11611
+ }
11612
+ for (const kw of keywords) {
11613
+ for (const st of includeClosed ? ["open", "closed"] : ["open"]) {
11614
+ for (const repo of PRODUCT_REPOS) {
11615
+ for (const i of searchRepoIssues(cnb, repo, kw, st)) rows.push({ where: "\u4EA7\u54C1\u4ED3", id: `${i.repo}#${i.number}`, title: i.title, state: i.state, url: i.url });
11616
+ }
11617
+ }
11618
+ }
11619
+ const seen = /* @__PURE__ */ new Set();
11620
+ return { rows: rows.filter((r) => seen.has(r.id) ? false : (seen.add(r.id), true)), jiraError };
11621
+ }
11622
+ async function gapStatus({ client: client3, cnb }, ref, casesSlug = "hcm/chiron-cases") {
11623
+ const parsed = parseRef(ref, client3.project, casesSlug);
11624
+ if (!parsed) throw new Error(`\u770B\u4E0D\u61C2 ${ref}\uFF1A\u7ED9 Jira \u5355\u53F7\uFF08HCMNX-12\uFF09\u3001\u4EA7\u54C1\u4ED3\u5F15\u7528\uFF08core#2198\uFF09\u6216\u5386\u53F2\u961F\u5217\u6761\u76EE\uFF08cases#26\uFF09`);
11625
+ if (parsed.kind === "repo") {
11626
+ const s = cnbIssueState(cnb, parsed.repo, parsed.number);
11627
+ if (s.kind !== "issue") throw new Error(`${parsed.repo}#${parsed.number} \u8BFB\u4E0D\u5230\uFF08\u7F16\u53F7\u4E0D\u5BF9\u3001\u662F PR \u53F7\uFF0C\u6216\u4F60\u6CA1\u6709\u8FD9\u4E2A\u4ED3\u7684\u6743\u9650\uFF09`);
11628
+ const where = parsed.repo === casesSlug ? "\u5386\u53F2\u961F\u5217" : "\u4EA7\u54C1\u4ED3";
11629
+ const nextStep2 = s.state === "closed" ? "\u8FD9\u6761\u5DF2\u5173\u3002\u76EE\u6807\u73AF\u5883\u90E8\u7F72\u5230\u542B\u4FEE\u590D\u7684\u7248\u672C\u540E `hcm skills update`\uFF0C\u518D\u6309\u6280\u80FD\u590D\u9A8C\u4E00\u6B21\u3002" : "\u8FD8\u5F00\u7740\u3002\u5148\u6309\u66FF\u4EE3\u6CD5\u7EE7\u7EED\u4EA4\u4ED8\uFF1B\u8981\u6392\u671F\u5C31\u5728\u90A3\u6761\u4E0B\u9762\u7559\u8A00\u3002";
11630
+ return { ref, lines: [`${where} ${s.repo}#${s.number} [${s.state}${s.reason ? "\xB7" + s.reason : ""}${s.priority ? " " + s.priority : ""}] ${s.title}`, ` ${s.url}`], nextStep: nextStep2, repo: s, links: [] };
11631
+ }
11632
+ const issue = await client3.issue(parsed.key);
11633
+ const cs = await client3.comments(parsed.key);
11634
+ const status = issue.fields.status?.name;
11635
+ const resolution = issue.fields.resolution?.name;
11636
+ const lines = [`Jira ${issue.key} [${status}${resolution ? "\xB7" + resolution : ""}${issue.fields.priority ? " " + issue.fields.priority.name : ""}] ${issue.fields.summary ?? ""}`, ` ${client3.browseUrl(issue.key)}`];
11637
+ const keyComments = cs.filter((c) => /分诊|已转|已修|合入|不做|重复|改技能|产品侧|代码库已关闭/.test(c.body ?? ""));
11638
+ const last = (keyComments.length ? keyComments : cs).at(-1);
11639
+ if (last) lines.push(` \u6700\u65B0\u5904\u7406\uFF08${String(last.created ?? "").slice(0, 10)} ${last.author?.displayName ?? "?"}\uFF09\uFF1A${(last.body ?? "").split("\n").find((l) => l.trim()) ?? ""}`.slice(0, 400));
11640
+ else lines.push(" \u8FD8\u6CA1\u6709\u4EBA\u5904\u7406\uFF08\u4EA7\u54C1\u4FA7\u6BCF\u5468\u6E05\u4E00\u6B21\uFF1B\u963B\u65AD\u7EA7\u8BF7\u5728\u9879\u76EE\u7FA4\u91CC\u70B9\u540D\u8D1F\u8D23\u4EBA\uFF09");
11641
+ const remote = (await client3.remoteLinks(parsed.key)).map((l) => l.object?.url ?? "").join("\n");
11642
+ const links = linkedRepoRefs(`${remote}
11643
+ ${issue.fields.description ?? ""}
11644
+ ${cs.map((c) => c.body ?? "").join("\n")}`).map((l) => cnbIssueState(cnb, l.repo, l.number));
11645
+ const issues = links.filter((l) => l.kind === "issue");
11646
+ for (const p of issues) lines.push(`\u4EA7\u54C1\u4ED3 ${p.repo}#${p.number} [${p.state}${p.reason ? "\xB7" + p.reason : ""}${p.priority ? " " + p.priority : ""}] ${p.title}`, ` ${p.url}`);
11647
+ let nextStep;
11648
+ 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 skills update`\uFF0C\u518D\u6309\u6280\u80FD\u590D\u9A8C\u4E00\u6B21\u3002";
11649
+ else if (issues.length && issues.every((s) => s.state === "closed")) nextStep = "\u4EA7\u54C1\u4ED3\u90A3\u6761\u5DF2\u5173\u3001Jira \u8FD8\u6CA1\u5173\uFF0C\u591A\u534A\u5728\u7B49\u53D1\u5E03\u3002\u7EE7\u7EED\u7528\u66FF\u4EE3\u6CD5\uFF0C\u53D1\u5E03\u540E\u590D\u9A8C\u3002";
11650
+ else if (issues.length) nextStep = "\u4EA7\u54C1\u4ED3\u5DF2\u7ACB\u9879\u3001\u8FD8\u6CA1\u5173\u3002\u7EE7\u7EED\u7528\u66FF\u4EE3\u6CD5\uFF1B\u60F3\u8981\u6392\u671F\u5C31\u5728 Jira \u8FD9\u5355\u4E0B\u7559\u8A00\u3002";
11651
+ 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`;
11652
+ return { ref, lines, nextStep, jira: { key: issue.key, status, resolution, url: client3.browseUrl(issue.key) }, links };
11653
+ }
11654
+
11655
+ // src/jira/triage.ts
11656
+ var GAP_PREFIX = "\u7F3A\u53E3\uFF1A";
11657
+ var PENDING_STATUS = "\u65B0\u589E";
11658
+ var SYNC_MARKER = "\u4EE3\u7801\u5E93\u5DF2\u5173\u95ED\uFF1A";
11659
+ var bodyText = (issue, comments, remote = []) => [issue.fields.description ?? "", ...comments.map((c) => c.body ?? ""), ...remote.map((l) => l.object?.url ?? "")].join("\n");
11660
+ async function listOpen(client3, { all = false } = {}) {
11661
+ const every = await client3.search(`project = ${client3.project} AND resolution = Unresolved ORDER BY created DESC`, { max: 100 });
11662
+ const picked = all ? every : every.filter((i) => i.fields.status?.name === PENDING_STATUS);
11663
+ return {
11664
+ unresolved: every.length,
11665
+ rows: picked.map((i) => ({
11666
+ key: i.key,
11667
+ status: i.fields.status?.name ?? "?",
11668
+ priority: i.fields.priority?.name,
11669
+ summary: i.fields.summary ?? "",
11670
+ url: client3.browseUrl(i.key),
11671
+ reporter: i.fields.reporter?.displayName,
11672
+ created: String(i.fields.created ?? "").slice(0, 10),
11673
+ fromAgent: (i.fields.summary ?? "").startsWith(GAP_PREFIX)
11674
+ }))
11675
+ };
11676
+ }
11677
+ async function showIssue({ client: client3, cnb }, key2) {
11678
+ const issue = await client3.issue(key2);
11679
+ const comments = await client3.comments(key2);
11680
+ const remoteLinks = await client3.remoteLinks(key2);
11681
+ const links = linkedRepoRefs(bodyText(issue, comments, remoteLinks)).map((l) => cnbIssueState(cnb, l.repo, l.number));
11682
+ const transitions = await client3.transitions(key2);
11683
+ return { issue, comments, remoteLinks, links, transitions };
11684
+ }
11685
+ async function commentIssue(client3, key2, body) {
11686
+ await client3.addComment(key2, body);
11687
+ return { key: key2, url: client3.browseUrl(key2) };
11688
+ }
11689
+ async function assignIssue(client3, key2, who) {
11690
+ const name = who === "me" || !who ? (await client3.myself()).name ?? "" : who;
11691
+ if (!name) throw new Error("\u53D6\u4E0D\u5230\u5F53\u524D\u7528\u6237\u540D\uFF0C\u65E0\u6CD5\u63A5\u624B");
11692
+ await client3.assign(key2, name);
11693
+ return { key: key2, who: name, transitions: await client3.transitions(key2) };
11694
+ }
11695
+ async function moveIssue(client3, key2, target, comment) {
11696
+ const transition = await client3.transition(key2, target, comment);
11697
+ return { key: key2, transition };
11698
+ }
11699
+ async function toIssue({ client: client3, cnb }, key2, { repo = "hcm/hcm_nx_core", force = false, priority = "P2" } = {}) {
11700
+ const issue = await client3.issue(key2);
11701
+ const comments = await client3.comments(key2);
11702
+ const existing = linkedRepoRefs(bodyText(issue, comments, await client3.remoteLinks(key2)));
11703
+ if (existing.length && !force) return { key: key2, existing: existing.map((e) => `${e.repo}#${e.number}`) };
11704
+ const title = `${issue.fields.summary ?? ""}\uFF08Jira ${key2}\uFF09`;
11705
+ const body = [
11706
+ `> \u6765\u81EA Jira ${key2}\uFF1A${client3.browseUrl(key2)}`,
11707
+ `> \u62A5\u544A\u4EBA\uFF1A${issue.fields.reporter?.displayName ?? "?"} \u4F18\u5148\u7EA7\uFF1A${issue.fields.priority?.name ?? "-"}`,
11708
+ "",
11709
+ issue.fields.description || "\uFF08Jira \u6B63\u6587\u4E3A\u7A7A\uFF09"
11710
+ ].join("\n");
11711
+ const raw = cnb(["issues", "create-issue", "--repo", repo, "--title", title, "--body", body, "--priority", priority]);
11712
+ const number = raw.match(/number:\s*"?(\d+)/)?.[1];
11713
+ if (!number) throw new Error(`\u4EA7\u54C1\u4ED3 issue \u5EFA\u5931\u8D25\uFF0Ccnb \u539F\u6837\u8F93\u51FA\uFF1A
11714
+ ${raw.slice(0, 500)}`);
11715
+ const url = repoIssueUrl(repo, number);
11716
+ await client3.addRemoteLink(key2, url, `${repo}#${number} ${issue.fields.summary ?? ""}`.slice(0, 250));
11717
+ await client3.addComment(key2, `\u5DF2\u5728\u4EE3\u7801\u5E93\u767B\u8BB0\uFF1A${repo}#${number}
11718
+ ${url}
11719
+ \u4FEE\u590D\u5408\u5165\u540E\u56DE\u5199\u672C\u5355\u4E3A\u300C\u5DF2\u4FEE\u590D\u300D\uFF0C\u76EE\u6807\u73AF\u5883\u53D1\u5E03\u4E14\u987E\u95EE\u590D\u9A8C\u901A\u8FC7\u540E\u624D\u5173\u95ED\u3002`);
11720
+ const me = (await client3.myself()).name;
11721
+ if (me && issue.fields.assignee?.name !== me) await client3.assign(key2, me);
11722
+ const out = { key: key2, repo, number, url };
11723
+ try {
11724
+ const hit = await client3.transition(key2, "\u6253\u5F00\u95EE\u9898");
11725
+ out.moved = hit.to?.name;
11726
+ } catch (e) {
11727
+ out.moveError = e.message;
11728
+ }
11729
+ return out;
11730
+ }
11731
+ async function syncIssue({ client: client3, cnb }, key2, { dryRun = false } = {}) {
11732
+ const issue = await client3.issue(key2);
11733
+ const comments = await client3.comments(key2);
11734
+ const refs = linkedRepoRefs(bodyText(issue, comments, await client3.remoteLinks(key2)));
11735
+ const links = refs.map((l) => cnbIssueState(cnb, l.repo, l.number));
11736
+ const issues = links.filter((l) => l.kind === "issue");
11737
+ if (!refs.length || !issues.length) return { key: key2, outcome: "no-links", links };
11738
+ if (links.some((l) => l.kind === "unreadable")) return { key: key2, outcome: "blocked-unreadable", links };
11739
+ const allClosed = issues.every((l) => l.state === "closed");
11740
+ if (!allClosed) return { key: key2, outcome: "not-closed", links };
11741
+ const already = comments.some((c) => (c.body ?? "").includes(SYNC_MARKER) || (c.body ?? "").includes("\u4EA7\u54C1\u4FA7\u5DF2\u5173\u95ED"));
11742
+ if (already) return { key: key2, outcome: "already-written", links };
11743
+ if (dryRun) return { key: key2, outcome: "dry-run-would-write", links };
11744
+ const summary = issues.map(describeIssueState).join("\u3001");
11745
+ await client3.addComment(
11746
+ key2,
11747
+ `${SYNC_MARKER}${summary}\u3002\u4FEE\u590D\u53EA\u662F\u8FDB\u4E86 main\u2014\u2014\u76EE\u6807\u73AF\u5883\u90E8\u7F72\u5230\u542B\u4FEE\u590D\u7684\u7248\u672C\u540E\uFF0C\u7531\u987E\u95EE\u590D\u9A8C\u901A\u8FC7\u624D\u5173\u672C\u5355\uFF08verify-pass\uFF09\uFF1B\u590D\u9A8C\u4E0D\u8FC7\u8D70 verify-fail \u9000\u56DE\u3002`
11748
+ );
11749
+ const out = { key: key2, outcome: "written", links };
11750
+ try {
11751
+ const hit = await client3.transition(key2, "\u5904\u7406\u5B8C\u6210");
11752
+ out.moved = hit.to?.name;
11753
+ } catch (e) {
11754
+ out.moveError = e.message;
11755
+ }
11756
+ return out;
11757
+ }
11758
+ async function verifyPass(client3, key2, note = "\u987E\u95EE\u5728\u76EE\u6807\u73AF\u5883\u590D\u9A8C\u901A\u8FC7\u3002") {
11759
+ await client3.addComment(key2, `\u987E\u95EE\u590D\u9A8C\u901A\u8FC7\uFF1A${note}`);
11760
+ const hit = await client3.transition(key2, "\u786E\u8BA4\u5173\u95ED");
11761
+ return { key: key2, to: hit.to?.name, url: client3.browseUrl(key2) };
11762
+ }
11763
+ async function verifyFail({ client: client3, cnb }, key2, note) {
11764
+ await client3.addComment(key2, `\u987E\u95EE\u590D\u9A8C\u672A\u901A\u8FC7\uFF0C\u9000\u56DE\uFF1A
11765
+ ${note}`);
11766
+ const out = { key: key2, reopened: [], failed: [] };
11767
+ try {
11768
+ out.moved = (await client3.transition(key2, "\u672A\u89E3\u51B3")).to?.name;
11769
+ } catch (e) {
11770
+ out.moveError = e.message;
11771
+ }
11772
+ const issue = await client3.issue(key2);
11773
+ const comments = await client3.comments(key2);
11774
+ for (const l of linkedRepoRefs(bodyText(issue, comments, await client3.remoteLinks(key2)))) {
11775
+ const state = cnbIssueState(cnb, l.repo, l.number);
11776
+ if (state.kind !== "issue") continue;
11777
+ try {
11778
+ cnb(["issues", "update-issue", "--repo", l.repo, "--number", l.number, "--state", "open", "--state-reason", "reopened"]);
11779
+ cnb(["issues", "post-issue-comment", "--repo", l.repo, "--number", l.number, "--body", `\u987E\u95EE\u590D\u9A8C\u672A\u901A\u8FC7\uFF0C\u91CD\u5F00\uFF08Jira ${key2}\uFF09\uFF1A
11780
+ ${note}`]);
11781
+ out.reopened.push(`${l.repo}#${l.number}`);
11782
+ } catch {
11783
+ out.failed.push(`${l.repo}#${l.number}`);
11784
+ }
11785
+ }
11786
+ return out;
11787
+ }
11788
+ async function auditIssues(client3) {
11789
+ const rows = (await client3.search(`project = ${client3.project} AND resolution = Unresolved ORDER BY created DESC`, { max: 100 })).filter(
11790
+ (i) => (i.fields.summary ?? "").startsWith(GAP_PREFIX)
11791
+ );
11792
+ const bad = [];
11793
+ for (const i of rows) {
11794
+ const status = i.fields.status?.name ?? "?";
11795
+ if (status === PENDING_STATUS) continue;
11796
+ const remote = await client3.remoteLinks(i.key);
11797
+ const text = bodyText(await client3.issue(i.key), await client3.comments(i.key), remote);
11798
+ if (!remote.length && !linkedRepoRefs(text).length) bad.push({ key: i.key, status, url: client3.browseUrl(i.key) });
11799
+ }
11800
+ return { checked: rows.length, bad };
11801
+ }
11802
+ async function probe(client3) {
11803
+ const [info, me, project] = await Promise.all([client3.serverInfo(), client3.myself(), client3.projectInfo()]);
11804
+ const types = (await client3.createMeta()).map((t) => ({
11805
+ id: t.id,
11806
+ name: t.name,
11807
+ required: (t.fields ?? []).filter((f) => f.required && !["project", "issuetype"].includes(f.fieldId)).map((f) => `${f.name}(${f.fieldId})${f.allowedValues ? `=[${f.allowedValues.slice(0, 8).map((v) => v.name ?? v.value).join("|")}]` : ""}`)
11808
+ }));
11809
+ const flows = (await client3.projectStatuses()).map((t) => ({ name: t.name, statuses: (t.statuses ?? []).map((s) => s.name ?? "") }));
11810
+ return {
11811
+ server: `Jira ${info.version ?? "?"} (${info.deploymentType ?? "?"}) @ ${client3.base}`,
11812
+ me: `${me.displayName ?? "?"} <${me.emailAddress ?? me.name ?? ""}> key=${me.key ?? me.name ?? ""}`,
11813
+ project: `${project.key ?? client3.project} ${project.name ?? ""} lead=${project.lead?.displayName ?? "?"}`,
11814
+ types,
11815
+ flows
11816
+ };
11817
+ }
11818
+
11819
+ // src/commands/jira.ts
11820
+ var defaultDeps3 = { client: () => createJiraClient(), cnb: defaultCnb };
11821
+ async function triageDeps(deps) {
11822
+ return { client: await deps.client(), cnb: deps.cnb };
11823
+ }
11824
+ function emit4(fmt, data, text) {
11825
+ if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject27(data, { format: fmt }) + "\n");
11826
+ else process.stdout.write(text() + "\n");
11827
+ }
11828
+ function readBody(opts, positional) {
11829
+ if (opts.file) return readFileSync7(opts.file, "utf8");
11830
+ if (opts.body) return opts.body;
11831
+ if (positional && positional.trim()) return positional;
11832
+ if (process.stdin.isTTY) throw new Error("\u7F3A\u6B63\u6587\uFF1A-f <\u6587\u4EF6> / --body <\u6587\u672C> / \u4F4D\u7F6E\u53C2\u6570\uFF0C\u6216\u4ECE\u6807\u51C6\u8F93\u5165\u5582");
11833
+ return readFileSync7(0, "utf8");
11834
+ }
11835
+ async function run(fn) {
11836
+ try {
11837
+ await fn();
11838
+ } catch (e) {
11839
+ exitWithError(e);
11840
+ }
11841
+ }
11842
+ async function jiraProbeCommand(args, deps = defaultDeps3) {
11843
+ await run(async () => {
11844
+ const r = await probe(await deps.client());
11845
+ emit4(
11846
+ args.output,
11847
+ r,
11848
+ () => [
11849
+ r.server,
11850
+ `\u6211\u662F\uFF1A${r.me}`,
11851
+ `\u9879\u76EE\uFF1A${r.project}`,
11852
+ ...r.types.map((t) => `issuetype ${t.name}(${t.id}) \u5FC5\u586B\uFF1A${t.required.join(" \xB7 ") || "\uFF08\u65E0\uFF09"}`),
11853
+ ...r.flows.map((f) => `\u72B6\u6001\u6D41 ${f.name}\uFF1A${f.statuses.join(" \u2192 ")}`)
11854
+ ].join("\n")
11855
+ );
11856
+ });
11857
+ }
11858
+ async function jiraOpenCommand(args, deps = defaultDeps3) {
11859
+ await run(async () => {
11860
+ const r = await listOpen(await deps.client(), { all: !!args.all });
11861
+ emit4(args.output, r, () => {
11862
+ if (!r.rows.length) return args.all ? "\u9879\u76EE\u91CC\u6CA1\u6709\u672A\u89E3\u51B3\u7684\u5355\u3002" : `\u6CA1\u6709\u5F85\u5206\u8BCA\uFF08\u72B6\u6001\u300C\u65B0\u589E\u300D\uFF09\u7684\u5355\uFF1B\u9879\u76EE\u91CC\u672A\u89E3\u51B3\u7684\u5171 ${r.unresolved} \u6761\uFF0C\u770B\u5168\u90E8\u52A0 --all\u3002`;
11863
+ return r.rows.map((i) => `${i.key} [${i.status}${i.priority ? " " + i.priority : ""}]${i.fromAgent ? "" : " \uFF08\u975E agent \u63D0\u5355\uFF09"} ${i.summary}
11864
+ ${i.url} \u62A5\u544A\u4EBA ${i.reporter ?? "?"} ${i.created}`).join("\n");
11865
+ });
11866
+ });
11867
+ }
11868
+ async function jiraShowCommand(key2, args, deps = defaultDeps3) {
11869
+ await run(async () => {
11870
+ const d = await triageDeps(deps);
11871
+ const r = await showIssue(d, key2);
11872
+ const i = r.issue;
11873
+ emit4(args.output, r, () => {
11874
+ const out = [
11875
+ `${i.key} [${i.fields.status?.name}${i.fields.resolution ? "\xB7" + i.fields.resolution.name : ""}${i.fields.priority ? " " + i.fields.priority.name : ""}] ${i.fields.summary ?? ""}`,
11876
+ `${d.client.browseUrl(i.key)} \u62A5\u544A\u4EBA ${i.fields.reporter?.displayName ?? "?"} \u7ECF\u529E\u4EBA ${i.fields.assignee?.displayName ?? "-"} \u6807\u7B7E ${(i.fields.labels ?? []).join(",") || "-"}`,
11877
+ "",
11878
+ "--- \u6B63\u6587 ---",
11879
+ i.fields.description || "\uFF08\u7A7A\uFF09"
11880
+ ];
11881
+ for (const c of r.comments) out.push("", `--- \u8BC4\u8BBA ${c.author?.displayName ?? "?"} ${String(c.created ?? "").slice(0, 10)} ---`, c.body ?? "");
11882
+ for (const l of r.links) out.push("", `\u5173\u8054\u4EE3\u7801\u5E93 ${describeIssueState(l)}`);
11883
+ out.push("", `\u53EF\u7528\u6D41\u8F6C\uFF1A${r.transitions.map((t) => `${t.name}\u2192${t.to?.name}`).join(" / ") || "\uFF08\u65E0\uFF09"}`);
11884
+ return out.join("\n");
11885
+ });
11886
+ });
11887
+ }
11888
+ async function jiraCommentCommand(key2, text, args, deps = defaultDeps3) {
11889
+ await run(async () => {
11890
+ const body = readBody(args, text);
11891
+ const r = await commentIssue(await deps.client(), key2, body);
11892
+ emit4(args.output, r, () => `\u5DF2\u56DE\u590D ${r.key}\uFF1A${r.url}`);
11893
+ });
11894
+ }
11895
+ async function jiraAssignCommand(key2, who, args, deps = defaultDeps3) {
11896
+ await run(async () => {
11897
+ const r = await assignIssue(await deps.client(), key2, who);
11898
+ emit4(args.output, r, () => `${r.key} \u5DF2\u6539\u6D3E\u7ED9 ${r.who}\u3002\u73B0\u5728\u53EF\u505A\u7684\u6D41\u8F6C\uFF1A${r.transitions.map((x) => `${x.name}\u2192${x.to?.name}`).join(" / ") || "\uFF08\u65E0\uFF09"}`);
11899
+ });
11900
+ }
11901
+ async function jiraMoveCommand(key2, target, args, deps = defaultDeps3) {
11902
+ await run(async () => {
11903
+ const comment = args.file || args.body ? readBody(args) : void 0;
11904
+ const r = await moveIssue(await deps.client(), key2, target, comment);
11905
+ emit4(args.output, r, () => `${r.key} \u5DF2\u6D41\u8F6C\uFF1A${r.transition.name} \u2192 ${r.transition.to?.name}`);
11906
+ });
11907
+ }
11908
+ async function jiraToIssueCommand(key2, args, deps = defaultDeps3) {
11909
+ await run(async () => {
11910
+ const r = await toIssue(await triageDeps(deps), key2, { repo: args.repo, force: !!args.force });
11911
+ emit4(args.output, r, () => {
11912
+ if ("existing" in r) return `${r.key} \u5DF2\u5173\u8054 ${r.existing.join("\u3001")}\uFF0C\u4E0D\u91CD\u590D\u5EFA\u3002\u8981\u518D\u5EFA\u52A0 --force`;
11913
+ const moved = r.moved ? `\uFF0C\u5DF2\u63A8\u8FDB\u5230 ${r.moved}` : r.moveError ? `\uFF0C\u4F46\u6CA1\u80FD\u63A8\u8FDB\u72B6\u6001\uFF1A${r.moveError}` : "";
11914
+ return `${r.key} \u2192 ${r.repo}#${r.number} ${r.url}${moved}`;
11915
+ });
11916
+ });
11917
+ }
11918
+ async function jiraSyncCommand(key2, args, deps = defaultDeps3) {
11919
+ await run(async () => {
11920
+ const r = await syncIssue(await triageDeps(deps), key2, { dryRun: !!args.dryRun });
11921
+ emit4(args.output, r, () => {
11922
+ const links = r.links.map(describeIssueState).join("\u3001") || "\uFF08\u65E0\uFF09";
11923
+ switch (r.outcome) {
11924
+ case "written":
11925
+ return `${r.key} \u5DF2\u56DE\u5199\uFF1A${links}${r.moved ? ` \u5E76\u63A8\u8FDB\u5230 ${r.moved}` : r.moveError ? `\uFF08\u72B6\u6001\u6CA1\u63A8\u52A8\uFF1A${r.moveError}\uFF09` : ""}`;
11926
+ case "dry-run-would-write":
11927
+ return `${r.key} \u4EE3\u7801\u5E93\u6761\u76EE\u5DF2\u5168\u5173\uFF0C\u5B9E\u8DD1\u4F1A\u56DE\u5199\u5E76\u63A8\u300C\u5904\u7406\u5B8C\u6210\u300D\uFF1A${links}`;
11928
+ case "already-written":
11929
+ return `${r.key} \u5DF2\u56DE\u5199\u8FC7\uFF0C\u8DF3\u8FC7\uFF1A${links}`;
11930
+ case "not-closed":
11931
+ return `${r.key} \u4EA7\u54C1\u4ED3\u8FD8\u6CA1\u5173\uFF1A${links}`;
11932
+ case "blocked-unreadable":
11933
+ return `${r.key} \u6709\u8BFB\u4E0D\u5230\u7684\u4EE3\u7801\u5E93\u6761\u76EE\uFF0C\u4E0D\u6562\u5224\u5DF2\u5173\uFF08fail-closed\uFF09\uFF1A${links}`;
11934
+ default:
11935
+ return `${r.key} \u6CA1\u6709\u5173\u8054\u7684\u4EA7\u54C1\u4ED3 issue\uFF08PR \u53F7\u4E0D\u7B97\uFF09\uFF0C\u5148 to-issue\uFF1A${links}`;
11936
+ }
11937
+ });
11938
+ if (r.outcome === "blocked-unreadable") process.exitCode = 1;
11939
+ });
11940
+ }
11941
+ async function jiraVerifyPassCommand(key2, note, args, deps = defaultDeps3) {
11942
+ await run(async () => {
11943
+ const text = args.file || args.body || note && note.trim() ? readBody(args, note) : "\u987E\u95EE\u5728\u76EE\u6807\u73AF\u5883\u590D\u9A8C\u901A\u8FC7\u3002";
11944
+ const r = await verifyPass(await deps.client(), key2, text);
11945
+ emit4(args.output, r, () => `${r.key} \u5DF2\u5173\u95ED\uFF08${r.to ?? "?"}\uFF09\uFF1A${r.url}`);
11946
+ });
11947
+ }
11948
+ async function jiraVerifyFailCommand(key2, note, args, deps = defaultDeps3) {
11949
+ await run(async () => {
11950
+ const r = await verifyFail(await triageDeps(deps), key2, readBody(args, note));
11951
+ emit4(args.output, r, () => {
11952
+ const moved = r.moved ? `\u5DF2\u9000\u56DE\u5230 ${r.moved}` : `\u72B6\u6001\u6CA1\u9000\u56DE\uFF08${r.moveError ?? "?"}\uFF09`;
11953
+ const failed2 = r.failed.length ? `\uFF1B\u91CD\u5F00\u5931\u8D25\uFF1A${r.failed.join("\u3001")}` : "";
11954
+ return `${r.key} ${moved}\uFF1B\u5DF2\u91CD\u5F00 ${r.reopened.join("\u3001") || "\uFF08\u6CA1\u6709\u53EF\u91CD\u5F00\u7684\u4EE3\u7801\u5E93\u6761\u76EE\uFF09"}${failed2}`;
11955
+ });
11956
+ });
11957
+ }
11958
+ async function jiraAuditCommand(args, deps = defaultDeps3) {
11959
+ await run(async () => {
11960
+ const r = await auditIssues(await deps.client());
11961
+ emit4(args.output, r, () => {
11962
+ if (!r.checked) return "\u9879\u76EE\u91CC\u6CA1\u6709\u672A\u89E3\u51B3\u7684\u7F3A\u53E3\u5355\u3002";
11963
+ const lines = r.bad.map((b) => `\u26A0\uFE0F ${b.key} [${b.status}] \u6CA1\u6709\u4EE3\u7801\u5E93\u6761\u76EE\uFF1A${b.url}`);
11964
+ lines.push(r.bad.length ? `${r.bad.length} \u6761\u72B6\u6001\u5DF2\u63A8\u8FDB\u5374\u6CA1\u767B\u8BB0\uFF0C\u5148\u8865 to-issue\u3002` : "\u4E00\u81F4\uFF1A\u5DF2\u53D7\u7406\u7684\u5355\u90FD\u6302\u7740\u4EE3\u7801\u5E93\u6761\u76EE\u3002");
11965
+ return lines.join("\n");
11966
+ });
11967
+ if (r.bad.length) process.exitCode = 1;
11968
+ });
11969
+ }
11970
+ async function jiraSearchCommand(keywords, args, deps = defaultDeps3) {
11971
+ await run(async () => {
11972
+ if (!keywords.length) throw new Error("\u7ED9\u81F3\u5C11\u4E00\u4E2A\u5173\u952E\u8BCD\uFF1A\u9519\u8BEF\u7801 / Model / Action / \u4E00\u53E5\u73B0\u8C61");
11973
+ const r = await gapSearch(await triageDeps(deps), keywords, { includeClosed: args.includeClosed !== false });
11974
+ emit4(args.output, r, () => {
11975
+ const head = r.jiraError ? `\u26A0\uFE0F Jira \u6CA1\u67E5\u6210\uFF08${r.jiraError}\uFF09\uFF0C\u4E0B\u9762\u53EA\u6709\u4EA7\u54C1\u4ED3\u7684\u7ED3\u679C\uFF0C\u4E0D\u4EE3\u8868 Jira \u91CC\u6CA1\u6709\u3002
11976
+ ` : "";
11977
+ if (!r.rows.length) return `${head}Jira \u4E0E\u4EA7\u54C1\u4ED3\u90FD\u6CA1\u6709\u76F8\u5173\u8BB0\u5F55\u3002\u53EF\u4EE5 submit\uFF0C\u4F46\u5148\u628A\u4E09\u95EE\u7B54\u5B8C\u3002`;
11978
+ return `${head}\u547D\u4E2D ${r.rows.length} \u6761\uFF08\u540C\u4E00\u7F3A\u53E3\u5DF2\u6709\u7F16\u53F7\u5C31\u5728\u90A3\u6761\u4E0B\u8FFD\u52A0\u73B0\u573A\uFF0C\u4E0D\u65B0\u5F00\uFF09\uFF1A
11979
+ ${r.rows.map((i) => `${i.where} ${i.id} [${i.state}${i.resolution ? "\xB7" + i.resolution : ""}] ${i.title}
11980
+ ${i.url}`).join("\n")}`;
11981
+ });
11982
+ });
11983
+ }
11984
+ async function jiraStatusCommand(ref, args, deps = defaultDeps3) {
11985
+ await run(async () => {
11986
+ const r = await gapStatus(await triageDeps(deps), ref);
11987
+ emit4(args.output, r, () => [...r.lines, `\u4E0B\u4E00\u6B65\uFF1A${r.nextStep}`].join("\n"));
11988
+ });
11989
+ }
11990
+ async function fingerprintText(env2) {
11991
+ try {
11992
+ const g = await loadGlobalConfig12();
11993
+ const name = resolveActiveEnv6({ envFlag: env2 }, process.env, g);
11994
+ const cfg = await loadEnv12(name);
11995
+ if (!cfg?.endpoint) return `\u672A\u53D6\u5230\u6307\u7EB9\uFF08env=${name}\uFF1A\u6CA1\u6709 endpoint\uFF09`;
11996
+ const http = createHttpClient4({ endpoint: cfg.endpoint.replace(/\/+$/, ""), getAccessToken: async () => null, onRefresh: async () => {
11997
+ } });
11998
+ const resp = await http.get("/api/version/backend");
11999
+ const info = resp.data?.data ?? resp.data ?? {};
12000
+ const commit = info.commit ?? info.gitCommit ?? info.version ?? "?";
12001
+ return `backend ${String(commit).slice(0, 12)} \xB7 CLI ${CLI_VERSION} \xB7 env ${name}`;
12002
+ } catch (e) {
12003
+ return `\u672A\u53D6\u5230\u6307\u7EB9\uFF08env=${env2 ?? "\u672A\u8BBE"}\uFF1B${String(e.message ?? e).split("\n")[0]?.slice(0, 120)}\uFF09`;
12004
+ }
12005
+ }
12006
+ async function jiraSubmitCommand(args, deps = defaultDeps3) {
12007
+ await run(async () => {
12008
+ const raw = args.file ? readFileSync7(args.file, "utf8") : process.stdin.isTTY ? "" : readFileSync7(0, "utf8");
12009
+ if (!raw.trim()) throw new Error("\u7F3A\u53E3\u8F7D\u8377\uFF1A--file <gap.json> \u6216\u4ECE\u6807\u51C6\u8F93\u5165\u5582 JSON");
12010
+ const gap = validateGapInput(JSON.parse(raw));
12011
+ const fp = args.fingerprint ?? await fingerprintText(args.env);
12012
+ const r = await gapSubmit(await triageDeps(deps), gap, { fingerprintText: fp, issuetypeOverride: args.issuetype, assigneeOverride: args.assignee });
12013
+ emit4(
12014
+ args.output,
12015
+ r,
12016
+ () => r.outcome === "appended" ? `Jira \u91CC\u5DF2\u6709\u540C\u4E00\u7F3A\u53E3 ${r.key}\u300C${r.summary}\u300D\uFF0C\u5DF2\u8FFD\u52A0\u300C\u53C8\u4E00\u4E2A\u73B0\u573A\u300D\u8BC4\u8BBA\uFF0C\u6CA1\u6709\u65B0\u5F00\u3002
12017
+ ${r.url}
12018
+ \u7ED9\u987E\u95EE\u7684\u8BDD\uFF1A\u8FD9\u4E2A\u95EE\u9898\u5DF2\u7ECF\u5728\u4EA7\u54C1\u90A3\u8FB9\u6392\u7740\uFF0C\u7F16\u53F7 ${r.key}\uFF1B\u5148\u7528\u66FF\u4EE3\u6CD5\u300C${r.alternative}\u300D\u7EE7\u7EED\uFF0C\u5206\u8BCA\u7ED3\u8BBA\u4F1A\u56DE\u5230\u90A3\u5355\u91CC\u3002` : `\u5DF2\u63D0 ${r.key}\uFF08${r.type} \xB7 ${r.module}\uFF09\uFF1A${r.url}
12019
+ \u7ED9\u987E\u95EE\u7684\u8BDD\uFF1A\u7F3A\u53E3\u5DF2\u63D0\uFF0C\u7F16\u53F7 ${r.key}\uFF1B\u5148\u7528\u66FF\u4EE3\u6CD5\u300C${r.alternative}\u300D\u7EE7\u7EED\uFF0C\u4EA7\u54C1\u5206\u8BCA\u540E\u4F1A\u5728\u90A3\u5355\u91CC\u56DE\u590D\u3002\u62A5\u544A\u91CC\u5199\u300CBLOCKED \xB7 \u5DF2\u63D0 ${r.key} \xB7 \u66FF\u4EE3\u6CD5\uFF1A${r.alternative}\u300D\u3002`
12020
+ );
12021
+ });
12022
+ }
12023
+
11039
12024
  // src/commands/delivery-recon.ts
11040
12025
  init_auth_guard();
11041
12026
  init_exit();
@@ -11044,7 +12029,7 @@ import {
11044
12029
  ReconLayout,
11045
12030
  ROUND_EXIT_CODES,
11046
12031
  computeReconSourceKey,
11047
- formatObject as formatObject27,
12032
+ formatObject as formatObject28,
11048
12033
  fromAxiosError as fromAxiosError22,
11049
12034
  httpProbe as httpProbe4,
11050
12035
  inspectRound,
@@ -11056,15 +12041,15 @@ async function deliveryReconCommand(args) {
11056
12041
  try {
11057
12042
  const ctx = await getActiveAuthContextFromCli(args);
11058
12043
  const client3 = HcmClient24.fromAuthContext(ctx);
11059
- const probe = httpProbe4(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES2);
11060
- const sourceKey = await computeReconSourceKey(probe);
12044
+ const probe2 = httpProbe4(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES2);
12045
+ const sourceKey = await computeReconSourceKey(probe2);
11061
12046
  const layout = new ReconLayout(args.out ?? ".", ctx.tenantId, sourceKey);
11062
- const summary = await runRecon(probe, layout, {
12047
+ const summary = await runRecon(probe2, layout, {
11063
12048
  state: args.state ?? "",
11064
12049
  onlyModel: args.model ?? null,
11065
12050
  identity: ctx.tenantId ? { requestedTenantId: ctx.tenantId } : null
11066
12051
  });
11067
- process.stdout.write(formatObject27(summary, { format: args.output ?? "json" }) + "\n");
12052
+ process.stdout.write(formatObject28(summary, { format: args.output ?? "json" }) + "\n");
11068
12053
  } catch (e) {
11069
12054
  const err = e;
11070
12055
  if (err?.isAxiosError) exitWithError(fromAxiosError22(err, args.env));
@@ -11078,7 +12063,7 @@ async function deliveryReconRoundCommand(args) {
11078
12063
  const result = inspectRound(args.dir ?? ".");
11079
12064
  const fmt = args.output ?? "json";
11080
12065
  if (fmt !== "json") process.stdout.write(renderRound(result));
11081
- process.stdout.write(formatObject27(result, { format: fmt }) + "\n");
12066
+ process.stdout.write(formatObject28(result, { format: fmt }) + "\n");
11082
12067
  code = ROUND_EXIT_CODES[result.state];
11083
12068
  } catch (e) {
11084
12069
  exitWithError(e);
@@ -11097,14 +12082,14 @@ import {
11097
12082
  GAP_REASONS,
11098
12083
  deriveAclass,
11099
12084
  exitCode as gate0ExitCode,
11100
- formatObject as formatObject28,
12085
+ formatObject as formatObject29,
11101
12086
  inspectRound as inspectRound2,
11102
12087
  loadProtocolFacts,
11103
12088
  scan
11104
12089
  } from "@hcmai/sdk";
11105
- import * as path13 from "path";
12090
+ import * as path14 from "path";
11106
12091
  function renderGate0(result, skillRoot) {
11107
- const where = skillRoot ? `\uFF08${path13.resolve(skillRoot)}\uFF09` : "";
12092
+ const where = skillRoot ? `\uFF08${path14.resolve(skillRoot)}\uFF09` : "";
11108
12093
  const lines = [
11109
12094
  `\u626B\u63CF\u9762${where}\uFF1A${result.scanned.length} \u4E2A\u6587\u4EF6\uFF1B\u5224\u7EA2 ${result.red.length} \u6761\uFF1B\u7F3A\u53E3\u653E\u884C ${result.gaps.length} \u6761\u3002`
11110
12095
  ];
@@ -11142,7 +12127,7 @@ async function deliveryGate0Command(args) {
11142
12127
  const merged = { ...result, premise: premise5 };
11143
12128
  const fmt = args.output ?? "json";
11144
12129
  if (fmt !== "json") process.stdout.write(renderGate0(merged, skillRoot));
11145
- process.stdout.write(`${formatObject28(merged, { format: fmt })}
12130
+ process.stdout.write(`${formatObject29(merged, { format: fmt })}
11146
12131
  `);
11147
12132
  for (const problem of premise5) {
11148
12133
  process.stderr.write(`\u{1F534} \u524D\u63D0\u4E0D\u6210\u7ACB\uFF08${problem.reason}\uFF09\uFF1A${problem.message}
@@ -11217,7 +12202,7 @@ import {
11217
12202
  writeRisk
11218
12203
  } from "@hcmai/sdk";
11219
12204
  import { existsSync as existsSync3 } from "fs";
11220
- import * as path14 from "path";
12205
+ import * as path15 from "path";
11221
12206
  function premise(message, hint = "") {
11222
12207
  process.stderr.write(message + (hint ? `
11223
12208
  \u2192 ${hint}` : "") + "\n");
@@ -11244,13 +12229,13 @@ async function runSeedPlan(args, client3) {
11244
12229
  const reconDir = candidates[0].reconDir;
11245
12230
  if (candidates.length > 1) {
11246
12231
  process.stderr.write(
11247
- `\u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u6709 ${candidates.length} \u4EFD\u57FA\u7EBF\uFF0C\u672C\u8F6E\u8BFB\u7684\u662F \`${path14.basename(reconDir)}\`\uFF1A` + candidates.slice(1).map((c) => `\`${path14.basename(c.reconDir)}\``).join("\u3001") + " \u672A\u88AB\u8BFB\u53D6 \u2014\u2014 \u4E0D\u540C sourceKey \u7684\u4EA7\u7269**\u4E0D\u53EF\u4E92\u6362**\u3002\n"
12232
+ `\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"
11248
12233
  );
11249
12234
  }
11250
12235
  const round = inspectRound3(reconDir);
11251
12236
  process.stderr.write(roundWarning(round));
11252
12237
  const baseline = {
11253
- path: `${path14.basename(path14.dirname(reconDir))}/${path14.basename(reconDir)}`,
12238
+ path: `${path15.basename(path15.dirname(reconDir))}/${path15.basename(reconDir)}`,
11254
12239
  roundId: round.roundId ?? null
11255
12240
  };
11256
12241
  let exemptions = null;
@@ -11511,8 +12496,8 @@ async function deliverySeedVerifyCommand(args) {
11511
12496
 
11512
12497
  // src/commands/delivery-seed-find.ts
11513
12498
  import { existsSync as existsSync4 } from "fs";
11514
- import { readFileSync as readFileSync7 } from "fs";
11515
- import * as path15 from "path";
12499
+ import { readFileSync as readFileSync8 } from "fs";
12500
+ import * as path16 from "path";
11516
12501
  import {
11517
12502
  INIT_EXIT_CODES as INIT_EXIT_CODES2,
11518
12503
  ValueHints,
@@ -11526,10 +12511,10 @@ import {
11526
12511
  valuesRoundCaveat
11527
12512
  } from "@hcmai/sdk";
11528
12513
  function provenance(chosenReconDir, others) {
11529
- let line = `> \u57FA\u7EBF\uFF1A\`${path15.basename(chosenReconDir)}\`
12514
+ let line = `> \u57FA\u7EBF\uFF1A\`${path16.basename(chosenReconDir)}\`
11530
12515
  `;
11531
12516
  if (others.length > 0) {
11532
- line += `> \u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u53E6\u6709 ${others.length} \u4EFD\u57FA\u7EBF\u672A\u88AB\u8BFB\u53D6\uFF1A` + others.map((o) => `\`${path15.basename(o)}\``).join("\u3001") + " \u2014\u2014 \u4E0D\u540C sourceKey \u7684\u4EA7\u7269**\u4E0D\u53EF\u4E92\u6362**\u3002\n";
12517
+ 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";
11533
12518
  }
11534
12519
  return `${line}
11535
12520
  `;
@@ -11574,7 +12559,7 @@ function runSeedFind(args) {
11574
12559
  if (!existsSync4(chosen.indexFile)) {
11575
12560
  return premise2(`\u7D22\u5F15\u6587\u4EF6\u5728\u9009\u4E2D\u4E4B\u540E\u6D88\u5931\u4E86\uFF1A${chosen.indexFile}`);
11576
12561
  }
11577
- const { rows, problems } = loadRows(readFileSync7(chosen.indexFile, "utf-8"));
12562
+ const { rows, problems } = loadRows(readFileSync8(chosen.indexFile, "utf-8"));
11578
12563
  process.stdout.write(
11579
12564
  renderFind(find(rows, args.term), args.term, rows.length, {
11580
12565
  prefixBytes: Buffer.byteLength(prefix, "utf-8"),
@@ -11614,7 +12599,7 @@ function deliverySeedValuesCommand(model, args) {
11614
12599
 
11615
12600
  // src/commands/delivery-meta.ts
11616
12601
  init_auth_guard();
11617
- import { readFileSync as readFileSync8 } from "fs";
12602
+ import { readFileSync as readFileSync9 } from "fs";
11618
12603
  import {
11619
12604
  BINDING_WORDS,
11620
12605
  CHANGE_STATES,
@@ -11762,7 +12747,7 @@ function premise3(what, hint) {
11762
12747
  async function runDeliveryMeta(args, client3) {
11763
12748
  let content;
11764
12749
  try {
11765
- content = readFileSync8(args.contentFile, "utf-8");
12750
+ content = readFileSync9(args.contentFile, "utf-8");
11766
12751
  } catch (e) {
11767
12752
  return premise3(
11768
12753
  `\u8981\u5199\u8FDB\u53BB\u7684\u6B63\u6587\u8BFB\u4E0D\u51FA\u6765\uFF1A${e.message}`,
@@ -11865,8 +12850,8 @@ import {
11865
12850
  ReconLayout as ReconLayout2,
11866
12851
  runTriageRound
11867
12852
  } from "@hcmai/sdk";
11868
- import { mkdirSync, readFileSync as readFileSync9, writeFileSync as writeFileSync2 } from "fs";
11869
- import * as path16 from "path";
12853
+ import { mkdirSync, readFileSync as readFileSync10, writeFileSync as writeFileSync2 } from "fs";
12854
+ import * as path17 from "path";
11870
12855
  var DEFAULT_CAPABILITIES4 = "default";
11871
12856
  function premise4(message, hint) {
11872
12857
  process.stderr.write(`\u{1F534} \u524D\u63D0\u4E0D\u6210\u7ACB\uFF1A${message}
@@ -11879,7 +12864,7 @@ var REQUESTS_SHAPE = "`--requests` \u6536\u7684\u662F\u4E00\u4E2A JSON \u6570\u7
11879
12864
  function readRequests(file) {
11880
12865
  let raw;
11881
12866
  try {
11882
- raw = JSON.parse(readFileSync9(file, "utf8"));
12867
+ raw = JSON.parse(readFileSync10(file, "utf8"));
11883
12868
  } catch (e) {
11884
12869
  throw new Error(`\u9700\u6C42\u6E05\u5355\u8BFB\u4E0D\u51FA\u6765\uFF08${file}\uFF09\uFF1A${e instanceof Error ? e.message : String(e)}`);
11885
12870
  }
@@ -11902,8 +12887,8 @@ function renderProblems(rows) {
11902
12887
  `;
11903
12888
  }
11904
12889
  function writeTriageArtifact(outDir, body) {
11905
- const out = path16.join(outDir, "work", "triage.md");
11906
- mkdirSync(path16.dirname(out), { recursive: true });
12890
+ const out = path17.join(outDir, "work", "triage.md");
12891
+ mkdirSync(path17.dirname(out), { recursive: true });
11907
12892
  writeFileSync2(out, body, "utf8");
11908
12893
  return out;
11909
12894
  }
@@ -11917,9 +12902,9 @@ async function runTriage(args) {
11917
12902
  }
11918
12903
  const ctx = await getActiveAuthContextFromCli(args);
11919
12904
  const client3 = HcmClient27.fromAuthContext(ctx);
11920
- const probe = httpProbe5(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES4);
11921
- const artifactsDir = args.recon ?? new ReconLayout2(args.out ?? ".", ctx.tenantId, await computeReconSourceKey2(probe)).dir;
11922
- const result = await runTriageRound(probe, artifactsDir, entriesIn);
12905
+ const probe2 = httpProbe5(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES4);
12906
+ const artifactsDir = args.recon ?? new ReconLayout2(args.out ?? ".", ctx.tenantId, await computeReconSourceKey2(probe2)).dir;
12907
+ const result = await runTriageRound(probe2, artifactsDir, entriesIn);
11923
12908
  if (result.body === null) {
11924
12909
  process.stdout.write(renderProblems(result.problems));
11925
12910
  return 1;
@@ -11944,9 +12929,9 @@ async function deliveryTriageCommand(args) {
11944
12929
  // src/commands/delivery-execution.ts
11945
12930
  import { createHash as createHash5, randomBytes as secureRandomBytes } from "crypto";
11946
12931
  import { spawn as spawn2 } from "child_process";
11947
- import { createReadStream, promises as fs13 } from "fs";
11948
- import path17 from "path";
11949
- import { CliError as CliError23, CliErrorCode as CliErrorCode21, formatObject as formatObject29 } from "@hcmai/sdk";
12932
+ import { createReadStream, promises as fs14 } from "fs";
12933
+ import path18 from "path";
12934
+ import { CliError as CliError23, CliErrorCode as CliErrorCode21, formatObject as formatObject30 } from "@hcmai/sdk";
11950
12935
  init_exit();
11951
12936
  var EXECUTION_CONTRACT_VERSION = "2026-09-03.controlled-v4";
11952
12937
  var DEFAULT_TTL_SECONDS = 15 * 60;
@@ -11988,11 +12973,11 @@ async function prepareDeliveryExecution(input) {
11988
12973
  };
11989
12974
  const planId = sha2565(canonicalJson(core)).slice(0, 24);
11990
12975
  const plan = { ...core, planId };
11991
- const plansDir = path17.join(project, ".hcm-delivery", "execution-plans");
12976
+ const plansDir = path18.join(project, ".hcm-delivery", "execution-plans");
11992
12977
  await safeManagedDirectory(project, ".hcm-delivery/execution-plans", plansDir);
11993
- const planFile = path17.join(plansDir, `${planId}.json`);
12978
+ const planFile = path18.join(plansDir, `${planId}.json`);
11994
12979
  try {
11995
- await fs13.writeFile(planFile, `${JSON.stringify(plan, null, 2)}
12980
+ await fs14.writeFile(planFile, `${JSON.stringify(plan, null, 2)}
11996
12981
  `, {
11997
12982
  encoding: "utf8",
11998
12983
  mode: 384,
@@ -12006,7 +12991,7 @@ async function prepareDeliveryExecution(input) {
12006
12991
  async function executeDeliveryPlan(input) {
12007
12992
  if (!PLAN_ID_PATTERN.test(input.planId)) throw invalid2("planId \u5FC5\u987B\u662F 24 \u4F4D\u5C0F\u5199\u5341\u516D\u8FDB\u5236");
12008
12993
  const project = await realProject(input.project);
12009
- const planFile = path17.join(project, ".hcm-delivery", "execution-plans", `${input.planId}.json`);
12994
+ const planFile = path18.join(project, ".hcm-delivery", "execution-plans", `${input.planId}.json`);
12010
12995
  const plan = await readPlan(project, planFile);
12011
12996
  if (plan.planId !== input.planId || computePlanId(plan) !== input.planId) {
12012
12997
  throw invalid2("\u6267\u884C\u8BA1\u5212\u5185\u5BB9\u4E0E planId \u6458\u8981\u4E0D\u4E00\u81F4");
@@ -12043,13 +13028,13 @@ async function executeDeliveryPlan(input) {
12043
13028
  await assertDocumentUnchanged(project, plan.documents.rollback, "\u56DE\u6EDA\u8BF4\u660E");
12044
13029
  await assertPayloadsUnchanged(project, plan.payloads);
12045
13030
  const evidenceDir = await bindEvidenceDirectory(project, plan.evidenceDir);
12046
- const receiptFile = path17.join(evidenceDir.absolute, `${plan.planId}.receipt.json`);
13031
+ const receiptFile = path18.join(evidenceDir.absolute, `${plan.planId}.receipt.json`);
12047
13032
  if (await pathExists(receiptFile)) throw invalid2(`\u6267\u884C\u6536\u636E\u5DF2\u5B58\u5728\uFF0C\u62D2\u7EDD\u518D\u6B21\u6267\u884C\uFF1A${plan.planId}`);
12048
- const claimsDir = path17.join(project, ".hcm-delivery", "execution-claims");
13033
+ const claimsDir = path18.join(project, ".hcm-delivery", "execution-claims");
12049
13034
  await safeManagedDirectory(project, ".hcm-delivery/execution-claims", claimsDir);
12050
- const claimFile = path17.join(claimsDir, `${plan.planId}.json`);
13035
+ const claimFile = path18.join(claimsDir, `${plan.planId}.json`);
12051
13036
  try {
12052
- await fs13.writeFile(
13037
+ await fs14.writeFile(
12053
13038
  claimFile,
12054
13039
  `${JSON.stringify({ schemaVersion: 1, planId: plan.planId, claimedAt: now.toISOString() }, null, 2)}
12055
13040
  `,
@@ -12060,10 +13045,10 @@ async function executeDeliveryPlan(input) {
12060
13045
  }
12061
13046
  const stdoutHash = createHash5("sha256");
12062
13047
  const stderrHash = createHash5("sha256");
12063
- const run = input.runCommand ?? runCurrentCliCommand;
13048
+ const run2 = input.runCommand ?? runCurrentCliCommand;
12064
13049
  let exitCode;
12065
13050
  try {
12066
- ({ exitCode } = await run(argv, project, {
13051
+ ({ exitCode } = await run2(argv, project, {
12067
13052
  stdout: (chunk) => stdoutHash.update(chunk),
12068
13053
  stderr: (chunk) => stderrHash.update(chunk)
12069
13054
  }));
@@ -12106,7 +13091,7 @@ async function deliveryPrepareCommand(argv, args) {
12106
13091
  evidenceDir: args.evidenceDir,
12107
13092
  ...ttlSeconds === void 0 ? {} : { ttlSeconds }
12108
13093
  });
12109
- process.stdout.write(formatObject29(plan, { format: args.output ?? "json" }) + "\n");
13094
+ process.stdout.write(formatObject30(plan, { format: args.output ?? "json" }) + "\n");
12110
13095
  process.stderr.write(
12111
13096
  `
12112
13097
  \u4E0B\u4E00\u6B65\uFF08argv \u5FC5\u987B\u4E0E\u672C\u6B21\u5B8C\u5168\u4E00\u81F4\uFF09\uFF1A
@@ -12135,11 +13120,11 @@ async function deliveryExecuteCommand(planId, argv, args) {
12135
13120
  }
12136
13121
  }
12137
13122
  function writeDeliveryExecutionReceipt(receipt, format = "json") {
12138
- process.stderr.write(formatObject29(receipt, { format }) + "\n");
13123
+ process.stderr.write(formatObject30(receipt, { format }) + "\n");
12139
13124
  process.exitCode = receipt.exitCode;
12140
13125
  }
12141
13126
  async function readProjectMode(project, environment) {
12142
- const file = path17.join(project, ".hcm-delivery", "project.yml");
13127
+ const file = path18.join(project, ".hcm-delivery", "project.yml");
12143
13128
  const content = await readSafeFile(project, file, "\u9879\u76EE\u914D\u7F6E");
12144
13129
  let mode;
12145
13130
  try {
@@ -12158,13 +13143,13 @@ async function readProjectMode(project, environment) {
12158
13143
  return mode;
12159
13144
  }
12160
13145
  var SKILLS_LOCK_CANDIDATES = [
12161
- path17.join("hcm-skills", ".hcm-skills.json"),
12162
- path17.join(".claude", "skills", ".hcm-skills.json")
13146
+ path18.join("hcm-skills", ".hcm-skills.json"),
13147
+ path18.join(".claude", "skills", ".hcm-skills.json")
12163
13148
  ];
12164
13149
  async function readSkillsLock(project) {
12165
13150
  const found = [];
12166
13151
  for (const candidate of SKILLS_LOCK_CANDIDATES) {
12167
- if (await pathExists(path17.join(project, candidate))) found.push(candidate);
13152
+ if (await pathExists(path18.join(project, candidate))) found.push(candidate);
12168
13153
  }
12169
13154
  if (found.length === 0) {
12170
13155
  throw invalid2(
@@ -12176,7 +13161,7 @@ async function readSkillsLock(project) {
12176
13161
  `\u9879\u76EE\u91CC\u6709\u591A\u4EFD\u6280\u80FD\u9501\uFF08${found.join("\u3001")}\uFF09\uFF0C\u65E0\u6CD5\u552F\u4E00\u5224\u5B9A\u53D7\u63A7\u6267\u884C\u7ED1\u5B9A\u54EA\u4E00\u4EFD\u3002next_step=\u53EA\u4FDD\u7559\u5B9E\u9645\u5728\u7528\u7684\u90A3\u4E2A\u6280\u80FD\u76EE\u5F55`
12177
13162
  );
12178
13163
  }
12179
- const bytes = await readSafeFile(project, path17.join(project, found[0]), "\u6280\u80FD\u9501");
13164
+ const bytes = await readSafeFile(project, path18.join(project, found[0]), "\u6280\u80FD\u9501");
12180
13165
  try {
12181
13166
  JSON.parse(bytes.toString("utf8"));
12182
13167
  } catch (cause) {
@@ -12189,7 +13174,7 @@ async function bindDocument(project, reference, label) {
12189
13174
  if (!(relative2.startsWith("work/") || relative2.startsWith("decisions/"))) {
12190
13175
  throw invalid2(`${label}\u5FC5\u987B\u4F4D\u4E8E\u9879\u76EE work/ \u6216 decisions/ \u4E0B`);
12191
13176
  }
12192
- const file = path17.join(project, relative2);
13177
+ const file = path18.join(project, relative2);
12193
13178
  const bytes = await readSafeFile(project, file, label);
12194
13179
  return { path: relative2, sha256: sha2565(bytes) };
12195
13180
  }
@@ -12202,11 +13187,11 @@ async function bindEvidenceDirectory(project, reference) {
12202
13187
  if (!(relative2 === "evidence" || relative2.startsWith("evidence/"))) {
12203
13188
  throw invalid2("evidence \u76EE\u5F55\u5FC5\u987B\u4F4D\u4E8E\u9879\u76EE evidence/ \u4E0B");
12204
13189
  }
12205
- const absolute = path17.join(project, relative2);
13190
+ const absolute = path18.join(project, relative2);
12206
13191
  await assertNoSymlinkComponents(project, relative2);
12207
- const stat = await fs13.stat(absolute).catch(() => null);
13192
+ const stat = await fs14.stat(absolute).catch(() => null);
12208
13193
  if (stat === null) {
12209
- await fs13.mkdir(absolute, { recursive: true, mode: 448 }).catch((cause) => {
13194
+ await fs14.mkdir(absolute, { recursive: true, mode: 448 }).catch((cause) => {
12210
13195
  throw invalid2(
12211
13196
  `evidence \u76EE\u5F55\u5EFA\u4E0D\u51FA\u6765\uFF1A${relative2}\u3002next_step=\u68C0\u67E5\u4E0A\u7EA7\u76EE\u5F55\u6743\u9650\uFF0C\u6216\u6362\u4E00\u4E2A evidence/ \u4E0B\u7684\u8DEF\u5F84`,
12212
13197
  cause
@@ -12389,7 +13374,7 @@ async function bindPayloadPath(project, reference, label) {
12389
13374
  const relative2 = safeRelative(reference, label);
12390
13375
  let stat;
12391
13376
  try {
12392
- stat = await fs13.stat(path17.join(project, relative2));
13377
+ stat = await fs14.stat(path18.join(project, relative2));
12393
13378
  } catch (cause) {
12394
13379
  throw invalid2(
12395
13380
  `${label}\u4E0D\u5B58\u5728\uFF1A${relative2}\u3002next_step=\u628A\u6570\u636E\u96C6\u653E\u8FDB\u9879\u76EE\u76EE\u5F55\u5185\uFF0C\u5E76\u7528\u9879\u76EE\u5185\u76F8\u5BF9\u8DEF\u5F84\u5F15\u7528\uFF08\u53D7\u63A7\u6267\u884C\u53EA\u9489\u5F97\u4F4F\u9879\u76EE\u5185\u7684\u8F7D\u8377\uFF09`,
@@ -12400,10 +13385,10 @@ async function bindPayloadPath(project, reference, label) {
12400
13385
  }
12401
13386
  async function bindPayloadDirectory(project, reference, label) {
12402
13387
  const relative2 = reference === "." ? "." : safeRelative(reference, label);
12403
- const root = path17.join(project, relative2);
13388
+ const root = path18.join(project, relative2);
12404
13389
  let stat;
12405
13390
  try {
12406
- stat = await fs13.stat(root);
13391
+ stat = await fs14.stat(root);
12407
13392
  } catch {
12408
13393
  throw invalid2(`${label}\u4E0D\u5B58\u5728\uFF1A${relative2}`);
12409
13394
  }
@@ -12413,12 +13398,12 @@ async function bindPayloadDirectory(project, reference, label) {
12413
13398
  const skipToolingAtRoot = relative2 === ".";
12414
13399
  const entries = [];
12415
13400
  const walk = async (dir, prefix) => {
12416
- const items = await fs13.readdir(dir, { withFileTypes: true });
13401
+ const items = await fs14.readdir(dir, { withFileTypes: true });
12417
13402
  for (const item of [...items].sort(
12418
13403
  (a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0
12419
13404
  )) {
12420
13405
  if (skipToolingAtRoot && prefix === "" && TOOLING_DIRS.includes(item.name)) continue;
12421
- const child = path17.join(dir, item.name);
13406
+ const child = path18.join(dir, item.name);
12422
13407
  const rel = prefix ? `${prefix}/${item.name}` : item.name;
12423
13408
  if (item.isSymbolicLink()) {
12424
13409
  throw invalid2(
@@ -12443,7 +13428,7 @@ ${sha2565(bytes)}`);
12443
13428
  }
12444
13429
  async function bindPayloadFile(project, reference, label) {
12445
13430
  const relative2 = safeRelative(reference, label);
12446
- const file = path17.join(project, relative2);
13431
+ const file = path18.join(project, relative2);
12447
13432
  const bytes = await readSafeFile(project, file, label);
12448
13433
  return { path: relative2, kind: "file", sha256: sha2565(bytes) };
12449
13434
  }
@@ -12506,29 +13491,29 @@ async function runCurrentCliCommand(argv, cwd, streams) {
12506
13491
  async function writeReceiptExclusive(target, receipt) {
12507
13492
  const temp = `${target}.${process.pid}.${Date.now()}.tmp`;
12508
13493
  try {
12509
- await fs13.writeFile(temp, `${JSON.stringify(receipt, null, 2)}
13494
+ await fs14.writeFile(temp, `${JSON.stringify(receipt, null, 2)}
12510
13495
  `, {
12511
13496
  encoding: "utf8",
12512
13497
  mode: 384,
12513
13498
  flag: "wx"
12514
13499
  });
12515
- await fs13.link(temp, target);
13500
+ await fs14.link(temp, target);
12516
13501
  } catch (cause) {
12517
- throw invalid2(`\u6267\u884C\u6536\u636E\u5199\u5165\u5931\u8D25\u6216\u5DF2\u5B58\u5728\uFF1A${path17.basename(target)}`, cause);
13502
+ throw invalid2(`\u6267\u884C\u6536\u636E\u5199\u5165\u5931\u8D25\u6216\u5DF2\u5B58\u5728\uFF1A${path18.basename(target)}`, cause);
12518
13503
  } finally {
12519
- await fs13.unlink(temp).catch(() => void 0);
13504
+ await fs14.unlink(temp).catch(() => void 0);
12520
13505
  }
12521
13506
  }
12522
13507
  async function safeManagedDirectory(project, relative2, absolute) {
12523
- await assertNoSymlinkComponents(project, path17.dirname(relative2));
12524
- const existing = await fs13.lstat(absolute).catch(() => void 0);
13508
+ await assertNoSymlinkComponents(project, path18.dirname(relative2));
13509
+ const existing = await fs14.lstat(absolute).catch(() => void 0);
12525
13510
  if (existing?.isSymbolicLink()) throw invalid2(`\u53D7\u7BA1\u76EE\u5F55\u4E0D\u80FD\u662F\u7B26\u53F7\u94FE\u63A5\uFF1A${relative2}`);
12526
13511
  if (existing && !existing.isDirectory()) throw invalid2(`\u53D7\u7BA1\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55\uFF1A${relative2}`);
12527
- if (!existing) await fs13.mkdir(absolute, { mode: 448 });
12528
- await fs13.chmod(absolute, 448);
13512
+ if (!existing) await fs14.mkdir(absolute, { mode: 448 });
13513
+ await fs14.chmod(absolute, 448);
12529
13514
  }
12530
13515
  async function pathExists(file) {
12531
- return fs13.lstat(file).then(
13516
+ return fs14.lstat(file).then(
12532
13517
  () => true,
12533
13518
  (cause) => {
12534
13519
  if (cause.code === "ENOENT") return false;
@@ -12537,47 +13522,47 @@ async function pathExists(file) {
12537
13522
  );
12538
13523
  }
12539
13524
  async function readSafeFile(project, file, label) {
12540
- const relative2 = path17.relative(project, file).split(path17.sep).join("/");
12541
- if (relative2.startsWith("../") || path17.isAbsolute(relative2))
13525
+ const relative2 = path18.relative(project, file).split(path18.sep).join("/");
13526
+ if (relative2.startsWith("../") || path18.isAbsolute(relative2))
12542
13527
  throw invalid2(`${label}\u8DEF\u5F84\u9003\u9038\u9879\u76EE`);
12543
13528
  await assertNoSymlinkComponents(project, relative2);
12544
13529
  let stat;
12545
13530
  try {
12546
- stat = await fs13.lstat(file);
13531
+ stat = await fs14.lstat(file);
12547
13532
  } catch (cause) {
12548
13533
  throw invalid2(`${label}\u4E0D\u53EF\u7528\uFF1A${relative2}`, cause);
12549
13534
  }
12550
13535
  if (stat.isSymbolicLink()) throw invalid2(`${label}\u4E0D\u80FD\u662F\u7B26\u53F7\u94FE\u63A5\uFF1A${relative2}`);
12551
13536
  if (!stat.isFile()) throw invalid2(`${label}\u4E0D\u662F\u666E\u901A\u6587\u4EF6\uFF1A${relative2}`);
12552
- return fs13.readFile(file);
13537
+ return fs14.readFile(file);
12553
13538
  }
12554
13539
  async function assertNoSymlinkComponents(project, relative2) {
12555
13540
  const parts = relative2.split("/").filter(Boolean);
12556
13541
  let current = project;
12557
13542
  for (const part of parts) {
12558
- current = path17.join(current, part);
12559
- const stat = await fs13.lstat(current).catch(() => void 0);
13543
+ current = path18.join(current, part);
13544
+ const stat = await fs14.lstat(current).catch(() => void 0);
12560
13545
  if (stat?.isSymbolicLink()) throw invalid2(`\u8DEF\u5F84\u5305\u542B\u7B26\u53F7\u94FE\u63A5\uFF1A${relative2}`);
12561
13546
  if (!stat) break;
12562
13547
  }
12563
13548
  }
12564
13549
  async function realProject(requested) {
12565
- const absolute = path17.resolve(requested);
13550
+ const absolute = path18.resolve(requested);
12566
13551
  let project;
12567
13552
  try {
12568
- project = await fs13.realpath(absolute);
13553
+ project = await fs14.realpath(absolute);
12569
13554
  } catch (cause) {
12570
13555
  throw invalid2(`\u9879\u76EE\u76EE\u5F55\u4E0D\u53EF\u7528\uFF1A${absolute}`, cause);
12571
13556
  }
12572
- const stat = await fs13.stat(project);
13557
+ const stat = await fs14.stat(project);
12573
13558
  if (!stat.isDirectory()) throw invalid2(`\u9879\u76EE\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55\uFF1A${absolute}`);
12574
13559
  return project;
12575
13560
  }
12576
13561
  function safeRelative(reference, label) {
12577
- if (!reference || path17.isAbsolute(reference) || /[\r\n\0]/.test(reference)) {
13562
+ if (!reference || path18.isAbsolute(reference) || /[\r\n\0]/.test(reference)) {
12578
13563
  throw invalid2(`${label}\u5FC5\u987B\u662F\u9879\u76EE\u5185\u76F8\u5BF9\u8DEF\u5F84`);
12579
13564
  }
12580
- const normalized = path17.normalize(reference).split(path17.sep).join("/");
13565
+ const normalized = path18.normalize(reference).split(path18.sep).join("/");
12581
13566
  if (normalized === ".." || normalized.startsWith("../") || normalized === ".") {
12582
13567
  throw invalid2(`${label}\u8DEF\u5F84\u9003\u9038\u9879\u76EE`);
12583
13568
  }
@@ -12644,7 +13629,7 @@ init_exit();
12644
13629
  import {
12645
13630
  HcmClient as HcmClient28,
12646
13631
  adminResetPassword,
12647
- formatObject as formatObject30,
13632
+ formatObject as formatObject31,
12648
13633
  fromAxiosError as fromAxiosError23,
12649
13634
  CliError as CliError24,
12650
13635
  CliErrorCode as CliErrorCode22
@@ -12678,7 +13663,7 @@ async function userResetPasswordCommand(args) {
12678
13663
  const request = buildAdminResetPasswordRequest(args, password);
12679
13664
  const client3 = HcmClient28.fromAuthContext(await getActiveAuthContextFromCli(args));
12680
13665
  const result = await adminResetPassword(client3.raw(), request);
12681
- process.stdout.write(formatObject30(result, { format: args.output ?? "json" }) + "\n");
13666
+ process.stdout.write(formatObject31(result, { format: args.output ?? "json" }) + "\n");
12682
13667
  } catch (cause) {
12683
13668
  const err = cause;
12684
13669
  if (err?.isAxiosError) exitWithError(fromAxiosError23(err, args.env));
@@ -12702,7 +13687,7 @@ init_exit();
12702
13687
  init_auth_guard();
12703
13688
  import {
12704
13689
  HcmClient as HcmClient29,
12705
- formatObject as formatObject31,
13690
+ formatObject as formatObject32,
12706
13691
  fromAxiosError as fromAxiosError24
12707
13692
  } from "@hcmai/sdk";
12708
13693
  async function modelsCommand(keyword, args) {
@@ -12713,7 +13698,7 @@ async function modelsCommand(keyword, args) {
12713
13698
  const rows = (needle ? all.filter((m) => JSON.stringify(m).toLowerCase().includes(needle)) : all).sort((a, b) => key(a).localeCompare(key(b)));
12714
13699
  const fmt = args.output ?? "table";
12715
13700
  if (fmt !== "table") {
12716
- process.stdout.write(formatObject31({ total: rows.length, models: rows }, { format: fmt }) + "\n");
13701
+ process.stdout.write(formatObject32({ total: rows.length, models: rows }, { format: fmt }) + "\n");
12717
13702
  process.exitCode = 0;
12718
13703
  return;
12719
13704
  }
@@ -12806,6 +13791,22 @@ chiron.command("test").description("\u6309\u7528\u4F8B\u8DD1\u4E00\u904D\u5E76\u
12806
13791
  chiron.command("doctor").description(
12807
13792
  "\u6838\u5BF9\uFF1A\u672C\u673A\u767B\u5F55\u662F\u5426\u5BF9\u7740 env.yaml \u7684\u73AF\u5883\uFF08\u542B\u56DB\u6761\u951A\u70B9\uFF09/ \u6280\u80FD\u88C5\u6CA1\u88C5 / \u6848\u4F8B\u5E93\u63A5\u6CA1\u63A5 / Jira \u80FD\u4E0D\u80FD\u63D0\u5355"
12808
13793
  ).option("--project <dir>", "\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--fix", "\u80FD\u81EA\u52A8\u8865\u7684\u8865\u4E0A\uFF08\u6280\u80FD / \u6848\u4F8B\u5E93\uFF09\u540E\u518D\u6838\u4E00\u904D").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => chironDoctorCommand(opts));
13794
+ var OUTPUT_OPT = ["--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table"];
13795
+ var jira = program.command("jira").description("\u777F\u620E\u7F3A\u53E3\u5728 Jira\uFF08HCMNX\uFF09\u4E0A\u7684\u51FA\u53E3\uFF1A\u987E\u95EE\u4FA7 search / status / submit\uFF1B\u4EA7\u54C1\u4FA7 open / show / to-issue / sync / verify-*");
13796
+ jira.command("probe").description("\u6211\u662F\u8C01 / Jira \u7248\u672C / \u9879\u76EE / issuetype \u4E0E\u5FC5\u586B\u5B57\u6BB5 / \u72B6\u6001\u6D41\uFF1B\u7B2C\u4E00\u6B21\u5148\u8DD1\u5B83").option(...OUTPUT_OPT).action((opts) => jiraProbeCommand(opts));
13797
+ jira.command("open").description("\u5F85\u5206\u8BCA\u7684\u5355\uFF08\u72B6\u6001\u300C\u65B0\u589E\u300D\uFF09\uFF1B--all \u770B\u9879\u76EE\u91CC\u5168\u90E8\u672A\u89E3\u51B3\u7684").option("--all", "\u5168\u90E8\u672A\u89E3\u51B3\u7684\u5355\uFF0C\u4E0D\u53EA\u5F85\u5206\u8BCA").option(...OUTPUT_OPT).action((opts) => jiraOpenCommand(opts));
13798
+ jira.command("show").description("\u6B63\u6587 + \u8BC4\u8BBA + \u5173\u8054\u4EE3\u7801\u5E93\u6761\u76EE\u7684\u72B6\u6001 + \u53EF\u7528\u6D41\u8F6C").argument("<key>", "Jira \u5355\u53F7\uFF0C\u5982 HCMNX-12").option(...OUTPUT_OPT).action((key2, opts) => jiraShowCommand(key2, opts));
13799
+ jira.command("comment").description("\u56DE\u590D\uFF08\u5206\u8BCA\u7ED3\u8BBA\u8D70\u8FD9\u6761\uFF09\uFF1A-f \u6587\u4EF6 / --body \u6587\u672C / \u4F4D\u7F6E\u53C2\u6570 / \u6807\u51C6\u8F93\u5165").argument("<key>", "Jira \u5355\u53F7").argument("[text]", "\u6B63\u6587").option("-f, --file <path>", "\u6B63\u6587\u6587\u4EF6").option("--body <text>", "\u6B63\u6587").option(...OUTPUT_OPT).action((key2, text, opts) => jiraCommentCommand(key2, text, opts));
13800
+ jira.command("assign").description("\u63A5\u624B\uFF1A\u6539\u7ECF\u529E\u4EBA\uFF08\u9ED8\u8BA4 me\uFF09").argument("<key>", "Jira \u5355\u53F7").argument("[who]", "\u7528\u6237\u540D\u6216 me", "me").option(...OUTPUT_OPT).action((key2, who, opts) => jiraAssignCommand(key2, who, opts));
13801
+ jira.command("move").description("\u6D41\u8F6C\uFF1A\u76EE\u6807\u72B6\u6001\u540D\u6216\u6D41\u8F6C\u540D\uFF08\u5982 \u63D0\u4EA4\u534F\u8C03 / \u4E0D\u7528\u5904\u7406\u4E86\uFF09\uFF1B\u53EF\u9644\u8BC4\u8BBA").argument("<key>", "Jira \u5355\u53F7").argument("<target>", "\u72B6\u6001\u6216\u6D41\u8F6C\u540D").option("-f, --file <path>", "\u9644\u5E26\u8BC4\u8BBA\u7684\u6587\u4EF6").option("--body <text>", "\u9644\u5E26\u8BC4\u8BBA").option(...OUTPUT_OPT).action((key2, target, opts) => jiraMoveCommand(key2, target, opts));
13802
+ jira.command("to-issue").description("\u5206\u8BCA\u4E3A\u771F\u7F3A\u53E3\uFF1A\u8F6C\u4EA7\u54C1\u4ED3 issue \u5E76\u53CC\u5411\u56DE\u94FE\uFF08\u5EFA\u6761\u76EE \u2192 \u6302\u94FE\u63A5 \u2192 \u63A5\u624B \u2192 \u63A8 OPEN\uFF09").argument("<key>", "Jira \u5355\u53F7").option("--repo <slug>", "\u4EA7\u54C1\u4ED3", "hcm/hcm_nx_core").option("--force", "\u5DF2\u5173\u8054\u8FC7\u4E5F\u518D\u5EFA\u4E00\u6761").option(...OUTPUT_OPT).action((key2, opts) => jiraToIssueCommand(key2, opts));
13803
+ jira.command("sync").description("\u4EE3\u7801\u5E93\u6761\u76EE\u5168\u5173 \u2192 \u56DE\u5199 Jira \u5E76\u63A8\u300C\u5DF2\u4FEE\u590D\u300D\uFF08PR \u53F7\u4E0D\u7B97\u6761\u76EE\uFF1B\u8BFB\u4E0D\u5230\u7684\u6309\u672A\u5173\u5904\u7406\uFF09").argument("<key>", "Jira \u5355\u53F7").option("--dry-run", "\u53EA\u5224\u65AD\u4E0D\u5199").option(...OUTPUT_OPT).action((key2, opts) => jiraSyncCommand(key2, opts));
13804
+ jira.command("verify-pass").description("\u987E\u95EE\u5728\u76EE\u6807\u73AF\u5883\u590D\u9A8C\u901A\u8FC7 \u2192 CLOSE").argument("<key>", "Jira \u5355\u53F7").argument("[note]", "\u8BF4\u660E").option("-f, --file <path>", "\u8BF4\u660E\u6587\u4EF6").option("--body <text>", "\u8BF4\u660E").option(...OUTPUT_OPT).action((key2, note, opts) => jiraVerifyPassCommand(key2, note, opts));
13805
+ jira.command("verify-fail").description("\u590D\u9A8C\u4E0D\u901A\u8FC7 \u2192 \u9000\u56DE OPEN\uFF0C\u5E76\u91CD\u5F00\u4EE3\u7801\u5E93 issue").argument("<key>", "Jira \u5355\u53F7").argument("[note]", "\u4E0D\u901A\u8FC7\u7684\u8BF4\u660E").option("-f, --file <path>", "\u8BF4\u660E\u6587\u4EF6").option("--body <text>", "\u8BF4\u660E").option(...OUTPUT_OPT).action((key2, note, opts) => jiraVerifyFailCommand(key2, note, opts));
13806
+ jira.command("audit").description("\u4E00\u81F4\u6027\uFF1A\u72B6\u6001\u5DF2\u79BB\u5F00\u300C\u65B0\u589E\u300D\u7684\u7F3A\u53E3\u5355\u5FC5\u987B\u6302\u7740\u4EE3\u7801\u5E93\u6761\u76EE").option(...OUTPUT_OPT).action((opts) => jiraAuditCommand(opts));
13807
+ jira.command("search").description("\u987E\u95EE\u4FA7\u67E5\u91CD\uFF1A\u6309\u9519\u8BEF\u7801 / Model / Action / \u4E00\u53E5\u73B0\u8C61\u67E5 Jira \u4E0E\u4EA7\u54C1\u4ED3\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) => jiraSearchCommand(keywords, opts));
13808
+ jira.command("status").description("\u987E\u95EE\u4FA7\u67E5\u8FDB\u5EA6\uFF1A\u8BA4 HCMNX-12 / 12 / core#2198 / cases#26").argument("<ref>", "Jira \u5355\u53F7\u6216\u4EE3\u7801\u5E93\u5F15\u7528").option(...OUTPUT_OPT).action((ref, opts) => jiraStatusCommand(ref, opts));
13809
+ jira.command("submit").description("\u987E\u95EE\u4FA7\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) => jiraSubmitCommand(opts));
12809
13810
  var delivery = program.command("delivery").description("\u987E\u95EE\u4EA4\u4ED8\uFF1A\u73B0\u573A\u63A2\u6D3B\u3001\u98CE\u9669\u8BC4\u4F30\u4E0E\u4E00\u6B21\u6027\u53D7\u63A7\u6267\u884C\u5408\u540C");
12810
13811
  delivery.command("assess").description("\u8BC4\u4F30\u4E00\u6B21 HCM CLI argv\uFF1BAction \u98CE\u63A7\u58F0\u660E\u8BFB\u53D6\u81EA\u76EE\u6807 Core\uFF0C\u7528 -- \u5206\u9694\u88AB\u8BC4\u4F30\u547D\u4EE4").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").allowUnknownOption(true).argument("<command...>", "\u88AB\u8BC4\u4F30\u7684 HCM \u5B50\u547D\u4EE4\u4E0E\u53C2\u6570\uFF0C\u4E0D\u5305\u542B hcm \u672C\u8EAB").action((command, opts) => deliveryAssessCommand(command, opts));
12811
13812
  delivery.command("doctor").description("\u56DB\u6761\u951A\u70B9\u63A2\u6D3B\uFF1A\u8FDE\u901A / \u6211\u662F\u8C01 / configAdmin / \u7AD9\u5728\u54EA\u4E00\u5C42").option("--env <name>", "\u76EE\u6807\u73AF\u5883\u522B\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--capabilities <s>", "\u722C\u53D6\u65F6\u58F0\u660E\u7684 capability \u4E32\uFF08\u4F1A\u968F\u56DB\u5143\u7EC4\u7559\u6863\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => deliveryDoctorCommand(opts));
@@ -12923,6 +13924,7 @@ var workspace = program.command("workspace").description("\u5F00\u53D1\u79DF\u62
12923
13924
  workspace.command("list").description("\u5217\u51FA\u5F53\u524D\u7528\u6237\u53EF\u8BBF\u95EE\u7684\u79DF\u6237\u5F00\u53D1\u7A7A\u95F4").option("--keyword <text>", "\u6309\u7A7A\u95F4 Key / \u8BF4\u660E / Owner \u641C\u7D22").option("--limit <n>", "\u8FD4\u56DE\u6761\u6570", "50").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").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").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => workspaceListCommand(opts));
12924
13925
  workspace.command("active").description("\u67E5\u770B\u5F53\u524D HCM \u5F00\u53D1\u6A21\u5F0F\u6FC0\u6D3B\u7A7A\u95F4\uFF0C\u5E76\u5BF9\u6BD4\u672C\u5730\u76EE\u5F55\u7ED1\u5B9A").option("--dir <path>", "\u5DE5\u4F5C\u7A7A\u95F4\u672C\u5730\u76EE\u5F55", ".").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").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").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => workspaceActiveCommand(opts));
12925
13926
  workspace.command("activate <workspaceKey>").description("\u628A\u5F53\u524D\u7528\u6237\u7684\u5F00\u53D1\u8005\u6A21\u5F0F\u7ED1\u5B9A\u5230\u8BE5\u5F00\u53D1\u7A7A\u95F4\u2014\u2014\u7A7A\u95F4\u5185\u7684 artifact \u968F\u5373\u5728\u672C\u79DF\u6237\u751F\u6548").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((key2, opts) => workspaceActivateCommand(key2, opts));
13927
+ workspace.command("deactivate").description("\u8BA9\u5F53\u524D\u8EAB\u4EFD\u9000\u51FA\u5F00\u53D1\u8005\u6A21\u5F0F\uFF1B\u4E0D\u5220\u9664\u5F00\u53D1\u7A7A\u95F4\u6216\u5DF2\u53D1\u5E03\u8D44\u4EA7").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").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").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => workspaceDeactivateCommand(opts));
12926
13928
  workspace.command("bind <workspaceKey>").description("\u628A\u5F53\u524D\u76EE\u5F55\u7ED1\u5B9A\u5230\u4E00\u4E2A\u79DF\u6237\u5F00\u53D1\u7A7A\u95F4").option("--dir <path>", "\u5DE5\u4F5C\u7A7A\u95F4\u672C\u5730\u76EE\u5F55", ".").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").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").option("--tenant <tenantId>", "\u79DF\u6237 ID\uFF08\u9ED8\u8BA4\u4F7F\u7528 env \u914D\u7F6E\uFF09").option("--endpoint <url>", "HCM \u540E\u7AEF\u5730\u5740\uFF08\u9ED8\u8BA4\u4F7F\u7528 env \u914D\u7F6E\uFF09").option("--force", "\u5F3A\u5236\u8986\u76D6\u5DF2\u6709\u7ED1\u5B9A").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((workspaceKey, opts) => workspaceBindCommand(workspaceKey, opts));
12927
13929
  workspace.command("create <workspaceKey>").description("\u65B0\u5EFA\u79DF\u6237\u5F00\u53D1\u7A7A\u95F4\uFF0C\u5E76\u5728\u672C\u5730\u76EE\u5F55\u5199\u5165 workspace \u7ED1\u5B9A").option("--dir <path>", "\u5DE5\u4F5C\u7A7A\u95F4\u672C\u5730\u76EE\u5F55", ".").option("--description <text>", "\u5F00\u53D1\u7A7A\u95F4\u8BF4\u660E").option("--activate", "\u521B\u5EFA\u540E\u7ED1\u5B9A\u4E3A\u5F53\u524D\u5F00\u53D1\u7A7A\u95F4").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").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").option("--force", "\u672C\u5730\u76EE\u5F55\u5DF2\u6709\u4E0D\u540C workspace \u7ED1\u5B9A\u65F6\u5F3A\u5236\u8986\u76D6").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((workspaceKey, opts) => workspaceCreateCommand(workspaceKey, opts));
12928
13930
  workspace.command("pull").description("\u4ECE\u5F00\u53D1\u7A7A\u95F4\u62C9\u53D6\u6587\u4EF6\u5305\u5230\u672C\u5730\uFF1Bmini_apps \u4F1A\u751F\u6210\u53EF\u9A8C\u8BC1\u7684 artifact \u4E0A\u4E0B\u6587").option("--workspace <key>", "\u79DF\u6237\u5F00\u53D1\u7A7A\u95F4 key\uFF1B\u672A\u63D0\u4F9B\u65F6\u8BFB\u53D6\u672C\u5730\u7ED1\u5B9A").option("--dir <path>", "\u5DE5\u4F5C\u7A7A\u95F4\u672C\u5730\u76EE\u5F55", ".").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").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").option("--force", "\u5F3A\u5236\u8986\u76D6\u5DF2\u6709\u7684\u672C\u5730\u6587\u4EF6").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => workspacePullCommand(opts));
@@ -12996,7 +13998,7 @@ program.command("update <Model>").description("\u66F4\u65B0\u4E00\u6761 Model \u
12996
13998
  ).action((model, opts) => updateCommand(model, opts));
12997
13999
  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 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));
12998
14000
  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));
12999
- 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>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").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));
14001
+ 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>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").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));
13000
14002
  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");
13001
14003
  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>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").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));
13002
14004
  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(