@hcmai/cli 0.4.8 → 0.4.10

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: fromAxiosError22 } = await import("@hcmai/sdk");
2289
+ const { fromAxiosError: fromAxiosError23 } = await import("@hcmai/sdk");
2290
2290
  exitWithError(
2291
- fromAxiosError22(
2291
+ fromAxiosError23(
2292
2292
  e,
2293
2293
  envName
2294
2294
  )
@@ -4412,6 +4412,65 @@ async function uploadCommand(filePath, args) {
4412
4412
  }
4413
4413
  }
4414
4414
 
4415
+ // src/commands/datapackage.ts
4416
+ init_exit();
4417
+ init_auth_guard();
4418
+ import {
4419
+ HcmClient as HcmClient16,
4420
+ formatObject as formatObject14,
4421
+ fromAxiosError as fromAxiosError14,
4422
+ packDataPackage,
4423
+ installDataPackageArtifact,
4424
+ DEFAULT_ARTIFACT_CATEGORY
4425
+ } from "@hcmai/sdk";
4426
+ async function datapackagePackCommand(packageDir, args) {
4427
+ try {
4428
+ const result = await packDataPackage(packageDir, args.out);
4429
+ const fmt = args.output ?? "json";
4430
+ if (fmt !== "json") {
4431
+ process.stdout.write(
4432
+ `\u{1F4E6} ${result.name} v${result.version}\uFF08${result.entryCount} \u4E2A\u6587\u4EF6\uFF09\u2192 ${result.artifactPath}
4433
+ `
4434
+ );
4435
+ }
4436
+ process.stdout.write(formatObject14(result, { format: fmt }) + "\n");
4437
+ process.exit(0);
4438
+ } catch (e) {
4439
+ exitWithError(e);
4440
+ }
4441
+ }
4442
+ async function datapackageInstallCommand(artifactPath, args) {
4443
+ try {
4444
+ const ctx = await getActiveAuthContextFromCli(args);
4445
+ const client3 = HcmClient16.fromAuthContext(ctx);
4446
+ const { documentId, view } = await installDataPackageArtifact(client3, artifactPath, {
4447
+ category: args.category ?? DEFAULT_ARTIFACT_CATEGORY
4448
+ });
4449
+ const fmt = args.output ?? "json";
4450
+ if (fmt !== "json") {
4451
+ process.stdout.write(
4452
+ `\u{1F4E5} ${view.code ?? "?"} v${view.version ?? "?"} \u2192 ${view.installStatus ?? "?"}\uFF08rowCount=${view.rowCount ?? 0}\uFF0CdocumentId=${documentId}\uFF09
4453
+ `
4454
+ );
4455
+ if (view.replayNotice) {
4456
+ process.stdout.write(`\u26A0\uFE0F ${view.replayNotice}
4457
+ `);
4458
+ }
4459
+ }
4460
+ process.stdout.write(formatObject14(view, { format: fmt }) + "\n");
4461
+ process.exit(0);
4462
+ } catch (e) {
4463
+ const err = e;
4464
+ if (err?.code === "ENOENT") {
4465
+ exitWithError(new Error(`\u5236\u54C1\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${artifactPath}`));
4466
+ } else if (err?.isAxiosError) {
4467
+ exitWithError(fromAxiosError14(err, args.env));
4468
+ } else {
4469
+ exitWithError(e);
4470
+ }
4471
+ }
4472
+ }
4473
+
4415
4474
  // src/commands/skills.ts
4416
4475
  init_exit();
4417
4476
  import { promises as fsp2 } from "fs";
@@ -4433,8 +4492,8 @@ import {
4433
4492
  resolveAllSkillsInstallOrder,
4434
4493
  matchSkills,
4435
4494
  filterByStage,
4436
- formatObject as formatObject15,
4437
- fromAxiosError as fromAxiosError14,
4495
+ formatObject as formatObject16,
4496
+ fromAxiosError as fromAxiosError15,
4438
4497
  loadEnv as loadEnv5,
4439
4498
  loadGlobalConfig as loadGlobalConfig6,
4440
4499
  resolveActiveEnv as resolveActiveEnv3,
@@ -4565,7 +4624,7 @@ import { readFileSync as readFileSync4, readdirSync as readdirSync2, statSync as
4565
4624
  import { createHash } from "crypto";
4566
4625
  import * as path2 from "path";
4567
4626
  import { fileURLToPath } from "url";
4568
- import { formatObject as formatObject14, parseSkillFrontmatter } from "@hcmai/sdk";
4627
+ import { formatObject as formatObject15, parseSkillFrontmatter } from "@hcmai/sdk";
4569
4628
  function collectCommandSurface(root) {
4570
4629
  const out = [];
4571
4630
  const walk = (cmd, prefix) => {
@@ -4636,7 +4695,7 @@ function buildManifest(root, skillsDir = bundledSkillsDir()) {
4636
4695
  }
4637
4696
  function skillsManifestCommand(root, args) {
4638
4697
  const manifest2 = buildManifest(root);
4639
- process.stdout.write(formatObject14(manifest2, { format: args.output ?? "json" }) + "\n");
4698
+ process.stdout.write(formatObject15(manifest2, { format: args.output ?? "json" }) + "\n");
4640
4699
  }
4641
4700
  function str(v) {
4642
4701
  return typeof v === "string" && v ? v : void 0;
@@ -4832,7 +4891,7 @@ function fail4(e, args) {
4832
4891
  if (err?.response?.status === 404) {
4833
4892
  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"));
4834
4893
  }
4835
- if (err?.isAxiosError) exitWithError(fromAxiosError14(err, args.env));
4894
+ if (err?.isAxiosError) exitWithError(fromAxiosError15(err, args.env));
4836
4895
  exitWithError(e);
4837
4896
  process.exit(1);
4838
4897
  }
@@ -4883,7 +4942,7 @@ async function skillsListCommand(keyword, args) {
4883
4942
  }
4884
4943
  if (fmt === "json" || fmt === "yaml") {
4885
4944
  process.stdout.write(
4886
- formatObject15(
4945
+ formatObject16(
4887
4946
  {
4888
4947
  ...manifest2 ?? {},
4889
4948
  categories: cats,
@@ -4965,7 +5024,7 @@ async function listInstalledSkills(keyword, args) {
4965
5024
  const fmt = args.output ?? "table";
4966
5025
  if (!state || Object.keys(state.skills).length === 0) {
4967
5026
  if (fmt === "json" || fmt === "yaml") {
4968
- process.stdout.write(formatObject15({ baseDir: layout.baseDir, target: layout.target, all: false, skills: [] }, { format: fmt }) + "\n");
5027
+ process.stdout.write(formatObject16({ baseDir: layout.baseDir, target: layout.target, all: false, skills: [] }, { format: fmt }) + "\n");
4969
5028
  process.exit(0);
4970
5029
  }
4971
5030
  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
@@ -4998,7 +5057,7 @@ async function listInstalledSkills(keyword, args) {
4998
5057
  const shown = sourceFilter === "all" ? byKeyword : byKeyword.filter((row) => row.sourceKind === sourceFilter);
4999
5058
  const groupOf = (kind) => kind === "cli" ? "CLI \u81EA\u5E26" : kind === "local" ? "\u672C\u5730\u76EE\u5F55\u88C5\u7684" : "\u777F\u620E\u6280\u80FD\u5E93";
5000
5059
  if (fmt === "json" || fmt === "yaml") {
5001
- process.stdout.write(formatObject15({
5060
+ process.stdout.write(formatObject16({
5002
5061
  baseDir: layout.baseDir,
5003
5062
  target: layout.target,
5004
5063
  endpoint: state.endpoint,
@@ -5197,7 +5256,7 @@ async function skillsInstallCommand(id, args) {
5197
5256
  const agents = layout.agentsFile ? await syncAgentsIndex(layout, manifest2) : void 0;
5198
5257
  const fmt = args.output ?? "table";
5199
5258
  if (fmt === "json" || fmt === "yaml") {
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");
5259
+ process.stdout.write(formatObject16({ ...result, all, target_agent: layout.target, agentsFile: layout.agentsFile, agents, conflictCheck: conflictNote ? { checked: false, note: conflictNote } : { checked: true } }, { format: fmt }) + "\n");
5201
5260
  } else {
5202
5261
  const headline = all ? `\u2705 \u5168\u90E8 ${requestedIds.length} \u4E2A\u6280\u80FD \u2192 ${result.baseDir}` : `\u2705 ${id} \u2192 ${path4.join(result.baseDir, id, "SKILL.md")}`;
5203
5262
  process.stdout.write(`${headline}
@@ -5762,7 +5821,7 @@ async function skillsUpdateCommand(args) {
5762
5821
  const changed = plan.entries.filter((e) => e.status === "updated" || e.status === "added");
5763
5822
  const fmt = args.output ?? "table";
5764
5823
  if (fmt === "json" || fmt === "yaml") {
5765
- process.stdout.write(formatObject15({
5824
+ process.stdout.write(formatObject16({
5766
5825
  endpoint,
5767
5826
  baseDir: layout.baseDir,
5768
5827
  target: layout.target,
@@ -5841,8 +5900,8 @@ async function skillsUpdateCommand(args) {
5841
5900
  import {
5842
5901
  bootstrapTenant,
5843
5902
  createHttpClient as createHttpClient3,
5844
- formatObject as formatObject16,
5845
- fromAxiosError as fromAxiosError15,
5903
+ formatObject as formatObject17,
5904
+ fromAxiosError as fromAxiosError16,
5846
5905
  loadEnv as loadEnv6,
5847
5906
  loadGlobalConfig as loadGlobalConfig7,
5848
5907
  resolveActiveEnv as resolveActiveEnv4,
@@ -5933,14 +5992,14 @@ async function tenantBootstrapCommand(args) {
5933
5992
  `
5934
5993
  );
5935
5994
  }
5936
- process.stdout.write(formatObject16(result, { format: fmt }) + "\n");
5995
+ process.stdout.write(formatObject17(result, { format: fmt }) + "\n");
5937
5996
  process.exit(0);
5938
5997
  } catch (e) {
5939
5998
  const err = e;
5940
5999
  if (err?.response?.status === 403) {
5941
6000
  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"));
5942
6001
  } else if (err?.isAxiosError) {
5943
- exitWithError(fromAxiosError15(err, args.env));
6002
+ exitWithError(fromAxiosError16(err, args.env));
5944
6003
  } else {
5945
6004
  exitWithError(e);
5946
6005
  }
@@ -5950,9 +6009,9 @@ async function tenantBootstrapCommand(args) {
5950
6009
  // src/commands/meta.ts
5951
6010
  import { promises as fsp3 } from "fs";
5952
6011
  import {
5953
- HcmClient as HcmClient16,
5954
- formatObject as formatObject17,
5955
- fromAxiosError as fromAxiosError16,
6012
+ HcmClient as HcmClient17,
6013
+ formatObject as formatObject18,
6014
+ fromAxiosError as fromAxiosError17,
5956
6015
  listTenantMeta,
5957
6016
  getTenantMeta,
5958
6017
  saveTenantMeta,
@@ -5963,7 +6022,7 @@ import {
5963
6022
  init_exit();
5964
6023
  init_auth_guard();
5965
6024
  async function client2(args) {
5966
- return HcmClient16.fromAuthContext(await getActiveAuthContextFromCli(args));
6025
+ return HcmClient17.fromAuthContext(await getActiveAuthContextFromCli(args));
5967
6026
  }
5968
6027
  function fail5(e, args) {
5969
6028
  const err = e;
@@ -5972,7 +6031,7 @@ function fail5(e, args) {
5972
6031
  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>`")
5973
6032
  );
5974
6033
  }
5975
- if (err?.isAxiosError) exitWithError(fromAxiosError16(err, args.env));
6034
+ if (err?.isAxiosError) exitWithError(fromAxiosError17(err, args.env));
5976
6035
  exitWithError(e);
5977
6036
  process.exit(1);
5978
6037
  }
@@ -5988,7 +6047,7 @@ async function metaListCommand(args) {
5988
6047
  const fmt = args.output ?? "json";
5989
6048
  if (fmt !== "json") process.stdout.write(`\u{1F4C4} ${items.length} \u4EFD${total ? ` / \u5171 ${total}` : ""}
5990
6049
  `);
5991
- process.stdout.write(formatObject17(items, { format: fmt }) + "\n");
6050
+ process.stdout.write(formatObject18(items, { format: fmt }) + "\n");
5992
6051
  process.exit(0);
5993
6052
  } catch (e) {
5994
6053
  fail5(e, args);
@@ -6036,7 +6095,7 @@ ${content}
6036
6095
  \u8BB0\u5F97\u6E05\u7F13\u5B58\uFF1Ahcm cache clear-meta <Model>
6037
6096
  `);
6038
6097
  }
6039
- process.stdout.write(formatObject17(result, { format: fmt }) + "\n");
6098
+ process.stdout.write(formatObject18(result, { format: fmt }) + "\n");
6040
6099
  process.exit(0);
6041
6100
  } catch (e) {
6042
6101
  if (e?.code === "ENOENT") exitWithError(new Error(`\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${args.file}`));
@@ -6057,7 +6116,7 @@ async function metaDeleteCommand(path12, args) {
6057
6116
  const fmt = args.output ?? "json";
6058
6117
  if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${path12}
6059
6118
  `);
6060
- process.stdout.write(formatObject17(result, { format: fmt }) + "\n");
6119
+ process.stdout.write(formatObject18(result, { format: fmt }) + "\n");
6061
6120
  process.exit(0);
6062
6121
  } catch (e) {
6063
6122
  fail5(e, args);
@@ -6076,10 +6135,10 @@ import {
6076
6135
  createWorkspaceFile,
6077
6136
  deleteWorkspaceFile,
6078
6137
  formatMiniVerifyReport,
6079
- formatObject as formatObject18,
6138
+ formatObject as formatObject19,
6080
6139
  formatRows as formatRows5,
6081
6140
  getMiniStatus,
6082
- HcmClient as HcmClient17,
6141
+ HcmClient as HcmClient18,
6083
6142
  initMiniAppProject,
6084
6143
  inferMiniWritableTemplateOptionsFromModel,
6085
6144
  listWorkspaceFiles,
@@ -6089,7 +6148,7 @@ import {
6089
6148
  runMiniSmokeChecks,
6090
6149
  saveWorkspaceFileContent,
6091
6150
  validateMiniProject,
6092
- fromAxiosError as fromAxiosError17
6151
+ fromAxiosError as fromAxiosError18
6093
6152
  } from "@hcmai/sdk";
6094
6153
 
6095
6154
  // src/commands/workspace-format.ts
@@ -6136,7 +6195,7 @@ var RAW_WORKSPACE_EXCLUDED_DIRS = /* @__PURE__ */ new Set([
6136
6195
  var RAW_WORKSPACE_EXCLUDED_FILES = /* @__PURE__ */ new Set([WORKSPACE_CONTEXT_FILE, ".DS_Store"]);
6137
6196
  async function workspaceListCommand(args) {
6138
6197
  try {
6139
- const client3 = HcmClient17.fromAuthContext(await getActiveAuthContextFromCli(args));
6198
+ const client3 = HcmClient18.fromAuthContext(await getActiveAuthContextFromCli(args));
6140
6199
  const limit = parsePositiveInt3(args.limit, 50, "--limit");
6141
6200
  const result = await client3.query("TenantExtensionWorkspace", {
6142
6201
  keyword: args.keyword,
@@ -6165,7 +6224,7 @@ async function workspaceActiveCommand(args) {
6165
6224
  const ctx = await getActiveAuthContextFromCli(args, {
6166
6225
  fallbackEnv: localContext?.profile
6167
6226
  });
6168
- const client3 = HcmClient17.fromAuthContext(ctx);
6227
+ const client3 = HcmClient18.fromAuthContext(ctx);
6169
6228
  const result = await client3.query("TenantExtensionWorkspace", {
6170
6229
  filter: { devModeEnabled: true },
6171
6230
  fields: ["workspaceKey", "devModeEnabled"],
@@ -6220,7 +6279,7 @@ async function workspaceCreateCommand(workspaceKey, args) {
6220
6279
  `${WORKSPACE_CONTEXT_FILE} already binds workspace '${existing.workspaceKey}'; use --force to rebind`
6221
6280
  );
6222
6281
  }
6223
- const client3 = HcmClient17.fromAuthContext(await getActiveAuthContextFromCli(args));
6282
+ const client3 = HcmClient18.fromAuthContext(await getActiveAuthContextFromCli(args));
6224
6283
  const normalizedWorkspaceKey = normalizeWorkspaceKey(workspaceKey);
6225
6284
  const resp = await client3.raw().post("/api/models/TenantExtensionWorkspace", {
6226
6285
  workspaceKey: normalizedWorkspaceKey,
@@ -6267,7 +6326,7 @@ async function workspacePullCommand(args) {
6267
6326
  `workspace key is required; pass --workspace <key> or run hcm workspace bind <key> first`
6268
6327
  );
6269
6328
  }
6270
- const client3 = HcmClient17.fromAuthContext(
6329
+ const client3 = HcmClient18.fromAuthContext(
6271
6330
  await getActiveAuthContextFromCli(args, { fallbackEnv: existing?.profile })
6272
6331
  );
6273
6332
  const context = buildWorkspaceContext({
@@ -6405,7 +6464,7 @@ async function workspaceStatusCommand(args) {
6405
6464
  }
6406
6465
  if (args.output === "json" || args.output === "yaml") {
6407
6466
  process.stdout.write(
6408
- formatObject18({ rootDir, miniApps: rows }, { format: args.output }) + "\n"
6467
+ formatObject19({ rootDir, miniApps: rows }, { format: args.output }) + "\n"
6409
6468
  );
6410
6469
  } else {
6411
6470
  process.stdout.write(formatRows5(rows, { format: "table" }) + "\n");
@@ -6437,7 +6496,7 @@ async function workspacePushCommand(args) {
6437
6496
  const rootDir = resolveRootDir(args.dir);
6438
6497
  const context = await requireWorkspaceContext(rootDir);
6439
6498
  const miniApps = await discoverMiniApps(rootDir);
6440
- const client3 = HcmClient17.fromAuthContext(
6499
+ const client3 = HcmClient18.fromAuthContext(
6441
6500
  await getActiveAuthContextFromCli(args, { fallbackEnv: context.profile })
6442
6501
  );
6443
6502
  const activeWorkspaceKey = args.dryRun ? null : await probeActiveWorkspaceKey(client3);
@@ -6509,7 +6568,7 @@ async function workspacePreviewCommand(args) {
6509
6568
  );
6510
6569
  }
6511
6570
  if (args.output === "json" || args.output === "yaml") {
6512
- process.stdout.write(formatObject18(rows, { format: args.output }) + "\n");
6571
+ process.stdout.write(formatObject19(rows, { format: args.output }) + "\n");
6513
6572
  } else {
6514
6573
  process.stdout.write(formatRows5(rows, { format: "table" }) + "\n");
6515
6574
  }
@@ -6960,7 +7019,7 @@ async function readMiniStatusSafely(app) {
6960
7019
  async function loadProfileClient(args) {
6961
7020
  try {
6962
7021
  const ctx = await getActiveAuthContextFromCli(args);
6963
- return HcmClient17.fromAuthContext(ctx);
7022
+ return HcmClient18.fromAuthContext(ctx);
6964
7023
  } catch (e) {
6965
7024
  if (args.env || args.profile) throw e;
6966
7025
  return null;
@@ -7115,7 +7174,7 @@ function optionalText(value) {
7115
7174
  }
7116
7175
  function writeWorkspaceListResult(rows, format, total) {
7117
7176
  if (format !== "table") {
7118
- process.stdout.write(formatObject18({ rows, total }, { format }) + "\n");
7177
+ process.stdout.write(formatObject19({ rows, total }, { format }) + "\n");
7119
7178
  return;
7120
7179
  }
7121
7180
  process.stdout.write(formatRows5(toWorkspaceListRows(rows), { format: "table" }) + "\n");
@@ -7126,7 +7185,7 @@ function writeWorkspaceListResult(rows, format, total) {
7126
7185
  }
7127
7186
  function writeWorkspaceActiveResult(view, format) {
7128
7187
  if (format !== "table") {
7129
- process.stdout.write(formatObject18(view, { format }) + "\n");
7188
+ process.stdout.write(formatObject19(view, { format }) + "\n");
7130
7189
  return;
7131
7190
  }
7132
7191
  const rows = [
@@ -7144,7 +7203,7 @@ function writeWorkspaceActiveResult(view, format) {
7144
7203
  }
7145
7204
  function writeWorkspaceBindResult(context, rootDir, format) {
7146
7205
  if (format !== "table") {
7147
- process.stdout.write(formatObject18({ ...context, rootDir }, { format }) + "\n");
7206
+ process.stdout.write(formatObject19({ ...context, rootDir }, { format }) + "\n");
7148
7207
  return;
7149
7208
  }
7150
7209
  process.stdout.write(
@@ -7158,7 +7217,7 @@ function writeWorkspaceBindResult(context, rootDir, format) {
7158
7217
  }
7159
7218
  function writeWorkspaceCreateResult(result, format) {
7160
7219
  if (format !== "table") {
7161
- process.stdout.write(formatObject18(result, { format }) + "\n");
7220
+ process.stdout.write(formatObject19(result, { format }) + "\n");
7162
7221
  return;
7163
7222
  }
7164
7223
  process.stdout.write(
@@ -7174,7 +7233,7 @@ function writeWorkspaceCreateResult(result, format) {
7174
7233
  }
7175
7234
  function writeWorkspacePullResult(result, format) {
7176
7235
  if (format !== "table") {
7177
- process.stdout.write(formatObject18(result, { format }) + "\n");
7236
+ process.stdout.write(formatObject19(result, { format }) + "\n");
7178
7237
  return;
7179
7238
  }
7180
7239
  const lines = [
@@ -7192,7 +7251,7 @@ function writeWorkspacePullResult(result, format) {
7192
7251
  }
7193
7252
  function writeWorkspaceAddMiniResult(result, rootDir, format) {
7194
7253
  if (format !== "table") {
7195
- process.stdout.write(formatObject18({ ...result, workspaceRoot: rootDir }, { format }) + "\n");
7254
+ process.stdout.write(formatObject19({ ...result, workspaceRoot: rootDir }, { format }) + "\n");
7196
7255
  return;
7197
7256
  }
7198
7257
  process.stdout.write(
@@ -7208,7 +7267,7 @@ function writeWorkspaceAddMiniResult(result, rootDir, format) {
7208
7267
  function writeWorkspaceValidateResult(results, format) {
7209
7268
  if (format !== "table") {
7210
7269
  process.stdout.write(
7211
- formatObject18(
7270
+ formatObject19(
7212
7271
  results.map((item) => ({ artifact: `mini:${item.app.appCode}`, ...item.result })),
7213
7272
  { format }
7214
7273
  ) + "\n"
@@ -7236,7 +7295,7 @@ mini:${item.app.appCode}
7236
7295
  function writeWorkspacePushResult(rawResult, results, format) {
7237
7296
  if (format !== "table") {
7238
7297
  process.stdout.write(
7239
- formatObject18(
7298
+ formatObject19(
7240
7299
  {
7241
7300
  workspaceFiles: { artifact: "workspace", ...rawResult },
7242
7301
  miniApps: results.map((item) => ({ artifact: `mini:${item.app.appCode}`, ...item.result }))
@@ -7292,7 +7351,7 @@ function writeWorkspaceVerifyResult(context, rootDir, raw, reports, format) {
7292
7351
  const ok = rawOk && reports.every((item) => item.report.ok);
7293
7352
  if (format === "json") {
7294
7353
  process.stdout.write(
7295
- formatObject18(
7354
+ formatObject19(
7296
7355
  {
7297
7356
  ok,
7298
7357
  workspaceKey: context.workspaceKey,
@@ -7319,7 +7378,7 @@ function writeWorkspaceVerifyResult(context, rootDir, raw, reports, format) {
7319
7378
  }
7320
7379
  if (format !== "table") {
7321
7380
  process.stdout.write(
7322
- formatObject18(
7381
+ formatObject19(
7323
7382
  {
7324
7383
  ok,
7325
7384
  workspaceKey: context.workspaceKey,
@@ -7371,7 +7430,7 @@ function formatStatusSummary(summary) {
7371
7430
  function exitWorkspaceError(err, profile) {
7372
7431
  const maybeAxios = err;
7373
7432
  if (maybeAxios?.isAxiosError) {
7374
- exitWithError(fromAxiosError17(err, profile));
7433
+ exitWithError(fromAxiosError18(err, profile));
7375
7434
  }
7376
7435
  exitWithError(err);
7377
7436
  }
@@ -7406,7 +7465,7 @@ async function setDevModeBinding(client3, workspaceKey) {
7406
7465
  }
7407
7466
  async function workspaceActivateCommand(workspaceKey, args) {
7408
7467
  try {
7409
- const client3 = HcmClient17.fromAuthContext(await getActiveAuthContextFromCli(args));
7468
+ const client3 = HcmClient18.fromAuthContext(await getActiveAuthContextFromCli(args));
7410
7469
  const key2 = normalizeWorkspaceKey(workspaceKey);
7411
7470
  await setDevModeBinding(client3, key2);
7412
7471
  const fmt = args.output ?? "table";
@@ -7416,7 +7475,7 @@ async function workspaceActivateCommand(workspaceKey, args) {
7416
7475
  process.stdout.write("\u8BE5\u7A7A\u95F4\u7684 metas / scripts / menus / mini_apps \u73B0\u5DF2\u5728\u5F53\u524D\u79DF\u6237\u751F\u6548\u3002\n");
7417
7476
  } else {
7418
7477
  process.stdout.write(
7419
- formatObject18({ workspaceKey: key2, activated: true }, { format: fmt }) + "\n"
7478
+ formatObject19({ workspaceKey: key2, activated: true }, { format: fmt }) + "\n"
7420
7479
  );
7421
7480
  }
7422
7481
  process.exit(0);
@@ -7504,8 +7563,8 @@ init_auth_guard();
7504
7563
  import { existsSync as existsSync2 } from "fs";
7505
7564
  import { join as pathJoin } from "path";
7506
7565
  import {
7507
- HcmClient as HcmClient18,
7508
- formatObject as formatObject19
7566
+ HcmClient as HcmClient19,
7567
+ formatObject as formatObject20
7509
7568
  } from "@hcmai/sdk";
7510
7569
 
7511
7570
  // src/commands/delivery.ts
@@ -7528,16 +7587,32 @@ var GUARDED_EXECUTOR_REASON_CODES = /* @__PURE__ */ new Set([
7528
7587
  "setting-write",
7529
7588
  "credential-reset",
7530
7589
  "action-write",
7531
- // workspace 侧只收**输入可完整绑进计划**的那两个:它们的入参是 workspace key,
7532
- // 没有外部载荷文件。
7533
- //
7534
- // 🔴 刻意不收 workspace-push / metadata-write / workspace-local-change:
7535
- // push 读的是整个本地目录、meta set 读 --file 指向的任意文件,而载荷绑定只覆盖
7536
- // --data-file / --params-file(PAYLOAD_FILE_FLAGS)。绑不住就意味着「批准时看到的内容」
7537
- // 与「执行时实际读到的内容」可以不同 —— 那正是受控执行要挡住的东西。
7538
- // 要收它们,得先把目录/文件载荷也纳入绑定与 assertPayloadsUnchanged。
7539
7590
  "workspace-create",
7540
- "workspace-activate"
7591
+ "workspace-activate",
7592
+ // 这两个的载荷是**任意文件 / 整棵目录**,此前刻意不收——绑不住就意味着
7593
+ // 「批准时看到的内容」与「执行时实际读到的内容」可以不同。
7594
+ //
7595
+ // 现在绑得住了:PAYLOAD_FILE_FLAGS 收了 --file,PAYLOAD_DIR_FLAGS 收了 --dir
7596
+ // (workspace push 不传 --dir 时按其 option 默认值 '.' 隐式绑定),
7597
+ // 目录按「路径 + 内容、排序稳定」整树摘要,assertPayloadsUnchanged 执行前逐一重算比对。
7598
+ //
7599
+ // 🔴 二次开发的整条链就卡在这两个上:2026-09-01 轨道 A 第四轮验收,
7600
+ // 受控执行第一次跑通了 workspace create,却在 meta set / workspace push 上
7601
+ // 被「该 R2 命令不在首批受控执行器支持面」拦死,远端只多了一个空 workspace。
7602
+ "metadata-write",
7603
+ "workspace-push",
7604
+ // 载荷是**位置参数**(`hcm import <路径>`),既不走 --file 也不走 --dir,
7605
+ // 所以上一刀把文件与目录开关收进来时它仍留在外面(0.4.9 CHANGELOG 逐字记了这一条)。
7606
+ //
7607
+ // 现在收得住了:POSITIONAL_PAYLOAD_COMMANDS 把 argv[1] 这个固定位置钉成载荷,
7608
+ // 目录走整树摘要、单文件走文件摘要,execute 前重算比对(与 --dir 同一套 bind/assert)。
7609
+ // 位置定死而不是「扫第一个非 flag 参数」,是因为 shape 校验与载荷绑定必须对
7610
+ // 「哪个 token 是载荷」看法一致——两处各自解析就能绑 A 执行 B。
7611
+ //
7612
+ // 🔴 客户存量组织导入的整条链就卡在这一个上:2026-09-01 演示环境租户 15,
7613
+ // 531 条组织机构 dry-run 全绿(静态校验 0 失败),正式导入被
7614
+ // 「该 R2 命令不在首批受控执行器支持面」拦死,一个写请求都没发出去。
7615
+ "import-write"
7541
7616
  ]);
7542
7617
  function assessDeliveryCommand(inputArgv, options = {}) {
7543
7618
  const argv = inputArgv[0] === "--" ? inputArgv.slice(1) : [...inputArgv];
@@ -7897,7 +7972,7 @@ function withProjectReadiness(assessment, projectRoot = ".") {
7897
7972
  async function deliveryAssessCommand(argv, args) {
7898
7973
  const assessment = await assessEffectiveDeliveryCommand(argv);
7899
7974
  const enriched = withProjectReadiness(assessment);
7900
- process.stdout.write(formatObject19(enriched, { format: args.output ?? "json" }) + "\n");
7975
+ process.stdout.write(formatObject20(enriched, { format: args.output ?? "json" }) + "\n");
7901
7976
  }
7902
7977
  async function resolveCoreAction(request) {
7903
7978
  try {
@@ -7906,7 +7981,7 @@ async function resolveCoreAction(request) {
7906
7981
  as: request.identity,
7907
7982
  profile: request.profile
7908
7983
  });
7909
- const description = await HcmClient18.fromAuthContext(auth).describe(request.model);
7984
+ const description = await HcmClient19.fromAuthContext(auth).describe(request.model);
7910
7985
  const named = description.actions.filter((action2) => action2.name === request.action);
7911
7986
  if (named.length === 0) {
7912
7987
  return failed(
@@ -7996,7 +8071,7 @@ function flagValue2(argv, flag) {
7996
8071
  init_exit();
7997
8072
  import { promises as fs6 } from "fs";
7998
8073
  import path6 from "path";
7999
- import { formatObject as formatObject20 } from "@hcmai/sdk";
8074
+ import { formatObject as formatObject21 } from "@hcmai/sdk";
8000
8075
  var MODES = ["plan-only", "controlled"];
8001
8076
  var SCAFFOLD_DIRS = ["work", "decisions", "evidence"];
8002
8077
  function renderProjectYml(mode) {
@@ -8055,7 +8130,7 @@ async function deliveryInitCommand(args) {
8055
8130
  scaffold: created,
8056
8131
  nextStep: mode === "controlled" ? "hcm delivery assess <\u547D\u4EE4>\uFF1BR2 \u518D hcm delivery prepare --change-ref \u2026 --rollback-ref \u2026 --evidence-dir \u2026" : "hcm delivery assess <\u547D\u4EE4>\uFF1B\u672C\u9879\u76EE\u4E3A plan-only\uFF0Cexecute \u4F1A\u88AB\u62D2\u7EDD"
8057
8132
  };
8058
- process.stdout.write(formatObject20(result, { format: args.output ?? "json" }) + "\n");
8133
+ process.stdout.write(formatObject21(result, { format: args.output ?? "json" }) + "\n");
8059
8134
  process.exit(0);
8060
8135
  } catch (e) {
8061
8136
  exitWithError(e);
@@ -8067,10 +8142,10 @@ async function deliveryInitCommand(args) {
8067
8142
  init_auth_guard();
8068
8143
  init_exit();
8069
8144
  import {
8070
- HcmClient as HcmClient19,
8145
+ HcmClient as HcmClient20,
8071
8146
  fetchReconIdentity,
8072
- formatObject as formatObject21,
8073
- fromAxiosError as fromAxiosError18,
8147
+ formatObject as formatObject22,
8148
+ fromAxiosError as fromAxiosError19,
8074
8149
  httpProbe,
8075
8150
  runDoctor
8076
8151
  } from "@hcmai/sdk";
@@ -8089,17 +8164,17 @@ function render2(report) {
8089
8164
  async function deliveryDoctorCommand(args) {
8090
8165
  try {
8091
8166
  const ctx = await getActiveAuthContextFromCli(args);
8092
- const client3 = HcmClient19.fromAuthContext(ctx);
8167
+ const client3 = HcmClient20.fromAuthContext(ctx);
8093
8168
  const probe = httpProbe(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES);
8094
8169
  const identity2 = await fetchReconIdentity(probe, ctx.tenantId);
8095
8170
  const report = await runDoctor(probe, identity2);
8096
8171
  const fmt = args.output ?? "json";
8097
8172
  if (fmt !== "json") process.stdout.write(render2(report) + "\n");
8098
- process.stdout.write(formatObject21(report, { format: fmt }) + "\n");
8173
+ process.stdout.write(formatObject22(report, { format: fmt }) + "\n");
8099
8174
  process.exit(report.ok ? 0 : 1);
8100
8175
  } catch (e) {
8101
8176
  const err = e;
8102
- if (err?.isAxiosError) exitWithError(fromAxiosError18(err, args.env));
8177
+ if (err?.isAxiosError) exitWithError(fromAxiosError19(err, args.env));
8103
8178
  exitWithError(e);
8104
8179
  process.exit(1);
8105
8180
  }
@@ -8109,12 +8184,12 @@ async function deliveryDoctorCommand(args) {
8109
8184
  init_auth_guard();
8110
8185
  init_exit();
8111
8186
  import {
8112
- HcmClient as HcmClient20,
8187
+ HcmClient as HcmClient21,
8113
8188
  ReconLayout,
8114
8189
  ROUND_EXIT_CODES,
8115
8190
  computeReconSourceKey,
8116
- formatObject as formatObject22,
8117
- fromAxiosError as fromAxiosError19,
8191
+ formatObject as formatObject23,
8192
+ fromAxiosError as fromAxiosError20,
8118
8193
  httpProbe as httpProbe2,
8119
8194
  inspectRound,
8120
8195
  renderRound,
@@ -8124,7 +8199,7 @@ var DEFAULT_CAPABILITIES2 = "default";
8124
8199
  async function deliveryReconCommand(args) {
8125
8200
  try {
8126
8201
  const ctx = await getActiveAuthContextFromCli(args);
8127
- const client3 = HcmClient20.fromAuthContext(ctx);
8202
+ const client3 = HcmClient21.fromAuthContext(ctx);
8128
8203
  const probe = httpProbe2(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES2);
8129
8204
  const sourceKey = await computeReconSourceKey(probe);
8130
8205
  const layout = new ReconLayout(args.out ?? ".", ctx.tenantId, sourceKey);
@@ -8133,10 +8208,10 @@ async function deliveryReconCommand(args) {
8133
8208
  onlyModel: args.model ?? null,
8134
8209
  identity: ctx.tenantId ? { requestedTenantId: ctx.tenantId } : null
8135
8210
  });
8136
- process.stdout.write(formatObject22(summary, { format: args.output ?? "json" }) + "\n");
8211
+ process.stdout.write(formatObject23(summary, { format: args.output ?? "json" }) + "\n");
8137
8212
  } catch (e) {
8138
8213
  const err = e;
8139
- if (err?.isAxiosError) exitWithError(fromAxiosError19(err, args.env));
8214
+ if (err?.isAxiosError) exitWithError(fromAxiosError20(err, args.env));
8140
8215
  exitWithError(e);
8141
8216
  process.exit(1);
8142
8217
  }
@@ -8147,7 +8222,7 @@ async function deliveryReconRoundCommand(args) {
8147
8222
  const result = inspectRound(args.dir ?? ".");
8148
8223
  const fmt = args.output ?? "json";
8149
8224
  if (fmt !== "json") process.stdout.write(renderRound(result));
8150
- process.stdout.write(formatObject22(result, { format: fmt }) + "\n");
8225
+ process.stdout.write(formatObject23(result, { format: fmt }) + "\n");
8151
8226
  code = ROUND_EXIT_CODES[result.state];
8152
8227
  } catch (e) {
8153
8228
  exitWithError(e);
@@ -8165,7 +8240,7 @@ import {
8165
8240
  GAP_REASONS,
8166
8241
  deriveAclass,
8167
8242
  exitCode as gate0ExitCode,
8168
- formatObject as formatObject23,
8243
+ formatObject as formatObject24,
8169
8244
  inspectRound as inspectRound2,
8170
8245
  loadProtocolFacts,
8171
8246
  scan
@@ -8210,7 +8285,7 @@ async function deliveryGate0Command(args) {
8210
8285
  const merged = { ...result, premise: premise5 };
8211
8286
  const fmt = args.output ?? "json";
8212
8287
  if (fmt !== "json") process.stdout.write(renderGate0(merged, skillRoot));
8213
- process.stdout.write(`${formatObject23(merged, { format: fmt })}
8288
+ process.stdout.write(`${formatObject24(merged, { format: fmt })}
8214
8289
  `);
8215
8290
  for (const problem of premise5) {
8216
8291
  process.stderr.write(`\u{1F534} \u524D\u63D0\u4E0D\u6210\u7ACB\uFF08${problem.reason}\uFF09\uFF1A${problem.message}
@@ -8234,7 +8309,7 @@ import {
8234
8309
  DRY_RUN_TAIL,
8235
8310
  DriftDetected,
8236
8311
  FORCE_STALE_FLAG,
8237
- HcmClient as HcmClient21,
8312
+ HcmClient as HcmClient22,
8238
8313
  fetchReconIdentity as fetchReconIdentity2,
8239
8314
  INIT_EXIT_CODES,
8240
8315
  JOURNAL_STOP_KINDS,
@@ -8374,7 +8449,7 @@ async function authOrSignpost(args, cmd) {
8374
8449
  }
8375
8450
  async function deliverySeedPlanCommand(args) {
8376
8451
  const ctx = await authOrSignpost(args, "plan");
8377
- const client3 = HcmClient21.fromAuthContext(ctx);
8452
+ const client3 = HcmClient22.fromAuthContext(ctx);
8378
8453
  process.exitCode = await runSeedPlan(args, seedClient(client3, ctx));
8379
8454
  }
8380
8455
  function seedClient(client3, ctx) {
@@ -8548,7 +8623,7 @@ async function runSeedApply(args, client3) {
8548
8623
  }
8549
8624
  async function deliverySeedApplyCommand(args) {
8550
8625
  const ctx = await authOrSignpost(args, "apply");
8551
- const client3 = HcmClient21.fromAuthContext(ctx);
8626
+ const client3 = HcmClient22.fromAuthContext(ctx);
8552
8627
  process.exitCode = await runSeedApply(args, seedClient(client3, ctx));
8553
8628
  }
8554
8629
  async function runSeedVerify(args, client3) {
@@ -8572,7 +8647,7 @@ async function deliverySeedVerifyCommand(args) {
8572
8647
  return;
8573
8648
  }
8574
8649
  const ctx = await authOrSignpost(args, "verify");
8575
- const client3 = HcmClient21.fromAuthContext(ctx);
8650
+ const client3 = HcmClient22.fromAuthContext(ctx);
8576
8651
  process.exitCode = await runSeedVerify(args, await seedVerifyClient(client3, ctx));
8577
8652
  }
8578
8653
 
@@ -8687,7 +8762,7 @@ import {
8687
8762
  CHANGE_STATES,
8688
8763
  CHANGE_UNKNOWN,
8689
8764
  CODE_WORDS,
8690
- HcmClient as HcmClient22,
8765
+ HcmClient as HcmClient23,
8691
8766
  INIT_EXIT_CODES as INIT_EXIT_CODES3,
8692
8767
  META_WRITE_STEPS,
8693
8768
  META_VERIFY_STEPS,
@@ -8915,7 +8990,7 @@ function lowerCaseHeaders2(headers) {
8915
8990
  }
8916
8991
  async function deliveryMetaCommand(args) {
8917
8992
  const ctx = await getActiveAuthContextFromCli(args);
8918
- const client3 = HcmClient22.fromAuthContext(ctx);
8993
+ const client3 = HcmClient23.fromAuthContext(ctx);
8919
8994
  process.exitCode = await runDeliveryMeta(
8920
8995
  { ...args, tenant: args.tenant ?? String(ctx.tenantId ?? "") },
8921
8996
  metaClient(client3, ctx)
@@ -8927,7 +9002,7 @@ init_auth_guard();
8927
9002
  init_exit();
8928
9003
  import {
8929
9004
  computeReconSourceKey as computeReconSourceKey2,
8930
- HcmClient as HcmClient23,
9005
+ HcmClient as HcmClient24,
8931
9006
  httpProbe as httpProbe3,
8932
9007
  ReconLayout as ReconLayout2,
8933
9008
  runTriageRound
@@ -8983,7 +9058,7 @@ async function runTriage(args) {
8983
9058
  return premise4(e instanceof Error ? e.message : String(e), REQUESTS_SHAPE);
8984
9059
  }
8985
9060
  const ctx = await getActiveAuthContextFromCli(args);
8986
- const client3 = HcmClient23.fromAuthContext(ctx);
9061
+ const client3 = HcmClient24.fromAuthContext(ctx);
8987
9062
  const probe = httpProbe3(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES4);
8988
9063
  const artifactsDir = args.recon ?? new ReconLayout2(args.out ?? ".", ctx.tenantId, await computeReconSourceKey2(probe)).dir;
8989
9064
  const result = await runTriageRound(probe, artifactsDir, entriesIn);
@@ -9012,7 +9087,7 @@ import { createHash as createHash5, randomBytes as secureRandomBytes } from "cry
9012
9087
  import { spawn } from "child_process";
9013
9088
  import { createReadStream, promises as fs7 } from "fs";
9014
9089
  import path11 from "path";
9015
- import { CliError as CliError20, CliErrorCode as CliErrorCode19, formatObject as formatObject24 } from "@hcmai/sdk";
9090
+ import { CliError as CliError20, CliErrorCode as CliErrorCode19, formatObject as formatObject25 } from "@hcmai/sdk";
9016
9091
  init_exit();
9017
9092
  var EXECUTION_CONTRACT_VERSION = "2026-08-29.controlled-v3";
9018
9093
  var DEFAULT_TTL_SECONDS = 15 * 60;
@@ -9022,15 +9097,16 @@ var PLAN_ID_PATTERN = /^[a-f0-9]{24}$/;
9022
9097
  async function prepareDeliveryExecution(input) {
9023
9098
  const project = await realProject(input.project);
9024
9099
  await readProjectMode(project);
9025
- const assessment = await (input.assessCommand ?? assessEffectiveDeliveryCommand)(input.argv);
9026
- assertGuardedAssessment(assessment, input.argv);
9100
+ const argv = normalizeCommandArgv(input.argv);
9101
+ const assessment = await (input.assessCommand ?? assessEffectiveDeliveryCommand)(argv);
9102
+ assertGuardedAssessment(assessment, argv);
9027
9103
  const ttlSeconds = input.ttlSeconds ?? DEFAULT_TTL_SECONDS;
9028
9104
  if (!Number.isInteger(ttlSeconds) || ttlSeconds < MIN_TTL_SECONDS || ttlSeconds > MAX_TTL_SECONDS) {
9029
9105
  throw invalid2(`--ttl-seconds \u5FC5\u987B\u662F ${MIN_TTL_SECONDS} \u5230 ${MAX_TTL_SECONDS} \u7684\u6574\u6570`);
9030
9106
  }
9031
9107
  const change = await bindDocument(project, input.changeRef, "\u53D8\u66F4\u8BF4\u660E");
9032
9108
  const rollback = await bindDocument(project, input.rollbackRef, "\u56DE\u6EDA\u8BF4\u660E");
9033
- const payloads = await bindPayloadFiles(project, input.argv);
9109
+ const payloads = await bindPayloadFiles(project, argv);
9034
9110
  const evidence = await bindEvidenceDirectory(project, input.evidenceDir);
9035
9111
  const lockBytes = await readSkillsLock(project);
9036
9112
  const runtime = await (input.runtimeIdentity ?? currentRuntimeIdentity)();
@@ -9086,8 +9162,9 @@ async function executeDeliveryPlan(input) {
9086
9162
  }
9087
9163
  if (now.getTime() < createdAt - 5e3) throw invalid2("\u5F53\u524D\u65F6\u95F4\u65E9\u4E8E\u8BA1\u5212\u521B\u5EFA\u65F6\u95F4");
9088
9164
  if (now.getTime() > expiresAt) throw invalid2("\u6267\u884C\u8BA1\u5212\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u91CD\u65B0 prepare");
9089
- const assessment = await (input.assessCommand ?? assessEffectiveDeliveryCommand)(input.argv);
9090
- assertGuardedAssessment(assessment, input.argv);
9165
+ const argv = normalizeCommandArgv(input.argv);
9166
+ const assessment = await (input.assessCommand ?? assessEffectiveDeliveryCommand)(argv);
9167
+ assertGuardedAssessment(assessment, argv);
9091
9168
  if (canonicalJson(assessment) !== canonicalJson(plan.assessment)) {
9092
9169
  throw invalid2("\u5B9E\u9645 argv \u4E0E\u6267\u884C\u8BA1\u5212\u7684\u547D\u4EE4\u6458\u8981\u6216\u98CE\u9669\u4E8B\u5B9E\u4E0D\u4E00\u81F4");
9093
9170
  }
@@ -9123,7 +9200,7 @@ async function executeDeliveryPlan(input) {
9123
9200
  const run = input.runCommand ?? runCurrentCliCommand;
9124
9201
  let exitCode;
9125
9202
  try {
9126
- ({ exitCode } = await run(input.argv, project, {
9203
+ ({ exitCode } = await run(argv, project, {
9127
9204
  stdout: (chunk) => stdoutHash.update(chunk),
9128
9205
  stderr: (chunk) => stderrHash.update(chunk)
9129
9206
  }));
@@ -9166,7 +9243,7 @@ async function deliveryPrepareCommand(argv, args) {
9166
9243
  evidenceDir: args.evidenceDir,
9167
9244
  ...ttlSeconds === void 0 ? {} : { ttlSeconds }
9168
9245
  });
9169
- process.stdout.write(formatObject24(plan, { format: args.output ?? "json" }) + "\n");
9246
+ process.stdout.write(formatObject25(plan, { format: args.output ?? "json" }) + "\n");
9170
9247
  process.stderr.write(`
9171
9248
  \u4E0B\u4E00\u6B65\uFF08argv \u5FC5\u987B\u4E0E\u672C\u6B21\u5B8C\u5168\u4E00\u81F4\uFF09\uFF1A
9172
9249
  ${nextCommandHint(plan.planId, args.project, argv)}
@@ -9187,7 +9264,7 @@ async function deliveryExecuteCommand(planId, argv, args) {
9187
9264
  planId,
9188
9265
  argv
9189
9266
  });
9190
- process.stdout.write(formatObject24(receipt, { format: args.output ?? "json" }) + "\n");
9267
+ process.stdout.write(formatObject25(receipt, { format: args.output ?? "json" }) + "\n");
9191
9268
  process.exitCode = receipt.exitCode;
9192
9269
  } catch (cause) {
9193
9270
  exitWithError(cause);
@@ -9323,6 +9400,18 @@ function validateSupportedCommandShape(reasonCode, argv) {
9323
9400
  }
9324
9401
  return;
9325
9402
  }
9403
+ if (reasonCode === "import-write") {
9404
+ if (argv[0] !== "import") {
9405
+ throw invalid2(`import \u7684\u547D\u4EE4\u540D\u5FC5\u987B\u662F argv \u7684\u7B2C\u4E00\u4E2A token\uFF0C\u5B9E\u9645\u662F\uFF1A${argv[0] ?? "(\u7A7A)"}`);
9406
+ }
9407
+ const dataset = argv[1];
9408
+ if (!dataset || dataset.startsWith("-")) {
9409
+ throw invalid2(
9410
+ "import \u7684\u6570\u636E\u96C6\u8DEF\u5F84\u5FC5\u987B\u7D27\u8DDF\u5728 import \u4E4B\u540E\uFF08hcm import <\u8DEF\u5F84> ...\uFF09\u3002next_step=\u628A\u8DEF\u5F84\u79FB\u5230\u547D\u4EE4\u540D\u540E\u9762\u7684\u7B2C\u4E00\u4E2A\u4F4D\u7F6E\u2014\u2014\u53D7\u63A7\u6267\u884C\u6309\u8FD9\u4E2A\u4F4D\u7F6E\u9489\u4F4F\u8F7D\u8377"
9411
+ );
9412
+ }
9413
+ return;
9414
+ }
9326
9415
  if (reasonCode === "record-create") {
9327
9416
  requireExactlyOnePayload(argv, "create");
9328
9417
  return;
@@ -9370,7 +9459,16 @@ function requireExactlyOnePayload(argv, command) {
9370
9459
  throw invalid2(`${command} \u5FC5\u987B\u5305\u542B --data <JSON> \u6216 --data-file <\u6587\u4EF6>`);
9371
9460
  }
9372
9461
  }
9373
- var PAYLOAD_FILE_FLAGS = ["--data-file", "--params-file"];
9462
+ var PAYLOAD_FILE_FLAGS = ["--data-file", "--params-file", "--file"];
9463
+ var PAYLOAD_DIR_FLAGS = ["--dir"];
9464
+ var IMPLICIT_DIR_COMMANDS = { "workspace push": "." };
9465
+ var TOOLING_DIRS = [".git", "node_modules", ".hcm-delivery", "evidence"];
9466
+ var POSITIONAL_PAYLOAD_COMMANDS = { import: 1 };
9467
+ function normalizeCommandArgv(argv) {
9468
+ let start = 0;
9469
+ while (argv[start] === "--") start += 1;
9470
+ return argv.slice(start);
9471
+ }
9374
9472
  async function bindPayloadFiles(project, argv) {
9375
9473
  const bound = [];
9376
9474
  for (const flag of PAYLOAD_FILE_FLAGS) {
@@ -9378,8 +9476,71 @@ async function bindPayloadFiles(project, argv) {
9378
9476
  if (reference === void 0) continue;
9379
9477
  bound.push(await bindPayloadFile(project, reference, `${flag} \u8F7D\u8377`));
9380
9478
  }
9479
+ for (const flag of PAYLOAD_DIR_FLAGS) {
9480
+ const reference = optionalFlagValue(argv, flag);
9481
+ if (reference === void 0) continue;
9482
+ bound.push(await bindPayloadDirectory(project, reference, `${flag} \u76EE\u5F55\u8F7D\u8377`));
9483
+ }
9484
+ const implicit = IMPLICIT_DIR_COMMANDS[`${argv[0]} ${argv[1]}`];
9485
+ if (implicit !== void 0 && optionalFlagValue(argv, "--dir") === void 0) {
9486
+ bound.push(await bindPayloadDirectory(project, implicit, "\u5DE5\u4F5C\u7A7A\u95F4\u76EE\u5F55\u8F7D\u8377"));
9487
+ }
9488
+ const positional = POSITIONAL_PAYLOAD_COMMANDS[argv[0] ?? ""];
9489
+ if (positional !== void 0) {
9490
+ bound.push(await bindPayloadPath(project, argv[positional] ?? "", `${argv[0]} \u6570\u636E\u96C6\u8F7D\u8377`));
9491
+ }
9381
9492
  return bound;
9382
9493
  }
9494
+ async function bindPayloadPath(project, reference, label) {
9495
+ const relative2 = safeRelative(reference, label);
9496
+ let stat;
9497
+ try {
9498
+ stat = await fs7.stat(path11.join(project, relative2));
9499
+ } catch (cause) {
9500
+ throw invalid2(
9501
+ `${label}\u4E0D\u5B58\u5728\uFF1A${relative2}\u3002next_step=\u628A\u6570\u636E\u96C6\u653E\u8FDB\u9879\u76EE\u76EE\u5F55\u5185\uFF0C\u5E76\u7528\u9879\u76EE\u5185\u76F8\u5BF9\u8DEF\u5F84\u5F15\u7528\uFF08\u53D7\u63A7\u6267\u884C\u53EA\u9489\u5F97\u4F4F\u9879\u76EE\u5185\u7684\u8F7D\u8377\uFF09`,
9502
+ cause
9503
+ );
9504
+ }
9505
+ return stat.isDirectory() ? bindPayloadDirectory(project, relative2, label) : bindPayloadFile(project, relative2, label);
9506
+ }
9507
+ async function bindPayloadDirectory(project, reference, label) {
9508
+ const relative2 = reference === "." ? "." : safeRelative(reference, label);
9509
+ const root = path11.join(project, relative2);
9510
+ let stat;
9511
+ try {
9512
+ stat = await fs7.stat(root);
9513
+ } catch {
9514
+ throw invalid2(`${label}\u4E0D\u5B58\u5728\uFF1A${relative2}`);
9515
+ }
9516
+ if (!stat.isDirectory()) {
9517
+ throw invalid2(`${label}\u4E0D\u662F\u76EE\u5F55\uFF1A${relative2}`);
9518
+ }
9519
+ const skipToolingAtRoot = relative2 === ".";
9520
+ const entries = [];
9521
+ const walk = async (dir, prefix) => {
9522
+ const items = await fs7.readdir(dir, { withFileTypes: true });
9523
+ for (const item of [...items].sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0)) {
9524
+ if (skipToolingAtRoot && prefix === "" && TOOLING_DIRS.includes(item.name)) continue;
9525
+ const child = path11.join(dir, item.name);
9526
+ const rel = prefix ? `${prefix}/${item.name}` : item.name;
9527
+ if (item.isSymbolicLink()) {
9528
+ throw invalid2(
9529
+ `${label}\u542B\u7B26\u53F7\u94FE\u63A5\uFF1A${rel}\u3002next_step=\u628A\u8F6F\u94FE\u6362\u6210\u771F\u5B9E\u6587\u4EF6\u6216\u76EE\u5F55\u2014\u2014\u53D7\u63A7\u6267\u884C\u9489\u4E0D\u4F4F\u8F6F\u94FE\u6307\u5411\u7684\u5185\u5BB9`
9530
+ );
9531
+ }
9532
+ if (item.isDirectory()) {
9533
+ await walk(child, rel);
9534
+ } else if (item.isFile()) {
9535
+ const bytes = await readSafeFile(project, child, `${label} ${rel}`);
9536
+ entries.push(`${rel}
9537
+ ${sha2565(bytes)}`);
9538
+ }
9539
+ }
9540
+ };
9541
+ await walk(root, "");
9542
+ return { path: relative2, sha256: sha2565(Buffer.from(entries.join("\n"), "utf8")) };
9543
+ }
9383
9544
  async function bindPayloadFile(project, reference, label) {
9384
9545
  const relative2 = safeRelative(reference, label);
9385
9546
  const file = path11.join(project, relative2);
@@ -9388,9 +9549,17 @@ async function bindPayloadFile(project, reference, label) {
9388
9549
  }
9389
9550
  async function assertPayloadsUnchanged(project, payloads) {
9390
9551
  for (const payload of payloads) {
9391
- const current = await bindPayloadFile(project, payload.path, `\u8F7D\u8377 ${payload.path}`);
9552
+ let isDirectory = false;
9553
+ try {
9554
+ isDirectory = (await fs7.stat(path11.join(project, payload.path))).isDirectory();
9555
+ } catch {
9556
+ isDirectory = false;
9557
+ }
9558
+ const current = isDirectory ? await bindPayloadDirectory(project, payload.path, `\u8F7D\u8377 ${payload.path}`) : await bindPayloadFile(project, payload.path, `\u8F7D\u8377 ${payload.path}`);
9392
9559
  if (current.sha256 !== payload.sha256) {
9393
- throw invalid2(`\u8F7D\u8377\u6587\u4EF6 ${payload.path} \u7684\u5185\u5BB9\u5DF2\u53D8\u66F4\uFF0C\u8BF7\u91CD\u65B0 prepare`);
9560
+ throw invalid2(
9561
+ `\u8F7D\u8377${isDirectory ? "\u76EE\u5F55" : "\u6587\u4EF6"} ${payload.path} \u7684\u5185\u5BB9\u5DF2\u53D8\u66F4\uFF0C\u8BF7\u91CD\u65B0 prepare`
9562
+ );
9394
9563
  }
9395
9564
  }
9396
9565
  }
@@ -9576,10 +9745,10 @@ function nextCommandHint(planId, project, argv) {
9576
9745
  init_auth_guard();
9577
9746
  init_exit();
9578
9747
  import {
9579
- HcmClient as HcmClient24,
9748
+ HcmClient as HcmClient25,
9580
9749
  adminResetPassword,
9581
- formatObject as formatObject25,
9582
- fromAxiosError as fromAxiosError20,
9750
+ formatObject as formatObject26,
9751
+ fromAxiosError as fromAxiosError21,
9583
9752
  CliError as CliError21,
9584
9753
  CliErrorCode as CliErrorCode20
9585
9754
  } from "@hcmai/sdk";
@@ -9610,12 +9779,12 @@ async function userResetPasswordCommand(args) {
9610
9779
  try {
9611
9780
  const password = args.passwordStdin ? await readSecretFromStdin() : await promptPasswordTwice();
9612
9781
  const request = buildAdminResetPasswordRequest(args, password);
9613
- const client3 = HcmClient24.fromAuthContext(await getActiveAuthContextFromCli(args));
9782
+ const client3 = HcmClient25.fromAuthContext(await getActiveAuthContextFromCli(args));
9614
9783
  const result = await adminResetPassword(client3.raw(), request);
9615
- process.stdout.write(formatObject25(result, { format: args.output ?? "json" }) + "\n");
9784
+ process.stdout.write(formatObject26(result, { format: args.output ?? "json" }) + "\n");
9616
9785
  } catch (cause) {
9617
9786
  const err = cause;
9618
- if (err?.isAxiosError) exitWithError(fromAxiosError20(err, args.env));
9787
+ if (err?.isAxiosError) exitWithError(fromAxiosError21(err, args.env));
9619
9788
  exitWithError(cause);
9620
9789
  }
9621
9790
  }
@@ -9635,19 +9804,19 @@ async function promptPasswordTwice() {
9635
9804
  init_exit();
9636
9805
  init_auth_guard();
9637
9806
  import {
9638
- HcmClient as HcmClient25,
9639
- formatObject as formatObject26,
9640
- fromAxiosError as fromAxiosError21
9807
+ HcmClient as HcmClient26,
9808
+ formatObject as formatObject27,
9809
+ fromAxiosError as fromAxiosError22
9641
9810
  } from "@hcmai/sdk";
9642
9811
  async function modelsCommand(keyword, args) {
9643
9812
  try {
9644
- const client3 = HcmClient25.fromAuthContext(await getActiveAuthContextFromCli(args));
9813
+ const client3 = HcmClient26.fromAuthContext(await getActiveAuthContextFromCli(args));
9645
9814
  const all = await client3.listModels();
9646
9815
  const needle = keyword?.trim().toLowerCase();
9647
9816
  const rows = (needle ? all.filter((m) => JSON.stringify(m).toLowerCase().includes(needle)) : all).sort((a, b) => key(a).localeCompare(key(b)));
9648
9817
  const fmt = args.output ?? "table";
9649
9818
  if (fmt !== "table") {
9650
- process.stdout.write(formatObject26({ total: rows.length, models: rows }, { format: fmt }) + "\n");
9819
+ process.stdout.write(formatObject27({ total: rows.length, models: rows }, { format: fmt }) + "\n");
9651
9820
  process.exit(0);
9652
9821
  }
9653
9822
  if (rows.length === 0) {
@@ -9671,7 +9840,7 @@ async function modelsCommand(keyword, args) {
9671
9840
  process.exit(0);
9672
9841
  } catch (e) {
9673
9842
  const err = e;
9674
- if (err?.isAxiosError) exitWithError(fromAxiosError21(err, args.profile));
9843
+ if (err?.isAxiosError) exitWithError(fromAxiosError22(err, args.profile));
9675
9844
  exitWithError(e);
9676
9845
  }
9677
9846
  }
@@ -9845,6 +10014,9 @@ program.command("upload <file>").description("\u4E0A\u4F20\u672C\u5730\u6587\u4E
9845
10014
  "\u5B58\u50A8\u5206\u7C7B\uFF08\u987B\u662F\u76EE\u6807\u73AF\u5883\u91CC\u771F\u5B9E\u5B58\u5728\u7684\u5206\u7C7B\uFF0C\u5982 flex-report / template / attachment\uFF09",
9846
10015
  "attachment"
9847
10016
  ).action((file, opts) => uploadCommand(file, opts));
10017
+ var datapackage = program.command("datapackage").description("DataPackage \u5355\u6587\u4EF6\u5236\u54C1\uFF1Apack \u6253\u5305\uFF08\u7EAF\u672C\u5730\uFF09/ install \u4E0A\u4F20\u5B89\u88C5\uFF08\u670D\u52A1\u7AEF\u5B89\u88C5\u5668\uFF09");
10018
+ datapackage.command("pack <packageDir>").description("\u628A\u5305\u76EE\u5F55\uFF08\u542B package.yml\uFF09\u6253\u6210 .hcmpkg \u5355\u6587\u4EF6\u5236\u54C1\uFF0C\u4E0D\u8054\u7F51").option("-o, --out <path>", "\u4EA7\u7269\u8DEF\u5F84\uFF08\u7F3A\u7701 <name \u672B\u6BB5>-<version>.hcmpkg\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((dir, opts) => datapackagePackCommand(dir, opts));
10019
+ datapackage.command("install <artifact>").description("\u4E0A\u4F20 .hcmpkg \u5236\u54C1\u5E76\u7ECF\u670D\u52A1\u7AEF DataPackage.installFromDocument \u5B89\u88C5\uFF08admin.system\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("--category <name>", "\u5236\u54C1\u4E0A\u4F20\u7684\u5B58\u50A8\u5206\u7C7B\uFF08\u670D\u52A1\u7AEF\u6570\u636E\u975E\u679A\u4E3E\uFF09", "attachment").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((artifact, opts) => datapackageInstallCommand(artifact, opts));
9848
10020
  var tenant = program.command("tenant").description("\u79DF\u6237\u5F00\u901A\u4E0E\u751F\u547D\u5468\u671F");
9849
10021
  tenant.command("bootstrap").description("\u5F00\u901A\u65B0\u79DF\u6237\uFF08\u5EFA\u79DF\u6237 + admin \u7528\u6237 + \u7ED3\u6784 reconcile\uFF09\u2014\u2014\u4E0D\u53EF\u9006\uFF0C\u9ED8\u8BA4\u8FC7\u786E\u8BA4\u95F8").requiredOption("--tenant-id <id>", "\u79DF\u6237 ID").requiredOption("--admin-username <user>", "\u7BA1\u7406\u5458\u7528\u6237\u540D").option("--admin-password <pwd>", "\u7BA1\u7406\u5458\u5BC6\u7801\uFF08\u4F1A\u6CC4\u6F0F\u5230 history/ps\uFF0C\u5EFA\u8BAE --admin-password-stdin\uFF09").option("--admin-password-stdin", "\u4ECE\u6807\u51C6\u8F93\u5165\u8BFB\u7BA1\u7406\u5458\u5BC6\u7801\uFF08\u63A8\u8350\uFF09").option("--tenant-name <name>", "\u79DF\u6237\u540D\u79F0\uFF08\u9ED8\u8BA4\u53D6 tenantId\uFF09").option("--bootstrap-key <key>", "bootstrap \u5BC6\u94A5\uFF08\u5EFA\u8BAE\u7528 HCM_BOOTSTRAP_KEY \u73AF\u5883\u53D8\u91CF\uFF09").option("--bootstrap-key-stdin", "\u4ECE\u6807\u51C6\u8F93\u5165\u8BFB bootstrap \u5BC6\u94A5").option("--endpoint <url>", "\u540E\u7AEF\u5730\u5740\uFF08\u9ED8\u8BA4\u53D6 activeEnv \u7684 endpoint\uFF09").option("--env <name>", "\u4ECE\u8BE5 env \u89E3\u6790 endpoint").option("-y, --yes", "\u8DF3\u8FC7\u786E\u8BA4\uFF08CI \u7528\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => tenantBootstrapCommand(opts));
9850
10022
  var meta = program.command("meta").description("\u79DF\u6237\u5143\u6570\u636E\u8BFB\u5199\uFF08\u9875\u9762/\u5B57\u6BB5/\u5217\u8868\u914D\u7F6E\uFF09");