@hcmai/cli 0.3.15 → 0.3.16

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
@@ -523,8 +523,8 @@ var init_TerminalRenderer = __esm({
523
523
  }
524
524
  }
525
525
  /** 来源行(仅子代理触发,agentPath ≥2 段时显示 `↑ 来自 a › b`,对齐 Web)。 */
526
- originLine(path9) {
527
- const segs = path9.split(".").filter(Boolean);
526
+ originLine(path10) {
527
+ const segs = path10.split(".").filter(Boolean);
528
528
  if (segs.length < 2) return "";
529
529
  const names = segs.map((k) => agentDisplayName(k));
530
530
  return chalk.gray(` \u2191 \u6765\u81EA ${names.join(" \u203A ")}`) + "\n";
@@ -1706,8 +1706,8 @@ function agentLabel(agentId) {
1706
1706
  if (/^[0-9a-f]{8}-[0-9a-f-]{27}$/i.test(agentId)) return `agent \u2026${agentId.slice(-4)}`;
1707
1707
  return agentDisplayName(agentId);
1708
1708
  }
1709
- function originLine(path9) {
1710
- const segs = (path9 ?? "").split(".").filter(Boolean);
1709
+ function originLine(path10) {
1710
+ const segs = (path10 ?? "").split(".").filter(Boolean);
1711
1711
  if (segs.length < 2) return null;
1712
1712
  return `\u6765\u81EA ${segs.map((k) => agentDisplayName(k)).join(" \u203A ")}`;
1713
1713
  }
@@ -3059,8 +3059,8 @@ import {
3059
3059
  formatObject as formatObject7,
3060
3060
  fromAxiosError as fromAxiosError8
3061
3061
  } from "@hcmai/sdk";
3062
- function collectYmlFiles(path9) {
3063
- if (statSync(path9).isFile()) return [path9];
3062
+ function collectYmlFiles(path10) {
3063
+ if (statSync(path10).isFile()) return [path10];
3064
3064
  const out = [];
3065
3065
  const walk = (dir) => {
3066
3066
  for (const name of readdirSync(dir).sort()) {
@@ -3069,7 +3069,7 @@ function collectYmlFiles(path9) {
3069
3069
  else if (full.endsWith(".yml") || full.endsWith(".yaml")) out.push(full);
3070
3070
  }
3071
3071
  };
3072
- walk(path9);
3072
+ walk(path10);
3073
3073
  return out.sort();
3074
3074
  }
3075
3075
  var DRY_RUN_CLIENT = {
@@ -3077,9 +3077,9 @@ var DRY_RUN_CLIENT = {
3077
3077
  create: async () => ({ id: "" }),
3078
3078
  update: async () => ({})
3079
3079
  };
3080
- async function importCommand(path9, args) {
3080
+ async function importCommand(path10, args) {
3081
3081
  try {
3082
- const files = collectYmlFiles(path9);
3082
+ const files = collectYmlFiles(path10);
3083
3083
  const fixtures = files.map(
3084
3084
  (f) => parseFixture(readFileSync2(f, "utf8"), relative(process.cwd(), f))
3085
3085
  );
@@ -5858,17 +5858,17 @@ async function metaListCommand(args) {
5858
5858
  fail4(e, args);
5859
5859
  }
5860
5860
  }
5861
- async function metaGetCommand(path9, args) {
5861
+ async function metaGetCommand(path10, args) {
5862
5862
  try {
5863
5863
  const c = await client2(args);
5864
- const content = await getTenantMeta(c.raw(), path9);
5864
+ const content = await getTenantMeta(c.raw(), path10);
5865
5865
  process.stdout.write(content.endsWith("\n") ? content : content + "\n");
5866
5866
  process.exit(0);
5867
5867
  } catch (e) {
5868
5868
  fail4(e, args);
5869
5869
  }
5870
5870
  }
5871
- async function metaSetCommand(path9, args) {
5871
+ async function metaSetCommand(path10, args) {
5872
5872
  try {
5873
5873
  if (!args.file) {
5874
5874
  throw new CliError18({
@@ -5885,7 +5885,7 @@ async function metaSetCommand(path9, args) {
5885
5885
  }) : await fsp3.readFile(args.file, "utf8");
5886
5886
  if (args.dryRun) {
5887
5887
  process.stdout.write(
5888
- `[dry-run] \u5C06\u5199\u5165 ${path9}\uFF08${Buffer.byteLength(content)} B\uFF09\u2014\u2014\u672A\u5B9E\u9645\u5199\u5165
5888
+ `[dry-run] \u5C06\u5199\u5165 ${path10}\uFF08${Buffer.byteLength(content)} B\uFF09\u2014\u2014\u672A\u5B9E\u9645\u5199\u5165
5889
5889
  ---
5890
5890
  ${content}
5891
5891
  `
@@ -5893,10 +5893,10 @@ ${content}
5893
5893
  process.exit(0);
5894
5894
  }
5895
5895
  const c = await client2(args);
5896
- const result = await saveTenantMeta(c.raw(), path9, content);
5896
+ const result = await saveTenantMeta(c.raw(), path10, content);
5897
5897
  const fmt = args.output ?? "json";
5898
5898
  if (fmt !== "json") {
5899
- process.stdout.write(`\u2705 \u5DF2\u5199\u5165 ${path9}
5899
+ process.stdout.write(`\u2705 \u5DF2\u5199\u5165 ${path10}
5900
5900
  \u8BB0\u5F97\u6E05\u7F13\u5B58\uFF1Ahcm cache clear-meta <Model>
5901
5901
  `);
5902
5902
  }
@@ -5907,19 +5907,19 @@ ${content}
5907
5907
  fail4(e, args);
5908
5908
  }
5909
5909
  }
5910
- async function metaDeleteCommand(path9, args) {
5910
+ async function metaDeleteCommand(path10, args) {
5911
5911
  try {
5912
5912
  if (!args.yes) {
5913
- const ok = await promptConfirm(`\u5C06\u5220\u9664\u5143\u6570\u636E ${path9}\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u9006\u3002\u7EE7\u7EED\uFF1F`);
5913
+ const ok = await promptConfirm(`\u5C06\u5220\u9664\u5143\u6570\u636E ${path10}\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u9006\u3002\u7EE7\u7EED\uFF1F`);
5914
5914
  if (!ok) {
5915
5915
  process.stderr.write("\u5DF2\u53D6\u6D88\n");
5916
5916
  process.exit(1);
5917
5917
  }
5918
5918
  }
5919
5919
  const c = await client2(args);
5920
- const result = await deleteTenantMeta(c.raw(), path9);
5920
+ const result = await deleteTenantMeta(c.raw(), path10);
5921
5921
  const fmt = args.output ?? "json";
5922
- if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${path9}
5922
+ if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${path10}
5923
5923
  `);
5924
5924
  process.stdout.write(formatObject16(result, { format: fmt }) + "\n");
5925
5925
  process.exit(0);
@@ -7873,16 +7873,16 @@ async function deliveryGate0Command(args) {
7873
7873
  const { aclass, problems: aclassProblems } = deriveAclass(reconDir, args.mapping ?? null);
7874
7874
  const { facts, problems: factsProblems } = loadProtocolFacts();
7875
7875
  const result = scan(skillRoot, aclass, facts, { aclassProblems, factsProblems });
7876
- const premise2 = checkPremise([
7876
+ const premise3 = checkPremise([
7877
7877
  ...result.premise,
7878
7878
  ...baselineRoundPremise(inspectRound2(reconDir))
7879
7879
  ]);
7880
- const merged = { ...result, premise: premise2 };
7880
+ const merged = { ...result, premise: premise3 };
7881
7881
  const fmt = args.output ?? "json";
7882
7882
  if (fmt !== "json") process.stdout.write(renderGate0(merged, skillRoot));
7883
7883
  process.stdout.write(`${formatObject21(merged, { format: fmt })}
7884
7884
  `);
7885
- for (const problem of premise2) {
7885
+ for (const problem of premise3) {
7886
7886
  process.stderr.write(`\u{1F534} \u524D\u63D0\u4E0D\u6210\u7ACB\uFF08${problem.reason}\uFF09\uFF1A${problem.message}
7887
7887
  `);
7888
7888
  }
@@ -7894,20 +7894,147 @@ async function deliveryGate0Command(args) {
7894
7894
  process.exit(code);
7895
7895
  }
7896
7896
 
7897
+ // src/commands/delivery-seed.ts
7898
+ init_auth_guard();
7899
+ import {
7900
+ HcmClient as HcmClient20,
7901
+ INIT_EXIT_CODES,
7902
+ baselineRoundPremise as baselineRoundPremise2,
7903
+ MappingError,
7904
+ discardedColumnLines,
7905
+ inspectRound as inspectRound3,
7906
+ loadExemptions,
7907
+ planFromArtifacts,
7908
+ planProblemLines,
7909
+ planRc,
7910
+ planSummaryLine,
7911
+ riskFromArtifacts,
7912
+ roundWarning,
7913
+ seedBaselines,
7914
+ seedMappingPath,
7915
+ seedWorkDir,
7916
+ writeImportPlan,
7917
+ writeRisk
7918
+ } from "@hcmai/sdk";
7919
+ import { existsSync as existsSync2 } from "fs";
7920
+ import * as path7 from "path";
7921
+ function premise(message, hint = "") {
7922
+ process.stderr.write(message + (hint ? `
7923
+ \u2192 ${hint}` : "") + "\n");
7924
+ return INIT_EXIT_CODES.premise;
7925
+ }
7926
+ async function runSeedPlan(args, client3) {
7927
+ const out = args.out ?? ".";
7928
+ const tenant2 = tenantOf(client3);
7929
+ const work = seedWorkDir({ out, tenant: tenant2, work: args.work ?? null, mapping: args.mapping ?? null });
7930
+ const mappingPath = seedMappingPath({ out, tenant: tenant2, mapping: args.mapping ?? null }, work);
7931
+ if (!existsSync2(mappingPath)) {
7932
+ return premise(
7933
+ `\u8BFB\u4E0D\u5230\u5BFC\u5165\u6620\u5C04\u5DE5\u4EF6\uFF1A${mappingPath}`,
7934
+ "\u5DE5\u4EF6\u662F\u987E\u95EE\u81EA\u5DF1\u5199\u7684\uFF08\u5951\u7EA6\u89C1 README \u7684 `work/mapping.json` \u4E00\u8282\uFF09\u3002\u5199\u5728\u522B\u5904\u5C31\u7528 `--mapping <\u8DEF\u5F84>` \u6307\u8FC7\u53BB\uFF0C\u6216\u7528 `--work <\u76EE\u5F55>` \u6362 work \u76EE\u5F55\u3002"
7935
+ );
7936
+ }
7937
+ const [base, candidates] = seedBaselines(out, tenant2);
7938
+ if (candidates.length === 0) {
7939
+ return premise(
7940
+ `\u672A\u627E\u5230\u5200 2 \u7684\u57FA\u7EBF\uFF1A${base}/*/index/fields.jsonl`,
7941
+ "`plan` \u7684\u98CE\u9669\u6E05\u5355\u8981\u8BFB recon \u4EA7\u7269\u91CC\u7684 `mapping/` \u4E0E `valuedomain/`\u3002\u5148\u8DD1\u4E00\u6B21 `hcm delivery recon`\u3002"
7942
+ );
7943
+ }
7944
+ const reconDir = candidates[0].reconDir;
7945
+ if (candidates.length > 1) {
7946
+ process.stderr.write(
7947
+ `\u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u6709 ${candidates.length} \u4EFD\u57FA\u7EBF\uFF0C\u672C\u8F6E\u8BFB\u7684\u662F \`${path7.basename(reconDir)}\`\uFF1A` + candidates.slice(1).map((c) => `\`${path7.basename(c.reconDir)}\``).join("\u3001") + " \u672A\u88AB\u8BFB\u53D6 \u2014\u2014 \u4E0D\u540C sourceKey \u7684\u4EA7\u7269**\u4E0D\u53EF\u4E92\u6362**\u3002\n"
7948
+ );
7949
+ }
7950
+ const round = inspectRound3(reconDir);
7951
+ process.stderr.write(roundWarning(round));
7952
+ const baseline = {
7953
+ path: `${path7.basename(path7.dirname(reconDir))}/${path7.basename(reconDir)}`,
7954
+ roundId: round.roundId ?? null
7955
+ };
7956
+ let exemptions = null;
7957
+ if (args.exemptions) {
7958
+ const [loaded, err] = loadExemptions(args.exemptions);
7959
+ if (err !== null) {
7960
+ process.stderr.write(err + "\n");
7961
+ return INIT_EXIT_CODES.premise;
7962
+ }
7963
+ exemptions = loaded;
7964
+ }
7965
+ let plan;
7966
+ let risk;
7967
+ try {
7968
+ plan = await planFromArtifacts(client3, mappingPath, args.sourceDir, { baseline });
7969
+ risk = await riskFromArtifacts(mappingPath, reconDir, {
7970
+ sourceDir: args.sourceDir,
7971
+ exemptions,
7972
+ plan,
7973
+ // 🔴 **判据整个在生产模块里**(`baselineRoundPremise`),本层不重判、不改写判词;
7974
+ // risk 那一层只做形态转换(加 hint)。
7975
+ roundPremise: baselineRoundPremise2(round)
7976
+ });
7977
+ } catch (e) {
7978
+ if (e instanceof MappingError) {
7979
+ return premise(`\u5DE5\u4EF6\u88C5\u4E0D\u8FDB\u6765\uFF1A[${e.reason}] ${e.message}`, e.hint);
7980
+ }
7981
+ throw e;
7982
+ }
7983
+ const planFile = writeImportPlan(plan, work);
7984
+ const riskFile = writeRisk(risk, work);
7985
+ process.stdout.write(`\u8BA1\u5212\uFF1A${planFile}
7986
+ `);
7987
+ process.stdout.write(`\u98CE\u9669\uFF1A${riskFile}
7988
+ `);
7989
+ for (const line of discardedColumnLines(plan.notes)) process.stdout.write(line + "\n");
7990
+ process.stdout.write(planSummaryLine(plan, risk) + "\n");
7991
+ for (const line of planProblemLines(plan, risk)) process.stderr.write(line + "\n");
7992
+ return planRc(plan, risk);
7993
+ }
7994
+ function tenantOf(client3) {
7995
+ const t = client3?.tenantId;
7996
+ return t === void 0 || t === null ? "" : String(t);
7997
+ }
7998
+ async function deliverySeedPlanCommand(args) {
7999
+ const ctx = await getActiveAuthContextFromCli(args);
8000
+ const client3 = HcmClient20.fromAuthContext(ctx);
8001
+ process.exitCode = await runSeedPlan(args, seedClient(client3, ctx));
8002
+ }
8003
+ function seedClient(client3, ctx) {
8004
+ const raw = client3.raw();
8005
+ return {
8006
+ tenantId: ctx.tenantId,
8007
+ async post(p, body) {
8008
+ try {
8009
+ const res = await raw.post(p, body);
8010
+ return { status: res.status, body: res.data, error: "ok", headers: {} };
8011
+ } catch (e) {
8012
+ const status = e?.response?.status ?? -1;
8013
+ return {
8014
+ status,
8015
+ body: e?.response?.data ?? null,
8016
+ error: status === -1 ? "network" : `http-${status}`,
8017
+ headers: {}
8018
+ };
8019
+ }
8020
+ }
8021
+ };
8022
+ }
8023
+
7897
8024
  // src/commands/delivery-triage.ts
7898
8025
  init_auth_guard();
7899
8026
  init_exit();
7900
8027
  import {
7901
8028
  computeReconSourceKey as computeReconSourceKey2,
7902
- HcmClient as HcmClient20,
8029
+ HcmClient as HcmClient21,
7903
8030
  httpProbe as httpProbe3,
7904
8031
  ReconLayout as ReconLayout2,
7905
8032
  runTriageRound
7906
8033
  } from "@hcmai/sdk";
7907
8034
  import { mkdirSync, readFileSync as readFileSync4, writeFileSync as writeFileSync2 } from "fs";
7908
- import * as path7 from "path";
8035
+ import * as path8 from "path";
7909
8036
  var DEFAULT_CAPABILITIES3 = "default";
7910
- function premise(message, hint) {
8037
+ function premise2(message, hint) {
7911
8038
  process.stderr.write(`\u{1F534} \u524D\u63D0\u4E0D\u6210\u7ACB\uFF1A${message}
7912
8039
  `);
7913
8040
  process.stderr.write(` ${hint}
@@ -7941,21 +8068,21 @@ function renderProblems(rows) {
7941
8068
  `;
7942
8069
  }
7943
8070
  function writeTriageArtifact(outDir, body) {
7944
- const out = path7.join(outDir, "work", "triage.md");
7945
- mkdirSync(path7.dirname(out), { recursive: true });
8071
+ const out = path8.join(outDir, "work", "triage.md");
8072
+ mkdirSync(path8.dirname(out), { recursive: true });
7946
8073
  writeFileSync2(out, body, "utf8");
7947
8074
  return out;
7948
8075
  }
7949
8076
  async function runTriage(args) {
7950
- if (!args.requests) return premise("\u6CA1\u7ED9 `--requests`", REQUESTS_SHAPE);
8077
+ if (!args.requests) return premise2("\u6CA1\u7ED9 `--requests`", REQUESTS_SHAPE);
7951
8078
  let entriesIn;
7952
8079
  try {
7953
8080
  entriesIn = readRequests(args.requests);
7954
8081
  } catch (e) {
7955
- return premise(e instanceof Error ? e.message : String(e), REQUESTS_SHAPE);
8082
+ return premise2(e instanceof Error ? e.message : String(e), REQUESTS_SHAPE);
7956
8083
  }
7957
8084
  const ctx = await getActiveAuthContextFromCli(args);
7958
- const client3 = HcmClient20.fromAuthContext(ctx);
8085
+ const client3 = HcmClient21.fromAuthContext(ctx);
7959
8086
  const probe = httpProbe3(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES3);
7960
8087
  const artifactsDir = args.recon ?? new ReconLayout2(args.out ?? ".", ctx.tenantId, await computeReconSourceKey2(probe)).dir;
7961
8088
  const result = await runTriageRound(probe, artifactsDir, entriesIn);
@@ -7983,7 +8110,7 @@ async function deliveryTriageCommand(args) {
7983
8110
  import { createHash as createHash5, randomBytes as secureRandomBytes } from "crypto";
7984
8111
  import { spawn } from "child_process";
7985
8112
  import { createReadStream, promises as fs6 } from "fs";
7986
- import path8 from "path";
8113
+ import path9 from "path";
7987
8114
  import { CliError as CliError20, CliErrorCode as CliErrorCode19, formatObject as formatObject22 } from "@hcmai/sdk";
7988
8115
  init_exit();
7989
8116
  var EXECUTION_CONTRACT_VERSION = "2026-08-29.controlled-v3";
@@ -8023,9 +8150,9 @@ async function prepareDeliveryExecution(input) {
8023
8150
  };
8024
8151
  const planId = sha2565(canonicalJson(core)).slice(0, 24);
8025
8152
  const plan = { ...core, planId };
8026
- const plansDir = path8.join(project, ".hcm-delivery", "execution-plans");
8153
+ const plansDir = path9.join(project, ".hcm-delivery", "execution-plans");
8027
8154
  await safeManagedDirectory(project, ".hcm-delivery/execution-plans", plansDir);
8028
- const planFile = path8.join(plansDir, `${planId}.json`);
8155
+ const planFile = path9.join(plansDir, `${planId}.json`);
8029
8156
  try {
8030
8157
  await fs6.writeFile(planFile, `${JSON.stringify(plan, null, 2)}
8031
8158
  `, {
@@ -8044,7 +8171,7 @@ async function executeDeliveryPlan(input) {
8044
8171
  if (await readProjectMode(project) !== "controlled") {
8045
8172
  throw invalid2("\u9879\u76EE\u4E0D\u662F controlled\uFF0C\u4E0D\u80FD\u6267\u884C R2 \u8BA1\u5212");
8046
8173
  }
8047
- const planFile = path8.join(project, ".hcm-delivery", "execution-plans", `${input.planId}.json`);
8174
+ const planFile = path9.join(project, ".hcm-delivery", "execution-plans", `${input.planId}.json`);
8048
8175
  const plan = await readPlan(project, planFile);
8049
8176
  if (plan.planId !== input.planId || computePlanId(plan) !== input.planId) {
8050
8177
  throw invalid2("\u6267\u884C\u8BA1\u5212\u5185\u5BB9\u4E0E planId \u6458\u8981\u4E0D\u4E00\u81F4");
@@ -8075,11 +8202,11 @@ async function executeDeliveryPlan(input) {
8075
8202
  await assertDocumentUnchanged(project, plan.documents.rollback, "\u56DE\u6EDA\u8BF4\u660E");
8076
8203
  await assertPayloadsUnchanged(project, plan.payloads);
8077
8204
  const evidenceDir = await bindEvidenceDirectory(project, plan.evidenceDir);
8078
- const receiptFile = path8.join(evidenceDir.absolute, `${plan.planId}.receipt.json`);
8205
+ const receiptFile = path9.join(evidenceDir.absolute, `${plan.planId}.receipt.json`);
8079
8206
  if (await pathExists(receiptFile)) throw invalid2(`\u6267\u884C\u6536\u636E\u5DF2\u5B58\u5728\uFF0C\u62D2\u7EDD\u518D\u6B21\u6267\u884C\uFF1A${plan.planId}`);
8080
- const claimsDir = path8.join(project, ".hcm-delivery", "execution-claims");
8207
+ const claimsDir = path9.join(project, ".hcm-delivery", "execution-claims");
8081
8208
  await safeManagedDirectory(project, ".hcm-delivery/execution-claims", claimsDir);
8082
- const claimFile = path8.join(claimsDir, `${plan.planId}.json`);
8209
+ const claimFile = path9.join(claimsDir, `${plan.planId}.json`);
8083
8210
  try {
8084
8211
  await fs6.writeFile(
8085
8212
  claimFile,
@@ -8139,12 +8266,21 @@ async function deliveryPrepareCommand(argv, args) {
8139
8266
  ...ttlSeconds === void 0 ? {} : { ttlSeconds }
8140
8267
  });
8141
8268
  process.stdout.write(formatObject22(plan, { format: args.output ?? "json" }) + "\n");
8269
+ process.stderr.write(`
8270
+ \u4E0B\u4E00\u6B65\uFF08argv \u5FC5\u987B\u4E0E\u672C\u6B21\u5B8C\u5168\u4E00\u81F4\uFF09\uFF1A
8271
+ ${nextCommandHint(plan.planId, args.project, argv)}
8272
+ `);
8142
8273
  } catch (cause) {
8143
8274
  exitWithError(cause);
8144
8275
  }
8145
8276
  }
8146
8277
  async function deliveryExecuteCommand(planId, argv, args) {
8147
8278
  try {
8279
+ if (!argv || argv.length === 0) {
8280
+ throw invalid2(
8281
+ `execute \u5FC5\u987B\u5728 \`--\` \u4E4B\u540E\u590D\u8FF0\u4E0E prepare \u5B8C\u5168\u76F8\u540C\u7684\u90A3\u4E32 argv\u3002\u6267\u884C\u8BA1\u5212\u53EA\u5B58\u8BE5\u547D\u4EE4\u7684\u6458\u8981\u3001\u4E0D\u5B58\u539F\u6587\uFF08\u8FD9\u6837\u8BA1\u5212\u6587\u4EF6\u843D\u76D8\u65F6\u4E0D\u4F1A\u643A\u5E26\u51ED\u636E\u7C7B\u53C2\u6570\uFF09\uFF0C\u6240\u4EE5\u8FD9\u4E00\u4E32\u5FC5\u987B\u7531\u4F60\u7ED9\u56DE\u6765\u3002next_step=hcm delivery execute ${planId} --project <\u9879\u76EE\u76EE\u5F55> -- <\u4E0E prepare \u5B8C\u5168\u76F8\u540C\u7684\u5B50\u547D\u4EE4\u4E0E\u53C2\u6570>`
8282
+ );
8283
+ }
8148
8284
  const receipt = await executeDeliveryPlan({
8149
8285
  project: args.project ?? process.cwd(),
8150
8286
  planId,
@@ -8157,7 +8293,7 @@ async function deliveryExecuteCommand(planId, argv, args) {
8157
8293
  }
8158
8294
  }
8159
8295
  async function readProjectMode(project) {
8160
- const file = path8.join(project, ".hcm-delivery", "project.yml");
8296
+ const file = path9.join(project, ".hcm-delivery", "project.yml");
8161
8297
  const content = await readSafeFile(project, file, "\u9879\u76EE\u914D\u7F6E");
8162
8298
  const match = content.toString("utf8").match(
8163
8299
  /^deliveryMode:\s*(?:"(plan-only|controlled)"|'(plan-only|controlled)'|(plan-only|controlled))\s*$/m
@@ -8169,13 +8305,13 @@ async function readProjectMode(project) {
8169
8305
  return mode;
8170
8306
  }
8171
8307
  var SKILLS_LOCK_CANDIDATES = [
8172
- path8.join("hcm-skills", ".hcm-skills.json"),
8173
- path8.join(".claude", "skills", ".hcm-skills.json")
8308
+ path9.join("hcm-skills", ".hcm-skills.json"),
8309
+ path9.join(".claude", "skills", ".hcm-skills.json")
8174
8310
  ];
8175
8311
  async function readSkillsLock(project) {
8176
8312
  const found = [];
8177
8313
  for (const candidate of SKILLS_LOCK_CANDIDATES) {
8178
- if (await pathExists(path8.join(project, candidate))) found.push(candidate);
8314
+ if (await pathExists(path9.join(project, candidate))) found.push(candidate);
8179
8315
  }
8180
8316
  if (found.length === 0) {
8181
8317
  throw invalid2(
@@ -8187,7 +8323,7 @@ async function readSkillsLock(project) {
8187
8323
  `\u9879\u76EE\u91CC\u6709\u591A\u4EFD\u6280\u80FD\u9501\uFF08${found.join("\u3001")}\uFF09\uFF0C\u65E0\u6CD5\u552F\u4E00\u5224\u5B9A\u53D7\u63A7\u6267\u884C\u7ED1\u5B9A\u54EA\u4E00\u4EFD\u3002next_step=\u53EA\u4FDD\u7559\u5B9E\u9645\u5728\u7528\u7684\u90A3\u4E2A\u6280\u80FD\u76EE\u5F55`
8188
8324
  );
8189
8325
  }
8190
- const bytes = await readSafeFile(project, path8.join(project, found[0]), "\u6280\u80FD\u9501");
8326
+ const bytes = await readSafeFile(project, path9.join(project, found[0]), "\u6280\u80FD\u9501");
8191
8327
  try {
8192
8328
  JSON.parse(bytes.toString("utf8"));
8193
8329
  } catch (cause) {
@@ -8200,7 +8336,7 @@ async function bindDocument(project, reference, label) {
8200
8336
  if (!(relative2.startsWith("work/") || relative2.startsWith("decisions/"))) {
8201
8337
  throw invalid2(`${label}\u5FC5\u987B\u4F4D\u4E8E\u9879\u76EE work/ \u6216 decisions/ \u4E0B`);
8202
8338
  }
8203
- const file = path8.join(project, relative2);
8339
+ const file = path9.join(project, relative2);
8204
8340
  const bytes = await readSafeFile(project, file, label);
8205
8341
  return { path: relative2, sha256: sha2565(bytes) };
8206
8342
  }
@@ -8213,7 +8349,7 @@ async function bindEvidenceDirectory(project, reference) {
8213
8349
  if (!(relative2 === "evidence" || relative2.startsWith("evidence/"))) {
8214
8350
  throw invalid2("evidence \u76EE\u5F55\u5FC5\u987B\u4F4D\u4E8E\u9879\u76EE evidence/ \u4E0B");
8215
8351
  }
8216
- const absolute = path8.join(project, relative2);
8352
+ const absolute = path9.join(project, relative2);
8217
8353
  await assertNoSymlinkComponents(project, relative2);
8218
8354
  const stat = await fs6.stat(absolute).catch(() => null);
8219
8355
  if (stat === null) {
@@ -8345,7 +8481,7 @@ async function bindPayloadFiles(project, argv) {
8345
8481
  }
8346
8482
  async function bindPayloadFile(project, reference, label) {
8347
8483
  const relative2 = safeRelative(reference, label);
8348
- const file = path8.join(project, relative2);
8484
+ const file = path9.join(project, relative2);
8349
8485
  const bytes = await readSafeFile(project, file, label);
8350
8486
  return { path: relative2, sha256: sha2565(bytes) };
8351
8487
  }
@@ -8414,13 +8550,13 @@ async function writeReceiptExclusive(target, receipt) {
8414
8550
  });
8415
8551
  await fs6.link(temp, target);
8416
8552
  } catch (cause) {
8417
- throw invalid2(`\u6267\u884C\u6536\u636E\u5199\u5165\u5931\u8D25\u6216\u5DF2\u5B58\u5728\uFF1A${path8.basename(target)}`, cause);
8553
+ throw invalid2(`\u6267\u884C\u6536\u636E\u5199\u5165\u5931\u8D25\u6216\u5DF2\u5B58\u5728\uFF1A${path9.basename(target)}`, cause);
8418
8554
  } finally {
8419
8555
  await fs6.unlink(temp).catch(() => void 0);
8420
8556
  }
8421
8557
  }
8422
8558
  async function safeManagedDirectory(project, relative2, absolute) {
8423
- await assertNoSymlinkComponents(project, path8.dirname(relative2));
8559
+ await assertNoSymlinkComponents(project, path9.dirname(relative2));
8424
8560
  const existing = await fs6.lstat(absolute).catch(() => void 0);
8425
8561
  if (existing?.isSymbolicLink()) throw invalid2(`\u53D7\u7BA1\u76EE\u5F55\u4E0D\u80FD\u662F\u7B26\u53F7\u94FE\u63A5\uFF1A${relative2}`);
8426
8562
  if (existing && !existing.isDirectory()) throw invalid2(`\u53D7\u7BA1\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55\uFF1A${relative2}`);
@@ -8437,8 +8573,8 @@ async function pathExists(file) {
8437
8573
  );
8438
8574
  }
8439
8575
  async function readSafeFile(project, file, label) {
8440
- const relative2 = path8.relative(project, file).split(path8.sep).join("/");
8441
- if (relative2.startsWith("../") || path8.isAbsolute(relative2))
8576
+ const relative2 = path9.relative(project, file).split(path9.sep).join("/");
8577
+ if (relative2.startsWith("../") || path9.isAbsolute(relative2))
8442
8578
  throw invalid2(`${label}\u8DEF\u5F84\u9003\u9038\u9879\u76EE`);
8443
8579
  await assertNoSymlinkComponents(project, relative2);
8444
8580
  let stat;
@@ -8455,14 +8591,14 @@ async function assertNoSymlinkComponents(project, relative2) {
8455
8591
  const parts = relative2.split("/").filter(Boolean);
8456
8592
  let current = project;
8457
8593
  for (const part of parts) {
8458
- current = path8.join(current, part);
8594
+ current = path9.join(current, part);
8459
8595
  const stat = await fs6.lstat(current).catch(() => void 0);
8460
8596
  if (stat?.isSymbolicLink()) throw invalid2(`\u8DEF\u5F84\u5305\u542B\u7B26\u53F7\u94FE\u63A5\uFF1A${relative2}`);
8461
8597
  if (!stat) break;
8462
8598
  }
8463
8599
  }
8464
8600
  async function realProject(requested) {
8465
- const absolute = path8.resolve(requested);
8601
+ const absolute = path9.resolve(requested);
8466
8602
  let project;
8467
8603
  try {
8468
8604
  project = await fs6.realpath(absolute);
@@ -8474,10 +8610,10 @@ async function realProject(requested) {
8474
8610
  return project;
8475
8611
  }
8476
8612
  function safeRelative(reference, label) {
8477
- if (!reference || path8.isAbsolute(reference) || /[\r\n\0]/.test(reference)) {
8613
+ if (!reference || path9.isAbsolute(reference) || /[\r\n\0]/.test(reference)) {
8478
8614
  throw invalid2(`${label}\u5FC5\u987B\u662F\u9879\u76EE\u5185\u76F8\u5BF9\u8DEF\u5F84`);
8479
8615
  }
8480
- const normalized = path8.normalize(reference).split(path8.sep).join("/");
8616
+ const normalized = path9.normalize(reference).split(path9.sep).join("/");
8481
8617
  if (normalized === ".." || normalized.startsWith("../") || normalized === ".") {
8482
8618
  throw invalid2(`${label}\u8DEF\u5F84\u9003\u9038\u9879\u76EE`);
8483
8619
  }
@@ -8529,12 +8665,17 @@ async function sha256File(file) {
8529
8665
  function invalid2(message, cause) {
8530
8666
  return new CliError20({ code: CliErrorCode19.INVALID_ARGUMENT, message, cause });
8531
8667
  }
8668
+ function nextCommandHint(planId, project, argv) {
8669
+ const quoted = argv.map((a) => /[\s"'$`\\]/.test(a) ? `'${a.replace(/'/g, `'\\''`)}'` : a);
8670
+ const proj = project && project !== "." ? ` --project ${project}` : "";
8671
+ return `hcm delivery execute ${planId}${proj} -- ${quoted.join(" ")}`;
8672
+ }
8532
8673
 
8533
8674
  // src/commands/user.ts
8534
8675
  init_auth_guard();
8535
8676
  init_exit();
8536
8677
  import {
8537
- HcmClient as HcmClient21,
8678
+ HcmClient as HcmClient22,
8538
8679
  adminResetPassword,
8539
8680
  formatObject as formatObject23,
8540
8681
  fromAxiosError as fromAxiosError19,
@@ -8568,7 +8709,7 @@ async function userResetPasswordCommand(args) {
8568
8709
  try {
8569
8710
  const password = args.passwordStdin ? await readSecretFromStdin() : await promptPasswordTwice();
8570
8711
  const request = buildAdminResetPasswordRequest(args, password);
8571
- const client3 = HcmClient21.fromAuthContext(await getActiveAuthContextFromCli(args));
8712
+ const client3 = HcmClient22.fromAuthContext(await getActiveAuthContextFromCli(args));
8572
8713
  const result = await adminResetPassword(client3.raw(), request);
8573
8714
  process.stdout.write(formatObject23(result, { format: args.output ?? "json" }) + "\n");
8574
8715
  } catch (cause) {
@@ -8593,13 +8734,13 @@ async function promptPasswordTwice() {
8593
8734
  init_exit();
8594
8735
  init_auth_guard();
8595
8736
  import {
8596
- HcmClient as HcmClient22,
8737
+ HcmClient as HcmClient23,
8597
8738
  formatObject as formatObject24,
8598
8739
  fromAxiosError as fromAxiosError20
8599
8740
  } from "@hcmai/sdk";
8600
8741
  async function modelsCommand(keyword, args) {
8601
8742
  try {
8602
- const client3 = HcmClient22.fromAuthContext(await getActiveAuthContextFromCli(args));
8743
+ const client3 = HcmClient23.fromAuthContext(await getActiveAuthContextFromCli(args));
8603
8744
  const all = await client3.listModels();
8604
8745
  const needle = keyword?.trim().toLowerCase();
8605
8746
  const rows = (needle ? all.filter((m) => JSON.stringify(m).toLowerCase().includes(needle)) : all).sort((a, b) => key(a).localeCompare(key(b)));
@@ -8686,6 +8827,10 @@ recon.command("round").description("\u96F6\u7F51\u7EDC\uFF1A\u8BFB\u4E00\u4EFD\u
8686
8827
  output: cmd.parent?.opts()?.output
8687
8828
  })
8688
8829
  );
8830
+ var seed = delivery.command("seed").description(
8831
+ "\u628A\u987E\u95EE\u624B\u4E0A\u7684**\u5BA2\u6237\u8868**\u53D8\u6210\u4EA7\u54C1\u91CC\u7684\u884C\u3002\u26A0\uFE0F \u4E0E\u9876\u5C42 `hcm import <path>` \u4E0D\u662F\u4E00\u56DE\u4E8B\uFF1A\u90A3\u4E00\u6761\u5403 DataPackage YAML\uFF08fixture \u6CE8\u5165\u5668\uFF09\uFF0C\u8FD9\u4E00\u65CF\u5403\u5BA2\u6237\u7684 Excel"
8832
+ );
8833
+ seed.command("plan").description("\u96F6\u5199\uFF1A\u8BFB\u5DE5\u4EF6 + \u6E90\u8868 + \u5200 2 \u7684\u57FA\u7EBF\uFF0C\u7B97\u51FA\u884C\u7EA7\u8BA1\u5212\u4E0E\u98CE\u9669\u6E05\u5355\u843D\u76D8\uFF08\u4E00\u53D1\u5199\u8BF7\u6C42\u90FD\u4E0D\u53D1\uFF09").option("--env <name>", "\u76EE\u6807\u73AF\u5883\u522B\u540D").option("--profile <name>", "\u8EAB\u4EFD\u6863\u6848").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--out <dir>", "recon \u4EA7\u7269\u6839\uFF08\u57FA\u7EBF\u5728 <out>/recon/<\u79DF\u6237\u6BB5>/<\u6765\u6E90\u6BB5>\uFF09", ".").option("--work <dir>", "work \u76EE\u5F55\uFF1B\u4E0D\u7ED9 \u21D2 <out>/work/<\u79DF\u6237\u6BB5>/").option("--mapping <file>", "\u5BFC\u5165\u6620\u5C04\u5DE5\u4EF6\uFF1B\u4E0D\u7ED9 \u21D2 <work>/mapping.json").option("--source-dir <dir>", "\u6E90\u8868\u6240\u5728\u76EE\u5F55\uFF08\u5DE5\u4EF6\u91CC\u5199\u7684\u662F\u76F8\u5BF9\u8DEF\u5F84\u65F6\u7528\u5B83\uFF09").option("--exemptions <file>", "\u7B7E\u5B57\u8C41\u514D\u53F0\u8D26\uFF08JSON \u6570\u7EC4\uFF09\uFF1B\u4E0D\u4F20\u4E0E\u4F20\u4E00\u4EFD\u7A7A\u53F0\u8D26\u662F\u4E24\u4E2A\u503C").action((opts) => deliverySeedPlanCommand(opts));
8689
8834
  delivery.command("gate0").description(
8690
8835
  "\u96F6\u7F51\u7EDC\uFF1A\u626B\u4E00\u4EFD skill \u7684\u6B63\u6587\uFF0C\u628A\u73AF\u5883\u4E8B\u5B9E / \u672A\u767B\u8BB0\u7684\u534F\u8BAE\u5F62\u6001 / \u4EA7\u7269\u8DEF\u5F84\u6321\u5728\u6210\u7A3F\u4E4B\u5916"
8691
8836
  ).requiredOption("--skills <dir>", "\u8981\u626B\u7684 skill \u6839\u76EE\u5F55\uFF08\u6B63\u6587 + references/ \u5168\u76EE\u5F55\uFF0C\u540C\u4E00\u5224\u636E\uFF09").option("--recon <dir>", "\u57FA\u7EBF\u4EA7\u7269\u76EE\u5F55\uFF08<out>/recon/<\u79DF\u6237\u6BB5>/<\u6765\u6E90\u6BB5>\uFF09", ".").option(
@@ -8702,7 +8847,7 @@ delivery.command("triage").description(
8702
8847
  "\u57FA\u7EBF\u4EA7\u7269\u76EE\u5F55\uFF08<out>/recon/<\u79DF\u6237\u6BB5>/<\u6765\u6E90\u6BB5>\uFF09\uFF1B\u4E0D\u7ED9\u5219\u6309\u722C\u53D6\u8EAB\u4EFD\u73B0\u7B97\u4E00\u4EFD"
8703
8848
  ).option("--out <dir>", "\u4EA7\u7269\u6839\uFF08\u5199 work/triage.md\uFF09", ".").option("--capabilities <caps>", "\u672C\u6B21\u63A2\u6D4B\u58F0\u660E\u7684 capability \u4E32", "default").action((opts) => deliveryTriageCommand(opts));
8704
8849
  delivery.command("prepare").description("\u628A\u53D7\u652F\u6301\u7684 R2 argv \u4E0E\u9501\u3001\u8FD0\u884C\u65F6\u548C\u53D8\u66F4/\u56DE\u6EDA\u8BF4\u660E\u7ED1\u5B9A\u4E3A\u77ED\u65F6\u6267\u884C\u8BA1\u5212").requiredOption("--change-ref <file>", "\u9879\u76EE work/ \u6216 decisions/ \u4E0B\u7684\u53D8\u66F4\u8BF4\u660E").requiredOption("--rollback-ref <file>", "\u9879\u76EE work/ \u6216 decisions/ \u4E0B\u7684\u56DE\u6EDA\u8BF4\u660E").requiredOption("--evidence-dir <dir>", "\u9879\u76EE evidence/ \u4E0B\u7684\u6536\u636E\u76EE\u5F55").option("--project <dir>", "HCM \u987E\u95EE\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--ttl-seconds <n>", "\u6709\u6548\u671F\u79D2\u6570\uFF0860-3600\uFF09", "900").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").allowUnknownOption(true).argument("<command...>", "\u88AB\u7ED1\u5B9A\u7684 R2 HCM \u5B50\u547D\u4EE4\u4E0E\u53C2\u6570\uFF0C\u4E0D\u5305\u542B hcm \u672C\u8EAB").action((command, opts) => deliveryPrepareCommand(command, opts));
8705
- delivery.command("execute <planId>").description("\u9010\u6B21\u6279\u51C6\u540E\u6D88\u8D39\u77ED\u65F6\u8BA1\u5212\uFF0C\u5E76\u6267\u884C\u4E00\u6B21\u4E0E\u8BA1\u5212\u5B8C\u5168\u76F8\u540C\u7684 R2 argv").option("--project <dir>", "HCM \u987E\u95EE\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--output <fmt>", "\u6536\u636E\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").allowUnknownOption(true).argument("<command...>", "\u4E0E prepare \u5B8C\u5168\u76F8\u540C\u7684 R2 HCM \u5B50\u547D\u4EE4\u4E0E\u53C2\u6570").action((planId, command, opts) => deliveryExecuteCommand(planId, command, opts));
8850
+ delivery.command("execute <planId>").description("\u9010\u6B21\u6279\u51C6\u540E\u6D88\u8D39\u77ED\u65F6\u8BA1\u5212\uFF0C\u5E76\u6267\u884C\u4E00\u6B21\u4E0E\u8BA1\u5212\u5B8C\u5168\u76F8\u540C\u7684 R2 argv").option("--project <dir>", "HCM \u987E\u95EE\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--output <fmt>", "\u6536\u636E\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").allowUnknownOption(true).argument("[command...]", "\u4E0E prepare \u5B8C\u5168\u76F8\u540C\u7684 R2 HCM \u5B50\u547D\u4EE4\u4E0E\u53C2\u6570").action((planId, command, opts) => deliveryExecuteCommand(planId, command, opts));
8706
8851
  program.command("query <Model>").description("\u67E5\u8BE2 Model \u5217\u8868\u6570\u636E\uFF08\u901A\u8FC7 ModelQueryDsl JSON \u8868\u8FBE\u8FC7\u6EE4/\u6392\u5E8F/\u5206\u9875\uFF09").option(
8707
8852
  "--filter <JSON>",
8708
8853
  `\u8FC7\u6EE4 AST\uFF08ModelQueryDsl\uFF09\uFF1A\u53F6\u5B50 '{"field":"status","op":"eq","value":"ACTIVE"}'\uFF0C\u591A\u6761\u4EF6\u7528 '{"and":[\u53F6\u5B50,\u2026]}'\u3002\u26A0\uFE0F \u4E0D\u63A5\u53D7 {"\u5B57\u6BB5":"\u503C"} \u7B80\u5199\uFF0Cschema \u5C42\u4F1A\u62D2`