Semantic code search plugin for OpenCode — find code by meaning, not just strings.
Beacon indexes your codebase using embeddings and provides 15 powerful tools for semantic search, dependency analysis, code quality checks, and more.
- Semantic Search — Find code by meaning, not just keyword matching
- Hybrid Search — Vector + BM25 + identifier boosting for best recall
- Smart Context Injection — Auto-inject relevant code into context
- Query Expansion — Expand queries with synonyms (Turkish + English)
- Incremental Suggestions — Autocomplete for search queries
- File Relationship Graph — Who imports whom? Dependency tracking
- Change Impact Analysis — What breaks if I change this file?
- Pattern Search — Find API endpoints, DB queries, React components, etc.
- Code Smell Detection — Dead code, duplicates, complex functions
- Documentation Linking — Connect code to JSDoc, README, related docs
- Temporal Search — Search within git history date ranges
- Multi-repo Search — Search across multiple repositories
- Semantic Diff — Compare files by meaning, not just syntax
- OpenCode — Latest version
- Embedding API — One of:
- Ollama (local, free) —
nomic-embed-text-v2-moeor any Ollama embedding model - OpenAI —
text-embedding-3-smallortext-embedding-3-large - Any OpenAI-compatible API — Custom embedding endpoints
- Ollama (local, free) —
# Install Ollama (if not installed)
curl -fsSL https://ollama.com/install.sh | sh
# Pull embedding model (768 dimensions, ~957 MB)
ollama pull nomic-embed-text-v2-moe
# Start Ollama service
sudo systemctl start ollama# Set your OpenAI API key
export OPENAI_API_KEY="sk-..."Any OpenAI-compatible embedding API works. Just configure in global config (see below).
# In your OpenCode project
npm install opencode-beaconThen add to opencode.json:
{
"plugin": ["opencode-beacon"]
}# Clone to OpenCode plugins directory
git clone https://github.com/nixaut-codelabs/opencode-beacon.git ~/.config/opencode/plugins/beacon
# Install dependencies
cd ~/.config/opencode/plugins/beacon
npm installCopy plugin.ts and scripts/ to ~/.config/opencode/plugins/beacon/:
mkdir -p ~/.config/opencode/plugins/beacon
cp plugin.ts ~/.config/opencode/plugins/beacon/
cp -r scripts ~/.config/opencode/plugins/beacon/
cp package.json ~/.config/opencode/plugins/beacon/
cd ~/.config/opencode/plugins/beacon
npm installOnce installed, Beacon automatically indexes your codebase on session start. Use the 15 tools in OpenCode:
| Tool | Description | Example |
|---|---|---|
beacon_search |
Semantic code search | "user authentication flow" |
beacon_context |
Smart context injection | "database connection setup" |
beacon_expand |
Query expansion | "giriş sistemi" → ["login", "auth"] |
beacon_suggest |
Autocomplete suggestions | "user ser" → ["userService", "user-service.ts"] |
| Tool | Description | Example |
|---|---|---|
beacon_graph |
File dependencies | file: "auth.ts", type: "dependents" |
beacon_impact |
Change impact analysis | file: "types.ts" → risk level |
beacon_pattern |
Pattern matching | pattern: "api-endpoint" |
beacon_smell |
Code smell detection | type: "dead_code" |
| Tool | Description | Example |
|---|---|---|
beacon_temporal |
Git history + search | query: "auth", since: "2024-01-01" |
beacon_multi |
Multi-repo search | query: "config", repos: "repo1,repo2" |
beacon_diff |
Semantic file comparison | file1: "a.ts", file2: "b.ts" |
beacon_docs |
Documentation linking | file: "auth.ts" → JSDoc, README |
| Tool | Description |
|---|---|
beacon_status |
Health check |
beacon_index |
Index status |
beacon_reindex |
Force re-index |
Beacon uses a 3-tier config system: defaults → global → project (project wins).
Platform-specific locations:
| Platform | Path |
|---|---|
| Linux | ~/.config/opencode/beacon.json |
| macOS | ~/Library/Application Support/opencode/beacon.json |
| Windows | %APPDATA%/opencode/beacon.json |
Example global config:
{
"embedding": {
"provider": "ollama",
"api_base": "http://localhost:11434/v1",
"model": "nomic-embed-text-v2-moe",
"api_key_env": "",
"dimensions": 768
},
"search": {
"top_k": 10,
"similarity_threshold": 0.25
},
"storage": {
"path": ".opencode/.beacon"
}
}Create .opencode/beacon.json in your project root to override global settings:
{
"embedding": {
"model": "text-embedding-3-small",
"dimensions": 1536
}
}{
"embedding": {
"provider": "ollama",
"api_base": "http://localhost:11434/v1",
"model": "nomic-embed-text-v2-moe",
"api_key_env": "",
"dimensions": 768
}
}{
"embedding": {
"provider": "openai",
"api_base": "https://api.openai.com/v1",
"model": "text-embedding-3-small",
"api_key_env": "OPENAI_API_KEY",
"dimensions": 1536
}
}Set your API key: export OPENAI_API_KEY="sk-..."
Any API that implements /v1/embeddings endpoint:
{
"embedding": {
"provider": "custom",
"api_base": "https://your-api.com/v1",
"model": "your-embedding-model",
"api_key_env": "YOUR_API_KEY_ENV_VAR",
"dimensions": 1024
}
}Beacon adds these slash commands to OpenCode:
| Command | Description |
|---|---|
/beacon-search <query> |
Semantic code search |
/beacon-status |
Show index status |
/beacon-reindex |
Force full re-index |
/beacon-impact <file> |
Analyze change impact |
/beacon-smell |
Detect code smells |
Beacon shows toast notifications when:
- Index is ready after session start
- Re-index completes
- Errors occur during sync
- Indexing — On session start, Beacon walks your codebase, chunks files, and generates embeddings via configured API
- Storage — Embeddings stored in SQLite with
sqlite-vecfor fast vector search - Hybrid Search — Combines vector similarity, BM25 keyword matching, and identifier boosting
- Incremental Updates — Only re-indexes changed files (tracked via git hash)
- Auto-sync — Background sync on session start, incremental updates on file edits
plugin.ts → OpenCode plugin wrapper (15 tools)
scripts/
├── lib/
│ ├── db.js → SQLite + sqlite-vec operations
│ ├── embedder.js → OpenAI-compatible embedding API
│ ├── chunker.js → Code chunking strategy
│ ├── graph.js → Dependency graph builder
│ ├── patterns.js → Code pattern definitions
│ ├── synonyms.js → Query expansion (TR + EN)
│ └── ...
├── search.js → Core semantic search
├── context.js → Smart context injection
├── sync.js → Full/diff-based indexing
└── ...
| Metric | Value |
|---|---|
| Index speed | ~100 files/sec (GPU), ~20 files/sec (CPU) |
| Search latency | <200ms (GPU), <500ms (CPU) |
| Memory usage | ~50MB base, +1MB per 1000 chunks |
| Disk usage | ~1MB per 1000 chunks |
GPU Acceleration: If you have an AMD GPU with ROCm, Beacon automatically uses it for 5-10x faster embedding.
User: "Where is the authentication logic?"
→ beacon_search(query="authentication logic")
→ Returns: auth.ts, middleware/auth-guard.ts, routes/login.ts
User: "What files depend on types.ts?"
→ beacon_impact(file="types.ts")
→ Returns: 5 direct dependents, 12 transitive, risk: medium
User: "Show me all API endpoints"
→ beacon_pattern(pattern="api-endpoint")
→ Returns: 23 endpoints across 8 files
User: "What auth code changed this week?"
→ beacon_temporal(query="auth", since="2025-01-01")
→ Returns: 4 files changed in date range
Run beacon_reindex or restart OpenCode session.
Ensure Ollama is running:
systemctl status ollama
sudo systemctl start ollama- Use GPU (ROCm) for 5-10x speedup
- Reduce
search.top_kin config - Increase
search.similarity_thresholdto filter more aggressively
If you changed embedding models, run beacon_reindex to rebuild the index.
Contributions welcome! Please:
- Fork the repo
- Create a feature branch
- Test your changes
- Submit a PR
- Original Beacon — sagarmk/beacon-plugin for Claude Code
- OpenCode Port — Community effort
- Ollama — Local embedding inference
- sqlite-vec — Vector search in SQLite
MIT © 2026 OpenCode Community
Original Beacon: MIT © 2026 Sagar MK