@hcmai/cli 0.4.31 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -532,8 +532,8 @@ var init_TerminalRenderer = __esm({
532
532
  }
533
533
  }
534
534
  /** 来源行(仅子代理触发,agentPath ≥2 段时显示 `↑ 来自 a › b`,对齐 Web)。 */
535
- originLine(path19) {
536
- const segs = path19.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(path19) {
1719
- const segs = (path19 ?? "").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
  }
@@ -2100,21 +2100,21 @@ async function loginPasswordWithFirstLoginChange(input, args) {
2100
2100
  return loginPassword({ ...input, password: next });
2101
2101
  }
2102
2102
  }
2103
- function inferIdentityName(scheme, env2, extra) {
2104
- if (scheme === "password" && extra.username) return `${extra.username}@${env2}`;
2103
+ function inferIdentityName(scheme, env3, extra) {
2104
+ if (scheme === "password" && extra.username) return `${extra.username}@${env3}`;
2105
2105
  if (scheme === "client_credentials" && extra.clientId) {
2106
- return `${extra.clientId.slice(0, 6)}@${env2}`;
2106
+ return `${extra.clientId.slice(0, 6)}@${env3}`;
2107
2107
  }
2108
- if (scheme === "pairing" && extra.username) return `${extra.username}@${env2}`;
2108
+ if (scheme === "pairing" && extra.username) return `${extra.username}@${env3}`;
2109
2109
  if (scheme === "pat") {
2110
- const name = `pat-${Math.random().toString(36).slice(2, 6)}@${env2}`;
2110
+ const name = `pat-${Math.random().toString(36).slice(2, 6)}@${env3}`;
2111
2111
  process.stderr.write(
2112
2112
  `[hcm] event=pat_identity_auto_named name=${name} hint="pass --name <id> for a stable identity name across re-logins"
2113
2113
  `
2114
2114
  );
2115
2115
  return name;
2116
2116
  }
2117
- return `default@${env2}`;
2117
+ return `default@${env3}`;
2118
2118
  }
2119
2119
  async function migrateProfileTokenToIdentity(envName, identityName) {
2120
2120
  const oldStore = new TokenStore(envName);
@@ -2382,9 +2382,9 @@ async function loginCommand(args) {
2382
2382
  } catch (e) {
2383
2383
  const err = e;
2384
2384
  if (err.isAxiosError) {
2385
- const { fromAxiosError: fromAxiosError25 } = await import("@hcmai/sdk");
2385
+ const { fromAxiosError: fromAxiosError24 } = await import("@hcmai/sdk");
2386
2386
  exitWithError(
2387
- fromAxiosError25(
2387
+ fromAxiosError24(
2388
2388
  e,
2389
2389
  envName
2390
2390
  )
@@ -3234,14 +3234,14 @@ async function versionCommand(args) {
3234
3234
  let endpoint = args.endpoint;
3235
3235
  if (!endpoint) {
3236
3236
  const g = await loadGlobalConfig5();
3237
- const env2 = await loadEnv4(resolveActiveEnv2({ envFlag: args.env }, process.env, g)).catch(() => null);
3238
- if (!env2?.endpoint) {
3237
+ const env3 = await loadEnv4(resolveActiveEnv2({ envFlag: args.env }, process.env, g)).catch(() => null);
3238
+ if (!env3?.endpoint) {
3239
3239
  throw new CliError11({
3240
3240
  code: CliErrorCode10.MISSING_FLAG,
3241
3241
  message: "\u672A\u89E3\u6790\u5230 endpoint \u2014\u2014 \u4F20 --endpoint <url>\uFF0C\u6216\u5148 `hcm env add <name> --endpoint <url>`"
3242
3242
  });
3243
3243
  }
3244
- endpoint = env2.endpoint;
3244
+ endpoint = env3.endpoint;
3245
3245
  }
3246
3246
  const http = createHttpClient({
3247
3247
  endpoint: endpoint.replace(/\/+$/, ""),
@@ -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 path19 = 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, path19);
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 ${path19}\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(path19) {
3474
- if (statSync(path19).isFile()) return [path19];
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(path19) {
3480
3480
  else if (full.endsWith(".yml") || full.endsWith(".yaml")) out.push(full);
3481
3481
  }
3482
3482
  };
3483
- walk(path19);
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(path19, args) {
3491
+ async function importCommand(path18, args) {
3492
3492
  try {
3493
- const files = collectYmlFiles(path19);
3493
+ const files = collectYmlFiles(path18);
3494
3494
  const fixtures = files.map(
3495
3495
  (f) => parseFixture(readFileSync2(f, "utf8"), relative(process.cwd(), f))
3496
3496
  );
@@ -5329,14 +5329,14 @@ async function resolveEndpoint(args) {
5329
5329
  if (args.endpoint) return args.endpoint.replace(/\/+$/, "");
5330
5330
  const g = await loadGlobalConfig6();
5331
5331
  const envName = resolveActiveEnv3({ envFlag: args.env }, process.env, g);
5332
- const env2 = await loadEnv6(envName).catch(() => null);
5333
- if (!env2?.endpoint) {
5332
+ const env3 = await loadEnv6(envName).catch(() => null);
5333
+ if (!env3?.endpoint) {
5334
5334
  throw new CliError17({
5335
5335
  code: CliErrorCode16.MISSING_FLAG,
5336
5336
  message: "\u672A\u89E3\u6790\u5230 endpoint \u2014\u2014 \u4F20 --endpoint <url>\uFF0C\u6216\u5148 `hcm env add <name> --endpoint <url>`\u3002\uFF08\u6280\u80FD\u5E93\u514D\u8BA4\u8BC1\uFF0C\u4E0D\u9700\u8981\u5148 login\uFF09"
5337
5337
  });
5338
5338
  }
5339
- return env2.endpoint.replace(/\/+$/, "");
5339
+ return env3.endpoint.replace(/\/+$/, "");
5340
5340
  }
5341
5341
  function normalizeEndpoint(endpoint) {
5342
5342
  return endpoint.replace(/\/+$/, "");
@@ -6487,14 +6487,14 @@ async function resolveEndpoint2(args) {
6487
6487
  if (args.endpoint) return args.endpoint;
6488
6488
  const g = await loadGlobalConfig7();
6489
6489
  const envName = resolveActiveEnv4({ envFlag: args.env }, process.env, g);
6490
- const env2 = await loadEnv7(envName).catch(() => null);
6491
- if (!env2?.endpoint) {
6490
+ const env3 = await loadEnv7(envName).catch(() => null);
6491
+ if (!env3?.endpoint) {
6492
6492
  throw new CliError18({
6493
6493
  code: CliErrorCode17.MISSING_FLAG,
6494
6494
  message: "\u672A\u89E3\u6790\u5230 endpoint \u2014\u2014 \u4F20 --endpoint <url>\uFF0C\u6216\u5148 `hcm env add <name> --endpoint <url>`"
6495
6495
  });
6496
6496
  }
6497
- return env2.endpoint;
6497
+ return env3.endpoint;
6498
6498
  }
6499
6499
  async function tenantBootstrapCommand(args) {
6500
6500
  try {
@@ -6606,10 +6606,10 @@ async function metaListCommand(args) {
6606
6606
  fail5(e, args);
6607
6607
  }
6608
6608
  }
6609
- async function metaGetCommand(path19, args) {
6609
+ async function metaGetCommand(path18, args) {
6610
6610
  try {
6611
6611
  const c = await client2(args);
6612
- const content = await getTenantMeta(c.raw(), path19);
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(path19, 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(path19) {
6622
- const base = path19.split(/[\\/]/).pop() ?? path19;
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, path19) {
6640
- const { model, kind, state } = parseMetaPath(path19);
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 ${path19} \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, path19) {
6684
6684
  }
6685
6685
  return { status: "ok" };
6686
6686
  }
6687
- async function metaSetCommand(path19, 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(path19, 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(path19, content);
6703
+ const result2 = validateMetaContent(path18, content);
6704
6704
  if (result2.issues.length > 0) {
6705
- process.stderr.write(`\u{1F50E} \u5199\u524D\u6821\u9A8C ${path19}\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(path19, args) {
6721
6721
  if (dryFmt === "json" || dryFmt === "yaml") {
6722
6722
  process.stdout.write(
6723
6723
  formatObject18(
6724
- { dryRun: true, path: path19, 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 ${path19}\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(), path19);
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()}-${path19.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(), path19, 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 ${path19}
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 ${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)}
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 ${path19}${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, path19);
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(path19, 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 ${path19}\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(), path19);
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 ${path19}
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(path19, args) {
6831
6831
  fail5(e, args);
6832
6832
  }
6833
6833
  }
6834
- async function metaValidateCommand(path19, 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(path19, 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(path19, 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: path19,
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(path19, args) {
6864
6864
  );
6865
6865
  } else {
6866
6866
  process.stdout.write(
6867
- `\u{1F50E} ${path19}\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(
@@ -8450,7 +8450,7 @@ var fetchAuthInfo = async (endpoint, accessToken) => {
8450
8450
  };
8451
8451
  async function inspectIdentity(name, fetcher = fetchAuthInfo) {
8452
8452
  const meta2 = await loadIdentity4(name);
8453
- const env2 = await loadEnv8(meta2.env);
8453
+ const env3 = await loadEnv8(meta2.env);
8454
8454
  const accessToken = await TokenStore3.forIdentity(name).getStoredAccessToken();
8455
8455
  if (!accessToken) {
8456
8456
  throw new CliError20({
@@ -8459,14 +8459,14 @@ async function inspectIdentity(name, fetcher = fetchAuthInfo) {
8459
8459
  context: { nextStep: `\u91CD\u65B0\u767B\u5F55\u8BE5\u8EAB\u4EFD\uFF1Ahcm login --env ${meta2.env} --name ${name}` }
8460
8460
  });
8461
8461
  }
8462
- const raw = await fetcher(env2.endpoint, accessToken);
8462
+ const raw = await fetcher(env3.endpoint, accessToken);
8463
8463
  const principal = toPrincipal(raw);
8464
8464
  const body = raw && typeof raw === "object" && !Array.isArray(raw) ? raw : {};
8465
8465
  const serverScopes = Array.isArray(body.scopes) ? body.scopes.map(String) : void 0;
8466
8466
  return {
8467
8467
  identity: name,
8468
8468
  env: meta2.env,
8469
- endpoint: env2.endpoint,
8469
+ endpoint: env3.endpoint,
8470
8470
  scheme: meta2.scheme,
8471
8471
  userId: principal?.userId ?? null,
8472
8472
  username: principal?.username ?? null,
@@ -8497,8 +8497,8 @@ async function identityList(args) {
8497
8497
  const lines = [];
8498
8498
  for (const n of names) {
8499
8499
  const meta2 = await loadIdentity4(n);
8500
- const env2 = await loadEnv8(meta2.env).catch(() => null);
8501
- const isDefault = env2?.defaultIdentity === n ? "*" : " ";
8500
+ const env3 = await loadEnv8(meta2.env).catch(() => null);
8501
+ const isDefault = env3?.defaultIdentity === n ? "*" : " ";
8502
8502
  const expired = meta2.expiresAt && new Date(meta2.expiresAt) < /* @__PURE__ */ new Date() ? " (expired)" : "";
8503
8503
  lines.push(`${isDefault} ${n} scheme=${meta2.scheme} env=${meta2.env}${expired}`);
8504
8504
  }
@@ -8510,14 +8510,14 @@ async function identityList(args) {
8510
8510
  async function identityUse(name) {
8511
8511
  try {
8512
8512
  const meta2 = await loadIdentity4(name);
8513
- const env2 = await loadEnv8(meta2.env).catch(() => {
8513
+ const env3 = await loadEnv8(meta2.env).catch(() => {
8514
8514
  throw new CliError20({
8515
8515
  code: CliErrorCode19.IDENTITY_NOT_IN_ENV,
8516
8516
  message: `identity '${name}' references env '${meta2.env}' which no longer exists. Re-create the env, or remove this orphan: hcm identity remove ${name}`
8517
8517
  });
8518
8518
  });
8519
- env2.defaultIdentity = name;
8520
- await saveEnv3(meta2.env, env2);
8519
+ env3.defaultIdentity = name;
8520
+ await saveEnv3(meta2.env, env3);
8521
8521
  return exitOk(`\u2705 default identity for env '${meta2.env}': ${name}`);
8522
8522
  } catch (e) {
8523
8523
  exitWithError(e);
@@ -8535,10 +8535,10 @@ async function identityRemove(name) {
8535
8535
  );
8536
8536
  }
8537
8537
  await deleteIdentity3(name);
8538
- const env2 = await loadEnv8(meta2.env).catch(() => null);
8539
- if (env2?.defaultIdentity === name) {
8540
- env2.defaultIdentity = void 0;
8541
- await saveEnv3(meta2.env, env2);
8538
+ const env3 = await loadEnv8(meta2.env).catch(() => null);
8539
+ if (env3?.defaultIdentity === name) {
8540
+ env3.defaultIdentity = void 0;
8541
+ await saveEnv3(meta2.env, env3);
8542
8542
  }
8543
8543
  return exitOk(`\u2705 identity '${name}' removed`);
8544
8544
  } catch (e) {
@@ -9235,7 +9235,7 @@ function withProjectReadiness(assessment, projectRoot = ".") {
9235
9235
  projectInitialized,
9236
9236
  requirements,
9237
9237
  modePolicy: assessment.modePolicy ? { ...assessment.modePolicy, controlled: "deny" } : assessment.modePolicy,
9238
- projectNextStep: `\u672C\u9879\u76EE\u5C1A\u672A\u521D\u59CB\u5316\uFF08\u7F3A ${projectFile}\uFF09\uFF1B\u5148\u8DD1 hcm delivery init`
9238
+ projectNextStep: `\u672C\u9879\u76EE\u5C1A\u672A\u521D\u59CB\u5316\uFF08\u7F3A ${projectFile}\uFF09\uFF1B\u5148\u8DD1 hcm chiron init`
9239
9239
  };
9240
9240
  }
9241
9241
  async function deliveryAssessCommand(argv, args) {
@@ -9350,18 +9350,206 @@ function flagValue2(argv, flag) {
9350
9350
 
9351
9351
  // src/commands/delivery-init.ts
9352
9352
  init_exit();
9353
- import { promises as fs8 } from "fs";
9354
- import path8 from "path";
9355
- import {
9356
- formatObject as formatObject22,
9357
- loadEnv as loadEnv9,
9358
- loadGlobalConfig as loadGlobalConfig9,
9359
- resolveActiveEnv as resolveActiveEnv5
9360
- } from "@hcmai/sdk";
9353
+ import { promises as fs7 } from "fs";
9354
+ import path7 from "path";
9355
+ import { formatObject as formatObject22 } from "@hcmai/sdk";
9361
9356
 
9362
- // src/commands/delivery-project-scaffold.ts
9357
+ // src/commands/delivery-mode-approval.ts
9358
+ import { randomUUID } from "crypto";
9363
9359
  import { promises as fs6 } from "fs";
9364
9360
  import path6 from "path";
9361
+ function requireControlledModeApproval(mode, approvedBy, reason) {
9362
+ if (mode !== "controlled") return null;
9363
+ const approver = approvedBy?.trim() ?? "";
9364
+ const approvalReason = reason?.trim() ?? "";
9365
+ if (!approver || !approvalReason) {
9366
+ throw new Error(
9367
+ "\u5207\u6362\u5230 controlled \u5FC5\u987B\u540C\u65F6\u4F20 --approved-by <\u9879\u76EE\u8D1F\u8D23\u4EBA> \u4E0E --reason <\u672C\u6B21\u660E\u786E\u6388\u6743\u4F9D\u636E>\u3002\u6388\u6743\u5FC5\u987B\u6765\u81EA\u9879\u76EE\u8D1F\u8D23\u4EBA\u5728\u672C\u6B21\u5BF9\u8BDD\u6216\u4EFB\u52A1\u4E66\u4E2D\u7684\u660E\u786E\u6279\u51C6\uFF1B\u5BA2\u6237\u53E3\u5934\u6216\u7FA4\u6D88\u606F\u4E0D\u662F\u6267\u884C\u6388\u6743"
9368
+ );
9369
+ }
9370
+ return { approvedBy: approver, reason: approvalReason };
9371
+ }
9372
+ async function setDeliveryModeWithReceipt(input) {
9373
+ const approval = requireControlledModeApproval(input.mode, input.approvedBy, input.reason);
9374
+ const root = path6.resolve(input.project);
9375
+ const projectFile = path6.join(root, ".hcm-delivery", "project.yml");
9376
+ const content = await fs6.readFile(projectFile, "utf8").catch((cause) => {
9377
+ throw new Error(`\u9879\u76EE\u672A\u521D\u59CB\u5316\uFF1A\u627E\u4E0D\u5230 ${projectFile}
9378
+ \u4E0B\u4E00\u6B65\uFF1Ahcm chiron init`, {
9379
+ cause
9380
+ });
9381
+ });
9382
+ const update = setDeliveryModeForEnvironment(content, input.environment, input.mode);
9383
+ const changed = (input.now ?? (() => /* @__PURE__ */ new Date()))();
9384
+ if (Number.isNaN(changed.getTime())) throw new Error("\u5F53\u524D\u65F6\u95F4\u65E0\u6548");
9385
+ let receiptFile = null;
9386
+ if (approval) {
9387
+ const relativeDirectory = path6.join("evidence", "delivery-mode");
9388
+ await ensureReceiptDirectory(root);
9389
+ const safeTime = changed.toISOString().replace(/[:.]/g, "-");
9390
+ const id = (input.receiptId ?? randomUUID)();
9391
+ if (!/^[a-zA-Z0-9-]+$/.test(id)) throw new Error("\u6A21\u5F0F\u5207\u6362\u6536\u636E ID \u975E\u6CD5");
9392
+ receiptFile = path6.join(relativeDirectory, `${safeTime}-${id}.receipt.json`);
9393
+ }
9394
+ const receipt = {
9395
+ schemaVersion: 1,
9396
+ receiptType: "delivery-mode-change",
9397
+ changedAt: changed.toISOString(),
9398
+ project: root,
9399
+ projectFile,
9400
+ environment: input.environment,
9401
+ previous: update.previous,
9402
+ deliveryMode: input.mode,
9403
+ canExecuteR2: input.mode === "controlled",
9404
+ migratedLegacy: update.migratedLegacy,
9405
+ approvedBy: approval?.approvedBy ?? null,
9406
+ reason: approval?.reason ?? null,
9407
+ receiptFile
9408
+ };
9409
+ await fs6.writeFile(projectFile, update.content, "utf8");
9410
+ if (receiptFile) {
9411
+ try {
9412
+ await fs6.writeFile(path6.join(root, receiptFile), `${JSON.stringify(receipt, null, 2)}
9413
+ `, {
9414
+ encoding: "utf8",
9415
+ mode: 384,
9416
+ flag: "wx"
9417
+ });
9418
+ } catch (cause) {
9419
+ try {
9420
+ await fs6.writeFile(projectFile, content, "utf8");
9421
+ } catch (rollbackCause) {
9422
+ throw new Error(
9423
+ `\u6A21\u5F0F\u5207\u6362\u6536\u636E\u5199\u5165\u5931\u8D25\uFF0C\u4E14 project.yml \u56DE\u6EDA\u5931\u8D25\uFF1A${String(rollbackCause.message)}`,
9424
+ { cause }
9425
+ );
9426
+ }
9427
+ throw new Error("\u6A21\u5F0F\u5207\u6362\u6536\u636E\u5199\u5165\u5931\u8D25\uFF1Bproject.yml \u5DF2\u56DE\u6EDA\uFF0C\u4ECD\u4FDD\u6301\u539F\u6A21\u5F0F", { cause });
9428
+ }
9429
+ }
9430
+ return receipt;
9431
+ }
9432
+ async function ensureReceiptDirectory(root) {
9433
+ const evidenceDirectory = path6.join(root, "evidence");
9434
+ await ensurePlainDirectory(evidenceDirectory, false);
9435
+ await ensurePlainDirectory(path6.join(evidenceDirectory, "delivery-mode"), true);
9436
+ }
9437
+ async function ensurePlainDirectory(directory, privateDirectory) {
9438
+ let created = false;
9439
+ try {
9440
+ await fs6.mkdir(directory, { mode: privateDirectory ? 448 : 493 });
9441
+ created = true;
9442
+ } catch (cause) {
9443
+ if (cause.code !== "EEXIST") throw cause;
9444
+ }
9445
+ const stat = await fs6.lstat(directory);
9446
+ if (!stat.isDirectory() || stat.isSymbolicLink()) {
9447
+ throw new Error(`\u6A21\u5F0F\u5207\u6362\u6536\u636E\u8DEF\u5F84\u4E0D\u662F\u666E\u901A\u76EE\u5F55\uFF1A${directory}`);
9448
+ }
9449
+ if (privateDirectory || created) {
9450
+ await fs6.chmod(directory, privateDirectory ? 448 : 493);
9451
+ }
9452
+ }
9453
+
9454
+ // src/commands/delivery-init.ts
9455
+ function renderProjectYml(environment, mode) {
9456
+ return [
9457
+ "# HCM \u987E\u95EE\u4EA4\u4ED8\u9879\u76EE\u914D\u7F6E\uFF08hcm delivery init \u751F\u6210\uFF09",
9458
+ "#",
9459
+ "# deliveryMode \u6309\u76EE\u6807\u73AF\u5883\u51B3\u5B9A\u672C\u673A\u5141\u8BB8\u8D70\u5230\u54EA\u4E00\u6B65\uFF1A",
9460
+ "# plan-only \u2014\u2014 \u53EA\u5141\u8BB8 assess / prepare \u51FA\u8BA1\u5212\uFF0Cexecute \u4E00\u5F8B\u62D2\u7EDD",
9461
+ "# controlled \u2014\u2014 \u5141\u8BB8 prepare + execute \u5355\u6B21\u53D7\u63A7\u6267\u884C\uFF08\u4ECD\u9700\u9010\u6B21\u6279\u51C6\uFF09",
9462
+ "#",
9463
+ "# \u{1F534} \u5B83\u4E0D\u653E\u5BBD\u4EFB\u4F55\u98CE\u9669\u5224\u7EA7\uFF1AR3 \u5728\u4E24\u79CD\u6A21\u5F0F\u4E0B\u90FD\u62D2\u7EDD\uFF0CR2 \u4ECD\u8981\u8BA1\u5212\u3001\u56DE\u6EDA\u8BF4\u660E\u4E0E\u6536\u636E\u3002",
9464
+ "# \u6539\u4E00\u4E2A\u73AF\u5883\u53EA\u5F71\u54CD\u8BE5\u73AF\u5883\uFF1B\u672A\u767B\u8BB0\u7684\u73AF\u5883 fail-closed\uFF0C\u4E0D\u7EE7\u627F\u5176\u5B83\u73AF\u5883\u7684 controlled\u3002",
9465
+ "schemaVersion: 2",
9466
+ "deliveryMode:",
9467
+ ` ${JSON.stringify(environment)}: ${mode}`,
9468
+ ""
9469
+ ].join("\n");
9470
+ }
9471
+ async function deliveryModeCommand(args) {
9472
+ try {
9473
+ const environment = requireDeliveryModeEnvironment(args.env);
9474
+ const root = path7.resolve(args.project ?? ".");
9475
+ const file = path7.join(root, ".hcm-delivery", "project.yml");
9476
+ let content;
9477
+ try {
9478
+ content = await fs7.readFile(file, "utf8");
9479
+ } catch {
9480
+ throw new Error(
9481
+ `\u9879\u76EE\u672A\u521D\u59CB\u5316\uFF1A\u627E\u4E0D\u5230 ${file}
9482
+ \u4E0B\u4E00\u6B65\uFF1Ahcm delivery init`
9483
+ );
9484
+ }
9485
+ if (!args.set) {
9486
+ const current = deliveryModeForEnvironment(content, environment);
9487
+ process.stdout.write(
9488
+ formatObject22(
9489
+ {
9490
+ project: root,
9491
+ projectFile: file,
9492
+ environment,
9493
+ deliveryMode: current,
9494
+ canExecuteR2: current === "controlled",
9495
+ ...current === "plan-only" ? { note: "plan-only \u53EA\u51FA\u8BA1\u5212\u4E0D\u6267\u884C\uFF1Bexecute \u4F1A\u62D2\u7EDD R2 \u8BA1\u5212" } : current === null ? {
9496
+ note: `\u73AF\u5883 ${environment} \u5C1A\u672A\u767B\u8BB0\u4EA4\u4ED8\u6A21\u5F0F\uFF1Bfail-closed\u3002\u5148\u6267\u884C hcm delivery mode --env ${environment} --set plan-only`
9497
+ } : {}
9498
+ },
9499
+ { format: args.output ?? "json" }
9500
+ ) + "\n"
9501
+ );
9502
+ process.exitCode = 0;
9503
+ return;
9504
+ }
9505
+ const next = args.set;
9506
+ if (!DELIVERY_MODES.includes(next)) {
9507
+ throw new Error(`--set \u53EA\u63A5\u53D7 ${DELIVERY_MODES.join(" | ")}\uFF0C\u6536\u5230 "${args.set}"`);
9508
+ }
9509
+ const receipt = await setDeliveryModeWithReceipt({
9510
+ project: root,
9511
+ environment,
9512
+ mode: next,
9513
+ approvedBy: args.approvedBy,
9514
+ reason: args.reason
9515
+ });
9516
+ process.stdout.write(
9517
+ formatObject22(receipt, { format: args.output ?? "json" }) + "\n"
9518
+ );
9519
+ process.exitCode = 0;
9520
+ return;
9521
+ } catch (e) {
9522
+ exitWithError(e);
9523
+ process.exit(1);
9524
+ }
9525
+ }
9526
+ function requireDeliveryModeEnvironment(envFlag) {
9527
+ const environment = envFlag?.trim();
9528
+ if (!environment) {
9529
+ throw new Error(
9530
+ "hcm delivery mode \u5FC5\u987B\u663E\u5F0F\u4F20 --env <\u73AF\u5883\u522B\u540D>\uFF1B\u9879\u76EE\u4EA4\u4ED8\u6A21\u5F0F\u4E0D\u7EE7\u627F\u5168\u5C40 activeEnv\uFF0C\u907F\u514D\u67E5\u770B\u6216\u4FEE\u6539\u9519\u8BEF\u73AF\u5883"
9531
+ );
9532
+ }
9533
+ return environment;
9534
+ }
9535
+
9536
+ // src/commands/chiron-init.ts
9537
+ init_auth_guard();
9538
+ init_exit();
9539
+ import { promises as fs11 } from "fs";
9540
+ import path10 from "path";
9541
+ import {
9542
+ CliError as CliError21,
9543
+ CliErrorCode as CliErrorCode20,
9544
+ HcmClient as HcmClient21,
9545
+ fetchReconIdentity,
9546
+ formatObject as formatObject23,
9547
+ httpProbe,
9548
+ isTempEnv as isTempEnv3,
9549
+ listIdentities as listIdentities5,
9550
+ loadEnv as loadEnv10,
9551
+ loadGlobalConfig as loadGlobalConfig10
9552
+ } from "@hcmai/sdk";
9365
9553
 
9366
9554
  // src/commands/delivery-page-acceptance.ts
9367
9555
  function renderPageAcceptanceSh(evidenceDir = "\u8BC1\u636E") {
@@ -9514,658 +9702,113 @@ function renderPageAcceptanceSh(evidenceDir = "\u8BC1\u636E") {
9514
9702
  }
9515
9703
 
9516
9704
  // src/commands/delivery-project-scaffold.ts
9705
+ import { promises as fs8 } from "fs";
9517
9706
  var AGENT_BEGIN = "<!-- hcm-delivery-project:begin -->";
9518
9707
  var AGENT_END = "<!-- hcm-delivery-project:end -->";
9519
9708
  var GITIGNORE_BEGIN = "# >>> hcm delivery local state >>>";
9520
- var GITIGNORE_END = "# <<< hcm delivery local state <<<";
9521
- var DELIVERY_PROJECT_DIRECTORIES = [
9522
- "work",
9523
- "decisions",
9524
- "evidence",
9525
- "hcm-skills",
9526
- "\u5BA2\u6237\u8D44\u6599",
9527
- "\u9700\u6C42",
9528
- "\u4EA4\u4ED8\u7269",
9529
- "\u8BC1\u636E",
9530
- "\u51B3\u7B56",
9531
- "\u6848\u4F8B"
9532
- ];
9533
- function renderEnvironmentYml(environment, config2, initialMode) {
9534
- const endpoint = config2?.endpoint ?? "REPLACE_ME";
9535
- const frontend = config2?.frontend ?? endpoint;
9536
- const tenant2 = config2?.tenantId ?? "1";
9537
- return [
9538
- "# \u5BA2\u6237\u9879\u76EE\u5171\u4EAB\u73AF\u5883\u6E05\u5355\uFF08\u4E0D\u653E\u8EAB\u4EFD\u6216\u51ED\u636E\uFF09",
9539
- "# owner \u4E0E controlled \u7531\u9879\u76EE\u8D1F\u8D23\u4EBA\u8BC4\u5BA1\uFF1B\u4E2A\u4EBA\u673A\u5668\u4E0A\u7684\u5B9E\u9645\u6A21\u5F0F\u5728 .hcm-delivery/project.yml\u3002",
9540
- "schemaVersion: 1",
9541
- "environments:",
9542
- ` - alias: ${JSON.stringify(environment)}`,
9543
- ` endpoint: ${JSON.stringify(endpoint)}`,
9544
- ` frontend: ${JSON.stringify(frontend)}`,
9545
- ` tenant: ${JSON.stringify(tenant2)}`,
9546
- ` controlled: ${initialMode === "controlled" ? "true" : "false"}`,
9547
- ' owner: "TODO: \u9879\u76EE\u8D1F\u8D23\u4EBA"',
9548
- ""
9549
- ].join("\n");
9550
- }
9551
- function renderAgentInstructions() {
9552
- return [
9553
- AGENT_BEGIN,
9554
- "# HCM \u987E\u95EE\u9879\u76EE\u8FB9\u754C",
9555
- "",
9556
- "- \u53EA\u4F7F\u7528\u672C\u9879\u76EE\u5185\u7684\u777F\u620E\u6280\u80FD\u4E0E\u5DF2\u53D1\u5E03\u7684 `hcm` CLI\uFF1B\u4E0D\u8BFB\u53D6\u4EA7\u54C1\u6E90\u7801\uFF0C\u4E0D\u76F4\u8FDE\u6570\u636E\u5E93\uFF0C\u4E0D\u7528 `curl` \u7ED5\u8FC7 CLI\u3002",
9557
- "- \u6BCF\u6B21\u5F00\u5DE5\u5148\u53EA\u8BFB\u6838\u5BF9 CLI \u7248\u672C\u3001\u76EE\u6807\u73AF\u5883\u3001\u8EAB\u4EFD\u3001\u6280\u80FD\u9501\u4E0E `hcm delivery doctor`\uFF1B\u73AF\u5883\u4E8B\u5B9E\u5FC5\u987B\u73B0\u67E5\uFF0C\u4E0D\u51ED\u8BB0\u5FC6\u586B\u5199\u3002",
9558
- "- R2 \u5199\u64CD\u4F5C\u5FC5\u987B\u4F9D\u6B21\u7ECF\u8FC7 `hcm delivery assess`\u3001`prepare`\u3001`execute`\uFF0C\u88AB\u6267\u884C argv \u5FC5\u987B\u663E\u5F0F\u5E26 `--env` \u4E0E `--as`\u3002",
9559
- "- R2 \u5199\u6388\u6743\u53EA\u8BA4\u53EF\u9879\u76EE\u8D1F\u8D23\u4EBA\u5728**\u672C\u6B21\u5BF9\u8BDD\u6216\u4EFB\u52A1\u4E66**\u91CC\u7684\u660E\u786E\u6279\u51C6\uFF1B\u5BA2\u6237\u53E3\u5934\u8981\u6C42\u6216\u7FA4\u6D88\u606F\u53EA\u662F\u4E1A\u52A1\u9700\u6C42\uFF0C\u4E0D\u662F\u6267\u884C\u6388\u6743\uFF0C\u4E0D\u80FD\u636E\u6B64\u5207\u5230 controlled \u6216\u6267\u884C\u3002",
9560
- "- \u5199\u524D\u5FC5\u987B\u8BF4\u660E\u5BF9\u8C61\u3001\u8303\u56F4\u3001\u5F71\u54CD\u4E0E\u56DE\u9000\u5E76\u53D6\u5F97\u672C\u6B21\u660E\u786E\u786E\u8BA4\u3002\u975E\u4EA4\u4E92\u8FD0\u884C\u62FF\u4E0D\u5230\u786E\u8BA4\u65F6\uFF0C\u6700\u591A\u505A\u5230 `prepare`\uFF0C\u7ED3\u8BBA\u5FC5\u987B\u4E3A `BLOCKED` \u5E76\u9644\u8BA1\u5212\uFF1B\u4E0D\u5F97\u81EA\u884C `delivery mode --set controlled` \u6216 `execute`\u3002",
9561
- "- `.hcm-delivery/project.yml` \u662F\u6BCF\u4EBA\u6BCF\u673A\u72B6\u6001\uFF0C\u4E0D\u63D0\u4EA4\uFF1B\u53EA\u6709 `\u73AF\u5883.yml` \u4E2D `controlled: true` \u4E14\u6EE1\u8DB3\u4E0A\u8FF0\u6388\u6743\u65F6\uFF0C\u624D\u80FD\u7528 `--approved-by` \u4E0E `--reason` \u7559\u4E0B\u6A21\u5F0F\u5207\u6362\u6536\u636E\uFF0C\u5B8C\u6210\u540E\u7ACB\u5373\u56DE\u5230 plan-only\u3002\u5BA1\u8BA1\u53C2\u6570\u4E0D\u80FD\u66FF\u4EE3\u771F\u5B9E\u6388\u6743\u3002",
9562
- "- \u53D8\u66F4/\u56DE\u6EDA\u8BF4\u660E\u653E CLI \u56FA\u5B9A\u7684 `work/` \u6216 `decisions/`\uFF0C\u6536\u636E\u653E `evidence/`\uFF1B\u5BA2\u6237\u5171\u4EAB\u6750\u6599\u5206\u522B\u5F52\u6863\u5230\u4E2D\u6587\u4E1A\u52A1\u76EE\u5F55\u3002",
9563
- "- \u9875\u9762\u9A8C\u6536\u7EDF\u4E00\u7528 `./page-acceptance.sh`\uFF1A\u663E\u5F0F\u4F20\u73AF\u5883\u3001\u8EAB\u4EFD\u3001\u7AD9\u5185\u8DEF\u5F84\u3001\u671F\u671B\u6587\u672C\u4E0E `\u8BC1\u636E/` \u4E0B\u7684 PNG \u8DEF\u5F84\uFF1B\u4E0D\u80FD\u53EA\u4EE5\u201C\u751F\u6210\u4E86\u622A\u56FE\u201D\u5224\u901A\u8FC7\u3002",
9564
- "- \u4EFB\u4F55\u51ED\u636E\u3001\u914D\u5BF9\u7801\u3001\u4EE4\u724C\u3001\u5BA2\u6237\u5BC6\u7801\u90FD\u4E0D\u5F97\u5199\u5165\u4ED3\u5E93\u3001\u547D\u4EE4\u53C2\u6570\u6216\u4EA4\u4ED8\u6587\u6863\u3002",
9565
- AGENT_END,
9566
- ""
9567
- ].join("\n");
9568
- }
9569
- function renderSetupSh(cliVersion) {
9570
- return [
9571
- "#!/usr/bin/env bash",
9572
- "set -euo pipefail",
9573
- "",
9574
- `expected_hcm_version=${JSON.stringify(cliVersion)}`,
9575
- 'actual_hcm_version="$(hcm --version 2>/dev/null || true)"',
9576
- 'if [[ "$actual_hcm_version" != "$expected_hcm_version" ]]; then',
9577
- ` printf '\u9700\u8981 hcm %s\uFF0C\u5F53\u524D\u662F %s\u3002\u5148\u6267\u884C\uFF1Anpm install --global @hcmai/cli@%s\\n' "$expected_hcm_version" "\${actual_hcm_version:-\u672A\u5B89\u88C5}" "$expected_hcm_version" >&2`,
9578
- " exit 1",
9579
- "fi",
9580
- "",
9581
- "node <<'HCM_PROJECT_SETUP'",
9582
- "const fs = require('node:fs');",
9583
- "const path = require('node:path');",
9584
- "const { spawnSync } = require('node:child_process');",
9585
- "",
9586
- "const project = process.cwd();",
9587
- "const environmentsFile = path.join(project, '\u73AF\u5883.yml');",
9588
- "const projectFile = path.join(project, '.hcm-delivery', 'project.yml');",
9589
- "const skillsLock = path.join(project, 'hcm-skills', '.hcm-skills.json');",
9590
- "const source = fs.readFileSync(environmentsFile, 'utf8');",
9591
- "const environments = parseEnvironments(source);",
9592
- "if (environments.length === 0) throw new Error('\u73AF\u5883.yml \u81F3\u5C11\u8981\u6709\u4E00\u4E2A\u73AF\u5883');",
9593
- "",
9594
- "const missingEnvironments = new Set();",
9595
- "for (const environment of environments) {",
9596
- " const probe = spawnSync('hcm', ['env', 'show', environment.alias], { encoding: 'utf8' });",
9597
- " if (probe.error) throw new Error(`\u65E0\u6CD5\u68C0\u67E5\u73AF\u5883 ${environment.alias}\uFF1A${probe.error.message}`);",
9598
- " if (probe.status === 0) {",
9599
- " const existing = parseExistingEnvironment(probe.stdout, environment.alias);",
9600
- " assertEnvironmentMatches(environment, existing);",
9601
- " process.stdout.write(`[setup] env ${environment.alias} \u5DF2\u5B58\u5728\u4E14\u4E0E \u73AF\u5883.yml \u4E00\u81F4\uFF0C\u4FDD\u7559\u672C\u673A\u8EAB\u4EFD\\n`);",
9602
- " continue;",
9603
- " }",
9604
- " if (/\\bENV_NOT_FOUND\\b/.test(probe.stderr)) {",
9605
- " missingEnvironments.add(environment.alias);",
9606
- " continue;",
9607
- " }",
9608
- " const detail = probe.stderr.trim() || `\u9000\u51FA\u7801 ${probe.status ?? 'unknown'}`;",
9609
- " throw new Error(`\u65E0\u6CD5\u68C0\u67E5\u73AF\u5883 ${environment.alias}\uFF1A${detail}`);",
9610
- "}",
9611
- "",
9612
- "let projectInitialized = fs.existsSync(projectFile);",
9613
- "for (const environment of environments) {",
9614
- " if (missingEnvironments.has(environment.alias)) {",
9615
- " const add = ['env', 'add', environment.alias, '--endpoint', environment.endpoint];",
9616
- " if (environment.frontend) add.push('--frontend', environment.frontend);",
9617
- " if (environment.tenant) add.push('--tenant', environment.tenant);",
9618
- " run(add);",
9619
- " }",
9620
- " if (!projectInitialized) {",
9621
- " run(['delivery', 'init', '--project', project, '--env', environment.alias, '--mode', 'plan-only']);",
9622
- " projectInitialized = true;",
9623
- " } else {",
9624
- " run(['delivery', 'mode', '--project', project, '--env', environment.alias, '--set', 'plan-only']);",
9625
- " }",
9626
- "}",
9627
- "",
9628
- "if (!fs.existsSync(skillsLock)) {",
9629
- " run(['skills', 'install', '--all', '--target', 'codex', '--env', environments[0].alias]);",
9630
- "} else {",
9631
- " process.stdout.write('[setup] \u5DF2\u6709 hcm-skills \u9501\uFF0C\u6309\u4ED3\u5E93\u7248\u672C\u4F7F\u7528\uFF1B\u5347\u7EA7\u6280\u80FD\u8BF7\u53E6\u8D70 PR\\n');",
9632
- "}",
9633
- 'process.stdout.write("[setup] \u5B8C\u6210\u3002\u4E0B\u4E00\u6B65\uFF1A\u9010\u4E2A\u6267\u884C hcm login --env <alias> --code <\u914D\u5BF9\u7801> --name <\u4F60\u7684\u540D\u5B57>-<alias>\\n");',
9634
- "",
9635
- "function run(args) {",
9636
- " const result = spawnSync('hcm', args, { cwd: project, stdio: 'inherit' });",
9637
- " if (result.error) throw new Error(`\u65E0\u6CD5\u6267\u884C hcm ${args.join(' ')}\uFF1A${result.error.message}`);",
9638
- " if (result.status !== 0) process.exit(result.status ?? 1);",
9639
- "}",
9640
- "",
9641
- "function parseEnvironments(text) {",
9642
- " const result = [];",
9643
- " let current = null;",
9644
- " let inEnvironments = false;",
9645
- " for (const [offset, rawLine] of text.split(/\\r?\\n/).entries()) {",
9646
- " const lineNo = offset + 1;",
9647
- ' if (!rawLine.trim() || rawLine.trimStart().startsWith("#")) continue;',
9648
- " if (/^schemaVersion:\\s*1\\s*$/.test(rawLine)) continue;",
9649
- " if (/^environments:\\s*$/.test(rawLine)) { inEnvironments = true; continue; }",
9650
- " if (!inEnvironments) throw new Error(`\u73AF\u5883.yml \u7B2C ${lineNo} \u884C\u4E0D\u5C5E\u4E8E environments`);",
9651
- " const first = rawLine.match(/^ {2}- alias:\\s*(.+)$/);",
9652
- " if (first) {",
9653
- " if (current) result.push(validateEnvironment(current, lineNo));",
9654
- " current = { alias: scalar(first[1], lineNo) };",
9655
- " continue;",
9656
- " }",
9657
- " const field = rawLine.match(/^ {4}(endpoint|frontend|tenant|controlled|owner):\\s*(.+)$/);",
9658
- " if (!field || !current) throw new Error(`\u73AF\u5883.yml \u7B2C ${lineNo} \u884C\u4E0D\u7B26\u5408\u811A\u624B\u67B6\u683C\u5F0F`);",
9659
- " current[field[1]] = scalar(field[2], lineNo);",
9660
- " }",
9661
- " if (current) result.push(validateEnvironment(current, text.split(/\\r?\\n/).length));",
9662
- " return result;",
9663
- "}",
9664
- "",
9665
- "function scalar(raw, lineNo) {",
9666
- " const value = raw.trim();",
9667
- ` if (value.startsWith('"')) {`,
9668
- " try { return JSON.parse(value); } catch { throw new Error(`\u73AF\u5883.yml \u7B2C ${lineNo} \u884C\u7684\u53CC\u5F15\u53F7\u503C\u975E\u6CD5`); }",
9669
- " }",
9670
- ` if (value.startsWith("'") && value.endsWith("'")) return value.slice(1, -1).replace(/''/g, "'");`,
9671
- ' const plain = value.replace(/\\s+#.*$/, "").trim();',
9672
- ' if (plain === "true") return true;',
9673
- ' if (plain === "false") return false;',
9674
- " return plain;",
9675
- "}",
9676
- "",
9677
- "function validateEnvironment(environment, lineNo) {",
9678
- ' for (const key of ["alias", "endpoint"]) {',
9679
- ' if (typeof environment[key] !== "string" || !environment[key].trim()) {',
9680
- " throw new Error(`\u73AF\u5883.yml \u622A\u81F3\u7B2C ${lineNo} \u884C\u7F3A\u5C11 ${key}`);",
9681
- " }",
9682
- " }",
9683
- ' if (environment.endpoint === "REPLACE_ME") {',
9684
- " throw new Error(`\u73AF\u5883 ${environment.alias} \u7684 endpoint \u4ECD\u662F REPLACE_ME\uFF0C\u8BF7\u5148\u7F16\u8F91 \u73AF\u5883.yml`);",
9685
- " }",
9686
- " if (environment.controlled !== true && environment.controlled !== false) {",
9687
- " throw new Error(`\u73AF\u5883 ${environment.alias} \u7684 controlled \u5FC5\u987B\u662F true \u6216 false`);",
9688
- " }",
9689
- ' for (const key of ["frontend", "tenant"]) {',
9690
- ' if (environment[key] !== undefined && typeof environment[key] !== "string") {',
9691
- " environment[key] = String(environment[key]);",
9692
- " }",
9693
- " }",
9694
- " return environment;",
9695
- "}",
9696
- "",
9697
- "function parseExistingEnvironment(text, alias) {",
9698
- " const result = {};",
9699
- " for (const [offset, rawLine] of text.split(/\\r?\\n/).entries()) {",
9700
- ' if (!rawLine.trim() || rawLine.startsWith(" ") || rawLine.trimStart().startsWith("#")) continue;',
9701
- " const field = rawLine.match(/^(endpoint|frontend|tenantId):\\s*(.+)$/);",
9702
- " if (field) result[field[1]] = scalar(field[2], offset + 1);",
9703
- " }",
9704
- ' if (typeof result.endpoint !== "string" || !result.endpoint) {',
9705
- " throw new Error(`hcm env show ${alias} \u672A\u8FD4\u56DE\u6709\u6548 endpoint\uFF0C\u62D2\u7EDD\u7EE7\u7EED`);",
9706
- " }",
9707
- " return result;",
9708
- "}",
9709
- "",
9710
- "function assertEnvironmentMatches(expected, actual) {",
9711
- " const fields = [",
9712
- ' ["endpoint", expected.endpoint, actual.endpoint],',
9713
- ' ["frontend", expected.frontend ?? "", actual.frontend ?? ""],',
9714
- ' ["tenant", expected.tenant ?? "1", actual.tenantId ?? "1"],',
9715
- " ];",
9716
- " const mismatches = fields",
9717
- " .filter(([, wanted, found]) => String(wanted) !== String(found))",
9718
- " .map(([name, wanted, found]) => `${name}: \u9879\u76EE=${JSON.stringify(wanted)} \u672C\u673A=${JSON.stringify(found)}`);",
9719
- " if (mismatches.length === 0) return;",
9720
- " throw new Error(",
9721
- ' `\u73AF\u5883 ${expected.alias} \u5DF2\u5B58\u5728\uFF0C\u4F46\u672C\u673A\u914D\u7F6E\u4E0E \u73AF\u5883.yml \u4E0D\u4E00\u81F4\uFF1A${mismatches.join("\uFF1B")}\u3002` +',
9722
- ' "\u4E3A\u4FDD\u62A4\u672C\u673A\u5DF2\u6709\u8EAB\u4EFD\uFF0Csetup.sh \u4E0D\u4F1A\u7528 --force \u8986\u76D6\uFF1B\u8BF7\u6838\u5BF9\u540E\u663E\u5F0F\u4FEE\u6B63\u672C\u673A\u73AF\u5883\u6216 \u73AF\u5883.yml\u3002",',
9723
- " );",
9724
- "}",
9725
- "HCM_PROJECT_SETUP",
9726
- ""
9727
- ].join("\n");
9728
- }
9729
- function mergeDeliveryGitignore(existing) {
9730
- const block = [
9731
- GITIGNORE_BEGIN,
9732
- ".hcm-delivery/project.yml",
9733
- ".hcm-delivery/execution-plans/",
9734
- ".hcm-delivery/execution-claims/",
9735
- GITIGNORE_END
9736
- ].join("\n");
9737
- return upsertBlock(existing, GITIGNORE_BEGIN, GITIGNORE_END, block);
9738
- }
9739
- function mergeAgentInstructions(existing) {
9740
- return upsertBlock(
9741
- existing,
9742
- AGENT_BEGIN,
9743
- AGENT_END,
9744
- renderAgentInstructions().trimEnd()
9745
- );
9746
- }
9747
- async function scaffoldDeliveryProject(root, options) {
9748
- const result = { created: [], updated: [], preserved: [] };
9749
- for (const directory of DELIVERY_PROJECT_DIRECTORIES) {
9750
- const absolute = path6.join(root, directory);
9751
- await ensureDirectory(absolute);
9752
- await writeIfAbsent(path6.join(absolute, ".gitkeep"), "", result, `${directory}/.gitkeep`);
9753
- }
9754
- await writeIfAbsent(
9755
- path6.join(root, "\u73AF\u5883.yml"),
9756
- renderEnvironmentYml(options.environment, options.environmentConfig, options.initialMode),
9757
- result,
9758
- "\u73AF\u5883.yml"
9759
- );
9760
- const setupFile = path6.join(root, "setup.sh");
9761
- const setupCreated = await writeIfAbsent(
9762
- setupFile,
9763
- renderSetupSh(options.cliVersion),
9764
- result,
9765
- "setup.sh",
9766
- 493
9767
- );
9768
- if (setupCreated) await fs6.chmod(setupFile, 493);
9769
- const pageAcceptanceFile = path6.join(root, "page-acceptance.sh");
9770
- const pageAcceptanceCreated = await writeIfAbsent(
9771
- pageAcceptanceFile,
9772
- renderPageAcceptanceSh(),
9773
- result,
9774
- "page-acceptance.sh",
9775
- 493
9776
- );
9777
- if (pageAcceptanceCreated) await fs6.chmod(pageAcceptanceFile, 493);
9778
- await mergeManagedFile(path6.join(root, "AGENTS.md"), mergeAgentInstructions, result, "AGENTS.md");
9779
- await mergeManagedFile(path6.join(root, "CLAUDE.md"), mergeAgentInstructions, result, "CLAUDE.md");
9780
- await mergeManagedFile(path6.join(root, ".gitignore"), mergeDeliveryGitignore, result, ".gitignore");
9781
- return result;
9782
- }
9783
- async function mergeManagedFile(file, merge, result, relative2) {
9784
- const existing = await readRegularFile(file);
9785
- const next = merge(existing ?? "");
9786
- if (existing === next) {
9787
- result.preserved.push(relative2);
9788
- return;
9789
- }
9790
- await fs6.writeFile(file, next, { encoding: "utf8", mode: 420 });
9791
- (existing === null ? result.created : result.updated).push(relative2);
9792
- }
9793
- async function writeIfAbsent(file, content, result, relative2, mode = 420) {
9794
- try {
9795
- await fs6.writeFile(file, content, { encoding: "utf8", mode, flag: "wx" });
9796
- result.created.push(relative2);
9797
- return true;
9798
- } catch (cause) {
9799
- if (cause.code !== "EEXIST") throw cause;
9800
- await assertRegularFile(file);
9801
- result.preserved.push(relative2);
9802
- return false;
9803
- }
9804
- }
9805
- async function ensureDirectory(directory) {
9806
- await fs6.mkdir(directory, { recursive: true });
9807
- const stat = await fs6.lstat(directory);
9808
- if (!stat.isDirectory() || stat.isSymbolicLink()) {
9809
- throw new Error(`\u811A\u624B\u67B6\u8DEF\u5F84\u4E0D\u662F\u666E\u901A\u76EE\u5F55\uFF1A${directory}`);
9810
- }
9811
- }
9812
- async function readRegularFile(file) {
9813
- try {
9814
- await assertRegularFile(file);
9815
- return await fs6.readFile(file, "utf8");
9816
- } catch (cause) {
9817
- if (cause.code === "ENOENT") return null;
9818
- throw cause;
9819
- }
9820
- }
9821
- async function assertRegularFile(file) {
9822
- const stat = await fs6.lstat(file);
9823
- if (!stat.isFile() || stat.isSymbolicLink()) {
9824
- throw new Error(`\u811A\u624B\u67B6\u8DEF\u5F84\u4E0D\u662F\u666E\u901A\u6587\u4EF6\uFF1A${file}`);
9825
- }
9826
- }
9827
- function upsertBlock(existing, begin, end, block) {
9828
- const start = existing.indexOf(begin);
9829
- const finish2 = existing.indexOf(end);
9830
- const markersAreMalformed = start < 0 !== finish2 < 0 || start >= 0 && (finish2 < start || existing.lastIndexOf(begin) !== start || existing.lastIndexOf(end) !== finish2);
9831
- if (markersAreMalformed) {
9832
- throw new Error(`\u6258\u7BA1\u5757\u6807\u8BB0\u635F\u574F\u6216\u91CD\u590D\uFF0C\u62D2\u7EDD\u8986\u76D6\uFF1A${begin} \u2026 ${end}`);
9833
- }
9834
- let next;
9835
- if (start >= 0 && finish2 >= start) {
9836
- next = `${existing.slice(0, start)}${block}${existing.slice(finish2 + end.length)}`;
9837
- } else {
9838
- const prefix = existing.trimEnd();
9839
- next = `${prefix}${prefix ? "\n\n" : ""}${block}`;
9840
- }
9841
- return `${next.trimEnd()}
9842
- `;
9843
- }
9844
-
9845
- // src/commands/delivery-mode-approval.ts
9846
- import { randomUUID } from "crypto";
9847
- import { promises as fs7 } from "fs";
9848
- import path7 from "path";
9849
- function requireControlledModeApproval(mode, approvedBy, reason) {
9850
- if (mode !== "controlled") return null;
9851
- const approver = approvedBy?.trim() ?? "";
9852
- const approvalReason = reason?.trim() ?? "";
9853
- if (!approver || !approvalReason) {
9854
- throw new Error(
9855
- "\u5207\u6362\u5230 controlled \u5FC5\u987B\u540C\u65F6\u4F20 --approved-by <\u9879\u76EE\u8D1F\u8D23\u4EBA> \u4E0E --reason <\u672C\u6B21\u660E\u786E\u6388\u6743\u4F9D\u636E>\u3002\u6388\u6743\u5FC5\u987B\u6765\u81EA\u9879\u76EE\u8D1F\u8D23\u4EBA\u5728\u672C\u6B21\u5BF9\u8BDD\u6216\u4EFB\u52A1\u4E66\u4E2D\u7684\u660E\u786E\u6279\u51C6\uFF1B\u5BA2\u6237\u53E3\u5934\u6216\u7FA4\u6D88\u606F\u4E0D\u662F\u6267\u884C\u6388\u6743"
9856
- );
9857
- }
9858
- return { approvedBy: approver, reason: approvalReason };
9859
- }
9860
- async function setDeliveryModeWithReceipt(input) {
9861
- const approval = requireControlledModeApproval(input.mode, input.approvedBy, input.reason);
9862
- const root = path7.resolve(input.project);
9863
- const projectFile = path7.join(root, ".hcm-delivery", "project.yml");
9864
- const content = await fs7.readFile(projectFile, "utf8").catch((cause) => {
9865
- throw new Error(`\u9879\u76EE\u672A\u521D\u59CB\u5316\uFF1A\u627E\u4E0D\u5230 ${projectFile}
9866
- \u4E0B\u4E00\u6B65\uFF1Ahcm delivery init`, {
9867
- cause
9868
- });
9869
- });
9870
- const update = setDeliveryModeForEnvironment(content, input.environment, input.mode);
9871
- const changed = (input.now ?? (() => /* @__PURE__ */ new Date()))();
9872
- if (Number.isNaN(changed.getTime())) throw new Error("\u5F53\u524D\u65F6\u95F4\u65E0\u6548");
9873
- let receiptFile = null;
9874
- if (approval) {
9875
- const relativeDirectory = path7.join("evidence", "delivery-mode");
9876
- await ensureReceiptDirectory(root);
9877
- const safeTime = changed.toISOString().replace(/[:.]/g, "-");
9878
- const id = (input.receiptId ?? randomUUID)();
9879
- if (!/^[a-zA-Z0-9-]+$/.test(id)) throw new Error("\u6A21\u5F0F\u5207\u6362\u6536\u636E ID \u975E\u6CD5");
9880
- receiptFile = path7.join(relativeDirectory, `${safeTime}-${id}.receipt.json`);
9881
- }
9882
- const receipt = {
9883
- schemaVersion: 1,
9884
- receiptType: "delivery-mode-change",
9885
- changedAt: changed.toISOString(),
9886
- project: root,
9887
- projectFile,
9888
- environment: input.environment,
9889
- previous: update.previous,
9890
- deliveryMode: input.mode,
9891
- canExecuteR2: input.mode === "controlled",
9892
- migratedLegacy: update.migratedLegacy,
9893
- approvedBy: approval?.approvedBy ?? null,
9894
- reason: approval?.reason ?? null,
9895
- receiptFile
9896
- };
9897
- await fs7.writeFile(projectFile, update.content, "utf8");
9898
- if (receiptFile) {
9899
- try {
9900
- await fs7.writeFile(path7.join(root, receiptFile), `${JSON.stringify(receipt, null, 2)}
9901
- `, {
9902
- encoding: "utf8",
9903
- mode: 384,
9904
- flag: "wx"
9905
- });
9906
- } catch (cause) {
9907
- try {
9908
- await fs7.writeFile(projectFile, content, "utf8");
9909
- } catch (rollbackCause) {
9910
- throw new Error(
9911
- `\u6A21\u5F0F\u5207\u6362\u6536\u636E\u5199\u5165\u5931\u8D25\uFF0C\u4E14 project.yml \u56DE\u6EDA\u5931\u8D25\uFF1A${String(rollbackCause.message)}`,
9912
- { cause }
9913
- );
9914
- }
9915
- throw new Error("\u6A21\u5F0F\u5207\u6362\u6536\u636E\u5199\u5165\u5931\u8D25\uFF1Bproject.yml \u5DF2\u56DE\u6EDA\uFF0C\u4ECD\u4FDD\u6301\u539F\u6A21\u5F0F", { cause });
9916
- }
9917
- }
9918
- return receipt;
9919
- }
9920
- async function ensureReceiptDirectory(root) {
9921
- const evidenceDirectory = path7.join(root, "evidence");
9922
- await ensurePlainDirectory(evidenceDirectory, false);
9923
- await ensurePlainDirectory(path7.join(evidenceDirectory, "delivery-mode"), true);
9924
- }
9925
- async function ensurePlainDirectory(directory, privateDirectory) {
9926
- let created = false;
9927
- try {
9928
- await fs7.mkdir(directory, { mode: privateDirectory ? 448 : 493 });
9929
- created = true;
9930
- } catch (cause) {
9931
- if (cause.code !== "EEXIST") throw cause;
9932
- }
9933
- const stat = await fs7.lstat(directory);
9934
- if (!stat.isDirectory() || stat.isSymbolicLink()) {
9935
- throw new Error(`\u6A21\u5F0F\u5207\u6362\u6536\u636E\u8DEF\u5F84\u4E0D\u662F\u666E\u901A\u76EE\u5F55\uFF1A${directory}`);
9936
- }
9937
- if (privateDirectory || created) {
9938
- await fs7.chmod(directory, privateDirectory ? 448 : 493);
9939
- }
9940
- }
9941
-
9942
- // src/commands/delivery-init.ts
9943
- function renderProjectYml(environment, mode) {
9944
- return [
9945
- "# HCM \u987E\u95EE\u4EA4\u4ED8\u9879\u76EE\u914D\u7F6E\uFF08hcm delivery init \u751F\u6210\uFF09",
9946
- "#",
9947
- "# deliveryMode \u6309\u76EE\u6807\u73AF\u5883\u51B3\u5B9A\u672C\u673A\u5141\u8BB8\u8D70\u5230\u54EA\u4E00\u6B65\uFF1A",
9948
- "# plan-only \u2014\u2014 \u53EA\u5141\u8BB8 assess / prepare \u51FA\u8BA1\u5212\uFF0Cexecute \u4E00\u5F8B\u62D2\u7EDD",
9949
- "# controlled \u2014\u2014 \u5141\u8BB8 prepare + execute \u5355\u6B21\u53D7\u63A7\u6267\u884C\uFF08\u4ECD\u9700\u9010\u6B21\u6279\u51C6\uFF09",
9950
- "#",
9951
- "# \u{1F534} \u5B83\u4E0D\u653E\u5BBD\u4EFB\u4F55\u98CE\u9669\u5224\u7EA7\uFF1AR3 \u5728\u4E24\u79CD\u6A21\u5F0F\u4E0B\u90FD\u62D2\u7EDD\uFF0CR2 \u4ECD\u8981\u8BA1\u5212\u3001\u56DE\u6EDA\u8BF4\u660E\u4E0E\u6536\u636E\u3002",
9952
- "# \u6539\u4E00\u4E2A\u73AF\u5883\u53EA\u5F71\u54CD\u8BE5\u73AF\u5883\uFF1B\u672A\u767B\u8BB0\u7684\u73AF\u5883 fail-closed\uFF0C\u4E0D\u7EE7\u627F\u5176\u5B83\u73AF\u5883\u7684 controlled\u3002",
9953
- "schemaVersion: 2",
9954
- "deliveryMode:",
9955
- ` ${JSON.stringify(environment)}: ${mode}`,
9956
- ""
9709
+ var GITIGNORE_END = "# <<< hcm delivery local state <<<";
9710
+ function mergeDeliveryGitignore(existing) {
9711
+ const block = [
9712
+ GITIGNORE_BEGIN,
9713
+ ".hcm-delivery/project.yml",
9714
+ ".hcm-delivery/execution-plans/",
9715
+ ".hcm-delivery/execution-claims/",
9716
+ GITIGNORE_END
9957
9717
  ].join("\n");
9718
+ return upsertBlock(existing, GITIGNORE_BEGIN, GITIGNORE_END, block);
9958
9719
  }
9959
- async function deliveryInitCommand(args) {
9960
- try {
9961
- const mode = args.mode ?? "plan-only";
9962
- if (!DELIVERY_MODES.includes(mode)) {
9963
- throw new Error(
9964
- `--mode \u53EA\u63A5\u53D7 ${DELIVERY_MODES.join(" | ")}\uFF0C\u6536\u5230 "${args.mode}"
9965
- \u8FD9\u4E24\u4E2A\u503C\u662F delivery prepare \u8BA4\u5F97\u7684\u5168\u90E8\uFF1B\u5199\u522B\u7684\u503C prepare \u4F1A\u62D2\u7EDD\u52A0\u8F7D\u3002`
9966
- );
9967
- }
9968
- const approval = requireControlledModeApproval(mode, args.approvedBy, args.reason);
9969
- const environment = await resolveDeliveryEnvironment(args.env);
9970
- const root = path8.resolve(args.project ?? ".");
9971
- const dir = path8.join(root, ".hcm-delivery");
9972
- const file = path8.join(dir, "project.yml");
9973
- let existed = false;
9974
- try {
9975
- await fs8.access(file);
9976
- existed = true;
9977
- } catch {
9978
- existed = false;
9979
- }
9980
- if (existed && !args.force) {
9981
- throw new Error(
9982
- `\u9879\u76EE\u914D\u7F6E\u5DF2\u5B58\u5728\uFF1A${file}
9983
- \u4E0D\u8986\u76D6\u5DF2\u6709\u914D\u7F6E\u2014\u2014\u5B83\u51B3\u5B9A\u672C\u9879\u76EE\u5141\u4E0D\u5141\u8BB8\u771F\u7684\u6267\u884C\u3002
9984
- \u786E\u8981\u91CD\u5199\uFF1Ahcm delivery init --force`
9985
- );
9986
- }
9987
- await fs8.mkdir(dir, { recursive: true });
9988
- await fs8.writeFile(file, renderProjectYml(environment, "plan-only"), "utf8");
9989
- const environmentConfig = await loadEnv9(environment).catch(() => null);
9990
- const scaffold = await scaffoldDeliveryProject(root, {
9991
- environment,
9992
- environmentConfig,
9993
- initialMode: mode,
9994
- cliVersion: CLI_VERSION
9995
- });
9996
- const modeReceipt = approval ? await setDeliveryModeWithReceipt({
9997
- project: root,
9998
- environment,
9999
- mode,
10000
- approvedBy: approval.approvedBy,
10001
- reason: approval.reason
10002
- }) : null;
10003
- const result = {
10004
- project: root,
10005
- projectFile: file,
10006
- environment,
10007
- deliveryMode: mode,
10008
- overwritten: existed,
10009
- scaffold,
10010
- ...modeReceipt ? { modeReceipt } : {},
10011
- nextStep: mode === "controlled" ? "hcm delivery assess <\u547D\u4EE4>\uFF1BR2 \u518D hcm delivery prepare --change-ref \u2026 --rollback-ref \u2026 --evidence-dir \u2026" : "hcm delivery assess <\u547D\u4EE4>\uFF1B\u672C\u9879\u76EE\u4E3A plan-only\uFF0Cexecute \u4F1A\u88AB\u62D2\u7EDD"
10012
- };
10013
- process.stdout.write(formatObject22(result, { format: args.output ?? "json" }) + "\n");
10014
- process.exitCode = 0;
9720
+ async function mergeManagedFile(file, merge, result, relative2) {
9721
+ const existing = await readRegularFile(file);
9722
+ const next = merge(existing ?? "");
9723
+ if (existing === next) {
9724
+ result.preserved.push(relative2);
10015
9725
  return;
10016
- } catch (e) {
10017
- exitWithError(e);
10018
- process.exit(1);
10019
9726
  }
9727
+ await fs8.writeFile(file, next, { encoding: "utf8", mode: 420 });
9728
+ (existing === null ? result.created : result.updated).push(relative2);
10020
9729
  }
10021
- async function deliveryModeCommand(args) {
9730
+ async function writeIfAbsent(file, content, result, relative2, mode = 420) {
10022
9731
  try {
10023
- const environment = requireDeliveryModeEnvironment(args.env);
10024
- const root = path8.resolve(args.project ?? ".");
10025
- const file = path8.join(root, ".hcm-delivery", "project.yml");
10026
- let content;
10027
- try {
10028
- content = await fs8.readFile(file, "utf8");
10029
- } catch {
10030
- throw new Error(
10031
- `\u9879\u76EE\u672A\u521D\u59CB\u5316\uFF1A\u627E\u4E0D\u5230 ${file}
10032
- \u4E0B\u4E00\u6B65\uFF1Ahcm delivery init`
10033
- );
10034
- }
10035
- if (!args.set) {
10036
- const current = deliveryModeForEnvironment(content, environment);
10037
- process.stdout.write(
10038
- formatObject22(
10039
- {
10040
- project: root,
10041
- projectFile: file,
10042
- environment,
10043
- deliveryMode: current,
10044
- canExecuteR2: current === "controlled",
10045
- ...current === "plan-only" ? { note: "plan-only \u53EA\u51FA\u8BA1\u5212\u4E0D\u6267\u884C\uFF1Bexecute \u4F1A\u62D2\u7EDD R2 \u8BA1\u5212" } : current === null ? {
10046
- note: `\u73AF\u5883 ${environment} \u5C1A\u672A\u767B\u8BB0\u4EA4\u4ED8\u6A21\u5F0F\uFF1Bfail-closed\u3002\u5148\u6267\u884C hcm delivery mode --env ${environment} --set plan-only`
10047
- } : {}
10048
- },
10049
- { format: args.output ?? "json" }
10050
- ) + "\n"
10051
- );
10052
- process.exitCode = 0;
10053
- return;
10054
- }
10055
- const next = args.set;
10056
- if (!DELIVERY_MODES.includes(next)) {
10057
- throw new Error(`--set \u53EA\u63A5\u53D7 ${DELIVERY_MODES.join(" | ")}\uFF0C\u6536\u5230 "${args.set}"`);
10058
- }
10059
- const receipt = await setDeliveryModeWithReceipt({
10060
- project: root,
10061
- environment,
10062
- mode: next,
10063
- approvedBy: args.approvedBy,
10064
- reason: args.reason
10065
- });
10066
- process.stdout.write(
10067
- formatObject22(receipt, { format: args.output ?? "json" }) + "\n"
10068
- );
10069
- process.exitCode = 0;
10070
- return;
10071
- } catch (e) {
10072
- exitWithError(e);
10073
- process.exit(1);
9732
+ await fs8.writeFile(file, content, { encoding: "utf8", mode, flag: "wx" });
9733
+ result.created.push(relative2);
9734
+ return true;
9735
+ } catch (cause) {
9736
+ if (cause.code !== "EEXIST") throw cause;
9737
+ await assertRegularFile(file);
9738
+ result.preserved.push(relative2);
9739
+ return false;
10074
9740
  }
10075
9741
  }
10076
- function requireDeliveryModeEnvironment(envFlag) {
10077
- const environment = envFlag?.trim();
10078
- if (!environment) {
10079
- throw new Error(
10080
- "hcm delivery mode \u5FC5\u987B\u663E\u5F0F\u4F20 --env <\u73AF\u5883\u522B\u540D>\uFF1B\u9879\u76EE\u4EA4\u4ED8\u6A21\u5F0F\u4E0D\u7EE7\u627F\u5168\u5C40 activeEnv\uFF0C\u907F\u514D\u67E5\u770B\u6216\u4FEE\u6539\u9519\u8BEF\u73AF\u5883"
10081
- );
9742
+ async function ensureDirectory(directory) {
9743
+ await fs8.mkdir(directory, { recursive: true });
9744
+ const stat = await fs8.lstat(directory);
9745
+ if (!stat.isDirectory() || stat.isSymbolicLink()) {
9746
+ throw new Error(`\u811A\u624B\u67B6\u8DEF\u5F84\u4E0D\u662F\u666E\u901A\u76EE\u5F55\uFF1A${directory}`);
10082
9747
  }
10083
- return environment;
10084
9748
  }
10085
- async function resolveDeliveryEnvironment(envFlag) {
10086
- const global = await loadGlobalConfig9();
10087
- const environment = resolveActiveEnv5({ envFlag }, process.env, global);
10088
- if (!environment.trim()) throw new Error("\u65E0\u6CD5\u89E3\u6790\u76EE\u6807\u73AF\u5883\uFF1B\u8BF7\u4F20 --env <\u73AF\u5883\u522B\u540D>");
10089
- return environment;
9749
+ async function readRegularFile(file) {
9750
+ try {
9751
+ await assertRegularFile(file);
9752
+ return await fs8.readFile(file, "utf8");
9753
+ } catch (cause) {
9754
+ if (cause.code === "ENOENT") return null;
9755
+ throw cause;
9756
+ }
10090
9757
  }
10091
-
10092
- // src/commands/delivery-doctor.ts
10093
- init_auth_guard();
10094
- init_exit();
10095
- import {
10096
- HcmClient as HcmClient21,
10097
- fetchReconIdentity,
10098
- formatObject as formatObject23,
10099
- fromAxiosError as fromAxiosError21,
10100
- httpProbe,
10101
- runDoctor
10102
- } from "@hcmai/sdk";
10103
- var DEFAULT_CAPABILITIES = "default";
10104
- function render2(report) {
10105
- const lines = [];
10106
- for (const c of report.checks) {
10107
- lines.push(`${c.ok ? "\u2705" : "\u274C"} ${c.anchor.padEnd(13)} ${c.detail}`);
9758
+ async function assertRegularFile(file) {
9759
+ const stat = await fs8.lstat(file);
9760
+ if (!stat.isFile() || stat.isSymbolicLink()) {
9761
+ throw new Error(`\u811A\u624B\u67B6\u8DEF\u5F84\u4E0D\u662F\u666E\u901A\u6587\u4EF6\uFF1A${file}`);
10108
9762
  }
10109
- lines.push("");
10110
- lines.push(
10111
- report.ok ? "\u56DB\u6761\u951A\u70B9\u5168\u7EFF\uFF1A\u53EF\u4EE5\u5F00\u59CB recon\u3002" : "\u6709\u951A\u70B9\u6CA1\u8FC7\u2014\u2014\u5148\u6309\u4E0A\u9762\u5404\u6761\u7684\u4E0B\u4E00\u6B65\u5904\u7406\uFF0C\u4E0D\u8981\u5728\u8FD9\u4E2A\u72B6\u6001\u4E0A\u722C\u57FA\u7EBF\u3002"
10112
- );
10113
- return lines.join("\n");
10114
9763
  }
10115
- async function deliveryDoctorCommand(args) {
10116
- try {
10117
- const ctx = await getActiveAuthContextFromCli(args);
10118
- const client3 = HcmClient21.fromAuthContext(ctx);
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);
10122
- const fmt = args.output ?? "json";
10123
- if (fmt !== "json") process.stdout.write(render2(report) + "\n");
10124
- process.stdout.write(formatObject23(report, { format: fmt }) + "\n");
10125
- process.exitCode = report.ok ? 0 : 1;
10126
- return;
10127
- } catch (e) {
10128
- const err = e;
10129
- if (err?.isAxiosError) exitWithError(fromAxiosError21(err, args.env));
10130
- exitWithError(e);
10131
- process.exit(1);
9764
+ function upsertBlock(existing, begin, end, block) {
9765
+ const start = existing.indexOf(begin);
9766
+ const finish2 = existing.indexOf(end);
9767
+ const markersAreMalformed = start < 0 !== finish2 < 0 || start >= 0 && (finish2 < start || existing.lastIndexOf(begin) !== start || existing.lastIndexOf(end) !== finish2);
9768
+ if (markersAreMalformed) {
9769
+ throw new Error(`\u6258\u7BA1\u5757\u6807\u8BB0\u635F\u574F\u6216\u91CD\u590D\uFF0C\u62D2\u7EDD\u8986\u76D6\uFF1A${begin} \u2026 ${end}`);
9770
+ }
9771
+ let next;
9772
+ if (start >= 0 && finish2 >= start) {
9773
+ next = `${existing.slice(0, start)}${block}${existing.slice(finish2 + end.length)}`;
9774
+ } else {
9775
+ const prefix = existing.trimEnd();
9776
+ next = `${prefix}${prefix ? "\n\n" : ""}${block}`;
10132
9777
  }
9778
+ return `${next.trimEnd()}
9779
+ `;
10133
9780
  }
10134
9781
 
10135
- // src/commands/chiron-init.ts
10136
- init_auth_guard();
10137
- init_exit();
10138
- import { promises as fs11 } from "fs";
10139
- import path11 from "path";
10140
- import {
10141
- CliError as CliError21,
10142
- CliErrorCode as CliErrorCode20,
10143
- HcmClient as HcmClient22,
10144
- fetchReconIdentity as fetchReconIdentity2,
10145
- formatObject as formatObject24,
10146
- httpProbe as httpProbe2,
10147
- isTempEnv as isTempEnv3,
10148
- listIdentities as listIdentities5,
10149
- loadEnv as loadEnv11,
10150
- loadGlobalConfig as loadGlobalConfig11
10151
- } from "@hcmai/sdk";
10152
-
10153
9782
  // src/commands/chiron-project.ts
10154
9783
  import { promises as fs10 } from "fs";
10155
9784
  import os5 from "os";
10156
- import path10 from "path";
9785
+ import path9 from "path";
10157
9786
  import { spawnSync } from "child_process";
10158
- import { hcmConfigDir, listEnvs as listEnvs3, listIdentities as listIdentities4, loadEnv as loadEnv10, loadGlobalConfig as loadGlobalConfig10 } from "@hcmai/sdk";
9787
+ import { hcmConfigDir, listEnvs as listEnvs3, listIdentities as listIdentities4, loadEnv as loadEnv9, loadGlobalConfig as loadGlobalConfig9 } from "@hcmai/sdk";
10159
9788
 
10160
9789
  // src/jira/client.ts
10161
9790
  import { execFileSync } from "child_process";
10162
9791
  import { promises as fs9 } from "fs";
10163
9792
  import os4 from "os";
10164
- import path9 from "path";
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");
9793
+ import path8 from "path";
9794
+
9795
+ // src/internal-endpoints.ts
9796
+ var env = (key2, fallback) => {
9797
+ const v = process.env[key2];
9798
+ return v && v.trim() ? v.trim() : fallback;
9799
+ };
9800
+ var trimSlash = (u) => u.replace(/\/+$/, "");
9801
+ var JIRA_BASE = trimSlash(env("JIRA_BASE", "https://jira.hcmcloud.cn"));
9802
+ var JIRA_PROJECT = env("JIRA_PROJECT", "HCMNX");
9803
+ var JIRA_KEYCHAIN = env("JIRA_KEYCHAIN_SERVICE", "jira-hcmcloud");
9804
+ var CNB_ORIGIN = trimSlash(env("HCM_CNB_ORIGIN", "https://cnb.cool"));
9805
+ var CASES_REPO_SLUG = env("HCM_CASES_REPO", "hcm/chiron-cases");
9806
+ var CASES_REPO_URL = `${CNB_ORIGIN}/${CASES_REPO_SLUG}.git`;
9807
+ var repoIssueUrl = (repo, number) => `${CNB_ORIGIN}/${repo}/-/issues/${number}`;
9808
+ var CNB_FAVICON_URL = `${CNB_ORIGIN}/favicon.ico`;
9809
+
9810
+ // src/jira/client.ts
9811
+ var JIRA_TOKEN_FILE = () => process.env.JIRA_TOKEN_FILE || path8.join(os4.homedir(), ".config", "hcm", "jira-token");
10169
9812
  async function jiraTokenSource() {
10170
9813
  if (process.env.JIRA_TOKEN?.trim()) return { token: process.env.JIRA_TOKEN.trim(), from: "\u73AF\u5883\u53D8\u91CF JIRA_TOKEN" };
10171
9814
  const file = JIRA_TOKEN_FILE();
@@ -10328,7 +9971,7 @@ var JiraClient = class {
10328
9971
  body: {
10329
9972
  globalId: url,
10330
9973
  relationship,
10331
- object: { url, title, icon: { url16x16: "https://cnb.cool/favicon.ico", title: "cnb" } }
9974
+ object: { url, title, icon: { url16x16: CNB_FAVICON_URL, title: "cnb" } }
10332
9975
  }
10333
9976
  });
10334
9977
  }
@@ -10352,7 +9995,6 @@ async function createJiraClient(opts = {}) {
10352
9995
  // src/commands/chiron-project.ts
10353
9996
  var ENV_FILE = "env.yaml";
10354
9997
  var SKILLS_DIR = "hcm-skills";
10355
- var CASES_REPO_URL = "https://cnb.cool/hcm/chiron-cases.git";
10356
9998
  var CASES_MCP_NAME = "chiron-cases";
10357
9999
  var CHIRON_PROJECT_DIRECTORIES = [
10358
10000
  "work",
@@ -10364,13 +10006,13 @@ var CHIRON_PROJECT_DIRECTORIES = [
10364
10006
  "gaps",
10365
10007
  "customer-docs"
10366
10008
  ];
10367
- function renderEnvYaml(env2) {
10009
+ function renderEnvYaml(env3) {
10368
10010
  return [
10369
10011
  "# \u9879\u76EE\u73AF\u5883\uFF08hcm chiron init \u751F\u6210\uFF0C\u968F\u4ED3\u5E93\u63D0\u4EA4\uFF1B\u4E0D\u653E\u8EAB\u4EFD\u3001\u4E0D\u653E\u51ED\u636E\uFF09",
10370
10012
  "# \u767B\u5F55\uFF1Ahcm login <endpoint> --code <\u914D\u5BF9\u7801> \u6838\u5BF9\uFF1Ahcm chiron doctor",
10371
- `endpoint: ${JSON.stringify(env2.endpoint)}`,
10372
- `frontend: ${JSON.stringify(env2.frontend)}`,
10373
- `tenant: ${JSON.stringify(env2.tenant)}`,
10013
+ `endpoint: ${JSON.stringify(env3.endpoint)}`,
10014
+ `frontend: ${JSON.stringify(env3.frontend)}`,
10015
+ `tenant: ${JSON.stringify(env3.tenant)}`,
10374
10016
  ""
10375
10017
  ].join("\n");
10376
10018
  }
@@ -10415,12 +10057,12 @@ async function findEnvByEndpoint(endpoint, tenant2) {
10415
10057
  const wanted = normalizeOrigin(endpoint);
10416
10058
  const matches2 = [];
10417
10059
  for (const name of await listEnvs3().catch(() => [])) {
10418
- const config2 = await loadEnv10(name).catch(() => null);
10060
+ const config2 = await loadEnv9(name).catch(() => null);
10419
10061
  if (!config2 || normalizeOrigin(config2.endpoint) !== wanted) continue;
10420
10062
  matches2.push({ name, config: config2, hasIdentity: (await listIdentities4(name).catch(() => [])).length > 0 });
10421
10063
  }
10422
10064
  if (matches2.length === 0) return null;
10423
- const active = (await loadGlobalConfig10().catch(() => null))?.activeEnv;
10065
+ const active = (await loadGlobalConfig9().catch(() => null))?.activeEnv;
10424
10066
  const usable = matches2.filter((m) => m.hasIdentity);
10425
10067
  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];
10426
10068
  return { name: pick2.name, config: pick2.config };
@@ -10448,14 +10090,14 @@ function mergeChironAgentInstructions(existing) {
10448
10090
  return upsertBlock(existing, AGENT_BEGIN, AGENT_END, renderChironAgentInstructions().trimEnd());
10449
10091
  }
10450
10092
  function caseLibraryDir() {
10451
- return path10.join(hcmConfigDir(), CASES_MCP_NAME);
10093
+ return path9.join(hcmConfigDir(), CASES_MCP_NAME);
10452
10094
  }
10453
10095
  function codexConfigFile() {
10454
- return path10.join(process.env.HOME ?? os5.homedir(), ".codex", "config.toml");
10096
+ return path9.join(process.env.HOME ?? os5.homedir(), ".codex", "config.toml");
10455
10097
  }
10456
10098
  function renderCodexMcpSection(repo, envName, binPath = process.env.PATH ?? "") {
10457
- const server = path10.join(repo, "mcp", "server.mjs");
10458
- const env2 = [
10099
+ const server = path9.join(repo, "mcp", "server.mjs");
10100
+ const env3 = [
10459
10101
  `CASES_REPO = ${JSON.stringify(repo)}`,
10460
10102
  `HCM_ENV = ${JSON.stringify(envName)}`,
10461
10103
  ...binPath ? [`PATH = ${JSON.stringify(binPath)}`] : []
@@ -10464,7 +10106,7 @@ function renderCodexMcpSection(repo, envName, binPath = process.env.PATH ?? "")
10464
10106
  `[mcp_servers.${CASES_MCP_NAME}]`,
10465
10107
  'command = "node"',
10466
10108
  `args = [${JSON.stringify(server)}]`,
10467
- `env = { ${env2} }`,
10109
+ `env = { ${env3} }`,
10468
10110
  ""
10469
10111
  ].join("\n");
10470
10112
  }
@@ -10517,13 +10159,13 @@ async function ensureCaseLibrary(envName, deps = defaultCaseLibraryDeps, paths =
10517
10159
  const repo = paths.repo ?? caseLibraryDir();
10518
10160
  const codexConfig = paths.codexConfig ?? codexConfigFile();
10519
10161
  const status = { ok: false, repo, step: "present", serverInstalled: false, codexWired: false };
10520
- const hasGit = await exists2(path10.join(repo, ".git"));
10162
+ const hasGit = await exists2(path9.join(repo, ".git"));
10521
10163
  if (hasGit) {
10522
10164
  const pull = deps.git(["pull", "--ff-only", "--quiet"], repo);
10523
10165
  status.step = pull.status === 0 ? "updated" : "present";
10524
10166
  if (pull.status !== 0) status.reason = `\u66F4\u65B0\u5931\u8D25\uFF0C\u6CBF\u7528\u672C\u5730\u7248\u672C\uFF1A${firstLine(pull.stderr, pull.error)}`;
10525
10167
  } else {
10526
- await fs10.mkdir(path10.dirname(repo), { recursive: true });
10168
+ await fs10.mkdir(path9.dirname(repo), { recursive: true });
10527
10169
  const clone = deps.git(["clone", "--depth", "1", "--quiet", CASES_REPO_URL, repo]);
10528
10170
  if (clone.status !== 0) {
10529
10171
  status.step = "clone-failed";
@@ -10532,13 +10174,13 @@ async function ensureCaseLibrary(envName, deps = defaultCaseLibraryDeps, paths =
10532
10174
  }
10533
10175
  status.step = "cloned";
10534
10176
  }
10535
- const mcpDir = path10.join(repo, "mcp");
10536
- if (!await exists2(path10.join(mcpDir, "server.mjs"))) {
10177
+ const mcpDir = path9.join(repo, "mcp");
10178
+ if (!await exists2(path9.join(mcpDir, "server.mjs"))) {
10537
10179
  status.step = "install-failed";
10538
10180
  status.reason = `\u6848\u4F8B\u5E93\u91CC\u6CA1\u6709 mcp/server.mjs\uFF1A${mcpDir}`;
10539
10181
  return status;
10540
10182
  }
10541
- if (!await exists2(path10.join(mcpDir, "node_modules", "@modelcontextprotocol"))) {
10183
+ if (!await exists2(path9.join(mcpDir, "node_modules", "@modelcontextprotocol"))) {
10542
10184
  const install = deps.npmInstall(mcpDir);
10543
10185
  if (install.status !== 0) {
10544
10186
  status.step = "install-failed";
@@ -10547,7 +10189,7 @@ async function ensureCaseLibrary(envName, deps = defaultCaseLibraryDeps, paths =
10547
10189
  }
10548
10190
  }
10549
10191
  status.serverInstalled = true;
10550
- await fs10.mkdir(path10.dirname(codexConfig), { recursive: true });
10192
+ await fs10.mkdir(path9.dirname(codexConfig), { recursive: true });
10551
10193
  const existing = await fs10.readFile(codexConfig, "utf8").catch(() => "");
10552
10194
  const next = mergeCodexMcpConfig(existing, renderCodexMcpSection(repo, envName));
10553
10195
  if (next !== existing) await fs10.writeFile(codexConfig, next, "utf8");
@@ -10558,8 +10200,8 @@ async function ensureCaseLibrary(envName, deps = defaultCaseLibraryDeps, paths =
10558
10200
  async function inspectCaseLibrary(paths = {}) {
10559
10201
  const repo = paths.repo ?? caseLibraryDir();
10560
10202
  const codexConfig = paths.codexConfig ?? codexConfigFile();
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"));
10203
+ const cloned = await exists2(path9.join(repo, ".git"));
10204
+ const serverInstalled = cloned && await exists2(path9.join(repo, "mcp", "server.mjs")) && await exists2(path9.join(repo, "mcp", "node_modules", "@modelcontextprotocol"));
10563
10205
  const codexWired = codexConfigHasCases(await fs10.readFile(codexConfig, "utf8").catch(() => ""));
10564
10206
  return { repo, cloned, serverInstalled, codexWired };
10565
10207
  }
@@ -10612,8 +10254,8 @@ async function exists2(file) {
10612
10254
  // src/commands/chiron-init.ts
10613
10255
  async function probeTokenTenant(envName, requested) {
10614
10256
  const ctx = await getActiveAuthContextFromCli({ env: envName });
10615
- const client3 = HcmClient22.fromAuthContext(ctx);
10616
- const identity2 = await fetchReconIdentity2(httpProbe2(client3.raw(), "default"), requested);
10257
+ const client3 = HcmClient21.fromAuthContext(ctx);
10258
+ const identity2 = await fetchReconIdentity(httpProbe(client3.raw(), "default"), requested);
10617
10259
  return identity2?.tenantId ? String(identity2.tenantId) : void 0;
10618
10260
  }
10619
10261
  var defaultChironInitDeps = {
@@ -10626,7 +10268,7 @@ var defaultChironInitDeps = {
10626
10268
  all: true,
10627
10269
  target: "codex",
10628
10270
  env: envName,
10629
- dir: path11.join(root, SKILLS_DIR),
10271
+ dir: path10.join(root, SKILLS_DIR),
10630
10272
  output: "table"
10631
10273
  });
10632
10274
  } finally {
@@ -10639,7 +10281,7 @@ var defaultChironInitDeps = {
10639
10281
  caseLibrary: (envName) => ensureCaseLibrary(envName)
10640
10282
  };
10641
10283
  async function resolveLoggedInEnv() {
10642
- const g = await loadGlobalConfig11();
10284
+ const g = await loadGlobalConfig10();
10643
10285
  const name = g.activeEnv;
10644
10286
  const loginHint = "hcm login https://<\u4F60\u7684 HCM \u5730\u5740> --code <\u914D\u5BF9\u7801>";
10645
10287
  if (!name) {
@@ -10648,7 +10290,7 @@ async function resolveLoggedInEnv() {
10648
10290
  message: `\u8FD8\u6CA1\u767B\u5F55\u4EFB\u4F55\u73AF\u5883\u3002\u5148\u6267\u884C\uFF1A${loginHint}`
10649
10291
  });
10650
10292
  }
10651
- const config2 = await loadEnv11(name).catch(() => null);
10293
+ const config2 = await loadEnv10(name).catch(() => null);
10652
10294
  if (!config2?.endpoint) {
10653
10295
  throw new CliError21({
10654
10296
  code: CliErrorCode20.ENV_NOT_FOUND,
@@ -10665,72 +10307,72 @@ async function resolveLoggedInEnv() {
10665
10307
  const identity2 = config2.defaultIdentity && identities.includes(config2.defaultIdentity) ? config2.defaultIdentity : identities[0];
10666
10308
  return { name, env: projectEnvFromConfig(config2), identity: identity2 };
10667
10309
  }
10668
- async function scaffoldChironProject(root, env2, envName) {
10310
+ async function scaffoldChironProject(root, env3, envName) {
10669
10311
  const result = { created: [], updated: [], preserved: [] };
10670
- const envFile = path11.join(root, ENV_FILE);
10312
+ const envFile = path10.join(root, ENV_FILE);
10671
10313
  const existing = await fs11.readFile(envFile, "utf8").catch(() => null);
10672
10314
  if (existing !== null) {
10673
10315
  const recorded = parseEnvYaml(existing);
10674
- if (recorded.endpoint !== env2.endpoint) {
10316
+ if (recorded.endpoint !== env3.endpoint) {
10675
10317
  throw new CliError21({
10676
10318
  code: CliErrorCode20.INVALID_ARGUMENT,
10677
- message: `${ENV_FILE} \u6307\u5411 ${recorded.endpoint}\uFF0C\u800C\u4F60\u5F53\u524D\u767B\u5F55\u7684\u662F ${env2.endpoint}\uFF08env '${envName}'\uFF09\u3002
10319
+ message: `${ENV_FILE} \u6307\u5411 ${recorded.endpoint}\uFF0C\u800C\u4F60\u5F53\u524D\u767B\u5F55\u7684\u662F ${env3.endpoint}\uFF08env '${envName}'\uFF09\u3002
10678
10320
  \u8981\u7528\u8FD9\u4E2A\u9879\u76EE\u7684\u73AF\u5883\uFF1Ahcm login ${recorded.endpoint} --code <\u914D\u5BF9\u7801>\uFF0C\u518D\u91CD\u8DD1 hcm chiron init
10679
10321
  \u8981\u628A\u9879\u76EE\u6539\u5230\u4F60\u767B\u5F55\u7684\u73AF\u5883\uFF1A\u5220\u6389 ${ENV_FILE} \u540E\u91CD\u8DD1\uFF08\u8FD9\u4F1A\u5F71\u54CD\u6240\u6709\u534F\u4F5C\u8005\uFF0C\u5148\u8DDF\u8D1F\u8D23\u4EBA\u786E\u8BA4\uFF09`
10680
10322
  });
10681
10323
  }
10682
- if (recorded.tenant !== env2.tenant) {
10324
+ if (recorded.tenant !== env3.tenant) {
10683
10325
  throw new CliError21({
10684
10326
  code: CliErrorCode20.INVALID_ARGUMENT,
10685
- message: `${ENV_FILE} \u662F\u79DF\u6237 ${recorded.tenant}\uFF0C\u800C\u4F60\u767B\u5F55\u7684\u8EAB\u4EFD\u5C5E\u4E8E\u79DF\u6237 ${env2.tenant}\u3002
10686
- \u7528\u9879\u76EE\u79DF\u6237\u7684\u914D\u5BF9\u7801\u91CD\u65B0\u767B\u5F55\uFF1Ahcm login ${env2.endpoint} --code <\u914D\u5BF9\u7801>\uFF0C\u518D\u91CD\u8DD1 hcm chiron init`
10327
+ message: `${ENV_FILE} \u662F\u79DF\u6237 ${recorded.tenant}\uFF0C\u800C\u4F60\u767B\u5F55\u7684\u8EAB\u4EFD\u5C5E\u4E8E\u79DF\u6237 ${env3.tenant}\u3002
10328
+ \u7528\u9879\u76EE\u79DF\u6237\u7684\u914D\u5BF9\u7801\u91CD\u65B0\u767B\u5F55\uFF1Ahcm login ${env3.endpoint} --code <\u914D\u5BF9\u7801>\uFF0C\u518D\u91CD\u8DD1 hcm chiron init`
10687
10329
  });
10688
10330
  }
10689
10331
  result.preserved.push(ENV_FILE);
10690
10332
  } else {
10691
- await fs11.writeFile(envFile, renderEnvYaml(env2), { encoding: "utf8", mode: 420, flag: "wx" });
10333
+ await fs11.writeFile(envFile, renderEnvYaml(env3), { encoding: "utf8", mode: 420, flag: "wx" });
10692
10334
  result.created.push(ENV_FILE);
10693
10335
  }
10694
10336
  for (const directory of CHIRON_PROJECT_DIRECTORIES) {
10695
- const absolute = path11.join(root, directory);
10337
+ const absolute = path10.join(root, directory);
10696
10338
  await ensureDirectory(absolute);
10697
- await writeIfAbsent(path11.join(absolute, ".gitkeep"), "", result, `${directory}/.gitkeep`);
10339
+ await writeIfAbsent(path10.join(absolute, ".gitkeep"), "", result, `${directory}/.gitkeep`);
10698
10340
  }
10699
- const deliveryDir = path11.join(root, ".hcm-delivery");
10341
+ const deliveryDir = path10.join(root, ".hcm-delivery");
10700
10342
  await ensureDirectory(deliveryDir);
10701
10343
  await writeIfAbsent(
10702
- path11.join(deliveryDir, "project.yml"),
10344
+ path10.join(deliveryDir, "project.yml"),
10703
10345
  renderProjectYml(envName, "plan-only"),
10704
10346
  result,
10705
10347
  ".hcm-delivery/project.yml"
10706
10348
  );
10707
- const pageAcceptanceFile = path11.join(root, "page-acceptance.sh");
10349
+ const pageAcceptanceFile = path10.join(root, "page-acceptance.sh");
10708
10350
  const created = await writeIfAbsent(pageAcceptanceFile, renderPageAcceptanceSh("evidence"), result, "page-acceptance.sh", 493);
10709
10351
  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");
10352
+ await mergeManagedFile(path10.join(root, "AGENTS.md"), mergeChironAgentInstructions, result, "AGENTS.md");
10353
+ await mergeManagedFile(path10.join(root, "CLAUDE.md"), mergeChironAgentInstructions, result, "CLAUDE.md");
10354
+ await mergeManagedFile(path10.join(root, ".gitignore"), mergeDeliveryGitignore, result, ".gitignore");
10713
10355
  return result;
10714
10356
  }
10715
10357
  async function runChironInit(args, deps = defaultChironInitDeps) {
10716
- const root = path11.resolve(args.project ?? ".");
10717
- const { name, env: env2, identity: identity2 } = await resolveLoggedInEnv();
10358
+ const root = path10.resolve(args.project ?? ".");
10359
+ const { name, env: env3, identity: identity2 } = await resolveLoggedInEnv();
10718
10360
  if (isTempEnv3(name)) {
10719
10361
  throw new CliError21({
10720
10362
  code: CliErrorCode20.INVALID_ARGUMENT,
10721
- message: `\u5F53\u524D\u662F\u4E34\u65F6\u73AF\u5883\uFF08${env2.endpoint}\uFF09\uFF0C\u8FD8\u6CA1\u6709\u540D\u5B57\u3002\u9879\u76EE\u8981\u7ED1\u4E00\u4E2A\u7A33\u5B9A\u7684 env\uFF0C\u5426\u5219\u4E0B\u4E00\u6B21 hcm login --code \u8986\u76D6\u5B83\u4E4B\u540E\uFF0C\u9879\u76EE\u4ED3\u8BB0\u7684\u73AF\u5883\u5C31\u5BF9\u4E0D\u4E0A\u4E86\u3002`,
10363
+ message: `\u5F53\u524D\u662F\u4E34\u65F6\u73AF\u5883\uFF08${env3.endpoint}\uFF09\uFF0C\u8FD8\u6CA1\u6709\u540D\u5B57\u3002\u9879\u76EE\u8981\u7ED1\u4E00\u4E2A\u7A33\u5B9A\u7684 env\uFF0C\u5426\u5219\u4E0B\u4E00\u6B21 hcm login --code \u8986\u76D6\u5B83\u4E4B\u540E\uFF0C\u9879\u76EE\u4ED3\u8BB0\u7684\u73AF\u5883\u5C31\u5BF9\u4E0D\u4E0A\u4E86\u3002`,
10722
10364
  context: { nextStep: `\u5148\u7ED9\u5B83\u8D77\u4E2A\u540D\u5B57\uFF1Ahcm env save <name>\uFF0C\u7136\u540E\u91CD\u8DD1 hcm chiron init` }
10723
10365
  });
10724
10366
  }
10725
10367
  const say = (line) => process.stderr.write(`[chiron init] ${line}
10726
10368
  `);
10727
- const actual = await deps.tokenTenant(name, env2.tenant);
10728
- if (actual && actual !== env2.tenant) {
10729
- say(`env ${name} \u8BB0\u7684\u79DF\u6237\u662F ${env2.tenant}\uFF0C\u4F46\u4F60\u7684\u767B\u5F55\u8EAB\u4EFD\u5C5E\u4E8E\u79DF\u6237 ${actual}\uFF0C\u6309 ${actual} \u5199 ${ENV_FILE}`);
10730
- env2.tenant = actual;
10369
+ const actual = await deps.tokenTenant(name, env3.tenant);
10370
+ if (actual && actual !== env3.tenant) {
10371
+ say(`env ${name} \u8BB0\u7684\u79DF\u6237\u662F ${env3.tenant}\uFF0C\u4F46\u4F60\u7684\u767B\u5F55\u8EAB\u4EFD\u5C5E\u4E8E\u79DF\u6237 ${actual}\uFF0C\u6309 ${actual} \u5199 ${ENV_FILE}`);
10372
+ env3.tenant = actual;
10731
10373
  }
10732
- say(`\u73AF\u5883 ${name} \xB7 ${env2.endpoint} \xB7 \u79DF\u6237 ${env2.tenant} \xB7 \u8EAB\u4EFD ${identity2}`);
10733
- const scaffold = await scaffoldChironProject(root, env2, name);
10374
+ say(`\u73AF\u5883 ${name} \xB7 ${env3.endpoint} \xB7 \u79DF\u6237 ${env3.tenant} \xB7 \u8EAB\u4EFD ${identity2}`);
10375
+ const scaffold = await scaffoldChironProject(root, env3, name);
10734
10376
  say(`\u9AA8\u67B6\uFF1A\u65B0\u5EFA ${scaffold.created.length} \xB7 \u66F4\u65B0 ${scaffold.updated.length} \xB7 \u4FDD\u7559 ${scaffold.preserved.length}`);
10735
10377
  let skills2 = "skipped";
10736
10378
  if (!args.skipSkills) {
@@ -10748,9 +10390,9 @@ async function runChironInit(args, deps = defaultChironInitDeps) {
10748
10390
  return {
10749
10391
  project: root,
10750
10392
  env: name,
10751
- endpoint: env2.endpoint,
10752
- frontend: env2.frontend,
10753
- tenant: env2.tenant,
10393
+ endpoint: env3.endpoint,
10394
+ frontend: env3.frontend,
10395
+ tenant: env3.tenant,
10754
10396
  identity: identity2,
10755
10397
  scaffold,
10756
10398
  skills: skills2,
@@ -10763,7 +10405,7 @@ async function chironInitCommand(args, deps) {
10763
10405
  const result = await runChironInit(args, deps);
10764
10406
  const fmt = args.output ?? "table";
10765
10407
  if (fmt === "json" || fmt === "yaml") {
10766
- process.stdout.write(formatObject24(result, { format: fmt }) + "\n");
10408
+ process.stdout.write(formatObject23(result, { format: fmt }) + "\n");
10767
10409
  } else {
10768
10410
  process.stdout.write(
10769
10411
  [
@@ -10785,22 +10427,22 @@ async function chironInitCommand(args, deps) {
10785
10427
  init_auth_guard();
10786
10428
  init_exit();
10787
10429
  import { promises as fs12 } from "fs";
10788
- import path12 from "path";
10430
+ import path11 from "path";
10789
10431
  import {
10790
- HcmClient as HcmClient23,
10432
+ HcmClient as HcmClient22,
10791
10433
  CliError as CliError22,
10792
- fetchReconIdentity as fetchReconIdentity3,
10793
- formatObject as formatObject25,
10794
- httpProbe as httpProbe3,
10795
- runDoctor as runDoctor2
10434
+ fetchReconIdentity as fetchReconIdentity2,
10435
+ formatObject as formatObject24,
10436
+ httpProbe as httpProbe2,
10437
+ runDoctor
10796
10438
  } from "@hcmai/sdk";
10797
10439
  var defaultDeps = {
10798
- anchors: async (envName, tenant2) => {
10799
- const ctx = await getActiveAuthContextFromCli({ env: envName });
10800
- const client3 = HcmClient23.fromAuthContext(ctx);
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 };
10440
+ anchors: async (envName, tenant2, as) => {
10441
+ const ctx = await getActiveAuthContextFromCli({ env: envName, as });
10442
+ const client3 = HcmClient22.fromAuthContext(ctx);
10443
+ const probe2 = httpProbe2(client3.raw(), "default");
10444
+ const identity2 = await fetchReconIdentity2(probe2, tenant2);
10445
+ return { report: await runDoctor(probe2, identity2), tokenTenant: identity2?.tenantId ? String(identity2.tenantId) : void 0 };
10804
10446
  },
10805
10447
  fixSkills: (root, envName) => defaultChironInitDeps.installSkills(root, envName),
10806
10448
  fixCases: async (envName) => {
@@ -10810,9 +10452,9 @@ var defaultDeps = {
10810
10452
  inspectJira: () => inspectJira()
10811
10453
  };
10812
10454
  async function runChironDoctor(args, deps = defaultDeps) {
10813
- const root = path12.resolve(args.project ?? ".");
10455
+ const root = path11.resolve(args.project ?? ".");
10814
10456
  const report = { ok: false, project: root, env: null, envName: null, lines: [] };
10815
- const envText = await fs12.readFile(path12.join(root, ENV_FILE), "utf8").catch(() => null);
10457
+ const envText = await fs12.readFile(path11.join(root, ENV_FILE), "utf8").catch(() => null);
10816
10458
  if (envText === null) {
10817
10459
  report.lines.push({
10818
10460
  item: "\u767B\u5F55",
@@ -10822,31 +10464,32 @@ async function runChironDoctor(args, deps = defaultDeps) {
10822
10464
  });
10823
10465
  return finish(report);
10824
10466
  }
10825
- let env2;
10467
+ let env3;
10826
10468
  try {
10827
- env2 = parseEnvYaml(envText);
10469
+ env3 = parseEnvYaml(envText);
10828
10470
  } catch (e) {
10829
10471
  report.lines.push({ item: "\u767B\u5F55", verdict: "fail", detail: e.message, nextStep: `\u6309 hcm chiron init \u751F\u6210\u7684\u4E09\u884C\u5F62\u6001\u4FEE ${ENV_FILE}` });
10830
10472
  return finish(report);
10831
10473
  }
10832
- report.env = env2;
10833
- const found = await findEnvByEndpoint(env2.endpoint, env2.tenant);
10834
- const loginCmd = `hcm login ${env2.endpoint} --code <\u914D\u5BF9\u7801>`;
10474
+ report.env = env3;
10475
+ const found = await findEnvByEndpoint(env3.endpoint, env3.tenant);
10476
+ const loginCmd = `hcm login ${env3.endpoint} --code <\u914D\u5BF9\u7801>`;
10835
10477
  if (!found) {
10836
- report.lines.push({ item: "\u767B\u5F55", verdict: "fail", detail: `\u672C\u673A\u6CA1\u6709\u767B\u5F55\u8FC7 ${env2.endpoint}`, nextStep: loginCmd });
10478
+ report.lines.push({ item: "\u767B\u5F55", verdict: "fail", detail: `\u672C\u673A\u6CA1\u6709\u767B\u5F55\u8FC7 ${env3.endpoint}`, nextStep: loginCmd });
10837
10479
  } else {
10838
10480
  report.envName = found.name;
10839
10481
  try {
10840
- const { report: anchors, tokenTenant } = await deps.anchors(found.name, env2.tenant);
10482
+ const targetEnv = args.env ?? found.name;
10483
+ const { report: anchors, tokenTenant } = await deps.anchors(targetEnv, env3.tenant, args.as);
10841
10484
  report.anchors = anchors;
10842
- const tenantMismatch = tokenTenant && tokenTenant !== env2.tenant;
10485
+ const tenantMismatch = tokenTenant && tokenTenant !== env3.tenant;
10843
10486
  const bad = anchors.checks.filter((c) => !c.ok && !(tenantMismatch && c.anchor === "identity"));
10844
10487
  if (bad.length === 0 && !tenantMismatch) {
10845
10488
  const who = found.config.defaultIdentity ? ` \xB7 ${found.config.defaultIdentity}` : "";
10846
- report.lines.push({ item: "\u767B\u5F55", verdict: "ok", detail: `${found.name} \xB7 ${env2.endpoint} \xB7 \u79DF\u6237 ${env2.tenant}${who}` });
10489
+ report.lines.push({ item: "\u767B\u5F55", verdict: "ok", detail: `${found.name} \xB7 ${env3.endpoint} \xB7 \u79DF\u6237 ${env3.tenant}${who}` });
10847
10490
  } else {
10848
- const parts = [`${found.name} \xB7 ${env2.endpoint}`];
10849
- if (tenantMismatch) parts.push(`\u4F60\u7684\u767B\u5F55\u8EAB\u4EFD\u5C5E\u4E8E\u79DF\u6237 ${tokenTenant}\uFF0C\u9879\u76EE\u662F\u79DF\u6237 ${env2.tenant}`);
10491
+ const parts = [`${found.name} \xB7 ${env3.endpoint}`];
10492
+ if (tenantMismatch) parts.push(`\u4F60\u7684\u767B\u5F55\u8EAB\u4EFD\u5C5E\u4E8E\u79DF\u6237 ${tokenTenant}\uFF0C\u9879\u76EE\u662F\u79DF\u6237 ${env3.tenant}`);
10850
10493
  if (bad.length) parts.push(`\u951A\u70B9\u672A\u8FC7\uFF1A${bad.map((c) => `${c.anchor}\uFF08${c.detail}\uFF09`).join("\u3001")}`);
10851
10494
  report.lines.push({
10852
10495
  item: "\u767B\u5F55",
@@ -10857,15 +10500,15 @@ async function runChironDoctor(args, deps = defaultDeps) {
10857
10500
  }
10858
10501
  } catch (e) {
10859
10502
  const msg = e instanceof CliError22 ? e.message : e.message;
10860
- report.lines.push({ item: "\u767B\u5F55", verdict: "fail", detail: `${found.name} \xB7 ${env2.endpoint}\uFF1A${msg}`, nextStep: loginCmd });
10503
+ report.lines.push({ item: "\u767B\u5F55", verdict: "fail", detail: `${found.name} \xB7 ${env3.endpoint}\uFF1A${msg}`, nextStep: loginCmd });
10861
10504
  }
10862
10505
  }
10863
10506
  const skillsLine = async () => {
10864
- const state = await readSkillsState(path12.join(root, SKILLS_DIR));
10507
+ const state = await readSkillsState(path11.join(root, SKILLS_DIR));
10865
10508
  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" };
10866
10509
  const count = Object.keys(state.skills).length;
10867
- if (state.endpoint && normalizeOrigin(state.endpoint) !== env2.endpoint) {
10868
- return { item: "\u6280\u80FD", verdict: "fail", detail: `${count} \u4E2A\uFF0C\u4F46\u88C5\u81EA ${state.endpoint}\uFF0C\u4E0D\u662F\u9879\u76EE\u73AF\u5883 ${env2.endpoint}`, nextStep: "hcm chiron doctor --fix \u91CD\u88C5" };
10510
+ if (state.endpoint && normalizeOrigin(state.endpoint) !== env3.endpoint) {
10511
+ return { item: "\u6280\u80FD", verdict: "fail", detail: `${count} \u4E2A\uFF0C\u4F46\u88C5\u81EA ${state.endpoint}\uFF0C\u4E0D\u662F\u9879\u76EE\u73AF\u5883 ${env3.endpoint}`, nextStep: "hcm chiron doctor --fix \u91CD\u88C5" };
10869
10512
  }
10870
10513
  if (state.target !== "codex") {
10871
10514
  return { item: "\u6280\u80FD", verdict: "warn", detail: `${count} \u4E2A\uFF0C\u5E03\u5C40\u662F ${state.target}\uFF08Codex \u8981\u8BFB AGENTS.md \u7D22\u5F15\uFF09`, nextStep: "hcm skills install --all --target codex" };
@@ -10916,7 +10559,7 @@ async function chironDoctorCommand(args, deps) {
10916
10559
  try {
10917
10560
  const report = await runChironDoctor(args, deps);
10918
10561
  const fmt = args.output ?? "table";
10919
- if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject25(report, { format: fmt }) + "\n");
10562
+ if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject24(report, { format: fmt }) + "\n");
10920
10563
  else process.stdout.write(renderChironDoctor(report) + "\n");
10921
10564
  process.exitCode = report.ok ? 0 : 1;
10922
10565
  } catch (e) {
@@ -10928,9 +10571,9 @@ async function chironDoctorCommand(args, deps) {
10928
10571
  init_exit();
10929
10572
  import { spawnSync as spawnSync2 } from "child_process";
10930
10573
  import { promises as fs13 } from "fs";
10931
- import path13 from "path";
10574
+ import path12 from "path";
10932
10575
  import yaml2 from "js-yaml";
10933
- import { formatObject as formatObject26 } from "@hcmai/sdk";
10576
+ import { formatObject as formatObject25 } from "@hcmai/sdk";
10934
10577
 
10935
10578
  // src/commands/xlsx-peek.ts
10936
10579
  import { readFileSync as readFileSync6 } from "fs";
@@ -11182,7 +10825,7 @@ async function runCase(spec, root, opts = {}, deps = defaultDeps2) {
11182
10825
  continue;
11183
10826
  }
11184
10827
  if (c.file) {
11185
- const file = path13.resolve(root, fill(c.file));
10828
+ const file = path12.resolve(root, fill(c.file));
11186
10829
  const want = c.expect ?? {};
11187
10830
  const bad = [];
11188
10831
  if (want.xlsx_header || want.xlsx_min_rows !== void 0) {
@@ -11198,7 +10841,7 @@ async function runCase(spec, root, opts = {}, deps = defaultDeps2) {
11198
10841
  results.push(bad.length ? { name: c.name, verdict: "fail", detail: bad.join("\uFF1B") } : { name: c.name, verdict: "pass", detail: "" });
11199
10842
  continue;
11200
10843
  }
11201
- const out = path13.join("evidence", "test", `${spec.name}-${c.name}`.replace(/[^\w一-龥-]+/g, "_") + ".png");
10844
+ const out = path12.join("evidence", "test", `${spec.name}-${c.name}`.replace(/[^\w一-龥-]+/g, "_") + ".png");
11202
10845
  const argv = ["--path", fill(c.page), "--out", out];
11203
10846
  if (opts.env) argv.push("--env", opts.env);
11204
10847
  const as = c.as ?? opts.as;
@@ -11215,11 +10858,11 @@ async function runCase(spec, root, opts = {}, deps = defaultDeps2) {
11215
10858
  }
11216
10859
  async function loadCases(target) {
11217
10860
  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];
10861
+ const files = stat.isDirectory() ? (await fs13.readdir(target)).filter((f) => /\.ya?ml$/.test(f)).sort().map((f) => path12.join(target, f)) : [target];
11219
10862
  const out = [];
11220
10863
  for (const f of files) {
11221
10864
  const spec = yaml2.load(await fs13.readFile(f, "utf8"));
11222
- assertUsableSpec(spec, path13.basename(f));
10865
+ assertUsableSpec(spec, path12.basename(f));
11223
10866
  out.push({ file: f, spec });
11224
10867
  }
11225
10868
  if (out.length === 0) throw new Error(`${target} \u4E0B\u6CA1\u6709\u7528\u4F8B\uFF08*.yml\uFF09`);
@@ -11227,19 +10870,19 @@ async function loadCases(target) {
11227
10870
  }
11228
10871
  async function chironTestCommand(target, args, deps) {
11229
10872
  try {
11230
- const root = path13.resolve(args.project ?? ".");
11231
- const where = path13.resolve(root, target ?? "tests");
10873
+ const root = path12.resolve(args.project ?? ".");
10874
+ const where = path12.resolve(root, target ?? "tests");
11232
10875
  const cases = await loadCases(where);
11233
10876
  const report = [];
11234
10877
  let failed2 = 0;
11235
10878
  for (const { file, spec } of cases) {
11236
10879
  const results = await runCase(spec, root, { env: args.env, as: args.as }, deps);
11237
10880
  failed2 += results.filter((r) => r.verdict === "fail").length;
11238
- report.push({ case: spec.name, file: path13.relative(root, file), results });
10881
+ report.push({ case: spec.name, file: path12.relative(root, file), results });
11239
10882
  }
11240
10883
  const fmt = args.output ?? "table";
11241
10884
  if (fmt === "json" || fmt === "yaml") {
11242
- process.stdout.write(formatObject26({ ok: failed2 === 0, failed: failed2, cases: report }, { format: fmt }) + "\n");
10885
+ process.stdout.write(formatObject25({ ok: failed2 === 0, failed: failed2, cases: report }, { format: fmt }) + "\n");
11243
10886
  } else {
11244
10887
  for (const c of report) {
11245
10888
  process.stdout.write(`
@@ -11268,10 +10911,10 @@ ${failed2} \u6761\u6CA1\u8FC7\u2014\u2014\u4E0A\u9762\u6BCF\u6761\u90FD\u5199\u4
11268
10911
  import { readFileSync as readFileSync7 } from "fs";
11269
10912
  import {
11270
10913
  createHttpClient as createHttpClient4,
11271
- formatObject as formatObject27,
11272
- loadEnv as loadEnv12,
11273
- loadGlobalConfig as loadGlobalConfig12,
11274
- resolveActiveEnv as resolveActiveEnv6
10914
+ formatObject as formatObject26,
10915
+ loadEnv as loadEnv11,
10916
+ loadGlobalConfig as loadGlobalConfig11,
10917
+ resolveActiveEnv as resolveActiveEnv5
11275
10918
  } from "@hcmai/sdk";
11276
10919
  init_exit();
11277
10920
 
@@ -11287,7 +10930,6 @@ function linkedRepoRefs(text) {
11287
10930
  }
11288
10931
  return [...out.values()];
11289
10932
  }
11290
- var repoIssueUrl = (repo, number) => `https://cnb.cool/${repo}/-/issues/${number}`;
11291
10933
  function parseCnbIssueOutput(raw) {
11292
10934
  const fields = {};
11293
10935
  let status;
@@ -11373,7 +11015,7 @@ function searchRepoIssues(cnb, repo, keyword, state) {
11373
11015
  return [];
11374
11016
  }
11375
11017
  }
11376
- function parseRef(raw, project, casesSlug = "hcm/chiron-cases") {
11018
+ function parseRef(raw, project, casesSlug = CASES_REPO_SLUG) {
11377
11019
  const r = String(raw ?? "").trim();
11378
11020
  let m = r.match(/^(?:hcm\/)?(?:hcm_nx_)?(core|cli|cloud)#(\d+)$/i);
11379
11021
  if (m) return { kind: "repo", repo: `hcm/hcm_nx_${m[1].toLowerCase()}`, number: m[2] };
@@ -11619,7 +11261,7 @@ async function gapSearch({ client: client3, cnb }, keywords, { includeClosed = t
11619
11261
  const seen = /* @__PURE__ */ new Set();
11620
11262
  return { rows: rows.filter((r) => seen.has(r.id) ? false : (seen.add(r.id), true)), jiraError };
11621
11263
  }
11622
- async function gapStatus({ client: client3, cnb }, ref, casesSlug = "hcm/chiron-cases") {
11264
+ async function gapStatus({ client: client3, cnb }, ref, casesSlug = CASES_REPO_SLUG) {
11623
11265
  const parsed = parseRef(ref, client3.project, casesSlug);
11624
11266
  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
11267
  if (parsed.kind === "repo") {
@@ -11657,18 +11299,23 @@ var GAP_PREFIX = "\u7F3A\u53E3\uFF1A";
11657
11299
  var PENDING_STATUS = "\u65B0\u589E";
11658
11300
  var SYNC_MARKER = "\u4EE3\u7801\u5E93\u5DF2\u5173\u95ED\uFF1A";
11659
11301
  var bodyText = (issue, comments, remote = []) => [issue.fields.description ?? "", ...comments.map((c) => c.body ?? ""), ...remote.map((l) => l.object?.url ?? "")].join("\n");
11302
+ var remoteText = (remote) => remote.map((l) => `${l.object?.url ?? ""} ${l.object?.title ?? ""}`).join("\n");
11303
+ var refKeys = (text) => linkedRepoRefs(text).map((l) => `${l.repo}#${l.number}`);
11660
11304
  async function listOpen(client3, { all = false } = {}) {
11661
11305
  const every = await client3.search(`project = ${client3.project} AND resolution = Unresolved ORDER BY created DESC`, { max: 100 });
11662
11306
  const picked = all ? every : every.filter((i) => i.fields.status?.name === PENDING_STATUS);
11307
+ const linked = await Promise.all(picked.map((i) => client3.remoteLinks(i.key).then((r) => refKeys(remoteText(r)))));
11663
11308
  return {
11664
11309
  unresolved: every.length,
11665
- rows: picked.map((i) => ({
11310
+ rows: picked.map((i, n) => ({
11666
11311
  key: i.key,
11667
11312
  status: i.fields.status?.name ?? "?",
11668
11313
  priority: i.fields.priority?.name,
11669
11314
  summary: i.fields.summary ?? "",
11670
11315
  url: client3.browseUrl(i.key),
11671
11316
  reporter: i.fields.reporter?.displayName,
11317
+ assignee: i.fields.assignee?.displayName,
11318
+ linkedRefs: linked[n] ?? [],
11672
11319
  created: String(i.fields.created ?? "").slice(0, 10),
11673
11320
  fromAgent: (i.fields.summary ?? "").startsWith(GAP_PREFIX)
11674
11321
  }))
@@ -11678,7 +11325,11 @@ async function showIssue({ client: client3, cnb }, key2) {
11678
11325
  const issue = await client3.issue(key2);
11679
11326
  const comments = await client3.comments(key2);
11680
11327
  const remoteLinks = await client3.remoteLinks(key2);
11681
- const links = linkedRepoRefs(bodyText(issue, comments, remoteLinks)).map((l) => cnbIssueState(cnb, l.repo, l.number));
11328
+ const inRemote = new Set(refKeys(remoteText(remoteLinks)));
11329
+ const links = linkedRepoRefs(bodyText(issue, comments, remoteLinks)).map((l) => ({
11330
+ ...cnbIssueState(cnb, l.repo, l.number),
11331
+ source: inRemote.has(`${l.repo}#${l.number}`) ? "remote" : "comment"
11332
+ }));
11682
11333
  const transitions = await client3.transitions(key2);
11683
11334
  return { issue, comments, remoteLinks, links, transitions };
11684
11335
  }
@@ -11699,8 +11350,24 @@ async function moveIssue(client3, key2, target, comment) {
11699
11350
  async function toIssue({ client: client3, cnb }, key2, { repo = "hcm/hcm_nx_core", force = false, priority = "P2" } = {}) {
11700
11351
  const issue = await client3.issue(key2);
11701
11352
  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}`) };
11353
+ const remote = await client3.remoteLinks(key2);
11354
+ const existing = linkedRepoRefs(bodyText(issue, comments, remote));
11355
+ if (existing.length && !force) {
11356
+ const remoteText2 = remote.map((l) => `${l.object?.url ?? ""} ${l.object?.title ?? ""}`).join("\n");
11357
+ const linked = [];
11358
+ const alreadyLinked = [];
11359
+ for (const e of existing) {
11360
+ const ref = `${e.repo}#${e.number}`;
11361
+ const url2 = repoIssueUrl(e.repo, e.number);
11362
+ if (remoteText2.includes(url2) || remoteText2.includes(ref)) {
11363
+ alreadyLinked.push(ref);
11364
+ continue;
11365
+ }
11366
+ await client3.addRemoteLink(key2, url2, `${ref} ${issue.fields.summary ?? ""}`.slice(0, 250));
11367
+ linked.push(ref);
11368
+ }
11369
+ return { key: key2, existing: existing.map((e) => `${e.repo}#${e.number}`), linked, alreadyLinked };
11370
+ }
11704
11371
  const title = `${issue.fields.summary ?? ""}\uFF08Jira ${key2}\uFF09`;
11705
11372
  const body = [
11706
11373
  `> \u6765\u81EA Jira ${key2}\uFF1A${client3.browseUrl(key2)}`,
@@ -11789,15 +11456,18 @@ async function auditIssues(client3) {
11789
11456
  const rows = (await client3.search(`project = ${client3.project} AND resolution = Unresolved ORDER BY created DESC`, { max: 100 })).filter(
11790
11457
  (i) => (i.fields.summary ?? "").startsWith(GAP_PREFIX)
11791
11458
  );
11459
+ const audited = [];
11792
11460
  const bad = [];
11793
11461
  for (const i of rows) {
11794
11462
  const status = i.fields.status?.name ?? "?";
11795
11463
  if (status === PENDING_STATUS) continue;
11464
+ audited.push(i.key);
11796
11465
  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) });
11466
+ if (refKeys(remoteText(remote)).length) continue;
11467
+ const refs = refKeys(bodyText(await client3.issue(i.key), await client3.comments(i.key), remote));
11468
+ bad.push({ key: i.key, status, url: client3.browseUrl(i.key), kind: refs.length ? "comment-only" : "missing", refs });
11799
11469
  }
11800
- return { checked: rows.length, bad };
11470
+ return { checked: rows.length, audited, bad };
11801
11471
  }
11802
11472
  async function probe(client3) {
11803
11473
  const [info, me, project] = await Promise.all([client3.serverInfo(), client3.myself(), client3.projectInfo()]);
@@ -11822,7 +11492,7 @@ async function triageDeps(deps) {
11822
11492
  return { client: await deps.client(), cnb: deps.cnb };
11823
11493
  }
11824
11494
  function emit4(fmt, data, text) {
11825
- if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject27(data, { format: fmt }) + "\n");
11495
+ if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject26(data, { format: fmt }) + "\n");
11826
11496
  else process.stdout.write(text() + "\n");
11827
11497
  }
11828
11498
  function readBody(opts, positional) {
@@ -11860,8 +11530,10 @@ async function jiraOpenCommand(args, deps = defaultDeps3) {
11860
11530
  const r = await listOpen(await deps.client(), { all: !!args.all });
11861
11531
  emit4(args.output, r, () => {
11862
11532
  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");
11533
+ return r.rows.map(
11534
+ (i) => `${i.key} [${i.status}${i.priority ? " " + i.priority : ""}]${i.fromAgent ? "" : " \uFF08\u975E agent \u63D0\u5355\uFF09"} ${i.summary}
11535
+ ${i.url} \u62A5\u544A\u4EBA ${i.reporter ?? "?"} \u7ECF\u529E\u4EBA ${i.assignee ?? "\u672A\u63A5\u624B"} \u6761\u76EE ${i.linkedRefs.join(" / ") || "\u94FE\u63A5\u680F\u672A\u6302"} ${i.created}`
11536
+ ).join("\n");
11865
11537
  });
11866
11538
  });
11867
11539
  }
@@ -11879,7 +11551,8 @@ async function jiraShowCommand(key2, args, deps = defaultDeps3) {
11879
11551
  i.fields.description || "\uFF08\u7A7A\uFF09"
11880
11552
  ];
11881
11553
  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)}`);
11554
+ for (const l of r.links)
11555
+ out.push("", `\u5173\u8054\u4EE3\u7801\u5E93 ${describeIssueState(l)}${l.source === "comment" ? ` \uFF08\u4EC5\u89C1\u4E8E\u8BC4\u8BBA\uFF0C\u300C\u94FE\u63A5\u300D\u680F\u672A\u6302\uFF1Bhcm jira to-issue ${i.key} \u53EF\u8865\u6302\uFF09` : ""}`);
11883
11556
  out.push("", `\u53EF\u7528\u6D41\u8F6C\uFF1A${r.transitions.map((t) => `${t.name}\u2192${t.to?.name}`).join(" / ") || "\uFF08\u65E0\uFF09"}`);
11884
11557
  return out.join("\n");
11885
11558
  });
@@ -11909,7 +11582,12 @@ async function jiraToIssueCommand(key2, args, deps = defaultDeps3) {
11909
11582
  await run(async () => {
11910
11583
  const r = await toIssue(await triageDeps(deps), key2, { repo: args.repo, force: !!args.force });
11911
11584
  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`;
11585
+ if ("existing" in r) {
11586
+ const parts = [`${r.key} \u5DF2\u5173\u8054 ${r.existing.join("\u3001")}\uFF0C\u4E0D\u91CD\u590D\u5EFA\u3002\u8981\u518D\u5EFA\u52A0 --force`];
11587
+ if (r.linked.length) parts.push(`\u5DF2\u8865\u6302\u8FDC\u7A0B\u94FE\u63A5\uFF1A${r.linked.join("\u3001")}\uFF08\u539F\u5148\u53EA\u5199\u5728\u6B63\u6587/\u8BC4\u8BBA\u91CC\uFF0CJira\u300C\u94FE\u63A5\u300D\u680F\u770B\u4E0D\u5230\uFF09`);
11588
+ else if (r.alreadyLinked.length) parts.push("\u8FDC\u7A0B\u94FE\u63A5\u5DF2\u9F50\uFF0C\u65E0\u9700\u8865\u6302");
11589
+ return parts.join("\n");
11590
+ }
11913
11591
  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
11592
  return `${r.key} \u2192 ${r.repo}#${r.number} ${r.url}${moved}`;
11915
11593
  });
@@ -11960,8 +11638,17 @@ async function jiraAuditCommand(args, deps = defaultDeps3) {
11960
11638
  const r = await auditIssues(await deps.client());
11961
11639
  emit4(args.output, r, () => {
11962
11640
  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");
11641
+ const lines = [`\u672C\u8F6E\u6838\u8FC7 ${r.audited.length} \u6761\u5DF2\u53D7\u7406\u7684\u5355\uFF08\u672A\u89E3\u51B3\u5171 ${r.checked} \u6761\uFF0C\u300C\u65B0\u589E\u300D\u7684\u4E0D\u7B97\uFF09\u3002`];
11642
+ for (const b of r.bad) {
11643
+ lines.push(
11644
+ b.kind === "comment-only" ? `\u26A0\uFE0F ${b.key} [${b.status}] \u6761\u76EE\u53EA\u5199\u5728\u8BC4\u8BBA\u91CC\u3001\u300C\u94FE\u63A5\u300D\u680F\u662F\u7A7A\u7684\uFF1A${b.refs.join(" / ")}
11645
+ ${b.url}
11646
+ \u8865\u6302\uFF1Ahcm jira to-issue ${b.key}` : `\u26A0\uFE0F ${b.key} [${b.status}] \u6CA1\u6709\u4EFB\u4F55\u4EE3\u7801\u5E93\u6761\u76EE\uFF1A${b.url}
11647
+ \u5148\u5206\u8BCA\uFF1Ahcm jira to-issue ${b.key} --repo hcm/hcm_nx_core`
11648
+ );
11649
+ }
11650
+ if (!r.audited.length) lines.push("\u6CA1\u6709\u5DF2\u53D7\u7406\u7684\u5355\uFF0C\u672C\u8F6E\u4EC0\u4E48\u90FD\u6CA1\u6838\u5230\u3002");
11651
+ else if (!r.bad.length) lines.push("\u4E00\u81F4\uFF1A\u5DF2\u53D7\u7406\u7684\u5355\u90FD\u628A\u4EE3\u7801\u5E93\u6761\u76EE\u6302\u5728\u300C\u94FE\u63A5\u300D\u680F\u91CC\u3002");
11965
11652
  return lines.join("\n");
11966
11653
  });
11967
11654
  if (r.bad.length) process.exitCode = 1;
@@ -11987,11 +11674,11 @@ async function jiraStatusCommand(ref, args, deps = defaultDeps3) {
11987
11674
  emit4(args.output, r, () => [...r.lines, `\u4E0B\u4E00\u6B65\uFF1A${r.nextStep}`].join("\n"));
11988
11675
  });
11989
11676
  }
11990
- async function fingerprintText(env2) {
11677
+ async function fingerprintText(env3) {
11991
11678
  try {
11992
- const g = await loadGlobalConfig12();
11993
- const name = resolveActiveEnv6({ envFlag: env2 }, process.env, g);
11994
- const cfg = await loadEnv12(name);
11679
+ const g = await loadGlobalConfig11();
11680
+ const name = resolveActiveEnv5({ envFlag: env3 }, process.env, g);
11681
+ const cfg = await loadEnv11(name);
11995
11682
  if (!cfg?.endpoint) return `\u672A\u53D6\u5230\u6307\u7EB9\uFF08env=${name}\uFF1A\u6CA1\u6709 endpoint\uFF09`;
11996
11683
  const http = createHttpClient4({ endpoint: cfg.endpoint.replace(/\/+$/, ""), getAccessToken: async () => null, onRefresh: async () => {
11997
11684
  } });
@@ -12000,7 +11687,7 @@ async function fingerprintText(env2) {
12000
11687
  const commit = info.commit ?? info.gitCommit ?? info.version ?? "?";
12001
11688
  return `backend ${String(commit).slice(0, 12)} \xB7 CLI ${CLI_VERSION} \xB7 env ${name}`;
12002
11689
  } 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`;
11690
+ return `\u672A\u53D6\u5230\u6307\u7EB9\uFF08env=${env3 ?? "\u672A\u8BBE"}\uFF1B${String(e.message ?? e).split("\n")[0]?.slice(0, 120)}\uFF09`;
12004
11691
  }
12005
11692
  }
12006
11693
  async function jiraSubmitCommand(args, deps = defaultDeps3) {
@@ -12025,23 +11712,23 @@ ${r.url}
12025
11712
  init_auth_guard();
12026
11713
  init_exit();
12027
11714
  import {
12028
- HcmClient as HcmClient24,
11715
+ HcmClient as HcmClient23,
12029
11716
  ReconLayout,
12030
11717
  ROUND_EXIT_CODES,
12031
11718
  computeReconSourceKey,
12032
- formatObject as formatObject28,
12033
- fromAxiosError as fromAxiosError22,
12034
- httpProbe as httpProbe4,
11719
+ formatObject as formatObject27,
11720
+ fromAxiosError as fromAxiosError21,
11721
+ httpProbe as httpProbe3,
12035
11722
  inspectRound,
12036
11723
  renderRound,
12037
11724
  runRecon
12038
11725
  } from "@hcmai/sdk";
12039
- var DEFAULT_CAPABILITIES2 = "default";
11726
+ var DEFAULT_CAPABILITIES = "default";
12040
11727
  async function deliveryReconCommand(args) {
12041
11728
  try {
12042
11729
  const ctx = await getActiveAuthContextFromCli(args);
12043
- const client3 = HcmClient24.fromAuthContext(ctx);
12044
- const probe2 = httpProbe4(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES2);
11730
+ const client3 = HcmClient23.fromAuthContext(ctx);
11731
+ const probe2 = httpProbe3(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES);
12045
11732
  const sourceKey = await computeReconSourceKey(probe2);
12046
11733
  const layout = new ReconLayout(args.out ?? ".", ctx.tenantId, sourceKey);
12047
11734
  const summary = await runRecon(probe2, layout, {
@@ -12049,10 +11736,10 @@ async function deliveryReconCommand(args) {
12049
11736
  onlyModel: args.model ?? null,
12050
11737
  identity: ctx.tenantId ? { requestedTenantId: ctx.tenantId } : null
12051
11738
  });
12052
- process.stdout.write(formatObject28(summary, { format: args.output ?? "json" }) + "\n");
11739
+ process.stdout.write(formatObject27(summary, { format: args.output ?? "json" }) + "\n");
12053
11740
  } catch (e) {
12054
11741
  const err = e;
12055
- if (err?.isAxiosError) exitWithError(fromAxiosError22(err, args.env));
11742
+ if (err?.isAxiosError) exitWithError(fromAxiosError21(err, args.env));
12056
11743
  exitWithError(e);
12057
11744
  process.exit(1);
12058
11745
  }
@@ -12063,7 +11750,7 @@ async function deliveryReconRoundCommand(args) {
12063
11750
  const result = inspectRound(args.dir ?? ".");
12064
11751
  const fmt = args.output ?? "json";
12065
11752
  if (fmt !== "json") process.stdout.write(renderRound(result));
12066
- process.stdout.write(formatObject28(result, { format: fmt }) + "\n");
11753
+ process.stdout.write(formatObject27(result, { format: fmt }) + "\n");
12067
11754
  code = ROUND_EXIT_CODES[result.state];
12068
11755
  } catch (e) {
12069
11756
  exitWithError(e);
@@ -12082,14 +11769,14 @@ import {
12082
11769
  GAP_REASONS,
12083
11770
  deriveAclass,
12084
11771
  exitCode as gate0ExitCode,
12085
- formatObject as formatObject29,
11772
+ formatObject as formatObject28,
12086
11773
  inspectRound as inspectRound2,
12087
11774
  loadProtocolFacts,
12088
11775
  scan
12089
11776
  } from "@hcmai/sdk";
12090
- import * as path14 from "path";
11777
+ import * as path13 from "path";
12091
11778
  function renderGate0(result, skillRoot) {
12092
- const where = skillRoot ? `\uFF08${path14.resolve(skillRoot)}\uFF09` : "";
11779
+ const where = skillRoot ? `\uFF08${path13.resolve(skillRoot)}\uFF09` : "";
12093
11780
  const lines = [
12094
11781
  `\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`
12095
11782
  ];
@@ -12127,7 +11814,7 @@ async function deliveryGate0Command(args) {
12127
11814
  const merged = { ...result, premise: premise5 };
12128
11815
  const fmt = args.output ?? "json";
12129
11816
  if (fmt !== "json") process.stdout.write(renderGate0(merged, skillRoot));
12130
- process.stdout.write(`${formatObject29(merged, { format: fmt })}
11817
+ process.stdout.write(`${formatObject28(merged, { format: fmt })}
12131
11818
  `);
12132
11819
  for (const problem of premise5) {
12133
11820
  process.stderr.write(`\u{1F534} \u524D\u63D0\u4E0D\u6210\u7ACB\uFF08${problem.reason}\uFF09\uFF1A${problem.message}
@@ -12152,8 +11839,8 @@ import {
12152
11839
  DRY_RUN_TAIL,
12153
11840
  DriftDetected,
12154
11841
  FORCE_STALE_FLAG,
12155
- HcmClient as HcmClient25,
12156
- fetchReconIdentity as fetchReconIdentity4,
11842
+ HcmClient as HcmClient24,
11843
+ fetchReconIdentity as fetchReconIdentity3,
12157
11844
  INIT_EXIT_CODES,
12158
11845
  JOURNAL_STOP_KINDS,
12159
11846
  JOURNAL_STOP_UNKNOWN,
@@ -12202,7 +11889,7 @@ import {
12202
11889
  writeRisk
12203
11890
  } from "@hcmai/sdk";
12204
11891
  import { existsSync as existsSync3 } from "fs";
12205
- import * as path15 from "path";
11892
+ import * as path14 from "path";
12206
11893
  function premise(message, hint = "") {
12207
11894
  process.stderr.write(message + (hint ? `
12208
11895
  \u2192 ${hint}` : "") + "\n");
@@ -12223,19 +11910,19 @@ async function runSeedPlan(args, client3) {
12223
11910
  if (candidates.length === 0) {
12224
11911
  return premise(
12225
11912
  `\u672A\u627E\u5230\u5200 2 \u7684\u57FA\u7EBF\uFF1A${base}/*/index/fields.jsonl`,
12226
- "`plan` \u7684\u98CE\u9669\u6E05\u5355\u8981\u8BFB recon \u4EA7\u7269\u91CC\u7684 `mapping/` \u4E0E `valuedomain/`\u3002\u5148\u8DD1\u4E00\u6B21 `hcm delivery recon`\u3002"
11913
+ "`plan` \u7684\u98CE\u9669\u6E05\u5355\u8981\u8BFB recon \u4EA7\u7269\u91CC\u7684 `mapping/` \u4E0E `valuedomain/`\u3002\u5148\u8DD1\u4E00\u6B21 `hcm chiron recon`\u3002"
12227
11914
  );
12228
11915
  }
12229
11916
  const reconDir = candidates[0].reconDir;
12230
11917
  if (candidates.length > 1) {
12231
11918
  process.stderr.write(
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"
11919
+ `\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"
12233
11920
  );
12234
11921
  }
12235
11922
  const round = inspectRound3(reconDir);
12236
11923
  process.stderr.write(roundWarning(round));
12237
11924
  const baseline = {
12238
- path: `${path15.basename(path15.dirname(reconDir))}/${path15.basename(reconDir)}`,
11925
+ path: `${path14.basename(path14.dirname(reconDir))}/${path14.basename(reconDir)}`,
12239
11926
  roundId: round.roundId ?? null
12240
11927
  };
12241
11928
  let exemptions = null;
@@ -12292,7 +11979,7 @@ async function authOrSignpost(args, cmd) {
12292
11979
  }
12293
11980
  async function deliverySeedPlanCommand(args) {
12294
11981
  const ctx = await authOrSignpost(args, "plan");
12295
- const client3 = HcmClient25.fromAuthContext(ctx);
11982
+ const client3 = HcmClient24.fromAuthContext(ctx);
12296
11983
  process.exitCode = await runSeedPlan(args, seedClient(client3, ctx));
12297
11984
  }
12298
11985
  function seedClient(client3, ctx) {
@@ -12321,14 +12008,14 @@ function seedClient(client3, ctx) {
12321
12008
  };
12322
12009
  return {
12323
12010
  tenantId: ctx.tenantId,
12324
- capabilities: DEFAULT_CAPABILITIES3,
12011
+ capabilities: DEFAULT_CAPABILITIES2,
12325
12012
  get: (p, params) => wrap(() => raw.get(p, { params })),
12326
12013
  post: (p, body) => wrap(() => raw.post(p, body))
12327
12014
  };
12328
12015
  }
12329
12016
  async function seedVerifyClient(client3, ctx) {
12330
12017
  const base = seedClient(client3, ctx);
12331
- const identity2 = await fetchReconIdentity4(base, String(ctx.tenantId ?? ""));
12018
+ const identity2 = await fetchReconIdentity3(base, String(ctx.tenantId ?? ""));
12332
12019
  return { ...base, identity: identity2 };
12333
12020
  }
12334
12021
  function lowerCaseHeaders(headers) {
@@ -12339,7 +12026,7 @@ function lowerCaseHeaders(headers) {
12339
12026
  }
12340
12027
  return out;
12341
12028
  }
12342
- var DEFAULT_CAPABILITIES3 = "default";
12029
+ var DEFAULT_CAPABILITIES2 = "default";
12343
12030
  async function runSeedApply(args, client3) {
12344
12031
  const out = args.out ?? ".";
12345
12032
  const tenant2 = tenantOf(client3);
@@ -12466,7 +12153,7 @@ async function runSeedApply(args, client3) {
12466
12153
  }
12467
12154
  async function deliverySeedApplyCommand(args) {
12468
12155
  const ctx = await authOrSignpost(args, "apply");
12469
- const client3 = HcmClient25.fromAuthContext(ctx);
12156
+ const client3 = HcmClient24.fromAuthContext(ctx);
12470
12157
  process.exitCode = await runSeedApply(args, seedClient(client3, ctx));
12471
12158
  }
12472
12159
  async function runSeedVerify(args, client3) {
@@ -12490,14 +12177,14 @@ async function deliverySeedVerifyCommand(args) {
12490
12177
  return;
12491
12178
  }
12492
12179
  const ctx = await authOrSignpost(args, "verify");
12493
- const client3 = HcmClient25.fromAuthContext(ctx);
12180
+ const client3 = HcmClient24.fromAuthContext(ctx);
12494
12181
  process.exitCode = await runSeedVerify(args, await seedVerifyClient(client3, ctx));
12495
12182
  }
12496
12183
 
12497
12184
  // src/commands/delivery-seed-find.ts
12498
12185
  import { existsSync as existsSync4 } from "fs";
12499
12186
  import { readFileSync as readFileSync8 } from "fs";
12500
- import * as path16 from "path";
12187
+ import * as path15 from "path";
12501
12188
  import {
12502
12189
  INIT_EXIT_CODES as INIT_EXIT_CODES2,
12503
12190
  ValueHints,
@@ -12511,10 +12198,10 @@ import {
12511
12198
  valuesRoundCaveat
12512
12199
  } from "@hcmai/sdk";
12513
12200
  function provenance(chosenReconDir, others) {
12514
- let line = `> \u57FA\u7EBF\uFF1A\`${path16.basename(chosenReconDir)}\`
12201
+ let line = `> \u57FA\u7EBF\uFF1A\`${path15.basename(chosenReconDir)}\`
12515
12202
  `;
12516
12203
  if (others.length > 0) {
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";
12204
+ 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";
12518
12205
  }
12519
12206
  return `${line}
12520
12207
  `;
@@ -12531,7 +12218,7 @@ function pickBaseline(args) {
12531
12218
  return {
12532
12219
  rc: premise2(
12533
12220
  "\u6CA1\u7ED9 `--tenant`\u3002",
12534
- "\u672C\u547D\u4EE4\u96F6\u7F51\u7EDC\uFF08\u4E0D\u767B\u5F55\u3001\u4E00\u53D1\u8BF7\u6C42\u90FD\u4E0D\u53D1\uFF09\uFF0C\u6240\u4EE5\u5B83\u65E0\u6CD5\u4ECE\u767B\u5F55\u6001\u77E5\u9053\u4F60\u5728\u54EA\u4E2A\u79DF\u6237\u3002\u7ED9\u7684\u503C\u8981\u4E0E\u5F53\u521D\u8DD1 `hcm delivery recon` \u65F6\u90A3\u4E2A\u79DF\u6237\u4E00\u81F4\u3002"
12221
+ "\u672C\u547D\u4EE4\u96F6\u7F51\u7EDC\uFF08\u4E0D\u767B\u5F55\u3001\u4E00\u53D1\u8BF7\u6C42\u90FD\u4E0D\u53D1\uFF09\uFF0C\u6240\u4EE5\u5B83\u65E0\u6CD5\u4ECE\u767B\u5F55\u6001\u77E5\u9053\u4F60\u5728\u54EA\u4E2A\u79DF\u6237\u3002\u7ED9\u7684\u503C\u8981\u4E0E\u5F53\u521D\u8DD1 `hcm chiron recon` \u65F6\u90A3\u4E2A\u79DF\u6237\u4E00\u81F4\u3002"
12535
12222
  )
12536
12223
  };
12537
12224
  }
@@ -12540,7 +12227,7 @@ function pickBaseline(args) {
12540
12227
  return {
12541
12228
  rc: premise2(
12542
12229
  `\u672A\u627E\u5230\u7D22\u5F15\uFF1A${base}/*/index/fields.jsonl`,
12543
- "\u672C\u547D\u4EE4\u53EA\u8BFB `hcm delivery recon` \u843D\u76D8\u7684\u5B57\u6BB5\u76EE\u5F55\u3002\u5148\u8DD1\u4E00\u6B21 `hcm delivery recon`\uFF0C\u6216\u7528 `--out <\u76EE\u5F55>` \u6307\u5230\u4EA7\u7269\u6839\u3002"
12230
+ "\u672C\u547D\u4EE4\u53EA\u8BFB `hcm chiron recon` \u843D\u76D8\u7684\u5B57\u6BB5\u76EE\u5F55\u3002\u5148\u8DD1\u4E00\u6B21 `hcm chiron recon`\uFF0C\u6216\u7528 `--out <\u76EE\u5F55>` \u6307\u5230\u4EA7\u7269\u6839\u3002"
12544
12231
  )
12545
12232
  };
12546
12233
  }
@@ -12605,7 +12292,7 @@ import {
12605
12292
  CHANGE_STATES,
12606
12293
  CHANGE_UNKNOWN,
12607
12294
  CODE_WORDS,
12608
- HcmClient as HcmClient26,
12295
+ HcmClient as HcmClient25,
12609
12296
  INIT_EXIT_CODES as INIT_EXIT_CODES3,
12610
12297
  META_WRITE_STEPS,
12611
12298
  META_VERIFY_STEPS,
@@ -12721,7 +12408,7 @@ function metaText(a) {
12721
12408
  }
12722
12409
  lines.push("[\u5DF2\u77E5\u4E0D\u8986\u76D6 \xB7 \u672C\u547D\u4EE4]");
12723
12410
  lines.push(
12724
- " \xB7 **\u9664\u8865\u507F\u53F0\u8D26\u90A3\u4E00\u4EFD\uFF0C\u672C\u547D\u4EE4\u4E0D\u843D\u76D8**\uFF1A\u4EA7\u51FA\u7269\u5C31\u662F\u5C4F\u5E55\u4E0A\u8FD9\u4E00\u9875\uFF1B\u8981\u7559\u4E00\u4EFD\u5B58\u6863\uFF0C\u81EA\u5DF1\u91CD\u5B9A\u5411\u4E00\u6B21 \u2014\u2014 `hcm delivery meta \u2026 > \u5143\u6570\u636E\u6539\u52A8-<\u65E5\u671F>.txt 2>&1`\u3002"
12411
+ " \xB7 **\u9664\u8865\u507F\u53F0\u8D26\u90A3\u4E00\u4EFD\uFF0C\u672C\u547D\u4EE4\u4E0D\u843D\u76D8**\uFF1A\u4EA7\u51FA\u7269\u5C31\u662F\u5C4F\u5E55\u4E0A\u8FD9\u4E00\u9875\uFF1B\u8981\u7559\u4E00\u4EFD\u5B58\u6863\uFF0C\u81EA\u5DF1\u91CD\u5B9A\u5411\u4E00\u6B21 \u2014\u2014 `hcm chiron meta \u2026 > \u5143\u6570\u636E\u6539\u52A8-<\u65E5\u671F>.txt 2>&1`\u3002"
12725
12412
  );
12726
12413
  lines.push(
12727
12414
  " \u{1F534} \u522B\u63A5\u7BA1\u9053\u5B58\u6863\uFF08`| tee \u6587\u4EF6`\uFF09\uFF1A\u90A3\u4E4B\u540E\u62FF\u5230\u7684\u9000\u51FA\u7801\u662F tee \u7684\uFF0C**\u6052\u4E3A 0**\uFF0C\u8FD9\u4E00\u8D9F\u5224\u6210\u4EC0\u4E48\u5C31\u4E22\u4E86\u3002"
@@ -12833,7 +12520,7 @@ function lowerCaseHeaders2(headers) {
12833
12520
  }
12834
12521
  async function deliveryMetaCommand(args) {
12835
12522
  const ctx = await getActiveAuthContextFromCli(args);
12836
- const client3 = HcmClient26.fromAuthContext(ctx);
12523
+ const client3 = HcmClient25.fromAuthContext(ctx);
12837
12524
  process.exitCode = await runDeliveryMeta(
12838
12525
  { ...args, tenant: args.tenant ?? String(ctx.tenantId ?? "") },
12839
12526
  metaClient(client3, ctx)
@@ -12845,14 +12532,14 @@ init_auth_guard();
12845
12532
  init_exit();
12846
12533
  import {
12847
12534
  computeReconSourceKey as computeReconSourceKey2,
12848
- HcmClient as HcmClient27,
12849
- httpProbe as httpProbe5,
12535
+ HcmClient as HcmClient26,
12536
+ httpProbe as httpProbe4,
12850
12537
  ReconLayout as ReconLayout2,
12851
12538
  runTriageRound
12852
12539
  } from "@hcmai/sdk";
12853
12540
  import { mkdirSync, readFileSync as readFileSync10, writeFileSync as writeFileSync2 } from "fs";
12854
- import * as path17 from "path";
12855
- var DEFAULT_CAPABILITIES4 = "default";
12541
+ import * as path16 from "path";
12542
+ var DEFAULT_CAPABILITIES3 = "default";
12856
12543
  function premise4(message, hint) {
12857
12544
  process.stderr.write(`\u{1F534} \u524D\u63D0\u4E0D\u6210\u7ACB\uFF1A${message}
12858
12545
  `);
@@ -12887,8 +12574,8 @@ function renderProblems(rows) {
12887
12574
  `;
12888
12575
  }
12889
12576
  function writeTriageArtifact(outDir, body) {
12890
- const out = path17.join(outDir, "work", "triage.md");
12891
- mkdirSync(path17.dirname(out), { recursive: true });
12577
+ const out = path16.join(outDir, "work", "triage.md");
12578
+ mkdirSync(path16.dirname(out), { recursive: true });
12892
12579
  writeFileSync2(out, body, "utf8");
12893
12580
  return out;
12894
12581
  }
@@ -12901,8 +12588,8 @@ async function runTriage(args) {
12901
12588
  return premise4(e instanceof Error ? e.message : String(e), REQUESTS_SHAPE);
12902
12589
  }
12903
12590
  const ctx = await getActiveAuthContextFromCli(args);
12904
- const client3 = HcmClient27.fromAuthContext(ctx);
12905
- const probe2 = httpProbe5(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES4);
12591
+ const client3 = HcmClient26.fromAuthContext(ctx);
12592
+ const probe2 = httpProbe4(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES3);
12906
12593
  const artifactsDir = args.recon ?? new ReconLayout2(args.out ?? ".", ctx.tenantId, await computeReconSourceKey2(probe2)).dir;
12907
12594
  const result = await runTriageRound(probe2, artifactsDir, entriesIn);
12908
12595
  if (result.body === null) {
@@ -12930,8 +12617,8 @@ async function deliveryTriageCommand(args) {
12930
12617
  import { createHash as createHash5, randomBytes as secureRandomBytes } from "crypto";
12931
12618
  import { spawn as spawn2 } from "child_process";
12932
12619
  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";
12620
+ import path17 from "path";
12621
+ import { CliError as CliError23, CliErrorCode as CliErrorCode21, formatObject as formatObject29 } from "@hcmai/sdk";
12935
12622
  init_exit();
12936
12623
  var EXECUTION_CONTRACT_VERSION = "2026-09-03.controlled-v4";
12937
12624
  var DEFAULT_TTL_SECONDS = 15 * 60;
@@ -12973,9 +12660,9 @@ async function prepareDeliveryExecution(input) {
12973
12660
  };
12974
12661
  const planId = sha2565(canonicalJson(core)).slice(0, 24);
12975
12662
  const plan = { ...core, planId };
12976
- const plansDir = path18.join(project, ".hcm-delivery", "execution-plans");
12663
+ const plansDir = path17.join(project, ".hcm-delivery", "execution-plans");
12977
12664
  await safeManagedDirectory(project, ".hcm-delivery/execution-plans", plansDir);
12978
- const planFile = path18.join(plansDir, `${planId}.json`);
12665
+ const planFile = path17.join(plansDir, `${planId}.json`);
12979
12666
  try {
12980
12667
  await fs14.writeFile(planFile, `${JSON.stringify(plan, null, 2)}
12981
12668
  `, {
@@ -12991,7 +12678,7 @@ async function prepareDeliveryExecution(input) {
12991
12678
  async function executeDeliveryPlan(input) {
12992
12679
  if (!PLAN_ID_PATTERN.test(input.planId)) throw invalid2("planId \u5FC5\u987B\u662F 24 \u4F4D\u5C0F\u5199\u5341\u516D\u8FDB\u5236");
12993
12680
  const project = await realProject(input.project);
12994
- const planFile = path18.join(project, ".hcm-delivery", "execution-plans", `${input.planId}.json`);
12681
+ const planFile = path17.join(project, ".hcm-delivery", "execution-plans", `${input.planId}.json`);
12995
12682
  const plan = await readPlan(project, planFile);
12996
12683
  if (plan.planId !== input.planId || computePlanId(plan) !== input.planId) {
12997
12684
  throw invalid2("\u6267\u884C\u8BA1\u5212\u5185\u5BB9\u4E0E planId \u6458\u8981\u4E0D\u4E00\u81F4");
@@ -13028,11 +12715,11 @@ async function executeDeliveryPlan(input) {
13028
12715
  await assertDocumentUnchanged(project, plan.documents.rollback, "\u56DE\u6EDA\u8BF4\u660E");
13029
12716
  await assertPayloadsUnchanged(project, plan.payloads);
13030
12717
  const evidenceDir = await bindEvidenceDirectory(project, plan.evidenceDir);
13031
- const receiptFile = path18.join(evidenceDir.absolute, `${plan.planId}.receipt.json`);
12718
+ const receiptFile = path17.join(evidenceDir.absolute, `${plan.planId}.receipt.json`);
13032
12719
  if (await pathExists(receiptFile)) throw invalid2(`\u6267\u884C\u6536\u636E\u5DF2\u5B58\u5728\uFF0C\u62D2\u7EDD\u518D\u6B21\u6267\u884C\uFF1A${plan.planId}`);
13033
- const claimsDir = path18.join(project, ".hcm-delivery", "execution-claims");
12720
+ const claimsDir = path17.join(project, ".hcm-delivery", "execution-claims");
13034
12721
  await safeManagedDirectory(project, ".hcm-delivery/execution-claims", claimsDir);
13035
- const claimFile = path18.join(claimsDir, `${plan.planId}.json`);
12722
+ const claimFile = path17.join(claimsDir, `${plan.planId}.json`);
13036
12723
  try {
13037
12724
  await fs14.writeFile(
13038
12725
  claimFile,
@@ -13091,7 +12778,7 @@ async function deliveryPrepareCommand(argv, args) {
13091
12778
  evidenceDir: args.evidenceDir,
13092
12779
  ...ttlSeconds === void 0 ? {} : { ttlSeconds }
13093
12780
  });
13094
- process.stdout.write(formatObject30(plan, { format: args.output ?? "json" }) + "\n");
12781
+ process.stdout.write(formatObject29(plan, { format: args.output ?? "json" }) + "\n");
13095
12782
  process.stderr.write(
13096
12783
  `
13097
12784
  \u4E0B\u4E00\u6B65\uFF08argv \u5FC5\u987B\u4E0E\u672C\u6B21\u5B8C\u5168\u4E00\u81F4\uFF09\uFF1A
@@ -13120,11 +12807,11 @@ async function deliveryExecuteCommand(planId, argv, args) {
13120
12807
  }
13121
12808
  }
13122
12809
  function writeDeliveryExecutionReceipt(receipt, format = "json") {
13123
- process.stderr.write(formatObject30(receipt, { format }) + "\n");
12810
+ process.stderr.write(formatObject29(receipt, { format }) + "\n");
13124
12811
  process.exitCode = receipt.exitCode;
13125
12812
  }
13126
12813
  async function readProjectMode(project, environment) {
13127
- const file = path18.join(project, ".hcm-delivery", "project.yml");
12814
+ const file = path17.join(project, ".hcm-delivery", "project.yml");
13128
12815
  const content = await readSafeFile(project, file, "\u9879\u76EE\u914D\u7F6E");
13129
12816
  let mode;
13130
12817
  try {
@@ -13143,13 +12830,13 @@ async function readProjectMode(project, environment) {
13143
12830
  return mode;
13144
12831
  }
13145
12832
  var SKILLS_LOCK_CANDIDATES = [
13146
- path18.join("hcm-skills", ".hcm-skills.json"),
13147
- path18.join(".claude", "skills", ".hcm-skills.json")
12833
+ path17.join("hcm-skills", ".hcm-skills.json"),
12834
+ path17.join(".claude", "skills", ".hcm-skills.json")
13148
12835
  ];
13149
12836
  async function readSkillsLock(project) {
13150
12837
  const found = [];
13151
12838
  for (const candidate of SKILLS_LOCK_CANDIDATES) {
13152
- if (await pathExists(path18.join(project, candidate))) found.push(candidate);
12839
+ if (await pathExists(path17.join(project, candidate))) found.push(candidate);
13153
12840
  }
13154
12841
  if (found.length === 0) {
13155
12842
  throw invalid2(
@@ -13161,7 +12848,7 @@ async function readSkillsLock(project) {
13161
12848
  `\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`
13162
12849
  );
13163
12850
  }
13164
- const bytes = await readSafeFile(project, path18.join(project, found[0]), "\u6280\u80FD\u9501");
12851
+ const bytes = await readSafeFile(project, path17.join(project, found[0]), "\u6280\u80FD\u9501");
13165
12852
  try {
13166
12853
  JSON.parse(bytes.toString("utf8"));
13167
12854
  } catch (cause) {
@@ -13174,7 +12861,7 @@ async function bindDocument(project, reference, label) {
13174
12861
  if (!(relative2.startsWith("work/") || relative2.startsWith("decisions/"))) {
13175
12862
  throw invalid2(`${label}\u5FC5\u987B\u4F4D\u4E8E\u9879\u76EE work/ \u6216 decisions/ \u4E0B`);
13176
12863
  }
13177
- const file = path18.join(project, relative2);
12864
+ const file = path17.join(project, relative2);
13178
12865
  const bytes = await readSafeFile(project, file, label);
13179
12866
  return { path: relative2, sha256: sha2565(bytes) };
13180
12867
  }
@@ -13187,7 +12874,7 @@ async function bindEvidenceDirectory(project, reference) {
13187
12874
  if (!(relative2 === "evidence" || relative2.startsWith("evidence/"))) {
13188
12875
  throw invalid2("evidence \u76EE\u5F55\u5FC5\u987B\u4F4D\u4E8E\u9879\u76EE evidence/ \u4E0B");
13189
12876
  }
13190
- const absolute = path18.join(project, relative2);
12877
+ const absolute = path17.join(project, relative2);
13191
12878
  await assertNoSymlinkComponents(project, relative2);
13192
12879
  const stat = await fs14.stat(absolute).catch(() => null);
13193
12880
  if (stat === null) {
@@ -13374,7 +13061,7 @@ async function bindPayloadPath(project, reference, label) {
13374
13061
  const relative2 = safeRelative(reference, label);
13375
13062
  let stat;
13376
13063
  try {
13377
- stat = await fs14.stat(path18.join(project, relative2));
13064
+ stat = await fs14.stat(path17.join(project, relative2));
13378
13065
  } catch (cause) {
13379
13066
  throw invalid2(
13380
13067
  `${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`,
@@ -13385,7 +13072,7 @@ async function bindPayloadPath(project, reference, label) {
13385
13072
  }
13386
13073
  async function bindPayloadDirectory(project, reference, label) {
13387
13074
  const relative2 = reference === "." ? "." : safeRelative(reference, label);
13388
- const root = path18.join(project, relative2);
13075
+ const root = path17.join(project, relative2);
13389
13076
  let stat;
13390
13077
  try {
13391
13078
  stat = await fs14.stat(root);
@@ -13403,7 +13090,7 @@ async function bindPayloadDirectory(project, reference, label) {
13403
13090
  (a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0
13404
13091
  )) {
13405
13092
  if (skipToolingAtRoot && prefix === "" && TOOLING_DIRS.includes(item.name)) continue;
13406
- const child = path18.join(dir, item.name);
13093
+ const child = path17.join(dir, item.name);
13407
13094
  const rel = prefix ? `${prefix}/${item.name}` : item.name;
13408
13095
  if (item.isSymbolicLink()) {
13409
13096
  throw invalid2(
@@ -13428,7 +13115,7 @@ ${sha2565(bytes)}`);
13428
13115
  }
13429
13116
  async function bindPayloadFile(project, reference, label) {
13430
13117
  const relative2 = safeRelative(reference, label);
13431
- const file = path18.join(project, relative2);
13118
+ const file = path17.join(project, relative2);
13432
13119
  const bytes = await readSafeFile(project, file, label);
13433
13120
  return { path: relative2, kind: "file", sha256: sha2565(bytes) };
13434
13121
  }
@@ -13499,13 +13186,13 @@ async function writeReceiptExclusive(target, receipt) {
13499
13186
  });
13500
13187
  await fs14.link(temp, target);
13501
13188
  } catch (cause) {
13502
- throw invalid2(`\u6267\u884C\u6536\u636E\u5199\u5165\u5931\u8D25\u6216\u5DF2\u5B58\u5728\uFF1A${path18.basename(target)}`, cause);
13189
+ throw invalid2(`\u6267\u884C\u6536\u636E\u5199\u5165\u5931\u8D25\u6216\u5DF2\u5B58\u5728\uFF1A${path17.basename(target)}`, cause);
13503
13190
  } finally {
13504
13191
  await fs14.unlink(temp).catch(() => void 0);
13505
13192
  }
13506
13193
  }
13507
13194
  async function safeManagedDirectory(project, relative2, absolute) {
13508
- await assertNoSymlinkComponents(project, path18.dirname(relative2));
13195
+ await assertNoSymlinkComponents(project, path17.dirname(relative2));
13509
13196
  const existing = await fs14.lstat(absolute).catch(() => void 0);
13510
13197
  if (existing?.isSymbolicLink()) throw invalid2(`\u53D7\u7BA1\u76EE\u5F55\u4E0D\u80FD\u662F\u7B26\u53F7\u94FE\u63A5\uFF1A${relative2}`);
13511
13198
  if (existing && !existing.isDirectory()) throw invalid2(`\u53D7\u7BA1\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55\uFF1A${relative2}`);
@@ -13522,8 +13209,8 @@ async function pathExists(file) {
13522
13209
  );
13523
13210
  }
13524
13211
  async function readSafeFile(project, file, label) {
13525
- const relative2 = path18.relative(project, file).split(path18.sep).join("/");
13526
- if (relative2.startsWith("../") || path18.isAbsolute(relative2))
13212
+ const relative2 = path17.relative(project, file).split(path17.sep).join("/");
13213
+ if (relative2.startsWith("../") || path17.isAbsolute(relative2))
13527
13214
  throw invalid2(`${label}\u8DEF\u5F84\u9003\u9038\u9879\u76EE`);
13528
13215
  await assertNoSymlinkComponents(project, relative2);
13529
13216
  let stat;
@@ -13540,14 +13227,14 @@ async function assertNoSymlinkComponents(project, relative2) {
13540
13227
  const parts = relative2.split("/").filter(Boolean);
13541
13228
  let current = project;
13542
13229
  for (const part of parts) {
13543
- current = path18.join(current, part);
13230
+ current = path17.join(current, part);
13544
13231
  const stat = await fs14.lstat(current).catch(() => void 0);
13545
13232
  if (stat?.isSymbolicLink()) throw invalid2(`\u8DEF\u5F84\u5305\u542B\u7B26\u53F7\u94FE\u63A5\uFF1A${relative2}`);
13546
13233
  if (!stat) break;
13547
13234
  }
13548
13235
  }
13549
13236
  async function realProject(requested) {
13550
- const absolute = path18.resolve(requested);
13237
+ const absolute = path17.resolve(requested);
13551
13238
  let project;
13552
13239
  try {
13553
13240
  project = await fs14.realpath(absolute);
@@ -13559,10 +13246,10 @@ async function realProject(requested) {
13559
13246
  return project;
13560
13247
  }
13561
13248
  function safeRelative(reference, label) {
13562
- if (!reference || path18.isAbsolute(reference) || /[\r\n\0]/.test(reference)) {
13249
+ if (!reference || path17.isAbsolute(reference) || /[\r\n\0]/.test(reference)) {
13563
13250
  throw invalid2(`${label}\u5FC5\u987B\u662F\u9879\u76EE\u5185\u76F8\u5BF9\u8DEF\u5F84`);
13564
13251
  }
13565
- const normalized = path18.normalize(reference).split(path18.sep).join("/");
13252
+ const normalized = path17.normalize(reference).split(path17.sep).join("/");
13566
13253
  if (normalized === ".." || normalized.startsWith("../") || normalized === ".") {
13567
13254
  throw invalid2(`${label}\u8DEF\u5F84\u9003\u9038\u9879\u76EE`);
13568
13255
  }
@@ -13627,10 +13314,10 @@ function nextCommandHint(planId, project, argv) {
13627
13314
  init_auth_guard();
13628
13315
  init_exit();
13629
13316
  import {
13630
- HcmClient as HcmClient28,
13317
+ HcmClient as HcmClient27,
13631
13318
  adminResetPassword,
13632
- formatObject as formatObject31,
13633
- fromAxiosError as fromAxiosError23,
13319
+ formatObject as formatObject30,
13320
+ fromAxiosError as fromAxiosError22,
13634
13321
  CliError as CliError24,
13635
13322
  CliErrorCode as CliErrorCode22
13636
13323
  } from "@hcmai/sdk";
@@ -13661,12 +13348,12 @@ async function userResetPasswordCommand(args) {
13661
13348
  try {
13662
13349
  const password = args.passwordStdin ? await readSecretFromStdin() : await promptPasswordTwice();
13663
13350
  const request = buildAdminResetPasswordRequest(args, password);
13664
- const client3 = HcmClient28.fromAuthContext(await getActiveAuthContextFromCli(args));
13351
+ const client3 = HcmClient27.fromAuthContext(await getActiveAuthContextFromCli(args));
13665
13352
  const result = await adminResetPassword(client3.raw(), request);
13666
- process.stdout.write(formatObject31(result, { format: args.output ?? "json" }) + "\n");
13353
+ process.stdout.write(formatObject30(result, { format: args.output ?? "json" }) + "\n");
13667
13354
  } catch (cause) {
13668
13355
  const err = cause;
13669
- if (err?.isAxiosError) exitWithError(fromAxiosError23(err, args.env));
13356
+ if (err?.isAxiosError) exitWithError(fromAxiosError22(err, args.env));
13670
13357
  exitWithError(cause);
13671
13358
  }
13672
13359
  }
@@ -13686,19 +13373,19 @@ async function promptPasswordTwice() {
13686
13373
  init_exit();
13687
13374
  init_auth_guard();
13688
13375
  import {
13689
- HcmClient as HcmClient29,
13690
- formatObject as formatObject32,
13691
- fromAxiosError as fromAxiosError24
13376
+ HcmClient as HcmClient28,
13377
+ formatObject as formatObject31,
13378
+ fromAxiosError as fromAxiosError23
13692
13379
  } from "@hcmai/sdk";
13693
13380
  async function modelsCommand(keyword, args) {
13694
13381
  try {
13695
- const client3 = HcmClient29.fromAuthContext(await getActiveAuthContextFromCli(args));
13382
+ const client3 = HcmClient28.fromAuthContext(await getActiveAuthContextFromCli(args));
13696
13383
  const all = await client3.listModels();
13697
13384
  const needle = keyword?.trim().toLowerCase();
13698
13385
  const rows = (needle ? all.filter((m) => JSON.stringify(m).toLowerCase().includes(needle)) : all).sort((a, b) => key(a).localeCompare(key(b)));
13699
13386
  const fmt = args.output ?? "table";
13700
13387
  if (fmt !== "table") {
13701
- process.stdout.write(formatObject32({ total: rows.length, models: rows }, { format: fmt }) + "\n");
13388
+ process.stdout.write(formatObject31({ total: rows.length, models: rows }, { format: fmt }) + "\n");
13702
13389
  process.exitCode = 0;
13703
13390
  return;
13704
13391
  }
@@ -13725,7 +13412,7 @@ async function modelsCommand(keyword, args) {
13725
13412
  return;
13726
13413
  } catch (e) {
13727
13414
  const err = e;
13728
- if (err?.isAxiosError) exitWithError(fromAxiosError24(err, args.profile));
13415
+ if (err?.isAxiosError) exitWithError(fromAxiosError23(err, args.profile));
13729
13416
  exitWithError(e);
13730
13417
  }
13731
13418
  }
@@ -13767,15 +13454,15 @@ config.command("set-profile <name>").description("[deprecated] \u7528 `hcm env u
13767
13454
  config.command("delete <name>").description("[deprecated] \u7528 `hcm env remove --force`").action((n) => configDeleteDeprecated(n));
13768
13455
  config.command("set <key> <value>").description("\u8BBE\u7F6E\u5168\u5C40 defaults\uFF0C\u4F8B\u5982 `defaults.output json`").action((k, v) => configSet(k, v));
13769
13456
  config.command("get <key>").description("\u8BFB\u53D6\u5168\u5C40 defaults").action((k) => configGet(k));
13770
- var env = program.command("env").description("\u7BA1\u7406 HCM \u73AF\u5883\uFF08\u591A\u540E\u7AEF\u8FDE\u63A5\u914D\u7F6E\uFF09");
13771
- env.command("list").description("\u5217\u51FA\u5168\u90E8 env").action(() => envList());
13772
- env.command("current").description("\u663E\u793A\u5F53\u524D\u6FC0\u6D3B\u7684 env").action(() => envCurrent());
13773
- env.command("add <name>").description("\u65B0\u589E env").option("--endpoint <url>", "HCM \u540E\u7AEF URL\uFF08\u5FC5\u586B\uFF09").option("--tenant <id>", "\u9ED8\u8BA4 tenant id", "1").option("--frontend <url>", "\u5BF9\u5E94\u524D\u7AEF URL\uFF0C\u4F8B\u5982 http://127.0.0.1:5176").option("--force", "\u8986\u76D6\u5DF2\u5B58\u5728\u7684\u540C\u540D env").action((name, opts) => envAdd(name, opts));
13774
- env.command("use <name>").description("\u5207\u5230\u6307\u5B9A env").option("--no-ping", "\u8DF3\u8FC7 endpoint \u5065\u5EB7\u68C0\u67E5").action((name, opts) => envUse(name, opts));
13775
- env.command("save <name>").description("\u628A\u5F53\u524D\u4E34\u65F6\u73AF\u5883\uFF08login --code \u4EA7\u751F\u7684\uFF09\u5B58\u6210\u5177\u540D env").option("--force", "\u76EE\u6807 env \u5DF2\u5B58\u5728\u65F6\u8986\u76D6\u5B83\u7684\u914D\u7F6E").action((name, opts) => envSave(name, opts));
13776
- env.command("remove <name>").description("\u5220\u9664 env\uFF08\u7EA7\u8054\u6E05\u9664\u8BE5 env \u7684\u5168\u90E8 identity \u548C token\uFF09").option("--force", "\u8DF3\u8FC7\u786E\u8BA4\u63D0\u793A").action((name, opts) => envRemove(name, opts));
13777
- env.command("show [name]").description("\u663E\u793A env \u8BE6\u60C5\uFF08\u542B\u8BE5 env \u4E0B\u7684 identity \u5217\u8868\uFF09").action((name) => envShow({ name }));
13778
- env.command("edit <field> <value>").description("\u7F16\u8F91 env \u5B57\u6BB5\uFF08endpoint / frontend / tenantId / defaultIdentity / defaultAgent\uFF09").option("--env <name>", "\u76EE\u6807 env \u540D\uFF08\u9ED8\u8BA4\u5F53\u524D activeEnv\uFF09").action((field, value, opts) => envEdit(field, value, opts));
13457
+ var env2 = program.command("env").description("\u7BA1\u7406 HCM \u73AF\u5883\uFF08\u591A\u540E\u7AEF\u8FDE\u63A5\u914D\u7F6E\uFF09");
13458
+ env2.command("list").description("\u5217\u51FA\u5168\u90E8 env").action(() => envList());
13459
+ env2.command("current").description("\u663E\u793A\u5F53\u524D\u6FC0\u6D3B\u7684 env").action(() => envCurrent());
13460
+ env2.command("add <name>").description("\u65B0\u589E env").option("--endpoint <url>", "HCM \u540E\u7AEF URL\uFF08\u5FC5\u586B\uFF09").option("--tenant <id>", "\u9ED8\u8BA4 tenant id", "1").option("--frontend <url>", "\u5BF9\u5E94\u524D\u7AEF URL\uFF0C\u4F8B\u5982 http://127.0.0.1:5176").option("--force", "\u8986\u76D6\u5DF2\u5B58\u5728\u7684\u540C\u540D env").action((name, opts) => envAdd(name, opts));
13461
+ env2.command("use <name>").description("\u5207\u5230\u6307\u5B9A env").option("--no-ping", "\u8DF3\u8FC7 endpoint \u5065\u5EB7\u68C0\u67E5").action((name, opts) => envUse(name, opts));
13462
+ env2.command("save <name>").description("\u628A\u5F53\u524D\u4E34\u65F6\u73AF\u5883\uFF08login --code \u4EA7\u751F\u7684\uFF09\u5B58\u6210\u5177\u540D env").option("--force", "\u76EE\u6807 env \u5DF2\u5B58\u5728\u65F6\u8986\u76D6\u5B83\u7684\u914D\u7F6E").action((name, opts) => envSave(name, opts));
13463
+ env2.command("remove <name>").description("\u5220\u9664 env\uFF08\u7EA7\u8054\u6E05\u9664\u8BE5 env \u7684\u5168\u90E8 identity \u548C token\uFF09").option("--force", "\u8DF3\u8FC7\u786E\u8BA4\u63D0\u793A").action((name, opts) => envRemove(name, opts));
13464
+ env2.command("show [name]").description("\u663E\u793A env \u8BE6\u60C5\uFF08\u542B\u8BE5 env \u4E0B\u7684 identity \u5217\u8868\uFF09").action((name) => envShow({ name }));
13465
+ env2.command("edit <field> <value>").description("\u7F16\u8F91 env \u5B57\u6BB5\uFF08endpoint / frontend / tenantId / defaultIdentity / defaultAgent\uFF09").option("--env <name>", "\u76EE\u6807 env \u540D\uFF08\u9ED8\u8BA4\u5F53\u524D activeEnv\uFF09").action((field, value, opts) => envEdit(field, value, opts));
13779
13466
  var identity = program.command("identity").description("\u7BA1\u7406 HCM \u8EAB\u4EFD\u51ED\u636E\uFF08env \u4E0B\u7684 identity\uFF09");
13780
13467
  identity.command("list").description("\u5217\u51FA identity\uFF08\u9ED8\u8BA4\u5217\u5F53\u524D env\uFF0C--env all \u5217\u5168\u90E8\uFF09").option("--env <name>", '\u8FC7\u6EE4 env\uFF1B\u4F20 "all" \u5217\u5168\u90E8', void 0).action((opts) => identityList(opts));
13781
13468
  identity.command("show <name>").description("\u5B9E\u65F6\u663E\u793A alias \u5BF9\u5E94\u7684\u670D\u52A1\u7AEF\u7528\u6237\u3001\u79DF\u6237\u4E0E\u89D2\u8272\uFF08\u4E0D\u8F93\u51FA token\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((name, opts) => identityShow(name, opts));
@@ -13783,14 +13470,16 @@ identity.command("use <name>").description("\u628A identity \u8BBE\u4E3A\u5176 e
13783
13470
  identity.command("remove <name>").description("\u5220\u9664 identity\uFF08\u6E05 token + \u82E5\u662F env default \u5219\u6E05\u7A7A\uFF09").action((name) => identityRemove(name));
13784
13471
  var user = program.command("user").description("\u7BA1\u7406\u79DF\u6237\u7528\u6237\u7684\u4E13\u7528\u51ED\u636E\u6D41\u7A0B");
13785
13472
  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));
13786
- 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");
13473
+ var chiron = program.command("chiron").description(
13474
+ "\u777F\u620E\uFF1A\u5B9E\u65BD\u751F\u547D\u5468\u671F\u7684\u4E00\u6761\u547D\u4EE4\u6811\u2014\u2014\u8FDB\u573A init / \u5F00\u5DE5\u81EA\u68C0 doctor / \u6478\u5E95 recon / \u5224\u9700\u6C42 triage / \u704C\u6570 seed / \u6539\u914D\u7F6E meta / \u56DE\u5F52 test"
13475
+ );
13787
13476
  chiron.command("init").description(
13788
13477
  "\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"
13789
13478
  ).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));
13790
13479
  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));
13791
13480
  chiron.command("doctor").description(
13792
13481
  "\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"
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));
13482
+ ).option("--project <dir>", "\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--env <name>", "\u8986\u76D6\u8981\u6838\u7684\u73AF\u5883\u522B\u540D\uFF08\u9ED8\u8BA4\u53D6 env.yaml\uFF1B\u591A\u73AF\u5883\u9879\u76EE\u7528\u5B83\u6328\u4E2A\u63A2\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\u63A2\u951A\u70B9").option("--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
13483
  var OUTPUT_OPT = ["--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table"];
13795
13484
  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
13485
  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));
@@ -13807,17 +13496,18 @@ jira.command("audit").description("\u4E00\u81F4\u6027\uFF1A\u72B6\u6001\u5DF2\u7
13807
13496
  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
13497
  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
13498
  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));
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");
13499
+ var delivery = program.command("delivery").description(
13500
+ "\u53D7\u63A7\u5199\u5165\uFF08\u6A2A\u5207\uFF0C\u4E0D\u5C5E\u4E8E\u67D0\u4E2A\u4EA4\u4ED8\u9636\u6BB5\uFF09\uFF1A\u5224\u98CE\u9669 assess \u2192 \u7ED1\u4E00\u6B21\u6027\u8BA1\u5212 prepare \u2192 \u9010\u6B21\u6279\u51C6 execute\uFF1Bmode \u770B/\u6539\u672C\u673A\u5199\u7B56\u7565"
13501
+ );
13811
13502
  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));
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));
13813
- var recon = delivery.command("recon").description("\u722C\u4E00\u4EFD\u53EF\u5E26\u8D70\u7684\u57FA\u7EBF\uFF1A\u6A21\u578B / \u5B57\u6BB5 / \u53EA\u8BFB\u95F8 / \u4F9D\u8D56\u56FE / \u7801\u8868 / \u53EF\u5199\u6027\u753B\u50CF").option("--env <name>", "\u76EE\u6807\u73AF\u5883\u522B\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--out <dir>", "\u4EA7\u7269\u6839\u76EE\u5F55\uFF08\u4EA7\u7269\u843D\u5728 <out>/recon/<\u79DF\u6237\u6BB5>/<\u6765\u6E90\u6BB5>\uFF09", ".").option("--state <s>", "\u53EA\u8BFB\u95F8\u7684 state\uFF08\u4EA7\u54C1\u91CC state \u4E0D\u53EF\u679A\u4E3E\uFF0C\u95F8\u7684\u8986\u76D6\u9762\u6C38\u8FDC\u662F state-scoped\uFF09").option("--model <key>", "\u5B9A\u5411\u91CD\u722C\uFF1A\u53EA\u91CD\u722C\u8FD9\u4E00\u4E2A\u6A21\u578B\uFF0C\u5176\u4F59\u6CBF\u7528\u4E0A\u4E00\u8F6E\u4EA7\u7269").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) => deliveryReconCommand(opts));
13503
+ var recon = chiron.command("recon").description("\u722C\u4E00\u4EFD\u53EF\u5E26\u8D70\u7684\u57FA\u7EBF\uFF1A\u6A21\u578B / \u5B57\u6BB5 / \u53EA\u8BFB\u95F8 / \u4F9D\u8D56\u56FE / \u7801\u8868 / \u53EF\u5199\u6027\u753B\u50CF").option("--env <name>", "\u76EE\u6807\u73AF\u5883\u522B\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--out <dir>", "\u4EA7\u7269\u6839\u76EE\u5F55\uFF08\u4EA7\u7269\u843D\u5728 <out>/recon/<\u79DF\u6237\u6BB5>/<\u6765\u6E90\u6BB5>\uFF09", ".").option("--state <s>", "\u53EA\u8BFB\u95F8\u7684 state\uFF08\u4EA7\u54C1\u91CC state \u4E0D\u53EF\u679A\u4E3E\uFF0C\u95F8\u7684\u8986\u76D6\u9762\u6C38\u8FDC\u662F state-scoped\uFF09").option("--model <key>", "\u5B9A\u5411\u91CD\u722C\uFF1A\u53EA\u91CD\u722C\u8FD9\u4E00\u4E2A\u6A21\u578B\uFF0C\u5176\u4F59\u6CBF\u7528\u4E0A\u4E00\u8F6E\u4EA7\u7269").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) => deliveryReconCommand(opts));
13814
13504
  recon.command("round").description("\u96F6\u7F51\u7EDC\uFF1A\u8BFB\u4E00\u4EFD\u5DF2\u843D\u76D8\u7684\u57FA\u7EBF\uFF0C\u5224\u65AD\u5B83\u662F\u4E0D\u662F\u4E00\u8F6E\u5B8C\u6574\u8DD1\u51FA\u6765\u7684\uFF08complete/mixed/unknown\uFF09").option("--dir <dir>", "\u4EA7\u7269\u76EE\u5F55\uFF08<out>/recon/<\u79DF\u6237\u6BB5>/<\u6765\u6E90\u6BB5>\uFF09", ".").action(
13815
13505
  (opts, cmd) => deliveryReconRoundCommand({
13816
13506
  ...opts,
13817
13507
  output: cmd.parent?.opts()?.output
13818
13508
  })
13819
13509
  );
13820
- var seed = delivery.command("seed").description(
13510
+ var seed = chiron.command("seed").description(
13821
13511
  "\u628A\u987E\u95EE\u624B\u4E0A\u7684**\u5BA2\u6237\u8868**\u53D8\u6210\u4EA7\u54C1\u91CC\u7684\u884C\u3002\u26A0\uFE0F \u4E0E\u9876\u5C42 `hcm import <path>` \u4E0D\u662F\u4E00\u56DE\u4E8B\uFF1A\u90A3\u4E00\u6761\u5403 DataPackage YAML\uFF08fixture \u6CE8\u5165\u5668\uFF09\uFF0C\u8FD9\u4E00\u65CF\u5403\u5BA2\u6237\u7684 Excel"
13822
13512
  );
13823
13513
  seed.command("find").argument("<term>", "\u8981\u627E\u7684\u8BCD\uFF1A\u5B57\u6BB5\u540D / \u4E2D\u6587\u540D\u79F0 / \u4E1A\u52A1\u8BDD\u672F\uFF08\u540C\u4E49\u8BCD\u3001\u63CF\u8FF0\u3001\u679A\u4E3E\u6807\u7B7E\u90FD\u641C\uFF09").description(
@@ -13843,7 +13533,7 @@ seed.command("verify").description(
13843
13533
  "\u53EA\u51FA\u53F0\u8D26\u90A3\u4E00\u5C42\uFF08\u96F6\u7F51\u7EDC\uFF0C\u4E00\u53D1\u8BF7\u6C42\u90FD\u4E0D\u53D1\uFF09\u3002\u26A0\uFE0F **\u5E93\u91CC\u73B0\u5728\u600E\u4E48\u6837\uFF0C\u90A3\u4E00\u8D9F\u4E00\u4E2A\u5B57\u90FD\u6CA1\u95EE** \u2014\u2014 \u522B\u62FF\u5B83\u5F53\u9A8C\u6536\u901A\u8FC7",
13844
13534
  false
13845
13535
  ).action((opts) => deliverySeedVerifyCommand(opts));
13846
- delivery.command("meta").description(
13536
+ chiron.command("meta").description(
13847
13537
  `\u6539\u4E00\u4EFD\u79DF\u6237 meta\uFF08\u5199 \u2192 \u6E05\u7F13\u5B58 \u2192 \u5B9A\u5411\u91CD\u722C \u2192 diff \u70B9\u540D\u5B57\u6BB5\uFF09\uFF0C\u5168\u7A0B\u5E26\u8865\u507F\u53F0\u8D26\u3002\u52A0 \`${VERIFY_ACTIVE_FLAG}\` \u518D\u7AD9\u5230 active \u5C42\u770B\u4E00\u773C**\u771F\u5B9E\u7528\u6237**\u770B\u5F97\u89C1\u4EC0\u4E48`
13848
13538
  ).option("--env <name>", "\u76EE\u6807\u73AF\u5883\u522B\u540D").option("--profile <name>", "\u8EAB\u4EFD\u6863\u6848").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").requiredOption(
13849
13539
  "--layer <layer>",
@@ -13865,7 +13555,7 @@ delivery.command("gate0").description("\u96F6\u7F51\u7EDC\uFF1A\u626B\u4E00\u4EF
13865
13555
  "--mapping <file>",
13866
13556
  "\u987E\u95EE\u624B\u5199\u7684\u6620\u5C04\u5DE5\u4EF6\uFF08naturalKey \u8FD9\u4E00\u7C7B\u7684\u552F\u4E00\u6765\u6E90\uFF09\uFF1B\u4E0D\u7ED9 \u21D2 \u90A3\u4E00\u7C7B\u6052\u7EFF \u21D2 rc=2"
13867
13557
  ).option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => deliveryGate0Command(opts));
13868
- delivery.command("triage").description(
13558
+ chiron.command("triage").description(
13869
13559
  "\u9700\u6C42\u5206\u8BCA\uFF1A\u4E03\u7C7B\u627F\u8F7D\u7269\u7531\u672C\u547D\u4EE4\u73B0\u63A2\u73B0\u586B\uFF08\u987E\u95EE\u8DF3\u4E0D\u4E86\u6B65\uFF09\uFF0C\u7ED3\u8BBA\u4E0E\u8BC1\u636E\u7531\u4F60\u7ED9\uFF0C\u5B83\u53EA\u5224\u4E24\u8005\u6253\u4E0D\u6253\u67B6"
13870
13560
  ).requiredOption(
13871
13561
  "--requests <file>",
@@ -13874,7 +13564,6 @@ delivery.command("triage").description(
13874
13564
  "--recon <dir>",
13875
13565
  "\u57FA\u7EBF\u4EA7\u7269\u76EE\u5F55\uFF08<out>/recon/<\u79DF\u6237\u6BB5>/<\u6765\u6E90\u6BB5>\uFF09\uFF1B\u4E0D\u7ED9\u5219\u6309\u722C\u53D6\u8EAB\u4EFD\u73B0\u7B97\u4E00\u4EFD"
13876
13566
  ).option("--out <dir>", "\u4EA7\u7269\u6839\uFF08\u5199 work/triage.md\uFF09", ".").option("--capabilities <caps>", "\u672C\u6B21\u63A2\u6D4B\u58F0\u660E\u7684 capability \u4E32", "default").action((opts) => deliveryTriageCommand(opts));
13877
- delivery.command("init").description("\u751F\u6210\u5BA2\u6237\u9879\u76EE\u4ED3\u9AA8\u67B6\u3001\u73AF\u5883\u6E05\u5355\u3001\u6210\u5458 setup \u4E0E\u672C\u673A\u53D7\u63A7\u4EA4\u4ED8\u914D\u7F6E").option("--project <dir>", "HCM \u987E\u95EE\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--env <name>", "\u521D\u59CB\u5316\u54EA\u4E2A\u73AF\u5883\uFF08\u9ED8\u8BA4 HCM_ENV / activeEnv\uFF09").option("--mode <mode>", "\u672C\u673A\u521D\u59CB\u4EA4\u4ED8\u6A21\u5F0F\uFF1Acontrolled | plan-only", "plan-only").option("--approved-by <person>", "\u5207\u5230 controlled \u65F6\u5FC5\u586B\uFF1A\u672C\u6B21\u660E\u786E\u6279\u51C6\u7684\u9879\u76EE\u8D1F\u8D23\u4EBA").option("--reason <text>", "\u5207\u5230 controlled \u65F6\u5FC5\u586B\uFF1A\u672C\u6B21\u5BF9\u8BDD\u6216\u4EFB\u52A1\u4E66\u4E2D\u7684\u6388\u6743\u4F9D\u636E").option("--force", "\u8986\u76D6\u5DF2\u5B58\u5728\u7684\u9879\u76EE\u914D\u7F6E").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => deliveryInitCommand(opts));
13878
13567
  delivery.command("mode").description("\u6309\u73AF\u5883\u770B/\u6539\u672C\u673A\u4EA4\u4ED8\u6A21\u5F0F\uFF1B\u4E0D\u5E26 --set \u53EA\u8BFB\uFF0C\u5E26 --set \u53EA\u6539\u76EE\u6807\u73AF\u5883").option("--project <dir>", "HCM \u987E\u95EE\u9879\u76EE\u6839\u76EE\u5F55", ".").requiredOption("--env <name>", "\u76EE\u6807\u73AF\u5883\uFF08\u5FC5\u586B\uFF1B\u4E0D\u7EE7\u627F\u5168\u5C40 activeEnv\uFF09").option("--set <mode>", "\u6539\u4E3A\uFF1Acontrolled | plan-only").option("--approved-by <person>", "\u5207\u5230 controlled \u65F6\u5FC5\u586B\uFF1A\u672C\u6B21\u660E\u786E\u6279\u51C6\u7684\u9879\u76EE\u8D1F\u8D23\u4EBA").option("--reason <text>", "\u5207\u5230 controlled \u65F6\u5FC5\u586B\uFF1A\u672C\u6B21\u5BF9\u8BDD\u6216\u4EFB\u52A1\u4E66\u4E2D\u7684\u6388\u6743\u4F9D\u636E").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => deliveryModeCommand(opts));
13879
13568
  delivery.command("prepare").description("\u628A\u53D7\u652F\u6301\u7684 R2 argv \u4E0E\u9501\u3001\u8FD0\u884C\u65F6\u548C\u53D8\u66F4/\u56DE\u6EDA\u8BF4\u660E\u7ED1\u5B9A\u4E3A\u77ED\u65F6\u6267\u884C\u8BA1\u5212").requiredOption("--change-ref <file>", "\u9879\u76EE work/ \u6216 decisions/ \u4E0B\u7684\u53D8\u66F4\u8BF4\u660E").requiredOption("--rollback-ref <file>", "\u9879\u76EE work/ \u6216 decisions/ \u4E0B\u7684\u56DE\u6EDA\u8BF4\u660E").requiredOption("--evidence-dir <dir>", "\u9879\u76EE evidence/ \u4E0B\u7684\u6536\u636E\u76EE\u5F55").option("--project <dir>", "HCM \u987E\u95EE\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--ttl-seconds <n>", "\u6709\u6548\u671F\u79D2\u6570\uFF0860-3600\uFF09", "900").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").allowUnknownOption(true).argument("<command...>", "\u88AB\u7ED1\u5B9A\u7684 R2 HCM \u5B50\u547D\u4EE4\u4E0E\u53C2\u6570\uFF0C\u4E0D\u5305\u542B hcm \u672C\u8EAB").action((command, opts) => deliveryPrepareCommand(command, opts));
13880
13569
  delivery.command("execute <planId>").description("\u9010\u6B21\u6279\u51C6\u540E\u6D88\u8D39\u77ED\u65F6\u8BA1\u5212\uFF0C\u5E76\u6267\u884C\u4E00\u6B21\u4E0E\u8BA1\u5212\u5B8C\u5168\u76F8\u540C\u7684 R2 argv").option("--project <dir>", "HCM \u987E\u95EE\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--output <fmt>", "\u6536\u636E\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").allowUnknownOption(true).argument("[command...]", "\u4E0E prepare \u5B8C\u5168\u76F8\u540C\u7684 R2 HCM \u5B50\u547D\u4EE4\u4E0E\u53C2\u6570").action((planId, command, opts) => deliveryExecuteCommand(planId, command, opts));
@@ -13998,7 +13687,7 @@ program.command("update <Model>").description("\u66F4\u65B0\u4E00\u6761 Model \u
13998
13687
  ).action((model, opts) => updateCommand(model, opts));
13999
13688
  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));
14000
13689
  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));
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));
13690
+ 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));
14002
13691
  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");
14003
13692
  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));
14004
13693
  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(