@hcmai/cli 0.15.13 → 0.16.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
@@ -783,8 +783,8 @@ var init_TerminalRenderer = __esm({
783
783
  }
784
784
  }
785
785
  /** 来源行(仅子代理触发,agentPath ≥2 段时显示 `↑ 来自 a › b`,对齐 Web)。 */
786
- originLine(path19) {
787
- const segs = path19.split(".").filter(Boolean);
786
+ originLine(path20) {
787
+ const segs = path20.split(".").filter(Boolean);
788
788
  if (segs.length < 2) return "";
789
789
  const names = segs.map((k) => agentDisplayName(k));
790
790
  return chalk.gray(` \u2191 \u6765\u81EA ${names.join(" \u203A ")}`) + "\n";
@@ -1973,8 +1973,8 @@ function agentLabel(agentId) {
1973
1973
  if (/^[0-9a-f]{8}-[0-9a-f-]{27}$/i.test(agentId)) return `agent \u2026${agentId.slice(-4)}`;
1974
1974
  return agentDisplayName(agentId);
1975
1975
  }
1976
- function originLine(path19) {
1977
- const segs = (path19 ?? "").split(".").filter(Boolean);
1976
+ function originLine(path20) {
1977
+ const segs = (path20 ?? "").split(".").filter(Boolean);
1978
1978
  if (segs.length < 2) return null;
1979
1979
  return `\u6765\u81EA ${segs.map((k) => agentDisplayName(k)).join(" \u203A ")}`;
1980
1980
  }
@@ -2225,7 +2225,7 @@ var init_readline = __esm({
2225
2225
 
2226
2226
  // src/index.ts
2227
2227
  import { Command } from "commander";
2228
- import { LEDGER_ONLY_FLAG, migrateLegacyProfiles } from "@hcmai/sdk";
2228
+ import { LEDGER_ONLY_FLAG as LEDGER_ONLY_FLAG2, migrateLegacyProfiles } from "@hcmai/sdk";
2229
2229
 
2230
2230
  // src/package-version.ts
2231
2231
  import { readFileSync } from "fs";
@@ -2399,7 +2399,7 @@ function launchBrowser(url, platform = process.platform, onFailure) {
2399
2399
  child.unref();
2400
2400
  }
2401
2401
  async function runOpen(target, args, deps) {
2402
- const path19 = normalizeTarget(target);
2402
+ const path20 = normalizeTarget(target);
2403
2403
  if (!deps.frontend?.trim()) {
2404
2404
  throw new CliError3({
2405
2405
  code: CliErrorCode2.INVALID_ARGUMENT,
@@ -2407,13 +2407,13 @@ async function runOpen(target, args, deps) {
2407
2407
  });
2408
2408
  }
2409
2409
  const { ticket, expiresIn } = await deps.mintTicket();
2410
- const url = buildBrowserLoginUrl(deps.frontend, ticket, path19);
2410
+ const url = buildBrowserLoginUrl(deps.frontend, ticket, path20);
2411
2411
  if (args.printUrl) {
2412
2412
  deps.write(`${url}
2413
2413
  `);
2414
2414
  } else {
2415
2415
  deps.launch(url);
2416
- deps.write(`\u5DF2\u7528\u5F53\u524D\u8EAB\u4EFD\u6253\u5F00 ${path19}\uFF08\u7968\u636E ${expiresIn ?? 60}s \u5185\u6709\u6548\uFF0C\u53EA\u80FD\u7528\u4E00\u6B21\uFF09
2416
+ deps.write(`\u5DF2\u7528\u5F53\u524D\u8EAB\u4EFD\u6253\u5F00 ${path20}\uFF08\u7968\u636E ${expiresIn ?? 60}s \u5185\u6709\u6548\uFF0C\u53EA\u80FD\u7528\u4E00\u6B21\uFF09
2417
2417
  `);
2418
2418
  }
2419
2419
  return { url, expiresIn };
@@ -4169,9 +4169,9 @@ async function actionCommand(spec, args) {
4169
4169
  }
4170
4170
  const explicitMethod = args.method !== void 0;
4171
4171
  const explicitScope = args.scope !== void 0;
4172
- let method = normalizeMethod(args.method);
4172
+ let method2 = normalizeMethod(args.method);
4173
4173
  let scope = normalizeScope(args.scope);
4174
- const input = { method };
4174
+ const input = { method: method2 };
4175
4175
  if (scope) input.scope = scope;
4176
4176
  if (args.id) input.id = args.id;
4177
4177
  if (args.ids) input.ids = args.ids.split(",").map((s) => s.trim());
@@ -4187,9 +4187,9 @@ async function actionCommand(spec, args) {
4187
4187
  if (!explicitMethod || !explicitScope) {
4188
4188
  const shape = await lookupActionShape(client3, model, action);
4189
4189
  if (shape) {
4190
- if (!explicitMethod && shape.httpMethod) method = shape.httpMethod;
4190
+ if (!explicitMethod && shape.httpMethod) method2 = shape.httpMethod;
4191
4191
  if (!explicitScope && shape.scope) scope = shape.scope;
4192
- input.method = method;
4192
+ input.method = method2;
4193
4193
  if (scope) input.scope = scope;
4194
4194
  }
4195
4195
  }
@@ -4596,8 +4596,8 @@ import {
4596
4596
  formatObject as formatObject7,
4597
4597
  fromAxiosError as fromAxiosError9
4598
4598
  } from "@hcmai/sdk";
4599
- function collectYmlFiles(path19) {
4600
- if (statSync(path19).isFile()) return [path19];
4599
+ function collectYmlFiles(path20) {
4600
+ if (statSync(path20).isFile()) return [path20];
4601
4601
  const out = [];
4602
4602
  const walk = (dir) => {
4603
4603
  for (const name of readdirSync(dir).sort()) {
@@ -4606,7 +4606,7 @@ function collectYmlFiles(path19) {
4606
4606
  else if (full.endsWith(".yml") || full.endsWith(".yaml")) out.push(full);
4607
4607
  }
4608
4608
  };
4609
- walk(path19);
4609
+ walk(path20);
4610
4610
  return out.sort();
4611
4611
  }
4612
4612
  var DRY_RUN_CLIENT = {
@@ -4615,9 +4615,9 @@ var DRY_RUN_CLIENT = {
4615
4615
  update: async () => ({}),
4616
4616
  fieldKeys: async () => []
4617
4617
  };
4618
- async function importCommand(path19, args) {
4618
+ async function importCommand(path20, args) {
4619
4619
  try {
4620
- const files = collectYmlFiles(path19);
4620
+ const files = collectYmlFiles(path20);
4621
4621
  const fixtures = files.map(
4622
4622
  (f) => parseFixture(readFileSync2(f, "utf8"), relative(process.cwd(), f))
4623
4623
  );
@@ -6271,8 +6271,8 @@ async function scriptManifestValidateCommand(args) {
6271
6271
  if (!args.file) {
6272
6272
  throw new Error("\u7F3A\u5C11 --file\n \u4E0B\u4E00\u6B65\uFF1Ahcm script manifest-validate --file ./manifest.yml");
6273
6273
  }
6274
- const yaml3 = readFileSync3(args.file, "utf8");
6275
- const result = await withClient2(args, (c) => validateScriptManifest(c.raw(), yaml3));
6274
+ const yaml4 = readFileSync3(args.file, "utf8");
6275
+ const result = await withClient2(args, (c) => validateScriptManifest(c.raw(), yaml4));
6276
6276
  emit2(result, args, `\u{1F4CB} manifest \u6821\u9A8C\u5B8C\u6210\uFF1A${args.file}`);
6277
6277
  } catch (e) {
6278
6278
  fail4(e, args);
@@ -6827,6 +6827,7 @@ function matchTag(c, fp) {
6827
6827
  const b = fp.backend.slice(0, 12);
6828
6828
  return a === b ? "\u5339\u914D" : `\u4E0D\u5339\u914D\uFF08\u6848\u4F8B ${a} / \u5F53\u524D ${b}\uFF09`;
6829
6829
  }
6830
+ var APPROVED_STATUS_NOTE = "\u6CE8\uFF1Astatus \u4E3A approved \u76EE\u524D\u4E0D\u4EE3\u8868\u7ECF\u8FC7\u8BC4\u5BA1\u2014\u2014\u6848\u4F8B\u4E0A\u884C\u65F6\u6CA1\u5199 status \u4F1A\u88AB\u7F3A\u7701\u8865\u6210 approved\uFF0C\u6848\u4F8B\u5E93\u8FD8\u6CA1\u6709\u8BC4\u5BA1\u95F8\u3002\u7167\u505A\u524D\u5148\u8BFB\u6B63\u6587\u3001\u5BF9\u6307\u7EB9\u3002";
6830
6831
  function emit4(args, data, text) {
6831
6832
  if (args.output === "json" || args.output === "yaml") {
6832
6833
  process.stdout.write(formatObject17(data, { format: args.output }) + "\n");
@@ -6887,9 +6888,9 @@ async function caseSearchCommand(query, args) {
6887
6888
  const rows2 = [...seen.values()];
6888
6889
  emit4(
6889
6890
  args,
6890
- { query, rows: rows2 },
6891
- () => rows2.length ? rows2.map((r) => `${r.id} [${r.status ?? "?"}\xB7${r.match}] ${r.customer_ask ?? ""}
6892
- \u6280\u80FD\uFF1A${(r.skills ?? []).join(" / ") || "\uFF08\u672A\u767B\u8BB0\uFF09"}`).join("\n") : `\u6CA1\u6709\u547D\u4E2D\u300C${query}\u300D\u7684\u6848\u4F8B\u3002\u5148\u6309\u6280\u80FD\u505A\uFF0C\u8DD1\u901A\u4E86\u7528 \`hcm chiron case submit\` \u4E0A\u884C\u4E00\u6761\u3002`
6891
+ { query, rows: rows2, statusNote: APPROVED_STATUS_NOTE },
6892
+ () => rows2.length ? [...rows2.map((r) => `${r.id} [${r.status ?? "?"}\xB7${r.match}] ${r.customer_ask ?? ""}
6893
+ \u6280\u80FD\uFF1A${(r.skills ?? []).join(" / ") || "\uFF08\u672A\u767B\u8BB0\uFF09"}`), APPROVED_STATUS_NOTE].join("\n") : `\u6CA1\u6709\u547D\u4E2D\u300C${query}\u300D\u7684\u6848\u4F8B\u3002\u5148\u6309\u6280\u80FD\u505A\uFF0C\u8DD1\u901A\u4E86\u7528 \`hcm chiron case submit\` \u4E0A\u884C\u4E00\u6761\u3002`
6893
6894
  );
6894
6895
  });
6895
6896
  }
@@ -6919,10 +6920,12 @@ ${fetchRepoFile(`${c.path}/${f}`)}`);
6919
6920
  const meta2 = fetchRepoFile(`${c.path}/case.yml`);
6920
6921
  emit4(
6921
6922
  args,
6922
- { id, caseYml: meta2, files: parts },
6923
+ { id, caseYml: meta2, files: parts, statusNote: APPROVED_STATUS_NOTE },
6923
6924
  () => `case.yml:
6924
6925
  ${meta2}
6925
6926
 
6927
+ ${APPROVED_STATUS_NOTE}
6928
+
6926
6929
  ${parts.join("\n\n---\n\n")}
6927
6930
 
6928
6931
  \uFF08\u8BC1\u636E\u6587\u4EF6\u6CA1\u6709\u4E0B\u8F7D \u2014\u2014 \u53BB ${CNB_ORIGIN}/${CASES_REPO_SLUG}/-/tree/main/${c.path} \u770B\uFF09`
@@ -6934,9 +6937,9 @@ async function caseMatchCommand(args) {
6934
6937
  const idx = loadIndex({ refresh: args.refresh });
6935
6938
  const fp = backendFingerprint(args.env);
6936
6939
  const rows2 = idx.cases.filter((c) => c.status === "approved").map((c) => ({ id: c.id, match: matchTag(c, fp), skills: c.skills, customer_ask: c.customer_ask }));
6937
- emit4(args, { fingerprint: fp, rows: rows2 }, () => {
6940
+ emit4(args, { fingerprint: fp, rows: rows2, statusNote: APPROVED_STATUS_NOTE }, () => {
6938
6941
  const head = fp.backend ? `\u5F53\u524D\u540E\u7AEF ${fp.backend.slice(0, 12)}\uFF08env ${args.env}\uFF09` : `\u26A0\uFE0F \u6CA1\u53D6\u5230\u5F53\u524D\u6307\u7EB9\uFF08${fp.reason}\uFF09\u2014\u2014\u4E0B\u9762\u6BCF\u4E00\u6761\u90FD\u6807\u7740\u300C\u672A\u6BD4\u5BF9\u300D\uFF0C\u522B\u628A\u5B83\u8BFB\u6210\u300C\u90FD\u80FD\u7167\u505A\u300D`;
6939
- return [head, ...rows2.map((r) => `${r.match === "\u5339\u914D" ? "\u2705" : "\xB7 "} ${r.id} [${r.match}] ${r.customer_ask ?? ""}`)].join("\n");
6942
+ return [head, ...rows2.map((r) => `${r.match === "\u5339\u914D" ? "\u2705" : "\xB7 "} ${r.id} [${r.match}] ${r.customer_ask ?? ""}`), APPROVED_STATUS_NOTE].join("\n");
6940
6943
  });
6941
6944
  });
6942
6945
  }
@@ -9215,10 +9218,10 @@ async function metaListCommand(args) {
9215
9218
  fail7(e, args, "read");
9216
9219
  }
9217
9220
  }
9218
- async function metaGetCommand(path19, args) {
9221
+ async function metaGetCommand(path20, args) {
9219
9222
  try {
9220
9223
  const c = await client2(args);
9221
- const content = await getTenantMeta(c.raw(), path19);
9224
+ const content = await getTenantMeta(c.raw(), path20);
9222
9225
  process.stdout.write(content.endsWith("\n") ? content : content + "\n");
9223
9226
  process.exitCode = 0;
9224
9227
  return;
@@ -9227,8 +9230,8 @@ async function metaGetCommand(path19, args) {
9227
9230
  }
9228
9231
  }
9229
9232
  var PROBEABLE_META_TYPES = /* @__PURE__ */ new Set(["model", "list", "info", "view", "filter", "page", "wiz", "impexp"]);
9230
- function parseMetaPath(path19) {
9231
- const base = path19.split(/[\\/]/).pop() ?? path19;
9233
+ function parseMetaPath(path20) {
9234
+ const base = path20.split(/[\\/]/).pop() ?? path20;
9232
9235
  if (!/\.(yml|yaml)$/i.test(base)) return {};
9233
9236
  const parts = base.replace(/\.(yml|yaml)$/i, "").split(".");
9234
9237
  return { model: parts[0] || void 0, kind: parts[1] ?? "model", state: parts[2] };
@@ -9245,10 +9248,10 @@ function unverifiableReason(e) {
9245
9248
  if (st == null) return `\u8BF7\u6C42\u6CA1\u53D1\u51FA\u53BB\u6216\u6CA1\u56DE\u6765\uFF08${err.code ?? err.message ?? "\u672A\u77E5"}\uFF09`;
9246
9249
  return void 0;
9247
9250
  }
9248
- async function verifyAfterWrite(c, path19) {
9249
- const { model, kind, state } = parseMetaPath(path19);
9251
+ async function verifyAfterWrite(c, path20) {
9252
+ const { model, kind, state } = parseMetaPath(path20);
9250
9253
  if (!model || !kind) {
9251
- return { status: "unverified", where: "(\u672A\u63A2)", why: `\u4ECE\u8DEF\u5F84 ${path19} \u8BA4\u4E0D\u51FA\u6A21\u578B\u540D/\u5C42\u540D` };
9254
+ return { status: "unverified", where: "(\u672A\u63A2)", why: `\u4ECE\u8DEF\u5F84 ${path20} \u8BA4\u4E0D\u51FA\u6A21\u578B\u540D/\u5C42\u540D` };
9252
9255
  }
9253
9256
  try {
9254
9257
  await clearMetaCache2(c.raw(), model, {});
@@ -9293,7 +9296,7 @@ async function verifyAfterWrite(c, path19) {
9293
9296
  }
9294
9297
  return { status: "ok" };
9295
9298
  }
9296
- async function metaSetCommand(path19, args) {
9299
+ async function metaSetCommand(path20, args) {
9297
9300
  try {
9298
9301
  if (!args.file) {
9299
9302
  throw new CliError23({
@@ -9309,9 +9312,9 @@ async function metaSetCommand(path19, args) {
9309
9312
  process.stdin.on("error", reject);
9310
9313
  }) : await fsp3.readFile(args.file, "utf8");
9311
9314
  if (!args.skipValidate) {
9312
- const result2 = validateMetaContent(path19, content);
9315
+ const result2 = validateMetaContent(path20, content);
9313
9316
  if (result2.issues.length > 0) {
9314
- process.stderr.write(`\u{1F50E} \u5199\u524D\u6821\u9A8C ${path19}\uFF08schema \u7C7B\u578B\uFF1A${result2.kind ?? "\u672A\u8BC6\u522B"}\uFF09
9317
+ process.stderr.write(`\u{1F50E} \u5199\u524D\u6821\u9A8C ${path20}\uFF08schema \u7C7B\u578B\uFF1A${result2.kind ?? "\u672A\u8BC6\u522B"}\uFF09
9315
9318
  `);
9316
9319
  process.stderr.write(formatMetaIssues(result2, " ") + "\n");
9317
9320
  }
@@ -9330,13 +9333,13 @@ async function metaSetCommand(path19, args) {
9330
9333
  if (dryFmt === "json" || dryFmt === "yaml") {
9331
9334
  process.stdout.write(
9332
9335
  formatObject21(
9333
- { dryRun: true, path: path19, bytes: Buffer.byteLength(content), content },
9336
+ { dryRun: true, path: path20, bytes: Buffer.byteLength(content), content },
9334
9337
  { format: dryFmt }
9335
9338
  ) + "\n"
9336
9339
  );
9337
9340
  } else {
9338
9341
  process.stdout.write(
9339
- `[dry-run] \u5C06\u5199\u5165 ${path19}\uFF08${Buffer.byteLength(content)} B\uFF09\u2014\u2014\u672A\u5B9E\u9645\u5199\u5165
9342
+ `[dry-run] \u5C06\u5199\u5165 ${path20}\uFF08${Buffer.byteLength(content)} B\uFF09\u2014\u2014\u672A\u5B9E\u9645\u5199\u5165
9340
9343
  ---
9341
9344
  ${content}
9342
9345
  `
@@ -9350,13 +9353,13 @@ ${content}
9350
9353
  let backupState = "unknown";
9351
9354
  let backupWhy;
9352
9355
  try {
9353
- const prev = await getTenantMeta(c.raw(), path19);
9356
+ const prev = await getTenantMeta(c.raw(), path20);
9354
9357
  if (!prev || prev.trim() === "") {
9355
9358
  backupState = "absent";
9356
9359
  } else {
9357
9360
  backupFile = nodePath.join(
9358
9361
  os4.tmpdir(),
9359
- `hcm-meta-backup-${Date.now()}-${path19.replace(/[\\/]/g, "_")}`
9362
+ `hcm-meta-backup-${Date.now()}-${path20.replace(/[\\/]/g, "_")}`
9360
9363
  );
9361
9364
  await fsp3.writeFile(backupFile, prev, "utf8");
9362
9365
  backupState = "saved";
@@ -9371,22 +9374,22 @@ ${content}
9371
9374
  backupWhy = `HTTP ${st ?? "-"}${err.code ? ` ${err.code}` : ""}${err.message ? `\uFF1A${err.message}` : ""}`;
9372
9375
  }
9373
9376
  }
9374
- const result = await saveTenantMeta(c.raw(), path19, content);
9377
+ const result = await saveTenantMeta(c.raw(), path20, content);
9375
9378
  const fmt = args.output ?? "json";
9376
- if (fmt !== "json") process.stdout.write(`\u2705 \u5DF2\u5199\u5165 ${path19}
9379
+ if (fmt !== "json") process.stdout.write(`\u2705 \u5DF2\u5199\u5165 ${path20}
9377
9380
  `);
9378
9381
  const restoreHint = backupState === "saved" && backupFile ? ` \u65E7\u5185\u5BB9\u5DF2\u5B58\uFF1A${backupFile}
9379
- \u653E\u56DE\u53BB\uFF1Ahcm meta set ${path19} --file ${backupFile}${connFlags(args)}
9380
- ` : backupState === "absent" ? ` \u8FD9\u4E00\u5C42\u6B64\u524D\u6CA1\u6709\u8986\u76D6\uFF08\u5DF2\u8BC1\u5B9E\uFF09\uFF0C\u6062\u590D\u5373\u5220\u9664\uFF1Ahcm meta delete ${path19}${connFlags(args)}
9382
+ \u653E\u56DE\u53BB\uFF1Ahcm meta set ${path20} --file ${backupFile}${connFlags(args)}
9383
+ ` : 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 ${path20}${connFlags(args)}
9381
9384
  ` : ` \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
9382
- \u5148\u81EA\u5DF1\u8BFB\u4E00\u904D\u786E\u8BA4\uFF1Ahcm meta get ${path19}${connFlags(args)}
9385
+ \u5148\u81EA\u5DF1\u8BFB\u4E00\u904D\u786E\u8BA4\uFF1Ahcm meta get ${path20}${connFlags(args)}
9383
9386
  `;
9384
9387
  if (args.verify === false) {
9385
9388
  process.stderr.write(
9386
9389
  "\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
9387
9390
  );
9388
9391
  } else {
9389
- const outcome = await verifyAfterWrite(c, path19);
9392
+ const outcome = await verifyAfterWrite(c, path20);
9390
9393
  if (outcome.status === "broken") {
9391
9394
  const human = explainJacksonError(outcome.raw);
9392
9395
  process.stderr.write(
@@ -9420,19 +9423,19 @@ ${content}
9420
9423
  fail7(e, args);
9421
9424
  }
9422
9425
  }
9423
- async function metaDeleteCommand(path19, args) {
9426
+ async function metaDeleteCommand(path20, args) {
9424
9427
  try {
9425
9428
  if (!args.yes) {
9426
- const ok = await promptConfirm(`\u5C06\u5220\u9664\u5143\u6570\u636E ${path19}\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u9006\u3002\u7EE7\u7EED\uFF1F`);
9429
+ const ok = await promptConfirm(`\u5C06\u5220\u9664\u5143\u6570\u636E ${path20}\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u9006\u3002\u7EE7\u7EED\uFF1F`);
9427
9430
  if (!ok) {
9428
9431
  process.stderr.write("\u5DF2\u53D6\u6D88\n");
9429
9432
  process.exit(1);
9430
9433
  }
9431
9434
  }
9432
9435
  const c = await client2(args);
9433
- const result = await deleteTenantMeta(c.raw(), path19);
9436
+ const result = await deleteTenantMeta(c.raw(), path20);
9434
9437
  const fmt = args.output ?? "json";
9435
- if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${path19}
9438
+ if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${path20}
9436
9439
  `);
9437
9440
  process.stdout.write(formatObject21(result, { format: fmt }) + "\n");
9438
9441
  process.exitCode = 0;
@@ -9441,7 +9444,7 @@ async function metaDeleteCommand(path19, args) {
9441
9444
  fail7(e, args);
9442
9445
  }
9443
9446
  }
9444
- async function metaValidateCommand(path19, args) {
9447
+ async function metaValidateCommand(path20, args) {
9445
9448
  try {
9446
9449
  if (!args.file) {
9447
9450
  throw new CliError23({
@@ -9456,13 +9459,13 @@ async function metaValidateCommand(path19, args) {
9456
9459
  process.stdin.on("end", () => resolve3(buf));
9457
9460
  process.stdin.on("error", reject);
9458
9461
  }) : await fsp3.readFile(args.file, "utf8");
9459
- const result = validateMetaContent(path19, content);
9462
+ const result = validateMetaContent(path20, content);
9460
9463
  const fmt = args.output ?? "table";
9461
9464
  if (fmt === "json" || fmt === "yaml") {
9462
9465
  process.stdout.write(
9463
9466
  formatObject21(
9464
9467
  {
9465
- path: path19,
9468
+ path: path20,
9466
9469
  kind: result.kind,
9467
9470
  schemaKnown: result.schemaKnown,
9468
9471
  schemaSourceCommit: META_SCHEMA_SOURCE_COMMIT,
@@ -9474,7 +9477,7 @@ async function metaValidateCommand(path19, args) {
9474
9477
  );
9475
9478
  } else {
9476
9479
  process.stdout.write(
9477
- `\u{1F50E} ${path19}\uFF08schema \u7C7B\u578B\uFF1A${result.kind ?? "\u672A\u8BC6\u522B"}\uFF0C\u6765\u6E90 ${META_SCHEMA_SOURCE_COMMIT.slice(0, 8)}\uFF09
9480
+ `\u{1F50E} ${path20}\uFF08schema \u7C7B\u578B\uFF1A${result.kind ?? "\u672A\u8BC6\u522B"}\uFF0C\u6765\u6E90 ${META_SCHEMA_SOURCE_COMMIT.slice(0, 8)}\uFF09
9478
9481
  `
9479
9482
  );
9480
9483
  process.stdout.write(
@@ -11405,7 +11408,7 @@ init_exit();
11405
11408
  import { createJiraClient } from "@hcmai/sdk";
11406
11409
 
11407
11410
  // src/jira/gaps.ts
11408
- import { CASES_REPO_SLUG as CASES_REPO_SLUG2, repoIssueUrl } from "@hcmai/sdk";
11411
+ import { CASES_REPO_SLUG as CASES_REPO_SLUG2, describeNonBmpHits, findNonBmpChars, repoIssueUrl } from "@hcmai/sdk";
11409
11412
  import { linkedRepoRefs, parseRef } from "@hcmai/sdk";
11410
11413
  var MIN_LEN = [
11411
11414
  ["title", 8],
@@ -11429,6 +11432,8 @@ function validateGapInput(x) {
11429
11432
  if (!["\u963B\u65AD", "\u6709\u66FF\u4EE3\u6CD5", "\u63AA\u8F9E\u7EA7"].includes(String(g.severity))) problems.push("severity \u53EA\u80FD\u662F \u963B\u65AD / \u6709\u66FF\u4EE3\u6CD5 / \u63AA\u8F9E\u7EA7");
11430
11433
  if (!["\u7F3A\u9677", "\u7F3A\u80FD\u529B"].includes(String(g.kind))) problems.push("kind \u53EA\u80FD\u662F \u7F3A\u9677\uFF08\u6545\u969C\uFF09/ \u7F3A\u80FD\u529B\uFF08\u9700\u6C42\uFF09");
11431
11434
  if (g.module !== void 0 && !["HCM-Core", "HCM-Cloud", "\u4EA7\u54C1\u652F\u6301"].includes(String(g.module))) problems.push("module \u53EA\u80FD\u662F HCM-Core / HCM-Cloud / \u4EA7\u54C1\u652F\u6301");
11435
+ const nonBmp = findNonBmpChars(g);
11436
+ if (nonBmp.length) problems.push(describeNonBmpHits(nonBmp).split("\n").join("\n "));
11432
11437
  if (problems.length) throw new Error(`\u7F3A\u53E3\u8F7D\u8377\u4E0D\u5408\u683C\uFF0C\u6CA1\u6709\u63D0\uFF1A
11433
11438
  ${problems.join("\n ")}`);
11434
11439
  return g;
@@ -11791,7 +11796,17 @@ async function gapComments({ client: client3 }, ref, { limit } = {}, casesSlug =
11791
11796
  }
11792
11797
 
11793
11798
  // src/jira/gap-verify.ts
11794
- import { CASES_REPO_SLUG as CASES_REPO_SLUG3, CliError as CliError26, CliErrorCode as CliErrorCode27, JiraHttpError, firstLine as firstLine2, parseRef as parseRef2 } from "@hcmai/sdk";
11799
+ import {
11800
+ CASES_REPO_SLUG as CASES_REPO_SLUG3,
11801
+ CliError as CliError26,
11802
+ CliErrorCode as CliErrorCode27,
11803
+ JiraHttpError,
11804
+ JiraNonBmpContentError,
11805
+ NON_BMP_RULE_NOTE,
11806
+ firstLine as firstLine2,
11807
+ nonBmpHitLines,
11808
+ parseRef as parseRef2
11809
+ } from "@hcmai/sdk";
11795
11810
  var VERIFY_RESULTS = ["pass", "fail", "partial"];
11796
11811
  var WRITTEN_TAG = { no: "\u3010\u672A\u5199\u5165\u3011", yes: "\u3010\u5DF2\u5199\u5165\u3011", unknown: "\u3010\u5199\u6CA1\u5199\u4E0D\u786E\u5B9A\u3011" };
11797
11812
  var FIXED_STATUS = "\u5DF2\u4FEE\u590D";
@@ -11887,6 +11902,19 @@ function unconfirmedWhy(e) {
11887
11902
  return name;
11888
11903
  }
11889
11904
  function writeFailure(e, key2, what) {
11905
+ if (e instanceof JiraNonBmpContentError) {
11906
+ return verifyFailure(
11907
+ "non-bmp-content",
11908
+ CliErrorCode27.INVALID_ARGUMENT,
11909
+ "no",
11910
+ `\u8FD9\u6B21${what}\u4E00\u4E2A\u5B57\u90FD\u6CA1\u53D1\u51FA\u53BB\uFF1A\u6B63\u6587\u91CC\u6709 ${e.hits.length} \u5904 Jira \u5B58\u4E0D\u4E0B\u7684\u5B57\u7B26`,
11911
+ // 🔴 清单落 nextStep,不落 cause:CliError 渲染 cause 时 formatCause 截到 300 字,
11912
+ // 三处命中就会把「该怎么改」整段截掉——那正是顾问唯一需要的那段。
11913
+ `\u6362\u6389\u4E0B\u9762\u8FD9\u4E9B\u5B57\u7B26\u518D\u91CD\u8DD1\uFF08${NON_BMP_RULE_NOTE}\uFF09\uFF1A
11914
+ ${nonBmpHitLines(e.hits)}`,
11915
+ { key: key2, hits: e.hits }
11916
+ );
11917
+ }
11890
11918
  if (e instanceof JiraHttpError && e.status >= 400 && e.status < 500) {
11891
11919
  return verifyFailure("write-rejected", CliErrorCode27.BUSINESS_RULE_VIOLATION, "no", `Jira \u4EE5 ${e.status} \u62D2\u7EDD\u4E86\u8FD9\u6B21${what}`, rejectNextStep(e.status, key2), {
11892
11920
  key: key2,
@@ -12331,20 +12359,1174 @@ async function gapVerifyCommand(ref, args, deps = defaultDeps) {
12331
12359
  init_auth_guard();
12332
12360
  init_exit();
12333
12361
  import { promises as fs10 } from "fs";
12334
- import path11 from "path";
12362
+ import path12 from "path";
12335
12363
  import {
12336
12364
  HcmClient as HcmClient24,
12337
- CliError as CliError27,
12338
- CliErrorCode as CliErrorCode29,
12365
+ CliError as CliError28,
12366
+ CliErrorCode as CliErrorCode30,
12339
12367
  loadGlobalConfig as loadGlobalConfig11,
12340
12368
  resolveEnvContext as resolveEnvContext8,
12341
12369
  fetchReconIdentity as fetchReconIdentity2,
12342
- formatObject as formatObject26,
12370
+ formatObject as formatObject27,
12343
12371
  httpProbe as httpProbe2,
12344
12372
  conversationWebSocketEndpoint as conversationWebSocketEndpoint4,
12345
12373
  probeConversationHandshake,
12346
12374
  runDoctor
12347
12375
  } from "@hcmai/sdk";
12376
+
12377
+ // src/commands/chiron-method.ts
12378
+ init_exit();
12379
+ import { execFileSync as execFileSync2 } from "child_process";
12380
+ import { createHash as createHash6 } from "crypto";
12381
+ import { existsSync as existsSync3, promises as fsp4 } from "fs";
12382
+ import os5 from "os";
12383
+ import path11 from "path";
12384
+ import yaml from "js-yaml";
12385
+ import {
12386
+ CliError as CliError27,
12387
+ CliErrorCode as CliErrorCode29,
12388
+ METHOD_REPO_DISPLAY,
12389
+ METHOD_REPO_URL,
12390
+ assertSafeSkillId as assertSafeSkillId2,
12391
+ createHttpClient as createHttpClient5,
12392
+ discoverProjectEnv as discoverProjectEnv6,
12393
+ fetchSkillCatalog as fetchSkillCatalog2,
12394
+ flattenSkills as flattenSkills2,
12395
+ formatObject as formatObject26,
12396
+ parseSkillFrontmatter as parseSkillFrontmatter3,
12397
+ resolveChironBase as resolveChironBase2
12398
+ } from "@hcmai/sdk";
12399
+ var METHOD_DIR = "hcm-methodology";
12400
+ var METHOD_LOCK_FILE = "methodology.lock.json";
12401
+ var METHOD_STATE_FILE = ".state.json";
12402
+ var METHOD_SKILL_PREFIX = "method-";
12403
+ var METHOD_PHASES = ["\u5BA2\u6237\u51C6\u5907", "\u8BA1\u5212", "\u67B6\u6784\u4E0E\u914D\u7F6E", "\u6D4B\u8BD5", "\u90E8\u7F72", "\u91C7\u7528\u4E0E\u4F18\u5316"];
12404
+ var KNOWN_PACKAGE_SCHEMA_VERSIONS = [1];
12405
+ var GITIGNORE_BEGIN = "# hcm-methodology:begin";
12406
+ var GITIGNORE_END = "# hcm-methodology:end";
12407
+ var GITIGNORE_RULES = [
12408
+ `${METHOD_DIR}/*`,
12409
+ `!${METHOD_DIR}/${METHOD_LOCK_FILE}`,
12410
+ ".claude/skills/method-*/",
12411
+ // 安装中途的暂存目录(`.hcm-methodology.staging-<pid>` / `.old-<pid>`):进程在替换那一步被杀时
12412
+ // 会留下整份副本,不忽略就会被 `git add -A` 扫进项目仓。
12413
+ `/.${METHOD_DIR}.*/`
12414
+ ];
12415
+ var AGENTS_METHOD_BEGIN = "<!-- hcm-methodology:begin -->";
12416
+ var AGENTS_METHOD_END = "<!-- hcm-methodology:end -->";
12417
+ var GATES_FILE = "quality-gates/gates.yml";
12418
+ var GIT_NETWORK_TIMEOUT_MS = 12e4;
12419
+ var GIT_LS_REMOTE_TIMEOUT_MS = 3e4;
12420
+ function gitErrorText(e) {
12421
+ const err = e;
12422
+ const stderr = typeof err.stderr === "string" ? err.stderr : err.stderr?.toString("utf8") ?? "";
12423
+ return (stderr.trim() || String(err.message ?? e)).trim().replace(/([a-z][a-z0-9+.-]*:\/\/)[^\s/@'"]+@/gi, "$1");
12424
+ }
12425
+ function classifyGitFailure(e, repoDisplay) {
12426
+ const err = e;
12427
+ if (err.code === "ENOENT") {
12428
+ return new CliError27({
12429
+ code: CliErrorCode29.METHOD_GIT_UNAVAILABLE,
12430
+ message: "\u672C\u673A\u627E\u4E0D\u5230 git\uFF0C\u53D6\u65B9\u6CD5\u5305\u9760\u5B83",
12431
+ context: { nextStep: "\u88C5\u4E0A git\uFF08`git --version` \u80FD\u8DD1\u901A\uFF09\uFF0C\u518D\u91CD\u8DD1\u8FD9\u6761\u547D\u4EE4" }
12432
+ });
12433
+ }
12434
+ const text = gitErrorText(e);
12435
+ const head = text.split("\n").filter(Boolean).slice(-3).join(" / ").slice(0, 400);
12436
+ if (err.code === "ETIMEDOUT" || err.signal === "SIGTERM") {
12437
+ return new CliError27({
12438
+ code: CliErrorCode29.METHOD_SOURCE_NETWORK,
12439
+ message: `git \u5728\u65F6\u9650\u5185\u6CA1\u6709\u8FD4\u56DE\uFF08${repoDisplay}\uFF09`,
12440
+ context: { nextStep: "\u67E5\u7F51\u7EDC\u6216\u4EE3\u7406\u540E\u91CD\u8DD1\uFF1B\u5DF2\u88C5\u7684\u65B9\u6CD5\u5305\u79BB\u7EBF\u53EF\u8BFB\uFF0C`hcm chiron method status` \u7167\u5E38\u80FD\u7528" }
12441
+ });
12442
+ }
12443
+ if (/could not read Username|Authentication failed|terminal prompts disabled|returned error: 401|HTTP Basic: Access denied|invalid credentials|Permission denied \(publickey/i.test(text)) {
12444
+ return new CliError27({
12445
+ code: CliErrorCode29.METHOD_SOURCE_AUTH_REQUIRED,
12446
+ message: `\u65B9\u6CD5\u8BBA\u4ED3\u8981\u8BA4\u8BC1\uFF0C\u672C\u673A\u6CA1\u6709\u53EF\u7528\u7684 git \u51ED\u636E\uFF08${repoDisplay}\uFF09\uFF1A${head}`,
12447
+ context: { nextStep: "`cnb login` \u4E4B\u540E\u91CD\u8DD1\u3002\u65B9\u6CD5\u5305\u8D70\u7684\u662F git \u51ED\u636E\uFF0C\u4E0D\u662F `hcm login`" }
12448
+ });
12449
+ }
12450
+ const notFound = /returned error: 404|Repository not found|repository '.*' not found|does not appear to be a git repository/i.test(text);
12451
+ if (/returned error: 403|403 Forbidden|access denied|not authorized/i.test(text) || notFound) {
12452
+ const overridden = Boolean(process.env.HCM_METHOD_REPO?.trim() || process.env.HCM_METHOD_REPO_URL?.trim());
12453
+ return new CliError27({
12454
+ code: CliErrorCode29.METHOD_SOURCE_FORBIDDEN,
12455
+ message: `\u51ED\u636E\u6709\u6548\u4F46\u8BFB\u4E0D\u5230\u65B9\u6CD5\u8BBA\u4ED3 ${repoDisplay}\uFF1A${head}` + (notFound ? "\uFF08\u8FDC\u7AEF\u5BF9\u65E0\u6743\u8BBF\u95EE\u7684\u79C1\u6709\u4ED3\u4E5F\u53EF\u80FD\u56DE 404\uFF0C\u6240\u4EE5\u8FD9\u91CC\u4E0D\u628A\u5B83\u5224\u6210\u300C\u4ED3\u4E0D\u5B58\u5728\u300D\uFF09" : ""),
12456
+ context: {
12457
+ nextStep: "\u627E\u77E5\u8BC6\u7EC4\u7EC7\u7BA1\u7406\u5458\u628A\u4F60\u52A0\u8FDB\u65B9\u6CD5\u8BBA\u4ED3\uFF08\u8981\u4EE3\u7801\u8BFB\u6743\u9650\uFF09" + (overridden ? "\uFF1B\u4F60\u8BBE\u4E86 HCM_METHOD_REPO / HCM_METHOD_REPO_URL\uFF0C\u5148\u6838\u5BF9\u62FC\u5199" : "")
12458
+ }
12459
+ });
12460
+ }
12461
+ if (/Could not resolve host|Failed to connect|Connection refused|Connection timed out|Operation timed out|Network is unreachable|Could not connect|SSL|TLS|timed out/i.test(text)) {
12462
+ return new CliError27({
12463
+ code: CliErrorCode29.METHOD_SOURCE_NETWORK,
12464
+ message: `\u8FDE\u4E0D\u4E0A\u65B9\u6CD5\u8BBA\u4ED3\uFF08${repoDisplay}\uFF09\uFF1A${head}`,
12465
+ context: { nextStep: "\u67E5\u7F51\u7EDC\u6216\u4EE3\u7406\u540E\u91CD\u8DD1\uFF1B\u5DF2\u88C5\u7684\u65B9\u6CD5\u5305\u79BB\u7EBF\u53EF\u8BFB\uFF0C`hcm chiron method status` \u7167\u5E38\u80FD\u7528" }
12466
+ });
12467
+ }
12468
+ return new CliError27({
12469
+ code: CliErrorCode29.METHOD_SOURCE_GIT_FAILED,
12470
+ message: `git \u5931\u8D25\u4E86\uFF0C\u539F\u56E0\u4E0D\u5728\u8BA4\u8BC1 / \u6743\u9650 / \u7F51\u7EDC\u4E09\u7C7B\u91CC\uFF08${repoDisplay}\uFF09\uFF1A${head}`,
12471
+ context: { nextStep: `\u81EA\u5DF1\u8DD1\u4E00\u6B21 \`git ls-remote --tags <\u65B9\u6CD5\u8BBA\u4ED3\u5730\u5740>\` \u770B\u539F\u8BDD\uFF1B\u628A\u4E0A\u9762\u8FD9\u6BB5\u8FDE\u540C \`git --version\` \u62A5\u7ED9 CLI \u7EF4\u62A4\u8005` }
12472
+ });
12473
+ }
12474
+ function makeGitRunner(repoDisplay) {
12475
+ return (args, opts = {}) => {
12476
+ try {
12477
+ return execFileSync2("git", args, {
12478
+ cwd: opts.cwd,
12479
+ encoding: "utf8",
12480
+ maxBuffer: 1 << 26,
12481
+ timeout: opts.timeoutMs ?? GIT_NETWORK_TIMEOUT_MS,
12482
+ stdio: ["ignore", "pipe", "pipe"],
12483
+ // 🔴 不许 git 停下来问口令:agent 跑它时没人回答,只会一直挂着。凭据缺就当场报认证失败。
12484
+ env: { ...process.env, GIT_TERMINAL_PROMPT: "0", GCM_INTERACTIVE: "never" }
12485
+ });
12486
+ } catch (e) {
12487
+ throw classifyGitFailure(e, repoDisplay);
12488
+ }
12489
+ };
12490
+ }
12491
+ function defaultMethodDeps() {
12492
+ return {
12493
+ repoUrl: METHOD_REPO_URL,
12494
+ repoDisplay: METHOD_REPO_DISPLAY,
12495
+ git: makeGitRunner(METHOD_REPO_DISPLAY),
12496
+ listBundled: () => ({ ids: listBundledSkills().map((s) => s.id), version: CLI_VERSION, dir: bundledSkillsDir() }),
12497
+ fetchOnlineCatalog: async (endpoint) => {
12498
+ const http = createHttpClient5({ endpoint, getAccessToken: async () => null, onRefresh: async () => {
12499
+ }, timeoutMs: 15e3 });
12500
+ const base = await resolveChironBase2(http);
12501
+ return flattenSkills2(await fetchSkillCatalog2(http, base)).map((s) => s.id);
12502
+ },
12503
+ now: () => /* @__PURE__ */ new Date(),
12504
+ log: (line) => process.stderr.write(`[hcm] ${line}
12505
+ `)
12506
+ };
12507
+ }
12508
+ function parseLsRemoteTags(out) {
12509
+ const direct2 = /* @__PURE__ */ new Map();
12510
+ const peeled = /* @__PURE__ */ new Map();
12511
+ for (const line of out.split("\n")) {
12512
+ const m = /^([0-9a-f]{40,64})\s+refs\/tags\/(.+?)(\^\{\})?$/.exec(line.trim());
12513
+ if (!m) continue;
12514
+ (m[3] ? peeled : direct2).set(m[2], m[1]);
12515
+ }
12516
+ const tags = /* @__PURE__ */ new Map();
12517
+ for (const [name, sha] of direct2) tags.set(name, peeled.get(name) ?? sha);
12518
+ return tags;
12519
+ }
12520
+ var SEMVER_TAG = /^v(\d+)\.(\d+)\.(\d+)$/;
12521
+ function semverKey(tag) {
12522
+ const m = SEMVER_TAG.exec(tag);
12523
+ return m ? [Number(m[1]), Number(m[2]), Number(m[3])] : void 0;
12524
+ }
12525
+ function compareTags(a, b) {
12526
+ const ka = semverKey(a);
12527
+ const kb = semverKey(b);
12528
+ if (!ka || !kb) return 0;
12529
+ for (let i = 0; i < 3; i++) if (ka[i] !== kb[i]) return ka[i] - kb[i];
12530
+ return 0;
12531
+ }
12532
+ function latestVersionTag(tags) {
12533
+ return [...tags.keys()].filter((t) => SEMVER_TAG.test(t)).sort(compareTags).pop();
12534
+ }
12535
+ function listRemoteTags(deps) {
12536
+ return parseLsRemoteTags(deps.git(["ls-remote", "--tags", deps.repoUrl], { timeoutMs: GIT_LS_REMOTE_TIMEOUT_MS }));
12537
+ }
12538
+ function resolveRef(tags, ref, deps) {
12539
+ const versions = [...tags.keys()].filter((t) => SEMVER_TAG.test(t)).sort(compareTags).reverse();
12540
+ if (ref === void 0) {
12541
+ const latest = versions[0];
12542
+ if (!latest) {
12543
+ throw new CliError27({
12544
+ code: CliErrorCode29.METHOD_REF_NOT_FOUND,
12545
+ message: `\u65B9\u6CD5\u8BBA\u4ED3 ${deps.repoDisplay} \u91CC\u4E00\u4E2A vX.Y.Z \u5F62\u5F0F\u7684\u7248\u672C tag \u90FD\u6CA1\u6709`,
12546
+ context: { nextStep: tags.size ? `\u4ED3\u91CC\u6709\u8FD9\u4E9B tag\uFF1A${[...tags.keys()].slice(0, 10).join("\u3001")}\uFF0C\u7528 --ref \u6307\u5B9A\u4E00\u4E2A` : "\u65B9\u6CD5\u8BBA\u4ED3\u8FD8\u6CA1\u53D1\u8FC7\u7248\uFF0C\u627E\u65B9\u6CD5\u8D1F\u8D23\u4EBA\u786E\u8BA4" }
12547
+ });
12548
+ }
12549
+ return { ref: latest, commit: tags.get(latest) };
12550
+ }
12551
+ const name = tags.has(ref) ? ref : tags.has(`v${ref}`) ? `v${ref}` : void 0;
12552
+ if (!name) {
12553
+ throw new CliError27({
12554
+ code: CliErrorCode29.METHOD_REF_NOT_FOUND,
12555
+ message: `\u65B9\u6CD5\u8BBA\u4ED3 ${deps.repoDisplay} \u91CC\u6CA1\u6709 tag ${ref}`,
12556
+ context: { nextStep: versions.length ? `\u53EF\u7528\u7684\u7248\u672C tag\uFF1A${versions.slice(0, 10).join("\u3001")}` : "\u65B9\u6CD5\u8BBA\u4ED3\u8FD8\u6CA1\u53D1\u8FC7\u7248\uFF0C\u627E\u65B9\u6CD5\u8D1F\u8D23\u4EBA\u786E\u8BA4" }
12557
+ });
12558
+ }
12559
+ return { ref: name, commit: tags.get(name) };
12560
+ }
12561
+ function invalidPackage(field, message) {
12562
+ return new CliError27({
12563
+ code: CliErrorCode29.METHOD_PACKAGE_INVALID,
12564
+ message: `\u65B9\u6CD5\u5305\u6E05\u5355 package.yml \u4E0D\u5408\u683C\uFF1A${message}`,
12565
+ context: { field, nextStep: "\u8FD9\u662F\u65B9\u6CD5\u5305\u7684\u7F3A\u9677\uFF0C\u4E0D\u662F\u672C\u673A\u95EE\u9898\uFF1A\u628A\u8FD9\u6BB5\u62A5\u7ED9\u65B9\u6CD5\u8BBA\u4ED3\u8D1F\u8D23\u4EBA\u3002\u5DF2\u88C5\u7684\u65B9\u6CD5\u5305\uFF08\u5982\u6709\uFF09\u4FDD\u6301\u539F\u6837\uFF0C\u6CA1\u52A8" }
12566
+ });
12567
+ }
12568
+ function isSafeRelative(p, allowDirSlash = false) {
12569
+ if (typeof p !== "string" || !p || p.includes("\\") || p.includes("\0") || p.startsWith("/") || p.startsWith("-")) return false;
12570
+ const body = allowDirSlash && p.endsWith("/") ? p.slice(0, -1) : p;
12571
+ return body.split("/").every((seg) => seg !== "" && seg !== "." && seg !== "..");
12572
+ }
12573
+ var isStringArray = (v) => Array.isArray(v) && v.every((x) => typeof x === "string" && x.length > 0);
12574
+ function parsePackageManifest(text) {
12575
+ let raw;
12576
+ try {
12577
+ raw = yaml.load(text, { schema: yaml.JSON_SCHEMA });
12578
+ } catch (e) {
12579
+ throw invalidPackage("(root)", `\u4E0D\u662F\u5408\u6CD5 YAML\uFF08${e.message.split("\n")[0]}\uFF09`);
12580
+ }
12581
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) throw invalidPackage("(root)", "\u9876\u5C42\u4E0D\u662F\u4E00\u4E2A\u5BF9\u8C61");
12582
+ const m = raw;
12583
+ if (typeof m.schemaVersion !== "number" || !Number.isInteger(m.schemaVersion)) {
12584
+ throw invalidPackage("schemaVersion", "\u7F3A schemaVersion\uFF08\u6574\u6570\uFF09");
12585
+ }
12586
+ if (!KNOWN_PACKAGE_SCHEMA_VERSIONS.includes(m.schemaVersion)) {
12587
+ throw new CliError27({
12588
+ code: CliErrorCode29.METHOD_PACKAGE_SCHEMA_UNSUPPORTED,
12589
+ message: `\u65B9\u6CD5\u5305\u6E05\u5355\u7684\u683C\u5F0F\u7248\u672C schemaVersion=${m.schemaVersion}\uFF0C\u8FD9\u7248 CLI\uFF08${CLI_VERSION}\uFF09\u53EA\u8BA4\u8BC6 ${KNOWN_PACKAGE_SCHEMA_VERSIONS.join(" / ")}`,
12590
+ context: { nextStep: "\u5347\u7EA7 CLI\uFF1A`npm install --global @hcmai/cli@latest`\uFF08\u6216 `hcm upgrade`\uFF09\uFF0C\u518D\u91CD\u8DD1\u3002\u5DF2\u88C5\u7684\u65B9\u6CD5\u5305\uFF08\u5982\u6709\uFF09\u4FDD\u6301\u539F\u6837\uFF0C\u6CA1\u52A8" }
12591
+ });
12592
+ }
12593
+ if (typeof m.name !== "string" || !m.name.trim()) throw invalidPackage("name", "\u7F3A name");
12594
+ if (typeof m.version !== "string" || !/^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/.test(m.version)) {
12595
+ throw invalidPackage("version", `version \u8981\u662F X.Y.Z \u5F62\u5F0F\u7684\u5B57\u7B26\u4E32\uFF0C\u6536\u5230 ${JSON.stringify(m.version)}`);
12596
+ }
12597
+ const components = {};
12598
+ if (m.components !== void 0) {
12599
+ if (!m.components || typeof m.components !== "object" || Array.isArray(m.components)) throw invalidPackage("components", "components \u8981\u662F\u5BF9\u8C61");
12600
+ for (const [k, v] of Object.entries(m.components)) {
12601
+ if (typeof v !== "string") throw invalidPackage(`components.${k}`, `components.${k} \u8981\u662F\u7248\u672C\u53F7\u5B57\u7B26\u4E32`);
12602
+ components[k] = v;
12603
+ }
12604
+ }
12605
+ if (!isStringArray(m.include) || m.include.length === 0) throw invalidPackage("include", "include \u8981\u662F\u975E\u7A7A\u7684\u8DEF\u5F84\u6570\u7EC4");
12606
+ const include = m.include;
12607
+ include.forEach((entry, i) => {
12608
+ if (!isSafeRelative(entry, true)) throw invalidPackage(`include[${i}]`, `include \u91CC\u7684 ${JSON.stringify(entry)} \u4E0D\u662F\u5B89\u5168\u7684\u5305\u5185\u76F8\u5BF9\u8DEF\u5F84`);
12609
+ if (!entry.endsWith("/") && entry.includes("/")) {
12610
+ throw invalidPackage(`include[${i}]`, `include \u91CC\u7684\u6587\u4EF6\u53EA\u80FD\u5728\u6839\u76EE\u5F55\uFF08\u7A00\u758F\u68C0\u51FA\u53EA\u81EA\u52A8\u5E26\u6839\u76EE\u5F55\u6587\u4EF6\uFF09\uFF0C\u6536\u5230 ${entry}`);
12611
+ }
12612
+ });
12613
+ if (!include.includes("package.yml")) throw invalidPackage("include", "include \u5FC5\u987B\u542B package.yml\uFF08\u672C\u673A\u526F\u672C\u9760\u5B83\u6838\u5BF9\u9501\u5B9A\u7248\u672C\uFF09");
12614
+ const includeDirs = include.filter((e) => e.endsWith("/"));
12615
+ const underInclude = (p) => !p.includes("/") ? include.includes(p) : includeDirs.some((d) => p.startsWith(d));
12616
+ if (!Array.isArray(m.files) || m.files.length === 0) throw invalidPackage("files", "files \u8981\u662F\u975E\u7A7A\u6570\u7EC4\uFF08\u9010\u6587\u4EF6\u7684 path \u4E0E sha256\uFF09");
12617
+ const files = [];
12618
+ const seenFiles = /* @__PURE__ */ new Set();
12619
+ m.files.forEach((f, i) => {
12620
+ const r = f;
12621
+ if (!r || typeof r !== "object") throw invalidPackage(`files[${i}]`, "\u4E0D\u662F\u5BF9\u8C61");
12622
+ if (typeof r.path !== "string" || !isSafeRelative(r.path)) throw invalidPackage(`files[${i}].path`, `\u4E0D\u662F\u5B89\u5168\u7684\u5305\u5185\u76F8\u5BF9\u8DEF\u5F84\uFF1A${JSON.stringify(r.path)}`);
12623
+ if (!underInclude(r.path)) throw invalidPackage(`files[${i}].path`, `${r.path} \u4E0D\u5728 include \u7684\u8303\u56F4\u91CC\uFF0C\u88C5\u7684\u65F6\u5019\u4E0D\u4F1A\u88AB\u53D6\u4E0B\u6765`);
12624
+ if (typeof r.sha256 !== "string" || !/^[0-9a-f]{64}$/.test(r.sha256)) throw invalidPackage(`files[${i}].sha256`, `${r.path} \u7684 sha256 \u4E0D\u662F 64 \u4F4D\u5C0F\u5199\u5341\u516D\u8FDB\u5236`);
12625
+ if (r.size !== void 0 && (typeof r.size !== "number" || r.size < 0)) throw invalidPackage(`files[${i}].size`, `${r.path} \u7684 size \u4E0D\u662F\u975E\u8D1F\u6570`);
12626
+ if (seenFiles.has(r.path)) throw invalidPackage(`files[${i}].path`, `${r.path} \u767B\u8BB0\u4E86\u4E24\u6B21`);
12627
+ seenFiles.add(r.path);
12628
+ files.push({ path: r.path, sha256: r.sha256, size: r.size, mediaType: typeof r.mediaType === "string" ? r.mediaType : void 0 });
12629
+ });
12630
+ if (!Array.isArray(m.skills) || m.skills.length === 0) throw invalidPackage("skills", "skills \u8981\u662F\u975E\u7A7A\u6570\u7EC4");
12631
+ const skills2 = [];
12632
+ const seenIds = /* @__PURE__ */ new Set();
12633
+ m.skills.forEach((s, i) => {
12634
+ const r = s;
12635
+ if (!r || typeof r !== "object") throw invalidPackage(`skills[${i}]`, "\u4E0D\u662F\u5BF9\u8C61");
12636
+ if (typeof r.id !== "string") throw invalidPackage(`skills[${i}].id`, "\u7F3A id");
12637
+ try {
12638
+ assertSafeSkillId2(r.id);
12639
+ } catch {
12640
+ throw invalidPackage(`skills[${i}].id`, `id \u53EA\u80FD\u662F\u5C0F\u5199\u5B57\u6BCD/\u6570\u5B57/\u8FDE\u5B57\u7B26\uFF1A${r.id}`);
12641
+ }
12642
+ if (!r.id.startsWith(METHOD_SKILL_PREFIX)) {
12643
+ throw invalidPackage(`skills[${i}].id`, `\u65B9\u6CD5\u6280\u80FD\u7684 id \u5FC5\u987B\u4EE5 ${METHOD_SKILL_PREFIX} \u5F00\u5934\uFF08\u524D\u7F00\u4FDD\u7559\u7ED9\u65B9\u6CD5\u6765\u6E90\uFF0C\u9632\u6B62\u906E\u853D\u4EA7\u54C1\u6280\u80FD\uFF09\uFF1A${r.id}`);
12644
+ }
12645
+ if (seenIds.has(r.id)) throw invalidPackage(`skills[${i}].id`, `${r.id} \u767B\u8BB0\u4E86\u4E24\u6B21`);
12646
+ seenIds.add(r.id);
12647
+ if (typeof r.title !== "string" || !r.title.trim()) throw invalidPackage(`skills[${i}].title`, `${r.id} \u7F3A title`);
12648
+ if (!isStringArray(r.phases) || r.phases.length === 0) throw invalidPackage(`skills[${i}].phases`, `${r.id} \u7684 phases \u8981\u662F\u975E\u7A7A\u6570\u7EC4`);
12649
+ r.phases.forEach((p, j) => {
12650
+ if (!METHOD_PHASES.includes(p)) {
12651
+ throw invalidPackage(`skills[${i}].phases[${j}]`, `${r.id} \u7684\u9636\u6BB5\u300C${p}\u300D\u4E0D\u5728\u95ED\u96C6\u91CC\uFF08${METHOD_PHASES.join(" / ")}\uFF09`);
12652
+ }
12653
+ });
12654
+ if (r.gates !== void 0 && !isStringArray(r.gates)) throw invalidPackage(`skills[${i}].gates`, `${r.id} \u7684 gates \u8981\u662F\u5B57\u7B26\u4E32\u6570\u7EC4`);
12655
+ if (r.packs !== void 0 && !isStringArray(r.packs)) throw invalidPackage(`skills[${i}].packs`, `${r.id} \u7684 packs \u8981\u662F\u5B57\u7B26\u4E32\u6570\u7EC4`);
12656
+ if (typeof r.path !== "string" || !isSafeRelative(r.path) || !r.path.endsWith(`/${r.id}/SKILL.md`)) {
12657
+ throw invalidPackage(`skills[${i}].path`, `${r.id} \u7684 path \u8981\u662F <\u76EE\u5F55>/${r.id}/SKILL.md\uFF0C\u6536\u5230 ${JSON.stringify(r.path)}`);
12658
+ }
12659
+ if (!seenFiles.has(r.path)) throw invalidPackage(`skills[${i}].path`, `${r.path} \u6CA1\u5728 files \u91CC\u767B\u8BB0\u6458\u8981`);
12660
+ skills2.push({ id: r.id, title: r.title.trim(), phases: r.phases, gates: r.gates, packs: r.packs, path: r.path });
12661
+ });
12662
+ const snap = m.productSkillSnapshot;
12663
+ return {
12664
+ schemaVersion: m.schemaVersion,
12665
+ name: m.name.trim(),
12666
+ version: m.version,
12667
+ components,
12668
+ include,
12669
+ productSkillSnapshot: snap && typeof snap === "object" ? { commit: typeof snap.commit === "string" ? snap.commit : void 0, count: typeof snap.count === "number" ? snap.count : void 0 } : void 0,
12670
+ skills: skills2,
12671
+ files
12672
+ };
12673
+ }
12674
+ async function sha256File(file) {
12675
+ return createHash6("sha256").update(await fsp4.readFile(file)).digest("hex");
12676
+ }
12677
+ async function verifyDigests(entries, resolve3) {
12678
+ const out = { files: entries.length, mismatched: [], missing: [] };
12679
+ for (const f of entries) {
12680
+ const abs = resolve3(f.path);
12681
+ if (!existsSync3(abs)) {
12682
+ out.missing.push(f.path);
12683
+ continue;
12684
+ }
12685
+ if (await sha256File(abs) !== f.sha256) out.mismatched.push(f.path);
12686
+ }
12687
+ return out;
12688
+ }
12689
+ async function listFilesUnder(root, rel) {
12690
+ const out = { files: [], links: [] };
12691
+ const walk = async (dirRel) => {
12692
+ let items;
12693
+ try {
12694
+ items = await fsp4.readdir(path11.join(root, dirRel), { withFileTypes: true });
12695
+ } catch {
12696
+ return;
12697
+ }
12698
+ for (const it of items) {
12699
+ const r = `${dirRel}/${it.name}`;
12700
+ if (it.isSymbolicLink()) out.links.push(r);
12701
+ else if (it.isDirectory()) await walk(r);
12702
+ else if (it.isFile()) out.files.push(r);
12703
+ }
12704
+ };
12705
+ await walk(rel);
12706
+ return out;
12707
+ }
12708
+ var naming = (list, max = 8) => list.slice(0, max).join("\u3001") + (list.length > max ? ` \u7B49 ${list.length} \u4EFD` : "");
12709
+ var BLOCK_LABEL = {
12710
+ "cli-bundled": "CLI \u81EA\u5E26",
12711
+ "project-installed": "\u672C\u9879\u76EE\u5DF2\u88C5\u7684\u4EA7\u54C1\u6280\u80FD",
12712
+ "online-catalog": "\u5728\u7EBF\u4EA7\u54C1\u76EE\u5F55"
12713
+ };
12714
+ var PROJECT_SKILL_STATE_FILES = [
12715
+ path11.join(SKILLS_DIR, SKILLS_SYNC_SUBDIR, SKILLS_STATE_FILE),
12716
+ path11.join(SKILLS_DIR, SKILLS_STATE_FILE),
12717
+ path11.join(".claude", "skills", SKILLS_STATE_FILE)
12718
+ ];
12719
+ async function onlineTargetFor(root) {
12720
+ try {
12721
+ const found = await discoverProjectEnv6(root);
12722
+ if (!found) return { reason: "\u6CA1\u6709 env.yaml\uFF0C\u4E0D\u77E5\u9053\u8BE5\u6BD4\u5BF9\u54EA\u4E2A\u73AF\u5883\u7684\u5728\u7EBF\u76EE\u5F55" };
12723
+ const name = found.config.default;
12724
+ const env2 = found.config.environments[name];
12725
+ if (!env2) return { reason: `env.yaml \u7684\u9ED8\u8BA4\u73AF\u5883 ${name} \u6CA1\u6709\u58F0\u660E` };
12726
+ return { endpoint: env2.endpoint, envName: name };
12727
+ } catch (e) {
12728
+ return { reason: `env.yaml \u8BFB\u4E0D\u61C2\uFF08${e.message.split("\n")[0]}\uFF09` };
12729
+ }
12730
+ }
12731
+ async function checkMethodConflicts(methodIds, root, online, deps) {
12732
+ const wanted = new Set(methodIds);
12733
+ const blocks = [];
12734
+ {
12735
+ const b = { block: "cli-bundled", label: BLOCK_LABEL["cli-bundled"], checked: false, compared: [], conflicts: [] };
12736
+ try {
12737
+ const bundled = deps.listBundled();
12738
+ if (bundled.ids.length === 0) {
12739
+ b.note = `\u8FD9\u4EFD CLI \u7684\u81EA\u5E26\u6280\u80FD\u6E05\u5355\u662F\u7A7A\u7684\uFF08\u627E\u7684\u4F4D\u7F6E\uFF1A${bundled.dir}\uFF09\uFF0C\u7A7A\u96C6\u5408\u4E0A\u6BD4\u4E0D\u51FA\u300C\u65E0\u540C\u540D\u300D\uFF0CCLI \u81EA\u5E26\u4FA7\u672A\u6BD4\u5BF9`;
12740
+ } else {
12741
+ b.checked = true;
12742
+ b.source = `@hcmai/cli@${bundled.version}`;
12743
+ b.compared = [...bundled.ids].sort();
12744
+ b.conflicts = b.compared.filter((id) => wanted.has(id)).map((id) => ({ id, other: `CLI \u81EA\u5E26 @hcmai/cli@${bundled.version}` }));
12745
+ }
12746
+ } catch (e) {
12747
+ b.note = `\u8BFB\u4E0D\u5230\u8FD9\u4EFD CLI \u7684\u81EA\u5E26\u6280\u80FD\u6E05\u5355\uFF08${e.message.split("\n")[0]}\uFF09\uFF0CCLI \u81EA\u5E26\u4FA7\u672A\u6BD4\u5BF9`;
12748
+ }
12749
+ blocks.push(b);
12750
+ }
12751
+ {
12752
+ const b = { block: "project-installed", label: BLOCK_LABEL["project-installed"], checked: false, compared: [], conflicts: [] };
12753
+ const found = [];
12754
+ const unreadable = [];
12755
+ const owners = /* @__PURE__ */ new Map();
12756
+ for (const rel of PROJECT_SKILL_STATE_FILES) {
12757
+ const file = path11.join(root, rel);
12758
+ if (!existsSync3(file)) continue;
12759
+ found.push(rel);
12760
+ try {
12761
+ const state = JSON.parse(await fsp4.readFile(file, "utf8"));
12762
+ for (const [id, rec] of Object.entries(state.skills ?? {})) {
12763
+ if (!owners.has(id)) {
12764
+ const from = rec?.sourceKind === "cli" ? "CLI \u81EA\u5E26" : rec?.sourceKind === "local" ? "\u672C\u5730\u76EE\u5F55" : `\u4EA7\u54C1 ${state.endpoint ?? "\uFF08\u672A\u8BB0\u73AF\u5883\uFF09"}`;
12765
+ owners.set(id, `\u672C\u9879\u76EE\u5DF2\u88C5\uFF08${rel.split(path11.sep).join("/")}\uFF0C\u6765\u6E90 ${from}\uFF09`);
12766
+ }
12767
+ }
12768
+ } catch (e) {
12769
+ unreadable.push(`${rel.split(path11.sep).join("/")}\uFF08${e.message.split("\n")[0]}\uFF09`);
12770
+ }
12771
+ }
12772
+ if (found.length === 0) {
12773
+ b.note = "\u672C\u9879\u76EE\u8FD8\u6CA1\u88C5\u4EA7\u54C1\u6280\u80FD\uFF0C\u4EA7\u54C1\u4FA7\u672A\u6BD4\u5BF9";
12774
+ } else if (owners.size === 0) {
12775
+ b.note = unreadable.length ? `\u5B89\u88C5\u6E05\u5355\u8BFB\u4E0D\u61C2\uFF1A${unreadable.join("\uFF1B")}\uFF0C\u4EA7\u54C1\u4FA7\u672A\u6BD4\u5BF9` : `\u5B89\u88C5\u6E05\u5355\u5728\uFF08${found.map((f) => f.split(path11.sep).join("/")).join("\u3001")}\uFF09\uFF0C\u4F46\u4E00\u6761\u8BB0\u5F55\u90FD\u6CA1\u6709\uFF0C\u7A7A\u96C6\u5408\u4E0A\u6BD4\u4E0D\u51FA\u300C\u65E0\u540C\u540D\u300D\uFF0C\u4EA7\u54C1\u4FA7\u672A\u6BD4\u5BF9`;
12776
+ } else {
12777
+ b.checked = true;
12778
+ b.source = found.map((f) => f.split(path11.sep).join("/")).join("\u3001");
12779
+ b.compared = [...owners.keys()].sort();
12780
+ b.conflicts = b.compared.filter((id) => wanted.has(id)).map((id) => ({ id, other: owners.get(id) }));
12781
+ if (unreadable.length) b.note = `\u53E6\u6709\u6E05\u5355\u8BFB\u4E0D\u61C2\u3001\u6CA1\u7B97\u8FDB\u6765\uFF1A${unreadable.join("\uFF1B")}`;
12782
+ }
12783
+ blocks.push(b);
12784
+ }
12785
+ {
12786
+ const b = { block: "online-catalog", label: BLOCK_LABEL["online-catalog"], checked: false, compared: [], conflicts: [] };
12787
+ if (!online.endpoint) {
12788
+ b.note = online.reason ?? "\u6CA1\u6709\u53EF\u6BD4\u5BF9\u7684\u73AF\u5883";
12789
+ } else {
12790
+ try {
12791
+ const ids = await deps.fetchOnlineCatalog(online.endpoint);
12792
+ if (ids.length === 0) {
12793
+ b.note = `${online.endpoint} \u7684\u5728\u7EBF\u76EE\u5F55\u662F\u7A7A\u7684\uFF0C\u7A7A\u96C6\u5408\u4E0A\u6BD4\u4E0D\u51FA\u300C\u65E0\u540C\u540D\u300D\uFF0C\u5728\u7EBF\u76EE\u5F55\u672A\u6BD4\u5BF9`;
12794
+ } else {
12795
+ const where = `${online.envName ?? "\u73AF\u5883"}\uFF08${online.endpoint}\uFF09\u7684\u5728\u7EBF\u76EE\u5F55`;
12796
+ b.checked = true;
12797
+ b.source = where;
12798
+ b.compared = [...new Set(ids)].sort();
12799
+ b.conflicts = b.compared.filter((id) => wanted.has(id)).map((id) => ({ id, other: where }));
12800
+ }
12801
+ } catch (e) {
12802
+ b.note = `\u53D6\u4E0D\u5230 ${online.endpoint} \u7684\u5728\u7EBF\u76EE\u5F55\uFF08${e.message.split("\n")[0]}\uFF09\uFF0C\u5728\u7EBF\u76EE\u5F55\u672A\u6BD4\u5BF9`;
12803
+ }
12804
+ }
12805
+ blocks.push(b);
12806
+ }
12807
+ return blocks;
12808
+ }
12809
+ function renderConflictBlocks(blocks) {
12810
+ const lines = blocks.map((b) => {
12811
+ const head = `${b.label}${b.source ? `\uFF08${b.source}\uFF09` : ""}`;
12812
+ if (!b.checked) return ` \xB7 ${head}\uFF1A\u672A\u6BD4\u5BF9 \u2014\u2014 ${b.note ?? "\u539F\u56E0\u672A\u77E5"}`;
12813
+ const tail = b.note ? `\uFF1B${b.note}` : "";
12814
+ return b.conflicts.length ? ` \xB7 ${head}\uFF1A\u540C\u540D ${b.conflicts.map((c) => c.id).join("\u3001")}${tail}` : ` \xB7 ${head}\uFF1A\u5DF2\u6BD4\u5BF9 ${b.compared.length} \u4E2A id\uFF0C\u65E0\u540C\u540D${tail}`;
12815
+ });
12816
+ const unchecked = blocks.filter((b) => !b.checked).length;
12817
+ lines.push(
12818
+ unchecked === 0 ? " \u4E09\u5757\u90FD\u6BD4\u5BF9\u8FC7\u3002" : ` ${unchecked} \u5757\u6CA1\u6BD4\u5BF9\uFF08\u539F\u56E0\u89C1\u4E0A\uFF09\uFF0C\u8FD9\u51E0\u5757\u4E0A\u4E0D\u80FD\u8BF4\u300C\u65E0\u51B2\u7A81\u300D\u3002`
12819
+ );
12820
+ return lines;
12821
+ }
12822
+ function conflictError(blocks, pkg, commit) {
12823
+ const hits = blocks.flatMap((b) => b.conflicts);
12824
+ return new CliError27({
12825
+ code: CliErrorCode29.SKILL_ID_CONFLICT,
12826
+ message: "\u65B9\u6CD5\u5305\u91CC\u7684\u6280\u80FD id \u4E0E\u5DF2\u6709\u6765\u6E90\u540C\u540D\uFF0C\u62D2\u88C5\uFF1A\n" + hits.map((c) => ` \xB7 \`${c.id}\`\uFF1A\u65B9\u6CD5 ${pkg.version} @${commit.slice(0, 12)} \u2194 ${c.other}`).join("\n") + "\n\u672C\u8D9F\u51B2\u7A81\u68C0\u67E5\uFF1A\n" + renderConflictBlocks(blocks).join("\n"),
12827
+ context: {
12828
+ nextStep: `\u62A5\u65B9\u6CD5\u8D1F\u8D23\u4EBA\u6539\u540D\u3002\`${METHOD_SKILL_PREFIX}\` \u524D\u7F00\u53EA\u7ED9\u65B9\u6CD5\u6765\u6E90\uFF0C\u7EA6\u5B9A\u751F\u6548\u65F6\u4E0D\u8BE5\u649E\u540D\uFF1B\u649E\u4E86\u8BF4\u660E\u6709\u4E00\u8FB9\u8FDD\u53CD\u4E86\u524D\u7F00\u7EA6\u5B9A\u3002\u5DF2\u88C5\u7684\u65B9\u6CD5\u5305\uFF08\u5982\u6709\uFF09\u4FDD\u6301\u539F\u6837\uFF0C\u6CA1\u52A8`,
12829
+ conflictCheck: blocks
12830
+ }
12831
+ });
12832
+ }
12833
+ function upsertManagedBlock(existing, begin, end, block, label) {
12834
+ if (existing === null || existing === "") return `${block}
12835
+ `;
12836
+ const start = existing.indexOf(begin);
12837
+ const finish2 = existing.indexOf(end);
12838
+ const malformed = start < 0 !== finish2 < 0 || start >= 0 && (finish2 < start || existing.lastIndexOf(begin) !== start || existing.lastIndexOf(end) !== finish2);
12839
+ if (malformed) {
12840
+ throw new CliError27({
12841
+ code: CliErrorCode29.METHOD_MANAGED_BLOCK_CORRUPT,
12842
+ message: `${label} \u91CC\u65B9\u6CD5\u53D7\u7BA1\u5757\u7684\u6807\u8BB0\u635F\u574F\u6216\u91CD\u590D\uFF08${begin} \u2026 ${end}\uFF09\uFF0C\u62D2\u7EDD\u8986\u76D6`,
12843
+ context: { nextStep: `\u624B\u5DE5\u628A ${label} \u91CC\u8FD9\u4E24\u884C\u6807\u8BB0\u4FEE\u6210\u5404\u51FA\u73B0\u4E00\u6B21\u3001begin \u5728\u524D\uFF08\u6216\u8FDE\u540C\u4E2D\u95F4\u5185\u5BB9\u6574\u6BB5\u5220\u6389\uFF09\uFF0C\u518D\u91CD\u8DD1` }
12844
+ });
12845
+ }
12846
+ if (start >= 0) return existing.slice(0, start) + block + existing.slice(finish2 + end.length);
12847
+ return `${existing}${existing.endsWith("\n") ? "" : "\n"}${block}
12848
+ `;
12849
+ }
12850
+ async function readTextOrNull(file) {
12851
+ return fsp4.readFile(file, "utf8").catch((e) => {
12852
+ if (e.code === "ENOENT") return null;
12853
+ throw e;
12854
+ });
12855
+ }
12856
+ async function preflightManaged(files) {
12857
+ for (const f of files) upsertManagedBlock(await readTextOrNull(f.file), f.begin, f.end, `${f.begin}
12858
+ ${f.end}`, f.label);
12859
+ }
12860
+ async function writeManaged(file, begin, end, block, label) {
12861
+ const existing = await readTextOrNull(file);
12862
+ const next = upsertManagedBlock(existing, begin, end, block, label);
12863
+ if (next === existing) return "unchanged";
12864
+ await fsp4.writeFile(file, next, "utf8");
12865
+ return existing === null ? "created" : "updated";
12866
+ }
12867
+ function renderGitignoreBlock() {
12868
+ return [
12869
+ `${GITIGNORE_BEGIN}\uFF08\u7531 hcm chiron method install \u7EF4\u62A4\uFF0C\u52FF\u624B\u5DE5\u7F16\u8F91\u672C\u5757\uFF09`,
12870
+ "# \u65B9\u6CD5\u5305\u662F\u672C\u673A\u7F13\u5B58\uFF0C\u53EA\u63D0\u4EA4\u9501\u6587\u4EF6\uFF1BClaude \u76EE\u6807\u4E0B\u590D\u5236\u51FA\u6765\u7684\u65B9\u6CD5\u6280\u80FD\u4E5F\u4E0D\u5165\u5E93",
12871
+ ...GITIGNORE_RULES,
12872
+ GITIGNORE_END
12873
+ ].join("\n");
12874
+ }
12875
+ function renderMethodAgentsBlock(lock, entries) {
12876
+ const lines = [
12877
+ AGENTS_METHOD_BEGIN,
12878
+ `## \u5B9E\u65BD\u65B9\u6CD5\u6280\u80FD\uFF08\u65B9\u6CD5 ${lock.package.version} \xB7 ${lock.ref} @ ${lock.commit.slice(0, 12)}\uFF1B\u7531 \`hcm chiron method install\` \u7EF4\u62A4\uFF0C\u52FF\u624B\u5DE5\u7F16\u8F91\u672C\u5757\uFF09`,
12879
+ "",
12880
+ "\u65B9\u6CD5\u56DE\u7B54\u300C\u5B9E\u65BD\u8BE5\u600E\u4E48\u7EC4\u7EC7\u300D\uFF1A\u9636\u6BB5\u3001\u8D28\u91CF\u95E8\u3001\u4E13\u9898\u5DE5\u4F5C\u574A\u3002\u4EA7\u54C1\u600E\u4E48\u64CD\u4F5C\u4ECD\u4EE5\u4EA7\u54C1\u6280\u80FD\u4E3A\u51C6\u3002",
12881
+ `\u65B9\u6CD5\u5305\u662F\u672C\u673A\u7F13\u5B58\u3001\u4E0D\u5165\u5E93\uFF0C\u4ED3\u91CC\u53EA\u63D0\u4EA4 \`${METHOD_DIR}/${METHOD_LOCK_FILE}\`\u3002\u4E0B\u9762\u7684\u6587\u4EF6\u4E0D\u5B58\u5728\uFF0C\u8BF4\u660E\u8FD9\u53F0\u673A\u5668\u8FD8\u6CA1\u88C5\uFF1A`,
12882
+ "\u6709\u77E5\u8BC6\u7EC4\u7EC7\u6388\u6743\u5C31\u8DD1 `hcm chiron method install`\uFF08\u6309\u9501\u6587\u4EF6\u7248\u672C\u88C5\uFF09\uFF1B\u6CA1\u6709\u6388\u6743\u5C31\u8DF3\u8FC7\u8FD9\u4E00\u7EC4\u3002",
12883
+ ""
12884
+ ];
12885
+ for (const e of entries) {
12886
+ lines.push(`- \`${e.relativePath}\` \u2014 **${e.title}**\uFF08\u9636\u6BB5\uFF1A${e.phases.join(" / ")}\uFF09`);
12887
+ lines.push(e.description ? ` ${e.description}` : " \uFF08\u67E5\u4E0D\u5230\u63CF\u8FF0\uFF1A\u8FD9\u4EFD SKILL.md \u7684 frontmatter \u6CA1\u7ED9 description\u3002\u8981\u7528\u5B83\u5C31\u5148\u6253\u5F00\u8BFB\u4E00\u773C\u3002\uFF09");
12888
+ }
12889
+ lines.push("", AGENTS_METHOD_END);
12890
+ return lines.join("\n");
12891
+ }
12892
+ function renderLock(lock) {
12893
+ return `${JSON.stringify(lock, null, 2)}
12894
+ `;
12895
+ }
12896
+ async function readLock(root) {
12897
+ const file = path11.join(root, METHOD_DIR, METHOD_LOCK_FILE);
12898
+ let text;
12899
+ try {
12900
+ text = await fsp4.readFile(file, "utf8");
12901
+ } catch (e) {
12902
+ if (e.code === "ENOENT") return void 0;
12903
+ throw e;
12904
+ }
12905
+ const bad = (why) => new CliError27({
12906
+ code: CliErrorCode29.METHOD_LOCK_INVALID,
12907
+ message: `\u9501\u6587\u4EF6 ${METHOD_DIR}/${METHOD_LOCK_FILE} \u8BFB\u4E0D\u61C2\uFF1A${why}`,
12908
+ context: { nextStep: "\u591A\u534A\u662F\u5408\u5E76\u51B2\u7A81\u7559\u4E0B\u7684\u6807\u8BB0\uFF1A\u6309\u9879\u76EE PR \u91CC\u60F3\u8981\u7684\u90A3\u4E00\u7248\u89E3\u51B3\u51B2\u7A81\uFF08\u6216 `git checkout` \u56DE\u4E0A\u4E00\u7248\uFF09\uFF0C\u518D\u8DD1 `hcm chiron method status`" }
12909
+ });
12910
+ let parsed;
12911
+ try {
12912
+ parsed = JSON.parse(text);
12913
+ } catch (e) {
12914
+ throw bad(`\u4E0D\u662F\u5408\u6CD5 JSON\uFF08${e.message}\uFF09`);
12915
+ }
12916
+ const l = parsed;
12917
+ if (l?.lockVersion !== 1) throw bad(`lockVersion \u662F ${JSON.stringify(l?.lockVersion)}\uFF0C\u8FD9\u7248 CLI \u53EA\u8BA4 1`);
12918
+ if (typeof l.ref !== "string" || typeof l.commit !== "string" || !/^[0-9a-f]{40,64}$/.test(l.commit)) throw bad("\u7F3A ref \u6216\u5B8C\u6574 commit");
12919
+ if (!l.package || typeof l.package.version !== "string") throw bad("\u7F3A package.version");
12920
+ if (typeof l.manifestSha256 !== "string" || !Array.isArray(l.skills)) throw bad("\u7F3A manifestSha256 \u6216 skills");
12921
+ return l;
12922
+ }
12923
+ async function readState(root) {
12924
+ try {
12925
+ return JSON.parse(await fsp4.readFile(path11.join(root, METHOD_DIR, METHOD_STATE_FILE), "utf8"));
12926
+ } catch {
12927
+ return void 0;
12928
+ }
12929
+ }
12930
+ async function resolveMethodRoot(project, log) {
12931
+ if (project !== void 0) return { root: path11.resolve(project), rootSource: "--project" };
12932
+ const cwd = process.cwd();
12933
+ try {
12934
+ const found = await discoverProjectEnv6(cwd);
12935
+ if (found) return { root: path11.dirname(found.path), rootSource: "env.yaml" };
12936
+ } catch (e) {
12937
+ log(`env.yaml \u8BFB\u4E0D\u61C2\uFF08${e.message.split("\n")[0]}\uFF09\uFF0C\u4EE5\u5F53\u524D\u76EE\u5F55\u4E3A\u9879\u76EE\u6839\uFF1A${cwd}`);
12938
+ return { root: cwd, rootSource: "cwd" };
12939
+ }
12940
+ log(`\u6CA1\u627E\u5230 env.yaml\uFF0C\u4EE5\u5F53\u524D\u76EE\u5F55\u4E3A\u9879\u76EE\u6839\uFF1A${cwd}\uFF08\u65B9\u6CD5\u5305\u4E0D\u9700\u8981 HCM \u73AF\u5883\uFF1B\u8981\u6362\u76EE\u5F55\u7528 --project\uFF09`);
12941
+ return { root: cwd, rootSource: "cwd" };
12942
+ }
12943
+ async function resolveTarget(root, requested) {
12944
+ if (requested === "claude" || requested === "codex") return requested;
12945
+ if (requested !== void 0 && requested !== "auto") {
12946
+ throw new CliError27({ code: CliErrorCode29.INVALID_ARGUMENT, message: `--target \u53EA\u8BA4 claude / codex / auto\uFF0C\u6536\u5230 ${requested}` });
12947
+ }
12948
+ return (await readState(root))?.target ?? await detectTarget(root) ?? "claude";
12949
+ }
12950
+ function skillFileSig(manifest2, skill) {
12951
+ const dir = `${path11.posix.dirname(skill.path)}/`;
12952
+ return manifest2.files.filter((f) => f.path.startsWith(dir)).map((f) => `${f.path}:${f.sha256}`).sort().join("\n");
12953
+ }
12954
+ async function readCriteria(dir) {
12955
+ let text;
12956
+ try {
12957
+ text = await fsp4.readFile(path11.join(dir, GATES_FILE), "utf8");
12958
+ } catch {
12959
+ return { reason: `\u6CA1\u6709 ${GATES_FILE}` };
12960
+ }
12961
+ let doc;
12962
+ try {
12963
+ doc = yaml.load(text, { schema: yaml.JSON_SCHEMA });
12964
+ } catch (e) {
12965
+ return { reason: `\u7684 ${GATES_FILE} \u4E0D\u662F\u5408\u6CD5 YAML\uFF08${e.message.split("\n")[0]}\uFF09` };
12966
+ }
12967
+ const out = /* @__PURE__ */ new Map();
12968
+ const gates = doc?.gates;
12969
+ for (const g of Array.isArray(gates) ? gates : []) {
12970
+ const criteria = g?.criteria;
12971
+ for (const c of Array.isArray(criteria) ? criteria : []) {
12972
+ const id = c?.id;
12973
+ if (typeof id === "string") out.set(id, JSON.stringify(c));
12974
+ }
12975
+ }
12976
+ if (out.size === 0) return { reason: `\u7684 ${GATES_FILE} \u91CC\u4E00\u6761\u5E26 id \u7684\u5224\u636E\u90FD\u6CA1\u8BFB\u5230\uFF08\u627E\u7684\u662F gates[].criteria[].id\uFF09` };
12977
+ return { criteria: out };
12978
+ }
12979
+ async function diffPackages(oldDir, oldManifest, newDir, newManifest) {
12980
+ const diff = {
12981
+ skills: { checked: false, added: [], removed: [], changed: [] },
12982
+ criteria: { checked: false, added: [], removed: [], changed: [] }
12983
+ };
12984
+ if (!oldManifest || !oldDir) {
12985
+ diff.skills.note = "\u672C\u673A\u6CA1\u6709\u65E7\u7248\u526F\u672C\uFF0C\u6280\u80FD\u5DEE\u5F02\u672A\u6BD4\u5BF9";
12986
+ diff.criteria.note = "\u672C\u673A\u6CA1\u6709\u65E7\u7248\u526F\u672C\uFF0C\u95E8\u5224\u636E\u5DEE\u5F02\u672A\u6BD4\u5BF9";
12987
+ return diff;
12988
+ }
12989
+ const oldSkills = new Map(oldManifest.skills.map((s) => [s.id, skillFileSig(oldManifest, s)]));
12990
+ const newSkills = new Map(newManifest.skills.map((s) => [s.id, skillFileSig(newManifest, s)]));
12991
+ diff.skills.checked = true;
12992
+ diff.skills.added = [...newSkills.keys()].filter((id) => !oldSkills.has(id)).sort();
12993
+ diff.skills.removed = [...oldSkills.keys()].filter((id) => !newSkills.has(id)).sort();
12994
+ diff.skills.changed = [...newSkills.keys()].filter((id) => oldSkills.has(id) && oldSkills.get(id) !== newSkills.get(id)).sort();
12995
+ const [oldR, newR] = await Promise.all([readCriteria(oldDir), readCriteria(newDir)]);
12996
+ if (!("criteria" in oldR) || !("criteria" in newR)) {
12997
+ const why = [!("criteria" in oldR) ? `\u65E7\u7248${oldR.reason}` : "", !("criteria" in newR) ? `\u65B0\u7248${newR.reason}` : ""].filter(Boolean);
12998
+ diff.criteria.note = `${why.join("\uFF1B")}\uFF0C\u95E8\u5224\u636E\u5DEE\u5F02\u672A\u6BD4\u5BF9`;
12999
+ } else {
13000
+ const oldC = oldR.criteria;
13001
+ const newC = newR.criteria;
13002
+ diff.criteria.checked = true;
13003
+ diff.criteria.added = [...newC.keys()].filter((id) => !oldC.has(id)).sort();
13004
+ diff.criteria.removed = [...oldC.keys()].filter((id) => !newC.has(id)).sort();
13005
+ diff.criteria.changed = [...newC.keys()].filter((id) => oldC.has(id) && oldC.get(id) !== newC.get(id)).sort();
13006
+ }
13007
+ return diff;
13008
+ }
13009
+ function renderDiff(diff) {
13010
+ const part = (label, d) => d.checked ? `${label}\uFF1A\u65B0\u589E ${d.added.length ? d.added.join("\u3001") : "\u65E0"}\uFF1B\u5220\u9664 ${d.removed.length ? d.removed.join("\u3001") : "\u65E0"}\uFF1B\u6539\u52A8 ${d.changed.length ? d.changed.join("\u3001") : "\u65E0"}` : `${label}\uFF1A\u672A\u6BD4\u5BF9 \u2014\u2014 ${d.note}`;
13011
+ return [part("\u6280\u80FD", diff.skills), part("\u95E8\u5224\u636E", diff.criteria)];
13012
+ }
13013
+ var STEPS = 7;
13014
+ async function step(deps, n, label, fn) {
13015
+ deps.log(`\u65B9\u6CD5\u5305 ${n}/${STEPS} ${label} \u2026`);
13016
+ try {
13017
+ return await fn();
13018
+ } catch (e) {
13019
+ deps.log(`\u65B9\u6CD5\u5305\u505C\u5728\u7B2C ${n}/${STEPS} \u6B65\uFF08${label}\uFF09`);
13020
+ throw e;
13021
+ }
13022
+ }
13023
+ async function readInstalledManifest(root) {
13024
+ try {
13025
+ const text = await fsp4.readFile(path11.join(root, METHOD_DIR, "package.yml"), "utf8");
13026
+ return { text, manifest: parsePackageManifest(text) };
13027
+ } catch {
13028
+ return void 0;
13029
+ }
13030
+ }
13031
+ var sha256Text = (t) => createHash6("sha256").update(t, "utf8").digest("hex");
13032
+ async function hasClaudeCopies(root) {
13033
+ try {
13034
+ return (await fsp4.readdir(path11.join(root, ".claude", "skills"), { withFileTypes: true })).some((it) => it.isDirectory() && it.name.startsWith(METHOD_SKILL_PREFIX));
13035
+ } catch {
13036
+ return false;
13037
+ }
13038
+ }
13039
+ function codexAgentFiles(root) {
13040
+ const files = [path11.join(root, "AGENTS.md")];
13041
+ if (existsSync3(path11.join(root, "CLAUDE.md"))) files.push(path11.join(root, "CLAUDE.md"));
13042
+ return files;
13043
+ }
13044
+ async function installClaudeCopies(root, manifest2) {
13045
+ const skillsRoot = path11.join(root, ".claude", "skills");
13046
+ await fsp4.mkdir(skillsRoot, { recursive: true });
13047
+ const ids = new Set(manifest2.skills.map((s) => s.id));
13048
+ const written = [];
13049
+ for (const s of manifest2.skills) {
13050
+ const dst = path11.join(skillsRoot, s.id);
13051
+ await fsp4.rm(dst, { recursive: true, force: true });
13052
+ await fsp4.cp(path11.join(root, METHOD_DIR, path11.dirname(s.path)), dst, { recursive: true });
13053
+ written.push(`.claude/skills/${s.id}/`);
13054
+ }
13055
+ const pruned = [];
13056
+ for (const it of await fsp4.readdir(skillsRoot, { withFileTypes: true })) {
13057
+ if (it.isDirectory() && it.name.startsWith(METHOD_SKILL_PREFIX) && !ids.has(it.name)) {
13058
+ await fsp4.rm(path11.join(skillsRoot, it.name), { recursive: true, force: true });
13059
+ pruned.push(`.claude/skills/${it.name}/`);
13060
+ }
13061
+ }
13062
+ return { written, pruned };
13063
+ }
13064
+ async function indexEntries(root, agentsDir, manifest2) {
13065
+ const out = [];
13066
+ for (const s of manifest2.skills) {
13067
+ const abs = path11.join(root, METHOD_DIR, s.path);
13068
+ let description = "";
13069
+ try {
13070
+ const fm = parseSkillFrontmatter3(await fsp4.readFile(abs, "utf8"), s.id);
13071
+ if (typeof fm.description === "string") description = fm.description.trim().replace(/\s+/g, " ");
13072
+ } catch {
13073
+ }
13074
+ let rel = path11.relative(agentsDir, abs).split(path11.sep).join("/");
13075
+ if (!rel.startsWith(".")) rel = `./${rel}`;
13076
+ out.push({ id: s.id, title: s.title, description, phases: s.phases, relativePath: rel });
13077
+ }
13078
+ return out;
13079
+ }
13080
+ async function runMethodPipeline(input, deps) {
13081
+ const { root } = input;
13082
+ const previousLock = await readLock(root).catch(() => void 0);
13083
+ const before = await readInstalledManifest(root);
13084
+ const resolved = await step(deps, 1, "\u89E3\u6790\u7248\u672C tag", () => {
13085
+ const tags = listRemoteTags(deps);
13086
+ const r = resolveRef(tags, input.ref, deps);
13087
+ if (input.expectCommit && r.commit !== input.expectCommit) {
13088
+ throw new CliError27({
13089
+ code: CliErrorCode29.METHOD_TAG_MOVED,
13090
+ message: `\u9501\u6587\u4EF6\u9501\u5B9A ${r.ref} @ ${input.expectCommit}\uFF0C\u800C\u8FD9\u4E2A tag \u73B0\u5728\u6307\u5411 ${r.commit}\uFF08tag \u88AB\u79FB\u52A8\u8FC7\uFF09`,
13091
+ context: { nextStep: "\u627E\u65B9\u6CD5\u8D1F\u8D23\u4EBA\u786E\u8BA4\u8FD9\u4E2A tag \u4E3A\u4EC0\u4E48\u88AB\u79FB\u52A8\u3002\u786E\u8BA4\u8981\u8DDF\u65B0\u5185\u5BB9\u5C31 `hcm chiron method update --ref <tag>`\uFF08\u9501\u6587\u4EF6\u7684\u53D8\u66F4\u8D70\u9879\u76EE PR \u8BC4\u5BA1\uFF09" }
13092
+ });
13093
+ }
13094
+ deps.log(` ${r.ref} \u2192 ${r.commit.slice(0, 12)}`);
13095
+ return r;
13096
+ });
13097
+ const work = await fsp4.mkdtemp(path11.join(os5.tmpdir(), "hcm-method-"));
13098
+ try {
13099
+ const checkout = path11.join(work, "pkg");
13100
+ const { manifest: manifest2, manifestText } = await step(deps, 2, "\u53D6\u5305\uFF08\u7A00\u758F\u6D45 clone\uFF09", async () => {
13101
+ deps.git(["clone", "--depth", "1", "--filter=blob:none", "--sparse", "--quiet", "--branch", resolved.ref, deps.repoUrl, checkout]);
13102
+ const head = deps.git(["-C", checkout, "rev-parse", "HEAD"], { timeoutMs: 1e4 }).trim();
13103
+ if (head !== resolved.commit) {
13104
+ throw new CliError27({
13105
+ code: CliErrorCode29.METHOD_TAG_MOVED,
13106
+ message: `\u89E3\u6790\u65F6 ${resolved.ref} \u6307\u5411 ${resolved.commit}\uFF0C\u53D6\u4E0B\u6765\u7684\u5374\u662F ${head}\uFF08tag \u5728\u8FD9\u51E0\u79D2\u91CC\u88AB\u79FB\u52A8\u4E86\uFF09`,
13107
+ context: { nextStep: "\u91CD\u8DD1\u4E00\u6B21\uFF1B\u518D\u51FA\u73B0\u5C31\u627E\u65B9\u6CD5\u8D1F\u8D23\u4EBA\u786E\u8BA4\u8FD9\u4E2A tag \u4E3A\u4EC0\u4E48\u5728\u52A8" }
13108
+ });
13109
+ }
13110
+ let text;
13111
+ try {
13112
+ text = await fsp4.readFile(path11.join(checkout, "package.yml"), "utf8");
13113
+ } catch {
13114
+ throw invalidPackage("package.yml", `${resolved.ref} \u7684\u6839\u76EE\u5F55\u6CA1\u6709 package.yml\uFF08\u8FD9\u4E2A tag \u4E0D\u662F\u6309\u65B9\u6CD5\u5305\u6253\u7684\uFF09`);
13115
+ }
13116
+ const parsed = parsePackageManifest(text);
13117
+ const dirs = parsed.include.filter((e) => e.endsWith("/")).map((e) => e.slice(0, -1));
13118
+ if (dirs.length) deps.git(["-C", checkout, "sparse-checkout", "set", ...dirs]);
13119
+ return { manifest: parsed, manifestText: text };
13120
+ });
13121
+ const unlisted = await step(deps, 3, "\u6821\u9A8C\u6E05\u5355\u4E0E\u6458\u8981", async () => {
13122
+ for (const [i, entry] of manifest2.include.entries()) {
13123
+ if (!existsSync3(path11.join(checkout, entry.replace(/\/$/, "")))) {
13124
+ throw invalidPackage(`include[${i}]`, `include \u767B\u8BB0\u4E86 ${entry}\uFF0C\u4F46 ${resolved.ref} \u91CC\u6CA1\u6709\u5B83`);
13125
+ }
13126
+ }
13127
+ const check = await verifyDigests(manifest2.files, (p) => path11.join(checkout, p));
13128
+ if (check.missing.length) {
13129
+ throw invalidPackage("files", `\u6E05\u5355\u767B\u8BB0\u4E86\u3001\u5305\u91CC\u5374\u6CA1\u6709\uFF1A${naming(check.missing)}`);
13130
+ }
13131
+ if (check.mismatched.length) {
13132
+ throw invalidPackage("files", `\u521A\u4ECE ${resolved.ref} @ ${resolved.commit.slice(0, 12)} \u53D6\u4E0B\u6765\u5C31\u4E0E\u6E05\u5355\u6458\u8981\u5BF9\u4E0D\u4E0A\uFF08\u591A\u534A\u662F\u751F\u6210\u6E05\u5355\u540E\u53C8\u6539\u4E86\u6587\u4EF6\uFF09\uFF1A${naming(check.mismatched)}`);
13133
+ }
13134
+ const listed = new Set(manifest2.files.map((f) => f.path.normalize("NFC")));
13135
+ const walked = await Promise.all(manifest2.include.filter((e) => e.endsWith("/")).map((d) => listFilesUnder(checkout, d.slice(0, -1))));
13136
+ const links = walked.flatMap((w) => w.links);
13137
+ if (links.length) throw invalidPackage("files", `\u5305\u91CC\u6709\u7B26\u53F7\u94FE\u63A5\uFF1A${naming(links)}`);
13138
+ const extra = walked.flatMap((w) => w.files).filter((p) => !listed.has(p.normalize("NFC"))).sort();
13139
+ deps.log(` ${check.files} \u4EFD\u6587\u4EF6\u6458\u8981\u5168\u90E8\u5BF9\u4E0A${extra.length ? `\uFF1B\u53E6\u6709 ${extra.length} \u4EFD\u4E0D\u5728\u6E05\u5355\u91CC\u3001\u6CA1\u6838\u6458\u8981\uFF08\u7167\u6837\u88C5\u5165\uFF09` : ""}`);
13140
+ return extra;
13141
+ });
13142
+ const conflictCheck = await step(deps, 4, "\u51B2\u7A81\u68C0\u67E5\uFF08CLI \u81EA\u5E26 / \u672C\u9879\u76EE\u5DF2\u88C5 / \u5728\u7EBF\u76EE\u5F55\uFF09", async () => {
13143
+ const blocks = await checkMethodConflicts(manifest2.skills.map((s) => s.id), root, await onlineTargetFor(root), deps);
13144
+ if (blocks.some((b) => b.conflicts.length)) throw conflictError(blocks, manifest2, resolved.commit);
13145
+ for (const l of renderConflictBlocks(blocks)) deps.log(l);
13146
+ return blocks;
13147
+ });
13148
+ const diff = input.mode === "update" ? await diffPackages(before ? path11.join(root, METHOD_DIR) : void 0, before?.manifest, checkout, manifest2) : void 0;
13149
+ if (diff) for (const l of renderDiff(diff)) deps.log(` ${l}`);
13150
+ const lock = {
13151
+ lockVersion: 1,
13152
+ repo: deps.repoDisplay,
13153
+ ref: resolved.ref,
13154
+ commit: resolved.commit,
13155
+ package: { name: manifest2.name, version: manifest2.version, schemaVersion: manifest2.schemaVersion, components: manifest2.components },
13156
+ manifestSha256: sha256Text(manifestText),
13157
+ skills: manifest2.skills.map((s) => s.id)
13158
+ };
13159
+ const nowIso = deps.now().toISOString();
13160
+ const gitignorePath = path11.join(root, ".gitignore");
13161
+ const agentTargets = input.target === "codex" ? codexAgentFiles(root) : [];
13162
+ const gitignore = await step(deps, 5, "\u9884\u68C0\u53D7\u7BA1\u5757\u5E76\u7EF4\u62A4 .gitignore", async () => {
13163
+ await preflightManaged([
13164
+ { file: gitignorePath, begin: GITIGNORE_BEGIN, end: GITIGNORE_END, label: ".gitignore" },
13165
+ ...agentTargets.map((file) => ({ file, begin: AGENTS_METHOD_BEGIN, end: AGENTS_METHOD_END, label: path11.basename(file) }))
13166
+ ]);
13167
+ return writeManaged(gitignorePath, GITIGNORE_BEGIN, GITIGNORE_END, renderGitignoreBlock(), ".gitignore");
13168
+ });
13169
+ await step(deps, 6, `\u66FF\u6362 ${METHOD_DIR}/ \u5E76\u5199\u9501\u6587\u4EF6`, async () => {
13170
+ const targetDir = path11.join(root, METHOD_DIR);
13171
+ const staging = path11.join(root, `.${METHOD_DIR}.staging-${process.pid}`);
13172
+ const old = path11.join(root, `.${METHOD_DIR}.old-${process.pid}`);
13173
+ await fsp4.rm(staging, { recursive: true, force: true });
13174
+ try {
13175
+ await fsp4.mkdir(staging, { recursive: true });
13176
+ for (const entry of manifest2.include) {
13177
+ const rel = entry.replace(/\/$/, "");
13178
+ await fsp4.cp(path11.join(checkout, rel), path11.join(staging, rel), { recursive: true });
13179
+ }
13180
+ await fsp4.writeFile(path11.join(staging, METHOD_LOCK_FILE), renderLock(lock), "utf8");
13181
+ const state = { target: input.target, installedAt: nowIso, remoteCheckedAt: nowIso };
13182
+ await fsp4.writeFile(path11.join(staging, METHOD_STATE_FILE), `${JSON.stringify(state, null, 2)}
13183
+ `, "utf8");
13184
+ const hadOld = existsSync3(targetDir);
13185
+ if (hadOld) {
13186
+ await fsp4.rm(old, { recursive: true, force: true });
13187
+ await fsp4.rename(targetDir, old);
13188
+ }
13189
+ try {
13190
+ await fsp4.rename(staging, targetDir);
13191
+ } catch (e) {
13192
+ if (hadOld) await fsp4.rename(old, targetDir);
13193
+ throw e;
13194
+ }
13195
+ if (hadOld) await fsp4.rm(old, { recursive: true, force: true });
13196
+ } finally {
13197
+ await fsp4.rm(staging, { recursive: true, force: true });
13198
+ }
13199
+ });
13200
+ const agent = await step(deps, 7, `\u66F4\u65B0 agent \u5165\u53E3\uFF08${input.target}\uFF09`, async () => {
13201
+ const files = [];
13202
+ let copies = { written: [], pruned: [] };
13203
+ const refreshCopies = input.target === "claude" || await hasClaudeCopies(root);
13204
+ if (refreshCopies) copies = await installClaudeCopies(root, manifest2);
13205
+ for (const file of agentTargets) {
13206
+ const block = renderMethodAgentsBlock(lock, await indexEntries(root, path11.dirname(file), manifest2));
13207
+ files.push({ file: path11.relative(root, file), status: await writeManaged(file, AGENTS_METHOD_BEGIN, AGENTS_METHOD_END, block, path11.basename(file)) });
13208
+ }
13209
+ return { files, copies };
13210
+ });
13211
+ const toCommit = [
13212
+ ...gitignore !== "unchanged" ? [".gitignore"] : [],
13213
+ `${METHOD_DIR}/${METHOD_LOCK_FILE}`,
13214
+ ...agent.files.filter((f) => f.status !== "unchanged").map((f) => f.file)
13215
+ ];
13216
+ return {
13217
+ ok: true,
13218
+ mode: input.mode,
13219
+ root,
13220
+ rootSource: input.rootSource,
13221
+ repo: deps.repoDisplay,
13222
+ ref: resolved.ref,
13223
+ commit: resolved.commit,
13224
+ package: { name: manifest2.name, version: manifest2.version, schemaVersion: manifest2.schemaVersion },
13225
+ skills: lock.skills,
13226
+ target: input.target,
13227
+ previous: previousLock ? { ref: previousLock.ref, commit: previousLock.commit, version: previousLock.package.version } : void 0,
13228
+ digest: { files: manifest2.files.length, unlisted },
13229
+ conflictCheck,
13230
+ diff,
13231
+ gitignore,
13232
+ agentFiles: agent.files,
13233
+ claudeCopies: agent.copies,
13234
+ toCommit
13235
+ };
13236
+ } finally {
13237
+ await fsp4.rm(work, { recursive: true, force: true });
13238
+ }
13239
+ }
13240
+ function renderInstallReport(r) {
13241
+ const out = [];
13242
+ const verb = r.mode === "update" ? "\u5DF2\u66F4\u65B0\u5230" : "\u5DF2\u88C5";
13243
+ out.push(`${verb}\u65B9\u6CD5 ${r.package.version}\uFF08${r.ref} @ ${r.commit.slice(0, 12)}\uFF09\u2192 ${path11.join(r.root, METHOD_DIR)}/`);
13244
+ if (r.previous && r.previous.commit !== r.commit) out.push(` \u9501\u6587\u4EF6\uFF1A${r.previous.ref} @ ${r.previous.commit.slice(0, 12)} \u2192 ${r.ref} @ ${r.commit.slice(0, 12)}`);
13245
+ out.push(` \u6280\u80FD ${r.skills.length} \u4EFD\uFF1A${naming(r.skills, 6)}`);
13246
+ if (r.diff) for (const l of renderDiff(r.diff)) out.push(` ${l}`);
13247
+ out.push(r.target === "claude" ? ` \u843D\u70B9\uFF08claude\uFF09\uFF1A\u590D\u5236\u5230 .claude/skills/<id>/\uFF0C\u5171 ${r.claudeCopies.written.length} \u4EFD${r.claudeCopies.pruned.length ? `\uFF1B\u6E05\u6389\u65B0\u7248\u4E0D\u518D\u53D1\u7684 ${r.claudeCopies.pruned.join("\u3001")}` : ""}\uFF08\u5DF2\u88AB .gitignore \u5FFD\u7565\uFF09` : ` \u843D\u70B9\uFF08codex\uFF09\uFF1A${r.agentFiles.map((f) => `${f.file}\uFF08${f.status}\uFF09`).join("\u3001")} \u91CC\u7684\u65B9\u6CD5\u53D7\u7BA1\u5757\uFF0C\u76F4\u63A5\u6307\u5411 ${METHOD_DIR}/skills/` + (r.claudeCopies.written.length ? `\uFF1B\u53E6\u5237\u65B0\u4E86 .claude/skills \u4E0B\u5DF2\u6709\u7684\u65B9\u6CD5\u526F\u672C ${r.claudeCopies.written.length} \u4EFD\uFF08\u8FD9\u53F0\u673A\u5668\u4E4B\u524D\u7528 claude \u76EE\u6807\u88C5\u8FC7\uFF1B\u4E0D\u518D\u7528 Claude Code \u5C31\u5220\u6389 .claude/skills/method-*/\uFF09` : ""));
13248
+ out.push(` \u6458\u8981\uFF1A${r.digest.files} \u4EFD\u6587\u4EF6\u5BF9\u4E0A\u6E05\u5355${r.digest.unlisted.length ? `\uFF1B${r.digest.unlisted.length} \u4EFD\u4E0D\u5728\u6E05\u5355\u91CC\u3001\u6CA1\u6838\u6458\u8981\uFF1A${naming(r.digest.unlisted, 3)}` : ""}`);
13249
+ out.push(" \u51B2\u7A81\u68C0\u67E5\uFF1A", ...renderConflictBlocks(r.conflictCheck).map((l) => ` ${l}`));
13250
+ out.push(` .gitignore\uFF1A${r.gitignore}`);
13251
+ out.push(`\u4E0B\u4E00\u6B65\uFF1A\u63D0\u4EA4 ${r.toCommit.join("\u3001")}\uFF08\u65B9\u6CD5\u5305\u672C\u8EAB\u662F\u672C\u673A\u7F13\u5B58\uFF0C\u4E0D\u5165\u5E93\uFF09\u3002`);
13252
+ return out.join("\n");
13253
+ }
13254
+ async function runMethodStatus(root, deps, opts = {}) {
13255
+ const report = {
13256
+ ok: false,
13257
+ root,
13258
+ lock: null,
13259
+ installed: { present: false },
13260
+ digest: { checked: false, files: 0, mismatched: [], missing: [] },
13261
+ remote: { checked: false },
13262
+ shadowed: [],
13263
+ conflictCheck: [],
13264
+ rows: []
13265
+ };
13266
+ const done = () => {
13267
+ report.ok = report.rows.every((r) => r.verdict !== "fail");
13268
+ return report;
13269
+ };
13270
+ let lock;
13271
+ try {
13272
+ lock = await readLock(root);
13273
+ } catch (e) {
13274
+ const err = e;
13275
+ report.rows.push({ item: "\u9501\u5B9A", verdict: "fail", detail: err.message, nextStep: String(err.context?.nextStep ?? ""), code: err.code });
13276
+ return done();
13277
+ }
13278
+ if (!lock) {
13279
+ report.rows.push({
13280
+ item: "\u9501\u5B9A",
13281
+ verdict: "fail",
13282
+ detail: `\u6CA1\u6709 ${METHOD_DIR}/${METHOD_LOCK_FILE}\uFF1A\u8FD9\u4E2A\u9879\u76EE\u8FD8\u6CA1\u88C5\u65B9\u6CD5\u5305`,
13283
+ nextStep: "\u6709\u77E5\u8BC6\u7EC4\u7EC7\u6388\u6743\u5C31\u8DD1 `hcm chiron method install`\uFF1B\u6CA1\u6709\u6388\u6743\u53EF\u4EE5\u8DF3\u8FC7\uFF0C\u4E0D\u5F71\u54CD\u4EA7\u54C1\u64CD\u4F5C",
13284
+ code: CliErrorCode29.METHOD_NOT_INSTALLED
13285
+ });
13286
+ return done();
13287
+ }
13288
+ report.lock = lock;
13289
+ report.rows.push({ item: "\u9501\u5B9A", verdict: "ok", detail: `\u65B9\u6CD5 ${lock.package.version} \xB7 ${lock.ref} @ ${lock.commit.slice(0, 12)}\uFF08${lock.skills.length} \u4EFD\u6280\u80FD\uFF09` });
13290
+ const state = await readState(root);
13291
+ const installed = await fsp4.readFile(path11.join(root, METHOD_DIR, "package.yml"), "utf8").catch(() => void 0);
13292
+ if (installed === void 0) {
13293
+ report.rows.push({
13294
+ item: "\u5B89\u88C5",
13295
+ verdict: "fail",
13296
+ detail: "\u9501\u6587\u4EF6\u5728\uFF0C\u4F46\u672C\u673A\u6CA1\u6709\u65B9\u6CD5\u5305\u526F\u672C\uFF08\u521A clone \u4E0B\u6765\u7684\u9879\u76EE\u4ED3\u5C31\u662F\u8FD9\u6837\uFF09",
13297
+ nextStep: "`hcm chiron method install`\uFF08\u6309\u9501\u6587\u4EF6\u7684\u7248\u672C\u88C5\uFF09",
13298
+ code: CliErrorCode29.METHOD_NOT_INSTALLED
13299
+ });
13300
+ } else {
13301
+ report.installed.present = true;
13302
+ report.installed.matchesLock = sha256Text(installed) === lock.manifestSha256;
13303
+ if (!report.installed.matchesLock) {
13304
+ report.rows.push({
13305
+ item: "\u5B89\u88C5",
13306
+ verdict: "fail",
13307
+ detail: "\u672C\u673A\u526F\u672C\u7684 package.yml \u4E0E\u9501\u6587\u4EF6\u8BB0\u7684\u6458\u8981\u4E0D\u4E00\u81F4\uFF1A\u88C5\u7684\u4E0D\u662F\u9501\u5B9A\u7684\u90A3\u4E00\u7248",
13308
+ nextStep: "`hcm chiron method install`\uFF08\u6309\u9501\u6587\u4EF6\u7684 commit \u91CD\u88C5\uFF09",
13309
+ code: CliErrorCode29.METHOD_DIGEST_MISMATCH
13310
+ });
13311
+ } else {
13312
+ report.rows.push({ item: "\u5B89\u88C5", verdict: "ok", detail: `\u672C\u673A\u526F\u672C\u5C31\u662F\u9501\u5B9A\u7684\u90A3\u4E00\u7248\uFF08${path11.join(root, METHOD_DIR)}/\uFF09` });
13313
+ let manifest2;
13314
+ try {
13315
+ manifest2 = parsePackageManifest(installed);
13316
+ } catch (e) {
13317
+ report.digest.note = `\u672C\u673A package.yml \u8BFB\u4E0D\u61C2\uFF1A${e.message}`;
13318
+ }
13319
+ if (manifest2) {
13320
+ const main2 = await verifyDigests(manifest2.files, (p) => path11.join(root, METHOD_DIR, p));
13321
+ const copyEntries = [];
13322
+ const copyMap = /* @__PURE__ */ new Map();
13323
+ for (const s of manifest2.skills) {
13324
+ const copyDir = path11.join(root, ".claude", "skills", s.id);
13325
+ if (!existsSync3(copyDir) && state?.target !== "claude") continue;
13326
+ const prefix = `${path11.posix.dirname(s.path)}/`;
13327
+ for (const f of manifest2.files.filter((x) => x.path.startsWith(prefix))) {
13328
+ const shown = `.claude/skills/${s.id}/${f.path.slice(prefix.length)}`;
13329
+ copyEntries.push({ ...f, path: shown });
13330
+ copyMap.set(shown, path11.join(root, shown));
13331
+ }
13332
+ }
13333
+ const copies = await verifyDigests(copyEntries, (p) => copyMap.get(p));
13334
+ report.digest = {
13335
+ checked: true,
13336
+ files: main2.files,
13337
+ copies: copies.files,
13338
+ mismatched: [...main2.mismatched.map((p) => `${METHOD_DIR}/${p}`), ...copies.mismatched],
13339
+ missing: [...main2.missing.map((p) => `${METHOD_DIR}/${p}`), ...copies.missing]
13340
+ };
13341
+ }
13342
+ const bad = [...report.digest.mismatched, ...report.digest.missing];
13343
+ if (!report.digest.checked) {
13344
+ report.rows.push({ item: "\u6458\u8981", verdict: "fail", detail: `\u6CA1\u6838\u6210\uFF1A${report.digest.note}`, nextStep: "`hcm chiron method install`\uFF08\u6309\u9501\u6587\u4EF6\u7684 commit \u91CD\u88C5\uFF09" });
13345
+ } else if (bad.length) {
13346
+ const listing = `${report.digest.mismatched.length ? `\u6539\u8FC7 ${naming(report.digest.mismatched)}` : ""}${report.digest.mismatched.length && report.digest.missing.length ? "\uFF1B" : ""}${report.digest.missing.length ? `\u7F3A ${naming(report.digest.missing)}` : ""}`;
13347
+ const leftover = state?.target !== void 0 && state.target !== "claude" && bad.every((p) => p.startsWith(".claude/skills/"));
13348
+ report.rows.push(leftover ? {
13349
+ item: "\u6458\u8981",
13350
+ verdict: "fail",
13351
+ detail: `${bad.length} \u4EFD .claude/skills \u65B9\u6CD5\u526F\u672C\u4E0E\u9501\u5B9A\u7248\u672C\u4E0D\u7B26\uFF08\u8FD9\u53F0\u673A\u5668\u73B0\u5728\u7684 target \u662F ${state.target}\uFF0C\u8FD9\u4E9B\u526F\u672C\u662F\u4E4B\u524D\u7528 claude \u76EE\u6807\u88C5\u65F6\u7559\u4E0B\u7684\uFF09\uFF1A${listing}`,
13352
+ nextStep: "`hcm chiron method install`\uFF08\u4F1A\u4E00\u5E76\u5237\u65B0 .claude/skills \u4E0B\u5DF2\u6709\u7684\u65B9\u6CD5\u526F\u672C\uFF09\uFF1B\u4E0D\u518D\u7528 Claude Code \u5C31\u5220\u6389 `.claude/skills/method-*/`",
13353
+ code: CliErrorCode29.METHOD_DIGEST_MISMATCH
13354
+ } : {
13355
+ item: "\u6458\u8981",
13356
+ verdict: "fail",
13357
+ detail: `${bad.length} \u4EFD\u6587\u4EF6\u4E0E\u6E05\u5355\u4E0D\u7B26\uFF1A${listing}`,
13358
+ nextStep: "`hcm chiron method install`\uFF08\u6309\u9501\u6587\u4EF6\u7684 commit \u91CD\u88C5\uFF0C\u672C\u673A\u6539\u52A8\u4F1A\u88AB\u8986\u76D6\uFF1B\u8981\u6539\u65B9\u6CD5\u5C31\u53BB\u65B9\u6CD5\u8BBA\u4ED3\u63D0\uFF09",
13359
+ code: CliErrorCode29.METHOD_DIGEST_MISMATCH
13360
+ });
13361
+ } else {
13362
+ report.rows.push({
13363
+ item: "\u6458\u8981",
13364
+ verdict: "ok",
13365
+ detail: `${report.digest.files} \u4EFD\u65B9\u6CD5\u5305\u6587\u4EF6${report.digest.copies ? ` + ${report.digest.copies} \u4EFD .claude/skills \u526F\u672C` : ""}\u4E0E\u6E05\u5355\u4E00\u81F4`
13366
+ });
13367
+ }
13368
+ }
13369
+ }
13370
+ report.remote.lastCheckedAt = state?.remoteCheckedAt;
13371
+ try {
13372
+ const tags = listRemoteTags(deps);
13373
+ report.remote.checked = true;
13374
+ report.remote.latestTag = latestVersionTag(tags);
13375
+ report.remote.lockedTagCommit = tags.get(lock.ref);
13376
+ if (report.remote.lockedTagCommit && report.remote.lockedTagCommit !== lock.commit) {
13377
+ report.rows.push({
13378
+ item: "\u65B0\u7248",
13379
+ verdict: "warn",
13380
+ detail: `tag ${lock.ref} \u73B0\u5728\u6307\u5411 ${report.remote.lockedTagCommit.slice(0, 12)}\uFF0C\u9501\u5B9A\u7684\u662F ${lock.commit.slice(0, 12)}\uFF08tag \u88AB\u79FB\u52A8\u8FC7\uFF1B\u672C\u673A\u526F\u672C\u4EE5\u9501\u5B9A\u7684 commit \u4E3A\u51C6\uFF09`,
13381
+ nextStep: "\u627E\u65B9\u6CD5\u8D1F\u8D23\u4EBA\u786E\u8BA4 tag \u4E3A\u4EC0\u4E48\u88AB\u79FB\u52A8\uFF1B\u8981\u8DDF\u65B0\u5185\u5BB9\u5C31 `hcm chiron method update --ref <tag>`",
13382
+ code: CliErrorCode29.METHOD_TAG_MOVED
13383
+ });
13384
+ } else if (!SEMVER_TAG.test(lock.ref) || !report.remote.latestTag) {
13385
+ report.remote.undetermined = !SEMVER_TAG.test(lock.ref) ? `\u9501\u5B9A\u7684 ref ${lock.ref} \u4E0D\u662F vX.Y.Z \u7248\u672C tag\uFF0C\u65E0\u6CD5\u5224\u65AD\u662F\u5426\u843D\u540E\uFF08\u8FDC\u7AEF\u6700\u65B0\u7248\u672C tag\uFF1A${report.remote.latestTag ?? "\u65E0"}\uFF09` : "\u8FDC\u7AEF\u4E00\u4E2A vX.Y.Z \u7248\u672C tag \u90FD\u6CA1\u6709\uFF0C\u65E0\u6CD5\u5224\u65AD\u662F\u5426\u843D\u540E";
13386
+ report.rows.push({
13387
+ item: "\u65B0\u7248",
13388
+ verdict: "warn",
13389
+ detail: report.remote.undetermined,
13390
+ nextStep: report.remote.latestTag ? "\u8981\u8DDF\u6B63\u5F0F\u7248\u672C\u8D70\u5C31 `hcm chiron method update`\uFF08\u6362\u5230\u6700\u65B0\u7684\u7248\u672C tag\uFF1B\u9501\u6587\u4EF6\u7684\u53D8\u66F4\u8D70\u9879\u76EE PR \u8BC4\u5BA1\uFF09" : "\u627E\u65B9\u6CD5\u8D1F\u8D23\u4EBA\u786E\u8BA4\u65B9\u6CD5\u8BBA\u4ED3\u7684\u7248\u672C tag\uFF1B\u672C\u673A\u526F\u672C\u7167\u5E38\u80FD\u7528"
13391
+ });
13392
+ } else if (compareTags(report.remote.latestTag, lock.ref) > 0) {
13393
+ report.rows.push({
13394
+ item: "\u65B0\u7248",
13395
+ verdict: "warn",
13396
+ detail: `\u6709\u65B0\u7248 ${report.remote.latestTag}\uFF08\u9501\u5B9A ${lock.ref}\uFF09`,
13397
+ nextStep: "`hcm chiron method update`\uFF08\u5148\u5217\u51FA\u5DEE\u5F02\u518D\u66FF\u6362\uFF1B\u9501\u6587\u4EF6\u7684\u53D8\u66F4\u8D70\u9879\u76EE PR \u8BC4\u5BA1\uFF09"
13398
+ });
13399
+ } else {
13400
+ report.rows.push({ item: "\u65B0\u7248", verdict: "ok", detail: `${lock.ref} \u5DF2\u662F\u6700\u65B0\u7684\u7248\u672C tag` });
13401
+ }
13402
+ } catch (e) {
13403
+ report.remote.reason = e.message.split("\n")[0];
13404
+ report.rows.push({
13405
+ item: "\u65B0\u7248",
13406
+ verdict: "warn",
13407
+ detail: `unknown\uFF1A\u65E0\u6CD5\u5224\u65AD\u6709\u6CA1\u6709\u65B0\u7248\uFF08${report.remote.reason}\uFF09\uFF1B\u4E0A\u6B21\u8054\u7F51\u6838\u5BF9 ${report.remote.lastCheckedAt ?? "\u65E0\u8BB0\u5F55"}\uFF08install / update \u65F6\uFF09`,
13408
+ nextStep: "\u8054\u7F51\u540E\u518D\u8DD1 `hcm chiron method status`\uFF1B\u5DF2\u88C5\u7684\u65B9\u6CD5\u5305\u79BB\u7EBF\u7167\u5E38\u80FD\u8BFB",
13409
+ code: e.code
13410
+ });
13411
+ }
13412
+ for (const id of lock.skills) {
13413
+ const by = path11.join(SKILLS_DIR, SKILLS_LOCAL_SUBDIR, id);
13414
+ if (existsSync3(path11.join(root, by, "SKILL.md"))) report.shadowed.push({ id, by: `${by.split(path11.sep).join("/")}/` });
13415
+ }
13416
+ report.rows.push(report.shadowed.length ? {
13417
+ item: "\u906E\u853D",
13418
+ verdict: "warn",
13419
+ detail: `${report.shadowed.map((s) => `${s.id} \u88AB ${s.by} \u906E\u4F4F`).join("\uFF1B")}\uFF08\u7D22\u5F15\u91CC\u751F\u6548\u7684\u662F local \u90A3\u4EFD\uFF09`,
13420
+ nextStep: "\u8FD9\u662F\u672C\u5730\u8986\u76D6\uFF0C\u5C5E\u8BBE\u8BA1\u884C\u4E3A\uFF1B\u8981\u7528\u65B9\u6CD5\u90A3\u4E00\u4EFD\u5C31\u5220\u6389 local \u91CC\u7684\u540C\u540D\u76EE\u5F55"
13421
+ } : { item: "\u906E\u853D", verdict: "ok", detail: `\u6CA1\u6709\u88AB ${SKILLS_DIR}/${SKILLS_LOCAL_SUBDIR}/ \u906E\u4F4F\u7684\u65B9\u6CD5\u6280\u80FD` });
13422
+ if (opts.withConflicts !== false) {
13423
+ report.conflictCheck = await checkMethodConflicts(lock.skills, root, await onlineTargetFor(root), deps);
13424
+ const hits = report.conflictCheck.flatMap((b) => b.conflicts);
13425
+ const unchecked = report.conflictCheck.filter((b) => !b.checked);
13426
+ const summary = report.conflictCheck.map((b) => b.checked ? `${b.label}\uFF1A\u5DF2\u6BD4\u5BF9 ${b.compared.length} \u4E2A${b.conflicts.length ? `\uFF0C\u540C\u540D ${b.conflicts.map((c) => c.id).join("\u3001")}` : "\uFF0C\u65E0\u540C\u540D"}` : `${b.label}\uFF1A\u672A\u6BD4\u5BF9\uFF08${b.note}\uFF09`).join("\uFF1B");
13427
+ report.rows.push(hits.length ? { item: "\u51B2\u7A81", verdict: "fail", detail: summary, nextStep: "\u62A5\u65B9\u6CD5\u8D1F\u8D23\u4EBA\u6539\u540D\uFF08method- \u524D\u7F00\u53EA\u7ED9\u65B9\u6CD5\u6765\u6E90\uFF09", code: CliErrorCode29.SKILL_ID_CONFLICT } : unchecked.length ? { item: "\u51B2\u7A81", verdict: "warn", detail: `${summary}\u2014\u2014\u6CA1\u6BD4\u5BF9\u7684\u5757\u4E0A\u4E0D\u80FD\u8BF4\u300C\u65E0\u51B2\u7A81\u300D` } : { item: "\u51B2\u7A81", verdict: "ok", detail: summary });
13428
+ }
13429
+ report.rows.push(report.remote.checked ? { item: "\u6765\u6E90", verdict: "ok", detail: `\u5728\u7EBF\uFF1Agit \u51ED\u636E\u8BA4\u8BC1\u53D6 tag\uFF0Ccommit \u56FA\u5B9A\uFF08${lock.repo}\uFF09` } : { item: "\u6765\u6E90", verdict: "warn", detail: "\u79BB\u7EBF\uFF1A\u53EA\u6838\u4E86\u672C\u673A\u526F\u672C\u7684\u6458\u8981\uFF0C\u6CA1\u4E0E\u8FDC\u7AEF\u6838\u5BF9 tag" });
13430
+ return done();
13431
+ }
13432
+ function renderMethodStatus(r) {
13433
+ const mark = { ok: "\u2705", warn: "\u26A0\uFE0F", fail: "\u274C" };
13434
+ const out = [`\u65B9\u6CD5\u5305\uFF1A${path11.join(r.root, METHOD_DIR)}/`];
13435
+ for (const row of r.rows) {
13436
+ out.push(`${mark[row.verdict]} ${row.item} ${row.detail}`);
13437
+ if (row.nextStep && row.verdict !== "ok") out.push(` \u2192 ${row.nextStep}`);
13438
+ }
13439
+ return out.join("\n");
13440
+ }
13441
+ async function inspectMethodForDoctor(root, deps = quietDeps()) {
13442
+ const s = await runMethodStatus(root, deps, { withConflicts: false });
13443
+ const row = (item) => s.rows.find((r) => r.item === item);
13444
+ const lockRow = row("\u9501\u5B9A");
13445
+ if (!s.lock) {
13446
+ return lockRow.code === CliErrorCode29.METHOD_NOT_INSTALLED ? { verdict: "warn", detail: "\u672A\u5B89\u88C5\uFF08\u9879\u76EE\u91CC\u6CA1\u6709\u65B9\u6CD5\u5305\u9501\u6587\u4EF6\uFF09", nextStep: "\u6709\u77E5\u8BC6\u7EC4\u7EC7\u6388\u6743\u5C31\u8DD1 `hcm chiron method install`\uFF1B\u6CA1\u6709\u6388\u6743\u53EF\u4EE5\u8DF3\u8FC7\uFF0C\u4E0D\u5F71\u54CD\u4EA7\u54C1\u64CD\u4F5C" } : { verdict: "warn", detail: `\u65E0\u6CD5\u5224\u65AD\uFF1A${lockRow.detail}`, nextStep: lockRow.nextStep };
13447
+ }
13448
+ const install = row("\u5B89\u88C5");
13449
+ if (install?.code === CliErrorCode29.METHOD_NOT_INSTALLED) {
13450
+ return { verdict: "warn", detail: `\u672A\u5B89\u88C5\uFF08\u9501\u6587\u4EF6\u9501\u5B9A\u65B9\u6CD5 ${s.lock.package.version} \xB7 ${s.lock.ref}\uFF0C\u672C\u673A\u8FD8\u6CA1\u6709\u65B9\u6CD5\u5305\u526F\u672C\uFF09`, nextStep: "\u6709\u77E5\u8BC6\u7EC4\u7EC7\u6388\u6743\u5C31\u8DD1 `hcm chiron method install`\uFF08\u6309\u9501\u6587\u4EF6\u7684\u7248\u672C\u88C5\uFF09\uFF1B\u6CA1\u6709\u6388\u6743\u53EF\u4EE5\u8DF3\u8FC7\uFF0C\u4E0D\u5F71\u54CD\u4EA7\u54C1\u64CD\u4F5C" };
13451
+ }
13452
+ const local = [install, row("\u6458\u8981")].find((r) => r && r.verdict === "fail");
13453
+ if (local) return { verdict: "warn", detail: `\u672C\u673A\u526F\u672C\u4E0E\u9501\u6587\u4EF6\u4E0D\u7B26\uFF1A${local.detail}`, nextStep: local.nextStep };
13454
+ const where = `\u65B9\u6CD5 ${s.lock.package.version} \xB7 ${s.lock.ref} @ ${s.lock.commit.slice(0, 12)}\uFF0C\u672C\u673A\u526F\u672C\u6458\u8981\u6838\u5BF9\u901A\u8FC7`;
13455
+ const remote = row("\u65B0\u7248");
13456
+ if (!s.remote.checked) return { verdict: "warn", detail: `\u65E0\u6CD5\u5224\u65AD\u662F\u5426\u843D\u540E\uFF08${s.remote.reason}\uFF09\uFF1B${where}\uFF1B\u4E0A\u6B21\u8054\u7F51\u6838\u5BF9 ${s.remote.lastCheckedAt ?? "\u65E0\u8BB0\u5F55"}`, nextStep: remote.nextStep };
13457
+ if (s.remote.undetermined) return { verdict: "warn", detail: `\u65E0\u6CD5\u5224\u65AD\u662F\u5426\u843D\u540E\uFF08${s.remote.undetermined}\uFF09\uFF1B${where}`, nextStep: remote.nextStep };
13458
+ if (remote.verdict === "warn") return { verdict: "warn", detail: `\u7248\u672C\u843D\u540E\uFF1A${remote.detail}\uFF1B${where}`, nextStep: remote.nextStep };
13459
+ return { verdict: "ok", detail: `${where}\uFF0C\u5DF2\u662F\u6700\u65B0 tag` };
13460
+ }
13461
+ function quietDeps() {
13462
+ return { ...defaultMethodDeps(), log: () => {
13463
+ } };
13464
+ }
13465
+ function emit6(output, data, text) {
13466
+ if (output === "json" || output === "yaml") process.stdout.write(formatObject26(data, { format: output }) + "\n");
13467
+ else process.stdout.write(text() + "\n");
13468
+ }
13469
+ async function runMethodInstall(args, deps = defaultMethodDeps()) {
13470
+ const { root, rootSource } = await resolveMethodRoot(args.project, deps.log);
13471
+ const lock = args.ref === void 0 ? await readLock(root) : void 0;
13472
+ const target = await resolveTarget(root, args.target);
13473
+ return runMethodPipeline(
13474
+ { root, rootSource, ref: args.ref ?? lock?.ref, expectCommit: lock?.commit, target, mode: "install" },
13475
+ deps
13476
+ );
13477
+ }
13478
+ async function runMethodUpdate(args, deps = defaultMethodDeps()) {
13479
+ const { root, rootSource } = await resolveMethodRoot(args.project, deps.log);
13480
+ const lock = await readLock(root);
13481
+ if (!lock) {
13482
+ throw new CliError27({
13483
+ code: CliErrorCode29.METHOD_NOT_INSTALLED,
13484
+ message: `${root} \u91CC\u6CA1\u6709 ${METHOD_DIR}/${METHOD_LOCK_FILE}\uFF1A\u8FD9\u4E2A\u9879\u76EE\u8FD8\u6CA1\u88C5\u65B9\u6CD5\u5305\uFF0C\u6CA1\u6709\u53EF\u4EE5\u66F4\u65B0\u7684\u8D77\u70B9`,
13485
+ context: { nextStep: "`hcm chiron method install`\uFF08\u88C5\u6700\u65B0\u7684\u7248\u672C tag\uFF09" }
13486
+ });
13487
+ }
13488
+ const target = await resolveTarget(root, args.target);
13489
+ const tags = listRemoteTags(deps);
13490
+ const want = resolveRef(tags, args.ref, deps);
13491
+ if (want.commit === lock.commit) {
13492
+ const local = await runMethodStatus(root, deps, { withConflicts: false });
13493
+ const intact = local.rows.every((r) => !["\u5B89\u88C5", "\u6458\u8981"].includes(r.item) || r.verdict === "ok");
13494
+ if (intact) {
13495
+ deps.log(`\u5DF2\u662F ${want.ref} @ ${want.commit.slice(0, 12)}\uFF0C\u672C\u673A\u526F\u672C\u5B8C\u597D\uFF0C\u6CA1\u6709\u53D8\u66F4`);
13496
+ return { ok: true, mode: "update", unchanged: true, root, ref: want.ref, commit: want.commit };
13497
+ }
13498
+ }
13499
+ return runMethodPipeline({ root, rootSource, ref: want.ref, target, mode: "update" }, deps);
13500
+ }
13501
+ async function methodInstallCommand(args) {
13502
+ try {
13503
+ const r = await runMethodInstall(args);
13504
+ emit6(args.output, r, () => renderInstallReport(r));
13505
+ } catch (e) {
13506
+ exitWithError(e);
13507
+ }
13508
+ }
13509
+ async function methodUpdateCommand(args) {
13510
+ try {
13511
+ const r = await runMethodUpdate(args);
13512
+ emit6(args.output, r, () => "unchanged" in r ? `\u5DF2\u662F ${r.ref} @ ${r.commit.slice(0, 12)}\uFF0C\u672C\u673A\u526F\u672C\u5B8C\u597D\uFF0C\u6CA1\u6709\u53D8\u66F4\u3002` : renderInstallReport(r));
13513
+ } catch (e) {
13514
+ exitWithError(e);
13515
+ }
13516
+ }
13517
+ async function methodStatusCommand(args) {
13518
+ try {
13519
+ const deps = defaultMethodDeps();
13520
+ const { root } = await resolveMethodRoot(args.project, deps.log);
13521
+ const r = await runMethodStatus(root, deps);
13522
+ emit6(args.output, r, () => renderMethodStatus(r));
13523
+ process.exitCode = r.ok ? 0 : 1;
13524
+ } catch (e) {
13525
+ exitWithError(e);
13526
+ }
13527
+ }
13528
+
13529
+ // src/commands/chiron-doctor.ts
12348
13530
  var defaultDeps2 = {
12349
13531
  anchors: async (envName, tenant2, as, project) => {
12350
13532
  const ctx = await getActiveAuthContextFromCli({ env: envName, as }, { cwd: project });
@@ -12361,9 +13543,9 @@ var defaultDeps2 = {
12361
13543
  inspectJira: () => inspectJira()
12362
13544
  };
12363
13545
  async function runChironDoctor(args, deps = defaultDeps2) {
12364
- const root = path11.resolve(args.project ?? ".");
13546
+ const root = path12.resolve(args.project ?? ".");
12365
13547
  const report = { ok: false, project: root, env: null, envName: null, lines: [] };
12366
- const envText = await fs10.readFile(path11.join(root, ENV_FILE), "utf8").catch(() => null);
13548
+ const envText = await fs10.readFile(path12.join(root, ENV_FILE), "utf8").catch(() => null);
12367
13549
  if (envText === null) {
12368
13550
  report.lines.push({
12369
13551
  item: "\u767B\u5F55",
@@ -12386,8 +13568,8 @@ async function runChironDoctor(args, deps = defaultDeps2) {
12386
13568
  if (args.env !== void 0 && !Object.hasOwn(file.environments, args.env)) {
12387
13569
  try {
12388
13570
  explicitSlot = await resolveEnvContext8({ envFlag: args.env, cwd: root }, process.env, await loadGlobalConfig11());
12389
- if (!explicitSlot.project) throw new CliError27({
12390
- code: CliErrorCode29.INVALID_ARGUMENT,
13571
+ if (!explicitSlot.project) throw new CliError28({
13572
+ code: CliErrorCode30.INVALID_ARGUMENT,
12391
13573
  message: `\u672C\u673A\u69FD '${args.env}' \u7684\u5730\u5740\u6216\u79DF\u6237\u4E0D\u5339\u914D\u672C\u9879\u76EE\uFF1B\u672C\u9879\u76EE\u6709\uFF1A${names.join(", ")}`
12392
13574
  });
12393
13575
  selectedName = explicitSlot.project.name;
@@ -12441,7 +13623,7 @@ async function runChironDoctor(args, deps = defaultDeps2) {
12441
13623
  });
12442
13624
  }
12443
13625
  } catch (e) {
12444
- const msg = e instanceof CliError27 ? e.message : e.message;
13626
+ const msg = e instanceof CliError28 ? e.message : e.message;
12445
13627
  report.lines.push({ item: "\u767B\u5F55", verdict: severity(), detail: `${label} \xB7 \u672C\u673A\u69FD ${found.name} \xB7 ${env3.endpoint}\uFF1A${msg}`, nextStep: loginCmd });
12446
13628
  }
12447
13629
  }
@@ -12450,7 +13632,7 @@ async function runChironDoctor(args, deps = defaultDeps2) {
12450
13632
  const skillsLine = async () => {
12451
13633
  const state = await readSkillsState(skillsSyncDir(root));
12452
13634
  if (!state) {
12453
- const legacy = await readSkillsState(path11.join(root, SKILLS_DIR));
13635
+ const legacy = await readSkillsState(path12.join(root, SKILLS_DIR));
12454
13636
  if (legacy) {
12455
13637
  return {
12456
13638
  item: "\u6280\u80FD",
@@ -12489,6 +13671,8 @@ async function runChironDoctor(args, deps = defaultDeps2) {
12489
13671
  report.lines.push(
12490
13672
  jira.ok ? { item: "Jira", verdict: "ok", detail: `${jira.who || "\u5DF2\u8FDE\u63A5"} \xB7 \u770B\u5F97\u5230 ${JIRA_PROJECT2}\uFF08\u4EE4\u724C\u6765\u81EA ${jira.from}\uFF09` } : { item: "Jira", verdict: "warn", detail: jira.reason ?? "\u4E0D\u53EF\u7528", nextStep: "\u73B0\u5728\u4E0D\u914D\u4E5F\u80FD\u4EA4\u4ED8\uFF1B\u649E\u5230\u300C\u4EA7\u54C1\u505A\u4E0D\u5230\u300D\u8981\u63D0\u5355\u65F6\u5FC5\u987B\u5148\u914D\u597D" }
12491
13673
  );
13674
+ const methodLine = await (deps.inspectMethod ?? inspectMethodForDoctor)(root);
13675
+ report.lines.push({ item: "\u65B9\u6CD5", ...methodLine });
12492
13676
  return finish(report);
12493
13677
  }
12494
13678
  function finish(report) {
@@ -12517,7 +13701,7 @@ async function chironDoctorCommand(args, deps) {
12517
13701
  try {
12518
13702
  const report = await runChironDoctor(args, deps);
12519
13703
  const fmt = args.output ?? "table";
12520
- if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject26(report, { format: fmt }) + "\n");
13704
+ if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject27(report, { format: fmt }) + "\n");
12521
13705
  else process.stdout.write(renderChironDoctor(report) + "\n");
12522
13706
  process.exitCode = report.ok ? 0 : 1;
12523
13707
  } catch (e) {
@@ -12528,16 +13712,16 @@ async function chironDoctorCommand(args, deps) {
12528
13712
  // src/commands/chiron-env.ts
12529
13713
  init_exit();
12530
13714
  import { promises as fs11 } from "fs";
12531
- import path12 from "path";
12532
- import yaml from "js-yaml";
13715
+ import path13 from "path";
13716
+ import yaml2 from "js-yaml";
12533
13717
  import {
12534
13718
  AUTH_INFO_PATH as AUTH_INFO_PATH2,
12535
- CliError as CliError28,
12536
- CliErrorCode as CliErrorCode30,
12537
- discoverProjectEnv as discoverProjectEnv6,
13719
+ CliError as CliError29,
13720
+ CliErrorCode as CliErrorCode31,
13721
+ discoverProjectEnv as discoverProjectEnv7,
12538
13722
  ENV_FILE as ENV_FILE2,
12539
13723
  findEnvByEndpoint as findEnvByEndpoint5,
12540
- formatObject as formatObject27,
13724
+ formatObject as formatObject28,
12541
13725
  listIdentities as listIdentities6,
12542
13726
  parseEnvYaml as parseEnvYaml2,
12543
13727
  renderEnvYaml as renderEnvYaml2,
@@ -12556,7 +13740,7 @@ function summarizeReasons(reasons) {
12556
13740
  return reasons.length === 1 ? reasons[0] : `${reasons[0]} \u7B49 ${reasons.length} \u6761\uFF08--output json \u770B\u5168\u90E8\uFF09`;
12557
13741
  }
12558
13742
  function invalid2(message, nextStep) {
12559
- throw new CliError28({ code: CliErrorCode30.INVALID_ARGUMENT, message, context: { nextStep } });
13743
+ throw new CliError29({ code: CliErrorCode31.INVALID_ARGUMENT, message, context: { nextStep } });
12560
13744
  }
12561
13745
  function required(value, label) {
12562
13746
  if (!value?.trim()) invalid2(`${label} \u4E0D\u80FD\u4E3A\u7A7A\uFF1B\u914D\u7F6E\u672A\u5199\u5165\u3002`, `\u8BF7\u63D0\u4F9B\u975E\u7A7A\u7684 ${label}`);
@@ -12674,9 +13858,9 @@ async function runChironEnv(action, args = {}) {
12674
13858
  if (args.output && !["table", "json", "yaml"].includes(args.output)) {
12675
13859
  invalid2(`\u672A\u77E5\u8F93\u51FA\u683C\u5F0F '${args.output}'\uFF0C\u914D\u7F6E\u672A\u5199\u5165\u3002`, "\u4F7F\u7528 --output table\u3001json \u6216 yaml");
12676
13860
  }
12677
- const root = path12.resolve(args.project ?? ".");
12678
- const discovered = await discoverProjectEnv6(root);
12679
- const file = discovered?.path ?? path12.join(root, ENV_FILE2);
13861
+ const root = path13.resolve(args.project ?? ".");
13862
+ const discovered = await discoverProjectEnv7(root);
13863
+ const file = discovered?.path ?? path13.join(root, ENV_FILE2);
12680
13864
  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>");
12681
13865
  const original = discovered ? await fs11.readFile(file, "utf8") : null;
12682
13866
  const config2 = original ? parseEnvYaml2(original) : { default: "", environments: {} };
@@ -12729,8 +13913,8 @@ async function runChironEnv(action, args = {}) {
12729
13913
  if (tenant2.status === "mismatch") warnings.push(`token \u5B9E\u9645\u79DF\u6237 ${tenant2.actual} \u4E0E\u58F0\u660E\u79DF\u6237 ${config2.environments[name].tenant} \u4E0D\u4E00\u81F4\uFF1B\u914D\u7F6E\u5DF2\u5199\u5165\uFF0C\u8BF7\u7528 hcm login --env ${name} \u767B\u5F55\u6B63\u786E\u79DF\u6237\u3002`);
12730
13914
  if (tenant2.status === "unverified") warnings.push(`\u79DF\u6237\u672A\u7ECF\u8BC1\u5B9E\uFF08${tenant2.reason}\uFF09\uFF1B\u8BF7\u5728\u8054\u7F51\u5E76\u767B\u5F55\u540E\u8FD0\u884C hcm chiron doctor --env ${name}\u3002`);
12731
13915
  }
12732
- const legacy = original !== null && Object.hasOwn(yaml.load(original), "endpoint");
12733
- const rendered = legacy && action === "edit" ? yaml.dump(config2.environments.default, { noRefs: true, lineWidth: -1 }) : renderEnvYaml2(config2);
13916
+ const legacy = original !== null && Object.hasOwn(yaml2.load(original), "endpoint");
13917
+ const rendered = legacy && action === "edit" ? yaml2.dump(config2.environments.default, { noRefs: true, lineWidth: -1 }) : renderEnvYaml2(config2);
12734
13918
  parseEnvYaml2(rendered);
12735
13919
  if (original !== null && await fs11.readFile(file, "utf8") !== original) invalid2(`${file} \u5728\u6838\u9A8C\u671F\u95F4\u88AB\u4FEE\u6539\uFF0C\u914D\u7F6E\u672A\u5199\u5165\u3002`, "\u91CD\u65B0\u8FD0\u884C\u547D\u4EE4\uFF0C\u57FA\u4E8E\u6700\u65B0\u914D\u7F6E\u7F16\u8F91");
12736
13920
  await fs11.writeFile(file, rendered, { encoding: "utf8", flag: original === null ? "wx" : "w" });
@@ -12739,7 +13923,7 @@ async function runChironEnv(action, args = {}) {
12739
13923
  return report;
12740
13924
  }
12741
13925
  function formatChironEnvReport(report, output = "table") {
12742
- if (output !== "table") return formatObject27(report, { format: output });
13926
+ if (output !== "table") return formatObject28(report, { format: output });
12743
13927
  const lines = [
12744
13928
  report.action === "list" ? `\u9879\u76EE\u73AF\u5883\uFF1A${report.path}` : `\u5DF2\u5199\u5165\uFF1A${report.path}`,
12745
13929
  formatTable(report.environments.map((env2) => ({
@@ -12772,13 +13956,13 @@ init_exit();
12772
13956
  import { spawnSync } from "child_process";
12773
13957
  import { accessSync, constants, readdirSync as readdirSync3 } from "fs";
12774
13958
  import fs12 from "fs/promises";
12775
- import os5 from "os";
12776
- import path14 from "path";
12777
- import { CliError as CliError31, CliErrorCode as CliErrorCode33, formatObject as formatObject28, HcmClient as HcmClient25, loadEnv as loadEnv6 } from "@hcmai/sdk";
13959
+ import os6 from "os";
13960
+ import path15 from "path";
13961
+ import { CliError as CliError32, CliErrorCode as CliErrorCode34, formatObject as formatObject29, HcmClient as HcmClient25, loadEnv as loadEnv6 } from "@hcmai/sdk";
12778
13962
  import { createRequire } from "module";
12779
13963
 
12780
13964
  // src/commands/chiron-page-cdp.ts
12781
- import { CliError as CliError29, CliErrorCode as CliErrorCode31 } from "@hcmai/sdk";
13965
+ import { CliError as CliError30, CliErrorCode as CliErrorCode32 } from "@hcmai/sdk";
12782
13966
 
12783
13967
  // src/commands/chiron-page-shared.ts
12784
13968
  function redactTicket(text) {
@@ -12814,14 +13998,14 @@ function normalizeCdpEndpoint(raw) {
12814
13998
  try {
12815
13999
  url = new URL(candidate);
12816
14000
  } catch {
12817
- throw new CliError29({ code: CliErrorCode31.INVALID_ARGUMENT, message: `--cdp \u8981\u5199\u6210 http://\u4E3B\u673A:\u7AEF\u53E3\uFF08Chrome \u7684 --remote-debugging-port\uFF09\uFF0C\u6536\u5230\u7684\u662F ${text}` });
14001
+ throw new CliError30({ code: CliErrorCode32.INVALID_ARGUMENT, message: `--cdp \u8981\u5199\u6210 http://\u4E3B\u673A:\u7AEF\u53E3\uFF08Chrome \u7684 --remote-debugging-port\uFF09\uFF0C\u6536\u5230\u7684\u662F ${text}` });
12818
14002
  }
12819
14003
  const protocol = url.protocol === "wss:" ? "https:" : url.protocol === "ws:" ? "http:" : url.protocol;
12820
14004
  if (protocol !== "http:" && protocol !== "https:") {
12821
- throw new CliError29({ code: CliErrorCode31.INVALID_ARGUMENT, message: `--cdp \u53EA\u8BA4 http(s) \u6216 ws(s) \u7AEF\u70B9\uFF0C\u6536\u5230\u7684\u662F ${text}` });
14005
+ throw new CliError30({ code: CliErrorCode32.INVALID_ARGUMENT, message: `--cdp \u53EA\u8BA4 http(s) \u6216 ws(s) \u7AEF\u70B9\uFF0C\u6536\u5230\u7684\u662F ${text}` });
12822
14006
  }
12823
14007
  if (!url.port) {
12824
- throw new CliError29({ code: CliErrorCode31.INVALID_ARGUMENT, message: `--cdp \u8981\u5E26\u7AEF\u53E3\uFF08Chrome \u542F\u52A8\u65F6 --remote-debugging-port=<\u7AEF\u53E3> \u7684\u90A3\u4E2A\uFF09\uFF0C\u6536\u5230\u7684\u662F ${text}` });
14008
+ throw new CliError30({ code: CliErrorCode32.INVALID_ARGUMENT, message: `--cdp \u8981\u5E26\u7AEF\u53E3\uFF08Chrome \u542F\u52A8\u65F6 --remote-debugging-port=<\u7AEF\u53E3> \u7684\u90A3\u4E2A\uFF09\uFF0C\u6536\u5230\u7684\u662F ${text}` });
12825
14009
  }
12826
14010
  return `${protocol}//${url.hostname}:${url.port}`;
12827
14011
  }
@@ -12837,12 +14021,12 @@ var CdpSession = class {
12837
14021
  pending = /* @__PURE__ */ new Map();
12838
14022
  listeners = /* @__PURE__ */ new Map();
12839
14023
  closed = false;
12840
- send(method, params = {}) {
12841
- if (this.closed) return Promise.reject(new Error(`CDP socket \u5DF2\u5173\u95ED\uFF0C\u53D1\u4E0D\u4E86 ${method}`));
14024
+ send(method2, params = {}) {
14025
+ if (this.closed) return Promise.reject(new Error(`CDP socket \u5DF2\u5173\u95ED\uFF0C\u53D1\u4E0D\u4E86 ${method2}`));
12842
14026
  const id = this.nextId++;
12843
14027
  return new Promise((resolve3, reject) => {
12844
- this.pending.set(id, { resolve: resolve3, reject, method });
12845
- this.socket.send(JSON.stringify({ id, method, params }));
14028
+ this.pending.set(id, { resolve: resolve3, reject, method: method2 });
14029
+ this.socket.send(JSON.stringify({ id, method: method2, params }));
12846
14030
  });
12847
14031
  }
12848
14032
  on(event, listener) {
@@ -12918,8 +14102,8 @@ async function captureViaCdp(input, io) {
12918
14102
  const browser = version?.Browser ? String(version.Browser) : `attached ${input.endpoint}`;
12919
14103
  const target = await io.fetchJson(`${input.endpoint}/json/new?about:blank`, "PUT");
12920
14104
  if (!target?.id || !target.webSocketDebuggerUrl) {
12921
- throw new CliError29({
12922
- code: CliErrorCode31.SERVER_ERROR,
14105
+ throw new CliError30({
14106
+ code: CliErrorCode32.SERVER_ERROR,
12923
14107
  message: `${input.endpoint}/json/new \u6CA1\u6709\u7ED9\u51FA\u6807\u7B7E\u9875\uFF08id / webSocketDebuggerUrl \u7F3A\u5931\uFF09`,
12924
14108
  context: { nextStep: "\u786E\u8BA4 Chrome \u662F\u5E26 --remote-debugging-port \u8D77\u7684\uFF0C\u4E14 --cdp \u6307\u5230\u7684\u662F\u5B83" }
12925
14109
  });
@@ -12949,7 +14133,7 @@ async function captureViaCdp(input, io) {
12949
14133
  });
12950
14134
  if (r.exceptionDetails) {
12951
14135
  const why = r.exceptionDetails.exception?.description ?? r.exceptionDetails.text ?? "unknown";
12952
- throw new CliError29({ code: CliErrorCode31.INVALID_ARGUMENT, message: `--eval \u5728\u9875\u9762\u91CC\u629B\u4E86\u5F02\u5E38\uFF1A${redactTicket(why.split("\n")[0] ?? why)}` });
14136
+ throw new CliError30({ code: CliErrorCode32.INVALID_ARGUMENT, message: `--eval \u5728\u9875\u9762\u91CC\u629B\u4E86\u5F02\u5E38\uFF1A${redactTicket(why.split("\n")[0] ?? why)}` });
12953
14137
  }
12954
14138
  evalResult = r.result && "value" in r.result ? toPlainJson(r.result.value) : toPlainJson(r.result?.description);
12955
14139
  }
@@ -12960,7 +14144,7 @@ async function captureViaCdp(input, io) {
12960
14144
  const dom = typeof domReply.result?.value === "string" ? domReply.result.value : "";
12961
14145
  const shot = await session.send("Page.captureScreenshot", { format: "png" });
12962
14146
  if (!shot.data) {
12963
- throw new CliError29({ code: CliErrorCode31.SERVER_ERROR, message: "Page.captureScreenshot \u6CA1\u6709\u8FD4\u56DE\u56FE\u50CF\u6570\u636E" });
14147
+ throw new CliError30({ code: CliErrorCode32.SERVER_ERROR, message: "Page.captureScreenshot \u6CA1\u6709\u8FD4\u56DE\u56FE\u50CF\u6570\u636E" });
12964
14148
  }
12965
14149
  await io.writeFile(input.screenshot, Buffer.from(shot.data, "base64"));
12966
14150
  return { dom, browser, evalResult, navigated, minted };
@@ -12973,16 +14157,16 @@ async function captureViaCdp(input, io) {
12973
14157
  }
12974
14158
  }
12975
14159
  var defaultCdpIo = {
12976
- fetchJson: async (url, method) => {
12977
- const res = await fetch(url, { method, signal: AbortSignal.timeout(CDP_IO_TIMEOUT_MS) });
12978
- if (!res.ok) throw new Error(`${method} ${url} \u2192 HTTP ${res.status}`);
14160
+ fetchJson: async (url, method2) => {
14161
+ const res = await fetch(url, { method: method2, signal: AbortSignal.timeout(CDP_IO_TIMEOUT_MS) });
14162
+ if (!res.ok) throw new Error(`${method2} ${url} \u2192 HTTP ${res.status}`);
12979
14163
  const text = await res.text();
12980
14164
  return text ? JSON.parse(text) : null;
12981
14165
  },
12982
14166
  openSocket: (wsUrl) => new Promise((resolve3, reject) => {
12983
14167
  const Ctor = globalThis.WebSocket;
12984
14168
  if (!Ctor) {
12985
- reject(new CliError29({ code: CliErrorCode31.SERVER_ERROR, message: "\u8FD9\u4E2A Node \u6CA1\u6709\u5168\u5C40 WebSocket\uFF08\u9700\u8981 Node \u2265 22.4\uFF1B22.0\u201322.3 \u8981\u52A0 --experimental-websocket\uFF09" }));
14169
+ reject(new CliError30({ code: CliErrorCode32.SERVER_ERROR, message: "\u8FD9\u4E2A Node \u6CA1\u6709\u5168\u5C40 WebSocket\uFF08\u9700\u8981 Node \u2265 22.4\uFF1B22.0\u201322.3 \u8981\u52A0 --experimental-websocket\uFF09" }));
12986
14170
  return;
12987
14171
  }
12988
14172
  const ws = new Ctor(wsUrl);
@@ -13004,17 +14188,17 @@ var defaultCdpIo = {
13004
14188
  };
13005
14189
 
13006
14190
  // src/commands/chiron-page-playwright.ts
13007
- import path13 from "path";
13008
- import { CliError as CliError30, CliErrorCode as CliErrorCode32 } from "@hcmai/sdk";
14191
+ import path14 from "path";
14192
+ import { CliError as CliError31, CliErrorCode as CliErrorCode33 } from "@hcmai/sdk";
13009
14193
  function playwrightCacheRoot(probe) {
13010
14194
  const override = probe.env.PLAYWRIGHT_BROWSERS_PATH?.trim();
13011
- if (override === "0" && probe.packageRoot) return path13.join(probe.packageRoot, ".local-browsers");
13012
- if (override && override !== "0") return path13.resolve(override);
13013
- if (probe.platform === "darwin") return path13.join(probe.homedir(), "Library", "Caches", "ms-playwright");
14195
+ if (override === "0" && probe.packageRoot) return path14.join(probe.packageRoot, ".local-browsers");
14196
+ if (override && override !== "0") return path14.resolve(override);
14197
+ if (probe.platform === "darwin") return path14.join(probe.homedir(), "Library", "Caches", "ms-playwright");
13014
14198
  if (probe.platform === "win32") {
13015
- return path13.join(probe.env.LOCALAPPDATA?.trim() || path13.join(probe.homedir(), "AppData", "Local"), "ms-playwright");
14199
+ return path14.join(probe.env.LOCALAPPDATA?.trim() || path14.join(probe.homedir(), "AppData", "Local"), "ms-playwright");
13016
14200
  }
13017
- return path13.join(probe.env.XDG_CACHE_HOME?.trim() || path13.join(probe.homedir(), ".cache"), "ms-playwright");
14201
+ return path14.join(probe.env.XDG_CACHE_HOME?.trim() || path14.join(probe.homedir(), ".cache"), "ms-playwright");
13018
14202
  }
13019
14203
  function playwrightPlatformTag(probe) {
13020
14204
  const arm = probe.arch === "arm64";
@@ -13030,26 +14214,26 @@ function revisionOf(entry, prefix) {
13030
14214
  function candidateBinaries(probe, kind) {
13031
14215
  const tag = playwrightPlatformTag(probe);
13032
14216
  if (kind === "headless-shell") {
13033
- return [path13.join(`chrome-headless-shell-${tag}`, probe.platform === "win32" ? "chrome-headless-shell.exe" : "chrome-headless-shell")];
14217
+ return [path14.join(`chrome-headless-shell-${tag}`, probe.platform === "win32" ? "chrome-headless-shell.exe" : "chrome-headless-shell")];
13034
14218
  }
13035
14219
  if (probe.platform === "darwin") {
13036
14220
  return [
13037
14221
  // Playwright ≥ 1.49:Chrome for Testing 的 .app
13038
- path13.join(`chrome-${tag}`, "Google Chrome for Testing.app", "Contents", "MacOS", "Google Chrome for Testing"),
14222
+ path14.join(`chrome-${tag}`, "Google Chrome for Testing.app", "Contents", "MacOS", "Google Chrome for Testing"),
13039
14223
  // ≤ 1.48:Chromium.app,目录名不分架构
13040
- path13.join("chrome-mac", "Chromium.app", "Contents", "MacOS", "Chromium"),
13041
- path13.join(`chrome-${tag}`, "Chromium.app", "Contents", "MacOS", "Chromium")
14224
+ path14.join("chrome-mac", "Chromium.app", "Contents", "MacOS", "Chromium"),
14225
+ path14.join(`chrome-${tag}`, "Chromium.app", "Contents", "MacOS", "Chromium")
13042
14226
  ];
13043
14227
  }
13044
- if (probe.platform === "win32") return [path13.join("chrome-win64", "chrome.exe"), path13.join("chrome-win", "chrome.exe")];
13045
- return [path13.join(`chrome-${tag}`, "chrome"), path13.join("chrome-linux", "chrome")];
14228
+ if (probe.platform === "win32") return [path14.join("chrome-win64", "chrome.exe"), path14.join("chrome-win", "chrome.exe")];
14229
+ return [path14.join(`chrome-${tag}`, "chrome"), path14.join("chrome-linux", "chrome")];
13046
14230
  }
13047
14231
  function discoverPlaywrightBrowser(probe) {
13048
14232
  const explicit = probe.env.HCM_PLAYWRIGHT_EXECUTABLE?.trim();
13049
14233
  if (explicit) {
13050
14234
  if (probe.executable(explicit)) return { executablePath: explicit, kind: "explicit", from: "HCM_PLAYWRIGHT_EXECUTABLE" };
13051
- throw new CliError30({
13052
- code: CliErrorCode32.INVALID_ARGUMENT,
14235
+ throw new CliError31({
14236
+ code: CliErrorCode33.INVALID_ARGUMENT,
13053
14237
  message: `HCM_PLAYWRIGHT_EXECUTABLE \u6307\u7684\u6587\u4EF6\u4E0D\u53EF\u6267\u884C\uFF1A${explicit}`,
13054
14238
  context: { nextStep: "\u6307\u5230 Playwright \u88C5\u7684 chrome-headless-shell / chrome \u4E8C\u8FDB\u5236\uFF0C\u6216\u53BB\u6389\u8FD9\u4E2A\u53D8\u91CF\u8BA9 CLI \u81EA\u5DF1\u627E" }
13055
14239
  });
@@ -13060,8 +14244,8 @@ function discoverPlaywrightBrowser(probe) {
13060
14244
  const revisions = entries.map((e) => ({ e, rev: revisionOf(e, prefix) })).filter((x) => x.rev !== null).sort((a, b) => b.rev - a.rev);
13061
14245
  for (const { e } of revisions) {
13062
14246
  for (const rel of candidateBinaries(probe, kind)) {
13063
- const candidate = path13.join(root, e, rel);
13064
- if (probe.executable(candidate)) return { executablePath: candidate, kind, from: path13.join(root, e) };
14247
+ const candidate = path14.join(root, e, rel);
14248
+ if (probe.executable(candidate)) return { executablePath: candidate, kind, from: path14.join(root, e) };
13065
14249
  }
13066
14250
  }
13067
14251
  return null;
@@ -13091,8 +14275,8 @@ async function captureViaPlaywright(input) {
13091
14275
  }
13092
14276
  }
13093
14277
  if (!browser) {
13094
- throw new CliError30({
13095
- code: CliErrorCode32.SERVER_ERROR,
14278
+ throw new CliError31({
14279
+ code: CliErrorCode33.SERVER_ERROR,
13096
14280
  message: `Playwright \u8D77\u4E0D\u4E86\u6D4F\u89C8\u5668\uFF1A${failures.join("\uFF1B")}`,
13097
14281
  context: {
13098
14282
  nextStep: "\u88C5\u4E00\u4EFD Playwright \u7684 Chromium\uFF1Anpx playwright install chromium-headless-shell\uFF08\u6216 chromium\uFF09\uFF1B\u5DF2\u7ECF\u88C5\u4E86\u4F46\u4E0D\u5728\u7F3A\u7701\u7F13\u5B58\u76EE\u5F55\u5C31 export PLAYWRIGHT_BROWSERS_PATH=<\u76EE\u5F55> \u6216 HCM_PLAYWRIGHT_EXECUTABLE=<\u4E8C\u8FDB\u5236>\uFF1B\u6C99\u7BB1\u8FDE headless shell \u90FD\u8D77\u4E0D\u4E86\u65F6\uFF0C\u5728\u6C99\u7BB1\u5916\u8D77 Chrome \u5E76\u7528 --cdp \u8FDE"
@@ -13112,7 +14296,7 @@ async function captureViaPlaywright(input) {
13112
14296
  evalResult = toPlainJson(await page.evaluate(wrapEvalBody(input.evalJs)));
13113
14297
  } catch (e) {
13114
14298
  const why = (e instanceof Error ? e.message : String(e)).split("\n")[0] ?? "";
13115
- throw new CliError30({ code: CliErrorCode32.INVALID_ARGUMENT, message: `--eval \u5728\u9875\u9762\u91CC\u629B\u4E86\u5F02\u5E38\uFF1A${redactTicket(why)}` });
14299
+ throw new CliError31({ code: CliErrorCode33.INVALID_ARGUMENT, message: `--eval \u5728\u9875\u9762\u91CC\u629B\u4E86\u5F02\u5E38\uFF1A${redactTicket(why)}` });
13116
14300
  }
13117
14301
  }
13118
14302
  const dom = await page.content();
@@ -13136,13 +14320,13 @@ function judgePageContent(input) {
13136
14320
  function parseViewport(size) {
13137
14321
  const m = /^(\d+)x(\d+)$/.exec(size.trim());
13138
14322
  if (!m) {
13139
- throw new CliError31({ code: CliErrorCode33.INVALID_ARGUMENT, message: `--size \u8981\u5199\u6210 <\u5BBD>x<\u9AD8>\uFF0C\u4F8B\u5982 1440x900\uFF0C\u6536\u5230\u7684\u662F ${size}` });
14323
+ throw new CliError32({ code: CliErrorCode34.INVALID_ARGUMENT, message: `--size \u8981\u5199\u6210 <\u5BBD>x<\u9AD8>\uFF0C\u4F8B\u5982 1440x900\uFF0C\u6536\u5230\u7684\u662F ${size}` });
13140
14324
  }
13141
14325
  const width = Number(m[1]);
13142
14326
  const height = Number(m[2]);
13143
14327
  if (width < VIEWPORT_MIN.width || width > VIEWPORT_MAX.width || height < VIEWPORT_MIN.height || height > VIEWPORT_MAX.height) {
13144
- throw new CliError31({
13145
- code: CliErrorCode33.INVALID_ARGUMENT,
14328
+ throw new CliError32({
14329
+ code: CliErrorCode34.INVALID_ARGUMENT,
13146
14330
  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}`
13147
14331
  });
13148
14332
  }
@@ -13152,23 +14336,23 @@ function parseWaitMs(raw) {
13152
14336
  if (raw === void 0) return 1e4;
13153
14337
  const value = typeof raw === "number" ? raw : Number(raw);
13154
14338
  if (!Number.isInteger(value) || value < 0 || value > WAIT_MS_MAX) {
13155
- throw new CliError31({ code: CliErrorCode33.INVALID_ARGUMENT, message: `--wait-ms \u8981\u662F 0..${WAIT_MS_MAX} \u7684\u6574\u6570\uFF0C\u6536\u5230\u7684\u662F ${raw}` });
14339
+ throw new CliError32({ code: CliErrorCode34.INVALID_ARGUMENT, message: `--wait-ms \u8981\u662F 0..${WAIT_MS_MAX} \u7684\u6574\u6570\uFF0C\u6536\u5230\u7684\u662F ${raw}` });
13156
14340
  }
13157
14341
  return value;
13158
14342
  }
13159
14343
  function resolveEvidenceTarget(projectRoot, out) {
13160
14344
  if (!out?.trim()) {
13161
- throw new CliError31({ code: CliErrorCode33.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` });
14345
+ throw new CliError32({ code: CliErrorCode34.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` });
13162
14346
  }
13163
14347
  if (!out.endsWith(".png")) {
13164
- throw new CliError31({ code: CliErrorCode33.INVALID_ARGUMENT, message: `--out \u8981\u4EE5 .png \u7ED3\u5C3E\uFF0C\u6536\u5230\u7684\u662F ${out}` });
14348
+ throw new CliError32({ code: CliErrorCode34.INVALID_ARGUMENT, message: `--out \u8981\u4EE5 .png \u7ED3\u5C3E\uFF0C\u6536\u5230\u7684\u662F ${out}` });
13165
14349
  }
13166
- const root = path14.resolve(projectRoot);
13167
- const evidenceRoot = path14.join(root, EVIDENCE_DIR);
13168
- const absolute = path14.resolve(root, out);
13169
- if (absolute !== evidenceRoot && !absolute.startsWith(evidenceRoot + path14.sep)) {
13170
- throw new CliError31({
13171
- code: CliErrorCode33.INVALID_ARGUMENT,
14350
+ const root = path15.resolve(projectRoot);
14351
+ const evidenceRoot = path15.join(root, EVIDENCE_DIR);
14352
+ const absolute = path15.resolve(root, out);
14353
+ if (absolute !== evidenceRoot && !absolute.startsWith(evidenceRoot + path15.sep)) {
14354
+ throw new CliError32({
14355
+ code: CliErrorCode34.INVALID_ARGUMENT,
13172
14356
  message: `--out \u8981\u843D\u5728\u9879\u76EE\u7684 ${EVIDENCE_DIR}/ \u4E0B\uFF08${evidenceRoot}\uFF09\uFF0C\u6536\u5230\u7684\u662F ${absolute}`
13173
14357
  });
13174
14358
  }
@@ -13213,11 +14397,11 @@ function findChrome(probe, override) {
13213
14397
  }
13214
14398
  async function assertInsideEvidence(deps, evidenceRoot, absolute) {
13215
14399
  const canonicalRoot = await deps.realpath(evidenceRoot);
13216
- const canonicalParent = await deps.realpath(path14.dirname(absolute));
14400
+ const canonicalParent = await deps.realpath(path15.dirname(absolute));
13217
14401
  if (canonicalRoot === null || canonicalParent === null) return;
13218
- if (canonicalParent !== canonicalRoot && !canonicalParent.startsWith(canonicalRoot + path14.sep)) {
13219
- throw new CliError31({
13220
- code: CliErrorCode33.INVALID_ARGUMENT,
14402
+ if (canonicalParent !== canonicalRoot && !canonicalParent.startsWith(canonicalRoot + path15.sep)) {
14403
+ throw new CliError32({
14404
+ code: CliErrorCode34.INVALID_ARGUMENT,
13221
14405
  message: `--out \u7684\u7236\u76EE\u5F55\u7ECF\u7B26\u53F7\u94FE\u63A5\u8DD1\u51FA\u4E86 ${EVIDENCE_DIR}/\uFF1A${canonicalParent}`
13222
14406
  });
13223
14407
  }
@@ -13226,23 +14410,23 @@ async function runChironPage(target, args, deps) {
13226
14410
  const sitePath = normalizeTarget(target);
13227
14411
  const expect = (args.expectText ?? []).filter((t) => t.trim().length > 0);
13228
14412
  if (expect.length === 0) {
13229
- throw new CliError31({
13230
- code: CliErrorCode33.MISSING_FLAG,
14413
+ throw new CliError32({
14414
+ code: CliErrorCode34.MISSING_FLAG,
13231
14415
  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"
13232
14416
  });
13233
14417
  }
13234
14418
  const reject = (args.rejectText ?? []).filter((t) => t.trim().length > 0);
13235
14419
  const viewport = parseViewport(args.size ?? "1440x900");
13236
14420
  const waitMs = parseWaitMs(args.waitMs);
13237
- const root = path14.resolve(args.project ?? ".");
14421
+ const root = path15.resolve(args.project ?? ".");
13238
14422
  const { evidenceRoot, absolute } = resolveEvidenceTarget(root, args.out);
13239
14423
  if (await deps.present(absolute)) {
13240
- throw new CliError31({
13241
- code: CliErrorCode33.INVALID_ARGUMENT,
14424
+ throw new CliError32({
14425
+ code: CliErrorCode34.INVALID_ARGUMENT,
13242
14426
  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`
13243
14427
  });
13244
14428
  }
13245
- await deps.ensureDir(path14.dirname(absolute));
14429
+ await deps.ensureDir(path15.dirname(absolute));
13246
14430
  await assertInsideEvidence(deps, evidenceRoot, absolute);
13247
14431
  const endpoint = normalizeCdpEndpoint(args.cdp ?? deps.env.HCM_CHROME_CDP);
13248
14432
  const evalJs = args.eval?.trim() ? args.eval : void 0;
@@ -13250,8 +14434,8 @@ async function runChironPage(target, args, deps) {
13250
14434
  const playwrightBrowser = endpoint || forceSpawn ? null : deps.findPlaywrightBrowser();
13251
14435
  const usePlaywright = !endpoint && !forceSpawn && (playwrightBrowser !== null || evalJs !== void 0);
13252
14436
  if (evalJs && !endpoint && !usePlaywright) {
13253
- throw new CliError31({
13254
- code: CliErrorCode33.INVALID_ARGUMENT,
14437
+ throw new CliError32({
14438
+ code: CliErrorCode34.INVALID_ARGUMENT,
13255
14439
  message: "--eval \u9700\u8981 Playwright \u6216 --cdp\uFF1A\u8001\u7684 spawn \u8DEF\u5F84\u53EA\u4F1A --dump-dom\uFF0C\u585E\u4E0D\u8FDB\u811A\u672C\u3002",
13256
14440
  context: { nextStep: "npx playwright install chromium-headless-shell\uFF0C\u6216\u5728\u6C99\u7BB1\u5916\u8D77 Chrome \u7528 --cdp \u8FDE" }
13257
14441
  });
@@ -13269,10 +14453,10 @@ async function runChironPage(target, args, deps) {
13269
14453
  try {
13270
14454
  captured = endpoint ? await deps.captureAttached({ endpoint, viewport, waitMs, evalJs, screenshot: absolute, mintUrl: mint }) : await deps.capturePlaywright({ viewport, waitMs, evalJs, screenshot: absolute, browser: playwrightBrowser, mintUrl: mint });
13271
14455
  } catch (e) {
13272
- if (e instanceof CliError31) throw new CliError31({ code: e.code, message: redactTicket(e.message), context: e.context });
14456
+ if (e instanceof CliError32) throw new CliError32({ code: e.code, message: redactTicket(e.message), context: e.context });
13273
14457
  const where = endpoint ? `\u8FDE\u5230 ${endpoint} \u7684 Chrome` : "Playwright \u8D77\u7684\u6D4F\u89C8\u5668";
13274
- throw new CliError31({
13275
- code: CliErrorCode33.SERVER_ERROR,
14458
+ throw new CliError32({
14459
+ code: CliErrorCode34.SERVER_ERROR,
13276
14460
  message: `${where}\u6CA1\u8DD1\u5B8C\uFF1A${redactTicket(e instanceof Error ? e.message : String(e))}`,
13277
14461
  context: {
13278
14462
  nextStep: endpoint ? `\u6838\u4E00\u773C ${endpoint}/json/version \u80FD\u4E0D\u80FD\u6253\u5F00\uFF1BChrome \u8981\u5E26 --remote-debugging-port \u8D77\uFF0C\u4E14\u6C99\u7BB1\u653E\u884C\u4E86\u8FD9\u4E2A\u7AEF\u53E3` : "npx playwright install chromium-headless-shell \u540E\u91CD\u8DD1\uFF1B\u6216 HCM_CHIRON_PAGE_DRIVER=spawn \u8D70\u8001\u8DEF\u5F84\u5BF9\u7167"
@@ -13288,8 +14472,8 @@ async function runChironPage(target, args, deps) {
13288
14472
  mode = "spawn";
13289
14473
  const browser = deps.findBrowser();
13290
14474
  if (!browser) {
13291
- throw new CliError31({
13292
- code: CliErrorCode33.INVALID_ARGUMENT,
14475
+ throw new CliError32({
14476
+ code: CliErrorCode34.INVALID_ARGUMENT,
13293
14477
  message: "\u672C\u673A\u627E\u4E0D\u5230 Playwright \u7684 Chromium\uFF0C\u4E5F\u627E\u4E0D\u5230 Chrome/Chromium\uFF0C\u622A\u4E0D\u4E86\u56FE\u3002",
13294
14478
  context: { nextStep: "npx playwright install chromium-headless-shell\uFF08\u6C99\u7BB1\u91CC\u4E5F\u80FD\u8DD1\uFF09\uFF1B\u6216\u88C5\u4E00\u4E2A Chrome / HCM_CHROME_BIN=/\u7EDD\u5BF9\u8DEF\u5F84\uFF1B\u6216\u5728\u6C99\u7BB1\u5916\u8D77 Chrome \u7528 --cdp \u8FDE" }
13295
14479
  });
@@ -13297,8 +14481,8 @@ async function runChironPage(target, args, deps) {
13297
14481
  minted = await mint();
13298
14482
  const result = deps.capture({ browser, argv: chromeArgv({ viewport, waitMs, screenshot: absolute, url: minted.url, isRoot: process.getuid?.() === 0 }) });
13299
14483
  if (!result.ok) {
13300
- throw new CliError31({
13301
- code: CliErrorCode33.SERVER_ERROR,
14484
+ throw new CliError32({
14485
+ code: CliErrorCode34.SERVER_ERROR,
13302
14486
  message: `\u6D4F\u89C8\u5668\u6CA1\u8DD1\u5B8C\uFF1A${redactTicket(result.stderr.trim().split("\n").slice(-1)[0] ?? "\u65E0\u8F93\u51FA")}`,
13303
14487
  context: { nextStep: spawnFailureNextStep(browser, result, deps.platform) }
13304
14488
  });
@@ -13308,7 +14492,7 @@ async function runChironPage(target, args, deps) {
13308
14492
  }
13309
14493
  const bytes = await deps.present(absolute) ? await deps.sizeOf(absolute) : 0;
13310
14494
  if (bytes === 0) {
13311
- throw new CliError31({ code: CliErrorCode33.SERVER_ERROR, message: `\u6D4F\u89C8\u5668\u6CA1\u5199\u51FA\u975E\u7A7A PNG\uFF1A${absolute}` });
14495
+ throw new CliError32({ code: CliErrorCode34.SERVER_ERROR, message: `\u6D4F\u89C8\u5668\u6CA1\u5199\u51FA\u975E\u7A7A PNG\uFF1A${absolute}` });
13312
14496
  }
13313
14497
  const verdict = judgePageContent({ dom, expect, reject });
13314
14498
  return {
@@ -13360,7 +14544,7 @@ function safeStringify(value) {
13360
14544
  }
13361
14545
  function playwrightPackageRoot() {
13362
14546
  try {
13363
- return path14.dirname(createRequire(import.meta.url).resolve("playwright-core/package.json"));
14547
+ return path15.dirname(createRequire(import.meta.url).resolve("playwright-core/package.json"));
13364
14548
  } catch {
13365
14549
  return void 0;
13366
14550
  }
@@ -13371,8 +14555,8 @@ var defaultChironPageDeps = {
13371
14555
  const envCfg = await loadEnv6(ctx.env);
13372
14556
  const frontend = ctx.frontend ?? envCfg.frontend;
13373
14557
  if (!frontend?.trim()) {
13374
- throw new CliError31({
13375
- code: CliErrorCode33.INVALID_ARGUMENT,
14558
+ throw new CliError32({
14559
+ code: CliErrorCode34.INVALID_ARGUMENT,
13376
14560
  message: `env '${ctx.env}' \u6CA1\u914D\u524D\u7AEF\u5730\u5740\uFF0C\u5F00\u4E0D\u4E86\u9875\u9762\u3002`,
13377
14561
  context: { nextStep: `hcm env edit frontend <\u524D\u7AEF\u5730\u5740> --env ${ctx.env}` }
13378
14562
  });
@@ -13410,7 +14594,7 @@ var defaultChironPageDeps = {
13410
14594
  arch: process.arch,
13411
14595
  env: process.env,
13412
14596
  packageRoot: playwrightPackageRoot(),
13413
- homedir: () => os5.homedir(),
14597
+ homedir: () => os6.homedir(),
13414
14598
  readdir: (dir) => {
13415
14599
  try {
13416
14600
  return readdirSync3(dir);
@@ -13439,7 +14623,7 @@ async function chironPageCommand(target, args, deps = defaultChironPageDeps) {
13439
14623
  try {
13440
14624
  const receipt = await runChironPage(target, args, deps);
13441
14625
  const fmt = args.output ?? "table";
13442
- if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject28(receipt, { format: fmt }) + "\n");
14626
+ if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject29(receipt, { format: fmt }) + "\n");
13443
14627
  else process.stdout.write(renderChironPage(receipt) + "\n");
13444
14628
  process.exitCode = receipt.ok ? 0 : 3;
13445
14629
  } catch (e) {
@@ -13452,16 +14636,17 @@ init_exit();
13452
14636
  import { spawnSync as spawnSync2 } from "child_process";
13453
14637
  import { randomUUID } from "crypto";
13454
14638
  import { promises as fs13 } from "fs";
13455
- import path15 from "path";
13456
- import yaml2 from "js-yaml";
13457
- import { formatObject as formatObject29 } from "@hcmai/sdk";
14639
+ import path16 from "path";
14640
+ import yaml3 from "js-yaml";
14641
+ import { formatObject as formatObject30 } from "@hcmai/sdk";
13458
14642
 
13459
14643
  // src/commands/delivery-action-policy.ts
13460
14644
  init_auth_guard();
13461
14645
  import { HcmClient as HcmClient26, classifyEffect } from "@hcmai/sdk";
13462
14646
 
13463
14647
  // src/commands/delivery.ts
13464
- import { createHash as createHash6 } from "crypto";
14648
+ import { createHash as createHash7 } from "crypto";
14649
+ import { LEDGER_ONLY_FLAG } from "@hcmai/sdk";
13465
14650
  var APPROVAL_BYPASS_FLAGS = /* @__PURE__ */ new Set(["-y", "--yes", "--force", "--auto-approve"]);
13466
14651
  var CREDENTIAL_FLAGS = /* @__PURE__ */ new Set([
13467
14652
  "--password",
@@ -13656,13 +14841,58 @@ function classify(argv, actionResolution) {
13656
14841
  if (["add", "edit", "remove"].includes(operation ?? "")) return direct("R1", "managed-local-write", "chiron-project-env");
13657
14842
  return forbidden("unknown-command", "\u672A\u77E5 chiron env \u5B50\u547D\u4EE4\u6309\u6700\u9AD8\u98CE\u9669\u5173\u95ED\u3002");
13658
14843
  }
14844
+ const third = argv[2] ?? "";
13659
14845
  if (subcommand === "gap") {
13660
- const third = argv[2] ?? "";
13661
14846
  if (["search", "status", "comments"].includes(third)) return direct("R1", "remote-read", "gap-read");
13662
14847
  if (third === "submit") return direct("R1", "external-tracker-write", "gap-submit");
13663
14848
  if (third === "verify") return direct("R1", "external-tracker-write", "gap-verify");
13664
14849
  return forbidden("unknown-command", "\u672A\u77E5 chiron gap \u5B50\u547D\u4EE4\u6309\u6700\u9AD8\u98CE\u9669\u5173\u95ED\u3002");
13665
14850
  }
14851
+ if (subcommand === "method") {
14852
+ if (third === "status") return direct("R1", "remote-read", "chiron-method-status");
14853
+ if (third === "install" || third === "update") return direct("R1", "managed-local-write", "chiron-method-write");
14854
+ return forbidden("unknown-command", "\u672A\u77E5 chiron method \u5B50\u547D\u4EE4\u6309\u6700\u9AD8\u98CE\u9669\u5173\u95ED\u3002");
14855
+ }
14856
+ if (subcommand === "case") {
14857
+ if (["search", "show", "match"].includes(third)) return direct("R1", "remote-read", "case-read");
14858
+ if (third === "submit") return direct("R1", "external-repo-write", "case-submit");
14859
+ return forbidden("unknown-command", "\u672A\u77E5 chiron case \u5B50\u547D\u4EE4\u6309\u6700\u9AD8\u98CE\u9669\u5173\u95ED\u3002");
14860
+ }
14861
+ if (subcommand === "skills") {
14862
+ if (third === "sync") return direct("R1", "managed-local-write", "skill-managed-write");
14863
+ if (third === "path") return direct("R0", "local-discovery", "skill-path");
14864
+ return forbidden("unknown-command", "\u672A\u77E5 chiron skills \u5B50\u547D\u4EE4\u6309\u6700\u9AD8\u98CE\u9669\u5173\u95ED\u3002");
14865
+ }
14866
+ if (subcommand === "page") {
14867
+ if (hasFlag(argv, "--eval")) {
14868
+ return {
14869
+ risk: "R2",
14870
+ execution: "guarded",
14871
+ effect: "undetermined",
14872
+ reasonCode: "chiron-page-eval",
14873
+ reason: "`--eval` \u5728\u9875\u9762\u91CC\u8DD1\u4EFB\u610F JS\uFF0C\u5199\u4E0D\u5199\u5E93\u7531\u90A3\u6BB5\u811A\u672C\u51B3\u5B9A\uFF0C\u672C\u8868\u5224\u4E0D\u4E86\uFF1B\u6309\u4F1A\u5199\u5904\u7F6E\u8D70\u5199\u6388\u6743\u7EAA\u5F8B\u3002next_step=\u53EA\u622A\u56FE\u5224\u6587\u672C\u5C31\u53BB\u6389 --eval\uFF1B\u8981\u70B9\u6309\u94AE\u3001\u586B\u8868\uFF0C\u5C31\u6309\u9879\u76EE\u7684\u5199\u6388\u6743\u7EAA\u5F8B\u5728\u73AF\u5883\u91CC\u505A\u6389\uFF0C\u518D\u7528\u53EA\u8BFB\u547D\u4EE4\u65AD\u8A00\u7ED3\u679C\u3002"
14874
+ };
14875
+ }
14876
+ return direct("R1", "remote-read", "chiron-page");
14877
+ }
14878
+ if (subcommand === "recon") {
14879
+ if (third === "round") return direct("R0", "local-discovery", "recon-round");
14880
+ if (third === "" || third.startsWith("-")) return direct("R1", "remote-read", "chiron-recon");
14881
+ return forbidden("unknown-command", "\u672A\u77E5 chiron recon \u5B50\u547D\u4EE4\u6309\u6700\u9AD8\u98CE\u9669\u5173\u95ED\u3002");
14882
+ }
14883
+ if (subcommand === "seed") {
14884
+ if (third === "find" || third === "values") return direct("R0", "local-discovery", "seed-local-read");
14885
+ if (third === "plan") return direct("R1", "remote-read", "seed-plan");
14886
+ if (third === "apply") {
14887
+ return hasFlag(argv, "--execute") ? guarded("bulk-tenant-write", "seed-apply") : direct("R1", "remote-read", "seed-apply-dry-run");
14888
+ }
14889
+ if (third === "verify") {
14890
+ return hasFlag(argv, LEDGER_ONLY_FLAG) ? direct("R0", "local-discovery", "seed-verify-ledger") : direct("R1", "remote-read", "seed-verify");
14891
+ }
14892
+ return forbidden("unknown-command", "\u672A\u77E5 chiron seed \u5B50\u547D\u4EE4\u6309\u6700\u9AD8\u98CE\u9669\u5173\u95ED\u3002");
14893
+ }
14894
+ if (subcommand === "triage") return direct("R1", "remote-read", "chiron-triage");
14895
+ if (subcommand === "meta") return guarded("tenant-config-write", "chiron-meta-write");
13666
14896
  return forbidden("unknown-command", "\u672A\u77E5 chiron \u5B50\u547D\u4EE4\u6309\u6700\u9AD8\u98CE\u9669\u5173\u95ED\u3002");
13667
14897
  }
13668
14898
  if (name === "skills") {
@@ -13955,7 +15185,7 @@ function valuesAfterFlag(argv, flag) {
13955
15185
  return values;
13956
15186
  }
13957
15187
  function sha2564(value) {
13958
- return createHash6("sha256").update(value).digest("hex");
15188
+ return createHash7("sha256").update(value).digest("hex");
13959
15189
  }
13960
15190
  function isPlainObject(value) {
13961
15191
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -14094,7 +15324,7 @@ function readZip(buf, want) {
14094
15324
  const out = [];
14095
15325
  for (let n = 0; n < count; n++) {
14096
15326
  if (buf.readUInt32LE(p) !== 33639248) break;
14097
- const method = buf.readUInt16LE(p + 10);
15327
+ const method2 = buf.readUInt16LE(p + 10);
14098
15328
  const compressedSize = buf.readUInt32LE(p + 20);
14099
15329
  const nameLen = buf.readUInt16LE(p + 28);
14100
15330
  const extraLen = buf.readUInt16LE(p + 30);
@@ -14106,9 +15336,9 @@ function readZip(buf, want) {
14106
15336
  const lextraLen = buf.readUInt16LE(localOffset + 28);
14107
15337
  const start = localOffset + 30 + lnameLen + lextraLen;
14108
15338
  const raw = buf.subarray(start, start + compressedSize);
14109
- if (method === 0) out.push({ name, data: Buffer.from(raw) });
14110
- else if (method === 8) out.push({ name, data: inflateRawSync(raw) });
14111
- else throw new Error(`xlsx \u91CC\u7684 ${name} \u7528\u4E86\u4E0D\u652F\u6301\u7684\u538B\u7F29\u65B9\u5F0F ${method}`);
15339
+ if (method2 === 0) out.push({ name, data: Buffer.from(raw) });
15340
+ else if (method2 === 8) out.push({ name, data: inflateRawSync(raw) });
15341
+ else throw new Error(`xlsx \u91CC\u7684 ${name} \u7528\u4E86\u4E0D\u652F\u6301\u7684\u538B\u7F29\u65B9\u5F0F ${method2}`);
14112
15342
  }
14113
15343
  p += 46 + nameLen + extraLen + commentLen;
14114
15344
  }
@@ -14348,7 +15578,7 @@ async function runCase(spec, root, opts = {}, deps = defaultDeps3) {
14348
15578
  continue;
14349
15579
  }
14350
15580
  if (c.file) {
14351
- const file = path15.resolve(root, fill(c.file));
15581
+ const file = path16.resolve(root, fill(c.file));
14352
15582
  const want = c.expect ?? {};
14353
15583
  const bad = [];
14354
15584
  if (want.xlsx_header || want.xlsx_min_rows !== void 0) {
@@ -14370,7 +15600,7 @@ async function runCase(spec, root, opts = {}, deps = defaultDeps3) {
14370
15600
  results.push(bad.length ? { name: c.name, verdict: "fail", detail: bad.join("\uFF1B") } : { name: c.name, verdict: "pass", detail: "" });
14371
15601
  continue;
14372
15602
  }
14373
- const out = path15.join(
15603
+ const out = path16.join(
14374
15604
  "evidence",
14375
15605
  "test",
14376
15606
  opts.evidenceRunId ?? "current",
@@ -14392,11 +15622,11 @@ async function runCase(spec, root, opts = {}, deps = defaultDeps3) {
14392
15622
  }
14393
15623
  async function loadCases(target) {
14394
15624
  const stat = await fs13.stat(target);
14395
- const files = stat.isDirectory() ? (await fs13.readdir(target)).filter((f) => /\.ya?ml$/.test(f)).sort().map((f) => path15.join(target, f)) : [target];
15625
+ const files = stat.isDirectory() ? (await fs13.readdir(target)).filter((f) => /\.ya?ml$/.test(f)).sort().map((f) => path16.join(target, f)) : [target];
14396
15626
  const out = [];
14397
15627
  for (const f of files) {
14398
- const spec = yaml2.load(await fs13.readFile(f, "utf8"));
14399
- assertUsableSpec(spec, path15.basename(f));
15628
+ const spec = yaml3.load(await fs13.readFile(f, "utf8"));
15629
+ assertUsableSpec(spec, path16.basename(f));
14400
15630
  out.push({ file: f, spec });
14401
15631
  }
14402
15632
  if (out.length === 0) throw new Error(`${target} \u4E0B\u6CA1\u6709\u7528\u4F8B\uFF08*.yml\uFF09`);
@@ -14404,8 +15634,8 @@ async function loadCases(target) {
14404
15634
  }
14405
15635
  async function chironTestCommand(target, args, deps) {
14406
15636
  try {
14407
- const root = path15.resolve(args.project ?? ".");
14408
- const where = path15.resolve(root, target ?? "tests");
15637
+ const root = path16.resolve(args.project ?? ".");
15638
+ const where = path16.resolve(root, target ?? "tests");
14409
15639
  const cases = await loadCases(where);
14410
15640
  const report = [];
14411
15641
  let failed2 = 0;
@@ -14417,11 +15647,11 @@ async function chironTestCommand(target, args, deps) {
14417
15647
  deps
14418
15648
  );
14419
15649
  failed2 += results.filter((r) => r.verdict === "fail").length;
14420
- report.push({ case: spec.name, file: path15.relative(root, file), results });
15650
+ report.push({ case: spec.name, file: path16.relative(root, file), results });
14421
15651
  }
14422
15652
  const fmt = args.output ?? "table";
14423
15653
  if (fmt === "json" || fmt === "yaml") {
14424
- process.stdout.write(formatObject29({ ok: failed2 === 0, failed: failed2, cases: report }, { format: fmt }) + "\n");
15654
+ process.stdout.write(formatObject30({ ok: failed2 === 0, failed: failed2, cases: report }, { format: fmt }) + "\n");
14425
15655
  } else {
14426
15656
  for (const c of report) {
14427
15657
  process.stdout.write(`
@@ -14454,7 +15684,7 @@ import {
14454
15684
  ReconLayout,
14455
15685
  ROUND_EXIT_CODES,
14456
15686
  computeReconSourceKey,
14457
- formatObject as formatObject30,
15687
+ formatObject as formatObject31,
14458
15688
  fromAxiosError as fromAxiosError22,
14459
15689
  httpProbe as httpProbe3,
14460
15690
  inspectRound,
@@ -14474,7 +15704,7 @@ async function deliveryReconCommand(args) {
14474
15704
  onlyModel: args.model ?? null,
14475
15705
  identity: ctx.tenantId ? { requestedTenantId: ctx.tenantId } : null
14476
15706
  });
14477
- process.stdout.write(formatObject30(summary, { format: args.output ?? "json" }) + "\n");
15707
+ process.stdout.write(formatObject31(summary, { format: args.output ?? "json" }) + "\n");
14478
15708
  } catch (e) {
14479
15709
  const err = e;
14480
15710
  if (err?.isAxiosError) exitWithError(fromAxiosError22(err, args.env));
@@ -14488,7 +15718,7 @@ async function deliveryReconRoundCommand(args) {
14488
15718
  const result = inspectRound(args.dir ?? ".");
14489
15719
  const fmt = args.output ?? "json";
14490
15720
  if (fmt !== "json") process.stdout.write(renderRound(result));
14491
- process.stdout.write(formatObject30(result, { format: fmt }) + "\n");
15721
+ process.stdout.write(formatObject31(result, { format: fmt }) + "\n");
14492
15722
  code = ROUND_EXIT_CODES[result.state];
14493
15723
  } catch (e) {
14494
15724
  exitWithError(e);
@@ -14557,8 +15787,8 @@ import {
14557
15787
  writeImportPlan,
14558
15788
  writeRisk
14559
15789
  } from "@hcmai/sdk";
14560
- import { existsSync as existsSync3 } from "fs";
14561
- import * as path16 from "path";
15790
+ import { existsSync as existsSync4 } from "fs";
15791
+ import * as path17 from "path";
14562
15792
  function premise(message, hint = "") {
14563
15793
  process.stderr.write(message + (hint ? `
14564
15794
  \u2192 ${hint}` : "") + "\n");
@@ -14569,7 +15799,7 @@ async function runSeedPlan(args, client3) {
14569
15799
  const tenant2 = tenantOf(client3);
14570
15800
  const work = seedWorkDir({ out, tenant: tenant2, work: args.work ?? null, mapping: args.mapping ?? null });
14571
15801
  const mappingPath = seedMappingPath({ out, tenant: tenant2, mapping: args.mapping ?? null }, work);
14572
- if (!existsSync3(mappingPath)) {
15802
+ if (!existsSync4(mappingPath)) {
14573
15803
  return premise(
14574
15804
  `\u8BFB\u4E0D\u5230\u5BFC\u5165\u6620\u5C04\u5DE5\u4EF6\uFF1A${mappingPath}`,
14575
15805
  "\u5DE5\u4EF6\u662F\u987E\u95EE\u81EA\u5DF1\u5199\u7684\uFF08\u5951\u7EA6\u89C1 README \u7684 `work/mapping.json` \u4E00\u8282\uFF09\u3002\u5199\u5728\u522B\u5904\u5C31\u7528 `--mapping <\u8DEF\u5F84>` \u6307\u8FC7\u53BB\uFF0C\u6216\u7528 `--work <\u76EE\u5F55>` \u6362 work \u76EE\u5F55\u3002"
@@ -14585,13 +15815,13 @@ async function runSeedPlan(args, client3) {
14585
15815
  const reconDir = candidates[0].reconDir;
14586
15816
  if (candidates.length > 1) {
14587
15817
  process.stderr.write(
14588
- `\u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u6709 ${candidates.length} \u4EFD\u57FA\u7EBF\uFF0C\u672C\u8F6E\u8BFB\u7684\u662F \`${path16.basename(reconDir)}\`\uFF1A` + candidates.slice(1).map((c) => `\`${path16.basename(c.reconDir)}\``).join("\u3001") + " \u672A\u88AB\u8BFB\u53D6 \u2014\u2014 \u4E0D\u540C sourceKey \u7684\u4EA7\u7269**\u4E0D\u53EF\u4E92\u6362**\u3002\n"
15818
+ `\u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u6709 ${candidates.length} \u4EFD\u57FA\u7EBF\uFF0C\u672C\u8F6E\u8BFB\u7684\u662F \`${path17.basename(reconDir)}\`\uFF1A` + candidates.slice(1).map((c) => `\`${path17.basename(c.reconDir)}\``).join("\u3001") + " \u672A\u88AB\u8BFB\u53D6 \u2014\u2014 \u4E0D\u540C sourceKey \u7684\u4EA7\u7269**\u4E0D\u53EF\u4E92\u6362**\u3002\n"
14589
15819
  );
14590
15820
  }
14591
15821
  const round = inspectRound2(reconDir);
14592
15822
  process.stderr.write(roundWarning(round));
14593
15823
  const baseline = {
14594
- path: `${path16.basename(path16.dirname(reconDir))}/${path16.basename(reconDir)}`,
15824
+ path: `${path17.basename(path17.dirname(reconDir))}/${path17.basename(reconDir)}`,
14595
15825
  roundId: round.roundId ?? null
14596
15826
  };
14597
15827
  let exemptions = null;
@@ -14851,9 +16081,9 @@ async function deliverySeedVerifyCommand(args) {
14851
16081
  }
14852
16082
 
14853
16083
  // src/commands/delivery-seed-find.ts
14854
- import { existsSync as existsSync4 } from "fs";
16084
+ import { existsSync as existsSync5 } from "fs";
14855
16085
  import { readFileSync as readFileSync8 } from "fs";
14856
- import * as path17 from "path";
16086
+ import * as path18 from "path";
14857
16087
  import {
14858
16088
  INIT_EXIT_CODES as INIT_EXIT_CODES2,
14859
16089
  ValueHints,
@@ -14867,10 +16097,10 @@ import {
14867
16097
  valuesRoundCaveat
14868
16098
  } from "@hcmai/sdk";
14869
16099
  function provenance(chosenReconDir, others) {
14870
- let line = `> \u57FA\u7EBF\uFF1A\`${path17.basename(chosenReconDir)}\`
16100
+ let line = `> \u57FA\u7EBF\uFF1A\`${path18.basename(chosenReconDir)}\`
14871
16101
  `;
14872
16102
  if (others.length > 0) {
14873
- line += `> \u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u53E6\u6709 ${others.length} \u4EFD\u57FA\u7EBF\u672A\u88AB\u8BFB\u53D6\uFF1A` + others.map((o) => `\`${path17.basename(o)}\``).join("\u3001") + " \u2014\u2014 \u4E0D\u540C sourceKey \u7684\u4EA7\u7269**\u4E0D\u53EF\u4E92\u6362**\u3002\n";
16103
+ line += `> \u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u53E6\u6709 ${others.length} \u4EFD\u57FA\u7EBF\u672A\u88AB\u8BFB\u53D6\uFF1A` + others.map((o) => `\`${path18.basename(o)}\``).join("\u3001") + " \u2014\u2014 \u4E0D\u540C sourceKey \u7684\u4EA7\u7269**\u4E0D\u53EF\u4E92\u6362**\u3002\n";
14874
16104
  }
14875
16105
  return `${line}
14876
16106
  `;
@@ -14912,7 +16142,7 @@ function runSeedFind(args) {
14912
16142
  const chosen = { reconDir: picked.reconDir, indexFile: picked.indexFile };
14913
16143
  const prefix = picked.prefix;
14914
16144
  process.stdout.write(prefix);
14915
- if (!existsSync4(chosen.indexFile)) {
16145
+ if (!existsSync5(chosen.indexFile)) {
14916
16146
  return premise2(`\u7D22\u5F15\u6587\u4EF6\u5728\u9009\u4E2D\u4E4B\u540E\u6D88\u5931\u4E86\uFF1A${chosen.indexFile}`);
14917
16147
  }
14918
16148
  const { rows: rows2, problems } = loadRows(readFileSync8(chosen.indexFile, "utf-8"));
@@ -14997,9 +16227,9 @@ function indent(text) {
14997
16227
  }
14998
16228
  function metaStepLines(steps) {
14999
16229
  const lines = [];
15000
- for (const step of steps) {
15001
- lines.push(` \xB7 ${step.step} [${step.state}] ${step.detail}`);
15002
- if (step.recovery) lines.push(` \u2192 ${indent(step.recovery)}`);
16230
+ for (const step2 of steps) {
16231
+ lines.push(` \xB7 ${step2.step} [${step2.state}] ${step2.detail}`);
16232
+ if (step2.recovery) lines.push(` \u2192 ${indent(step2.recovery)}`);
15003
16233
  }
15004
16234
  return lines;
15005
16235
  }
@@ -15207,7 +16437,7 @@ import {
15207
16437
  runTriageRound
15208
16438
  } from "@hcmai/sdk";
15209
16439
  import { mkdirSync as mkdirSync2, readFileSync as readFileSync10, writeFileSync as writeFileSync3 } from "fs";
15210
- import * as path18 from "path";
16440
+ import * as path19 from "path";
15211
16441
  var DEFAULT_CAPABILITIES3 = "default";
15212
16442
  function premise4(message, hint) {
15213
16443
  process.stderr.write(`\u{1F534} \u524D\u63D0\u4E0D\u6210\u7ACB\uFF1A${message}
@@ -15243,8 +16473,8 @@ function renderProblems(rows2) {
15243
16473
  `;
15244
16474
  }
15245
16475
  function writeTriageArtifact(outDir, body) {
15246
- const out = path18.join(outDir, "work", "triage.md");
15247
- mkdirSync2(path18.dirname(out), { recursive: true });
16476
+ const out = path19.join(outDir, "work", "triage.md");
16477
+ mkdirSync2(path19.dirname(out), { recursive: true });
15248
16478
  writeFileSync3(out, body, "utf8");
15249
16479
  return out;
15250
16480
  }
@@ -15288,23 +16518,23 @@ init_exit();
15288
16518
  import {
15289
16519
  HcmClient as HcmClient31,
15290
16520
  adminResetPassword,
15291
- formatObject as formatObject31,
16521
+ formatObject as formatObject32,
15292
16522
  fromAxiosError as fromAxiosError23,
15293
- CliError as CliError32,
15294
- CliErrorCode as CliErrorCode34
16523
+ CliError as CliError33,
16524
+ CliErrorCode as CliErrorCode35
15295
16525
  } from "@hcmai/sdk";
15296
16526
  function buildAdminResetPasswordRequest(args, password) {
15297
16527
  const hasId = Boolean(args.id);
15298
16528
  const hasUsername = Boolean(args.username);
15299
16529
  if (hasId === hasUsername) {
15300
- throw new CliError32({
15301
- code: CliErrorCode34.INVALID_ARGUMENT,
16530
+ throw new CliError33({
16531
+ code: CliErrorCode35.INVALID_ARGUMENT,
15302
16532
  message: "--id <uuid> \u4E0E --username <user> \u5FC5\u987B\u4E14\u53EA\u80FD\u63D0\u4F9B\u4E00\u4E2A"
15303
16533
  });
15304
16534
  }
15305
16535
  if (!password) {
15306
- throw new CliError32({
15307
- code: CliErrorCode34.INVALID_ARGUMENT,
16536
+ throw new CliError33({
16537
+ code: CliErrorCode35.INVALID_ARGUMENT,
15308
16538
  message: "\u65B0\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A"
15309
16539
  });
15310
16540
  }
@@ -15322,7 +16552,7 @@ async function userResetPasswordCommand(args) {
15322
16552
  const request = buildAdminResetPasswordRequest(args, password);
15323
16553
  const client3 = HcmClient31.fromAuthContext(await getActiveAuthContextFromCli(args));
15324
16554
  const result = await adminResetPassword(client3.raw(), request);
15325
- process.stdout.write(formatObject31(result, { format: args.output ?? "json" }) + "\n");
16555
+ process.stdout.write(formatObject32(result, { format: args.output ?? "json" }) + "\n");
15326
16556
  } catch (cause) {
15327
16557
  const err = cause;
15328
16558
  if (err?.isAxiosError) exitWithError(fromAxiosError23(err, args.env));
@@ -15333,8 +16563,8 @@ async function promptPasswordTwice() {
15333
16563
  const password = await promptSecret("\u65B0\u5BC6\u7801: ");
15334
16564
  const confirmation = await promptSecret("\u518D\u6B21\u8F93\u5165\u65B0\u5BC6\u7801: ");
15335
16565
  if (password !== confirmation) {
15336
- throw new CliError32({
15337
- code: CliErrorCode34.INVALID_ARGUMENT,
16566
+ throw new CliError33({
16567
+ code: CliErrorCode35.INVALID_ARGUMENT,
15338
16568
  message: "\u4E24\u6B21\u8F93\u5165\u7684\u65B0\u5BC6\u7801\u4E0D\u4E00\u81F4"
15339
16569
  });
15340
16570
  }
@@ -15346,7 +16576,7 @@ init_exit();
15346
16576
  init_auth_guard();
15347
16577
  import {
15348
16578
  HcmClient as HcmClient32,
15349
- formatObject as formatObject32,
16579
+ formatObject as formatObject33,
15350
16580
  fromAxiosError as fromAxiosError24
15351
16581
  } from "@hcmai/sdk";
15352
16582
  async function modelsCommand(keyword, args) {
@@ -15357,7 +16587,7 @@ async function modelsCommand(keyword, args) {
15357
16587
  const rows2 = (needle ? all.filter((m) => JSON.stringify(m).toLowerCase().includes(needle)) : all).sort((a, b) => key(a).localeCompare(key(b)));
15358
16588
  const fmt = args.output ?? "table";
15359
16589
  if (fmt !== "table") {
15360
- process.stdout.write(formatObject32({ total: rows2.length, models: rows2 }, { format: fmt }) + "\n");
16590
+ process.stdout.write(formatObject33({ total: rows2.length, models: rows2 }, { format: fmt }) + "\n");
15361
16591
  process.exitCode = 0;
15362
16592
  return;
15363
16593
  }
@@ -15487,8 +16717,12 @@ gap.command("verify").description("\u9A8C\u6536\uFF1A\u4FEE\u590D\u53D1\u5230\u4
15487
16717
  var kase = chiron.command("case").description("\u516C\u5171\u6848\u4F8B\u5E93\uFF1A\u67E5 search / \u770B show / \u5BF9\u6307\u7EB9 match / \u9879\u76EE\u6848\u4F8B\u4E0A\u884C submit");
15488
16718
  kase.command("search").description("\u6309\u5BA2\u6237\u539F\u8BDD / \u9519\u8BEF\u7801 / Model / \u6280\u80FD\u627E\u516C\u5171\u6848\u4F8B\uFF0C\u5E76\u6309\u5F53\u524D\u73AF\u5883\u6307\u7EB9\u6807\u5339\u914D").argument("<query>", "\u4E00\u53E5\u8BDD\u6216\u5173\u952E\u8BCD").option("--top-k <n>", "\u53D6\u524D\u51E0\u6761\uFF081-10\uFF09", "5").option("--refresh", "\u5FFD\u7565\u672C\u673A\u7D22\u5F15\u7F13\u5B58\uFF08\u9ED8\u8BA4\u5B58\u4E00\u5C0F\u65F6\uFF09\uFF0C\u73B0\u62C9\u4E00\u4EFD \u2014\u2014 \u6848\u4F8B\u521A\u5408\u8FDB\u6848\u4F8B\u5E93\u65F6\u7528").option("--env <name>", "\u7528\u54EA\u4E2A\u73AF\u5883\u7684\u540E\u7AEF\u6307\u7EB9\u6BD4\u5BF9\uFF08\u4E0D\u7ED9\u5C31\u6807\u300C\u672A\u6BD4\u5BF9\u300D\uFF0C\u4E0D\u5047\u88C5\u5339\u914D\uFF09").option(...OUTPUT_OPT).action((query, opts) => caseSearchCommand(query, { ...opts, topK: Number(opts.topK) }));
15489
16719
  kase.command("show").description("\u8BFB\u4E00\u4E2A\u6848\u4F8B\u7684\u6B63\u6587\uFF08\u9ED8\u8BA4 \u95EE\u9898.md + \u65B9\u6848.md\uFF09").argument("<id>", "\u6848\u4F8B id\uFF0C\u5982 CASE-20260828-xxx").option("--refresh", "\u5FFD\u7565\u672C\u673A\u7D22\u5F15\u7F13\u5B58\uFF08\u9ED8\u8BA4\u5B58\u4E00\u5C0F\u65F6\uFF09\uFF0C\u73B0\u62C9\u4E00\u4EFD \u2014\u2014 \u6848\u4F8B\u521A\u5408\u8FDB\u6848\u4F8B\u5E93\u65F6\u7528").option("--file <name>", "\u53EA\u770B\u67D0\u4E00\u4EFD\u6587\u4EF6").option(...OUTPUT_OPT).action((id, opts) => caseShowCommand(id, opts));
15490
- kase.command("match").description("\u5217\u51FA\u5F53\u524D\u73AF\u5883\u6307\u7EB9\u4E0B\u53EF\u7167\u505A\u7684\u516C\u5171\u6848\u4F8B\uFF08status=approved\uFF09").option("--refresh", "\u5FFD\u7565\u672C\u673A\u7D22\u5F15\u7F13\u5B58\uFF08\u9ED8\u8BA4\u5B58\u4E00\u5C0F\u65F6\uFF09\uFF0C\u73B0\u62C9\u4E00\u4EFD \u2014\u2014 \u6848\u4F8B\u521A\u5408\u8FDB\u6848\u4F8B\u5E93\u65F6\u7528").option("--env <name>", "\u7528\u54EA\u4E2A\u73AF\u5883\u7684\u540E\u7AEF\u6307\u7EB9\u6BD4\u5BF9").option(...OUTPUT_OPT).action((opts) => caseMatchCommand(opts));
16720
+ kase.command("match").description("\u5217\u51FA\u5F53\u524D\u73AF\u5883\u6307\u7EB9\u4E0B status=approved \u7684\u516C\u5171\u6848\u4F8B\uFF08approved \u76EE\u524D\u4E0D\u4EE3\u8868\u7ECF\u8FC7\u8BC4\u5BA1\uFF0C\u8F93\u51FA\u91CC\u4F1A\u81EA\u9648\uFF09").option("--refresh", "\u5FFD\u7565\u672C\u673A\u7D22\u5F15\u7F13\u5B58\uFF08\u9ED8\u8BA4\u5B58\u4E00\u5C0F\u65F6\uFF09\uFF0C\u73B0\u62C9\u4E00\u4EFD \u2014\u2014 \u6848\u4F8B\u521A\u5408\u8FDB\u6848\u4F8B\u5E93\u65F6\u7528").option("--env <name>", "\u7528\u54EA\u4E2A\u73AF\u5883\u7684\u540E\u7AEF\u6307\u7EB9\u6BD4\u5BF9").option(...OUTPUT_OPT).action((opts) => caseMatchCommand(opts));
15491
16721
  kase.command("submit").description("\u628A\u9879\u76EE\u6848\u4F8B\u8131\u654F\u4E0A\u884C\u4E3A\u516C\u5171\u6848\u4F8B\uFF1A\u590D\u5236\u8FDB\u672C\u673A clone \u2192 tier=public \u2192 lint \u2192 \u5F00 PR").argument("<dir>", "\u9879\u76EE\u4ED3\u91CC\u7684\u6848\u4F8B\u76EE\u5F55\uFF0C\u5982 cases/CASE-20260902-xxx").requiredOption("--category <name>", "\u516C\u5171\u6848\u4F8B\u7684\u5206\u7C7B\u76EE\u5F55").requiredOption("--origin <text>", "\u6765\u6E90\u8BF4\u660E\uFF0C\u5982\u300C\u9879\u76EE\u4ED3 acme-hr cases/\u2026\u300D").option(...OUTPUT_OPT).action((dir, opts) => caseSubmitCommand(dir, opts));
16722
+ var method = chiron.command("method").description("\u5B9E\u65BD\u65B9\u6CD5\u5305\uFF08\u9636\u6BB5 / \u8D28\u91CF\u95E8 / \u4E13\u9898\u5DE5\u4F5C\u574A\u6280\u80FD\uFF09\uFF1A\u88C5 install / \u5347\u7EA7 update / \u6838\u5BF9 status\u3002\u6309 tag \u53D6\uFF0C\u9879\u76EE\u53EA\u63D0\u4EA4\u9501\u6587\u4EF6\uFF0C\u4E0D\u9700\u8981 HCM \u73AF\u5883");
16723
+ method.command("install").description("\u88C5\u65B9\u6CD5\u5305\uFF1A\u7ED9 --ref \u88C5\u90A3\u4E2A tag\uFF1B\u4E0D\u7ED9\u65F6\u6709\u9501\u6587\u4EF6\u6309\u9501\u6587\u4EF6\u91CD\u88C5\uFF0C\u6CA1\u6709\u5C31\u88C5\u6700\u65B0\u7684\u7248\u672C tag\u3002\u4E09\u5757\u51B2\u7A81\u68C0\u67E5\uFF08CLI \u81EA\u5E26 / \u672C\u9879\u76EE\u5DF2\u88C5 / \u5728\u7EBF\u76EE\u5F55\uFF09\u9010\u5757\u81EA\u9648").option("--ref <tag>", "\u65B9\u6CD5\u5305\u7684\u7248\u672C tag\uFF0C\u5982 v2.0.0").option("--target <agent>", "claude\uFF08\u590D\u5236\u5230 .claude/skills/method-*/\uFF09| codex\uFF08AGENTS.md \u53D7\u7BA1\u5757\u6307\u5411 hcm-methodology/skills/\uFF0C\u6709 CLAUDE.md \u65F6\u955C\u50CF\uFF09| auto", "auto").option("--project <dir>", "\u9879\u76EE\u6839\u76EE\u5F55\uFF08\u4E0D\u7ED9\u5219\u5411\u4E0A\u627E env.yaml\uFF0C\u627E\u4E0D\u5230\u5C31\u7528\u5F53\u524D\u76EE\u5F55\uFF09").option(...OUTPUT_OPT).action((opts) => methodInstallCommand(opts));
16724
+ method.command("update").description("\u4EE5\u9501\u6587\u4EF6\u4E3A\u8D77\u70B9\u6362\u5230 --ref \u6216\u6700\u65B0\u7684\u7248\u672C tag\uFF1A\u5148\u5217\u6280\u80FD\u4E0E\u95E8\u5224\u636E\u7684\u5DEE\u5F02\uFF0C\u518D\u66FF\u6362\u3002\u9501\u6587\u4EF6\u7684\u53D8\u66F4\u8D70\u9879\u76EE PR \u8BC4\u5BA1").option("--ref <tag>", "\u8981\u6362\u5230\u7684\u7248\u672C tag\uFF08\u9ED8\u8BA4\u6700\u65B0\uFF09").option("--target <agent>", "claude | codex | auto", "auto").option("--project <dir>", "\u9879\u76EE\u6839\u76EE\u5F55\uFF08\u4E0D\u7ED9\u5219\u5411\u4E0A\u627E env.yaml\uFF0C\u627E\u4E0D\u5230\u5C31\u7528\u5F53\u524D\u76EE\u5F55\uFF09").option(...OUTPUT_OPT).action((opts) => methodUpdateCommand(opts));
16725
+ method.command("status").description("\u6838\u5BF9\uFF1A\u9501\u5B9A\u4E0E\u672C\u673A\u526F\u672C\u662F\u5426\u4E00\u81F4\u3001\u9010\u6587\u4EF6\u6458\u8981\u3001\u6709\u6CA1\u6709\u65B0\u7248\uFF08\u8FDE\u4E0D\u4E0A\u65F6\u5199 unknown \u4E0E\u4E0A\u6B21\u6838\u5BF9\u65F6\u95F4\uFF09\u3001\u906E\u853D\u3001\u51B2\u7A81\u68C0\u67E5\u4E09\u5757\uFF1B\u4EFB\u4E00\u884C\u7EA2\u5219\u9000\u51FA\u7801 1").option("--project <dir>", "\u9879\u76EE\u6839\u76EE\u5F55\uFF08\u4E0D\u7ED9\u5219\u5411\u4E0A\u627E env.yaml\uFF0C\u627E\u4E0D\u5230\u5C31\u7528\u5F53\u524D\u76EE\u5F55\uFF09").option(...OUTPUT_OPT).action((opts) => methodStatusCommand(opts));
15492
16726
  var recon = chiron.command("recon").description("\u722C\u4E00\u4EFD\u53EF\u5E26\u8D70\u7684\u57FA\u7EBF\uFF1A\u6A21\u578B / \u5B57\u6BB5 / \u53EA\u8BFB\u95F8 / \u4F9D\u8D56\u56FE / \u7801\u8868 / \u53EF\u5199\u6027\u753B\u50CF").option("--env <name>", "\u76EE\u6807\u73AF\u5883\u522B\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--out <dir>", "\u4EA7\u7269\u6839\u76EE\u5F55\uFF08\u4EA7\u7269\u843D\u5728 <out>/recon/<\u79DF\u6237\u6BB5>/<\u6765\u6E90\u6BB5>\uFF09", ".").option("--state <s>", "\u53EA\u8BFB\u95F8\u7684 state\uFF08\u4EA7\u54C1\u91CC state \u4E0D\u53EF\u679A\u4E3E\uFF0C\u95F8\u7684\u8986\u76D6\u9762\u6C38\u8FDC\u662F state-scoped\uFF09").option("--model <key>", "\u5B9A\u5411\u91CD\u722C\uFF1A\u53EA\u91CD\u722C\u8FD9\u4E00\u4E2A\u6A21\u578B\uFF0C\u5176\u4F59\u6CBF\u7528\u4E0A\u4E00\u8F6E\u4EA7\u7269").option("--capabilities <s>", "\u722C\u53D6\u65F6\u58F0\u660E\u7684 capability \u4E32\uFF08\u4F1A\u968F\u56DB\u5143\u7EC4\u7559\u6863\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => deliveryReconCommand(opts));
15493
16727
  recon.command("round").description("\u96F6\u7F51\u7EDC\uFF1A\u8BFB\u4E00\u4EFD\u5DF2\u843D\u76D8\u7684\u57FA\u7EBF\uFF0C\u5224\u65AD\u5B83\u662F\u4E0D\u662F\u4E00\u8F6E\u5B8C\u6574\u8DD1\u51FA\u6765\u7684\uFF08complete/mixed/unknown\uFF09").option("--dir <dir>", "\u4EA7\u7269\u76EE\u5F55\uFF08<out>/recon/<\u79DF\u6237\u6BB5>/<\u6765\u6E90\u6BB5>\uFF09", ".").action(
15494
16728
  (opts, cmd) => deliveryReconRoundCommand({
@@ -15518,7 +16752,7 @@ seed.command("apply").description("\u7167\u8BA1\u5212\u628A\u884C\u5EFA\u8FDB\u5
15518
16752
  seed.command("verify").description(
15519
16753
  "\u628A\u4E24\u5C42\u8BC1\u636E\uFF08\u53F0\u8D26+\u8BA1\u5212 / \u5E93\u91CC\u73B0\u5728\u600E\u4E48\u6837\uFF09\u6E32\u67D3\u6210\u4E00\u9875\u53EF\u7B7E\u5B57\u7684\u7EB8\uFF0C\u518D\u7ED9\u4E00\u4E2A\u9000\u51FA\u7801\u3002\u6C14\u9699\u673A\u5668\u4E0A\u7528 `--ledger-only`\uFF1A\u53EA\u51FA\u53F0\u8D26\u90A3\u4E00\u5C42\uFF0C\u4E00\u53D1\u8BF7\u6C42\u90FD\u4E0D\u53D1"
15520
16754
  ).option("--env <name>", "\u76EE\u6807\u73AF\u5883\u522B\u540D").option("--profile <name>", "\u8EAB\u4EFD\u6863\u6848").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--out <dir>", "recon \u4EA7\u7269\u6839", ".").option("--work <dir>", "work \u76EE\u5F55\uFF1B\u4E0D\u7ED9 \u21D2 <out>/work/<\u79DF\u6237\u6BB5>/").option(
15521
- LEDGER_ONLY_FLAG,
16755
+ LEDGER_ONLY_FLAG2,
15522
16756
  "\u53EA\u51FA\u53F0\u8D26\u90A3\u4E00\u5C42\uFF08\u96F6\u7F51\u7EDC\uFF0C\u4E00\u53D1\u8BF7\u6C42\u90FD\u4E0D\u53D1\uFF09\u3002\u26A0\uFE0F **\u5E93\u91CC\u73B0\u5728\u600E\u4E48\u6837\uFF0C\u90A3\u4E00\u8D9F\u4E00\u4E2A\u5B57\u90FD\u6CA1\u95EE** \u2014\u2014 \u522B\u62FF\u5B83\u5F53\u9A8C\u6536\u901A\u8FC7",
15523
16757
  false
15524
16758
  ).action((opts) => deliverySeedVerifyCommand(opts));
@@ -15686,7 +16920,7 @@ program.command("update <Model>").description("\u66F4\u65B0\u4E00\u6761 Model \u
15686
16920
  ).action((model, opts) => updateCommand(model, opts));
15687
16921
  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));
15688
16922
  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));
15689
- program.command("open [path]").description("\u7528\u5F53\u524D CLI \u8EAB\u4EFD\u6253\u5F00\u524D\u7AEF\u9875\u9762\uFF1A\u94F8\u4E00\u5F20 60s \u4E00\u6B21\u6027\u7968\u636E\u4EA4\u7ED9\u6D4F\u89C8\u5668\uFF0C\u4F1A\u8BDD token \u4E0D\u8FDB URL").option("--print-url", "\u53EA\u6253\u5370\u767B\u5F55 URL\uFF0C\u4E0D\u5F00\u6D4F\u89C8\u5668\uFF08\u7ED9 agent \u6D4F\u89C8\u5668 navigate \u7528\uFF09").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").action((path19, opts) => openCommand(path19, opts));
16923
+ 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((path20, opts) => openCommand(path20, opts));
15690
16924
  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");
15691
16925
  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));
15692
16926
  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(