@botconnector/bccli 0.4.0-beta.53 → 0.4.0-beta.55

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.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/version.ts
4
- var VERSION = true ? "0.4.0-beta.53" : "0.0.0-dev";
4
+ var VERSION = true ? "0.4.0-beta.55" : "0.0.0-dev";
5
5
 
6
6
  export {
7
7
  VERSION
package/dist/cli.js CHANGED
@@ -12,7 +12,7 @@ import "./chunk-YATYUXV7.js";
12
12
  import "./chunk-PSO7R5AD.js";
13
13
  import {
14
14
  VERSION
15
- } from "./chunk-Y3J5XLHS.js";
15
+ } from "./chunk-KOPSZHK5.js";
16
16
  import {
17
17
  helpText,
18
18
  parseCliArgs
@@ -108,7 +108,7 @@ async function main() {
108
108
  return runModelsCommand(args, { env: process.env, cwd, out: (s) => console.log(s), err: (s) => console.error(s), fetch: globalThis.fetch });
109
109
  }
110
110
  if (args.command === "update") {
111
- const { runUpdateCommand } = await import("./update-6SGG73NB.js");
111
+ const { runUpdateCommand } = await import("./update-ZAX5PCLX.js");
112
112
  return runUpdateCommand({ env: process.env });
113
113
  }
114
114
  if (args.command === "acp") {
@@ -117,7 +117,7 @@ async function main() {
117
117
  return 0;
118
118
  }
119
119
  if (args.command === "serve") {
120
- const { startServe } = await import("./serve-CIPCJQEV.js");
120
+ const { startServe } = await import("./serve-NENIGKAA.js");
121
121
  const handle = await startServe({ port: args.port, host: args.host, token: args.token, cwd, env: process.env });
122
122
  process.stderr.write(`bccli serve ${handle.url} \u2014 Authorization: Bearer ${handle.token}
123
123
  `);
@@ -196,7 +196,7 @@ async function main() {
196
196
  let updateMessage;
197
197
  if (rt.config.updateCheck !== "off" && !process.env.BCCLI_NO_UPDATE_CHECK) {
198
198
  try {
199
- const { checkForUpdate } = await import("./update-6SGG73NB.js");
199
+ const { checkForUpdate } = await import("./update-ZAX5PCLX.js");
200
200
  const update = await checkForUpdate({ home: rt.home, fetch: globalThis.fetch, now: /* @__PURE__ */ new Date() });
201
201
  updateMessage = update;
202
202
  } catch {
@@ -8,7 +8,7 @@ import "./chunk-YATYUXV7.js";
8
8
  import "./chunk-PSO7R5AD.js";
9
9
  import {
10
10
  VERSION
11
- } from "./chunk-Y3J5XLHS.js";
11
+ } from "./chunk-KOPSZHK5.js";
12
12
  import {
13
13
  LOOPBACK_BIND,
14
14
  MAX_FRAME_BYTES,
@@ -1,15 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  VERSION
4
- } from "./chunk-Y3J5XLHS.js";
4
+ } from "./chunk-KOPSZHK5.js";
5
5
  import {
6
6
  t
7
7
  } from "./chunk-LUTJZME3.js";
8
8
 
9
9
  // src/update.ts
10
10
  import { spawnSync } from "child_process";
11
- import { mkdirSync, readFileSync, renameSync, writeFileSync } from "fs";
12
- import { join } from "path";
11
+ import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "fs";
12
+ import { dirname, join } from "path";
13
13
  var REGISTRY_URL = "https://registry.npmjs.org/-/package/@botconnector/bccli/dist-tags";
14
14
  var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
15
15
  function splitVersion(v) {
@@ -98,12 +98,40 @@ async function checkForUpdate(deps) {
98
98
  return void 0;
99
99
  }
100
100
  }
101
+ function updateSpawnCommand(version, platform = process.platform, nodeExecPath = process.execPath, targetVersion) {
102
+ const spec = `@botconnector/bccli@${targetVersion ?? channelFor(version)}`;
103
+ if (platform !== "win32") return { command: "npm", args: ["i", "-g", spec] };
104
+ const npmCli = join(dirname(nodeExecPath), "node_modules", "npm", "bin", "npm-cli.js");
105
+ return { command: nodeExecPath, args: [npmCli, "i", "-g", spec], npmCli };
106
+ }
101
107
  async function runUpdateCommand(deps) {
102
- const version = deps.env.BCCLI_VERSION_OVERRIDE ?? VERSION;
103
- const spec = `@botconnector/bccli@${channelFor(version)}`;
104
- const spawnFn = deps.spawn ?? spawnSync;
105
- const cmd = process.platform === "win32" ? "npm.cmd" : "npm";
106
- const r = spawnFn(cmd, ["i", "-g", spec], { stdio: "inherit", env: deps.env });
108
+ const current = deps.env.BCCLI_VERSION_OVERRIDE ?? VERSION;
109
+ let target;
110
+ try {
111
+ const response = await (deps.fetch ?? fetch)(REGISTRY_URL, {
112
+ signal: AbortSignal.timeout(8e3),
113
+ cache: "no-store",
114
+ headers: { "cache-control": "no-cache" }
115
+ });
116
+ if (!response.ok) throw new Error(`HTTP ${response.status}`);
117
+ const tags = await response.json();
118
+ target = tags[channelFor(current)];
119
+ if (!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(target ?? "")) throw new Error("invalid registry version");
120
+ } catch (error) {
121
+ console.error(`Could not verify BCCLI update version: ${String(error)}. No changes made.`);
122
+ return 1;
123
+ }
124
+ if (compareVersions(target, current) <= 0) {
125
+ console.log(`BCCLI ${current} is already up to date (registry: ${target}); no changes made.`);
126
+ return 0;
127
+ }
128
+ const spec = updateSpawnCommand(current, deps.platform, deps.nodeExecPath, target);
129
+ if (spec.npmCli && !existsSync(spec.npmCli)) {
130
+ console.error(`npm CLI was not found at ${spec.npmCli}. Update manually with: npm install -g @botconnector/bccli@${channelFor(deps.env.BCCLI_VERSION_OVERRIDE ?? VERSION)}`);
131
+ return 1;
132
+ }
133
+ const r = (deps.spawn ?? spawnSync)(spec.command, spec.args, { stdio: "inherit", env: deps.env, shell: false });
134
+ if (r.error) console.error(`BCCLI update failed: ${r.error.message}. Try: npm install -g @botconnector/bccli@${channelFor(deps.env.BCCLI_VERSION_OVERRIDE ?? VERSION)}`);
107
135
  return typeof r.status === "number" ? r.status : 1;
108
136
  }
109
137
  export {
@@ -112,5 +140,6 @@ export {
112
140
  compareVersions,
113
141
  dueForCheck,
114
142
  runUpdateCommand,
115
- updateNotice
143
+ updateNotice,
144
+ updateSpawnCommand
116
145
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botconnector/bccli",
3
- "version": "0.4.0-beta.53",
3
+ "version": "0.4.0-beta.55",
4
4
  "description": "BCCLI — BotConnector AI coding agent for the terminal",
5
5
  "type": "module",
6
6
  "bin": {