Overview
Repo Intel consists of three main components:- Index: ETS-based file system indexing with metadata
- RepoMap: Symbol extraction and relevance ranking
- ContextPacker: Token-budgeted context generation
File Index
TheLoom.RepoIntel.Index module maintains a fast in-memory index of your project files.
build/1
Perform a full scan of the project directory.The index automatically skips common directories like
.git, _build, deps, node_modules, and .loom.refresh/1
Incremental update - rescan only files whose modification time changed.Use
refresh/1 instead of build/1 for better performance after small changes. It only rescans modified files.lookup/2
Get metadata for a single file path.Relative file path from project root.
File metadata containing:
mtime(NaiveDateTime.t()): Last modification timesize(integer()): File size in bytestype(:file): Entry type (always:filefor now)language(atom()): Detected programming language
File not found in index.
list_files/2
List files with optional filters.Filter options:
language: atom()- Filter by programming languagepattern: String.t()- Glob pattern (supports**for directories)min_size: integer()- Minimum file size in bytesmax_size: integer()- Maximum file size in bytes
List of tuples
{path, metadata}, sorted by path.stats/1
Get summary statistics about the indexed repository.Statistics containing:
total_files(integer()): Total number of indexed filesby_language(map()): Count of files per languagetotal_size(integer()): Combined size of all files in bytes
detect_language/1
Detect the programming language of a file by extension.File path with extension.
Detected language:
:elixir, :javascript, :typescript, :python, :ruby, :rust, :go, :markdown, :json, :yaml, :html, :css, :sql, :shell, or :unknown.set_project/2
Change the project path and trigger a full rescan.Symbol Extraction
TheLoom.RepoIntel.RepoMap module extracts symbols (functions, classes, modules) from source files.
extract_symbols/1
Extract symbols from a source file using tree-sitter or regex.Absolute or relative path to source file.
List of symbol maps containing:
name(String.t()): Symbol nametype(atom()): Symbol type (:module,:function,:class,:struct, etc.)line(integer()): Line number where symbol is definedsignature(String.t() | nil): Function signature if available
Symbol extraction uses tree-sitter when available for accurate AST-based parsing. Falls back to regex patterns if tree-sitter is not installed.
tree_sitter_available?/0
Check if tree-sitter based extraction is available.extract_symbols_regex/1
Force regex-based symbol extraction (bypasses tree-sitter).rank_files/2
Rank file entries by relevance for a given context.List of
{path, metadata} tuples from Index.list_files/1.Ranking options:
mentioned_files: [String.t()]- Files mentioned in conversation (+100 score)keywords: [String.t()]- Relevant keywords (+10 per match)
List of
{path, metadata, score} tuples, sorted by score (highest first).generate/2
Generate a text repo map within a token budget.Root directory of the project.
Generation options:
max_tokens: integer()- Token budget (default: 2048)mentioned_files: [String.t()]- Files to prioritizekeywords: [String.t()]- Keywords for relevance ranking
Generated markdown text containing file paths and symbols, ranked by relevance.
Context Packing
TheLoom.RepoIntel.ContextPacker module packs ranked files into a token-budgeted context string.
pack/3
Pack ranked files into context within a token budget.List of
{path, metadata, score} tuples from RepoMap.rank_files/2.Maximum tokens to use (1 token ≈ 4 characters).
Options:
project_path: String.t()- Project root (defaults toFile.cwd!())
Markdown-formatted context string containing:
- High-relevance files: Full file content
- Medium-relevance files: Symbol listings only
- Low-relevance files: Just filenames
The packer intelligently adjusts content depth based on relevance score and remaining token budget:
- Score ≥ 100: Full file content
- Score ≥ 10: Symbols only
- Score < 10: Filename only
Tree-Sitter Integration
TheLoom.RepoIntel.TreeSitter module provides advanced symbol extraction using the tree-sitter CLI.
available?/0
Check if tree-sitter CLI is installed.extract_symbols/1
Extract symbols using tree-sitter with caching.extract_with_cli/2
Extract symbols directly using tree-sitter CLI (no caching).extract_with_regex/2
Extract symbols using enhanced regex patterns.clear_cache/0
Clear the symbol extraction cache.init_cache/0
Initialize the ETS cache table (called automatically on boot).Supported Languages
Symbol Extraction Support
| Language | Tree-Sitter | Regex | Symbols Extracted |
|---|---|---|---|
| Elixir | ✓ | ✓ | modules, functions, macros, types, specs, structs |
| JavaScript | ✓ | ✓ | functions, classes, constants, interfaces |
| TypeScript | ✓ | ✓ | functions, classes, interfaces, types, enums |
| Python | ✓ | ✓ | classes, functions, constants |
| Go | ✓ | ✓ | functions, methods, structs, interfaces, types |
| Rust | ✓ | ✓ | functions, structs, enums, traits, impls, modules |
| Ruby | ✓ | ✓ | classes, modules, methods, attributes |