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: Rust, Go, Java, Python, TypeScript, TSX, Fortran, JavaScript, C/C++, C# (feature-gated)
- Schema generation: Optional JSON schema support via the
schemarsfeature - 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_raw_range;pub use analyze::analyze_str;pub use edit::EditError;pub use edit::edit_insert_at_symbol;pub use edit::edit_overwrite_content;pub use edit::edit_rename_directory;pub use edit::edit_rename_in_file;pub use edit::edit_replace_block;pub use lang::language_for_extension;pub use lang::supported_languages;pub use parser::ParserError;pub use types::AnalysisMode;pub use types::AnalysisResult;pub use types::AnalyzeDirectoryParams;pub use types::AnalyzeFileField;pub use types::AnalyzeFileParams;pub use types::AnalyzeModuleParams;pub use types::AnalyzeRawOutput;pub use types::AnalyzeRawParams;pub use types::AnalyzeSymbolParams;pub use types::CallChain;pub use types::CallEdge;pub use types::CallInfo;pub use types::ClassInfo;pub use types::DefUseKind;pub use types::DefUseSite;pub use types::EditInsertOutput;pub use types::EditInsertParams;pub use types::EditOverwriteOutput;pub use types::EditOverwriteParams;pub use types::EditRenameOutput;pub use types::EditRenameParams;pub use types::EditReplaceOutput;pub use types::EditReplaceParams;pub use types::ErrorMeta;pub use types::ExecCommandParams;pub use types::FileInfo;pub use types::FileRenameError;pub use types::FileRenameResult;pub use types::FocusedAnalysisData;pub use types::FunctionInfo;pub use types::ImplTraitInfo;pub use types::ImportInfo;pub use types::InsertPosition;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::STDIN_MAX_BYTES;pub use types::SemanticAnalysis;pub use types::ShellOutput;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.
- completion
- Path completion support for file and directory paths.
- edit
- File write utilities for the
edit_overwrite,edit_replace,edit_rename, andedit_inserttools. - 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§
- Analysis
Config - Resource limits and configuration for analysis operations.
- Query
Capture - Captures from a custom tree-sitter query.
Functions§
- execute_
query - Execute a custom tree-sitter query against source code.