Skip to content

Commit 3dc906e

Browse files
committed
fix: update zsh completions and README documentation
- Remove non-existent profiles from zsh completions (node, python, go, git) - Remove aliases using non-existent profiles (sxn, sxp) - Add missing CLI options to zsh completions (--config, --no-config, --trace-file, --allow-read, --allow-write, --deny-read) - Expand README options table with all CLI flags - Improve shell integration docs with Homebrew paths, features, and aliases
1 parent 604ab32 commit 3dc906e

3 files changed

Lines changed: 115 additions & 36 deletions

File tree

.github/workflows/release.yaml

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,9 @@ jobs:
208208
run: |
209209
mkdir -p dist
210210
cp target/${{ matrix.target }}/release/sx dist/
211+
cp -r shell dist/
211212
cd dist
212-
tar czf sx-${{ needs.validate.outputs.version }}-${{ matrix.target }}.tar.gz sx
213+
tar czf sx-${{ needs.validate.outputs.version }}-${{ matrix.target }}.tar.gz sx shell/
213214
shasum -a 256 sx-${{ needs.validate.outputs.version }}-${{ matrix.target }}.tar.gz > sx-${{ needs.validate.outputs.version }}-${{ matrix.target }}.tar.gz.sha256
214215
215216
- name: Upload artifact
@@ -335,6 +336,54 @@ jobs:
335336
' /tmp/formula.rb > /tmp/formula_updated.rb
336337
mv /tmp/formula_updated.rb /tmp/formula.rb
337338
339+
# Ensure install block includes shell scripts (idempotent)
340+
if ! grep -q 'share/"sx"' /tmp/formula.rb; then
341+
sed -i 's|bin.install "sx"|bin.install "sx"\n (share/"sx").install Dir["shell/*"]|' /tmp/formula.rb
342+
fi
343+
344+
# Ensure caveats mention shell integration (idempotent)
345+
if ! grep -q 'Shell integration' /tmp/formula.rb; then
346+
# Replace the caveats block with updated version
347+
cat > /tmp/caveats_block.txt << 'CAVEATS_EOF'
348+
def caveats
349+
<<~EOS
350+
sx restricts filesystem and network access using macOS Seatbelt.
351+
352+
Quick start:
353+
sx -- echo "sandboxed" # Run command in sandbox
354+
sx rust -- cargo build # Use rust profile
355+
sx online -- npm install # Allow network access
356+
357+
Shell integration (add to your shell config):
358+
# Zsh (~/.zshrc)
359+
source #{share}/sx/sx.zsh
360+
361+
# Bash (~/.bashrc)
362+
source #{share}/sx/sx.bash
363+
364+
# Fish
365+
cp #{share}/sx/sx.fish ~/.config/fish/conf.d/
366+
367+
Provides: prompt indicator, tab completion, aliases (sxo, sxl, sxr, sxc)
368+
369+
Documentation: https://github.com/agentic-dev3o/sandbox-shell
370+
EOS
371+
end
372+
CAVEATS_EOF
373+
# Use awk to replace the entire caveats block
374+
awk '
375+
/def caveats/,/^ end$/ {
376+
if (/def caveats/ && !done) {
377+
while ((getline line < "/tmp/caveats_block.txt") > 0) print line
378+
done = 1
379+
}
380+
next
381+
}
382+
{ print }
383+
' /tmp/formula.rb > /tmp/formula_updated.rb
384+
mv /tmp/formula_updated.rb /tmp/formula.rb
385+
fi
386+
338387
# Show changes
339388
echo "==> Updated formula:"
340389
cat /tmp/formula.rb

README.md

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,20 @@ sx --dry-run rust # Preview sandbox profile
140140
| Option | Description |
141141
|--------|-------------|
142142
| `-v, --verbose` | Show sandbox configuration |
143+
| `-d, --debug` | Enable debug mode (log all denials) |
143144
| `-t, --trace` | Trace sandbox violations in real-time (see note below) |
144145
| `--trace-file <PATH>` | Write trace output to file instead of stderr |
145146
| `-n, --dry-run` | Print sandbox profile without executing |
147+
| `-c, --config <PATH>` | Use specific config file |
148+
| `--no-config` | Ignore all config files |
146149
| `--explain` | Show what would be allowed/denied |
147150
| `--init` | Create `.sandbox.toml` in current directory |
151+
| `--offline` | Block all network (default) |
152+
| `--online` | Allow all network |
153+
| `--localhost` | Allow localhost only |
148154
| `--allow-read <PATH>` | Allow read access to path |
149155
| `--allow-write <PATH>` | Allow write access to path |
156+
| `--deny-read <PATH>` | Deny read access to path (override allows) |
150157

151158
> **Note on `--trace`:** The trace output shows sandbox violations from **all sandboxed processes** on the system, not just the current session. This is a limitation of macOS sandbox logging, which doesn't include session identifiers in denial logs. If you're running multiple `sx` sessions simultaneously, violations from all sessions will appear in each trace output.
152159
@@ -226,24 +233,46 @@ System-wide defaults and custom profiles.
226233

227234
## Shell Integration
228235

229-
Add to your shell config for prompt indicators and tab completion:
236+
Optional shell integration provides prompt indicators, tab completion, and aliases.
230237

231-
**Zsh** (`~/.zshrc`):
238+
### Installation
239+
240+
**Zsh** - Add to `~/.zshrc`:
232241
```bash
242+
# If installed via Homebrew
243+
source $(brew --prefix)/share/sx/sx.zsh
244+
245+
# Or from source
233246
source /path/to/sandbox-shell/shell/sx.zsh
234247
```
235248

236-
**Bash** (`~/.bashrc`):
249+
**Bash** - Add to `~/.bashrc`:
237250
```bash
238-
source /path/to/sandbox-shell/shell/sx.bash
251+
source $(brew --prefix)/share/sx/sx.bash
252+
# Or: source /path/to/sandbox-shell/shell/sx.bash
239253
```
240254

241-
**Fish** (`~/.config/fish/conf.d/`):
255+
**Fish** - Copy to config:
242256
```fish
243-
cp shell/sx.fish ~/.config/fish/conf.d/
257+
cp $(brew --prefix)/share/sx/sx.fish ~/.config/fish/conf.d/
244258
```
245259

246-
Provides: prompt indicator, tab completion, aliases (`sxo`, `sxl`, `sxr`).
260+
### Features
261+
262+
**Prompt indicator** - Shows sandbox mode with color coding:
263+
- `[sx:offline]` (red) - Network blocked
264+
- `[sx:localhost]` (yellow) - Localhost only
265+
- `[sx:online]` (green) - Full network access
266+
267+
**Aliases:**
268+
| Alias | Command | Description |
269+
|-------|---------|-------------|
270+
| `sxo` | `sx online` | Full network access |
271+
| `sxl` | `sx localhost` | Localhost only |
272+
| `sxr` | `sx online rust` | Rust with network |
273+
| `sxc` | `sx online gpg claude` | Claude Code with GPG |
274+
275+
**Tab completion** - Complete profiles, options, and commands.
247276

248277
## Development
249278

shell/sx.zsh

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -28,52 +28,53 @@ _sx() {
2828
'base:Minimal sandbox (always included)'
2929
'online:Full network access'
3030
'localhost:Localhost network only'
31-
'node:Node.js/npm toolchain'
32-
'python:Python toolchain'
3331
'rust:Rust/Cargo toolchain'
34-
'go:Go toolchain'
3532
'claude:Claude Code support'
3633
'gpg:GPG signing support'
37-
'git:Git with signing'
3834
)
3935

40-
local -a options
41-
options=(
42-
'--help:Show help'
43-
'--version:Show version'
44-
'--verbose:Verbose output'
45-
'--debug:Debug mode'
46-
'--trace:Trace sandbox violations'
47-
'--dry-run:Show profile without executing'
48-
'--explain:Show what would be allowed/denied'
49-
'--init:Initialize .sandbox.toml'
50-
'--offline:Block all network'
51-
'--online:Allow all network'
52-
'--localhost:Allow localhost only'
53-
)
54-
55-
_arguments \
36+
_arguments -s \
5637
'(-h --help)'{-h,--help}'[Show help]' \
5738
'(-V --version)'{-V,--version}'[Show version]' \
5839
'(-v --verbose)'{-v,--verbose}'[Verbose output]' \
5940
'(-d --debug)'{-d,--debug}'[Debug mode]' \
6041
'(-t --trace)'{-t,--trace}'[Trace violations]' \
42+
'--trace-file=[Write trace to file]:file:_files' \
6143
'(-n --dry-run)'{-n,--dry-run}'[Show profile]' \
44+
'(-c --config)'{-c,--config}'=[Use config file]:file:_files' \
45+
'--no-config[Ignore all config files]' \
6246
'--explain[Show permissions]' \
6347
'--init[Initialize config]' \
6448
'--offline[Block network]' \
6549
'--online[Allow network]' \
6650
'--localhost[Localhost only]' \
67-
'*:profile:_describe "profile" profiles' \
68-
'-- :command:_command_names'
51+
'*--allow-read=[Allow read access]:path:_files' \
52+
'*--allow-write=[Allow write access]:path:_files' \
53+
'*--deny-read=[Deny read access]:path:_files' \
54+
'*:: :->args'
55+
56+
case $state in
57+
args)
58+
if [[ ${words[CURRENT]} == -* ]]; then
59+
return
60+
fi
61+
# Check if we're past -- (command mode)
62+
local i
63+
for (( i=1; i < CURRENT; i++ )); do
64+
if [[ ${words[i]} == "--" ]]; then
65+
_command_names
66+
return
67+
fi
68+
done
69+
_describe -t profiles 'profile' profiles
70+
;;
71+
esac
6972
}
7073

7174
compdef _sx sx
7275

7376
# Aliases for common patterns
74-
alias sxo='sx online'
75-
alias sxl='sx localhost'
76-
alias sxn='sx online node'
77-
alias sxp='sx online python'
78-
alias sxr='sx online rust'
79-
alias sxc='sx gpg online claude'
77+
alias sxo='sx online' # Online network access
78+
alias sxl='sx localhost' # Localhost only
79+
alias sxr='sx online rust' # Rust with network
80+
alias sxc='sx online gpg claude' # Claude Code with GPG signing

0 commit comments

Comments
 (0)