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:
loctree # Scan and snapshot
loctree slice src/App.tsx # Extract AI context
loctree trace get_user # Trace Tauri handler
loctree -A --circular # Find circular imports
loctree --for-ai # AI-optimized JSON outputSee the README for full documentation.
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 analyzer::run_import_analyzer;pub use analyzer::ReportSection;pub use analyzer::CommandGap;pub use analyzer::RankedDup;pub use cli::Command;pub use cli::GlobalOptions;pub use cli::ParsedCommand;
Modules§
- analyzer
- Import/export analyzer supporting TypeScript, JavaScript, Python, Rust, and CSS.
- args
- Command-line argument parsing.
- cli
- New CLI module for the subcommand-based interface.
- config
- Configuration file support.
- detect
- Auto-detection of project stacks.
- diff
- Snapshot comparison engine for temporal analysis.
- fs_
utils - Filesystem utilities.
- git
- Git operations for temporal awareness.
- query
- Query API for fast lookups against the cached snapshot.
- similarity
- String similarity using Levenshtein distance.
- slicer
- Holographic slice extraction.
- snapshot
- Incremental snapshot persistence.
- tree
- Directory tree with LOC counts.
- types
- Common types used throughout the crate.