Skip to main content

grove_core/
lib.rs

1//! grove-core — the structural code-intelligence library behind the grove CLI
2//! and MCP server.
3//!
4//! This crate hosts the tree-sitter AST engine, the grammar registry, grammar
5//! fetching, and source ingest. It is `clap`-free: command-line concerns live in
6//! the `grove` binary crate, which consumes this library via `grove_core::`.
7//!
8//! # Overview
9//!
10//! The consumer-facing surface is the [`ops`] module — a small set of structural
11//! queries that work for **any** registered language (grammars load from the
12//! [`registry`] as wasm, so nothing is compiled in):
13//!
14//! - [`ops::outline`] — the definitions in one file (its symbol skeleton).
15//! - [`ops::symbols`] — find symbols across a directory, gitignore-aware.
16//! - [`ops::source`] — the full source text of one symbol, by id or name.
17//! - [`ops::check`] — the syntactic defects (ERROR / MISSING) in one file.
18//! - [`ops::callers`] — every reference to a name, with its enclosing function.
19//! - [`ops::map`] — a directory's definitions and their outgoing references.
20//! - [`ops::definition`] / [`ops::definition_at`] — go-to-def by name or use site.
21//!
22//! [`init::provision_project`] is the grammar-provisioning entry point used by
23//! `grove init`. The lower-level [`engine`], [`fetch`], and [`ingest`] modules are
24//! public for hosts that need deeper access.
25//!
26//! # Example
27//!
28//! ```no_run
29//! use std::path::Path;
30//! use grove_core::ops;
31//!
32//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
33//! // Every definition under `src/`, gitignore-aware.
34//! let symbols = ops::symbols(Path::new("src"), None, None, false, false)?;
35//! for s in &symbols {
36//!     println!("{} {} — {}:{}", s.kind, s.name, s.file, s.line);
37//! }
38//! # Ok(())
39//! # }
40//! ```
41
42pub mod config;
43pub mod doctor;
44pub mod engine;
45pub mod fetch;
46pub mod harness;
47pub mod ingest;
48pub mod init;
49pub mod ops;
50/// Shared proxy resolution for grove's `ureq` HTTP clients — used by
51/// [`fetch`] here and by the `grove-explore-core` crate's chat/health clients.
52pub mod proxy;
53pub mod registry;
54pub mod render;
55
56// ---- Curated public surface ----
57//
58// Root re-exports so consumers can name the common return types and entry points
59// directly (e.g. `grove_core::Symbol`) instead of reaching through module paths.
60// The full module set above stays public for callers that need deeper access;
61// internal helpers (`Loaded`, `CapturedQuery`, `Index`, `Sources`, `Spec`,
62// `Catalog`, …) remain private to their modules and are not re-exported.
63
64/// Core symbol/defect types extracted by the [`engine`].
65pub use engine::{Defect, Symbol};
66/// Return types of the [`ops`] structural queries.
67pub use ops::{CallSite, FileMap, MapEntry, SourceResult};
68/// The grammar-provisioning entry point behind `grove init` (see [`init`]).
69pub use init::provision_project;
70/// The grove project config type and integration mode (see [`config`]).
71pub use config::{active_mode, GroveConfig, Mode, ModeChoice};
72/// Lock-file verification types returned by [`registry::verify_lock`].
73pub use registry::{LockVerifyEntry, LockVerifyStatus};