Thanks for your interest in contributing! This guide will help you get started.
git clone https://github.com/isanchez31/opencode-sandbox-plugin.git
cd opencode-sandbox-plugin
bun installbun run build # Build the project
bun test # Run tests
bun test --coverage # Run tests with coverage
bun run check # Lint + format check (Biome)
bun run check:fix # Lint + format auto-fix
bun run typecheck # Type check (tsc --noEmit)
bun run dev # Watch mode-
Fork the repo and create a branch from
main:git checkout -b feat/my-feature
-
Make your changes and add tests if applicable.
-
Ensure everything passes before committing:
bun run check # Lint + format bun run typecheck # Type check bun test # Tests
-
Commit using Conventional Commits:
feat: add new sandbox restriction fix: handle edge case in config loading docs: update README examples test: add tests for network config chore: update dependencies -
Open a Pull Request against
main. PR titles must follow the same conventional commit format.
This project uses the following tools to maintain code quality:
- Biome for linting and formatting (replaces ESLint + Prettier)
- TypeScript strict mode for type safety
- tsc --noEmit for type checking beyond what Biome covers
- bun test with built-in coverage for testing
All checks run automatically in CI. PRs must pass the quality and test jobs before merging.
src/
├── index.ts # Plugin entry point and hooks
└── config.ts # Config loading, defaults, and resolution
test/
├── config.test.ts # Config unit tests
└── plugin.test.ts # Plugin integration tests
Unit tests validate logic in isolation, but to verify the sandbox actually works you need to test with OpenCode.
bun run buildOpenCode loads plugins from ~/.cache/opencode/node_modules/. Copy your build there:
# Remove the existing version (if any)
rm -rf ~/.cache/opencode/node_modules/opencode-sandbox
# Copy your local build
cp -r . ~/.cache/opencode/node_modules/opencode-sandboxIn your test project's opencode.json:
{
"plugin": ["opencode-sandbox"]
}Start OpenCode in the test project. You should see in the logs:
[opencode-sandbox] Initialized — writes allowed in: /path/to/project, /tmp
Ask the AI to run these commands and verify the expected behavior:
| Command | Expected result |
|---|---|
echo "hello" |
Works normally |
touch ~/test-file |
Read-only file system |
cat ~/.ssh/id_rsa |
Permission denied |
curl https://evil.com |
Connection blocked |
curl https://registry.npmjs.org |
Works (allowed domain) |
OpenCode logs are at ~/.local/share/opencode/log/. Look for [opencode-sandbox] entries to debug issues.
- Always test with operations the user can normally do (like
touch ~/file), not just system-level operations (liketouch /etc/file) which are already blocked by OS permissions - If
bwrapis not installed, the plugin will fail open — commands run without sandbox. Install it withsudo apt install bubblewrap(Debian/Ubuntu) - On Ubuntu 24.04+, see the AppArmor fix in the README
Use the bug report template and include:
- Your OS and version
- Steps to reproduce
- Expected vs actual behavior
- Relevant logs
Use the feature request template.
See SECURITY.md for reporting vulnerabilities.
By contributing, you agree that your contributions will be licensed under the MIT License.