mayros code-index
Scan the codebase structure and store it as RDF triples in the Cortex knowledge graph. Supports incremental updates via content hashing so only changed files are re-indexed.
Subcommands
code-index run
Run a full or incremental code index. Scans TypeScript/JS files using regex-based parsing, detects functions, classes, imports, and file entities, and writes them as triples to Cortex.
Options:
| Flag | Description |
|---|---|
--path <dir> | Override the project root directory (default: current working directory) |
Output includes:
- Total files scanned
- New, changed, unchanged, and removed file counts
- Entity and triple counts
- Duration in milliseconds
code-index status
Show the current code index statistics from Cortex:
- Files — number of indexed files
- Functions — number of indexed functions
- Classes — number of indexed classes
- Imports — number of indexed imports
- Last indexed — timestamp of the last index run
code-index query <term>
Search code entities in the knowledge graph by name or file path.
| Argument | Description |
|---|---|
<term> | Search term (symbol name, file path, or module) |
Options:
| Flag | Description |
|---|---|
--type <type> | Filter by entity type: function, class, import, file |
--limit <n> | Maximum results to return (default: 10) |
Results show the entity type, name, file path, and line number.
How it works
- The scanner walks configured paths and file extensions
- Each file is hashed (SHA-256) for incremental change detection
- Regex patterns extract functions, classes, imports, and file metadata
- Entities are mapped to RDF triples using namespace-prefixed predicates
- Triples are stored in Cortex with
code:type,code:name,code:path, andcode:linepredicates
Examples
bashmayros code-index run mayros code-index run --path /path/to/project mayros code-index status mayros code-index query "CortexClient" mayros code-index query "index.ts" --type file mayros code-index query "createTriple" --type function --limit 5
Related
- Code Indexer — architecture and configuration
- Knowledge Graph — graph storage and querying