Semantic indexing and search over source code using vector embeddings
npm install inbedInbed 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.
---
- π Semantic code search
- π€ LLM / RAG context retrieval
- π§ AI copilots & agents
- π§ Navigating large or legacy repos
---
``bash``
npm install inbed
---
`ts
import { OpenAIEmbedder } from 'inbed';
const embedder = new OpenAIEmbedder(
process.env.OPENAI_API_KEY!
);
`
`ts
import { Inbed } from 'inbed';
const inbed = new Inbed(embedder, {
rootDir: process.cwd(),
fileExtensions: ['.ts', '.js'],
ignorePatterns: ['dist/', 'node_modules/']
});
await inbed.load();
`
---
`ts
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.
---
`ts``
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.
---
1. Scans the project
2. Splits files into chunks (AST-aware for TS)
3. Generates embeddings (cached locally)
4. Watches files for changes
5. Searches by vector similarity
---
* OpenAI
* Ollama (local)
* OpenRouter
---
* A static analyzer
* A refactor engine
* A bug detector
It retrieves relevant context β the LLM does the reasoning.