Expand description
Β§Scribe - Advanced Code Analysis Library
Scribe is a comprehensive Rust library for code analysis, repository exploration, and intelligent file processing. It provides powerful tools for understanding codebases through heuristic scoring, graph analysis, and AI-powered insights.
Β§Features
- π Intelligent File Analysis: Multi-dimensional heuristic scoring system
- π Dependency Graph Analysis: PageRank centrality for code importance
- β‘ High-Performance Scanning: Parallel file system traversal with git integration
- π― Advanced Pattern Matching: Flexible glob and gitignore pattern support
- π§ Smart Code Selection: Context-aware code bundling and relevance scoring
- π οΈ Extensible Architecture: Plugin system for custom analyzers and scorers
Β§Quick Start
Add this to your Cargo.toml:
[dependencies]
scribe = "0.1.0"Β§Basic Usage
use scribe_analyzer::prelude::*;
use std::path::Path;
// Configure analysis
let config = Config::default();
let repo_path = Path::new(".");
// Quick analysis - get most important files
let important_files = scribe_analyzer::analyze_repository(repo_path, &config).await?;
println!("Top 10 most important files:");
for (file, score) in important_files.top_files(10) {
println!(" {}: {:.3}", file, score);
}Β§Feature-Specific Usage
// For minimal installations with selective features
use scribe_analyzer::core::{Config, FileInfo};
use scribe_analyzer::scanner::{Scanner, ScanOptions};
let scanner = Scanner::new();
let options = ScanOptions::default();
let files = scanner.scan(".", options).await?;
println!("Found {} files", files.len());Β§Feature Flags
Scribe uses feature flags to allow selective compilation:
default: Includescore,analysis,graph,scanner,patterns,selectioncore: Essential types, traits, and utilities (always recommended)analysis: Heuristic scoring and code analysis algorithmsgraph: PageRank centrality and dependency graph analysisscanner: High-performance file system scanning with git integrationpatterns: Flexible pattern matching (glob, gitignore)selection: Intelligent code selection and context extraction
Β§Feature Groups
minimal: Justcorefunctionalityfast: Core + scanning and patterns for quick file operationscomprehensive: All features (same as default)full: Alias for default
Β§Selective Installation Examples
# Minimal installation
scribe = { version = "0.1.0", default-features = false, features = ["core"] }
# Fast file operations only
scribe = { version = "0.1.0", default-features = false, features = ["fast"] }
# Analysis without graph features
scribe = { version = "0.1.0", default-features = false, features = ["core", "analysis", "scanner"] }Β§Architecture
Scribe is built with a modular architecture:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β scribe β
β βββββββββββββββ βββββββββββββββ βββββββββββββββββββββββββββ β
β β scribe-core β βscribe-scannerβ β scribe-patterns β β
β β (types, β β(file system β β (glob, gitignore, β β
β β traits, β β traversal, β β pattern matching) β β
β β utilities) β β git support) β β β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββββββββββββββ β
β βββββββββββββββ βββββββββββββββ βββββββββββββββββββββββββββ β
β βscribe-analysisβ βscribe-graph β β scribe-selection β β
β β (heuristic β β (PageRank β β (intelligent bundling, β β
β β scoring, β β centrality, β β context extraction, β β
β β code metrics)β β dependency β β relevance scoring) β β
β β β β analysis) β β β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββRe-exportsΒ§
pub use pipeline::analyze_and_select;pub use pipeline::select_from_analysis;pub use pipeline::AnalysisOutcome;pub use pipeline::SelectionOptions;pub use pipeline::SelectionOutcome;pub use report::format_bytes;pub use report::format_number;pub use report::format_timestamp;pub use report::generate_cxml_output;pub use report::generate_html_output;pub use report::generate_json_output;pub use report::generate_markdown_output;pub use report::generate_repomix_output;pub use report::generate_report;pub use report::generate_text_output;pub use report::generate_xml_output;pub use report::get_file_icon;pub use report::ReportFile;pub use report::ReportFormat;pub use report::SelectionMetrics;pub use scribe_core as core;pub use scribe_analysis as analysis;pub use scribe_graph as graph;pub use scribe_scanner as scanner;pub use scribe_patterns as patterns;pub use scribe_selection as selection;
ModulesΒ§
- meta
- Library metadata and build information
- pipeline
- prelude
- Prelude module for convenient imports
- presets
- Pre-configured pattern matchers for common use cases
- report
- utils
- Utility functions for common operations
StructsΒ§
- Analysis
Metadata - Metadata about the analysis process
- Centrality
Calculator - Main centrality calculator with heuristics integration
- Centrality
Results - Complete centrality calculation results with comprehensive metadata
- Code
Bundle - Code
Bundler - Code
Context - Code
Selector - Config
- Main configuration structure for Scribe
- Context
Extractor - Context
File - Dependency
Graph - Efficient dependency graph representation optimized for PageRank computation Uses integer-based internal representation for massive performance improvements
- Document
Analysis - Document analysis results for scoring
- File
Info - Comprehensive file metadata structure
- File
Scanner - High-level scanner facade providing convenient access to all scanning functionality
- Gitignore
Matcher - Gitignore pattern matcher with full syntax support
- Glob
Matcher - High-performance glob pattern matcher with compilation caching
- Graph
Analysis - Main entry point for PageRank centrality analysis
- Graph
Statistics - Graph statistics computed lazily and cached
- Heuristic
Scorer - Main heuristic scorer that coordinates all scoring components
- Heuristic
System - Main entry point for the heuristic scoring system
- Heuristic
Weights - Configurable weights for different scoring components
- Import
Graph - Dependency graph for centrality calculation
- Import
Graph Builder - Builder for constructing import graphs from scan results
- Language
Detector - High-performance language detector with multiple strategies
- Page
Rank Analysis - Main entry point for PageRank centrality analysis
- Page
Rank Results - PageRank computation results with comprehensive metadata
- Pattern
Builder - Pattern matching builder for fluent API construction
- Pattern
Matcher - Combined pattern matcher that integrates glob and gitignore patterns
- Pattern
Matcher Builder - Builder for creating pattern matchers with a fluent API
- Quick
Matcher - Quick pattern matching utility for simple use cases
- Quota
Manager - Manages budget quotas and density-greedy selection
- Repository
Analysis - High-level repository analysis results
- Scan
Options - Configuration options for scanning operations
- Scan
Result - Result of a scanning operation
- Scanner
- High-performance file system scanner with parallel processing
- Scanner
Stats - Statistics about the scanning process
- Score
Components - Individual components of the heuristic scoring system
- Selection
Engine - Main entry point for intelligent code selection
- Template
Detector - Advanced template detection engine
- TwoPass
Selector - Main two-pass selection engine
EnumsΒ§
- File
Type - File type classification for analysis purposes
- Language
- Programming language classification
- Scribe
Error - Comprehensive error type for all Scribe operations
ConstantsΒ§
- CORE_
VERSION - Current version of the Scribe library
- VERSION
- Current version of the main Scribe library
FunctionsΒ§
- analyze_
repository - Convenience function for quick repository analysis
- apply_
token_ budget_ selection - Apply the libraryβs tiered token budget selection to a set of files.
- scan_
repository - Convenience function for fast file scanning without deep analysis
Type AliasesΒ§
- Result
- Type alias for Results using ScribeError