Skip to main content

Crate llmy_codegraph

Crate llmy_codegraph 

Source
Expand description

Tree-sitter based code indexing for smart contracts: call graphs and state graphs over Solidity, Rust (Anchor / CosmWasm) and Move (Aptos / Sui), plus agent-facing query tools.

Re-exports§

pub use builder::BuildResult;
pub use builder::CodeGraphBuilder;
pub use model::CodeGraph;
pub use store::CodeGraphStore;
pub use tools::CodegraphContext;

Modules§

builder
Builds a CodeGraph from a project root: file discovery (gitignore aware), Move dialect detection per package, extraction, and by-name resolution of call sites and state references. Resolution is syntactic: same-module candidates win, a qualifier that names a module scopes the search, everything else stays ambiguous or external — explicitly.
extract
Shared extraction machinery: the raw per-file representation every language extractor produces, the tree-sitter language registry (including the vendored Move grammars), and node helpers used by all extractors.
model
Language-neutral code graph model shared by every extractor: containers (contracts / modules), callables (functions / modifiers / entries), state items (storage variables / accounts / resources / objects) and the edges between them. Call edges resolved purely from syntax keep their ambiguity explicit instead of pretending precision the parser does not have.
move_lang
Move extraction, one extractor per dialect: Aptos Move (vendored aptos-labs grammar; global storage accessed via move_to / borrow_global*) and Sui Move (vendored tzakian grammar; objects with key flowing through function parameters). The dialects differ enough — syntax and storage model both — that sharing one extractor would hide more than it saves.
rust_lang
Rust contract extraction over tree-sitter-rust. One module per file. State is recognized for the two supported contract ecosystems: Anchor (#[account] structs, expanded through Context<T> / #[derive(Accounts)] containers) and CosmWasm (Item / Map storage declarations with their save/load-style accesses). Plain Rust still gets modules, functions and call edges.
solidity
Solidity extraction over tree-sitter-solidity: contracts / interfaces / libraries, callables (functions, constructor, modifiers, fallback/receive), state variables, inheritance, call sites and state-variable reads/writes. Writes through storage-pointer aliases are a known precision loss of the pure-syntax approach.
store
SQLite cache for prebuilt code graphs. The graph is stored as one serialized snapshot per root keyed by an input fingerprint (relative paths and sizes), so llmy codegraph index can prebuild and the harness can load-or-rebuild cheaply. A stale fingerprint simply misses.
tools
Agent-facing query tools over a built CodeGraph: overview, per-module and per-callable source reading, call-edge lookups and state cross-references.