@ashutoshpaliwal26/code-x-ray
v1.0.0
Published
High-performance AST scanner for Node.js
Maintainers
Readme
⚡️ C O D E - X - R A Y
The High-Performance AST Scanner for the Modern Web
Give your AI Agents "Eyes" into your codebase. Scan 10,000 files in seconds. Extract symbols instantly. Zero overhead.
🔮 The Problem
Node.js is fantastic, but it struggles with heavy computation. Trying to parse thousands of TypeScript or Python files in a single thread is slow, fragile, and memory-intensive.
⚡️ The Solution: Code X-Ray
We moved the heavy lifting to Rust. By bridging Node.js with a compiled Rust binary, we bypass the event loop entirely, utilizing Parallel Computing to scan your project at the speed of disk I/O.
🔥 Why Developers Choose X-Ray
| 🚀 Blazing Performance | 🛡️ Bulletproof Safety | 🧠 Intelligent Parsing |
| :--- | :--- | :--- |
| Uses Rayon to multithread across all CPU cores. Scans ~1.5ms per file. | Sandboxed file access. Respects .gitignore automatically. No crashes. | Powered by Tree-Sitter. Understands code structure, not just regex matches. |
📦 Installation
Add it to your project with a single command. It detects your OS (Windows/Linux/Mac) and downloads the correct optimized binary automatically.
npm install code-x-ray
💻 Developer Experience We designed Code X-Ray to feel like a native part of your toolchain. It’s fully typed, asynchronous-ready, and zero-config.
- The "Hello World" Scan Get a complete map of your project in 3 lines of code.
TypeScript
import { scanProject } from 'code-x-ray';🚀 Fire up the engine (scans recursively)
console.time("✨ Magic Time");
const context = scanProject("./src");
console.timeEnd("✨ Magic Time");
console.log(`\n📦 Scanned ${context.files_scanned} files in ${context.duration_ms}ms`);2. Powerful Filtering
Don't just scan—understand. Filter the raw AST data to find exactly what you need.
TypeScript
// Example: Find all 'TODO' comments or specific function definitions
const context = scanProject("./src");
// 🔍 Filter for TypeScript functions only
const functions = context.files
.filter(f => f.language === 'TypeScript')
.flatMap(f => f.symbols)
.filter(s => s.kind === 'function');
console.table(functions.map(fn => ({
Name: fn.name,
Location: `L${fn.start.row}:${fn.start.column}`,
Signature: fn.signature || '(unknown)'
})));3. The "Context" Payload
The engine returns a clean, highly-structured JSON object optimized for LLM Context Windows (GPT-4, Claude, Llama 3).
JSON
{
"root_dir": "./src",
"stats": {
"duration_ms": 142.5,
"files_processed": 45,
"threads_active": 12
},
"files": [
{
"path": "src/services/auth.ts",
"language": "TypeScript",
"size": 2048,
"symbols": [
{
"name": "authenticateUser",
"kind": "function",
"range": {
"start": { "row": 15, "col": 0 },
"end": { "row": 25, "col": 1 }
},
"signature": "async (token: string) => Promise<User>"
}
]
}
]
}