opencode-semantic-search
v0.1.0
Published
Local-first semantic search plugin for OpenCode — hybrid vector + BM25 search, AST chunking, smart grep override.
Maintainers
Readme
opencode-semantic-search
Local-first semantic search plugin for OpenCode, with smart grep routing and incremental indexing.
Quickstart
Prerequisites
Install
Option A — bunx (recommended after the package is on npm)
Runs the same installer as install.sh from the published package (no clone):
# Global shim (~/.config/opencode/plugins) — default
bunx opencode-semantic-search@latest
# Project-local only (./.opencode/plugins)
bunx opencode-semantic-search@latest install --localOther flags match install.sh (see below).
Option B — Remote install.sh (curl)
curl -fsSL https://raw.githubusercontent.com/jainprashul/opencode-semantic-search/main/install.sh | bashUse bash -s -- --local after the pipe for a project-local shim instead of the default global install.
Option C — Git clone
git clone https://github.com/jainprashul/opencode-semantic-search.git
cd opencode-semantic-search
# Global (default): ~/.config/opencode/plugins
bash install.sh
# Project-local only: ./.opencode/plugins
bash install.sh --localCommon installer modes (clone or remote script):
# explicit global install (default)
bash install.sh --global
# project-local only
bash install.sh --local
# OpenAI embeddings instead of Ollama
bash install.sh --openai-key-env OPENAI_API_KEY --skip-ollama
# custom Ollama model
bash install.sh --ollama-model nomic-embed-text
# skip Ollama checks/model pull
bash install.sh --skip-ollamaThe script installs dependencies, writes a plugin shim, optionally pulls the Ollama model, writes config, and runs integration self-tests when the test scripts are present (git clone); npm installs skip that step.
Start
# Ollama users
ollama serve
# open your codebase
cd /path/to/your/repo
opencodeAvailable tools
semantic_search(query, top_k?, threshold?, path?)grep(pattern|query, ...)smart route: conceptual -> semantic, exact/regex ->rgindex_status()health and coverage statsreindex()full index rebuilddiagnostic_bundle()JSON support bundle (provider, index, routing history)
Optional slash aliases (/sem-status, /sem-search, etc.): add Markdown stubs under .opencode/commands/ as described in SETUP.md. Each stub body is an LLM prompt that asks the assistant to call the matching tool.
Verify it works
From this plugin repo:
bun run check
bun run test:integration
bun run diagnostic:bundleExpected:
bun run checkexits successfully (no TypeScript errors).bun run test:integrationprints JSON with"ok":truefrom both suites.bun run diagnostic:bundleprints one JSON bundle with provider health, index stats, DB path, and recent routing outcomes.
In OpenCode (after startup indexing):
index_status()should reportprovider_healthy: true,files_indexed > 0,total_chunks > 0.semantic_search("authentication flow")should return JSON results with file paths and scores.grep("auth retry flow")should return scored semantic matches (score=...) when provider/index are healthy.
Debugging pointers
- No semantic results: ensure embedder is reachable (
ollama serveor valid OpenAI key) and runreindex(). grepbehaving like plain text search: this is expected for exact/regex/single-token patterns.- Wrong results after changing embedding model/dimensions: run
reindex(). - Persistent index issues: remove the project DB under
~/.cache/opencode/semantic-search/<project-hash>/embeddings.db.
Publishing (maintainers)
Bump version in package.json, then:
bun run typecheck
npm publish --access publicprepublishOnly runs typecheck automatically. The npm package name is opencode-semantic-search.
Docs
docs/ARCHITECTURE.mdarchitecture, data flow, index lifecycle, smart grep routingdocs/CONFIG.mdfull configuration reference + install script behaviordocs/DEBUGGING.mdlogging/diagnostics, troubleshooting, and verification playbookSETUP.mdextended setup walkthrough and notes
