npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

opencode-codebase-index

v0.35.2

Published

Host-neutral semantic codebase search with embeddings, symbol discovery, and call-graph tooling

Readme

open-codebase-index

npm version License: MIT Downloads Build Status Node.js

Search a codebase by meaning, then follow the result into definitions, callers, and dependency paths.

open-codebase-index is a local semantic code index for OpenCode, Jcode, Pi, Codex, Claude Code, and other MCP clients. It combines embeddings, BM25 keyword search, branch-aware filtering, symbol lookup, and a call graph behind agent-friendly tools.

New installs should use open-codebase-index and open-codebase-index-mcp. The legacy package opencode-codebase-index and opencode-codebase-index-mcp remain supported aliases.

For terminal use outside an MCP client, install the package globally and use the concise ocbi command:

npm install -g open-codebase-index
ocbi status --project /path/to/repo --host jcode
ocbi search "retry recovery" --project /path/to/repo

cbi remains available as a compatibility alias. ocbi provides status, indexing, search, definition lookup, and direct caller or callee inspection. See Installation and host setup for the full command reference.

Highlights

  • Semantic and hybrid retrieval for questions where you do not know the identifier.
  • Low-token discovery through codebase_context and codebase_peek.
  • Definition and graph navigation through implementation_lookup, call_graph, and call_graph_path.
  • Incremental, branch-aware indexing with file watching and content-hash reuse.
  • Local storage backed by SQLite, usearch vectors, and a BM25 inverted index.
  • Multiple embedding providers: Ollama, OpenAI, Google, or a custom OpenAI-compatible endpoint.
  • Native parsing for TypeScript/TSX, JavaScript/JSX, Python, Rust, Swift, Go, Java, C#, Ruby, C/C++, Metal, PHP, Apex, Bash, Zig, GDScript, MATLAB, JSON, TOML, YAML, Markdown, HTML, XML, and SVG, plus text fallback for other formats.

Quick start with OpenCode

Requires Node.js 22.13 or newer. Node.js 24 LTS is recommended.

  1. Install the package:

    npm install open-codebase-index

    Legacy installs continue to work with:

    npm install opencode-codebase-index
  2. Add it to opencode.json:

    For OpenCode 2.x:

    {
      "plugins": ["open-codebase-index"]
    }

    For OpenCode 1.x (1.3.4 or newer):

    {
      "plugin": ["open-codebase-index"]
    }

    Legacy alias (OpenCode 2.x):

    {
      "plugins": ["opencode-codebase-index"]
    }

    Legacy alias (OpenCode 1.x):

    {
      "plugin": ["opencode-codebase-index"]
    }
  3. Run /status, then /index.

  4. Ask a repository question, for example:

    Where is authentication state validated before an API request?

The first index creates embeddings. Later runs reuse unchanged content and process only relevant changes.

Choose your host

| Host | Recommended integration | Storage | |---|---|---| | OpenCode | Native plugin | .opencode/ | | Jcode | Per-session MCP server | .codebase-index/ | | Pi | Pi package | .codebase-index/ | | omp (oh-my-pi) | omp package | .codebase-index/ | | Codex | Marketplace plugin with MCP and skill guidance | .codebase-index/ | | Claude Code | Marketplace plugin with MCP and skill guidance | .claude/ | | Cursor, Windsurf, other MCP clients | open-codebase-index-mcp (legacy alias: opencode-codebase-index-mcp) | Selected by --host; default is OpenCode-compatible |

See Installation and host setup for complete instructions.

Recommended workflow

  1. Check readiness when unknown with index_status or /status; index only when needed.
  2. Orient in unfamiliar code with one compact codebase_context first pass (tokenBudget: 600, limit: 5), then inspect the evidence. Skip this step when the task is already scoped.
  3. Go directly to known definitions or relationships with implementation_lookup, call_graph, or call_graph_path.
  4. Optionally prepare a known edit target with codebase_edit_context for bounded source and direct graph evidence.
  5. Choose metadata or matching source with codebase_peek or codebase_search; do not repeat context calls unnecessarily.
  6. Read known paths or match literals directly with targeted reads or grep.

Which search tool should I use?

| Need | Tool | |---|---| | Orient in unfamiliar repository code with a compact evidence pack | codebase_context | | Find likely files and symbols without source bodies | codebase_peek | | Retrieve full matching code | codebase_search | | Find an authoritative definition | implementation_lookup | | Find analogous implementations or duplicates | find_similar | | Find direct callers or callees | call_graph | | Find a path between two symbols | call_graph_path | | Analyze a branch or pull request blast radius | pr_impact |

See Tools and commands for host availability, tool details, MCP prompts, and slash commands.

How it works

source files
   │
   ├─ file discovery and git-aware change detection
   ├─ tree-sitter parsing and semantic chunking
   ├─ embedding generation and content-hash reuse
   ▼
SQLite metadata + usearch vectors + BM25 index
   │
   ├─ semantic candidates
   ├─ keyword candidates
   ├─ branch and request filters
   ├─ deterministic fusion and ranking
   ▼
locations, source results, definitions, and call-graph evidence

The TypeScript layer handles host integration, configuration, indexing orchestration, providers, ranking, and tools. The Rust NAPI module handles parsing, vector storage, SQLite operations, BM25 indexing, hashing, and call extraction.

Read Architecture for the detailed data flow and design decisions.

Embedding providers

With embeddingProvider: "auto", providers are tried in this order:

  1. Ollama
  2. OpenAI
  3. Google

Ollama is the simplest local option:

ollama pull nomic-embed-text
{
  "embeddingProvider": "ollama"
}

A custom OpenAI-compatible embeddings endpoint is also supported. Provider, indexing, search, reranking, include/exclude, knowledge-base, storage, and debug settings are documented in Configuration.

Configuration example

OpenCode project config lives at .opencode/codebase-index.json. Codex, Pi, and Jcode use .codebase-index/config.json; Claude uses .claude/codebase-index.json.

{
  "embeddingProvider": "auto",
  "scope": "project",
  "indexing": {
    "autoIndex": false,
    "watchFiles": true,
    "requireProjectMarker": true,
    "semanticOnly": false
  },
  "search": {
    "maxResults": 20,
    "minScore": 0.1,
    "fusionStrategy": "rrf",
    "rerankTopN": 20
  },
  "mcp": {
    "stallTimeoutMs": 300000
  }
}

Only specify values you want to override. See Configuration for defaults and host-specific paths.

Branch-aware indexing

The index stores reusable content by hash and maintains branch catalogs for chunks and symbols. On a branch switch, unchanged content can be reused while results remain scoped to the active branch. Linked worktrees without a local project config share the main checkout's portable project index; adding a worktree-local config creates an isolated index boundary.

Knowledge bases and reranking

OpenCode, Pi, and every MCP client can index additional directories as knowledge bases. Configure them with knowledgeBases, or use the knowledge-base tools:

  • MCP and OpenCode: add_knowledge_base, list_knowledge_bases, remove_knowledge_base
  • Pi: knowledge_base_add, knowledge_base_list, knowledge_base_remove

Optional external reranking supports Cohere, Jina, and custom compatible endpoints. Local filtering and evidence classes are applied before external candidates are submitted.

See Configuration for examples and privacy considerations.

Troubleshooting

Start with:

  1. /status or index_status
  2. index_health_check
  3. a normal /index retry
  4. a forced rebuild only when status reports incompatibility or corruption

Common provider, native module, stale index, branch, and performance issues are covered in Troubleshooting.

MCP operations report structured, redacted failures and durable phase diagnostics through index_status. Codex keeps a lightweight connection while its idle indexing engine sleeps and resumes on demand. See MCP engine idle timeout for configuration and external cleanup requirements. If the supervisor itself is terminated and the client loses stdio, start a fresh client session before retrying.

Evaluation and performance

The repository includes reproducible retrieval datasets, latency and quality budgets, baseline comparison, and cross-repository benchmarking tools.

Performance depends on repository size, parser coverage, provider latency, embedding cache reuse, and the selected indexing limits. Prefer measured evaluation over fixed marketing claims.

Development

npm ci
npm run build
npm run typecheck
npm run lint
npm run test:run

Native changes require Rust and npm run build:native. See Contributing, Architecture, and Adding language support.

Documentation

License

MIT. See LICENSE.