@bivy/bivy 0.16.9-staging.7 → 0.16.9-staging.9

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/bivy.mjs CHANGED
@@ -41,7 +41,7 @@ import { renderManagedBlock, upsertManagedBlock, removeManagedBlock, rcFileForSh
41
41
  import { removeInstallAndState } from "./uninstall-paths.mjs";
42
42
  import { findAvailablePort, reconcilePort } from "./port-picker.mjs";
43
43
  import { resolveAttachSessionId } from "./attach-session-id.mjs";
44
- import { detectInstallKind as classifyInstallKind } from "./install-kind.mjs";
44
+ import { detectInstallKind as classifyInstallKind, npmGlobalPrefix } from "./install-kind.mjs";
45
45
  import { hasConfiguredService as configuredServiceExists } from "./service-state.mjs";
46
46
 
47
47
  const selfScript = fileURLToPath(import.meta.url);
@@ -4447,7 +4447,13 @@ async function runUpdate(args = []) {
4447
4447
 
4448
4448
  if (kind === "npm-global") {
4449
4449
  console.log(c.dim(`Updating the globally-installed bivy package (channel: ${channel})…`));
4450
- const code = await run("npm", ["install", "-g", `@bivy/bivy@${channel}`, "--no-audit", "--no-fund"]);
4450
+ // npm's configured global prefix may not be the prefix that owns this
4451
+ // executable (for example, `npm config get prefix` can remain /usr after
4452
+ // installing Bivy with --prefix ~/.local). Always update the installation
4453
+ // that is actually running this command.
4454
+ const prefix = npmGlobalPrefix(repoRoot);
4455
+ const prefixArgs = prefix ? ["--prefix", prefix] : [];
4456
+ const code = await run("npm", ["install", "-g", ...prefixArgs, `@bivy/bivy@${channel}`, "--no-audit", "--no-fund"]);
4451
4457
  if (code !== 0) {
4452
4458
  console.log(c.yellow(`npm reported an issue (exit ${code}). Try: sudo npm i -g @bivy/bivy@${channel}`));
4453
4459
  process.exit(code);
@@ -18,3 +18,23 @@ export function detectInstallKind(repoRoot, existsSync = fs.existsSync) {
18
18
  if (inNodeModules) return "npm-global";
19
19
  return "packaged";
20
20
  }
21
+
22
+ /**
23
+ * Return the npm prefix that owns a package installed below node_modules.
24
+ * npm uses <prefix>/lib/node_modules on Unix and <prefix>/node_modules on
25
+ * other platforms. The running npm process may have a different configured
26
+ * prefix, so deriving it from the package path is important for user-local
27
+ * installs.
28
+ */
29
+ export function npmGlobalPrefix(repoRoot) {
30
+ let current = path.resolve(repoRoot);
31
+ while (true) {
32
+ if (path.basename(current) === "node_modules") {
33
+ const parent = path.dirname(current);
34
+ return path.basename(parent) === "lib" ? path.dirname(parent) : parent;
35
+ }
36
+ const parent = path.dirname(current);
37
+ if (parent === current) return undefined;
38
+ current = parent;
39
+ }
40
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bivy/bivy",
3
- "version": "0.16.9-staging.7",
3
+ "version": "0.16.9-staging.9",
4
4
  "type": "module",
5
5
  "license": "AGPL-3.0-only",
6
6
  "description": "Run coding agents on machines you own. Open-source, self-hostable agent workspace.",