# nono-opencode-tinfoil A [`nono`](https://github.com/guybedford/nono) sandbox profile for running [OpenCode](https://opencode.ai) with access to [Tinfoil](https://tinfoil.sh) enclaves and other LLM providers. ## Quick Start ```bash git clone https://github.com/autonomic/nono-opencode-tinfoil.git cd nono-opencode-tinfoil make install # Ensure ~/.local/bin is in your PATH opencode ``` ## Install ### macOS / Linux ```bash git clone https://github.com/autonomic/nono-opencode-tinfoil.git cd nono-opencode-tinfoil make install ``` This installs: - The sandbox profile to `~/.config/nono/profiles/opencode-tinfoil.json` - A wrapper script to `~/.local/bin/opencode` ### Requirements - [nono](https://github.com/guybedford/nono) installed e.g. `brew install nono` - `opencode` installed globally. If not already installed, you can use any of: - **Homebrew**: `brew install opencode` - **npm**: `npm i -g opencode-ai` - **Other**: Any Node version manager (Volta, fnm, etc.) ## How it works ``` you type: opencode ↓ ~/.local/bin/opencode (wrapper) ↓ scans PATH for the real opencode binary (skips itself — finds brew, npm, volta, etc.) ↓ exec nono run --profile opencode-tinfoil --allow-cwd -- ↓ opencode runs inside the sandbox ``` The wrapper resolves the real `opencode` binary at runtime by scanning every directory in your `PATH`. It skips itself, so it works regardless of: - Where opencode is installed (Homebrew on macOS/Linux, npm global, Volta, etc.) - PATH ordering between the wrapper and the real binary - opencode version bumps You just type `opencode` from any project directory and it runs sandboxed. ### PATH ordering If a non-sandboxed `opencode` appears *earlier* on your `PATH` than the wrapper, typing `opencode` will bypass the sandbox. The installer detects and warns about this. Fix it by adding this to your shell config file (e.g., `~/.bashrc` or `~/.zshrc`): ```bash export PATH="$HOME/.local/bin:$PATH" ``` Or add an alias to your shell profile: ```bash alias opencode="$HOME/.local/bin/opencode" ``` ## Usage From any project directory: ```bash opencode ``` Or use the profile directly with any opencode binary: ```bash nono run --profile opencode-tinfoil --allow-cwd -- opencode ``` You can also point it at a specific binary: ```bash # Homebrew (macOS) nono run --profile opencode-tinfoil --allow-cwd -- /opt/homebrew/bin/opencode # Homebrew (Linux) nono run --profile opencode-tinfoil --allow-cwd -- /home/linuxbrew/.linuxbrew/bin/opencode # npm global nono run --profile opencode-tinfoil --allow-cwd -- $(npm root -g)/opencode/bin/opencode ``` ## Tinfoil integration The profile allows network access to: - `*.tinfoil.sh` - `inference.tinfoil.sh` - `containers.tinfoil.sh` - `127.0.0.1` (supports Tinfoil local proxy at `http://127.0.0.1:3301/v1`) - `ghcr.io` It also grants read/write access to `~/.tinfoil` for Tinfoil credentials. Other LLM provider network options (Anthropic, GLM, Kimi, etc.) are provided as commented-out entries in the profile for easy activation. ## Security model - Current working directory: read/write - OpenCode config: read/write - Tinfoil config: read/write - SSH private keys, AWS/GCP/Azure credentials, kubeconfig: denied - `sudo`, `su`, `doas`, `passwd`, disk tools: denied ### Environment Variables | Status | Variables / Patterns | |--------|----------------------| | Allowed | `PATH`, `HOME`, `USER`, `SHELL`, `TERM` | | Denied | `AWS_*`, `GOOGLE_*`, `AZURE_*`, `KUBECONFIG`, `SSH_AUTH_SOCK` | ## Uninstall ```bash make uninstall ``` ## License GPL-3.0 ## Troubleshooting **"command not found: opencode"** Ensure `~/.local/bin` is in your `PATH`. Add `export PATH="$HOME/.local/bin:$PATH"` to your `.bashrc` or `.zshrc` and restart your terminal. **Sandbox is being bypassed** If you have another version of `opencode` installed (e.g. via Homebrew) that appears earlier in your `PATH` than the wrapper, the sandbox will be bypassed. Check this using `which -a opencode`. The wrapper at `~/.local/bin/opencode` must come first.