@hcmai/cli 0.4.27 → 0.4.28

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(path17) {
536
- const segs = path17.split(".").filter(Boolean);
535
+ originLine(path18) {
536
+ const segs = path18.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(path17) {
1719
- const segs = (path17 ?? "").split(".").filter(Boolean);
1718
+ function originLine(path18) {
1719
+ const segs = (path18 ?? "").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 path17 = normalizeTarget(target);
3365
+ const path18 = 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, path17);
3373
+ const url = buildBrowserLoginUrl(deps.frontend, ticket, path18);
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 ${path17}\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 ${path18}\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(path17) {
3474
- if (statSync(path17).isFile()) return [path17];
3473
+ function collectYmlFiles(path18) {
3474
+ if (statSync(path18).isFile()) return [path18];
3475
3475
  const out = [];
3476
3476
  const walk = (dir) => {
3477
3477
  for (const name of readdirSync(dir).sort()) {
@@ -3480,7 +3480,7 @@ function collectYmlFiles(path17) {
3480
3480
  else if (full.endsWith(".yml") || full.endsWith(".yaml")) out.push(full);
3481
3481
  }
3482
3482
  };
3483
- walk(path17);
3483
+ walk(path18);
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(path17, args) {
3491
+ async function importCommand(path18, args) {
3492
3492
  try {
3493
- const files = collectYmlFiles(path17);
3493
+ const files = collectYmlFiles(path18);
3494
3494
  const fixtures = files.map(
3495
3495
  (f) => parseFixture(readFileSync2(f, "utf8"), relative(process.cwd(), f))
3496
3496
  );
@@ -4751,8 +4751,8 @@ async function scriptManifestValidateCommand(args) {
4751
4751
  if (!args.file) {
4752
4752
  throw new Error("\u7F3A\u5C11 --file\n \u4E0B\u4E00\u6B65\uFF1Ahcm script manifest-validate --file ./manifest.yml");
4753
4753
  }
4754
- const yaml2 = readFileSync3(args.file, "utf8");
4755
- const result = await withClient2(args, (c) => validateScriptManifest(c.raw(), yaml2));
4754
+ const yaml3 = readFileSync3(args.file, "utf8");
4755
+ const result = await withClient2(args, (c) => validateScriptManifest(c.raw(), yaml3));
4756
4756
  emit2(result, args, `\u{1F4CB} manifest \u6821\u9A8C\u5B8C\u6210\uFF1A${args.file}`);
4757
4757
  } catch (e) {
4758
4758
  fail3(e, args);
@@ -6606,10 +6606,10 @@ async function metaListCommand(args) {
6606
6606
  fail5(e, args);
6607
6607
  }
6608
6608
  }
6609
- async function metaGetCommand(path17, args) {
6609
+ async function metaGetCommand(path18, args) {
6610
6610
  try {
6611
6611
  const c = await client2(args);
6612
- const content = await getTenantMeta(c.raw(), path17);
6612
+ const content = await getTenantMeta(c.raw(), path18);
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(path17, 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(path17) {
6622
- const base = path17.split(/[\\/]/).pop() ?? path17;
6621
+ function parseMetaPath(path18) {
6622
+ const base = path18.split(/[\\/]/).pop() ?? path18;
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, path17) {
6640
- const { model, kind, state } = parseMetaPath(path17);
6639
+ async function verifyAfterWrite(c, path18) {
6640
+ const { model, kind, state } = parseMetaPath(path18);
6641
6641
  if (!model || !kind) {
6642
- return { status: "unverified", where: "(\u672A\u63A2)", why: `\u4ECE\u8DEF\u5F84 ${path17} \u8BA4\u4E0D\u51FA\u6A21\u578B\u540D/\u5C42\u540D` };
6642
+ return { status: "unverified", where: "(\u672A\u63A2)", why: `\u4ECE\u8DEF\u5F84 ${path18} \u8BA4\u4E0D\u51FA\u6A21\u578B\u540D/\u5C42\u540D` };
6643
6643
  }
6644
6644
  try {
6645
6645
  await clearMetaCache2(c.raw(), model, {});
@@ -6684,7 +6684,7 @@ async function verifyAfterWrite(c, path17) {
6684
6684
  }
6685
6685
  return { status: "ok" };
6686
6686
  }
6687
- async function metaSetCommand(path17, args) {
6687
+ async function metaSetCommand(path18, args) {
6688
6688
  try {
6689
6689
  if (!args.file) {
6690
6690
  throw new CliError19({
@@ -6700,9 +6700,9 @@ async function metaSetCommand(path17, 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(path17, content);
6703
+ const result2 = validateMetaContent(path18, content);
6704
6704
  if (result2.issues.length > 0) {
6705
- process.stderr.write(`\u{1F50E} \u5199\u524D\u6821\u9A8C ${path17}\uFF08schema \u7C7B\u578B\uFF1A${result2.kind ?? "\u672A\u8BC6\u522B"}\uFF09
6705
+ process.stderr.write(`\u{1F50E} \u5199\u524D\u6821\u9A8C ${path18}\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(path17, args) {
6721
6721
  if (dryFmt === "json" || dryFmt === "yaml") {
6722
6722
  process.stdout.write(
6723
6723
  formatObject18(
6724
- { dryRun: true, path: path17, bytes: Buffer.byteLength(content), content },
6724
+ { dryRun: true, path: path18, 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 ${path17}\uFF08${Buffer.byteLength(content)} B\uFF09\u2014\u2014\u672A\u5B9E\u9645\u5199\u5165
6730
+ `[dry-run] \u5C06\u5199\u5165 ${path18}\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(), path17);
6744
+ const prev = await getTenantMeta(c.raw(), path18);
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()}-${path17.replace(/[\\/]/g, "_")}`
6750
+ `hcm-meta-backup-${Date.now()}-${path18.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(), path17, content);
6765
+ const result = await saveTenantMeta(c.raw(), path18, content);
6766
6766
  const fmt = args.output ?? "json";
6767
- if (fmt !== "json") process.stdout.write(`\u2705 \u5DF2\u5199\u5165 ${path17}
6767
+ if (fmt !== "json") process.stdout.write(`\u2705 \u5DF2\u5199\u5165 ${path18}
6768
6768
  `);
6769
6769
  const restoreHint = backupState === "saved" && backupFile ? ` \u65E7\u5185\u5BB9\u5DF2\u5B58\uFF1A${backupFile}
6770
- \u653E\u56DE\u53BB\uFF1Ahcm meta set ${path17} --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 ${path17}${connFlags(args)}
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)}
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 ${path17}${connFlags(args)}
6773
+ \u5148\u81EA\u5DF1\u8BFB\u4E00\u904D\u786E\u8BA4\uFF1Ahcm meta get ${path18}${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, path17);
6780
+ const outcome = await verifyAfterWrite(c, path18);
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(path17, args) {
6813
+ async function metaDeleteCommand(path18, args) {
6814
6814
  try {
6815
6815
  if (!args.yes) {
6816
- const ok = await promptConfirm(`\u5C06\u5220\u9664\u5143\u6570\u636E ${path17}\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u9006\u3002\u7EE7\u7EED\uFF1F`);
6816
+ const ok = await promptConfirm(`\u5C06\u5220\u9664\u5143\u6570\u636E ${path18}\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(), path17);
6823
+ const result = await deleteTenantMeta(c.raw(), path18);
6824
6824
  const fmt = args.output ?? "json";
6825
- if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${path17}
6825
+ if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${path18}
6826
6826
  `);
6827
6827
  process.stdout.write(formatObject18(result, { format: fmt }) + "\n");
6828
6828
  process.exitCode = 0;
@@ -6831,7 +6831,7 @@ async function metaDeleteCommand(path17, args) {
6831
6831
  fail5(e, args);
6832
6832
  }
6833
6833
  }
6834
- async function metaValidateCommand(path17, args) {
6834
+ async function metaValidateCommand(path18, args) {
6835
6835
  try {
6836
6836
  if (!args.file) {
6837
6837
  throw new CliError19({
@@ -6846,13 +6846,13 @@ async function metaValidateCommand(path17, 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(path17, content);
6849
+ const result = validateMetaContent(path18, 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: path17,
6855
+ path: path18,
6856
6856
  kind: result.kind,
6857
6857
  schemaKnown: result.schemaKnown,
6858
6858
  schemaSourceCommit: META_SCHEMA_SOURCE_COMMIT,
@@ -6864,7 +6864,7 @@ async function metaValidateCommand(path17, args) {
6864
6864
  );
6865
6865
  } else {
6866
6866
  process.stdout.write(
6867
- `\u{1F50E} ${path17}\uFF08schema \u7C7B\u578B\uFF1A${result.kind ?? "\u672A\u8BC6\u522B"}\uFF0C\u6765\u6E90 ${META_SCHEMA_SOURCE_COMMIT.slice(0, 8)}\uFF09
6867
+ `\u{1F50E} ${path18}\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(
@@ -8568,6 +8568,7 @@ function classify(argv, actionResolution) {
8568
8568
  if (name === "chiron") {
8569
8569
  if (subcommand === "doctor") return direct("R0", "local-discovery", "chiron-doctor");
8570
8570
  if (subcommand === "init") return direct("R1", "managed-local-write", "chiron-project-scaffold");
8571
+ if (subcommand === "test") return direct("R1", "remote-read", "chiron-regression-test");
8571
8572
  return forbidden("unknown-command", "\u672A\u77E5 chiron \u5B50\u547D\u4EE4\u6309\u6700\u9AD8\u98CE\u9669\u5173\u95ED\u3002");
8572
8573
  }
8573
8574
  if (name === "skills") {
@@ -9067,21 +9068,21 @@ async function resolveCoreAction(request) {
9067
9068
  `Core \u5143\u6570\u636E\u91CC\u6CA1\u6709 ${request.model}.${request.action} \u8FD9\u4E2A Action\u3002${degraded}next_step=\u7528 \`hcm describe ${request.model}\` \u770B\u5B83\u5217\u51FA\u7684 Action \u540D\uFF08\u811A\u672C Action \u4F1A\u6807 [script]\uFF09`
9068
9069
  );
9069
9070
  }
9070
- const matches = request.explicitShape ? named.filter((action) => matchesRequest(action, request)) : named;
9071
- if (matches.length === 0) {
9071
+ const matches2 = request.explicitShape ? named.filter((action) => matchesRequest(action, request)) : named;
9072
+ if (matches2.length === 0) {
9072
9073
  const shapes = named.map((a) => `scope=${a.scope ?? "?"} method=${(a.httpMethod ?? "?").toUpperCase()}`).join("\uFF1B");
9073
9074
  return failed(
9074
9075
  "action-shape-mismatch",
9075
9076
  `${request.model}.${request.action} \u5B58\u5728\uFF0C\u4F46\u5F62\u6001\u5BF9\u4E0D\u4E0A\uFF1A\u4F60\u7ED9\u7684\u662F scope=${request.scope} method=${request.httpMethod}\uFF0C\u5143\u6570\u636E\u91CC\u662F ${shapes}\u3002next_step=\u53BB\u6389 --scope/--method \u8BA9 CLI \u6309\u5143\u6570\u636E\u81EA\u52A8\u5224\u5B9A\uFF0C\u6216\u6539\u6210\u4E0A\u9762\u7684\u5F62\u6001`
9076
9077
  );
9077
9078
  }
9078
- if (matches.length > 1) {
9079
+ if (matches2.length > 1) {
9079
9080
  return failed(
9080
9081
  "action-metadata-ambiguous",
9081
9082
  `${request.model}.${request.action} \u5728\u5143\u6570\u636E\u91CC\u6709\u591A\u79CD\u5F62\u6001\uFF0C\u65E0\u6CD5\u552F\u4E00\u5224\u5B9A\u3002next_step=\u7528 --scope \u4E0E --method \u6307\u660E\u8981\u8C03\u54EA\u4E00\u4E2A`
9082
9083
  );
9083
9084
  }
9084
- return policyFromActionMeta(matches[0], request);
9085
+ return policyFromActionMeta(matches2[0], request);
9085
9086
  } catch {
9086
9087
  return failed(
9087
9088
  "action-metadata-unavailable",
@@ -10027,17 +10028,17 @@ function projectEnvFromConfig(cfg) {
10027
10028
  }
10028
10029
  async function findEnvByEndpoint(endpoint, tenant2) {
10029
10030
  const wanted = normalizeOrigin(endpoint);
10030
- const matches = [];
10031
+ const matches2 = [];
10031
10032
  for (const name of await listEnvs3().catch(() => [])) {
10032
10033
  const config2 = await loadEnv10(name).catch(() => null);
10033
10034
  if (!config2 || normalizeOrigin(config2.endpoint) !== wanted) continue;
10034
- matches.push({ name, config: config2, hasIdentity: (await listIdentities4(name).catch(() => [])).length > 0 });
10035
+ matches2.push({ name, config: config2, hasIdentity: (await listIdentities4(name).catch(() => [])).length > 0 });
10035
10036
  }
10036
- if (matches.length === 0) return null;
10037
+ if (matches2.length === 0) return null;
10037
10038
  const active = (await loadGlobalConfig10().catch(() => null))?.activeEnv;
10038
- const usable = matches.filter((m) => m.hasIdentity);
10039
- const pick = usable.find((m) => m.name === active) ?? (tenant2 ? usable.find((m) => (m.config.tenantId ?? "1") === tenant2) : void 0) ?? usable[0] ?? matches.find((m) => m.name === active) ?? matches[0];
10040
- return { name: pick.name, config: pick.config };
10039
+ const usable = matches2.filter((m) => m.hasIdentity);
10040
+ const pick2 = usable.find((m) => m.name === active) ?? (tenant2 ? usable.find((m) => (m.config.tenantId ?? "1") === tenant2) : void 0) ?? usable[0] ?? matches2.find((m) => m.name === active) ?? matches2[0];
10041
+ return { name: pick2.name, config: pick2.config };
10041
10042
  }
10042
10043
  function renderChironAgentInstructions() {
10043
10044
  return [
@@ -10560,6 +10561,346 @@ async function chironDoctorCommand(args, deps) {
10560
10561
  }
10561
10562
  }
10562
10563
 
10564
+ // src/commands/chiron-test.ts
10565
+ init_exit();
10566
+ import { spawnSync as spawnSync2 } from "child_process";
10567
+ import { promises as fs12 } from "fs";
10568
+ import path12 from "path";
10569
+ import yaml2 from "js-yaml";
10570
+ import { formatObject as formatObject26 } from "@hcmai/sdk";
10571
+
10572
+ // src/commands/xlsx-peek.ts
10573
+ import { readFileSync as readFileSync6 } from "fs";
10574
+ import { inflateRawSync } from "zlib";
10575
+ function readZip(buf, want) {
10576
+ let eocd = -1;
10577
+ for (let i = buf.length - 22; i >= 0 && i > buf.length - 66e3; i--) {
10578
+ if (buf.readUInt32LE(i) === 101010256) {
10579
+ eocd = i;
10580
+ break;
10581
+ }
10582
+ }
10583
+ if (eocd < 0) throw new Error("\u4E0D\u662F\u6709\u6548\u7684 zip/xlsx\uFF08\u627E\u4E0D\u5230\u4E2D\u592E\u76EE\u5F55\uFF09");
10584
+ const count = buf.readUInt16LE(eocd + 10);
10585
+ let p = buf.readUInt32LE(eocd + 16);
10586
+ const out = [];
10587
+ for (let n = 0; n < count; n++) {
10588
+ if (buf.readUInt32LE(p) !== 33639248) break;
10589
+ const method = buf.readUInt16LE(p + 10);
10590
+ const compressedSize = buf.readUInt32LE(p + 20);
10591
+ const nameLen = buf.readUInt16LE(p + 28);
10592
+ const extraLen = buf.readUInt16LE(p + 30);
10593
+ const commentLen = buf.readUInt16LE(p + 32);
10594
+ const localOffset = buf.readUInt32LE(p + 42);
10595
+ const name = buf.subarray(p + 46, p + 46 + nameLen).toString("utf8");
10596
+ if (want(name)) {
10597
+ const lnameLen = buf.readUInt16LE(localOffset + 26);
10598
+ const lextraLen = buf.readUInt16LE(localOffset + 28);
10599
+ const start = localOffset + 30 + lnameLen + lextraLen;
10600
+ const raw = buf.subarray(start, start + compressedSize);
10601
+ if (method === 0) out.push({ name, data: Buffer.from(raw) });
10602
+ else if (method === 8) out.push({ name, data: inflateRawSync(raw) });
10603
+ else throw new Error(`xlsx \u91CC\u7684 ${name} \u7528\u4E86\u4E0D\u652F\u6301\u7684\u538B\u7F29\u65B9\u5F0F ${method}`);
10604
+ }
10605
+ p += 46 + nameLen + extraLen + commentLen;
10606
+ }
10607
+ return out;
10608
+ }
10609
+ var decode = (s) => s.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&amp;/g, "&");
10610
+ function xlsxRows(file, maxRows = 50) {
10611
+ const buf = readFileSync6(file);
10612
+ const [sheet] = readZip(buf, (n) => n === "xl/worksheets/sheet1.xml");
10613
+ if (!sheet) throw new Error(`${file} \u91CC\u6CA1\u6709 xl/worksheets/sheet1.xml\uFF0C\u53EF\u80FD\u4E0D\u662F xlsx`);
10614
+ const [shared] = readZip(buf, (n) => n === "xl/sharedStrings.xml");
10615
+ const sharedStrings = [];
10616
+ if (shared) {
10617
+ for (const si of shared.data.toString("utf8").split("<si>").slice(1)) {
10618
+ sharedStrings.push(decode([...si.matchAll(/<t[^>]*>([\s\S]*?)<\/t>/g)].map((m) => m[1] ?? "").join("")));
10619
+ }
10620
+ }
10621
+ const xml = sheet.data.toString("utf8");
10622
+ const rows = [];
10623
+ for (const rowXml of xml.split("<row").slice(1)) {
10624
+ if (rows.length >= maxRows) break;
10625
+ const cells = [];
10626
+ for (const m of rowXml.matchAll(/<c\b([^>]*)>([\s\S]*?)<\/c>/g)) {
10627
+ const attrs = m[1] ?? "";
10628
+ const body = m[2] ?? "";
10629
+ const v = /<v>([\s\S]*?)<\/v>/.exec(body)?.[1] ?? "";
10630
+ const inline = [...body.matchAll(/<t[^>]*>([\s\S]*?)<\/t>/g)].map((x) => x[1] ?? "").join("");
10631
+ if (/t="s"/.test(attrs)) cells.push(sharedStrings[Number(v)] ?? "");
10632
+ else if (inline) cells.push(decode(inline));
10633
+ else cells.push(decode(v));
10634
+ }
10635
+ rows.push(cells);
10636
+ }
10637
+ return rows;
10638
+ }
10639
+
10640
+ // src/commands/chiron-test.ts
10641
+ var CONTENT_KEYS = ["stdout_contains", "json", "xlsx_header", "xlsx_min_rows", "text_contains"];
10642
+ var hasContentAssertion = (c) => (c.page ? (c.expect_text?.length ?? 0) > 0 : false) || CONTENT_KEYS.some((k) => c.expect?.[k] !== void 0);
10643
+ function assertUsableSpec(spec, where) {
10644
+ if (!spec?.name || !Array.isArray(spec.checks) || spec.checks.length === 0) {
10645
+ throw new Error(`${where}: \u7528\u4F8B\u8981\u6709 name \u4E0E\u81F3\u5C11\u4E00\u6761 checks`);
10646
+ }
10647
+ spec.checks.forEach((c, i) => {
10648
+ const at = `${where} \u7B2C ${i + 1} \u6761\u300C${c.name ?? "\u672A\u547D\u540D"}\u300D`;
10649
+ if (!c.name) throw new Error(`${at}: \u7F3A name`);
10650
+ const kinds = [c.run, c.file, c.page].filter(Boolean).length;
10651
+ if (kinds !== 1) throw new Error(`${at}: run / file / page \u5FC5\u987B\u4E14\u53EA\u80FD\u6709\u4E00\u4E2A`);
10652
+ if (c.run) {
10653
+ if (!/^hcm\s/.test(c.run.trim())) {
10654
+ throw new Error(`${at}: run \u53EA\u80FD\u8DD1 hcm \u5B50\u547D\u4EE4\uFF08\u4E0D\u63A5\u53D7\u4EFB\u610F shell\uFF1B\u8981\u7ED5\u8FC7 CLI \u7684\u4E8B\u672C\u6765\u5C31\u4E0D\u8BE5\u505A\uFF09`);
10655
+ }
10656
+ tokenize(c.run);
10657
+ }
10658
+ if (c.page && !c.expect_text?.length) throw new Error(`${at}: \u9875\u9762\u5224\u636E\u81F3\u5C11\u8981\u4E00\u4E2A expect_text\u2014\u2014\u622A\u56FE\u5B58\u5728\u4E0D\u7B49\u4E8E\u9875\u9762\u5BF9`);
10659
+ if (c.file && !hasContentAssertion(c)) throw new Error(`${at}: \u8BFB\u6587\u4EF6\u5374\u6CA1\u6709\u5185\u5BB9\u5224\u636E\uFF08${CONTENT_KEYS.join(" / ")}\uFF09\u2014\u2014\u6587\u4EF6\u5B58\u5728\u4E0D\u7B49\u4E8E\u5185\u5BB9\u5BF9`);
10660
+ });
10661
+ if (!spec.checks.some(hasContentAssertion)) {
10662
+ throw new Error(
10663
+ `${where}: \u6574\u4EFD\u7528\u4F8B\u6CA1\u6709\u4EFB\u4F55\u5185\u5BB9\u5224\u636E\uFF08${CONTENT_KEYS.join(" / ")} / expect_text\uFF09\uFF0C\u53EA\u8DD1\u4E0D\u770B\u7B49\u4E8E\u6CA1\u6D4B\u3002`
10664
+ );
10665
+ }
10666
+ }
10667
+ function tokenize(line) {
10668
+ const out = [];
10669
+ let cur = "";
10670
+ let quote = null;
10671
+ let started = false;
10672
+ for (let i = 0; i < line.length; i++) {
10673
+ const ch = line[i];
10674
+ if (quote) {
10675
+ if (ch === quote) quote = null;
10676
+ else if (ch === "\\" && quote === '"' && i + 1 < line.length) {
10677
+ cur += line[++i];
10678
+ } else cur += ch;
10679
+ continue;
10680
+ }
10681
+ if (ch === '"' || ch === "'") {
10682
+ quote = ch;
10683
+ started = true;
10684
+ continue;
10685
+ }
10686
+ if (ch === "\\" && i + 1 < line.length) {
10687
+ cur += line[++i];
10688
+ started = true;
10689
+ continue;
10690
+ }
10691
+ if (/\s/.test(ch)) {
10692
+ if (started || cur) {
10693
+ out.push(cur);
10694
+ cur = "";
10695
+ started = false;
10696
+ }
10697
+ continue;
10698
+ }
10699
+ cur += ch;
10700
+ started = true;
10701
+ }
10702
+ if (quote) throw new Error(`\u547D\u4EE4\u91CC\u7684\u5F15\u53F7\u6CA1\u95ED\u5408\uFF1A${line}`);
10703
+ if (started || cur) out.push(cur);
10704
+ return out;
10705
+ }
10706
+ function parseJsonLoose(stdout) {
10707
+ const candidates = [];
10708
+ const oa = stdout.indexOf("{"), ob = stdout.lastIndexOf("}");
10709
+ const aa = stdout.indexOf("["), ab = stdout.lastIndexOf("]");
10710
+ if (aa >= 0 && ab > aa) candidates.push([aa, ab]);
10711
+ if (oa >= 0 && ob > oa) candidates.push([oa, ob]);
10712
+ candidates.sort((x, y) => x[0] - y[0]);
10713
+ for (const [a, b] of candidates) {
10714
+ try {
10715
+ return JSON.parse(stdout.slice(a, b + 1));
10716
+ } catch {
10717
+ }
10718
+ }
10719
+ return void 0;
10720
+ }
10721
+ function pick(value, expr) {
10722
+ const tokens = [...expr.replace(/^\$/, "").matchAll(/\[(\d+)\]|([^.[\]]+)/g)];
10723
+ let cur = value;
10724
+ for (const t of tokens) {
10725
+ if (cur === null || cur === void 0) return void 0;
10726
+ if (t[1] !== void 0) {
10727
+ if (!Array.isArray(cur)) return void 0;
10728
+ cur = cur[Number(t[1])];
10729
+ } else {
10730
+ if (typeof cur !== "object") return void 0;
10731
+ cur = cur[t[2]];
10732
+ }
10733
+ }
10734
+ return cur;
10735
+ }
10736
+ function matches(actual, rule) {
10737
+ const r = rule.trim();
10738
+ if (r === "\u975E\u7A7A" || r === "nonempty") return actual !== void 0 && actual !== null && String(actual) !== "" && !(Array.isArray(actual) && actual.length === 0);
10739
+ const m = /^(>=|<=|>|<|!=|=)\s*(.*)$/.exec(r);
10740
+ if (!m) return String(actual) === r;
10741
+ const [, op, want] = m;
10742
+ const n = Number(want), a = Array.isArray(actual) ? actual.length : Number(actual);
10743
+ switch (op) {
10744
+ case ">":
10745
+ return Number.isFinite(a) && a > n;
10746
+ case "<":
10747
+ return Number.isFinite(a) && a < n;
10748
+ case ">=":
10749
+ return Number.isFinite(a) && a >= n;
10750
+ case "<=":
10751
+ return Number.isFinite(a) && a <= n;
10752
+ case "!=":
10753
+ return String(actual) !== want;
10754
+ default:
10755
+ return String(actual) === want;
10756
+ }
10757
+ }
10758
+ var defaultDeps2 = {
10759
+ assess: (argv) => assessEffectiveDeliveryCommand(argv),
10760
+ hcm: (argv, cwd) => {
10761
+ const r = spawnSync2("hcm", argv, { cwd, encoding: "utf8", maxBuffer: 1 << 26, timeout: 6e5 });
10762
+ return { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
10763
+ },
10764
+ pageAcceptance: (root, argv) => {
10765
+ const r = spawnSync2("./page-acceptance.sh", argv, { cwd: root, encoding: "utf8", maxBuffer: 1 << 24, timeout: 3e5 });
10766
+ return { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
10767
+ },
10768
+ readXlsx: (file) => xlsxRows(file),
10769
+ readText: (file) => fs12.readFile(file, "utf8")
10770
+ };
10771
+ async function runCase(spec, root, opts = {}, deps = defaultDeps2) {
10772
+ const results = [];
10773
+ const vars = {};
10774
+ const fill = (text) => text.replace(/\$\{(\w+)\}/g, (_, k) => {
10775
+ if (vars[k] === void 0) throw new Error(`\u7528\u5230\u4E86 ${"$"}{${k}} \u4F46\u524D\u9762\u6CA1\u6709\u54EA\u4E00\u6B65\u6355\u83B7\u5B83`);
10776
+ return vars[k];
10777
+ });
10778
+ for (const c of spec.checks) {
10779
+ try {
10780
+ if (c.run) {
10781
+ const argv2 = tokenize(fill(c.run)).slice(1);
10782
+ const verdict = await deps.assess(argv2);
10783
+ if (verdict.execution !== "direct") {
10784
+ results.push({
10785
+ name: c.name,
10786
+ verdict: "fail",
10787
+ detail: `\u8FD9\u6761\u547D\u4EE4\u6309\u4EA4\u4ED8\u98CE\u63A7\u662F ${verdict.risk} / ${verdict.execution}\uFF08${verdict.reasonCode}\uFF09\uFF0C\u6CA1\u6709\u8DD1\u3002\u7528\u4F8B\u53EA\u8DD1\u53EA\u8BFB\uFF1B\u8981\u5199\u6570\u636E\u8D70 hcm delivery assess \u2192 prepare \u2192 execute\u3002`
10788
+ });
10789
+ continue;
10790
+ }
10791
+ if (opts.env && !argv2.includes("--env")) argv2.push("--env", opts.env);
10792
+ const as2 = c.as ?? opts.as;
10793
+ if (as2 && !argv2.includes("--as")) argv2.push("--as", as2);
10794
+ const r2 = deps.hcm(argv2, root);
10795
+ const want = c.expect ?? {};
10796
+ const bad = [];
10797
+ if (want.exit !== void 0 && r2.status !== want.exit) bad.push(`\u9000\u51FA\u7801 ${r2.status} \u2260 ${want.exit}`);
10798
+ for (const t of want.stdout_contains ?? []) if (!r2.stdout.includes(t)) bad.push(`\u8F93\u51FA\u91CC\u6CA1\u6709\u300C${t}\u300D`);
10799
+ for (const t of want.stdout_not_contains ?? []) if (r2.stdout.includes(t)) bad.push(`\u8F93\u51FA\u91CC\u51FA\u73B0\u4E86\u4E0D\u8BE5\u6709\u7684\u300C${t}\u300D`);
10800
+ if (want.json) {
10801
+ const parsed = parseJsonLoose(r2.stdout);
10802
+ if (parsed === void 0) bad.push("\u8F93\u51FA\u4E0D\u662F JSON\uFF0C\u65E0\u6CD5\u6309 json \u5224\u636E\u6BD4\u5BF9");
10803
+ if (parsed !== void 0) {
10804
+ for (const [expr, rule] of Object.entries(want.json)) {
10805
+ const actual = pick(parsed, expr);
10806
+ if (!matches(actual, rule)) bad.push(`${expr} \u5B9E\u9645 ${JSON.stringify(actual)}\uFF0C\u671F\u671B ${rule}`);
10807
+ }
10808
+ }
10809
+ }
10810
+ if (c.capture && bad.length === 0) {
10811
+ const parsed = parseJsonLoose(r2.stdout);
10812
+ for (const [name, expr] of Object.entries(c.capture)) {
10813
+ const v = pick(parsed, expr);
10814
+ if (v === void 0 || v === null || String(v) === "") bad.push(`\u8981\u6355\u83B7\u7684 ${name}\uFF08${expr}\uFF09\u5728\u8F93\u51FA\u91CC\u53D6\u4E0D\u5230`);
10815
+ else vars[name] = String(v);
10816
+ }
10817
+ }
10818
+ results.push(bad.length ? { name: c.name, verdict: "fail", detail: `${bad.join("\uFF1B")}${r2.stderr.trim() ? `\uFF5Cstderr: ${r2.stderr.trim().split("\n")[0]}` : ""}` } : { name: c.name, verdict: hasContentAssertion(c) ? "pass" : "step", detail: c.capture ? `\u6355\u83B7 ${Object.keys(c.capture).join("\u3001")}` : "" });
10819
+ continue;
10820
+ }
10821
+ if (c.file) {
10822
+ const file = path12.resolve(root, fill(c.file));
10823
+ const want = c.expect ?? {};
10824
+ const bad = [];
10825
+ if (want.xlsx_header || want.xlsx_min_rows !== void 0) {
10826
+ const rows = deps.readXlsx(file);
10827
+ const header = (rows[0] ?? []).map((x) => String(x).trim());
10828
+ for (const h of want.xlsx_header ?? []) if (!header.includes(h)) bad.push(`\u8868\u5934\u91CC\u6CA1\u6709\u300C${h}\u300D\uFF0C\u5B9E\u9645\u662F [${header.slice(0, 8).join(", ")}]`);
10829
+ if (want.xlsx_min_rows !== void 0 && rows.length - 1 < want.xlsx_min_rows) bad.push(`\u6570\u636E\u884C ${Math.max(rows.length - 1, 0)} \u5C11\u4E8E ${want.xlsx_min_rows}`);
10830
+ }
10831
+ if (want.text_contains) {
10832
+ const text = await deps.readText(file);
10833
+ for (const t of want.text_contains) if (!text.includes(t)) bad.push(`\u6587\u4EF6\u91CC\u6CA1\u6709\u300C${t}\u300D`);
10834
+ }
10835
+ results.push(bad.length ? { name: c.name, verdict: "fail", detail: bad.join("\uFF1B") } : { name: c.name, verdict: "pass", detail: "" });
10836
+ continue;
10837
+ }
10838
+ const out = path12.join("evidence", "test", `${spec.name}-${c.name}`.replace(/[^\w一-龥-]+/g, "_") + ".png");
10839
+ const argv = ["--path", fill(c.page), "--out", out];
10840
+ if (opts.env) argv.push("--env", opts.env);
10841
+ const as = c.as ?? opts.as;
10842
+ if (as) argv.push("--as", as);
10843
+ for (const t of c.expect_text ?? []) argv.push("--expect-text", t);
10844
+ for (const t of c.reject_text ?? []) argv.push("--reject-text", t);
10845
+ const r = deps.pageAcceptance(root, argv);
10846
+ results.push(r.status === 0 ? { name: c.name, verdict: "pass", detail: out } : { name: c.name, verdict: "fail", detail: (r.stderr || r.stdout).trim().split("\n").slice(-1)[0] ?? `\u9000\u51FA\u7801 ${r.status}` });
10847
+ } catch (e) {
10848
+ results.push({ name: c.name, verdict: "fail", detail: e.message });
10849
+ }
10850
+ }
10851
+ return results;
10852
+ }
10853
+ async function loadCases(target) {
10854
+ const stat = await fs12.stat(target);
10855
+ const files = stat.isDirectory() ? (await fs12.readdir(target)).filter((f) => /\.ya?ml$/.test(f)).sort().map((f) => path12.join(target, f)) : [target];
10856
+ const out = [];
10857
+ for (const f of files) {
10858
+ const spec = yaml2.load(await fs12.readFile(f, "utf8"));
10859
+ assertUsableSpec(spec, path12.basename(f));
10860
+ out.push({ file: f, spec });
10861
+ }
10862
+ if (out.length === 0) throw new Error(`${target} \u4E0B\u6CA1\u6709\u7528\u4F8B\uFF08*.yml\uFF09`);
10863
+ return out;
10864
+ }
10865
+ async function chironTestCommand(target, args, deps) {
10866
+ try {
10867
+ const root = path12.resolve(args.project ?? ".");
10868
+ const where = path12.resolve(root, target ?? "tests");
10869
+ const cases = await loadCases(where);
10870
+ const report = [];
10871
+ let failed2 = 0;
10872
+ for (const { file, spec } of cases) {
10873
+ const results = await runCase(spec, root, { env: args.env, as: args.as }, deps);
10874
+ failed2 += results.filter((r) => r.verdict === "fail").length;
10875
+ report.push({ case: spec.name, file: path12.relative(root, file), results });
10876
+ }
10877
+ const fmt = args.output ?? "table";
10878
+ if (fmt === "json" || fmt === "yaml") {
10879
+ process.stdout.write(formatObject26({ ok: failed2 === 0, failed: failed2, cases: report }, { format: fmt }) + "\n");
10880
+ } else {
10881
+ for (const c of report) {
10882
+ process.stdout.write(`
10883
+ ${c.case}\uFF08${c.file}\uFF09
10884
+ `);
10885
+ for (const r of c.results) {
10886
+ const mark = r.verdict === "pass" ? "\u2705" : r.verdict === "step" ? "\xB7" : r.verdict === "warn" ? "\u26A0\uFE0F" : "\u274C";
10887
+ process.stdout.write(` ${mark} ${r.name}${r.detail ? ` ${r.detail}` : ""}
10888
+ `);
10889
+ }
10890
+ }
10891
+ const verified = report.reduce((n, c) => n + c.results.filter((r) => r.verdict === "pass").length, 0);
10892
+ process.stdout.write(failed2 === 0 ? `
10893
+ \u5168\u90E8\u901A\u8FC7\uFF08\u771F\u5224\u8FC7\u5185\u5BB9\u7684 ${verified} \u6761\uFF1B\u5E26 \xB7 \u7684\u662F\u6B65\u9AA4\uFF0C\u4E0D\u7B97\u9A8C\u8BC1\uFF09\u3002
10894
+ ` : `
10895
+ ${failed2} \u6761\u6CA1\u8FC7\u2014\u2014\u4E0A\u9762\u6BCF\u6761\u90FD\u5199\u4E86\u5B9E\u9645\u503C\u4E0E\u671F\u671B\uFF0C\u7167\u7740\u67E5\u3002
10896
+ `);
10897
+ }
10898
+ process.exitCode = failed2 === 0 ? 0 : 1;
10899
+ } catch (e) {
10900
+ exitWithError(e);
10901
+ }
10902
+ }
10903
+
10563
10904
  // src/commands/delivery-recon.ts
10564
10905
  init_auth_guard();
10565
10906
  init_exit();
@@ -10568,7 +10909,7 @@ import {
10568
10909
  ReconLayout,
10569
10910
  ROUND_EXIT_CODES,
10570
10911
  computeReconSourceKey,
10571
- formatObject as formatObject26,
10912
+ formatObject as formatObject27,
10572
10913
  fromAxiosError as fromAxiosError22,
10573
10914
  httpProbe as httpProbe4,
10574
10915
  inspectRound,
@@ -10588,7 +10929,7 @@ async function deliveryReconCommand(args) {
10588
10929
  onlyModel: args.model ?? null,
10589
10930
  identity: ctx.tenantId ? { requestedTenantId: ctx.tenantId } : null
10590
10931
  });
10591
- process.stdout.write(formatObject26(summary, { format: args.output ?? "json" }) + "\n");
10932
+ process.stdout.write(formatObject27(summary, { format: args.output ?? "json" }) + "\n");
10592
10933
  } catch (e) {
10593
10934
  const err = e;
10594
10935
  if (err?.isAxiosError) exitWithError(fromAxiosError22(err, args.env));
@@ -10602,7 +10943,7 @@ async function deliveryReconRoundCommand(args) {
10602
10943
  const result = inspectRound(args.dir ?? ".");
10603
10944
  const fmt = args.output ?? "json";
10604
10945
  if (fmt !== "json") process.stdout.write(renderRound(result));
10605
- process.stdout.write(formatObject26(result, { format: fmt }) + "\n");
10946
+ process.stdout.write(formatObject27(result, { format: fmt }) + "\n");
10606
10947
  code = ROUND_EXIT_CODES[result.state];
10607
10948
  } catch (e) {
10608
10949
  exitWithError(e);
@@ -10621,14 +10962,14 @@ import {
10621
10962
  GAP_REASONS,
10622
10963
  deriveAclass,
10623
10964
  exitCode as gate0ExitCode,
10624
- formatObject as formatObject27,
10965
+ formatObject as formatObject28,
10625
10966
  inspectRound as inspectRound2,
10626
10967
  loadProtocolFacts,
10627
10968
  scan
10628
10969
  } from "@hcmai/sdk";
10629
- import * as path12 from "path";
10970
+ import * as path13 from "path";
10630
10971
  function renderGate0(result, skillRoot) {
10631
- const where = skillRoot ? `\uFF08${path12.resolve(skillRoot)}\uFF09` : "";
10972
+ const where = skillRoot ? `\uFF08${path13.resolve(skillRoot)}\uFF09` : "";
10632
10973
  const lines = [
10633
10974
  `\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`
10634
10975
  ];
@@ -10666,7 +11007,7 @@ async function deliveryGate0Command(args) {
10666
11007
  const merged = { ...result, premise: premise5 };
10667
11008
  const fmt = args.output ?? "json";
10668
11009
  if (fmt !== "json") process.stdout.write(renderGate0(merged, skillRoot));
10669
- process.stdout.write(`${formatObject27(merged, { format: fmt })}
11010
+ process.stdout.write(`${formatObject28(merged, { format: fmt })}
10670
11011
  `);
10671
11012
  for (const problem of premise5) {
10672
11013
  process.stderr.write(`\u{1F534} \u524D\u63D0\u4E0D\u6210\u7ACB\uFF08${problem.reason}\uFF09\uFF1A${problem.message}
@@ -10741,7 +11082,7 @@ import {
10741
11082
  writeRisk
10742
11083
  } from "@hcmai/sdk";
10743
11084
  import { existsSync as existsSync3 } from "fs";
10744
- import * as path13 from "path";
11085
+ import * as path14 from "path";
10745
11086
  function premise(message, hint = "") {
10746
11087
  process.stderr.write(message + (hint ? `
10747
11088
  \u2192 ${hint}` : "") + "\n");
@@ -10768,13 +11109,13 @@ async function runSeedPlan(args, client3) {
10768
11109
  const reconDir = candidates[0].reconDir;
10769
11110
  if (candidates.length > 1) {
10770
11111
  process.stderr.write(
10771
- `\u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u6709 ${candidates.length} \u4EFD\u57FA\u7EBF\uFF0C\u672C\u8F6E\u8BFB\u7684\u662F \`${path13.basename(reconDir)}\`\uFF1A` + candidates.slice(1).map((c) => `\`${path13.basename(c.reconDir)}\``).join("\u3001") + " \u672A\u88AB\u8BFB\u53D6 \u2014\u2014 \u4E0D\u540C sourceKey \u7684\u4EA7\u7269**\u4E0D\u53EF\u4E92\u6362**\u3002\n"
11112
+ `\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"
10772
11113
  );
10773
11114
  }
10774
11115
  const round = inspectRound3(reconDir);
10775
11116
  process.stderr.write(roundWarning(round));
10776
11117
  const baseline = {
10777
- path: `${path13.basename(path13.dirname(reconDir))}/${path13.basename(reconDir)}`,
11118
+ path: `${path14.basename(path14.dirname(reconDir))}/${path14.basename(reconDir)}`,
10778
11119
  roundId: round.roundId ?? null
10779
11120
  };
10780
11121
  let exemptions = null;
@@ -11035,8 +11376,8 @@ async function deliverySeedVerifyCommand(args) {
11035
11376
 
11036
11377
  // src/commands/delivery-seed-find.ts
11037
11378
  import { existsSync as existsSync4 } from "fs";
11038
- import { readFileSync as readFileSync6 } from "fs";
11039
- import * as path14 from "path";
11379
+ import { readFileSync as readFileSync7 } from "fs";
11380
+ import * as path15 from "path";
11040
11381
  import {
11041
11382
  INIT_EXIT_CODES as INIT_EXIT_CODES2,
11042
11383
  ValueHints,
@@ -11050,10 +11391,10 @@ import {
11050
11391
  valuesRoundCaveat
11051
11392
  } from "@hcmai/sdk";
11052
11393
  function provenance(chosenReconDir, others) {
11053
- let line = `> \u57FA\u7EBF\uFF1A\`${path14.basename(chosenReconDir)}\`
11394
+ let line = `> \u57FA\u7EBF\uFF1A\`${path15.basename(chosenReconDir)}\`
11054
11395
  `;
11055
11396
  if (others.length > 0) {
11056
- line += `> \u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u53E6\u6709 ${others.length} \u4EFD\u57FA\u7EBF\u672A\u88AB\u8BFB\u53D6\uFF1A` + others.map((o) => `\`${path14.basename(o)}\``).join("\u3001") + " \u2014\u2014 \u4E0D\u540C sourceKey \u7684\u4EA7\u7269**\u4E0D\u53EF\u4E92\u6362**\u3002\n";
11397
+ 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";
11057
11398
  }
11058
11399
  return `${line}
11059
11400
  `;
@@ -11098,7 +11439,7 @@ function runSeedFind(args) {
11098
11439
  if (!existsSync4(chosen.indexFile)) {
11099
11440
  return premise2(`\u7D22\u5F15\u6587\u4EF6\u5728\u9009\u4E2D\u4E4B\u540E\u6D88\u5931\u4E86\uFF1A${chosen.indexFile}`);
11100
11441
  }
11101
- const { rows, problems } = loadRows(readFileSync6(chosen.indexFile, "utf-8"));
11442
+ const { rows, problems } = loadRows(readFileSync7(chosen.indexFile, "utf-8"));
11102
11443
  process.stdout.write(
11103
11444
  renderFind(find(rows, args.term), args.term, rows.length, {
11104
11445
  prefixBytes: Buffer.byteLength(prefix, "utf-8"),
@@ -11138,7 +11479,7 @@ function deliverySeedValuesCommand(model, args) {
11138
11479
 
11139
11480
  // src/commands/delivery-meta.ts
11140
11481
  init_auth_guard();
11141
- import { readFileSync as readFileSync7 } from "fs";
11482
+ import { readFileSync as readFileSync8 } from "fs";
11142
11483
  import {
11143
11484
  BINDING_WORDS,
11144
11485
  CHANGE_STATES,
@@ -11286,7 +11627,7 @@ function premise3(what, hint) {
11286
11627
  async function runDeliveryMeta(args, client3) {
11287
11628
  let content;
11288
11629
  try {
11289
- content = readFileSync7(args.contentFile, "utf-8");
11630
+ content = readFileSync8(args.contentFile, "utf-8");
11290
11631
  } catch (e) {
11291
11632
  return premise3(
11292
11633
  `\u8981\u5199\u8FDB\u53BB\u7684\u6B63\u6587\u8BFB\u4E0D\u51FA\u6765\uFF1A${e.message}`,
@@ -11389,8 +11730,8 @@ import {
11389
11730
  ReconLayout as ReconLayout2,
11390
11731
  runTriageRound
11391
11732
  } from "@hcmai/sdk";
11392
- import { mkdirSync, readFileSync as readFileSync8, writeFileSync as writeFileSync2 } from "fs";
11393
- import * as path15 from "path";
11733
+ import { mkdirSync, readFileSync as readFileSync9, writeFileSync as writeFileSync2 } from "fs";
11734
+ import * as path16 from "path";
11394
11735
  var DEFAULT_CAPABILITIES4 = "default";
11395
11736
  function premise4(message, hint) {
11396
11737
  process.stderr.write(`\u{1F534} \u524D\u63D0\u4E0D\u6210\u7ACB\uFF1A${message}
@@ -11403,7 +11744,7 @@ var REQUESTS_SHAPE = "`--requests` \u6536\u7684\u662F\u4E00\u4E2A JSON \u6570\u7
11403
11744
  function readRequests(file) {
11404
11745
  let raw;
11405
11746
  try {
11406
- raw = JSON.parse(readFileSync8(file, "utf8"));
11747
+ raw = JSON.parse(readFileSync9(file, "utf8"));
11407
11748
  } catch (e) {
11408
11749
  throw new Error(`\u9700\u6C42\u6E05\u5355\u8BFB\u4E0D\u51FA\u6765\uFF08${file}\uFF09\uFF1A${e instanceof Error ? e.message : String(e)}`);
11409
11750
  }
@@ -11426,8 +11767,8 @@ function renderProblems(rows) {
11426
11767
  `;
11427
11768
  }
11428
11769
  function writeTriageArtifact(outDir, body) {
11429
- const out = path15.join(outDir, "work", "triage.md");
11430
- mkdirSync(path15.dirname(out), { recursive: true });
11770
+ const out = path16.join(outDir, "work", "triage.md");
11771
+ mkdirSync(path16.dirname(out), { recursive: true });
11431
11772
  writeFileSync2(out, body, "utf8");
11432
11773
  return out;
11433
11774
  }
@@ -11468,9 +11809,9 @@ async function deliveryTriageCommand(args) {
11468
11809
  // src/commands/delivery-execution.ts
11469
11810
  import { createHash as createHash5, randomBytes as secureRandomBytes } from "crypto";
11470
11811
  import { spawn as spawn2 } from "child_process";
11471
- import { createReadStream, promises as fs12 } from "fs";
11472
- import path16 from "path";
11473
- import { CliError as CliError23, CliErrorCode as CliErrorCode21, formatObject as formatObject28 } from "@hcmai/sdk";
11812
+ import { createReadStream, promises as fs13 } from "fs";
11813
+ import path17 from "path";
11814
+ import { CliError as CliError23, CliErrorCode as CliErrorCode21, formatObject as formatObject29 } from "@hcmai/sdk";
11474
11815
  init_exit();
11475
11816
  var EXECUTION_CONTRACT_VERSION = "2026-09-03.controlled-v4";
11476
11817
  var DEFAULT_TTL_SECONDS = 15 * 60;
@@ -11512,11 +11853,11 @@ async function prepareDeliveryExecution(input) {
11512
11853
  };
11513
11854
  const planId = sha2565(canonicalJson(core)).slice(0, 24);
11514
11855
  const plan = { ...core, planId };
11515
- const plansDir = path16.join(project, ".hcm-delivery", "execution-plans");
11856
+ const plansDir = path17.join(project, ".hcm-delivery", "execution-plans");
11516
11857
  await safeManagedDirectory(project, ".hcm-delivery/execution-plans", plansDir);
11517
- const planFile = path16.join(plansDir, `${planId}.json`);
11858
+ const planFile = path17.join(plansDir, `${planId}.json`);
11518
11859
  try {
11519
- await fs12.writeFile(planFile, `${JSON.stringify(plan, null, 2)}
11860
+ await fs13.writeFile(planFile, `${JSON.stringify(plan, null, 2)}
11520
11861
  `, {
11521
11862
  encoding: "utf8",
11522
11863
  mode: 384,
@@ -11530,7 +11871,7 @@ async function prepareDeliveryExecution(input) {
11530
11871
  async function executeDeliveryPlan(input) {
11531
11872
  if (!PLAN_ID_PATTERN.test(input.planId)) throw invalid2("planId \u5FC5\u987B\u662F 24 \u4F4D\u5C0F\u5199\u5341\u516D\u8FDB\u5236");
11532
11873
  const project = await realProject(input.project);
11533
- const planFile = path16.join(project, ".hcm-delivery", "execution-plans", `${input.planId}.json`);
11874
+ const planFile = path17.join(project, ".hcm-delivery", "execution-plans", `${input.planId}.json`);
11534
11875
  const plan = await readPlan(project, planFile);
11535
11876
  if (plan.planId !== input.planId || computePlanId(plan) !== input.planId) {
11536
11877
  throw invalid2("\u6267\u884C\u8BA1\u5212\u5185\u5BB9\u4E0E planId \u6458\u8981\u4E0D\u4E00\u81F4");
@@ -11567,13 +11908,13 @@ async function executeDeliveryPlan(input) {
11567
11908
  await assertDocumentUnchanged(project, plan.documents.rollback, "\u56DE\u6EDA\u8BF4\u660E");
11568
11909
  await assertPayloadsUnchanged(project, plan.payloads);
11569
11910
  const evidenceDir = await bindEvidenceDirectory(project, plan.evidenceDir);
11570
- const receiptFile = path16.join(evidenceDir.absolute, `${plan.planId}.receipt.json`);
11911
+ const receiptFile = path17.join(evidenceDir.absolute, `${plan.planId}.receipt.json`);
11571
11912
  if (await pathExists(receiptFile)) throw invalid2(`\u6267\u884C\u6536\u636E\u5DF2\u5B58\u5728\uFF0C\u62D2\u7EDD\u518D\u6B21\u6267\u884C\uFF1A${plan.planId}`);
11572
- const claimsDir = path16.join(project, ".hcm-delivery", "execution-claims");
11913
+ const claimsDir = path17.join(project, ".hcm-delivery", "execution-claims");
11573
11914
  await safeManagedDirectory(project, ".hcm-delivery/execution-claims", claimsDir);
11574
- const claimFile = path16.join(claimsDir, `${plan.planId}.json`);
11915
+ const claimFile = path17.join(claimsDir, `${plan.planId}.json`);
11575
11916
  try {
11576
- await fs12.writeFile(
11917
+ await fs13.writeFile(
11577
11918
  claimFile,
11578
11919
  `${JSON.stringify({ schemaVersion: 1, planId: plan.planId, claimedAt: now.toISOString() }, null, 2)}
11579
11920
  `,
@@ -11630,7 +11971,7 @@ async function deliveryPrepareCommand(argv, args) {
11630
11971
  evidenceDir: args.evidenceDir,
11631
11972
  ...ttlSeconds === void 0 ? {} : { ttlSeconds }
11632
11973
  });
11633
- process.stdout.write(formatObject28(plan, { format: args.output ?? "json" }) + "\n");
11974
+ process.stdout.write(formatObject29(plan, { format: args.output ?? "json" }) + "\n");
11634
11975
  process.stderr.write(`
11635
11976
  \u4E0B\u4E00\u6B65\uFF08argv \u5FC5\u987B\u4E0E\u672C\u6B21\u5B8C\u5168\u4E00\u81F4\uFF09\uFF1A
11636
11977
  ${nextCommandHint(plan.planId, args.project, argv)}
@@ -11657,11 +11998,11 @@ async function deliveryExecuteCommand(planId, argv, args) {
11657
11998
  }
11658
11999
  }
11659
12000
  function writeDeliveryExecutionReceipt(receipt, format = "json") {
11660
- process.stderr.write(formatObject28(receipt, { format }) + "\n");
12001
+ process.stderr.write(formatObject29(receipt, { format }) + "\n");
11661
12002
  process.exitCode = receipt.exitCode;
11662
12003
  }
11663
12004
  async function readProjectMode(project, environment) {
11664
- const file = path16.join(project, ".hcm-delivery", "project.yml");
12005
+ const file = path17.join(project, ".hcm-delivery", "project.yml");
11665
12006
  const content = await readSafeFile(project, file, "\u9879\u76EE\u914D\u7F6E");
11666
12007
  let mode;
11667
12008
  try {
@@ -11677,13 +12018,13 @@ async function readProjectMode(project, environment) {
11677
12018
  return mode;
11678
12019
  }
11679
12020
  var SKILLS_LOCK_CANDIDATES = [
11680
- path16.join("hcm-skills", ".hcm-skills.json"),
11681
- path16.join(".claude", "skills", ".hcm-skills.json")
12021
+ path17.join("hcm-skills", ".hcm-skills.json"),
12022
+ path17.join(".claude", "skills", ".hcm-skills.json")
11682
12023
  ];
11683
12024
  async function readSkillsLock(project) {
11684
12025
  const found = [];
11685
12026
  for (const candidate of SKILLS_LOCK_CANDIDATES) {
11686
- if (await pathExists(path16.join(project, candidate))) found.push(candidate);
12027
+ if (await pathExists(path17.join(project, candidate))) found.push(candidate);
11687
12028
  }
11688
12029
  if (found.length === 0) {
11689
12030
  throw invalid2(
@@ -11695,7 +12036,7 @@ async function readSkillsLock(project) {
11695
12036
  `\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`
11696
12037
  );
11697
12038
  }
11698
- const bytes = await readSafeFile(project, path16.join(project, found[0]), "\u6280\u80FD\u9501");
12039
+ const bytes = await readSafeFile(project, path17.join(project, found[0]), "\u6280\u80FD\u9501");
11699
12040
  try {
11700
12041
  JSON.parse(bytes.toString("utf8"));
11701
12042
  } catch (cause) {
@@ -11708,7 +12049,7 @@ async function bindDocument(project, reference, label) {
11708
12049
  if (!(relative2.startsWith("work/") || relative2.startsWith("decisions/"))) {
11709
12050
  throw invalid2(`${label}\u5FC5\u987B\u4F4D\u4E8E\u9879\u76EE work/ \u6216 decisions/ \u4E0B`);
11710
12051
  }
11711
- const file = path16.join(project, relative2);
12052
+ const file = path17.join(project, relative2);
11712
12053
  const bytes = await readSafeFile(project, file, label);
11713
12054
  return { path: relative2, sha256: sha2565(bytes) };
11714
12055
  }
@@ -11721,11 +12062,11 @@ async function bindEvidenceDirectory(project, reference) {
11721
12062
  if (!(relative2 === "evidence" || relative2.startsWith("evidence/"))) {
11722
12063
  throw invalid2("evidence \u76EE\u5F55\u5FC5\u987B\u4F4D\u4E8E\u9879\u76EE evidence/ \u4E0B");
11723
12064
  }
11724
- const absolute = path16.join(project, relative2);
12065
+ const absolute = path17.join(project, relative2);
11725
12066
  await assertNoSymlinkComponents(project, relative2);
11726
- const stat = await fs12.stat(absolute).catch(() => null);
12067
+ const stat = await fs13.stat(absolute).catch(() => null);
11727
12068
  if (stat === null) {
11728
- await fs12.mkdir(absolute, { recursive: true, mode: 448 }).catch((cause) => {
12069
+ await fs13.mkdir(absolute, { recursive: true, mode: 448 }).catch((cause) => {
11729
12070
  throw invalid2(
11730
12071
  `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`,
11731
12072
  cause
@@ -11905,7 +12246,7 @@ async function bindPayloadPath(project, reference, label) {
11905
12246
  const relative2 = safeRelative(reference, label);
11906
12247
  let stat;
11907
12248
  try {
11908
- stat = await fs12.stat(path16.join(project, relative2));
12249
+ stat = await fs13.stat(path17.join(project, relative2));
11909
12250
  } catch (cause) {
11910
12251
  throw invalid2(
11911
12252
  `${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`,
@@ -11916,10 +12257,10 @@ async function bindPayloadPath(project, reference, label) {
11916
12257
  }
11917
12258
  async function bindPayloadDirectory(project, reference, label) {
11918
12259
  const relative2 = reference === "." ? "." : safeRelative(reference, label);
11919
- const root = path16.join(project, relative2);
12260
+ const root = path17.join(project, relative2);
11920
12261
  let stat;
11921
12262
  try {
11922
- stat = await fs12.stat(root);
12263
+ stat = await fs13.stat(root);
11923
12264
  } catch {
11924
12265
  throw invalid2(`${label}\u4E0D\u5B58\u5728\uFF1A${relative2}`);
11925
12266
  }
@@ -11929,10 +12270,10 @@ async function bindPayloadDirectory(project, reference, label) {
11929
12270
  const skipToolingAtRoot = relative2 === ".";
11930
12271
  const entries = [];
11931
12272
  const walk = async (dir, prefix) => {
11932
- const items = await fs12.readdir(dir, { withFileTypes: true });
12273
+ const items = await fs13.readdir(dir, { withFileTypes: true });
11933
12274
  for (const item of [...items].sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0)) {
11934
12275
  if (skipToolingAtRoot && prefix === "" && TOOLING_DIRS.includes(item.name)) continue;
11935
- const child = path16.join(dir, item.name);
12276
+ const child = path17.join(dir, item.name);
11936
12277
  const rel = prefix ? `${prefix}/${item.name}` : item.name;
11937
12278
  if (item.isSymbolicLink()) {
11938
12279
  throw invalid2(
@@ -11957,7 +12298,7 @@ ${sha2565(bytes)}`);
11957
12298
  }
11958
12299
  async function bindPayloadFile(project, reference, label) {
11959
12300
  const relative2 = safeRelative(reference, label);
11960
- const file = path16.join(project, relative2);
12301
+ const file = path17.join(project, relative2);
11961
12302
  const bytes = await readSafeFile(project, file, label);
11962
12303
  return { path: relative2, kind: "file", sha256: sha2565(bytes) };
11963
12304
  }
@@ -12020,29 +12361,29 @@ async function runCurrentCliCommand(argv, cwd, streams) {
12020
12361
  async function writeReceiptExclusive(target, receipt) {
12021
12362
  const temp = `${target}.${process.pid}.${Date.now()}.tmp`;
12022
12363
  try {
12023
- await fs12.writeFile(temp, `${JSON.stringify(receipt, null, 2)}
12364
+ await fs13.writeFile(temp, `${JSON.stringify(receipt, null, 2)}
12024
12365
  `, {
12025
12366
  encoding: "utf8",
12026
12367
  mode: 384,
12027
12368
  flag: "wx"
12028
12369
  });
12029
- await fs12.link(temp, target);
12370
+ await fs13.link(temp, target);
12030
12371
  } catch (cause) {
12031
- throw invalid2(`\u6267\u884C\u6536\u636E\u5199\u5165\u5931\u8D25\u6216\u5DF2\u5B58\u5728\uFF1A${path16.basename(target)}`, cause);
12372
+ throw invalid2(`\u6267\u884C\u6536\u636E\u5199\u5165\u5931\u8D25\u6216\u5DF2\u5B58\u5728\uFF1A${path17.basename(target)}`, cause);
12032
12373
  } finally {
12033
- await fs12.unlink(temp).catch(() => void 0);
12374
+ await fs13.unlink(temp).catch(() => void 0);
12034
12375
  }
12035
12376
  }
12036
12377
  async function safeManagedDirectory(project, relative2, absolute) {
12037
- await assertNoSymlinkComponents(project, path16.dirname(relative2));
12038
- const existing = await fs12.lstat(absolute).catch(() => void 0);
12378
+ await assertNoSymlinkComponents(project, path17.dirname(relative2));
12379
+ const existing = await fs13.lstat(absolute).catch(() => void 0);
12039
12380
  if (existing?.isSymbolicLink()) throw invalid2(`\u53D7\u7BA1\u76EE\u5F55\u4E0D\u80FD\u662F\u7B26\u53F7\u94FE\u63A5\uFF1A${relative2}`);
12040
12381
  if (existing && !existing.isDirectory()) throw invalid2(`\u53D7\u7BA1\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55\uFF1A${relative2}`);
12041
- if (!existing) await fs12.mkdir(absolute, { mode: 448 });
12042
- await fs12.chmod(absolute, 448);
12382
+ if (!existing) await fs13.mkdir(absolute, { mode: 448 });
12383
+ await fs13.chmod(absolute, 448);
12043
12384
  }
12044
12385
  async function pathExists(file) {
12045
- return fs12.lstat(file).then(
12386
+ return fs13.lstat(file).then(
12046
12387
  () => true,
12047
12388
  (cause) => {
12048
12389
  if (cause.code === "ENOENT") return false;
@@ -12051,47 +12392,47 @@ async function pathExists(file) {
12051
12392
  );
12052
12393
  }
12053
12394
  async function readSafeFile(project, file, label) {
12054
- const relative2 = path16.relative(project, file).split(path16.sep).join("/");
12055
- if (relative2.startsWith("../") || path16.isAbsolute(relative2))
12395
+ const relative2 = path17.relative(project, file).split(path17.sep).join("/");
12396
+ if (relative2.startsWith("../") || path17.isAbsolute(relative2))
12056
12397
  throw invalid2(`${label}\u8DEF\u5F84\u9003\u9038\u9879\u76EE`);
12057
12398
  await assertNoSymlinkComponents(project, relative2);
12058
12399
  let stat;
12059
12400
  try {
12060
- stat = await fs12.lstat(file);
12401
+ stat = await fs13.lstat(file);
12061
12402
  } catch (cause) {
12062
12403
  throw invalid2(`${label}\u4E0D\u53EF\u7528\uFF1A${relative2}`, cause);
12063
12404
  }
12064
12405
  if (stat.isSymbolicLink()) throw invalid2(`${label}\u4E0D\u80FD\u662F\u7B26\u53F7\u94FE\u63A5\uFF1A${relative2}`);
12065
12406
  if (!stat.isFile()) throw invalid2(`${label}\u4E0D\u662F\u666E\u901A\u6587\u4EF6\uFF1A${relative2}`);
12066
- return fs12.readFile(file);
12407
+ return fs13.readFile(file);
12067
12408
  }
12068
12409
  async function assertNoSymlinkComponents(project, relative2) {
12069
12410
  const parts = relative2.split("/").filter(Boolean);
12070
12411
  let current = project;
12071
12412
  for (const part of parts) {
12072
- current = path16.join(current, part);
12073
- const stat = await fs12.lstat(current).catch(() => void 0);
12413
+ current = path17.join(current, part);
12414
+ const stat = await fs13.lstat(current).catch(() => void 0);
12074
12415
  if (stat?.isSymbolicLink()) throw invalid2(`\u8DEF\u5F84\u5305\u542B\u7B26\u53F7\u94FE\u63A5\uFF1A${relative2}`);
12075
12416
  if (!stat) break;
12076
12417
  }
12077
12418
  }
12078
12419
  async function realProject(requested) {
12079
- const absolute = path16.resolve(requested);
12420
+ const absolute = path17.resolve(requested);
12080
12421
  let project;
12081
12422
  try {
12082
- project = await fs12.realpath(absolute);
12423
+ project = await fs13.realpath(absolute);
12083
12424
  } catch (cause) {
12084
12425
  throw invalid2(`\u9879\u76EE\u76EE\u5F55\u4E0D\u53EF\u7528\uFF1A${absolute}`, cause);
12085
12426
  }
12086
- const stat = await fs12.stat(project);
12427
+ const stat = await fs13.stat(project);
12087
12428
  if (!stat.isDirectory()) throw invalid2(`\u9879\u76EE\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55\uFF1A${absolute}`);
12088
12429
  return project;
12089
12430
  }
12090
12431
  function safeRelative(reference, label) {
12091
- if (!reference || path16.isAbsolute(reference) || /[\r\n\0]/.test(reference)) {
12432
+ if (!reference || path17.isAbsolute(reference) || /[\r\n\0]/.test(reference)) {
12092
12433
  throw invalid2(`${label}\u5FC5\u987B\u662F\u9879\u76EE\u5185\u76F8\u5BF9\u8DEF\u5F84`);
12093
12434
  }
12094
- const normalized = path16.normalize(reference).split(path16.sep).join("/");
12435
+ const normalized = path17.normalize(reference).split(path17.sep).join("/");
12095
12436
  if (normalized === ".." || normalized.startsWith("../") || normalized === ".") {
12096
12437
  throw invalid2(`${label}\u8DEF\u5F84\u9003\u9038\u9879\u76EE`);
12097
12438
  }
@@ -12158,7 +12499,7 @@ init_exit();
12158
12499
  import {
12159
12500
  HcmClient as HcmClient28,
12160
12501
  adminResetPassword,
12161
- formatObject as formatObject29,
12502
+ formatObject as formatObject30,
12162
12503
  fromAxiosError as fromAxiosError23,
12163
12504
  CliError as CliError24,
12164
12505
  CliErrorCode as CliErrorCode22
@@ -12192,7 +12533,7 @@ async function userResetPasswordCommand(args) {
12192
12533
  const request = buildAdminResetPasswordRequest(args, password);
12193
12534
  const client3 = HcmClient28.fromAuthContext(await getActiveAuthContextFromCli(args));
12194
12535
  const result = await adminResetPassword(client3.raw(), request);
12195
- process.stdout.write(formatObject29(result, { format: args.output ?? "json" }) + "\n");
12536
+ process.stdout.write(formatObject30(result, { format: args.output ?? "json" }) + "\n");
12196
12537
  } catch (cause) {
12197
12538
  const err = cause;
12198
12539
  if (err?.isAxiosError) exitWithError(fromAxiosError23(err, args.env));
@@ -12216,7 +12557,7 @@ init_exit();
12216
12557
  init_auth_guard();
12217
12558
  import {
12218
12559
  HcmClient as HcmClient29,
12219
- formatObject as formatObject30,
12560
+ formatObject as formatObject31,
12220
12561
  fromAxiosError as fromAxiosError24
12221
12562
  } from "@hcmai/sdk";
12222
12563
  async function modelsCommand(keyword, args) {
@@ -12227,7 +12568,7 @@ async function modelsCommand(keyword, args) {
12227
12568
  const rows = (needle ? all.filter((m) => JSON.stringify(m).toLowerCase().includes(needle)) : all).sort((a, b) => key(a).localeCompare(key(b)));
12228
12569
  const fmt = args.output ?? "table";
12229
12570
  if (fmt !== "table") {
12230
- process.stdout.write(formatObject30({ total: rows.length, models: rows }, { format: fmt }) + "\n");
12571
+ process.stdout.write(formatObject31({ total: rows.length, models: rows }, { format: fmt }) + "\n");
12231
12572
  process.exitCode = 0;
12232
12573
  return;
12233
12574
  }
@@ -12308,6 +12649,7 @@ var user = program.command("user").description("\u7BA1\u7406\u79DF\u6237\u7528\u
12308
12649
  user.command("reset-password").description("\u7531 admin.system \u5B89\u5168\u91CD\u7F6E\u7528\u6237\u5BC6\u7801\uFF0C\u5E76\u4F7F\u65E2\u6709\u4F1A\u8BDD\u5931\u6548").option("--id <uuid>", "\u76EE\u6807\u7528\u6237 ID\uFF08\u4E0E --username \u4E8C\u9009\u4E00\uFF09").option("--username <user>", "\u76EE\u6807\u7528\u6237\u540D\uFF08\u4E0E --id \u4E8C\u9009\u4E00\uFF09").option("--password-stdin", "\u4ECE\u6807\u51C6\u8F93\u5165\u8BFB\u53D6\u65B0\u5BC6\u7801\uFF08Agent/\u53D7\u63A7\u4EA4\u4ED8\u5FC5\u987B\u4F7F\u7528\uFF09").option("--no-force-change", "\u4E0B\u6B21\u767B\u5F55\u4E0D\u5F3A\u5236\u6539\u5BC6\uFF08\u4EC5\u9650\u5DF2\u6279\u51C6\u7684\u9694\u79BB\u6D4B\u8BD5\u73AF\u5883\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\u5FC5\u987B\u5177\u5907 admin.system\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => userResetPasswordCommand(opts));
12309
12650
  var chiron = program.command("chiron").description("\u777F\u620E\u987E\u95EE\u9879\u76EE\uFF1Ainit \u4E00\u6761\u547D\u4EE4\u521D\u59CB\u5316\u9879\u76EE\u4ED3\uFF0Cdoctor \u56DB\u884C\u6838\u5BF9\u80FD\u4E0D\u80FD\u5F00\u5DE5");
12310
12651
  chiron.command("init").description("\u521D\u59CB\u5316\u987E\u95EE\u9879\u76EE\u4ED3\uFF1A\u5199 env.yaml\uFF08\u7528\u521A hcm login \u7684\u73AF\u5883\uFF09\u3001\u5EFA\u76EE\u5F55\u3001\u88C5\u5168\u90E8\u6280\u80FD\u3001\u63A5\u6848\u4F8B\u5E93\uFF1B\u91CD\u8DD1\u5B89\u5168").option("--project <dir>", "\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--skip-skills", "\u4E0D\u88C5\u6280\u80FD\uFF08\u79BB\u7EBF/\u6D4B\u8BD5\uFF09").option("--skip-cases", "\u4E0D\u63A5\u6848\u4F8B\u5E93").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => chironInitCommand(opts));
12652
+ chiron.command("test").description("\u6309\u7528\u4F8B\u8DD1\u4E00\u904D\u5E76\u628A\u95EE\u9898\u627E\u51FA\u6765\uFF1A\u7528\u4F8B\u5728\u9879\u76EE\u4ED3 tests/\uFF0C\u5224\u636E\u5FC5\u987B\u770B\u5185\u5BB9\uFF08\u53EA\u5224\u9000\u51FA\u7801\u7684\u7528\u4F8B\u4F1A\u88AB\u62D2\u7EDD\u52A0\u8F7D\uFF09").argument("[target]", "\u7528\u4F8B\u6587\u4EF6\u6216\u76EE\u5F55\uFF08\u9ED8\u8BA4 tests/\uFF09").option("--project <dir>", "\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--env <name>", "\u76EE\u6807\u73AF\u5883\uFF1B\u7528\u4F8B\u91CC\u6CA1\u5199 --env \u65F6\u8865\u4E0A").option("--as <identity>", "\u8EAB\u4EFD\uFF1B\u7528\u4F8B\u91CC\u6CA1\u5199 --as \u65F6\u8865\u4E0A").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((target, opts) => chironTestCommand(target, opts));
12311
12653
  chiron.command("doctor").description("\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").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));
12312
12654
  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");
12313
12655
  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));
@@ -12461,7 +12803,7 @@ skills.command("update").description("\u628A\u88C5\u8FC7\u7684\u6280\u80FD\u5347
12461
12803
  program.command("update <Model>").description("\u66F4\u65B0\u4E00\u6761 Model \u8BB0\u5F55\uFF08\u8D70\u540E\u7AEF\u5B8C\u6574\u6821\u9A8C\uFF09\u3002\u5347\u7EA7 CLI \u8BF7\u7528 `hcm upgrade`").requiredOption("--id <id>", "\u8BB0\u5F55 ID").option("--data <JSON>", `\u8981\u66F4\u65B0\u7684\u5B57\u6BB5 JSON\uFF0C\u4F8B\u5982 '{"name":"\u65B0\u540D\u79F0"}'`).option("--data-file <path>", "\u4ECE UTF-8 JSON \u6587\u4EF6\u8BFB\u53D6\u66F4\u65B0\u5B57\u6BB5\uFF08\u4E0E --data \u4E92\u65A5\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("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").option("--i18n", "\u591A\u8BED\u8A00\u5B57\u6BB5\u6309 Map \u5B8C\u6574\u66FF\u6362\uFF08\u952E\u7528 zh-CN / en-US \u8FDE\u5B57\u7B26\u5F62\uFF09\uFF1B\u4E0D\u4F20\u5219\u6309\u5B57\u7B26\u4E32\u53EA\u6539\u5F53\u524D\u8BED\u8A00").action((model, opts) => updateCommand(model, opts));
12462
12804
  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));
12463
12805
  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));
12464
- 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((path17, opts) => openCommand(path17, opts));
12806
+ 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));
12465
12807
  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");
12466
12808
  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));
12467
12809
  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("--set <assignment...>", "namespace.key=value\uFF0C\u4F8B\u5982 security.password.passwordPolicy=complex").option("--dry-run", "\u53EA\u663E\u793A\u5C06\u5199\u5165\u4EC0\u4E48\uFF0C\u4E0D\u5B9E\u9645\u5199\u5165").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", "json").action((d, opts) => settingSetCommand(d, opts));