@hcmai/cli 0.4.9 → 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
@@ -7541,7 +7600,19 @@ var GUARDED_EXECUTOR_REASON_CODES = /* @__PURE__ */ new Set([
7541
7600
  // 受控执行第一次跑通了 workspace create,却在 meta set / workspace push 上
7542
7601
  // 被「该 R2 命令不在首批受控执行器支持面」拦死,远端只多了一个空 workspace。
7543
7602
  "metadata-write",
7544
- "workspace-push"
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"
7545
7616
  ]);
7546
7617
  function assessDeliveryCommand(inputArgv, options = {}) {
7547
7618
  const argv = inputArgv[0] === "--" ? inputArgv.slice(1) : [...inputArgv];
@@ -7901,7 +7972,7 @@ function withProjectReadiness(assessment, projectRoot = ".") {
7901
7972
  async function deliveryAssessCommand(argv, args) {
7902
7973
  const assessment = await assessEffectiveDeliveryCommand(argv);
7903
7974
  const enriched = withProjectReadiness(assessment);
7904
- process.stdout.write(formatObject19(enriched, { format: args.output ?? "json" }) + "\n");
7975
+ process.stdout.write(formatObject20(enriched, { format: args.output ?? "json" }) + "\n");
7905
7976
  }
7906
7977
  async function resolveCoreAction(request) {
7907
7978
  try {
@@ -7910,7 +7981,7 @@ async function resolveCoreAction(request) {
7910
7981
  as: request.identity,
7911
7982
  profile: request.profile
7912
7983
  });
7913
- const description = await HcmClient18.fromAuthContext(auth).describe(request.model);
7984
+ const description = await HcmClient19.fromAuthContext(auth).describe(request.model);
7914
7985
  const named = description.actions.filter((action2) => action2.name === request.action);
7915
7986
  if (named.length === 0) {
7916
7987
  return failed(
@@ -8000,7 +8071,7 @@ function flagValue2(argv, flag) {
8000
8071
  init_exit();
8001
8072
  import { promises as fs6 } from "fs";
8002
8073
  import path6 from "path";
8003
- import { formatObject as formatObject20 } from "@hcmai/sdk";
8074
+ import { formatObject as formatObject21 } from "@hcmai/sdk";
8004
8075
  var MODES = ["plan-only", "controlled"];
8005
8076
  var SCAFFOLD_DIRS = ["work", "decisions", "evidence"];
8006
8077
  function renderProjectYml(mode) {
@@ -8059,7 +8130,7 @@ async function deliveryInitCommand(args) {
8059
8130
  scaffold: created,
8060
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"
8061
8132
  };
8062
- process.stdout.write(formatObject20(result, { format: args.output ?? "json" }) + "\n");
8133
+ process.stdout.write(formatObject21(result, { format: args.output ?? "json" }) + "\n");
8063
8134
  process.exit(0);
8064
8135
  } catch (e) {
8065
8136
  exitWithError(e);
@@ -8071,10 +8142,10 @@ async function deliveryInitCommand(args) {
8071
8142
  init_auth_guard();
8072
8143
  init_exit();
8073
8144
  import {
8074
- HcmClient as HcmClient19,
8145
+ HcmClient as HcmClient20,
8075
8146
  fetchReconIdentity,
8076
- formatObject as formatObject21,
8077
- fromAxiosError as fromAxiosError18,
8147
+ formatObject as formatObject22,
8148
+ fromAxiosError as fromAxiosError19,
8078
8149
  httpProbe,
8079
8150
  runDoctor
8080
8151
  } from "@hcmai/sdk";
@@ -8093,17 +8164,17 @@ function render2(report) {
8093
8164
  async function deliveryDoctorCommand(args) {
8094
8165
  try {
8095
8166
  const ctx = await getActiveAuthContextFromCli(args);
8096
- const client3 = HcmClient19.fromAuthContext(ctx);
8167
+ const client3 = HcmClient20.fromAuthContext(ctx);
8097
8168
  const probe = httpProbe(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES);
8098
8169
  const identity2 = await fetchReconIdentity(probe, ctx.tenantId);
8099
8170
  const report = await runDoctor(probe, identity2);
8100
8171
  const fmt = args.output ?? "json";
8101
8172
  if (fmt !== "json") process.stdout.write(render2(report) + "\n");
8102
- process.stdout.write(formatObject21(report, { format: fmt }) + "\n");
8173
+ process.stdout.write(formatObject22(report, { format: fmt }) + "\n");
8103
8174
  process.exit(report.ok ? 0 : 1);
8104
8175
  } catch (e) {
8105
8176
  const err = e;
8106
- if (err?.isAxiosError) exitWithError(fromAxiosError18(err, args.env));
8177
+ if (err?.isAxiosError) exitWithError(fromAxiosError19(err, args.env));
8107
8178
  exitWithError(e);
8108
8179
  process.exit(1);
8109
8180
  }
@@ -8113,12 +8184,12 @@ async function deliveryDoctorCommand(args) {
8113
8184
  init_auth_guard();
8114
8185
  init_exit();
8115
8186
  import {
8116
- HcmClient as HcmClient20,
8187
+ HcmClient as HcmClient21,
8117
8188
  ReconLayout,
8118
8189
  ROUND_EXIT_CODES,
8119
8190
  computeReconSourceKey,
8120
- formatObject as formatObject22,
8121
- fromAxiosError as fromAxiosError19,
8191
+ formatObject as formatObject23,
8192
+ fromAxiosError as fromAxiosError20,
8122
8193
  httpProbe as httpProbe2,
8123
8194
  inspectRound,
8124
8195
  renderRound,
@@ -8128,7 +8199,7 @@ var DEFAULT_CAPABILITIES2 = "default";
8128
8199
  async function deliveryReconCommand(args) {
8129
8200
  try {
8130
8201
  const ctx = await getActiveAuthContextFromCli(args);
8131
- const client3 = HcmClient20.fromAuthContext(ctx);
8202
+ const client3 = HcmClient21.fromAuthContext(ctx);
8132
8203
  const probe = httpProbe2(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES2);
8133
8204
  const sourceKey = await computeReconSourceKey(probe);
8134
8205
  const layout = new ReconLayout(args.out ?? ".", ctx.tenantId, sourceKey);
@@ -8137,10 +8208,10 @@ async function deliveryReconCommand(args) {
8137
8208
  onlyModel: args.model ?? null,
8138
8209
  identity: ctx.tenantId ? { requestedTenantId: ctx.tenantId } : null
8139
8210
  });
8140
- process.stdout.write(formatObject22(summary, { format: args.output ?? "json" }) + "\n");
8211
+ process.stdout.write(formatObject23(summary, { format: args.output ?? "json" }) + "\n");
8141
8212
  } catch (e) {
8142
8213
  const err = e;
8143
- if (err?.isAxiosError) exitWithError(fromAxiosError19(err, args.env));
8214
+ if (err?.isAxiosError) exitWithError(fromAxiosError20(err, args.env));
8144
8215
  exitWithError(e);
8145
8216
  process.exit(1);
8146
8217
  }
@@ -8151,7 +8222,7 @@ async function deliveryReconRoundCommand(args) {
8151
8222
  const result = inspectRound(args.dir ?? ".");
8152
8223
  const fmt = args.output ?? "json";
8153
8224
  if (fmt !== "json") process.stdout.write(renderRound(result));
8154
- process.stdout.write(formatObject22(result, { format: fmt }) + "\n");
8225
+ process.stdout.write(formatObject23(result, { format: fmt }) + "\n");
8155
8226
  code = ROUND_EXIT_CODES[result.state];
8156
8227
  } catch (e) {
8157
8228
  exitWithError(e);
@@ -8169,7 +8240,7 @@ import {
8169
8240
  GAP_REASONS,
8170
8241
  deriveAclass,
8171
8242
  exitCode as gate0ExitCode,
8172
- formatObject as formatObject23,
8243
+ formatObject as formatObject24,
8173
8244
  inspectRound as inspectRound2,
8174
8245
  loadProtocolFacts,
8175
8246
  scan
@@ -8214,7 +8285,7 @@ async function deliveryGate0Command(args) {
8214
8285
  const merged = { ...result, premise: premise5 };
8215
8286
  const fmt = args.output ?? "json";
8216
8287
  if (fmt !== "json") process.stdout.write(renderGate0(merged, skillRoot));
8217
- process.stdout.write(`${formatObject23(merged, { format: fmt })}
8288
+ process.stdout.write(`${formatObject24(merged, { format: fmt })}
8218
8289
  `);
8219
8290
  for (const problem of premise5) {
8220
8291
  process.stderr.write(`\u{1F534} \u524D\u63D0\u4E0D\u6210\u7ACB\uFF08${problem.reason}\uFF09\uFF1A${problem.message}
@@ -8238,7 +8309,7 @@ import {
8238
8309
  DRY_RUN_TAIL,
8239
8310
  DriftDetected,
8240
8311
  FORCE_STALE_FLAG,
8241
- HcmClient as HcmClient21,
8312
+ HcmClient as HcmClient22,
8242
8313
  fetchReconIdentity as fetchReconIdentity2,
8243
8314
  INIT_EXIT_CODES,
8244
8315
  JOURNAL_STOP_KINDS,
@@ -8378,7 +8449,7 @@ async function authOrSignpost(args, cmd) {
8378
8449
  }
8379
8450
  async function deliverySeedPlanCommand(args) {
8380
8451
  const ctx = await authOrSignpost(args, "plan");
8381
- const client3 = HcmClient21.fromAuthContext(ctx);
8452
+ const client3 = HcmClient22.fromAuthContext(ctx);
8382
8453
  process.exitCode = await runSeedPlan(args, seedClient(client3, ctx));
8383
8454
  }
8384
8455
  function seedClient(client3, ctx) {
@@ -8552,7 +8623,7 @@ async function runSeedApply(args, client3) {
8552
8623
  }
8553
8624
  async function deliverySeedApplyCommand(args) {
8554
8625
  const ctx = await authOrSignpost(args, "apply");
8555
- const client3 = HcmClient21.fromAuthContext(ctx);
8626
+ const client3 = HcmClient22.fromAuthContext(ctx);
8556
8627
  process.exitCode = await runSeedApply(args, seedClient(client3, ctx));
8557
8628
  }
8558
8629
  async function runSeedVerify(args, client3) {
@@ -8576,7 +8647,7 @@ async function deliverySeedVerifyCommand(args) {
8576
8647
  return;
8577
8648
  }
8578
8649
  const ctx = await authOrSignpost(args, "verify");
8579
- const client3 = HcmClient21.fromAuthContext(ctx);
8650
+ const client3 = HcmClient22.fromAuthContext(ctx);
8580
8651
  process.exitCode = await runSeedVerify(args, await seedVerifyClient(client3, ctx));
8581
8652
  }
8582
8653
 
@@ -8691,7 +8762,7 @@ import {
8691
8762
  CHANGE_STATES,
8692
8763
  CHANGE_UNKNOWN,
8693
8764
  CODE_WORDS,
8694
- HcmClient as HcmClient22,
8765
+ HcmClient as HcmClient23,
8695
8766
  INIT_EXIT_CODES as INIT_EXIT_CODES3,
8696
8767
  META_WRITE_STEPS,
8697
8768
  META_VERIFY_STEPS,
@@ -8919,7 +8990,7 @@ function lowerCaseHeaders2(headers) {
8919
8990
  }
8920
8991
  async function deliveryMetaCommand(args) {
8921
8992
  const ctx = await getActiveAuthContextFromCli(args);
8922
- const client3 = HcmClient22.fromAuthContext(ctx);
8993
+ const client3 = HcmClient23.fromAuthContext(ctx);
8923
8994
  process.exitCode = await runDeliveryMeta(
8924
8995
  { ...args, tenant: args.tenant ?? String(ctx.tenantId ?? "") },
8925
8996
  metaClient(client3, ctx)
@@ -8931,7 +9002,7 @@ init_auth_guard();
8931
9002
  init_exit();
8932
9003
  import {
8933
9004
  computeReconSourceKey as computeReconSourceKey2,
8934
- HcmClient as HcmClient23,
9005
+ HcmClient as HcmClient24,
8935
9006
  httpProbe as httpProbe3,
8936
9007
  ReconLayout as ReconLayout2,
8937
9008
  runTriageRound
@@ -8987,7 +9058,7 @@ async function runTriage(args) {
8987
9058
  return premise4(e instanceof Error ? e.message : String(e), REQUESTS_SHAPE);
8988
9059
  }
8989
9060
  const ctx = await getActiveAuthContextFromCli(args);
8990
- const client3 = HcmClient23.fromAuthContext(ctx);
9061
+ const client3 = HcmClient24.fromAuthContext(ctx);
8991
9062
  const probe = httpProbe3(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES4);
8992
9063
  const artifactsDir = args.recon ?? new ReconLayout2(args.out ?? ".", ctx.tenantId, await computeReconSourceKey2(probe)).dir;
8993
9064
  const result = await runTriageRound(probe, artifactsDir, entriesIn);
@@ -9016,7 +9087,7 @@ import { createHash as createHash5, randomBytes as secureRandomBytes } from "cry
9016
9087
  import { spawn } from "child_process";
9017
9088
  import { createReadStream, promises as fs7 } from "fs";
9018
9089
  import path11 from "path";
9019
- 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";
9020
9091
  init_exit();
9021
9092
  var EXECUTION_CONTRACT_VERSION = "2026-08-29.controlled-v3";
9022
9093
  var DEFAULT_TTL_SECONDS = 15 * 60;
@@ -9026,15 +9097,16 @@ var PLAN_ID_PATTERN = /^[a-f0-9]{24}$/;
9026
9097
  async function prepareDeliveryExecution(input) {
9027
9098
  const project = await realProject(input.project);
9028
9099
  await readProjectMode(project);
9029
- const assessment = await (input.assessCommand ?? assessEffectiveDeliveryCommand)(input.argv);
9030
- assertGuardedAssessment(assessment, input.argv);
9100
+ const argv = normalizeCommandArgv(input.argv);
9101
+ const assessment = await (input.assessCommand ?? assessEffectiveDeliveryCommand)(argv);
9102
+ assertGuardedAssessment(assessment, argv);
9031
9103
  const ttlSeconds = input.ttlSeconds ?? DEFAULT_TTL_SECONDS;
9032
9104
  if (!Number.isInteger(ttlSeconds) || ttlSeconds < MIN_TTL_SECONDS || ttlSeconds > MAX_TTL_SECONDS) {
9033
9105
  throw invalid2(`--ttl-seconds \u5FC5\u987B\u662F ${MIN_TTL_SECONDS} \u5230 ${MAX_TTL_SECONDS} \u7684\u6574\u6570`);
9034
9106
  }
9035
9107
  const change = await bindDocument(project, input.changeRef, "\u53D8\u66F4\u8BF4\u660E");
9036
9108
  const rollback = await bindDocument(project, input.rollbackRef, "\u56DE\u6EDA\u8BF4\u660E");
9037
- const payloads = await bindPayloadFiles(project, input.argv);
9109
+ const payloads = await bindPayloadFiles(project, argv);
9038
9110
  const evidence = await bindEvidenceDirectory(project, input.evidenceDir);
9039
9111
  const lockBytes = await readSkillsLock(project);
9040
9112
  const runtime = await (input.runtimeIdentity ?? currentRuntimeIdentity)();
@@ -9090,8 +9162,9 @@ async function executeDeliveryPlan(input) {
9090
9162
  }
9091
9163
  if (now.getTime() < createdAt - 5e3) throw invalid2("\u5F53\u524D\u65F6\u95F4\u65E9\u4E8E\u8BA1\u5212\u521B\u5EFA\u65F6\u95F4");
9092
9164
  if (now.getTime() > expiresAt) throw invalid2("\u6267\u884C\u8BA1\u5212\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u91CD\u65B0 prepare");
9093
- const assessment = await (input.assessCommand ?? assessEffectiveDeliveryCommand)(input.argv);
9094
- assertGuardedAssessment(assessment, input.argv);
9165
+ const argv = normalizeCommandArgv(input.argv);
9166
+ const assessment = await (input.assessCommand ?? assessEffectiveDeliveryCommand)(argv);
9167
+ assertGuardedAssessment(assessment, argv);
9095
9168
  if (canonicalJson(assessment) !== canonicalJson(plan.assessment)) {
9096
9169
  throw invalid2("\u5B9E\u9645 argv \u4E0E\u6267\u884C\u8BA1\u5212\u7684\u547D\u4EE4\u6458\u8981\u6216\u98CE\u9669\u4E8B\u5B9E\u4E0D\u4E00\u81F4");
9097
9170
  }
@@ -9127,7 +9200,7 @@ async function executeDeliveryPlan(input) {
9127
9200
  const run = input.runCommand ?? runCurrentCliCommand;
9128
9201
  let exitCode;
9129
9202
  try {
9130
- ({ exitCode } = await run(input.argv, project, {
9203
+ ({ exitCode } = await run(argv, project, {
9131
9204
  stdout: (chunk) => stdoutHash.update(chunk),
9132
9205
  stderr: (chunk) => stderrHash.update(chunk)
9133
9206
  }));
@@ -9170,7 +9243,7 @@ async function deliveryPrepareCommand(argv, args) {
9170
9243
  evidenceDir: args.evidenceDir,
9171
9244
  ...ttlSeconds === void 0 ? {} : { ttlSeconds }
9172
9245
  });
9173
- process.stdout.write(formatObject24(plan, { format: args.output ?? "json" }) + "\n");
9246
+ process.stdout.write(formatObject25(plan, { format: args.output ?? "json" }) + "\n");
9174
9247
  process.stderr.write(`
9175
9248
  \u4E0B\u4E00\u6B65\uFF08argv \u5FC5\u987B\u4E0E\u672C\u6B21\u5B8C\u5168\u4E00\u81F4\uFF09\uFF1A
9176
9249
  ${nextCommandHint(plan.planId, args.project, argv)}
@@ -9191,7 +9264,7 @@ async function deliveryExecuteCommand(planId, argv, args) {
9191
9264
  planId,
9192
9265
  argv
9193
9266
  });
9194
- process.stdout.write(formatObject24(receipt, { format: args.output ?? "json" }) + "\n");
9267
+ process.stdout.write(formatObject25(receipt, { format: args.output ?? "json" }) + "\n");
9195
9268
  process.exitCode = receipt.exitCode;
9196
9269
  } catch (cause) {
9197
9270
  exitWithError(cause);
@@ -9327,6 +9400,18 @@ function validateSupportedCommandShape(reasonCode, argv) {
9327
9400
  }
9328
9401
  return;
9329
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
+ }
9330
9415
  if (reasonCode === "record-create") {
9331
9416
  requireExactlyOnePayload(argv, "create");
9332
9417
  return;
@@ -9377,6 +9462,13 @@ function requireExactlyOnePayload(argv, command) {
9377
9462
  var PAYLOAD_FILE_FLAGS = ["--data-file", "--params-file", "--file"];
9378
9463
  var PAYLOAD_DIR_FLAGS = ["--dir"];
9379
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
+ }
9380
9472
  async function bindPayloadFiles(project, argv) {
9381
9473
  const bound = [];
9382
9474
  for (const flag of PAYLOAD_FILE_FLAGS) {
@@ -9393,8 +9485,25 @@ async function bindPayloadFiles(project, argv) {
9393
9485
  if (implicit !== void 0 && optionalFlagValue(argv, "--dir") === void 0) {
9394
9486
  bound.push(await bindPayloadDirectory(project, implicit, "\u5DE5\u4F5C\u7A7A\u95F4\u76EE\u5F55\u8F7D\u8377"));
9395
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
+ }
9396
9492
  return bound;
9397
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
+ }
9398
9507
  async function bindPayloadDirectory(project, reference, label) {
9399
9508
  const relative2 = reference === "." ? "." : safeRelative(reference, label);
9400
9509
  const root = path11.join(project, relative2);
@@ -9407,13 +9516,19 @@ async function bindPayloadDirectory(project, reference, label) {
9407
9516
  if (!stat.isDirectory()) {
9408
9517
  throw invalid2(`${label}\u4E0D\u662F\u76EE\u5F55\uFF1A${relative2}`);
9409
9518
  }
9519
+ const skipToolingAtRoot = relative2 === ".";
9410
9520
  const entries = [];
9411
9521
  const walk = async (dir, prefix) => {
9412
9522
  const items = await fs7.readdir(dir, { withFileTypes: true });
9413
9523
  for (const item of [...items].sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0)) {
9414
- if ([".git", "node_modules", ".hcm-delivery", "evidence"].includes(item.name)) continue;
9524
+ if (skipToolingAtRoot && prefix === "" && TOOLING_DIRS.includes(item.name)) continue;
9415
9525
  const child = path11.join(dir, item.name);
9416
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
+ }
9417
9532
  if (item.isDirectory()) {
9418
9533
  await walk(child, rel);
9419
9534
  } else if (item.isFile()) {
@@ -9630,10 +9745,10 @@ function nextCommandHint(planId, project, argv) {
9630
9745
  init_auth_guard();
9631
9746
  init_exit();
9632
9747
  import {
9633
- HcmClient as HcmClient24,
9748
+ HcmClient as HcmClient25,
9634
9749
  adminResetPassword,
9635
- formatObject as formatObject25,
9636
- fromAxiosError as fromAxiosError20,
9750
+ formatObject as formatObject26,
9751
+ fromAxiosError as fromAxiosError21,
9637
9752
  CliError as CliError21,
9638
9753
  CliErrorCode as CliErrorCode20
9639
9754
  } from "@hcmai/sdk";
@@ -9664,12 +9779,12 @@ async function userResetPasswordCommand(args) {
9664
9779
  try {
9665
9780
  const password = args.passwordStdin ? await readSecretFromStdin() : await promptPasswordTwice();
9666
9781
  const request = buildAdminResetPasswordRequest(args, password);
9667
- const client3 = HcmClient24.fromAuthContext(await getActiveAuthContextFromCli(args));
9782
+ const client3 = HcmClient25.fromAuthContext(await getActiveAuthContextFromCli(args));
9668
9783
  const result = await adminResetPassword(client3.raw(), request);
9669
- process.stdout.write(formatObject25(result, { format: args.output ?? "json" }) + "\n");
9784
+ process.stdout.write(formatObject26(result, { format: args.output ?? "json" }) + "\n");
9670
9785
  } catch (cause) {
9671
9786
  const err = cause;
9672
- if (err?.isAxiosError) exitWithError(fromAxiosError20(err, args.env));
9787
+ if (err?.isAxiosError) exitWithError(fromAxiosError21(err, args.env));
9673
9788
  exitWithError(cause);
9674
9789
  }
9675
9790
  }
@@ -9689,19 +9804,19 @@ async function promptPasswordTwice() {
9689
9804
  init_exit();
9690
9805
  init_auth_guard();
9691
9806
  import {
9692
- HcmClient as HcmClient25,
9693
- formatObject as formatObject26,
9694
- fromAxiosError as fromAxiosError21
9807
+ HcmClient as HcmClient26,
9808
+ formatObject as formatObject27,
9809
+ fromAxiosError as fromAxiosError22
9695
9810
  } from "@hcmai/sdk";
9696
9811
  async function modelsCommand(keyword, args) {
9697
9812
  try {
9698
- const client3 = HcmClient25.fromAuthContext(await getActiveAuthContextFromCli(args));
9813
+ const client3 = HcmClient26.fromAuthContext(await getActiveAuthContextFromCli(args));
9699
9814
  const all = await client3.listModels();
9700
9815
  const needle = keyword?.trim().toLowerCase();
9701
9816
  const rows = (needle ? all.filter((m) => JSON.stringify(m).toLowerCase().includes(needle)) : all).sort((a, b) => key(a).localeCompare(key(b)));
9702
9817
  const fmt = args.output ?? "table";
9703
9818
  if (fmt !== "table") {
9704
- 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");
9705
9820
  process.exit(0);
9706
9821
  }
9707
9822
  if (rows.length === 0) {
@@ -9725,7 +9840,7 @@ async function modelsCommand(keyword, args) {
9725
9840
  process.exit(0);
9726
9841
  } catch (e) {
9727
9842
  const err = e;
9728
- if (err?.isAxiosError) exitWithError(fromAxiosError21(err, args.profile));
9843
+ if (err?.isAxiosError) exitWithError(fromAxiosError22(err, args.profile));
9729
9844
  exitWithError(e);
9730
9845
  }
9731
9846
  }
@@ -9899,6 +10014,9 @@ program.command("upload <file>").description("\u4E0A\u4F20\u672C\u5730\u6587\u4E
9899
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",
9900
10015
  "attachment"
9901
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));
9902
10020
  var tenant = program.command("tenant").description("\u79DF\u6237\u5F00\u901A\u4E0E\u751F\u547D\u5468\u671F");
9903
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));
9904
10022
  var meta = program.command("meta").description("\u79DF\u6237\u5143\u6570\u636E\u8BFB\u5199\uFF08\u9875\u9762/\u5B57\u6BB5/\u5217\u8868\u914D\u7F6E\uFF09");