OpenCode Plugin
Noodlbox plugin for OpenCode with semantic search hooks and MCP tools
The noodlbox plugin for OpenCode provides automatic semantic search augmentation and MCP tools for intelligent codebase exploration.
Installation
Automatic Setup (Recommended)
The easiest way to install the plugin is through the noodlbox CLI:
noodl configure opencodeThis automatically:
- Copies the plugin to
~/.config/opencode/plugin/noodlbox/ - Copies skills to
~/.config/opencode/skill/ - Configures MCP server connection in
~/.config/opencode/opencode.json
Manual Setup
If you prefer manual installation:
- Copy the plugin files:
mkdir -p ~/.config/opencode/plugin/noodlbox
cp -r platforms/opencode/plugin/* ~/.config/opencode/plugin/noodlbox/
cp -r shared/hooks ~/.config/opencode/plugin/noodlbox/shared/- Copy skills:
cp -r shared/skills/* ~/.config/opencode/skill/- Add MCP config to
~/.config/opencode/opencode.json:
{
"mcp": {
"noodlbox": {
"type": "local",
"command": ["noodl", "mcp"]
}
}
}Plugin Architecture
The OpenCode plugin uses a multi-hook architecture for seamless integration:
| Hook | Event | Purpose |
|---|---|---|
session.created | Session start | Lists indexed repositories |
tool.execute.before | Before Glob/Grep/Bash | Runs semantic search, stores results |
chat.message | Before LLM message | Injects search context into message |
tool.execute.after | After MCP tools | Formats query results for display |
How It Works
Automatic Context Injection
When you use search tools (Glob, Grep, Bash), the plugin automatically:
- Intercepts the tool call in
tool.execute.before - Extracts a semantic query from the pattern
- Runs
noodl searchagainst your indexed codebase - Stores results in session-scoped storage (with 30s TTL for memory safety)
- Injects context via
chat.messagehook into the next LLM message - Consumes (clears) the context after injection to prevent stale data
This happens transparently - you get semantic search results without changing your workflow.
Context Format
Search results are injected as XML context:
<noodlbox-context query="authentication">
<!-- Execution flows, symbols, and call chains -->
</noodlbox-context>The LLM sees this context alongside your original search results, providing architectural understanding.
MCP Tools
The plugin connects to the noodlbox MCP server, providing these tools:
| Tool | Purpose |
|---|---|
noodlbox_query_with_context | Semantic code search returning execution flows |
noodlbox_symbol_context | Get 360-degree context for a symbol (references, community, docs) |
noodlbox_detect_impact | Analyze git changes and their ripple effects |
noodlbox_rename_symbol | Multi-file coordinated rename with confidence-tagged edits |
noodlbox_raw_cypher_query | Direct graph queries for advanced analysis |
noodlbox_analyze | Index a new repository |
Skills
Noodlbox provides the noodlbox-setup skill for initializing noodlbox context in a project:
| Skill | Purpose | When to Use |
|---|---|---|
noodlbox-setup | Initialize noodlbox context in a project | "Set up noodlbox" |
Skills are installed to ~/.config/opencode/skill/ and discovered automatically by OpenCode.
Session Startup
On session start, the plugin logs all indexed repositories:
[noodlbox] Indexed repositories:
owner/my-app (last analyzed: 2 hours ago)
owner/other-repo (last analyzed: 1 day ago)This helps you know which repositories have context available.
Example Usage
Automatic Enhancement
When you search with Grep:
Grep for "handleAuth"The plugin automatically augments with semantic search, showing:
- Functions that implement authentication
- Related processes and call chains
- Entry points into the auth system
Explicit Tool Calls
For direct queries:
Use noodlbox_query_with_context to find the payment processing flowImpact Analysis
Before committing:
Use noodlbox_detect_impact to check what my staged changes affectConfiguration
Environment Variables
| Variable | Default | Purpose |
|---|---|---|
NOODLBOX_CLI_PATH | noodl | Path to noodl CLI |
NOODLBOX_HOOK_DEBUG | false | Enable debug logging |
Debug Mode
Enable debug logging to troubleshoot hook execution:
export NOODLBOX_HOOK_DEBUG=trueWorkflow: First-Time Setup
For a new repository:
# 1. Analyze the codebase
noodl analyze /path/to/repo
# 2. Configure OpenCode
noodl configure opencode
# 3. Start coding - hooks work automaticallyWorkflow: Pre-Commit Review
Before committing changes, ask OpenCode:
Use noodlbox_detect_impact to analyze my staged changesReview the impacted processes and plan testing accordingly.
Troubleshooting
Hooks Not Firing
- Check plugin is installed:
ls ~/.config/opencode/plugin/noodlbox/ - Verify shared lib exists:
ls ~/.config/opencode/plugin/noodlbox/shared/hooks/lib.js - Enable debug mode to see hook execution:
export NOODLBOX_HOOK_DEBUG=trueMCP Tools Not Available
- Check MCP config:
cat ~/.config/opencode/opencode.json - Verify noodl is in PATH:
which noodl - Test MCP server:
noodl mcp
No Search Results
- Verify repository is indexed:
noodl list - Re-analyze if needed:
noodl analyze .
Related
- Getting Started - Installation and MCP setup
- Workflows - Step-by-step guides for common tasks