6 releases (breaking)
| 0.5.1 | Dec 1, 2025 |
|---|---|
| 0.5.0 | Sep 19, 2025 |
| 0.4.0 | Sep 17, 2025 |
| 0.3.0 | Sep 16, 2025 |
| 0.1.0 | Sep 13, 2025 |
#2332 in Parser implementations
223 downloads per month
Used in 10 crates
160KB
3.5K
SLoC
Scribe Core
Core types, utilities, and foundational components for the Scribe code analysis library.
Overview
scribe-core provides the fundamental data structures and traits used across all other Scribe crates. It includes comprehensive error handling, file analysis types, scoring components, configuration management, and extensibility traits.
Features
- Comprehensive Error Handling: Rich error types with proper context and error chaining
- File Analysis: File metadata, language detection, and classification systems
- Scoring System: Heuristic scoring components and configurable weights
- Configuration: Flexible configuration with validation and serialization support
- Extensibility: Traits for custom analyzers, scorers, and formatters
- Utilities: Common functions for path manipulation, string processing, and more
Usage
Add this to your Cargo.toml:
[dependencies]
scribe-core = "0.1.0"
Basic usage:
use scribe_core::{Config, Language, ScoreComponents, HeuristicWeights, Result};
// Create a default configuration
let config = Config::default();
// Detect programming language from file extension
let language = Language::from_extension("rs");
assert_eq!(language, Language::Rust);
// Work with scoring components
let mut scores = ScoreComponents::zero();
scores.doc_score = 0.8;
scores.import_score = 0.6;
let weights = HeuristicWeights::default();
scores.compute_final_score(&weights);
println!("Final score: {}", scores.final_score);
Key Types
Error Handling
ScribeError: Comprehensive error type for all Scribe operationsResult<T>: Type alias forstd::result::Result<T, ScribeError>
File Analysis
FileInfo: Complete file metadata and analysis resultsLanguage: Programming language detection and classificationFileType: File type classification (source, test, documentation, etc.)RenderDecision: Include/exclude decisions for files
Scoring System
ScoreComponents: Individual heuristic score componentsHeuristicWeights: Configurable weights for scoringRepositoryInfo: Repository-level statistics and metadata
Configuration
Config: Main configuration structureFeatureFlags: Enable/disable experimental features- Various sub-configurations for filtering, analysis, performance, etc.
Traits for Extensibility
FileAnalyzer: Custom file analysis implementationsHeuristicScorer: Custom scoring algorithmsOutputFormatter: Custom output formatsCacheStorage: Custom caching implementations
Architecture
The crate is organized into several modules:
error: Comprehensive error types and handlingfile: File metadata and analysis typestypes: Core data structures and scoring componentsconfig: Configuration managementtraits: Extensibility traits and abstractionsutils: Common utility functions
Memory Safety and Performance
Scribe Core is built with Rust's ownership principles in mind:
- Zero-cost abstractions: Efficient implementations without runtime overhead
- Memory safety: Compile-time guarantees prevent common bugs
- Thread safety: Safe concurrent operations where appropriate
- Resource efficiency: Minimal memory allocations in hot paths
Testing
Run the test suite:
cargo test
Run benchmarks:
cargo bench
Contributing
This crate serves as the foundation for the entire Scribe ecosystem. When adding new functionality:
- Ensure comprehensive error handling using
ScribeError - Add proper documentation and examples
- Include unit tests for all new functionality
- Consider thread safety and performance implications
- Follow existing naming conventions and patterns
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Dependencies
~24MB
~255K SLoC