Skip to main content

Crate loctree

Crate loctree 

Source
Expand description

§loctree

AI-oriented Project Analyzer - Static analysis tool designed for AI agents and developers building production-ready software.

loctree helps overcome the common AI tendency to generate excessive artifacts that lead to re-export cascades, circular imports, and spaghetti dependencies.

§Features

  • Holographic Slice - Extract focused context (deps + consumers) for any file
  • Handler Trace - Follow Tauri commands through the entire pipeline
  • Dead Export Detection - Find unused exports and orphaned code
  • Circular Import Detection - Catch runtime bombs before they explode
  • Auto-Detect Stack - Automatically configure for Rust, TypeScript, Python, Tauri
  • HTML Reports - Interactive reports with Cytoscape.js dependency graphs

§Quick Start (Library Usage)

use loctree::{detect, snapshot, slicer};
use std::path::PathBuf;

// Detect project stack
let detected = detect::detect_stack(std::path::Path::new("."));
println!("Detected: {}", detected.description);

§Running Import Analysis

use loctree::{analyzer, args};
use std::path::PathBuf;

// Run the full import analyzer on a project
let mut parsed = args::ParsedArgs::default();
parsed.dead_exports = true;
parsed.circular = true;

let roots = vec![PathBuf::from(".")];
analyzer::run_import_analyzer(&roots, &parsed).unwrap();

§CLI Usage

For command-line usage, install with cargo install loctree and run:

loct                       # Auto-scan with stack detection
loct slice src/App.tsx     # Extract holographic context
loct trace get_user        # Trace Tauri handler
loct cycles                # Find circular imports
loct context               # Brand-defining pill (markdown by default)

See the README for full documentation.

§Public Library API

MCP servers, IDE extensions, and other library consumers should import from library-layer modules such as pack, atlas, analyzer, query, and snapshot.

cli::* modules are CLI-internal and may change without notice. Re-exports exist for backward compatibility, but new non-CLI code should not depend on them.

Re-exports§

pub use types::Mode;
pub use types::Options;
pub use types::OutputMode;
pub use types::ColorMode;
pub use types::FileAnalysis;
pub use detect::DetectedStack;
pub use detect::detect_stack;
pub use slicer::HolographicSlice;
pub use slicer::SliceConfig;
pub use snapshot::Snapshot;
pub use symbols::SymbolGraph;
pub use analyzer::run_import_analyzer;
pub use analyzer::ReportSection;
pub use analyzer::CommandGap;
pub use analyzer::RankedDup;
pub use refactor_plan::RefactorPlan;
pub use refactor_plan::Layer;
pub use refactor_plan::RiskLevel;
pub use pack::ContextOptions;
pub use pack::ContextPack;
pub use pack::compose_context_pack;
pub use cli::Command;
pub use cli::GlobalOptions;
pub use cli::ParsedCommand;

Modules§

aicx
Read-only consumer wrapper around the external aicx CLI.
analysis_reports
Library-facing report builders for health, findings, audit, and coverage. Library-facing analysis reports shared by MCP, CLI-adjacent callers, and tests.
analyzer
Import/export analyzer supporting TypeScript, JavaScript, Python, Rust, and CSS.
args
Command-line argument parsing.
atlas
Public Context Atlas API for non-CLI library consumers.
body
Bounded symbol body / source-range retrieval.
cli
New CLI module for the subcommand-based interface.
colors
Terminal color utilities for CLI output.
config
Configuration file support.
context_scope
detect
Auto-detection of project stacks.
diff
Snapshot comparison engine for temporal analysis.
focuser
Directory-level holographic focus.
fs_utils
Filesystem utilities.
git
Git operations for temporal awareness.
impact
Impact analysis module for understanding file dependencies.
jaq_query
jaq query execution for filtering snapshot data.
layoutmap
CSS Layout Analysis.
metrics
Canonical repository metrics derived once from snapshot graph authority. Canonical repository metrics derived from the snapshot graph.
pack
Public ContextPack composition API shared by CLI, MCP, and library users. Public composition API for ContextPack.
progress
Progress UI utilities (spinners, status messages).
query
Query API for fast lookups against the cached snapshot.
refactor_plan
Refactor plan generation for architectural reorganization.
semantic
Runtime semantic contracts and idiom catalogs. Layer 3: RuntimeSemanticAnalyzer, per-runtime semantic interpretation of the symbol model emitted by Layer 1/2 sensors.
similarity
String similarity using Levenshtein distance.
slicer
Holographic slice extraction.
snapshot
Incremental snapshot persistence.
suppressions
Suppression system for false positives.
symbols
Symbol graph schema — semantic-topology layer beside import_graph.
tree
Directory tree with LOC counts.
types
Common types used throughout the crate.
watch
Watch mode for live snapshot refresh during iterative development.
watch_lock
Single-instance lock guarding long-lived watch loops.

Structs§

PrismAxisScore
Compose a PrismReport for a multi-task framing comparison.
PrismOverlap
Compose a PrismReport for a multi-task framing comparison.
PrismReport
Compose a PrismReport for a multi-task framing comparison.
PrismTaskSummary
Compose a PrismReport for a multi-task framing comparison.

Functions§

run_prism
Compose a PrismReport for a multi-task framing comparison.