Extending
The sandbox is deliberately modular so new capabilities land without surgery on existing code. Three common extensions:
Adding a new tool
Section titled “Adding a new tool”-
Create
internal/tools/my_tool.go. DefineRegisterMyTool(s ToolAdder, deps *Deps)andHandleMyTool(deps *Deps) func(...). -
Add handler tests in
internal/tools/my_tool_test.go. Follow the black-box pattern (package tools_test) and reuse the shared helpersnewTestDeps/textOfdeclared inread_test.go. -
Register in
server.New:tools.RegisterMyTool(reg, deps)This automatically wraps the handler in
scrubMiddlewarebecauseregis thescrubbingRegistrar. -
Add a docs page under
docs/src/content/docs/tools/my-tool.mdand link it from the sidebar (autogenerated from thetools/directory).
Adding a language detector
Section titled “Adding a language detector”See the Detector interface reference for the interface shape. Concretely:
- Create
internal/verify/<language>.gowith a struct implementingDetector. - Extend
Detectininternal/verify/verify.goto check for the marker file. - Update the Dockerfile to install the runtime (
apk add nodejs npm, etc.). - If the linter output format differs from
<file>:<line>:<col>: <msg> (<rule>), either updateverify.ParseLint(for a universal parser) or add a per-detector parser method. - Add unit tests for the detector and an integration test for run_lint with a seeded project.
Adding a scrub pattern
Section titled “Adding a scrub pattern”- Add an entry to the
patternsslice ininternal/scrub/scrub.go. Order matters — more specific patterns first (e.g., Anthropic’ssk-ant-before OpenAI’s genericsk-). - Add a test case to
internal/scrub/scrub_test.goshowing both a positive match and a plausible non-match (to guard against future pattern-interaction surprises). - No other code changes. The scrubber iterates all patterns; new ones fire automatically.
Target: common shapes (API keys from well-known providers, PEM private keys, basic-auth URLs). Entropy-based detection (TruffleHog, gitleaks’ generic rule) is out of scope.
Adding a deny pattern
Section titled “Adding a deny pattern”Same shape as scrub patterns — regex only, fixed set. Edit denyPattern in internal/tools/bash.go. Add the token to the alternation (put specific variants before general ones, e.g. mkfs.ext4 via an optional .\w+ group). Add a test in bash_internal_test.go’s table of match cases.
A note on web tools
Section titled “A note on web tools”WebSearch / WebFetch are not in this sandbox — agents connect a sibling MCP server (Brave / Exa / Tavily / the official fetch server) alongside. See Non-sandbox tools. To control outbound behaviour, configure the agent runtime’s MCP server list and/or your container runtime’s egress policy.