inbed
v1.0.5
Published
Semantic indexing and search over source code using vector embeddings
Maintainers
Readme
Inbed
Inbed is a TypeScript library for semantic indexing and retrieval of source code, built to map natural language intent to real codebases.
It helps LLMs and developer tools find the right files and code snippets for a given user request.
What it’s for
- 🔍 Semantic code search
- 🤖 LLM / RAG context retrieval
- 🧠 AI copilots & agents
- 🧭 Navigating large or legacy repos
Installation
npm install inbedBasic Usage
Create an embedder
import { OpenAIEmbedder } from 'inbed';
const embedder = new OpenAIEmbedder(
process.env.OPENAI_API_KEY!
);Initialize Inbed
import { Inbed } from 'inbed';
const inbed = new Inbed(embedder, {
rootDir: process.cwd(),
fileExtensions: ['.ts', '.js'],
ignorePatterns: ['dist/**', 'node_modules/**']
});
await inbed.load();Semantic Search
const results = await inbed.semanticSearch(
'where cache is written to disk',
5
);
results.forEach(r => {
console.log(r.path, r.score);
});Returns the most relevant files and snippets for the query.
Common Pattern: Prompt → Files
async function selectRelevantFiles(prompt: string) {
const results = await inbed.semanticSearch(prompt, 5);
return results.map(r => r.path);
}Use this to feed only the necessary code into an LLM prompt.
How it works (short)
- Scans the project
- Splits files into chunks (AST-aware for TS)
- Generates embeddings (cached locally)
- Watches files for changes
- Searches by vector similarity
Embedding Providers
- OpenAI
- Ollama (local)
- OpenRouter
What Inbed is not
- A static analyzer
- A refactor engine
- A bug detector
It retrieves relevant context — the LLM does the reasoning.
