@hcmai/cli 0.10.0 → 0.11.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
@@ -343,7 +343,7 @@ __export(attachment_args_exports, {
343
343
  });
344
344
  import * as fs3 from "fs";
345
345
  import * as os from "os";
346
- import * as path2 from "path";
346
+ import * as path3 from "path";
347
347
  function extractAtFileTokens(text) {
348
348
  const paths = [];
349
349
  const re = /@(?:"([^"]+)"|'([^']+)'|(\S+))/g;
@@ -379,7 +379,7 @@ function isBareFilePath(text) {
379
379
  return isExistingFile(abs) ? abs : null;
380
380
  }
381
381
  function expandHome(p) {
382
- return p.startsWith("~") ? path2.join(os.homedir(), p.slice(1)) : path2.resolve(p);
382
+ return p.startsWith("~") ? path3.join(os.homedir(), p.slice(1)) : path3.resolve(p);
383
383
  }
384
384
  function isExistingFile(p) {
385
385
  try {
@@ -752,8 +752,8 @@ var init_TerminalRenderer = __esm({
752
752
  }
753
753
  }
754
754
  /** 来源行(仅子代理触发,agentPath ≥2 段时显示 `↑ 来自 a › b`,对齐 Web)。 */
755
- originLine(path16) {
756
- const segs = path16.split(".").filter(Boolean);
755
+ originLine(path17) {
756
+ const segs = path17.split(".").filter(Boolean);
757
757
  if (segs.length < 2) return "";
758
758
  const names = segs.map((k) => agentDisplayName(k));
759
759
  return chalk.gray(` \u2191 \u6765\u81EA ${names.join(" \u203A ")}`) + "\n";
@@ -1935,8 +1935,8 @@ function agentLabel(agentId) {
1935
1935
  if (/^[0-9a-f]{8}-[0-9a-f-]{27}$/i.test(agentId)) return `agent \u2026${agentId.slice(-4)}`;
1936
1936
  return agentDisplayName(agentId);
1937
1937
  }
1938
- function originLine(path16) {
1939
- const segs = (path16 ?? "").split(".").filter(Boolean);
1938
+ function originLine(path17) {
1939
+ const segs = (path17 ?? "").split(".").filter(Boolean);
1940
1940
  if (segs.length < 2) return null;
1941
1941
  return `\u6765\u81EA ${segs.map((k) => agentDisplayName(k)).join(" \u203A ")}`;
1942
1942
  }
@@ -2359,7 +2359,7 @@ function launchBrowser(url, platform = process.platform, onFailure) {
2359
2359
  child.unref();
2360
2360
  }
2361
2361
  async function runOpen(target, args, deps) {
2362
- const path16 = normalizeTarget(target);
2362
+ const path17 = normalizeTarget(target);
2363
2363
  if (!deps.frontend?.trim()) {
2364
2364
  throw new CliError3({
2365
2365
  code: CliErrorCode2.INVALID_ARGUMENT,
@@ -2367,17 +2367,46 @@ async function runOpen(target, args, deps) {
2367
2367
  });
2368
2368
  }
2369
2369
  const { ticket, expiresIn } = await deps.mintTicket();
2370
- const url = buildBrowserLoginUrl(deps.frontend, ticket, path16);
2370
+ const url = buildBrowserLoginUrl(deps.frontend, ticket, path17);
2371
2371
  if (args.printUrl) {
2372
2372
  deps.write(`${url}
2373
2373
  `);
2374
2374
  } else {
2375
2375
  deps.launch(url);
2376
- deps.write(`\u5DF2\u7528\u5F53\u524D\u8EAB\u4EFD\u6253\u5F00 ${path16}\uFF08\u7968\u636E ${expiresIn ?? 60}s \u5185\u6709\u6548\uFF0C\u53EA\u80FD\u7528\u4E00\u6B21\uFF09
2376
+ deps.write(`\u5DF2\u7528\u5F53\u524D\u8EAB\u4EFD\u6253\u5F00 ${path17}\uFF08\u7968\u636E ${expiresIn ?? 60}s \u5185\u6709\u6548\uFF0C\u53EA\u80FD\u7528\u4E00\u6B21\uFF09
2377
2377
  `);
2378
2378
  }
2379
2379
  return { url, expiresIn };
2380
2380
  }
2381
+ function mintBrowserTicket(client3, envName) {
2382
+ return async () => {
2383
+ let data;
2384
+ try {
2385
+ const resp = await client3.raw().post(BROWSER_TICKET_PATH, {});
2386
+ data = resp.data?.data ?? resp.data ?? {};
2387
+ } catch (e) {
2388
+ const err = e;
2389
+ if (err?.isAxiosError && err.response?.status === 404) {
2390
+ throw new CliError3({
2391
+ code: CliErrorCode2.INVALID_ARGUMENT,
2392
+ message: `\u540E\u7AEF\u6CA1\u6709 ${BROWSER_TICKET_PATH}\uFF08\u9700\u8981\u542B\u6D4F\u89C8\u5668\u4F1A\u8BDD\u7968\u636E\u7684\u540E\u7AEF\u7248\u672C\uFF09\uFF0C\u5347\u7EA7\u540E\u7AEF\u540E\u518D\u8BD5\u3002\u672C\u547D\u4EE4\u4E0D\u4F1A\u628A\u4F1A\u8BDD token \u62FC\u8FDB URL \u515C\u5E95\u3002`
2393
+ });
2394
+ }
2395
+ if (err?.isAxiosError) throw fromAxiosError(err, envName);
2396
+ throw e;
2397
+ }
2398
+ if (typeof data.ticket !== "string" || !data.ticket) {
2399
+ throw new CliError3({
2400
+ code: CliErrorCode2.INVALID_ARGUMENT,
2401
+ message: "\u94F8\u7968\u54CD\u5E94\u91CC\u6CA1\u6709 ticket \u2014\u2014 \u540E\u7AEF\u7248\u672C\u4E0E\u672C CLI \u7684\u5951\u7EA6\u5BF9\u4E0D\u4E0A"
2402
+ });
2403
+ }
2404
+ return {
2405
+ ticket: data.ticket,
2406
+ expiresIn: typeof data.expiresIn === "number" ? data.expiresIn : void 0
2407
+ };
2408
+ };
2409
+ }
2381
2410
  async function openCommand(target, args) {
2382
2411
  try {
2383
2412
  const ctx = await getActiveAuthContextFromCli(args);
@@ -2388,33 +2417,7 @@ async function openCommand(target, args) {
2388
2417
  { printUrl: args.printUrl, envName: ctx.env },
2389
2418
  {
2390
2419
  frontend: ctx.frontend ?? envCfg.frontend,
2391
- mintTicket: async () => {
2392
- let data;
2393
- try {
2394
- const resp = await client3.raw().post(BROWSER_TICKET_PATH, {});
2395
- data = resp.data?.data ?? resp.data ?? {};
2396
- } catch (e) {
2397
- const err = e;
2398
- if (err?.isAxiosError && err.response?.status === 404) {
2399
- throw new CliError3({
2400
- code: CliErrorCode2.INVALID_ARGUMENT,
2401
- message: `\u540E\u7AEF\u6CA1\u6709 ${BROWSER_TICKET_PATH}\uFF08\u9700\u8981\u542B\u6D4F\u89C8\u5668\u4F1A\u8BDD\u7968\u636E\u7684\u540E\u7AEF\u7248\u672C\uFF09\uFF0C\u5347\u7EA7\u540E\u7AEF\u540E\u518D\u8BD5\u3002\u672C\u547D\u4EE4\u4E0D\u4F1A\u628A\u4F1A\u8BDD token \u62FC\u8FDB URL \u515C\u5E95\u3002`
2402
- });
2403
- }
2404
- if (err?.isAxiosError) throw fromAxiosError(err, ctx.env);
2405
- throw e;
2406
- }
2407
- if (typeof data.ticket !== "string" || !data.ticket) {
2408
- throw new CliError3({
2409
- code: CliErrorCode2.INVALID_ARGUMENT,
2410
- message: "\u94F8\u7968\u54CD\u5E94\u91CC\u6CA1\u6709 ticket \u2014\u2014 \u540E\u7AEF\u7248\u672C\u4E0E\u672C CLI \u7684\u5951\u7EA6\u5BF9\u4E0D\u4E0A"
2411
- });
2412
- }
2413
- return {
2414
- ticket: data.ticket,
2415
- expiresIn: typeof data.expiresIn === "number" ? data.expiresIn : void 0
2416
- };
2417
- },
2420
+ mintTicket: mintBrowserTicket(client3, ctx.env),
2418
2421
  launch: launchBrowser,
2419
2422
  write: (line) => process.stdout.write(line)
2420
2423
  }
@@ -3327,6 +3330,7 @@ import {
3327
3330
 
3328
3331
  // src/commands/env.ts
3329
3332
  init_exit();
3333
+ import path from "path";
3330
3334
  import axios3 from "axios";
3331
3335
  import {
3332
3336
  loadEnv as loadEnv3,
@@ -3335,7 +3339,9 @@ import {
3335
3339
  deleteEnv,
3336
3340
  loadGlobalConfig as loadGlobalConfig3,
3337
3341
  resolveEnvContext as resolveEnvContext3,
3342
+ resolveProjectEnvironment as resolveProjectEnvironment2,
3338
3343
  discoverProjectEnv as discoverProjectEnv2,
3344
+ findEnvByEndpoint as findEnvByEndpoint2,
3339
3345
  saveGlobalConfig as saveGlobalConfig2,
3340
3346
  loadIdentity as loadIdentity3,
3341
3347
  saveIdentity as saveIdentity2,
@@ -3366,29 +3372,103 @@ function formatTable(rows2) {
3366
3372
  }
3367
3373
 
3368
3374
  // src/commands/env.ts
3369
- async function envList() {
3375
+ function renderEnvListing(listing) {
3376
+ const slotTable = formatTable(
3377
+ listing.slots.map((s) => ({
3378
+ active: s.name === listing.activeEnv ? "*" : " ",
3379
+ name: s.temp ? `${s.name} (\u4E34\u65F6\xB7\u672A\u4FDD\u5B58)` : s.name,
3380
+ endpoint: s.endpoint,
3381
+ frontend: s.frontend,
3382
+ tenant: s.tenant,
3383
+ identity: s.identity
3384
+ }))
3385
+ );
3386
+ if (!listing.project) return slotTable;
3387
+ const { file, rows: rows2, effective, source } = listing.project;
3388
+ const out = [];
3389
+ const effectiveRow = rows2.find((r) => r.name === effective);
3390
+ out.push(
3391
+ effective ? `\u2192 \u8FD9\u4E2A\u76EE\u5F55\u7528 ${effective}\uFF08\u6765\u81EA ${source === "env.yaml" ? `${file} \u7684 default` : source}\uFF09${effectiveRow?.slot ? `\uFF0C\u51ED\u636E\u53D6\u672C\u673A\u69FD ${effectiveRow.slot}` : "\uFF0C\u4F46\u5B83\u8FD8\u6CA1\u5728\u672C\u673A\u767B\u5F55\u8FC7"}` : `\u2192 \u8FD9\u4E2A\u76EE\u5F55\u6709 ${file}\uFF0C\u4F46\u751F\u6548\u7684\u662F\u672C\u673A\u69FD ${listing.activeEnv}\uFF08${source ?? "activeEnv"} \u6307\u7684\u540D\u5B57\u4E0D\u5728 ${file} \u91CC\uFF09`
3392
+ );
3393
+ out.push("");
3394
+ out.push(`\u9879\u76EE\u73AF\u5883\uFF08${file}\uFF09`);
3395
+ out.push(
3396
+ formatTable(
3397
+ rows2.map((r) => ({
3398
+ use: r.name === effective ? "*" : " ",
3399
+ name: r.name,
3400
+ endpoint: r.endpoint,
3401
+ tenant: r.tenant,
3402
+ slot: r.slot ?? "-",
3403
+ danger: r.danger ? "yes" : ""
3404
+ }))
3405
+ )
3406
+ );
3407
+ out.push("");
3408
+ out.push(
3409
+ listing.hiddenSlots ? `\u672C\u673A\u69FD\uFF08\u53EA\u5217\u8DDF\u672C\u9879\u76EE\u6709\u5173\u7684\uFF1B\u53E6\u6709 ${listing.hiddenSlots} \u4E2A\u4E0E\u672C\u9879\u76EE\u65E0\u5173\uFF0Chcm env list --all \u770B\u5168\u90E8\uFF09` : "\u672C\u673A\u69FD\uFF08\u8DE8\u9879\u76EE\u5171\u7528\uFF0C\u51ED\u636E\u5B58\u8FD9\u91CC\uFF09"
3410
+ );
3411
+ out.push(slotTable || " \uFF08\u672C\u9879\u76EE\u7684\u73AF\u5883\u4E00\u4E2A\u90FD\u8FD8\u6CA1\u5728\u672C\u673A\u767B\u5F55\u8FC7\uFF09");
3412
+ out.push("");
3413
+ if (effective !== null && effectiveRow?.slot !== listing.activeEnv) {
3414
+ out.push(`\u26A0\uFE0F \u672C\u673A activeEnv \u662F ${listing.activeEnv}\uFF0C\u5728\u8FD9\u4E2A\u76EE\u5F55\u4E0B\u4E0D\u751F\u6548\u2014\u2014${file} \u8BF4\u4E86\u7B97\uFF08hcm env use \u6539\u7684\u662F activeEnv\uFF09\u3002`);
3415
+ }
3416
+ for (const r of rows2) {
3417
+ if (r.slot === null) out.push(` ${r.name} \u8FD8\u6CA1\u5728\u672C\u673A\u767B\u5F55\uFF1Ahcm login --env ${r.name}`);
3418
+ }
3419
+ out.push(" \u6539\u9879\u76EE\u73AF\u5883\u7528 hcm chiron env add/edit/remove\uFF08\u8981\u63D0\u4EA4\u8FDB\u4ED3\uFF09\uFF1B\u6539\u672C\u673A\u69FD\u7528 hcm env add/edit\u3002");
3420
+ return out.join("\n");
3421
+ }
3422
+ async function collectEnvListing(args = {}) {
3423
+ const names = await listEnvs();
3424
+ const g = await loadGlobalConfig3();
3425
+ const slots = await Promise.all(
3426
+ names.map(async (name) => {
3427
+ const cfg = await loadEnv3(name);
3428
+ return {
3429
+ name,
3430
+ endpoint: cfg.endpoint,
3431
+ frontend: cfg.frontend ?? "(none)",
3432
+ tenant: cfg.tenantId ?? "1",
3433
+ identity: cfg.defaultIdentity ?? "(none)",
3434
+ // 临时槽位在列表里如实标出来:它不是使用者起的名字,也随时会被下一次
3435
+ // `login --code` 覆盖 —— 显示成一个普通 env 名会让人以为它是自己建的。
3436
+ temp: isTempEnv2(name)
3437
+ };
3438
+ })
3439
+ );
3440
+ const listing = { slots, activeEnv: g.activeEnv };
3441
+ const discovered = await discoverProjectEnv2();
3442
+ if (!discovered) return listing;
3443
+ const selected = await resolveProjectEnvironment2({}, process.env);
3444
+ const rows2 = await Promise.all(
3445
+ Object.entries(discovered.config.environments).map(async ([name, env2]) => {
3446
+ const found = await findEnvByEndpoint2(env2.endpoint, env2.tenant, { strictTenant: true, activeEnv: g.activeEnv });
3447
+ return { name, endpoint: env2.endpoint, tenant: env2.tenant, danger: env2.danger === true, slot: found?.name ?? null };
3448
+ })
3449
+ );
3450
+ if (!args.all) {
3451
+ const relevant = new Set(rows2.map((r) => r.slot).filter((n) => n !== null));
3452
+ const kept = slots.filter((s) => relevant.has(s.name));
3453
+ listing.hiddenSlots = slots.length - kept.length;
3454
+ listing.slots = kept;
3455
+ }
3456
+ const relative2 = path.relative(process.cwd(), discovered.path);
3457
+ listing.project = {
3458
+ file: relative2.startsWith(".") ? relative2 : `./${relative2}`,
3459
+ rows: rows2,
3460
+ effective: selected?.name ?? null,
3461
+ source: selected?.source ?? null
3462
+ };
3463
+ return listing;
3464
+ }
3465
+ async function envList(args = {}) {
3370
3466
  try {
3371
- const envs = await listEnvs();
3372
- const g = await loadGlobalConfig3();
3373
- if (envs.length === 0) {
3467
+ const listing = await collectEnvListing(args);
3468
+ if (listing.slots.length === 0 && !listing.project) {
3374
3469
  return exitOk("(no envs; run `hcm env add <name> --endpoint <url>`)");
3375
3470
  }
3376
- const rows2 = await Promise.all(
3377
- envs.map(async (name) => {
3378
- const cfg = await loadEnv3(name);
3379
- return {
3380
- active: name === g.activeEnv ? "*" : " ",
3381
- // 临时槽位在列表里如实标出来:它不是使用者起的名字,也随时会被下一次
3382
- // `login --code` 覆盖 —— 显示成一个普通 env 名会让人以为它是自己建的。
3383
- name: isTempEnv2(name) ? `${name} (\u4E34\u65F6\xB7\u672A\u4FDD\u5B58)` : name,
3384
- endpoint: cfg.endpoint,
3385
- frontend: cfg.frontend ?? "(none)",
3386
- tenant: cfg.tenantId ?? "1",
3387
- identity: cfg.defaultIdentity ?? "(none)"
3388
- };
3389
- })
3390
- );
3391
- return exitOk(formatTable(rows2));
3471
+ return exitOk(renderEnvListing(listing));
3392
3472
  } catch (e) {
3393
3473
  exitWithError(e);
3394
3474
  }
@@ -3835,7 +3915,7 @@ async function readJsonObjectInput(options) {
3835
3915
  import { createHash as createHash2 } from "crypto";
3836
3916
  import { CliError as CliError10, CliErrorCode as CliErrorCode9 } from "@hcmai/sdk";
3837
3917
  import { promises as fs2 } from "fs";
3838
- import path from "path";
3918
+ import path2 from "path";
3839
3919
  var MAX_ARTIFACT_BYTES = 10 * 1024 * 1024;
3840
3920
  var ARTIFACT_ENCODING_BASE64 = "base64";
3841
3921
  var SHA256_HEX = /^[0-9a-f]{64}$/;
@@ -3867,7 +3947,7 @@ function parseArtifactEnvelope(data) {
3867
3947
  }
3868
3948
  var fail = (message, nextStep) => new CliError10({ code: CliErrorCode9.INVALID_ARGUMENT, message, context: { nextStep } });
3869
3949
  async function writeArtifact(artifact, target, opts = {}) {
3870
- const abs = path.resolve(target);
3950
+ const abs = path2.resolve(target);
3871
3951
  const stat = await fs2.lstat(abs).catch(() => null);
3872
3952
  if (stat) {
3873
3953
  if (stat.isSymbolicLink()) {
@@ -3896,9 +3976,9 @@ async function writeArtifact(artifact, target, opts = {}) {
3896
3976
  if (digest !== artifact.sha256) {
3897
3977
  throw fail(`SHA-256 \u5BF9\u4E0D\u4E0A\uFF1A\u4FE1\u5C01\u8BF4 ${artifact.sha256}\uFF0C\u5B9E\u9645 ${digest}`, "\u540C\u4E0A\uFF1A\u5185\u5BB9\u4E0E\u6458\u8981\u4E0D\u4E00\u81F4\uFF0C\u8FD9\u4EFD\u5236\u54C1\u4E0D\u53EF\u4FE1\uFF0C\u4E0D\u843D\u76D8\u3002");
3898
3978
  }
3899
- const dir = path.dirname(abs);
3979
+ const dir = path2.dirname(abs);
3900
3980
  await fs2.mkdir(dir, { recursive: true });
3901
- const tmp = path.join(dir, `.tmp-artifact-${process.pid}-${Date.now()}`);
3981
+ const tmp = path2.join(dir, `.tmp-artifact-${process.pid}-${Date.now()}`);
3902
3982
  try {
3903
3983
  await fs2.writeFile(tmp, bytes, { mode: 384, flag: "wx" });
3904
3984
  await fs2.rename(tmp, abs);
@@ -4363,8 +4443,8 @@ import {
4363
4443
  formatObject as formatObject7,
4364
4444
  fromAxiosError as fromAxiosError9
4365
4445
  } from "@hcmai/sdk";
4366
- function collectYmlFiles(path16) {
4367
- if (statSync(path16).isFile()) return [path16];
4446
+ function collectYmlFiles(path17) {
4447
+ if (statSync(path17).isFile()) return [path17];
4368
4448
  const out = [];
4369
4449
  const walk = (dir) => {
4370
4450
  for (const name of readdirSync(dir).sort()) {
@@ -4373,7 +4453,7 @@ function collectYmlFiles(path16) {
4373
4453
  else if (full.endsWith(".yml") || full.endsWith(".yaml")) out.push(full);
4374
4454
  }
4375
4455
  };
4376
- walk(path16);
4456
+ walk(path17);
4377
4457
  return out.sort();
4378
4458
  }
4379
4459
  var DRY_RUN_CLIENT = {
@@ -4381,9 +4461,9 @@ var DRY_RUN_CLIENT = {
4381
4461
  create: async () => ({ id: "" }),
4382
4462
  update: async () => ({})
4383
4463
  };
4384
- async function importCommand(path16, args) {
4464
+ async function importCommand(path17, args) {
4385
4465
  try {
4386
- const files = collectYmlFiles(path16);
4466
+ const files = collectYmlFiles(path17);
4387
4467
  const fixtures = files.map(
4388
4468
  (f) => parseFixture(readFileSync2(f, "utf8"), relative(process.cwd(), f))
4389
4469
  );
@@ -5893,7 +5973,7 @@ function emit3(payload, fmt) {
5893
5973
  init_exit();
5894
5974
  import { promises as fsp2 } from "fs";
5895
5975
  import os2 from "os";
5896
- import path5 from "path";
5976
+ import path6 from "path";
5897
5977
  import { createHash as createHash4 } from "crypto";
5898
5978
  import {
5899
5979
  createHttpClient as createHttpClient2,
@@ -6032,15 +6112,88 @@ function checkCrossSourceRequires(catalog) {
6032
6112
  return out;
6033
6113
  }
6034
6114
 
6115
+ // src/commands/delivery-project-scaffold.ts
6116
+ import { promises as fs6 } from "fs";
6117
+ var AGENT_BEGIN = "<!-- hcm-delivery-project:begin -->";
6118
+ var AGENT_END = "<!-- hcm-delivery-project:end -->";
6119
+ async function writeIfAbsent(file, content, result, relative2, mode = 420) {
6120
+ try {
6121
+ await fs6.writeFile(file, content, { encoding: "utf8", mode, flag: "wx" });
6122
+ result.created.push(relative2);
6123
+ return true;
6124
+ } catch (cause) {
6125
+ if (cause.code !== "EEXIST") throw cause;
6126
+ await assertRegularFile(file);
6127
+ result.preserved.push(relative2);
6128
+ return false;
6129
+ }
6130
+ }
6131
+ async function ensureDirectory(directory) {
6132
+ await fs6.mkdir(directory, { recursive: true });
6133
+ const stat = await fs6.lstat(directory);
6134
+ if (!stat.isDirectory() || stat.isSymbolicLink()) {
6135
+ throw new Error(`\u811A\u624B\u67B6\u8DEF\u5F84\u4E0D\u662F\u666E\u901A\u76EE\u5F55\uFF1A${directory}`);
6136
+ }
6137
+ }
6138
+ async function assertRegularFile(file) {
6139
+ const stat = await fs6.lstat(file);
6140
+ if (!stat.isFile() || stat.isSymbolicLink()) {
6141
+ throw new Error(`\u811A\u624B\u67B6\u8DEF\u5F84\u4E0D\u662F\u666E\u901A\u6587\u4EF6\uFF1A${file}`);
6142
+ }
6143
+ }
6144
+ function upsertBlock(existing, begin, end, block) {
6145
+ const start = existing.indexOf(begin);
6146
+ const finish2 = existing.indexOf(end);
6147
+ const markersAreMalformed = start < 0 !== finish2 < 0 || start >= 0 && (finish2 < start || existing.lastIndexOf(begin) !== start || existing.lastIndexOf(end) !== finish2);
6148
+ if (markersAreMalformed) {
6149
+ throw new Error(`\u6258\u7BA1\u5757\u6807\u8BB0\u635F\u574F\u6216\u91CD\u590D\uFF0C\u62D2\u7EDD\u8986\u76D6\uFF1A${begin} \u2026 ${end}`);
6150
+ }
6151
+ let next;
6152
+ if (start >= 0 && finish2 >= start) {
6153
+ next = `${existing.slice(0, start)}${block}${existing.slice(finish2 + end.length)}`;
6154
+ } else {
6155
+ const prefix = existing.trimEnd();
6156
+ next = `${prefix}${prefix ? "\n\n" : ""}${block}`;
6157
+ }
6158
+ return `${next.trimEnd()}
6159
+ `;
6160
+ }
6161
+
6162
+ // src/commands/chiron-agent-boundary.ts
6163
+ var BUILTIN_BOUNDARY = [
6164
+ "# HCM \u987E\u95EE\u9879\u76EE\u8FB9\u754C",
6165
+ "",
6166
+ "- \u53EA\u4F7F\u7528\u672C\u9879\u76EE `hcm-skills/` \u91CC\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",
6167
+ "- **\u63A5\u5230\u9700\u6C42\u5148\u505A\u4E00\u8F6E\u53EA\u8BFB\u6838\u5BF9**\uFF08\u8FB9\u754C\u3001\u6280\u80FD\u6E05\u5355\u3001CLI \u7248\u672C\u3001\u73AF\u5883\u4E0E\u8EAB\u4EFD\uFF09\uFF0C\u7ED9\u51FA READY / READY WITH RISKS / BLOCKED \u518D\u52A8\u624B\u3002\u987E\u95EE\u4E0D\u9700\u8981\u7C98\u4EFB\u4F55\u5F00\u573A\u767D\uFF0C\u8FD9\u6761\u5C31\u662F\u5F00\u573A\u767D\u3002",
6168
+ "- \u9700\u6C42\u8BF4\u5F97\u542B\u7CCA\u5C31\u8FFD\u95EE\uFF0C\u4E0D\u8981\u66FF\u5BA2\u6237\u731C\u53E3\u5F84\uFF1B\u53E3\u5F84\u4E0E\u8303\u56F4\u5199\u8FDB `requirements/`\uFF0C\u5BA2\u6237\u62CD\u677F\u7684\u5199\u8FDB `decisions/`\u3002",
6169
+ "- \u9879\u76EE\u5BF9\u7740\u7684\u73AF\u5883\u5728 `env.yaml`\uFF08default / environments\uFF0C\u5404\u73AF\u5883\u542B endpoint / frontend / tenant / roles\uFF09\uFF0C\u8EAB\u4EFD\u5728\u672C\u673A `hcm login`\u3002\u6BCF\u6B21\u5F00\u5DE5\u5148\u8DD1 `hcm chiron doctor`\uFF1B\u73AF\u5883\u4E8B\u5B9E\u5FC5\u987B\u73B0\u67E5\uFF0C\u4E0D\u51ED\u8BB0\u5FC6\u586B\u5199\u3002",
6170
+ "- \u5199\u6388\u6743\u53EA\u8BA4\u9879\u76EE\u8D1F\u8D23\u4EBA\u5728**\u672C\u6B21\u5BF9\u8BDD\u6216\u4EFB\u52A1\u4E66**\u91CC\u7684\u660E\u786E\u6279\u51C6\uFF1B\u5BA2\u6237\u53E3\u5934\u8981\u6C42\u6216\u7FA4\u6D88\u606F\u4E0D\u662F\u6267\u884C\u6388\u6743\u3002",
6171
+ "- \u5199\u524D\u5FC5\u987B\u8BF4\u660E\u5BF9\u8C61\u3001\u8303\u56F4\u3001\u5F71\u54CD\u4E0E\u56DE\u9000\u5E76\u53D6\u5F97\u672C\u6B21\u660E\u786E\u786E\u8BA4\u3002\u975E\u4EA4\u4E92\u8FD0\u884C\u62FF\u4E0D\u5230\u786E\u8BA4\u65F6**\u505C\u5728\u8BA1\u5212\u3001\u4E0D\u8981\u5199**\uFF0C\u7ED3\u8BBA\u5FC5\u987B\u4E3A `BLOCKED` \u5E76\u9644\u8BA1\u5212\u3002",
6172
+ "- \u76EE\u5F55\u7EA6\u5B9A\uFF1A`requirements/` \u5BA2\u6237\u9700\u6C42 \xB7 `deliverables/` \u4EA4\u4ED8\u7269 \xB7 `evidence/` \u622A\u56FE\u4E0E\u6536\u636E \xB7 `cases/` \u6C89\u6DC0\u7684\u6848\u4F8B \xB7 `gaps/` \u4EA7\u54C1\u505A\u4E0D\u5230\u7684\u53F0\u8D26 \xB7 `decisions/` \u51B3\u7B56 \xB7 `customer-docs/` \u5BA2\u6237\u8D44\u6599 \xB7 `work/` \u53D8\u66F4\u4E0E\u56DE\u6EDA\u8BF4\u660E\u3002",
6173
+ "- \u649E\u5230\u4EA7\u54C1\u505A\u4E0D\u5230\uFF1A\u5148\u5199 `gaps/` \u53F0\u8D26\u5E76\u7B54\u6E05\u4E09\u95EE\uFF0C\u7528 `hcm chiron gap search` \u67E5\u91CD\uFF0C\u7ECF\u987E\u95EE\u786E\u8BA4\u540E `hcm chiron gap submit` \u63D0\u5230 Jira\uFF08\u4EA7\u54C1\u5BF9\u5916\u7684\u7EDF\u4E00\u9762\uFF09\uFF0C\u62A5\u544A\u5199 `BLOCKED \xB7 \u5DF2\u63D0 <\u5355\u53F7> \xB7 \u66FF\u4EE3\u6CD5`\uFF1B\u4E4B\u540E\u7528 `hcm chiron gap status` \u67E5\u8FDB\u5EA6\u3002",
6174
+ "- \u9875\u9762\u9A8C\u6536\u7EDF\u4E00\u7528 `hcm chiron page </\u8DEF\u5F84> --expect-text <\u9875\u9762\u4E0A\u5FC5\u987B\u51FA\u73B0\u7684\u6587\u672C> --out evidence/\u2026.png`\uFF1B\u53EA\u622A\u5230\u56FE\u4E0D\u7B97\u901A\u8FC7\u3002",
6175
+ "- \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"
6176
+ ].join("\n");
6177
+ var FALLBACK_NOTICE = "> \u26A0\uFE0F \u672C\u6BB5\u6765\u81EA CLI \u5185\u7F6E\u526F\u672C\uFF0C**\u672A\u4E0E\u4EA7\u54C1\u7248\u672C\u6838\u5BF9**\uFF08\u8FD9\u4E2A\u73AF\u5883\u7684 `/chiron.json` \u6CA1\u5E26 `agentBoundary`\uFF0C\u591A\u534A\u662F\u540E\u7AEF\u8FD8\u6CA1\u5347\u5230\u542B\u4F5C\u8005\u6E90\u7684\u7248\u672C\uFF09\u3002\u8054\u7F51\u5E76\u5347\u7EA7\u540E\u7AEF\u540E\u8DD1\u4E00\u6B21 `hcm skills sync` \u5C31\u4F1A\u6362\u6210\u4EA7\u54C1\u90A3\u4E00\u7248\u3002";
6178
+ function renderBoundaryBlock(fromProduct) {
6179
+ const trimmed = fromProduct?.trim();
6180
+ if (trimmed) return { block: [AGENT_BEGIN, trimmed, AGENT_END, ""].join("\n"), source: "product" };
6181
+ return { block: [AGENT_BEGIN, BUILTIN_BOUNDARY, "", FALLBACK_NOTICE, AGENT_END, ""].join("\n"), source: "cli-fallback" };
6182
+ }
6183
+ function mergeBoundaryBlock(existing, fromProduct) {
6184
+ const { block, source } = renderBoundaryBlock(fromProduct);
6185
+ return { text: upsertBlock(existing, AGENT_BEGIN, AGENT_END, block.trimEnd()), source };
6186
+ }
6187
+
6035
6188
  // src/commands/skills-bundled.ts
6036
6189
  import { promises as fsp } from "fs";
6037
- import * as path4 from "path";
6190
+ import * as path5 from "path";
6038
6191
  import { CliError as CliError18, CliErrorCode as CliErrorCode17, assertSafeReferencePath, parseSkillRequirements } from "@hcmai/sdk";
6039
6192
 
6040
6193
  // src/commands/skills-manifest.ts
6041
6194
  import { readFileSync as readFileSync4, readdirSync as readdirSync2, statSync as statSync3, existsSync } from "fs";
6042
6195
  import { createHash as createHash3 } from "crypto";
6043
- import * as path3 from "path";
6196
+ import * as path4 from "path";
6044
6197
  import { fileURLToPath } from "url";
6045
6198
  import { formatObject as formatObject15, parseSkillFrontmatter } from "@hcmai/sdk";
6046
6199
  function collectCommandSurface(root) {
@@ -6057,8 +6210,8 @@ function collectCommandSurface(root) {
6057
6210
  return out.sort((a, b) => a.path.localeCompare(b.path));
6058
6211
  }
6059
6212
  function bundledSkillsDir() {
6060
- const here = path3.dirname(fileURLToPath(import.meta.url));
6061
- return path3.join(here, "skills");
6213
+ const here = path4.dirname(fileURLToPath(import.meta.url));
6214
+ return path4.join(here, "skills");
6062
6215
  }
6063
6216
  function sha256(buf) {
6064
6217
  return createHash3("sha256").update(buf).digest("hex");
@@ -6066,7 +6219,7 @@ function sha256(buf) {
6066
6219
  function listFiles(dir, rel = "") {
6067
6220
  const out = [];
6068
6221
  for (const name of readdirSync2(dir)) {
6069
- const p = path3.join(dir, name);
6222
+ const p = path4.join(dir, name);
6070
6223
  const r = rel ? `${rel}/${name}` : name;
6071
6224
  if (statSync3(p).isDirectory()) out.push(...listFiles(p, r));
6072
6225
  else out.push(r);
@@ -6077,17 +6230,17 @@ function collectBundledSkills(dir = bundledSkillsDir()) {
6077
6230
  if (!existsSync(dir)) return [];
6078
6231
  const out = [];
6079
6232
  for (const id of readdirSync2(dir).sort()) {
6080
- const skillDir = path3.join(dir, id);
6233
+ const skillDir = path4.join(dir, id);
6081
6234
  if (!statSync3(skillDir).isDirectory()) continue;
6082
6235
  const files = listFiles(skillDir).sort();
6083
6236
  if (!files.includes("SKILL.md")) continue;
6084
6237
  let bytes = 0;
6085
6238
  const fileRows = files.map((rel) => {
6086
- const buf = readFileSync4(path3.join(skillDir, rel));
6239
+ const buf = readFileSync4(path4.join(skillDir, rel));
6087
6240
  bytes += buf.byteLength;
6088
6241
  return { path: rel, bytes: buf.byteLength, sha256: sha256(buf) };
6089
6242
  });
6090
- const body = readFileSync4(path3.join(skillDir, "SKILL.md"), "utf8");
6243
+ const body = readFileSync4(path4.join(skillDir, "SKILL.md"), "utf8");
6091
6244
  const fm = parseSkillFrontmatter(body, id);
6092
6245
  out.push({
6093
6246
  id,
@@ -6134,7 +6287,7 @@ function unreachable(id, detail) {
6134
6287
  });
6135
6288
  }
6136
6289
  async function readBundledReferences(skillDir) {
6137
- const root = path4.join(skillDir, "references");
6290
+ const root = path5.join(skillDir, "references");
6138
6291
  const out = [];
6139
6292
  const walk = async (dir, prefix) => {
6140
6293
  let items;
@@ -6147,22 +6300,22 @@ async function readBundledReferences(skillDir) {
6147
6300
  for (const item of items.sort((a, b) => a.name.localeCompare(b.name))) {
6148
6301
  const relative2 = prefix ? `${prefix}/${item.name}` : item.name;
6149
6302
  if (item.isDirectory()) {
6150
- await walk(path4.join(dir, item.name), relative2);
6303
+ await walk(path5.join(dir, item.name), relative2);
6151
6304
  continue;
6152
6305
  }
6153
6306
  if (!item.isFile()) continue;
6154
6307
  assertSafeReferencePath(relative2);
6155
- out.push({ path: relative2, content: await fsp.readFile(path4.join(dir, item.name), "utf8") });
6308
+ out.push({ path: relative2, content: await fsp.readFile(path5.join(dir, item.name), "utf8") });
6156
6309
  }
6157
6310
  };
6158
6311
  await walk(root, "");
6159
6312
  return out;
6160
6313
  }
6161
6314
  async function readBundledSkillDocument(id, dir = bundledSkillsDir()) {
6162
- const skillDir = path4.join(dir, id);
6315
+ const skillDir = path5.join(dir, id);
6163
6316
  let markdown;
6164
6317
  try {
6165
- markdown = await fsp.readFile(path4.join(skillDir, "SKILL.md"), "utf8");
6318
+ markdown = await fsp.readFile(path5.join(skillDir, "SKILL.md"), "utf8");
6166
6319
  } catch (cause) {
6167
6320
  if (cause?.code === "ENOENT") throw unreachable(id, "SKILL.md \u4E0D\u5B58\u5728");
6168
6321
  throw cause;
@@ -6278,27 +6431,27 @@ async function exists(target) {
6278
6431
  }
6279
6432
  }
6280
6433
  async function detectTarget(cwd) {
6281
- if (await exists(path5.join(cwd, ".claude"))) return "claude";
6282
- if (await exists(path5.join(cwd, "AGENTS.md"))) return "codex";
6283
- if (await exists(path5.join(cwd, ".codex"))) return "codex";
6434
+ if (await exists(path6.join(cwd, ".claude"))) return "claude";
6435
+ if (await exists(path6.join(cwd, "AGENTS.md"))) return "codex";
6436
+ if (await exists(path6.join(cwd, ".codex"))) return "codex";
6284
6437
  return void 0;
6285
6438
  }
6286
6439
  async function resolveInstallLayout(args, cwd = process.cwd()) {
6287
6440
  const requested = args.target && args.target !== "auto" ? args.target : void 0;
6288
6441
  const target = requested ?? await detectTarget(cwd) ?? "claude";
6289
6442
  if (target === "codex") {
6290
- const root = args.global ? path5.join(os2.homedir(), ".codex") : cwd;
6291
- const claudeFile = path5.join(root, "CLAUDE.md");
6443
+ const root = args.global ? path6.join(os2.homedir(), ".codex") : cwd;
6444
+ const claudeFile = path6.join(root, "CLAUDE.md");
6292
6445
  return {
6293
6446
  target,
6294
- baseDir: args.dir ? path5.resolve(args.dir) : path5.join(root, "hcm-skills"),
6295
- agentsFile: path5.join(root, "AGENTS.md"),
6447
+ baseDir: args.dir ? path6.resolve(args.dir) : path6.join(root, "hcm-skills"),
6448
+ agentsFile: path6.join(root, "AGENTS.md"),
6296
6449
  companionAgentFiles: !args.global && await exists(claudeFile) ? [claudeFile] : []
6297
6450
  };
6298
6451
  }
6299
6452
  return {
6300
6453
  target,
6301
- baseDir: args.dir ? path5.resolve(args.dir) : args.global ? path5.join(os2.homedir(), ".claude", "skills") : path5.join(cwd, ".claude", "skills")
6454
+ baseDir: args.dir ? path6.resolve(args.dir) : args.global ? path6.join(os2.homedir(), ".claude", "skills") : path6.join(cwd, ".claude", "skills")
6302
6455
  };
6303
6456
  }
6304
6457
  async function chironClient(args) {
@@ -6422,7 +6575,7 @@ async function skillsListCommand(keyword, args) {
6422
6575
  }
6423
6576
  process.stdout.write(` \u25CF CLI \u5C31\u7EEA \u25CB \u5F85\u6539\u5199\u52A8\u4F5C\u9762 \u5171 ${shown.length} \u4E2A
6424
6577
  `);
6425
- process.stdout.write(` \u88C5\u4E00\u4E2A\uFF1Ahcm skills install <id>
6578
+ process.stdout.write(` \u88C5\u4E00\u4E2A\uFF1Ahcm skills sync --only <id>
6426
6579
  `);
6427
6580
  process.exitCode = 0;
6428
6581
  return;
@@ -6439,7 +6592,7 @@ async function skillsListCommand(keyword, args) {
6439
6592
  }
6440
6593
  process.stdout.write(` \u25CF CLI \u5C31\u7EEA \u25CB \u5F85\u6539\u5199\u52A8\u4F5C\u9762 \u5171 ${shown.length} \u4E2A
6441
6594
  `);
6442
- process.stdout.write(` \u88C5\u4E00\u4E2A\uFF1Ahcm skills install <id>
6595
+ process.stdout.write(` \u88C5\u4E00\u4E2A\uFF1Ahcm skills sync --only <id>
6443
6596
  `);
6444
6597
  process.exitCode = 0;
6445
6598
  return;
@@ -6457,9 +6610,9 @@ async function listInstalledSkills(keyword, args) {
6457
6610
  process.exitCode = 0;
6458
6611
  return;
6459
6612
  }
6460
- process.stdout.write(`${path5.join(layout.baseDir, SKILLS_STATE_FILE)} \u4E0D\u5B58\u5728\u6216\u4E3A\u7A7A \u2014\u2014 \u8FD9\u4E2A\u76EE\u5F55\u4E0B\u8FD8\u6CA1\u7528\u672C CLI \u88C5\u8FC7\u6280\u80FD\u3002
6613
+ process.stdout.write(`${path6.join(layout.baseDir, SKILLS_STATE_FILE)} \u4E0D\u5B58\u5728\u6216\u4E3A\u7A7A \u2014\u2014 \u8FD9\u4E2A\u76EE\u5F55\u4E0B\u8FD8\u6CA1\u7528\u672C CLI \u88C5\u8FC7\u6280\u80FD\u3002
6461
6614
  `);
6462
- process.stdout.write(" \u88C5\u5168\u90E8\uFF1Ahcm skills install --all\n");
6615
+ process.stdout.write(" \u5168\u90E8\u88C5\u9F50\uFF1Ahcm skills sync\n");
6463
6616
  process.exitCode = 0;
6464
6617
  return;
6465
6618
  }
@@ -6521,7 +6674,7 @@ async function listInstalledSkills(keyword, args) {
6521
6674
  `);
6522
6675
  for (const row of group) {
6523
6676
  const mark = row.status === "missing" ? "?" : row.status === "locally-modified" ? "!" : row.direct ? "\u25CF" : "\u25CB";
6524
- const note = row.status === "missing" ? "\u6587\u4EF6\u4E0D\u89C1\u4E86\uFF08update \u4F1A\u88C5\u56DE\uFF09" : row.status === "locally-modified" ? "\u672C\u5730\u6539\u8FC7" : row.direct ? "" : "\u4F9D\u8D56\u5E26\u5165";
6677
+ const note = row.status === "missing" ? "\u6587\u4EF6\u4E0D\u89C1\u4E86\uFF08hcm skills sync \u4F1A\u88C5\u56DE\uFF09" : row.status === "locally-modified" ? "\u672C\u5730\u6539\u8FC7" : row.direct ? "" : "\u4F9D\u8D56\u5E26\u5165";
6525
6678
  process.stdout.write(` ${mark} ${row.id.padEnd(30)} ${row.title.padEnd(24)} ${note}
6526
6679
  `);
6527
6680
  }
@@ -6538,7 +6691,7 @@ async function listInstalledSkills(keyword, args) {
6538
6691
  modified > 0 ? `${modified} \u4E2A\u672C\u5730\u6539\u8FC7` : "",
6539
6692
  missing > 0 ? `${missing} \u4E2A\u6587\u4EF6\u7F3A\u5931` : ""
6540
6693
  ].filter(Boolean).map((t) => `\uFF0C${t}`).join("") + "\n");
6541
- process.stdout.write(` \u5347\u7EA7\uFF1Ahcm skills update${state.all ? "" : "\uFF08\u60F3\u8DDF\u968F\u5168\u96C6\u52A0 --all\uFF09"}
6694
+ process.stdout.write(` \u5BF9\u9F50\uFF1Ahcm skills sync${state.all ? "" : "\uFF08\u8FD9\u4E2A\u76EE\u5F55\u5F53\u521D\u53EA\u88C5\u4E86\u6307\u5B9A\u7684\u51E0\u4E2A\uFF1Bsync \u4F1A\u8865\u9F50\u5168\u96C6\uFF09"}
6542
6695
  `);
6543
6696
  process.exitCode = 0;
6544
6697
  return;
@@ -6579,7 +6732,7 @@ async function skillsInstallCommand(id, args) {
6579
6732
  let manifest2;
6580
6733
  let conflictNote;
6581
6734
  if (args.from) {
6582
- const root = path5.resolve(args.from);
6735
+ const root = path6.resolve(args.from);
6583
6736
  requestedIds = all ? await listLocalSkillIds(root) : [id];
6584
6737
  const seen = /* @__PURE__ */ new Set();
6585
6738
  documents = [];
@@ -6698,7 +6851,7 @@ async function skillsInstallCommand(id, args) {
6698
6851
  if (fmt === "json" || fmt === "yaml") {
6699
6852
  process.stdout.write(formatObject16({ ...result, all, target_agent: layout.target, agentsFile: layout.agentsFile, agents, agentIndexes, conflictCheck: conflictNote ? { checked: false, note: conflictNote } : { checked: true } }, { format: fmt }) + "\n");
6700
6853
  } else {
6701
- const headline = all ? `\u2705 \u5168\u90E8 ${requestedIds.length} \u4E2A\u6280\u80FD \u2192 ${result.baseDir}` : `\u2705 ${id} \u2192 ${path5.join(result.baseDir, id, "SKILL.md")}`;
6854
+ const headline = all ? `\u2705 \u5168\u90E8 ${requestedIds.length} \u4E2A\u6280\u80FD \u2192 ${result.baseDir}` : `\u2705 ${id} \u2192 ${path6.join(result.baseDir, id, "SKILL.md")}`;
6702
6855
  process.stdout.write(`${headline}
6703
6856
  `);
6704
6857
  if (result.installed.length > 0) {
@@ -6717,15 +6870,18 @@ async function skillsInstallCommand(id, args) {
6717
6870
  `);
6718
6871
  }
6719
6872
  for (const index of agentIndexes) {
6720
- const reader = path5.basename(index.file) === "CLAUDE.md" ? "Claude Code" : "Codex";
6721
- process.stdout.write(` \u5DF2${index.status === "created" ? "\u521B\u5EFA" : "\u66F4\u65B0"} ${index.file} \u91CC\u7684\u6280\u80FD\u7D22\u5F15\uFF08${reader} \u8BFB\u8FD9\u91CC\uFF09
6873
+ const reader = path6.basename(index.file) === "CLAUDE.md" ? "Claude Code" : "Codex";
6874
+ process.stdout.write(` \u5DF2${index.status === "created" ? "\u521B\u5EFA" : "\u66F4\u65B0"} ${index.file} \u91CC\u7684\u6280\u80FD\u7D22\u5F15\u4E0E\u9879\u76EE\u8FB9\u754C\u5757\uFF08${reader} \u8BFB\u8FD9\u91CC\uFF09
6722
6875
  `);
6723
6876
  }
6724
- process.stdout.write(` \u6765\u6E90 ${endpoint ?? (args.from ? path5.resolve(args.from) : `@hcmai/cli@${CLI_VERSION}`)}
6877
+ if (agentIndexes.some((i) => i.boundary === "cli-fallback")) {
6878
+ process.stdout.write(" \u26A0\uFE0F \u9879\u76EE\u8FB9\u754C\u5757\u7528\u7684\u662F CLI \u5185\u7F6E\u526F\u672C\uFF08\u8FD9\u4E2A\u73AF\u5883\u7684 /chiron.json \u6CA1\u5E26 agentBoundary\uFF09\uFF0C\u672A\u4E0E\u4EA7\u54C1\u7248\u672C\u6838\u5BF9\n");
6879
+ }
6880
+ process.stdout.write(` \u6765\u6E90 ${endpoint ?? (args.from ? path6.resolve(args.from) : `@hcmai/cli@${CLI_VERSION}`)}
6725
6881
  `);
6726
6882
  if (conflictNote) process.stdout.write(` \u26A0\uFE0F ${conflictNote}
6727
6883
  `);
6728
- process.stdout.write(all ? " \u5DF2\u8BB0\u4E3A\u300C\u8DDF\u968F\u5168\u96C6\u300D\uFF1A\u4EE5\u540E\u8DD1 hcm skills update\uFF0C\u4EA7\u54C1\u65B0\u589E\u7684\u6280\u80FD\u4F1A\u81EA\u52A8\u8865\u4E0A\n" : " \u4EA7\u54C1\u66F4\u65B0\u540E\u8DD1 hcm skills update \u5347\u7EA7\n");
6884
+ process.stdout.write(all ? " \u5DF2\u8BB0\u4E3A\u300C\u8DDF\u968F\u5168\u96C6\u300D\uFF1A\u4EE5\u540E\u8DD1 hcm skills sync\uFF0C\u4EA7\u54C1\u65B0\u589E\u7684\u6280\u80FD\u4F1A\u81EA\u52A8\u8865\u4E0A\n" : " \u4EA7\u54C1\u66F4\u65B0\u540E\u8DD1 hcm skills sync \u5BF9\u9F50\n");
6729
6885
  }
6730
6886
  process.exitCode = 0;
6731
6887
  return;
@@ -6757,7 +6913,7 @@ async function listLocalSkillIds(root) {
6757
6913
  const ids = [];
6758
6914
  for (const entry of entries) {
6759
6915
  if (!entry.isDirectory()) continue;
6760
- if (await exists(path5.join(root, entry.name, "SKILL.md"))) ids.push(entry.name);
6916
+ if (await exists(path6.join(root, entry.name, "SKILL.md"))) ids.push(entry.name);
6761
6917
  }
6762
6918
  if (ids.length === 0) throw invalid(`\u672C\u5730\u76EE\u5F55\u91CC\u6CA1\u6709\u4EFB\u4F55 <id>/SKILL.md\uFF1A${root}`);
6763
6919
  return ids.sort();
@@ -6787,20 +6943,25 @@ async function syncAgentIndexes(layout, manifest2) {
6787
6943
  const files = [layout.agentsFile, ...layout.companionAgentFiles ?? []];
6788
6944
  const results = [];
6789
6945
  for (const file of files) {
6790
- const agentsDir = path5.dirname(file);
6946
+ const agentsDir = path6.dirname(file);
6791
6947
  const entries = Object.keys(state.skills).sort().map((id) => {
6792
6948
  const known = catalog.get(id);
6793
- const absolute = path5.join(layout.baseDir, id, "SKILL.md");
6794
- let relative2 = path5.relative(agentsDir, absolute);
6949
+ const absolute = path6.join(layout.baseDir, id, "SKILL.md");
6950
+ let relative2 = path6.relative(agentsDir, absolute);
6795
6951
  if (!relative2.startsWith(".")) relative2 = `./${relative2}`;
6796
6952
  return {
6797
6953
  id,
6798
6954
  title: known?.title ?? id,
6799
6955
  description: known?.description ?? "",
6800
- relativePath: relative2.split(path5.sep).join("/")
6956
+ relativePath: relative2.split(path6.sep).join("/")
6801
6957
  };
6802
6958
  });
6803
- results.push({ file, status: await upsertAgentsBlock(file, renderAgentsBlock(entries)) });
6959
+ const status = await upsertAgentsBlock(file, renderAgentsBlock(entries));
6960
+ const before = await fsp2.readFile(file, "utf8").catch(() => "");
6961
+ const merged = mergeBoundaryBlock(before, manifest2?.agentBoundary);
6962
+ if (merged.text !== before) await fsp2.writeFile(file, merged.text.endsWith("\n") ? merged.text : `${merged.text}
6963
+ `, "utf8");
6964
+ results.push({ file, status, boundary: merged.source });
6804
6965
  }
6805
6966
  return results;
6806
6967
  }
@@ -6817,13 +6978,13 @@ async function resolveLocalSkillDocuments(sourceRoot, targetId) {
6817
6978
  throw invalid(`\u6280\u80FD\u4F9D\u8D56\u5B58\u5728\u73AF: ${[...pathStack.slice(Math.max(0, start)), id].join(" -> ")}`);
6818
6979
  }
6819
6980
  assertSafeSkillId(id);
6820
- const local = path5.join(sourceRoot, id, "SKILL.md");
6981
+ const local = path6.join(sourceRoot, id, "SKILL.md");
6821
6982
  let markdown;
6822
6983
  try {
6823
6984
  markdown = await fsp2.readFile(local, "utf8");
6824
6985
  } catch (cause) {
6825
6986
  if (cause?.code === "ENOENT") {
6826
- throw invalid(requiredBy ? `\u672C\u5730\u6280\u80FD ${requiredBy} \u4F9D\u8D56\u4E0D\u5B58\u5728: ${id}\uFF08${local}\uFF09` : `\u672C\u5730\u76EE\u5F55\u91CC\u6CA1\u6709 ${id}/SKILL.md\uFF1A${path5.join(sourceRoot, id)}`);
6987
+ throw invalid(requiredBy ? `\u672C\u5730\u6280\u80FD ${requiredBy} \u4F9D\u8D56\u4E0D\u5B58\u5728: ${id}\uFF08${local}\uFF09` : `\u672C\u5730\u76EE\u5F55\u91CC\u6CA1\u6709 ${id}/SKILL.md\uFF1A${path6.join(sourceRoot, id)}`);
6827
6988
  }
6828
6989
  throw cause;
6829
6990
  }
@@ -6835,7 +6996,7 @@ async function resolveLocalSkillDocuments(sourceRoot, targetId) {
6835
6996
  markdown,
6836
6997
  source: local,
6837
6998
  sourceKind: "local",
6838
- references: await readLocalReferences(path5.join(sourceRoot, id))
6999
+ references: await readLocalReferences(path6.join(sourceRoot, id))
6839
7000
  };
6840
7001
  for (const required2 of parseSkillRequirements2(markdown, id)) {
6841
7002
  await visit(required2, id);
@@ -6849,7 +7010,7 @@ async function resolveLocalSkillDocuments(sourceRoot, targetId) {
6849
7010
  }
6850
7011
  async function readSkillsState(baseDir) {
6851
7012
  try {
6852
- const raw = await fsp2.readFile(path5.join(baseDir, SKILLS_STATE_FILE), "utf8");
7013
+ const raw = await fsp2.readFile(path6.join(baseDir, SKILLS_STATE_FILE), "utf8");
6853
7014
  const parsed = JSON.parse(raw);
6854
7015
  if (!parsed || typeof parsed !== "object" || !parsed.skills) return void 0;
6855
7016
  return migrateSkillsState(parsed);
@@ -6859,7 +7020,7 @@ async function readSkillsState(baseDir) {
6859
7020
  }
6860
7021
  async function writeSkillsState(baseDir, state) {
6861
7022
  await fsp2.mkdir(baseDir, { recursive: true });
6862
- const file = path5.join(baseDir, SKILLS_STATE_FILE);
7023
+ const file = path6.join(baseDir, SKILLS_STATE_FILE);
6863
7024
  const temp = `${file}.${process.pid}.tmp`;
6864
7025
  await fsp2.writeFile(temp, JSON.stringify(state, null, 2) + "\n", "utf8");
6865
7026
  await fsp2.rename(temp, file);
@@ -6869,7 +7030,7 @@ var AGENTS_BLOCK_END = "<!-- hcm-skills:end -->";
6869
7030
  function renderAgentsBlock(entries) {
6870
7031
  const lines = [
6871
7032
  AGENTS_BLOCK_BEGIN,
6872
- "## HCMnext \u4EA4\u4ED8\u6280\u80FD\uFF08\u7531 `hcm skills install` \u7EF4\u62A4\uFF0C\u52FF\u624B\u5DE5\u7F16\u8F91\u672C\u5757\uFF09",
7033
+ "## HCMnext \u4EA4\u4ED8\u6280\u80FD\uFF08\u7531 `hcm skills sync` \u7EF4\u62A4\uFF0C\u52FF\u624B\u5DE5\u7F16\u8F91\u672C\u5757\uFF09",
6873
7034
  "",
6874
7035
  "\u9047\u5230\u4E0B\u9762\u8FD9\u4E9B\u6D3B\u513F\uFF0C**\u5148\u8BFB\u5BF9\u5E94\u6587\u4EF6\u518D\u52A8\u624B**\u2014\u2014\u91CC\u9762\u662F\u8FD9\u5957\u4EA7\u54C1\u7684\u6B63\u786E\u505A\u6CD5\uFF0C",
6875
7036
  "\u7167\u7740\u505A\u4E0D\u7528\u7FFB\u6E90\u7801\uFF0C\u4E5F\u4E0D\u7528\u731C API\u3002",
@@ -6888,7 +7049,7 @@ async function upsertAgentsBlock(agentsFile, block) {
6888
7049
  existing = await fsp2.readFile(agentsFile, "utf8");
6889
7050
  } catch (cause) {
6890
7051
  if (cause?.code !== "ENOENT") throw cause;
6891
- await fsp2.mkdir(path5.dirname(agentsFile), { recursive: true });
7052
+ await fsp2.mkdir(path6.dirname(agentsFile), { recursive: true });
6892
7053
  await fsp2.writeFile(agentsFile, block + "\n", "utf8");
6893
7054
  return "created";
6894
7055
  }
@@ -6914,7 +7075,7 @@ async function installSkillDocuments(documents, requestedIds, baseDir, force, me
6914
7075
  if (!document.markdown.trim()) throw invalid(`\u6280\u80FD ${document.id} \u5185\u5BB9\u4E3A\u7A7A`);
6915
7076
  return {
6916
7077
  ...document,
6917
- target: path5.join(baseDir, document.id, "SKILL.md"),
7078
+ target: path6.join(baseDir, document.id, "SKILL.md"),
6918
7079
  bytes: Buffer.byteLength(document.markdown)
6919
7080
  };
6920
7081
  });
@@ -6931,7 +7092,7 @@ async function installSkillDocuments(documents, requestedIds, baseDir, force, me
6931
7092
  continue;
6932
7093
  }
6933
7094
  throw invalid(
6934
- `${candidate.target} \u5DF2\u5B58\u5728\uFF0C\u4E14\u548C\u76EE\u6807\u73AF\u5883\u8FD9\u4E00\u7248\u4E0D\u4E00\u81F4\u3002\u7528 --force \u8986\u76D6\uFF08\u4F1A\u4E22\u6389\u672C\u5730\u6539\u52A8\uFF09\uFF0C\u6216 --dir <path> \u88C5\u5230\u522B\u5904\uFF1B\u53EA\u60F3\u8DDF\u4E0A\u4EA7\u54C1\u7248\u672C\u7528 hcm skills update`
7095
+ `${candidate.target} \u5DF2\u5B58\u5728\uFF0C\u4E14\u548C\u76EE\u6807\u73AF\u5883\u8FD9\u4E00\u7248\u4E0D\u4E00\u81F4\u3002\u7528 --force \u8986\u76D6\uFF08\u4F1A\u4E22\u6389\u672C\u5730\u6539\u52A8\uFF09\uFF0C\u6216 --dir <path> \u88C5\u5230\u522B\u5904\uFF1B\u53EA\u60F3\u8DDF\u4E0A\u4EA7\u54C1\u7248\u672C\u7528 hcm skills sync`
6935
7096
  );
6936
7097
  }
6937
7098
  const pending = candidates.filter((candidate) => !unchanged.has(candidate.id));
@@ -6965,7 +7126,7 @@ async function sameOnDisk(baseDir, candidate) {
6965
7126
  return true;
6966
7127
  }
6967
7128
  async function readLocalReferences(skillDir) {
6968
- const root = path5.join(skillDir, "references");
7129
+ const root = path6.join(skillDir, "references");
6969
7130
  const out = [];
6970
7131
  const walk = async (dir, prefix) => {
6971
7132
  let items;
@@ -6978,12 +7139,12 @@ async function readLocalReferences(skillDir) {
6978
7139
  for (const item of items.sort((a, b) => a.name.localeCompare(b.name))) {
6979
7140
  const relative2 = prefix ? `${prefix}/${item.name}` : item.name;
6980
7141
  if (item.isDirectory()) {
6981
- await walk(path5.join(dir, item.name), relative2);
7142
+ await walk(path6.join(dir, item.name), relative2);
6982
7143
  continue;
6983
7144
  }
6984
7145
  if (!item.isFile()) continue;
6985
7146
  assertSafeReferencePath2(relative2);
6986
- out.push({ path: relative2, content: await fsp2.readFile(path5.join(dir, item.name), "utf8") });
7147
+ out.push({ path: relative2, content: await fsp2.readFile(path6.join(dir, item.name), "utf8") });
6987
7148
  }
6988
7149
  };
6989
7150
  await walk(root, "");
@@ -7014,15 +7175,15 @@ async function writeSkillDocuments(documents, baseDir, removals = []) {
7014
7175
  const removed = [];
7015
7176
  try {
7016
7177
  for (const document of documents) {
7017
- const target = path5.join(baseDir, document.id, "SKILL.md");
7018
- await fsp2.mkdir(path5.dirname(target), { recursive: true });
7019
- const temp = path5.join(path5.dirname(target), `.SKILL.md.${process.pid}.${Date.now()}.tmp`);
7178
+ const target = path6.join(baseDir, document.id, "SKILL.md");
7179
+ await fsp2.mkdir(path6.dirname(target), { recursive: true });
7180
+ const temp = path6.join(path6.dirname(target), `.SKILL.md.${process.pid}.${Date.now()}.tmp`);
7020
7181
  await fsp2.writeFile(temp, document.markdown, "utf8");
7021
7182
  staged.push({ temp, target });
7022
7183
  for (const reference of document.references ?? []) {
7023
7184
  assertSafeReferencePath2(reference.path);
7024
- const referenceTarget = path5.join(baseDir, document.id, "references", reference.path);
7025
- await fsp2.mkdir(path5.dirname(referenceTarget), { recursive: true });
7185
+ const referenceTarget = path6.join(baseDir, document.id, "references", reference.path);
7186
+ await fsp2.mkdir(path6.dirname(referenceTarget), { recursive: true });
7026
7187
  const referenceTemp = `${referenceTarget}.${process.pid}.${Date.now()}.tmp`;
7027
7188
  await fsp2.writeFile(referenceTemp, reference.content, "utf8");
7028
7189
  staged.push({ temp: referenceTemp, target: referenceTarget });
@@ -7030,7 +7191,7 @@ async function writeSkillDocuments(documents, baseDir, removals = []) {
7030
7191
  }
7031
7192
  for (const stale of removals) {
7032
7193
  assertSafeReferencePath2(stale.path);
7033
- const original = path5.join(baseDir, stale.id, "references", stale.path);
7194
+ const original = path6.join(baseDir, stale.id, "references", stale.path);
7034
7195
  const parked = `${original}.${process.pid}.${Date.now()}.removed`;
7035
7196
  await fsp2.rename(original, parked);
7036
7197
  removed.push({ parked, original });
@@ -7080,7 +7241,7 @@ function invalid(message) {
7080
7241
  }
7081
7242
  async function readInstalled(baseDir, id) {
7082
7243
  try {
7083
- return await fsp2.readFile(path5.join(baseDir, id, "SKILL.md"), "utf8");
7244
+ return await fsp2.readFile(path6.join(baseDir, id, "SKILL.md"), "utf8");
7084
7245
  } catch (cause) {
7085
7246
  if (cause?.code === "ENOENT") return void 0;
7086
7247
  throw cause;
@@ -7088,7 +7249,7 @@ async function readInstalled(baseDir, id) {
7088
7249
  }
7089
7250
  async function readInstalledReference(baseDir, id, relative2) {
7090
7251
  try {
7091
- return await fsp2.readFile(path5.join(baseDir, id, "references", relative2), "utf8");
7252
+ return await fsp2.readFile(path6.join(baseDir, id, "references", relative2), "utf8");
7092
7253
  } catch (cause) {
7093
7254
  if (cause?.code === "ENOENT") return void 0;
7094
7255
  throw cause;
@@ -7222,7 +7383,7 @@ async function skillsUpdateCommand(args) {
7222
7383
  if (!state || Object.keys(state.skills).length === 0) {
7223
7384
  throw new CliError19({
7224
7385
  code: CliErrorCode18.INVALID_ARGUMENT,
7225
- message: `${path5.join(layout.baseDir, SKILLS_STATE_FILE)} \u4E0D\u5B58\u5728\u6216\u4E3A\u7A7A \u2014\u2014 \u8FD9\u4E2A\u76EE\u5F55\u4E0B\u8FD8\u6CA1\u6709\u7528\u672C CLI \u88C5\u8FC7\u6280\u80FD\u3002\u5148 \`hcm skills install <id>\`\uFF1B\u5982\u679C\u6280\u80FD\u662F\u624B\u5DE5\u62F7\u8FDB\u6765\u7684\uFF0C\u91CD\u88C5\u4E00\u6B21\u5373\u53EF\u63A5\u7BA1\u5347\u7EA7\u3002`
7386
+ message: `${path6.join(layout.baseDir, SKILLS_STATE_FILE)} \u4E0D\u5B58\u5728\u6216\u4E3A\u7A7A \u2014\u2014 \u8FD9\u4E2A\u76EE\u5F55\u4E0B\u8FD8\u6CA1\u6709\u7528\u672C CLI \u88C5\u8FC7\u6280\u80FD\u3002\u5148\u8DD1 \`hcm skills sync\`\uFF1B\u5982\u679C\u6280\u80FD\u662F\u624B\u5DE5\u62F7\u8FDB\u6765\u7684\uFF0C\u540C\u6B65\u4E00\u6B21\u5373\u53EF\u63A5\u7BA1\u5347\u7EA7\u3002`
7226
7387
  });
7227
7388
  }
7228
7389
  const source = parseSourceFilter(args.source);
@@ -7267,7 +7428,7 @@ async function skillsUpdateCommand(args) {
7267
7428
  directIds: all ? new Set(plan.documents.map((document) => document.id)) : /* @__PURE__ */ new Set()
7268
7429
  });
7269
7430
  }
7270
- if (!args.check && layout.agentsFile) await syncAgentIndexes(layout, manifest2);
7431
+ const agentIndexes = !args.check && layout.agentsFile ? await syncAgentIndexes(layout, manifest2) : [];
7271
7432
  const changed = plan.entries.filter((e) => e.status === "updated" || e.status === "added");
7272
7433
  const fmt = args.output ?? "table";
7273
7434
  if (fmt === "json" || fmt === "yaml") {
@@ -7319,9 +7480,12 @@ async function skillsUpdateCommand(args) {
7319
7480
  }
7320
7481
  if (source === "cli" && all) {
7321
7482
  process.stdout.write(
7322
- " \u672C\u8D9F\u53EA\u770B\u4E86\u81EA\u5E26\u90A3\u4E00\u534A\uFF1B\u8FD9\u4E2A\u76EE\u5F55\u8BA2\u9605\u7684\u662F\u5168\u5E93\uFF0C\u8054\u7F51\u540E update \u4F1A\u8865\u9F50\u777F\u620E\u90A3\u4E00\u534A\n"
7483
+ " \u672C\u8D9F\u53EA\u770B\u4E86\u81EA\u5E26\u90A3\u4E00\u534A\uFF1B\u8FD9\u4E2A\u76EE\u5F55\u8BA2\u9605\u7684\u662F\u5168\u5E93\uFF0C\u8054\u7F51\u540E hcm skills sync \u4F1A\u8865\u9F50\u777F\u620E\u90A3\u4E00\u534A\n"
7323
7484
  );
7324
7485
  }
7486
+ if (agentIndexes.some((i) => i.boundary === "cli-fallback")) {
7487
+ process.stdout.write(" \u26A0\uFE0F \u9879\u76EE\u8FB9\u754C\u5757\u7528\u7684\u662F CLI \u5185\u7F6E\u526F\u672C\uFF08\u8FD9\u4E2A\u73AF\u5883\u7684 /chiron.json \u6CA1\u5E26 agentBoundary\uFF09\uFF0C\u672A\u4E0E\u4EA7\u54C1\u7248\u672C\u6838\u5BF9\n");
7488
+ }
7325
7489
  if (stale.remove.length > 0) {
7326
7490
  process.stdout.write(
7327
7491
  ` ${args.check ? "\u4F1A\u5220\u6389" : "\u5DF2\u5220\u6389"} ${stale.remove.length} \u4E2A\u4EA7\u54C1\u8FD9\u4E00\u7248\u64A4\u6389\u7684\u53C2\u8003\u6587\u4EF6\uFF08${stale.remove.map((r) => `${r.id}/references/${r.path}`).join("\u3001")}\uFF09
@@ -7347,6 +7511,40 @@ async function skillsUpdateCommand(args) {
7347
7511
  fail5(e, args);
7348
7512
  }
7349
7513
  }
7514
+ function assertSyncArgs(args) {
7515
+ const only = (args.only ?? []).filter((id) => id.trim().length > 0);
7516
+ if (only.length > 0 && args.check) {
7517
+ throw invalid("`--check` \u53EA\u5BF9\u5168\u96C6\u5BF9\u8D26\u6709\u610F\u4E49\uFF1B`--only` \u662F\u660E\u786E\u8981\u88C5\u8FD9\u51E0\u4E2A\uFF0C\u76F4\u63A5\u8DD1\u5C31\u884C");
7518
+ }
7519
+ return only;
7520
+ }
7521
+ var defaultSkillsSyncDeps = {
7522
+ install: skillsInstallCommand,
7523
+ reconcile: skillsUpdateCommand,
7524
+ managed: async (args) => {
7525
+ const layout = await resolveInstallLayout(args).catch(() => null);
7526
+ if (!layout) return false;
7527
+ const state = await readSkillsState(layout.baseDir).catch(() => void 0);
7528
+ return Boolean(state && Object.keys(state.skills).length > 0);
7529
+ }
7530
+ };
7531
+ async function skillsSyncCommand(args, deps = defaultSkillsSyncDeps) {
7532
+ let only;
7533
+ try {
7534
+ only = assertSyncArgs(args);
7535
+ } catch (e) {
7536
+ return exitWithError(e);
7537
+ }
7538
+ if (only.length > 0) {
7539
+ for (const id of only) {
7540
+ await deps.install(id, { ...args, all: false });
7541
+ if (process.exitCode && process.exitCode !== 0) return;
7542
+ }
7543
+ return;
7544
+ }
7545
+ if (await deps.managed(args)) return deps.reconcile({ ...args, all: true });
7546
+ return deps.install(void 0, { ...args, all: true });
7547
+ }
7350
7548
 
7351
7549
  // src/commands/tenant.ts
7352
7550
  import {
@@ -7524,10 +7722,10 @@ async function metaListCommand(args) {
7524
7722
  fail6(e, args);
7525
7723
  }
7526
7724
  }
7527
- async function metaGetCommand(path16, args) {
7725
+ async function metaGetCommand(path17, args) {
7528
7726
  try {
7529
7727
  const c = await client2(args);
7530
- const content = await getTenantMeta(c.raw(), path16);
7728
+ const content = await getTenantMeta(c.raw(), path17);
7531
7729
  process.stdout.write(content.endsWith("\n") ? content : content + "\n");
7532
7730
  process.exitCode = 0;
7533
7731
  return;
@@ -7536,8 +7734,8 @@ async function metaGetCommand(path16, args) {
7536
7734
  }
7537
7735
  }
7538
7736
  var PROBEABLE_META_TYPES = /* @__PURE__ */ new Set(["model", "list", "info", "view", "filter", "page", "wiz", "impexp"]);
7539
- function parseMetaPath(path16) {
7540
- const base = path16.split(/[\\/]/).pop() ?? path16;
7737
+ function parseMetaPath(path17) {
7738
+ const base = path17.split(/[\\/]/).pop() ?? path17;
7541
7739
  if (!/\.(yml|yaml)$/i.test(base)) return {};
7542
7740
  const parts = base.replace(/\.(yml|yaml)$/i, "").split(".");
7543
7741
  return { model: parts[0] || void 0, kind: parts[1] ?? "model", state: parts[2] };
@@ -7554,10 +7752,10 @@ function unverifiableReason(e) {
7554
7752
  if (st == null) return `\u8BF7\u6C42\u6CA1\u53D1\u51FA\u53BB\u6216\u6CA1\u56DE\u6765\uFF08${err.code ?? err.message ?? "\u672A\u77E5"}\uFF09`;
7555
7753
  return void 0;
7556
7754
  }
7557
- async function verifyAfterWrite(c, path16) {
7558
- const { model, kind, state } = parseMetaPath(path16);
7755
+ async function verifyAfterWrite(c, path17) {
7756
+ const { model, kind, state } = parseMetaPath(path17);
7559
7757
  if (!model || !kind) {
7560
- return { status: "unverified", where: "(\u672A\u63A2)", why: `\u4ECE\u8DEF\u5F84 ${path16} \u8BA4\u4E0D\u51FA\u6A21\u578B\u540D/\u5C42\u540D` };
7758
+ return { status: "unverified", where: "(\u672A\u63A2)", why: `\u4ECE\u8DEF\u5F84 ${path17} \u8BA4\u4E0D\u51FA\u6A21\u578B\u540D/\u5C42\u540D` };
7561
7759
  }
7562
7760
  try {
7563
7761
  await clearMetaCache2(c.raw(), model, {});
@@ -7602,7 +7800,7 @@ async function verifyAfterWrite(c, path16) {
7602
7800
  }
7603
7801
  return { status: "ok" };
7604
7802
  }
7605
- async function metaSetCommand(path16, args) {
7803
+ async function metaSetCommand(path17, args) {
7606
7804
  try {
7607
7805
  if (!args.file) {
7608
7806
  throw new CliError21({
@@ -7618,9 +7816,9 @@ async function metaSetCommand(path16, args) {
7618
7816
  process.stdin.on("error", reject);
7619
7817
  }) : await fsp3.readFile(args.file, "utf8");
7620
7818
  if (!args.skipValidate) {
7621
- const result2 = validateMetaContent(path16, content);
7819
+ const result2 = validateMetaContent(path17, content);
7622
7820
  if (result2.issues.length > 0) {
7623
- process.stderr.write(`\u{1F50E} \u5199\u524D\u6821\u9A8C ${path16}\uFF08schema \u7C7B\u578B\uFF1A${result2.kind ?? "\u672A\u8BC6\u522B"}\uFF09
7821
+ process.stderr.write(`\u{1F50E} \u5199\u524D\u6821\u9A8C ${path17}\uFF08schema \u7C7B\u578B\uFF1A${result2.kind ?? "\u672A\u8BC6\u522B"}\uFF09
7624
7822
  `);
7625
7823
  process.stderr.write(formatMetaIssues(result2, " ") + "\n");
7626
7824
  }
@@ -7639,13 +7837,13 @@ async function metaSetCommand(path16, args) {
7639
7837
  if (dryFmt === "json" || dryFmt === "yaml") {
7640
7838
  process.stdout.write(
7641
7839
  formatObject18(
7642
- { dryRun: true, path: path16, bytes: Buffer.byteLength(content), content },
7840
+ { dryRun: true, path: path17, bytes: Buffer.byteLength(content), content },
7643
7841
  { format: dryFmt }
7644
7842
  ) + "\n"
7645
7843
  );
7646
7844
  } else {
7647
7845
  process.stdout.write(
7648
- `[dry-run] \u5C06\u5199\u5165 ${path16}\uFF08${Buffer.byteLength(content)} B\uFF09\u2014\u2014\u672A\u5B9E\u9645\u5199\u5165
7846
+ `[dry-run] \u5C06\u5199\u5165 ${path17}\uFF08${Buffer.byteLength(content)} B\uFF09\u2014\u2014\u672A\u5B9E\u9645\u5199\u5165
7649
7847
  ---
7650
7848
  ${content}
7651
7849
  `
@@ -7659,13 +7857,13 @@ ${content}
7659
7857
  let backupState = "unknown";
7660
7858
  let backupWhy;
7661
7859
  try {
7662
- const prev = await getTenantMeta(c.raw(), path16);
7860
+ const prev = await getTenantMeta(c.raw(), path17);
7663
7861
  if (!prev || prev.trim() === "") {
7664
7862
  backupState = "absent";
7665
7863
  } else {
7666
7864
  backupFile = nodePath.join(
7667
7865
  os3.tmpdir(),
7668
- `hcm-meta-backup-${Date.now()}-${path16.replace(/[\\/]/g, "_")}`
7866
+ `hcm-meta-backup-${Date.now()}-${path17.replace(/[\\/]/g, "_")}`
7669
7867
  );
7670
7868
  await fsp3.writeFile(backupFile, prev, "utf8");
7671
7869
  backupState = "saved";
@@ -7680,22 +7878,22 @@ ${content}
7680
7878
  backupWhy = `HTTP ${st ?? "-"}${err.code ? ` ${err.code}` : ""}${err.message ? `\uFF1A${err.message}` : ""}`;
7681
7879
  }
7682
7880
  }
7683
- const result = await saveTenantMeta(c.raw(), path16, content);
7881
+ const result = await saveTenantMeta(c.raw(), path17, content);
7684
7882
  const fmt = args.output ?? "json";
7685
- if (fmt !== "json") process.stdout.write(`\u2705 \u5DF2\u5199\u5165 ${path16}
7883
+ if (fmt !== "json") process.stdout.write(`\u2705 \u5DF2\u5199\u5165 ${path17}
7686
7884
  `);
7687
7885
  const restoreHint = backupState === "saved" && backupFile ? ` \u65E7\u5185\u5BB9\u5DF2\u5B58\uFF1A${backupFile}
7688
- \u653E\u56DE\u53BB\uFF1Ahcm meta set ${path16} --file ${backupFile}${connFlags(args)}
7689
- ` : 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 ${path16}${connFlags(args)}
7886
+ \u653E\u56DE\u53BB\uFF1Ahcm meta set ${path17} --file ${backupFile}${connFlags(args)}
7887
+ ` : backupState === "absent" ? ` \u8FD9\u4E00\u5C42\u6B64\u524D\u6CA1\u6709\u8986\u76D6\uFF08\u5DF2\u8BC1\u5B9E\uFF09\uFF0C\u6062\u590D\u5373\u5220\u9664\uFF1Ahcm meta delete ${path17}${connFlags(args)}
7690
7888
  ` : ` \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
7691
- \u5148\u81EA\u5DF1\u8BFB\u4E00\u904D\u786E\u8BA4\uFF1Ahcm meta get ${path16}${connFlags(args)}
7889
+ \u5148\u81EA\u5DF1\u8BFB\u4E00\u904D\u786E\u8BA4\uFF1Ahcm meta get ${path17}${connFlags(args)}
7692
7890
  `;
7693
7891
  if (args.verify === false) {
7694
7892
  process.stderr.write(
7695
7893
  "\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
7696
7894
  );
7697
7895
  } else {
7698
- const outcome = await verifyAfterWrite(c, path16);
7896
+ const outcome = await verifyAfterWrite(c, path17);
7699
7897
  if (outcome.status === "broken") {
7700
7898
  const human = explainJacksonError(outcome.raw);
7701
7899
  process.stderr.write(
@@ -7729,19 +7927,19 @@ ${content}
7729
7927
  fail6(e, args);
7730
7928
  }
7731
7929
  }
7732
- async function metaDeleteCommand(path16, args) {
7930
+ async function metaDeleteCommand(path17, args) {
7733
7931
  try {
7734
7932
  if (!args.yes) {
7735
- const ok = await promptConfirm(`\u5C06\u5220\u9664\u5143\u6570\u636E ${path16}\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u9006\u3002\u7EE7\u7EED\uFF1F`);
7933
+ const ok = await promptConfirm(`\u5C06\u5220\u9664\u5143\u6570\u636E ${path17}\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u9006\u3002\u7EE7\u7EED\uFF1F`);
7736
7934
  if (!ok) {
7737
7935
  process.stderr.write("\u5DF2\u53D6\u6D88\n");
7738
7936
  process.exit(1);
7739
7937
  }
7740
7938
  }
7741
7939
  const c = await client2(args);
7742
- const result = await deleteTenantMeta(c.raw(), path16);
7940
+ const result = await deleteTenantMeta(c.raw(), path17);
7743
7941
  const fmt = args.output ?? "json";
7744
- if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${path16}
7942
+ if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${path17}
7745
7943
  `);
7746
7944
  process.stdout.write(formatObject18(result, { format: fmt }) + "\n");
7747
7945
  process.exitCode = 0;
@@ -7750,7 +7948,7 @@ async function metaDeleteCommand(path16, args) {
7750
7948
  fail6(e, args);
7751
7949
  }
7752
7950
  }
7753
- async function metaValidateCommand(path16, args) {
7951
+ async function metaValidateCommand(path17, args) {
7754
7952
  try {
7755
7953
  if (!args.file) {
7756
7954
  throw new CliError21({
@@ -7765,13 +7963,13 @@ async function metaValidateCommand(path16, args) {
7765
7963
  process.stdin.on("end", () => resolve3(buf));
7766
7964
  process.stdin.on("error", reject);
7767
7965
  }) : await fsp3.readFile(args.file, "utf8");
7768
- const result = validateMetaContent(path16, content);
7966
+ const result = validateMetaContent(path17, content);
7769
7967
  const fmt = args.output ?? "table";
7770
7968
  if (fmt === "json" || fmt === "yaml") {
7771
7969
  process.stdout.write(
7772
7970
  formatObject18(
7773
7971
  {
7774
- path: path16,
7972
+ path: path17,
7775
7973
  kind: result.kind,
7776
7974
  schemaKnown: result.schemaKnown,
7777
7975
  schemaSourceCommit: META_SCHEMA_SOURCE_COMMIT,
@@ -7783,7 +7981,7 @@ async function metaValidateCommand(path16, args) {
7783
7981
  );
7784
7982
  } else {
7785
7983
  process.stdout.write(
7786
- `\u{1F50E} ${path16}\uFF08schema \u7C7B\u578B\uFF1A${result.kind ?? "\u672A\u8BC6\u522B"}\uFF0C\u6765\u6E90 ${META_SCHEMA_SOURCE_COMMIT.slice(0, 8)}\uFF09
7984
+ `\u{1F50E} ${path17}\uFF08schema \u7C7B\u578B\uFF1A${result.kind ?? "\u672A\u8BC6\u522B"}\uFF0C\u6765\u6E90 ${META_SCHEMA_SOURCE_COMMIT.slice(0, 8)}\uFF09
7787
7985
  `
7788
7986
  );
7789
7987
  process.stdout.write(
@@ -7802,8 +8000,8 @@ async function metaValidateCommand(path16, args) {
7802
8000
  init_exit();
7803
8001
  init_auth_guard();
7804
8002
  import * as crypto from "crypto";
7805
- import * as fs6 from "fs/promises";
7806
- import * as path6 from "path";
8003
+ import * as fs7 from "fs/promises";
8004
+ import * as path7 from "path";
7807
8005
  import {
7808
8006
  buildMiniPreviewTargets,
7809
8007
  buildMiniVerifyAgentReport,
@@ -7943,7 +8141,7 @@ async function workspaceBindCommand(workspaceKey, args) {
7943
8141
  tenantId: args.tenant ?? client3?.tenantId,
7944
8142
  endpoint: args.endpoint ?? client3?.endpoint
7945
8143
  });
7946
- await fs6.mkdir(rootDir, { recursive: true });
8144
+ await fs7.mkdir(rootDir, { recursive: true });
7947
8145
  await writeWorkspaceContext(rootDir, context);
7948
8146
  writeWorkspaceBindResult(context, rootDir, args.output ?? "table");
7949
8147
  process.exitCode = 0;
@@ -7980,7 +8178,7 @@ async function workspaceCreateCommand(workspaceKey, args) {
7980
8178
  tenantId: client3.tenantId,
7981
8179
  endpoint: client3.endpoint
7982
8180
  });
7983
- await fs6.mkdir(rootDir, { recursive: true });
8181
+ await fs7.mkdir(rootDir, { recursive: true });
7984
8182
  await writeWorkspaceContext(rootDir, context);
7985
8183
  writeWorkspaceCreateResult(
7986
8184
  {
@@ -8018,7 +8216,7 @@ async function workspacePullCommand(args) {
8018
8216
  tenantId: client3.tenantId ?? existing?.tenantId,
8019
8217
  endpoint: client3.endpoint ?? existing?.endpoint
8020
8218
  });
8021
- await fs6.mkdir(rootDir, { recursive: true });
8219
+ await fs7.mkdir(rootDir, { recursive: true });
8022
8220
  await writeWorkspaceContext(rootDir, context);
8023
8221
  const files = await listWorkspaceFiles(client3.raw(), workspaceKey, { pageSize: 5e3 });
8024
8222
  const miniApps = detectRemoteMiniApps(files.data);
@@ -8028,7 +8226,7 @@ async function workspacePullCommand(args) {
8028
8226
  http: client3.raw(),
8029
8227
  appCode,
8030
8228
  workspaceKey,
8031
- targetDir: path6.join(rootDir, MINI_APPS_DIR, appCode),
8229
+ targetDir: path7.join(rootDir, MINI_APPS_DIR, appCode),
8032
8230
  tenantId: client3.tenantId,
8033
8231
  endpoint: client3.endpoint,
8034
8232
  profile: args.profile ?? client3.profile,
@@ -8043,7 +8241,7 @@ async function workspacePullCommand(args) {
8043
8241
  const rawRemoteByLocalPath = /* @__PURE__ */ new Map();
8044
8242
  for (const file of rawFiles) {
8045
8243
  const content = await loadWorkspaceFileContent(client3.raw(), file.id);
8046
- const target = path6.join(rootDir, content.relativePath);
8244
+ const target = path7.join(rootDir, content.relativePath);
8047
8245
  await writeTextFile(target, content.content, !!args.force);
8048
8246
  pulledRawFiles.push(content.relativePath);
8049
8247
  rawRemoteByLocalPath.set(content.relativePath, file);
@@ -8094,7 +8292,7 @@ async function workspaceAddMiniCommand(appCode, args) {
8094
8292
  const result = await initMiniAppProject({
8095
8293
  appCode,
8096
8294
  workspaceKey: context.workspaceKey,
8097
- targetDir: path6.join(rootDir, MINI_APPS_DIR, appCode),
8295
+ targetDir: path7.join(rootDir, MINI_APPS_DIR, appCode),
8098
8296
  name: args.name,
8099
8297
  defaultSurface: parseSurface(args.surface),
8100
8298
  templateKind,
@@ -8120,10 +8318,10 @@ async function workspaceRmCommand(relativePath, args) {
8120
8318
  const rootDir = resolveRootDir(args.dir);
8121
8319
  const context = await requireWorkspaceContext(rootDir);
8122
8320
  const normalized = normalizeWorkspaceRmPath(relativePath);
8123
- const absolutePath = path6.join(rootDir, ...normalized.split("/"));
8321
+ const absolutePath = path7.join(rootDir, ...normalized.split("/"));
8124
8322
  let stat;
8125
8323
  try {
8126
- stat = await fs6.lstat(absolutePath);
8324
+ stat = await fs7.lstat(absolutePath);
8127
8325
  } catch (e) {
8128
8326
  if (e.code !== "ENOENT") throw e;
8129
8327
  stat = null;
@@ -8179,7 +8377,7 @@ async function workspaceRmCommand(relativePath, args) {
8179
8377
  }
8180
8378
  throw new Error(`workspace file not found locally or in the workspace: ${normalized}`);
8181
8379
  }
8182
- await fs6.unlink(absolutePath);
8380
+ await fs7.unlink(absolutePath);
8183
8381
  const result = {
8184
8382
  workspaceKey: context.workspaceKey,
8185
8383
  file: normalized,
@@ -8453,7 +8651,7 @@ function removedMiniCommand() {
8453
8651
  );
8454
8652
  }
8455
8653
  function resolveRootDir(dir) {
8456
- return path6.resolve(dir ?? ".");
8654
+ return path7.resolve(dir ?? ".");
8457
8655
  }
8458
8656
  function buildWorkspaceContext(args) {
8459
8657
  return {
@@ -8469,7 +8667,7 @@ function buildWorkspaceContext(args) {
8469
8667
  async function readWorkspaceContext(rootDir) {
8470
8668
  try {
8471
8669
  const parsed = JSON.parse(
8472
- await fs6.readFile(path6.join(rootDir, WORKSPACE_CONTEXT_FILE), "utf-8")
8670
+ await fs7.readFile(path7.join(rootDir, WORKSPACE_CONTEXT_FILE), "utf-8")
8473
8671
  );
8474
8672
  if (parsed.kind !== WORKSPACE_CONTEXT_KIND || parsed.version !== WORKSPACE_CONTEXT_VERSION) {
8475
8673
  throw new Error(`${WORKSPACE_CONTEXT_FILE} is not an HCM workspace context`);
@@ -8498,26 +8696,26 @@ async function requireWorkspaceContext(rootDir) {
8498
8696
  return context;
8499
8697
  }
8500
8698
  async function writeWorkspaceContext(rootDir, context) {
8501
- await fs6.writeFile(
8502
- path6.join(rootDir, WORKSPACE_CONTEXT_FILE),
8699
+ await fs7.writeFile(
8700
+ path7.join(rootDir, WORKSPACE_CONTEXT_FILE),
8503
8701
  JSON.stringify(context, null, 2) + "\n"
8504
8702
  );
8505
8703
  }
8506
8704
  async function writeTextFile(file, content, force) {
8507
8705
  try {
8508
- await fs6.access(file);
8706
+ await fs7.access(file);
8509
8707
  if (!force) throw new Error(`${file} already exists; use --force to overwrite`);
8510
8708
  } catch (e) {
8511
8709
  if (e.code !== "ENOENT") throw e;
8512
8710
  }
8513
- await fs6.mkdir(path6.dirname(file), { recursive: true });
8514
- await fs6.writeFile(file, content);
8711
+ await fs7.mkdir(path7.dirname(file), { recursive: true });
8712
+ await fs7.writeFile(file, content);
8515
8713
  }
8516
8714
  async function readWorkspaceRawManifest(rootDir, context) {
8517
8715
  try {
8518
8716
  const parsed = JSON.parse(
8519
- await fs6.readFile(
8520
- path6.join(rootDir, WORKSPACE_STATE_DIR, WORKSPACE_PULL_MANIFEST_FILE),
8717
+ await fs7.readFile(
8718
+ path7.join(rootDir, WORKSPACE_STATE_DIR, WORKSPACE_PULL_MANIFEST_FILE),
8521
8719
  "utf-8"
8522
8720
  )
8523
8721
  );
@@ -8539,8 +8737,8 @@ async function readWorkspaceRawManifest(rootDir, context) {
8539
8737
  }
8540
8738
  }
8541
8739
  async function writeWorkspaceRawState(rootDir, context, files, remoteByLocalPath) {
8542
- const stateDir = path6.join(rootDir, WORKSPACE_STATE_DIR);
8543
- await fs6.mkdir(stateDir, { recursive: true });
8740
+ const stateDir = path7.join(rootDir, WORKSPACE_STATE_DIR);
8741
+ await fs7.mkdir(stateDir, { recursive: true });
8544
8742
  const snapshots = files.map(
8545
8743
  (file) => ({
8546
8744
  localPath: file.localPath,
@@ -8551,8 +8749,8 @@ async function writeWorkspaceRawState(rootDir, context, files, remoteByLocalPath
8551
8749
  lastModified: remoteByLocalPath.get(file.localPath)?.lastModified
8552
8750
  })
8553
8751
  );
8554
- await fs6.writeFile(
8555
- path6.join(stateDir, WORKSPACE_PULL_MANIFEST_FILE),
8752
+ await fs7.writeFile(
8753
+ path7.join(stateDir, WORKSPACE_PULL_MANIFEST_FILE),
8556
8754
  JSON.stringify(
8557
8755
  {
8558
8756
  version: WORKSPACE_CONTEXT_VERSION,
@@ -8568,10 +8766,10 @@ async function writeWorkspaceRawState(rootDir, context, files, remoteByLocalPath
8568
8766
  );
8569
8767
  }
8570
8768
  async function writeWorkspaceRawManifest(rootDir, manifest2) {
8571
- const stateDir = path6.join(rootDir, WORKSPACE_STATE_DIR);
8572
- await fs6.mkdir(stateDir, { recursive: true });
8573
- await fs6.writeFile(
8574
- path6.join(stateDir, WORKSPACE_PULL_MANIFEST_FILE),
8769
+ const stateDir = path7.join(rootDir, WORKSPACE_STATE_DIR);
8770
+ await fs7.mkdir(stateDir, { recursive: true });
8771
+ await fs7.writeFile(
8772
+ path7.join(stateDir, WORKSPACE_PULL_MANIFEST_FILE),
8575
8773
  JSON.stringify(manifest2, null, 2) + "\n",
8576
8774
  "utf8"
8577
8775
  );
@@ -8583,10 +8781,10 @@ async function readWorkspaceRawLocalFiles(rootDir) {
8583
8781
  return files;
8584
8782
  }
8585
8783
  async function walkWorkspaceRawFiles(rootDir, relativeDir, files) {
8586
- const absoluteDir = path6.join(rootDir, relativeDir);
8784
+ const absoluteDir = path7.join(rootDir, relativeDir);
8587
8785
  let entries;
8588
8786
  try {
8589
- entries = await fs6.readdir(absoluteDir, { withFileTypes: true });
8787
+ entries = await fs7.readdir(absoluteDir, { withFileTypes: true });
8590
8788
  } catch (e) {
8591
8789
  if (e.code === "ENOENT") return;
8592
8790
  throw e;
@@ -8594,14 +8792,14 @@ async function walkWorkspaceRawFiles(rootDir, relativeDir, files) {
8594
8792
  for (const entry of entries) {
8595
8793
  if (entry.isDirectory() && RAW_WORKSPACE_EXCLUDED_DIRS.has(entry.name)) continue;
8596
8794
  if (entry.isFile() && RAW_WORKSPACE_EXCLUDED_FILES.has(entry.name)) continue;
8597
- const localPath = normalizeRelativePath(path6.posix.join(toPosix(relativeDir), entry.name));
8598
- const absolutePath = path6.join(rootDir, localPath);
8795
+ const localPath = normalizeRelativePath(path7.posix.join(toPosix(relativeDir), entry.name));
8796
+ const absolutePath = path7.join(rootDir, localPath);
8599
8797
  if (entry.isDirectory()) {
8600
8798
  await walkWorkspaceRawFiles(rootDir, localPath, files);
8601
8799
  continue;
8602
8800
  }
8603
8801
  if (!entry.isFile()) continue;
8604
- const content = await fs6.readFile(absolutePath, "utf-8");
8802
+ const content = await fs7.readFile(absolutePath, "utf-8");
8605
8803
  files.push({
8606
8804
  localPath,
8607
8805
  absolutePath,
@@ -8783,15 +8981,15 @@ function workspaceRawConflict(entry, reason) {
8783
8981
  };
8784
8982
  }
8785
8983
  async function discoverMiniApps(rootDir) {
8786
- const appsRoot = path6.join(rootDir, MINI_APPS_DIR);
8984
+ const appsRoot = path7.join(rootDir, MINI_APPS_DIR);
8787
8985
  let entries;
8788
8986
  try {
8789
- entries = await fs6.readdir(appsRoot, { withFileTypes: true });
8987
+ entries = await fs7.readdir(appsRoot, { withFileTypes: true });
8790
8988
  } catch (e) {
8791
8989
  if (e.code === "ENOENT") return [];
8792
8990
  throw e;
8793
8991
  }
8794
- return entries.filter((entry) => entry.isDirectory()).map((entry) => ({ appCode: entry.name, dir: path6.join(appsRoot, entry.name) })).sort((a, b) => a.appCode.localeCompare(b.appCode));
8992
+ return entries.filter((entry) => entry.isDirectory()).map((entry) => ({ appCode: entry.name, dir: path7.join(appsRoot, entry.name) })).sort((a, b) => a.appCode.localeCompare(b.appCode));
8795
8993
  }
8796
8994
  function detectRemoteMiniApps(files) {
8797
8995
  const appCodes = /* @__PURE__ */ new Set();
@@ -8934,7 +9132,7 @@ function normalizeWorkspaceKey(value) {
8934
9132
  return key2;
8935
9133
  }
8936
9134
  function normalizeWorkspaceRmPath(value) {
8937
- if (path6.isAbsolute(value) || /^[A-Za-z]:[\\/]/.test(value)) {
9135
+ if (path7.isAbsolute(value) || /^[A-Za-z]:[\\/]/.test(value)) {
8938
9136
  throw new Error("workspace rm path must be relative to the bound workspace");
8939
9137
  }
8940
9138
  const normalized = normalizeRelativePath(value);
@@ -8956,7 +9154,7 @@ function normalizeRelativePath(value) {
8956
9154
  return normalized;
8957
9155
  }
8958
9156
  function toPosix(value) {
8959
- return value.split(path6.sep).join("/");
9157
+ return value.split(path7.sep).join("/");
8960
9158
  }
8961
9159
  function sha2563(content) {
8962
9160
  return crypto.createHash("sha256").update(content, "utf-8").digest("hex");
@@ -9483,229 +9681,12 @@ import {
9483
9681
  isTempEnv as isTempEnv3,
9484
9682
  listIdentities as listIdentities5,
9485
9683
  loadEnv as loadEnv5,
9486
- saveEnv as saveEnv4,
9487
- resolveProjectEnvironment as resolveProjectEnvironment2,
9488
- loadGlobalConfig as loadGlobalConfig9,
9489
- resolveEnvContext as resolveEnvContext7,
9490
- printResolvedEnvironment as printResolvedEnvironment7
9684
+ discoverProjectEnv as discoverProjectEnv4,
9685
+ findEnvByEndpoint as findEnvByEndpoint4,
9686
+ normalizeOrigin as normalizeOrigin5,
9687
+ loadGlobalConfig as loadGlobalConfig9
9491
9688
  } from "@hcmai/sdk";
9492
9689
 
9493
- // src/commands/delivery-page-acceptance.ts
9494
- function renderPageAcceptanceSh(evidenceDir = "\u8BC1\u636E") {
9495
- const ev = evidenceDir;
9496
- return [
9497
- "#!/usr/bin/env bash",
9498
- "set -euo pipefail",
9499
- "",
9500
- "usage() {",
9501
- " cat >&2 <<'USAGE'",
9502
- "\u7528\u6CD5\uFF1A",
9503
- " ./page-acceptance.sh --env <\u73AF\u5883> [--as <\u8EAB\u4EFD>] --path </\u7AD9\u5185\u8DEF\u5F84> \\",
9504
- " --expect-text <\u9875\u9762\u5FC5\u987B\u51FA\u73B0\u7684\u6587\u672C> [--expect-text <\u6587\u672C> ...] \\",
9505
- ` --out <${ev}/.../\u622A\u56FE.png> [--reject-text <\u4E0D\u5F97\u51FA\u73B0\u7684\u6587\u672C>] \\`,
9506
- " [--wait-ms 10000] [--size 1440x900]",
9507
- "",
9508
- "\u8BF4\u660E\uFF1A",
9509
- " - \u8C03\u7528 hcm open \u94F8\u4E00\u6B21\u6027\u767B\u5F55\u7968\u636E\uFF0C\u5E76\u7ACB\u5373\u4EA4\u7ED9\u672C\u673A Chrome/Chromium\u3002",
9510
- ` - \u622A\u56FE\u53EA\u80FD\u5199\u5165\u9879\u76EE\u7684 ${ev}/ \u76EE\u5F55\uFF1B\u5DF2\u6709\u6587\u4EF6\u4E0D\u4F1A\u88AB\u8986\u76D6\u3002`,
9511
- " - \u81F3\u5C11\u4E00\u4E2A --expect-text \u662F\u5FC5\u586B\u9879\uFF0C\u9632\u6B62\u628A\u767B\u5F55\u9875\u6216\u9519\u8BEF\u9875\u8BEF\u8BB0\u6210\u901A\u8FC7\u3002",
9512
- " - \u6D4F\u89C8\u5668\u672A\u5728 PATH \u65F6\uFF0C\u7528 HCM_CHROME_BIN=/\u7EDD\u5BF9\u8DEF\u5F84 \u6307\u5B9A\u3002",
9513
- "USAGE",
9514
- "}",
9515
- "",
9516
- "fail() {",
9517
- ` printf '\u9875\u9762\u9A8C\u6536\u5931\u8D25\uFF1A%s\\n' "$1" >&2`,
9518
- ' exit "${2:-1}"',
9519
- "}",
9520
- "",
9521
- "need_value() {",
9522
- ' if (( $# < 2 )) || [[ -z "$2" ]]; then fail "$1 \u7F3A\u5C11\u503C" 2; fi',
9523
- "}",
9524
- "",
9525
- 'environment=""',
9526
- 'identity=""',
9527
- 'page_path=""',
9528
- 'output=""',
9529
- 'wait_ms="10000"',
9530
- 'size="1440x900"',
9531
- "expected_texts=()",
9532
- "rejected_texts=()",
9533
- "",
9534
- "while (( $# > 0 )); do",
9535
- ' case "$1" in',
9536
- ' --env) need_value "$@"; environment="$2"; shift 2 ;;',
9537
- ' --as) need_value "$@"; identity="$2"; shift 2 ;;',
9538
- ' --path) need_value "$@"; page_path="$2"; shift 2 ;;',
9539
- ' --out) need_value "$@"; output="$2"; shift 2 ;;',
9540
- ' --expect-text) need_value "$@"; expected_texts+=("$2"); shift 2 ;;',
9541
- ' --reject-text) need_value "$@"; rejected_texts+=("$2"); shift 2 ;;',
9542
- ' --wait-ms) need_value "$@"; wait_ms="$2"; shift 2 ;;',
9543
- ' --size) need_value "$@"; size="$2"; shift 2 ;;',
9544
- " -h|--help) usage; exit 0 ;;",
9545
- ' *) fail "\u672A\u77E5\u53C2\u6570\uFF1A$1" 2 ;;',
9546
- " esac",
9547
- "done",
9548
- "",
9549
- '[[ -n "$environment" ]] || fail "\u5FC5\u987B\u663E\u5F0F\u4F20 --env" 2',
9550
- '[[ -n "$page_path" ]] || fail "\u5FC5\u987B\u4F20 --path" 2',
9551
- '[[ "$page_path" == /* ]] || fail "--path \u53EA\u63A5\u53D7\u4EE5 / \u5F00\u5934\u7684\u7AD9\u5185\u8DEF\u5F84" 2',
9552
- '[[ -n "$output" ]] || fail "\u5FC5\u987B\u4F20 --out" 2',
9553
- '[[ "$output" == *.png ]] || fail "--out \u5FC5\u987B\u4EE5 .png \u7ED3\u5C3E" 2',
9554
- '(( ${#expected_texts[@]} > 0 )) || fail "\u81F3\u5C11\u4F20\u4E00\u4E2A --expect-text" 2',
9555
- '[[ "$wait_ms" =~ ^[0-9]+$ ]] || fail "--wait-ms \u5FC5\u987B\u662F\u6574\u6570" 2',
9556
- '(( wait_ms >= 0 && wait_ms <= 60000 )) || fail "--wait-ms \u5FC5\u987B\u5728 0..60000" 2',
9557
- 'if [[ "$size" =~ ^([0-9]+)x([0-9]+)$ ]]; then',
9558
- ' width="${BASH_REMATCH[1]}"',
9559
- ' height="${BASH_REMATCH[2]}"',
9560
- "else",
9561
- ' fail "--size \u5FC5\u987B\u662F <\u5BBD>x<\u9AD8>\uFF0C\u4F8B\u5982 1440x900" 2',
9562
- "fi",
9563
- '(( width >= 320 && width <= 7680 && height >= 240 && height <= 7680 )) || fail "--size \u8D85\u51FA\u5141\u8BB8\u8303\u56F4\uFF08\u5BBD 320..7680\uFF0C\u9AD8 240..7680\uFF09" 2',
9564
- "",
9565
- 'project_root="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"',
9566
- `evidence_root="$project_root/${ev}"`,
9567
- `[[ -d "$evidence_root" && ! -L "$evidence_root" ]] || fail "\u9879\u76EE\u7684 ${ev}/ \u5FC5\u987B\u662F\u666E\u901A\u76EE\u5F55\uFF0C\u4E0D\u80FD\u662F\u7B26\u53F7\u94FE\u63A5"`,
9568
- `out_abs="$(node -e "const p=require('node:path'); const root=p.resolve(process.argv[1],'${ev}'); const out=p.resolve(process.argv[1],process.argv[2]); if(out!==root && !out.startsWith(root+p.sep)){process.stderr.write('--out \u5FC5\u987B\u4F4D\u4E8E\u9879\u76EE\u7684 ${ev}/ \u76EE\u5F55\\n'); process.exit(2)} process.stdout.write(out)" "$project_root" "$output")" || exit $?`,
9569
- '[[ ! -e "$out_abs" && ! -L "$out_abs" ]] || fail "\u622A\u56FE\u5DF2\u5B58\u5728\u6216\u662F\u7B26\u53F7\u94FE\u63A5\uFF0C\u62D2\u7EDD\u8986\u76D6\uFF1A$out_abs"',
9570
- 'mkdir -p "$(dirname "$out_abs")"',
9571
- 'canonical_root="$(cd "$evidence_root" && pwd -P)"',
9572
- 'canonical_parent="$(cd "$(dirname "$out_abs")" && pwd -P)"',
9573
- 'case "$canonical_parent/" in',
9574
- ' "$canonical_root/"*) ;;',
9575
- ` *) fail "--out \u7684\u7236\u76EE\u5F55\u7ECF\u7B26\u53F7\u94FE\u63A5\u9003\u51FA\u4E86 ${ev}/\uFF1A$output" ;;`,
9576
- "esac",
9577
- "",
9578
- "find_browser() {",
9579
- ' if [[ -n "${HCM_CHROME_BIN:-}" ]]; then',
9580
- ' if [[ -x "$HCM_CHROME_BIN" ]]; then printf "%s" "$HCM_CHROME_BIN"; return 0; fi',
9581
- ' if command -v "$HCM_CHROME_BIN" >/dev/null 2>&1; then command -v "$HCM_CHROME_BIN"; return 0; fi',
9582
- " return 1",
9583
- " fi",
9584
- " local candidate",
9585
- " for candidate in google-chrome-stable google-chrome chromium chromium-browser; do",
9586
- ' if command -v "$candidate" >/dev/null 2>&1; then command -v "$candidate"; return 0; fi',
9587
- " done",
9588
- ' for candidate in "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" "/Applications/Chromium.app/Contents/MacOS/Chromium"; do',
9589
- ' if [[ -x "$candidate" ]]; then printf "%s" "$candidate"; return 0; fi',
9590
- " done",
9591
- " return 1",
9592
- "}",
9593
- "",
9594
- 'command -v hcm >/dev/null 2>&1 || fail "\u627E\u4E0D\u5230 hcm\uFF1B\u5148\u8FD0\u884C ./setup.sh"',
9595
- 'browser="$(find_browser)" || fail "\u627E\u4E0D\u5230 Chrome/Chromium\uFF1B\u8BF7\u8BBE\u7F6E HCM_CHROME_BIN"',
9596
- 'temp_dir="$(mktemp -d "${TMPDIR:-/tmp}/hcm-page-acceptance.XXXXXX")"',
9597
- "cleanup() {",
9598
- ' case "$temp_dir" in "${TMPDIR:-/tmp}"/hcm-page-acceptance.*) rm -rf -- "$temp_dir" ;; esac',
9599
- "}",
9600
- "trap cleanup EXIT",
9601
- 'dom_file="$temp_dir/page.dom"',
9602
- 'browser_log="$temp_dir/browser.log"',
9603
- "",
9604
- 'hcm_args=(open "$page_path" --env "$environment")',
9605
- 'if [[ -n "$identity" ]]; then hcm_args+=(--as "$identity"); fi',
9606
- "hcm_args+=(--print-url)",
9607
- 'url="$(hcm "${hcm_args[@]}")" || fail "hcm open \u672A\u80FD\u94F8\u51FA\u9875\u9762\u7968\u636E"',
9608
- `url="\${url//$'\\r'/}"`,
9609
- '[[ "$url" == http://* || "$url" == https://* ]] || fail "hcm open \u6CA1\u6709\u8FD4\u56DE\u6709\u6548 URL"',
9610
- "",
9611
- "browser_args=(",
9612
- " --headless=new",
9613
- " --disable-gpu",
9614
- " --disable-dev-shm-usage",
9615
- " --hide-scrollbars",
9616
- " --no-first-run",
9617
- " --no-default-browser-check",
9618
- ' "--window-size=$size"',
9619
- ' "--virtual-time-budget=$wait_ms"',
9620
- ' "--screenshot=$out_abs"',
9621
- " --dump-dom",
9622
- ")",
9623
- 'if [[ "$(id -u)" == "0" ]]; then browser_args+=(--no-sandbox); fi',
9624
- 'if ! "$browser" "${browser_args[@]}" "$url" >"$dom_file" 2>"$browser_log"; then',
9625
- ' sed -E "s/(ticket=)[^&[:space:]]+/\\1<redacted>/g" "$browser_log" >&2 || true',
9626
- ' fail "\u6D4F\u89C8\u5668\u622A\u56FE\u8FDB\u7A0B\u5931\u8D25"',
9627
- "fi",
9628
- '[[ -s "$out_abs" ]] || fail "\u6D4F\u89C8\u5668\u672A\u751F\u6210\u975E\u7A7A PNG\uFF1A$out_abs"',
9629
- "",
9630
- 'for text in "${expected_texts[@]}"; do',
9631
- ' grep -Fq -- "$text" "$dom_file" || fail "\u9875\u9762\u672A\u51FA\u73B0\u671F\u671B\u6587\u672C\uFF1A$text\uFF08\u622A\u56FE\u5DF2\u4FDD\u7559\uFF09"',
9632
- "done",
9633
- 'for text in "${rejected_texts[@]}"; do',
9634
- ' if grep -Fq -- "$text" "$dom_file"; then fail "\u9875\u9762\u51FA\u73B0\u62D2\u7EDD\u6587\u672C\uFF1A$text\uFF08\u622A\u56FE\u5DF2\u4FDD\u7559\uFF09"; fi',
9635
- "done",
9636
- "",
9637
- 'browser_version="$("$browser" --version 2>/dev/null | head -n 1 || true)"',
9638
- `node -e "const fs=require('node:fs'); const result={ok:true,screenshot:process.argv[1],bytes:fs.statSync(process.argv[1]).size,environment:process.argv[2],identity:process.argv[3]||null,path:process.argv[4],viewport:process.argv[5],waitMs:Number(process.argv[6]),browser:process.argv[7]}; process.stdout.write(JSON.stringify(result)+'\\n')" "$out_abs" "$environment" "$identity" "$page_path" "$size" "$wait_ms" "$browser_version"`,
9639
- ""
9640
- ].join("\n");
9641
- }
9642
-
9643
- // src/commands/delivery-project-scaffold.ts
9644
- import { promises as fs7 } from "fs";
9645
- var AGENT_BEGIN = "<!-- hcm-delivery-project:begin -->";
9646
- var AGENT_END = "<!-- hcm-delivery-project:end -->";
9647
- async function mergeManagedFile(file, merge, result, relative2) {
9648
- const existing = await readRegularFile(file);
9649
- const next = merge(existing ?? "");
9650
- if (existing === next) {
9651
- result.preserved.push(relative2);
9652
- return;
9653
- }
9654
- await fs7.writeFile(file, next, { encoding: "utf8", mode: 420 });
9655
- (existing === null ? result.created : result.updated).push(relative2);
9656
- }
9657
- async function writeIfAbsent(file, content, result, relative2, mode = 420) {
9658
- try {
9659
- await fs7.writeFile(file, content, { encoding: "utf8", mode, flag: "wx" });
9660
- result.created.push(relative2);
9661
- return true;
9662
- } catch (cause) {
9663
- if (cause.code !== "EEXIST") throw cause;
9664
- await assertRegularFile(file);
9665
- result.preserved.push(relative2);
9666
- return false;
9667
- }
9668
- }
9669
- async function ensureDirectory(directory) {
9670
- await fs7.mkdir(directory, { recursive: true });
9671
- const stat = await fs7.lstat(directory);
9672
- if (!stat.isDirectory() || stat.isSymbolicLink()) {
9673
- throw new Error(`\u811A\u624B\u67B6\u8DEF\u5F84\u4E0D\u662F\u666E\u901A\u76EE\u5F55\uFF1A${directory}`);
9674
- }
9675
- }
9676
- async function readRegularFile(file) {
9677
- try {
9678
- await assertRegularFile(file);
9679
- return await fs7.readFile(file, "utf8");
9680
- } catch (cause) {
9681
- if (cause.code === "ENOENT") return null;
9682
- throw cause;
9683
- }
9684
- }
9685
- async function assertRegularFile(file) {
9686
- const stat = await fs7.lstat(file);
9687
- if (!stat.isFile() || stat.isSymbolicLink()) {
9688
- throw new Error(`\u811A\u624B\u67B6\u8DEF\u5F84\u4E0D\u662F\u666E\u901A\u6587\u4EF6\uFF1A${file}`);
9689
- }
9690
- }
9691
- function upsertBlock(existing, begin, end, block) {
9692
- const start = existing.indexOf(begin);
9693
- const finish2 = existing.indexOf(end);
9694
- const markersAreMalformed = start < 0 !== finish2 < 0 || start >= 0 && (finish2 < start || existing.lastIndexOf(begin) !== start || existing.lastIndexOf(end) !== finish2);
9695
- if (markersAreMalformed) {
9696
- throw new Error(`\u6258\u7BA1\u5757\u6807\u8BB0\u635F\u574F\u6216\u91CD\u590D\uFF0C\u62D2\u7EDD\u8986\u76D6\uFF1A${begin} \u2026 ${end}`);
9697
- }
9698
- let next;
9699
- if (start >= 0 && finish2 >= start) {
9700
- next = `${existing.slice(0, start)}${block}${existing.slice(finish2 + end.length)}`;
9701
- } else {
9702
- const prefix = existing.trimEnd();
9703
- next = `${prefix}${prefix ? "\n\n" : ""}${block}`;
9704
- }
9705
- return `${next.trimEnd()}
9706
- `;
9707
- }
9708
-
9709
9690
  // src/commands/chiron-project.ts
9710
9691
  import { promises as fs8 } from "fs";
9711
9692
 
@@ -9714,10 +9695,10 @@ init_exit();
9714
9695
  import { execFileSync } from "child_process";
9715
9696
  import { cpSync, existsSync as existsSync2, mkdirSync, mkdtempSync, readFileSync as readFileSync5, rmSync, statSync as statSync4, writeFileSync as writeFileSync2 } from "fs";
9716
9697
  import os4 from "os";
9717
- import path7 from "path";
9698
+ import path8 from "path";
9718
9699
  import { CASES_REPO_SLUG, CASES_REPO_URL, CNB_ORIGIN, CliError as CliError23, CliErrorCode as CliErrorCode22, formatObject as formatObject21 } from "@hcmai/sdk";
9719
- var casesCacheDir = () => process.env.HCM_CASES_CACHE?.trim() || path7.join(os4.homedir(), ".cache", "hcm", "chiron-cases");
9720
- var INDEX_CACHE = () => path7.join(casesCacheDir(), "index.json");
9700
+ var casesCacheDir = () => process.env.HCM_CASES_CACHE?.trim() || path8.join(os4.homedir(), ".cache", "hcm", "chiron-cases");
9701
+ var INDEX_CACHE = () => path8.join(casesCacheDir(), "index.json");
9721
9702
  var INDEX_TTL_MS = 60 * 60 * 1e3;
9722
9703
  var fail7 = (message, nextStep) => new CliError23({ code: CliErrorCode22.INVALID_ARGUMENT, message, context: { nextStep } });
9723
9704
  var run = (cmd, args, opts = {}) => execFileSync(cmd, args, { encoding: "utf8", maxBuffer: 1 << 26, ...opts });
@@ -9758,7 +9739,7 @@ function loadIndex(opts = {}) {
9758
9739
  );
9759
9740
  return JSON.parse(readFileSync5(file, "utf8"));
9760
9741
  }
9761
- mkdirSync(path7.dirname(file), { recursive: true });
9742
+ mkdirSync(path8.dirname(file), { recursive: true });
9762
9743
  writeFileSync2(file, text);
9763
9744
  return JSON.parse(text);
9764
9745
  }
@@ -9897,16 +9878,16 @@ async function caseMatchCommand(args) {
9897
9878
  }
9898
9879
  async function caseSubmitCommand(dir, args) {
9899
9880
  await guard(async () => {
9900
- const src = path7.resolve(dir);
9901
- if (!existsSync2(path7.join(src, "case.yml"))) {
9881
+ const src = path8.resolve(dir);
9882
+ if (!existsSync2(path8.join(src, "case.yml"))) {
9902
9883
  throw fail7(`${src} \u91CC\u6CA1\u6709 case.yml`, "\u6307\u5230\u9879\u76EE\u4ED3\u7684\u6848\u4F8B\u76EE\u5F55\uFF08\u5982 cases/CASE-20260902-xxx\uFF09\uFF0C\u90A3\u91CC\u5E94\u5F53\u6709 case.yml\u3002");
9903
9884
  }
9904
- const yamlText = readFileSync5(path7.join(src, "case.yml"), "utf8");
9885
+ const yamlText = readFileSync5(path8.join(src, "case.yml"), "utf8");
9905
9886
  const id = /^\s*(?:id|case_id):\s*(\S+)/m.exec(yamlText)?.[1];
9906
9887
  if (!id) throw fail7("case.yml \u91CC\u6CA1\u6709 id", "case.yml \u9876\u5C42\u8981\u6709 `id: CASE-YYYYMMDD-xxx`\u3002");
9907
- const work = mkdtempSync(path7.join(os4.tmpdir(), "hcm-case-submit-"));
9888
+ const work = mkdtempSync(path8.join(os4.tmpdir(), "hcm-case-submit-"));
9908
9889
  try {
9909
- const repo = path7.join(work, "chiron-cases");
9890
+ const repo = path8.join(work, "chiron-cases");
9910
9891
  try {
9911
9892
  run("git", ["clone", "--depth", "1", "--filter=blob:none", "--quiet", CASES_REPO_URL, repo]);
9912
9893
  } catch (e) {
@@ -9917,10 +9898,10 @@ async function caseSubmitCommand(dir, args) {
9917
9898
  }
9918
9899
  const branch = `case/${id}-submit`;
9919
9900
  run("git", ["-C", repo, "checkout", "-q", "-B", branch]);
9920
- const dst = path7.join(repo, "cases", args.category, id);
9901
+ const dst = path8.join(repo, "cases", args.category, id);
9921
9902
  cpSync(src, dst, { recursive: true, filter: (p) => !p.includes("node_modules") });
9922
- mkdirSync(path7.join(dst, "evidence"), { recursive: true });
9923
- let doc = readFileSync5(path7.join(dst, "case.yml"), "utf8");
9903
+ mkdirSync(path8.join(dst, "evidence"), { recursive: true });
9904
+ let doc = readFileSync5(path8.join(dst, "case.yml"), "utf8");
9924
9905
  doc = /^\s*tier:/m.test(doc) ? doc.replace(/^\s*tier:.*$/m, "tier: public") : `tier: public
9925
9906
  ${doc}`;
9926
9907
  doc = /^\s*category:/m.test(doc) ? doc.replace(/^\s*category:.*$/m, `category: ${args.category}`) : `category: ${args.category}
@@ -9929,7 +9910,7 @@ ${doc}`;
9929
9910
  ${doc}`;
9930
9911
  if (!/^\s*status:/m.test(doc)) doc = `status: approved
9931
9912
  ${doc}`;
9932
- writeFileSync2(path7.join(dst, "case.yml"), doc);
9913
+ writeFileSync2(path8.join(dst, "case.yml"), doc);
9933
9914
  run("python3", ["scripts/render-readme.py", dst], { cwd: repo });
9934
9915
  let lint;
9935
9916
  try {
@@ -9976,11 +9957,9 @@ ${lint.trim()}`
9976
9957
  }
9977
9958
 
9978
9959
  // src/commands/chiron-project.ts
9979
- import os5 from "os";
9980
- import path8 from "path";
9981
- import { hcmConfigDir, normalizeOrigin as normalizeOrigin3 } from "@hcmai/sdk";
9960
+ import { normalizeOrigin as normalizeOrigin3 } from "@hcmai/sdk";
9982
9961
  import { JIRA_BASE, JIRA_PROJECT, jiraTokenSource } from "@hcmai/sdk";
9983
- import { ENV_FILE, parseEnvYaml, renderEnvYaml, findEnvByEndpoint as findEnvByEndpoint2, normalizeOrigin as normalizeOrigin4 } from "@hcmai/sdk";
9962
+ import { ENV_FILE, parseEnvYaml, renderEnvYaml, findEnvByEndpoint as findEnvByEndpoint3, normalizeOrigin as normalizeOrigin4 } from "@hcmai/sdk";
9984
9963
  import { CASES_REPO_URL as CASES_REPO_URL2 } from "@hcmai/sdk";
9985
9964
  import { JIRA_BASE as JIRA_BASE2, JIRA_PROJECT as JIRA_PROJECT2, JIRA_TOKEN_FILE, jiraTokenSource as jiraTokenSource2 } from "@hcmai/sdk";
9986
9965
  var SKILLS_DIR = "hcm-skills";
@@ -10003,28 +9982,6 @@ function projectEnvFromConfig(cfg) {
10003
9982
  tenant: cfg.tenantId ?? "1"
10004
9983
  };
10005
9984
  }
10006
- function renderChironAgentInstructions() {
10007
- return [
10008
- AGENT_BEGIN,
10009
- "# HCM \u987E\u95EE\u9879\u76EE\u8FB9\u754C",
10010
- "",
10011
- "- \u53EA\u4F7F\u7528\u672C\u9879\u76EE `hcm-skills/` \u91CC\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",
10012
- "- **\u63A5\u5230\u9700\u6C42\u5148\u505A\u4E00\u8F6E\u53EA\u8BFB\u6838\u5BF9**\uFF08\u8FB9\u754C\u3001\u6280\u80FD\u6E05\u5355\u3001CLI \u7248\u672C\u3001\u73AF\u5883\u4E0E\u8EAB\u4EFD\uFF09\uFF0C\u7ED9\u51FA READY / READY WITH RISKS / BLOCKED \u518D\u52A8\u624B\u3002\u987E\u95EE\u4E0D\u9700\u8981\u7C98\u4EFB\u4F55\u5F00\u573A\u767D\uFF0C\u8FD9\u6761\u5C31\u662F\u5F00\u573A\u767D\u3002",
10013
- "- \u9700\u6C42\u8BF4\u5F97\u542B\u7CCA\u5C31\u8FFD\u95EE\uFF0C\u4E0D\u8981\u66FF\u5BA2\u6237\u731C\u53E3\u5F84\uFF1B\u53E3\u5F84\u4E0E\u8303\u56F4\u5199\u8FDB `requirements/`\uFF0C\u5BA2\u6237\u62CD\u677F\u7684\u5199\u8FDB `decisions/`\u3002",
10014
- "- \u9879\u76EE\u5BF9\u7740\u7684\u73AF\u5883\u5728 `env.yaml`\uFF08default / environments\uFF0C\u5404\u73AF\u5883\u542B endpoint / frontend / tenant / roles\uFF09\uFF0C\u8EAB\u4EFD\u5728\u672C\u673A `hcm login`\u3002\u6BCF\u6B21\u5F00\u5DE5\u5148\u8DD1 `hcm chiron doctor`\uFF1B\u73AF\u5883\u4E8B\u5B9E\u5FC5\u987B\u73B0\u67E5\uFF0C\u4E0D\u51ED\u8BB0\u5FC6\u586B\u5199\u3002",
10015
- "- \u5199\u6388\u6743\u53EA\u8BA4\u9879\u76EE\u8D1F\u8D23\u4EBA\u5728**\u672C\u6B21\u5BF9\u8BDD\u6216\u4EFB\u52A1\u4E66**\u91CC\u7684\u660E\u786E\u6279\u51C6\uFF1B\u5BA2\u6237\u53E3\u5934\u8981\u6C42\u6216\u7FA4\u6D88\u606F\u4E0D\u662F\u6267\u884C\u6388\u6743\u3002",
10016
- "- \u5199\u524D\u5FC5\u987B\u8BF4\u660E\u5BF9\u8C61\u3001\u8303\u56F4\u3001\u5F71\u54CD\u4E0E\u56DE\u9000\u5E76\u53D6\u5F97\u672C\u6B21\u660E\u786E\u786E\u8BA4\u3002\u975E\u4EA4\u4E92\u8FD0\u884C\u62FF\u4E0D\u5230\u786E\u8BA4\u65F6**\u505C\u5728\u8BA1\u5212\u3001\u4E0D\u8981\u5199**\uFF0C\u7ED3\u8BBA\u5FC5\u987B\u4E3A `BLOCKED` \u5E76\u9644\u8BA1\u5212\u3002",
10017
- "- \u76EE\u5F55\u7EA6\u5B9A\uFF1A`requirements/` \u5BA2\u6237\u9700\u6C42 \xB7 `deliverables/` \u4EA4\u4ED8\u7269 \xB7 `evidence/` \u622A\u56FE\u4E0E\u6536\u636E \xB7 `cases/` \u6C89\u6DC0\u7684\u6848\u4F8B \xB7 `gaps/` \u4EA7\u54C1\u505A\u4E0D\u5230\u7684\u53F0\u8D26 \xB7 `decisions/` \u51B3\u7B56 \xB7 `customer-docs/` \u5BA2\u6237\u8D44\u6599 \xB7 `work/` \u53D8\u66F4\u4E0E\u56DE\u6EDA\u8BF4\u660E\u3002",
10018
- "- \u649E\u5230\u4EA7\u54C1\u505A\u4E0D\u5230\uFF1A\u5148\u5199 `gaps/` \u53F0\u8D26\u5E76\u7B54\u6E05\u4E09\u95EE\uFF0C\u7528\u6848\u4F8B\u5E93 MCP \u7684 `gaps_search` \u67E5\u91CD\uFF0C\u7ECF\u987E\u95EE\u786E\u8BA4\u540E `gaps_submit` \u63D0\u5230 Jira\uFF08\u4EA7\u54C1\u5BF9\u5916\u7684\u7EDF\u4E00\u9762\uFF09\uFF0C\u62A5\u544A\u5199 `BLOCKED \xB7 \u5DF2\u63D0 <\u5355\u53F7> \xB7 \u66FF\u4EE3\u6CD5`\uFF1B\u4E4B\u540E\u7528 `gaps_status` \u67E5\u8FDB\u5EA6\u3002",
10019
- "- \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 `evidence/` \u4E0B\u7684 PNG \u8DEF\u5F84\uFF1B\u4E0D\u80FD\u53EA\u4EE5\u201C\u751F\u6210\u4E86\u622A\u56FE\u201D\u5224\u901A\u8FC7\u3002",
10020
- "- \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",
10021
- AGENT_END,
10022
- ""
10023
- ].join("\n");
10024
- }
10025
- function mergeChironAgentInstructions(existing) {
10026
- return upsertBlock(existing, AGENT_BEGIN, AGENT_END, renderChironAgentInstructions().trimEnd());
10027
- }
10028
9985
  async function inspectCaseLibrary() {
10029
9986
  try {
10030
9987
  const idx = loadIndex();
@@ -10080,12 +10037,13 @@ async function probeTokenTenant(envName, requested) {
10080
10037
  }
10081
10038
  var defaultChironInitDeps = {
10082
10039
  tokenTenant: probeTokenTenant,
10040
+ isTty: () => process.stdin.isTTY === true && process.stdout.isTTY === true,
10041
+ confirm: promptConfirm,
10083
10042
  installSkills: async (root, envName) => {
10084
10043
  const previous = process.cwd();
10085
10044
  process.chdir(root);
10086
10045
  try {
10087
- await skillsInstallCommand(void 0, {
10088
- all: true,
10046
+ await skillsSyncCommand({
10089
10047
  target: "codex",
10090
10048
  env: envName,
10091
10049
  dir: path9.join(root, SKILLS_DIR),
@@ -10095,38 +10053,77 @@ var defaultChironInitDeps = {
10095
10053
  process.chdir(previous);
10096
10054
  }
10097
10055
  if (process.exitCode && process.exitCode !== 0) {
10098
- throw new Error("\u6280\u80FD\u6CA1\u88C5\u4E0A\uFF08\u4E0A\u9762\u662F skills install \u7684\u8F93\u51FA\uFF09\uFF1B\u4FEE\u597D\u540E\u91CD\u8DD1 hcm chiron init");
10056
+ throw new Error("\u6280\u80FD\u6CA1\u88C5\u4E0A\uFF08\u4E0A\u9762\u662F hcm skills sync \u7684\u8F93\u51FA\uFF09\uFF1B\u4FEE\u597D\u540E\u5355\u8DD1 hcm skills sync \u5373\u53EF\uFF0C\u4E0D\u7528\u91CD\u8DD1 init");
10099
10057
  }
10100
10058
  }
10101
10059
  };
10102
- async function resolveLoggedInEnv(cwd, envFlag) {
10103
- const g = await loadGlobalConfig9();
10104
- const resolved = await resolveEnvContext7({ cwd, envFlag }, process.env, g);
10105
- const name = resolved.name;
10106
- const loginHint = "hcm login https://<\u4F60\u7684 HCM \u5730\u5740> --code <\u914D\u5BF9\u7801>";
10107
- if (!name) {
10108
- throw new CliError24({
10109
- code: CliErrorCode23.ENV_NOT_FOUND,
10110
- message: `\u8FD8\u6CA1\u767B\u5F55\u4EFB\u4F55\u73AF\u5883\u3002\u5148\u6267\u884C\uFF1A${loginHint}`
10060
+ async function resolveInitEnv(root, args, deps) {
10061
+ const identityOf = async (name2) => {
10062
+ const identities = await listIdentities5(name2).catch(() => []);
10063
+ if (identities.length === 0) return null;
10064
+ const config3 = await loadEnv5(name2).catch(() => null);
10065
+ return config3?.defaultIdentity && identities.includes(config3.defaultIdentity) ? config3.defaultIdentity : identities[0];
10066
+ };
10067
+ if (args.endpoint) {
10068
+ const endpoint = normalizeOrigin5(args.endpoint);
10069
+ return {
10070
+ // 🔴 没给 --env 时这个名字是 env.yaml 的占位名,**不是**在指本机某个槽。
10071
+ // 所以也不去查身份:本机恰好有个同名槽,跟这次声明的地址毫无关系
10072
+ // (实测:`--endpoint http://127.0.0.1:59999` 回执里冒出了 `suitj@default`)。
10073
+ name: args.env ?? "default",
10074
+ env: { endpoint, frontend: args.frontend ? normalizeOrigin5(args.frontend) : endpoint, tenant: args.tenant ?? "1" },
10075
+ source: "--endpoint",
10076
+ identity: args.env ? await identityOf(args.env) : null
10077
+ };
10078
+ }
10079
+ const existing = await discoverProjectEnv4(root);
10080
+ if (existing && path9.dirname(existing.path) === path9.resolve(root)) {
10081
+ const name2 = args.env ?? existing.config.default;
10082
+ const env2 = existing.config.environments[name2];
10083
+ if (!env2) throw new CliError24({
10084
+ code: CliErrorCode23.INVALID_ARGUMENT,
10085
+ message: `${existing.path} \u91CC\u6CA1\u6709\u73AF\u5883 '${name2}'\uFF0C\u53EA\u6709\uFF1A${Object.keys(existing.config.environments).join("\u3001")}`,
10086
+ context: { nextStep: `hcm chiron env add ${name2} --endpoint <\u540E\u7AEF\u5730\u5740>` }
10111
10087
  });
10088
+ const slot = await findEnvByEndpoint4(env2.endpoint, env2.tenant, { strictTenant: true });
10089
+ return { name: name2, env: env2, source: "env.yaml", identity: slot ? await identityOf(slot.name) : null };
10112
10090
  }
10113
- const config2 = await loadEnv5(name).catch(() => null);
10114
- if (!config2?.endpoint) {
10115
- throw new CliError24({
10091
+ if (args.env) {
10092
+ const config3 = await loadEnv5(args.env).catch(() => null);
10093
+ if (!config3?.endpoint) throw new CliError24({
10116
10094
  code: CliErrorCode23.ENV_NOT_FOUND,
10117
- message: `\u5F53\u524D\u73AF\u5883 '${name}' \u6CA1\u6709 endpoint\u3002\u5148\u6267\u884C\uFF1A${loginHint}`
10095
+ message: `\u672C\u673A\u6CA1\u6709\u540D\u53EB '${args.env}' \u7684\u73AF\u5883\u3002`,
10096
+ context: { nextStep: "`hcm env list` \u770B\u6709\u54EA\u4E9B\uFF1B\u6216\u5B8C\u5168\u663E\u5F0F\u5730\u5EFA\uFF1A`hcm chiron init --endpoint <\u540E\u7AEF\u5730\u5740> --tenant <\u79DF\u6237\u53F7>`" }
10118
10097
  });
10098
+ return { name: args.env, env: projectEnvFromConfig(config3), source: "--env", identity: await identityOf(args.env) };
10119
10099
  }
10120
- const identities = await listIdentities5(name).catch(() => []);
10121
- if (identities.length === 0) {
10122
- throw new CliError24({
10123
- code: CliErrorCode23.IDENTITY_NOT_FOUND,
10124
- message: `\u73AF\u5883 '${name}'\uFF08${config2.endpoint}\uFF09\u8FD8\u6CA1\u6709\u767B\u5F55\u8EAB\u4EFD\u3002\u5148\u6267\u884C\uFF1Ahcm login ${config2.endpoint} --code <\u914D\u5BF9\u7801>`
10100
+ const g = await loadGlobalConfig9();
10101
+ const name = g.activeEnv;
10102
+ const config2 = name ? await loadEnv5(name).catch(() => null) : null;
10103
+ const explicitPaths = " hcm chiron init --env <\u672C\u673A\u73AF\u5883\u540D>\uFF08hcm env list \u770B\u6709\u54EA\u4E9B\uFF09\n hcm chiron init --endpoint <\u540E\u7AEF\u5730\u5740> --tenant <\u79DF\u6237\u53F7>\uFF08\u5B8C\u5168\u663E\u5F0F\uFF0C\u4E0D\u9700\u8981\u5148\u767B\u5F55\uFF09";
10104
+ if (!config2?.endpoint) throw new CliError24({
10105
+ code: CliErrorCode23.ENV_NOT_FOUND,
10106
+ message: "\u6CA1\u8BF4\u8FD9\u4E2A\u9879\u76EE\u5BF9\u7740\u54EA\u4E2A\u73AF\u5883\uFF0C\u672C\u673A\u4E5F\u6CA1\u6709\u53EF\u7528\u7684\u6D3B\u52A8\u73AF\u5883\u3002",
10107
+ context: { nextStep: `\u4E8C\u9009\u4E00\uFF1A
10108
+ ${explicitPaths}` }
10109
+ });
10110
+ if (isTempEnv3(name)) throw new CliError24({
10111
+ code: CliErrorCode23.INVALID_ARGUMENT,
10112
+ message: `\u672C\u673A\u6D3B\u52A8\u73AF\u5883\u662F\u4E34\u65F6\u7684\uFF08${config2.endpoint}\uFF09\uFF0C\u8FD8\u6CA1\u6709\u540D\u5B57\u3002\u9879\u76EE\u8981\u7ED1\u4E00\u4E2A\u7A33\u5B9A\u7684\u73AF\u5883\uFF0C\u5426\u5219\u4E0B\u4E00\u6B21 hcm login --code \u8986\u76D6\u5B83\u4E4B\u540E\uFF0C\u4ED3\u91CC\u8BB0\u7684\u5C31\u5BF9\u4E0D\u4E0A\u4E86\u3002`,
10113
+ context: { nextStep: `\u5148\u7ED9\u5B83\u8D77\u4E2A\u540D\u5B57\uFF1Ahcm env save <name>\uFF1B\u6216\u76F4\u63A5\u663E\u5F0F\u5EFA\uFF1A
10114
+ ${explicitPaths}` }
10115
+ });
10116
+ const summary = `${name} \xB7 ${config2.endpoint} \xB7 \u79DF\u6237 ${config2.tenantId ?? "1"}`;
10117
+ if (!args.yes) {
10118
+ const ok = deps.isTty() && deps.confirm ? await deps.confirm(`\u6CA1\u6307\u5B9A\u73AF\u5883\uFF0C\u7528\u672C\u673A\u5F53\u524D\u6D3B\u52A8\u7684 ${summary} \u5417\uFF1F[y/N] `) : false;
10119
+ if (!ok) throw new CliError24({
10120
+ code: CliErrorCode23.INVALID_ARGUMENT,
10121
+ message: `\u6CA1\u786E\u8BA4\u8981\u7528\u672C\u673A\u6D3B\u52A8\u73AF\u5883\uFF08${summary}\uFF09\u3002\u9879\u76EE\u73AF\u5883\u4F1A\u63D0\u4EA4\u8FDB\u4ED3\u3001\u5F71\u54CD\u6240\u6709\u534F\u4F5C\u8005\uFF0C\u4E0D\u9760\u4E0A\u4E00\u6761\u547D\u4EE4\u7684\u526F\u4F5C\u7528\u51B3\u5B9A\u3002`,
10122
+ context: { nextStep: `\u786E\u8BA4\u5C31\u52A0 --yes\uFF1B\u6216\u660E\u8BF4\uFF1A
10123
+ ${explicitPaths}` }
10125
10124
  });
10126
10125
  }
10127
- const identity2 = config2.defaultIdentity && identities.includes(config2.defaultIdentity) ? config2.defaultIdentity : identities[0];
10128
- printResolvedEnvironment7(resolved, identity2);
10129
- return { name, env: resolved.project?.environment ?? projectEnvFromConfig(config2), identity: identity2 };
10126
+ return { name, env: projectEnvFromConfig(config2), source: "activeEnv\uFF08\u5DF2\u786E\u8BA4\uFF09", identity: await identityOf(name) };
10130
10127
  }
10131
10128
  async function scaffoldChironProject(root, env2, envName) {
10132
10129
  const result = { created: [], updated: [], preserved: [] };
@@ -10160,57 +10157,59 @@ async function scaffoldChironProject(root, env2, envName) {
10160
10157
  await ensureDirectory(absolute);
10161
10158
  await writeIfAbsent(path9.join(absolute, ".gitkeep"), "", result, `${directory}/.gitkeep`);
10162
10159
  }
10163
- const pageAcceptanceFile = path9.join(root, "page-acceptance.sh");
10164
- const created = await writeIfAbsent(pageAcceptanceFile, renderPageAcceptanceSh("evidence"), result, "page-acceptance.sh", 493);
10165
- if (created) await fs9.chmod(pageAcceptanceFile, 493);
10166
- await mergeManagedFile(path9.join(root, "AGENTS.md"), mergeChironAgentInstructions, result, "AGENTS.md");
10167
- await mergeManagedFile(path9.join(root, "CLAUDE.md"), mergeChironAgentInstructions, result, "CLAUDE.md");
10168
10160
  return result;
10169
10161
  }
10170
10162
  async function runChironInit(args, deps = defaultChironInitDeps) {
10171
10163
  const root = path9.resolve(args.project ?? ".");
10172
- const { name, env: env2, identity: identity2 } = await resolveLoggedInEnv(root, args.env);
10173
- if (isTempEnv3(name)) {
10174
- throw new CliError24({
10175
- code: CliErrorCode23.INVALID_ARGUMENT,
10176
- 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`,
10177
- context: { nextStep: `\u5148\u7ED9\u5B83\u8D77\u4E2A\u540D\u5B57\uFF1Ahcm env save <name>\uFF0C\u7136\u540E\u91CD\u8DD1 hcm chiron init` }
10178
- });
10179
- }
10180
10164
  const say = (line) => process.stderr.write(`[chiron init] ${line}
10181
10165
  `);
10182
- const actual = await deps.tokenTenant(name, env2.tenant);
10183
- const project = await resolveProjectEnvironment2({ cwd: root, envFlag: args.env });
10184
- if (project && actual && actual !== project.environment.tenant) throw new CliError24({
10185
- code: CliErrorCode23.IDENTITY_NOT_IN_ENV,
10186
- message: `${ENV_FILE} \u662F\u79DF\u6237 ${project.environment.tenant}\uFF0C\u800C\u4F60\u767B\u5F55\u7684\u8EAB\u4EFD\u5C5E\u4E8E\u79DF\u6237 ${actual}\u3002`,
10187
- context: { nextStep: `hcm login --env ${project.name} \u4F7F\u7528\u9879\u76EE\u79DF\u6237\u91CD\u65B0\u767B\u5F55` }
10188
- });
10189
- if (actual && actual !== env2.tenant) {
10190
- 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}`);
10191
- env2.tenant = actual;
10192
- const local = await loadEnv5(name);
10193
- await saveEnv4(name, { ...local, tenantId: actual });
10194
- }
10195
- say(`\u73AF\u5883 ${name} \xB7 ${env2.endpoint} \xB7 \u79DF\u6237 ${env2.tenant} \xB7 \u8EAB\u4EFD ${identity2}`);
10196
- const scaffold = await scaffoldChironProject(root, env2, name);
10166
+ const choice = await resolveInitEnv(root, args, deps);
10167
+ say(`\u73AF\u5883 ${choice.name} \xB7 ${choice.env.endpoint} \xB7 \u79DF\u6237 ${choice.env.tenant}\uFF08\u6765\u81EA ${choice.source}\uFF09`);
10168
+ const scaffold = await scaffoldChironProject(root, choice.env, choice.name);
10197
10169
  say(`\u9AA8\u67B6\uFF1A\u65B0\u5EFA ${scaffold.created.length} \xB7 \u66F4\u65B0 ${scaffold.updated.length} \xB7 \u4FDD\u7559 ${scaffold.preserved.length}`);
10170
+ let tenantCheck = { status: "skipped", detail: "\u5B8C\u5168\u663E\u5F0F\u58F0\u660E\uFF08--endpoint\uFF09\uFF0C\u6CA1\u6709\u5411\u670D\u52A1\u7AEF\u6838\u5BF9" };
10171
+ if (args.endpoint === void 0) {
10172
+ if (choice.identity === null) {
10173
+ tenantCheck = { status: "unreachable", detail: `\u73AF\u5883 '${choice.name}' \u8FD8\u6CA1\u6709\u767B\u5F55\u8EAB\u4EFD\uFF0C\u79DF\u6237 ${choice.env.tenant} \u53D6\u81EA\u672C\u5730\u58F0\u660E\uFF0C\u672A\u4E0E\u670D\u52A1\u7AEF\u6838\u5BF9` };
10174
+ } else {
10175
+ const actual = await deps.tokenTenant(choice.name, choice.env.tenant).catch(() => void 0);
10176
+ if (actual === void 0) {
10177
+ tenantCheck = { status: "unreachable", detail: `\u6CA1\u80FD\u4ECE\u670D\u52A1\u7AEF\u8BFB\u5230\u8EAB\u4EFD\u5F52\u5C5E\uFF0C\u79DF\u6237 ${choice.env.tenant} \u53D6\u81EA\u672C\u5730\u58F0\u660E\uFF0C\u672A\u6838\u5BF9` };
10178
+ } else if (actual === choice.env.tenant) {
10179
+ tenantCheck = { status: "verified", detail: `\u670D\u52A1\u7AEF\u786E\u8BA4\u8EAB\u4EFD\u5C5E\u4E8E\u79DF\u6237 ${actual}` };
10180
+ } else {
10181
+ tenantCheck = {
10182
+ status: "mismatch",
10183
+ detail: `${ENV_FILE} \u5199\u7684\u662F\u79DF\u6237 ${choice.env.tenant}\uFF0C\u800C ${choice.identity} \u5B9E\u9645\u5C5E\u4E8E\u79DF\u6237 ${actual}`,
10184
+ nextStep: `\u4ED3\u5EFA\u597D\u4E86\uFF0C\u4F46\u8FD9\u4E24\u4E2A\u6570\u5B57\u5FC5\u987B\u5BF9\u4E0A\uFF0C\u5426\u5219\u540E\u9762\u6BCF\u6761\u547D\u4EE4\u90FD\u8FDE\u4E0D\u4E0A\u3002\u4E8C\u9009\u4E00\uFF1A
10185
+ \u6309\u670D\u52A1\u7AEF\u6539\u58F0\u660E\uFF1Ahcm chiron env edit ${choice.name} tenant ${actual}\uFF08\u5E76\u540C\u6B65\u672C\u673A\u69FD hcm env edit tenant ${actual} --env ${choice.name}\uFF09
10186
+ \u6309\u58F0\u660E\u6362\u8EAB\u4EFD\uFF1Ahcm login --env ${choice.name}`
10187
+ };
10188
+ }
10189
+ }
10190
+ if (tenantCheck.status === "mismatch") {
10191
+ say(`\u274C ${tenantCheck.detail}`);
10192
+ say(tenantCheck.nextStep);
10193
+ } else if (tenantCheck.status !== "verified") say(`\u26A0\uFE0F \u79DF\u6237\u672A\u6838\u5BF9\uFF1A${tenantCheck.detail}`);
10194
+ }
10198
10195
  let skills2 = "skipped";
10199
- if (!args.skipSkills) {
10200
- say("\u88C5\u777F\u620E\u6280\u80FD\uFF08\u5168\u90E8\uFF0CCodex \u5E03\u5C40\uFF09\u2026");
10201
- await deps.installSkills(root, name);
10196
+ if (args.withSkills) {
10197
+ say("\u987A\u624B\u88C5\u4E00\u904D\u777F\u620E\u6280\u80FD\uFF08Codex \u5E03\u5C40\uFF09\u2026");
10198
+ await deps.installSkills(root, choice.name);
10202
10199
  skills2 = "installed";
10203
10200
  }
10204
10201
  return {
10205
10202
  project: root,
10206
- env: name,
10207
- endpoint: env2.endpoint,
10208
- frontend: env2.frontend,
10209
- tenant: env2.tenant,
10210
- identity: identity2,
10203
+ env: choice.name,
10204
+ endpoint: choice.env.endpoint,
10205
+ frontend: choice.env.frontend,
10206
+ tenant: choice.env.tenant,
10207
+ identity: choice.identity,
10208
+ envSource: choice.source,
10211
10209
  scaffold,
10212
10210
  skills: skills2,
10213
- nextStep: "hcm chiron doctor \u6838\u5BF9\u4E00\u904D\uFF0C\u7136\u540E\u5728\u8FD9\u4E2A\u76EE\u5F55\u91CC\u542F\u52A8 codex"
10211
+ tenantCheck,
10212
+ nextStep: skills2 === "installed" ? "hcm chiron doctor \u6838\u5BF9\u4E00\u904D\uFF0C\u7136\u540E\u5728\u8FD9\u4E2A\u76EE\u5F55\u91CC\u542F\u52A8 codex" : "hcm skills sync \u88C5\u6280\u80FD\uFF0C\u518D hcm chiron doctor \u6838\u5BF9\u4E00\u904D"
10214
10213
  };
10215
10214
  }
10216
10215
  async function chironInitCommand(args, deps) {
@@ -10220,16 +10219,18 @@ async function chironInitCommand(args, deps) {
10220
10219
  if (fmt === "json" || fmt === "yaml") {
10221
10220
  process.stdout.write(formatObject22(result, { format: fmt }) + "\n");
10222
10221
  } else {
10222
+ const mark = { verified: "\u2705", mismatch: "\u274C", unreachable: "\u26A0\uFE0F", skipped: "\xB7" }[result.tenantCheck.status];
10223
10223
  process.stdout.write(
10224
10224
  [
10225
10225
  `\u2705 \u9879\u76EE\u5DF2\u521D\u59CB\u5316\uFF1A${result.project}`,
10226
- ` \u73AF\u5883 ${result.env} \xB7 ${result.endpoint} \xB7 \u79DF\u6237 ${result.tenant} \xB7 \u8EAB\u4EFD ${result.identity}`,
10227
- ` \u6280\u80FD ${result.skills === "installed" ? `\u5DF2\u88C5\u5230 ${SKILLS_DIR}/` : "\u672A\u88C5\uFF08--skip-skills\uFF09"}`,
10226
+ ` \u73AF\u5883 ${result.env} \xB7 ${result.endpoint} \xB7 \u79DF\u6237 ${result.tenant} \xB7 \u8EAB\u4EFD ${result.identity ?? "\uFF08\u672C\u673A\u672A\u767B\u5F55\uFF09"}\uFF08\u6765\u81EA ${result.envSource}\uFF09`,
10227
+ ` ${mark} \u79DF\u6237 ${result.tenantCheck.detail ?? result.tenantCheck.status}`,
10228
+ ` \u6280\u80FD ${result.skills === "installed" ? `\u5DF2\u88C5\u5230 ${SKILLS_DIR}/` : "\u672A\u88C5\uFF08hcm skills sync \u88C5\uFF09"}`,
10228
10229
  ` \u4E0B\u4E00\u6B65\uFF1A${result.nextStep}`
10229
10230
  ].join("\n") + "\n"
10230
10231
  );
10231
10232
  }
10232
- process.exitCode = 0;
10233
+ process.exitCode = result.tenantCheck.status === "mismatch" ? 1 : 0;
10233
10234
  } catch (e) {
10234
10235
  exitWithError(e);
10235
10236
  }
@@ -10241,8 +10242,8 @@ import {
10241
10242
  createHttpClient as createHttpClient4,
10242
10243
  formatObject as formatObject23,
10243
10244
  loadGlobalConfig as loadGlobalConfig10,
10244
- resolveEnvContext as resolveEnvContext8,
10245
- printResolvedEnvironment as printResolvedEnvironment8
10245
+ resolveEnvContext as resolveEnvContext7,
10246
+ printResolvedEnvironment as printResolvedEnvironment7
10246
10247
  } from "@hcmai/sdk";
10247
10248
  init_exit();
10248
10249
  import { createJiraClient } from "@hcmai/sdk";
@@ -10500,7 +10501,7 @@ ${cs.map((c) => c.body ?? "").join("\n")}`).map((l) => ({
10500
10501
  }));
10501
10502
  for (const p of links) lines.push(`\u5DF2\u767B\u8BB0\u4EE3\u7801\u5E93\u6761\u76EE ${p.repo}#${p.number}`, ` ${p.url}`);
10502
10503
  let nextStep;
10503
- if (resolution) nextStep = "Jira \u8FD9\u5355\u5DF2\u89E3\u51B3\u3002\u76EE\u6807\u73AF\u5883\u90E8\u7F72\u5230\u542B\u4FEE\u590D\u7684\u7248\u672C\u540E\uFF08`hcm version` \u7684 commit \u4F1A\u53D8\uFF09\uFF0C\u8DD1 `hcm skills update`\uFF0C\u518D\u6309\u6280\u80FD\u590D\u9A8C\u4E00\u6B21\u3002";
10504
+ if (resolution) nextStep = "Jira \u8FD9\u5355\u5DF2\u89E3\u51B3\u3002\u76EE\u6807\u73AF\u5883\u90E8\u7F72\u5230\u542B\u4FEE\u590D\u7684\u7248\u672C\u540E\uFF08`hcm version` \u7684 commit \u4F1A\u53D8\uFF09\uFF0C\u8DD1 `hcm skills sync`\uFF0C\u518D\u6309\u6280\u80FD\u590D\u9A8C\u4E00\u6B21\u3002";
10504
10505
  else if (status === "\u8865\u5145\u8BF4\u660E") {
10505
10506
  nextStep = `\u{1F534} **\u7403\u5728\u4F60\u8FD9\u8FB9**\uFF1A\u4EA7\u54C1\u4FA7\u770B\u4E86\uFF0C\u4F46\u4FE1\u606F\u4E0D\u591F\uFF0C\u628A\u5355\u6253\u56DE\u6765\u8BA9\u4F60\u8865\u5145\u3002\u7167\u6700\u65B0\u90A3\u6761\u8BC4\u8BBA\u8BF4\u7684\u8865\u2014\u2014\u590D\u73B0\u547D\u4EE4\u3001\u539F\u59CB\u8F93\u51FA\u3001\u73AF\u5883\u6307\u7EB9\u7F3A\u54EA\u6837\u8865\u54EA\u6837\uFF0C\u7528 \`hcm chiron gap submit\` \u8FFD\u52A0\u4E00\u6761\u73B0\u573A\uFF0C\u6216\u76F4\u63A5\u5728 Jira \u90A3\u5355\u4E0B\u56DE\u590D\u3002\u8865\u5B8C\u8BA9\u5206\u8BCA\u4EBA\u63A8\u300C\u91CD\u65B0\u63D0\u4EA4\u300D\u3002**\u4E0D\u8865\u7684\u8BDD\u8FD9\u5355\u4E0D\u4F1A\u81EA\u5DF1\u5F80\u524D\u8D70\u3002**`;
10506
10507
  } else if (status === "\u4E0D\u5904\u7406" || status === "\u91CD\u590D\u95EE\u9898") {
@@ -10555,8 +10556,8 @@ async function gapStatusCommand(ref, args, deps = defaultDeps) {
10555
10556
  async function fingerprintText(env2) {
10556
10557
  try {
10557
10558
  const g = await loadGlobalConfig10();
10558
- const resolved = await resolveEnvContext8({ envFlag: env2 }, process.env, g);
10559
- printResolvedEnvironment8(resolved);
10559
+ const resolved = await resolveEnvContext7({ envFlag: env2 }, process.env, g);
10560
+ printResolvedEnvironment7(resolved);
10560
10561
  const { name, config: cfg } = resolved;
10561
10562
  if (!cfg?.endpoint) return `\u672A\u53D6\u5230\u6307\u7EB9\uFF08env=${name}\uFF1A\u6CA1\u6709 endpoint\uFF09`;
10562
10563
  const http = createHttpClient4({ endpoint: cfg.endpoint.replace(/\/+$/, ""), getAccessToken: async () => null, onRefresh: async () => {
@@ -10652,7 +10653,7 @@ async function runChironDoctor(args, deps = defaultDeps2) {
10652
10653
  const isDefault = name === file.default;
10653
10654
  const severity = () => isDefault ? "fail" : "warn";
10654
10655
  const label = `${name}${isDefault ? "\uFF08default\uFF09" : ""}${env3.danger ? " \xB7 danger" : ""}`;
10655
- const found = await findEnvByEndpoint2(env3.endpoint, env3.tenant);
10656
+ const found = await findEnvByEndpoint3(env3.endpoint, env3.tenant);
10656
10657
  const loginCmd = names.length > 1 ? `hcm login --env ${name} --code <\u914D\u5BF9\u7801>\uFF08\u914D\u5BF9\u7801\u5728 ${env3.frontend || env3.endpoint} \u7684\u7528\u6237\u83DC\u5355 \u2192\u300C\u547D\u4EE4\u884C\u5DE5\u5177\u300D\u751F\u6210\uFF09` : `hcm login ${env3.endpoint} --code <\u914D\u5BF9\u7801>`;
10657
10658
  if (!found) {
10658
10659
  report.lines.push({ item: "\u767B\u5F55", verdict: severity(), detail: `${label} \xB7 \u672C\u673A\u6CA1\u6709\u767B\u5F55\u8FC7 ${env3.endpoint}`, nextStep: loginCmd });
@@ -10692,7 +10693,7 @@ async function runChironDoctor(args, deps = defaultDeps2) {
10692
10693
  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" };
10693
10694
  }
10694
10695
  if (state.target !== "codex") {
10695
- 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" };
10696
+ 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 sync --target codex" };
10696
10697
  }
10697
10698
  return { item: "\u6280\u80FD", verdict: "ok", detail: `${count} \u4E2A\uFF0C\u6765\u81EA ${state.endpoint ?? "\u672C\u5730"}${state.all ? "\uFF0C\u8DDF\u968F\u5168\u96C6" : ""}` };
10698
10699
  };
@@ -10753,9 +10754,9 @@ import {
10753
10754
  AUTH_INFO_PATH as AUTH_INFO_PATH2,
10754
10755
  CliError as CliError26,
10755
10756
  CliErrorCode as CliErrorCode24,
10756
- discoverProjectEnv as discoverProjectEnv4,
10757
+ discoverProjectEnv as discoverProjectEnv5,
10757
10758
  ENV_FILE as ENV_FILE2,
10758
- findEnvByEndpoint as findEnvByEndpoint3,
10759
+ findEnvByEndpoint as findEnvByEndpoint5,
10759
10760
  formatObject as formatObject25,
10760
10761
  listIdentities as listIdentities6,
10761
10762
  parseEnvYaml as parseEnvYaml2,
@@ -10764,6 +10765,16 @@ import {
10764
10765
  toPrincipal as toPrincipal2,
10765
10766
  validateCliAuthorizationUrl as validateCliAuthorizationUrl2
10766
10767
  } from "@hcmai/sdk";
10768
+ function summarizeIdentities(identities) {
10769
+ if (identities.length === 0) return "\u65E0\u5DF2\u767B\u8BB0\u8EAB\u4EFD";
10770
+ const head = identities[0];
10771
+ const rest = identities.length - 1;
10772
+ return `${head.name}\uFF08${head.status}\uFF09${rest > 0 ? ` \u7B49 ${identities.length} \u4E2A\uFF08--output json \u770B\u5168\u90E8\uFF09` : ""}`;
10773
+ }
10774
+ function summarizeReasons(reasons) {
10775
+ if (reasons.length === 0) return "\u672C\u673A\u69FD\u6CA1\u6709\u5DF2\u767B\u8BB0\u8EAB\u4EFD";
10776
+ return reasons.length === 1 ? reasons[0] : `${reasons[0]} \u7B49 ${reasons.length} \u6761\uFF08--output json \u770B\u5168\u90E8\uFF09`;
10777
+ }
10767
10778
  function invalid2(message, nextStep) {
10768
10779
  throw new CliError26({ code: CliErrorCode24.INVALID_ARGUMENT, message, context: { nextStep } });
10769
10780
  }
@@ -10811,7 +10822,7 @@ async function inspectEnvironment(env2) {
10811
10822
  }
10812
10823
  const reachability = { status: "reachable" };
10813
10824
  try {
10814
- const slot = await findEnvByEndpoint3(env2.endpoint, env2.tenant);
10825
+ const slot = await findEnvByEndpoint5(env2.endpoint, env2.tenant);
10815
10826
  if (!slot) return { reachability, tenant: { status: "unverified", reason: "\u6CA1\u6709\u5339\u914D\u5730\u5740\u7684\u672C\u673A\u69FD" } };
10816
10827
  const names = await listIdentities6(slot.name);
10817
10828
  const reasons = [];
@@ -10835,7 +10846,10 @@ async function inspectEnvironment(env2) {
10835
10846
  return { reachability, tenant: {
10836
10847
  status: "unverified",
10837
10848
  slot: slot.name,
10838
- reason: reasons.join("\uFF1B") || "\u672C\u673A\u69FD\u6CA1\u6709\u5DF2\u767B\u8BB0\u8EAB\u4EFD"
10849
+ // 🔴 一个槽下几十个身份是常态(实测 consultant-slot4 有 25 个)。把每条理由原样拼起来,
10850
+ // 那一行会有几千字符、把表格整个撑塌,而且同一句话重复 25 遍——**读不到任何信息**。
10851
+ // 这里只留头一条 + 计数;要全量走 --output json。
10852
+ reason: summarizeReasons(reasons)
10839
10853
  } };
10840
10854
  } catch {
10841
10855
  return { reachability, tenant: { status: "unverified", reason: "\u65E0\u6CD5\u8BFB\u53D6\u672C\u673A\u69FD\u6216\u8EAB\u4EFD\u914D\u7F6E\uFF0C\u8BF7\u7528 hcm env list / hcm identity list \u6838\u5BF9" } };
@@ -10846,7 +10860,7 @@ async function rows(config2, warnings, verify = false) {
10846
10860
  let slot = null;
10847
10861
  const identities = [];
10848
10862
  try {
10849
- slot = (await findEnvByEndpoint3(env2.endpoint, env2.tenant, { strictTenant: true }))?.name ?? null;
10863
+ slot = (await findEnvByEndpoint5(env2.endpoint, env2.tenant, { strictTenant: true }))?.name ?? null;
10850
10864
  if (slot) for (const identity2 of await listIdentities6(slot)) {
10851
10865
  try {
10852
10866
  const token = await TokenStore5.forIdentity(identity2).getStoredAccessToken();
@@ -10881,7 +10895,7 @@ async function runChironEnv(action, args = {}) {
10881
10895
  invalid2(`\u672A\u77E5\u8F93\u51FA\u683C\u5F0F '${args.output}'\uFF0C\u914D\u7F6E\u672A\u5199\u5165\u3002`, "\u4F7F\u7528 --output table\u3001json \u6216 yaml");
10882
10896
  }
10883
10897
  const root = path11.resolve(args.project ?? ".");
10884
- const discovered = await discoverProjectEnv4(root);
10898
+ const discovered = await discoverProjectEnv5(root);
10885
10899
  const file = discovered?.path ?? path11.join(root, ENV_FILE2);
10886
10900
  if (!discovered && action !== "add") invalid2(`\u6CA1\u6709\u627E\u5230 ${file}\u3002`, "\u8FDB\u5165\u987E\u95EE\u9879\u76EE\uFF0C\u6216\u8FD0\u884C hcm chiron env add <\u540D\u5B57> --endpoint <URL> --frontend <URL> --tenant <\u79DF\u6237>");
10887
10901
  const original = discovered ? await fs11.readFile(file, "utf8") : null;
@@ -10955,7 +10969,7 @@ function formatChironEnvReport(report, output = "table") {
10955
10969
  tenant: env2.tenant,
10956
10970
  danger: String(env2.danger),
10957
10971
  slot: env2.slot ?? "\u65E0\u5339\u914D\u69FD",
10958
- identities: env2.identities.map((id) => `${id.name}\uFF08${id.reason}\uFF09`).join("\uFF1B") || "\u65E0\u5DF2\u767B\u8BB0\u8EAB\u4EFD"
10972
+ identities: summarizeIdentities(env2.identities)
10959
10973
  })))
10960
10974
  ];
10961
10975
  if (report.validation?.reachability.status === "reachable") lines.push("\u540E\u7AEF\u5730\u5740\u5DF2\u63A2\u901A\uFF08GET /api/version/backend\uFF09\u3002");
@@ -10972,17 +10986,252 @@ async function chironEnvCommand(action, args) {
10972
10986
  }
10973
10987
  }
10974
10988
 
10975
- // src/commands/chiron-test.ts
10989
+ // src/commands/chiron-page.ts
10990
+ init_auth_guard();
10976
10991
  init_exit();
10977
10992
  import { spawnSync } from "child_process";
10978
- import { promises as fs12 } from "fs";
10993
+ import { accessSync, constants } from "fs";
10994
+ import fs12 from "fs/promises";
10979
10995
  import path12 from "path";
10996
+ import { CliError as CliError27, CliErrorCode as CliErrorCode25, formatObject as formatObject26, HcmClient as HcmClient22, loadEnv as loadEnv6 } from "@hcmai/sdk";
10997
+ var EVIDENCE_DIR = "evidence";
10998
+ var WAIT_MS_MAX = 6e4;
10999
+ var VIEWPORT_MIN = { width: 320, height: 240 };
11000
+ var VIEWPORT_MAX = { width: 7680, height: 7680 };
11001
+ function judgePageContent(input) {
11002
+ const missing = input.expect.filter((t) => !input.dom.includes(t));
11003
+ const forbidden2 = input.reject.filter((t) => input.dom.includes(t));
11004
+ return { ok: missing.length === 0 && forbidden2.length === 0, missing, forbidden: forbidden2 };
11005
+ }
11006
+ function parseViewport(size) {
11007
+ const m = /^(\d+)x(\d+)$/.exec(size.trim());
11008
+ if (!m) {
11009
+ throw new CliError27({ code: CliErrorCode25.INVALID_ARGUMENT, message: `--size \u8981\u5199\u6210 <\u5BBD>x<\u9AD8>\uFF0C\u4F8B\u5982 1440x900\uFF0C\u6536\u5230\u7684\u662F ${size}` });
11010
+ }
11011
+ const width = Number(m[1]);
11012
+ const height = Number(m[2]);
11013
+ if (width < VIEWPORT_MIN.width || width > VIEWPORT_MAX.width || height < VIEWPORT_MIN.height || height > VIEWPORT_MAX.height) {
11014
+ throw new CliError27({
11015
+ code: CliErrorCode25.INVALID_ARGUMENT,
11016
+ message: `--size \u8D85\u51FA\u8303\u56F4\uFF1A\u5BBD ${VIEWPORT_MIN.width}..${VIEWPORT_MAX.width}\u3001\u9AD8 ${VIEWPORT_MIN.height}..${VIEWPORT_MAX.height}\uFF0C\u6536\u5230\u7684\u662F ${size}`
11017
+ });
11018
+ }
11019
+ return { width, height };
11020
+ }
11021
+ function parseWaitMs(raw) {
11022
+ if (raw === void 0) return 1e4;
11023
+ const value = typeof raw === "number" ? raw : Number(raw);
11024
+ if (!Number.isInteger(value) || value < 0 || value > WAIT_MS_MAX) {
11025
+ throw new CliError27({ code: CliErrorCode25.INVALID_ARGUMENT, message: `--wait-ms \u8981\u662F 0..${WAIT_MS_MAX} \u7684\u6574\u6570\uFF0C\u6536\u5230\u7684\u662F ${raw}` });
11026
+ }
11027
+ return value;
11028
+ }
11029
+ function resolveEvidenceTarget(projectRoot, out) {
11030
+ if (!out?.trim()) {
11031
+ throw new CliError27({ code: CliErrorCode25.MISSING_FLAG, message: `\u8981\u4F20 --out <${EVIDENCE_DIR}/\u2026/\u622A\u56FE.png>\uFF1A\u622A\u56FE\u843D\u5728\u54EA\u513F\u5FC5\u987B\u662F\u4F60\u5B9A\u7684\uFF0C\u4E0D\u7531\u547D\u4EE4\u731C` });
11032
+ }
11033
+ if (!out.endsWith(".png")) {
11034
+ throw new CliError27({ code: CliErrorCode25.INVALID_ARGUMENT, message: `--out \u8981\u4EE5 .png \u7ED3\u5C3E\uFF0C\u6536\u5230\u7684\u662F ${out}` });
11035
+ }
11036
+ const root = path12.resolve(projectRoot);
11037
+ const evidenceRoot = path12.join(root, EVIDENCE_DIR);
11038
+ const absolute = path12.resolve(root, out);
11039
+ if (absolute !== evidenceRoot && !absolute.startsWith(evidenceRoot + path12.sep)) {
11040
+ throw new CliError27({
11041
+ code: CliErrorCode25.INVALID_ARGUMENT,
11042
+ message: `--out \u8981\u843D\u5728\u9879\u76EE\u7684 ${EVIDENCE_DIR}/ \u4E0B\uFF08${evidenceRoot}\uFF09\uFF0C\u6536\u5230\u7684\u662F ${absolute}`
11043
+ });
11044
+ }
11045
+ return { evidenceRoot, absolute };
11046
+ }
11047
+ function chromeArgv(input) {
11048
+ const argv = [
11049
+ "--headless=new",
11050
+ "--disable-gpu",
11051
+ "--disable-dev-shm-usage",
11052
+ "--hide-scrollbars",
11053
+ "--no-first-run",
11054
+ "--no-default-browser-check",
11055
+ `--window-size=${input.viewport.width},${input.viewport.height}`,
11056
+ `--virtual-time-budget=${input.waitMs}`,
11057
+ `--screenshot=${input.screenshot}`,
11058
+ "--dump-dom"
11059
+ ];
11060
+ if (input.isRoot) argv.push("--no-sandbox");
11061
+ argv.push(input.url);
11062
+ return argv;
11063
+ }
11064
+ var CHROME_ON_PATH = ["google-chrome-stable", "google-chrome", "chromium", "chromium-browser"];
11065
+ var CHROME_APP_BUNDLES = [
11066
+ "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
11067
+ "/Applications/Chromium.app/Contents/MacOS/Chromium"
11068
+ ];
11069
+ function findChrome(probe, override) {
11070
+ if (override?.trim()) {
11071
+ const explicit = override.trim();
11072
+ if (probe.executable(explicit)) return explicit;
11073
+ return probe.which(explicit);
11074
+ }
11075
+ for (const candidate of CHROME_ON_PATH) {
11076
+ const found = probe.which(candidate);
11077
+ if (found) return found;
11078
+ }
11079
+ for (const bundle of CHROME_APP_BUNDLES) {
11080
+ if (probe.executable(bundle)) return bundle;
11081
+ }
11082
+ return null;
11083
+ }
11084
+ async function assertInsideEvidence(deps, evidenceRoot, absolute) {
11085
+ const canonicalRoot = await deps.realpath(evidenceRoot);
11086
+ const canonicalParent = await deps.realpath(path12.dirname(absolute));
11087
+ if (canonicalRoot === null || canonicalParent === null) return;
11088
+ if (canonicalParent !== canonicalRoot && !canonicalParent.startsWith(canonicalRoot + path12.sep)) {
11089
+ throw new CliError27({
11090
+ code: CliErrorCode25.INVALID_ARGUMENT,
11091
+ message: `--out \u7684\u7236\u76EE\u5F55\u7ECF\u7B26\u53F7\u94FE\u63A5\u8DD1\u51FA\u4E86 ${EVIDENCE_DIR}/\uFF1A${canonicalParent}`
11092
+ });
11093
+ }
11094
+ }
11095
+ async function runChironPage(target, args, deps) {
11096
+ const sitePath = normalizeTarget(target);
11097
+ const expect = (args.expectText ?? []).filter((t) => t.trim().length > 0);
11098
+ if (expect.length === 0) {
11099
+ throw new CliError27({
11100
+ code: CliErrorCode25.MISSING_FLAG,
11101
+ message: "\u81F3\u5C11\u8981\u4F20\u4E00\u6761 --expect-text\uFF08\u9875\u9762\u4E0A\u5FC5\u987B\u51FA\u73B0\u7684\u6587\u672C\uFF09\u3002\u53EA\u5224\u300C\u622A\u51FA\u56FE\u4E86\u300D\u4E0D\u7B97\u9A8C\u6536\uFF1A\u767B\u5F55\u9875\u3001\u62A5\u9519\u9875\u3001\u767D\u5C4F\u90FD\u80FD\u622A\u51FA\u56FE\u3002"
11102
+ });
11103
+ }
11104
+ const reject = (args.rejectText ?? []).filter((t) => t.trim().length > 0);
11105
+ const viewport = parseViewport(args.size ?? "1440x900");
11106
+ const waitMs = parseWaitMs(args.waitMs);
11107
+ const root = path12.resolve(args.project ?? ".");
11108
+ const { evidenceRoot, absolute } = resolveEvidenceTarget(root, args.out);
11109
+ if (await deps.present(absolute)) {
11110
+ throw new CliError27({
11111
+ code: CliErrorCode25.INVALID_ARGUMENT,
11112
+ message: `\u622A\u56FE\u5DF2\u5B58\u5728\uFF0C\u4E0D\u8986\u76D6\uFF1A${absolute}\u3002\u6362\u4E2A --out\uFF0C\u6216\u5148\u628A\u65E7\u8BC1\u636E\u632A\u8D70\u3002`
11113
+ });
11114
+ }
11115
+ await deps.ensureDir(path12.dirname(absolute));
11116
+ await assertInsideEvidence(deps, evidenceRoot, absolute);
11117
+ const browser = deps.findBrowser();
11118
+ if (!browser) {
11119
+ throw new CliError27({
11120
+ code: CliErrorCode25.INVALID_ARGUMENT,
11121
+ message: "\u672C\u673A\u627E\u4E0D\u5230 Chrome/Chromium\uFF0C\u622A\u4E0D\u4E86\u56FE\u3002",
11122
+ context: { nextStep: "\u88C5\u4E00\u4E2A Chrome\uFF0C\u6216\u7528 HCM_CHROME_BIN=/\u7EDD\u5BF9\u8DEF\u5F84 \u6307\u5230\u5DF2\u6709\u7684\u90A3\u4E2A" }
11123
+ });
11124
+ }
11125
+ const minted = await deps.mintUrl({ path: sitePath, args });
11126
+ const result = deps.capture({ browser, argv: chromeArgv({ viewport, waitMs, screenshot: absolute, url: minted.url, isRoot: process.getuid?.() === 0 }) });
11127
+ if (!result.ok) {
11128
+ throw new CliError27({
11129
+ code: CliErrorCode25.SERVER_ERROR,
11130
+ message: `\u6D4F\u89C8\u5668\u6CA1\u8DD1\u5B8C\uFF1A${result.stderr.trim().split("\n").slice(-1)[0] ?? "\u65E0\u8F93\u51FA"}`,
11131
+ context: { nextStep: `\u624B\u5DE5\u6838\u4E00\u773C\uFF1A${browser} --headless=new --screenshot \u8DD1\u5F97\u8D77\u6765\u5417` }
11132
+ });
11133
+ }
11134
+ const bytes = await deps.present(absolute) ? await deps.sizeOf(absolute) : 0;
11135
+ if (bytes === 0) {
11136
+ throw new CliError27({ code: CliErrorCode25.SERVER_ERROR, message: `\u6D4F\u89C8\u5668\u6CA1\u5199\u51FA\u975E\u7A7A PNG\uFF1A${absolute}` });
11137
+ }
11138
+ const verdict = judgePageContent({ dom: result.dom, expect, reject });
11139
+ return {
11140
+ ok: verdict.ok,
11141
+ path: sitePath,
11142
+ screenshot: absolute,
11143
+ bytes,
11144
+ environment: minted.environment,
11145
+ identity: minted.identity,
11146
+ viewport: `${viewport.width}x${viewport.height}`,
11147
+ waitMs,
11148
+ browser: deps.browserVersion(browser),
11149
+ expected: expect,
11150
+ rejected: reject,
11151
+ missing: verdict.missing,
11152
+ forbidden: verdict.forbidden
11153
+ };
11154
+ }
11155
+ function renderChironPage(receipt) {
11156
+ const out = [];
11157
+ out.push(`${receipt.ok ? "\u2705" : "\u274C"} ${receipt.path} \xB7 ${receipt.environment}${receipt.identity ? ` \xB7 ${receipt.identity}` : ""}`);
11158
+ out.push(` \u622A\u56FE ${receipt.screenshot}\uFF08${receipt.bytes} \u5B57\u8282\uFF0C${receipt.viewport}\uFF0C\u7B49 ${receipt.waitMs}ms\uFF09`);
11159
+ out.push(` \u6838\u8FC7 ${receipt.expected.map((t) => `\u300C${t}\u300D`).join("\u3001")}${receipt.rejected.length ? ` \xB7 \u4E0D\u8BB8\u51FA\u73B0 ${receipt.rejected.map((t) => `\u300C${t}\u300D`).join("\u3001")}` : ""}`);
11160
+ for (const t of receipt.missing) out.push(` \u274C \u9875\u9762\u4E0A\u6CA1\u6709\u300C${t}\u300D`);
11161
+ for (const t of receipt.forbidden) out.push(` \u274C \u9875\u9762\u4E0A\u51FA\u73B0\u4E86\u4E0D\u8BE5\u6709\u7684\u300C${t}\u300D`);
11162
+ if (!receipt.ok) out.push(" \u622A\u56FE\u4FDD\u7559\u7740\uFF0C\u6253\u5F00\u770B\u4E00\u773C\u662F\u767B\u5F55\u9875\u3001\u62A5\u9519\u9875\uFF0C\u8FD8\u662F\u9875\u9762\u771F\u7684\u5C11\u4E86\u4E1C\u897F\u3002");
11163
+ return out.join("\n");
11164
+ }
11165
+ function redactTicket(text) {
11166
+ return text.replace(/(ticket=)[^&\s"']+/g, "$1<redacted>");
11167
+ }
11168
+ var defaultChironPageDeps = {
11169
+ mintUrl: async ({ path: sitePath, args }) => {
11170
+ const ctx = await getActiveAuthContextFromCli(args);
11171
+ const envCfg = await loadEnv6(ctx.env);
11172
+ const frontend = ctx.frontend ?? envCfg.frontend;
11173
+ if (!frontend?.trim()) {
11174
+ throw new CliError27({
11175
+ code: CliErrorCode25.INVALID_ARGUMENT,
11176
+ message: `env '${ctx.env}' \u6CA1\u914D\u524D\u7AEF\u5730\u5740\uFF0C\u5F00\u4E0D\u4E86\u9875\u9762\u3002`,
11177
+ context: { nextStep: `hcm env edit frontend <\u524D\u7AEF\u5730\u5740> --env ${ctx.env}` }
11178
+ });
11179
+ }
11180
+ const client3 = HcmClient22.fromAuthContext(ctx);
11181
+ const { ticket } = await mintBrowserTicket(client3, ctx.env)();
11182
+ return { url: buildBrowserLoginUrl(frontend, ticket, sitePath), environment: ctx.env, identity: ctx.identity ?? null };
11183
+ },
11184
+ findBrowser: () => findChrome(
11185
+ {
11186
+ which: (cmd) => {
11187
+ const r = spawnSync("command", ["-v", cmd], { encoding: "utf8", shell: true });
11188
+ const line = (r.stdout ?? "").trim().split("\n")[0] ?? "";
11189
+ return r.status === 0 && line ? line : null;
11190
+ },
11191
+ executable: (file) => {
11192
+ try {
11193
+ accessSync(file, constants.X_OK);
11194
+ return true;
11195
+ } catch {
11196
+ return false;
11197
+ }
11198
+ }
11199
+ },
11200
+ process.env.HCM_CHROME_BIN
11201
+ ),
11202
+ capture: ({ browser, argv }) => {
11203
+ const r = spawnSync(browser, argv, { encoding: "utf8", maxBuffer: 1 << 26, timeout: 3e5 });
11204
+ return { ok: r.status === 0, dom: r.stdout ?? "", stderr: redactTicket(r.stderr ?? "") };
11205
+ },
11206
+ browserVersion: (browser) => (spawnSync(browser, ["--version"], { encoding: "utf8" }).stdout ?? "").trim().split("\n")[0] ?? "",
11207
+ ensureDir: (dir) => fs12.mkdir(dir, { recursive: true }).then(() => void 0),
11208
+ present: (file) => fs12.lstat(file).then(() => true).catch(() => false),
11209
+ sizeOf: (file) => fs12.stat(file).then((s) => s.size),
11210
+ realpath: (file) => fs12.realpath(file).catch(() => null)
11211
+ };
11212
+ async function chironPageCommand(target, args, deps = defaultChironPageDeps) {
11213
+ try {
11214
+ const receipt = await runChironPage(target, args, deps);
11215
+ const fmt = args.output ?? "table";
11216
+ if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject26(receipt, { format: fmt }) + "\n");
11217
+ else process.stdout.write(renderChironPage(receipt) + "\n");
11218
+ process.exitCode = receipt.ok ? 0 : 3;
11219
+ } catch (e) {
11220
+ exitWithError(e);
11221
+ }
11222
+ }
11223
+
11224
+ // src/commands/chiron-test.ts
11225
+ init_exit();
11226
+ import { spawnSync as spawnSync2 } from "child_process";
11227
+ import { promises as fs13 } from "fs";
11228
+ import path13 from "path";
10980
11229
  import yaml2 from "js-yaml";
10981
- import { formatObject as formatObject26 } from "@hcmai/sdk";
11230
+ import { formatObject as formatObject27 } from "@hcmai/sdk";
10982
11231
 
10983
11232
  // src/commands/delivery-action-policy.ts
10984
11233
  init_auth_guard();
10985
- import { HcmClient as HcmClient22, classifyEffect } from "@hcmai/sdk";
11234
+ import { HcmClient as HcmClient23, classifyEffect } from "@hcmai/sdk";
10986
11235
 
10987
11236
  // src/commands/delivery.ts
10988
11237
  import { createHash as createHash6 } from "crypto";
@@ -11492,7 +11741,7 @@ async function resolveCoreAction(request) {
11492
11741
  as: request.identity,
11493
11742
  profile: request.profile
11494
11743
  });
11495
- const description = await HcmClient22.fromAuthContext(auth).describe(request.model);
11744
+ const description = await HcmClient23.fromAuthContext(auth).describe(request.model);
11496
11745
  const named = description.actions.filter((action) => action.name === request.action);
11497
11746
  if (named.length === 0) {
11498
11747
  const degraded = description.effectiveActionsAvailable ? "" : `\u26A0\uFE0F \u672C\u6B21\u6BD4\u5BF9\u4E0D\u542B\u811A\u672C Action\u2014\u2014${description.effectiveActionsNote ?? "\u539F\u56E0\u672A\u77E5"}\u3002`;
@@ -11779,15 +12028,15 @@ function matches(actual, rule) {
11779
12028
  var defaultDeps3 = {
11780
12029
  assess: (argv) => assessEffectiveDeliveryCommand(argv),
11781
12030
  hcm: (argv, cwd) => {
11782
- const r = spawnSync("hcm", argv, { cwd, encoding: "utf8", maxBuffer: 1 << 26, timeout: 6e5 });
12031
+ const r = spawnSync2("hcm", argv, { cwd, encoding: "utf8", maxBuffer: 1 << 26, timeout: 6e5 });
11783
12032
  return { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
11784
12033
  },
11785
- pageAcceptance: (root, argv) => {
11786
- const r = spawnSync("./page-acceptance.sh", argv, { cwd: root, encoding: "utf8", maxBuffer: 1 << 24, timeout: 3e5 });
12034
+ page: (root, argv) => {
12035
+ const r = spawnSync2("hcm", ["chiron", "page", ...argv], { cwd: root, encoding: "utf8", maxBuffer: 1 << 24, timeout: 3e5 });
11787
12036
  return { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
11788
12037
  },
11789
12038
  readXlsx: (file) => xlsxRows(file),
11790
- readText: (file) => fs12.readFile(file, "utf8")
12039
+ readText: (file) => fs13.readFile(file, "utf8")
11791
12040
  };
11792
12041
  async function runCase(spec, root, opts = {}, deps = defaultDeps3) {
11793
12042
  const results = [];
@@ -11845,7 +12094,7 @@ async function runCase(spec, root, opts = {}, deps = defaultDeps3) {
11845
12094
  continue;
11846
12095
  }
11847
12096
  if (c.file) {
11848
- const file = path12.resolve(root, fill(c.file));
12097
+ const file = path13.resolve(root, fill(c.file));
11849
12098
  const want = c.expect ?? {};
11850
12099
  const bad = [];
11851
12100
  if (want.xlsx_header || want.xlsx_min_rows !== void 0) {
@@ -11861,14 +12110,14 @@ async function runCase(spec, root, opts = {}, deps = defaultDeps3) {
11861
12110
  results.push(bad.length ? { name: c.name, verdict: "fail", detail: bad.join("\uFF1B") } : { name: c.name, verdict: "pass", detail: "" });
11862
12111
  continue;
11863
12112
  }
11864
- const out = path12.join("evidence", "test", `${spec.name}-${c.name}`.replace(/[^\w一-龥-]+/g, "_") + ".png");
11865
- const argv = ["--path", fill(c.page), "--out", out];
12113
+ const out = path13.join("evidence", "test", `${spec.name}-${c.name}`.replace(/[^\w一-龥-]+/g, "_") + ".png");
12114
+ const argv = [fill(c.page), "--out", out, "--project", root];
11866
12115
  if (opts.env) argv.push("--env", opts.env);
11867
12116
  const as = c.as ?? opts.as;
11868
12117
  if (as) argv.push("--as", as);
11869
12118
  for (const t of c.expect_text ?? []) argv.push("--expect-text", t);
11870
12119
  for (const t of c.reject_text ?? []) argv.push("--reject-text", t);
11871
- const r = deps.pageAcceptance(root, argv);
12120
+ const r = deps.page(root, argv);
11872
12121
  results.push(r.status === 0 ? { name: c.name, verdict: "pass", detail: out } : { name: c.name, verdict: "fail", detail: (r.stderr || r.stdout).trim().split("\n").slice(-1)[0] ?? `\u9000\u51FA\u7801 ${r.status}` });
11873
12122
  } catch (e) {
11874
12123
  results.push({ name: c.name, verdict: "fail", detail: e.message });
@@ -11877,12 +12126,12 @@ async function runCase(spec, root, opts = {}, deps = defaultDeps3) {
11877
12126
  return results;
11878
12127
  }
11879
12128
  async function loadCases(target) {
11880
- const stat = await fs12.stat(target);
11881
- const files = stat.isDirectory() ? (await fs12.readdir(target)).filter((f) => /\.ya?ml$/.test(f)).sort().map((f) => path12.join(target, f)) : [target];
12129
+ const stat = await fs13.stat(target);
12130
+ const files = stat.isDirectory() ? (await fs13.readdir(target)).filter((f) => /\.ya?ml$/.test(f)).sort().map((f) => path13.join(target, f)) : [target];
11882
12131
  const out = [];
11883
12132
  for (const f of files) {
11884
- const spec = yaml2.load(await fs12.readFile(f, "utf8"));
11885
- assertUsableSpec(spec, path12.basename(f));
12133
+ const spec = yaml2.load(await fs13.readFile(f, "utf8"));
12134
+ assertUsableSpec(spec, path13.basename(f));
11886
12135
  out.push({ file: f, spec });
11887
12136
  }
11888
12137
  if (out.length === 0) throw new Error(`${target} \u4E0B\u6CA1\u6709\u7528\u4F8B\uFF08*.yml\uFF09`);
@@ -11890,19 +12139,19 @@ async function loadCases(target) {
11890
12139
  }
11891
12140
  async function chironTestCommand(target, args, deps) {
11892
12141
  try {
11893
- const root = path12.resolve(args.project ?? ".");
11894
- const where = path12.resolve(root, target ?? "tests");
12142
+ const root = path13.resolve(args.project ?? ".");
12143
+ const where = path13.resolve(root, target ?? "tests");
11895
12144
  const cases = await loadCases(where);
11896
12145
  const report = [];
11897
12146
  let failed2 = 0;
11898
12147
  for (const { file, spec } of cases) {
11899
12148
  const results = await runCase(spec, root, { env: args.env, as: args.as }, deps);
11900
12149
  failed2 += results.filter((r) => r.verdict === "fail").length;
11901
- report.push({ case: spec.name, file: path12.relative(root, file), results });
12150
+ report.push({ case: spec.name, file: path13.relative(root, file), results });
11902
12151
  }
11903
12152
  const fmt = args.output ?? "table";
11904
12153
  if (fmt === "json" || fmt === "yaml") {
11905
- process.stdout.write(formatObject26({ ok: failed2 === 0, failed: failed2, cases: report }, { format: fmt }) + "\n");
12154
+ process.stdout.write(formatObject27({ ok: failed2 === 0, failed: failed2, cases: report }, { format: fmt }) + "\n");
11906
12155
  } else {
11907
12156
  for (const c of report) {
11908
12157
  process.stdout.write(`
@@ -11931,11 +12180,11 @@ ${failed2} \u6761\u6CA1\u8FC7\u2014\u2014\u4E0A\u9762\u6BCF\u6761\u90FD\u5199\u4
11931
12180
  init_auth_guard();
11932
12181
  init_exit();
11933
12182
  import {
11934
- HcmClient as HcmClient23,
12183
+ HcmClient as HcmClient24,
11935
12184
  ReconLayout,
11936
12185
  ROUND_EXIT_CODES,
11937
12186
  computeReconSourceKey,
11938
- formatObject as formatObject27,
12187
+ formatObject as formatObject28,
11939
12188
  fromAxiosError as fromAxiosError21,
11940
12189
  httpProbe as httpProbe3,
11941
12190
  inspectRound,
@@ -11946,7 +12195,7 @@ var DEFAULT_CAPABILITIES = "default";
11946
12195
  async function deliveryReconCommand(args) {
11947
12196
  try {
11948
12197
  const ctx = await getActiveAuthContextFromCli(args);
11949
- const client3 = HcmClient23.fromAuthContext(ctx);
12198
+ const client3 = HcmClient24.fromAuthContext(ctx);
11950
12199
  const probe = httpProbe3(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES);
11951
12200
  const sourceKey = await computeReconSourceKey(probe);
11952
12201
  const layout = new ReconLayout(args.out ?? ".", ctx.tenantId, sourceKey);
@@ -11955,7 +12204,7 @@ async function deliveryReconCommand(args) {
11955
12204
  onlyModel: args.model ?? null,
11956
12205
  identity: ctx.tenantId ? { requestedTenantId: ctx.tenantId } : null
11957
12206
  });
11958
- process.stdout.write(formatObject27(summary, { format: args.output ?? "json" }) + "\n");
12207
+ process.stdout.write(formatObject28(summary, { format: args.output ?? "json" }) + "\n");
11959
12208
  } catch (e) {
11960
12209
  const err = e;
11961
12210
  if (err?.isAxiosError) exitWithError(fromAxiosError21(err, args.env));
@@ -11969,7 +12218,7 @@ async function deliveryReconRoundCommand(args) {
11969
12218
  const result = inspectRound(args.dir ?? ".");
11970
12219
  const fmt = args.output ?? "json";
11971
12220
  if (fmt !== "json") process.stdout.write(renderRound(result));
11972
- process.stdout.write(formatObject27(result, { format: fmt }) + "\n");
12221
+ process.stdout.write(formatObject28(result, { format: fmt }) + "\n");
11973
12222
  code = ROUND_EXIT_CODES[result.state];
11974
12223
  } catch (e) {
11975
12224
  exitWithError(e);
@@ -11989,7 +12238,7 @@ import {
11989
12238
  DRY_RUN_TAIL,
11990
12239
  DriftDetected,
11991
12240
  FORCE_STALE_FLAG,
11992
- HcmClient as HcmClient24,
12241
+ HcmClient as HcmClient25,
11993
12242
  fetchReconIdentity as fetchReconIdentity3,
11994
12243
  INIT_EXIT_CODES,
11995
12244
  JOURNAL_STOP_KINDS,
@@ -12039,7 +12288,7 @@ import {
12039
12288
  writeRisk
12040
12289
  } from "@hcmai/sdk";
12041
12290
  import { existsSync as existsSync3 } from "fs";
12042
- import * as path13 from "path";
12291
+ import * as path14 from "path";
12043
12292
  function premise(message, hint = "") {
12044
12293
  process.stderr.write(message + (hint ? `
12045
12294
  \u2192 ${hint}` : "") + "\n");
@@ -12066,13 +12315,13 @@ async function runSeedPlan(args, client3) {
12066
12315
  const reconDir = candidates[0].reconDir;
12067
12316
  if (candidates.length > 1) {
12068
12317
  process.stderr.write(
12069
- `\u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u6709 ${candidates.length} \u4EFD\u57FA\u7EBF\uFF0C\u672C\u8F6E\u8BFB\u7684\u662F \`${path13.basename(reconDir)}\`\uFF1A` + candidates.slice(1).map((c) => `\`${path13.basename(c.reconDir)}\``).join("\u3001") + " \u672A\u88AB\u8BFB\u53D6 \u2014\u2014 \u4E0D\u540C sourceKey \u7684\u4EA7\u7269**\u4E0D\u53EF\u4E92\u6362**\u3002\n"
12318
+ `\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"
12070
12319
  );
12071
12320
  }
12072
12321
  const round = inspectRound2(reconDir);
12073
12322
  process.stderr.write(roundWarning(round));
12074
12323
  const baseline = {
12075
- path: `${path13.basename(path13.dirname(reconDir))}/${path13.basename(reconDir)}`,
12324
+ path: `${path14.basename(path14.dirname(reconDir))}/${path14.basename(reconDir)}`,
12076
12325
  roundId: round.roundId ?? null
12077
12326
  };
12078
12327
  let exemptions = null;
@@ -12129,7 +12378,7 @@ async function authOrSignpost(args, cmd) {
12129
12378
  }
12130
12379
  async function deliverySeedPlanCommand(args) {
12131
12380
  const ctx = await authOrSignpost(args, "plan");
12132
- const client3 = HcmClient24.fromAuthContext(ctx);
12381
+ const client3 = HcmClient25.fromAuthContext(ctx);
12133
12382
  process.exitCode = await runSeedPlan(args, seedClient(client3, ctx));
12134
12383
  }
12135
12384
  function seedClient(client3, ctx) {
@@ -12303,7 +12552,7 @@ async function runSeedApply(args, client3) {
12303
12552
  }
12304
12553
  async function deliverySeedApplyCommand(args) {
12305
12554
  const ctx = await authOrSignpost(args, "apply");
12306
- const client3 = HcmClient24.fromAuthContext(ctx);
12555
+ const client3 = HcmClient25.fromAuthContext(ctx);
12307
12556
  process.exitCode = await runSeedApply(args, seedClient(client3, ctx));
12308
12557
  }
12309
12558
  async function runSeedVerify(args, client3) {
@@ -12327,14 +12576,14 @@ async function deliverySeedVerifyCommand(args) {
12327
12576
  return;
12328
12577
  }
12329
12578
  const ctx = await authOrSignpost(args, "verify");
12330
- const client3 = HcmClient24.fromAuthContext(ctx);
12579
+ const client3 = HcmClient25.fromAuthContext(ctx);
12331
12580
  process.exitCode = await runSeedVerify(args, await seedVerifyClient(client3, ctx));
12332
12581
  }
12333
12582
 
12334
12583
  // src/commands/delivery-seed-find.ts
12335
12584
  import { existsSync as existsSync4 } from "fs";
12336
12585
  import { readFileSync as readFileSync8 } from "fs";
12337
- import * as path14 from "path";
12586
+ import * as path15 from "path";
12338
12587
  import {
12339
12588
  INIT_EXIT_CODES as INIT_EXIT_CODES2,
12340
12589
  ValueHints,
@@ -12348,10 +12597,10 @@ import {
12348
12597
  valuesRoundCaveat
12349
12598
  } from "@hcmai/sdk";
12350
12599
  function provenance(chosenReconDir, others) {
12351
- let line = `> \u57FA\u7EBF\uFF1A\`${path14.basename(chosenReconDir)}\`
12600
+ let line = `> \u57FA\u7EBF\uFF1A\`${path15.basename(chosenReconDir)}\`
12352
12601
  `;
12353
12602
  if (others.length > 0) {
12354
- line += `> \u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u53E6\u6709 ${others.length} \u4EFD\u57FA\u7EBF\u672A\u88AB\u8BFB\u53D6\uFF1A` + others.map((o) => `\`${path14.basename(o)}\``).join("\u3001") + " \u2014\u2014 \u4E0D\u540C sourceKey \u7684\u4EA7\u7269**\u4E0D\u53EF\u4E92\u6362**\u3002\n";
12603
+ 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";
12355
12604
  }
12356
12605
  return `${line}
12357
12606
  `;
@@ -12442,7 +12691,7 @@ import {
12442
12691
  CHANGE_STATES,
12443
12692
  CHANGE_UNKNOWN,
12444
12693
  CODE_WORDS,
12445
- HcmClient as HcmClient25,
12694
+ HcmClient as HcmClient26,
12446
12695
  INIT_EXIT_CODES as INIT_EXIT_CODES3,
12447
12696
  META_WRITE_STEPS,
12448
12697
  META_VERIFY_STEPS,
@@ -12670,7 +12919,7 @@ function lowerCaseHeaders2(headers) {
12670
12919
  }
12671
12920
  async function deliveryMetaCommand(args) {
12672
12921
  const ctx = await getActiveAuthContextFromCli(args);
12673
- const client3 = HcmClient25.fromAuthContext(ctx);
12922
+ const client3 = HcmClient26.fromAuthContext(ctx);
12674
12923
  process.exitCode = await runDeliveryMeta(
12675
12924
  { ...args, tenant: args.tenant ?? String(ctx.tenantId ?? "") },
12676
12925
  metaClient(client3, ctx)
@@ -12682,13 +12931,13 @@ init_auth_guard();
12682
12931
  init_exit();
12683
12932
  import {
12684
12933
  computeReconSourceKey as computeReconSourceKey2,
12685
- HcmClient as HcmClient26,
12934
+ HcmClient as HcmClient27,
12686
12935
  httpProbe as httpProbe4,
12687
12936
  ReconLayout as ReconLayout2,
12688
12937
  runTriageRound
12689
12938
  } from "@hcmai/sdk";
12690
12939
  import { mkdirSync as mkdirSync2, readFileSync as readFileSync10, writeFileSync as writeFileSync3 } from "fs";
12691
- import * as path15 from "path";
12940
+ import * as path16 from "path";
12692
12941
  var DEFAULT_CAPABILITIES3 = "default";
12693
12942
  function premise4(message, hint) {
12694
12943
  process.stderr.write(`\u{1F534} \u524D\u63D0\u4E0D\u6210\u7ACB\uFF1A${message}
@@ -12724,8 +12973,8 @@ function renderProblems(rows2) {
12724
12973
  `;
12725
12974
  }
12726
12975
  function writeTriageArtifact(outDir, body) {
12727
- const out = path15.join(outDir, "work", "triage.md");
12728
- mkdirSync2(path15.dirname(out), { recursive: true });
12976
+ const out = path16.join(outDir, "work", "triage.md");
12977
+ mkdirSync2(path16.dirname(out), { recursive: true });
12729
12978
  writeFileSync3(out, body, "utf8");
12730
12979
  return out;
12731
12980
  }
@@ -12738,7 +12987,7 @@ async function runTriage(args) {
12738
12987
  return premise4(e instanceof Error ? e.message : String(e), REQUESTS_SHAPE);
12739
12988
  }
12740
12989
  const ctx = await getActiveAuthContextFromCli(args);
12741
- const client3 = HcmClient26.fromAuthContext(ctx);
12990
+ const client3 = HcmClient27.fromAuthContext(ctx);
12742
12991
  const probe = httpProbe4(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES3);
12743
12992
  const artifactsDir = args.recon ?? new ReconLayout2(args.out ?? ".", ctx.tenantId, await computeReconSourceKey2(probe)).dir;
12744
12993
  const result = await runTriageRound(probe, artifactsDir, entriesIn);
@@ -12767,25 +13016,25 @@ async function deliveryTriageCommand(args) {
12767
13016
  init_auth_guard();
12768
13017
  init_exit();
12769
13018
  import {
12770
- HcmClient as HcmClient27,
13019
+ HcmClient as HcmClient28,
12771
13020
  adminResetPassword,
12772
- formatObject as formatObject28,
13021
+ formatObject as formatObject29,
12773
13022
  fromAxiosError as fromAxiosError22,
12774
- CliError as CliError27,
12775
- CliErrorCode as CliErrorCode25
13023
+ CliError as CliError28,
13024
+ CliErrorCode as CliErrorCode26
12776
13025
  } from "@hcmai/sdk";
12777
13026
  function buildAdminResetPasswordRequest(args, password) {
12778
13027
  const hasId = Boolean(args.id);
12779
13028
  const hasUsername = Boolean(args.username);
12780
13029
  if (hasId === hasUsername) {
12781
- throw new CliError27({
12782
- code: CliErrorCode25.INVALID_ARGUMENT,
13030
+ throw new CliError28({
13031
+ code: CliErrorCode26.INVALID_ARGUMENT,
12783
13032
  message: "--id <uuid> \u4E0E --username <user> \u5FC5\u987B\u4E14\u53EA\u80FD\u63D0\u4F9B\u4E00\u4E2A"
12784
13033
  });
12785
13034
  }
12786
13035
  if (!password) {
12787
- throw new CliError27({
12788
- code: CliErrorCode25.INVALID_ARGUMENT,
13036
+ throw new CliError28({
13037
+ code: CliErrorCode26.INVALID_ARGUMENT,
12789
13038
  message: "\u65B0\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A"
12790
13039
  });
12791
13040
  }
@@ -12801,9 +13050,9 @@ async function userResetPasswordCommand(args) {
12801
13050
  try {
12802
13051
  const password = args.passwordStdin ? await readSecretFromStdin() : await promptPasswordTwice();
12803
13052
  const request = buildAdminResetPasswordRequest(args, password);
12804
- const client3 = HcmClient27.fromAuthContext(await getActiveAuthContextFromCli(args));
13053
+ const client3 = HcmClient28.fromAuthContext(await getActiveAuthContextFromCli(args));
12805
13054
  const result = await adminResetPassword(client3.raw(), request);
12806
- process.stdout.write(formatObject28(result, { format: args.output ?? "json" }) + "\n");
13055
+ process.stdout.write(formatObject29(result, { format: args.output ?? "json" }) + "\n");
12807
13056
  } catch (cause) {
12808
13057
  const err = cause;
12809
13058
  if (err?.isAxiosError) exitWithError(fromAxiosError22(err, args.env));
@@ -12814,8 +13063,8 @@ async function promptPasswordTwice() {
12814
13063
  const password = await promptSecret("\u65B0\u5BC6\u7801: ");
12815
13064
  const confirmation = await promptSecret("\u518D\u6B21\u8F93\u5165\u65B0\u5BC6\u7801: ");
12816
13065
  if (password !== confirmation) {
12817
- throw new CliError27({
12818
- code: CliErrorCode25.INVALID_ARGUMENT,
13066
+ throw new CliError28({
13067
+ code: CliErrorCode26.INVALID_ARGUMENT,
12819
13068
  message: "\u4E24\u6B21\u8F93\u5165\u7684\u65B0\u5BC6\u7801\u4E0D\u4E00\u81F4"
12820
13069
  });
12821
13070
  }
@@ -12826,19 +13075,19 @@ async function promptPasswordTwice() {
12826
13075
  init_exit();
12827
13076
  init_auth_guard();
12828
13077
  import {
12829
- HcmClient as HcmClient28,
12830
- formatObject as formatObject29,
13078
+ HcmClient as HcmClient29,
13079
+ formatObject as formatObject30,
12831
13080
  fromAxiosError as fromAxiosError23
12832
13081
  } from "@hcmai/sdk";
12833
13082
  async function modelsCommand(keyword, args) {
12834
13083
  try {
12835
- const client3 = HcmClient28.fromAuthContext(await getActiveAuthContextFromCli(args));
13084
+ const client3 = HcmClient29.fromAuthContext(await getActiveAuthContextFromCli(args));
12836
13085
  const all = await client3.listModels();
12837
13086
  const needle = keyword?.trim().toLowerCase();
12838
13087
  const rows2 = (needle ? all.filter((m) => JSON.stringify(m).toLowerCase().includes(needle)) : all).sort((a, b) => key(a).localeCompare(key(b)));
12839
13088
  const fmt = args.output ?? "table";
12840
13089
  if (fmt !== "table") {
12841
- process.stdout.write(formatObject29({ total: rows2.length, models: rows2 }, { format: fmt }) + "\n");
13090
+ process.stdout.write(formatObject30({ total: rows2.length, models: rows2 }, { format: fmt }) + "\n");
12842
13091
  process.exitCode = 0;
12843
13092
  return;
12844
13093
  }
@@ -12926,7 +13175,7 @@ config.command("delete <name>").description("[deprecated] \u7528 `hcm env remove
12926
13175
  config.command("set <key> <value>").description("\u8BBE\u7F6E\u5168\u5C40 defaults\uFF0C\u4F8B\u5982 `defaults.output json`").action((k, v) => configSet(k, v));
12927
13176
  config.command("get <key>").description("\u8BFB\u53D6\u5168\u5C40 defaults").action((k) => configGet(k));
12928
13177
  var env = program.command("env").description("\u7BA1\u7406 HCM \u73AF\u5883\uFF08\u591A\u540E\u7AEF\u8FDE\u63A5\u914D\u7F6E\uFF09");
12929
- env.command("list").description("\u5217\u51FA\u5168\u90E8 env").action(() => envList());
13178
+ env.command("list").description("\u5217\u51FA\u5168\u90E8 env").option("--all", "\u9879\u76EE\u76EE\u5F55\u91CC\u4E5F\u5217\u51FA\u4E0E\u672C\u9879\u76EE\u65E0\u5173\u7684\u672C\u673A\u69FD").action((opts) => envList(opts));
12930
13179
  env.command("current").description("\u663E\u793A\u5F53\u524D\u6FC0\u6D3B\u7684 env").action((opts) => envCurrent(opts));
12931
13180
  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));
12932
13181
  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));
@@ -12944,10 +13193,9 @@ user.command("reset-password").description("\u7531 admin.system \u5B89\u5168\u91
12944
13193
  var chiron = program.command("chiron").description(
12945
13194
  "\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"
12946
13195
  );
12947
- chiron.command("init").description(
12948
- "\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"
12949
- ).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));
13196
+ chiron.command("init").description("\u5EFA\u987E\u95EE\u9879\u76EE\u4ED3\uFF1A\u5199 env.yaml\u3001\u5EFA\u76EE\u5F55\u3001\u5199 AGENTS/CLAUDE \u8FB9\u754C\u5757\u3002\u7EAF\u672C\u5730\uFF0C\u65AD\u7F51\u4E5F\u80FD\u5EFA\uFF1B\u91CD\u8DD1\u5B89\u5168").option("--project <dir>", "\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--env <name>", "\u7ED1\u5230\u672C\u673A\u54EA\u4E2A\u73AF\u5883\uFF08\u6216\u5DF2\u6709 env.yaml \u91CC\u7684\u73AF\u5883\u540D\uFF09").option("--endpoint <url>", "\u5B8C\u5168\u663E\u5F0F\u5730\u58F0\u660E\u540E\u7AEF\u5730\u5740\uFF08\u4E0D\u9700\u8981\u5148\u767B\u5F55\uFF0C\u4E5F\u4E0D\u53D1\u4EFB\u4F55\u8BF7\u6C42\uFF09").option("--frontend <url>", "\u524D\u7AEF\u5730\u5740\uFF08\u914D\u5408 --endpoint\uFF1B\u9ED8\u8BA4\u4E0E\u540E\u7AEF\u540C\u5740\uFF09").option("--tenant <id>", "\u79DF\u6237\u53F7\uFF08\u914D\u5408 --endpoint\uFF1B\u9ED8\u8BA4 1\uFF09").option("--with-skills", "\u987A\u624B\u628A\u6280\u80FD\u4E5F\u88C5\u4E0A\uFF08\u9ED8\u8BA4\u4E0D\u88C5\uFF0C\u7528 hcm skills sync\uFF09").option("--yes", "\u975E\u4EA4\u4E92\u5730\u786E\u8BA4\u300C\u5C31\u7528\u672C\u673A\u5F53\u524D\u6D3B\u52A8\u73AF\u5883\u300D").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => chironInitCommand(opts));
12950
13197
  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));
13198
+ chiron.command("page").description("\u6253\u5F00\u9875\u9762\u622A\u56FE\u5E76\u5BF9\u7740\u9875\u9762\u5185\u5BB9\u5224\u4E00\u6B21\uFF1A\u81F3\u5C11\u8981\u7ED9\u4E00\u6761 --expect-text\uFF0C\u53EA\u622A\u56FE\u4E0D\u7B97\u9A8C\u6536").argument("<\u8DEF\u5F84>", "\u7AD9\u5185\u8DEF\u5F84\uFF0C\u5982 /dashboard/xxx").requiredOption("--out <file>", "\u622A\u56FE\u843D\u70B9\uFF0C\u5FC5\u987B\u5728\u9879\u76EE\u7684 evidence/ \u4E0B\u4E14\u4EE5 .png \u7ED3\u5C3E").option("--expect-text <text...>", "\u9875\u9762\u4E0A\u5FC5\u987B\u51FA\u73B0\u7684\u6587\u672C\uFF08\u81F3\u5C11\u4E00\u6761\uFF09").option("--reject-text <text...>", "\u9875\u9762\u4E0A\u4E0D\u5F97\u51FA\u73B0\u7684\u6587\u672C").option("--project <dir>", "\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--env <name>", "\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--wait-ms <ms>", "\u9875\u9762\u6E32\u67D3\u9884\u7B97\u6BEB\u79D2\u6570", "10000").option("--size <WxH>", "\u89C6\u53E3\u5C3A\u5BF8", "1440x900").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((target, opts) => chironPageCommand(target, opts));
12951
13199
  chiron.command("doctor").description(
12952
13200
  "\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 clone \u4E86\u6CA1 / Jira \u80FD\u4E0D\u80FD\u63D0\u5355"
12953
13201
  ).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));
@@ -13137,19 +13385,22 @@ skills.command("list [keyword]").description("\u5217\u51FA\u76EE\u6807\u73AF\u58
13137
13385
  ).option("--by-stage", "\u6309\u4EA4\u4ED8\u751F\u547D\u5468\u671F\u5206\u7EC4\u5C55\u793A\uFF08\u9ED8\u8BA4\u6309\u529F\u80FD\u5206\u7C7B\uFF09").option("--source <kind>", "\u8FD9\u4E00\u8D9F\u770B\u54EA\u4E9B\u6765\u6E90\uFF1Acli\uFF08\u53EA\u770B\u81EA\u5E26\uFF0C\u4E0D\u8FDE\u7F51\uFF09| chiron | all", "all").option("--endpoint <url>", "\u6280\u80FD\u5E93\u5730\u5740\uFF08\u9ED8\u8BA4\u53D6\u9879\u76EE\u73AF\u5883\u6216 activeEnv \u7684 endpoint\uFF09").option("--env <name>", "\u4ECE\u8BE5 env \u89E3\u6790 endpoint").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((kw, opts) => skillsListCommand(kw, opts));
13138
13386
  skills.command("manifest").description("\u6253\u5370\u672C CLI \u7684\u547D\u4EE4\u9762\u4E0E\u81EA\u5E26\u6280\u80FD\u6E05\u5355\uFF08\u4E0D\u8FDE\u7F51\uFF0C\u4F9B\u5B88\u536B\u4E0E\u5916\u90E8\u5DE5\u5177\u6BD4\u5BF9\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => skillsManifestCommand(program, opts));
13139
13387
  skills.command("show <id>").description("\u6253\u5370\u6280\u80FD\u539F\u6587\uFF08\u7BA1\u9053\u53CB\u597D\uFF09\uFF1B\u81EA\u5E26\u6280\u80FD\u76F4\u63A5\u8BFB\u672C\u5730\uFF0C\u4E0D\u8FDE\u7F51").option("--source <kind>", "\u8FD9\u4E00\u8D9F\u770B\u54EA\u4E9B\u6765\u6E90\uFF1Acli\uFF08\u53EA\u770B\u81EA\u5E26\uFF0C\u4E0D\u8FDE\u7F51\uFF09| chiron | all", "all").option("--endpoint <url>", "\u6280\u80FD\u5E93\u5730\u5740\uFF08\u9ED8\u8BA4\u53D6\u9879\u76EE\u73AF\u5883\u6216 activeEnv \u7684 endpoint\uFF09").option("--env <name>", "\u4ECE\u8BE5 env \u89E3\u6790 endpoint").action((id, opts) => skillsShowCommand(id, opts));
13140
- skills.command("install [id]").description("\u8FDE\u540C requires \u524D\u7F6E\u6280\u80FD\u4E0E\u53C2\u8003\u6587\u4EF6\u88C5\u5230 agent \u6280\u80FD\u76EE\u5F55\uFF1B--all \u88C5\u6574\u4E2A\u6280\u80FD\u5E93").option("--all", "\u88C5\u6574\u4E2A\u6280\u80FD\u5E93\uFF0C\u5E76\u8BB0\u4E3A\u300C\u8DDF\u968F\u5168\u96C6\u300D\uFF08\u5F80\u540E update \u4F1A\u81EA\u52A8\u8865\u4E0A\u4EA7\u54C1\u65B0\u589E\u7684\u6280\u80FD\uFF09").option(
13141
- "--target <agent>",
13142
- "\u88C5\u7ED9\u54EA\u4E2A agent\uFF1Aclaude\uFF08.claude/skills/\uFF09| codex\uFF08hcm-skills/ + Agent \u7D22\u5F15\uFF09| auto",
13143
- "auto"
13144
- ).option("--global", "\u88C5\u5230\u7528\u6237\u7EA7\u76EE\u5F55\u800C\u975E\u5F53\u524D\u9879\u76EE").option("--dir <path>", "\u88C5\u5230\u6307\u5B9A\u76EE\u5F55").option("--from <dir>", "\u4ECE\u672C\u5730\u76EE\u5F55\u88C5\uFF08\u73B0\u573A\u6539\u8FC7\u7684\u7248\u672C\uFF09\uFF0C\u4E0D\u8D70\u7F51\u7EDC").option("--source <kind>", "\u8FD9\u4E00\u8D9F\u770B\u54EA\u4E9B\u6765\u6E90\uFF1Acli\uFF08\u53EA\u770B\u81EA\u5E26\uFF0C\u4E0D\u8FDE\u7F51\uFF09| chiron | all", "all").option("--force", "\u8986\u76D6\u5DF2\u5B58\u5728\u7684\u540C\u540D\u6280\u80FD").option("--endpoint <url>", "\u6280\u80FD\u5E93\u5730\u5740\uFF08\u9ED8\u8BA4\u53D6\u9879\u76EE\u73AF\u5883\u6216 activeEnv \u7684 endpoint\uFF09").option("--env <name>", "\u4ECE\u8BE5 env \u89E3\u6790 endpoint").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((id, opts) => skillsInstallCommand(id, opts));
13145
- skills.command("update").description("\u628A\u88C5\u8FC7\u7684\u6280\u80FD\u5347\u5230\u76EE\u6807\u73AF\u5883\u8FD9\u4E00\u7248\uFF08\u4EA7\u54C1\u5347\u7EA7\u540E\u8DD1\u5B83\uFF09").option("--all", "\u8FDE\u4EA7\u54C1\u65B0\u589E\u7684\u6280\u80FD\u4E00\u8D77\u88C5\u4E0A\uFF0C\u5E76\u8BB0\u4E3A\u300C\u8DDF\u968F\u5168\u96C6\u300D").option("--check", "\u53EA\u770B\u4F1A\u53D8\u4EC0\u4E48\uFF0C\u4E0D\u5199\u76D8").option("--target <agent>", "claude | codex | auto\uFF08\u9ED8\u8BA4\u6309\u5DF2\u5B89\u88C5\u76EE\u5F55\u63A2\uFF09", "auto").option("--global", "\u5347\u7EA7\u7528\u6237\u7EA7\u76EE\u5F55\u91CC\u7684\u6280\u80FD").option("--dir <path>", "\u5347\u7EA7\u6307\u5B9A\u76EE\u5F55\u91CC\u7684\u6280\u80FD").option("--force", "\u8FDE\u672C\u5730\u6539\u8FC7\u7684\u6280\u80FD\u4E00\u8D77\u8986\u76D6\u6210\u4EA7\u54C1\u8FD9\u4E00\u7248").option("--source <kind>", "\u8FD9\u4E00\u8D9F\u770B\u54EA\u4E9B\u6765\u6E90\uFF1Acli\uFF08\u53EA\u770B\u81EA\u5E26\uFF0C\u4E0D\u8FDE\u7F51\uFF09| chiron | all", "all").option("--endpoint <url>", "\u6280\u80FD\u5E93\u5730\u5740\uFF08\u9ED8\u8BA4\u53D6\u5B89\u88C5\u65F6\u8BB0\u5F55\u7684\u5730\u5740\uFF09").option("--env <name>", "\u4ECE\u8BE5 env \u89E3\u6790 endpoint").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => skillsUpdateCommand(opts));
13388
+ skills.command("sync").description("\u8BA9\u8FD9\u4E2A\u4ED3\u7684\u6280\u80FD\u8DDF\u76EE\u6807\u73AF\u5883\u5BF9\u9F50\uFF1A\u7B2C\u4E00\u6B21\u5C31\u88C5\u9F50\uFF0C\u4E4B\u540E\u6309\u4EA7\u54C1\u5F53\u524D\u5168\u96C6\u5BF9\u8D26\u3002\u5E42\u7B49\uFF0C\u4EA7\u54C1\u5347\u7EA7\u540E\u8DD1\u5B83").option("--only <id...>", "\u53EA\u8981\u8FD9\u51E0\u4E2A\u6280\u80FD\uFF08\u8FDE\u540C requires \u524D\u7F6E\uFF09\uFF0C\u4E0D\u8BA2\u9605\u5168\u96C6\uFF1B\u8BAD\u7EC3\u573A blind \u6863\u7528").option("--check", "\u53EA\u770B\u4F1A\u53D8\u4EC0\u4E48\uFF0C\u4E0D\u5199\u76D8").option("--target <agent>", "claude\uFF08.claude/skills/\uFF09| codex\uFF08hcm-skills/ + Agent \u7D22\u5F15\uFF09| auto", "auto").option("--global", "\u540C\u6B65\u7528\u6237\u7EA7\u76EE\u5F55\u800C\u975E\u5F53\u524D\u9879\u76EE").option("--dir <path>", "\u540C\u6B65\u6307\u5B9A\u76EE\u5F55").option("--from <dir>", "\u4ECE\u672C\u5730\u76EE\u5F55\u53D6\uFF08\u73B0\u573A\u6539\u8FC7\u7684\u7248\u672C\uFF09\uFF0C\u4E0D\u8D70\u7F51\u7EDC").option("--force", "\u8FDE\u672C\u5730\u6539\u8FC7\u7684\u6280\u80FD\u4E00\u8D77\u8986\u76D6\u6210\u4EA7\u54C1\u8FD9\u4E00\u7248").option("--source <kind>", "\u8FD9\u4E00\u8D9F\u770B\u54EA\u4E9B\u6765\u6E90\uFF1Acli\uFF08\u53EA\u770B\u81EA\u5E26\uFF0C\u4E0D\u8FDE\u7F51\uFF09| chiron | all", "all").option("--endpoint <url>", "\u6280\u80FD\u5E93\u5730\u5740\uFF08\u9ED8\u8BA4\u53D6\u9879\u76EE\u73AF\u5883\u6216\u5B89\u88C5\u65F6\u8BB0\u5F55\u7684\u5730\u5740\uFF09").option("--env <name>", "\u4ECE\u8BE5 env \u89E3\u6790 endpoint").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => skillsSyncCommand(opts));
13389
+ skills.command("install [id]").description("[deprecated] \u7528 `hcm skills sync`\uFF08\u53EA\u8981\u67D0\u51E0\u4E2A\uFF1A--only <id>\uFF09").option("--all", "[deprecated] sync \u9ED8\u8BA4\u5C31\u662F\u5168\u96C6").option("--target <agent>", "claude | codex | auto", "auto").option("--global", "\u88C5\u5230\u7528\u6237\u7EA7\u76EE\u5F55\u800C\u975E\u5F53\u524D\u9879\u76EE").option("--dir <path>", "\u88C5\u5230\u6307\u5B9A\u76EE\u5F55").option("--from <dir>", "\u4ECE\u672C\u5730\u76EE\u5F55\u88C5\uFF08\u73B0\u573A\u6539\u8FC7\u7684\u7248\u672C\uFF09\uFF0C\u4E0D\u8D70\u7F51\u7EDC").option("--source <kind>", "\u8FD9\u4E00\u8D9F\u770B\u54EA\u4E9B\u6765\u6E90\uFF1Acli | chiron | all", "all").option("--force", "\u8986\u76D6\u5DF2\u5B58\u5728\u7684\u540C\u540D\u6280\u80FD").option("--endpoint <url>", "\u6280\u80FD\u5E93\u5730\u5740").option("--env <name>", "\u4ECE\u8BE5 env \u89E3\u6790 endpoint").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((id, opts) => {
13390
+ process.stderr.write("\u26A0\uFE0F `hcm skills install` \u5DF2\u6539\u540D\u4E3A `hcm skills sync`\uFF1B\u8FD9\u6B21\u7167\u65E7\u6267\u884C\uFF0C\u4E0B\u6B21\u8BF7\u7528\u65B0\u540D\u5B57\u3002\n");
13391
+ return skillsInstallCommand(id, opts);
13392
+ });
13393
+ skills.command("update").description("[deprecated] \u7528 `hcm skills sync`").option("--all", "[deprecated] sync \u9ED8\u8BA4\u5C31\u662F\u5168\u96C6").option("--check", "\u53EA\u770B\u4F1A\u53D8\u4EC0\u4E48\uFF0C\u4E0D\u5199\u76D8").option("--target <agent>", "claude | codex | auto\uFF08\u9ED8\u8BA4\u6309\u5DF2\u5B89\u88C5\u76EE\u5F55\u63A2\uFF09", "auto").option("--global", "\u5347\u7EA7\u7528\u6237\u7EA7\u76EE\u5F55\u91CC\u7684\u6280\u80FD").option("--dir <path>", "\u5347\u7EA7\u6307\u5B9A\u76EE\u5F55\u91CC\u7684\u6280\u80FD").option("--force", "\u8FDE\u672C\u5730\u6539\u8FC7\u7684\u6280\u80FD\u4E00\u8D77\u8986\u76D6\u6210\u4EA7\u54C1\u8FD9\u4E00\u7248").option("--source <kind>", "\u8FD9\u4E00\u8D9F\u770B\u54EA\u4E9B\u6765\u6E90\uFF1Acli | chiron | all", "all").option("--endpoint <url>", "\u6280\u80FD\u5E93\u5730\u5740\uFF08\u9ED8\u8BA4\u53D6\u5B89\u88C5\u65F6\u8BB0\u5F55\u7684\u5730\u5740\uFF09").option("--env <name>", "\u4ECE\u8BE5 env \u89E3\u6790 endpoint").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => {
13394
+ process.stderr.write("\u26A0\uFE0F `hcm skills update` \u5DF2\u6539\u540D\u4E3A `hcm skills sync`\uFF1B\u8FD9\u6B21\u7167\u65E7\u6267\u884C\uFF0C\u4E0B\u6B21\u8BF7\u7528\u65B0\u540D\u5B57\u3002\n");
13395
+ return skillsUpdateCommand(opts);
13396
+ });
13146
13397
  program.command("update <Model>").description("\u66F4\u65B0\u4E00\u6761 Model \u8BB0\u5F55\uFF08\u8D70\u540E\u7AEF\u5B8C\u6574\u6821\u9A8C\uFF09\u3002\u5347\u7EA7 CLI \u8BF7\u7528 `hcm upgrade`").requiredOption("--id <id>", "\u8BB0\u5F55 ID").option("--data <JSON>", `\u8981\u66F4\u65B0\u7684\u5B57\u6BB5 JSON\uFF0C\u4F8B\u5982 '{"name":"\u65B0\u540D\u79F0"}'`).option("--data-file <path>", "\u4ECE UTF-8 JSON \u6587\u4EF6\u8BFB\u53D6\u66F4\u65B0\u5B57\u6BB5\uFF08\u4E0E --data \u4E92\u65A5\uFF09").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").option(
13147
13398
  "--i18n",
13148
13399
  "\u591A\u8BED\u8A00\u5B57\u6BB5\u6309 Map \u5B8C\u6574\u66FF\u6362\uFF08\u952E\u7528 zh-CN / en-US \u8FDE\u5B57\u7B26\u5F62\uFF09\uFF1B\u4E0D\u4F20\u5219\u6309\u5B57\u7B26\u4E32\u53EA\u6539\u5F53\u524D\u8BED\u8A00"
13149
13400
  ).action((model, opts) => updateCommand(model, opts));
13150
13401
  program.command("version").description("\u67E5 CLI \u4E0E\u540E\u7AEF\u4E24\u4E2A\u7248\u672C\uFF08commit / tag / \u6784\u5EFA\u65F6\u95F4\uFF09\u2014\u2014\u514D\u8BA4\u8BC1\uFF0C\u65E0\u9700\u5148 login").option("--endpoint <url>", "\u540E\u7AEF\u5730\u5740\uFF08\u9ED8\u8BA4\u53D6\u9879\u76EE\u73AF\u5883\u6216 activeEnv \u7684 endpoint\uFF09").option("--env <name>", "\u4ECE\u8BE5 env \u89E3\u6790 endpoint").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => versionCommand(opts));
13151
13402
  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));
13152
- program.command("open [path]").description("\u7528\u5F53\u524D CLI \u8EAB\u4EFD\u6253\u5F00\u524D\u7AEF\u9875\u9762\uFF1A\u94F8\u4E00\u5F20 60s \u4E00\u6B21\u6027\u7968\u636E\u4EA4\u7ED9\u6D4F\u89C8\u5668\uFF0C\u4F1A\u8BDD token \u4E0D\u8FDB URL").option("--print-url", "\u53EA\u6253\u5370\u767B\u5F55 URL\uFF0C\u4E0D\u5F00\u6D4F\u89C8\u5668\uFF08\u7ED9 agent \u6D4F\u89C8\u5668 navigate \u7528\uFF09").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").action((path16, opts) => openCommand(path16, opts));
13403
+ program.command("open [path]").description("\u7528\u5F53\u524D CLI \u8EAB\u4EFD\u6253\u5F00\u524D\u7AEF\u9875\u9762\uFF1A\u94F8\u4E00\u5F20 60s \u4E00\u6B21\u6027\u7968\u636E\u4EA4\u7ED9\u6D4F\u89C8\u5668\uFF0C\u4F1A\u8BDD token \u4E0D\u8FDB URL").option("--print-url", "\u53EA\u6253\u5370\u767B\u5F55 URL\uFF0C\u4E0D\u5F00\u6D4F\u89C8\u5668\uFF08\u7ED9 agent \u6D4F\u89C8\u5668 navigate \u7528\uFF09").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").action((path17, opts) => openCommand(path17, opts));
13153
13404
  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");
13154
13405
  setting.command("get <domain>").description("\u8BFB\u67D0\u57DF\u53C2\u6570\uFF08\u5B9A\u4E49 + \u79DF\u6237\u8986\u76D6\u503C\u5408\u5E76\uFF0C\u7F3A\u5931\u56DE\u843D\u9ED8\u8BA4\u503C\uFF09").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((d, opts) => settingGetCommand(d, opts));
13155
13406
  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(