arcella-inspect
Static code introspection for Rust โ structured, machine-readable metadata for AI agents, architecture tools, and automated analysis.
arcella-inspect is a Rust library and CLI tool that parses Rust source code and extracts rich structural metadata โ functions, structs, calls, attributes, documentation โ into a clean, hierarchical YAML 1.2 format. Designed for integration with AI-driven code understanding, dependency mapping, documentation generation, and architectural audits.
Part of the Arcella ecosystem.
๐ Features
- โ
Accurate AST-based analysis using
syn - โ
Full function signatures: parameters, return types, attributes (
pub,async,unsafe, etc.) - โ Call graph extraction with internal/external call distinction
- โ
Documentation strings from
///and#[doc = "..."] - โ Cargo workspace support โ each crate analyzed as a subproject
- โ YAML 1.2 output โ human-readable and AI-friendly
- โ Extensible format designed for future enrichment (AI tags, performance hints, etc.)
๐ฆ Installation
As a CLI tool
As a library (in your Cargo.toml)
[]
= "0.1"
โถ๏ธ Usage
CLI: Analyze a project and output YAML
# Analyze current directory
# Analyze specific project
# Pipe to file
Library: Use in your own tool
use ;
let root = new;
let analysis = analyze_project?;
let yaml = analysis_to_yaml?;
println!;
๐ Output Format (Simplified)
version: "1.0"
subprojects:
- name: "auth-service"
root: "crates/auth"
functions:
- name: "validate_token"
file: "src/validator.rs"
line: 34
returns: "Result<Claims, AuthError>"
parameters:
- "token: &str"
- "secret: &[u8]"
attributes:
docstring: "Validates a JWT token using the provided secret."
calls:
- name: "jsonwebtoken::decode"
external: true
- name: "metrics::record_auth_attempt"
file: "src/metrics.rs"
line: 12
๐ See the full output format specification for details.
๐ Use Cases
- AI code agents: feed structured Rust metadata to LLMs for reasoning
- Architecture visualization: generate call graphs and module maps
- Documentation automation: extract public APIs with docs and signatures
- Security & compliance: audit for unsafe code, external dependencies, or missing docs
- Refactoring assistance: identify dead code, tight coupling, or complex call chains
๐งช Example
Given src/lib.rs:
/// Adds two numbers.
Running arc-inspect produces:
version: "1.0"
subprojects:
- name: "my-crate"
root: "."
functions:
- name: "add"
file: "src/lib.rs"
line: 2
returns: "i32"
parameters:
- "a: i32"
- "b: i32"
docstring: "Adds two numbers."
attributes:
calls:
๐ Documentation
๐ License
Dual-licensed under MIT or Apache 2.0 โ your choice.
๐ค Contributing
Contributions are welcome! Please open an issue or PR on GitHub.
Planned improvements:
- Support for enums, traits, and constants
- Performance optimizations for large codebases
- JSON and NDJSON output formats
- Integration with
rust-analyzerLSP for real-time analysis