bpmax-cli 0.2.1-beta.31 → 0.2.1-beta.32

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/bin.js CHANGED
@@ -492,7 +492,7 @@ function pluginAgentCapabilityForRequest(method, normalizedPath) {
492
492
  // package.json
493
493
  var package_default = {
494
494
  name: "bpmax-cli",
495
- version: "0.2.1-beta.31",
495
+ version: "0.2.1-beta.32",
496
496
  description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
497
497
  type: "module",
498
498
  bin: {
@@ -764,6 +764,9 @@ function printResult(format, value) {
764
764
  switch (format) {
765
765
  case "json":
766
766
  console.log(JSON.stringify(withJsonNotice(value), null, 2));
767
+ if (!isRecord(value)) {
768
+ emitTextNotice();
769
+ }
767
770
  return;
768
771
  case "ndjson":
769
772
  if (Array.isArray(value)) {
@@ -773,6 +776,7 @@ function printResult(format, value) {
773
776
  } else {
774
777
  console.log(JSON.stringify(value));
775
778
  }
779
+ emitTextNotice();
776
780
  return;
777
781
  case "table":
778
782
  if (Array.isArray(value)) {
@@ -782,6 +786,7 @@ function printResult(format, value) {
782
786
  } else {
783
787
  console.log(value);
784
788
  }
789
+ emitTextNotice();
785
790
  return;
786
791
  case "pretty":
787
792
  default:
@@ -24379,10 +24384,14 @@ var UPDATE_STATE_FILE = "update-state.json";
24379
24384
  var CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
24380
24385
  var FETCH_TIMEOUT_MS = 5e3;
24381
24386
  var NPM_INSTALL_TIMEOUT_MS = 10 * 60 * 1e3;
24382
- function buildRegistryUrl(packageName = NPM_PACKAGE, env = process.env) {
24387
+ function updateChannelForVersion(version) {
24388
+ const prerelease = version.trim().replace(/^v/, "").split("+", 1)[0].split("-", 2)[1] || "";
24389
+ return prerelease.split(".", 1)[0].toLowerCase() === "beta" ? "beta" : "latest";
24390
+ }
24391
+ function buildRegistryUrl(packageName = NPM_PACKAGE, env = process.env, distTag = "latest") {
24383
24392
  const base = env.BPMAX_CLI_REGISTRY_URL || DEFAULT_REGISTRY_URL;
24384
24393
  const normalizedBase = base.endsWith("/") ? base : `${base}/`;
24385
- return new URL(`${encodeURIComponent(packageName).replace("%40", "@")}/latest`, normalizedBase).toString();
24394
+ return new URL(`${encodeURIComponent(packageName).replace("%40", "@")}/${distTag}`, normalizedBase).toString();
24386
24395
  }
24387
24396
  function parseVersion(version) {
24388
24397
  const clean = version.trim().replace(/^v/, "").split("+")[0];
@@ -24469,7 +24478,7 @@ async function fetchLatestVersion(options = {}) {
24469
24478
  const timer = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
24470
24479
  try {
24471
24480
  const fetchImpl = options.fetchImpl || fetch;
24472
- const response = await fetchImpl(buildRegistryUrl(options.packageName, options.env), {
24481
+ const response = await fetchImpl(buildRegistryUrl(options.packageName, options.env, options.distTag), {
24473
24482
  signal: controller.signal
24474
24483
  });
24475
24484
  if (!response.ok) {
@@ -24494,7 +24503,11 @@ async function readUpdateState(configDir) {
24494
24503
  if (typeof parsed.latest_version !== "string" || typeof parsed.checked_at !== "number") {
24495
24504
  return null;
24496
24505
  }
24497
- return { latest_version: parsed.latest_version, checked_at: parsed.checked_at };
24506
+ return {
24507
+ latest_version: parsed.latest_version,
24508
+ checked_at: parsed.checked_at,
24509
+ channel: parsed.channel === "beta" ? "beta" : "latest"
24510
+ };
24498
24511
  } catch {
24499
24512
  return null;
24500
24513
  }
@@ -24511,6 +24524,10 @@ async function checkCachedUpdate(currentVersion, configDir = getConfigDir()) {
24511
24524
  if (!state) {
24512
24525
  return null;
24513
24526
  }
24527
+ const channel = updateChannelForVersion(currentVersion);
24528
+ if (state.channel !== channel) {
24529
+ return null;
24530
+ }
24514
24531
  const checkedAtMs = state.checked_at * 1e3;
24515
24532
  if (Date.now() - checkedAtMs > CACHE_TTL_MS) {
24516
24533
  return null;
@@ -24518,19 +24535,24 @@ async function checkCachedUpdate(currentVersion, configDir = getConfigDir()) {
24518
24535
  if (!isNewerVersion(state.latest_version, currentVersion)) {
24519
24536
  return null;
24520
24537
  }
24521
- return { current: currentVersion, latest: state.latest_version };
24538
+ return { current: currentVersion, latest: state.latest_version, channel };
24522
24539
  }
24523
24540
  async function refreshUpdateCache(currentVersion, configDir = getConfigDir(), options = {}) {
24524
24541
  if (process.env.BPMAX_CLI_NO_UPDATE_NOTIFIER) {
24525
24542
  return null;
24526
24543
  }
24544
+ const channel = updateChannelForVersion(currentVersion);
24527
24545
  const state = await readUpdateState(configDir);
24528
- if (state && Date.now() - state.checked_at * 1e3 < CACHE_TTL_MS) {
24529
- return isNewerVersion(state.latest_version, currentVersion) ? { current: currentVersion, latest: state.latest_version } : null;
24546
+ if (state && state.channel === channel && Date.now() - state.checked_at * 1e3 < CACHE_TTL_MS) {
24547
+ return isNewerVersion(state.latest_version, currentVersion) ? { current: currentVersion, latest: state.latest_version, channel } : null;
24530
24548
  }
24531
- const latest = await fetchLatestVersion(options);
24532
- await writeUpdateState({ latest_version: latest, checked_at: Math.floor(Date.now() / 1e3) }, configDir);
24533
- return isNewerVersion(latest, currentVersion) ? { current: currentVersion, latest } : null;
24549
+ const latest = await fetchLatestVersion({ ...options, distTag: options.distTag || channel });
24550
+ await writeUpdateState({
24551
+ latest_version: latest,
24552
+ checked_at: Math.floor(Date.now() / 1e3),
24553
+ channel
24554
+ }, configDir);
24555
+ return isNewerVersion(latest, currentVersion) ? { current: currentVersion, latest, channel } : null;
24534
24556
  }
24535
24557
  async function executablePath() {
24536
24558
  const candidate = process.argv[1] || "";
@@ -24601,7 +24623,8 @@ function skillsAction(result) {
24601
24623
  };
24602
24624
  }
24603
24625
  function registerUpdateCommands(program2, deps = {}) {
24604
- const fetchLatest = deps.fetchLatest || (() => fetchLatestVersion({ packageName: NPM_PACKAGE }));
24626
+ const channel = updateChannelForVersion(VERSION);
24627
+ const fetchLatest = deps.fetchLatest || (() => fetchLatestVersion({ packageName: NPM_PACKAGE, distTag: channel }));
24605
24628
  const detectInstall = deps.detectInstall || detectCurrentInstallMethod;
24606
24629
  const install = deps.install || ((version) => runNpmInstall(version, { packageName: NPM_PACKAGE }));
24607
24630
  const runSkills = deps.syncSkills || ((version, options) => syncSkills(version, options));
@@ -24628,6 +24651,7 @@ function registerUpdateCommands(program2, deps = {}) {
24628
24651
  previous_version: VERSION,
24629
24652
  current_version: VERSION,
24630
24653
  latest_version: latest,
24654
+ channel,
24631
24655
  action: updateAvailable ? "update_available" : "already_up_to_date",
24632
24656
  auto_update: detect.method === "npm" && detect.npmAvailable,
24633
24657
  skills_status: {
@@ -24653,6 +24677,7 @@ function registerUpdateCommands(program2, deps = {}) {
24653
24677
  previous_version: VERSION,
24654
24678
  current_version: VERSION,
24655
24679
  latest_version: latest,
24680
+ channel,
24656
24681
  action: "already_up_to_date",
24657
24682
  ...skillsAction(synced2)
24658
24683
  };
@@ -24675,6 +24700,7 @@ function registerUpdateCommands(program2, deps = {}) {
24675
24700
  previous_version: VERSION,
24676
24701
  current_version: VERSION,
24677
24702
  latest_version: latest,
24703
+ channel,
24678
24704
  action: "manual_required",
24679
24705
  message: `Automatic update unavailable: ${manualReason(detect)} (path: ${detect.resolvedPath})`,
24680
24706
  manual_command: `npm install -g ${NPM_PACKAGE}@${latest}`,
@@ -24715,6 +24741,7 @@ ${detail}` : ""}`);
24715
24741
  previous_version: VERSION,
24716
24742
  current_version: latest,
24717
24743
  latest_version: latest,
24744
+ channel,
24718
24745
  action: "updated",
24719
24746
  ...skillsAction(synced)
24720
24747
  };
@@ -24905,13 +24932,13 @@ var pendingUpdate = null;
24905
24932
  var pendingSkills = null;
24906
24933
  var pendingSetup = null;
24907
24934
  function updateMessage(info) {
24908
- return `bpmax-cli ${info.latest} available, current ${info.current}, run: bpmax-cli update`;
24935
+ return `\u68C0\u6D4B\u5230 bpmax-cli \u65B0\u7248\u672C ${info.latest}\uFF0C\u5F53\u524D\u7248\u672C ${info.current}\uFF0C\u8BF7\u6267\u884C\uFF1Abpmax-cli update --json`;
24909
24936
  }
24910
24937
  function skillsMessage(info) {
24911
24938
  if (!info.current) {
24912
- return "bpmax-cli skills not installed, run: bpmax-cli update";
24939
+ return "\u5C1A\u672A\u5B89\u88C5\u4E0E\u5F53\u524D bpmax-cli \u5339\u914D\u7684 Skills\uFF0C\u8BF7\u6267\u884C\uFF1Abpmax-cli update --json";
24913
24940
  }
24914
- return `bpmax-cli skills ${info.current} out of sync with binary ${info.target}, run: bpmax-cli update`;
24941
+ return `bpmax-cli Skills \u7248\u672C ${info.current} \u4E0E CLI ${info.target} \u4E0D\u4E00\u81F4\uFF0C\u8BF7\u6267\u884C\uFF1Abpmax-cli update --json`;
24915
24942
  }
24916
24943
  function setupMessage() {
24917
24944
  return [
@@ -24930,6 +24957,13 @@ function shouldWriteSetupNotice(argv) {
24930
24957
  }
24931
24958
  return args.includes("--version") || args.includes("-V");
24932
24959
  }
24960
+ function shouldWriteImmediateVersionNotice(argv) {
24961
+ const args = argv.slice(2);
24962
+ if (args.length === 0) {
24963
+ return true;
24964
+ }
24965
+ return args.some((arg) => ["--version", "-V", "--help", "-h"].includes(arg));
24966
+ }
24933
24967
  async function setupNotices(argv = process.argv) {
24934
24968
  pendingUpdate = await checkCachedUpdate(VERSION);
24935
24969
  const skills = await checkSkillsSync(VERSION);
@@ -24950,6 +24984,8 @@ async function setupNotices(argv = process.argv) {
24950
24984
  notice.update = {
24951
24985
  current: pendingUpdate.current,
24952
24986
  latest: pendingUpdate.latest,
24987
+ channel: pendingUpdate.channel,
24988
+ next_command: "bpmax-cli update --json",
24953
24989
  message: updateMessage(pendingUpdate)
24954
24990
  };
24955
24991
  }
@@ -24957,17 +24993,26 @@ async function setupNotices(argv = process.argv) {
24957
24993
  notice.skills = {
24958
24994
  current: pendingSkills.current,
24959
24995
  target: pendingSkills.target,
24996
+ next_command: "bpmax-cli update --json",
24960
24997
  message: skillsMessage(pendingSkills)
24961
24998
  };
24962
24999
  }
24963
25000
  return Object.keys(notice).length > 0 ? notice : null;
24964
25001
  });
24965
- void refreshUpdateCache(VERSION).then((info) => {
24966
- if (info) {
24967
- pendingUpdate = info;
25002
+ if (!pendingUpdate) {
25003
+ try {
25004
+ pendingUpdate = await refreshUpdateCache(VERSION);
25005
+ } catch {
24968
25006
  }
24969
- }).catch(() => {
24970
- });
25007
+ }
25008
+ if (shouldWriteImmediateVersionNotice(argv)) {
25009
+ if (pendingUpdate) {
25010
+ console.error(updateMessage(pendingUpdate));
25011
+ }
25012
+ if (pendingSkills) {
25013
+ console.error(skillsMessage(pendingSkills));
25014
+ }
25015
+ }
24971
25016
  }
24972
25017
 
24973
25018
  // src/bin.ts
@@ -25063,7 +25108,7 @@ function printCommandError(error) {
25063
25108
  const message = error instanceof Error ? error.message : String(error);
25064
25109
  const structured = error && typeof error === "object" ? error : {};
25065
25110
  if (formatFromArgv(process.argv) === "json") {
25066
- console.log(JSON.stringify({
25111
+ console.log(JSON.stringify(withJsonNotice({
25067
25112
  ok: false,
25068
25113
  error: message,
25069
25114
  ...typeof structured.code === "string" ? { code: structured.code } : {},
@@ -25085,9 +25130,10 @@ function printCommandError(error) {
25085
25130
  ...typeof structured.env === "string" ? { env: structured.env } : {},
25086
25131
  ...commandDomainFromArgv(process.argv) ? { domain: commandDomainFromArgv(process.argv) } : {},
25087
25132
  ...commandEndpointHint(process.argv) ? { endpoint: commandEndpointHint(process.argv) } : {}
25088
- }, null, 2));
25133
+ }), null, 2));
25089
25134
  return;
25090
25135
  }
25136
+ emitTextNotice();
25091
25137
  console.error(message);
25092
25138
  }
25093
25139
  function commanderExitCode(error) {