Crate pith

Crate pith 

Source
Expand description

Pith - Generate optimized codebase context for LLMs.

Pith walks directory trees, extracts API signatures (“codemaps”) from source files, and produces structured output suitable for feeding to language models.

§Quick Start

use pith::builder::Pith;
use pith::filter::Language;

// Extract codemaps from a project
let result = Pith::new("./my-project")
    .languages(&[Language::Rust, Language::TypeScript])
    .include_docs(true)
    .build()
    .unwrap();

println!("Found {} files with codemaps", result.codemaps.len());
println!("Total tokens: {}", result.total_tokens());

§Modules

  • tokens - Token counting for LLM context budgets
  • filter - File filtering with blocklist/allowlist/heuristics
  • tree - File tree representation and rendering
  • walker - Directory traversal with gitignore support
  • codemap - Tree-sitter based code extraction
  • builder - Fluent API for extraction

§Supported Languages

  • Rust (.rs)
  • TypeScript (.ts, .tsx)
  • JavaScript (.js, .jsx, .mjs, .cjs)
  • Python (.py, .pyi)
  • Go (.go)

Re-exports§

pub use builder::Pith;
pub use builder::PithResult;
pub use codemap::Codemap;
pub use codemap::CodemapError;
pub use codemap::Declaration;
pub use codemap::Visibility;
pub use codemap::Location;
pub use errors::PithError;
pub use filter::FilterError;
pub use filter::Language;
pub use output::OutputError;
pub use tree::FileNode;
pub use tree::NodeKind;
pub use tree::RenderOptions;
pub use tokens::count_tokens;
pub use tokens::Encoding;
pub use tokens::TokenCounter;
pub use walker::WalkError;

Modules§

builder
Fluent builder API for pith.
codemap
Codemap extraction using tree-sitter.
errors
Error types for Pith.
filter
File filtering using layered blocklist/allowlist/heuristics.
output
Output formatting for pith.
tokens
Token counting for LLM context budget management.
tree
File tree representation and rendering.
walker
Directory traversal with gitignore support.