@bivy/bivy 0.8.3-staging.119 → 0.8.3-staging.121

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
@@ -36,7 +36,7 @@ import vm from "node:vm";
36
36
  import { selectStaleSessions, sessionActivityMs } from "./prune-sessions.mjs";
37
37
  import { resolveSessionsLimit, truncateSavedSessions } from "./sessions-list.mjs";
38
38
  import { renderManagedBlock, upsertManagedBlock, removeManagedBlock, rcFileForShell } from "./shim-path.mjs";
39
- import { removeExcept } from "./uninstall-paths.mjs";
39
+ import { removeInstallAndState } from "./uninstall-paths.mjs";
40
40
  import { findAvailablePort, reconcilePort } from "./port-picker.mjs";
41
41
  import { resolveAttachSessionId } from "./attach-session-id.mjs";
42
42
 
@@ -4126,14 +4126,13 @@ async function cmdUninstall(args = []) {
4126
4126
  console.log(c.green(`Removed ${removed} worktree(s).`));
4127
4127
  }
4128
4128
 
4129
- // Delete the app + all local state. A git checkout keeps its source (only
4130
- // the .bivy state dir goes); a packaged install removes the whole app dir.
4131
- // With --keep-sessions, the pi transcripts and the session index are left
4132
- // in place rather than deleted (see removeExcept) — everything else in
4133
- // that state dir (config, credentials, relay enrollment, …) is still
4134
- // removed as normal.
4129
+ // Delete all local state and, for a packaged install, the package itself.
4130
+ // npm-global installs keep state outside repoRoot (normally ~/.bivy), while
4131
+ // tarball installs keep it below repoRoot; removeInstallAndState handles
4132
+ // both layouts. With --keep-sessions, the transcripts and session index
4133
+ // remain in place while config, credentials, relay enrollment, etc. go.
4135
4134
  const keepPaths = keepSessions ? [sessionsDir, metadataPath].filter((p) => fs.existsSync(p)) : [];
4136
- removeExcept(isGitCheckout ? appDir : repoRoot, keepPaths);
4135
+ removeInstallAndState(repoRoot, appDir, { keepInstall: isGitCheckout, keepState: keepPaths });
4137
4136
  fs.rmSync(symlink, { force: true });
4138
4137
 
4139
4138
  console.log(c.green("\nBivy uninstalled from this machine."));
@@ -46,3 +46,27 @@ export function removeExcept(root, keep) {
46
46
  };
47
47
  walk(root);
48
48
  }
49
+
50
+ function isInside(parent, candidate) {
51
+ const relative = path.relative(path.resolve(parent), path.resolve(candidate));
52
+ return relative === "" || (relative !== ".." && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative));
53
+ }
54
+
55
+ /**
56
+ * Remove the state directory and, for packaged installs, the install directory.
57
+ * Tarball installs keep state below the install directory, while npm-global
58
+ * installs keep it separately (normally ~/.bivy), so both layouts must be
59
+ * handled without deleting paths requested by --keep-sessions.
60
+ */
61
+ export function removeInstallAndState(installDir, stateDir, { keepInstall = false, keepState = [] } = {}) {
62
+ if (keepInstall) {
63
+ removeExcept(stateDir, keepState);
64
+ return;
65
+ }
66
+ if (isInside(installDir, stateDir)) {
67
+ removeExcept(installDir, keepState);
68
+ return;
69
+ }
70
+ removeExcept(stateDir, keepState);
71
+ fs.rmSync(installDir, { recursive: true, force: true });
72
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bivy/bivy",
3
- "version": "0.8.3-staging.119",
3
+ "version": "0.8.3-staging.121",
4
4
  "type": "module",
5
5
  "license": "FSL-1.1-ALv2",
6
6
  "description": "Run coding agents on machines you own. Source-available, self-hostable agent workspace.",