-
-
Notifications
You must be signed in to change notification settings - Fork 34
Code Intelligence
CortexPrism's code intelligence system provides deep structural understanding of codebases using tree-sitter WASM parsing with FTS5-backed full-text search over a graph database of code symbols and their relationships.
┌──────────────────────────────────────────────────────────────┐
│ Code Intelligence │
│ │
│ tree-sitter WASM (14+ languages) │
│ │ │
│ ▼ │
│ ┌──────────────────────────────────────┐ │
│ │ AST Extraction │ │
│ │ - Functions, classes, interfaces │ │
│ │ - Imports, exports, calls │ │
│ │ - Decorators, HTTP calls, async │ │
│ │ - Complexity estimation │ │
│ └──────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────────────────────────────┐ │
│ │ Code Graph (memory.db) │ │
│ │ - 14 node labels (CodeFunction, │ │
│ │ CodeClass, CodeInterface, etc.) │ │
│ │ - 18 edge types (CALLS, IMPORTS, │ │
│ │ DEFINES, IMPLEMENTS, INHERITS) │ │
│ │ - FTS5 full-text search │ │
│ └──────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────────────────────────────┐ │
│ │ Codegraph Resolver │ │
│ │ - Exact symbol match │ │
│ │ - Method on class resolution │ │
│ │ - Wildcard/relative import │ │
│ │ - Type inference │ │
│ │ - Fallback search │ │
│ └──────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────────────────────────────┐ │
│ │ 6 Agent Tools │ │
│ │ code_index code_search_symbol │ │
│ │ code_trace_path code_get_architecture│ │
│ │ code_analyze_impact code_list_projects│ │
│ └──────────────────────────────────────┘ │
│ │
│ Web UI: D3.js force-directed graph │
│ ┌──────────────────────────────────────┐ │
│ │ - Interactive dependency graph │ │
│ │ - Symbol search with FTS5 │ │
│ │ - Impact analysis (blast radius) │ │
│ │ - Path tracer (caller ↔ callee) │ │
│ └──────────────────────────────────────┘ │
└──────────────────────────────────────────────────────────────┘
Tree-sitter WASM parsers with lazy-loading from CDN:
| Language | File Extensions | Parser |
|---|---|---|
| TypeScript |
.ts, .tsx
|
tree-sitter-typescript |
| JavaScript |
.js, .jsx
|
tree-sitter-javascript |
| Python | .py |
tree-sitter-python |
| Go | .go |
tree-sitter-go |
| Rust | .rs |
tree-sitter-rust |
| Java | .java |
tree-sitter-java |
| Kotlin | .kt |
tree-sitter-kotlin |
| C |
.c, .h
|
tree-sitter-c |
| C++ |
.cpp, .hpp
|
tree-sitter-cpp |
| Ruby | .rb |
tree-sitter-ruby |
| PHP | .php |
tree-sitter-php |
| Swift | .swift |
tree-sitter-swift |
| Lua | .lua |
tree-sitter-lua |
| Bash |
.sh, .bash
|
tree-sitter-bash |
CodeProject, CodeFile, CodeFunction, CodeClass, CodeInterface, CodeEnum, CodeType, CodeVariable, CodeConstant, CodeModule, CodeDecorator, CodeEndpoint, CodeDatabaseQuery, CodeTest
CALLS, IMPORTS, DEFINES, IMPLEMENTS, INHERITS, HTTP_CALLS, ASYNC_CALLS, DECORATES, EXPORTS, REFERENCES, RETURNS, PARAMETER_OF, THROWS, TESTS, MOCKS, CONFIGURES, MIGRATES, DEPENDS_ON
code_index(projectPath)
1. Directory walk (max 200K files, depth 100)
2. File hash comparison (skip unchanged)
3. Language detection by extension
4. WASM parser validation (integrity check)
5. AST extraction per file
6. Chunked bulk insert (BFS-batched: 2 queries/level instead of N+1)
7. FTS5 index refresh
- Exact symbol match — direct name lookup
-
Method on class — resolve
ClassName.methodName -
Wildcard import — expand
import * as Xreferences -
Relative import path — resolve
./path/to/module - Type inference — follow type declarations to methods
- Fallback search — FTS5 full-text lookup
Full repository indexing with incremental sync.
| Parameter | Type | Description |
|---|---|---|
projectPath |
string | Root directory to index |
projectName |
string | Optional project identifier |
force |
boolean | Re-index all files (skip hash check) |
FTS5-backed symbol search across projects.
| Parameter | Type | Description |
|---|---|---|
query |
string | Symbol name to search |
project |
string | Optional project filter |
kind |
string | Optional node label filter |
limit |
number | Max results (default 20) |
Bidirectional call graph traversal.
| Parameter | Type | Description |
|---|---|---|
symbolId |
string | Starting symbol node ID |
direction |
string |
"inbound", "outbound", or "both"
|
maxDepth |
number | Maximum traversal depth (default 5) |
System architecture diagram extraction.
| Parameter | Type | Description |
|---|---|---|
project |
string | Project name |
Returns layers, modules, and dependency structure.
Blast radius analysis for a symbol.
| Parameter | Type | Description |
|---|---|---|
symbolId |
string | Target symbol node ID |
Returns direct/indirect callers, callees, dead code detection, and complexity metrics.
Project registry with language statistics.
Returns per-project node counts, edge counts, language breakdowns, and last-indexed timestamps.
- D3.js force-directed graph — interactive zoomable dependency visualization
- Symbol search — FTS5-powered search with type filters
- Impact analysis — click a node to see blast radius (callers + callees)
- Path tracer — trace calls between any two symbols
- Hotspot detection — identify high-complexity nodes
| Method | Path | Description |
|---|---|---|
GET |
/api/codegraph/projects |
List indexed projects |
POST |
/api/codegraph/index |
Start code indexing |
GET |
/api/codegraph/search?q=&project= |
Search symbols |
POST |
/api/codegraph/impact |
Impact analysis |
GET |
/api/codegraph/architecture?project= |
Architecture extraction |
POST |
/api/codegraph/trace |
Path tracing |
- Architecture — System overview
- Built-in Tools — Complete tool catalog
- Agent Loop — How tools integrate into agent turns
Search across all indexed projects simultaneously:
-
GET /api/codegraph/search-all?q=&language=returns ranked cross-repo results - Project name labels distinguish results from different repositories
- Codegraph web UI: 🌐 All repos button in the sidebar search panel
-
ftsSearchNodes()accepts optionallanguageparameter -
getLanguages()returns distinct languages per project - Language dropdown in the Codegraph sidebar filters search results
-
GET /api/codegraph/ownership?file=returnsgit blameauthor attribution - Owners ranked by lines authored (name and email)
-
GET /api/codegraph/history?file=returns recent commits viagit log - Hash, message context for each commit
-
GET /api/codegraph/qa?q=&project=returns symbol citations with provenance - Citations include file, line, signature, and language context
-
GET /api/codegraph/fitness?project=runs naming conventions, circular dependency, and layer isolation checks
-
GET /api/codegraph/pilot-configreturns token budget and pruning mode -
PUT /api/codegraph/pilot-configupdates pilot settings
-
GET /api/alcove/search?q=performs semantic search over.cortex/data/docs/ - Returns snippets with surrounding context lines from markdown/text files
CortexPrism — Open-source agentic AI harness · Discord · MIT License · Built with Deno 2.x + TypeScript
- Agent Loop
- Metacognition
- Memory System
- Skills System
- Sub-Agents
- Built-in Tools
- Code Intelligence
- Code Sandbox
- Cross-Agent Context Protocol
- Prompt Lab
- PKM Assistant
- Voice Pipeline
- Computer Use
- Browser Tool
- Git & GitHub
- Scheduler & Jobs
- Dashboard
- Observability
- A2A Protocol
- MCP Gateway
- Distributed Nodes
- Memori Checkpoints
- Eval System
- Workflow Engine
- Triggers
- Projects
- TUI
- Glossary
- Update System
- Chrome Bridge
- AgentLint