@hcmai/cli 0.27.2 → 0.27.4

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
@@ -6285,6 +6285,7 @@ function extractToolNames(raw) {
6285
6285
  function buildLlmTable(rows2) {
6286
6286
  let inSum = 0;
6287
6287
  let outSum = 0;
6288
+ const hasFallback = rows2.some((r) => r.selectionFallbackReason != null);
6288
6289
  const table = rows2.map((r) => {
6289
6290
  const pIn = Number(r.promptTokens ?? 0);
6290
6291
  const pOut = Number(r.completionTokens ?? 0);
@@ -6297,7 +6298,8 @@ function buildLlmTable(rows2) {
6297
6298
  TOOLS: short(extractToolNames(r.responseToolCalls), 30),
6298
6299
  "TOKENS(in/out)": `${pIn}/${pOut}`,
6299
6300
  LATENCY: fmtDuration(r.latencyMs ?? void 0),
6300
- FINISH: short(r.finishReason, 12)
6301
+ FINISH: short(r.finishReason, 12),
6302
+ ...hasFallback ? { FALLBACK: r.selectionFallbackReason ?? "-" } : {}
6301
6303
  };
6302
6304
  });
6303
6305
  return { table, inSum, outSum };
@@ -10412,7 +10414,8 @@ import {
10412
10414
  } from "@hcmai/sdk";
10413
10415
  var COLUMN_SLOT_SQL_PURPOSE = {
10414
10416
  countSlot: "\u69FD\u91CC\u672C\u79DF\u6237\u7684\u975E\u7A7A\u884C\u6570\uFF08\u7ED1\u5B9A\u524D\u987B\u4E3A 0\uFF09",
10415
- flexToSlot: "\u628A flex \u91CC\u7684\u503C\u642C\u8FDB\u69FD",
10417
+ flexToSlotBatched: "\u51BB\u7ED3\u524D\u5206\u6279\u628A flex \u91CC\u7684\u503C\u56DE\u586B\u8FDB\u69FD\uFF08\u533F\u540D\u5757\u3001\u6BCF\u6279\u63D0\u4EA4\uFF0C\u4E0D\u8981\u5305\u5728\u4E8B\u52A1\u91CC\uFF09",
10418
+ flexToSlot: "\u628A flex \u91CC\u7684\u503C\u642C\u8FDB\u69FD\uFF08\u53EA\u6539\u4E0E flex \u4E0D\u4E00\u81F4\u7684\u884C\uFF0C\u53EF\u91CD\u590D\u6267\u884C\uFF09",
10416
10419
  verifyFlexToSlot: "\u6838\u5BF9 flex \u4E0E\u69FD\u662F\u5426\u4E00\u81F4\uFF0C\u7ED3\u679C\u987B\u4E3A 0",
10417
10420
  slotToFlex: "\u628A\u69FD\u91CC\u7684\u503C\u5199\u56DE flex",
10418
10421
  removeFlexKey: "\u5220\u6389 flex \u91CC\u7684\u540C\u540D\u952E",
@@ -10657,6 +10660,7 @@ import {
10657
10660
  collectMiniPushWrites,
10658
10661
  createWorkspaceFile,
10659
10662
  deleteWorkspaceFileChecked,
10663
+ findPullMiniAppCodeCaseCollisions,
10660
10664
  formatMiniVerifyReport,
10661
10665
  formatObject as formatObject26,
10662
10666
  formatRows as formatRows6,
@@ -11136,6 +11140,8 @@ async function workspacePullCommand(args) {
11136
11140
  endpoint: client4.endpoint ?? existing?.endpoint
11137
11141
  });
11138
11142
  const files = await listWorkspaceFilesForSync(client4.raw(), workspaceKey);
11143
+ const miniApps = detectRemoteMiniApps(files.data);
11144
+ await assertNoMiniAppCaseCollisionBeforePull(rootDir, miniApps, workspaceKey);
11139
11145
  const localFiles = await readWorkspaceRawLocalFiles(rootDir);
11140
11146
  const remotePaths = new Set(files.data.map((file) => file.relativePath));
11141
11147
  const manifest2 = await readWorkspaceRawManifest(rootDir, context, true);
@@ -11159,7 +11165,6 @@ async function workspacePullCommand(args) {
11159
11165
  path11.join(rootDir, WORKSPACE_STATE_DIR, WORKSPACE_PULL_INCOMPLETE_FILE),
11160
11166
  JSON.stringify(context, null, 2) + "\n"
11161
11167
  );
11162
- const miniApps = detectRemoteMiniApps(files.data);
11163
11168
  const pulledMiniApps = [];
11164
11169
  for (const appCode of miniApps) {
11165
11170
  const result = await pullMiniAppProject({
@@ -11244,6 +11249,7 @@ async function workspaceAddMiniCommand(appCode, args) {
11244
11249
  fields: args.fields,
11245
11250
  defaults: args.defaults
11246
11251
  });
11252
+ await assertNoLocalMiniAppCaseCollision(rootDir, appCode);
11247
11253
  const result = await initMiniAppProject({
11248
11254
  appCode,
11249
11255
  workspaceKey: context.workspaceKey,
@@ -12111,12 +12117,14 @@ async function preflightWorkspacePlan(http, workspaceKey, operations, localFiles
12111
12117
  }
12112
12118
  try {
12113
12119
  const verdict = await validateWorkspaceFiles(http, workspaceKey, files, deletedPaths);
12120
+ const warnings = verdict.warnings ? { warnings: verdict.warnings } : {};
12114
12121
  if (!verdict.ok) {
12115
12122
  return {
12116
12123
  status: "failed",
12117
12124
  sent,
12118
12125
  checked: verdict.checked,
12119
12126
  issues: verdict.issues,
12127
+ ...warnings,
12120
12128
  nextStep: preflightFailureNextStep(verdict.issues)
12121
12129
  };
12122
12130
  }
@@ -12126,11 +12134,12 @@ async function preflightWorkspacePlan(http, workspaceKey, operations, localFiles
12126
12134
  sent,
12127
12135
  checked: verdict.checked,
12128
12136
  issues: [],
12137
+ ...warnings,
12129
12138
  reason: `\u670D\u52A1\u7AEF\u53EA\u68C0\u67E5\u4E86 ${verdict.checked}/${sent} \u4E2A\u6587\u4EF6\uFF0C\u7ED3\u8BBA\u4E0D\u8986\u76D6\u6574\u4EFD\u8BA1\u5212`,
12130
12139
  nextStep: "\u628A\u8FD9\u6761\u8F93\u51FA\u8FDE\u540C\u670D\u52A1\u7AEF\u7248\u672C\uFF08hcm version\uFF09\u62A5\u7ED9\u4EA7\u54C1\u4FA7\uFF1B\u5728\u6B64\u4E4B\u524D\u4EE5\u771F\u5B9E push \u7684\u7ED3\u679C\u4E3A\u51C6\u3002"
12131
12140
  };
12132
12141
  }
12133
- return { status: "passed", sent, checked: verdict.checked, issues: [] };
12142
+ return { status: "passed", sent, checked: verdict.checked, issues: [], ...warnings };
12134
12143
  } catch (error) {
12135
12144
  const status = error?.response?.status;
12136
12145
  const translated = error?.isAxiosError ? fromAxiosError25(error, profile) : error;
@@ -12173,6 +12182,14 @@ function formatPreflightIssues(issues, indent2 = "") {
12173
12182
  return lines.join("\n");
12174
12183
  }).join("\n");
12175
12184
  }
12185
+ function formatPreflightWarnings(warnings, indent2 = "") {
12186
+ return warnings.map((warning) => {
12187
+ const lines = [`${indent2}\u26A0 ${warning.path ?? "(\u6574\u6279)"} [${warning.warnCode ?? "WARN"}] ${warning.message}`];
12188
+ if (warning.fields?.length) lines.push(`${indent2} \u21B3 \u5B57\u6BB5\uFF1A${warning.fields.join(", ")}`);
12189
+ if (warning.nextStep) lines.push(`${indent2} \u21B3 \u4E0B\u4E00\u6B65\uFF1A${warning.nextStep}`);
12190
+ return lines.join("\n");
12191
+ }).join("\n");
12192
+ }
12176
12193
  function conflictHolder(issue) {
12177
12194
  const data = issue.data;
12178
12195
  if (typeof data?.conflictingWorkspaceKey !== "string" || !data.conflictingWorkspaceKey) return void 0;
@@ -12207,6 +12224,10 @@ function formatPreflightSummary(preflight, indent2 = "") {
12207
12224
  const head = preflight.status === "passed" ? `server preflight: OK (${preflight.checked}/${preflight.sent} checked)` : preflight.status === "failed" ? `server preflight: FAIL (${preflight.issues.length} issues in ${preflight.checked}/${preflight.sent} checked)` : preflight.status === "unavailable" ? `server preflight: UNAVAILABLE \u2014 ${preflight.reason}\uFF08\u4E0D\u662F\u901A\u8FC7\uFF09` : `server preflight: nothing to check (${preflight.reason})`;
12208
12225
  const lines = [`${indent2}${head}`];
12209
12226
  if (preflight.issues.length) lines.push(formatPreflightIssues(preflight.issues, `${indent2} `));
12227
+ if (preflight.warnings?.length) {
12228
+ lines.push(`${indent2} warnings: ${preflight.warnings.length}\uFF08\u4E0D\u5F71\u54CD\u901A\u8FC7\u4E0E\u5426\uFF0C\u6309\u4E0B\u4E00\u6B65\u5904\u7406\uFF09`);
12229
+ lines.push(formatPreflightWarnings(preflight.warnings, `${indent2} `));
12230
+ }
12210
12231
  if (preflight.nextStep) lines.push(`${indent2} next: ${preflight.nextStep}`);
12211
12232
  return lines.join("\n");
12212
12233
  }
@@ -12423,6 +12444,48 @@ function detectRemoteMiniApps(files) {
12423
12444
  }
12424
12445
  return Array.from(appCodes).sort();
12425
12446
  }
12447
+ async function assertNoMiniAppCaseCollisionBeforePull(rootDir, remoteCodes, workspaceKey) {
12448
+ const remote = new Set(remoteCodes);
12449
+ const local = new Set((await discoverMiniApps(rootDir)).map((app) => app.appCode));
12450
+ const collisions = findPullMiniAppCodeCaseCollisions(remote, local);
12451
+ if (!collisions.length) return;
12452
+ const origin = (code2) => remote.has(code2) && local.has(code2) ? "\u8FDC\u7AEF\uFF0C\u672C\u5730\u5DF2\u6709" : remote.has(code2) ? "\u8FDC\u7AEF" : `\u672C\u5730\u76EE\u5F55 ${MINI_APPS_DIR}/${code2}`;
12453
+ const listed = collisions.map((group) => group.map((code2) => `${code2}\uFF08${origin(code2)}\uFF09`).join(" / ")).join("\uFF1B");
12454
+ const remotePairs = collisions.some((group) => group.filter((code2) => remote.has(code2)).length > 1);
12455
+ const localPairs = collisions.some((group) => group.some((code2) => local.has(code2) && !remote.has(code2)));
12456
+ const steps = [
12457
+ ...remotePairs ? ["\u8FDC\u7AEF\u540C\u4E00\u7A7A\u95F4\u91CC\u6709\u53EA\u5DEE\u5927\u5C0F\u5199\u7684\u7F16\u7801\uFF1A\u5728\u7CFB\u7EDF\u91CC\u628A\u5176\u4E2D\u4E00\u4E2A\u8F7B\u5E94\u7528\u6539\u6210\u4E0D\u540C\u7684\u7F16\u7801\uFF08\u6216\u5220\u6389\u4E0D\u7528\u7684\u90A3\u4E2A\uFF09\u540E\u91CD\u65B0 pull"] : [],
12458
+ ...localPairs ? [`\u672C\u5730\u76EE\u5F55\u4E0E\u8FDC\u7AEF\u7F16\u7801\u53EA\u5DEE\u5927\u5C0F\u5199\uFF1A\u786E\u8BA4\u662F\u4E0D\u662F\u540C\u4E00\u4E2A\u5E94\u7528\u2014\u2014\u662F\u5C31\u628A\u6539\u52A8\u5E76\u5165\u4E0E\u8FDC\u7AEF\u7F16\u7801\u540C\u540D\u7684\u76EE\u5F55\uFF08\u672C\u5730\u8FD8\u6CA1\u6709\u5C31\u628A\u8BE5\u76EE\u5F55\u6539\u540D\u6210\u8FDC\u7AEF\u7684\u7F16\u7801\uFF09\uFF0C\u4E0D\u662F\u5C31\u5148\u628A\u672C\u5730\u76EE\u5F55\u79FB\u51FA ${MINI_APPS_DIR}/\uFF08\u672A push \u7684\u6539\u52A8\u5148\u5907\u4EFD\uFF09`] : []
12459
+ ];
12460
+ throw new CliError28({
12461
+ code: CliErrorCode29.BUSINESS_RULE_VIOLATION,
12462
+ message: `\u8F7B\u5E94\u7528\u7F16\u7801\u53EA\u5DEE\u5927\u5C0F\u5199\uFF1A${listed}\u3002\u670D\u52A1\u7AEF\u533A\u5206\u5927\u5C0F\u5199\uFF0C\u672C\u5730\u76EE\u5F55\u5728 macOS / Windows \u9ED8\u8BA4\u4E0D\u533A\u5206\uFF0C\u7EE7\u7EED\u62C9\u53D6\u4F1A\u5199\u8FDB\u540C\u4E00\u4E2A\u76EE\u5F55\u4E92\u76F8\u8986\u76D6\uFF1B\u672A\u5199\u5165\u4EFB\u4F55\u6587\u4EF6\u3002`,
12463
+ context: {
12464
+ workspaceKey,
12465
+ reasonCode: "MINI_APP_CODE_CASE_COLLISION",
12466
+ collisions,
12467
+ remote: collisions.flat().filter((code2) => remote.has(code2)),
12468
+ local: collisions.flat().filter((code2) => local.has(code2)),
12469
+ nextStep: steps.join("\uFF1B") + "\u3002"
12470
+ }
12471
+ });
12472
+ }
12473
+ async function assertNoLocalMiniAppCaseCollision(rootDir, appCode) {
12474
+ const wanted = appCode.trim();
12475
+ const existing = (await discoverMiniApps(rootDir)).map((app) => app.appCode);
12476
+ const clash = existing.filter((code2) => code2 !== wanted && code2.toLowerCase() === wanted.toLowerCase());
12477
+ if (!clash.length) return;
12478
+ throw new CliError28({
12479
+ code: CliErrorCode29.BUSINESS_RULE_VIOLATION,
12480
+ message: `\u672C\u5730\u5DF2\u6709\u53EA\u5DEE\u5927\u5C0F\u5199\u7684\u8F7B\u5E94\u7528\u76EE\u5F55 ${clash.map((code2) => `${MINI_APPS_DIR}/${code2}`).join(", ")}\uFF0C\u4E0D\u80FD\u518D\u65B0\u589E ${wanted}\uFF1A\u5728\u5927\u5C0F\u5199\u4E0D\u654F\u611F\u7684\u6587\u4EF6\u7CFB\u7EDF\u4E0A\u4E24\u8005\u662F\u540C\u4E00\u4E2A\u76EE\u5F55\u3002`,
12481
+ context: {
12482
+ reasonCode: "MINI_APP_CODE_CASE_COLLISION",
12483
+ appCode: wanted,
12484
+ existing: clash,
12485
+ nextStep: `\u6CBF\u7528\u5DF2\u6709\u7684\u7F16\u7801 ${clash[0]}\uFF0C\u6216\u6362\u4E00\u4E2A\u4E0D\u53EA\u5DEE\u5927\u5C0F\u5199\u7684\u65B0\u7F16\u7801\u3002`
12486
+ }
12487
+ });
12488
+ }
12426
12489
  function isMiniAppPath(relativePath) {
12427
12490
  return relativePath === MINI_APPS_DIR || relativePath.startsWith(`${MINI_APPS_DIR}/`);
12428
12491
  }