git clone <repository-url>
cd zlf
cargo build --release
The executable is target/release/zlf.
Open (or create) a database in the Prolog REPL:
target/release/zlf repl ./example-db
The REPL accepts facts, rules, directives, and queries:
node(alice, [person], { name: "Alice", title: "Engineer" }).
node(bob, [person], { name: "Bob", title: "Engineer" }).
knows(alice, bob).
friend(X, Y) :- person(X), person(Y), knows(X, Y).
? person(X).
? property(alice, name, Name).
? friend(alice, Who).
Exit with :quit, :exit, or Ctrl-D. :help prints examples. A successful ground query has no variable bindings and prints as [{}].
Turn a repository into queryable code symbols with no manifest required:
use zlf_codeindex::{CodeGraph, CodeRetrieval, IndexLifecycle, FileRef, Language};
// Open the lifecycle and graph.
let mut life = IndexLifecycle::open("./my-repo/index")?;
let graph = CodeGraph::open("./my-repo")?;
// Discover files (respects nested .gitignore).
let inv = zlf_codeindex::discover("src/".as_ref(), &Default::default());
// Ingest all discovered files.
for f in &inv.files {
let src = std::fs::read(&f.rel_path)?;
life.import_file(f, &src, &[])?;
}
// Sync into the graph.
graph.sync("my-repo", &life)?;
// Query via Prolog predicates or the Rust API.
let retrieval = CodeRetrieval::new(graph.storage())?;
let hits = retrieval.search("parse", 10, &Default::default(), 1000);
Supported languages: Java, C, C++, Python, Rust, JavaScript, TypeScript, Kotlin, Go, Swift. Vector embedding is not required.
See the full code indexing guide for Prolog predicates,
JSON/HTTP, the CodeQuery AST, and the benchmark harness.
Configuration is loaded from ./zlf.json, then ~/.zlf/config.json, then environment overrides. The default:
{
"db_path": "./zlf-db",
"embedding": {
"enabled": false,
"index_engine": "exact",
"provider": "ollama",
"api_endpoint": "http://localhost:11434",
"api_key": null,
"model": "bge-m3:latest",
"dimension": 1024
}
}
Embedding is disabled by default. Enable it only for semantic-retrieval workloads:
{
"db_path": "./zlf-db",
"embedding": {
"enabled": true,
"index_engine": "hnsw",
"provider": "ollama",
"api_endpoint": "http://localhost:11434",
"model": "bge-m3:latest",
"dimension": 1024
}
}
index_engine is exact or hnsw. HNSW always keeps exact RocksDB vectors as source of truth and fallback.
Environment overrides:
ZLF_DB_PATH=./zlf-db
ZLF_EMBED_ENABLED=true
ZLF_VECTOR_INDEX_ENGINE=hnsw
ZLF_EMBED_PROVIDER=ollama
ZLF_EMBED_ENDPOINT=http://localhost:11434
OLLAMA_ENDPOINT=http://localhost:11434
ZLF_EMBED_MODEL=bge-m3:latest
ZLF_EMBED_DIMENSION=1024
ZLF_EMBED_API_KEY=...