AI-Powered Code History Tracking with RAG-Based Natural Language Search
Never lose track of your code changes again. Search, explore, and restore any version with natural language.
Features β’ Installation β’ Usage β’ Configuration β’ Architecture
- Real-time capture of all code changes as you work
- Intelligent debouncing to avoid capturing every keystroke
- Configurable exclusion patterns for
node_modules, build files, etc. - Tracks file creates, modifies, deletes, and renames
- Session-based organization for better context
- Natural language queries: "What changes did I make to the authentication logic?"
- Hybrid search combining vector similarity and keyword matching (BM25)
- Context-aware results with relevant code snippets
- Temporal filtering: "Changes from last week"
- Powered by state-of-the-art embedding models
- Use
@historianin VS Code Chat to explore your code history - Conversational interface powered by your choice of LLM
- Ask questions like:
- "When did I last modify the User class?"
- "Find all changes related to database queries"
- "What did the login function look like before the refactor?"
- Restore any previous version of your code with one click
- Preview changes before restoring
- Automatic backup creation before restoration
- Works seamlessly with your existing git workflow
- Beautiful, modern timeline view of all changes
- Multiple view modes: Timeline, Cards, or Compact list
- Stats dashboard with activity heatmap
- Group by date, file, or folder
- Inline diff preview with syntax highlighting
- Filter by change type, date range, and more
- Open VS Code
- Go to Extensions (
Cmd/Ctrl + Shift + X) - Search for "Code Historian"
- Click Install
Or install directly: Install from Marketplace
git clone https://github.com/KirtiJha/code-historian.git
cd code-historian
npm install
npm run buildThen press F5 in VS Code to launch the extension in development mode.
Open VS Code Settings (Cmd/Ctrl + ,) and search for "Code Historian".
Code Historian supports multiple embedding providers for semantic search:
| Provider | Model | Local | Cost | Dimensions |
|---|---|---|---|---|
| HuggingFace (default) | BAAI/bge-large-en-v1.5 | β | Free | 1024 |
| Ollama | nomic-embed-text | β | Free | 768 |
| OpenAI | text-embedding-3-small | β | Paid | 1536 |
{
"codeHistorian.embedding.provider": "huggingface",
"codeHistorian.embedding.model": "BAAI/bge-large-en-v1.5"
}For the chat interface, configure your preferred LLM:
| Provider | Models | Local | Setup |
|---|---|---|---|
| Ollama | llama3.2, mistral, codellama | β | Free, local |
| OpenAI | gpt-4o, gpt-4-turbo, gpt-3.5-turbo | β | API key required |
| Anthropic | claude-sonnet-4-20250514, claude-3-haiku | β | API key required |
| Google Gemini | gemini-pro, gemini-1.5-flash | β | API key required |
{
"codeHistorian.llm.provider": "openai",
"codeHistorian.llm.model": "gpt-4o",
"codeHistorian.llm.apiKey": "your-api-key"
}{
"codeHistorian.capture.enabled": true,
"codeHistorian.capture.debounceMs": 2000,
"codeHistorian.capture.excludePatterns": [
"**/node_modules/**",
"**/.git/**",
"**/dist/**",
"**/*.lock"
],
"codeHistorian.capture.maxFileSizeKB": 1024
}- Click the Code Historian icon in the Activity Bar (sidebar)
- Browse your change history with multiple view options:
- Timeline View: Classic vertical timeline with connecting lines
- Cards View: Grid layout for visual scanning
- Compact View: Dense list for maximum information
- Use filters to narrow down results:
- Filter by change type (Created, Modified, Deleted)
- Filter by date range
- Search by filename or content
- Click any change to see detailed diff view
- Restore any previous version with one click
Open VS Code Chat (Cmd/Ctrl + Shift + I) and use @historian:
@historian What changes did I make to the authentication module?
@historian Show me the login function from last week
@historian Find all database-related changes
@historian When did I add the validation logic?
| Shortcut | Command |
|---|---|
Ctrl+Shift+H / Cmd+Shift+H |
Open Timeline |
Ctrl+Shift+F / Cmd+Shift+F |
Search History |
Code Historian uses a modern architecture optimized for VS Code extensions:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β VS Code Extension β
ββββββββββββββββ¬βββββββββββββββ¬ββββββββββββββββ¬ββββββββββββββββ€
β Capture β Embedding β Search β LLM β
β Engine β Service β Engine β Orchestrator β
β β β β β
β β’ Debounce β β’ HuggingFaceβ β’ Hybrid β β’ OpenAI β
β β’ Diff Gen β β’ Ollama β Search β β’ Anthropic β
β β’ Sessions β β’ OpenAI β β’ BM25+Vectorβ β’ Ollama β
ββββββββββββββββ΄βββββββββββββββ΄ββββββββββββββββ΄ββββββββββββββββ€
β Database Layer β
β SQLite (sql.js) β LanceDB β
β β’ Metadata β β’ Vector embeddings β
β β’ FTS5 keyword search β β’ Similarity search β
ββββββββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββ€
β React Webview UI β
β Timeline β’ Search β’ Settings β’ Diff Viewer β’ Chat β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| Component | Technology | Purpose |
|---|---|---|
| Metadata DB | SQLite (sql.js) | Fast, in-browser metadata storage with FTS5 |
| Vector DB | LanceDB | Embedded vector database with ANN search |
| Embeddings | HuggingFace/Ollama | Semantic code understanding |
| UI Framework | React 18 | Modern, reactive webview interface |
| Build Tool | esbuild | Fast TypeScript bundling |
| Chat API | VS Code Chat | Native chat participant integration |
User Query β Embedding β Vector Search (top-k)
β
RRF Fusion β Ranked Results
β
β BM25 Keyword Search (FTS5)
The hybrid search combines:
- Vector similarity (60% weight): Semantic understanding of code
- Keyword matching (40% weight): Exact term matches via FTS5
- Reciprocal Rank Fusion: Combines both result sets with overlap boosting
| Operation | Latency | Notes |
|---|---|---|
| Change capture | < 50ms | Debounced, non-blocking |
| Embedding generation | < 200ms | Batched for efficiency |
| Vector search | < 100ms | For 10K+ changes |
| Hybrid search | < 200ms | Vector + keyword fusion |
| UI render | < 16ms | 60fps smooth scrolling |
Storage: ~1MB per 1,000 changes (including embeddings)
Your data stays 100% local by default:
- β SQLite database in VS Code's global storage
- β LanceDB vectors stored locally
- β Optional Ollama for completely local AI
- β No telemetry or external data sharing
- β API keys stored securely in VS Code settings
When using cloud providers (OpenAI, HuggingFace, Anthropic), only embedding requests and chat queries are sent externally.
# Clone the repository
git clone https://github.com/KirtiJha/code-historian.git
cd code-historian
# Install dependencies
npm install
# Build the extension
npm run build
# Watch mode (auto-rebuild on changes)
npm run watch
# Type checking
npm run typecheck
# Linting
npm run lint
# Run tests
npm testcode-historian/
βββ src/
β βββ extension.ts # Extension entry point
β βββ constants.ts # Configuration constants
β βββ types/ # TypeScript type definitions
β βββ database/ # SQLite & LanceDB wrappers
β βββ services/ # Core services
β β βββ capture.ts # Change capture engine
β β βββ embedding.ts # Embedding service
β β βββ search.ts # Hybrid search engine
β β βββ llm.ts # LLM orchestrator
β β βββ restoration.ts # Code restoration
β βββ chat/ # VS Code Chat participant
β βββ webview/ # React webview UI
β β βββ ui/ # React components
β β βββ provider.ts # Webview provider
β βββ utils/ # Utilities
βββ media/ # Icons and assets
βββ dist/ # Build output
βββ package.json # Extension manifest
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Please read our Contributing Guide for details on our code of conduct and development process.
This project is licensed under the MIT License - see the LICENSE file for details.
- LanceDB - Excellent embedded vector database
- Ollama - Local AI inference made easy
- HuggingFace - State-of-the-art embeddings
- VS Code - Amazing extension API
- sql.js - SQLite compiled to WebAssembly
Made with β€οΈ for developers who value their code history