How bodsink/loci works
Loci indexes local repositories into a persistent symbol-and-relationship graph, then exposes structural discovery to coding agents through MCP and to people through a local web UI. The main workflow is CLI or MCP indexing → file walking and parsing → cross-file resolution (optionally aided by LSP) → graph storage → graph queries and snippets. The README also documents freshness, coverage, change detection, runtime traces, ADRs, and UI views. Several subsystem links reflect explicit README descriptions because their implementation excerpts were not provided.
Main entry points: lib.rs Index orchestration · handlers.rs Tool handlers · extract.rs Language parsing · main.rs CLI commands
Components 30
Indexing
- Repository walker
crates/loci-index/src/walk.rs - Language parsing
crates/loci-parse/src/extract.rs - Grammar registry
crates/loci-parse/src/registry.rs - Dialect adaptations
crates/loci-parse/src/dialect.rs - Language specifications
crates/loci-parse/src/spec.rs - Edge resolution
crates/loci-index/src/resolve.rs - Import resolution
crates/loci-index/src/imports.rs - Index orchestration
crates/loci-index/src/lib.rs - Change detection
crates/loci-index/src/changes.rs - Hybrid indexing
crates/loci-index/src/hybrid.rs - LSP client
crates/loci-lsp/src/client.rs
Graph engine
- Graph schema
crates/loci-graph/src/schema.rs - Persistent graph store
crates/loci-graph/src/store.rs - Graph queries
crates/loci-graph/src/query.rs - Project catalog
crates/loci-graph/src/catalog.rs - Index coverage
crates/loci-graph/src/coverage.rs
Agent interface
- CLI commands
crates/loci-cli/src/main.rs - MCP server
crates/loci-mcp/src/lib.rs - Tool handlers
crates/loci-mcp/src/handlers.rs - Tool definitions
crates/loci-mcp/src/tools.rs - Freshness checks
crates/loci-mcp/src/freshness.rs - Usage journal
crates/loci-mcp/src/journal.rs
Local web UI
- UI service
crates/loci-cli/src/ui.rs - Graph views
crates/loci-cli/src/ui/ui_graph.rs - Browser UI
crates/loci-cli/web/app.js
Other components
- Engineer or agent
- Source repository
- Cursor / MCP client
- Web browser
- Language server
Connections 33
- Engineer or agent → CLI commands: runs commands
- Engineer or agent → Cursor / MCP client: asks questions
- Cursor / MCP client → MCP server: starts stdio server
- MCP server → Tool definitions: registers tools
crates/loci-mcp/src/lib.rs - MCP server → Tool handlers: dispatches calls
crates/loci-mcp/src/lib.rs - Tool handlers → Index orchestration: indexes projects
crates/loci-mcp/src/handlers.rs - CLI commands → Index orchestration: indexes projects
crates/loci-cli/src/main.rs - Index orchestration → Repository walker: walks files
crates/loci-index/src/lib.rs - Index orchestration → Language parsing: parses changed files
crates/loci-index/src/lib.rs - Language parsing → Grammar registry: selects grammar
crates/loci-parse/src/extract.rs - Language parsing → Dialect adaptations: adapts syntax
crates/loci-parse/src/dialect.rs - Language parsing → Language specifications: uses language rules
crates/loci-parse/src/extract.rs - Index orchestration → Edge resolution: rebuilds edges
crates/loci-index/src/lib.rs - Edge resolution → Import resolution: resolves imports
- Index orchestration → Change detection: detects changes
crates/loci-index/src/lib.rs - Index orchestration → Hybrid indexing: adds LSP evidence
crates/loci-index/src/lib.rs - Hybrid indexing → LSP client: requests definitions
- LSP client → Language server: sends LSP requests
crates/loci-lsp/src/client.rs - Index orchestration → Persistent graph store: writes graph
- Persistent graph store → Graph schema: stores schema records
crates/loci-graph/src/store.rs - Tool handlers → Graph queries: runs graph queries
crates/loci-mcp/src/handlers.rs - Graph queries → Persistent graph store: reads graph
crates/loci-graph/src/query.rs - Tool handlers → Index coverage: reports coverage
- Tool handlers → Freshness checks: checks freshness
- Tool handlers → Usage journal: records tool calls
- CLI commands → Usage journal: summarizes usage
crates/loci-cli/src/main.rs - CLI commands → UI service: starts UI
crates/loci-cli/src/main.rs - UI service → Graph views: serves graph views
crates/loci-cli/src/ui.rs - UI service → Browser UI: serves browser assets
- Browser UI → Web browser: renders interface
- Graph views → Persistent graph store: reads graph
- Source repository → Index orchestration: provides source
- Tool handlers → Project catalog: uses project catalog