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.
- package/README.md +73 -83
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
# bx
|
|
1
|
+
# 📦 bx
|
|
2
2
|
|
|
3
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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`
|
|
27
|
-
- **Not a
|
|
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
|
-
|
|
51
|
+
**Requirements:** macOS (tested on Sequoia 15), Node.js >= 22
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
# Launch VSCode with sandbox protection
|
|
55
|
-
bx ~/work/my-project
|
|
56
|
-
```
|
|
53
|
+
## 🚀 Modes
|
|
57
54
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
bx [workdir]
|
|
64
|
-
bx
|
|
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
|
-
#
|
|
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
|
|
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
|
-
#
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
147
|
-
3. **Skip** the working directory, `~/Library`, dotfiles, and
|
|
148
|
-
4. **Descend** into parent directories of allowed paths to block only siblings (because SBPL deny rules always override allow rules
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
157
|
+
## 🛡️ Safety checks
|
|
169
158
|
|
|
170
|
-
|
|
159
|
+
bx detects and prevents problematic scenarios:
|
|
171
160
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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
|
-
##
|
|
165
|
+
## 💡 Tips
|
|
179
166
|
|
|
180
|
-
|
|
167
|
+
**Verify it works** — try reading a blocked file from the sandboxed terminal:
|
|
181
168
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
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`
|
|
189
|
-
- **SQLite warnings:** `state.vscdb` errors may appear in logs
|
|
190
|
-
- **`sandbox-exec` is undocumented:** Apple
|
|
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).
|