bx-mac 0.1.5 → 0.2.1

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.
Files changed (2) hide show
  1. package/README.md +73 -83
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,38 +1,38 @@
1
- # bx
1
+ # 📦 bx
2
2
 
3
- Launch VSCode, a terminal, Claude Code, or any command in a macOS sandbox. Your tools can only see the project you're working on — not your private files, SSH keys, or other repositories.
3
+ > **Put your AI in a box.** Launch VSCode, Claude Code, a terminal, or any command in a macOS sandbox your tools can only see the project you're working on.
4
4
 
5
- ## Why?
5
+ ## 🤔 Why?
6
6
 
7
- AI-powered coding tools like Claude Code, Copilot, or Cline run with broad file system access. A misguided tool call or hallucinated path could accidentally read your SSH keys, credentials, tax documents, or private photos.
7
+ AI-powered coding tools like Claude Code, Copilot, or Cline run with **broad file system access**. A misguided tool call or hallucinated path could accidentally read your SSH keys, credentials, tax documents, or private photos.
8
8
 
9
9
  **bx** wraps any application in a macOS sandbox (`sandbox-exec`) that blocks access to everything except the project directory you explicitly specify. No containers, no VMs, no setup — just one command.
10
10
 
11
- ## What it does
11
+ ```bash
12
+ bx ~/work/my-project
13
+ ```
14
+
15
+ That's it. 🎉 VSCode opens with full access to `~/work/my-project` and nothing else.
12
16
 
13
- - Blocks access to `~/Documents`, `~/Desktop`, `~/Downloads`, and all other personal folders
14
- - Blocks access to sibling projects — only the directory you specify is accessible
15
- - Protects sensitive dotdirs like `~/.ssh`, `~/.gnupg`, `~/.docker`, `~/.cargo` by default
16
- - Keeps VSCode, extensions, shell, Node.js, and other tooling fully functional
17
- - Generates sandbox rules dynamically based on your actual `$HOME` contents
18
- - Supports `.bxignore` to hide secrets like `.env` files within a project
19
- - Supports `~/.bxallow` to grant access to shared utility directories
17
+ ## What it does
20
18
 
21
- ## What it doesn't do
19
+ - 🔒 Blocks `~/Documents`, `~/Desktop`, `~/Downloads`, and all other personal folders
20
+ - 🚧 Blocks sibling projects — only the directory you specify is accessible
21
+ - 🛡️ Protects sensitive dotdirs like `~/.ssh`, `~/.gnupg`, `~/.docker`, `~/.cargo`
22
+ - ⚙️ Keeps VSCode, extensions, shell, Node.js, and other tooling fully functional
23
+ - 🔍 Generates sandbox rules dynamically based on your actual `$HOME` contents
24
+ - 📝 Supports `.bxignore` to hide secrets like `.env` files within a project
25
+ - 📂 Supports `~/.bxallow` to grant access to shared utility directories
26
+
27
+ ## 🚫 What it doesn't do
22
28
 
23
29
  - **No network restrictions** — API calls, git push/pull, npm install all work normally
24
30
  - **No process isolation** — this is file-level sandboxing, not a container
25
31
  - **No protection against root/sudo** — the sandbox applies to the user-level process
26
- - **macOS only** — relies on `sandbox-exec` which is an Apple-specific technology
27
- - **Not a security guarantee** — `sandbox-exec` is undocumented and may have limitations; treat this as a safety net, not a vault
28
-
29
- ## Requirements
30
-
31
- - macOS (tested on Sequoia / macOS 15)
32
- - Node.js >= 22
33
- - Visual Studio Code installed in `/Applications` (for `code` mode)
32
+ - **macOS only** — relies on `sandbox-exec` (Apple-specific)
33
+ - **Not a vault** — `sandbox-exec` is undocumented; treat this as a safety net, not a guarantee
34
34
 
35
- ## Install
35
+ ## 📥 Install
36
36
 
37
37
  ```bash
38
38
  # Homebrew
@@ -48,71 +48,65 @@ pnpm install && pnpm build
48
48
  pnpm link -g
49
49
  ```
50
50
 
51
- ## Quick start
51
+ **Requirements:** macOS (tested on Sequoia 15), Node.js >= 22
52
52
 
53
- ```bash
54
- # Launch VSCode with sandbox protection
55
- bx ~/work/my-project
56
- ```
53
+ ## 🚀 Modes
57
54
 
58
- That's it. VSCode opens with full access to `~/work/my-project` and nothing else.
59
-
60
- ## Modes
61
-
62
- ```bash
63
- bx [workdir] # VSCode (default)
64
- bx code [workdir] # VSCode (explicit)
65
- bx term [workdir] # sandboxed login shell ($SHELL -l)
66
- bx claude [workdir] # Claude Code CLI
67
- bx exec [workdir] -- command [args...] # arbitrary command
68
- ```
55
+ | Command | What it launches |
56
+ |---|---|
57
+ | `bx [workdir]` | 🖥️ VSCode (default) |
58
+ | `bx code [workdir]` | 🖥️ VSCode (explicit) |
59
+ | `bx term [workdir]` | 💻 Sandboxed login shell (`$SHELL -l`) |
60
+ | `bx claude [workdir]` | 🤖 Claude Code CLI |
61
+ | `bx exec [workdir] -- cmd` | ⚡ Any command you want |
69
62
 
70
63
  If no directory is given, the current directory is used.
71
64
 
72
65
  ### Examples
73
66
 
74
67
  ```bash
75
- # Work on a project in a sandboxed terminal
68
+ # 🖥️ VSCode with sandbox protection
69
+ bx ~/work/my-project
70
+
71
+ # 💻 Work on a project in a sandboxed terminal
76
72
  bx term ~/work/my-project
77
73
 
78
- # Let Claude Code work on a project without access to anything else
74
+ # 🤖 Let Claude Code work on a project nothing else visible
79
75
  bx claude ~/work/my-project
80
76
 
81
- # Run a script in a sandbox
77
+ # Run a script in a sandbox
82
78
  bx exec ~/work/my-project -- python train.py
83
79
 
84
- # VSCode with verbose output
80
+ # 🔍 See the generated sandbox profile
85
81
  bx --verbose ~/work/my-project
86
82
  ```
87
83
 
88
- ## Options
84
+ ## ⚙️ Options
89
85
 
90
86
  | Option | Description |
91
87
  |---|---|
92
88
  | `--verbose` | Print the generated sandbox profile to stderr |
93
- | `--profile-sandbox` | Use an isolated VSCode profile (separate extensions and settings, `code` mode only) |
89
+ | `--profile-sandbox` | Use an isolated VSCode profile (separate extensions/settings, `code` mode only) |
94
90
 
95
- ## Configuration
91
+ ## 📝 Configuration
96
92
 
97
- bx uses three optional config files, all with the same format: one entry per line, `#` for comments.
93
+ bx uses three optional config files one entry per line, `#` for comments.
98
94
 
99
95
  ### `~/.bxallow`
100
96
 
101
- Allow extra directories beyond the working directory. Paths are relative to `$HOME`.
97
+ Allow extra directories beyond the working directory. Paths relative to `$HOME`.
102
98
 
103
99
  ```gitignore
104
100
  # Shared shell scripts and utilities
105
101
  work/bin
106
- # Shared libraries used across projects
107
102
  shared/libs
108
103
  ```
109
104
 
110
105
  ### `~/.bxignore`
111
106
 
112
- Block additional dotdirs or files in your home. Paths are relative to `$HOME`.
107
+ Block additional dotdirs or files in your home. Paths relative to `$HOME`.
113
108
 
114
109
  ```gitignore
115
- # Cloud provider credentials
116
110
  .aws
117
111
  .azure
118
112
  .kube
@@ -121,74 +115,70 @@ Block additional dotdirs or files in your home. Paths are relative to `$HOME`.
121
115
 
122
116
  These are blocked **in addition** to the built-in protected list:
123
117
 
124
- > `.Trash` `.ssh` `.gnupg` `.docker` `.zsh_sessions` `.cargo` `.gradle` `.gem`
118
+ > 🔒 `.Trash` `.ssh` `.gnupg` `.docker` `.zsh_sessions` `.cargo` `.gradle` `.gem`
125
119
 
126
120
  ### `<project>/.bxignore`
127
121
 
128
- Block paths within the working directory itself. Supports glob patterns.
122
+ Block paths within the working directory. Supports glob patterns.
129
123
 
130
124
  ```gitignore
131
- # Environment files with secrets
132
125
  .env
133
126
  .env.*
134
-
135
- # Credentials and keys
136
127
  secrets/
137
128
  **/*.pem
138
129
  **/*.key
139
130
  ```
140
131
 
141
- ## How it works
132
+ ## 🔧 How it works
142
133
 
143
134
  bx generates a macOS sandbox profile at launch time:
144
135
 
145
136
  1. **Scan** `$HOME` for non-hidden directories
146
- 2. **Block** each one individually with a `(deny file* (subpath ...))` rule
147
- 3. **Skip** the working directory, `~/Library`, dotfiles, and any paths from `~/.bxallow`
148
- 4. **Descend** into parent directories of allowed paths to block only siblings (because SBPL deny rules always override allow rules — you can't deny a parent and allow a child)
137
+ 2. **Block** each one individually with `(deny file* (subpath ...))`
138
+ 3. **Skip** the working directory, `~/Library`, dotfiles, and `~/.bxallow` paths
139
+ 4. **Descend** into parent directories of allowed paths to block only siblings (because SBPL deny rules always override allow rules)
149
140
  5. **Append** deny rules for protected dotdirs and `.bxignore` entries
150
- 6. **Write** the profile to `/tmp`, launch VSCode via `sandbox-exec`, clean up on exit
141
+ 6. **Write** the profile to `/tmp`, launch the app via `sandbox-exec`, clean up on exit
151
142
 
152
143
  ### Why not a simple deny-all + allow?
153
144
 
154
- Apple's Sandbox Profile Language (SBPL) has a critical quirk: **`deny` always wins over `allow`**, regardless of rule order. This means:
145
+ Apple's SBPL has a critical quirk: **`deny` always wins over `allow`**, regardless of rule order:
155
146
 
156
147
  ```scheme
157
- ;; Does NOT work — the deny still blocks myproject
148
+ ;; Does NOT work — the deny still blocks myproject
158
149
  (deny file* (subpath "/Users/me/work"))
159
150
  (allow file* (subpath "/Users/me/work/myproject"))
160
151
  ```
161
152
 
162
- Additionally, a broad `(deny file* (subpath HOME))` breaks `kqueue`/FSEvents file watchers and SQLite `fcntl` locks, causing VSCode errors even for paths that should be allowed.
163
-
164
- bx avoids both issues by **never denying a parent of an allowed path**. Instead, it walks the directory tree and denies only the specific siblings that should be blocked.
153
+ Additionally, a broad `(deny file* (subpath HOME))` breaks `kqueue`/FSEvents file watchers and SQLite locks, causing VSCode errors.
165
154
 
166
- ## Tips
155
+ bx avoids both issues by **never denying a parent of an allowed path** — it walks the directory tree and blocks only the specific siblings.
167
156
 
168
- **See what's happening:** Use `--verbose` to inspect the generated profile before trusting it with sensitive work.
157
+ ## 🛡️ Safety checks
169
158
 
170
- **Test the sandbox:** Try reading a blocked file from VSCode's terminal:
159
+ bx detects and prevents problematic scenarios:
171
160
 
172
- ```bash
173
- cat ~/Documents/something.txt # Should fail with "Operation not permitted"
174
- cat ~/Desktop/file.txt # Should fail
175
- ls ~/work/other-project/ # Should fail
176
- ```
161
+ - **🔄 Sandbox nesting:** If `CODEBOX_SANDBOX=1` is set (auto-propagated), bx refuses to start — nested sandboxes cause silent failures.
162
+ - **🔍 Unknown sandbox:** On startup, bx probes `~/Documents`, `~/Desktop`, `~/Downloads`. If any return `EPERM`, another sandbox is active — bx aborts.
163
+ - **⚠️ VSCode terminal:** If `VSCODE_PID` is set, bx warns that it will launch a *new* instance, not sandbox the current one.
177
164
 
178
- ## Safety checks
165
+ ## 💡 Tips
179
166
 
180
- bx detects and prevents problematic scenarios:
167
+ **Verify it works** try reading a blocked file from the sandboxed terminal:
181
168
 
182
- - **Sandbox nesting:** If `CODEBOX_SANDBOX=1` is set (automatically passed to child processes), bx refuses to start — nested `sandbox-exec` causes silent failures.
183
- - **Unknown sandbox:** On startup, bx probes `~/Documents`, `~/Desktop`, and `~/Downloads`. If any return `EPERM`, another sandbox is already active — bx aborts.
184
- - **VSCode terminal:** If `VSCODE_PID` is set, bx warns that it will launch a *new* instance, not sandbox the current one.
169
+ ```bash
170
+ cat ~/Documents/something.txt # Operation not permitted
171
+ cat ~/Desktop/file.txt # Operation not permitted
172
+ ls ~/work/other-project/ # ❌ Operation not permitted
173
+ cat ./src/index.ts # ✅ Works!
174
+ ```
185
175
 
186
- ## Known limitations
176
+ ## ⚠️ Known limitations
187
177
 
188
- - **File watcher warnings:** VSCode may log `EPERM` errors for `fs.watch()` on some paths. These are cosmetic and don't affect functionality.
189
- - **SQLite warnings:** `state.vscdb` errors may appear in logs when VSCode's state database paths are affected. Extensions still work correctly.
190
- - **`sandbox-exec` is undocumented:** Apple provides no official documentation for SBPL. The tool works in practice but could change with OS updates.
178
+ - **File watcher warnings:** VSCode may log `EPERM` for `fs.watch()` on some paths cosmetic only
179
+ - **SQLite warnings:** `state.vscdb` errors may appear in logs extensions still work
180
+ - **`sandbox-exec` is undocumented:** Apple could change behavior with OS updates
191
181
 
192
- ## License
182
+ ## 📄 License
193
183
 
194
184
  MIT — see [LICENSE](LICENSE).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bx-mac",
3
- "version": "0.1.5",
3
+ "version": "0.2.1",
4
4
  "description": "Launch apps in a macOS sandbox — only the project directory is accessible",
5
5
  "type": "module",
6
6
  "bin": {