arcella-inspect

Crates.ioarcella-inspect
lib.rsarcella-inspect
version0.1.3
created_at2025-12-06 05:02:19.481018+00
updated_at2026-01-05 11:20:23.250331+00
descriptionStatic analysis of Rust code to extract structured metadata (functions, structs, calls) as YAML or structured data.
homepage
repositoryhttps://github.com/ArcellaTeam/arcella-rust-inspect/
max_upload_size
id1969632
size58,607
(arcella-team)

documentation

README

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.

crates.io
docs.rs
License: Apache-2.0/MIT

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

cargo install arcella-inspect

As a library (in your Cargo.toml)

[dependencies]
arcella-inspect = "0.1"

โ–ถ๏ธ Usage

CLI: Analyze a project and output YAML

# Analyze current directory
arc-inspect

# Analyze specific project
arc-inspect ./my-rust-project

# Pipe to file
arc-inspect > architecture.yaml

Library: Use in your own tool

use arcella_inspect::{analyze_project, analysis_to_yaml};

let root = std::path::Path::new("./my-project");
let analysis = analyze_project(root)?;
let yaml = analysis_to_yaml(&analysis, root)?;

println!("{}", yaml);

๐Ÿ“Š 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: ["pub", "async"]
        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.
pub fn add(a: i32, b: i32) -> i32 {
    a + b
}

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: ["pub"]
        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-analyzer LSP for real-time analysis

Commit count: 0

cargo fmt