@hcmai/cli 0.4.3 → 0.4.5

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
@@ -2286,9 +2286,9 @@ async function loginCommand(args) {
2286
2286
  } catch (e) {
2287
2287
  const err = e;
2288
2288
  if (err.isAxiosError) {
2289
- const { fromAxiosError: fromAxiosError21 } = await import("@hcmai/sdk");
2289
+ const { fromAxiosError: fromAxiosError22 } = await import("@hcmai/sdk");
2290
2290
  exitWithError(
2291
- fromAxiosError21(
2291
+ fromAxiosError22(
2292
2292
  e,
2293
2293
  envName
2294
2294
  )
@@ -3211,29 +3211,29 @@ import {
3211
3211
  import chalk2 from "chalk";
3212
3212
  import * as fs4 from "fs/promises";
3213
3213
  function parseInjectOn(s) {
3214
- const fail5 = (detail) => {
3214
+ const fail6 = (detail) => {
3215
3215
  throw new CliError13({
3216
3216
  code: CliErrorCode12.INVALID_ARGUMENT,
3217
3217
  message: `--inject-on \u683C\u5F0F <eventType>:<action>[:<arg>]\uFF0Caction \u2208 {interrupt, steer}\uFF08steer \u5FC5\u987B\u5E26 content\uFF09\uFF1B${detail}\uFF0C\u6536\u5230 "${s}"`
3218
3218
  });
3219
3219
  };
3220
3220
  const firstColon = s.indexOf(":");
3221
- if (firstColon < 0) return fail5("\u7F3A\u5C11 action \u6BB5");
3221
+ if (firstColon < 0) return fail6("\u7F3A\u5C11 action \u6BB5");
3222
3222
  const eventType = s.slice(0, firstColon);
3223
3223
  const rest = s.slice(firstColon + 1);
3224
3224
  const secondColon = rest.indexOf(":");
3225
3225
  const action = secondColon < 0 ? rest : rest.slice(0, secondColon);
3226
3226
  const arg = secondColon < 0 ? void 0 : rest.slice(secondColon + 1);
3227
- if (!eventType) return fail5("eventType \u6BB5\u4E3A\u7A7A");
3227
+ if (!eventType) return fail6("eventType \u6BB5\u4E3A\u7A7A");
3228
3228
  if (action === "interrupt") {
3229
- if (arg !== void 0) return fail5("interrupt \u4E0D\u63A5\u53D7 arg");
3229
+ if (arg !== void 0) return fail6("interrupt \u4E0D\u63A5\u53D7 arg");
3230
3230
  return { eventType, action: "interrupt" };
3231
3231
  }
3232
3232
  if (action === "steer") {
3233
- if (arg === void 0 || arg === "") return fail5("steer \u5FC5\u987B\u5E26 content\uFF08arg\uFF09");
3233
+ if (arg === void 0 || arg === "") return fail6("steer \u5FC5\u987B\u5E26 content\uFF08arg\uFF09");
3234
3234
  return { eventType, action: "steer", arg };
3235
3235
  }
3236
- return fail5(`\u672A\u77E5 action "${action}"`);
3236
+ return fail6(`\u672A\u77E5 action "${action}"`);
3237
3237
  }
3238
3238
  function parseOnConfirm(s) {
3239
3239
  if (s === "approve") return { decision: "approve" };
@@ -4258,20 +4258,131 @@ async function cacheClearMetaCommand(model, args) {
4258
4258
  }
4259
4259
  }
4260
4260
 
4261
- // src/commands/upload.ts
4261
+ // src/commands/script.ts
4262
4262
  init_exit();
4263
4263
  init_auth_guard();
4264
+ import { readFileSync as readFileSync3 } from "fs";
4264
4265
  import {
4265
4266
  HcmClient as HcmClient14,
4266
4267
  formatObject as formatObject12,
4267
4268
  fromAxiosError as fromAxiosError12,
4269
+ scriptDryRun,
4270
+ validateScriptManifest,
4271
+ queryScriptLogs,
4272
+ getScriptTask
4273
+ } from "@hcmai/sdk";
4274
+ async function withClient2(args, fn) {
4275
+ const client3 = HcmClient14.fromAuthContext(await getActiveAuthContextFromCli(args));
4276
+ return fn(client3);
4277
+ }
4278
+ function emit2(result, args, human) {
4279
+ const fmt = args.output ?? "json";
4280
+ if (fmt !== "json") process.stdout.write(human + "\n");
4281
+ process.stdout.write(formatObject12(result, { format: fmt }) + "\n");
4282
+ process.exit(0);
4283
+ }
4284
+ function fail3(e, args) {
4285
+ const err = e;
4286
+ if (err?.isAxiosError) exitWithError(fromAxiosError12(err, args.env));
4287
+ exitWithError(e);
4288
+ process.exit(1);
4289
+ }
4290
+ function parseJsonArg(raw, field) {
4291
+ if (raw === void 0) return void 0;
4292
+ try {
4293
+ const parsed = JSON.parse(raw);
4294
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
4295
+ throw new Error(`${field} \u5FC5\u987B\u662F JSON \u5BF9\u8C61\uFF0C\u5B9E\u9645\u662F ${Array.isArray(parsed) ? "\u6570\u7EC4" : typeof parsed}`);
4296
+ }
4297
+ return parsed;
4298
+ } catch (e) {
4299
+ throw new Error(`--${field} \u4E0D\u662F\u5408\u6CD5 JSON \u5BF9\u8C61\uFF1A${e.message}
4300
+ \u6536\u5230\uFF1A${raw}`);
4301
+ }
4302
+ }
4303
+ async function scriptDryRunCommand(args) {
4304
+ try {
4305
+ if (!args.scriptKey) {
4306
+ throw new Error("\u7F3A\u5C11 --script-key\n \u4E0B\u4E00\u6B65\uFF1Ahcm script dry-run --script-key <scriptKey>");
4307
+ }
4308
+ if (args.params && args.paramsFile) {
4309
+ throw new Error("--params \u4E0E --params-file \u4E92\u65A5\uFF0C\u4E8C\u9009\u4E00");
4310
+ }
4311
+ const rawParams = args.paramsFile ? readFileSync3(args.paramsFile, "utf8") : args.params;
4312
+ const request = {
4313
+ scriptKey: args.scriptKey,
4314
+ modelKey: args.model,
4315
+ actionKey: args.action,
4316
+ scope: args.scope,
4317
+ httpMethod: args.method,
4318
+ targetId: args.targetId,
4319
+ params: parseJsonArg(rawParams, "params"),
4320
+ context: parseJsonArg(args.context, "context"),
4321
+ event: parseJsonArg(args.event, "event"),
4322
+ timeoutMs: args.timeout ? Number(args.timeout) : void 0
4323
+ };
4324
+ const result = await withClient2(args, (c) => scriptDryRun(c.raw(), request));
4325
+ const intents = Array.isArray(result?.writeIntents) ? result.writeIntents.length : 0;
4326
+ emit2(result, args, `\u{1F9EA} dry-run \u5B8C\u6210\uFF1A${args.scriptKey}\uFF08\u62E6\u4E0B ${intents} \u4E2A\u5199\u610F\u56FE\uFF09`);
4327
+ } catch (e) {
4328
+ fail3(e, args);
4329
+ }
4330
+ }
4331
+ async function scriptManifestValidateCommand(args) {
4332
+ try {
4333
+ if (!args.file) {
4334
+ throw new Error("\u7F3A\u5C11 --file\n \u4E0B\u4E00\u6B65\uFF1Ahcm script manifest-validate --file ./manifest.yml");
4335
+ }
4336
+ const yaml = readFileSync3(args.file, "utf8");
4337
+ const result = await withClient2(args, (c) => validateScriptManifest(c.raw(), yaml));
4338
+ emit2(result, args, `\u{1F4CB} manifest \u6821\u9A8C\u5B8C\u6210\uFF1A${args.file}`);
4339
+ } catch (e) {
4340
+ fail3(e, args);
4341
+ }
4342
+ }
4343
+ async function scriptLogsCommand(args) {
4344
+ try {
4345
+ const page = await withClient2(
4346
+ args,
4347
+ (c) => queryScriptLogs(c.raw(), {
4348
+ scriptKey: args.scriptKey,
4349
+ status: args.status,
4350
+ mode: args.mode,
4351
+ dryRun: args.dryRun,
4352
+ from: args.from,
4353
+ to: args.to,
4354
+ page: args.page ? Number(args.page) : void 0,
4355
+ size: args.size ? Number(args.size) : void 0
4356
+ })
4357
+ );
4358
+ emit2(page, args, "\u{1F4DC} \u811A\u672C\u6267\u884C\u65E5\u5FD7");
4359
+ } catch (e) {
4360
+ fail3(e, args);
4361
+ }
4362
+ }
4363
+ async function scriptTaskCommand(taskId, args) {
4364
+ try {
4365
+ const task = await withClient2(args, (c) => getScriptTask(c.raw(), taskId));
4366
+ emit2(task, args, `\u2699\uFE0F \u4EFB\u52A1 ${taskId}\uFF1A${task?.status ?? "\u672A\u77E5"}\uFF08\u7B2C ${task?.attempts ?? "?"}/${task?.maxAttempts ?? "?"} \u6B21\uFF09`);
4367
+ } catch (e) {
4368
+ fail3(e, args);
4369
+ }
4370
+ }
4371
+
4372
+ // src/commands/upload.ts
4373
+ init_exit();
4374
+ init_auth_guard();
4375
+ import {
4376
+ HcmClient as HcmClient15,
4377
+ formatObject as formatObject13,
4378
+ fromAxiosError as fromAxiosError13,
4268
4379
  uploadDocument as uploadDocument2
4269
4380
  } from "@hcmai/sdk";
4270
4381
  var DEFAULT_UPLOAD_CATEGORY = "attachment";
4271
4382
  async function uploadCommand(filePath, args) {
4272
4383
  try {
4273
4384
  const ctx = await getActiveAuthContextFromCli(args);
4274
- const client3 = HcmClient14.fromAuthContext(ctx);
4385
+ const client3 = HcmClient15.fromAuthContext(ctx);
4275
4386
  const meta2 = await uploadDocument2(
4276
4387
  client3.raw(),
4277
4388
  filePath,
@@ -4284,7 +4395,7 @@ async function uploadCommand(filePath, args) {
4284
4395
  `
4285
4396
  );
4286
4397
  }
4287
- process.stdout.write(formatObject12(meta2, { format: fmt }) + "\n");
4398
+ process.stdout.write(formatObject13(meta2, { format: fmt }) + "\n");
4288
4399
  process.exit(0);
4289
4400
  } catch (e) {
4290
4401
  const err = e;
@@ -4294,7 +4405,7 @@ async function uploadCommand(filePath, args) {
4294
4405
  } else if (status === 413) {
4295
4406
  exitWithError(new Error("\u6587\u4EF6\u8D85\u51FA\u670D\u52A1\u7AEF\u5927\u5C0F\u4E0A\u9650\uFF08413\uFF09"));
4296
4407
  } else if (err?.isAxiosError) {
4297
- exitWithError(fromAxiosError12(err, args.env));
4408
+ exitWithError(fromAxiosError13(err, args.env));
4298
4409
  } else {
4299
4410
  exitWithError(e);
4300
4411
  }
@@ -4322,8 +4433,8 @@ import {
4322
4433
  resolveAllSkillsInstallOrder,
4323
4434
  matchSkills,
4324
4435
  filterByStage,
4325
- formatObject as formatObject14,
4326
- fromAxiosError as fromAxiosError13,
4436
+ formatObject as formatObject15,
4437
+ fromAxiosError as fromAxiosError14,
4327
4438
  loadEnv as loadEnv5,
4328
4439
  loadGlobalConfig as loadGlobalConfig6,
4329
4440
  resolveActiveEnv as resolveActiveEnv3,
@@ -4450,11 +4561,11 @@ import * as path3 from "path";
4450
4561
  import { CliError as CliError15, CliErrorCode as CliErrorCode14, assertSafeReferencePath, parseSkillRequirements } from "@hcmai/sdk";
4451
4562
 
4452
4563
  // src/commands/skills-manifest.ts
4453
- import { readFileSync as readFileSync3, readdirSync as readdirSync2, statSync as statSync3, existsSync } from "fs";
4564
+ import { readFileSync as readFileSync4, readdirSync as readdirSync2, statSync as statSync3, existsSync } from "fs";
4454
4565
  import { createHash } from "crypto";
4455
4566
  import * as path2 from "path";
4456
4567
  import { fileURLToPath } from "url";
4457
- import { formatObject as formatObject13, parseSkillFrontmatter } from "@hcmai/sdk";
4568
+ import { formatObject as formatObject14, parseSkillFrontmatter } from "@hcmai/sdk";
4458
4569
  function collectCommandSurface(root) {
4459
4570
  const out = [];
4460
4571
  const walk = (cmd, prefix) => {
@@ -4495,11 +4606,11 @@ function collectBundledSkills(dir = bundledSkillsDir()) {
4495
4606
  if (!files.includes("SKILL.md")) continue;
4496
4607
  let bytes = 0;
4497
4608
  const fileRows = files.map((rel) => {
4498
- const buf = readFileSync3(path2.join(skillDir, rel));
4609
+ const buf = readFileSync4(path2.join(skillDir, rel));
4499
4610
  bytes += buf.byteLength;
4500
4611
  return { path: rel, bytes: buf.byteLength, sha256: sha256(buf) };
4501
4612
  });
4502
- const body = readFileSync3(path2.join(skillDir, "SKILL.md"), "utf8");
4613
+ const body = readFileSync4(path2.join(skillDir, "SKILL.md"), "utf8");
4503
4614
  const fm = parseSkillFrontmatter(body, id);
4504
4615
  out.push({
4505
4616
  id,
@@ -4525,7 +4636,7 @@ function buildManifest(root, skillsDir = bundledSkillsDir()) {
4525
4636
  }
4526
4637
  function skillsManifestCommand(root, args) {
4527
4638
  const manifest2 = buildManifest(root);
4528
- process.stdout.write(formatObject13(manifest2, { format: args.output ?? "json" }) + "\n");
4639
+ process.stdout.write(formatObject14(manifest2, { format: args.output ?? "json" }) + "\n");
4529
4640
  }
4530
4641
  function str(v) {
4531
4642
  return typeof v === "string" && v ? v : void 0;
@@ -4716,12 +4827,12 @@ async function chironClient(args) {
4716
4827
  });
4717
4828
  return { http, endpoint, base: await resolveChironBase(http) };
4718
4829
  }
4719
- function fail3(e, args) {
4830
+ function fail4(e, args) {
4720
4831
  const err = e;
4721
4832
  if (err?.response?.status === 404) {
4722
4833
  exitWithError(new Error("\u8BE5\u73AF\u5883\u6CA1\u6709\u8FD9\u4E2A\u6280\u80FD \u2014\u2014 \u8DD1 `hcm skills list` \u770B\u76EE\u5F55\uFF08\u6280\u80FD\u968F\u4EA7\u54C1\u7248\u672C\u8D70\uFF09"));
4723
4834
  }
4724
- if (err?.isAxiosError) exitWithError(fromAxiosError13(err, args.env));
4835
+ if (err?.isAxiosError) exitWithError(fromAxiosError14(err, args.env));
4725
4836
  exitWithError(e);
4726
4837
  process.exit(1);
4727
4838
  }
@@ -4772,7 +4883,7 @@ async function skillsListCommand(keyword, args) {
4772
4883
  }
4773
4884
  if (fmt === "json" || fmt === "yaml") {
4774
4885
  process.stdout.write(
4775
- formatObject14(
4886
+ formatObject15(
4776
4887
  {
4777
4888
  ...manifest2 ?? {},
4778
4889
  categories: cats,
@@ -4845,7 +4956,7 @@ async function skillsListCommand(keyword, args) {
4845
4956
  `);
4846
4957
  process.exit(0);
4847
4958
  } catch (e) {
4848
- fail3(e, args);
4959
+ fail4(e, args);
4849
4960
  }
4850
4961
  }
4851
4962
  async function listInstalledSkills(keyword, args) {
@@ -4854,7 +4965,7 @@ async function listInstalledSkills(keyword, args) {
4854
4965
  const fmt = args.output ?? "table";
4855
4966
  if (!state || Object.keys(state.skills).length === 0) {
4856
4967
  if (fmt === "json" || fmt === "yaml") {
4857
- process.stdout.write(formatObject14({ baseDir: layout.baseDir, target: layout.target, all: false, skills: [] }, { format: fmt }) + "\n");
4968
+ process.stdout.write(formatObject15({ baseDir: layout.baseDir, target: layout.target, all: false, skills: [] }, { format: fmt }) + "\n");
4858
4969
  process.exit(0);
4859
4970
  }
4860
4971
  process.stdout.write(`${path4.join(layout.baseDir, SKILLS_STATE_FILE)} \u4E0D\u5B58\u5728\u6216\u4E3A\u7A7A \u2014\u2014 \u8FD9\u4E2A\u76EE\u5F55\u4E0B\u8FD8\u6CA1\u7528\u672C CLI \u88C5\u8FC7\u6280\u80FD\u3002
@@ -4887,7 +4998,7 @@ async function listInstalledSkills(keyword, args) {
4887
4998
  const shown = sourceFilter === "all" ? byKeyword : byKeyword.filter((row) => row.sourceKind === sourceFilter);
4888
4999
  const groupOf = (kind) => kind === "cli" ? "CLI \u81EA\u5E26" : kind === "local" ? "\u672C\u5730\u76EE\u5F55\u88C5\u7684" : "\u777F\u620E\u6280\u80FD\u5E93";
4889
5000
  if (fmt === "json" || fmt === "yaml") {
4890
- process.stdout.write(formatObject14({
5001
+ process.stdout.write(formatObject15({
4891
5002
  baseDir: layout.baseDir,
4892
5003
  target: layout.target,
4893
5004
  endpoint: state.endpoint,
@@ -4956,7 +5067,7 @@ async function skillsShowCommand(id, args) {
4956
5067
  process.stdout.write(md.endsWith("\n") ? md : md + "\n");
4957
5068
  process.exit(0);
4958
5069
  } catch (e) {
4959
- fail3(e, args);
5070
+ fail4(e, args);
4960
5071
  }
4961
5072
  }
4962
5073
  async function skillsInstallCommand(id, args) {
@@ -5086,7 +5197,7 @@ async function skillsInstallCommand(id, args) {
5086
5197
  const agents = layout.agentsFile ? await syncAgentsIndex(layout, manifest2) : void 0;
5087
5198
  const fmt = args.output ?? "table";
5088
5199
  if (fmt === "json" || fmt === "yaml") {
5089
- process.stdout.write(formatObject14({ ...result, all, target_agent: layout.target, agentsFile: layout.agentsFile, agents, conflictCheck: conflictNote ? { checked: false, note: conflictNote } : { checked: true } }, { format: fmt }) + "\n");
5200
+ process.stdout.write(formatObject15({ ...result, all, target_agent: layout.target, agentsFile: layout.agentsFile, agents, conflictCheck: conflictNote ? { checked: false, note: conflictNote } : { checked: true } }, { format: fmt }) + "\n");
5090
5201
  } else {
5091
5202
  const headline = all ? `\u2705 \u5168\u90E8 ${requestedIds.length} \u4E2A\u6280\u80FD \u2192 ${result.baseDir}` : `\u2705 ${id} \u2192 ${path4.join(result.baseDir, id, "SKILL.md")}`;
5092
5203
  process.stdout.write(`${headline}
@@ -5118,7 +5229,7 @@ async function skillsInstallCommand(id, args) {
5118
5229
  }
5119
5230
  process.exit(0);
5120
5231
  } catch (e) {
5121
- fail3(e, args);
5232
+ fail4(e, args);
5122
5233
  }
5123
5234
  }
5124
5235
  var FETCH_CONCURRENCY = 6;
@@ -5651,7 +5762,7 @@ async function skillsUpdateCommand(args) {
5651
5762
  const changed = plan.entries.filter((e) => e.status === "updated" || e.status === "added");
5652
5763
  const fmt = args.output ?? "table";
5653
5764
  if (fmt === "json" || fmt === "yaml") {
5654
- process.stdout.write(formatObject14({
5765
+ process.stdout.write(formatObject15({
5655
5766
  endpoint,
5656
5767
  baseDir: layout.baseDir,
5657
5768
  target: layout.target,
@@ -5722,7 +5833,7 @@ async function skillsUpdateCommand(args) {
5722
5833
  }
5723
5834
  process.exit(0);
5724
5835
  } catch (e) {
5725
- fail3(e, args);
5836
+ fail4(e, args);
5726
5837
  }
5727
5838
  }
5728
5839
 
@@ -5730,8 +5841,8 @@ async function skillsUpdateCommand(args) {
5730
5841
  import {
5731
5842
  bootstrapTenant,
5732
5843
  createHttpClient as createHttpClient3,
5733
- formatObject as formatObject15,
5734
- fromAxiosError as fromAxiosError14,
5844
+ formatObject as formatObject16,
5845
+ fromAxiosError as fromAxiosError15,
5735
5846
  loadEnv as loadEnv6,
5736
5847
  loadGlobalConfig as loadGlobalConfig7,
5737
5848
  resolveActiveEnv as resolveActiveEnv4,
@@ -5822,14 +5933,14 @@ async function tenantBootstrapCommand(args) {
5822
5933
  `
5823
5934
  );
5824
5935
  }
5825
- process.stdout.write(formatObject15(result, { format: fmt }) + "\n");
5936
+ process.stdout.write(formatObject16(result, { format: fmt }) + "\n");
5826
5937
  process.exit(0);
5827
5938
  } catch (e) {
5828
5939
  const err = e;
5829
5940
  if (err?.response?.status === 403) {
5830
5941
  exitWithError(new Error("bootstrap key \u65E0\u6548\uFF08403\uFF09\u2014\u2014 \u6838\u5BF9\u90E8\u7F72\u65B9\u63D0\u4F9B\u7684 key\uFF0C\u52FF\u590D\u7528\u5176\u4ED6\u73AF\u5883\u7684"));
5831
5942
  } else if (err?.isAxiosError) {
5832
- exitWithError(fromAxiosError14(err, args.env));
5943
+ exitWithError(fromAxiosError15(err, args.env));
5833
5944
  } else {
5834
5945
  exitWithError(e);
5835
5946
  }
@@ -5839,9 +5950,9 @@ async function tenantBootstrapCommand(args) {
5839
5950
  // src/commands/meta.ts
5840
5951
  import { promises as fsp3 } from "fs";
5841
5952
  import {
5842
- HcmClient as HcmClient15,
5843
- formatObject as formatObject16,
5844
- fromAxiosError as fromAxiosError15,
5953
+ HcmClient as HcmClient16,
5954
+ formatObject as formatObject17,
5955
+ fromAxiosError as fromAxiosError16,
5845
5956
  listTenantMeta,
5846
5957
  getTenantMeta,
5847
5958
  saveTenantMeta,
@@ -5852,16 +5963,16 @@ import {
5852
5963
  init_exit();
5853
5964
  init_auth_guard();
5854
5965
  async function client2(args) {
5855
- return HcmClient15.fromAuthContext(await getActiveAuthContextFromCli(args));
5966
+ return HcmClient16.fromAuthContext(await getActiveAuthContextFromCli(args));
5856
5967
  }
5857
- function fail4(e, args) {
5968
+ function fail5(e, args) {
5858
5969
  const err = e;
5859
5970
  if (err?.response?.status === 403) {
5860
5971
  exitWithError(
5861
5972
  new Error("\u5143\u6570\u636E\u5199\u5165\u88AB\u62D2\uFF08403\uFF09\u2014\u2014 \u9700 config-admin \u8EAB\u4EFD\u4E14\u5F53\u524D source \u53EF\u5199\uFF1B\u82E5\u5728\u79DF\u6237\u5F00\u53D1\u7A7A\u95F4\u5916\uFF0C\u5148 `hcm workspace bind <key>`")
5862
5973
  );
5863
5974
  }
5864
- if (err?.isAxiosError) exitWithError(fromAxiosError15(err, args.env));
5975
+ if (err?.isAxiosError) exitWithError(fromAxiosError16(err, args.env));
5865
5976
  exitWithError(e);
5866
5977
  process.exit(1);
5867
5978
  }
@@ -5877,10 +5988,10 @@ async function metaListCommand(args) {
5877
5988
  const fmt = args.output ?? "json";
5878
5989
  if (fmt !== "json") process.stdout.write(`\u{1F4C4} ${items.length} \u4EFD${total ? ` / \u5171 ${total}` : ""}
5879
5990
  `);
5880
- process.stdout.write(formatObject16(items, { format: fmt }) + "\n");
5991
+ process.stdout.write(formatObject17(items, { format: fmt }) + "\n");
5881
5992
  process.exit(0);
5882
5993
  } catch (e) {
5883
- fail4(e, args);
5994
+ fail5(e, args);
5884
5995
  }
5885
5996
  }
5886
5997
  async function metaGetCommand(path11, args) {
@@ -5890,7 +6001,7 @@ async function metaGetCommand(path11, args) {
5890
6001
  process.stdout.write(content.endsWith("\n") ? content : content + "\n");
5891
6002
  process.exit(0);
5892
6003
  } catch (e) {
5893
- fail4(e, args);
6004
+ fail5(e, args);
5894
6005
  }
5895
6006
  }
5896
6007
  async function metaSetCommand(path11, args) {
@@ -5925,11 +6036,11 @@ ${content}
5925
6036
  \u8BB0\u5F97\u6E05\u7F13\u5B58\uFF1Ahcm cache clear-meta <Model>
5926
6037
  `);
5927
6038
  }
5928
- process.stdout.write(formatObject16(result, { format: fmt }) + "\n");
6039
+ process.stdout.write(formatObject17(result, { format: fmt }) + "\n");
5929
6040
  process.exit(0);
5930
6041
  } catch (e) {
5931
6042
  if (e?.code === "ENOENT") exitWithError(new Error(`\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${args.file}`));
5932
- fail4(e, args);
6043
+ fail5(e, args);
5933
6044
  }
5934
6045
  }
5935
6046
  async function metaDeleteCommand(path11, args) {
@@ -5946,10 +6057,10 @@ async function metaDeleteCommand(path11, args) {
5946
6057
  const fmt = args.output ?? "json";
5947
6058
  if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${path11}
5948
6059
  `);
5949
- process.stdout.write(formatObject16(result, { format: fmt }) + "\n");
6060
+ process.stdout.write(formatObject17(result, { format: fmt }) + "\n");
5950
6061
  process.exit(0);
5951
6062
  } catch (e) {
5952
- fail4(e, args);
6063
+ fail5(e, args);
5953
6064
  }
5954
6065
  }
5955
6066
 
@@ -5965,10 +6076,10 @@ import {
5965
6076
  createWorkspaceFile,
5966
6077
  deleteWorkspaceFile,
5967
6078
  formatMiniVerifyReport,
5968
- formatObject as formatObject17,
6079
+ formatObject as formatObject18,
5969
6080
  formatRows as formatRows5,
5970
6081
  getMiniStatus,
5971
- HcmClient as HcmClient16,
6082
+ HcmClient as HcmClient17,
5972
6083
  initMiniAppProject,
5973
6084
  inferMiniWritableTemplateOptionsFromModel,
5974
6085
  listWorkspaceFiles,
@@ -5978,7 +6089,7 @@ import {
5978
6089
  runMiniSmokeChecks,
5979
6090
  saveWorkspaceFileContent,
5980
6091
  validateMiniProject,
5981
- fromAxiosError as fromAxiosError16
6092
+ fromAxiosError as fromAxiosError17
5982
6093
  } from "@hcmai/sdk";
5983
6094
 
5984
6095
  // src/commands/workspace-format.ts
@@ -6025,7 +6136,7 @@ var RAW_WORKSPACE_EXCLUDED_DIRS = /* @__PURE__ */ new Set([
6025
6136
  var RAW_WORKSPACE_EXCLUDED_FILES = /* @__PURE__ */ new Set([WORKSPACE_CONTEXT_FILE, ".DS_Store"]);
6026
6137
  async function workspaceListCommand(args) {
6027
6138
  try {
6028
- const client3 = HcmClient16.fromAuthContext(await getActiveAuthContextFromCli(args));
6139
+ const client3 = HcmClient17.fromAuthContext(await getActiveAuthContextFromCli(args));
6029
6140
  const limit = parsePositiveInt3(args.limit, 50, "--limit");
6030
6141
  const result = await client3.query("TenantExtensionWorkspace", {
6031
6142
  keyword: args.keyword,
@@ -6054,7 +6165,7 @@ async function workspaceActiveCommand(args) {
6054
6165
  const ctx = await getActiveAuthContextFromCli(args, {
6055
6166
  fallbackEnv: localContext?.profile
6056
6167
  });
6057
- const client3 = HcmClient16.fromAuthContext(ctx);
6168
+ const client3 = HcmClient17.fromAuthContext(ctx);
6058
6169
  const result = await client3.query("TenantExtensionWorkspace", {
6059
6170
  filter: { devModeEnabled: true },
6060
6171
  fields: ["workspaceKey", "devModeEnabled"],
@@ -6109,7 +6220,7 @@ async function workspaceCreateCommand(workspaceKey, args) {
6109
6220
  `${WORKSPACE_CONTEXT_FILE} already binds workspace '${existing.workspaceKey}'; use --force to rebind`
6110
6221
  );
6111
6222
  }
6112
- const client3 = HcmClient16.fromAuthContext(await getActiveAuthContextFromCli(args));
6223
+ const client3 = HcmClient17.fromAuthContext(await getActiveAuthContextFromCli(args));
6113
6224
  const normalizedWorkspaceKey = normalizeWorkspaceKey(workspaceKey);
6114
6225
  const resp = await client3.raw().post("/api/models/TenantExtensionWorkspace", {
6115
6226
  workspaceKey: normalizedWorkspaceKey,
@@ -6117,9 +6228,10 @@ async function workspaceCreateCommand(workspaceKey, args) {
6117
6228
  });
6118
6229
  const created = asRecord(unwrapData(resp.data));
6119
6230
  const id = stringOptional(created.id);
6231
+ let activated = false;
6120
6232
  if (args.activate) {
6121
- if (!id) throw new Error("created workspace response does not include id");
6122
- await client3.action("TenantExtensionWorkspace", "activate", { id });
6233
+ await setDevModeBinding(client3, normalizedWorkspaceKey);
6234
+ activated = true;
6123
6235
  }
6124
6236
  const context = buildWorkspaceContext({
6125
6237
  workspaceKey: normalizedWorkspaceKey,
@@ -6134,7 +6246,7 @@ async function workspaceCreateCommand(workspaceKey, args) {
6134
6246
  workspaceKey: normalizedWorkspaceKey,
6135
6247
  id: id ?? "-",
6136
6248
  rootDir,
6137
- activated: !!args.activate,
6249
+ activated,
6138
6250
  profile: client3.profile,
6139
6251
  tenantId: client3.tenantId
6140
6252
  },
@@ -6155,7 +6267,7 @@ async function workspacePullCommand(args) {
6155
6267
  `workspace key is required; pass --workspace <key> or run hcm workspace bind <key> first`
6156
6268
  );
6157
6269
  }
6158
- const client3 = HcmClient16.fromAuthContext(
6270
+ const client3 = HcmClient17.fromAuthContext(
6159
6271
  await getActiveAuthContextFromCli(args, { fallbackEnv: existing?.profile })
6160
6272
  );
6161
6273
  const context = buildWorkspaceContext({
@@ -6293,7 +6405,7 @@ async function workspaceStatusCommand(args) {
6293
6405
  }
6294
6406
  if (args.output === "json" || args.output === "yaml") {
6295
6407
  process.stdout.write(
6296
- formatObject17({ rootDir, miniApps: rows }, { format: args.output }) + "\n"
6408
+ formatObject18({ rootDir, miniApps: rows }, { format: args.output }) + "\n"
6297
6409
  );
6298
6410
  } else {
6299
6411
  process.stdout.write(formatRows5(rows, { format: "table" }) + "\n");
@@ -6322,7 +6434,7 @@ async function workspacePushCommand(args) {
6322
6434
  const rootDir = resolveRootDir(args.dir);
6323
6435
  const context = await requireWorkspaceContext(rootDir);
6324
6436
  const miniApps = await discoverMiniApps(rootDir);
6325
- const client3 = HcmClient16.fromAuthContext(
6437
+ const client3 = HcmClient17.fromAuthContext(
6326
6438
  await getActiveAuthContextFromCli(args, { fallbackEnv: context.profile })
6327
6439
  );
6328
6440
  const rawResult = await pushWorkspaceRawFiles({
@@ -6341,6 +6453,17 @@ async function workspacePushCommand(args) {
6341
6453
  results.push({ app, result });
6342
6454
  }
6343
6455
  writeWorkspacePushResult(rawResult, results, args.output ?? "table");
6456
+ const hint = activationHint(
6457
+ await probeActiveWorkspaceKey(
6458
+ HcmClient17.fromAuthContext(
6459
+ await getActiveAuthContextFromCli(args, { fallbackEnv: context.profile })
6460
+ )
6461
+ ),
6462
+ context.workspaceKey ?? null
6463
+ );
6464
+ if (hint) process.stderr.write(`
6465
+ ${hint}
6466
+ `);
6344
6467
  process.exit(
6345
6468
  rawResult.conflicts.length || results.some((item) => item.result.conflicts.length) ? 3 : 0
6346
6469
  );
@@ -6369,7 +6492,7 @@ async function workspacePreviewCommand(args) {
6369
6492
  );
6370
6493
  }
6371
6494
  if (args.output === "json" || args.output === "yaml") {
6372
- process.stdout.write(formatObject17(rows, { format: args.output }) + "\n");
6495
+ process.stdout.write(formatObject18(rows, { format: args.output }) + "\n");
6373
6496
  } else {
6374
6497
  process.stdout.write(formatRows5(rows, { format: "table" }) + "\n");
6375
6498
  }
@@ -6820,7 +6943,7 @@ async function readMiniStatusSafely(app) {
6820
6943
  async function loadProfileClient(args) {
6821
6944
  try {
6822
6945
  const ctx = await getActiveAuthContextFromCli(args);
6823
- return HcmClient16.fromAuthContext(ctx);
6946
+ return HcmClient17.fromAuthContext(ctx);
6824
6947
  } catch (e) {
6825
6948
  if (args.env || args.profile) throw e;
6826
6949
  return null;
@@ -6975,7 +7098,7 @@ function optionalText(value) {
6975
7098
  }
6976
7099
  function writeWorkspaceListResult(rows, format, total) {
6977
7100
  if (format !== "table") {
6978
- process.stdout.write(formatObject17({ rows, total }, { format }) + "\n");
7101
+ process.stdout.write(formatObject18({ rows, total }, { format }) + "\n");
6979
7102
  return;
6980
7103
  }
6981
7104
  process.stdout.write(formatRows5(toWorkspaceListRows(rows), { format: "table" }) + "\n");
@@ -6986,7 +7109,7 @@ function writeWorkspaceListResult(rows, format, total) {
6986
7109
  }
6987
7110
  function writeWorkspaceActiveResult(view, format) {
6988
7111
  if (format !== "table") {
6989
- process.stdout.write(formatObject17(view, { format }) + "\n");
7112
+ process.stdout.write(formatObject18(view, { format }) + "\n");
6990
7113
  return;
6991
7114
  }
6992
7115
  const rows = [
@@ -7004,7 +7127,7 @@ function writeWorkspaceActiveResult(view, format) {
7004
7127
  }
7005
7128
  function writeWorkspaceBindResult(context, rootDir, format) {
7006
7129
  if (format !== "table") {
7007
- process.stdout.write(formatObject17({ ...context, rootDir }, { format }) + "\n");
7130
+ process.stdout.write(formatObject18({ ...context, rootDir }, { format }) + "\n");
7008
7131
  return;
7009
7132
  }
7010
7133
  process.stdout.write(
@@ -7018,7 +7141,7 @@ function writeWorkspaceBindResult(context, rootDir, format) {
7018
7141
  }
7019
7142
  function writeWorkspaceCreateResult(result, format) {
7020
7143
  if (format !== "table") {
7021
- process.stdout.write(formatObject17(result, { format }) + "\n");
7144
+ process.stdout.write(formatObject18(result, { format }) + "\n");
7022
7145
  return;
7023
7146
  }
7024
7147
  process.stdout.write(
@@ -7034,7 +7157,7 @@ function writeWorkspaceCreateResult(result, format) {
7034
7157
  }
7035
7158
  function writeWorkspacePullResult(result, format) {
7036
7159
  if (format !== "table") {
7037
- process.stdout.write(formatObject17(result, { format }) + "\n");
7160
+ process.stdout.write(formatObject18(result, { format }) + "\n");
7038
7161
  return;
7039
7162
  }
7040
7163
  const lines = [
@@ -7052,7 +7175,7 @@ function writeWorkspacePullResult(result, format) {
7052
7175
  }
7053
7176
  function writeWorkspaceAddMiniResult(result, rootDir, format) {
7054
7177
  if (format !== "table") {
7055
- process.stdout.write(formatObject17({ ...result, workspaceRoot: rootDir }, { format }) + "\n");
7178
+ process.stdout.write(formatObject18({ ...result, workspaceRoot: rootDir }, { format }) + "\n");
7056
7179
  return;
7057
7180
  }
7058
7181
  process.stdout.write(
@@ -7068,7 +7191,7 @@ function writeWorkspaceAddMiniResult(result, rootDir, format) {
7068
7191
  function writeWorkspaceValidateResult(results, format) {
7069
7192
  if (format !== "table") {
7070
7193
  process.stdout.write(
7071
- formatObject17(
7194
+ formatObject18(
7072
7195
  results.map((item) => ({ artifact: `mini:${item.app.appCode}`, ...item.result })),
7073
7196
  { format }
7074
7197
  ) + "\n"
@@ -7096,7 +7219,7 @@ mini:${item.app.appCode}
7096
7219
  function writeWorkspacePushResult(rawResult, results, format) {
7097
7220
  if (format !== "table") {
7098
7221
  process.stdout.write(
7099
- formatObject17(
7222
+ formatObject18(
7100
7223
  {
7101
7224
  workspaceFiles: { artifact: "workspace", ...rawResult },
7102
7225
  miniApps: results.map((item) => ({ artifact: `mini:${item.app.appCode}`, ...item.result }))
@@ -7152,7 +7275,7 @@ function writeWorkspaceVerifyResult(context, rootDir, raw, reports, format) {
7152
7275
  const ok = rawOk && reports.every((item) => item.report.ok);
7153
7276
  if (format === "json") {
7154
7277
  process.stdout.write(
7155
- formatObject17(
7278
+ formatObject18(
7156
7279
  {
7157
7280
  ok,
7158
7281
  workspaceKey: context.workspaceKey,
@@ -7179,7 +7302,7 @@ function writeWorkspaceVerifyResult(context, rootDir, raw, reports, format) {
7179
7302
  }
7180
7303
  if (format !== "table") {
7181
7304
  process.stdout.write(
7182
- formatObject17(
7305
+ formatObject18(
7183
7306
  {
7184
7307
  ok,
7185
7308
  workspaceKey: context.workspaceKey,
@@ -7231,10 +7354,59 @@ function formatStatusSummary(summary) {
7231
7354
  function exitWorkspaceError(err, profile) {
7232
7355
  const maybeAxios = err;
7233
7356
  if (maybeAxios?.isAxiosError) {
7234
- exitWithError(fromAxiosError16(err, profile));
7357
+ exitWithError(fromAxiosError17(err, profile));
7235
7358
  }
7236
7359
  exitWithError(err);
7237
7360
  }
7361
+ async function probeActiveWorkspaceKey(client3) {
7362
+ try {
7363
+ const result = await client3.query("TenantExtensionWorkspace", {
7364
+ filter: { devModeEnabled: true },
7365
+ fields: ["workspaceKey", "devModeEnabled"],
7366
+ limit: 1
7367
+ });
7368
+ return optionalText(result.rows[0]?.workspaceKey) ?? null;
7369
+ } catch {
7370
+ return null;
7371
+ }
7372
+ }
7373
+ function activationHint(activeKey, localKey) {
7374
+ if (localKey && activeKey === localKey) {
7375
+ return null;
7376
+ }
7377
+ if (!activeKey) {
7378
+ return localKey ? `\u26A0\uFE0F \u5F53\u524D\u79DF\u6237\u6CA1\u6709\u6FC0\u6D3B\u7684\u5F00\u53D1\u7A7A\u95F4\u2014\u2014\u672C\u7A7A\u95F4\u7684\u5185\u5BB9\u5C1A\u672A\u751F\u6548\u3002
7379
+ \u4E0B\u4E00\u6B65\uFF1Ahcm workspace activate ${localKey}` : "\u26A0\uFE0F \u5F53\u524D\u79DF\u6237\u6CA1\u6709\u6FC0\u6D3B\u7684\u5F00\u53D1\u7A7A\u95F4\u2014\u2014\u5F00\u53D1\u7A7A\u95F4\u91CC\u7684\u5185\u5BB9\u5C1A\u672A\u751F\u6548\u3002";
7380
+ }
7381
+ return localKey ? `\u26A0\uFE0F \u5F53\u524D\u6FC0\u6D3B\u7684\u662F "${activeKey}"\uFF0C\u4E0D\u662F\u672C\u7A7A\u95F4 "${localKey}"\u2014\u2014\u672C\u7A7A\u95F4\u7684\u5185\u5BB9\u5C1A\u672A\u751F\u6548\u3002
7382
+ \u4E0B\u4E00\u6B65\uFF1Ahcm workspace activate ${localKey}` : `\u26A0\uFE0F \u5F53\u524D\u6FC0\u6D3B\u7684\u662F "${activeKey}"\u3002`;
7383
+ }
7384
+ async function setDevModeBinding(client3, workspaceKey) {
7385
+ await client3.raw().put("/api/tenant-extension/dev-mode", {
7386
+ enabled: true,
7387
+ workspaceKey
7388
+ });
7389
+ }
7390
+ async function workspaceActivateCommand(workspaceKey, args) {
7391
+ try {
7392
+ const client3 = HcmClient17.fromAuthContext(await getActiveAuthContextFromCli(args));
7393
+ const key2 = normalizeWorkspaceKey(workspaceKey);
7394
+ await setDevModeBinding(client3, key2);
7395
+ const fmt = args.output ?? "table";
7396
+ if (fmt === "table") {
7397
+ process.stdout.write(`workspace activated: ${key2}
7398
+ `);
7399
+ process.stdout.write("\u8BE5\u7A7A\u95F4\u7684 metas / scripts / menus / mini_apps \u73B0\u5DF2\u5728\u5F53\u524D\u79DF\u6237\u751F\u6548\u3002\n");
7400
+ } else {
7401
+ process.stdout.write(
7402
+ formatObject18({ workspaceKey: key2, activated: true }, { format: fmt }) + "\n"
7403
+ );
7404
+ }
7405
+ process.exit(0);
7406
+ } catch (e) {
7407
+ exitWorkspaceError(e, args.env ?? args.profile);
7408
+ }
7409
+ }
7238
7410
 
7239
7411
  // src/commands/identity.ts
7240
7412
  init_exit();
@@ -7313,8 +7485,8 @@ async function identityRemove(name) {
7313
7485
  // src/commands/delivery-action-policy.ts
7314
7486
  init_auth_guard();
7315
7487
  import {
7316
- HcmClient as HcmClient17,
7317
- formatObject as formatObject18
7488
+ HcmClient as HcmClient18,
7489
+ formatObject as formatObject19
7318
7490
  } from "@hcmai/sdk";
7319
7491
 
7320
7492
  // src/commands/delivery.ts
@@ -7670,7 +7842,7 @@ async function assessEffectiveDeliveryCommand(inputArgv, dependencies = {}) {
7670
7842
  }
7671
7843
  async function deliveryAssessCommand(argv, args) {
7672
7844
  const assessment = await assessEffectiveDeliveryCommand(argv);
7673
- process.stdout.write(formatObject18(assessment, { format: args.output ?? "json" }) + "\n");
7845
+ process.stdout.write(formatObject19(assessment, { format: args.output ?? "json" }) + "\n");
7674
7846
  }
7675
7847
  async function resolveCoreAction(request) {
7676
7848
  try {
@@ -7679,7 +7851,7 @@ async function resolveCoreAction(request) {
7679
7851
  as: request.identity,
7680
7852
  profile: request.profile
7681
7853
  });
7682
- const description = await HcmClient17.fromAuthContext(auth).describe(request.model);
7854
+ const description = await HcmClient18.fromAuthContext(auth).describe(request.model);
7683
7855
  const named = description.actions.filter((action2) => action2.name === request.action);
7684
7856
  if (named.length === 0) {
7685
7857
  return failed(
@@ -7769,10 +7941,10 @@ function flagValue2(argv, flag) {
7769
7941
  init_auth_guard();
7770
7942
  init_exit();
7771
7943
  import {
7772
- HcmClient as HcmClient18,
7944
+ HcmClient as HcmClient19,
7773
7945
  fetchReconIdentity,
7774
- formatObject as formatObject19,
7775
- fromAxiosError as fromAxiosError17,
7946
+ formatObject as formatObject20,
7947
+ fromAxiosError as fromAxiosError18,
7776
7948
  httpProbe,
7777
7949
  runDoctor
7778
7950
  } from "@hcmai/sdk";
@@ -7791,17 +7963,17 @@ function render2(report) {
7791
7963
  async function deliveryDoctorCommand(args) {
7792
7964
  try {
7793
7965
  const ctx = await getActiveAuthContextFromCli(args);
7794
- const client3 = HcmClient18.fromAuthContext(ctx);
7966
+ const client3 = HcmClient19.fromAuthContext(ctx);
7795
7967
  const probe = httpProbe(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES);
7796
7968
  const identity2 = await fetchReconIdentity(probe, ctx.tenantId);
7797
7969
  const report = await runDoctor(probe, identity2);
7798
7970
  const fmt = args.output ?? "json";
7799
7971
  if (fmt !== "json") process.stdout.write(render2(report) + "\n");
7800
- process.stdout.write(formatObject19(report, { format: fmt }) + "\n");
7972
+ process.stdout.write(formatObject20(report, { format: fmt }) + "\n");
7801
7973
  process.exit(report.ok ? 0 : 1);
7802
7974
  } catch (e) {
7803
7975
  const err = e;
7804
- if (err?.isAxiosError) exitWithError(fromAxiosError17(err, args.env));
7976
+ if (err?.isAxiosError) exitWithError(fromAxiosError18(err, args.env));
7805
7977
  exitWithError(e);
7806
7978
  process.exit(1);
7807
7979
  }
@@ -7811,12 +7983,12 @@ async function deliveryDoctorCommand(args) {
7811
7983
  init_auth_guard();
7812
7984
  init_exit();
7813
7985
  import {
7814
- HcmClient as HcmClient19,
7986
+ HcmClient as HcmClient20,
7815
7987
  ReconLayout,
7816
7988
  ROUND_EXIT_CODES,
7817
7989
  computeReconSourceKey,
7818
- formatObject as formatObject20,
7819
- fromAxiosError as fromAxiosError18,
7990
+ formatObject as formatObject21,
7991
+ fromAxiosError as fromAxiosError19,
7820
7992
  httpProbe as httpProbe2,
7821
7993
  inspectRound,
7822
7994
  renderRound,
@@ -7826,7 +7998,7 @@ var DEFAULT_CAPABILITIES2 = "default";
7826
7998
  async function deliveryReconCommand(args) {
7827
7999
  try {
7828
8000
  const ctx = await getActiveAuthContextFromCli(args);
7829
- const client3 = HcmClient19.fromAuthContext(ctx);
8001
+ const client3 = HcmClient20.fromAuthContext(ctx);
7830
8002
  const probe = httpProbe2(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES2);
7831
8003
  const sourceKey = await computeReconSourceKey(probe);
7832
8004
  const layout = new ReconLayout(args.out ?? ".", ctx.tenantId, sourceKey);
@@ -7835,10 +8007,10 @@ async function deliveryReconCommand(args) {
7835
8007
  onlyModel: args.model ?? null,
7836
8008
  identity: ctx.tenantId ? { requestedTenantId: ctx.tenantId } : null
7837
8009
  });
7838
- process.stdout.write(formatObject20(summary, { format: args.output ?? "json" }) + "\n");
8010
+ process.stdout.write(formatObject21(summary, { format: args.output ?? "json" }) + "\n");
7839
8011
  } catch (e) {
7840
8012
  const err = e;
7841
- if (err?.isAxiosError) exitWithError(fromAxiosError18(err, args.env));
8013
+ if (err?.isAxiosError) exitWithError(fromAxiosError19(err, args.env));
7842
8014
  exitWithError(e);
7843
8015
  process.exit(1);
7844
8016
  }
@@ -7849,7 +8021,7 @@ async function deliveryReconRoundCommand(args) {
7849
8021
  const result = inspectRound(args.dir ?? ".");
7850
8022
  const fmt = args.output ?? "json";
7851
8023
  if (fmt !== "json") process.stdout.write(renderRound(result));
7852
- process.stdout.write(formatObject20(result, { format: fmt }) + "\n");
8024
+ process.stdout.write(formatObject21(result, { format: fmt }) + "\n");
7853
8025
  code = ROUND_EXIT_CODES[result.state];
7854
8026
  } catch (e) {
7855
8027
  exitWithError(e);
@@ -7864,9 +8036,10 @@ import {
7864
8036
  baselineRoundPremise,
7865
8037
  checkPremise,
7866
8038
  CHANNELS,
8039
+ GAP_REASONS,
7867
8040
  deriveAclass,
7868
8041
  exitCode as gate0ExitCode,
7869
- formatObject as formatObject21,
8042
+ formatObject as formatObject22,
7870
8043
  inspectRound as inspectRound2,
7871
8044
  loadProtocolFacts,
7872
8045
  scan
@@ -7883,8 +8056,15 @@ function renderGate0(result, skillRoot) {
7883
8056
  for (const red of rows) lines.push(` - (${red.reason}) ${red.message}`);
7884
8057
  }
7885
8058
  if (result.gaps.length > 0) {
7886
- lines.push(` [gaps] ${result.gaps.length} \u6761\uFF08\u4E0D\u9876 rc\uFF0C\u8BF7\u81EA\u5DF1\u770B\u4E00\u773C\uFF09`);
7887
- for (const gap of result.gaps) lines.push(` - (${gap.reason}) ${gap.why}`);
8059
+ lines.push(` [gaps] ${result.gaps.length} \u6761\uFF08\u4E0D\u9876 rc\uFF0C\u8BF7\u81EA\u5DF1\u770B\u4E00\u773C\uFF1B\u9010\u6761\u89C1 --output json\uFF09`);
8060
+ for (const reason of GAP_REASONS) {
8061
+ const rows = result.gaps.filter((g) => g.reason === reason);
8062
+ if (rows.length === 0) continue;
8063
+ const byToken = /* @__PURE__ */ new Map();
8064
+ for (const g of rows) byToken.set(g.token, (byToken.get(g.token) ?? 0) + 1);
8065
+ const tokens = [...byToken.entries()].sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])).map(([token, n]) => n > 1 ? `${token}\xD7${n}` : token);
8066
+ lines.push(` - (${reason}) ${rows.length} \u6761 / ${byToken.size} \u4E2A token\uFF1A${tokens.join("\u3001")}`);
8067
+ }
7888
8068
  }
7889
8069
  return `${lines.join("\n")}
7890
8070
  `;
@@ -7904,7 +8084,7 @@ async function deliveryGate0Command(args) {
7904
8084
  const merged = { ...result, premise: premise5 };
7905
8085
  const fmt = args.output ?? "json";
7906
8086
  if (fmt !== "json") process.stdout.write(renderGate0(merged, skillRoot));
7907
- process.stdout.write(`${formatObject21(merged, { format: fmt })}
8087
+ process.stdout.write(`${formatObject22(merged, { format: fmt })}
7908
8088
  `);
7909
8089
  for (const problem of premise5) {
7910
8090
  process.stderr.write(`\u{1F534} \u524D\u63D0\u4E0D\u6210\u7ACB\uFF08${problem.reason}\uFF09\uFF1A${problem.message}
@@ -7928,7 +8108,8 @@ import {
7928
8108
  DRY_RUN_TAIL,
7929
8109
  DriftDetected,
7930
8110
  FORCE_STALE_FLAG,
7931
- HcmClient as HcmClient20,
8111
+ HcmClient as HcmClient21,
8112
+ fetchReconIdentity as fetchReconIdentity2,
7932
8113
  INIT_EXIT_CODES,
7933
8114
  JOURNAL_STOP_KINDS,
7934
8115
  JOURNAL_STOP_UNKNOWN,
@@ -8067,7 +8248,7 @@ async function authOrSignpost(args, cmd) {
8067
8248
  }
8068
8249
  async function deliverySeedPlanCommand(args) {
8069
8250
  const ctx = await authOrSignpost(args, "plan");
8070
- const client3 = HcmClient20.fromAuthContext(ctx);
8251
+ const client3 = HcmClient21.fromAuthContext(ctx);
8071
8252
  process.exitCode = await runSeedPlan(args, seedClient(client3, ctx));
8072
8253
  }
8073
8254
  function seedClient(client3, ctx) {
@@ -8101,6 +8282,11 @@ function seedClient(client3, ctx) {
8101
8282
  post: (p, body) => wrap(() => raw.post(p, body))
8102
8283
  };
8103
8284
  }
8285
+ async function seedVerifyClient(client3, ctx) {
8286
+ const base = seedClient(client3, ctx);
8287
+ const identity2 = await fetchReconIdentity2(base, String(ctx.tenantId ?? ""));
8288
+ return { ...base, identity: identity2 };
8289
+ }
8104
8290
  function lowerCaseHeaders(headers) {
8105
8291
  if (headers === null || typeof headers !== "object") return {};
8106
8292
  const out = {};
@@ -8236,7 +8422,7 @@ async function runSeedApply(args, client3) {
8236
8422
  }
8237
8423
  async function deliverySeedApplyCommand(args) {
8238
8424
  const ctx = await authOrSignpost(args, "apply");
8239
- const client3 = HcmClient20.fromAuthContext(ctx);
8425
+ const client3 = HcmClient21.fromAuthContext(ctx);
8240
8426
  process.exitCode = await runSeedApply(args, seedClient(client3, ctx));
8241
8427
  }
8242
8428
  async function runSeedVerify(args, client3) {
@@ -8260,13 +8446,13 @@ async function deliverySeedVerifyCommand(args) {
8260
8446
  return;
8261
8447
  }
8262
8448
  const ctx = await authOrSignpost(args, "verify");
8263
- const client3 = HcmClient20.fromAuthContext(ctx);
8264
- process.exitCode = await runSeedVerify(args, seedClient(client3, ctx));
8449
+ const client3 = HcmClient21.fromAuthContext(ctx);
8450
+ process.exitCode = await runSeedVerify(args, await seedVerifyClient(client3, ctx));
8265
8451
  }
8266
8452
 
8267
8453
  // src/commands/delivery-seed-find.ts
8268
8454
  import { existsSync as existsSync3 } from "fs";
8269
- import { readFileSync as readFileSync4 } from "fs";
8455
+ import { readFileSync as readFileSync5 } from "fs";
8270
8456
  import * as path8 from "path";
8271
8457
  import {
8272
8458
  INIT_EXIT_CODES as INIT_EXIT_CODES2,
@@ -8329,7 +8515,7 @@ function runSeedFind(args) {
8329
8515
  if (!existsSync3(chosen.indexFile)) {
8330
8516
  return premise2(`\u7D22\u5F15\u6587\u4EF6\u5728\u9009\u4E2D\u4E4B\u540E\u6D88\u5931\u4E86\uFF1A${chosen.indexFile}`);
8331
8517
  }
8332
- const { rows, problems } = loadRows(readFileSync4(chosen.indexFile, "utf-8"));
8518
+ const { rows, problems } = loadRows(readFileSync5(chosen.indexFile, "utf-8"));
8333
8519
  process.stdout.write(
8334
8520
  renderFind(find(rows, args.term), args.term, rows.length, {
8335
8521
  prefixBytes: Buffer.byteLength(prefix, "utf-8"),
@@ -8369,13 +8555,13 @@ function deliverySeedValuesCommand(model, args) {
8369
8555
 
8370
8556
  // src/commands/delivery-meta.ts
8371
8557
  init_auth_guard();
8372
- import { readFileSync as readFileSync5 } from "fs";
8558
+ import { readFileSync as readFileSync6 } from "fs";
8373
8559
  import {
8374
8560
  BINDING_WORDS,
8375
8561
  CHANGE_STATES,
8376
8562
  CHANGE_UNKNOWN,
8377
8563
  CODE_WORDS,
8378
- HcmClient as HcmClient21,
8564
+ HcmClient as HcmClient22,
8379
8565
  INIT_EXIT_CODES as INIT_EXIT_CODES3,
8380
8566
  META_WRITE_STEPS,
8381
8567
  META_VERIFY_STEPS,
@@ -8517,7 +8703,7 @@ function premise3(what, hint) {
8517
8703
  async function runDeliveryMeta(args, client3) {
8518
8704
  let content;
8519
8705
  try {
8520
- content = readFileSync5(args.contentFile, "utf-8");
8706
+ content = readFileSync6(args.contentFile, "utf-8");
8521
8707
  } catch (e) {
8522
8708
  return premise3(
8523
8709
  `\u8981\u5199\u8FDB\u53BB\u7684\u6B63\u6587\u8BFB\u4E0D\u51FA\u6765\uFF1A${e.message}`,
@@ -8603,7 +8789,7 @@ function lowerCaseHeaders2(headers) {
8603
8789
  }
8604
8790
  async function deliveryMetaCommand(args) {
8605
8791
  const ctx = await getActiveAuthContextFromCli(args);
8606
- const client3 = HcmClient21.fromAuthContext(ctx);
8792
+ const client3 = HcmClient22.fromAuthContext(ctx);
8607
8793
  process.exitCode = await runDeliveryMeta(
8608
8794
  { ...args, tenant: args.tenant ?? String(ctx.tenantId ?? "") },
8609
8795
  metaClient(client3, ctx)
@@ -8615,12 +8801,12 @@ init_auth_guard();
8615
8801
  init_exit();
8616
8802
  import {
8617
8803
  computeReconSourceKey as computeReconSourceKey2,
8618
- HcmClient as HcmClient22,
8804
+ HcmClient as HcmClient23,
8619
8805
  httpProbe as httpProbe3,
8620
8806
  ReconLayout as ReconLayout2,
8621
8807
  runTriageRound
8622
8808
  } from "@hcmai/sdk";
8623
- import { mkdirSync, readFileSync as readFileSync6, writeFileSync as writeFileSync2 } from "fs";
8809
+ import { mkdirSync, readFileSync as readFileSync7, writeFileSync as writeFileSync2 } from "fs";
8624
8810
  import * as path9 from "path";
8625
8811
  var DEFAULT_CAPABILITIES4 = "default";
8626
8812
  function premise4(message, hint) {
@@ -8634,7 +8820,7 @@ var REQUESTS_SHAPE = "`--requests` \u6536\u7684\u662F\u4E00\u4E2A JSON \u6570\u7
8634
8820
  function readRequests(file) {
8635
8821
  let raw;
8636
8822
  try {
8637
- raw = JSON.parse(readFileSync6(file, "utf8"));
8823
+ raw = JSON.parse(readFileSync7(file, "utf8"));
8638
8824
  } catch (e) {
8639
8825
  throw new Error(`\u9700\u6C42\u6E05\u5355\u8BFB\u4E0D\u51FA\u6765\uFF08${file}\uFF09\uFF1A${e instanceof Error ? e.message : String(e)}`);
8640
8826
  }
@@ -8671,7 +8857,7 @@ async function runTriage(args) {
8671
8857
  return premise4(e instanceof Error ? e.message : String(e), REQUESTS_SHAPE);
8672
8858
  }
8673
8859
  const ctx = await getActiveAuthContextFromCli(args);
8674
- const client3 = HcmClient22.fromAuthContext(ctx);
8860
+ const client3 = HcmClient23.fromAuthContext(ctx);
8675
8861
  const probe = httpProbe3(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES4);
8676
8862
  const artifactsDir = args.recon ?? new ReconLayout2(args.out ?? ".", ctx.tenantId, await computeReconSourceKey2(probe)).dir;
8677
8863
  const result = await runTriageRound(probe, artifactsDir, entriesIn);
@@ -8700,7 +8886,7 @@ import { createHash as createHash5, randomBytes as secureRandomBytes } from "cry
8700
8886
  import { spawn } from "child_process";
8701
8887
  import { createReadStream, promises as fs6 } from "fs";
8702
8888
  import path10 from "path";
8703
- import { CliError as CliError20, CliErrorCode as CliErrorCode19, formatObject as formatObject22 } from "@hcmai/sdk";
8889
+ import { CliError as CliError20, CliErrorCode as CliErrorCode19, formatObject as formatObject23 } from "@hcmai/sdk";
8704
8890
  init_exit();
8705
8891
  var EXECUTION_CONTRACT_VERSION = "2026-08-29.controlled-v3";
8706
8892
  var DEFAULT_TTL_SECONDS = 15 * 60;
@@ -8854,7 +9040,7 @@ async function deliveryPrepareCommand(argv, args) {
8854
9040
  evidenceDir: args.evidenceDir,
8855
9041
  ...ttlSeconds === void 0 ? {} : { ttlSeconds }
8856
9042
  });
8857
- process.stdout.write(formatObject22(plan, { format: args.output ?? "json" }) + "\n");
9043
+ process.stdout.write(formatObject23(plan, { format: args.output ?? "json" }) + "\n");
8858
9044
  process.stderr.write(`
8859
9045
  \u4E0B\u4E00\u6B65\uFF08argv \u5FC5\u987B\u4E0E\u672C\u6B21\u5B8C\u5168\u4E00\u81F4\uFF09\uFF1A
8860
9046
  ${nextCommandHint(plan.planId, args.project, argv)}
@@ -8875,7 +9061,7 @@ async function deliveryExecuteCommand(planId, argv, args) {
8875
9061
  planId,
8876
9062
  argv
8877
9063
  });
8878
- process.stdout.write(formatObject22(receipt, { format: args.output ?? "json" }) + "\n");
9064
+ process.stdout.write(formatObject23(receipt, { format: args.output ?? "json" }) + "\n");
8879
9065
  process.exitCode = receipt.exitCode;
8880
9066
  } catch (cause) {
8881
9067
  exitWithError(cause);
@@ -9264,10 +9450,10 @@ function nextCommandHint(planId, project, argv) {
9264
9450
  init_auth_guard();
9265
9451
  init_exit();
9266
9452
  import {
9267
- HcmClient as HcmClient23,
9453
+ HcmClient as HcmClient24,
9268
9454
  adminResetPassword,
9269
- formatObject as formatObject23,
9270
- fromAxiosError as fromAxiosError19,
9455
+ formatObject as formatObject24,
9456
+ fromAxiosError as fromAxiosError20,
9271
9457
  CliError as CliError21,
9272
9458
  CliErrorCode as CliErrorCode20
9273
9459
  } from "@hcmai/sdk";
@@ -9298,12 +9484,12 @@ async function userResetPasswordCommand(args) {
9298
9484
  try {
9299
9485
  const password = args.passwordStdin ? await readSecretFromStdin() : await promptPasswordTwice();
9300
9486
  const request = buildAdminResetPasswordRequest(args, password);
9301
- const client3 = HcmClient23.fromAuthContext(await getActiveAuthContextFromCli(args));
9487
+ const client3 = HcmClient24.fromAuthContext(await getActiveAuthContextFromCli(args));
9302
9488
  const result = await adminResetPassword(client3.raw(), request);
9303
- process.stdout.write(formatObject23(result, { format: args.output ?? "json" }) + "\n");
9489
+ process.stdout.write(formatObject24(result, { format: args.output ?? "json" }) + "\n");
9304
9490
  } catch (cause) {
9305
9491
  const err = cause;
9306
- if (err?.isAxiosError) exitWithError(fromAxiosError19(err, args.env));
9492
+ if (err?.isAxiosError) exitWithError(fromAxiosError20(err, args.env));
9307
9493
  exitWithError(cause);
9308
9494
  }
9309
9495
  }
@@ -9323,19 +9509,19 @@ async function promptPasswordTwice() {
9323
9509
  init_exit();
9324
9510
  init_auth_guard();
9325
9511
  import {
9326
- HcmClient as HcmClient24,
9327
- formatObject as formatObject24,
9328
- fromAxiosError as fromAxiosError20
9512
+ HcmClient as HcmClient25,
9513
+ formatObject as formatObject25,
9514
+ fromAxiosError as fromAxiosError21
9329
9515
  } from "@hcmai/sdk";
9330
9516
  async function modelsCommand(keyword, args) {
9331
9517
  try {
9332
- const client3 = HcmClient24.fromAuthContext(await getActiveAuthContextFromCli(args));
9518
+ const client3 = HcmClient25.fromAuthContext(await getActiveAuthContextFromCli(args));
9333
9519
  const all = await client3.listModels();
9334
9520
  const needle = keyword?.trim().toLowerCase();
9335
9521
  const rows = (needle ? all.filter((m) => JSON.stringify(m).toLowerCase().includes(needle)) : all).sort((a, b) => key(a).localeCompare(key(b)));
9336
9522
  const fmt = args.output ?? "table";
9337
9523
  if (fmt !== "table") {
9338
- process.stdout.write(formatObject24({ total: rows.length, models: rows }, { format: fmt }) + "\n");
9524
+ process.stdout.write(formatObject25({ total: rows.length, models: rows }, { format: fmt }) + "\n");
9339
9525
  process.exit(0);
9340
9526
  }
9341
9527
  if (rows.length === 0) {
@@ -9359,7 +9545,7 @@ async function modelsCommand(keyword, args) {
9359
9545
  process.exit(0);
9360
9546
  } catch (e) {
9361
9547
  const err = e;
9362
- if (err?.isAxiosError) exitWithError(fromAxiosError20(err, args.profile));
9548
+ if (err?.isAxiosError) exitWithError(fromAxiosError21(err, args.profile));
9363
9549
  exitWithError(e);
9364
9550
  }
9365
9551
  }
@@ -9499,6 +9685,7 @@ program.command("download <documentId>").description("\u4E0B\u8F7D HCM \u6587\u6
9499
9685
  var workspace = program.command("workspace").description("\u5F00\u53D1\u79DF\u6237\u5F00\u53D1\u7A7A\u95F4\u6587\u4EF6\u5305\uFF08mini_apps / menus / metas / scripts\uFF09");
9500
9686
  workspace.command("list").description("\u5217\u51FA\u5F53\u524D\u7528\u6237\u53EF\u8BBF\u95EE\u7684\u79DF\u6237\u5F00\u53D1\u7A7A\u95F4").option("--keyword <text>", "\u6309\u7A7A\u95F4 Key / \u8BF4\u660E / Owner \u641C\u7D22").option("--limit <n>", "\u8FD4\u56DE\u6761\u6570", "50").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => workspaceListCommand(opts));
9501
9687
  workspace.command("active").description("\u67E5\u770B\u5F53\u524D HCM \u5F00\u53D1\u6A21\u5F0F\u6FC0\u6D3B\u7A7A\u95F4\uFF0C\u5E76\u5BF9\u6BD4\u672C\u5730\u76EE\u5F55\u7ED1\u5B9A").option("--dir <path>", "\u5DE5\u4F5C\u7A7A\u95F4\u672C\u5730\u76EE\u5F55", ".").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => workspaceActiveCommand(opts));
9688
+ workspace.command("activate <workspaceKey>").description("\u628A\u5F53\u524D\u7528\u6237\u7684\u5F00\u53D1\u8005\u6A21\u5F0F\u7ED1\u5B9A\u5230\u8BE5\u5F00\u53D1\u7A7A\u95F4\u2014\u2014\u7A7A\u95F4\u5185\u7684 artifact \u968F\u5373\u5728\u672C\u79DF\u6237\u751F\u6548").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((key2, opts) => workspaceActivateCommand(key2, opts));
9502
9689
  workspace.command("bind <workspaceKey>").description("\u628A\u5F53\u524D\u76EE\u5F55\u7ED1\u5B9A\u5230\u4E00\u4E2A\u79DF\u6237\u5F00\u53D1\u7A7A\u95F4").option("--dir <path>", "\u5DE5\u4F5C\u7A7A\u95F4\u672C\u5730\u76EE\u5F55", ".").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").option("--tenant <tenantId>", "\u79DF\u6237 ID\uFF08\u9ED8\u8BA4\u4F7F\u7528 env \u914D\u7F6E\uFF09").option("--endpoint <url>", "HCM \u540E\u7AEF\u5730\u5740\uFF08\u9ED8\u8BA4\u4F7F\u7528 env \u914D\u7F6E\uFF09").option("--force", "\u5F3A\u5236\u8986\u76D6\u5DF2\u6709\u7ED1\u5B9A").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((workspaceKey, opts) => workspaceBindCommand(workspaceKey, opts));
9503
9690
  workspace.command("create <workspaceKey>").description("\u65B0\u5EFA\u79DF\u6237\u5F00\u53D1\u7A7A\u95F4\uFF0C\u5E76\u5728\u672C\u5730\u76EE\u5F55\u5199\u5165 workspace \u7ED1\u5B9A").option("--dir <path>", "\u5DE5\u4F5C\u7A7A\u95F4\u672C\u5730\u76EE\u5F55", ".").option("--description <text>", "\u5F00\u53D1\u7A7A\u95F4\u8BF4\u660E").option("--activate", "\u521B\u5EFA\u540E\u7ED1\u5B9A\u4E3A\u5F53\u524D\u5F00\u53D1\u7A7A\u95F4").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").option("--force", "\u672C\u5730\u76EE\u5F55\u5DF2\u6709\u4E0D\u540C workspace \u7ED1\u5B9A\u65F6\u5F3A\u5236\u8986\u76D6").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((workspaceKey, opts) => workspaceCreateCommand(workspaceKey, opts));
9504
9691
  workspace.command("pull").description("\u4ECE\u5F00\u53D1\u7A7A\u95F4\u62C9\u53D6\u6587\u4EF6\u5305\u5230\u672C\u5730\uFF1Bmini_apps \u4F1A\u751F\u6210\u53EF\u9A8C\u8BC1\u7684 artifact \u4E0A\u4E0B\u6587").option("--workspace <key>", "\u79DF\u6237\u5F00\u53D1\u7A7A\u95F4 key\uFF1B\u672A\u63D0\u4F9B\u65F6\u8BFB\u53D6\u672C\u5730\u7ED1\u5B9A").option("--dir <path>", "\u5DE5\u4F5C\u7A7A\u95F4\u672C\u5730\u76EE\u5F55", ".").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").option("--force", "\u5F3A\u5236\u8986\u76D6\u5DF2\u6709\u7684\u672C\u5730\u6587\u4EF6").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => workspacePullCommand(opts));
@@ -9517,6 +9704,11 @@ workspace.command("verify").description(
9517
9704
  ).option("--dir <path>", "\u5DE5\u4F5C\u7A7A\u95F4\u672C\u5730\u76EE\u5F55", ".").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0Cdry-run \u9636\u6BB5\u9700\u8981\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").option("--frontend <url>", "\u524D\u7AEF\u5730\u5740", "http://127.0.0.1:5179").option("--surface <surface>", "\u9884\u89C8\u5F62\u6001\uFF1Aall | bare | standalone | embedded", "all").option("--smoke", "\u5BF9\u9884\u89C8\u5165\u53E3\u4E0E\u57FA\u7840\u8D44\u6E90\u6267\u884C\u53EA\u8BFB HTTP GET \u53EF\u8FBE\u68C0\u67E5").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => workspaceVerifyCommand(opts));
9518
9705
  program.command("trace [traceId]").description("\u67E5\u770B trace\uFF1A\u4E0D\u4F20 traceId \u5217\u6700\u8FD1\u8BB0\u5F55\uFF0C\u4F20 traceId \u663E\u793A\u4EBA\u7C7B\u53EF\u8BFB\u8BE6\u60C5").option("--conv <convId>", "\u67E5\u4F1A\u8BDD\u7684 LLM \u9010\u8C03\u7528 trace\uFF08PG llm_call_trace\uFF0CADR-134 D2\uFF09").option("--llm-calls", "\u628A\u4F4D\u7F6E\u53C2\u5F53 convId \u67E5 LLM \u9010\u8C03\u7528\uFF08\u7B49\u4EF7 --conv <convId>\uFF09").option("--span <N>", "\u67E5\u770B\u7B2C N \u4E2A span \u7684\u8BE6\u60C5").option("-n, --limit <N>", "\u5217\u8868\u6A21\u5F0F\u663E\u793A\u6761\u6570", "10").option("--events", "\u6309\u4E8B\u4EF6\u65F6\u95F4\u7EBF\u5C55\u793A spans/logs/LLM \u5185\u5BB9\u6458\u8981").option("--raw", "\u8F93\u51FA\u539F\u59CB trace \u805A\u5408 JSON\uFF08\u534F\u8BAE/P0 \u8C03\u8BD5\u7528\uFF09").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").option("--output <fmt>", "\u517C\u5BB9\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml\uFF1B\u8C03\u8BD5\u539F\u6587\u4F18\u5148\u7528 --raw", "table").action((traceId, opts) => traceCommand(traceId ?? null, opts));
9519
9706
  program.command("mini").description("\u5DF2\u79FB\u9664\uFF1A\u8BF7\u6539\u7528 hcm workspace").allowUnknownOption(true).allowExcessArguments(true).argument("[args...]").action(() => removedMiniCommand());
9707
+ var script = program.command("script").description("\u4E91\u51FD\u6570\uFF1A\u53EA\u8BFB\u8BD5\u8FD0\u884C\u3001manifest \u6821\u9A8C\u3001\u6267\u884C\u65E5\u5FD7\u4E0E\u5F02\u6B65\u4EFB\u52A1\uFF08\u8D70 CLI \u8BA4\u8BC1\uFF0C\u4E0D\u9700\u8981\u81EA\u5DF1\u62FF token\uFF09");
9708
+ script.command("dry-run").description("\u53EA\u8BFB\u8BD5\u8FD0\u884C\u4E91\u51FD\u6570\uFF1B\u5199\u64CD\u4F5C\u88AB\u62E6\u622A\u3001\u4EC5\u8BB0\u5F55\u4E3A writeIntents\uFF0C\u4E0D\u6539\u6570\u636E").requiredOption("--script-key <key>", "\u811A\u672C key\uFF0C\u5982 employee.sync-tags").option("--model <Model>", "\u7ED1\u5B9A\u7684 Model").option("--action <action>", "\u7ED1\u5B9A\u7684 Action key").option("--scope <scope>", "Action scope\uFF1Aclass | object").option("--method <method>", "HTTP \u65B9\u6CD5").option("--target-id <id>", "object scope \u7684\u76EE\u6807\u5B9E\u4F53 id").option("--params <JSON>", "\u5165\u53C2 JSON \u5BF9\u8C61").option("--params-file <path>", "\u4ECE UTF-8 JSON \u6587\u4EF6\u8BFB\u5165\u53C2\uFF08\u4E0E --params \u4E92\u65A5\uFF09").option("--context <JSON>", "context JSON \u5BF9\u8C61").option("--event <JSON>", "event JSON \u5BF9\u8C61").option("--timeout <ms>", "\u8D85\u65F6\u6BEB\u79D2").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => scriptDryRunCommand(opts));
9709
+ script.command("manifest-validate").description("\u6821\u9A8C\u6269\u5C55\u5305 manifest.yml").requiredOption("--file <path>", "manifest.yml \u8DEF\u5F84").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => scriptManifestValidateCommand(opts));
9710
+ script.command("logs").description("\u67E5\u540C\u6B65\u6267\u884C\u65E5\u5FD7\uFF08\u5206\u9875\uFF09").option("--script-key <key>", "\u53EA\u770B\u67D0\u4E2A\u811A\u672C").option("--status <status>", "\u6309\u72B6\u6001\u8FC7\u6EE4").option("--mode <mode>", "\u6309 sync/async \u8FC7\u6EE4").option("--dry-run", "\u53EA\u770B dry-run \u8BB0\u5F55").option("--from <iso>", "\u8D77\u59CB\u65F6\u95F4\uFF08ISO 8601\uFF09").option("--to <iso>", "\u7ED3\u675F\u65F6\u95F4\uFF08ISO 8601\uFF09").option("--page <n>", "\u9875\u7801\uFF0C\u4ECE 0 \u5F00\u59CB").option("--size <n>", "\u6BCF\u9875\u6761\u6570").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => scriptLogsCommand(opts));
9711
+ script.command("task <taskId>").description("\u67E5\u5F02\u6B65\u4EFB\u52A1\uFF1A\u72B6\u6001\u3001\u91CD\u8BD5\u6B21\u6570\u3001\u6700\u7EC8\u7ED3\u679C\u4E0E\u9519\u8BEF").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((taskId, opts) => scriptTaskCommand(taskId, opts));
9520
9712
  var cache = program.command("cache").description("\u6A21\u578B\u7F13\u5B58\u8FD0\u7EF4\uFF08Caffeine \u672C\u5730 + Redis \u8FDC\u7A0B\uFF0C\u987B\u8D70 API\uFF09");
9521
9713
  cache.command("stats <Model>").description("\u67E5\u770B\u6A21\u578B\u7F13\u5B58\u7EDF\u8BA1").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((model, opts) => cacheStatsCommand(model, opts));
9522
9714
  cache.command("clear <Model>").description("\u6E05\u6A21\u578B\u5B9E\u4F53\u7F13\u5B58\uFF08\u5E42\u7B49\uFF0C\u4E0D\u7834\u574F\u6570\u636E\uFF09").option("--id <id>", "\u53EA\u6E05\u5355\u6761\uFF08\u9ED8\u8BA4\u6E05\u5168\u90E8\uFF09").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((model, opts) => cacheClearCommand(model, opts));