code-analyze-core 0.2.1

Multi-language AST analysis library using tree-sitter
Documentation

code-analyze-core

Core library for code structure analysis using tree-sitter.

docs.rs MCP server REUSE OpenSSF Best Practices

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)
  • Multi-language - Rust, Python, TypeScript, TSX, Go, Java, Fortran
  • 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]
code-analyze-core = "0.2"

Example

use code_analyze_core::{analyze_directory, analyze_file, AnalysisConfig};
use anyhow::Result;

#[tokio::main]
async fn main() -> Result<()> {
    // Analyze a directory (depth 2, compact summary)
    let output = analyze_directory("src/", Some(2), true, None, None, false, false).await?;
    println!("{}", output.formatted);

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

    Ok(())
}

Supported Languages

Language Extensions
Rust .rs
Python .py
TypeScript .ts, .tsx
Go .go
Java .java
Fortran .f, .f77, .f90, .f95, .f03, .f08, .for, .ftn

Configuration

AnalysisConfig provides resource limits for library consumers:

use code_analyze_core::AnalysisConfig;

let config = AnalysisConfig {
    max_file_bytes: Some(1_000_000), // skip files > 1 MB
    parse_timeout_micros: None,      // reserved, no-op in 0.2
    cache_capacity: None,            // use default LRU capacity
};

Support

For questions and support, visit clouatre.ca.

License

Apache-2.0. See LICENSE.