tokmd-model
Deterministic aggregation and receipt modeling for tokmd.
Overview
This is a Tier 1 crate containing the core business logic for transforming raw tokei scan results into tokmd receipts. It handles aggregation, sorting, path normalization, and filtering.
Installation
[]
= "1.3"
Usage
use ;
use ChildrenMode;
// Create language summary
let report = create_lang_report;
// Create module breakdown
let module_report = create_module_report;
// Collect file-level rows
let rows = collect_file_rows;
Key Functions
Report Creation
create_lang_report()- Aggregate by languagecreate_module_report()- Aggregate by directory structurecreate_export_data()- File-level inventory with filteringcollect_file_rows()- Raw file row collection
Path Utilities
normalize_path()- Cross-platform path normalizationmodule_key()- Compute module key from path
Key Patterns
Token Estimation
const CHARS_PER_TOKEN: usize = 4;
Simple heuristic: tokens = bytes / 4
Deterministic Sorting
All outputs sorted by:
- Code lines (descending)
- Name (ascending)
Children Mode
Collapse- Merge embedded languages into parentSeparate- Show as distinct rows
Path Normalization
- Forward slashes on all platforms
- Strip leading
./and/ - Optional prefix stripping
License
MIT OR Apache-2.0