universal-context-memory
v2.1.0
Published
Auto-indexing memory for AI coding assistants - baked into your project
Downloads
206
Maintainers
Readme
What is UCE?
Universal Context Engine indexes your codebase and provides intelligent context retrieval for AI coding assistants. Unlike cloud-based solutions, UCE runs 100% locally and stores everything in your project.
# Install and index your project
npm install universal-context-memory
npx ucm init
# That's it! Claude Code, Cursor, and Copilot now understand your codebasev2.0 Highlights
- Tree-sitter AST Parsing - 20+ languages with accurate symbol extraction
- Incremental Indexing - Only re-index changed files
- Knowledge Graph - Navigate code relationships (callers, inheritance, dependencies)
- Hybrid Retrieval - BM25 + semantic search for best results
- MCP Server - Direct integration with Claude Code and other AI tools
- Watch Mode - Auto-update on file changes
Features
| Feature | Description | |---------|-------------| | Tree-sitter Parsing | Accurate AST-based symbol extraction for 20+ languages | | Knowledge Graph | Track function calls, class inheritance, and dependencies | | Hybrid Search | BM25 lexical + semantic vector search | | Incremental Index | Fast updates - only re-parse changed files | | MCP Server | Model Context Protocol server for AI assistants | | Watch Mode | Real-time index updates on file changes | | Multi-tool Output | Claude Code, Cursor, Copilot, any LLM | | 100% Local | No cloud, no uploads, complete privacy |
Supported Languages
TypeScript, JavaScript, Python, Rust, Go, Java, C#, Ruby, PHP, Swift, Kotlin, Scala, C, C++, and more.
Installation
# npm
npm install universal-context-memory
# yarn
yarn add universal-context-memory
# pnpm
pnpm add universal-context-memory
# global install
npm install -g universal-context-memorySee INSTALLATION.md for detailed setup instructions.
Quick Start
1. Initialize
npx ucm initCreates:
your-project/
├── .context/index.json # Codebase index
├── UCM.md # Universal context (any AI)
├── CONTEXT.md # Generic LLM context
├── CLAUDE.md # Claude Code specific
├── .cursorrules # Cursor IDE
└── .github/copilot-instructions.md2. View Stats
npx ucm stats3. Search Your Code
npx ucm search "authentication"4. Start Watch Mode
npx ucm watchCommands
| Command | Description |
|---------|-------------|
| ucm init | Initialize UCE in a project |
| ucm index | Re-index the codebase |
| ucm watch | Watch for changes and auto-update |
| ucm stats | Show index statistics |
| ucm search <query> | Search codebase with BM25 |
| ucm query <term> | Query symbols and files |
| ucm graph | Export knowledge graph (JSON/DOT/Mermaid) |
| ucm related <symbol> | Find related symbols |
| ucm callers <function> | Find function callers |
| ucm inheritance <class> | Show class hierarchy |
| ucm serve | Start MCP server |
| ucm config | Manage configuration |
| ucm info | Show version and system info |
| ucm clean | Remove generated files |
| ucm export | Export index as JSON |
Examples
# Search for authentication code
npx ucm search "login validation"
# Find all callers of a function
npx ucm callers handleSubmit
# Show class inheritance tree
npx ucm inheritance BaseController
# Export graph as Mermaid diagram
npx ucm graph --format mermaid > architecture.md
# Start MCP server on custom port
npx ucm serve --port 4000Configuration
Create .ucmrc.json:
{
"projectName": "my-project",
"ignore": ["**/dist/**", "**/*.min.js"],
"priorityFiles": ["README.md", "src/index.ts"],
"maxTokens": 50000,
"enableEmbeddings": false,
"output": {
"ucmMd": true,
"contextMd": true,
"claudeMd": true,
"cursorRules": true,
"copilotInstructions": true
}
}Generate default config:
npx ucm config --initAPI
Context Engine
import { ContextEngine } from 'universal-context-memory';
const engine = new ContextEngine({
projectRoot: '/path/to/project',
enableEmbeddings: false,
});
await engine.initialize();
await engine.index();
// Retrieve context for a query
const context = await engine.retrieve('how does auth work?');
// Search symbols
const results = engine.searchSymbols('User');
// Knowledge graph queries
const callers = engine.findCallers('handleLogin');
const hierarchy = engine.getInheritance('BaseService');
const deps = engine.getDependencies('src/auth.ts');Legacy API (v1.x compatible)
import { Indexer, ContextGenerator, indexProject } from 'universal-context-memory';
// Quick one-liner
await indexProject('/path/to/project');
// Or manual control
const indexer = new Indexer({ projectRoot: '/path/to/project' });
const index = await indexer.index();
const generator = new ContextGenerator({ projectRoot: '/path/to/project', index });
generator.generateAll();MCP Server
UCE includes a Model Context Protocol server for direct AI assistant integration.
Start Server
npx ucm serve --port 3333Claude Code Integration
Add to your MCP configuration:
{
"mcpServers": {
"ucm": {
"command": "npx",
"args": ["ucm", "serve"],
"cwd": "/path/to/project"
}
}
}MCP Tools
| Tool | Description |
|------|-------------|
| retrieve | Get relevant context for a query |
| search | Search symbols |
| related | Find related code |
| callers | Find function callers |
| inheritance | Get class hierarchy |
| dependencies | Get file dependencies |
| stats | Index statistics |
Architecture
┌─────────────────────────────────────────────────────────────┐
│ Universal Context Engine v2.0 Architecture │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Tree-sitter │───▶│ Incremental │───▶│ Knowledge │ │
│ │ Parser │ │ Indexer │ │ Graph │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Context │◀───│ Hybrid │◀───│ BM25 │ │
│ │ Engine │ │ Retriever │ │ Index │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ MCP Server │ │ Generator │ │ Watch │ │
│ │ │ │ (MD files) │ │ Mode │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘Comparison
| Feature | UCE | Cloud Alternatives | |---------|-----|-------------------| | Data location | Your project | Their cloud | | Privacy | 100% local | Code uploaded | | Works offline | Yes | No | | Open source | Yes | Usually no | | Cost | Free | Paid | | Any LLM support | Yes | Vendor locked |
Contributing
We welcome contributions! See CONTRIBUTING.md for guidelines.
git clone https://github.com/Eskapeum/Context-Engine.git
cd Context-Engine
npm install
npm run build
npm testLicense
MIT License - see LICENSE
