@hcmai/cli 0.25.3 → 0.26.2

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
@@ -2126,7 +2126,7 @@ async function runInkRepl(args) {
2126
2126
  try {
2127
2127
  const ctx = await getActiveAuthContextFromCli(args);
2128
2128
  assertDangerWrite(ctx.environmentSafety, "\u542F\u52A8\u4EA4\u4E92\u4F1A\u8BDD\uFF08\u53EF\u80FD\u6267\u884C\u4E1A\u52A1\u5199\u5165\uFF09");
2129
- const client3 = HcmClient10.fromAuthContext(ctx);
2129
+ const client4 = HcmClient10.fromAuthContext(ctx);
2130
2130
  let initialConversationId;
2131
2131
  if (args.resume && args.conversation) {
2132
2132
  throw new Error("--resume \u548C --conversation \u4E0D\u80FD\u540C\u65F6\u4F7F\u7528\uFF1B\u65B0\u547D\u4EE4\u8BF7\u7528 --resume <conversationId>");
@@ -2141,15 +2141,15 @@ async function runInkRepl(args) {
2141
2141
  }
2142
2142
  const ws = new WsClient({
2143
2143
  endpoint: conversationWebSocketEndpoint(ctx.endpoint),
2144
- getAccessToken: () => client3.getAccessToken(),
2145
- onTokenExpiring: () => client3.handleRefresh(),
2144
+ getAccessToken: () => client4.getAccessToken(),
2145
+ onTokenExpiring: () => client4.handleRefresh(),
2146
2146
  conversationId: initialConversationId
2147
2147
  });
2148
2148
  await ws.connect();
2149
2149
  const { waitUntilExit } = render(
2150
2150
  React3.createElement(ReplApp, {
2151
2151
  ws,
2152
- client: client3,
2152
+ client: client4,
2153
2153
  agentId: args.agent ?? DEFAULT_AGENT_ID2,
2154
2154
  env: ctx.env,
2155
2155
  identity: ctx.identity,
@@ -2236,7 +2236,7 @@ var init_readline = __esm({
2236
2236
 
2237
2237
  // src/index.ts
2238
2238
  import { Command } from "commander";
2239
- import { DATA_PACKAGE_FIXTURE_SCHEMA_V1, LEDGER_ONLY_FLAG as LEDGER_ONLY_FLAG2, migrateLegacyProfiles } from "@hcmai/sdk";
2239
+ import { COLUMN_SLOT_SQL_KEYS as COLUMN_SLOT_SQL_KEYS2, DATA_PACKAGE_FIXTURE_SCHEMA_V1, LEDGER_ONLY_FLAG as LEDGER_ONLY_FLAG2, migrateLegacyProfiles } from "@hcmai/sdk";
2240
2240
 
2241
2241
  // src/package-version.ts
2242
2242
  import { readFileSync } from "fs";
@@ -2429,11 +2429,11 @@ async function runOpen(target, args, deps) {
2429
2429
  }
2430
2430
  return { url, expiresIn };
2431
2431
  }
2432
- function mintBrowserTicket(client3, envName) {
2432
+ function mintBrowserTicket(client4, envName) {
2433
2433
  return async () => {
2434
2434
  let data;
2435
2435
  try {
2436
- const resp = await client3.raw().post(BROWSER_TICKET_PATH, {});
2436
+ const resp = await client4.raw().post(BROWSER_TICKET_PATH, {});
2437
2437
  data = resp.data?.data ?? resp.data ?? {};
2438
2438
  } catch (e) {
2439
2439
  const err = e;
@@ -2462,13 +2462,13 @@ async function openCommand(target, args) {
2462
2462
  try {
2463
2463
  const ctx = await getActiveAuthContextFromCli(args);
2464
2464
  const envCfg = await loadEnv(ctx.env);
2465
- const client3 = HcmClient.fromAuthContext(ctx);
2465
+ const client4 = HcmClient.fromAuthContext(ctx);
2466
2466
  await runOpen(
2467
2467
  target,
2468
2468
  { printUrl: args.printUrl, envName: ctx.env },
2469
2469
  {
2470
2470
  frontend: ctx.frontend ?? envCfg.frontend,
2471
- mintTicket: mintBrowserTicket(client3, ctx.env),
2471
+ mintTicket: mintBrowserTicket(client4, ctx.env),
2472
2472
  launch: launchBrowser,
2473
2473
  write: (line) => process.stdout.write(line)
2474
2474
  }
@@ -3403,9 +3403,9 @@ async function loginCommand(args) {
3403
3403
  }
3404
3404
  const err = e;
3405
3405
  if (err.isAxiosError) {
3406
- const { fromAxiosError: fromAxiosError28 } = await import("@hcmai/sdk");
3406
+ const { fromAxiosError: fromAxiosError29 } = await import("@hcmai/sdk");
3407
3407
  exitWithError(
3408
- fromAxiosError28(
3408
+ fromAxiosError29(
3409
3409
  e,
3410
3410
  envName
3411
3411
  )
@@ -3990,8 +3990,8 @@ import {
3990
3990
  async function queryCommand(model, args) {
3991
3991
  try {
3992
3992
  const dsl = buildQueryDsl(args);
3993
- const client3 = HcmClient2.fromAuthContext(await getActiveAuthContextFromCli(args));
3994
- const result = await client3.query(model, dsl);
3993
+ const client4 = HcmClient2.fromAuthContext(await getActiveAuthContextFromCli(args));
3994
+ const result = await client4.query(model, dsl);
3995
3995
  const fmt = args.output ?? "table";
3996
3996
  printQueryResult(result, fmt, dsl);
3997
3997
  } catch (e) {
@@ -4245,9 +4245,9 @@ async function actionCommand(spec, args) {
4245
4245
  required: false
4246
4246
  });
4247
4247
  if (params) input.params = params;
4248
- const client3 = HcmClient3.fromAuthContext(await getActiveAuthContextFromCli(args));
4248
+ const client4 = HcmClient3.fromAuthContext(await getActiveAuthContextFromCli(args));
4249
4249
  if (!explicitMethod || !explicitScope) {
4250
- const shape = await lookupActionShape(client3, model, action);
4250
+ const shape = await lookupActionShape(client4, model, action);
4251
4251
  if (shape) {
4252
4252
  if (!explicitMethod && shape.httpMethod) method3 = shape.httpMethod;
4253
4253
  if (!explicitScope && shape.scope) scope = shape.scope;
@@ -4255,7 +4255,7 @@ async function actionCommand(spec, args) {
4255
4255
  if (scope) input.scope = scope;
4256
4256
  }
4257
4257
  }
4258
- const result = await client3.action(model, action, input);
4258
+ const result = await client4.action(model, action, input);
4259
4259
  const fmt = args.output ?? "json";
4260
4260
  if (args.artifactOutput) {
4261
4261
  await emitArtifact(result, args.artifactOutput, { force: args.artifactForce }, fmt);
@@ -4319,9 +4319,9 @@ function normalizeScope(value) {
4319
4319
  message: `--scope \u53D6\u503C class | object\uFF0C\u6536\u5230 "${value}"`
4320
4320
  });
4321
4321
  }
4322
- async function lookupActionShape(client3, model, action) {
4322
+ async function lookupActionShape(client4, model, action) {
4323
4323
  try {
4324
- const described = await client3.describe(model);
4324
+ const described = await client4.describe(model);
4325
4325
  const named = described.actions.filter((a) => a.name === action);
4326
4326
  if (named.length !== 1) return void 0;
4327
4327
  const only = named[0];
@@ -4346,8 +4346,8 @@ async function createCommand(model, args) {
4346
4346
  inlineFlag: "--data",
4347
4347
  fileFlag: "--data-file"
4348
4348
  });
4349
- const client3 = HcmClient4.fromAuthContext(await getActiveAuthContextFromCli(args));
4350
- const res = await client3.create(model, data, { i18n: args.i18n });
4349
+ const client4 = HcmClient4.fromAuthContext(await getActiveAuthContextFromCli(args));
4350
+ const res = await client4.create(model, data, { i18n: args.i18n });
4351
4351
  const fmt = args.output ?? "json";
4352
4352
  if (fmt !== "json") process.stdout.write("\u2705 created\n");
4353
4353
  process.stdout.write(formatObject2(res, { format: fmt }) + "\n");
@@ -4381,8 +4381,8 @@ async function updateCommand(model, args) {
4381
4381
  inlineFlag: "--data",
4382
4382
  fileFlag: "--data-file"
4383
4383
  });
4384
- const client3 = HcmClient5.fromAuthContext(await getActiveAuthContextFromCli(args));
4385
- const result = await client3.update(model, args.id, data, { i18n: args.i18n });
4384
+ const client4 = HcmClient5.fromAuthContext(await getActiveAuthContextFromCli(args));
4385
+ const result = await client4.update(model, args.id, data, { i18n: args.i18n });
4386
4386
  const fmt = args.output ?? "json";
4387
4387
  if (fmt !== "json") process.stdout.write(`\u2705 ${model}#${args.id} \u5DF2\u66F4\u65B0
4388
4388
  `);
@@ -4632,8 +4632,8 @@ async function deleteCommand(model, args) {
4632
4632
  if (!args.id) {
4633
4633
  throw new CliError15({ code: CliErrorCode14.MISSING_FLAG, message: "--id <id> \u5FC5\u586B" });
4634
4634
  }
4635
- const client3 = HcmClient7.fromAuthContext(await getActiveAuthContextFromCli(args));
4636
- const res = await client3.remove(model, args.id);
4635
+ const client4 = HcmClient7.fromAuthContext(await getActiveAuthContextFromCli(args));
4636
+ const res = await client4.remove(model, args.id);
4637
4637
  const fmt = args.output ?? "json";
4638
4638
  if (fmt !== "json") process.stdout.write("\u2705 deleted\n");
4639
4639
  process.stdout.write(formatObject6(res, { format: fmt }) + "\n");
@@ -4688,8 +4688,8 @@ async function importCommand(path22, args) {
4688
4688
  updateOnly: !!args.updateOnly,
4689
4689
  onError: args.onError === "stop" ? "stop" : "continue"
4690
4690
  };
4691
- const client3 = opts.dryRun ? DRY_RUN_CLIENT : HcmClient8.fromAuthContext(await getActiveAuthContextFromCli(args));
4692
- const result = await runImport(client3, fixtures, opts);
4691
+ const client4 = opts.dryRun ? DRY_RUN_CLIENT : HcmClient8.fromAuthContext(await getActiveAuthContextFromCli(args));
4692
+ const result = await runImport(client4, fixtures, opts);
4693
4693
  for (const warning of result.warnings ?? []) process.stderr.write(`\u26A0 ${warning}
4694
4694
  `);
4695
4695
  if (args.report) writeFileSync(args.report, JSON.stringify(result, null, 2));
@@ -4736,8 +4736,8 @@ import {
4736
4736
  } from "@hcmai/sdk";
4737
4737
  async function describeCommand(model, args) {
4738
4738
  try {
4739
- const client3 = HcmClient9.fromAuthContext(await getActiveAuthContextFromCli(args));
4740
- const desc = await client3.describe(model, { verbose: !!args.verbose });
4739
+ const client4 = HcmClient9.fromAuthContext(await getActiveAuthContextFromCli(args));
4740
+ const desc = await client4.describe(model, { verbose: !!args.verbose });
4741
4741
  const fmt = args.output ?? "table";
4742
4742
  if (fmt !== "table") {
4743
4743
  process.stdout.write(formatObject8(desc, { format: fmt }) + "\n");
@@ -4866,29 +4866,29 @@ init_exit();
4866
4866
  init_impersonation_lifecycle();
4867
4867
  init_auth_guard();
4868
4868
  function parseInjectOn(s) {
4869
- const fail8 = (detail) => {
4869
+ const fail9 = (detail) => {
4870
4870
  throw new CliError16({
4871
4871
  code: CliErrorCode17.INVALID_ARGUMENT,
4872
4872
  message: `--inject-on \u683C\u5F0F <eventType>:<action>[:<arg>]\uFF0Caction \u2208 {interrupt, steer}\uFF08steer \u5FC5\u987B\u5E26 content\uFF09\uFF1B${detail}\uFF0C\u6536\u5230 "${s}"`
4873
4873
  });
4874
4874
  };
4875
4875
  const firstColon = s.indexOf(":");
4876
- if (firstColon < 0) return fail8("\u7F3A\u5C11 action \u6BB5");
4876
+ if (firstColon < 0) return fail9("\u7F3A\u5C11 action \u6BB5");
4877
4877
  const eventType = s.slice(0, firstColon);
4878
4878
  const rest = s.slice(firstColon + 1);
4879
4879
  const secondColon = rest.indexOf(":");
4880
4880
  const action = secondColon < 0 ? rest : rest.slice(0, secondColon);
4881
4881
  const arg = secondColon < 0 ? void 0 : rest.slice(secondColon + 1);
4882
- if (!eventType) return fail8("eventType \u6BB5\u4E3A\u7A7A");
4882
+ if (!eventType) return fail9("eventType \u6BB5\u4E3A\u7A7A");
4883
4883
  if (action === "interrupt") {
4884
- if (arg !== void 0) return fail8("interrupt \u4E0D\u63A5\u53D7 arg");
4884
+ if (arg !== void 0) return fail9("interrupt \u4E0D\u63A5\u53D7 arg");
4885
4885
  return { eventType, action: "interrupt" };
4886
4886
  }
4887
4887
  if (action === "steer") {
4888
- if (arg === void 0 || arg === "") return fail8("steer \u5FC5\u987B\u5E26 content\uFF08arg\uFF09");
4888
+ if (arg === void 0 || arg === "") return fail9("steer \u5FC5\u987B\u5E26 content\uFF08arg\uFF09");
4889
4889
  return { eventType, action: "steer", arg };
4890
4890
  }
4891
- return fail8(`\u672A\u77E5 action "${action}"`);
4891
+ return fail9(`\u672A\u77E5 action "${action}"`);
4892
4892
  }
4893
4893
  function parseOnConfirm(s) {
4894
4894
  if (s === "approve") return { decision: "approve" };
@@ -5071,8 +5071,8 @@ function lastAssistantMissDetail(target) {
5071
5071
  }
5072
5072
  async function printConversationEvents(conversationId, args) {
5073
5073
  const ctx = await getActiveAuthContextFromCli(args);
5074
- const client3 = HcmClient11.fromAuthContext(ctx);
5075
- const items = await fetchConversationTimelineStrict(client3.raw(), conversationId);
5074
+ const client4 = HcmClient11.fromAuthContext(ctx);
5075
+ const items = await fetchConversationTimelineStrict(client4.raw(), conversationId);
5076
5076
  const fmt = args.output ?? "text";
5077
5077
  if (args.raw) {
5078
5078
  for (const item of items) {
@@ -5104,9 +5104,9 @@ async function printConversationList(args) {
5104
5104
  });
5105
5105
  }
5106
5106
  const ctx = await getActiveAuthContextFromCli(args);
5107
- const client3 = HcmClient11.fromAuthContext(ctx);
5107
+ const client4 = HcmClient11.fromAuthContext(ctx);
5108
5108
  const limit = parsePositiveInt(args.limit, 10, "--limit");
5109
- const result = await fetchRecentConversations(client3.raw(), limit);
5109
+ const result = await fetchRecentConversations(client4.raw(), limit);
5110
5110
  const fmt = args.output ?? "text";
5111
5111
  if (fmt === "json") {
5112
5112
  process.stdout.write(formatObject9(result, { format: "json" }) + "\n");
@@ -5192,17 +5192,17 @@ async function chatCommand(prompt, args) {
5192
5192
  const ctx = await getActiveAuthContextFromCli(args);
5193
5193
  assertDangerWrite2(ctx.environmentSafety, "\u53D1\u9001\u6216\u7EE7\u7EED\u4F1A\u8BDD\uFF08\u53EF\u80FD\u6267\u884C\u4E1A\u52A1\u5199\u5165\uFF09");
5194
5194
  const wsUrl = conversationWebSocketEndpoint2(ctx.endpoint);
5195
- const client3 = HcmClient11.fromAuthContext(ctx);
5195
+ const client4 = HcmClient11.fromAuthContext(ctx);
5196
5196
  const stateKey = ctx.env;
5197
5197
  const agentId = args.agent ?? DEFAULT_AGENT_ID3;
5198
5198
  let resumeConversationId = requestedConversationId;
5199
5199
  const resumedExisting = !!resumeConversationId;
5200
5200
  if (!resumeConversationId) {
5201
- const conv = await createConversation2(client3.raw(), agentId);
5201
+ const conv = await createConversation2(client4.raw(), agentId);
5202
5202
  resumeConversationId = conv.id;
5203
5203
  }
5204
5204
  if (regenerateFromLastAssistant) {
5205
- const items = await fetchConversationTimeline2(client3.raw(), resumeConversationId);
5205
+ const items = await fetchConversationTimeline2(client4.raw(), resumeConversationId);
5206
5206
  const target = findLastAssistantTarget(items);
5207
5207
  if (target.seq == null) {
5208
5208
  throw new CliError16({
@@ -5214,8 +5214,8 @@ async function chatCommand(prompt, args) {
5214
5214
  }
5215
5215
  const ws = new WsClient2({
5216
5216
  endpoint: wsUrl,
5217
- getAccessToken: () => client3.getAccessToken(),
5218
- onTokenExpiring: () => client3.handleRefresh(),
5217
+ getAccessToken: () => client4.getAccessToken(),
5218
+ onTokenExpiring: () => client4.handleRefresh(),
5219
5219
  // issue #257:握手带上会话 id,后端才会绑控制通道并重投上次留下的未决暂停。
5220
5220
  // 会话 id 在上面几十行就定下来了(--resume 或刚 createConversation 出来的),
5221
5221
  // 建连时它一定已经就位。
@@ -5236,7 +5236,7 @@ async function chatCommand(prompt, args) {
5236
5236
  verboseTools: !!args.verboseTools,
5237
5237
  spinner: args.spinner === false ? false : isTty,
5238
5238
  color: args.color === false ? false : isTty,
5239
- apiBase: client3.endpoint
5239
+ apiBase: client4.endpoint
5240
5240
  });
5241
5241
  const presenter = new StreamPresenter2(renderer, {
5242
5242
  showToolCalls: args.showToolCalls !== false,
@@ -5250,7 +5250,7 @@ async function chatCommand(prompt, args) {
5250
5250
  });
5251
5251
  if (resumedExisting && isTty && fmt === "text" && !args.raw) {
5252
5252
  const { fetchConversationTimeline: fetchConversationTimeline3, buildResumeSummary: buildResumeSummary2 } = await import("@hcmai/sdk");
5253
- const items = await fetchConversationTimeline3(client3.raw(), resumeConversationId);
5253
+ const items = await fetchConversationTimeline3(client4.raw(), resumeConversationId);
5254
5254
  const summary = items ? buildResumeSummary2(resumeConversationId, items) : null;
5255
5255
  if (summary) renderer.showResumeContext(summary);
5256
5256
  }
@@ -5259,7 +5259,7 @@ async function chatCommand(prompt, args) {
5259
5259
  const { uploadDocument: uploadDocument3 } = await import("@hcmai/sdk");
5260
5260
  chatAttachments = [];
5261
5261
  for (const fp of args.attach) {
5262
- const meta2 = await uploadDocument3(client3.raw(), fp);
5262
+ const meta2 = await uploadDocument3(client4.raw(), fp);
5263
5263
  chatAttachments.push(meta2);
5264
5264
  if (fmt === "text" && !args.raw) process.stderr.write(`\u{1F4CE} \u5DF2\u4E0A\u4F20 ${meta2.fileName} (${meta2.documentId})
5265
5265
  `);
@@ -5272,7 +5272,7 @@ async function chatCommand(prompt, args) {
5272
5272
  const { uploadDocument: uploadDocument3 } = await import("@hcmai/sdk");
5273
5273
  chatAttachments = chatAttachments ?? [];
5274
5274
  for (const fp of inline.paths) {
5275
- const meta2 = await uploadDocument3(client3.raw(), fp);
5275
+ const meta2 = await uploadDocument3(client4.raw(), fp);
5276
5276
  chatAttachments.push(meta2);
5277
5277
  if (fmt === "text" && !args.raw) process.stderr.write(`\u{1F4CE} \u5DF2\u4E0A\u4F20 ${meta2.fileName} (${meta2.documentId})
5278
5278
  `);
@@ -5630,9 +5630,9 @@ async function interactionsListCommand(args) {
5630
5630
  );
5631
5631
  const json2 = args.output === "json";
5632
5632
  announceSource(source, conversationId, json2);
5633
- const client3 = HcmClient12.fromAuthContext(ctx);
5633
+ const client4 = HcmClient12.fromAuthContext(ctx);
5634
5634
  const agentId = args.agent ?? DEFAULT_AGENT_ID4;
5635
- const rows2 = await listPendingInteractions(client3.raw(), agentId, conversationId);
5635
+ const rows2 = await listPendingInteractions(client4.raw(), agentId, conversationId);
5636
5636
  if (json2) {
5637
5637
  process.stdout.write(
5638
5638
  formatObject10(
@@ -5660,11 +5660,11 @@ async function interactionsRespondCommand(action, interactionId, args) {
5660
5660
  const json2 = args.output === "json";
5661
5661
  announceSource(source, conversationId, json2);
5662
5662
  assertDangerWrite3(ctx.environmentSafety, "\u56DE\u5E94\u6682\u505C\uFF08\u6279\u51C6\u4F1A\u771F\u7684\u6267\u884C\u90A3\u4E2A\u5199\u64CD\u4F5C\uFF09");
5663
- const client3 = HcmClient12.fromAuthContext(ctx);
5663
+ const client4 = HcmClient12.fromAuthContext(ctx);
5664
5664
  ws = new WsClient3({
5665
5665
  endpoint: conversationWebSocketEndpoint3(ctx.endpoint),
5666
- getAccessToken: () => client3.getAccessToken(),
5667
- onTokenExpiring: () => client3.handleRefresh(),
5666
+ getAccessToken: () => client4.getAccessToken(),
5667
+ onTokenExpiring: () => client4.handleRefresh(),
5668
5668
  conversationId
5669
5669
  });
5670
5670
  await ws.connect();
@@ -5705,8 +5705,8 @@ import { HcmClient as HcmClient13 } from "@hcmai/sdk";
5705
5705
  async function downloadCommand(documentId, args) {
5706
5706
  try {
5707
5707
  const ctx = await getActiveAuthContextFromCli(args);
5708
- const client3 = HcmClient13.fromAuthContext(ctx);
5709
- const saved = await downloadDocument(client3.raw(), { documentId }, args.output);
5708
+ const client4 = HcmClient13.fromAuthContext(ctx);
5709
+ const saved = await downloadDocument(client4.raw(), { documentId }, args.output);
5710
5710
  process.stdout.write(saved + "\n");
5711
5711
  process.exitCode = 0;
5712
5712
  return;
@@ -5737,8 +5737,8 @@ import {
5737
5737
  } from "@hcmai/sdk";
5738
5738
  async function documentDeleteCommand(documentId, args) {
5739
5739
  try {
5740
- const client3 = HcmClient14.fromAuthContext(await getActiveAuthContextFromCli(args));
5741
- await deleteDocument(client3.raw(), documentId);
5740
+ const client4 = HcmClient14.fromAuthContext(await getActiveAuthContextFromCli(args));
5741
+ await deleteDocument(client4.raw(), documentId);
5742
5742
  process.stdout.write(formatObject11({ success: true, documentId }, { format: args.output ?? "json" }) + "\n");
5743
5743
  process.exitCode = 0;
5744
5744
  } catch (e) {
@@ -5890,8 +5890,8 @@ function printTraceEvents(traceId, agg) {
5890
5890
  `);
5891
5891
  process.stdout.write(formatRows5(rows2, { format: "table" }) + "\n");
5892
5892
  }
5893
- async function listRecentTraces(client3, limit) {
5894
- const http = client3.raw();
5893
+ async function listRecentTraces(client4, limit) {
5894
+ const http = client4.raw();
5895
5895
  try {
5896
5896
  const resp = await http.get("/api/trace/recent", { params: { limit } });
5897
5897
  const data = resp.data ?? {};
@@ -5910,12 +5910,12 @@ async function listRecentTraces(client3, limit) {
5910
5910
 
5911
5911
  `);
5912
5912
  }
5913
- await listRecentConversationsPg(client3, limit);
5913
+ await listRecentConversationsPg(client4, limit);
5914
5914
  }
5915
- async function listRecentConversationsPg(client3, limit) {
5915
+ async function listRecentConversationsPg(client4, limit) {
5916
5916
  let rows2;
5917
5917
  try {
5918
- const res = await client3.query("ConversationModel", {
5918
+ const res = await client4.query("ConversationModel", {
5919
5919
  sort: [{ field: "lastActiveAt", direction: "desc" }],
5920
5920
  limit
5921
5921
  });
@@ -6146,8 +6146,8 @@ async function gatherLlmTraceTree(http, rootConvId, maxDepth = 3) {
6146
6146
  }
6147
6147
  async function traceCommand(traceId, args) {
6148
6148
  try {
6149
- const client3 = HcmClient15.fromAuthContext(await getActiveAuthContextFromCli(args));
6150
- const http = client3.raw();
6149
+ const client4 = HcmClient15.fromAuthContext(await getActiveAuthContextFromCli(args));
6150
+ const http = client4.raw();
6151
6151
  const convId = args.conv ?? (args.llmCalls ? traceId ?? void 0 : void 0);
6152
6152
  if (convId) {
6153
6153
  if (args.raw || args.output === "json" || args.output === "yaml") {
@@ -6171,7 +6171,7 @@ async function traceCommand(traceId, args) {
6171
6171
  exitWithError("traceId is required for --events, --raw, and --span");
6172
6172
  return;
6173
6173
  }
6174
- await listRecentTraces(client3, parsePositiveInt2(args.limit, 10, "--limit"));
6174
+ await listRecentTraces(client4, parsePositiveInt2(args.limit, 10, "--limit"));
6175
6175
  process.exitCode = 0;
6176
6176
  return;
6177
6177
  }
@@ -6226,8 +6226,8 @@ import {
6226
6226
  clearMetaCache
6227
6227
  } from "@hcmai/sdk";
6228
6228
  async function withClient(args, fn) {
6229
- const client3 = HcmClient16.fromAuthContext(await getActiveAuthContextFromCli(args));
6230
- return fn(client3);
6229
+ const client4 = HcmClient16.fromAuthContext(await getActiveAuthContextFromCli(args));
6230
+ return fn(client4);
6231
6231
  }
6232
6232
  function emit(result, args, human) {
6233
6233
  const fmt = args.output ?? "json";
@@ -6285,8 +6285,8 @@ import {
6285
6285
  getScriptTask
6286
6286
  } from "@hcmai/sdk";
6287
6287
  async function withClient2(args, fn) {
6288
- const client3 = HcmClient17.fromAuthContext(await getActiveAuthContextFromCli(args));
6289
- return fn(client3);
6288
+ const client4 = HcmClient17.fromAuthContext(await getActiveAuthContextFromCli(args));
6289
+ return fn(client4);
6290
6290
  }
6291
6291
  function emit2(result, args, human) {
6292
6292
  const fmt = args.output ?? "json";
@@ -6396,9 +6396,9 @@ var DEFAULT_UPLOAD_CATEGORY = "attachment";
6396
6396
  async function uploadCommand(filePath2, args) {
6397
6397
  try {
6398
6398
  const ctx = await getActiveAuthContextFromCli(args);
6399
- const client3 = HcmClient18.fromAuthContext(ctx);
6399
+ const client4 = HcmClient18.fromAuthContext(ctx);
6400
6400
  const meta2 = await uploadDocument2(
6401
- client3.raw(),
6401
+ client4.raw(),
6402
6402
  filePath2,
6403
6403
  args.category ?? DEFAULT_UPLOAD_CATEGORY,
6404
6404
  args.model || args.originId || args.field ? { model: args.model ?? "", originId: args.originId ?? "", field: args.field ?? "", state: args.state } : void 0
@@ -6478,10 +6478,10 @@ async function datapackagePackCommand(packageDir, args) {
6478
6478
  async function datapackageInstallCommand(artifactPath, args) {
6479
6479
  try {
6480
6480
  const ctx = await getActiveAuthContextFromCli(args);
6481
- const client3 = HcmClient19.fromAuthContext(ctx);
6481
+ const client4 = HcmClient19.fromAuthContext(ctx);
6482
6482
  const fmt = args.output ?? "json";
6483
6483
  const human = fmt !== "json";
6484
- const accepted = await installDataPackageArtifactAsync(client3, artifactPath, {
6484
+ const accepted = await installDataPackageArtifactAsync(client4, artifactPath, {
6485
6485
  category: args.category ?? DEFAULT_ARTIFACT_CATEGORY
6486
6486
  });
6487
6487
  if (human) {
@@ -6504,7 +6504,7 @@ async function datapackageInstallCommand(artifactPath, args) {
6504
6504
  }
6505
6505
  const timeoutMs = Math.max(1, Number(args.timeout ?? DEFAULT_INSTALL_WAIT_SECONDS)) * 1e3;
6506
6506
  const showProgress = human && process.stderr.isTTY === true;
6507
- const { run: run3, timedOut } = await waitForInstallRun(client3, accepted.runId, {
6507
+ const { run: run3, timedOut } = await waitForInstallRun(client4, accepted.runId, {
6508
6508
  timeoutMs,
6509
6509
  onProgress: showProgress ? (r) => process.stderr.write(`\r${renderProgress(r)}`.padEnd(96)) : void 0
6510
6510
  });
@@ -6555,8 +6555,8 @@ async function datapackageInstallCommand(artifactPath, args) {
6555
6555
  async function datapackageStatusCommand(runId, args) {
6556
6556
  try {
6557
6557
  const ctx = await getActiveAuthContextFromCli(args);
6558
- const client3 = HcmClient19.fromAuthContext(ctx);
6559
- const run3 = await fetchInstallRun(client3, runId);
6558
+ const client4 = HcmClient19.fromAuthContext(ctx);
6559
+ const run3 = await fetchInstallRun(client4, runId);
6560
6560
  const fmt = args.output ?? "json";
6561
6561
  if (!run3) {
6562
6562
  if (fmt !== "json") {
@@ -6830,8 +6830,8 @@ function stderrCause(stderr) {
6830
6830
  return lastMatching(/\[cause\]:/) ?? lastMatching(/^(fatal|error)\b|\w*Error\b.*:/i) ?? lines[lines.length - 1];
6831
6831
  }
6832
6832
  var runCaseProcess = async (cmd, args, opts = {}) => {
6833
- const { timeoutMs, ...rest } = opts;
6834
- const label = [path4.basename(cmd), args[0] && !args[0].startsWith("-") ? path4.basename(args[0]) : args[0] ?? ""].join(" ").trim();
6833
+ const { timeoutMs, label: given, ...rest } = opts;
6834
+ const label = given ?? [path4.basename(cmd), args[0] && !args[0].startsWith("-") ? path4.basename(args[0]) : args[0] ?? ""].join(" ").trim();
6835
6835
  try {
6836
6836
  const pending = execFileAsync(cmd, args, { encoding: "utf8", maxBuffer: 1 << 26, timeout: timeoutMs ?? 0, ...rest });
6837
6837
  pending.child.stdin?.end();
@@ -6853,6 +6853,63 @@ ${e.message}`;
6853
6853
  }
6854
6854
  };
6855
6855
  var run = runCaseProcess;
6856
+ var CNB_NOT_FOUND = "\u627E\u4E0D\u5230 cnb \u53EF\u6267\u884C\u6587\u4EF6\uFF08Windows \u4E0A\u9700 cnb.cmd / \u68C0\u67E5 PATH\uFF09";
6857
+ var CNB_NOT_FOUND_NEXT = "\u88C5 cnb\uFF1A`npm i -g @cnbcool/cnb-cli`\uFF0C\u518D `cnb login`\uFF1B\u88C5\u8FC7\u5C31\u68C0\u67E5 PATH\uFF08Windows \u4E0A `where cnb` \u5E94\u5217\u51FA cnb.exe \u6216\u5305\u7BA1\u7406\u5668\u751F\u6210\u7684 cnb.cmd\uFF0C\u7528 Volta \u7684\u8981\u6709 volta.exe\uFF1B\u81EA\u5DF1\u5199\u7684 .bat / .cmd \u5305\u88C5\u8BA4\u4E0D\u51FA\uFF09\uFF0C\u88C5\u574F\u4E86\u5C31\u91CD\u88C5\u3002\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";
6858
+ var CNB_NETWORK_CAUSE = /ECONN\w*|ENOTFOUND|EAI_AGAIN|ETIMEDOUT|fetch failed|socket|TLS/i;
6859
+ var CNB_LOGIN_CAUSE = /未登录|登录凭证|登录失效|cnb login|unauthori[sz]ed/i;
6860
+ var windowsPathDirs = (pathVar, p = path4) => pathVar.split(";").map((d) => d.trim().replace(/^"(.*)"$/, "$1")).filter((d) => p.isAbsolute(d));
6861
+ function shimTarget(dir, text, p = path4) {
6862
+ const rel = /"%~?dp0%?[\\/]([^"%]+\.[cm]?js)"/i.exec(text)?.[1];
6863
+ return rel ? p.join(dir, ...rel.split(/[\\/]/)) : /"([A-Za-z]:[\\/][^"%]+\.[cm]?js)"/.exec(text)?.[1];
6864
+ }
6865
+ var skippedNotices = /* @__PURE__ */ new Set();
6866
+ function resolveCnb() {
6867
+ if (process.platform !== "win32") return { cmd: "cnb", prefix: [] };
6868
+ const dirs = windowsPathDirs(process.env.PATH ?? "");
6869
+ let blocked;
6870
+ const use = (r) => {
6871
+ if (blocked && !skippedNotices.has(blocked)) {
6872
+ skippedNotices.add(blocked);
6873
+ process.stderr.write(`[hcm] PATH \u91CC\u9760\u524D\u7684 cnb \u8D77\u4E0D\u6765\uFF08${blocked}\uFF09\uFF0C\u6539\u7528 ${r.prefix[0] ?? r.cmd}
6874
+ `);
6875
+ }
6876
+ return r;
6877
+ };
6878
+ for (const dir of dirs) {
6879
+ const exe = path4.join(dir, "cnb.exe");
6880
+ if (existsSync(exe)) return use({ cmd: exe, prefix: [] });
6881
+ for (const shim of ["cnb.cmd", "cnb.bat"].map((f) => path4.join(dir, f)).filter((f) => existsSync(f))) {
6882
+ let text;
6883
+ try {
6884
+ text = readFileSync4(shim, "utf8");
6885
+ } catch (e) {
6886
+ blocked ??= `\u627E\u5230\u4E86 ${shim}\uFF0C\u4F46\u8BFB\u4E0D\u4E86\uFF1A${String(e.message).split("\n")[0]}`;
6887
+ continue;
6888
+ }
6889
+ if (/^\s*volta run %~n0 %\*\s*$/im.test(text)) {
6890
+ const volta = dirs.map((d) => path4.join(d, "volta.exe")).find((f) => existsSync(f));
6891
+ if (volta) return use({ cmd: volta, prefix: ["run", "cnb"] });
6892
+ blocked ??= `\u627E\u5230\u4E86 Volta \u7684 ${shim}\uFF0C\u4F46 PATH \u91CC\u6CA1\u6709 volta.exe`;
6893
+ continue;
6894
+ }
6895
+ const entry = shimTarget(dir, text);
6896
+ if (entry && existsSync(entry)) return use({ cmd: process.execPath, prefix: [entry] });
6897
+ blocked ??= entry ? `${shim} \u6307\u5411\u7684 ${entry} \u4E0D\u5B58\u5728\uFF08cnb \u88C5\u574F\u4E86\uFF09` : `\u627E\u5230\u4E86 ${shim}\uFF0C\u4F46\u8BA4\u4E0D\u51FA\u5B83\u6307\u5411\u7684 cnb \u5165\u53E3\u811A\u672C\uFF08\u4E0D\u662F\u5305\u7BA1\u7406\u5668\u751F\u6210\u7684 shim\uFF09`;
6898
+ }
6899
+ }
6900
+ throw Object.assign(new Error(blocked ? `\u8D77\u4E0D\u6765 cnb\uFF1A${blocked}` : CNB_NOT_FOUND), { cnbMissing: true });
6901
+ }
6902
+ async function runCnb(args, opts = {}) {
6903
+ try {
6904
+ const { cmd, prefix } = resolveCnb();
6905
+ return await run(cmd, [...prefix, ...args], { ...opts, label: `cnb ${args[0]}` });
6906
+ } catch (error) {
6907
+ const e = error;
6908
+ if (e.code === "ENOENT") Object.assign(e, { cnbMissing: true, message: `${CNB_NOT_FOUND}
6909
+ ${e.message}` });
6910
+ throw e;
6911
+ }
6912
+ }
6856
6913
  function parseCnbEnvelope(raw, what) {
6857
6914
  const trimmed = raw.trim();
6858
6915
  let parsed;
@@ -6888,7 +6945,7 @@ function parseCnbEnvelope(raw, what) {
6888
6945
  async function fetchRepoFile(relPath) {
6889
6946
  let raw;
6890
6947
  try {
6891
- raw = await run("cnb", [
6948
+ raw = await runCnb([
6892
6949
  "git",
6893
6950
  "get-raw",
6894
6951
  "--repo",
@@ -6899,11 +6956,12 @@ async function fetchRepoFile(relPath) {
6899
6956
  ], { timeoutMs: CNB_READ_TIMEOUT_MS });
6900
6957
  } catch (e) {
6901
6958
  const timedOut = e.timedOut === true;
6959
+ const cnbMissing = e.cnbMissing === true;
6902
6960
  const processCause = String(e.message).split("\n")[0];
6903
6961
  throw Object.assign(fail5(
6904
6962
  `\u53D6\u4E0D\u5230\u6848\u4F8B\u5E93\u6587\u4EF6 ${relPath}\uFF1A${timedOut ? `cnb \u8BFB\u53D6\u8D85\u65F6\uFF08${CNB_READ_TIMEOUT_MS / 1e3}s\uFF09` : processCause}`,
6905
- timedOut ? "cnb \u5728\u65F6\u9650\u5185\u6CA1\u8FD4\u56DE\uFF1A\u67E5\u7F51\u7EDC\u6216\u4EE3\u7406\u540E\u91CD\u8DD1\u3002\u8BFB\u4E0D\u5230\u65F6\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" : "\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",
6906
- timedOut ? {} : { processCause }
6963
+ timedOut ? "cnb \u5728\u65F6\u9650\u5185\u6CA1\u8FD4\u56DE\uFF1A\u67E5\u7F51\u7EDC\u6216\u4EE3\u7406\u540E\u91CD\u8DD1\u3002\u8BFB\u4E0D\u5230\u65F6\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" : cnbMissing ? CNB_NOT_FOUND_NEXT : CNB_NETWORK_CAUSE.test(processCause) ? "\u67E5\u7F51\u7EDC\u6216\u4EE3\u7406\u540E\u91CD\u8DD1\u3002\u8BFB\u4E0D\u5230\u65F6\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" : CNB_LOGIN_CAUSE.test(processCause) ? "cnb \u6CA1\u767B\u5F55\u6216\u767B\u5F55\u5931\u6548\uFF1A\u8FD0\u884C `cnb login` \u91CD\u65B0\u6388\u6743\u540E\u91CD\u8DD1\u3002\u8BFB\u4E0D\u5230\u65F6\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" : "\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",
6964
+ timedOut ? {} : { processCause, ...cnbMissing ? { cnbMissing } : {} }
6907
6965
  ), { timedOut });
6908
6966
  }
6909
6967
  const body = parseCnbEnvelope(raw, relPath);
@@ -6973,7 +7031,7 @@ async function caseSearchCommand(query, args) {
6973
7031
  const fp = await backendFingerprint(args.env);
6974
7032
  let raw;
6975
7033
  try {
6976
- raw = await run("cnb", [
7034
+ raw = await runCnb([
6977
7035
  "knowledge-base",
6978
7036
  "query-knowledge-base-get",
6979
7037
  "--repo",
@@ -6985,9 +7043,11 @@ async function caseSearchCommand(query, args) {
6985
7043
  "--verbose"
6986
7044
  ]);
6987
7045
  } catch (e) {
7046
+ const cnbMissing = e.cnbMissing === true;
6988
7047
  throw fail5(
6989
7048
  `\u6848\u4F8B\u5E93\u68C0\u7D22\u6CA1\u8DD1\u6210\uFF1A${String(e.message).split("\n")[0]}`,
6990
- "\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"
7049
+ cnbMissing ? CNB_NOT_FOUND_NEXT : "\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",
7050
+ cnbMissing ? { cnbMissing } : {}
6991
7051
  );
6992
7052
  }
6993
7053
  const hits = parseCnbEnvelope(raw, `\u68C0\u7D22\u300C${query}\u300D`);
@@ -7134,7 +7194,7 @@ ${e.stdout ?? e.message}`,
7134
7194
  await run("git", ["-C", repo, "add", "-A"]);
7135
7195
  await run("git", ["-C", repo, "-c", "user.name=hcm-cli", "-c", "user.email=chiron@local", "commit", "-q", "-m", `case: ${id}\uFF08\u9879\u76EE\u6848\u4F8B\u4E0A\u884C\uFF09`]);
7136
7196
  await run("git", ["-C", repo, "push", "-q", "-f", "-u", "origin", branch]);
7137
- const pr = await run("cnb", [
7197
+ const pr = await runCnb([
7138
7198
  "pulls",
7139
7199
  "post-pull",
7140
7200
  "--repo",
@@ -7636,9 +7696,9 @@ async function skillsListCommand(keyword, args, cwd = process.cwd()) {
7636
7696
  let manifest2;
7637
7697
  let endpoint;
7638
7698
  if (source !== "cli") {
7639
- const client3 = await chironClient(args);
7640
- endpoint = client3.endpoint;
7641
- manifest2 = await fetchSkillCatalog(client3.http, client3.base);
7699
+ const client4 = await chironClient(args);
7700
+ endpoint = client4.endpoint;
7701
+ manifest2 = await fetchSkillCatalog(client4.http, client4.base);
7642
7702
  }
7643
7703
  const bundled = source === "chiron" ? void 0 : listBundledSkills();
7644
7704
  const catalog = buildUnifiedCatalog({ source, chironManifest: manifest2, bundled, cliVersion: CLI_VERSION });
@@ -7940,10 +8000,10 @@ async function skillsInstallCommand(id, args) {
7940
8000
  }),
7941
8001
  recorded: (await readSkillsState(layout.baseDir))?.endpoint
7942
8002
  });
7943
- const client3 = await beforeAnyWrite(chironClient({ ...args, endpoint: tracked }));
7944
- endpoint = client3.endpoint;
7945
- base = client3.base;
7946
- http = client3.http;
8003
+ const client4 = await beforeAnyWrite(chironClient({ ...args, endpoint: tracked }));
8004
+ endpoint = client4.endpoint;
8005
+ base = client4.base;
8006
+ http = client4.http;
7947
8007
  manifest2 = await beforeAnyWrite(fetchSkillCatalog(http, base));
7948
8008
  }
7949
8009
  const catalog = buildUnifiedCatalog({ source, chironManifest: manifest2, bundled, cliVersion: CLI_VERSION });
@@ -9064,9 +9124,9 @@ async function skillsUpdateCommand(args) {
9064
9124
  let base;
9065
9125
  let http;
9066
9126
  if (source !== "cli") {
9067
- const client3 = await beforeAnyWrite(chironClient({ ...args, endpoint }));
9068
- http = client3.http;
9069
- base = client3.base;
9127
+ const client4 = await beforeAnyWrite(chironClient({ ...args, endpoint }));
9128
+ http = client4.http;
9129
+ base = client4.base;
9070
9130
  manifest2 = await beforeAnyWrite(fetchSkillCatalog(http, base));
9071
9131
  }
9072
9132
  const bundled = source === "chiron" ? void 0 : listBundledSkills();
@@ -9386,10 +9446,10 @@ async function tenantResetCommand(args) {
9386
9446
  assertDangerWrite4(safety, "\u91CD\u7F6E\u79DF\u6237 PostgreSQL \u6570\u636E");
9387
9447
  const accessToken = await HcmClient20.fromAuthContext(ctx).getAccessToken();
9388
9448
  if (!accessToken) throw new CliError22({ code: CliErrorCode23.AUTH_FAILED, message: "\u5F53\u524D\u8EAB\u4EFD\u6CA1\u6709\u53EF\u8BFB\u53D6\u7684\u51ED\u636E\uFF0C\u672A\u53D1\u9001\u91CD\u7F6E\u3002" });
9389
- const client3 = new HcmClient20({ endpoint, tenantId, accessToken, profile: env2, environmentSafety: safety });
9390
- client3.raw().defaults.maxRedirects = 0;
9391
- client3.raw().defaults.__skipRetry = true;
9392
- const principal = await readSessionPrincipal2(client3.raw());
9449
+ const client4 = new HcmClient20({ endpoint, tenantId, accessToken, profile: env2, environmentSafety: safety });
9450
+ client4.raw().defaults.maxRedirects = 0;
9451
+ client4.raw().defaults.__skipRetry = true;
9452
+ const principal = await readSessionPrincipal2(client4.raw());
9393
9453
  if (principal.tenantId !== tenantId || principal.username !== "admin" || !principal.roles?.includes("admin.system") || principal.impersonated || principal.actSub != null) {
9394
9454
  throw new CliError22({
9395
9455
  code: CliErrorCode23.SCOPE_FORBIDDEN,
@@ -9410,7 +9470,7 @@ async function tenantResetCommand(args) {
9410
9470
  if (!/^y(es)?$/i.test(answer)) throw new CliError22({ code: CliErrorCode23.INVALID_ARGUMENT, message: "\u5DF2\u53D6\u6D88\uFF0C\u672A\u53D1\u9001\u91CD\u7F6E\u3002" });
9411
9471
  }
9412
9472
  attempted = true;
9413
- const receipt = await resetTenant(client3.raw(), tenantId);
9473
+ const receipt = await resetTenant(client4.raw(), tenantId);
9414
9474
  if (fmt === "table") process.stdout.write(
9415
9475
  `\u79DF\u6237 ${receipt.tenantId} \xB7 \u6D41\u6C34 ${receipt.runId}
9416
9476
  \u5220\u9664 ${receipt.deletedRows} \u884C / \u6D89\u53CA ${receipt.touchedTables} \u8868 / \u91CD\u5EFA ${receipt.restoredRows} \u884C
@@ -9620,10 +9680,10 @@ async function tenantReconcileCommand(args) {
9620
9680
  code: CliErrorCode24.AUTH_FAILED,
9621
9681
  message: "\u5F53\u524D\u8EAB\u4EFD\u6CA1\u6709\u53EF\u8BFB\u53D6\u7684\u51ED\u636E\uFF0C\u672A\u53D1\u9001\u8865\u8DD1\u3002"
9622
9682
  });
9623
- const client3 = new HcmClient21({ endpoint, tenantId, accessToken, profile: env2, environmentSafety: safety });
9624
- client3.raw().defaults.maxRedirects = 0;
9625
- client3.raw().defaults.__skipRetry = true;
9626
- const principal = await readSessionPrincipal3(client3.raw());
9683
+ const client4 = new HcmClient21({ endpoint, tenantId, accessToken, profile: env2, environmentSafety: safety });
9684
+ client4.raw().defaults.maxRedirects = 0;
9685
+ client4.raw().defaults.__skipRetry = true;
9686
+ const principal = await readSessionPrincipal3(client4.raw());
9627
9687
  if (principal.tenantId !== tenantId || tenantId === "__SYSTEM__" || !principal.roles?.includes("admin.system") || principal.impersonated || principal.actSub != null) {
9628
9688
  throw new CliError23({
9629
9689
  code: CliErrorCode24.SCOPE_FORBIDDEN,
@@ -9631,7 +9691,7 @@ async function tenantReconcileCommand(args) {
9631
9691
  context: { nextStep: "\u7531\u76EE\u6807\u79DF\u6237\u7BA1\u7406\u5458\u6838\u5BF9\u73AF\u5883\u3001\u79DF\u6237\u4E0E\u767B\u5F55\u4F1A\u8BDD\uFF1BAPI Token/OAuth \u59D4\u6258\u7531\u670D\u52A1\u7AEF\u62D2\u7EDD\u3002" }
9632
9692
  });
9633
9693
  }
9634
- process.stderr.write(`\u2192 \u8865\u8DD1\u76EE\u6807 ${client3.endpoint} \xB7 \u73AF\u5883 ${env2} \xB7 \u79DF\u6237 ${tenantId} \xB7 \u7528\u6237 ${principal.username}
9694
+ process.stderr.write(`\u2192 \u8865\u8DD1\u76EE\u6807 ${client4.endpoint} \xB7 \u73AF\u5883 ${env2} \xB7 \u79DF\u6237 ${tenantId} \xB7 \u7528\u6237 ${principal.username}
9635
9695
  \u5C06\u5F53\u524D\u79DF\u6237\u5404\u521D\u59CB\u5316\u7EC4\u4EF6\u5BF9\u9F50\u5230\u670D\u52A1\u7AEF\u6700\u65B0 catalog\uFF1B\u53EF\u80FD\u65B0\u589E\u9ED8\u8BA4\u8D44\u6E90\uFF0C\u4FDD\u7559\u89C4\u5219\u4EE5\u5404\u7EC4\u4EF6\u4E3A\u51C6\u3002\u6267\u884C\u524D\u5E94\u6309\u672C\u6B21\u6388\u6743\u4FDD\u5B58\u914D\u7F6E\u57FA\u7EBF\uFF1B\u4E0D\u91CD\u7F6E\u79DF\u6237\uFF0C\u4E0D\u63A5\u53D7\u6307\u5B9A\u79DF\u6237\u6216\u7248\u672C\u3002
9636
9696
  `);
9637
9697
  if (!args.yes) {
@@ -9647,13 +9707,13 @@ async function tenantReconcileCommand(args) {
9647
9707
  });
9648
9708
  }
9649
9709
  attempted = true;
9650
- const reconcile = await reconcileTenant(client3.raw(), tenantId);
9710
+ const reconcile = await reconcileTenant(client4.raw(), tenantId);
9651
9711
  let verification;
9652
9712
  if (!reconcile.success || reconcile.error != null || reconcile.results.some((r) => r.status !== "SUCCESS")) {
9653
9713
  verification = { status: "FAILED", reason: "\u670D\u52A1\u7AEF\u56DE\u6267\u5305\u542B\u672A\u6210\u529F\u7EC4\u4EF6\uFF1B\u672A\u5C06\u90E8\u5206\u6210\u529F\u5F53\u4F5C\u5B8C\u6210\u3002" };
9654
9714
  } else {
9655
9715
  try {
9656
- const report = await bootstrapReport(client3.raw());
9716
+ const report = await bootstrapReport(client4.raw());
9657
9717
  const value = report;
9658
9718
  const checks = Array.isArray(value?.results) ? value.results.filter((r) => r?.checkId === "tenant.bootstrap") : [];
9659
9719
  const verdict = checks.length === 1 ? checks[0]?.verdict : void 0;
@@ -10026,6 +10086,256 @@ async function metaValidateCommand(path22, args) {
10026
10086
  }
10027
10087
  }
10028
10088
 
10089
+ // src/commands/meta-column-slots.ts
10090
+ init_exit();
10091
+ init_auth_guard();
10092
+ import {
10093
+ HcmClient as HcmClient23,
10094
+ CliError as CliError25,
10095
+ CliErrorCode as CliErrorCode26,
10096
+ fromAxiosError as fromAxiosError22,
10097
+ formatObject as formatObject23,
10098
+ getColumnSlots,
10099
+ getColumnSlotSql,
10100
+ COLUMN_SLOT_SQL_KEYS,
10101
+ COLUMN_SLOT_REBIND_SQL_KEYS
10102
+ } from "@hcmai/sdk";
10103
+ var COLUMN_SLOT_SQL_PURPOSE = {
10104
+ countSlot: "\u69FD\u91CC\u672C\u79DF\u6237\u7684\u975E\u7A7A\u884C\u6570\uFF08\u7ED1\u5B9A\u524D\u987B\u4E3A 0\uFF09",
10105
+ flexToSlot: "\u628A flex \u91CC\u7684\u503C\u642C\u8FDB\u69FD",
10106
+ verifyFlexToSlot: "\u6838\u5BF9 flex \u4E0E\u69FD\u662F\u5426\u4E00\u81F4\uFF0C\u7ED3\u679C\u987B\u4E3A 0",
10107
+ slotToFlex: "\u628A\u69FD\u91CC\u7684\u503C\u5199\u56DE flex",
10108
+ removeFlexKey: "\u5220\u6389 flex \u91CC\u7684\u540C\u540D\u952E",
10109
+ clearSlot: "\u6E05\u7A7A\u672C\u79DF\u6237\u5728\u8FD9\u4E2A\u69FD\u91CC\u7684\u503C",
10110
+ moveFromSlot: "\u6539\u7ED1\uFF1A\u628A\u65E7\u69FD\u7684\u503C\u642C\u8FDB\u65B0\u69FD",
10111
+ verifyMoveFromSlot: "\u6539\u7ED1\u6838\u5BF9\uFF1A\u65B0\u65E7\u69FD\u662F\u5426\u4E00\u81F4\uFF0C\u7ED3\u679C\u987B\u4E3A 0",
10112
+ clearFromSlot: "\u6539\u7ED1\uFF1A\u6E05\u7A7A\u65E7\u69FD"
10113
+ };
10114
+ var STEP_ORDER = ["flexToColumn", "columnToFlex", "rebind"];
10115
+ var STEP_LABEL = {
10116
+ flexToColumn: "flex \u2192 \u5217\u69FD",
10117
+ columnToFlex: "\u5217\u69FD \u2192 flex",
10118
+ rebind: "\u6539\u7ED1\u522B\u7684\u69FD"
10119
+ };
10120
+ var isKnownKey = (key2) => COLUMN_SLOT_SQL_KEYS.includes(key2);
10121
+ function flagsOf(args) {
10122
+ return connFlags(args) + (args.workspace ? ` --workspace ${args.workspace}` : "");
10123
+ }
10124
+ function client3(args) {
10125
+ return getActiveAuthContextFromCli(args).then((ctx) => HcmClient23.fromAuthContext(ctx));
10126
+ }
10127
+ function formatOf(args) {
10128
+ return args.output === "json" || args.output === "yaml" ? args.output : "table";
10129
+ }
10130
+ function fail8(e, args) {
10131
+ const err = e;
10132
+ if (err?.isAxiosError) {
10133
+ const ce = fromAxiosError22(err, args.env);
10134
+ if (err.response?.status === 404 && !ce.context?.nextStep) {
10135
+ exitWithError(
10136
+ new CliError25({
10137
+ code: ce.code,
10138
+ message: ce.message,
10139
+ context: {
10140
+ ...ce.context,
10141
+ nextStep: "\u76EE\u6807\u73AF\u5883\u7684\u540E\u7AEF\u591A\u534A\u8FD8\u6CA1\u6709\u5217\u69FD\u63A5\u53E3\uFF08\u968F ADR-452 \u5217\u69FD\u767B\u8BB0\u8868\u53D1\u5E03\uFF09\uFF1A\u7528 `hcm version` \u770B\u540E\u7AEF\u7248\u672C"
10142
+ },
10143
+ traceId: ce.traceId,
10144
+ profile: ce.profile,
10145
+ cause: ce.cause
10146
+ })
10147
+ );
10148
+ }
10149
+ exitWithError(ce);
10150
+ }
10151
+ exitWithError(e);
10152
+ }
10153
+ function writeNotes(view, args) {
10154
+ if (view.degraded) {
10155
+ process.stderr.write(`\u26A0\uFE0F \u964D\u7EA7\uFF08degraded\uFF09\uFF1A${view.reason ?? "\u670D\u52A1\u7AEF\u6CA1\u7ED9\u539F\u56E0"}
10156
+ `);
10157
+ }
10158
+ if (view.source === "active" && !args.workspace) {
10159
+ process.stderr.write(
10160
+ "\u6765\u6E90 active\uFF1A\u8FD9\u6B21\u6CA1\u8FDB\u5F00\u53D1\u7A7A\u95F4\uFF08\u6CA1\u5E26 --workspace\uFF0C\u5F53\u524D\u8EAB\u4EFD\u4E5F\u6CA1\u6709\u5F00\u53D1\u6A21\u5F0F\u7ED1\u5B9A\uFF09\uFF0C\u53EA\u4FDD\u5B58\u5728\u5F00\u53D1\u7A7A\u95F4\u91CC\u7684\u5B57\u6BB5\u4E0E\u5360\u7528\u4E0D\u7B97\u5728\u5185\uFF1B\u8981\u770B\u5F00\u53D1\u7A7A\u95F4\u5C31\u52A0 --workspace <key>\n"
10161
+ );
10162
+ }
10163
+ if (view.nextStep) process.stderr.write(`\u4E0B\u4E00\u6B65\uFF1A${view.nextStep}
10164
+ `);
10165
+ }
10166
+ function columnWidth(values, header) {
10167
+ return Math.max(header.length, ...values.map((v) => v.length));
10168
+ }
10169
+ function renderColumnSlots(view, flags = "") {
10170
+ const lines = [`\u6A21\u578B ${view.model} \u2192 \u8868 ${view.table} \xB7 \u6765\u6E90 ${view.source}`];
10171
+ if (view.degraded) {
10172
+ lines.push(`\u26A0\uFE0F \u964D\u7EA7\uFF08${view.reason ?? "\u670D\u52A1\u7AEF\u6CA1\u7ED9\u539F\u56E0"}\uFF09\uFF1A\u7ED3\u679C\u53EF\u80FD\u4E0D\u5168\uFF0C\u53EF\u9009\u69FD\u53EF\u80FD\u504F\u5C11`);
10173
+ }
10174
+ lines.push("", `\u53EF\u9009\u69FD\uFF08${view.slots.length}\uFF09\uFF1A`);
10175
+ if (view.slots.length === 0) lines.push(" \uFF08\u65E0\uFF09");
10176
+ else {
10177
+ const w = columnWidth(view.slots.map((s) => s.column), "COLUMN");
10178
+ lines.push(` ${"COLUMN".padEnd(w)} TYPE`);
10179
+ for (const s of view.slots) lines.push(` ${s.column.padEnd(w)} ${s.type}`);
10180
+ }
10181
+ lines.push("", `\u5DF2\u5360\u7528\uFF08${view.occupied.length}\uFF09\uFF1A`);
10182
+ if (view.occupied.length === 0) lines.push(" \uFF08\u65E0\uFF09");
10183
+ else {
10184
+ const w = columnWidth(view.occupied.map((s) => s.column), "COLUMN");
10185
+ const t = columnWidth(view.occupied.map((s) => s.type), "TYPE");
10186
+ lines.push(` ${"COLUMN".padEnd(w)} ${"TYPE".padEnd(t)} MODEL.FIELD`);
10187
+ for (const s of view.occupied) lines.push(` ${s.column.padEnd(w)} ${s.type.padEnd(t)} ${s.model}.${s.field}`);
10188
+ }
10189
+ const reasons = Object.entries(view.unavailableByReason ?? {});
10190
+ const total = reasons.reduce((n, [, c2]) => n + (Number(c2) || 0), 0);
10191
+ lines.push("", `\u4E0D\u53EF\u7528\u69FD\uFF08${total}\uFF0C\u6309\u539F\u56E0\u8BA1\u6570\uFF09\uFF1A`);
10192
+ if (reasons.length === 0) lines.push(" \uFF08\u65E0\uFF09");
10193
+ else {
10194
+ const w = columnWidth(reasons.map(([r]) => r), "REASON");
10195
+ for (const [reason, count] of reasons) lines.push(` ${reason.padEnd(w)} ${count}`);
10196
+ }
10197
+ lines.push(
10198
+ "",
10199
+ `\u53D6\u642C\u6570\u636E / \u6E05\u6570\u636E\u7684 SQL\uFF1A\`hcm meta column-slot-sql ${view.model} <\u5B57\u6BB5\u952E> --slot <\u69FD>${flags}\`\uFF08\u6539\u7ED1\u518D\u52A0 --from-slot <\u65E7\u69FD>\uFF09`
10200
+ );
10201
+ return lines.join("\n");
10202
+ }
10203
+ function sqlText(view, key2) {
10204
+ const text = view.sql[key2];
10205
+ return typeof text === "string" && text.trim() ? text : void 0;
10206
+ }
10207
+ function unavailableReason(view, key2) {
10208
+ const reason = view.unavailable?.[key2];
10209
+ if (typeof reason === "string" && reason.trim()) return reason;
10210
+ return view.sql[key2] === "" ? "\u670D\u52A1\u7AEF\u7ED9\u4E86\u7A7A\u4E32\uFF0C\u4E5F\u6CA1\u8BF4\u539F\u56E0" : "\u670D\u52A1\u7AEF\u6CA1\u7ED9\u539F\u56E0";
10211
+ }
10212
+ function sqlKeysOf(view) {
10213
+ const present = Object.keys(view.sql);
10214
+ return [...COLUMN_SLOT_SQL_KEYS.filter((k) => present.includes(k)), ...present.filter((k) => !isKnownKey(k))];
10215
+ }
10216
+ function renderColumnSlotSql(view) {
10217
+ const lines = [];
10218
+ const typeNote = [view.fieldType ? `type ${view.fieldType}` : void 0, view.storage ? `\u5B58\u50A8 ${view.storage}` : void 0].filter(Boolean).join(" \xB7 ");
10219
+ lines.push(`\u79DF\u6237 ${view.tenantId} \xB7 ${view.model}.${view.field}${typeNote ? `\uFF08${typeNote}\uFF09` : ""}`);
10220
+ lines.push(`\u8868 ${view.table} \xB7 \u6765\u6E90 ${view.source}`);
10221
+ const target = `${view.slot}${view.slotType ? `\uFF08${view.slotType}\uFF09` : ""}`;
10222
+ lines.push(
10223
+ view.fromSlot ? `\u69FD\uFF1A\u6539\u7ED1 ${view.fromSlot} \u2192 ${target} \xB7 \u5143\u6570\u636E\u5F53\u524D\u7ED1\u5B9A ${view.currentSlot ?? "\u65E0"}` : `\u69FD\uFF1A\u5F53\u524D ${view.currentSlot ?? "\u65E0\uFF08flex\uFF09"} \u2192 \u76EE\u6807 ${target}`
10224
+ );
10225
+ const disc = Object.entries(view.discriminator ?? {});
10226
+ lines.push(
10227
+ `\u533A\u5206\u6761\u4EF6\uFF1A${disc.length ? disc.map(([c2, v]) => `${c2} = ${v}`).join(" AND ") : "\u65E0\uFF08\u6BCF\u53E5\u53EA\u6309 tenant_id \u9650\u5B9A\uFF09"}`
10228
+ );
10229
+ lines.push(`\u65B9\u8A00\uFF1A${view.dialect ?? "\u670D\u52A1\u7AEF\u6CA1\u7ED9"}`);
10230
+ if (view.degraded) lines.push(`\u26A0\uFE0F \u964D\u7EA7\uFF1A${view.reason ?? "\u670D\u52A1\u7AEF\u6CA1\u7ED9\u539F\u56E0"}`);
10231
+ if (view.jsonSqlUnavailable) lines.push(`\u26A0\uFE0F JSON \u7C7B\u8BED\u53E5\u4E0D\u53EF\u7528\uFF1A${view.jsonSqlUnavailable}`);
10232
+ lines.push("", "\u53EF\u7528\u6027\uFF1A");
10233
+ const availability = Object.entries(view.availability ?? {});
10234
+ if (availability.length === 0) lines.push(" \uFF08\u670D\u52A1\u7AEF\u6CA1\u7ED9\uFF09");
10235
+ else {
10236
+ const w = columnWidth(availability.map(([s]) => s), "");
10237
+ for (const [slot, a] of availability) {
10238
+ if (a?.available) lines.push(` ${slot.padEnd(w)} \u53EF\u7528`);
10239
+ else {
10240
+ lines.push(` ${slot.padEnd(w)} \u4E0D\u53EF\u7528\uFF08${a?.reason ?? "\u670D\u52A1\u7AEF\u6CA1\u7ED9\u539F\u56E0"}\uFF09`);
10241
+ if (a?.nextStep) lines.push(` ${"".padEnd(w)} \u4E0B\u4E00\u6B65\uFF1A${a.nextStep}`);
10242
+ }
10243
+ }
10244
+ }
10245
+ lines.push("", "SQL\uFF08\u9010\u53E5\uFF1B\u7ED9\u4E0D\u51FA\u7684\u5199\u660E\u539F\u56E0\uFF09\uFF1A");
10246
+ for (const key2 of sqlKeysOf(view)) {
10247
+ const purpose = isKnownKey(key2) ? COLUMN_SLOT_SQL_PURPOSE[key2] : "\u672C\u7248 CLI \u4E0D\u8BA4\u8BC6\u8FD9\u53E5\u7684\u7528\u9014\uFF0C\u89C1\u4E0B\u65B9\u6D41\u7A0B";
10248
+ const text = sqlText(view, key2);
10249
+ lines.push("", `-- ${key2} \xB7 ${purpose}`, text ?? `\uFF08\u4E0D\u53EF\u7528\uFF1A${unavailableReason(view, key2)}\uFF09`);
10250
+ }
10251
+ const steps = view.steps ?? {};
10252
+ const stepKeys = [...STEP_ORDER.filter((k) => k in steps), ...Object.keys(steps).filter((k) => !STEP_ORDER.includes(k))];
10253
+ lines.push("", "\u6D41\u7A0B\uFF1A");
10254
+ if (stepKeys.length === 0) lines.push(" \uFF08\u670D\u52A1\u7AEF\u6CA1\u7ED9\uFF09");
10255
+ for (const k of stepKeys) lines.push(` ${k}\uFF08${STEP_LABEL[k] ?? k}\uFF09\uFF1A${steps[k]}`);
10256
+ return lines.join("\n");
10257
+ }
10258
+ async function metaColumnSlotsCommand(model, args) {
10259
+ try {
10260
+ const c2 = await client3(args);
10261
+ const view = await getColumnSlots(c2.raw(), model, { workspaceKey: args.workspace });
10262
+ const fmt = formatOf(args);
10263
+ process.stdout.write(
10264
+ (fmt === "table" ? renderColumnSlots(view, flagsOf(args)) : formatObject23(view, { format: fmt })) + "\n"
10265
+ );
10266
+ writeNotes(view, args);
10267
+ process.exitCode = 0;
10268
+ } catch (e) {
10269
+ fail8(e, args);
10270
+ }
10271
+ }
10272
+ async function metaColumnSlotSqlCommand(model, field, args) {
10273
+ try {
10274
+ const only = args.only;
10275
+ if (only !== void 0) {
10276
+ if (!isKnownKey(only)) {
10277
+ throw new CliError25({
10278
+ code: CliErrorCode26.INVALID_ARGUMENT,
10279
+ message: `--only ${only} \u4E0D\u662F\u8BA4\u5F97\u7684 SQL \u952E`,
10280
+ context: { nextStep: `\u53EF\u9009\uFF1A${COLUMN_SLOT_SQL_KEYS.join(" / ")}` }
10281
+ });
10282
+ }
10283
+ if (COLUMN_SLOT_REBIND_SQL_KEYS.includes(only) && !args.fromSlot) {
10284
+ throw new CliError25({
10285
+ code: CliErrorCode26.INVALID_ARGUMENT,
10286
+ message: `${only} \u662F\u6539\u7ED1\u4E09\u53E5\u4E4B\u4E00\uFF0C\u53EA\u5728\u5E26 --from-slot \u65F6\u624D\u7ED9\u51FA`,
10287
+ context: { nextStep: "\u52A0 --from-slot <\u65E7\u69FD> \u91CD\u8DD1\uFF08--slot \u5199\u65B0\u69FD\uFF09" }
10288
+ });
10289
+ }
10290
+ }
10291
+ const c2 = await client3(args);
10292
+ const view = await getColumnSlotSql(
10293
+ c2.raw(),
10294
+ { model, field, slot: args.slot, fromSlot: args.fromSlot },
10295
+ { workspaceKey: args.workspace }
10296
+ );
10297
+ if (only !== void 0) {
10298
+ if (!(only in view.sql)) {
10299
+ throw new CliError25({
10300
+ code: CliErrorCode26.PROTOCOL_UNSUPPORTED,
10301
+ message: `\u670D\u52A1\u7AEF\u54CD\u5E94\u91CC\u6CA1\u6709 sql.${only}\uFF08\u53EA\u6709\uFF1A${Object.keys(view.sql).join(" / ") || "\u65E0"}\uFF09`,
10302
+ context: {
10303
+ reasonCode: "COLUMN_SLOT_SQL_KEY_MISSING",
10304
+ nextStep: "\u53BB\u6389 --only \u770B\u6574\u4EFD\u8F93\u51FA\uFF1B\u7528 `hcm version` \u6838\u5BF9\u540E\u7AEF\u7248\u672C"
10305
+ }
10306
+ });
10307
+ }
10308
+ const text = sqlText(view, only);
10309
+ if (text === void 0) {
10310
+ throw new CliError25({
10311
+ code: CliErrorCode26.BUSINESS_RULE_VIOLATION,
10312
+ message: `sql.${only} \u7ED9\u4E0D\u51FA\uFF1A${unavailableReason(view, only)}`,
10313
+ context: {
10314
+ reasonCode: "COLUMN_SLOT_SQL_UNAVAILABLE",
10315
+ nextStep: view.degraded && view.nextStep ? view.nextStep : "\u53BB\u6389 --only \u770B\u6574\u4EFD\u8F93\u51FA\uFF08\u5404\u53E5\u539F\u56E0\u3001\u53EF\u7528\u6027\u4E0E\u6D41\u7A0B\uFF09"
10316
+ }
10317
+ });
10318
+ }
10319
+ process.stdout.write(text.endsWith("\n") ? text : text + "\n");
10320
+ } else {
10321
+ const fmt = formatOf(args);
10322
+ process.stdout.write((fmt === "table" ? renderColumnSlotSql(view) : formatObject23(view, { format: fmt })) + "\n");
10323
+ }
10324
+ if (only !== void 0 || formatOf(args) !== "table") {
10325
+ for (const [slot, a] of Object.entries(view.availability ?? {})) {
10326
+ if (a && !a.available) {
10327
+ process.stderr.write(`\u26A0\uFE0F \u69FD ${slot} \u672C\u5B9E\u4F8B\u4E0D\u53EF\u7528\uFF08${a.reason ?? "\u670D\u52A1\u7AEF\u6CA1\u7ED9\u539F\u56E0"}\uFF09${a.nextStep ? `\uFF1A${a.nextStep}` : ""}
10328
+ `);
10329
+ }
10330
+ }
10331
+ }
10332
+ writeNotes(view, args);
10333
+ process.exitCode = 0;
10334
+ } catch (e) {
10335
+ fail8(e, args);
10336
+ }
10337
+ }
10338
+
10029
10339
  // src/commands/workspace.ts
10030
10340
  init_exit();
10031
10341
  import * as crypto from "crypto";
@@ -10038,10 +10348,10 @@ import {
10038
10348
  createWorkspaceFile,
10039
10349
  deleteWorkspaceFile,
10040
10350
  formatMiniVerifyReport,
10041
- formatObject as formatObject24,
10351
+ formatObject as formatObject25,
10042
10352
  formatRows as formatRows6,
10043
10353
  getMiniStatus,
10044
- HcmClient as HcmClient23,
10354
+ HcmClient as HcmClient24,
10045
10355
  initMiniAppProject,
10046
10356
  inferMiniWritableTemplateOptionsFromModel,
10047
10357
  listWorkspaceFiles,
@@ -10056,14 +10366,14 @@ import {
10056
10366
  validateMiniProject,
10057
10367
  validateMetaContent as validateMetaContent2,
10058
10368
  validateWorkspaceFiles,
10059
- fromAxiosError as fromAxiosError23,
10060
- CliError as CliError26,
10061
- CliErrorCode as CliErrorCode27
10369
+ fromAxiosError as fromAxiosError24,
10370
+ CliError as CliError27,
10371
+ CliErrorCode as CliErrorCode28
10062
10372
  } from "@hcmai/sdk";
10063
10373
 
10064
10374
  // src/commands/workspace-push-progress.ts
10065
10375
  import { isAxiosError } from "axios";
10066
- import { CliError as CliError25, CliErrorCode as CliErrorCode26, fromAxiosError as fromAxiosError22 } from "@hcmai/sdk";
10376
+ import { CliError as CliError26, CliErrorCode as CliErrorCode27, fromAxiosError as fromAxiosError23 } from "@hcmai/sdk";
10067
10377
  var PUSH_DEADLINE_MS = 3e5;
10068
10378
  var HEARTBEAT_MS = 1e4;
10069
10379
  async function withWorkspacePushProgress(run3, profile) {
@@ -10091,8 +10401,8 @@ async function withWorkspacePushProgress(run3, profile) {
10091
10401
  let timer;
10092
10402
  const deadline = new Promise((_, reject) => {
10093
10403
  timer = setTimeout(() => {
10094
- failure2 = new CliError25({
10095
- code: CliErrorCode26.TIMEOUT,
10404
+ failure2 = new CliError26({
10405
+ code: CliErrorCode27.TIMEOUT,
10096
10406
  message: `workspace push \u6574\u4F53\u671F\u9650\u5DF2\u5230\uFF08300 \u79D2\uFF09\uFF1B\u7B49\u5F85 ${requestLabel()}\u3002\u670D\u52A1\u7AEF\u63D0\u4EA4\u72B6\u6001\u672A\u77E5\u3002`,
10097
10407
  traceId: traceId(),
10098
10408
  profile,
@@ -10133,8 +10443,8 @@ async function withWorkspacePushProgress(run3, profile) {
10133
10443
  return await Promise.race([operation, deadline]);
10134
10444
  } catch (error) {
10135
10445
  if (!isAxiosError(error)) throw error;
10136
- const translated = fromAxiosError22(error, profile);
10137
- throw new CliError25({
10446
+ const translated = fromAxiosError23(error, profile);
10447
+ throw new CliError26({
10138
10448
  code: translated.code,
10139
10449
  message: translated.message,
10140
10450
  traceId: translated.traceId,
@@ -10147,7 +10457,7 @@ async function withWorkspacePushProgress(run3, profile) {
10147
10457
  } : {},
10148
10458
  nextStep: [
10149
10459
  translated.context?.nextStep,
10150
- translated.code === CliErrorCode26.AUTH_FAILED ? `\u5148 hcm login --env ${profile ?? "<\u73AF\u5883>"} --username <\u771F\u5B9E\u767B\u5F55\u8D26\u53F7> --password-stdin\uFF0C\u518D hcm workspace active\uFF1B\u8BA4\u8BC1\u672A\u901A\u8FC7\u4E0D\u80FD\u636E\u6B64\u5224\u65AD\u5DE5\u4F5C\u533A\u5931\u6548\u3002` : void 0,
10460
+ translated.code === CliErrorCode27.AUTH_FAILED ? `\u5148 hcm login --env ${profile ?? "<\u73AF\u5883>"} --username <\u771F\u5B9E\u767B\u5F55\u8D26\u53F7> --password-stdin\uFF0C\u518D hcm workspace active\uFF1B\u8BA4\u8BC1\u672A\u901A\u8FC7\u4E0D\u80FD\u636E\u6B64\u5224\u65AD\u5DE5\u4F5C\u533A\u5931\u6548\u3002` : void 0,
10151
10461
  recovery2
10152
10462
  ].filter(Boolean).join(" ")
10153
10463
  }
@@ -10191,11 +10501,11 @@ function boolValue(value) {
10191
10501
  // src/commands/workspace-rebase.ts
10192
10502
  import * as fs8 from "fs/promises";
10193
10503
  import * as path9 from "path";
10194
- import { formatObject as formatObject23 } from "@hcmai/sdk";
10504
+ import { formatObject as formatObject24 } from "@hcmai/sdk";
10195
10505
  async function runWorkspaceRebase(workspaceKey, args, connect) {
10196
10506
  const plan = args.plan && !args.dryRun ? readPlan(JSON.parse(await fs8.readFile(args.plan, "utf8"))) : void 0;
10197
- const client3 = await connect();
10198
- const workspaces = await client3.query("TenantExtensionWorkspace", {
10507
+ const client4 = await connect();
10508
+ const workspaces = await client4.query("TenantExtensionWorkspace", {
10199
10509
  filter: { workspaceKey },
10200
10510
  fields: ["id", "workspaceKey"],
10201
10511
  limit: 2
@@ -10206,7 +10516,7 @@ async function runWorkspaceRebase(workspaceKey, args, connect) {
10206
10516
  const id = requiredText(workspaces.rows[0].id, "workspace model id");
10207
10517
  const action = `/api/models/TenantExtensionWorkspace/${encodeURIComponent(id)}/action`;
10208
10518
  if (plan) {
10209
- const response2 = await client3.raw().post(`${action}/resolve-conflicts`, { form: plan });
10519
+ const response2 = await client4.raw().post(`${action}/resolve-conflicts`, { form: plan });
10210
10520
  const result = actionPayload(response2.data);
10211
10521
  const expected = new Set(plan.resolutions.map((item) => item.relativePath));
10212
10522
  if (result.workspaceKey !== workspaceKey || !Array.isArray(result.resolvedPaths) || result.resolvedPaths.length !== expected.size || new Set(result.resolvedPaths).size !== expected.size || result.resolvedPaths.some((item) => typeof item !== "string" || !expected.has(item)) || !nonnegativeInteger(result.remainingConflicts)) {
@@ -10223,7 +10533,7 @@ async function runWorkspaceRebase(workspaceKey, args, connect) {
10223
10533
  ]);
10224
10534
  return;
10225
10535
  }
10226
- const response = await client3.raw().get(`${action}/preview-rebase`);
10536
+ const response = await client4.raw().get(`${action}/preview-rebase`);
10227
10537
  const preview = readPreview(actionPayload(response.data), workspaceKey);
10228
10538
  if (args.plan) {
10229
10539
  const draft = {
@@ -10326,7 +10636,7 @@ function filePath(value) {
10326
10636
  return text;
10327
10637
  }
10328
10638
  function writeResult(result, format = "table", lines) {
10329
- process.stdout.write((format === "table" ? lines.join("\n") : formatObject23(result, { format })) + "\n");
10639
+ process.stdout.write((format === "table" ? lines.join("\n") : formatObject24(result, { format })) + "\n");
10330
10640
  }
10331
10641
 
10332
10642
  // src/commands/workspace.ts
@@ -10348,9 +10658,9 @@ var RAW_WORKSPACE_EXCLUDED_DIRS = /* @__PURE__ */ new Set([
10348
10658
  var RAW_WORKSPACE_EXCLUDED_FILES = /* @__PURE__ */ new Set([WORKSPACE_CONTEXT_FILE, ".DS_Store"]);
10349
10659
  async function workspaceListCommand(args) {
10350
10660
  try {
10351
- const client3 = HcmClient23.fromAuthContext(await getActiveAuthContextFromCli(args));
10661
+ const client4 = HcmClient24.fromAuthContext(await getActiveAuthContextFromCli(args));
10352
10662
  const limit = parsePositiveInt3(args.limit, 50, "--limit");
10353
- const result = await client3.query("TenantExtensionWorkspace", {
10663
+ const result = await client4.query("TenantExtensionWorkspace", {
10354
10664
  keyword: args.keyword,
10355
10665
  fields: [
10356
10666
  "workspaceKey",
@@ -10381,8 +10691,8 @@ async function workspaceActiveCommand(args) {
10381
10691
  const ctx = await getActiveAuthContextFromCli(args, {
10382
10692
  fallbackEnv: localContext?.profile
10383
10693
  });
10384
- const client3 = HcmClient23.fromAuthContext(ctx);
10385
- const binding = await readWorkspaceDevModeBinding(client3);
10694
+ const client4 = HcmClient24.fromAuthContext(ctx);
10695
+ const binding = await readWorkspaceDevModeBinding(client4);
10386
10696
  const activeWorkspaceKey = binding.enabled ? optionalText(binding.workspaceKey) : null;
10387
10697
  const bindingUpdatedAt = typeof binding.updatedAt === "number" && Number.isFinite(binding.updatedAt) && binding.updatedAt > 0 && binding.updatedAt <= 864e13 ? binding.updatedAt : null;
10388
10698
  const view = {
@@ -10393,9 +10703,9 @@ async function workspaceActiveCommand(args) {
10393
10703
  localWorkspaceKey: localContext?.workspaceKey ?? null,
10394
10704
  matchesLocal: activeWorkspaceKey && localContext?.workspaceKey ? activeWorkspaceKey === localContext.workspaceKey : null,
10395
10705
  nextCommand: workspaceActiveNextCommand(activeWorkspaceKey),
10396
- profile: client3.profile,
10397
- tenantId: client3.tenantId,
10398
- endpoint: client3.endpoint,
10706
+ profile: client4.profile,
10707
+ tenantId: client4.tenantId,
10708
+ endpoint: client4.endpoint,
10399
10709
  rootDir
10400
10710
  };
10401
10711
  writeWorkspaceActiveResult(view, args.output ?? "table");
@@ -10414,12 +10724,12 @@ async function workspaceBindCommand(workspaceKey, args) {
10414
10724
  `${WORKSPACE_CONTEXT_FILE} already binds workspace '${existing.workspaceKey}'; use --force to rebind`
10415
10725
  );
10416
10726
  }
10417
- const client3 = await loadProfileClient(args);
10727
+ const client4 = await loadProfileClient(args);
10418
10728
  const context = buildWorkspaceContext({
10419
10729
  workspaceKey,
10420
- profile: args.env ?? args.profile ?? client3?.profile,
10421
- tenantId: args.tenant ?? client3?.tenantId,
10422
- endpoint: args.endpoint ?? client3?.endpoint
10730
+ profile: args.env ?? args.profile ?? client4?.profile,
10731
+ tenantId: args.tenant ?? client4?.tenantId,
10732
+ endpoint: args.endpoint ?? client4?.endpoint
10423
10733
  });
10424
10734
  await fs9.mkdir(rootDir, { recursive: true });
10425
10735
  await writeWorkspaceContext(rootDir, context);
@@ -10439,9 +10749,9 @@ async function workspaceCreateCommand(workspaceKey, args) {
10439
10749
  `${WORKSPACE_CONTEXT_FILE} already binds workspace '${existing.workspaceKey}'; use --force to rebind`
10440
10750
  );
10441
10751
  }
10442
- const client3 = HcmClient23.fromAuthContext(await getActiveAuthContextFromCli(args));
10752
+ const client4 = HcmClient24.fromAuthContext(await getActiveAuthContextFromCli(args));
10443
10753
  const normalizedWorkspaceKey = normalizeWorkspaceKey(workspaceKey);
10444
- const resp = await client3.raw().post("/api/models/TenantExtensionWorkspace", {
10754
+ const resp = await client4.raw().post("/api/models/TenantExtensionWorkspace", {
10445
10755
  workspaceKey: normalizedWorkspaceKey,
10446
10756
  description: args.description ?? ""
10447
10757
  });
@@ -10449,14 +10759,14 @@ async function workspaceCreateCommand(workspaceKey, args) {
10449
10759
  const id = stringOptional(created.id);
10450
10760
  let activated = false;
10451
10761
  if (args.activate) {
10452
- await setDevModeBinding(client3, normalizedWorkspaceKey);
10762
+ await setDevModeBinding(client4, normalizedWorkspaceKey);
10453
10763
  activated = true;
10454
10764
  }
10455
10765
  const context = buildWorkspaceContext({
10456
10766
  workspaceKey: normalizedWorkspaceKey,
10457
- profile: args.profile ?? client3.profile,
10458
- tenantId: client3.tenantId,
10459
- endpoint: client3.endpoint
10767
+ profile: args.profile ?? client4.profile,
10768
+ tenantId: client4.tenantId,
10769
+ endpoint: client4.endpoint
10460
10770
  });
10461
10771
  await fs9.mkdir(rootDir, { recursive: true });
10462
10772
  await writeWorkspaceContext(rootDir, context);
@@ -10466,8 +10776,8 @@ async function workspaceCreateCommand(workspaceKey, args) {
10466
10776
  id: id ?? "-",
10467
10777
  rootDir,
10468
10778
  activated,
10469
- profile: client3.profile,
10470
- tenantId: client3.tenantId
10779
+ profile: client4.profile,
10780
+ tenantId: client4.tenantId
10471
10781
  },
10472
10782
  args.output ?? "table"
10473
10783
  );
@@ -10481,7 +10791,7 @@ async function workspaceRebaseCommand(args) {
10481
10791
  try {
10482
10792
  const existing = await readWorkspaceContext(resolveRootDir(args.dir));
10483
10793
  const workspaceKey = normalizeWorkspaceKey(args.workspace ?? existing?.workspaceKey ?? "");
10484
- await runWorkspaceRebase(workspaceKey, args, async () => HcmClient23.fromAuthContext(
10794
+ await runWorkspaceRebase(workspaceKey, args, async () => HcmClient24.fromAuthContext(
10485
10795
  await getActiveAuthContextFromCli(args, { fallbackEnv: existing?.profile })
10486
10796
  ));
10487
10797
  process.exitCode = 0;
@@ -10499,16 +10809,16 @@ async function workspacePullCommand(args) {
10499
10809
  `workspace key is required; pass --workspace <key> or run hcm workspace bind <key> first`
10500
10810
  );
10501
10811
  }
10502
- const client3 = HcmClient23.fromAuthContext(
10812
+ const client4 = HcmClient24.fromAuthContext(
10503
10813
  await getActiveAuthContextFromCli(args, { fallbackEnv: existing?.profile })
10504
10814
  );
10505
10815
  const context = buildWorkspaceContext({
10506
10816
  workspaceKey,
10507
- profile: client3.profile ?? args.env ?? args.profile ?? existing?.profile,
10508
- tenantId: client3.tenantId ?? existing?.tenantId,
10509
- endpoint: client3.endpoint ?? existing?.endpoint
10817
+ profile: client4.profile ?? args.env ?? args.profile ?? existing?.profile,
10818
+ tenantId: client4.tenantId ?? existing?.tenantId,
10819
+ endpoint: client4.endpoint ?? existing?.endpoint
10510
10820
  });
10511
- const files = await listWorkspaceFilesForSync(client3.raw(), workspaceKey);
10821
+ const files = await listWorkspaceFilesForSync(client4.raw(), workspaceKey);
10512
10822
  const localFiles = await readWorkspaceRawLocalFiles(rootDir);
10513
10823
  const remotePaths = new Set(files.data.map((file) => file.relativePath));
10514
10824
  const manifest2 = await readWorkspaceRawManifest(rootDir, context, true);
@@ -10516,8 +10826,8 @@ async function workspacePullCommand(args) {
10516
10826
  const previous = sameTarget ? workspaceRawBaselineByPath(manifest2) : /* @__PURE__ */ new Map();
10517
10827
  const remoteDeleted = localFiles.filter((file) => previous.has(file.localPath) && !remotePaths.has(file.localPath));
10518
10828
  if (remoteDeleted.length) {
10519
- throw new CliError26({
10520
- code: CliErrorCode27.BUSINESS_RULE_VIOLATION,
10829
+ throw new CliError27({
10830
+ code: CliErrorCode28.BUSINESS_RULE_VIOLATION,
10521
10831
  message: `\u8FDC\u7AEF\u5DF2\u5220\u9664\u66FE\u540C\u6B65\u7684\u6587\u4EF6\uFF0C\u672C\u5730\u4ECD\u4FDD\u7559\u5185\u5BB9\uFF1A${remoteDeleted.map((file) => file.localPath).join(", ")}\u3002\u672A\u91CD\u5EFA\u540C\u6B65\u57FA\u7EBF\u3002`,
10522
10832
  context: {
10523
10833
  reason: "WORKSPACE_REMOTE_FILE_DELETED",
@@ -10536,12 +10846,12 @@ async function workspacePullCommand(args) {
10536
10846
  const pulledMiniApps = [];
10537
10847
  for (const appCode of miniApps) {
10538
10848
  const result = await pullMiniAppProject({
10539
- http: client3.raw(),
10849
+ http: client4.raw(),
10540
10850
  appCode,
10541
10851
  workspaceKey,
10542
10852
  targetDir: path10.join(rootDir, MINI_APPS_DIR, appCode),
10543
- tenantId: client3.tenantId,
10544
- endpoint: client3.endpoint,
10853
+ tenantId: client4.tenantId,
10854
+ endpoint: client4.endpoint,
10545
10855
  profile: context.profile,
10546
10856
  force: !!args.force
10547
10857
  });
@@ -10553,10 +10863,10 @@ async function workspacePullCommand(args) {
10553
10863
  const pulledRawFiles = [];
10554
10864
  const snapshots = [];
10555
10865
  for (const file of rawFiles) {
10556
- const content = await loadWorkspaceFileContent(client3.raw(), file.id);
10866
+ const content = await loadWorkspaceFileContent(client4.raw(), file.id);
10557
10867
  if (content.workspaceKey !== workspaceKey || content.relativePath !== file.relativePath) {
10558
- throw new CliError26({
10559
- code: CliErrorCode27.NETWORK_ERROR,
10868
+ throw new CliError27({
10869
+ code: CliErrorCode28.NETWORK_ERROR,
10560
10870
  message: `load-content \u56DE\u6267\u4E0E\u76EE\u6807\u5DE5\u4F5C\u533A\u6216\u6587\u4EF6\u4E0D\u7B26\uFF1A${file.relativePath}`,
10561
10871
  context: {
10562
10872
  reason: "INVALID_WORKSPACE_FILE_CONTENT",
@@ -10606,12 +10916,12 @@ async function workspaceAddMiniCommand(appCode, args) {
10606
10916
  const templateKind = parseTemplateKind(args.template);
10607
10917
  validateWritableOptions(templateKind, args);
10608
10918
  const model = parseModelKey(args.model);
10609
- const client3 = await loadProfileClient({
10919
+ const client4 = await loadProfileClient({
10610
10920
  ...args,
10611
10921
  env: args.env ?? args.profile ?? context.profile
10612
10922
  });
10613
10923
  const autoOptions = await resolveWritableAutoOptions({
10614
- client: client3,
10924
+ client: client4,
10615
10925
  templateKind,
10616
10926
  model,
10617
10927
  fields: args.fields,
@@ -10630,9 +10940,9 @@ async function workspaceAddMiniCommand(appCode, args) {
10630
10940
  writableDefaults: autoOptions.defaults ?? parseJsonObject(args.defaults, "--defaults"),
10631
10941
  writableTodayDefaultFields: autoOptions.todayDefaultFields,
10632
10942
  requiredScopes: parseScopes(args.scopes),
10633
- tenantId: args.tenant ?? client3?.tenantId ?? context.tenantId,
10634
- endpoint: client3?.endpoint ?? context.endpoint,
10635
- profile: args.env ?? args.profile ?? client3?.profile ?? context.profile,
10943
+ tenantId: args.tenant ?? client4?.tenantId ?? context.tenantId,
10944
+ endpoint: client4?.endpoint ?? context.endpoint,
10945
+ profile: args.env ?? args.profile ?? client4?.profile ?? context.profile,
10636
10946
  force: !!args.force
10637
10947
  });
10638
10948
  writeWorkspaceAddMiniResult(result, rootDir, args.output ?? "table");
@@ -10664,15 +10974,15 @@ async function workspaceRmCommand(relativePath, args) {
10664
10974
  const manifest2 = await readWorkspaceRawManifest(rootDir, context);
10665
10975
  let manifestEntry = workspaceRawBaselineByPath(manifest2).get(normalized);
10666
10976
  if (!manifestEntry) {
10667
- const client3 = HcmClient23.fromAuthContext(await getActiveAuthContextFromCli(
10977
+ const client4 = HcmClient24.fromAuthContext(await getActiveAuthContextFromCli(
10668
10978
  args,
10669
10979
  { fallbackEnv: context.profile }
10670
10980
  ));
10671
- const remote = (await listWorkspaceFilesForSync(client3.raw(), context.workspaceKey)).data.find(
10981
+ const remote = (await listWorkspaceFilesForSync(client4.raw(), context.workspaceKey)).data.find(
10672
10982
  (file) => file.relativePath === normalized
10673
10983
  );
10674
10984
  if (remote) {
10675
- const content = await loadWorkspaceFileContent(client3.raw(), remote.id);
10985
+ const content = await loadWorkspaceFileContent(client4.raw(), remote.id);
10676
10986
  manifestEntry = {
10677
10987
  localPath: normalized,
10678
10988
  remotePath: remote.relativePath,
@@ -10689,7 +10999,7 @@ async function workspaceRmCommand(relativePath, args) {
10689
10999
  if (!stat) {
10690
11000
  if (manifestEntry) {
10691
11001
  process.stdout.write(
10692
- formatObject24(
11002
+ formatObject25(
10693
11003
  {
10694
11004
  workspaceKey: context.workspaceKey,
10695
11005
  file: normalized,
@@ -10714,7 +11024,7 @@ async function workspaceRmCommand(relativePath, args) {
10714
11024
  next: `hcm workspace push --dir ${args.dir ?? "."}`
10715
11025
  };
10716
11026
  if (args.output === "json" || args.output === "yaml") {
10717
- process.stdout.write(formatObject24(result, { format: args.output }) + "\n");
11027
+ process.stdout.write(formatObject25(result, { format: args.output }) + "\n");
10718
11028
  } else {
10719
11029
  process.stdout.write(`workspace file staged for deletion: ${normalized}
10720
11030
  `);
@@ -10761,7 +11071,7 @@ async function workspaceStatusCommand(args) {
10761
11071
  }
10762
11072
  if (args.output === "json" || args.output === "yaml") {
10763
11073
  process.stdout.write(
10764
- formatObject24({ rootDir, miniApps: rows2 }, { format: args.output }) + "\n"
11074
+ formatObject25({ rootDir, miniApps: rows2 }, { format: args.output }) + "\n"
10765
11075
  );
10766
11076
  } else {
10767
11077
  process.stdout.write(formatRows6(rows2, { format: "table" }) + "\n");
@@ -10822,26 +11132,26 @@ async function workspacePushCommand(args) {
10822
11132
  for (const app of miniApps) {
10823
11133
  const validation = await validateMiniProject(app.dir);
10824
11134
  if (!validation.valid) {
10825
- throw new CliError26({
10826
- code: CliErrorCode27.INVALID_ARGUMENT,
11135
+ throw new CliError27({
11136
+ code: CliErrorCode28.INVALID_ARGUMENT,
10827
11137
  message: `mini app ${app.appCode} validation failed: ${validation.errors.join("; ")}`
10828
11138
  });
10829
11139
  }
10830
11140
  }
10831
- const client3 = HcmClient23.fromAuthContext(
11141
+ const client4 = HcmClient24.fromAuthContext(
10832
11142
  await getActiveAuthContextFromCli(args, { fallbackEnv: context.profile })
10833
11143
  );
10834
- profile = client3.profile ?? profile;
10835
- bindHttp(client3.raw());
11144
+ profile = client4.profile ?? profile;
11145
+ bindHttp(client4.raw());
10836
11146
  if (!args.dryRun) {
10837
- requireWorkspaceActivation(await probeActiveWorkspaceKey(client3), context.workspaceKey);
11147
+ requireWorkspaceActivation(await probeActiveWorkspaceKey(client4), context.workspaceKey);
10838
11148
  }
10839
11149
  const miniPlans = [];
10840
11150
  for (const app of miniApps) {
10841
- miniPlans.push({ app, plan: await pushMiniAppProject({ http: client3.raw(), rootDir: app.dir, dryRun: true }) });
11151
+ miniPlans.push({ app, plan: await pushMiniAppProject({ http: client4.raw(), rootDir: app.dir, dryRun: true }) });
10842
11152
  }
10843
11153
  const rawResult = await pushWorkspaceRawFiles({
10844
- http: client3.raw(),
11154
+ http: client4.raw(),
10845
11155
  rootDir,
10846
11156
  context,
10847
11157
  dryRun: !!args.dryRun,
@@ -10854,7 +11164,7 @@ async function workspacePushCommand(args) {
10854
11164
  const results = [];
10855
11165
  for (const { app, plan } of miniPlans) {
10856
11166
  const result = args.dryRun ? plan : await pushMiniAppProject({
10857
- http: client3.raw(),
11167
+ http: client4.raw(),
10858
11168
  rootDir: app.dir,
10859
11169
  dryRun: false
10860
11170
  });
@@ -10863,7 +11173,7 @@ async function workspacePushCommand(args) {
10863
11173
  assertRunning();
10864
11174
  writeWorkspacePushResult(rawResult, results, args.output ?? "table");
10865
11175
  if (!args.dryRun) {
10866
- requireWorkspaceActivation(await probeActiveWorkspaceKey(client3), context.workspaceKey, true);
11176
+ requireWorkspaceActivation(await probeActiveWorkspaceKey(client4), context.workspaceKey, true);
10867
11177
  }
10868
11178
  const preflightBlocks = !!args.dryRun && !!rawResult.preflight && (rawResult.preflight.status === "failed" || rawResult.preflight.status === "unavailable");
10869
11179
  process.exitCode = rawResult.conflicts.length || preflightBlocks || results.some((item) => item.result.conflicts.length) ? 3 : 0;
@@ -10871,8 +11181,8 @@ async function workspacePushCommand(args) {
10871
11181
  return;
10872
11182
  } catch (e) {
10873
11183
  let failure2 = e;
10874
- if (e instanceof CliError26 && pushProgress && !e.context?.push) {
10875
- failure2 = new CliError26({
11184
+ if (e instanceof CliError27 && pushProgress && !e.context?.push) {
11185
+ failure2 = new CliError27({
10876
11186
  code: e.code,
10877
11187
  message: e.message,
10878
11188
  traceId: e.traceId,
@@ -10909,7 +11219,7 @@ async function workspacePreviewCommand(args) {
10909
11219
  );
10910
11220
  }
10911
11221
  if (args.output === "json" || args.output === "yaml") {
10912
- process.stdout.write(formatObject24(rows2, { format: args.output }) + "\n");
11222
+ process.stdout.write(formatObject25(rows2, { format: args.output }) + "\n");
10913
11223
  } else {
10914
11224
  process.stdout.write(formatRows6(rows2, { format: "table" }) + "\n");
10915
11225
  }
@@ -10929,8 +11239,8 @@ async function workspaceVerifyCommand(args) {
10929
11239
  ...args,
10930
11240
  env: args.env ?? args.profile ?? context.profile
10931
11241
  };
10932
- const client3 = await loadProfileClient(authArgs);
10933
- const smokeAccessToken = args.smoke ? await loadSmokeAccessToken(client3, authArgs) : null;
11242
+ const client4 = await loadProfileClient(authArgs);
11243
+ const smokeAccessToken = args.smoke ? await loadSmokeAccessToken(client4, authArgs) : null;
10934
11244
  const rawStatus = await getWorkspaceRawStatus(rootDir, context);
10935
11245
  const miniPlans = [];
10936
11246
  for (const app of miniApps) {
@@ -10939,11 +11249,11 @@ async function workspaceVerifyCommand(args) {
10939
11249
  let planSkipped;
10940
11250
  if (!validation.valid) {
10941
11251
  planSkipped = "validation failed";
10942
- } else if (!client3) {
11252
+ } else if (!client4) {
10943
11253
  planSkipped = "profile not configured";
10944
11254
  } else {
10945
11255
  try {
10946
- plan = await pushMiniAppProject({ http: client3.raw(), rootDir: app.dir, dryRun: true });
11256
+ plan = await pushMiniAppProject({ http: client4.raw(), rootDir: app.dir, dryRun: true });
10947
11257
  } catch (planErr) {
10948
11258
  planSkipped = planErr.message ?? "push dry-run failed";
10949
11259
  }
@@ -10955,12 +11265,12 @@ async function workspaceVerifyCommand(args) {
10955
11265
  );
10956
11266
  let rawPlan = null;
10957
11267
  let rawPlanSkipped;
10958
- if (!client3) {
11268
+ if (!client4) {
10959
11269
  rawPlanSkipped = "profile not configured";
10960
11270
  } else {
10961
11271
  try {
10962
11272
  rawPlan = await pushWorkspaceRawFiles({
10963
- http: client3.raw(),
11273
+ http: client4.raw(),
10964
11274
  rootDir,
10965
11275
  context,
10966
11276
  dryRun: true,
@@ -11057,8 +11367,8 @@ async function assertWorkspacePushRoot(rootDir) {
11057
11367
  }
11058
11368
  if (!insideMiniApp && (!workspaceRoot || workspaceRoot === realRoot)) return;
11059
11369
  const target = workspaceRoot ? quoteWorkspaceArg(workspaceRoot) : "<workspace-root>";
11060
- throw new CliError26({
11061
- code: CliErrorCode27.INVALID_ARGUMENT,
11370
+ throw new CliError27({
11371
+ code: CliErrorCode28.INVALID_ARGUMENT,
11062
11372
  message: `workspace push \u5FC5\u987B\u4ECE workspace \u6839\u76EE\u5F55\u6267\u884C\uFF0C\u5F53\u524D\u76EE\u5F55 ${rootDir} \u662F${insideMiniApp ? "\u8F7B\u5E94\u7528\u76EE\u5F55\u6216\u5176\u5B50\u76EE\u5F55" : "\u5DE5\u4F5C\u533A\u5B50\u76EE\u5F55"}\uFF1B\u7EE7\u7EED\u4F1A\u8DF3\u8FC7\u8F7B\u5E94\u7528\u90E8\u7F72\u3002`,
11063
11373
  context: {
11064
11374
  nextStep: `${workspaceRoot ? `workspace \u6839\u76EE\u5F55\uFF1A${workspaceRoot}\u3002` : `\u672A\u627E\u5230\u4E0A\u5C42 ${WORKSPACE_CONTEXT_FILE}\uFF1B\u8BF7\u5148\u5B9A\u4F4D\u5305\u542B mini_apps/ \u7684 workspace \u6839\u76EE\u5F55\u3002`}\u6267\u884C hcm workspace push --dir ${target}\uFF0C\u4FDD\u7559\u539F\u6709 --env/--as \u7B49\u9009\u9879\u3002`
@@ -11127,8 +11437,8 @@ async function readWorkspaceRawManifest(rootDir, context, forPull = false) {
11127
11437
  if (!forPull) {
11128
11438
  try {
11129
11439
  await fs9.access(path10.join(rootDir, WORKSPACE_STATE_DIR, WORKSPACE_PULL_INCOMPLETE_FILE));
11130
- throw new CliError26({
11131
- code: CliErrorCode27.BUSINESS_RULE_VIOLATION,
11440
+ throw new CliError27({
11441
+ code: CliErrorCode28.BUSINESS_RULE_VIOLATION,
11132
11442
  message: "\u4E0A\u6B21 workspace pull \u672A\u5B8C\u6210\uFF0C\u672C\u5730\u53EF\u80FD\u6DF7\u6709\u4E0D\u540C\u76EE\u6807\u7684\u5185\u5BB9\uFF0C\u4E0D\u80FD\u7EE7\u7EED\u540C\u6B65\u3002",
11133
11443
  context: {
11134
11444
  reason: "WORKSPACE_PULL_INCOMPLETE",
@@ -11253,8 +11563,8 @@ async function pushWorkspaceRawFiles(args) {
11253
11563
  );
11254
11564
  if (args.dryRun) return result;
11255
11565
  if (result.preflight.status === "failed") {
11256
- throw new CliError26({
11257
- code: CliErrorCode27.INVALID_ARGUMENT,
11566
+ throw new CliError27({
11567
+ code: CliErrorCode28.INVALID_ARGUMENT,
11258
11568
  message: `\u670D\u52A1\u7AEF\u9884\u68C0\u672A\u901A\u8FC7\uFF0C\u672C\u6B21\u6CA1\u6709\u5199\u5165\u4EFB\u4F55\u6587\u4EF6\uFF1A${result.preflight.issues.length} \u5904\u95EE\u9898
11259
11569
  ${formatPreflightIssues(result.preflight.issues, " ")}`,
11260
11570
  profile: args.profile ?? args.context.profile,
@@ -11339,29 +11649,29 @@ ${formatPreflightIssues(result.preflight.issues, " ")}`,
11339
11649
  checkpointSaved
11340
11650
  });
11341
11651
  } catch (error) {
11342
- const translated = error?.isAxiosError ? fromAxiosError23(error, args.profile ?? args.context.profile) : error;
11652
+ const translated = error?.isAxiosError ? fromAxiosError24(error, args.profile ?? args.context.profile) : error;
11343
11653
  const push = progress();
11344
11654
  args.onProgress?.(push);
11345
- throw new CliError26({
11346
- code: translated instanceof CliError26 ? translated.code : CliErrorCode27.INVALID_ARGUMENT,
11655
+ throw new CliError27({
11656
+ code: translated instanceof CliError27 ? translated.code : CliErrorCode28.INVALID_ARGUMENT,
11347
11657
  message: translated instanceof Error ? translated.message : String(translated),
11348
- traceId: translated instanceof CliError26 ? translated.traceId : void 0,
11349
- profile: translated instanceof CliError26 ? translated.profile : args.profile ?? args.context.profile,
11658
+ traceId: translated instanceof CliError27 ? translated.traceId : void 0,
11659
+ profile: translated instanceof CliError27 ? translated.profile : args.profile ?? args.context.profile,
11350
11660
  cause: error,
11351
11661
  context: {
11352
- ...translated instanceof CliError26 ? translated.context : {},
11662
+ ...translated instanceof CliError27 ? translated.context : {},
11353
11663
  workspaceKey: args.context.workspaceKey,
11354
11664
  push,
11355
11665
  details: {
11356
- serverDetails: translated instanceof CliError26 ? translated.context?.details : void 0,
11666
+ serverDetails: translated instanceof CliError27 ? translated.context?.details : void 0,
11357
11667
  push
11358
11668
  },
11359
11669
  note: [
11360
- translated instanceof CliError26 ? translated.context?.note : void 0,
11670
+ translated instanceof CliError27 ? translated.context?.note : void 0,
11361
11671
  "\u9010\u6587\u4EF6\u63A8\u9001\u53EF\u80FD\u5DF2\u90E8\u5206\u5199\u5165\uFF1Bcommitted \u662F\u5DF2\u6536\u5230\u6210\u529F\u56DE\u6267\u7684\u6587\u4EF6\uFF0CUNKNOWN \u4E0D\u80FD\u5F53\u4F5C\u672A\u5199\u5165\u3002"
11362
11672
  ].filter(Boolean).join(" "),
11363
11673
  nextStep: [
11364
- translated instanceof CliError26 ? translated.context?.nextStep : void 0,
11674
+ translated instanceof CliError27 ? translated.context?.nextStep : void 0,
11365
11675
  "\u5DF2\u786E\u8BA4\u6587\u4EF6\u7684\u8FDB\u5EA6\u9010\u9879\u4FDD\u5B58\uFF1B\u4FEE\u6B63\u5931\u8D25\u6587\u4EF6\u540E\u5148 push --dry-run \u68C0\u67E5\uFF0C\u518D\u666E\u901A push \u7EED\u8DD1\u3002\u5F53\u524D\u5931\u8D25\u9879 checkpointSaved=false \u6216\u63D0\u4EA4\u72B6\u6001 UNKNOWN \u65F6\u987B\u56DE\u8BFB\u6838\u5BF9\uFF1B\u82E5\u6709\u771F\u5B9E\u8FDC\u7AEF\u51B2\u7A81\uFF0C\u5148 pull \u5230\u65B0\u7684\u7A7A\u76EE\u5F55\u6838\u5BF9\u5E76\u5408\u5E76\uFF0C\u7981\u6B62\u5F3A\u5236\u8986\u76D6\u3002"
11366
11676
  ].filter(Boolean).join(" ")
11367
11677
  }
@@ -11412,7 +11722,7 @@ async function preflightWorkspacePlan(http, workspaceKey, operations, localFiles
11412
11722
  return { status: "passed", sent, checked: verdict.checked, issues: [] };
11413
11723
  } catch (error) {
11414
11724
  const status = error?.response?.status;
11415
- const translated = error?.isAxiosError ? fromAxiosError23(error, profile) : error;
11725
+ const translated = error?.isAxiosError ? fromAxiosError24(error, profile) : error;
11416
11726
  const detail = translated instanceof Error ? translated.message : String(translated);
11417
11727
  return {
11418
11728
  status: "unavailable",
@@ -11492,8 +11802,8 @@ function formatPreflightSummary(preflight, indent2 = "") {
11492
11802
  async function listWorkspaceFilesForSync(http, workspaceKey) {
11493
11803
  const list = await listWorkspaceFiles(http, workspaceKey, { pageSize: 5e3 });
11494
11804
  if (list.total !== list.data.length || new Set(list.data.map((file) => file.relativePath)).size !== list.data.length) {
11495
- throw new CliError26({
11496
- code: CliErrorCode27.NETWORK_ERROR,
11805
+ throw new CliError27({
11806
+ code: CliErrorCode28.NETWORK_ERROR,
11497
11807
  message: `\u5DE5\u4F5C\u533A\u8FDC\u7AEF\u6587\u4EF6\u6E05\u5355\u4E0D\u5B8C\u6574\uFF1A\u6536\u5230 ${list.data.length} \u6761\uFF0C\u603B\u6570 ${list.total}\uFF0C\u65E0\u6CD5\u5224\u5B9A\u6587\u4EF6\u662F\u5426\u7F3A\u5931\u3002`,
11498
11808
  context: {
11499
11809
  reason: "INCOMPLETE_WORKSPACE_FILE_LIST",
@@ -11509,8 +11819,8 @@ async function listWorkspaceFilesForSync(http, workspaceKey) {
11509
11819
  return true;
11510
11820
  }
11511
11821
  })) {
11512
- throw new CliError26({
11513
- code: CliErrorCode27.NETWORK_ERROR,
11822
+ throw new CliError27({
11823
+ code: CliErrorCode28.NETWORK_ERROR,
11514
11824
  message: "\u5DE5\u4F5C\u533A\u6587\u4EF6\u5217\u8868\u542B\u6709\u65E0\u6548\u7684 ID\u3001\u5DE5\u4F5C\u533A\u6216\u6587\u4EF6\u8DEF\u5F84\u3002",
11515
11825
  context: { reason: "INVALID_WORKSPACE_FILE_LIST", nextStep: "\u6838\u5BF9\u76EE\u6807\u5DE5\u4F5C\u533A\u6587\u4EF6\u5217\u8868\u540E\u91CD\u8BD5\uFF1B\u4E0D\u80FD\u7528\u65E0\u6548\u8BB0\u5F55\u5224\u65AD\u8FDC\u7AEF\u5B58\u5728\u6027\u3002" }
11516
11826
  });
@@ -11692,15 +12002,15 @@ async function readMiniStatusSafely(app) {
11692
12002
  async function loadProfileClient(args) {
11693
12003
  try {
11694
12004
  const ctx = await getActiveAuthContextFromCli(args);
11695
- return HcmClient23.fromAuthContext(ctx);
12005
+ return HcmClient24.fromAuthContext(ctx);
11696
12006
  } catch (e) {
11697
12007
  if (args.env || args.profile) throw e;
11698
12008
  return null;
11699
12009
  }
11700
12010
  }
11701
- async function loadSmokeAccessToken(client3, args) {
12011
+ async function loadSmokeAccessToken(client4, args) {
11702
12012
  try {
11703
- const smokeClient = client3 ?? await loadProfileClient(args);
12013
+ const smokeClient = client4 ?? await loadProfileClient(args);
11704
12014
  return smokeClient ? smokeClient.getAccessToken() : null;
11705
12015
  } catch {
11706
12016
  return null;
@@ -11859,7 +12169,7 @@ function optionalText(value) {
11859
12169
  }
11860
12170
  function writeWorkspaceListResult(rows2, format, total) {
11861
12171
  if (format !== "table") {
11862
- process.stdout.write(formatObject24({ rows: rows2, total }, { format }) + "\n");
12172
+ process.stdout.write(formatObject25({ rows: rows2, total }, { format }) + "\n");
11863
12173
  return;
11864
12174
  }
11865
12175
  process.stdout.write(formatRows6(toWorkspaceListRows(rows2), { format: "table" }) + "\n");
@@ -11870,7 +12180,7 @@ function writeWorkspaceListResult(rows2, format, total) {
11870
12180
  }
11871
12181
  function writeWorkspaceActiveResult(view, format) {
11872
12182
  if (format !== "table") {
11873
- process.stdout.write(formatObject24(view, { format }) + "\n");
12183
+ process.stdout.write(formatObject25(view, { format }) + "\n");
11874
12184
  return;
11875
12185
  }
11876
12186
  const rows2 = [
@@ -11895,7 +12205,7 @@ function writeWorkspaceActiveResult(view, format) {
11895
12205
  }
11896
12206
  function writeWorkspaceBindResult(context, rootDir, format) {
11897
12207
  if (format !== "table") {
11898
- process.stdout.write(formatObject24({ ...context, rootDir }, { format }) + "\n");
12208
+ process.stdout.write(formatObject25({ ...context, rootDir }, { format }) + "\n");
11899
12209
  return;
11900
12210
  }
11901
12211
  process.stdout.write(
@@ -11909,7 +12219,7 @@ function writeWorkspaceBindResult(context, rootDir, format) {
11909
12219
  }
11910
12220
  function writeWorkspaceCreateResult(result, format) {
11911
12221
  if (format !== "table") {
11912
- process.stdout.write(formatObject24(result, { format }) + "\n");
12222
+ process.stdout.write(formatObject25(result, { format }) + "\n");
11913
12223
  return;
11914
12224
  }
11915
12225
  process.stdout.write(
@@ -11925,7 +12235,7 @@ function writeWorkspaceCreateResult(result, format) {
11925
12235
  }
11926
12236
  function writeWorkspacePullResult(result, format) {
11927
12237
  if (format !== "table") {
11928
- process.stdout.write(formatObject24(result, { format }) + "\n");
12238
+ process.stdout.write(formatObject25(result, { format }) + "\n");
11929
12239
  return;
11930
12240
  }
11931
12241
  const lines = [
@@ -11945,7 +12255,7 @@ function writeWorkspacePullResult(result, format) {
11945
12255
  }
11946
12256
  function writeWorkspaceAddMiniResult(result, rootDir, format) {
11947
12257
  if (format !== "table") {
11948
- process.stdout.write(formatObject24({ ...result, workspaceRoot: rootDir }, { format }) + "\n");
12258
+ process.stdout.write(formatObject25({ ...result, workspaceRoot: rootDir }, { format }) + "\n");
11949
12259
  return;
11950
12260
  }
11951
12261
  process.stdout.write(
@@ -11961,7 +12271,7 @@ function writeWorkspaceAddMiniResult(result, rootDir, format) {
11961
12271
  function writeWorkspaceValidateResult(results, format) {
11962
12272
  if (format !== "table") {
11963
12273
  process.stdout.write(
11964
- formatObject24(
12274
+ formatObject25(
11965
12275
  results.map((item) => ({ artifact: item.artifact, ...item.result })),
11966
12276
  { format }
11967
12277
  ) + "\n"
@@ -11989,7 +12299,7 @@ ${item.artifact}
11989
12299
  function writeWorkspacePushResult(rawResult, results, format) {
11990
12300
  if (format !== "table") {
11991
12301
  process.stdout.write(
11992
- formatObject24(
12302
+ formatObject25(
11993
12303
  {
11994
12304
  // 预检覆盖整份计划(workspace 文件 + 轻应用文件),放在顶层。
11995
12305
  preflight: rawResult.preflight ?? null,
@@ -12054,7 +12364,7 @@ function writeWorkspaceVerifyResult(context, rootDir, raw, reports, format) {
12054
12364
  const preflight = raw.plan?.preflight ?? null;
12055
12365
  if (format === "json") {
12056
12366
  process.stdout.write(
12057
- formatObject24(
12367
+ formatObject25(
12058
12368
  {
12059
12369
  ok,
12060
12370
  workspaceKey: context.workspaceKey,
@@ -12082,7 +12392,7 @@ function writeWorkspaceVerifyResult(context, rootDir, raw, reports, format) {
12082
12392
  }
12083
12393
  if (format !== "table") {
12084
12394
  process.stdout.write(
12085
- formatObject24(
12395
+ formatObject25(
12086
12396
  {
12087
12397
  ok,
12088
12398
  workspaceKey: context.workspaceKey,
@@ -12138,14 +12448,14 @@ function quoteWorkspaceArg(value) {
12138
12448
  }
12139
12449
  function exitWorkspaceError(err, profile, operation) {
12140
12450
  const maybeAxios = err;
12141
- const translated = maybeAxios?.isAxiosError ? fromAxiosError23(err, profile) : err;
12142
- if (translated instanceof CliError26 && operation && translated.context?.status === 409 && ["WORKSPACE_REVISION_CONFLICT", "DEPLOY_IN_PROGRESS"].includes(String(translated.context.responseCode))) {
12451
+ const translated = maybeAxios?.isAxiosError ? fromAxiosError24(err, profile) : err;
12452
+ if (translated instanceof CliError27 && operation && translated.context?.status === 409 && ["WORKSPACE_REVISION_CONFLICT", "DEPLOY_IN_PROGRESS"].includes(String(translated.context.responseCode))) {
12143
12453
  const scope = `${profile ? ` --env ${quoteWorkspaceArg(profile)}` : ""}${operation.as ? ` --as ${quoteWorkspaceArg(operation.as)}` : ""}`;
12144
12454
  const active = "hcm workspace active" + scope + (operation.dir ? ` --dir ${quoteWorkspaceArg(operation.dir)}` : "");
12145
12455
  const deployment = translated.context.responseCode === "DEPLOY_IN_PROGRESS" ? `\u6709\u53D1\u5E03\u67E5\u8BE2\u6743\u9650\u65F6\uFF0C\u6267\u884C hcm query TenantExtensionRelease --fields id,workspaceKey,deploymentStatus --limit 20${scope} \u67E5\u770B\u53EF\u89C1\u90E8\u7F72\u8BB0\u5F55\uFF1B\u7A7A\u7ED3\u679C\u4E0D\u80FD\u8BC1\u660E\u9501\u5DF2\u91CA\u653E\u3002` : void 0;
12146
12456
  const rebase = translated.context.responseCode === "WORKSPACE_REVISION_CONFLICT" ? `\u82E5\u670D\u52A1\u7AEF\u8BE6\u60C5\u786E\u8BA4 workspace \u4E0E active \u7684\u4FEE\u8BA2\u51B2\u7A81\uFF0C\u6267\u884C hcm workspace rebase --workspace ${quoteWorkspaceArg(operation.workspaceKey)} --dry-run${scope}\uFF0C\u518D\u7528 --dry-run --plan '<\u65B0\u8BA1\u5212\u6587\u4EF6>' \u751F\u6210\u9010\u8DEF\u5F84\u89E3\u51B3\u8349\u6848\u3002pull \u53EA\u6062\u590D\u672C\u5730\u5FEB\u7167\uFF0C\u4E0D\u66F4\u65B0\u670D\u52A1\u7AEF baseline\uFF1B\u4E0D\u8981\u5220\u9664\u91CD\u5EFA\u6587\u4EF6\u6216\u6574\u4E2A\u5F00\u53D1\u7A7A\u95F4\u6765\u5237\u65B0\u57FA\u7EBF\u3002` : void 0;
12147
12457
  const retry = operation.command === "activate" ? `\u6309\u670D\u52A1\u7AEF\u8BE6\u60C5\u5B8C\u6210\u5904\u7406\u5E76\u786E\u8BA4\u76EE\u6807\u5DE5\u4F5C\u533A\u540E\uFF0C\u518D\u6267\u884C hcm workspace activate ${quoteWorkspaceArg(operation.workspaceKey)}${scope}\u3002` : `\u4FDD\u7559\u672C\u5730\u76EE\u5F55 ${operation.dir}\uFF1B\u6267\u884C hcm workspace pull --workspace ${quoteWorkspaceArg(operation.workspaceKey)} --dir '<\u65B0\u7684\u7A7A\u76EE\u5F55>'${scope}\uFF0C\u6BD4\u5BF9\u540E\u628A\u5F85\u4FDD\u7559\u4FEE\u6539\uFF08\u542B\u5220\u9664\u610F\u56FE\uFF09\u5408\u5E76\u5230\u65B0\u76EE\u5F55\uFF0C\u518D\u6267\u884C hcm workspace push --dir '<\u65B0\u7684\u7A7A\u76EE\u5F55>' --dry-run${scope}\uFF0C\u6838\u5BF9\u8BA1\u5212\u540E\u5728\u65B0\u76EE\u5F55\u53BB\u6389 --dry-run \u63A8\u9001\u3002\u539F\u76EE\u5F55\u4FDD\u7559\u5907\u4EFD\uFF0C\u4E0D\u8981\u8986\u76D6\u6216\u7EE7\u7EED\u4F7F\u7528\u65E7\u57FA\u7EBF\u63A8\u9001\u3002`;
12148
- exitWithError(new CliError26({
12458
+ exitWithError(new CliError27({
12149
12459
  code: translated.code,
12150
12460
  message: translated.message,
12151
12461
  traceId: translated.traceId,
@@ -12158,8 +12468,8 @@ function exitWorkspaceError(err, profile, operation) {
12158
12468
  }
12159
12469
  }));
12160
12470
  }
12161
- if (translated instanceof CliError26 && translated.code === CliErrorCode27.AUTH_FAILED) {
12162
- exitWithError(new CliError26({
12471
+ if (translated instanceof CliError27 && translated.code === CliErrorCode28.AUTH_FAILED) {
12472
+ exitWithError(new CliError27({
12163
12473
  code: translated.code,
12164
12474
  message: translated.message,
12165
12475
  traceId: translated.traceId,
@@ -12170,8 +12480,8 @@ function exitWorkspaceError(err, profile, operation) {
12170
12480
  }
12171
12481
  exitWithError(translated);
12172
12482
  }
12173
- async function readWorkspaceDevModeBinding(client3) {
12174
- const response = await client3.raw().get("/api/tenant-extension/dev-mode");
12483
+ async function readWorkspaceDevModeBinding(client4) {
12484
+ const response = await client4.raw().get("/api/tenant-extension/dev-mode");
12175
12485
  if (response.data?.success === false) {
12176
12486
  throw new Error("\u5F00\u53D1\u6001\u72B6\u6001\u67E5\u8BE2\u5931\u8D25\uFF0C\u4E0D\u80FD\u5224\u65AD\u662F\u5426\u5DF2\u6FC0\u6D3B\uFF1B\u8BF7\u68C0\u67E5 /api/tenant-extension/dev-mode \u54CD\u5E94\u3002");
12177
12487
  }
@@ -12181,20 +12491,20 @@ async function readWorkspaceDevModeBinding(client3) {
12181
12491
  }
12182
12492
  return binding;
12183
12493
  }
12184
- async function probeActiveWorkspaceKey(client3) {
12185
- const binding = await readWorkspaceDevModeBinding(client3);
12494
+ async function probeActiveWorkspaceKey(client4) {
12495
+ const binding = await readWorkspaceDevModeBinding(client4);
12186
12496
  return binding.enabled ? optionalText(binding.workspaceKey) : null;
12187
12497
  }
12188
12498
  function requireWorkspaceActivation(activeKey, workspaceKey, afterPush = false) {
12189
12499
  if (activeKey === workspaceKey) return;
12190
- throw new CliError26({
12191
- code: CliErrorCode27.INVALID_ARGUMENT,
12500
+ throw new CliError27({
12501
+ code: CliErrorCode28.INVALID_ARGUMENT,
12192
12502
  message: (afterPush ? "\u63A8\u9001\u540E\u7ED1\u5B9A\u5DF2\u53D8\u5316\uFF0C\u6587\u4EF6\u53EF\u80FD\u5DF2\u4FDD\u5B58\u4E3A\u8349\u7A3F\uFF1B" : "") + (activeKey ? `\u5F53\u524D\u8EAB\u4EFD\u6FC0\u6D3B\u7684\u662F "${activeKey}"\uFF0C\u4E0D\u662F\u672C\u7A7A\u95F4 "${workspaceKey}"\uFF1B\u672C\u7A7A\u95F4\u5185\u5BB9\u5C1A\u672A\u7528\u4E8E\u5F00\u53D1\u9884\u89C8\u3002` : `\u5F53\u524D\u8EAB\u4EFD\u672A\u6FC0\u6D3B\u5F00\u53D1\u7A7A\u95F4 "${workspaceKey}"\uFF1B\u672C\u7A7A\u95F4\u5185\u5BB9\u5C1A\u672A\u7528\u4E8E\u5F00\u53D1\u9884\u89C8\u3002`),
12193
12503
  context: { workspaceKey, activeWorkspaceKey: activeKey, nextStep: `hcm workspace activate ${workspaceKey}` }
12194
12504
  });
12195
12505
  }
12196
- async function setDevModeBinding(client3, workspaceKey) {
12197
- await client3.raw().put("/api/tenant-extension/dev-mode", {
12506
+ async function setDevModeBinding(client4, workspaceKey) {
12507
+ await client4.raw().put("/api/tenant-extension/dev-mode", {
12198
12508
  enabled: true,
12199
12509
  workspaceKey
12200
12510
  });
@@ -12209,8 +12519,8 @@ function unwrapWorkspaceActionPayload(response) {
12209
12519
  if (envelope.result && typeof envelope.result === "object") return envelope.result;
12210
12520
  return response;
12211
12521
  }
12212
- async function requestWorkspaceDeactivation(client3) {
12213
- const response = await client3.action(
12522
+ async function requestWorkspaceDeactivation(client4) {
12523
+ const response = await client4.action(
12214
12524
  "TenantExtensionWorkspace",
12215
12525
  "unbind-current-user",
12216
12526
  { method: "POST", scope: "class" }
@@ -12225,11 +12535,11 @@ async function workspaceActivateCommand(workspaceKey, args) {
12225
12535
  let recovery2;
12226
12536
  let profile = args.env ?? args.profile;
12227
12537
  try {
12228
- const client3 = HcmClient23.fromAuthContext(await getActiveAuthContextFromCli(args));
12229
- profile = client3.profile ?? profile;
12538
+ const client4 = HcmClient24.fromAuthContext(await getActiveAuthContextFromCli(args));
12539
+ profile = client4.profile ?? profile;
12230
12540
  const key2 = normalizeWorkspaceKey(workspaceKey);
12231
12541
  recovery2 = { command: "activate", workspaceKey: key2, as: args.as };
12232
- await setDevModeBinding(client3, key2);
12542
+ await setDevModeBinding(client4, key2);
12233
12543
  const fmt = args.output ?? "table";
12234
12544
  if (fmt === "table") {
12235
12545
  process.stdout.write(`workspace activated: ${key2}
@@ -12237,7 +12547,7 @@ async function workspaceActivateCommand(workspaceKey, args) {
12237
12547
  process.stdout.write("\u8BE5\u7A7A\u95F4\u7684 metas / scripts / menus / mini_apps \u73B0\u5DF2\u5728\u5F53\u524D\u79DF\u6237\u751F\u6548\u3002\n");
12238
12548
  } else {
12239
12549
  process.stdout.write(
12240
- formatObject24({ workspaceKey: key2, activated: true }, { format: fmt }) + "\n"
12550
+ formatObject25({ workspaceKey: key2, activated: true }, { format: fmt }) + "\n"
12241
12551
  );
12242
12552
  }
12243
12553
  process.exitCode = 0;
@@ -12248,15 +12558,15 @@ async function workspaceActivateCommand(workspaceKey, args) {
12248
12558
  }
12249
12559
  async function workspaceDeactivateCommand(args) {
12250
12560
  try {
12251
- const client3 = HcmClient23.fromAuthContext(await getActiveAuthContextFromCli(args));
12252
- const binding = await requestWorkspaceDeactivation(client3);
12561
+ const client4 = HcmClient24.fromAuthContext(await getActiveAuthContextFromCli(args));
12562
+ const binding = await requestWorkspaceDeactivation(client4);
12253
12563
  const result = { ...binding, deactivated: true };
12254
12564
  const fmt = args.output ?? "table";
12255
12565
  if (fmt === "table") {
12256
12566
  process.stdout.write("workspace deactivated\n");
12257
12567
  process.stdout.write("\u5F53\u524D\u8EAB\u4EFD\u5DF2\u9000\u51FA\u5F00\u53D1\u8005\u6A21\u5F0F\uFF1B\u5F00\u53D1\u7A7A\u95F4\u3001\u672C\u5730\u6587\u4EF6\u4E0E\u5DF2\u53D1\u5E03\u8D44\u4EA7\u5747\u672A\u5220\u9664\u3002\n");
12258
12568
  } else {
12259
- process.stdout.write(formatObject24(result, { format: fmt }) + "\n");
12569
+ process.stdout.write(formatObject25(result, { format: fmt }) + "\n");
12260
12570
  }
12261
12571
  process.exitCode = 0;
12262
12572
  return;
@@ -12270,11 +12580,11 @@ init_exit();
12270
12580
  import axios5 from "axios";
12271
12581
  import {
12272
12582
  AUTH_INFO_PATH,
12273
- CliError as CliError27,
12274
- CliErrorCode as CliErrorCode28,
12275
- formatObject as formatObject25,
12583
+ CliError as CliError28,
12584
+ CliErrorCode as CliErrorCode29,
12585
+ formatObject as formatObject26,
12276
12586
  formatRows as formatRows7,
12277
- fromAxiosError as fromAxiosError24,
12587
+ fromAxiosError as fromAxiosError25,
12278
12588
  loadEnv as loadEnv4,
12279
12589
  saveEnv as saveEnv3,
12280
12590
  loadIdentity as loadIdentity4,
@@ -12298,8 +12608,8 @@ async function inspectIdentity(name, fetcher = fetchAuthInfo) {
12298
12608
  const env2 = await loadEnv4(meta2.env);
12299
12609
  const accessToken = await TokenStore4.forIdentity(name).getStoredAccessToken();
12300
12610
  if (!accessToken) {
12301
- throw new CliError27({
12302
- code: CliErrorCode28.AUTH_FAILED,
12611
+ throw new CliError28({
12612
+ code: CliErrorCode29.AUTH_FAILED,
12303
12613
  message: `identity '${name}' \u6CA1\u6709\u53EF\u8BFB\u53D6\u7684\u6301\u4E45\u5316 token`,
12304
12614
  context: { nextStep: `\u91CD\u65B0\u767B\u5F55\u8BE5\u8EAB\u4EFD\uFF1Ahcm login --env ${meta2.env} --name ${name}` }
12305
12615
  });
@@ -12327,9 +12637,9 @@ async function inspectIdentity(name, fetcher = fetchAuthInfo) {
12327
12637
  async function identityShow(name, args) {
12328
12638
  try {
12329
12639
  const details = await inspectIdentity(name);
12330
- return exitOk(formatObject25(details, { format: args.output ?? "json" }));
12640
+ return exitOk(formatObject26(details, { format: args.output ?? "json" }));
12331
12641
  } catch (e) {
12332
- exitWithError(axios5.isAxiosError(e) ? fromAxiosError24(e, name) : e);
12642
+ exitWithError(axios5.isAxiosError(e) ? fromAxiosError25(e, name) : e);
12333
12643
  }
12334
12644
  }
12335
12645
  async function identityList(args) {
@@ -12339,7 +12649,7 @@ async function identityList(args) {
12339
12649
  const names = await listIdentities4(filter);
12340
12650
  const fmt = args.output ?? "table";
12341
12651
  if (names.length === 0) {
12342
- return exitOk(fmt === "table" ? "(no identities)" : formatObject25([], { format: fmt }));
12652
+ return exitOk(fmt === "table" ? "(no identities)" : formatObject26([], { format: fmt }));
12343
12653
  }
12344
12654
  const rows2 = [];
12345
12655
  for (const n of names) {
@@ -12353,7 +12663,7 @@ async function identityList(args) {
12353
12663
  isDefault: env2?.defaultIdentity === n
12354
12664
  });
12355
12665
  }
12356
- return exitOk(fmt === "table" ? formatRows7(rows2, { format: fmt }) : formatObject25(rows2, { format: fmt }));
12666
+ return exitOk(fmt === "table" ? formatRows7(rows2, { format: fmt }) : formatObject26(rows2, { format: fmt }));
12357
12667
  } catch (e) {
12358
12668
  exitWithError(e);
12359
12669
  }
@@ -12362,8 +12672,8 @@ async function identityUse(name) {
12362
12672
  try {
12363
12673
  const meta2 = await loadIdentity4(name);
12364
12674
  const env2 = await loadEnv4(meta2.env).catch(() => {
12365
- throw new CliError27({
12366
- code: CliErrorCode28.IDENTITY_NOT_IN_ENV,
12675
+ throw new CliError28({
12676
+ code: CliErrorCode29.IDENTITY_NOT_IN_ENV,
12367
12677
  message: `identity '${name}' references env '${meta2.env}' which no longer exists. Re-create the env, or remove this orphan: hcm identity remove ${name}`
12368
12678
  });
12369
12679
  });
@@ -12403,11 +12713,11 @@ init_exit();
12403
12713
  import { promises as fs10 } from "fs";
12404
12714
  import path11 from "path";
12405
12715
  import {
12406
- CliError as CliError28,
12407
- CliErrorCode as CliErrorCode29,
12408
- HcmClient as HcmClient24,
12716
+ CliError as CliError29,
12717
+ CliErrorCode as CliErrorCode30,
12718
+ HcmClient as HcmClient25,
12409
12719
  fetchReconIdentity,
12410
- formatObject as formatObject26,
12720
+ formatObject as formatObject27,
12411
12721
  httpProbe,
12412
12722
  isTempEnv as isTempEnv3,
12413
12723
  assertNotReservedEnvName as assertNotReservedEnvName2,
@@ -12420,8 +12730,8 @@ import {
12420
12730
  } from "@hcmai/sdk";
12421
12731
  async function probeTokenTenant(envName, requested) {
12422
12732
  const ctx = await getActiveAuthContextFromCli({ env: envName });
12423
- const client3 = HcmClient24.fromAuthContext(ctx);
12424
- const identity3 = await fetchReconIdentity(httpProbe(client3.raw(), "default"), requested);
12733
+ const client4 = HcmClient25.fromAuthContext(ctx);
12734
+ const identity3 = await fetchReconIdentity(httpProbe(client4.raw(), "default"), requested);
12425
12735
  return identity3?.tenantId ? String(identity3.tenantId) : void 0;
12426
12736
  }
12427
12737
  async function syncSkillsForInit(root, envName, sync2 = skillsSyncCommand) {
@@ -12465,8 +12775,8 @@ async function resolveInitEnv(root, args, deps) {
12465
12775
  if (existing && path11.dirname(existing.path) === path11.resolve(root)) {
12466
12776
  const name2 = args.env ?? existing.config.default;
12467
12777
  const env2 = existing.config.environments[name2];
12468
- if (!env2) throw new CliError28({
12469
- code: CliErrorCode29.INVALID_ARGUMENT,
12778
+ if (!env2) throw new CliError29({
12779
+ code: CliErrorCode30.INVALID_ARGUMENT,
12470
12780
  message: `${existing.path} \u91CC\u6CA1\u6709\u73AF\u5883 '${name2}'\uFF0C\u53EA\u6709\uFF1A${Object.keys(existing.config.environments).join("\u3001")}`,
12471
12781
  // env add 的 endpoint / frontend / tenant 都是必填,少一个照抄就是 required option 报错。
12472
12782
  context: { nextStep: `hcm chiron env add ${name2} --endpoint <\u540E\u7AEF\u5730\u5740> --frontend <\u524D\u7AEF\u5730\u5740> --tenant <\u79DF\u6237\u53F7>` }
@@ -12476,8 +12786,8 @@ async function resolveInitEnv(root, args, deps) {
12476
12786
  }
12477
12787
  if (args.env) {
12478
12788
  const config3 = await loadEnv5(args.env).catch(() => null);
12479
- if (!config3?.endpoint) throw new CliError28({
12480
- code: CliErrorCode29.ENV_NOT_FOUND,
12789
+ if (!config3?.endpoint) throw new CliError29({
12790
+ code: CliErrorCode30.ENV_NOT_FOUND,
12481
12791
  message: `\u672C\u673A\u6CA1\u6709\u540D\u53EB '${args.env}' \u7684\u73AF\u5883\u3002`,
12482
12792
  context: { nextStep: "`hcm env list` \u770B\u6709\u54EA\u4E9B\uFF1B\u6216\u5B8C\u5168\u663E\u5F0F\u5730\u5EFA\uFF1A`hcm chiron init --endpoint <\u540E\u7AEF\u5730\u5740> --tenant <\u79DF\u6237\u53F7>`" }
12483
12793
  });
@@ -12487,14 +12797,14 @@ async function resolveInitEnv(root, args, deps) {
12487
12797
  const name = g.activeEnv;
12488
12798
  const config2 = name ? await loadEnv5(name).catch(() => null) : null;
12489
12799
  const explicitPaths = " hcm chiron init --env <\u672C\u673A\u73AF\u5883\u540D>\uFF08hcm env list \u770B\u6709\u54EA\u4E9B\uFF09\n hcm chiron init --endpoint <\u540E\u7AEF\u5730\u5740> --tenant <\u79DF\u6237\u53F7>\uFF08\u5B8C\u5168\u663E\u5F0F\uFF0C\u4E0D\u9700\u8981\u5148\u767B\u5F55\uFF09";
12490
- if (!config2?.endpoint) throw new CliError28({
12491
- code: CliErrorCode29.ENV_NOT_FOUND,
12800
+ if (!config2?.endpoint) throw new CliError29({
12801
+ code: CliErrorCode30.ENV_NOT_FOUND,
12492
12802
  message: "\u6CA1\u8BF4\u8FD9\u4E2A\u9879\u76EE\u5BF9\u7740\u54EA\u4E2A\u73AF\u5883\uFF0C\u672C\u673A\u4E5F\u6CA1\u6709\u53EF\u7528\u7684\u6D3B\u52A8\u73AF\u5883\u3002",
12493
12803
  context: { nextStep: `\u4E8C\u9009\u4E00\uFF1A
12494
12804
  ${explicitPaths}` }
12495
12805
  });
12496
- if (isTempEnv3(name)) throw new CliError28({
12497
- code: CliErrorCode29.INVALID_ARGUMENT,
12806
+ if (isTempEnv3(name)) throw new CliError29({
12807
+ code: CliErrorCode30.INVALID_ARGUMENT,
12498
12808
  message: `\u672C\u673A\u6D3B\u52A8\u73AF\u5883\u662F\u4E34\u65F6\u7684\uFF08${config2.endpoint}\uFF09\uFF0C\u8FD8\u6CA1\u6709\u540D\u5B57\u3002\u9879\u76EE\u8981\u7ED1\u4E00\u4E2A\u7A33\u5B9A\u7684\u73AF\u5883\uFF0C\u5426\u5219\u4E0B\u4E00\u6B21 hcm login --code \u8986\u76D6\u5B83\u4E4B\u540E\uFF0C\u4ED3\u91CC\u8BB0\u7684\u5C31\u5BF9\u4E0D\u4E0A\u4E86\u3002`,
12499
12809
  context: { nextStep: `\u5148\u7ED9\u5B83\u8D77\u4E2A\u540D\u5B57\uFF1Ahcm env save <name>\uFF1B\u6216\u76F4\u63A5\u663E\u5F0F\u5EFA\uFF1A
12500
12810
  ${explicitPaths}` }
@@ -12502,8 +12812,8 @@ ${explicitPaths}` }
12502
12812
  const summary = `${name} \xB7 ${config2.endpoint} \xB7 \u79DF\u6237 ${config2.tenantId ?? "1"}`;
12503
12813
  if (!args.yes) {
12504
12814
  const ok = deps.isTty() && deps.confirm ? await deps.confirm(`\u6CA1\u6307\u5B9A\u73AF\u5883\uFF0C\u7528\u672C\u673A\u5F53\u524D\u6D3B\u52A8\u7684 ${summary} \u5417\uFF1F[y/N] `) : false;
12505
- if (!ok) throw new CliError28({
12506
- code: CliErrorCode29.INVALID_ARGUMENT,
12815
+ if (!ok) throw new CliError29({
12816
+ code: CliErrorCode30.INVALID_ARGUMENT,
12507
12817
  message: `\u6CA1\u786E\u8BA4\u8981\u7528\u672C\u673A\u6D3B\u52A8\u73AF\u5883\uFF08${summary}\uFF09\u3002\u9879\u76EE\u73AF\u5883\u4F1A\u63D0\u4EA4\u8FDB\u4ED3\u3001\u5F71\u54CD\u6240\u6709\u534F\u4F5C\u8005\uFF0C\u4E0D\u9760\u4E0A\u4E00\u6761\u547D\u4EE4\u7684\u526F\u4F5C\u7528\u51B3\u5B9A\u3002`,
12508
12818
  context: { nextStep: `\u786E\u8BA4\u5C31\u52A0 --yes\uFF1B\u6216\u660E\u8BF4\uFF1A
12509
12819
  ${explicitPaths}` }
@@ -12519,24 +12829,24 @@ async function scaffoldChironProject(root, env2, envName) {
12519
12829
  const document2 = parseEnvYaml(existing);
12520
12830
  const recorded = Object.values(document2.environments).find((candidate) => candidate.endpoint === env2.endpoint && candidate.tenant === env2.tenant) ?? document2.environments[document2.default];
12521
12831
  if (recorded.endpoint !== env2.endpoint) {
12522
- throw new CliError28({
12523
- code: CliErrorCode29.INVALID_ARGUMENT,
12832
+ throw new CliError29({
12833
+ code: CliErrorCode30.INVALID_ARGUMENT,
12524
12834
  message: `${ENV_FILE} \u6307\u5411 ${recorded.endpoint}\uFF0C\u800C\u4F60\u5F53\u524D\u767B\u5F55\u7684\u662F ${env2.endpoint}\uFF08env '${envName}'\uFF09\u3002
12525
12835
  \u8981\u7528\u8FD9\u4E2A\u9879\u76EE\u7684\u73AF\u5883\uFF1Ahcm login ${recorded.endpoint} --code <\u914D\u5BF9\u7801>\uFF0C\u518D\u91CD\u8DD1 hcm chiron init
12526
12836
  \u8981\u628A\u9879\u76EE\u6539\u5230\u4F60\u767B\u5F55\u7684\u73AF\u5883\uFF1A\u5220\u6389 ${ENV_FILE} \u540E\u91CD\u8DD1\uFF08\u8FD9\u4F1A\u5F71\u54CD\u6240\u6709\u534F\u4F5C\u8005\uFF0C\u5148\u8DDF\u8D1F\u8D23\u4EBA\u786E\u8BA4\uFF09`
12527
12837
  });
12528
12838
  }
12529
12839
  if (recorded.tenant !== env2.tenant) {
12530
- throw new CliError28({
12531
- code: CliErrorCode29.INVALID_ARGUMENT,
12840
+ throw new CliError29({
12841
+ code: CliErrorCode30.INVALID_ARGUMENT,
12532
12842
  message: `${ENV_FILE} \u662F\u79DF\u6237 ${recorded.tenant}\uFF0C\u800C\u4F60\u767B\u5F55\u7684\u8EAB\u4EFD\u5C5E\u4E8E\u79DF\u6237 ${env2.tenant}\u3002
12533
12843
  \u7528\u9879\u76EE\u79DF\u6237\u7684\u914D\u5BF9\u7801\u91CD\u65B0\u767B\u5F55\uFF1Ahcm login ${env2.endpoint} --code <\u914D\u5BF9\u7801>\uFF0C\u518D\u91CD\u8DD1 hcm chiron init`
12534
12844
  });
12535
12845
  }
12536
12846
  result.preserved.push(ENV_FILE);
12537
12847
  } else {
12538
- if (!envName.trim() || envName.trim() !== envName) throw new CliError28({
12539
- code: CliErrorCode29.INVALID_ARGUMENT,
12848
+ if (!envName.trim() || envName.trim() !== envName) throw new CliError29({
12849
+ code: CliErrorCode30.INVALID_ARGUMENT,
12540
12850
  message: `\u73AF\u5883\u540D '${envName}' \u4E0D\u80FD\u5199\u5165 ${ENV_FILE}\uFF1A\u73AF\u5883\u540D\u5FC5\u987B\u975E\u7A7A\u4E14\u4E0D\u80FD\u542B\u9996\u5C3E\u7A7A\u767D\u3002`,
12541
12851
  context: { nextStep: "\u6362\u4E00\u4E2A\u6CA1\u6709\u9996\u5C3E\u7A7A\u767D\u7684\u73AF\u5883\u540D\uFF0C\u518D\u8FD0\u884C hcm chiron init --env <\u73AF\u5883\u540D>\uFF08\u6216 hcm chiron init --endpoint <\u540E\u7AEF\u5730\u5740> --env <\u73AF\u5883\u540D>\uFF09" }
12542
12852
  });
@@ -12549,8 +12859,8 @@ async function scaffoldChironProject(root, env2, envName) {
12549
12859
  try {
12550
12860
  const written = parseEnvYaml(await fs10.readFile(envFile, "utf8"));
12551
12861
  if (written.default !== envName || Object.keys(written.environments).length !== 1 || !Object.hasOwn(written.environments, envName)) {
12552
- throw new CliError28({
12553
- code: CliErrorCode29.CONFIG_PARSE_ERROR,
12862
+ throw new CliError29({
12863
+ code: CliErrorCode30.CONFIG_PARSE_ERROR,
12554
12864
  message: `${ENV_FILE} \u5199\u5165\u540E\u73AF\u5883\u540D\u4E0E\u56DE\u6267 '${envName}' \u4E0D\u4E00\u81F4\u3002`,
12555
12865
  context: { nextStep: `\u6838\u5BF9 ${ENV_FILE} \u7684 default \u4E0E environments \u952E\uFF0C\u518D\u91CD\u8DD1 hcm chiron init` }
12556
12866
  });
@@ -12628,7 +12938,7 @@ async function chironInitCommand(args, deps) {
12628
12938
  const result = await runChironInit(args, deps);
12629
12939
  const fmt = args.output ?? "table";
12630
12940
  if (fmt === "json" || fmt === "yaml") {
12631
- process.stdout.write(formatObject26(result, { format: fmt }) + "\n");
12941
+ process.stdout.write(formatObject27(result, { format: fmt }) + "\n");
12632
12942
  } else {
12633
12943
  const mark = { verified: "\u2705", mismatch: "\u274C", unreachable: "\u26A0\uFE0F", skipped: "\xB7" }[result.tenantCheck.status];
12634
12944
  process.stdout.write(
@@ -12650,9 +12960,9 @@ async function chironInitCommand(args, deps) {
12650
12960
  // src/commands/gap.ts
12651
12961
  import { readFileSync as readFileSync6 } from "fs";
12652
12962
  import {
12653
- CliErrorCode as CliErrorCode32,
12963
+ CliErrorCode as CliErrorCode33,
12654
12964
  createHttpClient as createHttpClient4,
12655
- formatObject as formatObject27,
12965
+ formatObject as formatObject28,
12656
12966
  loadGlobalConfig as loadGlobalConfig10,
12657
12967
  resolveEnvContext as resolveEnvContext7,
12658
12968
  printResolvedEnvironment as printResolvedEnvironment7,
@@ -12662,14 +12972,14 @@ init_exit();
12662
12972
  import { createJiraClient } from "@hcmai/sdk";
12663
12973
 
12664
12974
  // src/jira/gaps.ts
12665
- import { CASES_REPO_SLUG as CASES_REPO_SLUG3, CliError as CliError30, CliErrorCode as CliErrorCode31, describeNonBmpHits, findNonBmpChars, firstLine as firstLine3, repoIssueUrl } from "@hcmai/sdk";
12975
+ import { CASES_REPO_SLUG as CASES_REPO_SLUG3, CliError as CliError31, CliErrorCode as CliErrorCode32, describeNonBmpHits, findNonBmpChars, firstLine as firstLine3, repoIssueUrl } from "@hcmai/sdk";
12666
12976
  import { linkedRepoRefs, parseRef as parseRef2 } from "@hcmai/sdk";
12667
12977
 
12668
12978
  // src/jira/gap-verify.ts
12669
12979
  import {
12670
12980
  CASES_REPO_SLUG as CASES_REPO_SLUG2,
12671
- CliError as CliError29,
12672
- CliErrorCode as CliErrorCode30,
12981
+ CliError as CliError30,
12982
+ CliErrorCode as CliErrorCode31,
12673
12983
  JiraHttpError,
12674
12984
  JiraNonBmpContentError,
12675
12985
  NON_BMP_RULE_NOTE,
@@ -12704,14 +13014,14 @@ var VERIFY_PLAN = {
12704
13014
  function parseVerifyResult(raw) {
12705
13015
  const v = String(raw ?? "").trim().toLowerCase();
12706
13016
  if (VERIFY_RESULTS.includes(v)) return v;
12707
- throw new CliError29({
12708
- code: raw === void 0 ? CliErrorCode30.MISSING_FLAG : CliErrorCode30.INVALID_ARGUMENT,
13017
+ throw new CliError30({
13018
+ code: raw === void 0 ? CliErrorCode31.MISSING_FLAG : CliErrorCode31.INVALID_ARGUMENT,
12709
13019
  message: `--result \u53EA\u80FD\u662F pass / fail / partial\uFF0C\u7ED9\u7684\u662F\u300C${raw ?? "\uFF08\u6CA1\u7ED9\uFF09"}\u300D`,
12710
13020
  context: { nextStep: "pass = \u539F\u6545\u969C\u5728\u76EE\u6807\u73AF\u5883\u4E0D\u518D\u51FA\u73B0\uFF1Bfail = \u4ECD\u7136\u590D\u73B0\u6216\u9A8C\u51FA\u6CA1\u901A\u8FC7\u7684\uFF1Bpartial = \u53EA\u9A8C\u4E86\u4E00\u90E8\u5206\u3001\u9A8C\u8FC7\u7684\u90FD\u901A\u8FC7\uFF08\u4E0D\u5173\u5355\uFF09\u3002" }
12711
13021
  });
12712
13022
  }
12713
13023
  function verifyFailure(reasonCode, code2, written, message, nextStep, extra = {}, cause) {
12714
- return new CliError29({ code: code2, message: `${message}${WRITTEN_TAG[written]}`, context: { reasonCode, written, nextStep, ...extra }, cause });
13024
+ return new CliError30({ code: code2, message: `${message}${WRITTEN_TAG[written]}`, context: { reasonCode, written, nextStep, ...extra }, cause });
12715
13025
  }
12716
13026
  function who(u) {
12717
13027
  if (!u) return "\uFF08\u5355\u4E0A\u6CA1\u6709\uFF09";
@@ -12801,7 +13111,7 @@ function writeFailure(e, key2, what) {
12801
13111
  if (e instanceof JiraNonBmpContentError) {
12802
13112
  return verifyFailure(
12803
13113
  "non-bmp-content",
12804
- CliErrorCode30.INVALID_ARGUMENT,
13114
+ CliErrorCode31.INVALID_ARGUMENT,
12805
13115
  "no",
12806
13116
  `\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`,
12807
13117
  // 🔴 清单落 nextStep,不落 cause:CliError 渲染 cause 时 formatCause 截到 300 字,
@@ -12812,7 +13122,7 @@ ${nonBmpHitLines(e.hits)}`,
12812
13122
  );
12813
13123
  }
12814
13124
  if (e instanceof JiraHttpError && e.status >= 400 && e.status < 500) {
12815
- return verifyFailure("write-rejected", CliErrorCode30.BUSINESS_RULE_VIOLATION, "no", `Jira \u4EE5 ${e.status} \u62D2\u7EDD\u4E86\u8FD9\u6B21${what}`, rejectNextStep(e.status, key2), {
13125
+ return verifyFailure("write-rejected", CliErrorCode31.BUSINESS_RULE_VIOLATION, "no", `Jira \u4EE5 ${e.status} \u62D2\u7EDD\u4E86\u8FD9\u6B21${what}`, rejectNextStep(e.status, key2), {
12816
13126
  key: key2,
12817
13127
  status: e.status,
12818
13128
  details: e.message
@@ -12820,7 +13130,7 @@ ${nonBmpHitLines(e.hits)}`,
12820
13130
  }
12821
13131
  return verifyFailure(
12822
13132
  "write-unconfirmed",
12823
- CliErrorCode30.NETWORK_ERROR,
13133
+ CliErrorCode31.NETWORK_ERROR,
12824
13134
  "unknown",
12825
13135
  `${what}\u8BF7\u6C42\u6CA1\u5F97\u5230\u786E\u8BA4\uFF08${unconfirmedWhy(e)}\uFF09`,
12826
13136
  `\u5148\u7528 \`hcm chiron gap status ${key2}\` \u4E0E \`hcm chiron gap comments ${key2}\` \u6838\u5BF9\u5199\u8FDB\u53BB\u6CA1\u6709\uFF0C\u518D\u51B3\u5B9A\u8981\u4E0D\u8981\u91CD\u8DD1\u2014\u2014partial \u91CD\u8DD1\u4F1A\u591A\u4E00\u6761\u8BC4\u8BBA\u3002`,
@@ -12828,57 +13138,57 @@ ${nonBmpHitLines(e.hits)}`,
12828
13138
  e
12829
13139
  );
12830
13140
  }
12831
- async function claimTransitionComment(client3, key2, me, header, body, beforeIds) {
13141
+ async function claimTransitionComment(client4, key2, me, header, body, beforeIds) {
12832
13142
  try {
12833
- const hit = (await client3.comments(key2)).filter((c2) => !beforeIds.has(c2.id) && sameUser(c2.author, me) && firstLine2(c2.body ?? "") === header).at(-1);
12834
- return hit?.id ? { body, found: true, id: hit.id, url: client3.commentUrl(key2, hit.id) } : { body, found: false, note: `\u6D41\u8F6C\u5DF2\u63D0\u4EA4\uFF0C\u4F46\u56DE\u8BFB\u8BC4\u8BBA\u6CA1\u8BA4\u9886\u5230\u8FD9\u4E00\u6761\uFF08\u63A5\u53E3\u4E0D\u56DE\u8BC4\u8BBA id\uFF09\uFF1B\u4EE5 \`hcm chiron gap comments ${key2}\` \u4E3A\u51C6\u3002` };
13143
+ const hit = (await client4.comments(key2)).filter((c2) => !beforeIds.has(c2.id) && sameUser(c2.author, me) && firstLine2(c2.body ?? "") === header).at(-1);
13144
+ return hit?.id ? { body, found: true, id: hit.id, url: client4.commentUrl(key2, hit.id) } : { body, found: false, note: `\u6D41\u8F6C\u5DF2\u63D0\u4EA4\uFF0C\u4F46\u56DE\u8BFB\u8BC4\u8BBA\u6CA1\u8BA4\u9886\u5230\u8FD9\u4E00\u6761\uFF08\u63A5\u53E3\u4E0D\u56DE\u8BC4\u8BBA id\uFF09\uFF1B\u4EE5 \`hcm chiron gap comments ${key2}\` \u4E3A\u51C6\u3002` };
12835
13145
  } catch (e) {
12836
13146
  const why = e instanceof Error ? e.message.split("\n")[0] : String(e);
12837
13147
  return { body, found: false, note: `\u6D41\u8F6C\u5DF2\u63D0\u4EA4\uFF0C\u4F46\u56DE\u8BFB\u8BC4\u8BBA\u5931\u8D25\uFF08${why}\uFF09\uFF1B\u4EE5 \`hcm chiron gap comments ${key2}\` \u4E3A\u51C6\u3002` };
12838
13148
  }
12839
13149
  }
12840
13150
  var snapshotOf = (i) => ({ status: i.fields.status?.name, resolution: i.fields.resolution?.name ?? null });
12841
- async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLUG2) {
12842
- const parsed = parseRef(ref, client3.project, casesSlug);
13151
+ async function gapVerify({ client: client4 }, ref, o, casesSlug = CASES_REPO_SLUG2) {
13152
+ const parsed = parseRef(ref, client4.project, casesSlug);
12843
13153
  if (!parsed || parsed.kind !== "jira") {
12844
13154
  throw verifyFailure(
12845
13155
  "not-jira-key",
12846
- CliErrorCode30.INVALID_ARGUMENT,
13156
+ CliErrorCode31.INVALID_ARGUMENT,
12847
13157
  "no",
12848
13158
  parsed && parsed.kind === "repo" ? `${parsed.repo}#${parsed.number} \u662F\u4EA7\u54C1\u4ED3\u7F16\u53F7\uFF0C\u9A8C\u6536\u8981\u843D\u5728 Jira \u5355\u4E0A` : `\u770B\u4E0D\u61C2 ${ref}`,
12849
13159
  "\u7ED9 Jira \u5355\u53F7\uFF08HCMNX-12 \u6216\u88F8\u6570\u5B57 12\uFF09\u2014\u2014\u5C31\u662F `hcm chiron gap submit` \u56DE\u6267\u91CC\u7684\u90A3\u4E2A\u7F16\u53F7\u3002"
12850
13160
  );
12851
13161
  }
12852
13162
  const key2 = parsed.key;
12853
- const inProject = (k) => k.startsWith(`${client3.project}-`);
13163
+ const inProject = (k) => k.startsWith(`${client4.project}-`);
12854
13164
  const wrongProject = (k) => verifyFailure(
12855
13165
  "wrong-project",
12856
- CliErrorCode30.INVALID_ARGUMENT,
13166
+ CliErrorCode31.INVALID_ARGUMENT,
12857
13167
  "no",
12858
- `${k} \u4E0D\u5728 ${client3.project} \u9879\u76EE\u91CC\uFF0C\u9A8C\u6536\u53EA\u5199 ${client3.project} \u7684\u5355`,
12859
- `\u7ED9 ${client3.project} \u7684\u5355\u53F7\uFF08\`hcm chiron gap submit\` \u56DE\u6267\u91CC\u7684\u90A3\u4E2A\uFF09\u3002\u522B\u7684\u9879\u76EE\u7684\u5355\u8FD9\u6761\u547D\u4EE4\u4E0D\u78B0\u2014\u2014\u90A3\u91CC\u7684\u72B6\u6001\u540D\u4E0E\u6D41\u8F6C\u540D\u548C ${client3.project} \u540C\u5F62\uFF0C\u5199\u9519\u4E86\u4F1A\u628A\u522B\u5904\u7684\u5355\u5173\u6389\u3002`,
12860
- { key: k, project: client3.project }
13168
+ `${k} \u4E0D\u5728 ${client4.project} \u9879\u76EE\u91CC\uFF0C\u9A8C\u6536\u53EA\u5199 ${client4.project} \u7684\u5355`,
13169
+ `\u7ED9 ${client4.project} \u7684\u5355\u53F7\uFF08\`hcm chiron gap submit\` \u56DE\u6267\u91CC\u7684\u90A3\u4E2A\uFF09\u3002\u522B\u7684\u9879\u76EE\u7684\u5355\u8FD9\u6761\u547D\u4EE4\u4E0D\u78B0\u2014\u2014\u90A3\u91CC\u7684\u72B6\u6001\u540D\u4E0E\u6D41\u8F6C\u540D\u548C ${client4.project} \u540C\u5F62\uFF0C\u5199\u9519\u4E86\u4F1A\u628A\u522B\u5904\u7684\u5355\u5173\u6389\u3002`,
13170
+ { key: k, project: client4.project }
12861
13171
  );
12862
13172
  if (!inProject(key2)) throw wrongProject(key2);
12863
13173
  const evidence = o.evidence.trim();
12864
13174
  if (evidence.length < EVIDENCE_MIN) {
12865
13175
  throw verifyFailure(
12866
13176
  "evidence-too-short",
12867
- CliErrorCode30.INVALID_ARGUMENT,
13177
+ CliErrorCode31.INVALID_ARGUMENT,
12868
13178
  "no",
12869
13179
  `\u9A8C\u6536\u8BC1\u636E\u81F3\u5C11 ${EVIDENCE_MIN} \u4E2A\u5B57\uFF0C\u7ED9\u7684\u662F ${evidence.length} \u4E2A\u5B57`,
12870
13180
  "\u5199\u6E05\uFF1A\u54EA\u4E2A\u73AF\u5883\u3001\u54EA\u4E2A\u7248\u672C\uFF08`hcm version`\uFF09\u3001\u6309\u6280\u80FD\u8DD1\u4E86\u4EC0\u4E48\u3001\u770B\u5230\u4E86\u4EC0\u4E48\uFF1B\u8BC1\u636E\u6587\u4EF6\u653E\u5728 evidence/ \u4E0B\u5E76\u5199\u4E0A\u8DEF\u5F84\u3002",
12871
13181
  { key: key2 }
12872
13182
  );
12873
13183
  }
12874
- const [issue, me] = await Promise.all([client3.issue(key2), client3.myself()]);
13184
+ const [issue, me] = await Promise.all([client4.issue(key2), client4.myself()]);
12875
13185
  if (!inProject(issue.key)) throw wrongProject(issue.key);
12876
13186
  const before = snapshotOf(issue);
12877
13187
  const status = before.status;
12878
13188
  const reporter = issue.fields.reporter;
12879
13189
  const base = {
12880
13190
  key: key2,
12881
- url: client3.browseUrl(key2),
13191
+ url: client4.browseUrl(key2),
12882
13192
  summary: issue.fields.summary ?? "",
12883
13193
  result: o.result,
12884
13194
  reporter: who(reporter),
@@ -12890,7 +13200,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
12890
13200
  if (!sameUser(reporter, me)) {
12891
13201
  throw verifyFailure(
12892
13202
  "not-reporter",
12893
- CliErrorCode30.BUSINESS_RULE_VIOLATION,
13203
+ CliErrorCode31.BUSINESS_RULE_VIOLATION,
12894
13204
  "no",
12895
13205
  `\u53EA\u6709\u63D0\u5355\u4EBA\u80FD\u9A8C\u6536 ${key2}\uFF1A\u63D0\u5355\u4EBA\u662F ${who(reporter)}\uFF0C\u5F53\u524D\u8EAB\u4EFD\u662F ${who(me)}`,
12896
13206
  // 重复单上的 pass:提单人跑了也一个字不写(见下面 ②),叫人去找提单人是一跳死路
@@ -12905,7 +13215,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
12905
13215
  if (status !== FIXED_STATUS) {
12906
13216
  throw verifyFailure(
12907
13217
  "status-not-fixed",
12908
- CliErrorCode30.BUSINESS_RULE_VIOLATION,
13218
+ CliErrorCode31.BUSINESS_RULE_VIOLATION,
12909
13219
  "no",
12910
13220
  `${key2} \u7684\u72B6\u6001\u662F\u300C${status ?? "?"}\u300D\uFF0C\u9A8C\u6536\u53EA\u5728\u300C${FIXED_STATUS}\u300D\u4E0A\u505A`,
12911
13221
  notFixedNextStep(key2, before, o.result),
@@ -12917,7 +13227,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
12917
13227
  let comments;
12918
13228
  let readReason;
12919
13229
  try {
12920
- comments = await client3.comments(key2);
13230
+ comments = await client4.comments(key2);
12921
13231
  } catch (e) {
12922
13232
  readReason = e instanceof Error ? e.message.split("\n")[0] : String(e);
12923
13233
  }
@@ -12931,7 +13241,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
12931
13241
  } else if (o.fingerprint.revision < fixRevision) {
12932
13242
  const environmentRevision = o.fingerprint.revision;
12933
13243
  const message = `\u73AF\u5883\u5C1A\u672A\u5305\u542B\u4FEE\u590D\uFF08\u5F53\u524D r${environmentRevision} < \u4FEE\u590D r${fixRevision}\uFF09\uFF0C\u8BF7\u7B49\u90E8\u7F72\u540E\u590D\u9A8C\uFF1B\u81EA\u67E5 curl <env>/api/version/backend`;
12934
- throw verifyFailure("env-behind-fix", CliErrorCode30.BUSINESS_RULE_VIOLATION, "no", message, message, { key: key2, fixRevision, environmentRevision });
13244
+ throw verifyFailure("env-behind-fix", CliErrorCode31.BUSINESS_RULE_VIOLATION, "no", message, message, { key: key2, fixRevision, environmentRevision });
12935
13245
  } else {
12936
13246
  const environmentRevision = o.fingerprint.revision;
12937
13247
  versionComparison = { status: "passed", text: `\u7248\u672C\u6BD4\u5BF9\uFF1A\u73AF\u5883 r${environmentRevision} \u2265 \u4FEE\u590D r${fixRevision}`, fixRevision, environmentRevision };
@@ -12943,13 +13253,13 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
12943
13253
  let requiredChecked;
12944
13254
  if (plan.transition) {
12945
13255
  const want = plan.transition;
12946
- const list = await client3.transitions(key2);
13256
+ const list = await client4.transitions(key2);
12947
13257
  transition = list.find((t) => t.name === want.name && t.to?.name === want.to);
12948
13258
  if (!transition) {
12949
13259
  const available = list.map((t) => `${t.name}\u2192${t.to?.name ?? "?"}`);
12950
13260
  throw verifyFailure(
12951
13261
  "transition-unavailable",
12952
- CliErrorCode30.BUSINESS_RULE_VIOLATION,
13262
+ CliErrorCode31.BUSINESS_RULE_VIOLATION,
12953
13263
  "no",
12954
13264
  `${key2} \u4E0A\u670D\u52A1\u7AEF\u6B64\u523B\u4E0D\u7ED9\u300C${want.name}\u2192${want.to}\u300D\u8FD9\u6761\u6D41\u8F6C\uFF08\u53EF\u7528\uFF1A${available.join(" / ") || "\uFF08\u65E0\uFF09"}\uFF09`,
12955
13265
  "\u591A\u534A\u662F\u5DE5\u4F5C\u6D41\u88AB\u6539\u8FC7\uFF0C\u6216\u4F60\u7684\u8D26\u53F7\u5728\u8FD9\u4E2A\u9879\u76EE\u4E0A\u6CA1\u6709\u8FD9\u6761\u6D41\u8F6C\u7684\u6743\u9650\u3002\u628A\u8FD9\u6BB5\u8F93\u51FA\u53D1\u7ED9\u4EA7\u54C1\u4FA7\u5206\u8BCA\u4EBA\uFF1B\u522B\u81EA\u5DF1\u62FC HTTP\uFF0C\u4E5F\u522B\u6539\u95EE\u9898\u7C7B\u578B\u7ED5\u8FC7\u3002",
@@ -12961,7 +13271,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
12961
13271
  else if (req.missing.length) {
12962
13272
  throw verifyFailure(
12963
13273
  "required-fields-missing",
12964
- CliErrorCode30.BUSINESS_RULE_VIOLATION,
13274
+ CliErrorCode31.BUSINESS_RULE_VIOLATION,
12965
13275
  "no",
12966
13276
  `\u300C${transition.name}\u300D\u8981\u6C42\u8FD9\u4E9B\u5B57\u6BB5\u6709\u503C\uFF0C${key2} \u4E0A\u662F\u7A7A\u7684\uFF1A${req.missing.join("\u3001")}`,
12967
13277
  "\u8FD9\u4E9B\u5B57\u6BB5\u7531\u4EA7\u54C1\u4FA7\u7EF4\u62A4\uFF0C\u8BF7\u5206\u8BCA\u4EBA\u8865\u9F50\u540E\u518D\u8DD1\uFF1BCLI \u4E0D\u4EE3\u586B\uFF0C\u4E5F\u522B\u628A\u7ECF\u529E\u4EBA\u6216\u4FEE\u590D\u4EBA\u731C\u6210 Bug\u5F15\u5165\u4EBA\u3002",
@@ -12990,20 +13300,20 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
12990
13300
  }
12991
13301
  if (transition) {
12992
13302
  const what = `\u6D41\u8F6C\u300C${transition.name}\u300D\u4E0E\u8BC4\u8BBA`;
12993
- const beforeIds = new Set((await client3.comments(key2)).map((c2) => c2.id));
13303
+ const beforeIds = new Set((await client4.comments(key2)).map((c2) => c2.id));
12994
13304
  try {
12995
- await client3.transitionById(key2, transition.id, body);
13305
+ await client4.transitionById(key2, transition.id, body);
12996
13306
  } catch (e) {
12997
13307
  throw writeFailure(e, key2, what);
12998
13308
  }
12999
- const comment2 = await claimTransitionComment(client3, key2, me, plan.header, body, beforeIds);
13309
+ const comment2 = await claimTransitionComment(client4, key2, me, plan.header, body, beforeIds);
13000
13310
  let after2;
13001
13311
  try {
13002
- after2 = snapshotOf(await client3.issue(key2, ["status", "resolution"]));
13312
+ after2 = snapshotOf(await client4.issue(key2, ["status", "resolution"]));
13003
13313
  } catch (e) {
13004
13314
  throw verifyFailure(
13005
13315
  "readback-failed",
13006
- CliErrorCode30.NETWORK_ERROR,
13316
+ CliErrorCode31.NETWORK_ERROR,
13007
13317
  "yes",
13008
13318
  `${what}\u5DF2\u88AB Jira \u63A5\u53D7\uFF0C\u4F46\u56DE\u8BFB ${key2} \u5931\u8D25\uFF0C\u843D\u5230\u4EC0\u4E48\u72B6\u6001\u6CA1\u786E\u8BA4`,
13009
13319
  `\u7528 \`hcm chiron gap status ${key2}\` \u770B\u7ED3\u679C\uFF1B\u522B\u76F4\u63A5\u91CD\u8DD1\uFF08\u4F1A\u518D\u5199\u4E00\u6761\u8BC4\u8BBA\uFF09\u3002`,
@@ -13017,7 +13327,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
13017
13327
  const did = plan.outcome === "closed" ? "\u5173\u5355" : "\u9000\u56DE";
13018
13328
  throw verifyFailure(
13019
13329
  "readback-mismatch",
13020
- CliErrorCode30.SERVER_ERROR,
13330
+ CliErrorCode31.SERVER_ERROR,
13021
13331
  "yes",
13022
13332
  after2.status !== expected ? `${what}\u5DF2\u88AB Jira \u63A5\u53D7\uFF0C\u4F46\u56DE\u8BFB ${key2} \u7684\u72B6\u6001\u662F\u300C${after2.status ?? "?"}\u300D\uFF0C\u9884\u671F\u300C${expected}\u300D` : `${what}\u5DF2\u88AB Jira \u63A5\u53D7\uFF0C${key2} \u56DE\u5230\u4E86\u300C${expected}\u300D\uFF0C\u4F46 resolution \u8FD8\u662F\u300C${after2.resolution}\u300D\u2014\u2014\u5B83\u4F1A\u4ECE\u300C\u672A\u89E3\u51B3\u300D\u7684\u67E5\u8BE2\u91CC\u6D88\u5931`,
13023
13333
  after2.status !== expected ? `\u4EE5 \`hcm chiron gap status ${key2}\` \u4E3A\u51C6\uFF0C\u522B\u5F53\u6210\u5DF2\u7ECF${did}\uFF1B\u628A\u8FD9\u6BB5\u8F93\u51FA\u53D1\u7ED9\u4EA7\u54C1\u4FA7\u5206\u8BCA\u4EBA\u3002` : "\u8BF7\u4EA7\u54C1\u4FA7\u5206\u8BCA\u4EBA\u6E05\u6389\u8FD9\u5355\u7684 resolution\uFF08\u300C\u672A\u89E3\u51B3\u300D\u8FD9\u6761\u6D41\u8F6C\u672C\u6765\u4F1A\u6E05\uFF0C\u6CA1\u6E05\u8BF4\u660E\u5DE5\u4F5C\u6D41\u88AB\u6539\u8FC7\uFF09\uFF1B\u628A\u8FD9\u6BB5\u8F93\u51FA\u53D1\u7ED9\u4ED6\u3002",
@@ -13039,17 +13349,17 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
13039
13349
  }
13040
13350
  let written;
13041
13351
  try {
13042
- written = await client3.addComment(key2, body);
13352
+ written = await client4.addComment(key2, body);
13043
13353
  } catch (e) {
13044
13354
  throw writeFailure(e, key2, "\u8BC4\u8BBA");
13045
13355
  }
13046
13356
  let listed;
13047
13357
  try {
13048
- listed = await client3.comments(key2);
13358
+ listed = await client4.comments(key2);
13049
13359
  } catch (e) {
13050
13360
  throw verifyFailure(
13051
13361
  "readback-failed",
13052
- CliErrorCode30.NETWORK_ERROR,
13362
+ CliErrorCode31.NETWORK_ERROR,
13053
13363
  "yes",
13054
13364
  `\u8BC4\u8BBA\u5DF2\u88AB Jira \u63A5\u53D7\uFF0C\u4F46\u56DE\u8BFB ${key2} \u7684\u8BC4\u8BBA\u5931\u8D25\uFF0C\u6CA1\u786E\u8BA4\u5B83\u5728`,
13055
13365
  `\u7528 \`hcm chiron gap comments ${key2}\` \u770B\u5B83\u5728\u4E0D\u5728\uFF1B\u522B\u76F4\u63A5\u91CD\u8DD1\uFF08\u4F1A\u518D\u5199\u4E00\u6761\uFF09\u3002`,
@@ -13063,19 +13373,19 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
13063
13373
  } else if (!listed.some((c2) => c2.id === written.id)) {
13064
13374
  throw verifyFailure(
13065
13375
  "readback-mismatch",
13066
- CliErrorCode30.SERVER_ERROR,
13376
+ CliErrorCode31.SERVER_ERROR,
13067
13377
  "yes",
13068
13378
  `Jira \u56DE\u4E86\u8BC4\u8BBA ${written.id}\uFF0C\u4F46\u56DE\u8BFB ${key2} \u7684\u8BC4\u8BBA\u91CC\u6CA1\u6709\u5B83`,
13069
13379
  `\u7528 \`hcm chiron gap comments ${key2}\` \u6838\u5BF9\uFF1B\u522B\u76F4\u63A5\u91CD\u8DD1\uFF0C\u628A\u8FD9\u6BB5\u8F93\u51FA\u53D1\u7ED9\u4EA7\u54C1\u4FA7\u5206\u8BCA\u4EBA\u3002`,
13070
13380
  { key: key2, comment: written.id }
13071
13381
  );
13072
13382
  } else {
13073
- comment = { body, found: true, id: written.id, url: client3.commentUrl(key2, written.id) };
13383
+ comment = { body, found: true, id: written.id, url: client4.commentUrl(key2, written.id) };
13074
13384
  }
13075
13385
  let after;
13076
13386
  let aside = "";
13077
13387
  try {
13078
- after = snapshotOf(await client3.issue(key2, ["status", "resolution"]));
13388
+ after = snapshotOf(await client4.issue(key2, ["status", "resolution"]));
13079
13389
  if (after.status !== FIXED_STATUS) aside = `\uFF08\u56DE\u8BFB\u65F6\u5355\u5B50\u5DF2\u662F\u300C${after.status ?? "?"}\u300D\u2014\u2014\u8BC4\u8BBA\u5199\u8FDB\u53BB\u4E4B\u540E\u6709\u4EBA\u52A8\u8FC7\u5B83\uFF0C\u4EE5 \`hcm chiron gap status ${key2}\` \u4E3A\u51C6\u3002\uFF09`;
13080
13390
  } catch (e) {
13081
13391
  const why = e instanceof Error ? e.message.split("\n")[0] : String(e);
@@ -13174,7 +13484,7 @@ var reporterFields = (who2) => !who2 ? {} : who2.reportedByYou === null ? { repo
13174
13484
  var reporterCheckOf = (c2) => c2.reportedByYou === void 0 ? void 0 : c2.reportedByYou === null ? { reportedByYou: null, why: c2.reportedByYouUnknown ?? "\u539F\u56E0\u672A\u77E5" } : { reportedByYou: c2.reportedByYou, ...c2.reportedByYouBasis ? { basis: c2.reportedByYouBasis } : {} };
13175
13485
  var gapDedupeJql = (project2) => `project = ${project2} AND (resolution = Unresolved OR status = "${FIXED_STATUS}" OR (status = "${CLOSED_STATUS}" AND resolved >= -90d)) ORDER BY created DESC`;
13176
13486
  var GAP_DEDUPE_SCOPE = "\u672A\u89E3\u51B3 + \u5DF2\u4FEE\u590D + \u8FD1 90 \u5929 CLOSE";
13177
- function findGapCandidates(issues, g, client3) {
13487
+ function findGapCandidates(issues, g, client4) {
13178
13488
  const summary = gapSummary(g);
13179
13489
  const code2 = isMissingCode(g.error_code) ? void 0 : g.error_code;
13180
13490
  const out = [];
@@ -13199,7 +13509,7 @@ function findGapCandidates(issues, g, client3) {
13199
13509
  summary: t,
13200
13510
  status: i.fields.status?.name,
13201
13511
  resolution: i.fields.resolution?.name,
13202
- url: client3.browseUrl(i.key),
13512
+ url: client4.browseUrl(i.key),
13203
13513
  reason,
13204
13514
  ...score !== void 0 ? { score } : {}
13205
13515
  });
@@ -13363,18 +13673,18 @@ next_step=\u8BA9 Jira \u7BA1\u7406\u5458\u628A\u8FD9\u4E9B\u5B57\u6BB5\u6539\u62
13363
13673
  }
13364
13674
  return { fields, type, keyTag, summary: gapSummary(g), module: `${module}/${g.module_detail || MODULE_DEFAULT_CHILD[module]}` };
13365
13675
  }
13366
- async function withSituation(client3, c2, fingerprint, reporter) {
13676
+ async function withSituation(client4, c2, fingerprint, reporter) {
13367
13677
  if (!isFixedCandidate(c2)) return { ...c2, ...classifyCandidate(c2, void 0, fingerprint) };
13368
13678
  const who2 = c2.status === FIXED_STATUS ? await reporter() : void 0;
13369
13679
  try {
13370
- return { ...c2, ...classifyCandidate(c2, fixRevisionFromComments(await client3.comments(c2.key)), fingerprint, void 0, who2), ...reporterFields(who2) };
13680
+ return { ...c2, ...classifyCandidate(c2, fixRevisionFromComments(await client4.comments(c2.key)), fingerprint, void 0, who2), ...reporterFields(who2) };
13371
13681
  } catch (e) {
13372
13682
  return { ...c2, ...classifyCandidate(c2, void 0, fingerprint, firstLine3(String(e.message ?? e)), who2), ...reporterFields(who2) };
13373
13683
  }
13374
13684
  }
13375
- function reporterChecker(client3) {
13685
+ function reporterChecker(client4) {
13376
13686
  let me;
13377
- const myself = () => me ??= client3.myself();
13687
+ const myself = () => me ??= client4.myself();
13378
13688
  const check = async (reporter) => {
13379
13689
  let you;
13380
13690
  try {
@@ -13431,16 +13741,16 @@ localWorkaround: ${localWorkaroundText(g)}
13431
13741
  \u4E25\u91CD\u5EA6\uFF1A${g.severity}` + (target?.advice && comparesVersions(target.situation) ? `
13432
13742
 
13433
13743
  \u7248\u672C\u5224\u65AD\uFF1A${target.advice}` : "");
13434
- async function gapSubmit({ client: client3 }, g, opts) {
13744
+ async function gapSubmit({ client: client4 }, g, opts) {
13435
13745
  const summary = gapSummary(g);
13436
- const scope = await client3.searchAll(gapDedupeJql(client3.project), { fields: ["summary", "status", "resolution", "reporter"] });
13746
+ const scope = await client4.searchAll(gapDedupeJql(client4.project), { fields: ["summary", "status", "resolution", "reporter"] });
13437
13747
  const scanned = { scope: GAP_DEDUPE_SCOPE, count: scope.issues.length, total: scope.total, truncated: scope.truncated };
13438
- const raw = findGapCandidates(scope.issues, g, client3);
13748
+ const raw = findGapCandidates(scope.issues, g, client4);
13439
13749
  const reporters = new Map(scope.issues.map((i) => [i.key, i.fields.reporter]));
13440
- const who2 = reporterChecker(client3);
13750
+ const who2 = reporterChecker(client4);
13441
13751
  const candidates = [];
13442
13752
  for (const c2 of raw.slice(0, MAX_CANDIDATES)) {
13443
- const judged = await withSituation(client3, c2, opts.fingerprint, () => who2.check(reporters.get(c2.key)));
13753
+ const judged = await withSituation(client4, c2, opts.fingerprint, () => who2.check(reporters.get(c2.key)));
13444
13754
  candidates.push({ ...judged, appendable: !appendRefused(judged) });
13445
13755
  }
13446
13756
  const base = {
@@ -13453,17 +13763,17 @@ async function gapSubmit({ client: client3 }, g, opts) {
13453
13763
  localWorkaroundStated: Boolean(g.local_workaround?.trim())
13454
13764
  };
13455
13765
  if (opts.appendTo) {
13456
- const parsed = parseRef2(opts.appendTo, client3.project);
13457
- if (!parsed || parsed.kind !== "jira" || !parsed.key.startsWith(`${client3.project}-`)) {
13458
- throw new CliError30({ code: CliErrorCode31.INVALID_ARGUMENT, message: `--append-to \u8981\u7ED9 ${client3.project} \u7684\u5355\u53F7\uFF08\u5982 ${client3.project}-5\uFF09\uFF0C\u6536\u5230\u300C${opts.appendTo}\u300D` });
13766
+ const parsed = parseRef2(opts.appendTo, client4.project);
13767
+ if (!parsed || parsed.kind !== "jira" || !parsed.key.startsWith(`${client4.project}-`)) {
13768
+ throw new CliError31({ code: CliErrorCode32.INVALID_ARGUMENT, message: `--append-to \u8981\u7ED9 ${client4.project} \u7684\u5355\u53F7\uFF08\u5982 ${client4.project}-5\uFF09\uFF0C\u6536\u5230\u300C${opts.appendTo}\u300D` });
13459
13769
  }
13460
- const issue = await client3.issue(parsed.key, ["summary", "status", "resolution", "reporter"]);
13461
- const target = await withSituation(client3, {
13770
+ const issue = await client4.issue(parsed.key, ["summary", "status", "resolution", "reporter"]);
13771
+ const target = await withSituation(client4, {
13462
13772
  key: parsed.key,
13463
13773
  summary: issue.fields.summary ?? "",
13464
13774
  status: issue.fields.status?.name,
13465
13775
  resolution: issue.fields.resolution?.name,
13466
- url: client3.browseUrl(parsed.key),
13776
+ url: client4.browseUrl(parsed.key),
13467
13777
  ...(() => {
13468
13778
  const hit = raw.find((c2) => c2.key === parsed.key);
13469
13779
  return hit ? { reason: hit.reason, ...hit.score !== void 0 ? { score: hit.score } : {} } : { reason: "named" };
@@ -13471,8 +13781,8 @@ async function gapSubmit({ client: client3 }, g, opts) {
13471
13781
  }, opts.fingerprint, () => who2.check(issue.fields.reporter));
13472
13782
  if (appendRefused(target)) {
13473
13783
  const why = target.status === CLOSED_STATUS ? "\u8FD9\u5355\u5DF2\u5173\u95ED\uFF08\u7EC8\u6001\uFF09\uFF0C\u8FFD\u52A0\u7684\u73B0\u573A\u5206\u8BCA\u770B\u4E0D\u5230" : target.situation === "duplicate" ? "\u8FD9\u5F20\u88AB\u5224\u4E3A\u91CD\u590D\u5355\uFF0C\u73B0\u573A\u8BE5\u8BB0\u5728\u5B83\u6307\u5411\u7684\u539F\u5355\u4E0A" : target.status !== FIXED_STATUS ? "\u4F60\u7684\u73AF\u5883\u5DF2\u542B\u4FEE\u590D\u4ECD\u590D\u73B0\uFF0C\u7591\u4F3C\u56DE\u5F52\uFF0C\u8981\u65B0\u5F00\u5E76\u5F15\u7528\u539F\u5355" : target.reportedByYou === true ? "\u4F60\u7684\u73AF\u5883\u5DF2\u542B\u4FEE\u590D\u4ECD\u590D\u73B0\uFF0C\u7591\u4F3C\u56DE\u5F52\uFF1B\u539F\u5355\u8FD8\u505C\u5728\u300C\u5DF2\u4FEE\u590D\u300D\uFF0C\u4F60\u662F\u63D0\u5355\u4EBA\uFF0C\u590D\u9A8C\u7ED3\u8BBA\u8BE5\u9000\u56DE\u539F\u5355" : target.reportedByYou === false ? "\u4F60\u7684\u73AF\u5883\u5DF2\u542B\u4FEE\u590D\u4ECD\u590D\u73B0\uFF0C\u7591\u4F3C\u56DE\u5F52\uFF1B\u4F60\u4E0D\u662F\u539F\u5355\u63D0\u5355\u4EBA\u3001\u9000\u4E0D\u4E86\u539F\u5355\uFF0C\u8981\u65B0\u5F00\u5E76\u5F15\u7528\u539F\u5355" : "\u4F60\u7684\u73AF\u5883\u5DF2\u542B\u4FEE\u590D\u4ECD\u590D\u73B0\uFF0C\u7591\u4F3C\u56DE\u5F52\uFF1B\u6309\u4E0B\u4E00\u6B65\u8D70\uFF08\u539F\u5355\u63D0\u5355\u4EBA\u9000\u56DE\u539F\u5355\uFF0C\u4E0D\u662F\u63D0\u5355\u4EBA\u624D\u65B0\u5F00\uFF09";
13474
- throw new CliError30({
13475
- code: CliErrorCode31.BUSINESS_RULE_VIOLATION,
13784
+ throw new CliError31({
13785
+ code: CliErrorCode32.BUSINESS_RULE_VIOLATION,
13476
13786
  message: `\u6CA1\u6709\u5F80 ${parsed.key} \u8FFD\u52A0\uFF1A${why}`,
13477
13787
  context: {
13478
13788
  reasonCode: "append-refused",
@@ -13496,7 +13806,7 @@ async function gapSubmit({ client: client3 }, g, opts) {
13496
13806
  nextStep: `\u6CA1\u6709\u5199 Jira\u3002\u53BB\u6389 --dry-run \u5C31\u4F1A\u5F80 ${parsed.key} \u8FFD\u52A0\u8FD9\u4E00\u6BB5\u300C\u53C8\u4E00\u4E2A\u73B0\u573A\u300D\u3002`
13497
13807
  };
13498
13808
  }
13499
- await client3.addComment(parsed.key, appendBody(g, opts.fingerprint.text, target));
13809
+ await client4.addComment(parsed.key, appendBody(g, opts.fingerprint.text, target));
13500
13810
  return {
13501
13811
  ...base,
13502
13812
  outcome: "appended",
@@ -13517,12 +13827,12 @@ async function gapSubmit({ client: client3 }, g, opts) {
13517
13827
  nextStep: `\u6CA1\u6709\u63D0\u4EA4\u3002${partial}${choose}\uFF1B\u60F3\u5148\u770B\u4F1A\u5199\u4EC0\u4E48\u518D\u52A0 --dry-run\u3002`
13518
13828
  };
13519
13829
  }
13520
- const [types, me, project2] = await Promise.all([client3.createMeta(), who2.myself(), client3.projectInfo()]);
13830
+ const [types, me, project2] = await Promise.all([client4.createMeta(), who2.myself(), client4.projectInfo()]);
13521
13831
  const built = buildGapFields(g, {
13522
13832
  types,
13523
13833
  me: me.name ?? me.key ?? "",
13524
13834
  assignee: opts.assigneeOverride || project2.lead?.name || project2.lead?.key,
13525
- project: client3.project,
13835
+ project: client4.project,
13526
13836
  fingerprintText: opts.fingerprint.text,
13527
13837
  issuetypeOverride: opts.issuetypeOverride,
13528
13838
  dedupeNote: renderDedupeNote(candidates, raw.length)
@@ -13538,42 +13848,42 @@ async function gapSubmit({ client: client3 }, g, opts) {
13538
13848
  nextStep: "\u6CA1\u6709\u5199 Jira\u3002\u53BB\u6389 --dry-run \u5C31\u4F1A\u6309\u4E0A\u9762\u7684\u6982\u8981\u3001\u7C7B\u578B\u548C\u6A21\u5757\u65B0\u5F00\u3002"
13539
13849
  };
13540
13850
  }
13541
- const created = await client3.createIssue(built.fields);
13851
+ const created = await client4.createIssue(built.fields);
13542
13852
  return {
13543
13853
  ...base,
13544
13854
  outcome: "created",
13545
13855
  key: created.key,
13546
- url: client3.browseUrl(created.key),
13856
+ url: client4.browseUrl(created.key),
13547
13857
  summary: built.summary,
13548
13858
  type: built.type.name,
13549
13859
  module: built.module,
13550
13860
  nextStep: `\u7F3A\u53E3\u5DF2\u63D0\uFF0C\u7F16\u53F7 ${created.key}\uFF1B\u5148\u7528\u66FF\u4EE3\u6CD5\u300C${g.alternative}\u300D\u7EE7\u7EED\uFF0C\u4EA7\u54C1\u5206\u8BCA\u540E\u4F1A\u5728\u90A3\u5355\u91CC\u56DE\u590D\u3002\u62A5\u544A\u91CC\u5199\u300CBLOCKED \xB7 \u5DF2\u63D0 ${created.key} \xB7 \u66FF\u4EE3\u6CD5\uFF1A${g.alternative}\u300D\u3002`
13551
13861
  };
13552
13862
  }
13553
- function searchRow(client3, i) {
13863
+ function searchRow(client4, i) {
13554
13864
  const state = i.fields.status?.name, resolution = i.fields.resolution?.name;
13555
13865
  const advice = terminalGapHint({ key: i.key, status: state, resolution });
13556
- return { where: "Jira", id: i.key, title: i.fields.summary ?? "", state, resolution, url: client3.browseUrl(i.key), ...advice ? { advice } : {} };
13866
+ return { where: "Jira", id: i.key, title: i.fields.summary ?? "", state, resolution, url: client4.browseUrl(i.key), ...advice ? { advice } : {} };
13557
13867
  }
13558
- async function gapSearch({ client: client3 }, keywords, { includeClosed = true } = {}) {
13868
+ async function gapSearch({ client: client4 }, keywords, { includeClosed = true } = {}) {
13559
13869
  const rows2 = [];
13560
13870
  let jiraError;
13561
13871
  let truncated;
13562
13872
  try {
13563
13873
  for (const kw of keywords) {
13564
13874
  const safe = kw.replace(/["\\]/g, " ").trim();
13565
- const jql = `project = ${client3.project} AND text ~ "${safe}"${includeClosed ? "" : " AND resolution = Unresolved"} ORDER BY updated DESC`;
13566
- for (const i of await client3.search(jql, { max: 15 })) {
13567
- rows2.push(searchRow(client3, i));
13875
+ const jql = `project = ${client4.project} AND text ~ "${safe}"${includeClosed ? "" : " AND resolution = Unresolved"} ORDER BY updated DESC`;
13876
+ for (const i of await client4.search(jql, { max: 15 })) {
13877
+ rows2.push(searchRow(client4, i));
13568
13878
  }
13569
13879
  }
13570
13880
  if (!rows2.length) {
13571
- const jql = includeClosed ? gapDedupeJql(client3.project) : `project = ${client3.project} AND resolution = Unresolved ORDER BY created DESC`;
13572
- const scope = await client3.searchAll(jql, { fields: ["summary", "status", "resolution"] });
13881
+ const jql = includeClosed ? gapDedupeJql(client4.project) : `project = ${client4.project} AND resolution = Unresolved ORDER BY created DESC`;
13882
+ const scope = await client4.searchAll(jql, { fields: ["summary", "status", "resolution"] });
13573
13883
  if (scope.truncated) truncated = { count: scope.issues.length, total: scope.total };
13574
13884
  for (const i of scope.issues) {
13575
13885
  if (keywords.some((k) => (i.fields.summary ?? "").includes(k))) {
13576
- rows2.push(searchRow(client3, i));
13886
+ rows2.push(searchRow(client4, i));
13577
13887
  }
13578
13888
  }
13579
13889
  }
@@ -13602,11 +13912,11 @@ function lastEnteredStatus(histories, status) {
13602
13912
  }
13603
13913
  var unparseableEntries = (histories, status) => histories.filter((h) => entersStatus(h, status) && !Number.isFinite(Date.parse(h.created ?? ""))).map((h) => String(h.created ?? "\uFF08\u7A7A\uFF09"));
13604
13914
  var PENDING_VERIFY_CONCURRENCY = 4;
13605
- async function gapPendingVerify({ client: client3 }, { now = Date.now(), signal } = {}) {
13606
- const jql = pendingVerifyJql(client3.project);
13915
+ async function gapPendingVerify({ client: client4 }, { now = Date.now(), signal } = {}) {
13916
+ const jql = pendingVerifyJql(client4.project);
13607
13917
  let pre;
13608
13918
  try {
13609
- pre = await client3.searchAll(jql, { fields: ["summary", "status"] });
13919
+ pre = await client4.searchAll(jql, { fields: ["summary", "status"] });
13610
13920
  } catch (e) {
13611
13921
  return {
13612
13922
  complete: false,
@@ -13622,7 +13932,7 @@ async function gapPendingVerify({ client: client3 }, { now = Date.now(), signal
13622
13932
  const undetermined = [];
13623
13933
  const recentlyRefixed = [];
13624
13934
  const judge = async (i) => {
13625
- const base = { key: i.key, summary: i.fields.summary ?? "", url: client3.browseUrl(i.key) };
13935
+ const base = { key: i.key, summary: i.fields.summary ?? "", url: client4.browseUrl(i.key) };
13626
13936
  let reason;
13627
13937
  let fixedAt;
13628
13938
  let bad = [];
@@ -13631,7 +13941,7 @@ async function gapPendingVerify({ client: client3 }, { now = Date.now(), signal
13631
13941
  return;
13632
13942
  }
13633
13943
  try {
13634
- const cl = await client3.changelog(i.key);
13944
+ const cl = await client4.changelog(i.key);
13635
13945
  if (cl.total === null) reason = "Jira \u6CA1\u62A5 changelog \u603B\u6570\uFF0C\u4E0D\u77E5\u9053\u5386\u53F2\u5168\u4E0D\u5168";
13636
13946
  else if (cl.returned < cl.total) reason = `changelog \u53EA\u8FD4\u56DE\u4E86 ${cl.returned}/${cl.total} \u6761\uFF0C\u6700\u540E\u4E00\u6B21\u8FDB\u5165\u300C${FIXED_STATUS}\u300D\u53EF\u80FD\u5728\u6CA1\u8FD4\u56DE\u7684\u90A3\u90E8\u5206\u91CC`;
13637
13947
  else if ((bad = unparseableEntries(cl.histories, FIXED_STATUS)).length) reason = `changelog \u91CC\u6709 ${bad.length} \u6B21\u8FDB\u5165\u300C${FIXED_STATUS}\u300D\u7684\u65F6\u95F4\u8BFB\u4E0D\u51FA\uFF08${bad[0]}\uFF09\uFF0C\u4E0D\u77E5\u9053\u6700\u540E\u4E00\u6B21\u662F\u54EA\u6B21`;
@@ -13693,7 +14003,7 @@ function commentTime(c2, index) {
13693
14003
  function sortComments(cs) {
13694
14004
  return cs.map((c2, i) => ({ c: c2, i, t: commentTime(c2, i) })).sort((a, b) => a.t - b.t || a.i - b.i).map((x) => x.c);
13695
14005
  }
13696
- function toView(client3, key2, c2) {
14006
+ function toView(client4, key2, c2) {
13697
14007
  const { headline, truncated } = commentHeadline(c2.body);
13698
14008
  return {
13699
14009
  id: c2.id,
@@ -13702,22 +14012,22 @@ function toView(client3, key2, c2) {
13702
14012
  author: c2.author?.displayName ?? c2.author?.name ?? "?",
13703
14013
  headline,
13704
14014
  truncated,
13705
- url: c2.id ? client3.commentUrl(key2, c2.id) : void 0
14015
+ url: c2.id ? client4.commentUrl(key2, c2.id) : void 0
13706
14016
  };
13707
14017
  }
13708
- async function gapStatus({ client: client3 }, ref, casesSlug = CASES_REPO_SLUG3) {
13709
- const parsed = parseRef2(ref, client3.project, casesSlug);
14018
+ async function gapStatus({ client: client4 }, ref, casesSlug = CASES_REPO_SLUG3) {
14019
+ const parsed = parseRef2(ref, client4.project, casesSlug);
13710
14020
  if (!parsed) throw new Error(`\u770B\u4E0D\u61C2 ${ref}\uFF1A\u7ED9 Jira \u5355\u53F7\uFF08HCMNX-12\uFF09`);
13711
14021
  if (parsed.kind === "repo") {
13712
14022
  throw new Error(
13713
14023
  `${parsed.repo}#${parsed.number} \u662F\u4EA7\u54C1\u4ED3\u7F16\u53F7\uFF0C\u987E\u95EE\u4FA7\u67E5\u4E0D\u5230\u5B83\u7684\u72B6\u6001\uFF08\u6CA1\u6709\u90A3\u4E2A\u4ED3\u7684\u8BFB\u6743\u9650\uFF09\u3002next_step=\u7528 Jira \u5355\u53F7\u67E5\uFF08HCMNX-12\uFF09\u3002\u4EA7\u54C1\u4FA7\u7684\u8FDB\u5C55\u4F1A\u56DE\u5199\u5230 Jira \u5355\u4E0A\uFF0C\u90A3\u662F\u4EA7\u54C1\u5BF9\u5916\u7684\u7EDF\u4E00\u9762\u3002`
13714
14024
  );
13715
14025
  }
13716
- const issue = await client3.issue(parsed.key);
13717
- const cs = sortComments(await client3.comments(parsed.key));
14026
+ const issue = await client4.issue(parsed.key);
14027
+ const cs = sortComments(await client4.comments(parsed.key));
13718
14028
  const status = issue.fields.status?.name;
13719
14029
  const resolution = issue.fields.resolution?.name;
13720
- const lines = [`Jira ${issue.key} [${status}${resolution ? "\xB7" + resolution : ""}${issue.fields.priority ? " " + issue.fields.priority.name : ""}] ${issue.fields.summary ?? ""}`, ` ${client3.browseUrl(issue.key)}`];
14030
+ const lines = [`Jira ${issue.key} [${status}${resolution ? "\xB7" + resolution : ""}${issue.fields.priority ? " " + issue.fields.priority.name : ""}] ${issue.fields.summary ?? ""}`, ` ${client4.browseUrl(issue.key)}`];
13721
14031
  const productRaw = [...cs].reverse().find((c2) => PRODUCT_HANDLING_KEYWORDS.test(c2.body ?? ""));
13722
14032
  const latestRaw = cs.at(-1);
13723
14033
  const fullText = `\u5168\u6587\uFF1A\`hcm chiron gap comments ${issue.key}\``;
@@ -13730,11 +14040,11 @@ async function gapStatus({ client: client3 }, ref, casesSlug = CASES_REPO_SLUG3)
13730
14040
  let latestComment;
13731
14041
  let sameAsProduct;
13732
14042
  if (productRaw) {
13733
- latestProductComment = toView(client3, issue.key, productRaw);
14043
+ latestProductComment = toView(client4, issue.key, productRaw);
13734
14044
  latestProductComment.matchedKeyword = PRODUCT_HANDLING_KEYWORDS.exec(productRaw.body ?? "")?.[0];
13735
14045
  }
13736
14046
  if (latestRaw) {
13737
- latestComment = toView(client3, issue.key, latestRaw);
14047
+ latestComment = toView(client4, issue.key, latestRaw);
13738
14048
  sameAsProduct = !!productRaw && productRaw === latestRaw;
13739
14049
  if (!isAutoNotice(latestRaw.body)) latestComment.signal = classifyFollowUp(latestComment.headline);
13740
14050
  }
@@ -13747,7 +14057,7 @@ async function gapStatus({ client: client3 }, ref, casesSlug = CASES_REPO_SLUG3)
13747
14057
  if (latestComment) lines.push(...render2(`\u6700\u65B0\u8BC4\u8BBA\uFF08${stamp(latestComment)}\uFF09`, latestComment));
13748
14058
  }
13749
14059
  if (!latestComment) lines.push(" \u8FD8\u6CA1\u6709\u4EBA\u5904\u7406\uFF08\u4EA7\u54C1\u4FA7\u6BCF\u5468\u6E05\u4E00\u6B21\uFF1B\u963B\u65AD\u7EA7\u8BF7\u5728\u9879\u76EE\u7FA4\u91CC\u70B9\u540D\u8D1F\u8D23\u4EBA\uFF09");
13750
- const remote = (await client3.remoteLinks(parsed.key)).map((l) => l.object?.url ?? "").join("\n");
14060
+ const remote = (await client4.remoteLinks(parsed.key)).map((l) => l.object?.url ?? "").join("\n");
13751
14061
  const links = linkedRepoRefs(`${remote}
13752
14062
  ${issue.fields.description ?? ""}
13753
14063
  ${cs.map((c2) => c2.body ?? "").join("\n")}`).map((l) => ({
@@ -13798,21 +14108,21 @@ ${cs.map((c2) => c2.body ?? "").join("\n")}`).map((l) => ({
13798
14108
  if (!sameAsProduct) nextStep += ` \u53E6\uFF1A\u6709\u4E00\u6761\u6BD4\u4EA7\u54C1\u4FA7\u5904\u7406\u66F4\u65B0\u7684\u8BC4\u8BBA\u2014\u2014${cite}${tail}\uFF0C\u5148\u770B\u5B83\u3002`;
13799
14109
  }
13800
14110
  }
13801
- return { ref, lines, nextStep, jira: { key: issue.key, status, resolution, url: client3.browseUrl(issue.key) }, links, latestProductComment, latestComment, sameAsProduct };
14111
+ return { ref, lines, nextStep, jira: { key: issue.key, status, resolution, url: client4.browseUrl(issue.key) }, links, latestProductComment, latestComment, sameAsProduct };
13802
14112
  }
13803
- async function gapComments({ client: client3 }, ref, { limit } = {}, casesSlug = CASES_REPO_SLUG3) {
13804
- const parsed = parseRef2(ref, client3.project, casesSlug);
14113
+ async function gapComments({ client: client4 }, ref, { limit } = {}, casesSlug = CASES_REPO_SLUG3) {
14114
+ const parsed = parseRef2(ref, client4.project, casesSlug);
13805
14115
  if (!parsed) throw new Error(`\u770B\u4E0D\u61C2 ${ref}\uFF1A\u7ED9 Jira \u5355\u53F7\uFF08HCMNX-12\uFF09`);
13806
14116
  if (parsed.kind === "repo") {
13807
14117
  throw new Error(`${parsed.repo}#${parsed.number} \u662F\u4EA7\u54C1\u4ED3\u7F16\u53F7\uFF0C\u987E\u95EE\u4FA7\u8BFB\u4E0D\u5230\u5B83\u7684\u8BC4\u8BBA\uFF08\u6CA1\u6709\u90A3\u4E2A\u4ED3\u7684\u8BFB\u6743\u9650\uFF09\u3002next_step=\u7528 Jira \u5355\u53F7\uFF08HCMNX-12\uFF09\u3002`);
13808
14118
  }
13809
14119
  if (limit !== void 0 && (!Number.isInteger(limit) || limit < 1)) throw new Error(`--limit \u8981\u662F\u6B63\u6574\u6570\uFF0C\u7ED9\u7684\u662F ${String(limit)}`);
13810
- const all = sortComments(await client3.comments(parsed.key));
14120
+ const all = sortComments(await client4.comments(parsed.key));
13811
14121
  const picked = limit !== void 0 ? all.slice(-limit) : all;
13812
14122
  return {
13813
14123
  ref,
13814
14124
  key: parsed.key,
13815
- url: client3.browseUrl(parsed.key),
14125
+ url: client4.browseUrl(parsed.key),
13816
14126
  total: all.length,
13817
14127
  shown: picked.length,
13818
14128
  comments: picked.map((c2) => ({
@@ -13821,7 +14131,7 @@ async function gapComments({ client: client3 }, ref, { limit } = {}, casesSlug =
13821
14131
  when: commentWhen(c2.created),
13822
14132
  author: c2.author?.displayName ?? c2.author?.name ?? "?",
13823
14133
  body: (c2.body ?? "").trim(),
13824
- url: c2.id ? client3.commentUrl(parsed.key, c2.id) : void 0
14134
+ url: c2.id ? client4.commentUrl(parsed.key, c2.id) : void 0
13825
14135
  }))
13826
14136
  };
13827
14137
  }
@@ -13832,7 +14142,7 @@ async function gapDeps(deps) {
13832
14142
  return { client: await deps.client() };
13833
14143
  }
13834
14144
  function emit5(fmt, data, text) {
13835
- if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject27(data, { format: fmt }) + "\n");
14145
+ if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject28(data, { format: fmt }) + "\n");
13836
14146
  else process.stdout.write(text() + "\n");
13837
14147
  }
13838
14148
  async function run2(fn) {
@@ -14008,7 +14318,7 @@ function readEvidence(opts, stdinIsTTY = !!process.stdin.isTTY, readStdin2 = ()
14008
14318
  if (opts.file !== void 0 && opts.body !== void 0) {
14009
14319
  throw verifyFailure(
14010
14320
  "evidence-ambiguous",
14011
- CliErrorCode32.INVALID_ARGUMENT,
14321
+ CliErrorCode33.INVALID_ARGUMENT,
14012
14322
  "no",
14013
14323
  "--body \u4E0E --file \u540C\u65F6\u7ED9\u4E86\uFF0C\u4E0D\u77E5\u9053\u8BE5\u7528\u54EA\u4EFD\u505A\u9A8C\u6536\u8BC1\u636E",
14014
14324
  "\u53EA\u7559\u4E00\u4E2A\uFF1A\u77ED\u8BC1\u636E\u7528 --body\uFF0C\u957F\u8BC1\u636E\u5199\u8FDB\u6587\u4EF6\u7528 --file\u3002"
@@ -14020,7 +14330,7 @@ function readEvidence(opts, stdinIsTTY = !!process.stdin.isTTY, readStdin2 = ()
14020
14330
  } catch (e) {
14021
14331
  throw verifyFailure(
14022
14332
  "evidence-unreadable",
14023
- CliErrorCode32.INVALID_ARGUMENT,
14333
+ CliErrorCode33.INVALID_ARGUMENT,
14024
14334
  "no",
14025
14335
  `\u8BFB\u4E0D\u5230\u8BC1\u636E\u6587\u4EF6 ${opts.file}`,
14026
14336
  "\u6838\u5BF9\u8DEF\u5F84\u4E0E\u6743\u9650\uFF1B\u8BC1\u636E\u6587\u4EF6\u4E00\u822C\u653E\u5728\u9879\u76EE\u4ED3\u7684 evidence/ \u4E0B\u3002",
@@ -14033,7 +14343,7 @@ function readEvidence(opts, stdinIsTTY = !!process.stdin.isTTY, readStdin2 = ()
14033
14343
  if (stdinIsTTY) {
14034
14344
  throw verifyFailure(
14035
14345
  "evidence-missing",
14036
- CliErrorCode32.INVALID_ARGUMENT,
14346
+ CliErrorCode33.INVALID_ARGUMENT,
14037
14347
  "no",
14038
14348
  "\u6CA1\u7ED9\u9A8C\u6536\u8BC1\u636E",
14039
14349
  "\u7528 --body <\u6587\u672C> \u6216 --file <\u6587\u4EF6> \u7ED9\u51FA\uFF1A\u54EA\u4E2A\u73AF\u5883\u3001\u54EA\u4E2A\u7248\u672C\u3001\u6309\u6280\u80FD\u8DD1\u4E86\u4EC0\u4E48\u3001\u770B\u5230\u4E86\u4EC0\u4E48\u3002"
@@ -14093,9 +14403,9 @@ import { promises as fs13 } from "fs";
14093
14403
  import path15 from "path";
14094
14404
  import axios10 from "axios";
14095
14405
  import {
14096
- CliError as CliError36,
14097
- CliErrorCode as CliErrorCode37,
14098
- formatObject as formatObject30,
14406
+ CliError as CliError37,
14407
+ CliErrorCode as CliErrorCode38,
14408
+ formatObject as formatObject31,
14099
14409
  httpProbe as httpProbe2,
14100
14410
  listEnvs as listEnvs2,
14101
14411
  loadGlobalConfig as loadGlobalConfig12,
@@ -14119,12 +14429,12 @@ import yaml from "js-yaml";
14119
14429
  import {
14120
14430
  AUTH_INFO_PATH as AUTH_INFO_PATH2,
14121
14431
  assertNotReservedEnvName as assertNotReservedEnvName3,
14122
- CliError as CliError31,
14123
- CliErrorCode as CliErrorCode33,
14432
+ CliError as CliError32,
14433
+ CliErrorCode as CliErrorCode34,
14124
14434
  discoverProjectEnv as discoverProjectEnv6,
14125
14435
  ENV_FILE as ENV_FILE2,
14126
14436
  findEnvByEndpoint as findEnvByEndpoint5,
14127
- formatObject as formatObject28,
14437
+ formatObject as formatObject29,
14128
14438
  listIdentities as listIdentities6,
14129
14439
  parseEnvYaml as parseEnvYaml2,
14130
14440
  renderEnvYaml as renderEnvYaml2,
@@ -14143,7 +14453,7 @@ function summarizeReasons(reasons) {
14143
14453
  return reasons.length === 1 ? reasons[0] : `${reasons[0]} \u7B49 ${reasons.length} \u6761\uFF08--output json \u770B\u5168\u90E8\uFF09`;
14144
14454
  }
14145
14455
  function invalid2(message, nextStep) {
14146
- throw new CliError31({ code: CliErrorCode33.INVALID_ARGUMENT, message, context: { nextStep } });
14456
+ throw new CliError32({ code: CliErrorCode34.INVALID_ARGUMENT, message, context: { nextStep } });
14147
14457
  }
14148
14458
  function required(value, label) {
14149
14459
  if (!value?.trim()) invalid2(`${label} \u4E0D\u80FD\u4E3A\u7A7A\uFF1B\u914D\u7F6E\u672A\u5199\u5165\u3002`, `\u8BF7\u63D0\u4F9B\u975E\u7A7A\u7684 ${label}`);
@@ -14330,7 +14640,7 @@ async function runChironEnv(action, args = {}) {
14330
14640
  return report;
14331
14641
  }
14332
14642
  function formatChironEnvReport(report, output = "table") {
14333
- if (output !== "table") return formatObject28(report, { format: output });
14643
+ if (output !== "table") return formatObject29(report, { format: output });
14334
14644
  const lines = [
14335
14645
  report.action === "list" ? `\u9879\u76EE\u73AF\u5883\uFF1A${report.path}` : `\u5DF2\u5199\u5165\uFF1A${report.path}`,
14336
14646
  formatTable(report.environments.map((env2) => ({
@@ -14367,8 +14677,8 @@ import os5 from "os";
14367
14677
  import path13 from "path";
14368
14678
  import yaml2 from "js-yaml";
14369
14679
  import {
14370
- CliError as CliError32,
14371
- CliErrorCode as CliErrorCode34,
14680
+ CliError as CliError33,
14681
+ CliErrorCode as CliErrorCode35,
14372
14682
  METHOD_REPO_DISPLAY,
14373
14683
  METHOD_REPO_URL,
14374
14684
  assertSafeSkillId as assertSafeSkillId2,
@@ -14376,7 +14686,7 @@ import {
14376
14686
  discoverProjectEnv as discoverProjectEnv7,
14377
14687
  fetchSkillCatalog as fetchSkillCatalog2,
14378
14688
  flattenSkills as flattenSkills2,
14379
- formatObject as formatObject29,
14689
+ formatObject as formatObject30,
14380
14690
  parseSkillFrontmatter as parseSkillFrontmatter3,
14381
14691
  resolveChironBase as resolveChironBase2
14382
14692
  } from "@hcmai/sdk";
@@ -14409,8 +14719,8 @@ function gitErrorText(e) {
14409
14719
  function classifyGitFailure(e, repoDisplay) {
14410
14720
  const err = e;
14411
14721
  if (err.code === "ENOENT") {
14412
- return new CliError32({
14413
- code: CliErrorCode34.METHOD_GIT_UNAVAILABLE,
14722
+ return new CliError33({
14723
+ code: CliErrorCode35.METHOD_GIT_UNAVAILABLE,
14414
14724
  message: "\u672C\u673A\u627E\u4E0D\u5230 git\uFF0C\u53D6\u65B9\u6CD5\u5305\u9760\u5B83",
14415
14725
  context: { nextStep: "\u88C5\u4E0A git\uFF08`git --version` \u80FD\u8DD1\u901A\uFF09\uFF0C\u518D\u91CD\u8DD1\u8FD9\u6761\u547D\u4EE4" }
14416
14726
  });
@@ -14418,15 +14728,15 @@ function classifyGitFailure(e, repoDisplay) {
14418
14728
  const text = gitErrorText(e);
14419
14729
  const head = text.split("\n").filter(Boolean).slice(-3).join(" / ").slice(0, 400);
14420
14730
  if (err.code === "ETIMEDOUT" || err.signal === "SIGTERM") {
14421
- return new CliError32({
14422
- code: CliErrorCode34.METHOD_SOURCE_NETWORK,
14731
+ return new CliError33({
14732
+ code: CliErrorCode35.METHOD_SOURCE_NETWORK,
14423
14733
  message: `git \u5728\u65F6\u9650\u5185\u6CA1\u6709\u8FD4\u56DE\uFF08${repoDisplay}\uFF09`,
14424
14734
  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" }
14425
14735
  });
14426
14736
  }
14427
14737
  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)) {
14428
- return new CliError32({
14429
- code: CliErrorCode34.METHOD_SOURCE_AUTH_REQUIRED,
14738
+ return new CliError33({
14739
+ code: CliErrorCode35.METHOD_SOURCE_AUTH_REQUIRED,
14430
14740
  message: `\u65B9\u6CD5\u8BBA\u4ED3\u8981\u8BA4\u8BC1\uFF0C\u672C\u673A\u6CA1\u6709\u53EF\u7528\u7684 git \u51ED\u636E\uFF08${repoDisplay}\uFF09\uFF1A${head}`,
14431
14741
  context: { nextStep: "`cnb login` \u4E4B\u540E\u91CD\u8DD1\u3002\u65B9\u6CD5\u5305\u8D70\u7684\u662F git \u51ED\u636E\uFF0C\u4E0D\u662F `hcm login`" }
14432
14742
  });
@@ -14434,8 +14744,8 @@ function classifyGitFailure(e, repoDisplay) {
14434
14744
  const notFound = /returned error: 404|Repository not found|repository '.*' not found|does not appear to be a git repository/i.test(text);
14435
14745
  if (/returned error: 403|403 Forbidden|access denied|not authorized/i.test(text) || notFound) {
14436
14746
  const overridden = Boolean(process.env.HCM_METHOD_REPO?.trim() || process.env.HCM_METHOD_REPO_URL?.trim());
14437
- return new CliError32({
14438
- code: CliErrorCode34.METHOD_SOURCE_FORBIDDEN,
14747
+ return new CliError33({
14748
+ code: CliErrorCode35.METHOD_SOURCE_FORBIDDEN,
14439
14749
  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" : ""),
14440
14750
  context: {
14441
14751
  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" : "")
@@ -14443,14 +14753,14 @@ function classifyGitFailure(e, repoDisplay) {
14443
14753
  });
14444
14754
  }
14445
14755
  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)) {
14446
- return new CliError32({
14447
- code: CliErrorCode34.METHOD_SOURCE_NETWORK,
14756
+ return new CliError33({
14757
+ code: CliErrorCode35.METHOD_SOURCE_NETWORK,
14448
14758
  message: `\u8FDE\u4E0D\u4E0A\u65B9\u6CD5\u8BBA\u4ED3\uFF08${repoDisplay}\uFF09\uFF1A${head}`,
14449
14759
  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" }
14450
14760
  });
14451
14761
  }
14452
- return new CliError32({
14453
- code: CliErrorCode34.METHOD_SOURCE_GIT_FAILED,
14762
+ return new CliError33({
14763
+ code: CliErrorCode35.METHOD_SOURCE_GIT_FAILED,
14454
14764
  message: `git \u5931\u8D25\u4E86\uFF0C\u539F\u56E0\u4E0D\u5728\u8BA4\u8BC1 / \u6743\u9650 / \u7F51\u7EDC\u4E09\u7C7B\u91CC\uFF08${repoDisplay}\uFF09\uFF1A${head}`,
14455
14765
  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` }
14456
14766
  });
@@ -14554,8 +14864,8 @@ function resolveRef(tags, ref, deps) {
14554
14864
  if (ref === void 0) {
14555
14865
  const latest = versions[0];
14556
14866
  if (!latest) {
14557
- throw new CliError32({
14558
- code: CliErrorCode34.METHOD_REF_NOT_FOUND,
14867
+ throw new CliError33({
14868
+ code: CliErrorCode35.METHOD_REF_NOT_FOUND,
14559
14869
  message: `\u65B9\u6CD5\u8BBA\u4ED3 ${deps.repoDisplay} \u91CC\u4E00\u4E2A vX.Y.Z \u5F62\u5F0F\u7684\u7248\u672C tag \u90FD\u6CA1\u6709`,
14560
14870
  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" }
14561
14871
  });
@@ -14564,8 +14874,8 @@ function resolveRef(tags, ref, deps) {
14564
14874
  }
14565
14875
  const name = tags.has(ref) ? ref : tags.has(`v${ref}`) ? `v${ref}` : void 0;
14566
14876
  if (!name) {
14567
- throw new CliError32({
14568
- code: CliErrorCode34.METHOD_REF_NOT_FOUND,
14877
+ throw new CliError33({
14878
+ code: CliErrorCode35.METHOD_REF_NOT_FOUND,
14569
14879
  message: `\u65B9\u6CD5\u8BBA\u4ED3 ${deps.repoDisplay} \u91CC\u6CA1\u6709 tag ${ref}`,
14570
14880
  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" }
14571
14881
  });
@@ -14573,8 +14883,8 @@ function resolveRef(tags, ref, deps) {
14573
14883
  return { ref: name, commit: tags.get(name) };
14574
14884
  }
14575
14885
  function invalidPackage(field, message) {
14576
- return new CliError32({
14577
- code: CliErrorCode34.METHOD_PACKAGE_INVALID,
14886
+ return new CliError33({
14887
+ code: CliErrorCode35.METHOD_PACKAGE_INVALID,
14578
14888
  message: `\u65B9\u6CD5\u5305\u6E05\u5355 package.yml \u4E0D\u5408\u683C\uFF1A${message}`,
14579
14889
  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" }
14580
14890
  });
@@ -14598,8 +14908,8 @@ function parsePackageManifest(text) {
14598
14908
  throw invalidPackage("schemaVersion", "\u7F3A schemaVersion\uFF08\u6574\u6570\uFF09");
14599
14909
  }
14600
14910
  if (!KNOWN_PACKAGE_SCHEMA_VERSIONS.includes(m.schemaVersion)) {
14601
- throw new CliError32({
14602
- code: CliErrorCode34.METHOD_PACKAGE_SCHEMA_UNSUPPORTED,
14911
+ throw new CliError33({
14912
+ code: CliErrorCode35.METHOD_PACKAGE_SCHEMA_UNSUPPORTED,
14603
14913
  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(" / ")}`,
14604
14914
  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" }
14605
14915
  });
@@ -14813,7 +15123,7 @@ async function checkMethodConflicts(methodIds, root, online, deps) {
14813
15123
  b.conflicts = b.compared.filter((id) => wanted.has(id)).map((id) => ({ id, other: where }));
14814
15124
  }
14815
15125
  } catch (e) {
14816
- const reason = e instanceof CliError32 && typeof e.context?.reason === "string" ? `\uFF1A${e.context.reason}` : "";
15126
+ const reason = e instanceof CliError33 && typeof e.context?.reason === "string" ? `\uFF1A${e.context.reason}` : "";
14817
15127
  b.note = `\u53D6\u4E0D\u5230 ${online.endpoint} \u7684\u5728\u7EBF\u76EE\u5F55\uFF08${e.message.split("\n")[0]}${reason}\uFF09\uFF0C\u5728\u7EBF\u76EE\u5F55\u672A\u6BD4\u5BF9`;
14818
15128
  }
14819
15129
  }
@@ -14836,8 +15146,8 @@ function renderConflictBlocks(blocks) {
14836
15146
  }
14837
15147
  function conflictError(blocks, pkg, commit) {
14838
15148
  const hits = blocks.flatMap((b) => b.conflicts);
14839
- return new CliError32({
14840
- code: CliErrorCode34.SKILL_ID_CONFLICT,
15149
+ return new CliError33({
15150
+ code: CliErrorCode35.SKILL_ID_CONFLICT,
14841
15151
  message: "\u65B9\u6CD5\u5305\u91CC\u7684\u6280\u80FD id \u4E0E\u5DF2\u6709\u6765\u6E90\u540C\u540D\uFF0C\u62D2\u88C5\uFF1A\n" + hits.map((c2) => ` \xB7 \`${c2.id}\`\uFF1A\u65B9\u6CD5 ${pkg.version} @${commit.slice(0, 12)} \u2194 ${c2.other}`).join("\n") + "\n\u672C\u8D9F\u51B2\u7A81\u68C0\u67E5\uFF1A\n" + renderConflictBlocks(blocks).join("\n"),
14842
15152
  context: {
14843
15153
  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`,
@@ -14852,8 +15162,8 @@ function upsertManagedBlock(existing, begin, end, block, label) {
14852
15162
  const finish = existing.indexOf(end);
14853
15163
  const malformed = start < 0 !== finish < 0 || start >= 0 && (finish < start || existing.lastIndexOf(begin) !== start || existing.lastIndexOf(end) !== finish);
14854
15164
  if (malformed) {
14855
- throw new CliError32({
14856
- code: CliErrorCode34.METHOD_MANAGED_BLOCK_CORRUPT,
15165
+ throw new CliError33({
15166
+ code: CliErrorCode35.METHOD_MANAGED_BLOCK_CORRUPT,
14857
15167
  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`,
14858
15168
  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` }
14859
15169
  });
@@ -14917,8 +15227,8 @@ async function readLock(root) {
14917
15227
  if (e.code === "ENOENT") return void 0;
14918
15228
  throw e;
14919
15229
  }
14920
- const bad = (why) => new CliError32({
14921
- code: CliErrorCode34.METHOD_LOCK_INVALID,
15230
+ const bad = (why) => new CliError33({
15231
+ code: CliErrorCode35.METHOD_LOCK_INVALID,
14922
15232
  message: `\u9501\u6587\u4EF6 ${METHOD_DIR}/${METHOD_LOCK_FILE} \u8BFB\u4E0D\u61C2\uFF1A${why}`,
14923
15233
  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`" }
14924
15234
  });
@@ -14958,7 +15268,7 @@ async function resolveMethodRoot(project2, log) {
14958
15268
  async function resolveTarget(root, requested) {
14959
15269
  if (requested === "claude" || requested === "codex") return requested;
14960
15270
  if (requested !== void 0 && requested !== "auto") {
14961
- throw new CliError32({ code: CliErrorCode34.INVALID_ARGUMENT, message: `--target \u53EA\u8BA4 claude / codex / auto\uFF0C\u6536\u5230 ${requested}` });
15271
+ throw new CliError33({ code: CliErrorCode35.INVALID_ARGUMENT, message: `--target \u53EA\u8BA4 claude / codex / auto\uFF0C\u6536\u5230 ${requested}` });
14962
15272
  }
14963
15273
  return (await readState(root))?.target ?? await detectTarget(root) ?? "claude";
14964
15274
  }
@@ -15100,8 +15410,8 @@ async function runMethodPipeline(input, deps) {
15100
15410
  const tags = await listRemoteTags(deps);
15101
15411
  const r = resolveRef(tags, input.ref, deps);
15102
15412
  if (input.expectCommit && r.commit !== input.expectCommit) {
15103
- throw new CliError32({
15104
- code: CliErrorCode34.METHOD_TAG_MOVED,
15413
+ throw new CliError33({
15414
+ code: CliErrorCode35.METHOD_TAG_MOVED,
15105
15415
  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`,
15106
15416
  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" }
15107
15417
  });
@@ -15116,8 +15426,8 @@ async function runMethodPipeline(input, deps) {
15116
15426
  await deps.git(["clone", "--depth", "1", "--filter=blob:none", "--sparse", "--quiet", "--branch", resolved.ref, deps.repoUrl, checkout]);
15117
15427
  const head = (await deps.git(["-C", checkout, "rev-parse", "HEAD"], { timeoutMs: 1e4 })).trim();
15118
15428
  if (head !== resolved.commit) {
15119
- throw new CliError32({
15120
- code: CliErrorCode34.METHOD_TAG_MOVED,
15429
+ throw new CliError33({
15430
+ code: CliErrorCode35.METHOD_TAG_MOVED,
15121
15431
  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`,
15122
15432
  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" }
15123
15433
  });
@@ -15296,7 +15606,7 @@ async function runMethodStatus(root, deps, opts = {}) {
15296
15606
  verdict: "fail",
15297
15607
  detail: `\u6CA1\u6709 ${METHOD_DIR}/${METHOD_LOCK_FILE}\uFF1A\u8FD9\u4E2A\u9879\u76EE\u8FD8\u6CA1\u88C5\u65B9\u6CD5\u5305`,
15298
15608
  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",
15299
- code: CliErrorCode34.METHOD_NOT_INSTALLED
15609
+ code: CliErrorCode35.METHOD_NOT_INSTALLED
15300
15610
  });
15301
15611
  return done();
15302
15612
  }
@@ -15310,7 +15620,7 @@ async function runMethodStatus(root, deps, opts = {}) {
15310
15620
  verdict: "fail",
15311
15621
  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",
15312
15622
  nextStep: "`hcm chiron method install`\uFF08\u6309\u9501\u6587\u4EF6\u7684\u7248\u672C\u88C5\uFF09",
15313
- code: CliErrorCode34.METHOD_NOT_INSTALLED
15623
+ code: CliErrorCode35.METHOD_NOT_INSTALLED
15314
15624
  });
15315
15625
  } else {
15316
15626
  report.installed.present = true;
@@ -15321,7 +15631,7 @@ async function runMethodStatus(root, deps, opts = {}) {
15321
15631
  verdict: "fail",
15322
15632
  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",
15323
15633
  nextStep: "`hcm chiron method install`\uFF08\u6309\u9501\u6587\u4EF6\u7684 commit \u91CD\u88C5\uFF09",
15324
- code: CliErrorCode34.METHOD_DIGEST_MISMATCH
15634
+ code: CliErrorCode35.METHOD_DIGEST_MISMATCH
15325
15635
  });
15326
15636
  } else {
15327
15637
  report.rows.push({ item: "\u5B89\u88C5", verdict: "ok", detail: `\u672C\u673A\u526F\u672C\u5C31\u662F\u9501\u5B9A\u7684\u90A3\u4E00\u7248\uFF08${path13.join(root, METHOD_DIR)}/\uFF09` });
@@ -15365,13 +15675,13 @@ async function runMethodStatus(root, deps, opts = {}) {
15365
15675
  verdict: "fail",
15366
15676
  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}`,
15367
15677
  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-*/`",
15368
- code: CliErrorCode34.METHOD_DIGEST_MISMATCH
15678
+ code: CliErrorCode35.METHOD_DIGEST_MISMATCH
15369
15679
  } : {
15370
15680
  item: "\u6458\u8981",
15371
15681
  verdict: "fail",
15372
15682
  detail: `${bad.length} \u4EFD\u6587\u4EF6\u4E0E\u6E05\u5355\u4E0D\u7B26\uFF1A${listing}`,
15373
15683
  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",
15374
- code: CliErrorCode34.METHOD_DIGEST_MISMATCH
15684
+ code: CliErrorCode35.METHOD_DIGEST_MISMATCH
15375
15685
  });
15376
15686
  } else {
15377
15687
  report.rows.push({
@@ -15394,7 +15704,7 @@ async function runMethodStatus(root, deps, opts = {}) {
15394
15704
  verdict: "warn",
15395
15705
  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`,
15396
15706
  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>`",
15397
- code: CliErrorCode34.METHOD_TAG_MOVED
15707
+ code: CliErrorCode35.METHOD_TAG_MOVED
15398
15708
  });
15399
15709
  } else if (!SEMVER_TAG.test(lock.ref) || !report.remote.latestTag) {
15400
15710
  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";
@@ -15439,7 +15749,7 @@ async function runMethodStatus(root, deps, opts = {}) {
15439
15749
  const hits = report.conflictCheck.flatMap((b) => b.conflicts);
15440
15750
  const unchecked = report.conflictCheck.filter((b) => !b.checked);
15441
15751
  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((c2) => c2.id).join("\u3001")}` : "\uFF0C\u65E0\u540C\u540D"}` : `${b.label}\uFF1A\u672A\u6BD4\u5BF9\uFF08${b.note}\uFF09`).join("\uFF1B");
15442
- 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: CliErrorCode34.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 });
15752
+ 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: CliErrorCode35.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 });
15443
15753
  }
15444
15754
  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" });
15445
15755
  return done();
@@ -15458,10 +15768,10 @@ async function inspectMethodForDoctor(root, deps = quietDeps()) {
15458
15768
  const row = (item) => s.rows.find((r) => r.item === item);
15459
15769
  const lockRow = row("\u9501\u5B9A");
15460
15770
  if (!s.lock) {
15461
- return lockRow.code === CliErrorCode34.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 };
15771
+ return lockRow.code === CliErrorCode35.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 };
15462
15772
  }
15463
15773
  const install = row("\u5B89\u88C5");
15464
- if (install?.code === CliErrorCode34.METHOD_NOT_INSTALLED) {
15774
+ if (install?.code === CliErrorCode35.METHOD_NOT_INSTALLED) {
15465
15775
  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" };
15466
15776
  }
15467
15777
  const local = [install, row("\u6458\u8981")].find((r) => r && r.verdict === "fail");
@@ -15478,7 +15788,7 @@ function quietDeps() {
15478
15788
  } };
15479
15789
  }
15480
15790
  function emit6(output, data, text) {
15481
- if (output === "json" || output === "yaml") process.stdout.write(formatObject29(data, { format: output }) + "\n");
15791
+ if (output === "json" || output === "yaml") process.stdout.write(formatObject30(data, { format: output }) + "\n");
15482
15792
  else process.stdout.write(text() + "\n");
15483
15793
  }
15484
15794
  async function runMethodInstall(args, deps = defaultMethodDeps()) {
@@ -15494,8 +15804,8 @@ async function runMethodUpdate(args, deps = defaultMethodDeps()) {
15494
15804
  const { root, rootSource } = await resolveMethodRoot(args.project, deps.log);
15495
15805
  const lock = await readLock(root);
15496
15806
  if (!lock) {
15497
- throw new CliError32({
15498
- code: CliErrorCode34.METHOD_NOT_INSTALLED,
15807
+ throw new CliError33({
15808
+ code: CliErrorCode35.METHOD_NOT_INSTALLED,
15499
15809
  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`,
15500
15810
  context: { nextStep: "`hcm chiron method install`\uFF08\u88C5\u6700\u65B0\u7684\u7248\u672C tag\uFF09" }
15501
15811
  });
@@ -15545,7 +15855,7 @@ async function methodStatusCommand(args) {
15545
15855
  import { promises as fs12 } from "fs";
15546
15856
  import path14 from "path";
15547
15857
  import axios6 from "axios";
15548
- import { CliError as CliError33, CliErrorCode as CliErrorCode35, fetchSkillCatalog as fetchSkillCatalog3, fetchSkillMarkdown as fetchSkillMarkdown2, fetchSkillReference as fetchSkillReference2, normalizeReferences as normalizeReferences2, normalizeOrigin as normalizeOrigin6, resolveChironBase as resolveChironBase3 } from "@hcmai/sdk";
15858
+ import { CliError as CliError34, CliErrorCode as CliErrorCode36, fetchSkillCatalog as fetchSkillCatalog3, fetchSkillMarkdown as fetchSkillMarkdown2, fetchSkillReference as fetchSkillReference2, normalizeReferences as normalizeReferences2, normalizeOrigin as normalizeOrigin6, resolveChironBase as resolveChironBase3 } from "@hcmai/sdk";
15549
15859
 
15550
15860
  // src/commands/doctor/result.ts
15551
15861
  import { createHash as createHash7 } from "crypto";
@@ -15730,7 +16040,7 @@ async function inspectSkillsFresh(states, endpoint, signal) {
15730
16040
  const entries = plans.flatMap((p) => p.plan.entries);
15731
16041
  return classifySkillFreshness(states.length, entries, plans.flatMap((p) => p.mismatched));
15732
16042
  } catch (error) {
15733
- if (error instanceof CliError33 && error.code === CliErrorCode35.SKILL_CATALOG_UNAVAILABLE) {
16043
+ if (error instanceof CliError34 && error.code === CliErrorCode36.SKILL_CATALOG_UNAVAILABLE) {
15734
16044
  const reason = typeof error.context?.reason === "string" ? `\uFF1A${error.context.reason}` : "";
15735
16045
  const next = typeof error.context?.nextStep === "string" ? error.context.nextStep : void 0;
15736
16046
  return unknown("SKILLS_CATALOG_UNAVAILABLE", `\u670D\u52A1\u7AEF\u6280\u80FD\u76EE\u5F55\u4E0D\u53EF\u7528\uFF08${error.message}${reason}\uFF09\uFF0C\u672C\u8F6E\u6CA1\u6CD5\u5BF9\u8D26`, next ? { note: next } : {});
@@ -15772,6 +16082,7 @@ var method = async (ctx) => {
15772
16082
  return (code2 === "METHOD_UNCHECKED" ? unknown : found)(code2, status.detail, { note: status.nextStep });
15773
16083
  };
15774
16084
  function caseFailureAdvice(reason, timedOut) {
16085
+ if (/找不到 cnb 可执行文件|起不来 cnb/.test(reason ?? "")) return "\u88C5 cnb\uFF08npm i -g @cnbcool/cnb-cli\uFF09\u6216\u68C0\u67E5 PATH\uFF0C\u88C5\u574F\u4E86\u5C31\u91CD\u88C5\uFF08Windows \u4E0A\u9700 cnb.exe \u6216\u5305\u7BA1\u7406\u5668\u751F\u6210\u7684 cnb.cmd\uFF09";
15775
16086
  if (timedOut || /ECONN\w*|ENOTFOUND|EAI_AGAIN|ETIMEDOUT|fetch failed|socket|TLS/i.test(reason ?? "")) return "\u67E5\u7F51\u7EDC\u6216\u4EE3\u7406\u540E\u91CD\u8DD1";
15776
16087
  if (/登录凭证|cnb login|\b401\b|\b403\b/i.test(reason ?? "")) return "cnb login\uFF0C\u5E76\u8BA9\u8D1F\u8D23\u4EBA\u628A\u4F60\u52A0\u8FDB\u6848\u4F8B\u4ED3";
15777
16088
  return "\u672A\u80FD\u5224\u522B\u5931\u8D25\u7C7B\u578B\uFF1B\u67E5\u7F51\u7EDC\u6216\u4EE3\u7406\u540E\u91CD\u8DD1\uFF1B\u82E5\u4E3A\u8BA4\u8BC1\u95EE\u9898\uFF0Ccnb login\uFF0C\u5E76\u8BA9\u8D1F\u8D23\u4EBA\u628A\u4F60\u52A0\u8FDB\u6848\u4F8B\u4ED3";
@@ -15864,7 +16175,7 @@ var localChecks = { project, credential, version, installed, fresh, shadow, boun
15864
16175
  // src/commands/doctor/connect-checks.ts
15865
16176
  init_auth_guard();
15866
16177
  import axios8 from "axios";
15867
- import { CliError as CliError34, IMPERSONATION_START_PATH, USER_LOOKUP_PATH, probeDoctorEndpoint, probeDoctorLayer, layerDetail, toPrincipal as toPrincipal3 } from "@hcmai/sdk";
16178
+ import { CliError as CliError35, IMPERSONATION_START_PATH, USER_LOOKUP_PATH, probeDoctorEndpoint, probeDoctorLayer, layerDetail, toPrincipal as toPrincipal3 } from "@hcmai/sdk";
15868
16179
 
15869
16180
  // src/commands/doctor/server-report.ts
15870
16181
  import axios7 from "axios";
@@ -16240,8 +16551,8 @@ var identity = async (ctx, env2, execution) => {
16240
16551
  if (execution.signal.aborted) await e.close?.();
16241
16552
  return observation;
16242
16553
  } catch (error) {
16243
- const detail = error instanceof CliError34 ? error.context : void 0;
16244
- const errorCode = error instanceof CliError34 ? error.code : void 0;
16554
+ const detail = error instanceof CliError35 ? error.context : void 0;
16555
+ const errorCode = error instanceof CliError35 ? error.code : void 0;
16245
16556
  const actorStep = error !== null && typeof error === "object" ? error[AS_ACTOR_STEP] : void 0;
16246
16557
  if (actorStep) {
16247
16558
  const actorCode = actorStep === "meta" || actorStep === "env" ? "IDENTITY_META_INVALID" : actorStep === "resolve" && errorCode === "IDENTITY_NOT_FOUND" ? "IDENTITY_NOT_LOGGED_IN" : "IDENTITY_UNVERIFIED";
@@ -16857,8 +17168,8 @@ import { createHash as createHash8 } from "crypto";
16857
17168
  import axios9 from "axios";
16858
17169
  import {
16859
17170
  classifyStatus as classifyStatus2,
16860
- CliError as CliError35,
16861
- CliErrorCode as CliErrorCode36,
17171
+ CliError as CliError36,
17172
+ CliErrorCode as CliErrorCode37,
16862
17173
  loadGlobalConfig as loadGlobalConfig11,
16863
17174
  printResolvedEnvironment as printResolvedEnvironment8,
16864
17175
  resolveEnvContext as resolveEnvContext8
@@ -16966,11 +17277,11 @@ async function readPlatformOpsKey(args, io = {
16966
17277
  } else if (io.isTTY) {
16967
17278
  source = "tty";
16968
17279
  key2 = await io.prompt();
16969
- } else throw new CliError35({ code: CliErrorCode36.INVALID_ARGUMENT, message: blank ? "HCM_PLATFORM_OPS_KEY \u5DF2\u8BBE\u7F6E\u4F46\u5168\u662F\u7A7A\u767D\uFF0C\u5DF2\u5FFD\u7565\uFF1A\u628A\u5BC6\u94A5\u5199\u8FDB\u8BE5\u53D8\u91CF\u3001\u4F7F\u7528 --platform-ops-key-stdin\uFF0C\u6216\u5728 TTY \u4EA4\u4E92\u8F93\u5165" : "\u7F3A\u5C11\u8FD0\u7EF4\u5BC6\u94A5\uFF1A\u8BBE\u7F6E HCM_PLATFORM_OPS_KEY\u3001\u4F7F\u7528 --platform-ops-key-stdin\uFF0C\u6216\u5728 TTY \u4EA4\u4E92\u8F93\u5165" });
17280
+ } else throw new CliError36({ code: CliErrorCode37.INVALID_ARGUMENT, message: blank ? "HCM_PLATFORM_OPS_KEY \u5DF2\u8BBE\u7F6E\u4F46\u5168\u662F\u7A7A\u767D\uFF0C\u5DF2\u5FFD\u7565\uFF1A\u628A\u5BC6\u94A5\u5199\u8FDB\u8BE5\u53D8\u91CF\u3001\u4F7F\u7528 --platform-ops-key-stdin\uFF0C\u6216\u5728 TTY \u4EA4\u4E92\u8F93\u5165" : "\u7F3A\u5C11\u8FD0\u7EF4\u5BC6\u94A5\uFF1A\u8BBE\u7F6E HCM_PLATFORM_OPS_KEY\u3001\u4F7F\u7528 --platform-ops-key-stdin\uFF0C\u6216\u5728 TTY \u4EA4\u4E92\u8F93\u5165" });
16970
17281
  if (blank) io.stderr(`HCM_PLATFORM_OPS_KEY \u5168\u662F\u7A7A\u767D\uFF0C\u5DF2\u5FFD\u7565\uFF1B\u6539\u4ECE ${source} \u8BFB\u53D6
16971
17282
  `);
16972
17283
  key2 = key2.trim();
16973
- if (!key2) throw new CliError35({ code: CliErrorCode36.INVALID_ARGUMENT, message: "\u8FD0\u7EF4\u5BC6\u94A5\u4E3A\u7A7A" });
17284
+ if (!key2) throw new CliError36({ code: CliErrorCode37.INVALID_ARGUMENT, message: "\u8FD0\u7EF4\u5BC6\u94A5\u4E3A\u7A7A" });
16974
17285
  io.stderr(`\u8FD0\u7EF4\u5BC6\u94A5\u6765\u6E90\uFF1A${source} \xB7 \u6307\u7EB9 ${opsKeyFingerprint(key2)}
16975
17286
  `);
16976
17287
  return { key: key2, source };
@@ -16979,12 +17290,12 @@ var split = (value) => (Array.isArray(value) ? value : value ? [value] : []).fla
16979
17290
  function scopeFor(args) {
16980
17291
  const only = split(args.only), skip = split(args.skip);
16981
17292
  for (const token of [...only, ...skip]) if (!("platform.".startsWith(token) || token.startsWith("platform.")))
16982
- throw new CliError35({
16983
- code: CliErrorCode36.INVALID_ARGUMENT,
17293
+ throw new CliError36({
17294
+ code: CliErrorCode37.INVALID_ARGUMENT,
16984
17295
  message: `\u8FD0\u7EF4\u89C6\u56FE\u53EA\u770B\u5E73\u53F0\u5C42\uFF1A--only / --skip \u53EA\u63A5\u53D7 platform \u524D\u7F00\uFF0C\u6536\u5230 ${token}`
16985
17296
  });
16986
- if (skip.some((token) => "platform.".startsWith(token))) throw new CliError35({
16987
- code: CliErrorCode36.INVALID_ARGUMENT,
17297
+ if (skip.some((token) => "platform.".startsWith(token))) throw new CliError36({
17298
+ code: CliErrorCode37.INVALID_ARGUMENT,
16988
17299
  message: "\u6392\u9664\u4E86\u5E73\u53F0\u5C42\uFF0C\u8FD0\u7EF4\u89C6\u56FE\u6CA1\u6709\u53EF\u770B\u7684\u68C0\u67E5"
16989
17300
  });
16990
17301
  return {
@@ -17140,7 +17451,7 @@ function failure(ctx, env2, health, key2) {
17140
17451
  }
17141
17452
  var ENV_HINT = "hcm env list \u67E5\u770B\u53EF\u9009\u73AF\u5883\uFF1Bhcm env add <\u540D> --endpoint <url> \u767B\u8BB0";
17142
17453
  function resolverMessage(error) {
17143
- if (error instanceof CliError35 && error.code === CliErrorCode36.NO_ACTIVE_ENV) return "\u672A\u9009\u5B9A\u73AF\u5883\uFF1A\u7528 --env <\u540D> \u6307\u5B9A";
17454
+ if (error instanceof CliError36 && error.code === CliErrorCode37.NO_ACTIVE_ENV) return "\u672A\u9009\u5B9A\u73AF\u5883\uFF1A\u7528 --env <\u540D> \u6307\u5B9A";
17144
17455
  return (error instanceof Error ? error.message : safeError(error)).replace(/\s*(&&\s*)?hcm\s+login\b[^;;\n]*/gi, "");
17145
17456
  }
17146
17457
  async function runPlatformOps(args, services, readKey = readPlatformOpsKey, onReport) {
@@ -17149,10 +17460,10 @@ async function runPlatformOps(args, services, readKey = readPlatformOpsKey, onRe
17149
17460
  try {
17150
17461
  resolved = await resolveEnvContext8({ envFlag: args.env }, process.env, await loadGlobalConfig11());
17151
17462
  } catch (error2) {
17152
- throw new CliError35({ code: CliErrorCode36.INVALID_ARGUMENT, message: `${resolverMessage(error2)}\uFF1B${ENV_HINT}` });
17463
+ throw new CliError36({ code: CliErrorCode37.INVALID_ARGUMENT, message: `${resolverMessage(error2)}\uFF1B${ENV_HINT}` });
17153
17464
  }
17154
- if (!resolved.config.endpoint) throw new CliError35({
17155
- code: CliErrorCode36.INVALID_ARGUMENT,
17465
+ if (!resolved.config.endpoint) throw new CliError36({
17466
+ code: CliErrorCode37.INVALID_ARGUMENT,
17156
17467
  message: `\u672A\u89E3\u6790\u5230 endpoint\uFF1B${ENV_HINT}`
17157
17468
  });
17158
17469
  printResolvedEnvironment8(resolved);
@@ -17198,8 +17509,8 @@ async function runPlatformOps(args, services, readKey = readPlatformOpsKey, onRe
17198
17509
  const error = out && object(out.body) && object(out.body.error) ? out.body.error : void 0;
17199
17510
  if (out?.status === 400 && error?.code === "HEALTH_REPORT_INVALID_PARAM") {
17200
17511
  const trace = out.headers["x-trace-id"];
17201
- throw new CliError35({
17202
- code: CliErrorCode36.INVALID_ARGUMENT,
17512
+ throw new CliError36({
17513
+ code: CliErrorCode37.INVALID_ARGUMENT,
17203
17514
  message: `${typeof error.message === "string" ? redact(error.message, key2) : "\u8FD0\u7EF4\u68C0\u67E5\u8303\u56F4\u65E0\u6548"}${scope.only.length || scope.skip.length ? "\uFF1B\u53BB\u6389 --only / --skip \u91CD\u8DD1 hcm chiron doctor --platform-ops \u53EF\u770B\u5230\u5168\u90E8\u5E73\u53F0\u68C0\u67E5" : `\uFF1B\u672C\u6B21\u6CA1\u6709\u5E26 --only / --skip\uFF0C\u53C2\u6570\u4ECD\u88AB\u5224\u65E0\u6548\uFF0C\u5C5E\u670D\u52A1\u7AEF\u7F3A\u9677\uFF1A\u9644 traceId ${trace || "\uFF08\u54CD\u5E94\u672A\u5E26\uFF0C\u9644\u672C\u6B21\u65F6\u95F4\u4E0E\u73AF\u5883\u540D\uFF09"} \u8054\u7CFB\u7814\u53D1`}`
17204
17515
  });
17205
17516
  }
@@ -17506,13 +17817,13 @@ var defaultServices = {
17506
17817
  };
17507
17818
  function validate(args) {
17508
17819
  for (const [key2, value, choices] of [["output", args.output, ["table", "json", "yaml"]], ["fail-on", args.failOn, ["blocked", "risks"]]])
17509
- if (value !== void 0 && !choices.includes(value)) throw new CliError36({
17510
- code: CliErrorCode37.INVALID_ARGUMENT,
17820
+ if (value !== void 0 && !choices.includes(value)) throw new CliError37({
17821
+ code: CliErrorCode38.INVALID_ARGUMENT,
17511
17822
  message: `--${key2} \u53EA\u63A5\u53D7 ${choices.join(" / ")}\uFF0C\u6536\u5230 ${value}`
17512
17823
  });
17513
17824
  const stages = ["handover", "baseline", "configure", "migrate", "integrate", "golive", "operate"];
17514
- if (args.stage !== void 0 && !stages.includes(args.stage.toLowerCase())) throw new CliError36({
17515
- code: CliErrorCode37.INVALID_ARGUMENT,
17825
+ if (args.stage !== void 0 && !stages.includes(args.stage.toLowerCase())) throw new CliError37({
17826
+ code: CliErrorCode38.INVALID_ARGUMENT,
17516
17827
  message: `--stage \u53EA\u63A5\u53D7 ${stages.join(" / ")}\uFF0C\u6536\u5230 ${args.stage}`
17517
17828
  });
17518
17829
  if (args.platformOpsKeyStdin && !args.platformOps) invalidScope("--platform-ops-key-stdin \u53EA\u80FD\u4E0E --platform-ops \u540C\u7528");
@@ -17533,7 +17844,7 @@ var tokens = (value) => (Array.isArray(value) ? value : value ? [value] : []).fl
17533
17844
  var matches = (id, only, skip) => (!only.length || only.some((t) => id.startsWith(t))) && !skip.some((t) => id.startsWith(t));
17534
17845
  var serverCandidate = (t) => ["platform.", "tenant."].some((prefix) => prefix.startsWith(t) || t.startsWith(prefix));
17535
17846
  function invalidScope(message) {
17536
- throw new CliError36({ code: CliErrorCode37.INVALID_ARGUMENT, message });
17847
+ throw new CliError37({ code: CliErrorCode38.INVALID_ARGUMENT, message });
17537
17848
  }
17538
17849
  function scopeFor2(args, catalog) {
17539
17850
  const only = tokens(args.only), skip = tokens(args.skip), stage = args.stage?.toLowerCase() ?? null;
@@ -17568,7 +17879,7 @@ async function readCredential(envFlag, root, as) {
17568
17879
  try {
17569
17880
  resolved = await resolveEnvContext9({ envFlag, cwd: root }, process.env, await loadGlobalConfig12());
17570
17881
  } catch (error) {
17571
- if (error instanceof CliError36 && error.code === CliErrorCode37.ENV_NOT_FOUND) return { resolved: null };
17882
+ if (error instanceof CliError37 && error.code === CliErrorCode38.ENV_NOT_FOUND) return { resolved: null };
17572
17883
  throw error;
17573
17884
  }
17574
17885
  if (as) return { resolved };
@@ -17577,14 +17888,14 @@ async function readCredential(envFlag, root, as) {
17577
17888
  try {
17578
17889
  identity3 = await resolveActiveIdentity2({}, process.env, resolved.name);
17579
17890
  } catch (error) {
17580
- if (error instanceof CliError36 && error.code === CliErrorCode37.IDENTITY_NOT_FOUND) return { resolved, error: found("IDENTITY_NOT_LOGGED_IN") };
17891
+ if (error instanceof CliError37 && error.code === CliErrorCode38.IDENTITY_NOT_FOUND) return { resolved, error: found("IDENTITY_NOT_LOGGED_IN") };
17581
17892
  throw error;
17582
17893
  }
17583
17894
  let meta2;
17584
17895
  try {
17585
17896
  meta2 = await loadIdentity5(identity3);
17586
17897
  } catch (error) {
17587
- if (error instanceof CliError36 && error.code === CliErrorCode37.IDENTITY_NOT_FOUND) return { resolved, identity: identity3, error: found("IDENTITY_META_INVALID", `\u8EAB\u4EFD ${identity3} \u7684\u5143\u6570\u636E\u4E0D\u5B58\u5728\uFF1B\u91CD\u65B0\u767B\u5F55\u4FEE\u590D`) };
17898
+ if (error instanceof CliError37 && error.code === CliErrorCode38.IDENTITY_NOT_FOUND) return { resolved, identity: identity3, error: found("IDENTITY_META_INVALID", `\u8EAB\u4EFD ${identity3} \u7684\u5143\u6570\u636E\u4E0D\u5B58\u5728\uFF1B\u91CD\u65B0\u767B\u5F55\u4FEE\u590D`) };
17588
17899
  throw error;
17589
17900
  }
17590
17901
  if (!meta2.env || meta2.env !== resolved.name) return {
@@ -17626,7 +17937,7 @@ async function prepareContext(args, deps) {
17626
17937
  const detail = `${safeError(error)}\uFF1B\u53EF\u9009\u73AF\u5883\uFF1A${available.join(", ") || "\uFF08\u65E0\uFF09"}`;
17627
17938
  projectObservation = found("ENV_NOT_RESOLVED", detail);
17628
17939
  targetEnv = null;
17629
- const slotMissing = error instanceof CliError36 && error.code === CliErrorCode37.ENV_NOT_FOUND;
17940
+ const slotMissing = error instanceof CliError37 && error.code === CliErrorCode38.ENV_NOT_FOUND;
17630
17941
  const project2 = args.project !== void 0 ? ` --project ${quote(root)}` : "";
17631
17942
  const step2 = file ? `hcm chiron env add ${quote(args.env)} --endpoint <\u540E\u7AEF\u5730\u5740> --frontend <\u524D\u7AEF\u5730\u5740> --tenant <\u79DF\u6237\u53F7>${project2}` : slotMissing ? `hcm chiron init --env ${quote(args.env)} --endpoint <\u540E\u7AEF\u5730\u5740> --tenant <\u79DF\u6237\u53F7>${project2}` : `hcm chiron init --env ${quote(args.env)}${project2}`;
17632
17943
  if (slotMissing || error instanceof Error && error.message === "\u672C\u673A\u69FD\u4E0D\u5C5E\u4E8E\u5F53\u524D\u9879\u76EE")
@@ -17794,12 +18105,12 @@ async function chironDoctorCommand(args, deps) {
17794
18105
  }
17795
18106
  }
17796
18107
  const data = explainOpsCatalog(args.explain, descriptorReport);
17797
- process.stdout.write((args.output === "json" || args.output === "yaml" ? formatObject30(data, { format: args.output }) : renderCatalogExplanation(data)) + "\n");
18108
+ process.stdout.write((args.output === "json" || args.output === "yaml" ? formatObject31(data, { format: args.output }) : renderCatalogExplanation(data)) + "\n");
17798
18109
  process.exitCode = 0;
17799
18110
  return;
17800
18111
  }
17801
18112
  const report2 = await runPlatformOps(args, { ...defaultServices, ...deps });
17802
- process.stdout.write((args.output === "json" || args.output === "yaml" ? formatObject30(report2, { format: args.output }) : renderChironDoctor(report2)) + "\n");
18113
+ process.stdout.write((args.output === "json" || args.output === "yaml" ? formatObject31(report2, { format: args.output }) : renderChironDoctor(report2)) + "\n");
17803
18114
  process.exitCode = conclude(report2.results, { total: report2.coverage.total, failOn: args.failOn ?? "blocked" }).exitCode;
17804
18115
  return;
17805
18116
  }
@@ -17811,12 +18122,12 @@ async function chironDoctorCommand(args, deps) {
17811
18122
  if (!listing.server.known) process.stderr.write(`\u670D\u52A1\u7AEF\u76EE\u5F55${"partial" in listing.server ? "\u4E0D\u5168" : "\u672A\u53D6\u5230"}\uFF1A${listing.server.reason}
17812
18123
  `);
17813
18124
  }
17814
- process.stdout.write((args.output === "json" || args.output === "yaml" ? formatObject30(data, { format: args.output }) : args.list ? renderCatalogList(data) : renderCatalogExplanation(data)) + "\n");
18125
+ process.stdout.write((args.output === "json" || args.output === "yaml" ? formatObject31(data, { format: args.output }) : args.list ? renderCatalogList(data) : renderCatalogExplanation(data)) + "\n");
17815
18126
  process.exitCode = 0;
17816
18127
  return;
17817
18128
  }
17818
18129
  const report = await runChironDoctor(args, deps);
17819
- process.stdout.write((args.output === "json" || args.output === "yaml" ? formatObject30(report, { format: args.output }) : renderChironDoctor(report)) + "\n");
18130
+ process.stdout.write((args.output === "json" || args.output === "yaml" ? formatObject31(report, { format: args.output }) : renderChironDoctor(report)) + "\n");
17820
18131
  process.exitCode = conclude(report.results, {
17821
18132
  total: report.coverage.total,
17822
18133
  failOn: args.failOn ?? "blocked",
@@ -17837,11 +18148,11 @@ import { accessSync, constants, readdirSync as readdirSync3 } from "fs";
17837
18148
  import fs14 from "fs/promises";
17838
18149
  import os6 from "os";
17839
18150
  import path17 from "path";
17840
- import { CliError as CliError39, CliErrorCode as CliErrorCode40, formatObject as formatObject31, HcmClient as HcmClient25, loadEnv as loadEnv6 } from "@hcmai/sdk";
18151
+ import { CliError as CliError40, CliErrorCode as CliErrorCode41, formatObject as formatObject32, HcmClient as HcmClient26, loadEnv as loadEnv6 } from "@hcmai/sdk";
17841
18152
  import { createRequire } from "module";
17842
18153
 
17843
18154
  // src/commands/chiron-page-cdp.ts
17844
- import { CliError as CliError37, CliErrorCode as CliErrorCode38 } from "@hcmai/sdk";
18155
+ import { CliError as CliError38, CliErrorCode as CliErrorCode39 } from "@hcmai/sdk";
17845
18156
 
17846
18157
  // src/commands/chiron-page-shared.ts
17847
18158
  function redactTicket(text) {
@@ -17877,14 +18188,14 @@ function normalizeCdpEndpoint(raw) {
17877
18188
  try {
17878
18189
  url = new URL(candidate);
17879
18190
  } catch {
17880
- throw new CliError37({ code: CliErrorCode38.INVALID_ARGUMENT, message: `--cdp \u8981\u5199\u6210 http://\u4E3B\u673A:\u7AEF\u53E3\uFF08Chrome \u7684 --remote-debugging-port\uFF09\uFF0C\u6536\u5230\u7684\u662F ${text}` });
18191
+ throw new CliError38({ code: CliErrorCode39.INVALID_ARGUMENT, message: `--cdp \u8981\u5199\u6210 http://\u4E3B\u673A:\u7AEF\u53E3\uFF08Chrome \u7684 --remote-debugging-port\uFF09\uFF0C\u6536\u5230\u7684\u662F ${text}` });
17881
18192
  }
17882
18193
  const protocol = url.protocol === "wss:" ? "https:" : url.protocol === "ws:" ? "http:" : url.protocol;
17883
18194
  if (protocol !== "http:" && protocol !== "https:") {
17884
- throw new CliError37({ code: CliErrorCode38.INVALID_ARGUMENT, message: `--cdp \u53EA\u8BA4 http(s) \u6216 ws(s) \u7AEF\u70B9\uFF0C\u6536\u5230\u7684\u662F ${text}` });
18195
+ throw new CliError38({ code: CliErrorCode39.INVALID_ARGUMENT, message: `--cdp \u53EA\u8BA4 http(s) \u6216 ws(s) \u7AEF\u70B9\uFF0C\u6536\u5230\u7684\u662F ${text}` });
17885
18196
  }
17886
18197
  if (!url.port) {
17887
- throw new CliError37({ code: CliErrorCode38.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}` });
18198
+ throw new CliError38({ code: CliErrorCode39.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}` });
17888
18199
  }
17889
18200
  return `${protocol}//${url.hostname}:${url.port}`;
17890
18201
  }
@@ -17981,8 +18292,8 @@ async function captureViaCdp(input, io) {
17981
18292
  const browser = version2?.Browser ? String(version2.Browser) : `attached ${input.endpoint}`;
17982
18293
  const target = await io.fetchJson(`${input.endpoint}/json/new?about:blank`, "PUT");
17983
18294
  if (!target?.id || !target.webSocketDebuggerUrl) {
17984
- throw new CliError37({
17985
- code: CliErrorCode38.SERVER_ERROR,
18295
+ throw new CliError38({
18296
+ code: CliErrorCode39.SERVER_ERROR,
17986
18297
  message: `${input.endpoint}/json/new \u6CA1\u6709\u7ED9\u51FA\u6807\u7B7E\u9875\uFF08id / webSocketDebuggerUrl \u7F3A\u5931\uFF09`,
17987
18298
  context: { nextStep: "\u786E\u8BA4 Chrome \u662F\u5E26 --remote-debugging-port \u8D77\u7684\uFF0C\u4E14 --cdp \u6307\u5230\u7684\u662F\u5B83" }
17988
18299
  });
@@ -18012,7 +18323,7 @@ async function captureViaCdp(input, io) {
18012
18323
  });
18013
18324
  if (r.exceptionDetails) {
18014
18325
  const why = r.exceptionDetails.exception?.description ?? r.exceptionDetails.text ?? "unknown";
18015
- throw new CliError37({ code: CliErrorCode38.INVALID_ARGUMENT, message: `--eval \u5728\u9875\u9762\u91CC\u629B\u4E86\u5F02\u5E38\uFF1A${redactTicket(why.split("\n")[0] ?? why)}` });
18326
+ throw new CliError38({ code: CliErrorCode39.INVALID_ARGUMENT, message: `--eval \u5728\u9875\u9762\u91CC\u629B\u4E86\u5F02\u5E38\uFF1A${redactTicket(why.split("\n")[0] ?? why)}` });
18016
18327
  }
18017
18328
  evalResult = r.result && "value" in r.result ? toPlainJson(r.result.value) : toPlainJson(r.result?.description);
18018
18329
  }
@@ -18023,7 +18334,7 @@ async function captureViaCdp(input, io) {
18023
18334
  const dom = typeof domReply.result?.value === "string" ? domReply.result.value : "";
18024
18335
  const shot = await session.send("Page.captureScreenshot", { format: "png" });
18025
18336
  if (!shot.data) {
18026
- throw new CliError37({ code: CliErrorCode38.SERVER_ERROR, message: "Page.captureScreenshot \u6CA1\u6709\u8FD4\u56DE\u56FE\u50CF\u6570\u636E" });
18337
+ throw new CliError38({ code: CliErrorCode39.SERVER_ERROR, message: "Page.captureScreenshot \u6CA1\u6709\u8FD4\u56DE\u56FE\u50CF\u6570\u636E" });
18027
18338
  }
18028
18339
  await io.writeFile(input.screenshot, Buffer.from(shot.data, "base64"));
18029
18340
  return { dom, browser, evalResult, navigated, minted };
@@ -18045,7 +18356,7 @@ var defaultCdpIo = {
18045
18356
  openSocket: (wsUrl) => new Promise((resolve4, reject) => {
18046
18357
  const Ctor = globalThis.WebSocket;
18047
18358
  if (!Ctor) {
18048
- reject(new CliError37({ code: CliErrorCode38.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" }));
18359
+ reject(new CliError38({ code: CliErrorCode39.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" }));
18049
18360
  return;
18050
18361
  }
18051
18362
  const ws = new Ctor(wsUrl);
@@ -18068,7 +18379,7 @@ var defaultCdpIo = {
18068
18379
 
18069
18380
  // src/commands/chiron-page-playwright.ts
18070
18381
  import path16 from "path";
18071
- import { CliError as CliError38, CliErrorCode as CliErrorCode39 } from "@hcmai/sdk";
18382
+ import { CliError as CliError39, CliErrorCode as CliErrorCode40 } from "@hcmai/sdk";
18072
18383
  function playwrightCacheRoot(probe2) {
18073
18384
  const override = probe2.env.PLAYWRIGHT_BROWSERS_PATH?.trim();
18074
18385
  if (override === "0" && probe2.packageRoot) return path16.join(probe2.packageRoot, ".local-browsers");
@@ -18111,8 +18422,8 @@ function discoverPlaywrightBrowser(probe2) {
18111
18422
  const explicit = probe2.env.HCM_PLAYWRIGHT_EXECUTABLE?.trim();
18112
18423
  if (explicit) {
18113
18424
  if (probe2.executable(explicit)) return { executablePath: explicit, kind: "explicit", from: "HCM_PLAYWRIGHT_EXECUTABLE" };
18114
- throw new CliError38({
18115
- code: CliErrorCode39.INVALID_ARGUMENT,
18425
+ throw new CliError39({
18426
+ code: CliErrorCode40.INVALID_ARGUMENT,
18116
18427
  message: `HCM_PLAYWRIGHT_EXECUTABLE \u6307\u7684\u6587\u4EF6\u4E0D\u53EF\u6267\u884C\uFF1A${explicit}`,
18117
18428
  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" }
18118
18429
  });
@@ -18154,8 +18465,8 @@ async function captureViaPlaywright(input) {
18154
18465
  }
18155
18466
  }
18156
18467
  if (!browser) {
18157
- throw new CliError38({
18158
- code: CliErrorCode39.SERVER_ERROR,
18468
+ throw new CliError39({
18469
+ code: CliErrorCode40.SERVER_ERROR,
18159
18470
  message: `Playwright \u8D77\u4E0D\u4E86\u6D4F\u89C8\u5668\uFF1A${failures.join("\uFF1B")}`,
18160
18471
  context: {
18161
18472
  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"
@@ -18175,7 +18486,7 @@ async function captureViaPlaywright(input) {
18175
18486
  evalResult = toPlainJson(await page.evaluate(wrapEvalBody(input.evalJs)));
18176
18487
  } catch (e) {
18177
18488
  const why = (e instanceof Error ? e.message : String(e)).split("\n")[0] ?? "";
18178
- throw new CliError38({ code: CliErrorCode39.INVALID_ARGUMENT, message: `--eval \u5728\u9875\u9762\u91CC\u629B\u4E86\u5F02\u5E38\uFF1A${redactTicket(why)}` });
18489
+ throw new CliError39({ code: CliErrorCode40.INVALID_ARGUMENT, message: `--eval \u5728\u9875\u9762\u91CC\u629B\u4E86\u5F02\u5E38\uFF1A${redactTicket(why)}` });
18179
18490
  }
18180
18491
  }
18181
18492
  const dom = await page.content();
@@ -18199,13 +18510,13 @@ function judgePageContent(input) {
18199
18510
  function parseViewport(size) {
18200
18511
  const m = /^(\d+)x(\d+)$/.exec(size.trim());
18201
18512
  if (!m) {
18202
- throw new CliError39({ code: CliErrorCode40.INVALID_ARGUMENT, message: `--size \u8981\u5199\u6210 <\u5BBD>x<\u9AD8>\uFF0C\u4F8B\u5982 1440x900\uFF0C\u6536\u5230\u7684\u662F ${size}` });
18513
+ throw new CliError40({ code: CliErrorCode41.INVALID_ARGUMENT, message: `--size \u8981\u5199\u6210 <\u5BBD>x<\u9AD8>\uFF0C\u4F8B\u5982 1440x900\uFF0C\u6536\u5230\u7684\u662F ${size}` });
18203
18514
  }
18204
18515
  const width = Number(m[1]);
18205
18516
  const height = Number(m[2]);
18206
18517
  if (width < VIEWPORT_MIN.width || width > VIEWPORT_MAX.width || height < VIEWPORT_MIN.height || height > VIEWPORT_MAX.height) {
18207
- throw new CliError39({
18208
- code: CliErrorCode40.INVALID_ARGUMENT,
18518
+ throw new CliError40({
18519
+ code: CliErrorCode41.INVALID_ARGUMENT,
18209
18520
  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}`
18210
18521
  });
18211
18522
  }
@@ -18215,23 +18526,23 @@ function parseWaitMs(raw) {
18215
18526
  if (raw === void 0) return 1e4;
18216
18527
  const value = typeof raw === "number" ? raw : Number(raw);
18217
18528
  if (!Number.isInteger(value) || value < 0 || value > WAIT_MS_MAX) {
18218
- throw new CliError39({ code: CliErrorCode40.INVALID_ARGUMENT, message: `--wait-ms \u8981\u662F 0..${WAIT_MS_MAX} \u7684\u6574\u6570\uFF0C\u6536\u5230\u7684\u662F ${raw}` });
18529
+ throw new CliError40({ code: CliErrorCode41.INVALID_ARGUMENT, message: `--wait-ms \u8981\u662F 0..${WAIT_MS_MAX} \u7684\u6574\u6570\uFF0C\u6536\u5230\u7684\u662F ${raw}` });
18219
18530
  }
18220
18531
  return value;
18221
18532
  }
18222
18533
  function resolveEvidenceTarget(projectRoot, out) {
18223
18534
  if (!out?.trim()) {
18224
- throw new CliError39({ code: CliErrorCode40.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` });
18535
+ throw new CliError40({ code: CliErrorCode41.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` });
18225
18536
  }
18226
18537
  if (!out.endsWith(".png")) {
18227
- throw new CliError39({ code: CliErrorCode40.INVALID_ARGUMENT, message: `--out \u8981\u4EE5 .png \u7ED3\u5C3E\uFF0C\u6536\u5230\u7684\u662F ${out}` });
18538
+ throw new CliError40({ code: CliErrorCode41.INVALID_ARGUMENT, message: `--out \u8981\u4EE5 .png \u7ED3\u5C3E\uFF0C\u6536\u5230\u7684\u662F ${out}` });
18228
18539
  }
18229
18540
  const root = path17.resolve(projectRoot);
18230
18541
  const evidenceRoot = path17.join(root, EVIDENCE_DIR);
18231
18542
  const absolute = path17.resolve(root, out);
18232
18543
  if (absolute !== evidenceRoot && !absolute.startsWith(evidenceRoot + path17.sep)) {
18233
- throw new CliError39({
18234
- code: CliErrorCode40.INVALID_ARGUMENT,
18544
+ throw new CliError40({
18545
+ code: CliErrorCode41.INVALID_ARGUMENT,
18235
18546
  message: `--out \u8981\u843D\u5728\u9879\u76EE\u7684 ${EVIDENCE_DIR}/ \u4E0B\uFF08${evidenceRoot}\uFF09\uFF0C\u6536\u5230\u7684\u662F ${absolute}`
18236
18547
  });
18237
18548
  }
@@ -18279,8 +18590,8 @@ async function assertInsideEvidence(deps, evidenceRoot, absolute) {
18279
18590
  const canonicalParent = await deps.realpath(path17.dirname(absolute));
18280
18591
  if (canonicalRoot === null || canonicalParent === null) return;
18281
18592
  if (canonicalParent !== canonicalRoot && !canonicalParent.startsWith(canonicalRoot + path17.sep)) {
18282
- throw new CliError39({
18283
- code: CliErrorCode40.INVALID_ARGUMENT,
18593
+ throw new CliError40({
18594
+ code: CliErrorCode41.INVALID_ARGUMENT,
18284
18595
  message: `--out \u7684\u7236\u76EE\u5F55\u7ECF\u7B26\u53F7\u94FE\u63A5\u8DD1\u51FA\u4E86 ${EVIDENCE_DIR}/\uFF1A${canonicalParent}`
18285
18596
  });
18286
18597
  }
@@ -18289,8 +18600,8 @@ async function runChironPage(target, args, deps) {
18289
18600
  const sitePath = normalizeTarget(target);
18290
18601
  const expect = (args.expectText ?? []).filter((t) => t.trim().length > 0);
18291
18602
  if (expect.length === 0) {
18292
- throw new CliError39({
18293
- code: CliErrorCode40.MISSING_FLAG,
18603
+ throw new CliError40({
18604
+ code: CliErrorCode41.MISSING_FLAG,
18294
18605
  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"
18295
18606
  });
18296
18607
  }
@@ -18300,8 +18611,8 @@ async function runChironPage(target, args, deps) {
18300
18611
  const root = path17.resolve(args.project ?? ".");
18301
18612
  const { evidenceRoot, absolute } = resolveEvidenceTarget(root, args.out);
18302
18613
  if (await deps.present(absolute)) {
18303
- throw new CliError39({
18304
- code: CliErrorCode40.INVALID_ARGUMENT,
18614
+ throw new CliError40({
18615
+ code: CliErrorCode41.INVALID_ARGUMENT,
18305
18616
  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`
18306
18617
  });
18307
18618
  }
@@ -18313,8 +18624,8 @@ async function runChironPage(target, args, deps) {
18313
18624
  const playwrightBrowser = endpoint || forceSpawn ? null : deps.findPlaywrightBrowser();
18314
18625
  const usePlaywright = !endpoint && !forceSpawn && (playwrightBrowser !== null || evalJs !== void 0);
18315
18626
  if (evalJs && !endpoint && !usePlaywright) {
18316
- throw new CliError39({
18317
- code: CliErrorCode40.INVALID_ARGUMENT,
18627
+ throw new CliError40({
18628
+ code: CliErrorCode41.INVALID_ARGUMENT,
18318
18629
  message: "--eval \u9700\u8981 Playwright \u6216 --cdp\uFF1A\u8001\u7684 spawn \u8DEF\u5F84\u53EA\u4F1A --dump-dom\uFF0C\u585E\u4E0D\u8FDB\u811A\u672C\u3002",
18319
18630
  context: { nextStep: "npx playwright install chromium-headless-shell\uFF0C\u6216\u5728\u6C99\u7BB1\u5916\u8D77 Chrome \u7528 --cdp \u8FDE" }
18320
18631
  });
@@ -18332,10 +18643,10 @@ async function runChironPage(target, args, deps) {
18332
18643
  try {
18333
18644
  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 });
18334
18645
  } catch (e) {
18335
- if (e instanceof CliError39) throw new CliError39({ code: e.code, message: redactTicket(e.message), context: e.context });
18646
+ if (e instanceof CliError40) throw new CliError40({ code: e.code, message: redactTicket(e.message), context: e.context });
18336
18647
  const where = endpoint ? `\u8FDE\u5230 ${endpoint} \u7684 Chrome` : "Playwright \u8D77\u7684\u6D4F\u89C8\u5668";
18337
- throw new CliError39({
18338
- code: CliErrorCode40.SERVER_ERROR,
18648
+ throw new CliError40({
18649
+ code: CliErrorCode41.SERVER_ERROR,
18339
18650
  message: `${where}\u6CA1\u8DD1\u5B8C\uFF1A${redactTicket(e instanceof Error ? e.message : String(e))}`,
18340
18651
  context: {
18341
18652
  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"
@@ -18351,8 +18662,8 @@ async function runChironPage(target, args, deps) {
18351
18662
  mode = "spawn";
18352
18663
  const browser = deps.findBrowser();
18353
18664
  if (!browser) {
18354
- throw new CliError39({
18355
- code: CliErrorCode40.INVALID_ARGUMENT,
18665
+ throw new CliError40({
18666
+ code: CliErrorCode41.INVALID_ARGUMENT,
18356
18667
  message: "\u672C\u673A\u627E\u4E0D\u5230 Playwright \u7684 Chromium\uFF0C\u4E5F\u627E\u4E0D\u5230 Chrome/Chromium\uFF0C\u622A\u4E0D\u4E86\u56FE\u3002",
18357
18668
  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" }
18358
18669
  });
@@ -18360,8 +18671,8 @@ async function runChironPage(target, args, deps) {
18360
18671
  minted = await mint();
18361
18672
  const result = deps.capture({ browser, argv: chromeArgv({ viewport, waitMs, screenshot: absolute, url: minted.url, isRoot: process.getuid?.() === 0 }) });
18362
18673
  if (!result.ok) {
18363
- throw new CliError39({
18364
- code: CliErrorCode40.SERVER_ERROR,
18674
+ throw new CliError40({
18675
+ code: CliErrorCode41.SERVER_ERROR,
18365
18676
  message: `\u6D4F\u89C8\u5668\u6CA1\u8DD1\u5B8C\uFF1A${redactTicket(result.stderr.trim().split("\n").slice(-1)[0] ?? "\u65E0\u8F93\u51FA")}`,
18366
18677
  context: { nextStep: spawnFailureNextStep(browser, result, deps.platform) }
18367
18678
  });
@@ -18371,7 +18682,7 @@ async function runChironPage(target, args, deps) {
18371
18682
  }
18372
18683
  const bytes = await deps.present(absolute) ? await deps.sizeOf(absolute) : 0;
18373
18684
  if (bytes === 0) {
18374
- throw new CliError39({ code: CliErrorCode40.SERVER_ERROR, message: `\u6D4F\u89C8\u5668\u6CA1\u5199\u51FA\u975E\u7A7A PNG\uFF1A${absolute}` });
18685
+ throw new CliError40({ code: CliErrorCode41.SERVER_ERROR, message: `\u6D4F\u89C8\u5668\u6CA1\u5199\u51FA\u975E\u7A7A PNG\uFF1A${absolute}` });
18375
18686
  }
18376
18687
  const verdict = judgePageContent({ dom, expect, reject });
18377
18688
  return {
@@ -18434,14 +18745,14 @@ var defaultChironPageDeps = {
18434
18745
  const envCfg = await loadEnv6(ctx.env);
18435
18746
  const frontend = ctx.frontend ?? envCfg.frontend;
18436
18747
  if (!frontend?.trim()) {
18437
- throw new CliError39({
18438
- code: CliErrorCode40.INVALID_ARGUMENT,
18748
+ throw new CliError40({
18749
+ code: CliErrorCode41.INVALID_ARGUMENT,
18439
18750
  message: `env '${ctx.env}' \u6CA1\u914D\u524D\u7AEF\u5730\u5740\uFF0C\u5F00\u4E0D\u4E86\u9875\u9762\u3002`,
18440
18751
  context: { nextStep: `hcm env edit frontend <\u524D\u7AEF\u5730\u5740> --env ${ctx.env}` }
18441
18752
  });
18442
18753
  }
18443
- const client3 = HcmClient25.fromAuthContext(ctx);
18444
- const { ticket } = await mintBrowserTicket(client3, ctx.env)();
18754
+ const client4 = HcmClient26.fromAuthContext(ctx);
18755
+ const { ticket } = await mintBrowserTicket(client4, ctx.env)();
18445
18756
  return { url: buildBrowserLoginUrl(frontend, ticket, sitePath), environment: ctx.env, identity: ctx.identity ?? null };
18446
18757
  },
18447
18758
  findBrowser: () => findChrome(
@@ -18502,7 +18813,7 @@ async function chironPageCommand(target, args, deps = defaultChironPageDeps) {
18502
18813
  try {
18503
18814
  const receipt = await runChironPage(target, args, deps);
18504
18815
  const fmt = args.output ?? "table";
18505
- if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject31(receipt, { format: fmt }) + "\n");
18816
+ if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject32(receipt, { format: fmt }) + "\n");
18506
18817
  else process.stdout.write(renderChironPage(receipt) + "\n");
18507
18818
  process.exitCode = receipt.ok ? 0 : 3;
18508
18819
  } catch (e) {
@@ -18517,11 +18828,11 @@ import { randomUUID as randomUUID2 } from "crypto";
18517
18828
  import { promises as fs15 } from "fs";
18518
18829
  import path18 from "path";
18519
18830
  import yaml3 from "js-yaml";
18520
- import { formatObject as formatObject32 } from "@hcmai/sdk";
18831
+ import { formatObject as formatObject33 } from "@hcmai/sdk";
18521
18832
 
18522
18833
  // src/commands/delivery-action-policy.ts
18523
18834
  init_auth_guard();
18524
- import { HcmClient as HcmClient26, classifyEffect } from "@hcmai/sdk";
18835
+ import { HcmClient as HcmClient27, classifyEffect } from "@hcmai/sdk";
18525
18836
 
18526
18837
  // src/commands/delivery.ts
18527
18838
  import { createHash as createHash9 } from "crypto";
@@ -19116,7 +19427,7 @@ async function resolveCoreAction(request) {
19116
19427
  as: request.identity,
19117
19428
  profile: request.profile
19118
19429
  });
19119
- const description = await HcmClient26.fromAuthContext(auth).describe(request.model);
19430
+ const description = await HcmClient27.fromAuthContext(auth).describe(request.model);
19120
19431
  const named = description.actions.filter((action) => action.name === request.action);
19121
19432
  if (named.length === 0) {
19122
19433
  const degraded = description.effectiveActionsAvailable ? "" : `\u26A0\uFE0F \u672C\u6B21\u6BD4\u5BF9\u4E0D\u542B\u811A\u672C Action\u2014\u2014${description.effectiveActionsNote ?? "\u539F\u56E0\u672A\u77E5"}\u3002`;
@@ -19558,7 +19869,7 @@ async function chironTestCommand(target, args, deps) {
19558
19869
  }
19559
19870
  const fmt = args.output ?? "table";
19560
19871
  if (fmt === "json" || fmt === "yaml") {
19561
- process.stdout.write(formatObject32({ ok: failed2 === 0, failed: failed2, cases: report }, { format: fmt }) + "\n");
19872
+ process.stdout.write(formatObject33({ ok: failed2 === 0, failed: failed2, cases: report }, { format: fmt }) + "\n");
19562
19873
  } else {
19563
19874
  for (const c2 of report) {
19564
19875
  process.stdout.write(`
@@ -19587,12 +19898,12 @@ ${failed2} \u6761\u6CA1\u8FC7\u2014\u2014\u4E0A\u9762\u6BCF\u6761\u90FD\u5199\u4
19587
19898
  init_auth_guard();
19588
19899
  init_exit();
19589
19900
  import {
19590
- HcmClient as HcmClient27,
19901
+ HcmClient as HcmClient28,
19591
19902
  ReconLayout,
19592
19903
  ROUND_EXIT_CODES,
19593
19904
  computeReconSourceKey,
19594
- formatObject as formatObject33,
19595
- fromAxiosError as fromAxiosError25,
19905
+ formatObject as formatObject34,
19906
+ fromAxiosError as fromAxiosError26,
19596
19907
  httpProbe as httpProbe3,
19597
19908
  inspectRound,
19598
19909
  renderRound,
@@ -19602,8 +19913,8 @@ var DEFAULT_CAPABILITIES = "default";
19602
19913
  async function deliveryReconCommand(args) {
19603
19914
  try {
19604
19915
  const ctx = await getActiveAuthContextFromCli(args);
19605
- const client3 = HcmClient27.fromAuthContext(ctx);
19606
- const probe2 = httpProbe3(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES);
19916
+ const client4 = HcmClient28.fromAuthContext(ctx);
19917
+ const probe2 = httpProbe3(client4.raw(), args.capabilities ?? DEFAULT_CAPABILITIES);
19607
19918
  const sourceKey = await computeReconSourceKey(probe2);
19608
19919
  const layout = new ReconLayout(args.out ?? ".", ctx.tenantId, sourceKey);
19609
19920
  const summary = await runRecon(probe2, layout, {
@@ -19611,10 +19922,10 @@ async function deliveryReconCommand(args) {
19611
19922
  onlyModel: args.model ?? null,
19612
19923
  identity: ctx.tenantId ? { requestedTenantId: ctx.tenantId } : null
19613
19924
  });
19614
- process.stdout.write(formatObject33(summary, { format: args.output ?? "json" }) + "\n");
19925
+ process.stdout.write(formatObject34(summary, { format: args.output ?? "json" }) + "\n");
19615
19926
  } catch (e) {
19616
19927
  const err = e;
19617
- if (err?.isAxiosError) exitWithError(fromAxiosError25(err, args.env));
19928
+ if (err?.isAxiosError) exitWithError(fromAxiosError26(err, args.env));
19618
19929
  exitWithError(e);
19619
19930
  process.exit(1);
19620
19931
  }
@@ -19625,7 +19936,7 @@ async function deliveryReconRoundCommand(args) {
19625
19936
  const result = inspectRound(args.dir ?? ".");
19626
19937
  const fmt = args.output ?? "json";
19627
19938
  if (fmt !== "json") process.stdout.write(renderRound(result));
19628
- process.stdout.write(formatObject33(result, { format: fmt }) + "\n");
19939
+ process.stdout.write(formatObject34(result, { format: fmt }) + "\n");
19629
19940
  code2 = ROUND_EXIT_CODES[result.state];
19630
19941
  } catch (e) {
19631
19942
  exitWithError(e);
@@ -19645,7 +19956,7 @@ import {
19645
19956
  DRY_RUN_TAIL,
19646
19957
  DriftDetected,
19647
19958
  FORCE_STALE_FLAG,
19648
- HcmClient as HcmClient28,
19959
+ HcmClient as HcmClient29,
19649
19960
  fetchReconIdentity as fetchReconIdentity2,
19650
19961
  INIT_EXIT_CODES,
19651
19962
  JOURNAL_STOP_KINDS,
@@ -19701,9 +20012,9 @@ function premise(message, hint = "") {
19701
20012
  \u2192 ${hint}` : "") + "\n");
19702
20013
  return INIT_EXIT_CODES.premise;
19703
20014
  }
19704
- async function runSeedPlan(args, client3) {
20015
+ async function runSeedPlan(args, client4) {
19705
20016
  const out = args.out ?? ".";
19706
- const tenant2 = tenantOf(client3);
20017
+ const tenant2 = tenantOf(client4);
19707
20018
  const work = seedWorkDir({ out, tenant: tenant2, work: args.work ?? null, mapping: args.mapping ?? null });
19708
20019
  const mappingPath = seedMappingPath({ out, tenant: tenant2, mapping: args.mapping ?? null }, work);
19709
20020
  if (!existsSync4(mappingPath)) {
@@ -19743,7 +20054,7 @@ async function runSeedPlan(args, client3) {
19743
20054
  let plan;
19744
20055
  let risk;
19745
20056
  try {
19746
- plan = await planFromArtifacts(client3, mappingPath, args.sourceDir, { baseline });
20057
+ plan = await planFromArtifacts(client4, mappingPath, args.sourceDir, { baseline });
19747
20058
  risk = await riskFromArtifacts(mappingPath, reconDir, {
19748
20059
  sourceDir: args.sourceDir,
19749
20060
  exemptions,
@@ -19769,8 +20080,8 @@ async function runSeedPlan(args, client3) {
19769
20080
  for (const line of planProblemLines(plan, risk)) process.stderr.write(line + "\n");
19770
20081
  return planRc(plan, risk);
19771
20082
  }
19772
- function tenantOf(client3) {
19773
- const t = client3?.tenantId;
20083
+ function tenantOf(client4) {
20084
+ const t = client4?.tenantId;
19774
20085
  return t === void 0 || t === null ? "" : String(t);
19775
20086
  }
19776
20087
  async function authOrSignpost(args, cmd) {
@@ -19785,11 +20096,11 @@ async function authOrSignpost(args, cmd) {
19785
20096
  }
19786
20097
  async function deliverySeedPlanCommand(args) {
19787
20098
  const ctx = await authOrSignpost(args, "plan");
19788
- const client3 = HcmClient28.fromAuthContext(ctx);
19789
- process.exitCode = await runSeedPlan(args, seedClient(client3, ctx));
20099
+ const client4 = HcmClient29.fromAuthContext(ctx);
20100
+ process.exitCode = await runSeedPlan(args, seedClient(client4, ctx));
19790
20101
  }
19791
- function seedClient(client3, ctx) {
19792
- const raw = client3.raw();
20102
+ function seedClient(client4, ctx) {
20103
+ const raw = client4.raw();
19793
20104
  const wrap = async (send) => {
19794
20105
  try {
19795
20106
  const res = await send();
@@ -19819,8 +20130,8 @@ function seedClient(client3, ctx) {
19819
20130
  post: (p, body) => wrap(() => raw.post(p, body))
19820
20131
  };
19821
20132
  }
19822
- async function seedVerifyClient(client3, ctx) {
19823
- const base = seedClient(client3, ctx);
20133
+ async function seedVerifyClient(client4, ctx) {
20134
+ const base = seedClient(client4, ctx);
19824
20135
  const identity3 = await fetchReconIdentity2(base, String(ctx.tenantId ?? ""));
19825
20136
  return { ...base, identity: identity3 };
19826
20137
  }
@@ -19833,9 +20144,9 @@ function lowerCaseHeaders(headers) {
19833
20144
  return out;
19834
20145
  }
19835
20146
  var DEFAULT_CAPABILITIES2 = "default";
19836
- async function runSeedApply(args, client3) {
20147
+ async function runSeedApply(args, client4) {
19837
20148
  const out = args.out ?? ".";
19838
- const tenant2 = tenantOf(client3);
20149
+ const tenant2 = tenantOf(client4);
19839
20150
  const work = seedWorkDir({ out, tenant: tenant2, work: args.work ?? null, mapping: args.mapping ?? null });
19840
20151
  const mappingPath = seedMappingPath({ out, tenant: tenant2, mapping: args.mapping ?? null }, work);
19841
20152
  let plan;
@@ -19893,7 +20204,7 @@ async function runSeedApply(args, client3) {
19893
20204
  }
19894
20205
  }
19895
20206
  const [recorded, loadCause] = loadRecordedFingerprint(out, plan.baseline?.path ?? null);
19896
- const current = await computeFingerprint(client3);
20207
+ const current = await computeFingerprint(client4);
19897
20208
  const verdict = judgeDrift(recorded, current, { baseline: plan.baseline?.path ?? null, loadCause });
19898
20209
  let note;
19899
20210
  try {
@@ -19925,7 +20236,7 @@ async function runSeedApply(args, client3) {
19925
20236
  `);
19926
20237
  let report;
19927
20238
  try {
19928
- report = await applyPlan(client3, plan, mapping, journal, {
20239
+ report = await applyPlan(client4, plan, mapping, journal, {
19929
20240
  dryRun: !args.execute,
19930
20241
  sample: args.sample ?? null,
19931
20242
  onRequestSpent: lease.heartbeatIfDue.bind(lease)
@@ -19959,12 +20270,12 @@ async function runSeedApply(args, client3) {
19959
20270
  }
19960
20271
  async function deliverySeedApplyCommand(args) {
19961
20272
  const ctx = await authOrSignpost(args, "apply");
19962
- const client3 = HcmClient28.fromAuthContext(ctx);
19963
- process.exitCode = await runSeedApply(args, seedClient(client3, ctx));
20273
+ const client4 = HcmClient29.fromAuthContext(ctx);
20274
+ process.exitCode = await runSeedApply(args, seedClient(client4, ctx));
19964
20275
  }
19965
- async function runSeedVerify(args, client3) {
20276
+ async function runSeedVerify(args, client4) {
19966
20277
  const out = args.out ?? ".";
19967
- const tenant2 = tenantOf(client3);
20278
+ const tenant2 = tenantOf(client4);
19968
20279
  const work = seedWorkDir({ out, tenant: tenant2, work: args.work ?? null, mapping: args.mapping ?? null });
19969
20280
  let delivery;
19970
20281
  try {
@@ -19973,7 +20284,7 @@ async function runSeedVerify(args, client3) {
19973
20284
  if (e instanceof JournalError) return premise(`\u53F0\u8D26\u8BFB\u4E0D\u56DE\u6765\uFF1A[${e.reason}] ${e.message}`, e.hint ?? "");
19974
20285
  throw e;
19975
20286
  }
19976
- const recon2 = isZeroNetwork(args) ? notAsked(delivery) : await buildReconciliation(delivery, client3);
20287
+ const recon2 = isZeroNetwork(args) ? notAsked(delivery) : await buildReconciliation(delivery, client4);
19977
20288
  process.stdout.write(verifyText(delivery, recon2));
19978
20289
  return verifyRc(delivery, recon2);
19979
20290
  }
@@ -19983,8 +20294,8 @@ async function deliverySeedVerifyCommand(args) {
19983
20294
  return;
19984
20295
  }
19985
20296
  const ctx = await authOrSignpost(args, "verify");
19986
- const client3 = HcmClient28.fromAuthContext(ctx);
19987
- process.exitCode = await runSeedVerify(args, await seedVerifyClient(client3, ctx));
20297
+ const client4 = HcmClient29.fromAuthContext(ctx);
20298
+ process.exitCode = await runSeedVerify(args, await seedVerifyClient(client4, ctx));
19988
20299
  }
19989
20300
 
19990
20301
  // src/commands/delivery-seed-find.ts
@@ -20098,7 +20409,7 @@ import {
20098
20409
  CHANGE_STATES,
20099
20410
  CHANGE_UNKNOWN,
20100
20411
  CODE_WORDS,
20101
- HcmClient as HcmClient29,
20412
+ HcmClient as HcmClient30,
20102
20413
  INIT_EXIT_CODES as INIT_EXIT_CODES3,
20103
20414
  META_WRITE_STEPS,
20104
20415
  META_VERIFY_STEPS,
@@ -20237,7 +20548,7 @@ function premise3(what, hint) {
20237
20548
  `);
20238
20549
  return INIT_EXIT_CODES3.premise;
20239
20550
  }
20240
- async function runDeliveryMeta(args, client3) {
20551
+ async function runDeliveryMeta(args, client4) {
20241
20552
  let content;
20242
20553
  try {
20243
20554
  content = readFileSync9(args.contentFile, "utf-8");
@@ -20248,7 +20559,7 @@ async function runDeliveryMeta(args, client3) {
20248
20559
  );
20249
20560
  }
20250
20561
  const workDir = seedWorkDir2({ out: args.out, tenant: String(args.tenant ?? ""), work: args.work });
20251
- const change = await runMetaChange(client3, {
20562
+ const change = await runMetaChange(client4, {
20252
20563
  layer: args.layer,
20253
20564
  workspaceKey: args.workspace,
20254
20565
  model: args.model,
@@ -20262,7 +20573,7 @@ async function runDeliveryMeta(args, client3) {
20262
20573
  let verifyCode = args.verifyActive ? VERIFY_NOT_REACHED : VERIFY_NOT_ASKED;
20263
20574
  if (args.verifyActive && change.ok) {
20264
20575
  try {
20265
- verify = await runActiveVerify(client3, {
20576
+ verify = await runActiveVerify(client4, {
20266
20577
  model: args.model,
20267
20578
  workspaceKey: args.workspace,
20268
20579
  expectFields: args.expectField
@@ -20284,8 +20595,8 @@ async function runDeliveryMeta(args, client3) {
20284
20595
  }
20285
20596
  return rc;
20286
20597
  }
20287
- function metaClient(client3, ctx) {
20288
- const raw = client3.raw();
20598
+ function metaClient(client4, ctx) {
20599
+ const raw = client4.raw();
20289
20600
  const wrap = async (send) => {
20290
20601
  try {
20291
20602
  const res = await send();
@@ -20326,10 +20637,10 @@ function lowerCaseHeaders2(headers) {
20326
20637
  }
20327
20638
  async function deliveryMetaCommand(args) {
20328
20639
  const ctx = await getActiveAuthContextFromCli(args);
20329
- const client3 = HcmClient29.fromAuthContext(ctx);
20640
+ const client4 = HcmClient30.fromAuthContext(ctx);
20330
20641
  process.exitCode = await runDeliveryMeta(
20331
20642
  { ...args, tenant: args.tenant ?? String(ctx.tenantId ?? "") },
20332
- metaClient(client3, ctx)
20643
+ metaClient(client4, ctx)
20333
20644
  );
20334
20645
  }
20335
20646
 
@@ -20338,7 +20649,7 @@ init_auth_guard();
20338
20649
  init_exit();
20339
20650
  import {
20340
20651
  computeReconSourceKey as computeReconSourceKey2,
20341
- HcmClient as HcmClient30,
20652
+ HcmClient as HcmClient31,
20342
20653
  httpProbe as httpProbe4,
20343
20654
  ReconLayout as ReconLayout2,
20344
20655
  runTriageRound
@@ -20394,8 +20705,8 @@ async function runTriage(args) {
20394
20705
  return premise4(e instanceof Error ? e.message : String(e), REQUESTS_SHAPE);
20395
20706
  }
20396
20707
  const ctx = await getActiveAuthContextFromCli(args);
20397
- const client3 = HcmClient30.fromAuthContext(ctx);
20398
- const probe2 = httpProbe4(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES3);
20708
+ const client4 = HcmClient31.fromAuthContext(ctx);
20709
+ const probe2 = httpProbe4(client4.raw(), args.capabilities ?? DEFAULT_CAPABILITIES3);
20399
20710
  const artifactsDir = args.recon ?? new ReconLayout2(args.out ?? ".", ctx.tenantId, await computeReconSourceKey2(probe2)).dir;
20400
20711
  const result = await runTriageRound(probe2, artifactsDir, entriesIn);
20401
20712
  if (result.body === null) {
@@ -20423,25 +20734,25 @@ async function deliveryTriageCommand(args) {
20423
20734
  init_auth_guard();
20424
20735
  init_exit();
20425
20736
  import {
20426
- HcmClient as HcmClient31,
20737
+ HcmClient as HcmClient32,
20427
20738
  adminResetPassword,
20428
- formatObject as formatObject34,
20429
- fromAxiosError as fromAxiosError26,
20430
- CliError as CliError40,
20431
- CliErrorCode as CliErrorCode41
20739
+ formatObject as formatObject35,
20740
+ fromAxiosError as fromAxiosError27,
20741
+ CliError as CliError41,
20742
+ CliErrorCode as CliErrorCode42
20432
20743
  } from "@hcmai/sdk";
20433
20744
  function buildAdminResetPasswordRequest(args, password) {
20434
20745
  const hasId = Boolean(args.id);
20435
20746
  const hasUsername = Boolean(args.username);
20436
20747
  if (hasId === hasUsername) {
20437
- throw new CliError40({
20438
- code: CliErrorCode41.INVALID_ARGUMENT,
20748
+ throw new CliError41({
20749
+ code: CliErrorCode42.INVALID_ARGUMENT,
20439
20750
  message: "--id <uuid> \u4E0E --username <user> \u5FC5\u987B\u4E14\u53EA\u80FD\u63D0\u4F9B\u4E00\u4E2A"
20440
20751
  });
20441
20752
  }
20442
20753
  if (!password) {
20443
- throw new CliError40({
20444
- code: CliErrorCode41.INVALID_ARGUMENT,
20754
+ throw new CliError41({
20755
+ code: CliErrorCode42.INVALID_ARGUMENT,
20445
20756
  message: "\u65B0\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A"
20446
20757
  });
20447
20758
  }
@@ -20457,12 +20768,12 @@ async function userResetPasswordCommand(args) {
20457
20768
  try {
20458
20769
  const password = args.passwordStdin ? await readSecretFromStdin() : await promptPasswordTwice();
20459
20770
  const request = buildAdminResetPasswordRequest(args, password);
20460
- const client3 = HcmClient31.fromAuthContext(await getActiveAuthContextFromCli(args));
20461
- const result = await adminResetPassword(client3.raw(), request);
20462
- process.stdout.write(formatObject34(result, { format: args.output ?? "json" }) + "\n");
20771
+ const client4 = HcmClient32.fromAuthContext(await getActiveAuthContextFromCli(args));
20772
+ const result = await adminResetPassword(client4.raw(), request);
20773
+ process.stdout.write(formatObject35(result, { format: args.output ?? "json" }) + "\n");
20463
20774
  } catch (cause) {
20464
20775
  const err = cause;
20465
- if (err?.isAxiosError) exitWithError(fromAxiosError26(err, args.env));
20776
+ if (err?.isAxiosError) exitWithError(fromAxiosError27(err, args.env));
20466
20777
  exitWithError(cause);
20467
20778
  }
20468
20779
  }
@@ -20470,8 +20781,8 @@ async function promptPasswordTwice() {
20470
20781
  const password = await promptSecret("\u65B0\u5BC6\u7801: ");
20471
20782
  const confirmation = await promptSecret("\u518D\u6B21\u8F93\u5165\u65B0\u5BC6\u7801: ");
20472
20783
  if (password !== confirmation) {
20473
- throw new CliError40({
20474
- code: CliErrorCode41.INVALID_ARGUMENT,
20784
+ throw new CliError41({
20785
+ code: CliErrorCode42.INVALID_ARGUMENT,
20475
20786
  message: "\u4E24\u6B21\u8F93\u5165\u7684\u65B0\u5BC6\u7801\u4E0D\u4E00\u81F4"
20476
20787
  });
20477
20788
  }
@@ -20482,19 +20793,19 @@ async function promptPasswordTwice() {
20482
20793
  init_exit();
20483
20794
  init_auth_guard();
20484
20795
  import {
20485
- HcmClient as HcmClient32,
20486
- formatObject as formatObject35,
20487
- fromAxiosError as fromAxiosError27
20796
+ HcmClient as HcmClient33,
20797
+ formatObject as formatObject36,
20798
+ fromAxiosError as fromAxiosError28
20488
20799
  } from "@hcmai/sdk";
20489
20800
  async function modelsCommand(keyword, args) {
20490
20801
  try {
20491
- const client3 = HcmClient32.fromAuthContext(await getActiveAuthContextFromCli(args));
20492
- const all = await client3.listModels();
20802
+ const client4 = HcmClient33.fromAuthContext(await getActiveAuthContextFromCli(args));
20803
+ const all = await client4.listModels();
20493
20804
  const needle = keyword?.trim().toLowerCase();
20494
20805
  const rows2 = (needle ? all.filter((m) => JSON.stringify(m).toLowerCase().includes(needle)) : all).sort((a, b) => key(a).localeCompare(key(b)));
20495
20806
  const fmt = args.output ?? "table";
20496
20807
  if (fmt !== "table") {
20497
- process.stdout.write(formatObject35({ total: rows2.length, models: rows2 }, { format: fmt }) + "\n");
20808
+ process.stdout.write(formatObject36({ total: rows2.length, models: rows2 }, { format: fmt }) + "\n");
20498
20809
  process.exitCode = 0;
20499
20810
  return;
20500
20811
  }
@@ -20521,7 +20832,7 @@ async function modelsCommand(keyword, args) {
20521
20832
  return;
20522
20833
  } catch (e) {
20523
20834
  const err = e;
20524
- if (err?.isAxiosError) exitWithError(fromAxiosError27(err, args.profile));
20835
+ if (err?.isAxiosError) exitWithError(fromAxiosError28(err, args.profile));
20525
20836
  exitWithError(e);
20526
20837
  }
20527
20838
  }
@@ -20822,6 +21133,12 @@ meta.command("validate <path>").description(
20822
21133
  "\u96F6\u7F51\u7EDC\uFF1A\u6309 core \u4ED3\u7684 JSON Schema \u9A8C\u4E00\u4EFD meta \u539F\u6587\uFF08path \u53EA\u7528\u6765\u6311 schema\uFF0C\u4E0D\u53D1\u8BF7\u6C42\uFF09"
20823
21134
  ).requiredOption("--file <file>", "\u8981\u9A8C\u7684\u539F\u6587\uFF08- \u8868\u793A stdin\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((p, opts) => metaValidateCommand(p, opts));
20824
21135
  meta.command("delete <path>").description("\u5220\u9664 meta\uFF08\u4E0D\u53EF\u9006\uFF0C\u9ED8\u8BA4\u8FC7\u786E\u8BA4\u95F8\uFF09").option("-y, --yes", "\u8DF3\u8FC7\u786E\u8BA4").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", "json").action((p, opts) => metaDeleteCommand(p, opts));
21136
+ var COLUMN_SLOT_HELP = "\n\u8BF4\u660E\uFF1A\u8FD9\u662F\u79DF\u6237\u5185\u53EA\u8BFB\u63A5\u53E3\uFF08\u53EA\u53D1 GET\uFF0C\u79DF\u6237\u7531\u5F53\u524D\u4EE4\u724C\u51B3\u5B9A\uFF09\uFF0C\u4E0D\u6539\u4EFB\u4F55\u4E1C\u897F\u3002\n\u69FD\u7684\u767B\u8BB0 / \u590D\u6838 / \u6458\u9664\u662F\u5E73\u53F0\u65B9\u6301\u5E73\u53F0\u5BC6\u94A5\u505A\u7684\u8DE8\u79DF\u6237\u64CD\u4F5C\uFF0CCLI \u4E0D\u63D0\u4F9B\uFF0C\u987E\u95EE\u4E5F\u4E0D\u505A\uFF1A\u6CA1\u6709\u5408\u9002\u7684\u69FD\uFF0C\u5C31\u628A\u6A21\u578B\u3001\u8868\u540D\u3001\u8981\u7684\u69FD\u7C7B\u578B\u4EA4\u7ED9\u5E73\u53F0\u65B9\u3002\n\u6765\u6E90\uFF1A\u5E26 --workspace \u770B\u8BE5\u5F00\u53D1\u7A7A\u95F4\uFF08\u53E0\u52A0 active\uFF09\uFF1B\u4E0D\u5E26\u65F6\u6309\u5F53\u524D\u8EAB\u4EFD\u7684\u5F00\u53D1\u6A21\u5F0F\u7ED1\u5B9A\uFF08hcm workspace activate\uFF09\uFF0C\u6CA1\u7ED1\u5B9A\u5C31\u662F active\u3002\u8F93\u51FA\u91CC\u7684\u300C\u6765\u6E90\u300D\u8BF4\u660E\u8FD9\u6B21\u5B9E\u9645\u7528\u7684\u662F\u54EA\u4E00\u5C42\u3002\n";
21137
+ meta.command("column-slots <Model>").description("\u53EA\u8BFB\uFF1A\u67E5\u6A21\u578B\u5BBF\u4E3B\u8868\u4E0A\u672C\u79DF\u6237\u53EF\u9009 / \u5DF2\u5360\u7528 / \u4E0D\u53EF\u7528\u7684\u7269\u7406\u5217\u69FD\uFF08\u79DF\u6237\u5185\uFF09").option("--workspace <key>", "\u5F00\u53D1\u7A7A\u95F4 key\uFF1A\u5E26 X-Workspace-Key \u770B\u8BE5\u5F00\u53D1\u7A7A\u95F4\uFF1B\u4E0D\u5E26\u6309\u5F53\u524D\u5F00\u53D1\u6A21\u5F0F\u7ED1\u5B9A").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\uFF08json / yaml \u539F\u6837\u7ED9\u670D\u52A1\u7AEF data\uFF09", "table").addHelpText("after", COLUMN_SLOT_HELP).action((model, opts) => metaColumnSlotsCommand(model, opts));
21138
+ meta.command("column-slot-sql <Model> <field>").description("\u53EA\u8BFB\uFF1A\u6309\u672C\u79DF\u6237\u7ED9\u51FA\u8BE5\u5B57\u6BB5\u5728\u5217\u69FD\u4E0E flex \u4E4B\u95F4\u642C\u6570\u636E / \u6E05\u6570\u636E\u7684 SQL \u539F\u53E5\uFF08\u670D\u52A1\u7AEF\u4E0E CLI \u90FD\u4E0D\u6267\u884C\uFF0C\u4EA4 DBA\uFF09").option("--slot <column>", "\u76EE\u6807\u69FD ext_*\uFF08flex \u5B57\u6BB5\u5FC5\u586B\uFF1B\u5217\u69FD\u5B57\u6BB5\u7F3A\u7701\u53D6\u5F53\u524D\u7ED1\u5B9A\u7684\u69FD\uFF09").option("--from-slot <column>", "\u6539\u7ED1\u65F6\u7684\u65E7\u69FD ext_*\uFF1A\u53E6\u7ED9 moveFromSlot / verifyMoveFromSlot / clearFromSlot \u4E09\u53E5").option(
21139
+ "--only <key>",
21140
+ `\u53EA\u8F93\u51FA\u8FD9\u4E00\u53E5 SQL \u539F\u6587\uFF08\u65E0\u88C5\u9970\uFF0C\u53EF\u91CD\u5B9A\u5411\u7ED9 DBA\uFF1B\u5FFD\u7565 --output\uFF09\uFF1A${COLUMN_SLOT_SQL_KEYS2.join(" | ")}\uFF1B\u8BE5\u53E5\u7ED9\u4E0D\u51FA\u65F6\u975E\u96F6\u9000\u51FA\u5E76\u5728 stderr \u8BF4\u539F\u56E0`
21141
+ ).option("--workspace <key>", "\u5F00\u53D1\u7A7A\u95F4 key\uFF1A\u5E26 X-Workspace-Key \u770B\u8BE5\u5F00\u53D1\u7A7A\u95F4\uFF1B\u4E0D\u5E26\u6309\u5F53\u524D\u5F00\u53D1\u6A21\u5F0F\u7ED1\u5B9A").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\uFF08json / yaml \u539F\u6837\u7ED9\u670D\u52A1\u7AEF data\uFF09", "table").addHelpText("after", COLUMN_SLOT_HELP).action((model, field, opts) => metaColumnSlotSqlCommand(model, field, opts));
20825
21142
  var skills = program.command("skills").description("\u4EA4\u4ED8\u6280\u80FD\uFF1A\u777F\u620E Chiron \u6280\u80FD\u5E93 + CLI \u81EA\u5E26\u6280\u80FD\uFF08\u514D\u8BA4\u8BC1\uFF0C\u65E0\u9700\u5148 login\uFF09");
20826
21143
  skills.command("list [keyword]").description("\u5217\u51FA\u76EE\u6807\u73AF\u5883\u8FD9\u4E00\u7248\u7684\u4EA4\u4ED8\u6280\u80FD\uFF1B--installed \u6539\u770B\u672C\u5730\u88C5\u4E86\u54EA\u4E9B\uFF08\u4E0D\u8FDE\u7F51\uFF09").option("--installed", "\u53EA\u770B\u672C\u5730\u5DF2\u88C5\u7684\u6280\u80FD\uFF08\u8BFB .hcm-skills.json\uFF0C\u4E0D\u8FDE\u7F51\uFF09").option("--target <agent>", "\u914D\u5408 --installed\uFF1Aclaude | codex | auto", "auto").option("--global", "\u914D\u5408 --installed\uFF1A\u770B\u7528\u6237\u7EA7\u76EE\u5F55").option("--dir <path>", "\u914D\u5408 --installed\uFF1A\u770B\u6307\u5B9A\u76EE\u5F55").option("--category <key>", "\u53EA\u770B\u67D0\u4E2A\u5206\u7C7B").option(
20827
21144
  "--stage <key>",