aptu-coder-core 0.14.1

Multi-language AST analysis library using tree-sitter
Documentation

aptu-coder-core

Core library for code structure analysis using tree-sitter.

Features

  • Directory analysis - File tree with LOC, function, and class counts
  • File analysis - Functions, classes, and imports with signatures and line ranges
  • Symbol call graphs - Callers and callees across a directory with configurable depth
  • Module index - Lightweight function and import index (~75% smaller than full file analysis)
  • Edit operations - In-file edits: overwrite, exact-block replace
  • In-memory analysis - analyze_str parses source text directly without a file path; returns the same FileAnalysisOutput as analyze_file
  • Multi-language - Rust, Python, TypeScript, TSX, Go, Java, Kotlin, Fortran, JavaScript, C/C++, C#
  • Pagination - Cursor-based pagination for large outputs
  • Caching - LRU cache for parsed results with mtime-based invalidation
  • Parallel - Rayon-based parallel file analysis

Installation

Add to your Cargo.toml:

[dependencies]
aptu-coder-core = "*"

The current version is published on crates.io. Replace "*" with the latest version string if you prefer a pinned dependency.

Example

use aptu_coder_core::{analyze_directory, analyze_file, analyze_str};
use std::path::Path;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Analyze a directory
    let output = analyze_directory(Path::new("src/"), None)?;
    println!("{} files", output.files.len());

    // Analyze a single file
    let output = analyze_file("src/lib.rs", None)?;
    println!("{}", output.formatted);

    // Analyze source text in memory (no file path required)
    let source = std::fs::read_to_string("src/lib.rs")?;
    let output = analyze_str(&source, "rs", None)?;
    println!("{}", output.formatted);

    Ok(())
}

Supported Languages

Rust, Python, TypeScript, TSX, Go, Java, Kotlin, Fortran, JavaScript, C/C++, C#. See the MCP server README for the full table with file extensions and feature flags.

Configuration

AnalysisConfig provides resource limits for library consumers:

use aptu_coder_core::AnalysisConfig;

let config = AnalysisConfig {
    max_file_bytes: Some(1_000_000), // reserved, currently a no-op
    parse_timeout_micros: None,      // parse timeout in microseconds; None disables timeout
    cache_capacity: None,            // use default LRU capacity
};

Support

For questions and support, visit clouatre.ca.

License

Apache-2.0. See LICENSE.