Expand description
Code-tree: parse polyglot codebases into kglite knowledge graphs.
Originally extracted from kglite’s in-tree code_tree component (which
KGLite removed on 2026-07-16, leaving this crate the sole builder) —
it depends on the kglite engine crate for the graph core
(kglite::api::DirGraph), the columnar data model
(kglite::datatypes), and .kgl persistence
(kglite::api::io). Tree-sitter grammars are direct
dependencies of this crate.
Entry points:
builder::run_with_options— parse a directory or manifest-rooted project, returnsArc<DirGraph>manifest::read_manifest— extract project metadatarepo::clone_and_build— shallow-clone a GitHub repo and build, returnsArc<DirGraph>
Re-exports§
pub use builder::run_with_options as build_code_tree;pub use parsers::language_for_path;pub use rev::archive_and_build;pub use rev::build_code_tree_revs;pub use rev::dedup_revs;
Modules§
- builder
- Builder: orchestrates parse → model → load phases.
- cross_
lang - Cross-language HTTP boundary edges — links client calls to server routes. Cross-language HTTP boundary edges (Phase C.1).
- docs
- Optional docs pass — ingests a repo’s markdown as
:Docnodes and links them to code symbols. Reuses the OKF parser, so it’s gated on thedocsfeature. Optional docs pass forcode_tree. - manifest
- Project manifest readers — pyproject.toml, Cargo.toml.
- models
- Data models for parsed code entities (ported from parsers/models.py).
- parsers
- Language parsers: one file per language grammar.
- repo
- GitHub shallow-clone helper (ported from repo.py).
- rev
- Build a code graph from a git revision (git-archive → tempdir → build),
without disturbing the working tree. Exposed as
code_tree.build(rev=…). Build a code graph from a git revision without disturbing the working tree.
Structs§
- Code
Entity Context - Resolved code-entity neighborhood, kept directional for neutral bindings.
- Source
Location - Resolved code-entity location returned by
KnowledgeGraph::source_location. All optional fields mirror what code-graph builders (e.g. codingest) store on the node — graphs built from non-code-tree sources may have fewer populated.
Enums§
- Code
Context Lookup - Outcome of resolving a code entity for
code_entity_context. - Code
Entity Match - Name-matching strategy for
find_code_entities. - Source
Lookup - Outcome of a
KnowledgeGraph::source_locationlookup.
Constants§
- CODE_
TYPES - Code-entity node types used by
source_location/resolve_code_entitywhen the caller doesn’t specify anode_type. Matches what the code-graph builders (e.g. codingest) emit — language-specific subsets (Rust:Struct/Enum/Trait; Python:Class/Mixin/Protocol; etc.) are all listed so a single search covers every supported source language. - DOC_
EXTENSIONS - Markup extensions the docs pass ingests as
:Docnodes, lower-case and without the dot. Matching is case-insensitive at every use site (docs::doc_format_for_ext), soREADME.MDis a doc too.
Functions§
- code_
entity_ context - Resolve a code entity and collect its neighborhood up to
hopsaway. - find_
code_ entities - Search code-entity type indices by
nameortitle. - resolve_
code_ entity - Resolve a name (or qualified-name suffix) to a single code-entity
NodeIndex. Returns(Some(idx), Vec::new())for an unambiguous match,(None, matches)when 0 or >1 candidates matched. - source_
location - Look up the source-file location for a code-entity node.