Skip to main content

Crate aptu_coder_core

Crate aptu_coder_core 

Source
Expand description

Multi-language code structure analysis library using tree-sitter.

This crate provides core analysis functionality for extracting code structure from multiple programming languages. It is designed to be used as a library by MCP servers and other tools.

§Features

  • Language support: Astro, C/C++, C#, CSS, Fortran, Go, HTML, Java, JavaScript, JSON, Kotlin, Markdown, Python, Rust, TOML, TSX, TypeScript, YAML (feature-gated)
  • Schema generation: Optional JSON schema support via the schemars feature
  • Async-friendly: Uses tokio for concurrent analysis
  • Cancellation support: Built-in cancellation token support

§Examples

use aptu_coder_core::analyze::analyze_directory;
use std::path::Path;

let output = analyze_directory(Path::new("src"), None)?;
println!("Files: {:?}", output.files.len());

Re-exports§

pub use analyze::AnalysisOutput;
pub use analyze::AnalyzeError;
pub use analyze::CallChainEntry;
pub use analyze::FileAnalysisOutput;
pub use analyze::FocusedAnalysisConfig;
pub use analyze::FocusedAnalysisOutput;
pub use analyze::analyze_directory;
pub use analyze::analyze_directory_with_progress;
pub use analyze::analyze_file;
pub use analyze::analyze_focused;
pub use analyze::analyze_focused_with_progress;
pub use analyze::analyze_focused_with_progress_with_entries;
pub use analyze::analyze_module_file;
pub use analyze::analyze_str;
pub use edit::EditError;
pub use edit::edit_overwrite_content;
pub use edit::edit_replace_block;
pub use edit::edit_replace_block_with_options;
pub use graph::GraphError;
pub use graph::InternalCallChain;
pub use lang::language_for_extension;
pub use lang::supported_languages;
pub use pagination::CursorData;
pub use pagination::PaginationError;
pub use parser::ParserError;
pub use traversal::TraversalError;
pub use traversal::WalkEntry;
pub use types::AnalysisMode;
pub use types::AnalyzeDirectoryParams;
pub use types::AnalyzeFileField;
pub use types::AnalyzeFileParams;
pub use types::AnalyzeModuleParams;
pub use types::AnalyzeSymbolParams;
pub use types::CallEdge;
pub use types::CallInfo;
pub use types::ClassInfo;
pub use types::DefUseKind;
pub use types::DefUseSite;
pub use types::EditOverwriteOutput;
pub use types::EditOverwriteParams;
pub use types::EditReplaceOutput;
pub use types::EditReplaceParams;
pub use types::FileInfo;
pub use types::FilterRule;
pub use types::FunctionInfo;
pub use types::ImplTraitInfo;
pub use types::ImportInfo;
pub use types::ModuleFunctionInfo;
pub use types::ModuleImportInfo;
pub use types::ModuleInfo;
pub use types::OutputControlParams;
pub use types::PaginationParams;
pub use types::ReferenceInfo;
pub use types::ReferenceType;
pub use types::SemanticAnalysis;
pub use types::SymbolMatchMode;

Modules§

analyze
Main analysis engine for extracting code structure from files and directories.
cache
LRU cache for analysis results indexed by path, modification time, and mode.
cache_disk
Disk-based cache for analysis results.
completion
Path completion support for file and directory paths.
edit
File write utilities for the edit_overwrite and edit_replace tools.
formatter
Output formatting for analysis results across different modes.
formatter_defuse
Def-use pagination formatting.
graph
Call graph construction and analysis.
lang
Language detection by file extension.
languages
Language-specific handlers and query definitions for tree-sitter parsing.
pagination
Cursor-based pagination for large result sets.
parser
Tree-sitter-based parser for extracting semantic structure from source code.
schema_helpers
test_detection
Test file detection using path heuristics.
traversal
Directory traversal with .gitignore support.
types

Structs§

AnalysisConfig
Resource limits and configuration for analysis operations.
QueryCapture
Captures from a custom tree-sitter query.

Constants§

EXCLUDED_DIRS

Functions§

execute_query
Execute a custom tree-sitter query against source code.