instabox 0.8.235 → 0.8.236

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/bin/instabox.mjs CHANGED
@@ -29,6 +29,7 @@ import {
29
29
  real,
30
30
  runCli,
31
31
  sha256File,
32
+ sharedShim,
32
33
  } from '../lib/cli.mjs';
33
34
  import { browserCommand, canOpenBrowser, deviceLogin } from '../lib/login.mjs';
34
35
  import { makeDirPrivate, sessionArgs } from '../lib/ssh.mjs';
@@ -283,6 +284,13 @@ async function ensureBundledCli(bundled, found) {
283
284
  }
284
285
  if (version === 'dev' || version?.endsWith('-dirty'))
285
286
  return `instabox CLI at ${found} is a development build (${version}), left as is`;
287
+ // A tool manager's shim that already holds instabox (SUP2-1915) is not written again.
288
+ const shim = sharedShim(found, target);
289
+ if (shim)
290
+ return {
291
+ line: `instabox CLI${v} at ${found} is ${shim.whose} shared shim, which also starts ${shim.users}, left as is`,
292
+ more: `\n ${dim('it now holds instabox, so they run instabox instead · to repair it:')} ${shim.repair}`,
293
+ };
286
294
  // Only a target that identifies itself as InstaBox can be upgraded through a symlink.
287
295
  const dir = dirname(target);
288
296
  try {
package/cli/SHA256SUMS CHANGED
@@ -1,6 +1,6 @@
1
- cb91de1f9ce490f25bc324f129338f47190ad9068a0317c0a5090127bb02dd4b instabox-darwin-amd64
2
- 72977937e60ca9a6f5ad109d858e6d5c2b30b5698d1e7d1b25c074a35864fc59 instabox-darwin-arm64
3
- f18cea632ce486184ca870b5174abba3c2e32ed10821d675812ef10c44606598 instabox-linux-amd64
4
- 58a67acd9e060ecdc7455ad67bf4066f4e13e08f3539c07ebe7393864333d1d0 instabox-linux-arm64
5
- 98008a8a7627f87d441593aaa59396525135035cbb945f6aabc32504ecb65767 instabox-windows-amd64.exe
6
- fd467736b21563154da0358cd937119f187fd37f881c1e6a6218d6829a5757c9 instabox-windows-arm64.exe
1
+ 50a1ae3c31305340485e80aba9b8eb943db07a7ab4fb3a2ae16f84fc0684be0c instabox-darwin-amd64
2
+ 7a20debce6dde85a93929454fd024cc08afbf5f4afca2fb9ba2f0afc0251b9bf instabox-darwin-arm64
3
+ 63ee4948f7b450819917fe6c299c51e061cd73bbfd488506a675d386044313cf instabox-linux-amd64
4
+ 6af349d21c0ac354fdfd19973a11af7b348f031568f6300ce12dd7842ff4810b instabox-linux-arm64
5
+ 85de46eb0d1c22ede40ce5aa528f911c1b1fc0a136aaeccc38ba909741fe0c5f instabox-windows-amd64.exe
6
+ bd1a8b9eb834fc1e3957833c7a6e30c2935b50785321e0863570afe2bf81a5d3 instabox-windows-arm64.exe
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/lib/cli.mjs CHANGED
@@ -8,13 +8,14 @@ import {
8
8
  copyFileSync,
9
9
  createReadStream,
10
10
  mkdirSync,
11
+ readdirSync,
11
12
  realpathSync,
12
13
  renameSync,
13
14
  rmSync,
14
15
  statSync,
15
16
  } from 'node:fs';
16
17
  import { constants as osConstants, homedir } from 'node:os';
17
- import { dirname, join, sep } from 'node:path';
18
+ import { basename, dirname, join, sep } from 'node:path';
18
19
  import { fileURLToPath } from 'node:url';
19
20
  import { buildName, platformFor } from './platforms.mjs';
20
21
 
@@ -159,6 +160,60 @@ export function findCli({ env = process.env, self = process.argv[1], platform =
159
160
  return null;
160
161
  }
161
162
 
163
+ // Tool managers' shims that every tool they manage links to: one binary that starts the tool named
164
+ // by how it was run (as sharedShims in cmd/instabox/update.go).
165
+ const SHARED_SHIMS = new Map([
166
+ ['volta-shim', 'Volta'],
167
+ ['mise', 'mise'],
168
+ ['mise-shim', 'mise'],
169
+ ['proto-shim', 'proto'],
170
+ ]);
171
+ const commandName = (name) => name.toLowerCase().replace(/\.exe$/, '');
172
+
173
+ // names in a sentence: "a and b", "a, b and c", "a, b, c and 2 more".
174
+ function someNames(names) {
175
+ if (names.length > 3) return `${names.slice(0, 3).join(', ')} and ${names.length - 3} more`;
176
+ if (names.length === 1) return names[0];
177
+ return `${names.slice(0, -1).join(', ')} and ${names.at(-1)}`;
178
+ }
179
+
180
+ // When target, the file the CLI at found resolves to, is a tool manager's shared shim: its name is
181
+ // one of SHARED_SHIMS, or other commands next to found or target link to it. Old installers wrote
182
+ // the CLI over Volta's shim, which node and npm run through too, and it must not be written again
183
+ // (SUP2-1915). {whose, users, repair} for the line that says so, else null.
184
+ export function sharedShim(found, target, { platform = process.platform, arch = process.arch } = {}) {
185
+ const manager = SHARED_SHIMS.get(commandName(basename(target)));
186
+ const others = new Set();
187
+ for (const dir of new Set([dirname(found), dirname(target)])) {
188
+ let entries = [];
189
+ try {
190
+ entries = readdirSync(dir, { withFileTypes: true });
191
+ } catch {
192
+ continue;
193
+ }
194
+ for (const e of entries) {
195
+ if (!e.isSymbolicLink() || e.name === basename(found) || commandName(e.name) === 'instabox') continue;
196
+ if (real(join(dir, e.name)) === target) others.add(e.name);
197
+ }
198
+ }
199
+ if (!manager && !others.size) return null;
200
+ // node, npm and npx first, then by name.
201
+ const rank = (n) => {
202
+ const i = ['node', 'npm', 'npx'].indexOf(n);
203
+ return i < 0 ? 3 : i;
204
+ };
205
+ const names = [...others].sort((a, b) => rank(a) - rank(b) || (a < b ? -1 : 1));
206
+ const users = names.length ? someNames(names) : 'other commands';
207
+ const asset =
208
+ platform === 'darwin' ? 'macos' : platform === 'linux' ? (arch === 'arm64' ? 'linux-arm' : 'linux') : null;
209
+ let repair = 'reinstall the tool manager that made those links, then update instabox through it';
210
+ if (manager === 'Volta' && asset)
211
+ repair = `replace <version> with what volta --version prints and run: curl -fsSL https://github.com/volta-cli/volta/releases/download/v<version>/volta-<version>-${asset}.tar.gz | tar -xzf - -C "${dirname(target)}" volta-shim, then update instabox with: volta install instabox@latest`;
212
+ else if (manager === 'Volta') repair = 'reinstall Volta, then update instabox with: volta install instabox@latest';
213
+ else if (manager) repair = `reinstall ${manager}, then update instabox through ${manager}`;
214
+ return { whose: manager ? `${manager}'s` : "a tool manager's", users, repair };
215
+ }
216
+
162
217
  // What `instabox --version` prints after "instabox ", or null when it does not run. Async, so a
163
218
  // slow or hung binary does not hold up the rest of onboarding.
164
219
  export async function cliVersion(path) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "instabox",
3
- "version": "0.8.235",
3
+ "version": "0.8.236",
4
4
  "description": "A cloud box for your coding agent, the instabox CLI and its agent skills in one command: npx instabox@latest",
5
5
  "type": "module",
6
6
  "bin": {