How to Register Multiple Repositories for Cross-Repo Search in code-review-graph
Register multiple repositories in the code-review-graph VS Code extension by adding each repo to your workspace, which automatically indexes them into a unified SQLite-backed knowledge graph for seamless cross-repository search.
The code-review-graph extension transforms scattered codebases into a searchable knowledge graph. By registering multiple repositories, you enable cross-repo search—a single query that surfaces results across every indexed repository without switching contexts.
What Cross-Repo Search Means in code-review-graph
Cross-repository search lets you find symbols, functions, or patterns that span project boundaries. Unlike VS Code's native workspace search, which operates on raw text files, code-review-graph builds a semantic index that understands relationships between entities.
When you register a repository, the extension's backend (backend/watcher.ts) monitors filesystem changes and populates a local SQLite database (backend/sqlite.ts). Each file entry is tagged with a repo_id, creating a unified namespace across all registered repositories.
Registering Repositories: Two Methods
Method 1: Automatic Registration via Workspace Folders
The extension automatically registers any folder you open in VS Code:
- Open a repository folder in VS Code
- The extension triggers the onboarding flow in
onboarding/installer.ts registerRepo()inserts the repository path into therepostableindexRepository()performs the initial file scan
// src/onboarding/installer.ts
export async function registerRepo(rootPath: string) {
const db = await getDb();
db.run('INSERT OR IGNORE INTO repos (path, name) VALUES (?, ?)',
[rootPath, path.basename(rootPath)]);
// Kick off an initial indexing run
await indexRepository(rootPath);
}
Method 2: Manual Registration Through Command Palette
For repositories outside your current workspace:
- Run "Code Review Graph: Add Repository" from the command palette
- Select or type the absolute path to the repository root
- The extension validates the path and queues it for indexing
How the Search Engine Queries Across Repositories
Once multiple repositories are registered, the search functionality in features/search.ts executes cross-repo queries by filtering against all repo_id values present in the repos table.
Query Execution Flow
| Step | Component | Action |
|---|---|---|
| 1 | features/search.ts |
Captures user query from UI |
| 2 | RPC layer | Transmits query to backend |
| 3 | backend/sqlite.ts |
Executes parameterized SQL |
| 4 | Result aggregator | Deduplicates and ranks matches |
| 5 | views/graphWebview.ts |
Renders cross-repo results |
Backend Search Implementation
The core query spans all registered repositories automatically:
// src/features/search.ts
export async function searchAcrossRepos(query: string): Promise<SearchResult[]> {
const db = await getDb();
const stmt = db.prepare(`
SELECT file_path AS filePath, repo_name AS repoName
FROM files
WHERE repo_id IN (SELECT id FROM repos) -- all registered repos
AND content LIKE ?
LIMIT 100
`);
return stmt.all(`%${query}%`);
}
The repo_id IN (SELECT id FROM repos) clause ensures every registered repository is included without explicit enumeration.
Triggering Cross-Repo Search from the UI
Use the command palette to search across all registered repositories:
// Command registration (typically in extension.ts)
vscode.commands.registerCommand('codeReviewGraph.search', async () => {
const query = await vscode.window.showInputBox({
prompt: 'Search all registered repos'
});
if (!query) { return; }
// Send query to backend with progress notification
const results = await vscode.window.withProgress(
{
location: vscode.ProgressLocation.Notification,
title: `Searching for "${query}"`
},
() => rpc.invoke('searchAcrossRepos', query)
);
// Present results with repository provenance
const item = await vscode.window.showQuickPick(
results.map(r => ({
label: r.filePath,
description: r.repoName
}))
);
if (item) {
vscode.workspace.openTextDocument(item.label)
.then(doc => vscode.window.showTextDocument(doc));
}
});
Performance Optimizations for Multi-Repo Search
The extension implements several strategies to maintain speed across large repository sets:
- Indexed lookups: Composite index on (
repo_id,content) accelerates cross-repo queries - Incremental updates:
backend/watcher.tsonly re-indexes changed files - Result limiting:
LIMIT 100prevents UI bottleneck on broad queries - Lazy loading: Repository metadata loads on demand; full content indexes in background
Verifying Your Registration Status
Check which repositories are currently searchable:
- Open the Code Review Graph side panel
- View the repository tree—the count shows registered repos
- Each node displays indexing status:
pending,indexing, orready
Repositories with ready status are fully included in cross-repo search operations.
Summary
- Automatic registration: Opening folders in VS Code triggers
registerRepo()inonboarding/installer.ts - Unified index: All repositories share a single SQLite database with
repo_idtagging - Seamless queries:
searchAcrossRepos()infeatures/search.tsqueries all registered repos automatically - Scalable architecture: Incremental watchers and indexed columns maintain performance across dozens of repositories
Frequently Asked Questions
How many repositories can I register simultaneously?
There is no hard limit enforced by the extension. SQLite handles hundreds of repositories comfortably on modern hardware. Performance depends on total indexed file count rather than repository count—expect sub-second queries for workspaces under 500,000 files.
Do I need to re-register repositories after restarting VS Code?
No. Registered repositories persist in the SQLite database at ~/.code-review-graph/graph.db. The extension restores the repository list on activation and resumes filesystem watching via backend/watcher.ts.
Can I exclude specific files or directories from cross-repo search?
Yes. The extension respects .gitignore patterns during indexing. Additionally, modify the indexRepository() function in backend/watcher.ts or add path exclusions to the workspace settings under codeReviewGraph.excludePatterns.
How do I unregister a repository without deleting its files?
Run "Code Review Graph: Remove Repository" from the command palette. This executes DELETE FROM repos WHERE path = ? and purges associated file entries from the index, leaving the source files untouched.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →