@hcmai/cli 0.14.1 → 0.14.3

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
@@ -203,7 +203,8 @@ async function ensureActiveAuth(args) {
203
203
  if (idMeta.expiresAt && new Date(idMeta.expiresAt) < /* @__PURE__ */ new Date()) {
204
204
  throw new CliError2({
205
205
  code: CliErrorCode.TOKEN_EXPIRED,
206
- message: `identity '${identityName}' token expired. Run: hcm login --env ${envName}`
206
+ message: `identity '${identityName}' token expired. Run: hcm login --env ${envName}`,
207
+ context: await deadlockHint(envName)
207
208
  });
208
209
  }
209
210
  return finishContext({
@@ -328,6 +329,22 @@ async function getActiveAuthContextFromCli(args, opts) {
328
329
  const ctx = await ensureActiveAuth({ envFlag, asFlag: args.as, fallbackEnv: opts?.fallbackEnv, allowDanger: args.allowDanger });
329
330
  return ctx;
330
331
  }
332
+ async function deadlockHint(envName) {
333
+ try {
334
+ const names = await listIdentities(envName);
335
+ if (names.length < 2) return void 0;
336
+ const now = /* @__PURE__ */ new Date();
337
+ for (const name of names) {
338
+ const meta2 = await loadIdentity(name);
339
+ if (!meta2.expiresAt || new Date(meta2.expiresAt) >= now) return void 0;
340
+ }
341
+ return {
342
+ details: `\u8BE5\u73AF\u5883\u767B\u8BB0\u7684 ${names.length} \u4E2A\u8EAB\u4EFD\u5168\u90E8\u8FC7\u671F\u3002\u82E5\u53E3\u4EE4\u540C\u6837\u4E0D\u53EF\u7528\uFF0C\u89E3\u9501/\u6539\u5BC6/\u9881 PAT \u4E09\u6761\u6062\u590D\u8DEF\u90FD\u4F1A\u56E0\u300C\u9700\u8981\u7BA1\u7406\u5458 token\u300D\u800C\u540C\u65F6\u65AD\u6B7B\u2014\u2014\u6B64\u65F6\u8D70\u670D\u52A1\u5668\u672C\u673A\u7684\u5E94\u6025\u51ED\u636E\u91CD\u7F6E\uFF08break-glass\uFF09\uFF1A\u5728\u670D\u52A1\u5668\u4E0A curl -s -X POST 127.0.0.1:<\u7AEF\u53E3>/internal/breakglass/challenge \u5E76\u6309\u54CD\u5E94\u7684 nextStep \u64CD\u4F5C\u3002\u624B\u518C\uFF1Adocs/how-to/rbac/break-glass-credential-reset.md\uFF08hcm_nx_core\uFF09\u3002\u4E0D\u8981\u7ED5\u8FC7 API \u76F4\u63A5\u6539\u5E93\u3002`
343
+ };
344
+ } catch {
345
+ return void 0;
346
+ }
347
+ }
331
348
  var init_auth_guard = __esm({
332
349
  "src/middleware/auth-guard.ts"() {
333
350
  "use strict";
@@ -6212,27 +6229,57 @@ var INDEX_CACHE = () => path4.join(casesCacheDir(), "index.json");
6212
6229
  var INDEX_TTL_MS = 60 * 60 * 1e3;
6213
6230
  var fail5 = (message, nextStep) => new CliError18({ code: CliErrorCode17.INVALID_ARGUMENT, message, context: { nextStep } });
6214
6231
  var run = (cmd, args, opts = {}) => execFileSync(cmd, args, { encoding: "utf8", maxBuffer: 1 << 26, ...opts });
6232
+ function parseCnbEnvelope(raw, what) {
6233
+ const trimmed = raw.trim();
6234
+ let parsed;
6235
+ try {
6236
+ parsed = JSON.parse(trimmed);
6237
+ } catch {
6238
+ throw fail5(
6239
+ `cnb \u7684\u56DE\u6267\u4E0D\u662F JSON\uFF08${what}\uFF09\u3002\u5F00\u5934\u662F\uFF1A${trimmed.slice(0, 200)}`,
6240
+ "\u5148\u81EA\u5DF1\u8DD1\u4E00\u6B21 `cnb \u2026 --verbose` \u770B\u56DE\u6267\uFF1B\u786E\u8BA4\u5B83\u786E\u5B9E\u4E0D\u662F JSON \u4E4B\u540E\uFF0C\u628A\u4E0A\u9762\u90A3\u6BB5\u8FDE\u540C `cnb --version` \u4E00\u8D77\u62A5\u7ED9 CLI \u7EF4\u62A4\u8005\u3002"
6241
+ );
6242
+ }
6243
+ const envelope = parsed;
6244
+ if (typeof envelope.status === "number" && envelope.status >= 400) {
6245
+ const detail = envelope.data?.errmsg;
6246
+ throw fail5(
6247
+ `cnb \u56DE\u4E86 HTTP ${envelope.status}\uFF08${what}\uFF09${detail ? `\uFF1A${detail}` : ""}`,
6248
+ envelope.status === 404 || envelope.status === 403 ? `\u591A\u534A\u662F**\u6743\u9650\u6216\u8DEF\u5F84**\uFF0C\u4E0D\u662F CLI \u7248\u672C\uFF1A
6249
+ 1. \`cnb git get-raw --repo ${CASES_REPO_SLUG} --ref-with-path main/index/index.json\` \u81EA\u5DF1\u8DD1\u4E00\u6B21\u770B\u56DE\u6267
6250
+ 2. \u8FD9\u4E00\u53D1\u8981\u7684\u662F**\u4EE3\u7801\u8BFB\u6743\u9650**\uFF08repo-code:r\uFF09\uFF1B\u5728\u7F51\u9875\u4E0A\u80FD\u6253\u5F00\u6587\u4EF6\u4E0D\u7B49\u4E8E\u8FD9\u4E2A\u4EE4\u724C\u6709\u8FD9\u4E2A\u6743\u9650
6251
+ 3. \u786E\u8BA4 \`cnb login\` \u8FC7\u3001\u4E14\u8D26\u53F7\u5BF9 ${CASES_REPO_SLUG} \u6709\u8BFB\u6743\u9650
6252
+ \u53D6\u4E0D\u5230\u6848\u4F8B\u5E93\u4E0D\u62E6\u8DEF\uFF1A\u5148\u8DF3\u8FC7\u5B83\u6309\u6280\u80FD\u505A\uFF0C\u522B\u628A\u300C\u53D6\u4E0D\u5230\u300D\u5F53\u6210\u300C\u6CA1\u6709\u5148\u4F8B\u300D\u3002` : "\u628A\u4E0A\u9762\u8FD9\u6BB5\u8FDE\u540C `cnb --version` \u4E00\u8D77\u62A5\u7ED9 CLI \u7EF4\u62A4\u8005\u3002"
6253
+ );
6254
+ }
6255
+ if (envelope.data === void 0) {
6256
+ throw fail5(
6257
+ `cnb \u7684\u56DE\u6267\u91CC\u6CA1\u6709 data \u5B57\u6BB5\uFF08${what}\uFF09\u3002\u56DE\u6267\u662F\uFF1A${trimmed.slice(0, 200)}`,
6258
+ "\u672C\u547D\u4EE4\u8BFB\u7684\u662F `cnb \u2026 --verbose` \u7684 `data` \u5B57\u6BB5\u3002\u628A\u4E0A\u9762\u90A3\u6BB5\u8FDE\u540C `cnb --version` \u4E00\u8D77\u62A5\u7ED9 CLI \u7EF4\u62A4\u8005\u3002"
6259
+ );
6260
+ }
6261
+ return envelope.data;
6262
+ }
6215
6263
  function fetchRepoFile(relPath) {
6216
6264
  let raw;
6217
6265
  try {
6218
- raw = run("cnb", ["git", "get-raw", "--repo", CASES_REPO_SLUG, "--ref-with-path", `main/${relPath}`]);
6266
+ raw = run("cnb", [
6267
+ "git",
6268
+ "get-raw",
6269
+ "--repo",
6270
+ CASES_REPO_SLUG,
6271
+ "--ref-with-path",
6272
+ `main/${relPath}`,
6273
+ "--verbose"
6274
+ ]);
6219
6275
  } catch (e) {
6220
6276
  throw fail5(
6221
6277
  `\u53D6\u4E0D\u5230\u6848\u4F8B\u5E93\u6587\u4EF6 ${relPath}\uFF1A${String(e.message).split("\n")[0]}`,
6222
6278
  "\u6848\u4F8B\u5E93\u8BFB\u53D6\u8D70 cnb\uFF08\u9700\u8981\u5DF2 `cnb login` \u4E14\u6709\u8BE5\u4ED3\u8BFB\u6743\u9650\uFF09\u3002\u6CA1\u6709\u6743\u9650\u5C31\u5148\u8DF3\u8FC7\u6848\u4F8B\u5E93\uFF0C\u76F4\u63A5\u6309\u6280\u80FD\u505A\uFF1B\u522B\u628A\u300C\u53D6\u4E0D\u5230\u300D\u5F53\u6210\u300C\u6CA1\u6709\u5148\u4F8B\u300D\u3002"
6223
6279
  );
6224
6280
  }
6225
- const i = raw.indexOf("data: ");
6226
- if (i < 0) throw fail5(`cnb \u7684\u56DE\u6267\u91CC\u6CA1\u6709 data \u90A3\u4E00\u683C\uFF1A${relPath}`, "\u5347\u7EA7 cnb CLI\uFF0C\u6216\u628A\u8FD9\u6BB5\u539F\u6837\u8D34\u7ED9\u6211\u3002");
6227
- const body = raw.slice(i + "data: ".length).trim();
6228
- if (body.startsWith('"')) {
6229
- try {
6230
- return JSON.parse(body);
6231
- } catch {
6232
- return body;
6233
- }
6234
- }
6235
- return body;
6281
+ const body = parseCnbEnvelope(raw, relPath);
6282
+ return typeof body === "string" ? body : JSON.stringify(body);
6236
6283
  }
6237
6284
  function loadIndex(opts = {}) {
6238
6285
  const file = INDEX_CACHE();
@@ -6310,9 +6357,9 @@ async function caseSearchCommand(query, args) {
6310
6357
  "\u68C0\u7D22\u8D70 cnb \u7684\u77E5\u8BC6\u5E93\u63A5\u53E3\uFF0C\u9700\u8981 cnb \u5DF2\u767B\u5F55\u4E14\u6709\u6848\u4F8B\u5E93\u6743\u9650\u3002\u6CA1\u6709\u5C31\u5148\u8DF3\u8FC7\u6848\u4F8B\u5E93\uFF0C\u76F4\u63A5\u6309\u6280\u80FD\u505A\uFF1B\u522B\u628A\u300C\u67E5\u4E0D\u5230\u300D\u5F53\u6210\u300C\u6CA1\u6709\u5148\u4F8B\u300D\u3002"
6311
6358
  );
6312
6359
  }
6313
- const json = JSON.parse(raw.slice(raw.indexOf("{")));
6360
+ const hits = parseCnbEnvelope(raw, `\u68C0\u7D22\u300C${query}\u300D`);
6314
6361
  const seen = /* @__PURE__ */ new Map();
6315
- for (const h of json.data ?? []) {
6362
+ for (const h of hits ?? []) {
6316
6363
  const p = h.metadata?.path ?? "";
6317
6364
  const m = /^cases\/[^/]+\/([^/]+)\//.exec(p);
6318
6365
  if (!m) continue;
@@ -6611,6 +6658,11 @@ function collectBundledSkills(dir = bundledSkillsDir()) {
6611
6658
  stages: strArray(fm.stages),
6612
6659
  actionSurface: str(fm.actionSurface),
6613
6660
  requires: strArray(fm.requires),
6661
+ // 🔴 这一行原来是漏的:`BundledSkillEntry.renamedFrom` 的字段注释写着
6662
+ // 「`sync` 靠它清掉存量仓里的旧份」,而清单根本没读它 —— 于是**自带技能**改名时
6663
+ // 清理链路恒不触发(睿戎那一半读的是服务端目录,所以只有自带这一半是瞎的)。
6664
+ // 2026-09-09 独立核查逮到;同源于「解析了就要显示」,只是这里连解析都没做。
6665
+ renamedFrom: strArray(fm.renamedFrom),
6614
6666
  bytes,
6615
6667
  files: fileRows
6616
6668
  });
@@ -6976,8 +7028,23 @@ async function listInstalledSkills(keyword, args, cwd = process.cwd()) {
6976
7028
  const fmt = args.output ?? "table";
6977
7029
  const localSkills = await readLocalSkills(layout.localDir);
6978
7030
  if ((!state || Object.keys(state.skills).length === 0) && localSkills.length === 0) {
7031
+ const legacy = await detectLegacyFlatLayout(layout);
7032
+ const legacyState = legacy ? await readSkillsState(legacy) : void 0;
6979
7033
  if (fmt === "json" || fmt === "yaml") {
6980
- process.stdout.write(formatObject17({ baseDir: layout.baseDir, target: layout.target, all: false, skills: [] }, { format: fmt }) + "\n");
7034
+ process.stdout.write(formatObject17({
7035
+ baseDir: layout.baseDir,
7036
+ target: layout.target,
7037
+ all: false,
7038
+ skills: [],
7039
+ ...legacy ? { legacyFlatLayout: { dir: legacy, skills: Object.keys(legacyState?.skills ?? {}).length } } : {}
7040
+ }, { format: fmt }) + "\n");
7041
+ process.exitCode = 0;
7042
+ return;
7043
+ }
7044
+ if (legacy) {
7045
+ process.stdout.write(`\u8FD9\u4E2A\u4ED3\u8FD8\u662F\u65E7\u7684\u6241\u5E73\u5E03\u5C40\uFF1A${Object.keys(legacyState?.skills ?? {}).length} \u4EFD\u6280\u80FD\u5728 ${legacy}/ \u4E0B\uFF0C\u800C 0.14.0 \u8D77\u4EA7\u54C1\u90A3\u4E00\u534A\u5E94\u8BE5\u5728 ${legacy}/${SKILLS_SYNC_SUBDIR}/\u3002
7046
+ `);
7047
+ process.stdout.write(" \u8DD1\u4E00\u6B21 hcm chiron skills sync \u5C31\u5730\u5206\u597D\uFF08\u5E42\u7B49\uFF0C\u4E0D\u4F1A\u91CD\u88C5\uFF09\u3002\n");
6981
7048
  process.exitCode = 0;
6982
7049
  return;
6983
7050
  }
@@ -7225,6 +7292,27 @@ async function skillsInstallCommand(id, args) {
7225
7292
  }
7226
7293
  if (args.check) {
7227
7294
  const fmtCheck = args.output ?? "table";
7295
+ const legacyForCheck = await detectLegacyFlatLayout(layout);
7296
+ if (legacyForCheck) {
7297
+ const legacyState = await readSkillsState(legacyForCheck);
7298
+ const count = Object.keys(legacyState?.skills ?? {}).length;
7299
+ if (fmtCheck === "json" || fmtCheck === "yaml") {
7300
+ process.stdout.write(formatObject17({
7301
+ dryRun: true,
7302
+ legacyFlatLayout: { dir: legacyForCheck, skills: count },
7303
+ wouldMigrate: true,
7304
+ baseDir: layout.baseDir
7305
+ }, { format: fmtCheck }) + "\n");
7306
+ } else {
7307
+ process.stdout.write(`\u8FD9\u4E2A\u4ED3\u8FD8\u662F\u65E7\u7684\u6241\u5E73\u5E03\u5C40\uFF1A${count} \u4EFD\u6280\u80FD\u5728 ${legacyForCheck}/ \u4E0B\u3002
7308
+ `);
7309
+ process.stdout.write(`--check\uFF1A\u771F\u8DD1\u4F1A\u5148\u628A\u5B83\u5C31\u5730\u5206\u6210 ${SKILLS_SYNC_SUBDIR}/\uFF08\u4EA7\u54C1\u7684\uFF09\u4E0E ${SKILLS_LOCAL_SUBDIR}/\uFF08\u4F60\u81EA\u5DF1\u7684\uFF09\u4E24\u534A\uFF0C**\u518D**\u6309\u4EA7\u54C1\u5F53\u524D\u5168\u96C6\u5BF9\u8D26\u2014\u2014\u4E0D\u662F\u91CD\u88C5\u3002**\u672C\u6B21\u4E00\u4E2A\u5B57\u8282\u90FD\u6CA1\u5199\u3002**
7310
+ `);
7311
+ process.stdout.write(" \u771F\u8DD1\uFF1A\u53BB\u6389 --check \u91CD\u8DD1\u3002\n");
7312
+ }
7313
+ process.exitCode = 0;
7314
+ return;
7315
+ }
7228
7316
  const would = documents.map((d) => d.id).sort();
7229
7317
  if (fmtCheck === "json" || fmtCheck === "yaml") {
7230
7318
  process.stdout.write(formatObject17({
@@ -8047,6 +8135,12 @@ async function skillsUpdateCommand(args) {
8047
8135
  fail6(e, args);
8048
8136
  }
8049
8137
  }
8138
+ async function detectLegacyFlatLayout(layout) {
8139
+ if (!layout.localDir) return void 0;
8140
+ if (await readSkillsState(layout.baseDir)) return void 0;
8141
+ const legacyRoot = path8.dirname(layout.baseDir);
8142
+ return await readSkillsState(legacyRoot) ? legacyRoot : void 0;
8143
+ }
8050
8144
  async function migrateFlatSkillsLayout(skillsRoot) {
8051
8145
  const legacyState = path8.join(skillsRoot, SKILLS_STATE_FILE);
8052
8146
  const syncDir = path8.join(skillsRoot, SKILLS_SYNC_SUBDIR);
@@ -8061,14 +8155,25 @@ async function migrateFlatSkillsLayout(skillsRoot) {
8061
8155
  } catch {
8062
8156
  return { moved: [], migrated: false };
8063
8157
  }
8158
+ for (const reserved of [SKILLS_SYNC_SUBDIR, SKILLS_LOCAL_SUBDIR]) {
8159
+ if (!owned.has(reserved)) continue;
8160
+ throw invalid(`\u6280\u80FD id \u649E\u4E0A\u76EE\u5F55\u540D ${reserved}\uFF1A${skillsRoot} \u5206\u4E0D\u6210\u4E24\u534A\u3002\u8FD9\u662F\u4EA7\u54C1\u4FA7\u7684 id \u51B2\u7A81\uFF0C\u62A5\u7ED9\u4EA7\u54C1\u65B9\u6539\u540D\uFF1B\u5728\u90A3\u4E4B\u524D\u7528 --dir \u6307\u5B9A\u4E00\u4E2A\u522B\u7684\u843D\u70B9\u3002`);
8161
+ }
8064
8162
  const moved = [];
8065
8163
  for (const id of names) {
8066
8164
  const hasSkill = await fsp2.stat(path8.join(skillsRoot, id, "SKILL.md")).then(() => true).catch(() => false);
8067
8165
  if (!hasSkill) continue;
8068
8166
  const to = owned.has(id) ? "sync" : "local";
8069
8167
  const target = path8.join(to === "sync" ? syncDir : localDir, id);
8168
+ if (await fsp2.stat(target).then(() => true).catch(() => false)) {
8169
+ throw invalid(`${target} \u5DF2\u7ECF\u5B58\u5728\uFF0C${id} \u642C\u4E0D\u8FC7\u53BB \u2014\u2014 \u5DF2\u7ECF\u642C\u597D\u7684\u90A3\u4E9B\u7559\u5728\u539F\u5730\uFF0C\u6CA1\u6709\u534A\u4EFD\u6587\u4EF6\u3002\u6253\u5F00\u8FD9\u4E24\u4E2A\u76EE\u5F55\u6BD4\u4E00\u6BD4\uFF0C\u7559\u4E00\u4EFD\u3001\u5220\u53E6\u4E00\u4EFD\uFF0C\u7136\u540E\u91CD\u8DD1 hcm chiron skills sync\u3002`);
8170
+ }
8070
8171
  await fsp2.mkdir(path8.dirname(target), { recursive: true });
8071
- await fsp2.rename(path8.join(skillsRoot, id), target);
8172
+ try {
8173
+ await fsp2.rename(path8.join(skillsRoot, id), target);
8174
+ } catch (cause) {
8175
+ throw invalid(`\u628A ${id} \u642C\u8FDB ${to}/ \u5931\u8D25\uFF1A${cause.message}\u3002\u5DF2\u7ECF\u642C\u597D\u7684 ${moved.length} \u4EFD\u5728\u65B0\u4F4D\u7F6E\uFF0C\u6CA1\u642C\u7684\u8FD8\u5728\u539F\u5730\uFF0C\u4E24\u8FB9\u90FD\u662F\u5B8C\u6574\u76EE\u5F55 \u2014\u2014 \u5904\u7406\u6389\u8FD9\u4E2A\u9519\u8BEF\u4E4B\u540E\u91CD\u8DD1 hcm chiron skills sync \u4F1A\u63A5\u7740\u642C\u5B8C\u3002`);
8176
+ }
8072
8177
  moved.push({ id, to });
8073
8178
  }
8074
8179
  await fsp2.mkdir(syncDir, { recursive: true });
@@ -8094,7 +8199,7 @@ var defaultSkillsSyncDeps = {
8094
8199
  migrate: async (args) => {
8095
8200
  const layout = await resolveInstallLayout(args).catch(() => null);
8096
8201
  if (!layout || !layout.localDir) return { moved: [], migrated: false };
8097
- return migrateFlatSkillsLayout(path8.dirname(layout.baseDir)).catch(() => ({ moved: [], migrated: false }));
8202
+ return migrateFlatSkillsLayout(path8.dirname(layout.baseDir));
8098
8203
  }
8099
8204
  };
8100
8205
  async function skillsSyncCommand(args, deps = defaultSkillsSyncDeps) {
@@ -8105,7 +8210,12 @@ async function skillsSyncCommand(args, deps = defaultSkillsSyncDeps) {
8105
8210
  return exitWithError(e);
8106
8211
  }
8107
8212
  if (!args.check) {
8108
- const result = await deps.migrate(args);
8213
+ let result;
8214
+ try {
8215
+ result = await deps.migrate(args);
8216
+ } catch (e) {
8217
+ return exitWithError(e);
8218
+ }
8109
8219
  if (result.migrated) {
8110
8220
  const toSync = result.moved.filter((m) => m.to === "sync");
8111
8221
  const toLocal = result.moved.filter((m) => m.to === "local");
@@ -8274,11 +8384,17 @@ init_auth_guard();
8274
8384
  async function client2(args) {
8275
8385
  return HcmClient18.fromAuthContext(await getActiveAuthContextFromCli(args));
8276
8386
  }
8277
- function fail7(e, args) {
8387
+ function formatMetaForbiddenMessage(mode = "write") {
8388
+ if (mode === "read") {
8389
+ return "\u5143\u6570\u636E\u8BFB\u53D6\u88AB\u62D2\uFF08403\uFF09\u2014\u2014 \u7F3A\u5C11 config-admin \u8BFB\u53D6\u6743\u9650\uFF1Bnext_step\uFF1A\u6362\u7528\u6709\u6743\u9650\u7684\u8EAB\u4EFD\uFF0C\u6216\u8BA9\u7BA1\u7406\u5458\u4EE3\u8BFB";
8390
+ }
8391
+ return "\u5143\u6570\u636E\u5199\u5165\u88AB\u62D2\uFF08403\uFF09\u2014\u2014 \u9700 config-admin \u8EAB\u4EFD\u4E14\u5F53\u524D source \u53EF\u5199\uFF1B\u82E5\u5728\u79DF\u6237\u5F00\u53D1\u7A7A\u95F4\u5916\uFF0C\u5148 `hcm workspace bind <key>`";
8392
+ }
8393
+ function fail7(e, args, mode = "write") {
8278
8394
  const err = e;
8279
8395
  if (err?.response?.status === 403) {
8280
8396
  exitWithError(
8281
- new Error("\u5143\u6570\u636E\u5199\u5165\u88AB\u62D2\uFF08403\uFF09\u2014\u2014 \u9700 config-admin \u8EAB\u4EFD\u4E14\u5F53\u524D source \u53EF\u5199\uFF1B\u82E5\u5728\u79DF\u6237\u5F00\u53D1\u7A7A\u95F4\u5916\uFF0C\u5148 `hcm workspace bind <key>`")
8397
+ new Error(formatMetaForbiddenMessage(mode))
8282
8398
  );
8283
8399
  }
8284
8400
  if (err?.isAxiosError) exitWithError(fromAxiosError18(err, args.env));
@@ -8301,7 +8417,7 @@ async function metaListCommand(args) {
8301
8417
  process.exitCode = 0;
8302
8418
  return;
8303
8419
  } catch (e) {
8304
- fail7(e, args);
8420
+ fail7(e, args, "read");
8305
8421
  }
8306
8422
  }
8307
8423
  async function metaGetCommand(path18, args) {
@@ -8312,7 +8428,7 @@ async function metaGetCommand(path18, args) {
8312
8428
  process.exitCode = 0;
8313
8429
  return;
8314
8430
  } catch (e) {
8315
- fail7(e, args);
8431
+ fail7(e, args, "read");
8316
8432
  }
8317
8433
  }
8318
8434
  var PROBEABLE_META_TYPES = /* @__PURE__ */ new Set(["model", "list", "info", "view", "filter", "page", "wiz", "impexp"]);
@@ -10130,6 +10246,7 @@ import {
10130
10246
  CliError as CliError23,
10131
10247
  CliErrorCode as CliErrorCode22,
10132
10248
  formatObject as formatObject21,
10249
+ formatRows as formatRows6,
10133
10250
  fromAxiosError as fromAxiosError20,
10134
10251
  loadEnv as loadEnv4,
10135
10252
  saveEnv as saveEnv3,
@@ -10193,18 +10310,23 @@ async function identityList(args) {
10193
10310
  const g = await loadGlobalConfig8();
10194
10311
  const filter = args.env === "all" ? void 0 : await resolveActiveEnv({ envFlag: args.env }, process.env, g);
10195
10312
  const names = await listIdentities4(filter);
10313
+ const fmt = args.output ?? "table";
10196
10314
  if (names.length === 0) {
10197
- return exitOk("(no identities)");
10315
+ return exitOk(fmt === "table" ? "(no identities)" : formatObject21([], { format: fmt }));
10198
10316
  }
10199
- const lines = [];
10317
+ const rows2 = [];
10200
10318
  for (const n of names) {
10201
10319
  const meta2 = await loadIdentity4(n);
10202
10320
  const env2 = await loadEnv4(meta2.env).catch(() => null);
10203
- const isDefault = env2?.defaultIdentity === n ? "*" : " ";
10204
- const expired = meta2.expiresAt && new Date(meta2.expiresAt) < /* @__PURE__ */ new Date() ? " (expired)" : "";
10205
- lines.push(`${isDefault} ${n} scheme=${meta2.scheme} env=${meta2.env}${expired}`);
10321
+ rows2.push({
10322
+ name: n,
10323
+ scheme: meta2.scheme,
10324
+ env: meta2.env,
10325
+ expired: Boolean(meta2.expiresAt && new Date(meta2.expiresAt) < /* @__PURE__ */ new Date()),
10326
+ isDefault: env2?.defaultIdentity === n
10327
+ });
10206
10328
  }
10207
- return exitOk(lines.join("\n"));
10329
+ return exitOk(fmt === "table" ? formatRows6(rows2, { format: fmt }) : formatObject21(rows2, { format: fmt }));
10208
10330
  } catch (e) {
10209
10331
  exitWithError(e);
10210
10332
  }
@@ -10463,7 +10585,7 @@ async function chironInitCommand(args, deps) {
10463
10585
  `\u2705 \u9879\u76EE\u5DF2\u521D\u59CB\u5316\uFF1A${result.project}`,
10464
10586
  ` \u73AF\u5883 ${result.env} \xB7 ${result.endpoint} \xB7 \u79DF\u6237 ${result.tenant} \xB7 \u8EAB\u4EFD ${result.identity ?? "\uFF08\u672C\u673A\u672A\u767B\u5F55\uFF09"}\uFF08\u6765\u81EA ${result.envSource}\uFF09`,
10465
10587
  ` ${mark} \u79DF\u6237 ${result.tenantCheck.detail ?? result.tenantCheck.status}`,
10466
- ` \u6280\u80FD ${result.skills === "installed" ? `\u5DF2\u88C5\u5230 ${SKILLS_DIR}/` : "\u672A\u88C5\uFF08hcm chiron skills sync \u88C5\uFF09"}`,
10588
+ ` \u6280\u80FD ${result.skills === "installed" ? `\u5DF2\u88C5\u5230 ${SKILLS_DIR}/sync/\uFF08\u4F60\u81EA\u5DF1\u5199\u7684\u653E ${SKILLS_DIR}/local/\uFF09` : "\u672A\u88C5\uFF08hcm chiron skills sync \u88C5\uFF09"}`,
10467
10589
  ` \u4E0B\u4E00\u6B65\uFF1A${result.nextStep}`
10468
10590
  ].join("\n") + "\n"
10469
10591
  );
@@ -10925,6 +11047,15 @@ async function runChironDoctor(args, deps = defaultDeps2) {
10925
11047
  const skillsLine = async () => {
10926
11048
  const state = await readSkillsState(skillsSyncDir(root));
10927
11049
  if (!state) {
11050
+ const legacy = await readSkillsState(path11.join(root, SKILLS_DIR));
11051
+ if (legacy) {
11052
+ return {
11053
+ item: "\u6280\u80FD",
11054
+ verdict: "warn",
11055
+ detail: `${Object.keys(legacy.skills).length} \u4E2A\uFF0C\u4F46\u8FD8\u662F 0.14.0 \u4E4B\u524D\u7684\u6241\u5E73\u5E03\u5C40\uFF08\u6E05\u5355\u5728 ${SKILLS_DIR}/\uFF0C\u4EA7\u54C1\u90A3\u4E00\u534A\u5E94\u8BE5\u5728 ${SKILLS_DIR}/${SKILLS_SYNC_SUBDIR}/\uFF09`,
11056
+ nextStep: "hcm chiron skills sync \u5C31\u5730\u5206\u6210\u4E24\u534A\uFF08\u5E42\u7B49\uFF0C\u4E0D\u4F1A\u91CD\u88C5\uFF09"
11057
+ };
11058
+ }
10928
11059
  return {
10929
11060
  item: "\u6280\u80FD",
10930
11061
  verdict: "fail",
@@ -13423,7 +13554,7 @@ env.command("remove <name>").description("\u5220\u9664 env\uFF08\u7EA7\u8054\u6E
13423
13554
  env.command("show [name]").description("\u663E\u793A env \u8BE6\u60C5\uFF08\u542B\u8BE5 env \u4E0B\u7684 identity \u5217\u8868\uFF09").action((name) => envShow({ name }));
13424
13555
  env.command("edit <field> <value>").description("\u7F16\u8F91 env \u5B57\u6BB5\uFF08endpoint / frontend / tenantId / defaultIdentity / defaultAgent\uFF09").option("--env <name>", "\u76EE\u6807 env \u540D\uFF08\u9ED8\u8BA4\u5F53\u524D activeEnv\uFF09").action((field, value, opts) => envEdit(field, value, opts));
13425
13556
  var identity = program.command("identity").description("\u7BA1\u7406 HCM \u8EAB\u4EFD\u51ED\u636E\uFF08env \u4E0B\u7684 identity\uFF09");
13426
- identity.command("list").description("\u5217\u51FA identity\uFF08\u9ED8\u8BA4\u5217\u5F53\u524D env\uFF0C--env all \u5217\u5168\u90E8\uFF09").option("--env <name>", '\u8FC7\u6EE4 env\uFF1B\u4F20 "all" \u5217\u5168\u90E8', void 0).action((opts) => identityList(opts));
13557
+ identity.command("list").description("\u5217\u51FA identity\uFF08\u9ED8\u8BA4\u5217\u5F53\u524D env\uFF0C--env all \u5217\u5168\u90E8\uFF09").option("--env <name>", '\u8FC7\u6EE4 env\uFF1B\u4F20 "all" \u5217\u5168\u90E8', void 0).option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => identityList(opts));
13427
13558
  identity.command("show <name>").description("\u5B9E\u65F6\u663E\u793A alias \u5BF9\u5E94\u7684\u670D\u52A1\u7AEF\u7528\u6237\u3001\u79DF\u6237\u4E0E\u89D2\u8272\uFF08\u4E0D\u8F93\u51FA token\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((name, opts) => identityShow(name, opts));
13428
13559
  identity.command("use <name>").description("\u628A identity \u8BBE\u4E3A\u5176 env \u7684 default identity").action((name) => identityUse(name));
13429
13560
  identity.command("remove <name>").description("\u5220\u9664 identity\uFF08\u6E05 token + \u82E5\u662F env default \u5219\u6E05\u7A7A\uFF09").action((name) => identityRemove(name));