@hcmai/cli 0.23.0 → 0.24.0

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
@@ -33,13 +33,13 @@ function prepareImpersonationExit(code2, brokenStderr = false) {
33
33
  terminating ??= (async () => {
34
34
  process.exitCode = code2 || process.exitCode || 0;
35
35
  const errors = await cleanup();
36
- await new Promise((resolve3) => {
36
+ await new Promise((resolve4) => {
37
37
  let remaining = 2;
38
- const timer = setTimeout(resolve3, 1e3);
38
+ const timer = setTimeout(resolve4, 1e3);
39
39
  const done = () => {
40
40
  if (--remaining === 0) {
41
41
  clearTimeout(timer);
42
- resolve3();
42
+ resolve4();
43
43
  }
44
44
  };
45
45
  for (const stream of [process.stdout, process.stderr]) {
@@ -794,8 +794,8 @@ var init_TerminalRenderer = __esm({
794
794
  }
795
795
  }
796
796
  /** 来源行(仅子代理触发,agentPath ≥2 段时显示 `↑ 来自 a › b`,对齐 Web)。 */
797
- originLine(path21) {
798
- const segs = path21.split(".").filter(Boolean);
797
+ originLine(path22) {
798
+ const segs = path22.split(".").filter(Boolean);
799
799
  if (segs.length < 2) return "";
800
800
  const names = segs.map((k) => agentDisplayName(k));
801
801
  return chalk.gray(` \u2191 \u6765\u81EA ${names.join(" \u203A ")}`) + "\n";
@@ -1760,12 +1760,12 @@ function ReplApp(props) {
1760
1760
  setInteraction(null);
1761
1761
  }
1762
1762
  }, [appendBlock, updateStreaming, props]);
1763
- const uploadOne = useCallback(async (filePath) => {
1763
+ const uploadOne = useCallback(async (filePath2) => {
1764
1764
  try {
1765
- const meta2 = await uploadDocument(props.client.raw(), filePath);
1765
+ const meta2 = await uploadDocument(props.client.raw(), filePath2);
1766
1766
  return meta2;
1767
1767
  } catch (e) {
1768
- appendBlock({ kind: "banner", text: `\u{1F4CE} \u4E0A\u4F20\u5931\u8D25 ${filePath}: ${e.message}` });
1768
+ appendBlock({ kind: "banner", text: `\u{1F4CE} \u4E0A\u4F20\u5931\u8D25 ${filePath2}: ${e.message}` });
1769
1769
  return null;
1770
1770
  }
1771
1771
  }, [appendBlock, props.client]);
@@ -1984,8 +1984,8 @@ function agentLabel(agentId) {
1984
1984
  if (/^[0-9a-f]{8}-[0-9a-f-]{27}$/i.test(agentId)) return `agent \u2026${agentId.slice(-4)}`;
1985
1985
  return agentDisplayName(agentId);
1986
1986
  }
1987
- function originLine(path21) {
1988
- const segs = (path21 ?? "").split(".").filter(Boolean);
1987
+ function originLine(path22) {
1988
+ const segs = (path22 ?? "").split(".").filter(Boolean);
1989
1989
  if (segs.length < 2) return null;
1990
1990
  return `\u6765\u81EA ${segs.map((k) => agentDisplayName(k)).join(" \u203A ")}`;
1991
1991
  }
@@ -2221,10 +2221,10 @@ __export(readline_exports, {
2221
2221
  import * as readline2 from "readline";
2222
2222
  function readLineFromStdin(prompt = "") {
2223
2223
  const rl = readline2.createInterface({ input: process.stdin, output: process.stdout });
2224
- return new Promise((resolve3) => {
2224
+ return new Promise((resolve4) => {
2225
2225
  rl.question(prompt, (answer) => {
2226
2226
  rl.close();
2227
- resolve3(answer);
2227
+ resolve4(answer);
2228
2228
  });
2229
2229
  });
2230
2230
  }
@@ -2282,7 +2282,7 @@ import {
2282
2282
  import * as readline from "readline";
2283
2283
  async function promptText(question, output = process.stdout) {
2284
2284
  const rl = readline.createInterface({ input: process.stdin, output });
2285
- return new Promise((resolve3, reject) => {
2285
+ return new Promise((resolve4, reject) => {
2286
2286
  let answered = false;
2287
2287
  rl.on("close", () => {
2288
2288
  if (!answered) reject(new Error("\u8F93\u5165\u5DF2\u7ED3\u675F\uFF1B\u64CD\u4F5C\u5DF2\u53D6\u6D88\u3002"));
@@ -2290,12 +2290,12 @@ async function promptText(question, output = process.stdout) {
2290
2290
  rl.question(question, (ans) => {
2291
2291
  answered = true;
2292
2292
  rl.close();
2293
- resolve3(ans.trim());
2293
+ resolve4(ans.trim());
2294
2294
  });
2295
2295
  });
2296
2296
  }
2297
2297
  async function promptSecret(question, output = process.stdout) {
2298
- return new Promise((resolve3, reject) => {
2298
+ return new Promise((resolve4, reject) => {
2299
2299
  const stdin = process.stdin;
2300
2300
  stdin.setRawMode?.(true);
2301
2301
  let buf = "";
@@ -2315,7 +2315,7 @@ async function promptSecret(question, output = process.stdout) {
2315
2315
  stdin.removeListener("data", onData);
2316
2316
  stdin.removeListener("end", onEnd);
2317
2317
  output.write("\n");
2318
- resolve3(buf);
2318
+ resolve4(buf);
2319
2319
  return;
2320
2320
  }
2321
2321
  if (ch === "") {
@@ -2410,7 +2410,7 @@ function launchBrowser(url, platform = process.platform, onFailure) {
2410
2410
  child.unref();
2411
2411
  }
2412
2412
  async function runOpen(target, args, deps) {
2413
- const path21 = normalizeTarget(target);
2413
+ const path22 = normalizeTarget(target);
2414
2414
  if (!deps.frontend?.trim()) {
2415
2415
  throw new CliError3({
2416
2416
  code: CliErrorCode2.INVALID_ARGUMENT,
@@ -2418,13 +2418,13 @@ async function runOpen(target, args, deps) {
2418
2418
  });
2419
2419
  }
2420
2420
  const { ticket, expiresIn } = await deps.mintTicket();
2421
- const url = buildBrowserLoginUrl(deps.frontend, ticket, path21);
2421
+ const url = buildBrowserLoginUrl(deps.frontend, ticket, path22);
2422
2422
  if (args.printUrl) {
2423
2423
  deps.write(`${url}
2424
2424
  `);
2425
2425
  } else {
2426
2426
  deps.launch(url);
2427
- deps.write(`\u5DF2\u7528\u5F53\u524D\u8EAB\u4EFD\u6253\u5F00 ${path21}\uFF08\u7968\u636E ${expiresIn ?? 60}s \u5185\u6709\u6548\uFF0C\u53EA\u80FD\u7528\u4E00\u6B21\uFF09
2427
+ deps.write(`\u5DF2\u7528\u5F53\u524D\u8EAB\u4EFD\u6253\u5F00 ${path22}\uFF08\u7968\u636E ${expiresIn ?? 60}s \u5185\u6709\u6548\uFF0C\u53EA\u80FD\u7528\u4E00\u6B21\uFF09
2428
2428
  `);
2429
2429
  }
2430
2430
  return { url, expiresIn };
@@ -2621,10 +2621,10 @@ async function beginBrowserLogin(input) {
2621
2621
  let closing;
2622
2622
  let watch;
2623
2623
  let stopCountdown = () => void 0;
2624
- let resolve3;
2624
+ let resolve4;
2625
2625
  let reject;
2626
2626
  const result = new Promise((yes, no) => {
2627
- resolve3 = yes;
2627
+ resolve4 = yes;
2628
2628
  reject = no;
2629
2629
  });
2630
2630
  void result.catch(() => void 0);
@@ -2677,7 +2677,7 @@ async function beginBrowserLogin(input) {
2677
2677
  }).then((authorized) => {
2678
2678
  verifier = "";
2679
2679
  session = authorized;
2680
- resolve3({ session, close, complete: async () => {
2680
+ resolve4({ session, close, complete: async () => {
2681
2681
  if (cancel.controller.signal.aborted) throw cancel.error(new Error("\u767B\u5F55\u5DF2\u53D6\u6D88"));
2682
2682
  session.complete();
2683
2683
  reply(response, 200, "CLI \u767B\u5F55\u6210\u529F");
@@ -2912,9 +2912,9 @@ async function migrateProfileTokenToIdentity(envName, identityName) {
2912
2912
  const rawAccess = await oldStore.getAccessToken();
2913
2913
  const rawRefresh = await oldStore.getRefreshToken();
2914
2914
  const newStore = TokenStore2.forIdentity(identityName);
2915
- const record = { ...oldMeta };
2916
- if (rawAccess) record.accessTokenRef = await newStore.setAccessToken(rawAccess);
2917
- if (rawRefresh) record.refreshTokenRef = await newStore.setRefreshToken(rawRefresh);
2915
+ const record2 = { ...oldMeta };
2916
+ if (rawAccess) record2.accessTokenRef = await newStore.setAccessToken(rawAccess);
2917
+ if (rawRefresh) record2.refreshTokenRef = await newStore.setRefreshToken(rawRefresh);
2918
2918
  try {
2919
2919
  await oldStore.clear();
2920
2920
  } catch (err) {
@@ -2925,7 +2925,7 @@ async function migrateProfileTokenToIdentity(envName, identityName) {
2925
2925
  `
2926
2926
  );
2927
2927
  }
2928
- return record;
2928
+ return record2;
2929
2929
  }
2930
2930
  async function discardTempEnvSessions() {
2931
2931
  const ids = await listIdentities2(TEMP_ENV_NAME).catch(() => []);
@@ -3154,7 +3154,7 @@ async function loginCommand(args) {
3154
3154
  principal = session.principal;
3155
3155
  username = principal.username;
3156
3156
  } else if (args.code) {
3157
- const { record, principal: p } = await loginPairing({
3157
+ const { record: record2, principal: p } = await loginPairing({
3158
3158
  endpoint,
3159
3159
  code: args.code,
3160
3160
  profile: envName,
@@ -3166,11 +3166,11 @@ async function loginCommand(args) {
3166
3166
  await saveEnv(envName, envCfg);
3167
3167
  }
3168
3168
  scheme = "pairing";
3169
- scopes = record.scopes;
3169
+ scopes = record2.scopes;
3170
3170
  principal = p;
3171
3171
  username = p?.username;
3172
3172
  } else if (pat) {
3173
- const { record, principal: p } = await loginPat({
3173
+ const { record: record2, principal: p } = await loginPat({
3174
3174
  endpoint,
3175
3175
  tenantId,
3176
3176
  pat,
@@ -3179,7 +3179,7 @@ async function loginCommand(args) {
3179
3179
  httpClient: http
3180
3180
  });
3181
3181
  scheme = "pat";
3182
- scopes = record.scopes;
3182
+ scopes = record2.scopes;
3183
3183
  principal = p;
3184
3184
  } else if (args.clientId || args.clientSecret) {
3185
3185
  clientId = args.clientId ?? await promptText("client_id: ");
@@ -3190,7 +3190,7 @@ async function loginCommand(args) {
3190
3190
  message: "client_id and client_secret required"
3191
3191
  });
3192
3192
  }
3193
- const { record, principal: machinePrincipal } = await loginClientCredentials({
3193
+ const { record: record2, principal: machinePrincipal } = await loginClientCredentials({
3194
3194
  endpoint,
3195
3195
  tenantId,
3196
3196
  clientId,
@@ -3201,7 +3201,7 @@ async function loginCommand(args) {
3201
3201
  });
3202
3202
  scheme = "client_credentials";
3203
3203
  principal = machinePrincipal;
3204
- scopes = record.scopes;
3204
+ scopes = record2.scopes;
3205
3205
  } else {
3206
3206
  username = args.username ?? await promptText("username: ", process.stderr);
3207
3207
  await assertPasswordLoginAccount(username, envName);
@@ -3224,12 +3224,12 @@ async function loginCommand(args) {
3224
3224
  message: "username and password required"
3225
3225
  });
3226
3226
  }
3227
- const { record, principal: p } = await loginPasswordWithFirstLoginChange(
3227
+ const { record: record2, principal: p } = await loginPasswordWithFirstLoginChange(
3228
3228
  { endpoint, tenantId, username, password, profile: envName, expectedTenantId: project2?.environment.tenant, httpClient: http },
3229
3229
  args
3230
3230
  );
3231
3231
  scheme = "password";
3232
- scopes = record.scopes;
3232
+ scopes = record2.scopes;
3233
3233
  principal = p;
3234
3234
  }
3235
3235
  if (projectEnvPending) {
@@ -4658,8 +4658,8 @@ import {
4658
4658
  formatObject as formatObject7,
4659
4659
  fromAxiosError as fromAxiosError9
4660
4660
  } from "@hcmai/sdk";
4661
- function collectYmlFiles(path21) {
4662
- if (statSync(path21).isFile()) return [path21];
4661
+ function collectYmlFiles(path22) {
4662
+ if (statSync(path22).isFile()) return [path22];
4663
4663
  const out = [];
4664
4664
  const walk = (dir) => {
4665
4665
  for (const name of readdirSync(dir).sort()) {
@@ -4668,7 +4668,7 @@ function collectYmlFiles(path21) {
4668
4668
  else if (full.endsWith(".yml") || full.endsWith(".yaml")) out.push(full);
4669
4669
  }
4670
4670
  };
4671
- walk(path21);
4671
+ walk(path22);
4672
4672
  return out.sort();
4673
4673
  }
4674
4674
  var DRY_RUN_CLIENT = {
@@ -4677,9 +4677,9 @@ var DRY_RUN_CLIENT = {
4677
4677
  update: async () => ({}),
4678
4678
  fieldKeys: async () => []
4679
4679
  };
4680
- async function importCommand(path21, args) {
4680
+ async function importCommand(path22, args) {
4681
4681
  try {
4682
- const files = collectYmlFiles(path21);
4682
+ const files = collectYmlFiles(path22);
4683
4683
  const fixtures = files.map(
4684
4684
  (f) => parseFixture(readFileSync2(f, "utf8"), relative(process.cwd(), f))
4685
4685
  );
@@ -5352,11 +5352,11 @@ async function chatCommand(prompt, args) {
5352
5352
  lastConversationId: handle.conversationId,
5353
5353
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
5354
5354
  });
5355
- await new Promise((resolve3) => {
5355
+ await new Promise((resolve4) => {
5356
5356
  if (process.stdout.writableNeedDrain) {
5357
- process.stdout.once("drain", resolve3);
5357
+ process.stdout.once("drain", resolve4);
5358
5358
  } else {
5359
- resolve3();
5359
+ resolve4();
5360
5360
  }
5361
5361
  });
5362
5362
  process.exitCode = 0;
@@ -5425,11 +5425,11 @@ async function chatCommand(prompt, args) {
5425
5425
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
5426
5426
  });
5427
5427
  process.removeListener("SIGINT", sigintHandler);
5428
- await new Promise((resolve3) => {
5428
+ await new Promise((resolve4) => {
5429
5429
  if (process.stdout.writableNeedDrain) {
5430
- process.stdout.once("drain", resolve3);
5430
+ process.stdout.once("drain", resolve4);
5431
5431
  } else {
5432
- resolve3();
5432
+ resolve4();
5433
5433
  }
5434
5434
  });
5435
5435
  process.exitCode = result.status === "interrupted" ? 130 : 0;
@@ -6393,13 +6393,13 @@ import {
6393
6393
  uploadDocument as uploadDocument2
6394
6394
  } from "@hcmai/sdk";
6395
6395
  var DEFAULT_UPLOAD_CATEGORY = "attachment";
6396
- async function uploadCommand(filePath, args) {
6396
+ async function uploadCommand(filePath2, args) {
6397
6397
  try {
6398
6398
  const ctx = await getActiveAuthContextFromCli(args);
6399
6399
  const client3 = HcmClient18.fromAuthContext(ctx);
6400
6400
  const meta2 = await uploadDocument2(
6401
6401
  client3.raw(),
6402
- filePath,
6402
+ filePath2,
6403
6403
  args.category ?? DEFAULT_UPLOAD_CATEGORY,
6404
6404
  args.model || args.originId || args.field ? { model: args.model ?? "", originId: args.originId ?? "", field: args.field ?? "", state: args.state } : void 0
6405
6405
  );
@@ -6426,7 +6426,7 @@ async function uploadCommand(filePath, args) {
6426
6426
  const err = e;
6427
6427
  const status = err?.response?.status;
6428
6428
  if (err?.code === "ENOENT") {
6429
- exitWithError(new Error(`\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${filePath}`));
6429
+ exitWithError(new Error(`\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${filePath2}`));
6430
6430
  } else if (status === 413) {
6431
6431
  exitWithError(new Error("\u6587\u4EF6\u8D85\u51FA\u670D\u52A1\u7AEF\u5927\u5C0F\u4E0A\u9650\uFF08413\uFF09"));
6432
6432
  } else if (err?.isAxiosError) {
@@ -6712,8 +6712,8 @@ function conflictMessage(ids, endpoint) {
6712
6712
  function unconfirmedConflictNote(source) {
6713
6713
  return `\u672C\u8D9F\u53EA\u770B\u4E86${source === "cli" ? "CLI \u81EA\u5E26" : "\u777F\u620E"}\u6765\u6E90\uFF0C\u672A\u505A\u8DE8\u6765\u6E90\u51B2\u7A81\u68C0\u67E5`;
6714
6714
  }
6715
- function classifyInstalledSource(id, record, catalog) {
6716
- const kind = record.sourceKind ?? "chiron";
6715
+ function classifyInstalledSource(id, record2, catalog) {
6716
+ const kind = record2.sourceKind ?? "chiron";
6717
6717
  if (kind === "local") return "local";
6718
6718
  const half = kind === "cli" ? catalog.cli : catalog.chiron;
6719
6719
  if (half.status !== "fetched") return "not-checked";
@@ -7446,13 +7446,13 @@ function resolveRenamedId(id, half) {
7446
7446
  }
7447
7447
  function migrateSkillsState(state) {
7448
7448
  const skills2 = {};
7449
- for (const [id, record] of Object.entries(state.skills ?? {})) {
7450
- if (record.sourceKind) {
7451
- skills2[id] = record;
7449
+ for (const [id, record2] of Object.entries(state.skills ?? {})) {
7450
+ if (record2.sourceKind) {
7451
+ skills2[id] = record2;
7452
7452
  continue;
7453
7453
  }
7454
- const kind = /^https?:\/\//i.test(record.source ?? "") ? "chiron" : "local";
7455
- skills2[id] = { ...record, sourceKind: kind, sourceLocator: record.source };
7454
+ const kind = /^https?:\/\//i.test(record2.source ?? "") ? "chiron" : "local";
7455
+ skills2[id] = { ...record2, sourceKind: kind, sourceLocator: record2.source };
7456
7456
  }
7457
7457
  return { ...state, skills: skills2 };
7458
7458
  }
@@ -7760,7 +7760,7 @@ async function listInstalledSkills(keyword, args, cwd = process.cwd()) {
7760
7760
  return;
7761
7761
  }
7762
7762
  const rows2 = [];
7763
- for (const [id, record] of Object.entries(state?.skills ?? {}).sort(([a], [b]) => a.localeCompare(b))) {
7763
+ for (const [id, record2] of Object.entries(state?.skills ?? {}).sort(([a], [b]) => a.localeCompare(b))) {
7764
7764
  const markdown = await readInstalled(layout.baseDir, id);
7765
7765
  let title = id;
7766
7766
  if (markdown !== void 0) {
@@ -7771,12 +7771,12 @@ async function listInstalledSkills(keyword, args, cwd = process.cwd()) {
7771
7771
  id,
7772
7772
  title,
7773
7773
  // 迁移保证它必然有值;`?? 'chiron'` 只是让类型闭合,不是业务缺省。
7774
- sourceKind: record.sourceKind ?? "chiron",
7775
- sourceLocator: record.sourceLocator ?? record.source,
7776
- direct: record.direct,
7777
- installedAt: record.installedAt,
7774
+ sourceKind: record2.sourceKind ?? "chiron",
7775
+ sourceLocator: record2.sourceLocator ?? record2.source,
7776
+ direct: record2.direct,
7777
+ installedAt: record2.installedAt,
7778
7778
  // 三种状态互斥:文件没了 / 本地改过 / 和装的时候一致
7779
- status: markdown === void 0 ? "missing" : sha2562(markdown) !== record.sha256 ? "locally-modified" : "installed"
7779
+ status: markdown === void 0 ? "missing" : sha2562(markdown) !== record2.sha256 ? "locally-modified" : "installed"
7780
7780
  });
7781
7781
  }
7782
7782
  const shadowed = new Set(localSkills.map((x) => x.id));
@@ -8666,11 +8666,11 @@ async function planOrphanPrune(options) {
8666
8666
  for (const entry of entries) {
8667
8667
  if (!PRUNABLE_STATUS.has(entry.status)) continue;
8668
8668
  const id = entry.id;
8669
- const record = state.skills[id];
8669
+ const record2 = state.skills[id];
8670
8670
  const onDisk = await readInstalled(baseDir, id);
8671
- if (onDisk !== void 0 && record !== void 0) {
8672
- let edited = sha2562(onDisk) !== record.sha256;
8673
- for (const [refPath, recordedSha] of Object.entries(record.references ?? {})) {
8671
+ if (onDisk !== void 0 && record2 !== void 0) {
8672
+ let edited = sha2562(onDisk) !== record2.sha256;
8673
+ for (const [refPath, recordedSha] of Object.entries(record2.references ?? {})) {
8674
8674
  const installed2 = await readInstalledReference(baseDir, id, refPath);
8675
8675
  if (installed2 !== void 0 && sha2562(installed2) !== recordedSha) edited = true;
8676
8676
  }
@@ -8749,10 +8749,10 @@ async function planSkillUpdate(options) {
8749
8749
  }
8750
8750
  const liveIds = directIds.filter((id) => !renamedAway.has(id));
8751
8751
  for (const id of liveIds.sort()) {
8752
- const record = state.skills[id];
8753
- const status = classifyInstalledSource(id, record, catalog);
8752
+ const record2 = state.skills[id];
8753
+ const status = classifyInstalledSource(id, record2, catalog);
8754
8754
  if (status === "present") {
8755
- live.push({ id, kind: (record.sourceKind ?? "chiron") === "cli" ? "cli" : "chiron" });
8755
+ live.push({ id, kind: (record2.sourceKind ?? "chiron") === "cli" ? "cli" : "chiron" });
8756
8756
  continue;
8757
8757
  }
8758
8758
  entries.push({ id, status, note: SOURCE_STATUS_NOTE[status] });
@@ -8805,7 +8805,7 @@ async function planSkillUpdate(options) {
8805
8805
  const documents = [];
8806
8806
  const verified = [];
8807
8807
  for (const [id, item] of closure) {
8808
- const record = state.skills[id];
8808
+ const record2 = state.skills[id];
8809
8809
  const onDisk = await readInstalled(baseDir, id);
8810
8810
  const fetch2 = async () => item.kind === "cli" ? await fetchBundled(id) : await fetchDocument(item.skill);
8811
8811
  if (onDisk === void 0) {
@@ -8814,18 +8814,18 @@ async function planSkillUpdate(options) {
8814
8814
  entries.push({
8815
8815
  id,
8816
8816
  status: "added",
8817
- note: renamedFromId ? `${renamedFromId} \u6539\u540D\u540E\u7684\u65B0\u540D\uFF0C\u5185\u5BB9\u642C\u5230\u4E86\u8FD9\u91CC` : record ? "\u672C\u5730\u6587\u4EF6\u7F3A\u5931\uFF0C\u91CD\u65B0\u88C5\u56DE" : all ? "\u4EA7\u54C1\u8FD9\u4E00\u7248\u65B0\u589E\u7684\u6280\u80FD" : "\u4EA7\u54C1\u65B0\u589E\u7684\u524D\u7F6E\u6280\u80FD"
8817
+ note: renamedFromId ? `${renamedFromId} \u6539\u540D\u540E\u7684\u65B0\u540D\uFF0C\u5185\u5BB9\u642C\u5230\u4E86\u8FD9\u91CC` : record2 ? "\u672C\u5730\u6587\u4EF6\u7F3A\u5931\uFF0C\u91CD\u65B0\u88C5\u56DE" : all ? "\u4EA7\u54C1\u8FD9\u4E00\u7248\u65B0\u589E\u7684\u6280\u80FD" : "\u4EA7\u54C1\u65B0\u589E\u7684\u524D\u7F6E\u6280\u80FD"
8818
8818
  });
8819
8819
  continue;
8820
8820
  }
8821
8821
  const remote = await fetch2();
8822
8822
  const remoteReferences = remote.references ?? [];
8823
8823
  let differsFromRemote = remote.markdown !== onDisk;
8824
- let editedLocally = record !== void 0 && sha2562(onDisk) !== record.sha256;
8824
+ let editedLocally = record2 !== void 0 && sha2562(onDisk) !== record2.sha256;
8825
8825
  for (const reference of remoteReferences) {
8826
8826
  const installed2 = await readInstalledReference(baseDir, id, reference.path);
8827
8827
  if (installed2 !== reference.content) differsFromRemote = true;
8828
- const recordedSha = record?.references?.[reference.path];
8828
+ const recordedSha = record2?.references?.[reference.path];
8829
8829
  if (installed2 !== void 0 && recordedSha && sha2562(installed2) !== recordedSha) editedLocally = true;
8830
8830
  }
8831
8831
  if (!differsFromRemote) {
@@ -8868,17 +8868,17 @@ async function planSkillUpdate(options) {
8868
8868
  function planLockAlignment(state, plan, endpoint, options = {}) {
8869
8869
  const repairs = [];
8870
8870
  for (const doc of plan.verified) {
8871
- const record = state.skills[doc.id];
8872
- if (!record) continue;
8871
+ const record2 = state.skills[doc.id];
8872
+ if (!record2) continue;
8873
8873
  const measured = sha2562(doc.markdown);
8874
8874
  const references = {};
8875
8875
  for (const ref of doc.references ?? []) {
8876
- const actual = sha2562(ref.content), previous = record.references?.[ref.path];
8876
+ const actual = sha2562(ref.content), previous = record2.references?.[ref.path];
8877
8877
  if (actual !== previous) references[ref.path] = { from: previous, to: actual };
8878
8878
  }
8879
- if (record.sha256 !== measured || Object.keys(references).length) repairs.push({
8879
+ if (record2.sha256 !== measured || Object.keys(references).length) repairs.push({
8880
8880
  id: doc.id,
8881
- ...record.sha256 !== measured ? { sha256: { from: record.sha256, to: measured } } : {},
8881
+ ...record2.sha256 !== measured ? { sha256: { from: record2.sha256, to: measured } } : {},
8882
8882
  references
8883
8883
  });
8884
8884
  }
@@ -8897,9 +8897,9 @@ async function applyLockAlignment(baseDir, alignment, check) {
8897
8897
  const state = await readSkillsState(baseDir);
8898
8898
  if (!state) throw invalid("\u9501\u6587\u4EF6\u5728\u5BF9\u8D26\u540E\u6D88\u5931\uFF1B\u672A\u5199\u5165\u5BF9\u9F50\u7ED3\u679C");
8899
8899
  for (const repair of alignment.repairs) {
8900
- const record = state.skills[repair.id];
8901
- if (repair.sha256) record.sha256 = repair.sha256.to;
8902
- for (const [name, value] of Object.entries(repair.references)) (record.references ??= {})[name] = value.to;
8900
+ const record2 = state.skills[repair.id];
8901
+ if (repair.sha256) record2.sha256 = repair.sha256.to;
8902
+ for (const [name, value] of Object.entries(repair.references)) (record2.references ??= {})[name] = value.to;
8903
8903
  }
8904
8904
  if (alignment.endpoint) state.endpoint = alignment.endpoint.to;
8905
8905
  state.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
@@ -9467,7 +9467,7 @@ async function bootstrapReport(http) {
9467
9467
  const waitSeconds = Math.ceil(wait) + 1;
9468
9468
  process.stderr.write(`\u521D\u59CB\u5316\u590D\u9A8C\u88AB\u8282\u6D41\uFF0C\u6309 Retry-After \u52A0\u4E00\u79D2\u8FB9\u754C\u7B49\u5F85 ${waitSeconds} \u79D2\u540E\u53EA\u91CD\u8BD5\u4E00\u6B21\u53EA\u8BFB\u68C0\u67E5\u3002
9469
9469
  `);
9470
- await new Promise((resolve3) => setTimeout(resolve3, waitSeconds * 1e3));
9470
+ await new Promise((resolve4) => setTimeout(resolve4, waitSeconds * 1e3));
9471
9471
  return (await read()).data;
9472
9472
  }
9473
9473
  }
@@ -9629,10 +9629,10 @@ async function metaListCommand(args) {
9629
9629
  fail7(e, args, "read");
9630
9630
  }
9631
9631
  }
9632
- async function metaGetCommand(path21, args) {
9632
+ async function metaGetCommand(path22, args) {
9633
9633
  try {
9634
9634
  const c2 = await client2(args);
9635
- const content = await getTenantMeta(c2.raw(), path21);
9635
+ const content = await getTenantMeta(c2.raw(), path22);
9636
9636
  process.stdout.write(content.endsWith("\n") ? content : content + "\n");
9637
9637
  process.exitCode = 0;
9638
9638
  return;
@@ -9641,8 +9641,8 @@ async function metaGetCommand(path21, args) {
9641
9641
  }
9642
9642
  }
9643
9643
  var PROBEABLE_META_TYPES = /* @__PURE__ */ new Set(["model", "list", "info", "view", "filter", "page", "wiz", "impexp"]);
9644
- function parseMetaPath(path21) {
9645
- const base = path21.split(/[\\/]/).pop() ?? path21;
9644
+ function parseMetaPath(path22) {
9645
+ const base = path22.split(/[\\/]/).pop() ?? path22;
9646
9646
  if (!/\.(yml|yaml)$/i.test(base)) return {};
9647
9647
  const parts = base.replace(/\.(yml|yaml)$/i, "").split(".");
9648
9648
  return { model: parts[0] || void 0, kind: parts[1] ?? "model", state: parts[2] };
@@ -9659,10 +9659,10 @@ function unverifiableReason(e) {
9659
9659
  if (st == null) return `\u8BF7\u6C42\u6CA1\u53D1\u51FA\u53BB\u6216\u6CA1\u56DE\u6765\uFF08${err.code ?? err.message ?? "\u672A\u77E5"}\uFF09`;
9660
9660
  return void 0;
9661
9661
  }
9662
- async function verifyAfterWrite(c2, path21) {
9663
- const { model, kind, state } = parseMetaPath(path21);
9662
+ async function verifyAfterWrite(c2, path22) {
9663
+ const { model, kind, state } = parseMetaPath(path22);
9664
9664
  if (!model || !kind) {
9665
- return { status: "unverified", where: "(\u672A\u63A2)", why: `\u4ECE\u8DEF\u5F84 ${path21} \u8BA4\u4E0D\u51FA\u6A21\u578B\u540D/\u5C42\u540D` };
9665
+ return { status: "unverified", where: "(\u672A\u63A2)", why: `\u4ECE\u8DEF\u5F84 ${path22} \u8BA4\u4E0D\u51FA\u6A21\u578B\u540D/\u5C42\u540D` };
9666
9666
  }
9667
9667
  try {
9668
9668
  await clearMetaCache2(c2.raw(), model, {});
@@ -9707,7 +9707,7 @@ async function verifyAfterWrite(c2, path21) {
9707
9707
  }
9708
9708
  return { status: "ok" };
9709
9709
  }
9710
- async function metaSetCommand(path21, args) {
9710
+ async function metaSetCommand(path22, args) {
9711
9711
  try {
9712
9712
  if (!args.file) {
9713
9713
  throw new CliError24({
@@ -9715,17 +9715,17 @@ async function metaSetCommand(path21, args) {
9715
9715
  message: "--file <path> \u5FC5\u586B\uFF08\u4ECE\u6587\u4EF6\u8BFB\u53D6 meta \u539F\u6587\uFF1B\u7528 - \u8868\u793A stdin\uFF09"
9716
9716
  });
9717
9717
  }
9718
- const content = args.file === "-" ? await new Promise((resolve3, reject) => {
9718
+ const content = args.file === "-" ? await new Promise((resolve4, reject) => {
9719
9719
  let buf = "";
9720
9720
  process.stdin.setEncoding("utf8");
9721
9721
  process.stdin.on("data", (d) => buf += d);
9722
- process.stdin.on("end", () => resolve3(buf));
9722
+ process.stdin.on("end", () => resolve4(buf));
9723
9723
  process.stdin.on("error", reject);
9724
9724
  }) : await fsp3.readFile(args.file, "utf8");
9725
9725
  if (!args.skipValidate) {
9726
- const result2 = validateMetaContent(path21, content);
9726
+ const result2 = validateMetaContent(path22, content);
9727
9727
  if (result2.issues.length > 0) {
9728
- process.stderr.write(`\u{1F50E} \u5199\u524D\u6821\u9A8C ${path21}\uFF08schema \u7C7B\u578B\uFF1A${result2.kind ?? "\u672A\u8BC6\u522B"}\uFF09
9728
+ process.stderr.write(`\u{1F50E} \u5199\u524D\u6821\u9A8C ${path22}\uFF08schema \u7C7B\u578B\uFF1A${result2.kind ?? "\u672A\u8BC6\u522B"}\uFF09
9729
9729
  `);
9730
9730
  process.stderr.write(formatMetaIssues(result2, " ") + "\n");
9731
9731
  }
@@ -9744,13 +9744,13 @@ async function metaSetCommand(path21, args) {
9744
9744
  if (dryFmt === "json" || dryFmt === "yaml") {
9745
9745
  process.stdout.write(
9746
9746
  formatObject22(
9747
- { dryRun: true, path: path21, bytes: Buffer.byteLength(content), content },
9747
+ { dryRun: true, path: path22, bytes: Buffer.byteLength(content), content },
9748
9748
  { format: dryFmt }
9749
9749
  ) + "\n"
9750
9750
  );
9751
9751
  } else {
9752
9752
  process.stdout.write(
9753
- `[dry-run] \u5C06\u5199\u5165 ${path21}\uFF08${Buffer.byteLength(content)} B\uFF09\u2014\u2014\u672A\u5B9E\u9645\u5199\u5165
9753
+ `[dry-run] \u5C06\u5199\u5165 ${path22}\uFF08${Buffer.byteLength(content)} B\uFF09\u2014\u2014\u672A\u5B9E\u9645\u5199\u5165
9754
9754
  ---
9755
9755
  ${content}
9756
9756
  `
@@ -9764,13 +9764,13 @@ ${content}
9764
9764
  let backupState = "unknown";
9765
9765
  let backupWhy;
9766
9766
  try {
9767
- const prev = await getTenantMeta(c2.raw(), path21);
9767
+ const prev = await getTenantMeta(c2.raw(), path22);
9768
9768
  if (!prev || prev.trim() === "") {
9769
9769
  backupState = "absent";
9770
9770
  } else {
9771
9771
  backupFile = nodePath.join(
9772
9772
  os4.tmpdir(),
9773
- `hcm-meta-backup-${Date.now()}-${path21.replace(/[\\/]/g, "_")}`
9773
+ `hcm-meta-backup-${Date.now()}-${path22.replace(/[\\/]/g, "_")}`
9774
9774
  );
9775
9775
  await fsp3.writeFile(backupFile, prev, "utf8");
9776
9776
  backupState = "saved";
@@ -9785,22 +9785,22 @@ ${content}
9785
9785
  backupWhy = `HTTP ${st ?? "-"}${err.code ? ` ${err.code}` : ""}${err.message ? `\uFF1A${err.message}` : ""}`;
9786
9786
  }
9787
9787
  }
9788
- const result = await saveTenantMeta(c2.raw(), path21, content);
9788
+ const result = await saveTenantMeta(c2.raw(), path22, content);
9789
9789
  const fmt = args.output ?? "json";
9790
- if (fmt !== "json") process.stdout.write(`\u2705 \u5DF2\u5199\u5165 ${path21}
9790
+ if (fmt !== "json") process.stdout.write(`\u2705 \u5DF2\u5199\u5165 ${path22}
9791
9791
  `);
9792
9792
  const restoreHint = backupState === "saved" && backupFile ? ` \u65E7\u5185\u5BB9\u5DF2\u5B58\uFF1A${backupFile}
9793
- \u653E\u56DE\u53BB\uFF1Ahcm meta set ${path21} --file ${backupFile}${connFlags(args)}
9794
- ` : backupState === "absent" ? ` \u8FD9\u4E00\u5C42\u6B64\u524D\u6CA1\u6709\u8986\u76D6\uFF08\u5DF2\u8BC1\u5B9E\uFF09\uFF0C\u6062\u590D\u5373\u5220\u9664\uFF1Ahcm meta delete ${path21}${connFlags(args)}
9793
+ \u653E\u56DE\u53BB\uFF1Ahcm meta set ${path22} --file ${backupFile}${connFlags(args)}
9794
+ ` : backupState === "absent" ? ` \u8FD9\u4E00\u5C42\u6B64\u524D\u6CA1\u6709\u8986\u76D6\uFF08\u5DF2\u8BC1\u5B9E\uFF09\uFF0C\u6062\u590D\u5373\u5220\u9664\uFF1Ahcm meta delete ${path22}${connFlags(args)}
9795
9795
  ` : ` \u26A0\uFE0F \u65E7\u5185\u5BB9**\u6CA1\u5907\u4EFD\u6210**\uFF08${backupWhy ?? "\u539F\u56E0\u672A\u77E5"}\uFF09\u2014\u2014\u65E2\u4E0D\u77E5\u9053\u6B64\u524D\u6709\u6CA1\u6709\u8986\u76D6\uFF0C\u4E5F\u5C31\u7ED9\u4E0D\u51FA\u6062\u590D\u547D\u4EE4\u3002
9796
- \u5148\u81EA\u5DF1\u8BFB\u4E00\u904D\u786E\u8BA4\uFF1Ahcm meta get ${path21}${connFlags(args)}
9796
+ \u5148\u81EA\u5DF1\u8BFB\u4E00\u904D\u786E\u8BA4\uFF1Ahcm meta get ${path22}${connFlags(args)}
9797
9797
  `;
9798
9798
  if (args.verify === false) {
9799
9799
  process.stderr.write(
9800
9800
  "\u26A0\uFE0F --no-verify\uFF1A**\u6CA1\u6709**\u9A8C\u8FC7\u670D\u52A1\u7AEF\u8BFB\u4E0D\u8BFB\u5F97\u52A8\u8FD9\u4EFD meta\u3002\u300C\u5199\u5165\u6210\u529F\u300D\u53EA\u8BF4\u660E\u5B57\u8282\u6536\u4E0B\u4E86\u3002\n \u81EA\u5DF1\u8865\uFF1Ahcm cache clear-meta <Model> \u540E\u6253\u5F00\u9875\u9762\u770B\u4E00\u773C\u3002\n" + restoreHint
9801
9801
  );
9802
9802
  } else {
9803
- const outcome = await verifyAfterWrite(c2, path21);
9803
+ const outcome = await verifyAfterWrite(c2, path22);
9804
9804
  if (outcome.status === "broken") {
9805
9805
  const human = explainJacksonError(outcome.raw);
9806
9806
  process.stderr.write(
@@ -9834,19 +9834,19 @@ ${content}
9834
9834
  fail7(e, args);
9835
9835
  }
9836
9836
  }
9837
- async function metaDeleteCommand(path21, args) {
9837
+ async function metaDeleteCommand(path22, args) {
9838
9838
  try {
9839
9839
  if (!args.yes) {
9840
- const ok = await promptConfirm(`\u5C06\u5220\u9664\u5143\u6570\u636E ${path21}\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u9006\u3002\u7EE7\u7EED\uFF1F`);
9840
+ const ok = await promptConfirm(`\u5C06\u5220\u9664\u5143\u6570\u636E ${path22}\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u9006\u3002\u7EE7\u7EED\uFF1F`);
9841
9841
  if (!ok) {
9842
9842
  process.stderr.write("\u5DF2\u53D6\u6D88\n");
9843
9843
  process.exit(1);
9844
9844
  }
9845
9845
  }
9846
9846
  const c2 = await client2(args);
9847
- const result = await deleteTenantMeta(c2.raw(), path21);
9847
+ const result = await deleteTenantMeta(c2.raw(), path22);
9848
9848
  const fmt = args.output ?? "json";
9849
- if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${path21}
9849
+ if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${path22}
9850
9850
  `);
9851
9851
  process.stdout.write(formatObject22(result, { format: fmt }) + "\n");
9852
9852
  process.exitCode = 0;
@@ -9855,7 +9855,7 @@ async function metaDeleteCommand(path21, args) {
9855
9855
  fail7(e, args);
9856
9856
  }
9857
9857
  }
9858
- async function metaValidateCommand(path21, args) {
9858
+ async function metaValidateCommand(path22, args) {
9859
9859
  try {
9860
9860
  if (!args.file) {
9861
9861
  throw new CliError24({
@@ -9863,20 +9863,20 @@ async function metaValidateCommand(path21, args) {
9863
9863
  message: "--file <path> \u5FC5\u586B\uFF08\u8981\u9A8C\u7684\u90A3\u4EFD\u539F\u6587\uFF1B\u7528 - \u8868\u793A stdin\uFF09"
9864
9864
  });
9865
9865
  }
9866
- const content = args.file === "-" ? await new Promise((resolve3, reject) => {
9866
+ const content = args.file === "-" ? await new Promise((resolve4, reject) => {
9867
9867
  let buf = "";
9868
9868
  process.stdin.setEncoding("utf8");
9869
9869
  process.stdin.on("data", (d) => buf += d);
9870
- process.stdin.on("end", () => resolve3(buf));
9870
+ process.stdin.on("end", () => resolve4(buf));
9871
9871
  process.stdin.on("error", reject);
9872
9872
  }) : await fsp3.readFile(args.file, "utf8");
9873
- const result = validateMetaContent(path21, content);
9873
+ const result = validateMetaContent(path22, content);
9874
9874
  const fmt = args.output ?? "table";
9875
9875
  if (fmt === "json" || fmt === "yaml") {
9876
9876
  process.stdout.write(
9877
9877
  formatObject22(
9878
9878
  {
9879
- path: path21,
9879
+ path: path22,
9880
9880
  kind: result.kind,
9881
9881
  schemaKnown: result.schemaKnown,
9882
9882
  schemaSourceCommit: META_SCHEMA_SOURCE_COMMIT,
@@ -9888,7 +9888,7 @@ async function metaValidateCommand(path21, args) {
9888
9888
  );
9889
9889
  } else {
9890
9890
  process.stdout.write(
9891
- `\u{1F50E} ${path21}\uFF08schema \u7C7B\u578B\uFF1A${result.kind ?? "\u672A\u8BC6\u522B"}\uFF0C\u6765\u6E90 ${META_SCHEMA_SOURCE_COMMIT.slice(0, 8)}\uFF09
9891
+ `\u{1F50E} ${path22}\uFF08schema \u7C7B\u578B\uFF1A${result.kind ?? "\u672A\u8BC6\u522B"}\uFF0C\u6765\u6E90 ${META_SCHEMA_SOURCE_COMMIT.slice(0, 8)}\uFF09
9892
9892
  `
9893
9893
  );
9894
9894
  process.stdout.write(
@@ -9906,8 +9906,8 @@ async function metaValidateCommand(path21, args) {
9906
9906
  // src/commands/workspace.ts
9907
9907
  init_exit();
9908
9908
  import * as crypto from "crypto";
9909
- import * as fs8 from "fs/promises";
9910
- import * as path9 from "path";
9909
+ import * as fs9 from "fs/promises";
9910
+ import * as path10 from "path";
9911
9911
  import {
9912
9912
  buildMiniPreviewTargets,
9913
9913
  buildMiniVerifyAgentReport,
@@ -9915,7 +9915,7 @@ import {
9915
9915
  createWorkspaceFile,
9916
9916
  deleteWorkspaceFile,
9917
9917
  formatMiniVerifyReport,
9918
- formatObject as formatObject23,
9918
+ formatObject as formatObject24,
9919
9919
  formatRows as formatRows6,
9920
9920
  getMiniStatus,
9921
9921
  HcmClient as HcmClient23,
@@ -10065,6 +10065,147 @@ function boolValue(value) {
10065
10065
  return value === true || value === "true";
10066
10066
  }
10067
10067
 
10068
+ // src/commands/workspace-rebase.ts
10069
+ import * as fs8 from "fs/promises";
10070
+ import * as path9 from "path";
10071
+ import { formatObject as formatObject23 } from "@hcmai/sdk";
10072
+ async function runWorkspaceRebase(workspaceKey, args, connect) {
10073
+ const plan = args.plan && !args.dryRun ? readPlan(JSON.parse(await fs8.readFile(args.plan, "utf8"))) : void 0;
10074
+ const client3 = await connect();
10075
+ const workspaces = await client3.query("TenantExtensionWorkspace", {
10076
+ filter: { workspaceKey },
10077
+ fields: ["id", "workspaceKey"],
10078
+ limit: 2
10079
+ });
10080
+ if (workspaces.rows.length !== 1 || workspaces.rows[0]?.workspaceKey !== workspaceKey || workspaces.total !== void 0 && workspaces.total !== 1) {
10081
+ throw new Error(`workspace ${workspaceKey} \u5FC5\u987B\u5728\u5F53\u524D\u79DF\u6237\u67E5\u8BE2\u5230\u552F\u4E00\u7684\u5F00\u53D1\u7A7A\u95F4\uFF1B\u672A\u6267\u884C rebase\u3002`);
10082
+ }
10083
+ const id = requiredText(workspaces.rows[0].id, "workspace model id");
10084
+ const action = `/api/models/TenantExtensionWorkspace/${encodeURIComponent(id)}/action`;
10085
+ if (plan) {
10086
+ const response2 = await client3.raw().post(`${action}/resolve-conflicts`, { form: plan });
10087
+ const result = actionPayload(response2.data);
10088
+ const expected = new Set(plan.resolutions.map((item) => item.relativePath));
10089
+ if (result.workspaceKey !== workspaceKey || !Array.isArray(result.resolvedPaths) || result.resolvedPaths.length !== expected.size || new Set(result.resolvedPaths).size !== expected.size || result.resolvedPaths.some((item) => typeof item !== "string" || !expected.has(item)) || !nonnegativeInteger(result.remainingConflicts)) {
10090
+ throw new Error("resolve-conflicts \u56DE\u6267\u7F3A\u5931\u6216\u4E0E\u63D0\u4EA4\u8DEF\u5F84\u4E0D\u7B26\uFF1B\u4E0D\u80FD\u786E\u8BA4\u89E3\u51B3\u6210\u529F\uFF0C\u8BF7\u91CD\u65B0\u9884\u89C8\u540E\u6838\u5BF9\u3002");
10091
+ }
10092
+ requiredText(result.baselineHash, "resolve-conflicts baselineHash");
10093
+ writeResult(result, args.output, [
10094
+ `workspace rebase resolved: ${workspaceKey}`,
10095
+ `resolved paths: ${result.resolvedPaths.join(", ")}`,
10096
+ `baselineHash: ${result.baselineHash}`,
10097
+ `remainingConflicts: ${result.remainingConflicts}`,
10098
+ ...result.degraded !== void 0 ? [`degraded: ${String(result.degraded)}`] : [],
10099
+ ...result.reason !== void 0 ? [`reason: ${String(result.reason)}`] : []
10100
+ ]);
10101
+ return;
10102
+ }
10103
+ const response = await client3.raw().get(`${action}/preview-rebase`);
10104
+ const preview = readPreview(actionPayload(response.data), workspaceKey);
10105
+ if (args.plan) {
10106
+ const draft = {
10107
+ planDigest: preview.planDigest,
10108
+ reason: "",
10109
+ resolutions: preview.files.filter((file) => file.conflict).map((file) => ({
10110
+ relativePath: file.relativePath,
10111
+ resolution: "UNRESOLVED",
10112
+ content: file.workspaceContent
10113
+ }))
10114
+ };
10115
+ await fs8.writeFile(path9.resolve(args.plan), JSON.stringify(draft, null, 2) + "\n", { flag: "wx", mode: 384 });
10116
+ process.stderr.write(`\u5DF2\u5199\u89E3\u51B3\u8349\u6848 ${path9.resolve(args.plan)}\u3002\u586B\u5199 reason\uFF0C\u5220\u9664\u6682\u4E0D\u5904\u7406\u7684\u8DEF\u5F84\u884C\uFF1B\u9010\u8DEF\u5F84\u628A UNRESOLVED \u6539\u4E3A TAKE_ACTIVE / MERGED / KEEP_WORKSPACE / DELETE\u3002MERGED \u5FC5\u987B\u586B\u5199 content\uFF08\u7A7A\u4E32\u5408\u6CD5\uFF09\uFF1B\u5176\u4ED6\u9009\u62E9\u4E0D\u4F1A\u63D0\u4EA4\u8349\u6848 content\u3002\u6838\u5BF9\u540E\u6267\u884C hcm workspace rebase --plan <\u6587\u4EF6>\uFF0C\u6CBF\u7528\u672C\u6B21 --workspace/--dir/--env/--as\u3002
10117
+ `);
10118
+ } else {
10119
+ process.stderr.write("\u53EA\u8BFB\u9884\u89C8\u5B8C\u6210\u3002\u53EF\u7528 hcm workspace rebase --dry-run --plan <\u65B0\u6587\u4EF6> \u751F\u6210\u89E3\u51B3\u8349\u6848\uFF1B\u6CBF\u7528\u672C\u6B21 --workspace/--dir/--env/--as\u3002pull \u4E0D\u4F1A\u66F4\u65B0\u670D\u52A1\u7AEF baseline\u3002\n");
10120
+ }
10121
+ writeResult(preview, args.output, [
10122
+ `workspace rebase preview: ${workspaceKey}`,
10123
+ `baselineHash: ${preview.baselineHash}`,
10124
+ `planDigest: ${preview.planDigest}`,
10125
+ `baseContentAvailable: false\uFF08\u57FA\u7EBF\u4EC5\u4FDD\u5B58\u6458\u8981\uFF0C\u672A\u63D0\u4F9B\u57FA\u7EBF\u6B63\u6587\uFF09`,
10126
+ `conflictCount: ${preview.conflictCount}`,
10127
+ ...preview.files.map((file) => JSON.stringify(file))
10128
+ ]);
10129
+ }
10130
+ function readPlan(value) {
10131
+ const data = record(value, "rebase plan");
10132
+ const planDigest = requiredText(data.planDigest, "planDigest");
10133
+ const reason = requiredText(data.reason, "reason");
10134
+ if (!Array.isArray(data.resolutions) || !data.resolutions.length) {
10135
+ throw new Error("resolutions \u5FC5\u987B\u5305\u542B\u81F3\u5C11\u4E00\u4E2A\u5DF2\u660E\u786E\u5904\u7406\u7684\u8DEF\u5F84\uFF1B\u5220\u9664\u6682\u4E0D\u5904\u7406\u7684\u884C\u3002");
10136
+ }
10137
+ const seen = /* @__PURE__ */ new Set();
10138
+ const resolutions = data.resolutions.map((raw) => {
10139
+ const item = record(raw, "resolution");
10140
+ const relativePath = filePath(item.relativePath);
10141
+ if (seen.has(relativePath)) throw new Error(`resolution \u8DEF\u5F84\u91CD\u590D\uFF1A${relativePath}`);
10142
+ seen.add(relativePath);
10143
+ if (typeof item.resolution !== "string" || !["TAKE_ACTIVE", "MERGED", "KEEP_WORKSPACE", "DELETE"].includes(item.resolution)) {
10144
+ throw new Error(`${relativePath}: resolution \u5FC5\u987B\u660E\u786E\u9009\u62E9 TAKE_ACTIVE / MERGED / KEEP_WORKSPACE / DELETE\uFF1B\u4E0D\u80FD\u63D0\u4EA4 UNRESOLVED\u3002`);
10145
+ }
10146
+ if (item.content !== void 0 && item.content !== null && typeof item.content !== "string") {
10147
+ throw new Error(`${relativePath}: content \u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u6216 null\u3002`);
10148
+ }
10149
+ const resolution = item.resolution;
10150
+ if (resolution === "MERGED" && typeof item.content !== "string") {
10151
+ throw new Error(`${relativePath}: MERGED \u5FC5\u987B\u586B\u5199\u5B57\u7B26\u4E32 content\uFF08\u7A7A\u4E32\u5408\u6CD5\uFF09\u3002`);
10152
+ }
10153
+ return { relativePath, resolution, ...resolution === "MERGED" ? { content: item.content } : {} };
10154
+ });
10155
+ return { planDigest, reason, resolutions };
10156
+ }
10157
+ function readPreview(data, workspaceKey) {
10158
+ if (data.workspaceKey !== workspaceKey || data.baseContentAvailable !== false || !Array.isArray(data.files) || !nonnegativeInteger(data.conflictCount)) throw new Error("preview-rebase \u8FD4\u56DE\u65E0\u6548\u7684\u5DE5\u4F5C\u533A\u3001\u57FA\u7EBF\u53EF\u7528\u6027\u6216\u51B2\u7A81\u6E05\u5355\u3002");
10159
+ requiredText(data.baselineHash, "preview-rebase baselineHash");
10160
+ requiredText(data.planDigest, "preview-rebase planDigest");
10161
+ const seen = /* @__PURE__ */ new Set();
10162
+ for (const raw of data.files) {
10163
+ const file = record(raw, "preview-rebase file");
10164
+ const relativePath = filePath(file.relativePath);
10165
+ if (seen.has(relativePath)) throw new Error(`preview-rebase \u8DEF\u5F84\u91CD\u590D\uFF1A${relativePath}`);
10166
+ seen.add(relativePath);
10167
+ for (const key2 of ["baseHash", "activeHash", "workspaceHash"]) {
10168
+ if (file[key2] !== null) requiredText(file[key2], `${relativePath}: ${key2}`);
10169
+ }
10170
+ if (typeof file.workspaceDeleted !== "boolean" || typeof file.conflict !== "boolean" || !nullableText(file.activeContent) || !nullableText(file.workspaceContent)) {
10171
+ throw new Error(`${relativePath}: preview-rebase \u6587\u4EF6\u72B6\u6001\u6216\u6B63\u6587\u7F3A\u5931\u3002`);
10172
+ }
10173
+ }
10174
+ if (data.files.filter((file) => file.conflict).length !== data.conflictCount) {
10175
+ throw new Error("preview-rebase conflictCount \u4E0E\u6587\u4EF6\u6E05\u5355\u4E0D\u4E00\u81F4\uFF0C\u4E0D\u80FD\u751F\u6210\u89E3\u51B3\u8BA1\u5212\u3002");
10176
+ }
10177
+ return data;
10178
+ }
10179
+ function actionPayload(value) {
10180
+ const response = record(value, "workspace action response");
10181
+ if (response.success === false) throw new Error("workspace action \u8FD4\u56DE\u5931\u8D25\uFF1B\u8BF7\u68C0\u67E5\u670D\u52A1\u7AEF\u54CD\u5E94\u540E\u91CD\u8BD5\u3002");
10182
+ return record(response.data ?? response.result ?? response, "workspace action payload");
10183
+ }
10184
+ function record(value, label) {
10185
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(`${label} \u5FC5\u987B\u662F\u5BF9\u8C61\u3002`);
10186
+ return value;
10187
+ }
10188
+ function requiredText(value, label) {
10189
+ if (typeof value !== "string" || !value.trim()) throw new Error(`${label} \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32\u3002`);
10190
+ return value;
10191
+ }
10192
+ function nullableText(value) {
10193
+ return value === null || typeof value === "string";
10194
+ }
10195
+ function nonnegativeInteger(value) {
10196
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
10197
+ }
10198
+ function filePath(value) {
10199
+ const text = requiredText(value, "relativePath");
10200
+ if (path9.isAbsolute(text) || text.includes("\\") || text.includes("\0") || /^[A-Za-z]:/.test(text) || text.split("/").some((part) => !part || part === "." || part === "..")) {
10201
+ throw new Error(`relativePath \u5FC5\u987B\u662F\u5B89\u5168\u7684\u76F8\u5BF9\u6587\u4EF6\u8DEF\u5F84\uFF1A${text}`);
10202
+ }
10203
+ return text;
10204
+ }
10205
+ function writeResult(result, format = "table", lines) {
10206
+ process.stdout.write((format === "table" ? lines.join("\n") : formatObject23(result, { format })) + "\n");
10207
+ }
10208
+
10068
10209
  // src/commands/workspace.ts
10069
10210
  var DEFAULT_FRONTEND_URL = "http://127.0.0.1:5179";
10070
10211
  var WORKSPACE_CONTEXT_FILE = "hcm.workspace.json";
@@ -10156,7 +10297,7 @@ async function workspaceBindCommand(workspaceKey, args) {
10156
10297
  tenantId: args.tenant ?? client3?.tenantId,
10157
10298
  endpoint: args.endpoint ?? client3?.endpoint
10158
10299
  });
10159
- await fs8.mkdir(rootDir, { recursive: true });
10300
+ await fs9.mkdir(rootDir, { recursive: true });
10160
10301
  await writeWorkspaceContext(rootDir, context);
10161
10302
  writeWorkspaceBindResult(context, rootDir, args.output ?? "table");
10162
10303
  process.exitCode = 0;
@@ -10193,7 +10334,7 @@ async function workspaceCreateCommand(workspaceKey, args) {
10193
10334
  tenantId: client3.tenantId,
10194
10335
  endpoint: client3.endpoint
10195
10336
  });
10196
- await fs8.mkdir(rootDir, { recursive: true });
10337
+ await fs9.mkdir(rootDir, { recursive: true });
10197
10338
  await writeWorkspaceContext(rootDir, context);
10198
10339
  writeWorkspaceCreateResult(
10199
10340
  {
@@ -10212,6 +10353,18 @@ async function workspaceCreateCommand(workspaceKey, args) {
10212
10353
  exitWorkspaceError(e, args.env ?? args.profile);
10213
10354
  }
10214
10355
  }
10356
+ async function workspaceRebaseCommand(args) {
10357
+ try {
10358
+ const existing = await readWorkspaceContext(resolveRootDir(args.dir));
10359
+ const workspaceKey = normalizeWorkspaceKey(args.workspace ?? existing?.workspaceKey ?? "");
10360
+ await runWorkspaceRebase(workspaceKey, args, async () => HcmClient23.fromAuthContext(
10361
+ await getActiveAuthContextFromCli(args, { fallbackEnv: existing?.profile })
10362
+ ));
10363
+ process.exitCode = 0;
10364
+ } catch (e) {
10365
+ exitWorkspaceError(e, args.env ?? args.profile);
10366
+ }
10367
+ }
10215
10368
  async function workspacePullCommand(args) {
10216
10369
  try {
10217
10370
  const rootDir = resolveRootDir(args.dir);
@@ -10231,7 +10384,7 @@ async function workspacePullCommand(args) {
10231
10384
  tenantId: client3.tenantId ?? existing?.tenantId,
10232
10385
  endpoint: client3.endpoint ?? existing?.endpoint
10233
10386
  });
10234
- await fs8.mkdir(rootDir, { recursive: true });
10387
+ await fs9.mkdir(rootDir, { recursive: true });
10235
10388
  await writeWorkspaceContext(rootDir, context);
10236
10389
  const files = await listWorkspaceFiles(client3.raw(), workspaceKey, { pageSize: 5e3 });
10237
10390
  const miniApps = detectRemoteMiniApps(files.data);
@@ -10241,7 +10394,7 @@ async function workspacePullCommand(args) {
10241
10394
  http: client3.raw(),
10242
10395
  appCode,
10243
10396
  workspaceKey,
10244
- targetDir: path9.join(rootDir, MINI_APPS_DIR, appCode),
10397
+ targetDir: path10.join(rootDir, MINI_APPS_DIR, appCode),
10245
10398
  tenantId: client3.tenantId,
10246
10399
  endpoint: client3.endpoint,
10247
10400
  profile: args.profile ?? client3.profile,
@@ -10256,7 +10409,7 @@ async function workspacePullCommand(args) {
10256
10409
  const rawRemoteByLocalPath = /* @__PURE__ */ new Map();
10257
10410
  for (const file of rawFiles) {
10258
10411
  const content = await loadWorkspaceFileContent(client3.raw(), file.id);
10259
- const target = path9.join(rootDir, content.relativePath);
10412
+ const target = path10.join(rootDir, content.relativePath);
10260
10413
  await writeTextFile(target, content.content, !!args.force);
10261
10414
  pulledRawFiles.push(content.relativePath);
10262
10415
  rawRemoteByLocalPath.set(content.relativePath, file);
@@ -10307,7 +10460,7 @@ async function workspaceAddMiniCommand(appCode, args) {
10307
10460
  const result = await initMiniAppProject({
10308
10461
  appCode,
10309
10462
  workspaceKey: context.workspaceKey,
10310
- targetDir: path9.join(rootDir, MINI_APPS_DIR, appCode),
10463
+ targetDir: path10.join(rootDir, MINI_APPS_DIR, appCode),
10311
10464
  name: args.name,
10312
10465
  runtimeSdkVersion: args.sdkVersion,
10313
10466
  defaultSurface: parseSurface(args.surface),
@@ -10334,10 +10487,10 @@ async function workspaceRmCommand(relativePath, args) {
10334
10487
  const rootDir = resolveRootDir(args.dir);
10335
10488
  const context = await requireWorkspaceContext(rootDir);
10336
10489
  const normalized = normalizeWorkspaceRmPath(relativePath);
10337
- const absolutePath = path9.join(rootDir, ...normalized.split("/"));
10490
+ const absolutePath = path10.join(rootDir, ...normalized.split("/"));
10338
10491
  let stat;
10339
10492
  try {
10340
- stat = await fs8.lstat(absolutePath);
10493
+ stat = await fs9.lstat(absolutePath);
10341
10494
  } catch (e) {
10342
10495
  if (e.code !== "ENOENT") throw e;
10343
10496
  stat = null;
@@ -10377,7 +10530,7 @@ async function workspaceRmCommand(relativePath, args) {
10377
10530
  if (!stat) {
10378
10531
  if (manifestEntry) {
10379
10532
  process.stdout.write(
10380
- formatObject23(
10533
+ formatObject24(
10381
10534
  {
10382
10535
  workspaceKey: context.workspaceKey,
10383
10536
  file: normalized,
@@ -10393,7 +10546,7 @@ async function workspaceRmCommand(relativePath, args) {
10393
10546
  }
10394
10547
  throw new Error(`workspace file not found locally or in the workspace: ${normalized}`);
10395
10548
  }
10396
- await fs8.unlink(absolutePath);
10549
+ await fs9.unlink(absolutePath);
10397
10550
  const result = {
10398
10551
  workspaceKey: context.workspaceKey,
10399
10552
  file: normalized,
@@ -10402,7 +10555,7 @@ async function workspaceRmCommand(relativePath, args) {
10402
10555
  next: `hcm workspace push --dir ${args.dir ?? "."}`
10403
10556
  };
10404
10557
  if (args.output === "json" || args.output === "yaml") {
10405
- process.stdout.write(formatObject23(result, { format: args.output }) + "\n");
10558
+ process.stdout.write(formatObject24(result, { format: args.output }) + "\n");
10406
10559
  } else {
10407
10560
  process.stdout.write(`workspace file staged for deletion: ${normalized}
10408
10561
  `);
@@ -10449,7 +10602,7 @@ async function workspaceStatusCommand(args) {
10449
10602
  }
10450
10603
  if (args.output === "json" || args.output === "yaml") {
10451
10604
  process.stdout.write(
10452
- formatObject23({ rootDir, miniApps: rows2 }, { format: args.output }) + "\n"
10605
+ formatObject24({ rootDir, miniApps: rows2 }, { format: args.output }) + "\n"
10453
10606
  );
10454
10607
  } else {
10455
10608
  process.stdout.write(formatRows6(rows2, { format: "table" }) + "\n");
@@ -10465,7 +10618,7 @@ async function workspaceValidateCommand(args) {
10465
10618
  const rootDir = resolveRootDir(args.dir);
10466
10619
  await requireWorkspaceContext(rootDir);
10467
10620
  const miniApps = await discoverMiniApps(rootDir);
10468
- const metaFiles = await readWorkspaceRawLocalFiles(path9.join(rootDir, "metas"));
10621
+ const metaFiles = await readWorkspaceRawLocalFiles(path10.join(rootDir, "metas"));
10469
10622
  const metaResults = metaFiles.filter((file) => /\.ya?ml$/i.test(file.localPath)).map((file) => {
10470
10623
  const artifact = `meta:metas/${file.localPath}`;
10471
10624
  const validation = validateMetaContent2(`metas/${file.localPath}`, file.content);
@@ -10597,7 +10750,7 @@ async function workspacePreviewCommand(args) {
10597
10750
  );
10598
10751
  }
10599
10752
  if (args.output === "json" || args.output === "yaml") {
10600
- process.stdout.write(formatObject23(rows2, { format: args.output }) + "\n");
10753
+ process.stdout.write(formatObject24(rows2, { format: args.output }) + "\n");
10601
10754
  } else {
10602
10755
  process.stdout.write(formatRows6(rows2, { format: "table" }) + "\n");
10603
10756
  }
@@ -10715,11 +10868,11 @@ function removedMiniCommand() {
10715
10868
  );
10716
10869
  }
10717
10870
  function resolveRootDir(dir) {
10718
- return path9.resolve(dir ?? ".");
10871
+ return path10.resolve(dir ?? ".");
10719
10872
  }
10720
10873
  async function workspacePathExists(file) {
10721
10874
  try {
10722
- await fs8.access(file);
10875
+ await fs9.access(file);
10723
10876
  return true;
10724
10877
  } catch (e) {
10725
10878
  if (e.code === "ENOENT") return false;
@@ -10727,16 +10880,16 @@ async function workspacePathExists(file) {
10727
10880
  }
10728
10881
  }
10729
10882
  async function assertWorkspacePushRoot(rootDir) {
10730
- const realRoot = await fs8.realpath(rootDir);
10883
+ const realRoot = await fs9.realpath(rootDir);
10731
10884
  let workspaceRoot;
10732
10885
  let insideMiniApp = false;
10733
10886
  let dir = realRoot;
10734
10887
  for (; ; ) {
10735
- const parent = path9.dirname(dir);
10736
- const appsDir = path9.basename(dir) === MINI_APPS_DIR ? dir : path9.basename(parent) === MINI_APPS_DIR ? parent : void 0;
10737
- const miniDir = appsDir !== void 0 && (await workspacePathExists(path9.join(path9.dirname(appsDir), WORKSPACE_CONTEXT_FILE)) || appsDir === parent && await workspacePathExists(path9.join(dir, "manifest.json"))) || await workspacePathExists(path9.join(dir, MINI_CONTEXT_FILE)) || await workspacePathExists(path9.join(dir, MINI_STATE_DIR, MINI_PULL_MANIFEST_FILE));
10888
+ const parent = path10.dirname(dir);
10889
+ const appsDir = path10.basename(dir) === MINI_APPS_DIR ? dir : path10.basename(parent) === MINI_APPS_DIR ? parent : void 0;
10890
+ const miniDir = appsDir !== void 0 && (await workspacePathExists(path10.join(path10.dirname(appsDir), WORKSPACE_CONTEXT_FILE)) || appsDir === parent && await workspacePathExists(path10.join(dir, "manifest.json"))) || await workspacePathExists(path10.join(dir, MINI_CONTEXT_FILE)) || await workspacePathExists(path10.join(dir, MINI_STATE_DIR, MINI_PULL_MANIFEST_FILE));
10738
10891
  insideMiniApp ||= miniDir;
10739
- if (!miniDir && await workspacePathExists(path9.join(dir, WORKSPACE_CONTEXT_FILE))) {
10892
+ if (!miniDir && await workspacePathExists(path10.join(dir, WORKSPACE_CONTEXT_FILE))) {
10740
10893
  workspaceRoot = dir;
10741
10894
  break;
10742
10895
  }
@@ -10767,7 +10920,7 @@ function buildWorkspaceContext(args) {
10767
10920
  async function readWorkspaceContext(rootDir) {
10768
10921
  try {
10769
10922
  const parsed = JSON.parse(
10770
- await fs8.readFile(path9.join(rootDir, WORKSPACE_CONTEXT_FILE), "utf-8")
10923
+ await fs9.readFile(path10.join(rootDir, WORKSPACE_CONTEXT_FILE), "utf-8")
10771
10924
  );
10772
10925
  if (parsed.kind !== WORKSPACE_CONTEXT_KIND || parsed.version !== WORKSPACE_CONTEXT_VERSION) {
10773
10926
  throw new Error(`${WORKSPACE_CONTEXT_FILE} is not an HCM workspace context`);
@@ -10796,26 +10949,26 @@ async function requireWorkspaceContext(rootDir) {
10796
10949
  return context;
10797
10950
  }
10798
10951
  async function writeWorkspaceContext(rootDir, context) {
10799
- await fs8.writeFile(
10800
- path9.join(rootDir, WORKSPACE_CONTEXT_FILE),
10952
+ await fs9.writeFile(
10953
+ path10.join(rootDir, WORKSPACE_CONTEXT_FILE),
10801
10954
  JSON.stringify(context, null, 2) + "\n"
10802
10955
  );
10803
10956
  }
10804
10957
  async function writeTextFile(file, content, force) {
10805
10958
  try {
10806
- await fs8.access(file);
10959
+ await fs9.access(file);
10807
10960
  if (!force) throw new Error(`${file} already exists; use --force to overwrite`);
10808
10961
  } catch (e) {
10809
10962
  if (e.code !== "ENOENT") throw e;
10810
10963
  }
10811
- await fs8.mkdir(path9.dirname(file), { recursive: true });
10812
- await fs8.writeFile(file, content);
10964
+ await fs9.mkdir(path10.dirname(file), { recursive: true });
10965
+ await fs9.writeFile(file, content);
10813
10966
  }
10814
10967
  async function readWorkspaceRawManifest(rootDir, context) {
10815
10968
  try {
10816
10969
  const parsed = JSON.parse(
10817
- await fs8.readFile(
10818
- path9.join(rootDir, WORKSPACE_STATE_DIR, WORKSPACE_PULL_MANIFEST_FILE),
10970
+ await fs9.readFile(
10971
+ path10.join(rootDir, WORKSPACE_STATE_DIR, WORKSPACE_PULL_MANIFEST_FILE),
10819
10972
  "utf-8"
10820
10973
  )
10821
10974
  );
@@ -10837,8 +10990,8 @@ async function readWorkspaceRawManifest(rootDir, context) {
10837
10990
  }
10838
10991
  }
10839
10992
  async function writeWorkspaceRawState(rootDir, context, files, remoteByLocalPath) {
10840
- const stateDir = path9.join(rootDir, WORKSPACE_STATE_DIR);
10841
- await fs8.mkdir(stateDir, { recursive: true });
10993
+ const stateDir = path10.join(rootDir, WORKSPACE_STATE_DIR);
10994
+ await fs9.mkdir(stateDir, { recursive: true });
10842
10995
  const snapshots = files.map(
10843
10996
  (file) => ({
10844
10997
  localPath: file.localPath,
@@ -10849,8 +11002,8 @@ async function writeWorkspaceRawState(rootDir, context, files, remoteByLocalPath
10849
11002
  lastModified: remoteByLocalPath.get(file.localPath)?.lastModified
10850
11003
  })
10851
11004
  );
10852
- await fs8.writeFile(
10853
- path9.join(stateDir, WORKSPACE_PULL_MANIFEST_FILE),
11005
+ await fs9.writeFile(
11006
+ path10.join(stateDir, WORKSPACE_PULL_MANIFEST_FILE),
10854
11007
  JSON.stringify(
10855
11008
  {
10856
11009
  version: WORKSPACE_CONTEXT_VERSION,
@@ -10866,15 +11019,15 @@ async function writeWorkspaceRawState(rootDir, context, files, remoteByLocalPath
10866
11019
  );
10867
11020
  }
10868
11021
  async function writeWorkspaceRawManifest(rootDir, manifest2) {
10869
- const stateDir = path9.join(rootDir, WORKSPACE_STATE_DIR);
10870
- await fs8.mkdir(stateDir, { recursive: true });
10871
- const target = path9.join(stateDir, WORKSPACE_PULL_MANIFEST_FILE);
11022
+ const stateDir = path10.join(rootDir, WORKSPACE_STATE_DIR);
11023
+ await fs9.mkdir(stateDir, { recursive: true });
11024
+ const target = path10.join(stateDir, WORKSPACE_PULL_MANIFEST_FILE);
10872
11025
  const temporary = `${target}.${crypto.randomUUID()}.tmp`;
10873
11026
  try {
10874
- await fs8.writeFile(temporary, JSON.stringify(manifest2, null, 2) + "\n", { encoding: "utf8", flag: "wx" });
10875
- await fs8.rename(temporary, target);
11027
+ await fs9.writeFile(temporary, JSON.stringify(manifest2, null, 2) + "\n", { encoding: "utf8", flag: "wx" });
11028
+ await fs9.rename(temporary, target);
10876
11029
  } finally {
10877
- await fs8.rm(temporary, { force: true });
11030
+ await fs9.rm(temporary, { force: true });
10878
11031
  }
10879
11032
  }
10880
11033
  async function readWorkspaceRawLocalFiles(rootDir) {
@@ -10884,10 +11037,10 @@ async function readWorkspaceRawLocalFiles(rootDir) {
10884
11037
  return files;
10885
11038
  }
10886
11039
  async function walkWorkspaceRawFiles(rootDir, relativeDir, files) {
10887
- const absoluteDir = path9.join(rootDir, relativeDir);
11040
+ const absoluteDir = path10.join(rootDir, relativeDir);
10888
11041
  let entries;
10889
11042
  try {
10890
- entries = await fs8.readdir(absoluteDir, { withFileTypes: true });
11043
+ entries = await fs9.readdir(absoluteDir, { withFileTypes: true });
10891
11044
  } catch (e) {
10892
11045
  if (e.code === "ENOENT") return;
10893
11046
  throw e;
@@ -10895,14 +11048,14 @@ async function walkWorkspaceRawFiles(rootDir, relativeDir, files) {
10895
11048
  for (const entry of entries) {
10896
11049
  if (entry.isDirectory() && RAW_WORKSPACE_EXCLUDED_DIRS.has(entry.name)) continue;
10897
11050
  if (entry.isFile() && RAW_WORKSPACE_EXCLUDED_FILES.has(entry.name)) continue;
10898
- const localPath = normalizeRelativePath(path9.posix.join(toPosix(relativeDir), entry.name));
10899
- const absolutePath = path9.join(rootDir, localPath);
11051
+ const localPath = normalizeRelativePath(path10.posix.join(toPosix(relativeDir), entry.name));
11052
+ const absolutePath = path10.join(rootDir, localPath);
10900
11053
  if (entry.isDirectory()) {
10901
11054
  await walkWorkspaceRawFiles(rootDir, localPath, files);
10902
11055
  continue;
10903
11056
  }
10904
11057
  if (!entry.isFile()) continue;
10905
- const content = await fs8.readFile(absolutePath, "utf-8");
11058
+ const content = await fs9.readFile(absolutePath, "utf-8");
10906
11059
  files.push({
10907
11060
  localPath,
10908
11061
  absolutePath,
@@ -11312,15 +11465,15 @@ function workspaceRawConflict(entry, reason) {
11312
11465
  };
11313
11466
  }
11314
11467
  async function discoverMiniApps(rootDir) {
11315
- const appsRoot = path9.join(rootDir, MINI_APPS_DIR);
11468
+ const appsRoot = path10.join(rootDir, MINI_APPS_DIR);
11316
11469
  let entries;
11317
11470
  try {
11318
- entries = await fs8.readdir(appsRoot, { withFileTypes: true });
11471
+ entries = await fs9.readdir(appsRoot, { withFileTypes: true });
11319
11472
  } catch (e) {
11320
11473
  if (e.code === "ENOENT") return [];
11321
11474
  throw e;
11322
11475
  }
11323
- return entries.filter((entry) => entry.isDirectory()).map((entry) => ({ appCode: entry.name, dir: path9.join(appsRoot, entry.name) })).sort((a, b) => a.appCode.localeCompare(b.appCode));
11476
+ return entries.filter((entry) => entry.isDirectory()).map((entry) => ({ appCode: entry.name, dir: path10.join(appsRoot, entry.name) })).sort((a, b) => a.appCode.localeCompare(b.appCode));
11324
11477
  }
11325
11478
  function detectRemoteMiniApps(files) {
11326
11479
  const appCodes = /* @__PURE__ */ new Set();
@@ -11463,7 +11616,7 @@ function normalizeWorkspaceKey(value) {
11463
11616
  return key2;
11464
11617
  }
11465
11618
  function normalizeWorkspaceRmPath(value) {
11466
- if (path9.isAbsolute(value) || /^[A-Za-z]:[\\/]/.test(value)) {
11619
+ if (path10.isAbsolute(value) || /^[A-Za-z]:[\\/]/.test(value)) {
11467
11620
  throw new Error("workspace rm path must be relative to the bound workspace");
11468
11621
  }
11469
11622
  const normalized = normalizeRelativePath(value);
@@ -11485,7 +11638,7 @@ function normalizeRelativePath(value) {
11485
11638
  return normalized;
11486
11639
  }
11487
11640
  function toPosix(value) {
11488
- return value.split(path9.sep).join("/");
11641
+ return value.split(path10.sep).join("/");
11489
11642
  }
11490
11643
  function sha2563(content) {
11491
11644
  return crypto.createHash("sha256").update(content, "utf-8").digest("hex");
@@ -11513,7 +11666,7 @@ function optionalText(value) {
11513
11666
  }
11514
11667
  function writeWorkspaceListResult(rows2, format, total) {
11515
11668
  if (format !== "table") {
11516
- process.stdout.write(formatObject23({ rows: rows2, total }, { format }) + "\n");
11669
+ process.stdout.write(formatObject24({ rows: rows2, total }, { format }) + "\n");
11517
11670
  return;
11518
11671
  }
11519
11672
  process.stdout.write(formatRows6(toWorkspaceListRows(rows2), { format: "table" }) + "\n");
@@ -11524,7 +11677,7 @@ function writeWorkspaceListResult(rows2, format, total) {
11524
11677
  }
11525
11678
  function writeWorkspaceActiveResult(view, format) {
11526
11679
  if (format !== "table") {
11527
- process.stdout.write(formatObject23(view, { format }) + "\n");
11680
+ process.stdout.write(formatObject24(view, { format }) + "\n");
11528
11681
  return;
11529
11682
  }
11530
11683
  const rows2 = [
@@ -11549,7 +11702,7 @@ function writeWorkspaceActiveResult(view, format) {
11549
11702
  }
11550
11703
  function writeWorkspaceBindResult(context, rootDir, format) {
11551
11704
  if (format !== "table") {
11552
- process.stdout.write(formatObject23({ ...context, rootDir }, { format }) + "\n");
11705
+ process.stdout.write(formatObject24({ ...context, rootDir }, { format }) + "\n");
11553
11706
  return;
11554
11707
  }
11555
11708
  process.stdout.write(
@@ -11563,7 +11716,7 @@ function writeWorkspaceBindResult(context, rootDir, format) {
11563
11716
  }
11564
11717
  function writeWorkspaceCreateResult(result, format) {
11565
11718
  if (format !== "table") {
11566
- process.stdout.write(formatObject23(result, { format }) + "\n");
11719
+ process.stdout.write(formatObject24(result, { format }) + "\n");
11567
11720
  return;
11568
11721
  }
11569
11722
  process.stdout.write(
@@ -11579,7 +11732,7 @@ function writeWorkspaceCreateResult(result, format) {
11579
11732
  }
11580
11733
  function writeWorkspacePullResult(result, format) {
11581
11734
  if (format !== "table") {
11582
- process.stdout.write(formatObject23(result, { format }) + "\n");
11735
+ process.stdout.write(formatObject24(result, { format }) + "\n");
11583
11736
  return;
11584
11737
  }
11585
11738
  const lines = [
@@ -11597,7 +11750,7 @@ function writeWorkspacePullResult(result, format) {
11597
11750
  }
11598
11751
  function writeWorkspaceAddMiniResult(result, rootDir, format) {
11599
11752
  if (format !== "table") {
11600
- process.stdout.write(formatObject23({ ...result, workspaceRoot: rootDir }, { format }) + "\n");
11753
+ process.stdout.write(formatObject24({ ...result, workspaceRoot: rootDir }, { format }) + "\n");
11601
11754
  return;
11602
11755
  }
11603
11756
  process.stdout.write(
@@ -11613,7 +11766,7 @@ function writeWorkspaceAddMiniResult(result, rootDir, format) {
11613
11766
  function writeWorkspaceValidateResult(results, format) {
11614
11767
  if (format !== "table") {
11615
11768
  process.stdout.write(
11616
- formatObject23(
11769
+ formatObject24(
11617
11770
  results.map((item) => ({ artifact: item.artifact, ...item.result })),
11618
11771
  { format }
11619
11772
  ) + "\n"
@@ -11641,7 +11794,7 @@ ${item.artifact}
11641
11794
  function writeWorkspacePushResult(rawResult, results, format) {
11642
11795
  if (format !== "table") {
11643
11796
  process.stdout.write(
11644
- formatObject23(
11797
+ formatObject24(
11645
11798
  {
11646
11799
  // 预检覆盖整份计划(workspace 文件 + 轻应用文件),放在顶层。
11647
11800
  preflight: rawResult.preflight ?? null,
@@ -11706,7 +11859,7 @@ function writeWorkspaceVerifyResult(context, rootDir, raw, reports, format) {
11706
11859
  const preflight = raw.plan?.preflight ?? null;
11707
11860
  if (format === "json") {
11708
11861
  process.stdout.write(
11709
- formatObject23(
11862
+ formatObject24(
11710
11863
  {
11711
11864
  ok,
11712
11865
  workspaceKey: context.workspaceKey,
@@ -11734,7 +11887,7 @@ function writeWorkspaceVerifyResult(context, rootDir, raw, reports, format) {
11734
11887
  }
11735
11888
  if (format !== "table") {
11736
11889
  process.stdout.write(
11737
- formatObject23(
11890
+ formatObject24(
11738
11891
  {
11739
11892
  ok,
11740
11893
  workspaceKey: context.workspaceKey,
@@ -11795,6 +11948,7 @@ function exitWorkspaceError(err, profile, operation) {
11795
11948
  const scope = `${profile ? ` --env ${quoteWorkspaceArg(profile)}` : ""}${operation.as ? ` --as ${quoteWorkspaceArg(operation.as)}` : ""}`;
11796
11949
  const active = "hcm workspace active" + scope + (operation.dir ? ` --dir ${quoteWorkspaceArg(operation.dir)}` : "");
11797
11950
  const deployment = translated.context.responseCode === "DEPLOY_IN_PROGRESS" ? `\u6709\u53D1\u5E03\u67E5\u8BE2\u6743\u9650\u65F6\uFF0C\u6267\u884C hcm query TenantExtensionRelease --fields id,workspaceKey,deploymentStatus --limit 20${scope} \u67E5\u770B\u53EF\u89C1\u90E8\u7F72\u8BB0\u5F55\uFF1B\u7A7A\u7ED3\u679C\u4E0D\u80FD\u8BC1\u660E\u9501\u5DF2\u91CA\u653E\u3002` : void 0;
11951
+ const rebase = translated.context.responseCode === "WORKSPACE_REVISION_CONFLICT" ? `\u82E5\u670D\u52A1\u7AEF\u8BE6\u60C5\u786E\u8BA4 workspace \u4E0E active \u7684\u4FEE\u8BA2\u51B2\u7A81\uFF0C\u6267\u884C hcm workspace rebase --workspace ${quoteWorkspaceArg(operation.workspaceKey)} --dry-run${scope}\uFF0C\u518D\u7528 --dry-run --plan '<\u65B0\u8BA1\u5212\u6587\u4EF6>' \u751F\u6210\u9010\u8DEF\u5F84\u89E3\u51B3\u8349\u6848\u3002pull \u53EA\u6062\u590D\u672C\u5730\u5FEB\u7167\uFF0C\u4E0D\u66F4\u65B0\u670D\u52A1\u7AEF baseline\uFF1B\u4E0D\u8981\u5220\u9664\u91CD\u5EFA\u6587\u4EF6\u6216\u6574\u4E2A\u5F00\u53D1\u7A7A\u95F4\u6765\u5237\u65B0\u57FA\u7EBF\u3002` : void 0;
11798
11952
  const retry = operation.command === "activate" ? `\u6309\u670D\u52A1\u7AEF\u8BE6\u60C5\u5B8C\u6210\u5904\u7406\u5E76\u786E\u8BA4\u76EE\u6807\u5DE5\u4F5C\u533A\u540E\uFF0C\u518D\u6267\u884C hcm workspace activate ${quoteWorkspaceArg(operation.workspaceKey)}${scope}\u3002` : `\u4FDD\u7559\u672C\u5730\u76EE\u5F55 ${operation.dir}\uFF1B\u6267\u884C hcm workspace pull --workspace ${quoteWorkspaceArg(operation.workspaceKey)} --dir '<\u65B0\u7684\u7A7A\u76EE\u5F55>'${scope}\uFF0C\u6BD4\u5BF9\u540E\u628A\u5F85\u4FDD\u7559\u4FEE\u6539\uFF08\u542B\u5220\u9664\u610F\u56FE\uFF09\u5408\u5E76\u5230\u65B0\u76EE\u5F55\uFF0C\u518D\u6267\u884C hcm workspace push --dir '<\u65B0\u7684\u7A7A\u76EE\u5F55>' --dry-run${scope}\uFF0C\u6838\u5BF9\u8BA1\u5212\u540E\u5728\u65B0\u76EE\u5F55\u53BB\u6389 --dry-run \u63A8\u9001\u3002\u539F\u76EE\u5F55\u4FDD\u7559\u5907\u4EFD\uFF0C\u4E0D\u8981\u8986\u76D6\u6216\u7EE7\u7EED\u4F7F\u7528\u65E7\u57FA\u7EBF\u63A8\u9001\u3002`;
11799
11953
  exitWithError(new CliError26({
11800
11954
  code: translated.code,
@@ -11805,7 +11959,7 @@ function exitWorkspaceError(err, profile, operation) {
11805
11959
  context: {
11806
11960
  ...translated.context,
11807
11961
  workspaceKey: operation.workspaceKey,
11808
- nextStep: [translated.context.nextStep, `\u5148\u6267\u884C ${active} \u6838\u5BF9\u5F53\u524D\u8EAB\u4EFD\u7684\u5F00\u53D1\u6001\u7ED1\u5B9A\uFF08\u8BE5\u547D\u4EE4\u4E0D\u67E5\u8BE2\u90E8\u7F72\u8FDB\u5EA6\uFF09\u3002`, deployment, retry].filter(Boolean).join(" ")
11962
+ nextStep: [translated.context.nextStep, `\u5148\u6267\u884C ${active} \u6838\u5BF9\u5F53\u524D\u8EAB\u4EFD\u7684\u5F00\u53D1\u6001\u7ED1\u5B9A\uFF08\u8BE5\u547D\u4EE4\u4E0D\u67E5\u8BE2\u90E8\u7F72\u8FDB\u5EA6\uFF09\u3002`, deployment, rebase, retry].filter(Boolean).join(" ")
11809
11963
  }
11810
11964
  }));
11811
11965
  }
@@ -11888,7 +12042,7 @@ async function workspaceActivateCommand(workspaceKey, args) {
11888
12042
  process.stdout.write("\u8BE5\u7A7A\u95F4\u7684 metas / scripts / menus / mini_apps \u73B0\u5DF2\u5728\u5F53\u524D\u79DF\u6237\u751F\u6548\u3002\n");
11889
12043
  } else {
11890
12044
  process.stdout.write(
11891
- formatObject23({ workspaceKey: key2, activated: true }, { format: fmt }) + "\n"
12045
+ formatObject24({ workspaceKey: key2, activated: true }, { format: fmt }) + "\n"
11892
12046
  );
11893
12047
  }
11894
12048
  process.exitCode = 0;
@@ -11907,7 +12061,7 @@ async function workspaceDeactivateCommand(args) {
11907
12061
  process.stdout.write("workspace deactivated\n");
11908
12062
  process.stdout.write("\u5F53\u524D\u8EAB\u4EFD\u5DF2\u9000\u51FA\u5F00\u53D1\u8005\u6A21\u5F0F\uFF1B\u5F00\u53D1\u7A7A\u95F4\u3001\u672C\u5730\u6587\u4EF6\u4E0E\u5DF2\u53D1\u5E03\u8D44\u4EA7\u5747\u672A\u5220\u9664\u3002\n");
11909
12063
  } else {
11910
- process.stdout.write(formatObject23(result, { format: fmt }) + "\n");
12064
+ process.stdout.write(formatObject24(result, { format: fmt }) + "\n");
11911
12065
  }
11912
12066
  process.exitCode = 0;
11913
12067
  return;
@@ -11923,7 +12077,7 @@ import {
11923
12077
  AUTH_INFO_PATH,
11924
12078
  CliError as CliError27,
11925
12079
  CliErrorCode as CliErrorCode28,
11926
- formatObject as formatObject24,
12080
+ formatObject as formatObject25,
11927
12081
  formatRows as formatRows7,
11928
12082
  fromAxiosError as fromAxiosError24,
11929
12083
  loadEnv as loadEnv4,
@@ -11978,7 +12132,7 @@ async function inspectIdentity(name, fetcher = fetchAuthInfo) {
11978
12132
  async function identityShow(name, args) {
11979
12133
  try {
11980
12134
  const details = await inspectIdentity(name);
11981
- return exitOk(formatObject24(details, { format: args.output ?? "json" }));
12135
+ return exitOk(formatObject25(details, { format: args.output ?? "json" }));
11982
12136
  } catch (e) {
11983
12137
  exitWithError(axios5.isAxiosError(e) ? fromAxiosError24(e, name) : e);
11984
12138
  }
@@ -11990,7 +12144,7 @@ async function identityList(args) {
11990
12144
  const names = await listIdentities4(filter);
11991
12145
  const fmt = args.output ?? "table";
11992
12146
  if (names.length === 0) {
11993
- return exitOk(fmt === "table" ? "(no identities)" : formatObject24([], { format: fmt }));
12147
+ return exitOk(fmt === "table" ? "(no identities)" : formatObject25([], { format: fmt }));
11994
12148
  }
11995
12149
  const rows2 = [];
11996
12150
  for (const n of names) {
@@ -12004,7 +12158,7 @@ async function identityList(args) {
12004
12158
  isDefault: env2?.defaultIdentity === n
12005
12159
  });
12006
12160
  }
12007
- return exitOk(fmt === "table" ? formatRows7(rows2, { format: fmt }) : formatObject24(rows2, { format: fmt }));
12161
+ return exitOk(fmt === "table" ? formatRows7(rows2, { format: fmt }) : formatObject25(rows2, { format: fmt }));
12008
12162
  } catch (e) {
12009
12163
  exitWithError(e);
12010
12164
  }
@@ -12051,14 +12205,14 @@ async function identityRemove(name) {
12051
12205
  // src/commands/chiron-init.ts
12052
12206
  init_auth_guard();
12053
12207
  init_exit();
12054
- import { promises as fs9 } from "fs";
12055
- import path10 from "path";
12208
+ import { promises as fs10 } from "fs";
12209
+ import path11 from "path";
12056
12210
  import {
12057
12211
  CliError as CliError28,
12058
12212
  CliErrorCode as CliErrorCode29,
12059
12213
  HcmClient as HcmClient24,
12060
12214
  fetchReconIdentity,
12061
- formatObject as formatObject25,
12215
+ formatObject as formatObject26,
12062
12216
  httpProbe,
12063
12217
  isTempEnv as isTempEnv3,
12064
12218
  assertNotReservedEnvName as assertNotReservedEnvName2,
@@ -12113,7 +12267,7 @@ async function resolveInitEnv(root, args, deps) {
12113
12267
  };
12114
12268
  }
12115
12269
  const existing = await discoverProjectEnv5(root);
12116
- if (existing && path10.dirname(existing.path) === path10.resolve(root)) {
12270
+ if (existing && path11.dirname(existing.path) === path11.resolve(root)) {
12117
12271
  const name2 = args.env ?? existing.config.default;
12118
12272
  const env2 = existing.config.environments[name2];
12119
12273
  if (!env2) throw new CliError28({
@@ -12164,8 +12318,8 @@ ${explicitPaths}` }
12164
12318
  }
12165
12319
  async function scaffoldChironProject(root, env2, envName) {
12166
12320
  const result = { created: [], updated: [], preserved: [] };
12167
- const envFile = path10.join(root, ENV_FILE);
12168
- const existing = await fs9.readFile(envFile, "utf8").catch(() => null);
12321
+ const envFile = path11.join(root, ENV_FILE);
12322
+ const existing = await fs10.readFile(envFile, "utf8").catch(() => null);
12169
12323
  if (existing !== null) {
12170
12324
  const document2 = parseEnvYaml(existing);
12171
12325
  const recorded = Object.values(document2.environments).find((candidate) => candidate.endpoint === env2.endpoint && candidate.tenant === env2.tenant) ?? document2.environments[document2.default];
@@ -12192,13 +12346,13 @@ async function scaffoldChironProject(root, env2, envName) {
12192
12346
  context: { nextStep: "\u6362\u4E00\u4E2A\u6CA1\u6709\u9996\u5C3E\u7A7A\u767D\u7684\u73AF\u5883\u540D\uFF0C\u518D\u8FD0\u884C hcm chiron init --env <\u73AF\u5883\u540D>\uFF08\u6216 hcm chiron init --endpoint <\u540E\u7AEF\u5730\u5740> --env <\u73AF\u5883\u540D>\uFF09" }
12193
12347
  });
12194
12348
  assertNotReservedEnvName2(envName);
12195
- await fs9.writeFile(
12349
+ await fs10.writeFile(
12196
12350
  envFile,
12197
12351
  renderEnvYaml({ default: envName, environments: { [envName]: env2 } }),
12198
12352
  { encoding: "utf8", mode: 420, flag: "wx" }
12199
12353
  );
12200
12354
  try {
12201
- const written = parseEnvYaml(await fs9.readFile(envFile, "utf8"));
12355
+ const written = parseEnvYaml(await fs10.readFile(envFile, "utf8"));
12202
12356
  if (written.default !== envName || Object.keys(written.environments).length !== 1 || !Object.hasOwn(written.environments, envName)) {
12203
12357
  throw new CliError28({
12204
12358
  code: CliErrorCode29.CONFIG_PARSE_ERROR,
@@ -12207,20 +12361,20 @@ async function scaffoldChironProject(root, env2, envName) {
12207
12361
  });
12208
12362
  }
12209
12363
  } catch (error) {
12210
- await fs9.rm(envFile);
12364
+ await fs10.rm(envFile);
12211
12365
  throw error;
12212
12366
  }
12213
12367
  result.created.push(ENV_FILE);
12214
12368
  }
12215
12369
  for (const directory of CHIRON_PROJECT_DIRECTORIES) {
12216
- const absolute = path10.join(root, directory);
12370
+ const absolute = path11.join(root, directory);
12217
12371
  await ensureDirectory(absolute);
12218
- await writeIfAbsent(path10.join(absolute, ".gitkeep"), "", result, `${directory}/.gitkeep`);
12372
+ await writeIfAbsent(path11.join(absolute, ".gitkeep"), "", result, `${directory}/.gitkeep`);
12219
12373
  }
12220
12374
  return result;
12221
12375
  }
12222
12376
  async function runChironInit(args, deps = defaultChironInitDeps) {
12223
- const root = path10.resolve(args.project ?? ".");
12377
+ const root = path11.resolve(args.project ?? ".");
12224
12378
  const say = (line) => process.stderr.write(`[chiron init] ${line}
12225
12379
  `);
12226
12380
  const choice = await resolveInitEnv(root, args, deps);
@@ -12279,7 +12433,7 @@ async function chironInitCommand(args, deps) {
12279
12433
  const result = await runChironInit(args, deps);
12280
12434
  const fmt = args.output ?? "table";
12281
12435
  if (fmt === "json" || fmt === "yaml") {
12282
- process.stdout.write(formatObject25(result, { format: fmt }) + "\n");
12436
+ process.stdout.write(formatObject26(result, { format: fmt }) + "\n");
12283
12437
  } else {
12284
12438
  const mark = { verified: "\u2705", mismatch: "\u274C", unreachable: "\u26A0\uFE0F", skipped: "\xB7" }[result.tenantCheck.status];
12285
12439
  process.stdout.write(
@@ -12303,7 +12457,7 @@ import { readFileSync as readFileSync6 } from "fs";
12303
12457
  import {
12304
12458
  CliErrorCode as CliErrorCode31,
12305
12459
  createHttpClient as createHttpClient4,
12306
- formatObject as formatObject26,
12460
+ formatObject as formatObject27,
12307
12461
  loadGlobalConfig as loadGlobalConfig10,
12308
12462
  resolveEnvContext as resolveEnvContext7,
12309
12463
  printResolvedEnvironment as printResolvedEnvironment7,
@@ -13118,7 +13272,7 @@ async function gapDeps(deps) {
13118
13272
  return { client: await deps.client() };
13119
13273
  }
13120
13274
  function emit5(fmt, data, text) {
13121
- if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject26(data, { format: fmt }) + "\n");
13275
+ if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject27(data, { format: fmt }) + "\n");
13122
13276
  else process.stdout.write(text() + "\n");
13123
13277
  }
13124
13278
  async function run2(fn) {
@@ -13303,13 +13457,13 @@ async function gapVerifyCommand(ref, args, deps = defaultDeps) {
13303
13457
 
13304
13458
  // src/commands/chiron-doctor.ts
13305
13459
  init_auth_guard();
13306
- import { promises as fs12 } from "fs";
13307
- import path14 from "path";
13460
+ import { promises as fs13 } from "fs";
13461
+ import path15 from "path";
13308
13462
  import axios10 from "axios";
13309
13463
  import {
13310
13464
  CliError as CliError34,
13311
13465
  CliErrorCode as CliErrorCode35,
13312
- formatObject as formatObject29,
13466
+ formatObject as formatObject30,
13313
13467
  httpProbe as httpProbe2,
13314
13468
  listEnvs as listEnvs2,
13315
13469
  loadGlobalConfig as loadGlobalConfig12,
@@ -13325,8 +13479,8 @@ import {
13325
13479
 
13326
13480
  // src/commands/chiron-env.ts
13327
13481
  init_exit();
13328
- import { promises as fs10 } from "fs";
13329
- import path11 from "path";
13482
+ import { promises as fs11 } from "fs";
13483
+ import path12 from "path";
13330
13484
  import yaml from "js-yaml";
13331
13485
  import {
13332
13486
  AUTH_INFO_PATH as AUTH_INFO_PATH2,
@@ -13336,7 +13490,7 @@ import {
13336
13490
  discoverProjectEnv as discoverProjectEnv6,
13337
13491
  ENV_FILE as ENV_FILE2,
13338
13492
  findEnvByEndpoint as findEnvByEndpoint5,
13339
- formatObject as formatObject27,
13493
+ formatObject as formatObject28,
13340
13494
  listIdentities as listIdentities6,
13341
13495
  parseEnvYaml as parseEnvYaml2,
13342
13496
  renderEnvYaml as renderEnvYaml2,
@@ -13476,11 +13630,11 @@ async function runChironEnv(action, args = {}) {
13476
13630
  if (args.output && !["table", "json", "yaml"].includes(args.output)) {
13477
13631
  invalid2(`\u672A\u77E5\u8F93\u51FA\u683C\u5F0F '${args.output}'\uFF0C\u914D\u7F6E\u672A\u5199\u5165\u3002`, "\u4F7F\u7528 --output table\u3001json \u6216 yaml");
13478
13632
  }
13479
- const root = path11.resolve(args.project ?? ".");
13633
+ const root = path12.resolve(args.project ?? ".");
13480
13634
  const discovered = await discoverProjectEnv6(root);
13481
- const file = discovered?.path ?? path11.join(root, ENV_FILE2);
13635
+ const file = discovered?.path ?? path12.join(root, ENV_FILE2);
13482
13636
  if (!discovered && action !== "add") invalid2(`\u6CA1\u6709\u627E\u5230 ${file}\u3002`, "\u8FDB\u5165\u987E\u95EE\u9879\u76EE\uFF0C\u6216\u8FD0\u884C hcm chiron env add <\u540D\u5B57> --endpoint <URL> --frontend <URL> --tenant <\u79DF\u6237>");
13483
- const original = discovered ? await fs10.readFile(file, "utf8") : null;
13637
+ const original = discovered ? await fs11.readFile(file, "utf8") : null;
13484
13638
  const config2 = original ? parseEnvYaml2(original) : { default: "", environments: {} };
13485
13639
  const warnings = [];
13486
13640
  const report = { action, path: file, config: config2, environments: [], warnings };
@@ -13535,14 +13689,14 @@ async function runChironEnv(action, args = {}) {
13535
13689
  const legacy = original !== null && Object.hasOwn(yaml.load(original), "endpoint");
13536
13690
  const rendered = legacy && action === "edit" ? yaml.dump(config2.environments.default, { noRefs: true, lineWidth: -1 }) : renderEnvYaml2(config2);
13537
13691
  parseEnvYaml2(rendered);
13538
- if (original !== null && await fs10.readFile(file, "utf8") !== original) invalid2(`${file} \u5728\u6838\u9A8C\u671F\u95F4\u88AB\u4FEE\u6539\uFF0C\u914D\u7F6E\u672A\u5199\u5165\u3002`, "\u91CD\u65B0\u8FD0\u884C\u547D\u4EE4\uFF0C\u57FA\u4E8E\u6700\u65B0\u914D\u7F6E\u7F16\u8F91");
13539
- await fs10.writeFile(file, rendered, { encoding: "utf8", flag: original === null ? "wx" : "w" });
13540
- report.config = parseEnvYaml2(await fs10.readFile(file, "utf8"));
13692
+ if (original !== null && await fs11.readFile(file, "utf8") !== original) invalid2(`${file} \u5728\u6838\u9A8C\u671F\u95F4\u88AB\u4FEE\u6539\uFF0C\u914D\u7F6E\u672A\u5199\u5165\u3002`, "\u91CD\u65B0\u8FD0\u884C\u547D\u4EE4\uFF0C\u57FA\u4E8E\u6700\u65B0\u914D\u7F6E\u7F16\u8F91");
13693
+ await fs11.writeFile(file, rendered, { encoding: "utf8", flag: original === null ? "wx" : "w" });
13694
+ report.config = parseEnvYaml2(await fs11.readFile(file, "utf8"));
13541
13695
  report.environments = await rows(report.config, warnings);
13542
13696
  return report;
13543
13697
  }
13544
13698
  function formatChironEnvReport(report, output = "table") {
13545
- if (output !== "table") return formatObject27(report, { format: output });
13699
+ if (output !== "table") return formatObject28(report, { format: output });
13546
13700
  const lines = [
13547
13701
  report.action === "list" ? `\u9879\u76EE\u73AF\u5883\uFF1A${report.path}` : `\u5DF2\u5199\u5165\uFF1A${report.path}`,
13548
13702
  formatTable(report.environments.map((env2) => ({
@@ -13576,7 +13730,7 @@ import { promisify as promisify2 } from "util";
13576
13730
  import { createHash as createHash6 } from "crypto";
13577
13731
  import { existsSync as existsSync3, promises as fsp4 } from "fs";
13578
13732
  import os5 from "os";
13579
- import path12 from "path";
13733
+ import path13 from "path";
13580
13734
  import yaml2 from "js-yaml";
13581
13735
  import {
13582
13736
  CliError as CliError31,
@@ -13588,7 +13742,7 @@ import {
13588
13742
  discoverProjectEnv as discoverProjectEnv7,
13589
13743
  fetchSkillCatalog as fetchSkillCatalog2,
13590
13744
  flattenSkills as flattenSkills2,
13591
- formatObject as formatObject28,
13745
+ formatObject as formatObject29,
13592
13746
  parseSkillFrontmatter as parseSkillFrontmatter3,
13593
13747
  resolveChironBase as resolveChironBase2
13594
13748
  } from "@hcmai/sdk";
@@ -13872,10 +14026,10 @@ function parsePackageManifest(text) {
13872
14026
  async function sha256File(file) {
13873
14027
  return createHash6("sha256").update(await fsp4.readFile(file)).digest("hex");
13874
14028
  }
13875
- async function verifyDigests(entries, resolve3) {
14029
+ async function verifyDigests(entries, resolve4) {
13876
14030
  const out = { files: entries.length, mismatched: [], missing: [] };
13877
14031
  for (const f of entries) {
13878
- const abs = resolve3(f.path);
14032
+ const abs = resolve4(f.path);
13879
14033
  if (!existsSync3(abs)) {
13880
14034
  out.missing.push(f.path);
13881
14035
  continue;
@@ -13889,7 +14043,7 @@ async function listFilesUnder(root, rel) {
13889
14043
  const walk = async (dirRel) => {
13890
14044
  let items;
13891
14045
  try {
13892
- items = await fsp4.readdir(path12.join(root, dirRel), { withFileTypes: true });
14046
+ items = await fsp4.readdir(path13.join(root, dirRel), { withFileTypes: true });
13893
14047
  } catch {
13894
14048
  return;
13895
14049
  }
@@ -13910,9 +14064,9 @@ var BLOCK_LABEL = {
13910
14064
  "online-catalog": "\u5728\u7EBF\u4EA7\u54C1\u76EE\u5F55"
13911
14065
  };
13912
14066
  var PROJECT_SKILL_STATE_FILES = [
13913
- path12.join(SKILLS_DIR, SKILLS_SYNC_SUBDIR, SKILLS_STATE_FILE),
13914
- path12.join(SKILLS_DIR, SKILLS_STATE_FILE),
13915
- path12.join(".claude", "skills", SKILLS_STATE_FILE)
14067
+ path13.join(SKILLS_DIR, SKILLS_SYNC_SUBDIR, SKILLS_STATE_FILE),
14068
+ path13.join(SKILLS_DIR, SKILLS_STATE_FILE),
14069
+ path13.join(".claude", "skills", SKILLS_STATE_FILE)
13916
14070
  ];
13917
14071
  async function onlineTargetFor(root) {
13918
14072
  try {
@@ -13952,7 +14106,7 @@ async function checkMethodConflicts(methodIds, root, online, deps) {
13952
14106
  const unreadable = [];
13953
14107
  const owners = /* @__PURE__ */ new Map();
13954
14108
  for (const rel of PROJECT_SKILL_STATE_FILES) {
13955
- const file = path12.join(root, rel);
14109
+ const file = path13.join(root, rel);
13956
14110
  if (!existsSync3(file)) continue;
13957
14111
  found2.push(rel);
13958
14112
  try {
@@ -13960,20 +14114,20 @@ async function checkMethodConflicts(methodIds, root, online, deps) {
13960
14114
  for (const [id, rec] of Object.entries(state.skills ?? {})) {
13961
14115
  if (!owners.has(id)) {
13962
14116
  const from = rec?.sourceKind === "cli" ? "CLI \u81EA\u5E26" : rec?.sourceKind === "local" ? "\u672C\u5730\u76EE\u5F55" : `\u4EA7\u54C1 ${state.endpoint ?? "\uFF08\u672A\u8BB0\u73AF\u5883\uFF09"}`;
13963
- owners.set(id, `\u672C\u9879\u76EE\u5DF2\u88C5\uFF08${rel.split(path12.sep).join("/")}\uFF0C\u6765\u6E90 ${from}\uFF09`);
14117
+ owners.set(id, `\u672C\u9879\u76EE\u5DF2\u88C5\uFF08${rel.split(path13.sep).join("/")}\uFF0C\u6765\u6E90 ${from}\uFF09`);
13964
14118
  }
13965
14119
  }
13966
14120
  } catch (e) {
13967
- unreadable.push(`${rel.split(path12.sep).join("/")}\uFF08${e.message.split("\n")[0]}\uFF09`);
14121
+ unreadable.push(`${rel.split(path13.sep).join("/")}\uFF08${e.message.split("\n")[0]}\uFF09`);
13968
14122
  }
13969
14123
  }
13970
14124
  if (found2.length === 0) {
13971
14125
  b.note = "\u672C\u9879\u76EE\u8FD8\u6CA1\u88C5\u4EA7\u54C1\u6280\u80FD\uFF0C\u4EA7\u54C1\u4FA7\u672A\u6BD4\u5BF9";
13972
14126
  } else if (owners.size === 0) {
13973
- b.note = unreadable.length ? `\u5B89\u88C5\u6E05\u5355\u8BFB\u4E0D\u61C2\uFF1A${unreadable.join("\uFF1B")}\uFF0C\u4EA7\u54C1\u4FA7\u672A\u6BD4\u5BF9` : `\u5B89\u88C5\u6E05\u5355\u5728\uFF08${found2.map((f) => f.split(path12.sep).join("/")).join("\u3001")}\uFF09\uFF0C\u4F46\u4E00\u6761\u8BB0\u5F55\u90FD\u6CA1\u6709\uFF0C\u7A7A\u96C6\u5408\u4E0A\u6BD4\u4E0D\u51FA\u300C\u65E0\u540C\u540D\u300D\uFF0C\u4EA7\u54C1\u4FA7\u672A\u6BD4\u5BF9`;
14127
+ b.note = unreadable.length ? `\u5B89\u88C5\u6E05\u5355\u8BFB\u4E0D\u61C2\uFF1A${unreadable.join("\uFF1B")}\uFF0C\u4EA7\u54C1\u4FA7\u672A\u6BD4\u5BF9` : `\u5B89\u88C5\u6E05\u5355\u5728\uFF08${found2.map((f) => f.split(path13.sep).join("/")).join("\u3001")}\uFF09\uFF0C\u4F46\u4E00\u6761\u8BB0\u5F55\u90FD\u6CA1\u6709\uFF0C\u7A7A\u96C6\u5408\u4E0A\u6BD4\u4E0D\u51FA\u300C\u65E0\u540C\u540D\u300D\uFF0C\u4EA7\u54C1\u4FA7\u672A\u6BD4\u5BF9`;
13974
14128
  } else {
13975
14129
  b.checked = true;
13976
- b.source = found2.map((f) => f.split(path12.sep).join("/")).join("\u3001");
14130
+ b.source = found2.map((f) => f.split(path13.sep).join("/")).join("\u3001");
13977
14131
  b.compared = [...owners.keys()].sort();
13978
14132
  b.conflicts = b.compared.filter((id) => wanted.has(id)).map((id) => ({ id, other: owners.get(id) }));
13979
14133
  if (unreadable.length) b.note = `\u53E6\u6709\u6E05\u5355\u8BFB\u4E0D\u61C2\u3001\u6CA1\u7B97\u8FDB\u6765\uFF1A${unreadable.join("\uFF1B")}`;
@@ -14092,7 +14246,7 @@ function renderLock(lock) {
14092
14246
  `;
14093
14247
  }
14094
14248
  async function readLock(root) {
14095
- const file = path12.join(root, METHOD_DIR, METHOD_LOCK_FILE);
14249
+ const file = path13.join(root, METHOD_DIR, METHOD_LOCK_FILE);
14096
14250
  let text;
14097
14251
  try {
14098
14252
  text = await fsp4.readFile(file, "utf8");
@@ -14120,17 +14274,17 @@ async function readLock(root) {
14120
14274
  }
14121
14275
  async function readState(root) {
14122
14276
  try {
14123
- return JSON.parse(await fsp4.readFile(path12.join(root, METHOD_DIR, METHOD_STATE_FILE), "utf8"));
14277
+ return JSON.parse(await fsp4.readFile(path13.join(root, METHOD_DIR, METHOD_STATE_FILE), "utf8"));
14124
14278
  } catch {
14125
14279
  return void 0;
14126
14280
  }
14127
14281
  }
14128
14282
  async function resolveMethodRoot(project2, log) {
14129
- if (project2 !== void 0) return { root: path12.resolve(project2), rootSource: "--project" };
14283
+ if (project2 !== void 0) return { root: path13.resolve(project2), rootSource: "--project" };
14130
14284
  const cwd = process.cwd();
14131
14285
  try {
14132
14286
  const found2 = await discoverProjectEnv7(cwd);
14133
- if (found2) return { root: path12.dirname(found2.path), rootSource: "env.yaml" };
14287
+ if (found2) return { root: path13.dirname(found2.path), rootSource: "env.yaml" };
14134
14288
  } catch (e) {
14135
14289
  log(`env.yaml \u8BFB\u4E0D\u61C2\uFF08${e.message.split("\n")[0]}\uFF09\uFF0C\u4EE5\u5F53\u524D\u76EE\u5F55\u4E3A\u9879\u76EE\u6839\uFF1A${cwd}`);
14136
14290
  return { root: cwd, rootSource: "cwd" };
@@ -14146,13 +14300,13 @@ async function resolveTarget(root, requested) {
14146
14300
  return (await readState(root))?.target ?? await detectTarget(root) ?? "claude";
14147
14301
  }
14148
14302
  function skillFileSig(manifest2, skill) {
14149
- const dir = `${path12.posix.dirname(skill.path)}/`;
14303
+ const dir = `${path13.posix.dirname(skill.path)}/`;
14150
14304
  return manifest2.files.filter((f) => f.path.startsWith(dir)).map((f) => `${f.path}:${f.sha256}`).sort().join("\n");
14151
14305
  }
14152
14306
  async function readCriteria(dir) {
14153
14307
  let text;
14154
14308
  try {
14155
- text = await fsp4.readFile(path12.join(dir, GATES_FILE), "utf8");
14309
+ text = await fsp4.readFile(path13.join(dir, GATES_FILE), "utf8");
14156
14310
  } catch {
14157
14311
  return { reason: `\u6CA1\u6709 ${GATES_FILE}` };
14158
14312
  }
@@ -14220,7 +14374,7 @@ async function step(deps, n, label, fn) {
14220
14374
  }
14221
14375
  async function readInstalledManifest(root) {
14222
14376
  try {
14223
- const text = await fsp4.readFile(path12.join(root, METHOD_DIR, "package.yml"), "utf8");
14377
+ const text = await fsp4.readFile(path13.join(root, METHOD_DIR, "package.yml"), "utf8");
14224
14378
  return { text, manifest: parsePackageManifest(text) };
14225
14379
  } catch {
14226
14380
  return void 0;
@@ -14229,31 +14383,31 @@ async function readInstalledManifest(root) {
14229
14383
  var sha256Text = (t) => createHash6("sha256").update(t, "utf8").digest("hex");
14230
14384
  async function hasClaudeCopies(root) {
14231
14385
  try {
14232
- return (await fsp4.readdir(path12.join(root, ".claude", "skills"), { withFileTypes: true })).some((it) => it.isDirectory() && it.name.startsWith(METHOD_SKILL_PREFIX));
14386
+ return (await fsp4.readdir(path13.join(root, ".claude", "skills"), { withFileTypes: true })).some((it) => it.isDirectory() && it.name.startsWith(METHOD_SKILL_PREFIX));
14233
14387
  } catch {
14234
14388
  return false;
14235
14389
  }
14236
14390
  }
14237
14391
  function codexAgentFiles(root) {
14238
- const files = [path12.join(root, "AGENTS.md")];
14239
- if (existsSync3(path12.join(root, "CLAUDE.md"))) files.push(path12.join(root, "CLAUDE.md"));
14392
+ const files = [path13.join(root, "AGENTS.md")];
14393
+ if (existsSync3(path13.join(root, "CLAUDE.md"))) files.push(path13.join(root, "CLAUDE.md"));
14240
14394
  return files;
14241
14395
  }
14242
14396
  async function installClaudeCopies(root, manifest2) {
14243
- const skillsRoot = path12.join(root, ".claude", "skills");
14397
+ const skillsRoot = path13.join(root, ".claude", "skills");
14244
14398
  await fsp4.mkdir(skillsRoot, { recursive: true });
14245
14399
  const ids = new Set(manifest2.skills.map((s) => s.id));
14246
14400
  const written = [];
14247
14401
  for (const s of manifest2.skills) {
14248
- const dst = path12.join(skillsRoot, s.id);
14402
+ const dst = path13.join(skillsRoot, s.id);
14249
14403
  await fsp4.rm(dst, { recursive: true, force: true });
14250
- await fsp4.cp(path12.join(root, METHOD_DIR, path12.dirname(s.path)), dst, { recursive: true });
14404
+ await fsp4.cp(path13.join(root, METHOD_DIR, path13.dirname(s.path)), dst, { recursive: true });
14251
14405
  written.push(`.claude/skills/${s.id}/`);
14252
14406
  }
14253
14407
  const pruned = [];
14254
14408
  for (const it of await fsp4.readdir(skillsRoot, { withFileTypes: true })) {
14255
14409
  if (it.isDirectory() && it.name.startsWith(METHOD_SKILL_PREFIX) && !ids.has(it.name)) {
14256
- await fsp4.rm(path12.join(skillsRoot, it.name), { recursive: true, force: true });
14410
+ await fsp4.rm(path13.join(skillsRoot, it.name), { recursive: true, force: true });
14257
14411
  pruned.push(`.claude/skills/${it.name}/`);
14258
14412
  }
14259
14413
  }
@@ -14262,14 +14416,14 @@ async function installClaudeCopies(root, manifest2) {
14262
14416
  async function indexEntries(root, agentsDir, manifest2) {
14263
14417
  const out = [];
14264
14418
  for (const s of manifest2.skills) {
14265
- const abs = path12.join(root, METHOD_DIR, s.path);
14419
+ const abs = path13.join(root, METHOD_DIR, s.path);
14266
14420
  let description = "";
14267
14421
  try {
14268
14422
  const fm = parseSkillFrontmatter3(await fsp4.readFile(abs, "utf8"), s.id);
14269
14423
  if (typeof fm.description === "string") description = fm.description.trim().replace(/\s+/g, " ");
14270
14424
  } catch {
14271
14425
  }
14272
- let rel = path12.relative(agentsDir, abs).split(path12.sep).join("/");
14426
+ let rel = path13.relative(agentsDir, abs).split(path13.sep).join("/");
14273
14427
  if (!rel.startsWith(".")) rel = `./${rel}`;
14274
14428
  out.push({ id: s.id, title: s.title, description, phases: s.phases, relativePath: rel });
14275
14429
  }
@@ -14292,9 +14446,9 @@ async function runMethodPipeline(input, deps) {
14292
14446
  deps.log(` ${r.ref} \u2192 ${r.commit.slice(0, 12)}`);
14293
14447
  return r;
14294
14448
  });
14295
- const work = await fsp4.mkdtemp(path12.join(os5.tmpdir(), "hcm-method-"));
14449
+ const work = await fsp4.mkdtemp(path13.join(os5.tmpdir(), "hcm-method-"));
14296
14450
  try {
14297
- const checkout = path12.join(work, "pkg");
14451
+ const checkout = path13.join(work, "pkg");
14298
14452
  const { manifest: manifest2, manifestText } = await step(deps, 2, "\u53D6\u5305\uFF08\u7A00\u758F\u6D45 clone\uFF09", async () => {
14299
14453
  await deps.git(["clone", "--depth", "1", "--filter=blob:none", "--sparse", "--quiet", "--branch", resolved.ref, deps.repoUrl, checkout]);
14300
14454
  const head = (await deps.git(["-C", checkout, "rev-parse", "HEAD"], { timeoutMs: 1e4 })).trim();
@@ -14307,7 +14461,7 @@ async function runMethodPipeline(input, deps) {
14307
14461
  }
14308
14462
  let text;
14309
14463
  try {
14310
- text = await fsp4.readFile(path12.join(checkout, "package.yml"), "utf8");
14464
+ text = await fsp4.readFile(path13.join(checkout, "package.yml"), "utf8");
14311
14465
  } catch {
14312
14466
  throw invalidPackage("package.yml", `${resolved.ref} \u7684\u6839\u76EE\u5F55\u6CA1\u6709 package.yml\uFF08\u8FD9\u4E2A tag \u4E0D\u662F\u6309\u65B9\u6CD5\u5305\u6253\u7684\uFF09`);
14313
14467
  }
@@ -14318,11 +14472,11 @@ async function runMethodPipeline(input, deps) {
14318
14472
  });
14319
14473
  const unlisted = await step(deps, 3, "\u6821\u9A8C\u6E05\u5355\u4E0E\u6458\u8981", async () => {
14320
14474
  for (const [i, entry] of manifest2.include.entries()) {
14321
- if (!existsSync3(path12.join(checkout, entry.replace(/\/$/, "")))) {
14475
+ if (!existsSync3(path13.join(checkout, entry.replace(/\/$/, "")))) {
14322
14476
  throw invalidPackage(`include[${i}]`, `include \u767B\u8BB0\u4E86 ${entry}\uFF0C\u4F46 ${resolved.ref} \u91CC\u6CA1\u6709\u5B83`);
14323
14477
  }
14324
14478
  }
14325
- const check = await verifyDigests(manifest2.files, (p) => path12.join(checkout, p));
14479
+ const check = await verifyDigests(manifest2.files, (p) => path13.join(checkout, p));
14326
14480
  if (check.missing.length) {
14327
14481
  throw invalidPackage("files", `\u6E05\u5355\u767B\u8BB0\u4E86\u3001\u5305\u91CC\u5374\u6CA1\u6709\uFF1A${naming(check.missing)}`);
14328
14482
  }
@@ -14343,7 +14497,7 @@ async function runMethodPipeline(input, deps) {
14343
14497
  for (const l of renderConflictBlocks(blocks)) deps.log(l);
14344
14498
  return blocks;
14345
14499
  });
14346
- const diff = input.mode === "update" ? await diffPackages(before ? path12.join(root, METHOD_DIR) : void 0, before?.manifest, checkout, manifest2) : void 0;
14500
+ const diff = input.mode === "update" ? await diffPackages(before ? path13.join(root, METHOD_DIR) : void 0, before?.manifest, checkout, manifest2) : void 0;
14347
14501
  if (diff) for (const l of renderDiff(diff)) deps.log(` ${l}`);
14348
14502
  const lock = {
14349
14503
  lockVersion: 1,
@@ -14355,29 +14509,29 @@ async function runMethodPipeline(input, deps) {
14355
14509
  skills: manifest2.skills.map((s) => s.id)
14356
14510
  };
14357
14511
  const nowIso = deps.now().toISOString();
14358
- const gitignorePath = path12.join(root, ".gitignore");
14512
+ const gitignorePath = path13.join(root, ".gitignore");
14359
14513
  const agentTargets = input.target === "codex" ? codexAgentFiles(root) : [];
14360
14514
  const gitignore = await step(deps, 5, "\u9884\u68C0\u53D7\u7BA1\u5757\u5E76\u7EF4\u62A4 .gitignore", async () => {
14361
14515
  await preflightManaged([
14362
14516
  { file: gitignorePath, begin: GITIGNORE_BEGIN, end: GITIGNORE_END, label: ".gitignore" },
14363
- ...agentTargets.map((file) => ({ file, begin: AGENTS_METHOD_BEGIN, end: AGENTS_METHOD_END, label: path12.basename(file) }))
14517
+ ...agentTargets.map((file) => ({ file, begin: AGENTS_METHOD_BEGIN, end: AGENTS_METHOD_END, label: path13.basename(file) }))
14364
14518
  ]);
14365
14519
  return writeManaged(gitignorePath, GITIGNORE_BEGIN, GITIGNORE_END, renderGitignoreBlock(), ".gitignore");
14366
14520
  });
14367
14521
  await step(deps, 6, `\u66FF\u6362 ${METHOD_DIR}/ \u5E76\u5199\u9501\u6587\u4EF6`, async () => {
14368
- const targetDir = path12.join(root, METHOD_DIR);
14369
- const staging = path12.join(root, `.${METHOD_DIR}.staging-${process.pid}`);
14370
- const old = path12.join(root, `.${METHOD_DIR}.old-${process.pid}`);
14522
+ const targetDir = path13.join(root, METHOD_DIR);
14523
+ const staging = path13.join(root, `.${METHOD_DIR}.staging-${process.pid}`);
14524
+ const old = path13.join(root, `.${METHOD_DIR}.old-${process.pid}`);
14371
14525
  await fsp4.rm(staging, { recursive: true, force: true });
14372
14526
  try {
14373
14527
  await fsp4.mkdir(staging, { recursive: true });
14374
14528
  for (const entry of manifest2.include) {
14375
14529
  const rel = entry.replace(/\/$/, "");
14376
- await fsp4.cp(path12.join(checkout, rel), path12.join(staging, rel), { recursive: true });
14530
+ await fsp4.cp(path13.join(checkout, rel), path13.join(staging, rel), { recursive: true });
14377
14531
  }
14378
- await fsp4.writeFile(path12.join(staging, METHOD_LOCK_FILE), renderLock(lock), "utf8");
14532
+ await fsp4.writeFile(path13.join(staging, METHOD_LOCK_FILE), renderLock(lock), "utf8");
14379
14533
  const state = { target: input.target, installedAt: nowIso, remoteCheckedAt: nowIso };
14380
- await fsp4.writeFile(path12.join(staging, METHOD_STATE_FILE), `${JSON.stringify(state, null, 2)}
14534
+ await fsp4.writeFile(path13.join(staging, METHOD_STATE_FILE), `${JSON.stringify(state, null, 2)}
14381
14535
  `, "utf8");
14382
14536
  const hadOld = existsSync3(targetDir);
14383
14537
  if (hadOld) {
@@ -14401,8 +14555,8 @@ async function runMethodPipeline(input, deps) {
14401
14555
  const refreshCopies = input.target === "claude" || await hasClaudeCopies(root);
14402
14556
  if (refreshCopies) copies = await installClaudeCopies(root, manifest2);
14403
14557
  for (const file of agentTargets) {
14404
- const block = renderMethodAgentsBlock(lock, await indexEntries(root, path12.dirname(file), manifest2));
14405
- files.push({ file: path12.relative(root, file), status: await writeManaged(file, AGENTS_METHOD_BEGIN, AGENTS_METHOD_END, block, path12.basename(file)) });
14558
+ const block = renderMethodAgentsBlock(lock, await indexEntries(root, path13.dirname(file), manifest2));
14559
+ files.push({ file: path13.relative(root, file), status: await writeManaged(file, AGENTS_METHOD_BEGIN, AGENTS_METHOD_END, block, path13.basename(file)) });
14406
14560
  }
14407
14561
  return { files, copies };
14408
14562
  });
@@ -14438,7 +14592,7 @@ async function runMethodPipeline(input, deps) {
14438
14592
  function renderInstallReport(r) {
14439
14593
  const out = [];
14440
14594
  const verb = r.mode === "update" ? "\u5DF2\u66F4\u65B0\u5230" : "\u5DF2\u88C5";
14441
- out.push(`${verb}\u65B9\u6CD5 ${r.package.version}\uFF08${r.ref} @ ${r.commit.slice(0, 12)}\uFF09\u2192 ${path12.join(r.root, METHOD_DIR)}/`);
14595
+ out.push(`${verb}\u65B9\u6CD5 ${r.package.version}\uFF08${r.ref} @ ${r.commit.slice(0, 12)}\uFF09\u2192 ${path13.join(r.root, METHOD_DIR)}/`);
14442
14596
  if (r.previous && r.previous.commit !== r.commit) out.push(` \u9501\u6587\u4EF6\uFF1A${r.previous.ref} @ ${r.previous.commit.slice(0, 12)} \u2192 ${r.ref} @ ${r.commit.slice(0, 12)}`);
14443
14597
  out.push(` \u6280\u80FD ${r.skills.length} \u4EFD\uFF1A${naming(r.skills, 6)}`);
14444
14598
  if (r.diff) for (const l of renderDiff(r.diff)) out.push(` ${l}`);
@@ -14486,7 +14640,7 @@ async function runMethodStatus(root, deps, opts = {}) {
14486
14640
  report.lock = lock;
14487
14641
  report.rows.push({ item: "\u9501\u5B9A", verdict: "ok", detail: `\u65B9\u6CD5 ${lock.package.version} \xB7 ${lock.ref} @ ${lock.commit.slice(0, 12)}\uFF08${lock.skills.length} \u4EFD\u6280\u80FD\uFF09` });
14488
14642
  const state = await readState(root);
14489
- const installed2 = await fsp4.readFile(path12.join(root, METHOD_DIR, "package.yml"), "utf8").catch(() => void 0);
14643
+ const installed2 = await fsp4.readFile(path13.join(root, METHOD_DIR, "package.yml"), "utf8").catch(() => void 0);
14490
14644
  if (installed2 === void 0) {
14491
14645
  report.rows.push({
14492
14646
  item: "\u5B89\u88C5",
@@ -14507,7 +14661,7 @@ async function runMethodStatus(root, deps, opts = {}) {
14507
14661
  code: CliErrorCode33.METHOD_DIGEST_MISMATCH
14508
14662
  });
14509
14663
  } else {
14510
- report.rows.push({ item: "\u5B89\u88C5", verdict: "ok", detail: `\u672C\u673A\u526F\u672C\u5C31\u662F\u9501\u5B9A\u7684\u90A3\u4E00\u7248\uFF08${path12.join(root, METHOD_DIR)}/\uFF09` });
14664
+ report.rows.push({ item: "\u5B89\u88C5", verdict: "ok", detail: `\u672C\u673A\u526F\u672C\u5C31\u662F\u9501\u5B9A\u7684\u90A3\u4E00\u7248\uFF08${path13.join(root, METHOD_DIR)}/\uFF09` });
14511
14665
  let manifest2;
14512
14666
  try {
14513
14667
  manifest2 = parsePackageManifest(installed2);
@@ -14515,17 +14669,17 @@ async function runMethodStatus(root, deps, opts = {}) {
14515
14669
  report.digest.note = `\u672C\u673A package.yml \u8BFB\u4E0D\u61C2\uFF1A${e.message}`;
14516
14670
  }
14517
14671
  if (manifest2) {
14518
- const main2 = await verifyDigests(manifest2.files, (p) => path12.join(root, METHOD_DIR, p));
14672
+ const main2 = await verifyDigests(manifest2.files, (p) => path13.join(root, METHOD_DIR, p));
14519
14673
  const copyEntries = [];
14520
14674
  const copyMap = /* @__PURE__ */ new Map();
14521
14675
  for (const s of manifest2.skills) {
14522
- const copyDir = path12.join(root, ".claude", "skills", s.id);
14676
+ const copyDir = path13.join(root, ".claude", "skills", s.id);
14523
14677
  if (!existsSync3(copyDir) && state?.target !== "claude") continue;
14524
- const prefix = `${path12.posix.dirname(s.path)}/`;
14678
+ const prefix = `${path13.posix.dirname(s.path)}/`;
14525
14679
  for (const f of manifest2.files.filter((x) => x.path.startsWith(prefix))) {
14526
14680
  const shown = `.claude/skills/${s.id}/${f.path.slice(prefix.length)}`;
14527
14681
  copyEntries.push({ ...f, path: shown });
14528
- copyMap.set(shown, path12.join(root, shown));
14682
+ copyMap.set(shown, path13.join(root, shown));
14529
14683
  }
14530
14684
  }
14531
14685
  const copies = await verifyDigests(copyEntries, (p) => copyMap.get(p));
@@ -14608,8 +14762,8 @@ async function runMethodStatus(root, deps, opts = {}) {
14608
14762
  });
14609
14763
  }
14610
14764
  for (const id of lock.skills) {
14611
- const by = path12.join(SKILLS_DIR, SKILLS_LOCAL_SUBDIR, id);
14612
- if (existsSync3(path12.join(root, by, "SKILL.md"))) report.shadowed.push({ id, by: `${by.split(path12.sep).join("/")}/` });
14765
+ const by = path13.join(SKILLS_DIR, SKILLS_LOCAL_SUBDIR, id);
14766
+ if (existsSync3(path13.join(root, by, "SKILL.md"))) report.shadowed.push({ id, by: `${by.split(path13.sep).join("/")}/` });
14613
14767
  }
14614
14768
  report.rows.push(report.shadowed.length ? {
14615
14769
  item: "\u906E\u853D",
@@ -14629,7 +14783,7 @@ async function runMethodStatus(root, deps, opts = {}) {
14629
14783
  }
14630
14784
  function renderMethodStatus(r) {
14631
14785
  const mark = { ok: "\u2705", warn: "\u26A0\uFE0F", fail: "\u274C" };
14632
- const out = [`\u65B9\u6CD5\u5305\uFF1A${path12.join(r.root, METHOD_DIR)}/`];
14786
+ const out = [`\u65B9\u6CD5\u5305\uFF1A${path13.join(r.root, METHOD_DIR)}/`];
14633
14787
  for (const row of r.rows) {
14634
14788
  out.push(`${mark[row.verdict]} ${row.item} ${row.detail}`);
14635
14789
  if (row.nextStep && row.verdict !== "ok") out.push(` \u2192 ${row.nextStep}`);
@@ -14661,7 +14815,7 @@ function quietDeps() {
14661
14815
  } };
14662
14816
  }
14663
14817
  function emit6(output, data, text) {
14664
- if (output === "json" || output === "yaml") process.stdout.write(formatObject28(data, { format: output }) + "\n");
14818
+ if (output === "json" || output === "yaml") process.stdout.write(formatObject29(data, { format: output }) + "\n");
14665
14819
  else process.stdout.write(text() + "\n");
14666
14820
  }
14667
14821
  async function runMethodInstall(args, deps = defaultMethodDeps()) {
@@ -14725,8 +14879,8 @@ async function methodStatusCommand(args) {
14725
14879
  }
14726
14880
 
14727
14881
  // src/commands/doctor/local-checks.ts
14728
- import { promises as fs11 } from "fs";
14729
- import path13 from "path";
14882
+ import { promises as fs12 } from "fs";
14883
+ import path14 from "path";
14730
14884
  import axios6 from "axios";
14731
14885
  import { fetchSkillCatalog as fetchSkillCatalog3, fetchSkillMarkdown as fetchSkillMarkdown2, fetchSkillReference as fetchSkillReference2, normalizeReferences as normalizeReferences2, normalizeOrigin as normalizeOrigin6, resolveChironBase as resolveChironBase3 } from "@hcmai/sdk";
14732
14886
 
@@ -14828,13 +14982,13 @@ var version = async (ctx) => {
14828
14982
  var installed = async (ctx) => {
14829
14983
  let reading = "";
14830
14984
  const read = (baseDir) => {
14831
- reading = path13.join(baseDir, SKILLS_STATE_FILE);
14985
+ reading = path14.join(baseDir, SKILLS_STATE_FILE);
14832
14986
  return readSkillsState(baseDir, { strict: true });
14833
14987
  };
14834
14988
  try {
14835
14989
  const states = [];
14836
14990
  for (const [target2, folder] of [["codex", "hcm-skills/sync"], ["claude", ".claude/skills"]]) {
14837
- const baseDir = path13.join(ctx.root, folder);
14991
+ const baseDir = path14.join(ctx.root, folder);
14838
14992
  const state = await read(baseDir);
14839
14993
  if (state) states.push({ target: target2, baseDir, state });
14840
14994
  }
@@ -14845,12 +14999,12 @@ var installed = async (ctx) => {
14845
14999
  if (states.some((s) => s.state.endpoint && normalizeOrigin6(s.state.endpoint) !== normalizeOrigin6(target.config.endpoint)))
14846
15000
  return found("SKILLS_ENDPOINT_MISMATCH", void 0, { value: count });
14847
15001
  if (count === 0) {
14848
- const legacy = await read(path13.join(ctx.root, "hcm-skills"));
15002
+ const legacy = await read(path14.join(ctx.root, "hcm-skills"));
14849
15003
  return found(legacy && Object.keys(legacy.skills).length > 0 ? "SKILLS_LEGACY_LAYOUT" : "SKILLS_EMPTY", void 0, { value: count, evidence: "ABSENT" });
14850
15004
  }
14851
15005
  if (states.length === 2 && keys(states[0]).length > 0 && keys(states[1]).length > 0 && keys(states[0]).sort().join("\0") !== keys(states[1]).sort().join("\0"))
14852
15006
  return found("SKILLS_SPLIT_LAYOUT", void 0, { value: count });
14853
- return pass(`${count} \u4E2A\u6280\u80FD\uFF08\u4E24\u4EFD\u9501\u6587\u4EF6 skills \u952E\u7684\u5E76\u96C6\uFF09\uFF1B${states.map((s) => path13.relative(ctx.root, s.baseDir)).join("\u3001")}`, { value: count });
15007
+ return pass(`${count} \u4E2A\u6280\u80FD\uFF08\u4E24\u4EFD\u9501\u6587\u4EF6 skills \u952E\u7684\u5E76\u96C6\uFF09\uFF1B${states.map((s) => path14.relative(ctx.root, s.baseDir)).join("\u3001")}`, { value: count });
14854
15008
  } catch (error) {
14855
15009
  return unknown("SKILLS_STATE_UNREADABLE", void 0, {
14856
15010
  note: `${reading}\uFF1A${safeError(error)}\uFF1B\u5148\u4FEE\u590D\u9501\u6587\u4EF6 JSON \u6216\u8BFB\u53D6\u6743\u9650\uFF08\u53EF\u4ECE\u5907\u4EFD\u6062\u590D\uFF09\uFF0C\u518D\u6309\u4E0B\u4E00\u6B65\u540C\u6B65\u5E76\u91CD\u8DD1\u4F53\u68C0`
@@ -14916,7 +15070,7 @@ var boundary = async (ctx) => {
14916
15070
  for (const name of ["AGENTS.md", "CLAUDE.md"]) {
14917
15071
  let text;
14918
15072
  try {
14919
- text = await fs11.readFile(path13.join(ctx.root, name), "utf8");
15073
+ text = await fs12.readFile(path14.join(ctx.root, name), "utf8");
14920
15074
  } catch (error) {
14921
15075
  if (error.code === "ENOENT") continue;
14922
15076
  throw error;
@@ -15609,8 +15763,8 @@ async function executeChecks(ctx, options = {}) {
15609
15763
  let timer;
15610
15764
  let proxy = false;
15611
15765
  let expire;
15612
- const timeout = new Promise((resolve3) => {
15613
- expire = resolve3;
15766
+ const timeout = new Promise((resolve4) => {
15767
+ expire = resolve4;
15614
15768
  });
15615
15769
  const arm = (ms) => {
15616
15770
  clearTimeout(timer);
@@ -16637,11 +16791,11 @@ async function readCredential(envFlag, root, as) {
16637
16791
  return { resolved, identity: identity3, meta: meta2, token };
16638
16792
  }
16639
16793
  async function prepareContext(args, deps) {
16640
- const startedAt = Date.now(), root = path14.resolve(args.project ?? ".");
16794
+ const startedAt = Date.now(), root = path15.resolve(args.project ?? ".");
16641
16795
  let file;
16642
16796
  let projectObservation = found("ENV_FILE_MISSING", void 0, { evidence: "ABSENT" });
16643
16797
  try {
16644
- const text = await fs12.readFile(path14.join(root, "env.yaml"), "utf8");
16798
+ const text = await fs13.readFile(path15.join(root, "env.yaml"), "utf8");
16645
16799
  try {
16646
16800
  file = parseEnvYaml3(text);
16647
16801
  projectObservation = pass("env.yaml \u53EF\u89E3\u6790");
@@ -16657,7 +16811,7 @@ async function prepareContext(args, deps) {
16657
16811
  if (args.env && (!file || !Object.hasOwn(file.environments, args.env))) {
16658
16812
  try {
16659
16813
  const resolved = await resolveEnvContext9({ envFlag: args.env, cwd: root }, process.env, await loadGlobalConfig12());
16660
- if (resolved.project?.path !== path14.join(root, "env.yaml")) throw new Error("\u672C\u673A\u69FD\u4E0D\u5C5E\u4E8E\u5F53\u524D\u9879\u76EE");
16814
+ if (resolved.project?.path !== path15.join(root, "env.yaml")) throw new Error("\u672C\u673A\u69FD\u4E0D\u5C5E\u4E8E\u5F53\u524D\u9879\u76EE");
16661
16815
  targetEnv = resolved.project.name;
16662
16816
  explicitSlot = resolved.name;
16663
16817
  } catch (error) {
@@ -16833,12 +16987,12 @@ async function chironDoctorCommand(args, deps) {
16833
16987
  }
16834
16988
  }
16835
16989
  const data = explainOpsCatalog(args.explain, descriptorReport);
16836
- process.stdout.write((args.output === "json" || args.output === "yaml" ? formatObject29(data, { format: args.output }) : renderCatalogExplanation(data)) + "\n");
16990
+ process.stdout.write((args.output === "json" || args.output === "yaml" ? formatObject30(data, { format: args.output }) : renderCatalogExplanation(data)) + "\n");
16837
16991
  process.exitCode = 0;
16838
16992
  return;
16839
16993
  }
16840
16994
  const report2 = await runPlatformOps(args, { ...defaultServices, ...deps });
16841
- process.stdout.write((args.output === "json" || args.output === "yaml" ? formatObject29(report2, { format: args.output }) : renderChironDoctor(report2)) + "\n");
16995
+ process.stdout.write((args.output === "json" || args.output === "yaml" ? formatObject30(report2, { format: args.output }) : renderChironDoctor(report2)) + "\n");
16842
16996
  process.exitCode = conclude(report2.results, { total: report2.coverage.total, failOn: args.failOn ?? "blocked" }).exitCode;
16843
16997
  return;
16844
16998
  }
@@ -16850,12 +17004,12 @@ async function chironDoctorCommand(args, deps) {
16850
17004
  if (!listing.server.known) process.stderr.write(`\u670D\u52A1\u7AEF\u76EE\u5F55${"partial" in listing.server ? "\u4E0D\u5168" : "\u672A\u53D6\u5230"}\uFF1A${listing.server.reason}
16851
17005
  `);
16852
17006
  }
16853
- process.stdout.write((args.output === "json" || args.output === "yaml" ? formatObject29(data, { format: args.output }) : args.list ? renderCatalogList(data) : renderCatalogExplanation(data)) + "\n");
17007
+ process.stdout.write((args.output === "json" || args.output === "yaml" ? formatObject30(data, { format: args.output }) : args.list ? renderCatalogList(data) : renderCatalogExplanation(data)) + "\n");
16854
17008
  process.exitCode = 0;
16855
17009
  return;
16856
17010
  }
16857
17011
  const report = await runChironDoctor(args, deps);
16858
- process.stdout.write((args.output === "json" || args.output === "yaml" ? formatObject29(report, { format: args.output }) : renderChironDoctor(report)) + "\n");
17012
+ process.stdout.write((args.output === "json" || args.output === "yaml" ? formatObject30(report, { format: args.output }) : renderChironDoctor(report)) + "\n");
16859
17013
  process.exitCode = conclude(report.results, {
16860
17014
  total: report.coverage.total,
16861
17015
  failOn: args.failOn ?? "blocked",
@@ -16873,10 +17027,10 @@ init_auth_guard();
16873
17027
  init_exit();
16874
17028
  import { spawnSync } from "child_process";
16875
17029
  import { accessSync, constants, readdirSync as readdirSync3 } from "fs";
16876
- import fs13 from "fs/promises";
17030
+ import fs14 from "fs/promises";
16877
17031
  import os6 from "os";
16878
- import path16 from "path";
16879
- import { CliError as CliError37, CliErrorCode as CliErrorCode38, formatObject as formatObject30, HcmClient as HcmClient25, loadEnv as loadEnv6 } from "@hcmai/sdk";
17032
+ import path17 from "path";
17033
+ import { CliError as CliError37, CliErrorCode as CliErrorCode38, formatObject as formatObject31, HcmClient as HcmClient25, loadEnv as loadEnv6 } from "@hcmai/sdk";
16880
17034
  import { createRequire } from "module";
16881
17035
 
16882
17036
  // src/commands/chiron-page-cdp.ts
@@ -16942,8 +17096,8 @@ var CdpSession = class {
16942
17096
  send(method3, params = {}) {
16943
17097
  if (this.closed) return Promise.reject(new Error(`CDP socket \u5DF2\u5173\u95ED\uFF0C\u53D1\u4E0D\u4E86 ${method3}`));
16944
17098
  const id = this.nextId++;
16945
- return new Promise((resolve3, reject) => {
16946
- this.pending.set(id, { resolve: resolve3, reject, method: method3 });
17099
+ return new Promise((resolve4, reject) => {
17100
+ this.pending.set(id, { resolve: resolve4, reject, method: method3 });
16947
17101
  this.socket.send(JSON.stringify({ id, method: method3, params }));
16948
17102
  });
16949
17103
  }
@@ -16963,11 +17117,11 @@ var CdpSession = class {
16963
17117
  }
16964
17118
  /** 等一个事件,超时就 reject——「等 load 事件」不能无限等。无论哪种结束都摘掉监听器。 */
16965
17119
  waitFor(event, timeoutMs) {
16966
- return new Promise((resolve3, reject) => {
17120
+ return new Promise((resolve4, reject) => {
16967
17121
  const off = this.on(event, (params) => {
16968
17122
  clearTimeout(timer);
16969
17123
  off();
16970
- resolve3(params);
17124
+ resolve4(params);
16971
17125
  });
16972
17126
  const timer = setTimeout(() => {
16973
17127
  off();
@@ -17081,7 +17235,7 @@ var defaultCdpIo = {
17081
17235
  const text = await res.text();
17082
17236
  return text ? JSON.parse(text) : null;
17083
17237
  },
17084
- openSocket: (wsUrl) => new Promise((resolve3, reject) => {
17238
+ openSocket: (wsUrl) => new Promise((resolve4, reject) => {
17085
17239
  const Ctor = globalThis.WebSocket;
17086
17240
  if (!Ctor) {
17087
17241
  reject(new CliError35({ code: CliErrorCode36.SERVER_ERROR, message: "\u8FD9\u4E2A Node \u6CA1\u6709\u5168\u5C40 WebSocket\uFF08\u9700\u8981 Node \u2265 22.4\uFF1B22.0\u201322.3 \u8981\u52A0 --experimental-websocket\uFF09" }));
@@ -17091,7 +17245,7 @@ var defaultCdpIo = {
17091
17245
  const timer = setTimeout(() => reject(new Error(`\u8FDE ${wsUrl} \u8D85\u8FC7 ${CDP_IO_TIMEOUT_MS}ms \u6CA1\u63E1\u4E0A\u624B`)), CDP_IO_TIMEOUT_MS);
17092
17246
  ws.addEventListener("open", () => {
17093
17247
  clearTimeout(timer);
17094
- resolve3(ws);
17248
+ resolve4(ws);
17095
17249
  });
17096
17250
  ws.addEventListener("error", (ev) => {
17097
17251
  clearTimeout(timer);
@@ -17099,24 +17253,24 @@ var defaultCdpIo = {
17099
17253
  });
17100
17254
  }),
17101
17255
  writeFile: async (file, bytes) => {
17102
- const fs15 = await import("fs/promises");
17103
- await fs15.writeFile(file, bytes);
17256
+ const fs16 = await import("fs/promises");
17257
+ await fs16.writeFile(file, bytes);
17104
17258
  },
17105
17259
  sleep: (ms) => new Promise((r) => setTimeout(r, ms))
17106
17260
  };
17107
17261
 
17108
17262
  // src/commands/chiron-page-playwright.ts
17109
- import path15 from "path";
17263
+ import path16 from "path";
17110
17264
  import { CliError as CliError36, CliErrorCode as CliErrorCode37 } from "@hcmai/sdk";
17111
17265
  function playwrightCacheRoot(probe2) {
17112
17266
  const override = probe2.env.PLAYWRIGHT_BROWSERS_PATH?.trim();
17113
- if (override === "0" && probe2.packageRoot) return path15.join(probe2.packageRoot, ".local-browsers");
17114
- if (override && override !== "0") return path15.resolve(override);
17115
- if (probe2.platform === "darwin") return path15.join(probe2.homedir(), "Library", "Caches", "ms-playwright");
17267
+ if (override === "0" && probe2.packageRoot) return path16.join(probe2.packageRoot, ".local-browsers");
17268
+ if (override && override !== "0") return path16.resolve(override);
17269
+ if (probe2.platform === "darwin") return path16.join(probe2.homedir(), "Library", "Caches", "ms-playwright");
17116
17270
  if (probe2.platform === "win32") {
17117
- return path15.join(probe2.env.LOCALAPPDATA?.trim() || path15.join(probe2.homedir(), "AppData", "Local"), "ms-playwright");
17271
+ return path16.join(probe2.env.LOCALAPPDATA?.trim() || path16.join(probe2.homedir(), "AppData", "Local"), "ms-playwright");
17118
17272
  }
17119
- return path15.join(probe2.env.XDG_CACHE_HOME?.trim() || path15.join(probe2.homedir(), ".cache"), "ms-playwright");
17273
+ return path16.join(probe2.env.XDG_CACHE_HOME?.trim() || path16.join(probe2.homedir(), ".cache"), "ms-playwright");
17120
17274
  }
17121
17275
  function playwrightPlatformTag(probe2) {
17122
17276
  const arm = probe2.arch === "arm64";
@@ -17132,19 +17286,19 @@ function revisionOf(entry, prefix) {
17132
17286
  function candidateBinaries(probe2, kind) {
17133
17287
  const tag = playwrightPlatformTag(probe2);
17134
17288
  if (kind === "headless-shell") {
17135
- return [path15.join(`chrome-headless-shell-${tag}`, probe2.platform === "win32" ? "chrome-headless-shell.exe" : "chrome-headless-shell")];
17289
+ return [path16.join(`chrome-headless-shell-${tag}`, probe2.platform === "win32" ? "chrome-headless-shell.exe" : "chrome-headless-shell")];
17136
17290
  }
17137
17291
  if (probe2.platform === "darwin") {
17138
17292
  return [
17139
17293
  // Playwright ≥ 1.49:Chrome for Testing 的 .app
17140
- path15.join(`chrome-${tag}`, "Google Chrome for Testing.app", "Contents", "MacOS", "Google Chrome for Testing"),
17294
+ path16.join(`chrome-${tag}`, "Google Chrome for Testing.app", "Contents", "MacOS", "Google Chrome for Testing"),
17141
17295
  // ≤ 1.48:Chromium.app,目录名不分架构
17142
- path15.join("chrome-mac", "Chromium.app", "Contents", "MacOS", "Chromium"),
17143
- path15.join(`chrome-${tag}`, "Chromium.app", "Contents", "MacOS", "Chromium")
17296
+ path16.join("chrome-mac", "Chromium.app", "Contents", "MacOS", "Chromium"),
17297
+ path16.join(`chrome-${tag}`, "Chromium.app", "Contents", "MacOS", "Chromium")
17144
17298
  ];
17145
17299
  }
17146
- if (probe2.platform === "win32") return [path15.join("chrome-win64", "chrome.exe"), path15.join("chrome-win", "chrome.exe")];
17147
- return [path15.join(`chrome-${tag}`, "chrome"), path15.join("chrome-linux", "chrome")];
17300
+ if (probe2.platform === "win32") return [path16.join("chrome-win64", "chrome.exe"), path16.join("chrome-win", "chrome.exe")];
17301
+ return [path16.join(`chrome-${tag}`, "chrome"), path16.join("chrome-linux", "chrome")];
17148
17302
  }
17149
17303
  function discoverPlaywrightBrowser(probe2) {
17150
17304
  const explicit = probe2.env.HCM_PLAYWRIGHT_EXECUTABLE?.trim();
@@ -17162,8 +17316,8 @@ function discoverPlaywrightBrowser(probe2) {
17162
17316
  const revisions = entries.map((e) => ({ e, rev: revisionOf(e, prefix) })).filter((x) => x.rev !== null).sort((a, b) => b.rev - a.rev);
17163
17317
  for (const { e } of revisions) {
17164
17318
  for (const rel of candidateBinaries(probe2, kind)) {
17165
- const candidate = path15.join(root, e, rel);
17166
- if (probe2.executable(candidate)) return { executablePath: candidate, kind, from: path15.join(root, e) };
17319
+ const candidate = path16.join(root, e, rel);
17320
+ if (probe2.executable(candidate)) return { executablePath: candidate, kind, from: path16.join(root, e) };
17167
17321
  }
17168
17322
  }
17169
17323
  return null;
@@ -17265,10 +17419,10 @@ function resolveEvidenceTarget(projectRoot, out) {
17265
17419
  if (!out.endsWith(".png")) {
17266
17420
  throw new CliError37({ code: CliErrorCode38.INVALID_ARGUMENT, message: `--out \u8981\u4EE5 .png \u7ED3\u5C3E\uFF0C\u6536\u5230\u7684\u662F ${out}` });
17267
17421
  }
17268
- const root = path16.resolve(projectRoot);
17269
- const evidenceRoot = path16.join(root, EVIDENCE_DIR);
17270
- const absolute = path16.resolve(root, out);
17271
- if (absolute !== evidenceRoot && !absolute.startsWith(evidenceRoot + path16.sep)) {
17422
+ const root = path17.resolve(projectRoot);
17423
+ const evidenceRoot = path17.join(root, EVIDENCE_DIR);
17424
+ const absolute = path17.resolve(root, out);
17425
+ if (absolute !== evidenceRoot && !absolute.startsWith(evidenceRoot + path17.sep)) {
17272
17426
  throw new CliError37({
17273
17427
  code: CliErrorCode38.INVALID_ARGUMENT,
17274
17428
  message: `--out \u8981\u843D\u5728\u9879\u76EE\u7684 ${EVIDENCE_DIR}/ \u4E0B\uFF08${evidenceRoot}\uFF09\uFF0C\u6536\u5230\u7684\u662F ${absolute}`
@@ -17315,9 +17469,9 @@ function findChrome(probe2, override) {
17315
17469
  }
17316
17470
  async function assertInsideEvidence(deps, evidenceRoot, absolute) {
17317
17471
  const canonicalRoot = await deps.realpath(evidenceRoot);
17318
- const canonicalParent = await deps.realpath(path16.dirname(absolute));
17472
+ const canonicalParent = await deps.realpath(path17.dirname(absolute));
17319
17473
  if (canonicalRoot === null || canonicalParent === null) return;
17320
- if (canonicalParent !== canonicalRoot && !canonicalParent.startsWith(canonicalRoot + path16.sep)) {
17474
+ if (canonicalParent !== canonicalRoot && !canonicalParent.startsWith(canonicalRoot + path17.sep)) {
17321
17475
  throw new CliError37({
17322
17476
  code: CliErrorCode38.INVALID_ARGUMENT,
17323
17477
  message: `--out \u7684\u7236\u76EE\u5F55\u7ECF\u7B26\u53F7\u94FE\u63A5\u8DD1\u51FA\u4E86 ${EVIDENCE_DIR}/\uFF1A${canonicalParent}`
@@ -17336,7 +17490,7 @@ async function runChironPage(target, args, deps) {
17336
17490
  const reject = (args.rejectText ?? []).filter((t) => t.trim().length > 0);
17337
17491
  const viewport = parseViewport(args.size ?? "1440x900");
17338
17492
  const waitMs = parseWaitMs(args.waitMs);
17339
- const root = path16.resolve(args.project ?? ".");
17493
+ const root = path17.resolve(args.project ?? ".");
17340
17494
  const { evidenceRoot, absolute } = resolveEvidenceTarget(root, args.out);
17341
17495
  if (await deps.present(absolute)) {
17342
17496
  throw new CliError37({
@@ -17344,7 +17498,7 @@ async function runChironPage(target, args, deps) {
17344
17498
  message: `\u622A\u56FE\u5DF2\u5B58\u5728\uFF0C\u4E0D\u8986\u76D6\uFF1A${absolute}\u3002\u6362\u4E2A --out\uFF0C\u6216\u5148\u628A\u65E7\u8BC1\u636E\u632A\u8D70\u3002`
17345
17499
  });
17346
17500
  }
17347
- await deps.ensureDir(path16.dirname(absolute));
17501
+ await deps.ensureDir(path17.dirname(absolute));
17348
17502
  await assertInsideEvidence(deps, evidenceRoot, absolute);
17349
17503
  const endpoint = normalizeCdpEndpoint(args.cdp ?? deps.env.HCM_CHROME_CDP);
17350
17504
  const evalJs = args.eval?.trim() ? args.eval : void 0;
@@ -17462,7 +17616,7 @@ function safeStringify(value) {
17462
17616
  }
17463
17617
  function playwrightPackageRoot() {
17464
17618
  try {
17465
- return path16.dirname(createRequire(import.meta.url).resolve("playwright-core/package.json"));
17619
+ return path17.dirname(createRequire(import.meta.url).resolve("playwright-core/package.json"));
17466
17620
  } catch {
17467
17621
  return void 0;
17468
17622
  }
@@ -17532,16 +17686,16 @@ var defaultChironPageDeps = {
17532
17686
  capturePlaywright: (input) => captureViaPlaywright(input),
17533
17687
  platform: process.platform,
17534
17688
  browserVersion: (browser) => (spawnSync(browser, ["--version"], { encoding: "utf8" }).stdout ?? "").trim().split("\n")[0] ?? "",
17535
- ensureDir: (dir) => fs13.mkdir(dir, { recursive: true }).then(() => void 0),
17536
- present: (file) => fs13.lstat(file).then(() => true).catch(() => false),
17537
- sizeOf: (file) => fs13.stat(file).then((s) => s.size),
17538
- realpath: (file) => fs13.realpath(file).catch(() => null)
17689
+ ensureDir: (dir) => fs14.mkdir(dir, { recursive: true }).then(() => void 0),
17690
+ present: (file) => fs14.lstat(file).then(() => true).catch(() => false),
17691
+ sizeOf: (file) => fs14.stat(file).then((s) => s.size),
17692
+ realpath: (file) => fs14.realpath(file).catch(() => null)
17539
17693
  };
17540
17694
  async function chironPageCommand(target, args, deps = defaultChironPageDeps) {
17541
17695
  try {
17542
17696
  const receipt = await runChironPage(target, args, deps);
17543
17697
  const fmt = args.output ?? "table";
17544
- if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject30(receipt, { format: fmt }) + "\n");
17698
+ if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject31(receipt, { format: fmt }) + "\n");
17545
17699
  else process.stdout.write(renderChironPage(receipt) + "\n");
17546
17700
  process.exitCode = receipt.ok ? 0 : 3;
17547
17701
  } catch (e) {
@@ -17553,10 +17707,10 @@ async function chironPageCommand(target, args, deps = defaultChironPageDeps) {
17553
17707
  init_exit();
17554
17708
  import { spawnSync as spawnSync2 } from "child_process";
17555
17709
  import { randomUUID as randomUUID2 } from "crypto";
17556
- import { promises as fs14 } from "fs";
17557
- import path17 from "path";
17710
+ import { promises as fs15 } from "fs";
17711
+ import path18 from "path";
17558
17712
  import yaml3 from "js-yaml";
17559
- import { formatObject as formatObject31 } from "@hcmai/sdk";
17713
+ import { formatObject as formatObject32 } from "@hcmai/sdk";
17560
17714
 
17561
17715
  // src/commands/delivery-action-policy.ts
17562
17716
  init_auth_guard();
@@ -17606,6 +17760,7 @@ var GUARDED_EXECUTOR_REASON_CODES = /* @__PURE__ */ new Set([
17606
17760
  // 被「该 R2 命令不在首批受控执行器支持面」拦死,远端只多了一个空 workspace。
17607
17761
  "metadata-write",
17608
17762
  "workspace-push",
17763
+ "workspace-rebase",
17609
17764
  // 载荷是**位置参数**(`hcm import <路径>`),既不走 --file 也不走 --dir,
17610
17765
  // 所以上一刀把文件与目录开关收进来时它仍留在外面(0.4.9 CHANGELOG 逐字记了这一条)。
17611
17766
  //
@@ -17875,6 +18030,9 @@ function classify(argv, actionResolution) {
17875
18030
  }
17876
18031
  }
17877
18032
  if (name === "workspace") {
18033
+ if (subcommand === "rebase") {
18034
+ return hasFlag(argv, "--dry-run") || !hasFlag(argv, "--plan") ? direct("R1", "remote-read", "workspace-rebase-preview") : guarded("tenant-write", "workspace-rebase");
18035
+ }
17878
18036
  if (subcommand === "push" && hasFlag(argv, "--dry-run")) {
17879
18037
  return direct("R1", "remote-read", "workspace-push-dry-run");
17880
18038
  }
@@ -18455,7 +18613,7 @@ var defaultDeps2 = {
18455
18613
  return { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
18456
18614
  },
18457
18615
  readXlsx: (file) => xlsxRows(file),
18458
- readText: (file) => fs14.readFile(file, "utf8")
18616
+ readText: (file) => fs15.readFile(file, "utf8")
18459
18617
  };
18460
18618
  async function runCase(spec, root, opts = {}, deps = defaultDeps2) {
18461
18619
  const results = [];
@@ -18520,7 +18678,7 @@ async function runCase(spec, root, opts = {}, deps = defaultDeps2) {
18520
18678
  continue;
18521
18679
  }
18522
18680
  if (c2.file) {
18523
- const file = path17.resolve(root, fill(c2.file));
18681
+ const file = path18.resolve(root, fill(c2.file));
18524
18682
  const want = c2.expect ?? {};
18525
18683
  const bad = [];
18526
18684
  if (want.xlsx_header || want.xlsx_min_rows !== void 0) {
@@ -18542,7 +18700,7 @@ async function runCase(spec, root, opts = {}, deps = defaultDeps2) {
18542
18700
  results.push(bad.length ? { name: c2.name, verdict: "fail", detail: bad.join("\uFF1B") } : { name: c2.name, verdict: "pass", detail: "" });
18543
18701
  continue;
18544
18702
  }
18545
- const out = path17.join(
18703
+ const out = path18.join(
18546
18704
  "evidence",
18547
18705
  "test",
18548
18706
  opts.evidenceRunId ?? "current",
@@ -18563,12 +18721,12 @@ async function runCase(spec, root, opts = {}, deps = defaultDeps2) {
18563
18721
  return results;
18564
18722
  }
18565
18723
  async function loadCases(target) {
18566
- const stat = await fs14.stat(target);
18567
- const files = stat.isDirectory() ? (await fs14.readdir(target)).filter((f) => /\.ya?ml$/.test(f)).sort().map((f) => path17.join(target, f)) : [target];
18724
+ const stat = await fs15.stat(target);
18725
+ const files = stat.isDirectory() ? (await fs15.readdir(target)).filter((f) => /\.ya?ml$/.test(f)).sort().map((f) => path18.join(target, f)) : [target];
18568
18726
  const out = [];
18569
18727
  for (const f of files) {
18570
- const spec = yaml3.load(await fs14.readFile(f, "utf8"));
18571
- assertUsableSpec(spec, path17.basename(f));
18728
+ const spec = yaml3.load(await fs15.readFile(f, "utf8"));
18729
+ assertUsableSpec(spec, path18.basename(f));
18572
18730
  out.push({ file: f, spec });
18573
18731
  }
18574
18732
  if (out.length === 0) throw new Error(`${target} \u4E0B\u6CA1\u6709\u7528\u4F8B\uFF08*.yml\uFF09`);
@@ -18576,8 +18734,8 @@ async function loadCases(target) {
18576
18734
  }
18577
18735
  async function chironTestCommand(target, args, deps) {
18578
18736
  try {
18579
- const root = path17.resolve(args.project ?? ".");
18580
- const where = path17.resolve(root, target ?? "tests");
18737
+ const root = path18.resolve(args.project ?? ".");
18738
+ const where = path18.resolve(root, target ?? "tests");
18581
18739
  const cases2 = await loadCases(where);
18582
18740
  const report = [];
18583
18741
  let failed2 = 0;
@@ -18589,11 +18747,11 @@ async function chironTestCommand(target, args, deps) {
18589
18747
  deps
18590
18748
  );
18591
18749
  failed2 += results.filter((r) => r.verdict === "fail").length;
18592
- report.push({ case: spec.name, file: path17.relative(root, file), results });
18750
+ report.push({ case: spec.name, file: path18.relative(root, file), results });
18593
18751
  }
18594
18752
  const fmt = args.output ?? "table";
18595
18753
  if (fmt === "json" || fmt === "yaml") {
18596
- process.stdout.write(formatObject31({ ok: failed2 === 0, failed: failed2, cases: report }, { format: fmt }) + "\n");
18754
+ process.stdout.write(formatObject32({ ok: failed2 === 0, failed: failed2, cases: report }, { format: fmt }) + "\n");
18597
18755
  } else {
18598
18756
  for (const c2 of report) {
18599
18757
  process.stdout.write(`
@@ -18626,7 +18784,7 @@ import {
18626
18784
  ReconLayout,
18627
18785
  ROUND_EXIT_CODES,
18628
18786
  computeReconSourceKey,
18629
- formatObject as formatObject32,
18787
+ formatObject as formatObject33,
18630
18788
  fromAxiosError as fromAxiosError25,
18631
18789
  httpProbe as httpProbe3,
18632
18790
  inspectRound,
@@ -18646,7 +18804,7 @@ async function deliveryReconCommand(args) {
18646
18804
  onlyModel: args.model ?? null,
18647
18805
  identity: ctx.tenantId ? { requestedTenantId: ctx.tenantId } : null
18648
18806
  });
18649
- process.stdout.write(formatObject32(summary, { format: args.output ?? "json" }) + "\n");
18807
+ process.stdout.write(formatObject33(summary, { format: args.output ?? "json" }) + "\n");
18650
18808
  } catch (e) {
18651
18809
  const err = e;
18652
18810
  if (err?.isAxiosError) exitWithError(fromAxiosError25(err, args.env));
@@ -18660,7 +18818,7 @@ async function deliveryReconRoundCommand(args) {
18660
18818
  const result = inspectRound(args.dir ?? ".");
18661
18819
  const fmt = args.output ?? "json";
18662
18820
  if (fmt !== "json") process.stdout.write(renderRound(result));
18663
- process.stdout.write(formatObject32(result, { format: fmt }) + "\n");
18821
+ process.stdout.write(formatObject33(result, { format: fmt }) + "\n");
18664
18822
  code2 = ROUND_EXIT_CODES[result.state];
18665
18823
  } catch (e) {
18666
18824
  exitWithError(e);
@@ -18730,7 +18888,7 @@ import {
18730
18888
  writeRisk
18731
18889
  } from "@hcmai/sdk";
18732
18890
  import { existsSync as existsSync4 } from "fs";
18733
- import * as path18 from "path";
18891
+ import * as path19 from "path";
18734
18892
  function premise(message, hint = "") {
18735
18893
  process.stderr.write(message + (hint ? `
18736
18894
  \u2192 ${hint}` : "") + "\n");
@@ -18757,13 +18915,13 @@ async function runSeedPlan(args, client3) {
18757
18915
  const reconDir = candidates[0].reconDir;
18758
18916
  if (candidates.length > 1) {
18759
18917
  process.stderr.write(
18760
- `\u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u6709 ${candidates.length} \u4EFD\u57FA\u7EBF\uFF0C\u672C\u8F6E\u8BFB\u7684\u662F \`${path18.basename(reconDir)}\`\uFF1A` + candidates.slice(1).map((c2) => `\`${path18.basename(c2.reconDir)}\``).join("\u3001") + " \u672A\u88AB\u8BFB\u53D6 \u2014\u2014 \u4E0D\u540C sourceKey \u7684\u4EA7\u7269**\u4E0D\u53EF\u4E92\u6362**\u3002\n"
18918
+ `\u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u6709 ${candidates.length} \u4EFD\u57FA\u7EBF\uFF0C\u672C\u8F6E\u8BFB\u7684\u662F \`${path19.basename(reconDir)}\`\uFF1A` + candidates.slice(1).map((c2) => `\`${path19.basename(c2.reconDir)}\``).join("\u3001") + " \u672A\u88AB\u8BFB\u53D6 \u2014\u2014 \u4E0D\u540C sourceKey \u7684\u4EA7\u7269**\u4E0D\u53EF\u4E92\u6362**\u3002\n"
18761
18919
  );
18762
18920
  }
18763
18921
  const round = inspectRound2(reconDir);
18764
18922
  process.stderr.write(roundWarning(round));
18765
18923
  const baseline = {
18766
- path: `${path18.basename(path18.dirname(reconDir))}/${path18.basename(reconDir)}`,
18924
+ path: `${path19.basename(path19.dirname(reconDir))}/${path19.basename(reconDir)}`,
18767
18925
  roundId: round.roundId ?? null
18768
18926
  };
18769
18927
  let exemptions = null;
@@ -19025,7 +19183,7 @@ async function deliverySeedVerifyCommand(args) {
19025
19183
  // src/commands/delivery-seed-find.ts
19026
19184
  import { existsSync as existsSync5 } from "fs";
19027
19185
  import { readFileSync as readFileSync8 } from "fs";
19028
- import * as path19 from "path";
19186
+ import * as path20 from "path";
19029
19187
  import {
19030
19188
  INIT_EXIT_CODES as INIT_EXIT_CODES2,
19031
19189
  ValueHints,
@@ -19039,10 +19197,10 @@ import {
19039
19197
  valuesRoundCaveat
19040
19198
  } from "@hcmai/sdk";
19041
19199
  function provenance(chosenReconDir, others) {
19042
- let line = `> \u57FA\u7EBF\uFF1A\`${path19.basename(chosenReconDir)}\`
19200
+ let line = `> \u57FA\u7EBF\uFF1A\`${path20.basename(chosenReconDir)}\`
19043
19201
  `;
19044
19202
  if (others.length > 0) {
19045
- line += `> \u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u53E6\u6709 ${others.length} \u4EFD\u57FA\u7EBF\u672A\u88AB\u8BFB\u53D6\uFF1A` + others.map((o) => `\`${path19.basename(o)}\``).join("\u3001") + " \u2014\u2014 \u4E0D\u540C sourceKey \u7684\u4EA7\u7269**\u4E0D\u53EF\u4E92\u6362**\u3002\n";
19203
+ line += `> \u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u53E6\u6709 ${others.length} \u4EFD\u57FA\u7EBF\u672A\u88AB\u8BFB\u53D6\uFF1A` + others.map((o) => `\`${path20.basename(o)}\``).join("\u3001") + " \u2014\u2014 \u4E0D\u540C sourceKey \u7684\u4EA7\u7269**\u4E0D\u53EF\u4E92\u6362**\u3002\n";
19046
19204
  }
19047
19205
  return `${line}
19048
19206
  `;
@@ -19379,7 +19537,7 @@ import {
19379
19537
  runTriageRound
19380
19538
  } from "@hcmai/sdk";
19381
19539
  import { mkdirSync as mkdirSync2, readFileSync as readFileSync10, writeFileSync as writeFileSync3 } from "fs";
19382
- import * as path20 from "path";
19540
+ import * as path21 from "path";
19383
19541
  var DEFAULT_CAPABILITIES3 = "default";
19384
19542
  function premise4(message, hint) {
19385
19543
  process.stderr.write(`\u{1F534} \u524D\u63D0\u4E0D\u6210\u7ACB\uFF1A${message}
@@ -19415,8 +19573,8 @@ function renderProblems(rows2) {
19415
19573
  `;
19416
19574
  }
19417
19575
  function writeTriageArtifact(outDir, body) {
19418
- const out = path20.join(outDir, "work", "triage.md");
19419
- mkdirSync2(path20.dirname(out), { recursive: true });
19576
+ const out = path21.join(outDir, "work", "triage.md");
19577
+ mkdirSync2(path21.dirname(out), { recursive: true });
19420
19578
  writeFileSync3(out, body, "utf8");
19421
19579
  return out;
19422
19580
  }
@@ -19460,7 +19618,7 @@ init_exit();
19460
19618
  import {
19461
19619
  HcmClient as HcmClient31,
19462
19620
  adminResetPassword,
19463
- formatObject as formatObject33,
19621
+ formatObject as formatObject34,
19464
19622
  fromAxiosError as fromAxiosError26,
19465
19623
  CliError as CliError38,
19466
19624
  CliErrorCode as CliErrorCode39
@@ -19494,7 +19652,7 @@ async function userResetPasswordCommand(args) {
19494
19652
  const request = buildAdminResetPasswordRequest(args, password);
19495
19653
  const client3 = HcmClient31.fromAuthContext(await getActiveAuthContextFromCli(args));
19496
19654
  const result = await adminResetPassword(client3.raw(), request);
19497
- process.stdout.write(formatObject33(result, { format: args.output ?? "json" }) + "\n");
19655
+ process.stdout.write(formatObject34(result, { format: args.output ?? "json" }) + "\n");
19498
19656
  } catch (cause) {
19499
19657
  const err = cause;
19500
19658
  if (err?.isAxiosError) exitWithError(fromAxiosError26(err, args.env));
@@ -19518,7 +19676,7 @@ init_exit();
19518
19676
  init_auth_guard();
19519
19677
  import {
19520
19678
  HcmClient as HcmClient32,
19521
- formatObject as formatObject34,
19679
+ formatObject as formatObject35,
19522
19680
  fromAxiosError as fromAxiosError27
19523
19681
  } from "@hcmai/sdk";
19524
19682
  async function modelsCommand(keyword, args) {
@@ -19529,7 +19687,7 @@ async function modelsCommand(keyword, args) {
19529
19687
  const rows2 = (needle ? all.filter((m) => JSON.stringify(m).toLowerCase().includes(needle)) : all).sort((a, b) => key(a).localeCompare(key(b)));
19530
19688
  const fmt = args.output ?? "table";
19531
19689
  if (fmt !== "table") {
19532
- process.stdout.write(formatObject34({ total: rows2.length, models: rows2 }, { format: fmt }) + "\n");
19690
+ process.stdout.write(formatObject35({ total: rows2.length, models: rows2 }, { format: fmt }) + "\n");
19533
19691
  process.exitCode = 0;
19534
19692
  return;
19535
19693
  }
@@ -19802,6 +19960,7 @@ workspace.command("deactivate").description("\u8BA9\u5F53\u524D\u8EAB\u4EFD\u900
19802
19960
  workspace.command("bind <workspaceKey>").description("\u628A\u5F53\u524D\u76EE\u5F55\u7ED1\u5B9A\u5230\u4E00\u4E2A\u79DF\u6237\u5F00\u53D1\u7A7A\u95F4").option("--dir <path>", "\u5DE5\u4F5C\u7A7A\u95F4\u672C\u5730\u76EE\u5F55", ".").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").option("--tenant <tenantId>", "\u79DF\u6237 ID\uFF08\u9ED8\u8BA4\u4F7F\u7528 env \u914D\u7F6E\uFF09").option("--endpoint <url>", "HCM \u540E\u7AEF\u5730\u5740\uFF08\u9ED8\u8BA4\u4F7F\u7528 env \u914D\u7F6E\uFF09").option("--force", "\u5F3A\u5236\u8986\u76D6\u5DF2\u6709\u7ED1\u5B9A").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((workspaceKey, opts) => workspaceBindCommand(workspaceKey, opts));
19803
19961
  workspace.command("create <workspaceKey>").description("\u65B0\u5EFA\u79DF\u6237\u5F00\u53D1\u7A7A\u95F4\uFF0C\u5E76\u5728\u672C\u5730\u76EE\u5F55\u5199\u5165 workspace \u7ED1\u5B9A").option("--dir <path>", "\u5DE5\u4F5C\u7A7A\u95F4\u672C\u5730\u76EE\u5F55", ".").option("--description <text>", "\u5F00\u53D1\u7A7A\u95F4\u8BF4\u660E").option("--activate", "\u521B\u5EFA\u540E\u7ED1\u5B9A\u4E3A\u5F53\u524D\u5F00\u53D1\u7A7A\u95F4").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").option("--force", "\u672C\u5730\u76EE\u5F55\u5DF2\u6709\u4E0D\u540C workspace \u7ED1\u5B9A\u65F6\u5F3A\u5236\u8986\u76D6").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((workspaceKey, opts) => workspaceCreateCommand(workspaceKey, opts));
19804
19962
  workspace.command("pull").description("\u4ECE\u5F00\u53D1\u7A7A\u95F4\u62C9\u53D6\u6587\u4EF6\u5305\u5230\u672C\u5730\uFF1Bmini_apps \u4F1A\u751F\u6210\u53EF\u9A8C\u8BC1\u7684 artifact \u4E0A\u4E0B\u6587").option("--workspace <key>", "\u79DF\u6237\u5F00\u53D1\u7A7A\u95F4 key\uFF1B\u672A\u63D0\u4F9B\u65F6\u8BFB\u53D6\u672C\u5730\u7ED1\u5B9A").option("--dir <path>", "\u5DE5\u4F5C\u7A7A\u95F4\u672C\u5730\u76EE\u5F55", ".").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").option("--force", "\u5F3A\u5236\u8986\u76D6\u5DF2\u6709\u7684\u672C\u5730\u6587\u4EF6").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => workspacePullCommand(opts));
19963
+ workspace.command("rebase").description("\u9884\u89C8 workspace \u4E0E active \u7684\u4FEE\u8BA2\u5DEE\u5F02\uFF1B\u6309\u660E\u786E\u7684\u9010\u8DEF\u5F84\u89E3\u51B3\u8BA1\u5212\u66F4\u65B0\u5F00\u53D1\u7A7A\u95F4\u57FA\u7EBF").option("--workspace <key>", "\u79DF\u6237\u5F00\u53D1\u7A7A\u95F4 key\uFF1B\u672A\u63D0\u4F9B\u65F6\u8BFB\u53D6\u672C\u5730\u7ED1\u5B9A").option("--dir <path>", "\u5DE5\u4F5C\u7A7A\u95F4\u672C\u5730\u76EE\u5F55", ".").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").option("--dry-run", "\u53EA\u8BFB\u9884\u89C8\uFF1B\u914D\u5408 --plan \u5199\u4E00\u4E2A\u4E0D\u8986\u76D6\u5DF2\u6709\u6587\u4EF6\u7684\u89E3\u51B3\u8349\u6848").option("--plan <path>", "\u89E3\u51B3\u8BA1\u5212 JSON\uFF1B\u4E0D\u5E26 --dry-run \u65F6\u6821\u9A8C\u5E76\u6267\u884C\u8BE5\u8BA1\u5212\uFF0C\u672A\u63D0\u4F9B\u65F6\u53EA\u9884\u89C8").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => workspaceRebaseCommand(opts));
19805
19964
  var workspaceAdd = workspace.command("add").description("\u5411\u5DF2\u7ED1\u5B9A\u5F00\u53D1\u7A7A\u95F4\u6DFB\u52A0 artifact");
19806
19965
  workspaceAdd.command("mini <appCode>").description("\u65B0\u589E\u8F7B\u5E94\u7528 artifact\uFF08\u5199\u5165 mini_apps/<appCode>/\uFF09").option("--dir <path>", "\u5DE5\u4F5C\u7A7A\u95F4\u672C\u5730\u76EE\u5F55", ".").option("--name <name>", "\u8F7B\u5E94\u7528\u5C55\u793A\u540D").option("--template <kind>", "\u6A21\u677F\uFF1Adashboard | multi-page | writable-workbench", "dashboard").option("--sdk-version <semver>", "\u76EE\u6807 Core \u7684\u8F7B\u5E94\u7528\u8FD0\u884C\u65F6 ABI\uFF08\u9ED8\u8BA4 0.1.0\uFF0C\u72EC\u7ACB\u4E8E CLI \u5305\u7248\u672C\uFF1B\u4E0D\u63A2\u6D4B\u7EBF\u4E0A\u7248\u672C\uFF09").option("--model <Model>", "\u53EF\u5199\u5DE5\u4F5C\u53F0\u7ED1\u5B9A\u7684 Model\uFF0C\u4F8B\u5982 OrgUnit").option("--fields <csv|auto>", "\u53EF\u5199\u5DE5\u4F5C\u53F0\u8868\u5355\u5B57\u6BB5\u5217\u8868\uFF1B\u4F20 auto \u65F6\u6839\u636E Model \u5143\u6570\u636E\u63A8\u65AD").option("--defaults <JSON|auto>", "\u53EF\u5199\u5DE5\u4F5C\u53F0\u521B\u5EFA\u9ED8\u8BA4\u503C\uFF1B\u4F20 auto \u65F6\u6839\u636E Model \u5143\u6570\u636E\u63A8\u65AD").option(
19807
19966
  "--surface <surface>",
@@ -19868,7 +20027,7 @@ program.command("update <Model>").description("\u66F4\u65B0\u4E00\u6761 Model \u
19868
20027
  ).action((model, opts) => updateCommand(model, opts));
19869
20028
  program.command("version").description("\u67E5 CLI \u4E0E\u540E\u7AEF\u4E24\u4E2A\u7248\u672C\uFF08commit / tag / \u6784\u5EFA\u65F6\u95F4\uFF09\u2014\u2014\u514D\u8BA4\u8BC1\uFF0C\u65E0\u9700\u5148 login").option("--endpoint <url>", "\u540E\u7AEF\u5730\u5740\uFF08\u9ED8\u8BA4\u53D6\u9879\u76EE\u73AF\u5883\u6216 activeEnv \u7684 endpoint\uFF09").option("--env <name>", "\u4ECE\u8BE5 env \u89E3\u6790 endpoint").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => versionCommand(opts));
19870
20029
  program.command("upgrade").alias("self-update").description("\u5347\u7EA7 CLI \u81EA\u5DF1\uFF08\u6CE8\u610F\uFF1A`hcm update` \u662F\u66F4\u65B0\u4E1A\u52A1\u8BB0\u5F55\uFF0C\u4E0D\u662F\u5347\u7EA7\uFF09").option("--check", "\u53EA\u68C0\u67E5\uFF1B\u6709\u65B0\u7248\u672C\u65F6\u4EE5\u9000\u51FA\u7801 1 \u7ED3\u675F\uFF0C\u4FBF\u4E8E\u811A\u672C\u5224\u65AD").action((opts) => upgradeCommand(opts));
19871
- program.command("open [path]").description("\u7528\u5F53\u524D CLI \u8EAB\u4EFD\u6253\u5F00\u524D\u7AEF\u9875\u9762\uFF1A\u94F8\u4E00\u5F20 60s \u4E00\u6B21\u6027\u7968\u636E\u4EA4\u7ED9\u6D4F\u89C8\u5668\uFF0C\u4F1A\u8BDD token \u4E0D\u8FDB URL").option("--print-url", "\u53EA\u6253\u5370\u767B\u5F55 URL\uFF0C\u4E0D\u5F00\u6D4F\u89C8\u5668\uFF08\u7ED9 agent \u6D4F\u89C8\u5668 navigate \u7528\uFF09").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").action((path21, opts) => openCommand(path21, opts));
20030
+ program.command("open [path]").description("\u7528\u5F53\u524D CLI \u8EAB\u4EFD\u6253\u5F00\u524D\u7AEF\u9875\u9762\uFF1A\u94F8\u4E00\u5F20 60s \u4E00\u6B21\u6027\u7968\u636E\u4EA4\u7ED9\u6D4F\u89C8\u5668\uFF0C\u4F1A\u8BDD token \u4E0D\u8FDB URL").option("--print-url", "\u53EA\u6253\u5370\u767B\u5F55 URL\uFF0C\u4E0D\u5F00\u6D4F\u89C8\u5668\uFF08\u7ED9 agent \u6D4F\u89C8\u5668 navigate \u7528\uFF09").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").action((path22, opts) => openCommand(path22, opts));
19872
20031
  var setting = program.command("setting").description("\u79DF\u6237\u7CFB\u7EDF\u53C2\u6570\uFF08\u767B\u5F55\u7B56\u7565 / \u5BC6\u7801\u7B56\u7565 / \u529F\u80FD\u5F00\u5173 / \u96C6\u6210\u53C2\u6570\uFF09");
19873
20032
  setting.command("get <domain>").description("\u8BFB\u67D0\u57DF\u53C2\u6570\uFF08\u5B9A\u4E49 + \u79DF\u6237\u8986\u76D6\u503C\u5408\u5E76\uFF0C\u7F3A\u5931\u56DE\u843D\u9ED8\u8BA4\u503C\uFF09").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((d, opts) => settingGetCommand(d, opts));
19874
20033
  setting.command("set <domain>").description("\u6539\u53C2\u6570\uFF0C\u53EF\u91CD\u590D --set\uFF1B\u8D70\u53D7\u63A7\u6821\u9A8C\u8DEF\u5F84\u800C\u975E\u6807\u51C6 CRUD").option(