Skip to content

Latest commit

Β 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Code Intelligence Engine

Understand any TypeScript codebase instantly. [AI + Static Analysis + LSP]

A production-ready code intelligence engine that indexes, understands, and explains your TypeScript code with AIβ€”all for free.

License Rust TypeScript Groq


✨ Features

Feature Description
πŸ” Instant Symbol Search Find any function, class, or interface in milliseconds
πŸ“š AI-Powered Explanation Get detailed explanations of any code with one command
⚑ Incremental Indexing 300x faster updates (60s β†’ 0.2s)
πŸ”Œ VS Code Integration Go to definition, hover info, and more
πŸ†“ Free & Fast Uses Groq's free GPT-OSS-120B or local Ollama
πŸ”’ Secure Auto-redacts secrets before sending to AI
πŸ—„οΈ Persistent Cache LMDB-based storage for instant lookups
πŸ“¦ Single Binary No dependencies to install

πŸš€ Quick Start

Prerequisites

Installation

# Clone the repository
git clone https://github.com/yourusername/code-intel-engine
cd code-intel-engine

# Build the project
cargo build --release

# Install TypeScript worker dependencies
cd ts-worker
npm install
npm run build
cd ..

# Set up environment
cp .env.example .env
# Edit .env with your Groq API key or use Ollama

Environment Setup

For Groq (free, fastest):

export LLM_BASE_URL="https://api.groq.com/openai/v1"
export LLM_MODEL="openai/gpt-oss-120b"
export OPENAI_API_KEY="your-groq-api-key-here"

For Ollama (local, private):

export LLM_BASE_URL="http://localhost:11434/v1"
export LLM_MODEL="llama3.2:3b"
ollama pull llama3.2:3b

Index Your Project

# First run - indexes all TypeScript files (~60 seconds for 291 files)
cargo run --bin code-intel-cli -- index .

# Subsequent runs - only changed files (0.2 seconds)
cargo run --bin code-intel-cli -- index .

πŸ“š Commands

Search for Symbols

# Search for any symbol by name
cargo run --bin code-intel-cli -- search "findTsConfig"

# Search for all functions
cargo run --bin code-intel-cli -- search "function"

# Search for all classes
cargo run --bin code-intel-cli -- search "class"

Get Symbol Details

cargo run --bin code-intel-cli -- symbol "findTsConfig"

OUTPUT

Symbol: findTsConfig Kind: function File: ts-worker/src/tsconfig-parser.ts Location: 5:0-17:0 Signature: (startPath: string): string | null Documentation: null

AI-Powered Code Explanation

cargo run --bin code-intel-cli -- explain ts-worker/src/tsconfig-parser.ts --line 5 --col 1

Output What the function does

findTsConfig looks for a tsconfig.json file, starting from a given directory and walking up the folder hierarchy until it either finds the file or reaches the filesystem root. If it finds the file it returns the absolute path to it; otherwise it returns null.

Step‑by‑step explanation

  1. Initialize the search location
  2. Loop until we hit the root directory
  3. Check for tsconfig.json in the current directory
  4. Move one level up
  5. No file found β†’ return null

Why it's useful

Many tools need to locate the nearest tsconfig.json to understand TypeScript compiler options for a project.

πŸ—οΈ Architecture

The engine is built in three phases:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     Your TypeScript Code                    β”‚
β”‚                      (291 files, 8,908 symbols)              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                      β”‚
                      β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                Phase 1: Indexer (Rust + Node.js)            β”‚
β”‚  - Walks directories, finds .ts/.tsx files                  β”‚
β”‚  - Node.js worker extracts symbols via TypeScript Compiler  β”‚
β”‚  - LMDB caches everything with mtime tracking               β”‚
β”‚  - Incremental updates: 0.2 seconds                        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                      β”‚
                      β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                Phase 2: LSP Server (Rust)                   β”‚
β”‚  - Language Server Protocol implementation                  β”‚
β”‚  - Go to Definition (Ctrl+Click)                           β”‚
β”‚  - Hover information                                       β”‚
β”‚  - VS Code extension                                       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                      β”‚
                      β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                Phase 3: LLM Integration (Rust + Groq)       β”‚
β”‚  - Context Builder: extracts symbol + source code          β”‚
β”‚  - Redaction: removes API keys, emails, secrets            β”‚
β”‚  - Groq API: GPT-OSS-120B (free, fast)                    β”‚
β”‚  - Explain any function/class/interface                    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

How Incremental Updates Work bash

First run: indexes everything

cargo run --bin code-intel-cli -- index .

Output: Found 291 files, indexed 291 files (60s)

Second run: only changed files

cargo run --bin code-intel-cli -- index .

Output: Found 291 files, indexed 0 files (0.2s)

After modifying a file

touch ts-worker/src/tsconfig-parser.ts cargo run --bin code-intel-cli -- index .

Output: Found 291 files, indexed 1 file (0.2s)

πŸ”’ Security The engine automatically redacts sensitive information before sending code to AI:

API Keys: api_key: "sk-..." β†’ api_key: "[REDACTED]"

Emails: john@example.com β†’ [REDACTED-EMAIL]

Passwords: password: "secret" β†’ password: "[REDACTED]"

All processing happens locally. Only the code you explicitly ask to explain is sent to the AI provider.

πŸš€ VS Code Extension

The engine includes a VS Code extension for seamless integration:

bash

Open the extension in VS Code

cd vscode-extension npm install npm run compile

Press F5 to launch Extension Development Host

Features:

βœ… Go to Definition (Ctrl+Click)

βœ… Hover Information

βœ… Code Explanation (Right-click β†’ Explain This)

βœ… Symbol Search (Command Palette)

πŸ† Project Status Phase Feature Status Phase 1 Indexer (symbol extraction, LMDB cache, incremental updates) βœ… Complete Phase 2 LSP Server (go to definition, hover, VS Code extension) βœ… Complete Phase 3 LLM Integration (AI explanation, redaction, Groq API) βœ… Complete Total Symbols Extracted: 8,908 from 291 files Time to Index: 60s first run, 0.2s incremental

πŸ”§ Development Project Structure text code-intel-engine/ β”œβ”€β”€ crates/ β”‚ β”œβ”€β”€ core/ # Shared data structures (Symbol, SymbolKind) β”‚ β”œβ”€β”€ indexer/ # Indexing, LMDB storage, Node.js bridge β”‚ β”œβ”€β”€ cli/ # Command-line interface β”‚ β”œβ”€β”€ lsp/ # Language Server Protocol implementation β”‚ └── llm/ # LLM integration (context, client, redaction) β”œβ”€β”€ ts-worker/ # Node.js worker (TypeScript symbol extraction) β”œβ”€β”€ vscode-extension/ # VS Code extension └── .code-intel/ # LMDB cache (auto-generated) Building from Source bash

Build everything

cargo build --release

Build TypeScript worker

cd ts-worker npm install npm run build

Run tests

cargo test Adding a New Language Create a new worker in your target language (e.g., py-worker/ for Python)

Implement symbol extraction using the language's parser

Update the bridge to support multiple workers

Extend the Symbol struct with language-specific fields

πŸ“ Blog Post

Read the full journey: Building a Code Intelligence Engine from Scratch

Topics Covered:

Why I built this (the problem with large codebases)

Phase 1: Building the Indexer with Rust and Node.js

Phase 2: Adding LSP and VS Code Integration

Phase 3: AI-Powered Code Explanation with Groq

Performance optimizations (60s β†’ 0.2s)

Lessons learned and future plans

🀝 Contributing

Contributions are welcome! Here's how you can help:

πŸ› Bug Reports: Open an issue with steps to reproduce

πŸ’‘ Feature Requests: Open an issue describing the feature

πŸ”§ Pull Requests: Submit PRs with tests and documentation

πŸ“š Documentation: Improve the README, add examples

Development Guidelines Follow Rust best practices and idioms

Add tests for new functionality

Update documentation for API changes

Keep performance in mind (we're in milliseconds)

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

TypeScript Compiler API

Language Server Protocol

LMDB

Groq for free AI inference

Ollama for local LLMs

πŸ“« Contact

GitHub: @shreyannandanwar

Twitter: @yourhandle

LinkedIn: your-profile

Email: your.email@example.com

⭐ Star History

https://api.star-history.com/svg?repos=yourusername/code-intel-engine&type=Date

Built with Rust, TypeScript, LMDB, LSP, and ❀️

The engine that understands your code.

text


πŸ“ Additional Files to Create

.env.example

# Groq API (free, fast)
# Get your key from: https://console.groq.com/
LLM_BASE_URL="https://api.groq.com/openai/v1"
LLM_MODEL="openai/gpt-oss-120b"
OPENAI_API_KEY="your-groq-api-key-here"

# OR use Ollama (local, private)
# LLM_BASE_URL="http://localhost:11434/v1"
# LLM_MODEL="llama3.2:3b"
# OPENAI_API_KEY=""

LICENSE markdown MIT License

Copyright (c) 2024 [Your Name]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages