@warmhub/cli 0.59.0 → 0.60.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.
Files changed (2) hide show
  1. package/dist/wh.js +203 -18
  2. package/package.json +1 -1
package/dist/wh.js CHANGED
@@ -21457,7 +21457,7 @@ function findSystemComponent(componentId) {
21457
21457
  // ../../packages/sdk-ts/package.json
21458
21458
  var package_default = {
21459
21459
  name: "@warmhub/sdk-ts",
21460
- version: "0.59.0",
21460
+ version: "0.60.0",
21461
21461
  private: false,
21462
21462
  type: "module",
21463
21463
  description: "The TypeScript SDK for WarmHub — create repos, commit and query data, and compound knowledge with your AI agents.",
@@ -21578,6 +21578,14 @@ function toBackendStreamOperation(operation) {
21578
21578
  ...operation.leaseId ? { leaseId: operation.leaseId } : {}
21579
21579
  };
21580
21580
  }
21581
+ if (operation.operation === "rename") {
21582
+ return {
21583
+ operation: "rename",
21584
+ name: operation.name,
21585
+ newName: operation.newName,
21586
+ ...operation.kind ? { kind: operation.kind } : {}
21587
+ };
21588
+ }
21581
21589
  if (operation.operation === "revise") {
21582
21590
  const name = operation.name ?? operation.wref;
21583
21591
  if (!name) {
@@ -21970,7 +21978,7 @@ function toSubmittedStreamResult(writeResult, committer, createdByEmail, message
21970
21978
  operations: results.map((result) => ({
21971
21979
  ...result.opIndex !== undefined ? { opIndex: result.opIndex } : {},
21972
21980
  name: result.name ?? "",
21973
- operation: result.operation === "revise" || result.operation === "retract" || result.operation === "noop" ? result.operation : "add",
21981
+ operation: result.operation === "revise" || result.operation === "retract" || result.operation === "rename" || result.operation === "noop" ? result.operation : "add",
21974
21982
  dataHash: result.dataHash ?? "",
21975
21983
  version: result.version ?? 0,
21976
21984
  status: streamAppendResultStatus(result),
@@ -24190,6 +24198,9 @@ function toCliError(err) {
24190
24198
  const defaultHint = typeof retryAfter === "number" ? `Rate limited. Retry after ${retryAfter}s.` : "Rate limited. Wait for the Retry-After window before retrying.";
24191
24199
  return fromWh(4 /* Backend */, "RATE_LIMITED", err, err.hint ?? defaultHint);
24192
24200
  }
24201
+ if (err.code === "QUERY_TOO_EXPENSIVE") {
24202
+ return fromWh(2 /* UserInput */, "QUERY_TOO_EXPENSIVE", err, err.hint ?? "Narrow the query with a more selective field predicate or retry with a shallower page.");
24203
+ }
24193
24204
  if (err.status) {
24194
24205
  return fromWh(4 /* Backend */, "BACKEND", err);
24195
24206
  }
@@ -24346,6 +24357,14 @@ function generateSuggestions(code, message, context, errorCode) {
24346
24357
  command: "wh repo describe --indexed-fields"
24347
24358
  });
24348
24359
  }
24360
+ if (code === "QUERY_TOO_EXPENSIVE") {
24361
+ suggestions.push({
24362
+ action: "Narrow the query with a more selective field predicate"
24363
+ });
24364
+ suggestions.push({
24365
+ action: "Retry with a shallower page or smaller result window"
24366
+ });
24367
+ }
24349
24368
  if (code === "AUTH") {
24350
24369
  suggestions.push({
24351
24370
  action: "Re-authenticate",
@@ -24380,6 +24399,7 @@ function shouldLogToErrorTier(err) {
24380
24399
  case "UNKNOWN":
24381
24400
  case "RATE_LIMITED":
24382
24401
  return true;
24402
+ case "QUERY_TOO_EXPENSIVE":
24383
24403
  case "FIELD_NOT_INDEXABLE":
24384
24404
  return false;
24385
24405
  case "FIELD_INDEX_UNAVAILABLE":
@@ -24431,6 +24451,9 @@ function cliErrorFromOpFailure(failure) {
24431
24451
  if (code === "RATE_LIMITED") {
24432
24452
  return make(4 /* Backend */, "RATE_LIMITED", "Rate limited. Wait for the Retry-After window before retrying.");
24433
24453
  }
24454
+ if (code === "QUERY_TOO_EXPENSIVE") {
24455
+ return make(2 /* UserInput */, "QUERY_TOO_EXPENSIVE", "Narrow the query with a more selective field predicate or retry with a shallower page.");
24456
+ }
24434
24457
  return make(4 /* Backend */, "BACKEND");
24435
24458
  }
24436
24459
  function cliErrorFromAllFailed(failures) {
@@ -26644,16 +26667,16 @@ function renderThing(out, c, result) {
26644
26667
  out(` ${c.dim}about:${c.reset} ${String(aboutWref)}`);
26645
26668
  }
26646
26669
  const meta = result.metadata;
26647
- if (meta?.durableId || meta?.thingCreatedAt || meta?.versionCreatedAt) {
26670
+ if (meta?.durableId || meta?.createdOn || meta?.revisedOn) {
26648
26671
  const now = Date.now();
26649
26672
  if (meta.durableId) {
26650
26673
  out(` ${c.dim}durableId:${c.reset} ${meta.durableId}`);
26651
26674
  }
26652
- if (meta.thingCreatedAt) {
26653
- out(` ${c.dim}thingCreated:${c.reset} ${formatTime(meta.thingCreatedAt, now)}`);
26675
+ if (meta.createdOn) {
26676
+ out(` ${c.dim}createdOn:${c.reset} ${formatTime(meta.createdOn, now)}`);
26654
26677
  }
26655
- if (meta.versionCreatedAt) {
26656
- out(` ${c.dim}versionCreated:${c.reset}${formatTime(meta.versionCreatedAt, now)}`);
26678
+ if (meta.revisedOn) {
26679
+ out(` ${c.dim}revisedOn:${c.reset} ${formatTime(meta.revisedOn, now)}`);
26657
26680
  }
26658
26681
  }
26659
26682
  const fields = shapeName && result.data ? collectionFields(shapeName, result.data) : null;
@@ -26766,8 +26789,8 @@ function renderHistory(out, c, result) {
26766
26789
  const wref = ver.wref ?? ver.thingName;
26767
26790
  const wrefStr = wref ? pinnedWref(c, wref, ver.version) : "";
26768
26791
  const by = ver.committerWref ? ` ${c.dim}by${c.reset} ${pinnedWref(c, ver.committerWref)}` : "";
26769
- const thingCreatedAt = ver.metadata?.thingCreatedAt;
26770
- const thingCreatedStr = thingCreatedAt ? ` ${c.dim}born:${formatTime(thingCreatedAt, now)}${c.reset}` : "";
26792
+ const createdOn = ver.metadata?.createdOn;
26793
+ const thingCreatedStr = createdOn ? ` ${c.dim}born:${formatTime(createdOn, now)}${c.reset}` : "";
26771
26794
  out(` ${wrefStr} ${op} ${c.dim}${time}${c.reset}${by}${thingCreatedStr}`);
26772
26795
  }
26773
26796
  }
@@ -33828,7 +33851,7 @@ async function collectChecks(ctx) {
33828
33851
  name: "compatibility",
33829
33852
  status: "fail",
33830
33853
  message: `SDK v${SDK_VERSION} is older than minimum supported ${caps.minSupportedSdk} (apiVersion: ${caps.apiVersion})`,
33831
- fix: "Update with: bun install @warmhub/cli@latest"
33854
+ fix: "Update with: wh update --yes"
33832
33855
  });
33833
33856
  } else {
33834
33857
  checks.push({
@@ -37386,7 +37409,7 @@ var TOKEN_DOMAIN = defineDomain({
37386
37409
 
37387
37410
  // ../../packages/warmhub-cli/src/domains/update.ts
37388
37411
  import { spawnSync as spawnSync2 } from "node:child_process";
37389
- import { existsSync as existsSync7, readFileSync as readFileSync10 } from "node:fs";
37412
+ import { existsSync as existsSync7, readFileSync as readFileSync10, realpathSync } from "node:fs";
37390
37413
  import { homedir as homedir6 } from "node:os";
37391
37414
  import { dirname as dirname8, resolve as resolve4 } from "node:path";
37392
37415
 
@@ -37535,10 +37558,144 @@ var resolveUpdateStatus = async (currentVersion, deps = {}) => {
37535
37558
  cacheHit
37536
37559
  };
37537
37560
  };
37538
- var defaultRunInstall = (latestVersion, registry2) => {
37539
- const proc = spawnSync2("npm", ["install", "-g", `@warmhub/cli@${latestVersion}`, "--registry", registry2], { stdio: "inherit", timeout: 120000 });
37561
+ var normalizePath = (path2) => path2 ? path2.replaceAll("\\", "/") : "";
37562
+ var pathStartsWith = (path2, prefix) => {
37563
+ if (!prefix)
37564
+ return false;
37565
+ const normalizedPath = normalizePath(path2);
37566
+ const normalizedPrefix = normalizePath(prefix).replace(/\/+$/, "");
37567
+ return normalizedPath === normalizedPrefix || normalizedPath.startsWith(`${normalizedPrefix}/`);
37568
+ };
37569
+ var homeRelative = (homePath, suffix) => `${homePath.replace(/\/+$/, "")}/${suffix.replace(/^\/+/, "")}`;
37570
+ var getActiveWhLookupCommand = (platform2 = process.platform) => platform2 === "win32" ? { command: "where.exe", args: ["wh"] } : { command: "sh", args: ["-lc", "command -v wh"] };
37571
+ var resolveActiveWh = (deps = {}) => {
37572
+ const env = deps.env ?? process.env;
37573
+ const lookup = getActiveWhLookupCommand(deps.platform);
37574
+ const spawn = deps.spawn ?? spawnSync2;
37575
+ const realpath = deps.realpath ?? realpathSync.native;
37576
+ const proc = spawn(lookup.command, lookup.args, {
37577
+ encoding: "utf8",
37578
+ env,
37579
+ timeout: 5000
37580
+ });
37581
+ const activePath = proc.status === 0 ? proc.stdout.split(/\r?\n/).map((line) => line.trim()).find(Boolean) : undefined;
37582
+ let realPath;
37583
+ if (activePath) {
37584
+ try {
37585
+ realPath = realpath(activePath);
37586
+ } catch {
37587
+ realPath = activePath;
37588
+ }
37589
+ }
37590
+ return { activePath, realPath };
37591
+ };
37592
+ var classifyActiveInstallManager = ({
37593
+ activePath,
37594
+ realPath,
37595
+ env = process.env,
37596
+ homePath = homedir6()
37597
+ }) => {
37598
+ if (!activePath)
37599
+ return;
37600
+ const active = normalizePath(activePath);
37601
+ const real = normalizePath(realPath ?? activePath);
37602
+ const paths = [active, real];
37603
+ const bunInstall = env.BUN_INSTALL ?? homeRelative(homePath, ".bun");
37604
+ const pnpmHome = env.PNPM_HOME;
37605
+ const windowsPnpmHome = env.LOCALAPPDATA ? `${env.LOCALAPPDATA}/pnpm` : undefined;
37606
+ const npmPrefix = env.npm_config_prefix ?? env.NPM_CONFIG_PREFIX;
37607
+ const windowsNpmHome = env.APPDATA ? `${env.APPDATA}/npm` : undefined;
37608
+ if (paths.some((path2) => pathStartsWith(path2, homeRelative(homePath, ".bun/bin")) || pathStartsWith(path2, homeRelative(homePath, ".bun/install/global")) || pathStartsWith(path2, `${bunInstall}/bin`) || pathStartsWith(path2, `${bunInstall}/install/global`))) {
37609
+ return "bun";
37610
+ }
37611
+ if (paths.some((path2) => pathStartsWith(path2, pnpmHome) || pathStartsWith(path2, windowsPnpmHome) || path2.includes("/pnpm-global/") || path2.includes("/.local/share/pnpm/") || path2.includes("/Library/pnpm/") || path2.includes("/AppData/Local/pnpm/") || path2.includes("/node_modules/.pnpm/"))) {
37612
+ return "pnpm";
37613
+ }
37614
+ if (paths.some((path2) => pathStartsWith(path2, npmPrefix) || pathStartsWith(path2, windowsNpmHome) || path2.includes("/lib/node_modules/@warmhub/cli/") || path2.includes("/AppData/Roaming/npm/") || path2.includes("/node_modules/@warmhub/cli/"))) {
37615
+ return "npm";
37616
+ }
37617
+ return;
37618
+ };
37619
+ var buildManualCommand = (manager, latestVersion, registry2) => {
37620
+ const spec = `${WH_CACHE_PACKAGE_NAME}@${latestVersion}`;
37621
+ switch (manager) {
37622
+ case "bun":
37623
+ return `bun add -g ${spec} --registry ${registry2}`;
37624
+ case "pnpm":
37625
+ return `pnpm add -g ${spec} --registry ${registry2}`;
37626
+ case "npm":
37627
+ return `npm install -g ${spec} --registry ${registry2}`;
37628
+ }
37629
+ };
37630
+ var buildInstallPlan = (manager, latestVersion, registry2, activePath, realPath) => {
37631
+ const spec = `${WH_CACHE_PACKAGE_NAME}@${latestVersion}`;
37632
+ const manualCommand = buildManualCommand(manager, latestVersion, registry2);
37633
+ switch (manager) {
37634
+ case "bun":
37635
+ return {
37636
+ manager,
37637
+ activePath,
37638
+ realPath,
37639
+ command: "bun",
37640
+ args: ["add", "-g", spec, "--registry", registry2],
37641
+ manualCommand
37642
+ };
37643
+ case "pnpm":
37644
+ return {
37645
+ manager,
37646
+ activePath,
37647
+ realPath,
37648
+ command: "pnpm",
37649
+ args: ["add", "-g", spec, "--registry", registry2],
37650
+ manualCommand
37651
+ };
37652
+ case "npm":
37653
+ return {
37654
+ manager,
37655
+ activePath,
37656
+ realPath,
37657
+ command: "npm",
37658
+ args: ["install", "-g", spec, "--registry", registry2],
37659
+ manualCommand
37660
+ };
37661
+ }
37662
+ };
37663
+ var defaultRunInstall = (plan) => {
37664
+ const proc = spawnSync2(plan.command, plan.args, {
37665
+ stdio: "inherit",
37666
+ timeout: 120000
37667
+ });
37540
37668
  return { status: proc.status, signal: proc.signal, error: proc.error };
37541
37669
  };
37670
+ var verifyActiveVersion = (activePath, deps = {}) => {
37671
+ const platform2 = deps.platform ?? process.platform;
37672
+ const spawn = deps.spawn ?? spawnSync2;
37673
+ const shell = platform2 === "win32" && /\.(?:cmd|bat)$/i.test(normalizePath(activePath));
37674
+ const proc = spawn(activePath, ["--version"], {
37675
+ encoding: "utf8",
37676
+ timeout: 15000,
37677
+ ...shell ? { shell: true } : {}
37678
+ });
37679
+ return {
37680
+ status: proc.status,
37681
+ signal: proc.signal,
37682
+ error: proc.error,
37683
+ stdout: proc.stdout,
37684
+ stderr: proc.stderr
37685
+ };
37686
+ };
37687
+ var defaultVerifyActiveVersion = (activePath) => verifyActiveVersion(activePath);
37688
+ var parseVersionOutput = (output) => output?.match(/\b\d+\.\d+\.\d+(?:[-+][^\s]+)?\b/)?.[0];
37689
+ var formatInstallFailureMessage = (plan, result) => result.error ? `${plan.manager} install failed: ${result.error.message}` : result.signal ? `${plan.manager} install terminated by signal ${result.signal}` : `${plan.manager} install exited with status ${result.status}`;
37690
+ var formatUnknownInstallHint = (activePath, realPath, latestVersion, registry2) => [
37691
+ activePath ? `Active wh path: ${activePath}` : "Active wh path: (not found)",
37692
+ realPath && realPath !== activePath ? `Resolved path: ${realPath}` : "",
37693
+ "Install manually with the package manager that owns that path:",
37694
+ ` ${buildManualCommand("npm", latestVersion, registry2)}`,
37695
+ ` ${buildManualCommand("bun", latestVersion, registry2)}`,
37696
+ ` ${buildManualCommand("pnpm", latestVersion, registry2)}`
37697
+ ].filter(Boolean).join(`
37698
+ `);
37542
37699
  var isDevInstall = (scriptPath) => {
37543
37700
  if (!scriptPath)
37544
37701
  return false;
@@ -37598,6 +37755,8 @@ var runUpdate = async (ctx, { flags, args }, deps = {}) => {
37598
37755
  throw new CliError(2 /* UserInput */, "USER_INPUT", `Unexpected argument: '${args[0]}'`, undefined, "'wh update' takes no positional arguments");
37599
37756
  }
37600
37757
  const runInstall = deps.runInstall ?? defaultRunInstall;
37758
+ const verifyActiveVersion2 = deps.verifyActiveVersion ?? defaultVerifyActiveVersion;
37759
+ const resolveActiveInstall = deps.resolveActiveInstall ?? (() => resolveActiveWh({ env: deps.statusDeps?.env }));
37601
37760
  const isDev = deps.isDev ?? isDevInstall;
37602
37761
  const markNotified = deps.markNotified ?? ((latestVersion) => markUpdateNoticeShown({ latestVersion }));
37603
37762
  const scriptPath = deps.scriptPath ?? process.argv[1];
@@ -37623,6 +37782,19 @@ var runUpdate = async (ctx, { flags, args }, deps = {}) => {
37623
37782
  });
37624
37783
  return;
37625
37784
  }
37785
+ const activeInstall = resolveActiveInstall();
37786
+ const activePath = activeInstall.activePath;
37787
+ const realPath = activeInstall.realPath ?? activePath;
37788
+ const manager = classifyActiveInstallManager({
37789
+ activePath,
37790
+ realPath,
37791
+ env: deps.statusDeps?.env,
37792
+ homePath: deps.statusDeps?.homePath
37793
+ });
37794
+ if (!manager || !activePath || !realPath) {
37795
+ throw new CliError(1 /* Runtime */, "UNKNOWN", "Unable to determine which package manager owns the active wh binary.", undefined, formatUnknownInstallHint(activePath, realPath, status.latestVersion, status.registry));
37796
+ }
37797
+ const installPlan = buildInstallPlan(manager, status.latestVersion, status.registry, activePath, realPath);
37626
37798
  if (!flags.yes) {
37627
37799
  const ok = await ctx.confirm?.(`Update @warmhub/cli ${currentVersion} -> ${status.latestVersion}?`);
37628
37800
  if (!ok) {
@@ -37630,9 +37802,22 @@ var runUpdate = async (ctx, { flags, args }, deps = {}) => {
37630
37802
  return;
37631
37803
  }
37632
37804
  }
37633
- const result = runInstall(status.latestVersion, status.registry);
37805
+ const result = runInstall(installPlan);
37634
37806
  if (result.error || result.signal !== null || result.status !== 0 && result.status !== null) {
37635
- throw new CliError(1 /* Runtime */, "UNKNOWN", result.error ? `npm install failed: ${result.error.message}` : result.signal ? `npm install terminated by signal ${result.signal}` : `npm install exited with status ${result.status}`, result.error, `Try running manually: npm install -g @warmhub/cli@${status.latestVersion} --registry ${status.registry}`);
37807
+ throw new CliError(1 /* Runtime */, "UNKNOWN", formatInstallFailureMessage(installPlan, result), result.error, `Try running manually: ${installPlan.manualCommand}`);
37808
+ }
37809
+ const verify = verifyActiveVersion2(activePath);
37810
+ const observedVersion = parseVersionOutput([verify.stdout, verify.stderr].filter(Boolean).join(`
37811
+ `));
37812
+ if (verify.error || verify.signal !== null || verify.status !== 0 && verify.status !== null || observedVersion !== status.latestVersion) {
37813
+ throw new CliError(1 /* Runtime */, "UNKNOWN", observedVersion ? `Updated install, but active wh reports ${observedVersion} instead of ${status.latestVersion}.` : "Updated install, but active wh version could not be verified.", verify.error, [
37814
+ `Active wh path: ${activePath}`,
37815
+ realPath !== activePath ? `Resolved path: ${realPath}` : "",
37816
+ observedVersion ? `Observed version: ${observedVersion}` : "",
37817
+ `Expected version: ${status.latestVersion}`,
37818
+ `Manual command: ${installPlan.manualCommand}`
37819
+ ].filter(Boolean).join(`
37820
+ `));
37636
37821
  }
37637
37822
  markNotified(status.latestVersion);
37638
37823
  ctx.status(`Updated to ${status.latestVersion}.`);
@@ -37808,7 +37993,7 @@ async function checkCompatibility(ctx, domainPath, canonicalVerb, args) {
37808
37993
  try {
37809
37994
  const caps = await ctx.client.diagnostics.capabilities();
37810
37995
  if (isNewerVersion(caps.minSupportedSdk, SDK_VERSION)) {
37811
- throw new CliError(4 /* Backend */, "BACKEND", `Your CLI (SDK v${SDK_VERSION}) is older than the minimum supported version (${caps.minSupportedSdk}).`, undefined, "Update with: bun install @warmhub/cli@latest");
37996
+ throw new CliError(4 /* Backend */, "BACKEND", `Your CLI (SDK v${SDK_VERSION}) is older than the minimum supported version (${caps.minSupportedSdk}).`, undefined, "Update with: wh update --yes");
37812
37997
  }
37813
37998
  } catch (err) {
37814
37999
  if (err instanceof CliError)
@@ -38874,7 +39059,7 @@ function resolveLogLevel(flags, env) {
38874
39059
  // package.json
38875
39060
  var package_default3 = {
38876
39061
  name: "@warmhub/cli",
38877
- version: "0.59.0",
39062
+ version: "0.60.0",
38878
39063
  private: false,
38879
39064
  type: "module",
38880
39065
  description: "The wh CLI for WarmHub — create repos, commit and query data, and compound knowledge with your AI agents.",
@@ -39515,4 +39700,4 @@ if (!updateCheckSuppressedByArgv && shouldRunUpdateCheck(updateEligibility)) {
39515
39700
  var interceptedExitCode = await maybeHandleComponentShellBoundary(dispatchArgv);
39516
39701
  process.exitCode = interceptedExitCode === undefined ? await runCli(dispatchArgv, { version: package_default3.version }) : interceptedExitCode;
39517
39702
 
39518
- //# debugId=133777AA8F34C0BB64756E2164756E21
39703
+ //# debugId=E83ADE028217301D64756E2164756E21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@warmhub/cli",
3
- "version": "0.59.0",
3
+ "version": "0.60.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "The wh CLI for WarmHub — create repos, commit and query data, and compound knowledge with your AI agents.",