loading…
Search for a command to run...
loading…
Convert source code repositories into searchable knowledge bases with AI-powered search using GPT-5, intelligent chunking, and OpenAI embeddings for semantic co
Convert source code repositories into searchable knowledge bases with AI-powered search using GPT-5, intelligent chunking, and OpenAI embeddings for semantic code understanding.
Convert any source code repository into a searchable knowledge base with automatic chunking, embedding generation, and intelligent search capabilities. Now with MCP (Model Context Protocol) support for Claude Code and Cursor integration!
📦 Now available on npm! Install with: npm install -g @vezlo/src-to-kb
After installation, you'll have access to these commands:
src-to-kb - Generate knowledge base from source codesrc-to-kb-search - Search the knowledge basesrc-to-kb-upload - Upload local knowledge base to external serversrc-to-kb-api - Start REST API server with Swagger docssrc-to-kb-mcp - Start MCP server for IDE integrationsrc-to-kb-mcp-install - Auto-configure Claude Code/Cursor# Install globally
npm install -g @vezlo/src-to-kb
# Generate KB from your project
src-to-kb ./my-nextjs-app --output ./my-kb
# Start API server
src-to-kb-api
# Search your codebase
src-to-kb-search search "How does routing work?" --mode developer
That's it! Your codebase is now searchable with AI assistance.
The following table shows how flags work across different sources and modes:
| Source | Mode | Default (no flags) | --chunks-only |
--with-embeddings |
|---|---|---|---|---|
| Codebase | Local | Creates chunks | Same (redundant) | Creates chunks + embeddings |
| Codebase | Server | Sends raw content | Creates chunks → sends | Creates chunks + embeddings → sends |
| Notion | Local | Creates chunks | Same (redundant) | Creates chunks + embeddings |
| Notion | Server | Sends raw content | Creates chunks → sends | Creates chunks + embeddings → sends |
Note: Server mode is enabled when EXTERNAL_KB_URL environment variable is set.
Experience external server integration immediately with our production-ready assistant-server:
# Default: Send raw content (server creates chunks)
EXTERNAL_KB_URL=https://your-assistant-server.com/api/knowledge/items src-to-kb ./your-repo
# Create chunks locally, then send to server
EXTERNAL_KB_URL=https://your-assistant-server.com/api/knowledge/items src-to-kb ./your-repo --chunks-only
# Create chunks + embeddings locally, then send to server
EXTERNAL_KB_URL=https://your-assistant-server.com/api/knowledge/items OPENAI_API_KEY=sk-... src-to-kb ./your-repo --with-embeddings
# With API key authentication
EXTERNAL_KB_URL=https://your-assistant-server.com/api/knowledge/items EXTERNAL_KB_API_KEY=your-api-key src-to-kb ./your-repo
# Search using assistant-server
EXTERNAL_KB_URL=https://your-assistant-server.com/api/knowledge/items \
EXTERNAL_KB_SEARCH_URL=https://your-assistant-server.com/api/search \
src-to-kb-search search "how does authentication work?"
Assistant Server: vezlo/assistant-server - Production-ready Node.js/TypeScript API server with vector search and Docker deployment
Upload an existing local knowledge base to an external server:
# Default: Upload raw content (reconstructs from chunks)
EXTERNAL_KB_URL=https://your-assistant-server.com/api/knowledge/items \
src-to-kb-upload --kb ./knowledge-base
# Upload chunks only (server generates embeddings)
EXTERNAL_KB_URL=https://your-assistant-server.com/api/knowledge/items \
src-to-kb-upload --kb ./knowledge-base --chunks-only
# Upload chunks with embeddings
EXTERNAL_KB_URL=https://your-assistant-server.com/api/knowledge/items \
src-to-kb-upload --kb ./knowledge-base --with-embeddings
Requirements:
EXTERNAL_KB_URL environment variable must be setdocuments/ and chunks/ directories--with-embeddings: embeddings/ directory must existFor production deployments or custom servers:
📖 Complete Guide: External Server Setup Guide
NEW! Import your Notion pages and databases directly into your knowledge base! Perfect for combining documentation, project plans, and code knowledge in one searchable system.
# 1. Get your Notion API key (see full guide below)
export NOTION_API_KEY=secret_xxx
# 2. Generate KB from a Notion page
src-to-kb --source=notion --notion-url=https://notion.so/Your-Page-abc123
# 3. Or fetch all pages from a Notion database
src-to-kb --source=notion --notion-url=https://notion.so/Database-xyz789
# 4. Search your Notion content
src-to-kb-search search "your query" --kb ./knowledge-base/notion
Send Notion content directly to your assistant-server:
# Set external server URL
export EXTERNAL_KB_URL=http://localhost:3002/api/knowledge/items
export EXTERNAL_KB_API_KEY=your-api-key
# Send raw content from Notion to server (default)
src-to-kb --source=notion --notion-url=https://notion.so/Your-Page-abc123
# Send chunks from Notion to server
src-to-kb --source=notion --notion-url=https://notion.so/Your-Page-abc123 --chunks-only
# Send chunks + embeddings from Notion to server
OPENAI_API_KEY=sk-... src-to-kb --source=notion --notion-url=https://notion.so/Your-Page-abc123 --with-embeddings
# Search via external server
export EXTERNAL_KB_URL=http://localhost:3002/api/knowledge/items
export EXTERNAL_KB_SEARCH_URL=http://localhost:3002/api/search
src-to-kb-search search "your query"
./knowledge-base/notion by default# Single page (local KB)
src-to-kb --source=notion --notion-url=https://notion.so/Project-Docs-abc123
# Database with all pages (local KB)
src-to-kb --source=notion --notion-url=https://notion.so/Team-Wiki-xyz789
# With API key as parameter
src-to-kb --source=notion --notion-key=secret_xxx --notion-url=https://notion.so/Page-abc123
# Send to external server (raw content by default)
EXTERNAL_KB_URL=http://localhost:3002/api/knowledge/items \
EXTERNAL_KB_API_KEY=your-key \
src-to-kb --source=notion --notion-url=https://notion.so/Page-abc123
# Search local Notion KB
src-to-kb-search search "project timeline" --kb ./knowledge-base/notion
# Search via external server
EXTERNAL_KB_URL=http://localhost:3002/api/knowledge/items \
EXTERNAL_KB_SEARCH_URL=http://localhost:3002/api/search \
src-to-kb-search search "project timeline"
📖 Complete Notion Guide: Notion Integration Documentation - Includes setup instructions, API key creation, sharing pages/databases, and troubleshooting
Process your repository with default settings:
# If installed globally via npm
src-to-kb /path/to/your/repo
# Or using the script directly
node kb-generator.js /path/to/your/repo
src-to-kb /path/to/your/repo --output ./my-knowledge-base
# Set your OpenAI API key
export OPENAI_API_KEY=your-api-key-here
# Generate with embeddings
src-to-kb /path/to/your/repo --with-embeddings
Choose the right answer mode for your needs:
# First generate a knowledge base
src-to-kb ./your-project --output ./project-kb
# Search with different modes:
# End User Mode - Simple, non-technical answers
src-to-kb-search search "how do I reset password?" --kb ./project-kb --mode enduser
# Developer Mode - Technical details and architecture (default)
src-to-kb-search search "authentication flow" --kb ./project-kb --mode developer
# Copilot Mode - Code examples and implementation patterns
src-to-kb-search search "implement user login" --kb ./project-kb --mode copilot
# View available modes
src-to-kb-search modes
The search tool adapts its responses based on who's asking:
| Mode | For | Description | Example Use Case |
|---|---|---|---|
enduser |
Non-technical users | Simple explanations without technical jargon, focuses on features and capabilities | Product managers, business stakeholders asking about features |
developer |
Software developers | Full technical details including architecture, dependencies, and implementation details | Engineers understanding codebase structure and design patterns |
copilot |
Coding assistance | Code examples, snippets, and implementation patterns ready to use | Developers looking for code to copy/adapt for their implementation |
# CEO asks: "What payment methods do we support?"
src-to-kb-search search "payment methods" --mode enduser
# Returns: Simple list of supported payment options
# Developer asks: "How is payment processing implemented?"
src-to-kb-search search "payment processing" --mode developer
# Returns: Technical details about payment gateway integration, API endpoints, error handling
# Developer needs: "Show me payment integration code"
src-to-kb-search search "payment integration" --mode copilot
# Returns: Actual code snippets for payment implementation
# Install globally from npm registry
npm install -g @vezlo/src-to-kb
# Now use the commands anywhere on your system
src-to-kb /path/to/repo # Generate knowledge base
src-to-kb-search search "your query" # Search knowledge base
src-to-kb-mcp # Start MCP server for Claude/Cursor
# Run directly without installing
npx @vezlo/src-to-kb /path/to/repo
npx @vezlo/src-to-kb-search search "your query"
npx @vezlo/src-to-kb-mcp
# Add as a project dependency
npm install @vezlo/src-to-kb
# Use with npx in your project
npx src-to-kb /path/to/repo
# Clone the repository
git clone https://github.com/vezlo/src-to-kb.git
cd src-to-kb
# Install dependencies
npm install
# Run directly
node kb-generator.js /path/to/repo
Usage: node kb-generator.js <repository-path> [options]
node kb-generator.js --source=notion [notion-options] [options]
Options:
--output, -o Output directory (default: ./knowledge-base)
--chunk-size Chunk size in characters (default: 1000)
--chunk-overlap Overlap between chunks (default: 200)
--max-file-size Maximum file size in MB (default: 10)
--chunks-only Create chunks locally (and send to server if enabled)
--with-embeddings Create chunks with embeddings (requires OPENAI_API_KEY)
--no-comments Exclude comments from code
--exclude Additional paths to exclude (comma-separated)
--extensions File extensions to include (comma-separated)
Notion Options (use with --source=notion):
--source Source type: code (default) or notion
--notion-key Notion API integration token (or set NOTION_API_KEY env var)
--notion-url Notion page or database URL (auto-detects type)
# 1. Generate knowledge base from your frontend code
src-to-kb ./frontend/ --output ./frontend-kb
# 2. Different users asking different questions:
# Product Manager asks about features
src-to-kb-search search "password reset feature" --kb ./frontend-kb --mode enduser
# Developer investigates technical implementation
src-to-kb-search search "authentication flow" --kb ./frontend-kb --mode developer
# Developer needs code examples
src-to-kb-search search "login component implementation" --kb ./frontend-kb --mode copilot
# 3. Get statistics about the codebase
src-to-kb-search stats --kb ./frontend-kb
# 4. List all TypeScript files
src-to-kb-search type TypeScript --kb ./frontend-kb
# 5. View available answer modes
src-to-kb-search modes
# Using npm package
src-to-kb /path/to/repo --output ./repo-kb --with-embeddings
# Or with npx
npx @vezlo/src-to-kb /path/to/repo --output ./repo-kb --with-embeddings
src-to-kb /path/to/repo --extensions .js,.ts,.jsx,.tsx
src-to-kb /path/to/repo --exclude tests,build,dist,coverage
src-to-kb /path/to/large-repo \
--chunk-size 2000 \
--chunk-overlap 400 \
--max-file-size 20
Run the included test suite to verify functionality:
# Run comprehensive tests
node test.js
# This will:
# 1. Create a test repository with sample files
# 2. Process it into a knowledge base
# 3. Verify the output structure
# 4. Test chunking on large files
# 5. Verify language detection
The Source-to-KB REST API provides programmatic access to all functionality with comprehensive Swagger documentation.
# Start with defaults (port 3000, no authentication)
src-to-kb-api
# With custom port and API key
PORT=8080 API_KEY=your-secret-key src-to-kb-api
# With all options
PORT=8080 API_KEY=secret OPENAI_API_KEY=sk-... src-to-kb-api
Once started, visit: http://localhost:3000/api/v1/docs for interactive Swagger UI
POST /api/v1/knowledge-bases - Create new knowledge basePOST /api/v1/search - Search with mode selectionGET /api/v1/modes - List available answer modesGET /api/v1/statistics/{id} - Get KB statisticsPOST /api/v1/process-file - Process single file// Create knowledge base
const response = await fetch('http://localhost:3000/api/v1/knowledge-bases', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': 'your-api-key'
},
body: JSON.stringify({
name: 'My Project',
sourcePath: '/path/to/project',
options: { chunkSize: 1500 }
})
});
// Search with mode
const searchResponse = await fetch('http://localhost:3000/api/v1/search', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': 'your-api-key'
},
body: JSON.stringify({
query: 'authentication',
knowledgeBaseId: 'abc123',
mode: 'developer'
})
});
For complete API documentation, see API_DOCUMENTATION.md
# 1. Install the package globally
npm install -g @vezlo/src-to-kb
# 2. Find your global npm installation path
npm list -g @vezlo/src-to-kb --depth=0
# 3. Add to Claude Code (replace the path with your npm global path)
# For macOS/Linux with nvm:
claude mcp add src-to-kb -- node ~/.nvm/versions/node/v22.6.0/lib/node_modules/@vezlo/src-to-kb/mcp-server.mjs
# For macOS/Linux without nvm:
claude mcp add src-to-kb -- node /usr/local/lib/node_modules/@vezlo/src-to-kb/mcp-server.mjs
# For Windows:
claude mcp add src-to-kb -- node %APPDATA%\npm\node_modules\@vezlo\src-to-kb\mcp-server.mjs
# With OpenAI API key for embeddings:
claude mcp add src-to-kb --env OPENAI_API_KEY=your-key -- node [your-path]/mcp-server.mjs
# Try with npx (may not work on all systems)
claude mcp add src-to-kb -- npx -y @vezlo/src-to-kb src-to-kb-mcp
# Check if installed
claude mcp list
# Remove if needed
claude mcp remove src-to-kb
# Get server details
claude mcp get src-to-kb
See MCP_SETUP.md for manual setup and MCP_TOOLS_GUIDE.md for detailed tool documentation.
The search tool supports three different answer modes to tailor responses based on your needs:
enduser: Simplified answers for non-technical users, focusing on features and capabilitiesdeveloper: Detailed technical answers including architecture and implementation details (default)copilot: Code-focused answers with examples and patterns for implementation# Examples with different modes
src-to-kb-search search "how to use API?" --mode enduser # Simple explanation
src-to-kb-search search "authentication flow" --mode developer # Technical details
src-to-kb-search search "login implementation" --mode copilot # Code examples
# List available modes
src-to-kb-search modes
When OPENAI_API_KEY is set, searches use GPT-5 (OpenAI's latest reasoning model) for intelligent answers:
# Set your OpenAI API key
export OPENAI_API_KEY=your-api-key-here
# Get intelligent, context-aware answers with mode selection
src-to-kb-search search "how does authentication work?" --kb ./project-kb --mode developer
src-to-kb-search search "where is password reset?" --kb ./project-kb --mode enduser
Without an API key, the tool provides basic keyword search:
# Basic search with pattern matching
src-to-kb-search search "authentication" --kb ./project-kb
# Find all JavaScript files
src-to-kb-search type JavaScript --kb ./project-kb
# Show statistics
src-to-kb-search stats --kb ./project-kb
# Find similar files
src-to-kb-search similar src/index.js --kb ./project-kb
# Specify knowledge base path
src-to-kb-search search "query" --kb ./my-knowledge-base
# Select answer mode
src-to-kb-search search "query" --mode enduser|developer|copilot
# Show detailed evidence
src-to-kb-search search "query" --verbose
# Get raw search results (old format)
src-to-kb-search search "query" --raw
The generator creates the following directory structure:
knowledge-base/
├── documents/ # Document metadata (without content)
│ ├── doc_xxx.json
│ └── ...
├── chunks/ # Document chunks for searching
│ ├── doc_xxx.json
│ └── ...
├── embeddings/ # OpenAI embeddings (if enabled)
│ ├── doc_xxx.json
│ └── ...
└── metadata/ # Summary and statistics
└── summary.json
Each document contains:
{
"id": "doc_1234567890_abc123",
"path": "/full/path/to/file.js",
"relativePath": "src/file.js",
"fileName": "file.js",
"extension": ".js",
"size": 2048,
"checksum": "sha256-hash",
"metadata": {
"createdAt": "2024-01-01T00:00:00.000Z",
"modifiedAt": "2024-01-01T00:00:00.000Z",
"lines": 100,
"language": "JavaScript",
"type": "code"
}
}
Each chunk contains:
{
"id": "doc_xxx_chunk_0",
"index": 0,
"content": "chunk content here...",
"startLine": 1,
"endLine": 25,
"size": 1000
}
Transform your frontend codebase into a searchable knowledge base with AI-powered assistance:
# 1. Generate knowledge base from your project
src-to-kb /path/to/nextjs-app --output ./nextjs-kb
# 2. Start the API server
src-to-kb-api
# 3. Query your codebase
curl -X POST http://localhost:3000/api/v1/search \
-H "Content-Type: application/json" \
-d '{"query": "How is authentication implemented?", "knowledgeBaseId": "your-kb-id", "mode": "developer"}'
// components/CodeSearch.jsx
import { useState } from 'react';
export default function CodeSearch() {
const [query, setQuery] = useState('');
const [result, setResult] = useState(null);
const search = async () => {
const response = await fetch('http://localhost:3000/api/v1/search', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
query,
knowledgeBaseId: 'your-kb-id',
mode: 'developer'
})
});
const data = await response.json();
setResult(data);
};
return (
<div>
<input
value={query}
onChange={(e) => setQuery(e.target.value)}
placeholder="Ask about your codebase..."
/>
<button onClick={search}>Search</button>
{result && <div>{result.answer}</div>}
</div>
);
}
# GitHub Actions example
name: Update Knowledge Base
on: [push]
jobs:
update-kb:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install -g @vezlo/src-to-kb
- run: src-to-kb . --output ./kb
# Upload KB as artifact or deploy to server
For production environments:
# Start with authentication and custom port
API_KEY=secure-key PORT=8080 src-to-kb-api
# Use with Docker
docker run -p 3000:3000 -e API_KEY=secret vezlo/src-to-kb-api
Also processes:
Chunking Strategy:
Overlap:
Exclusions:
File Size:
const { KnowledgeBaseGenerator } = require('./kb-generator');
async function generateKB() {
const generator = new KnowledgeBaseGenerator({
outputPath: './my-kb',
chunkSize: 1500,
generateEmbeddings: true,
openaiApiKey: 'your-api-key'
});
generator.on('fileProcessed', (data) => {
console.log(`Processed: ${data.file}`);
});
const result = await generator.processRepository('/path/to/repo');
console.log(`Generated KB with ${result.documents.length} documents`);
}
generateKB();
This software is dual-licensed:
See LICENSE file for full details.
Feel free to submit issues and enhancement requests!
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"vezlo-src-to-kb": {
"command": "npx",
"args": []
}
}
}