run_on_cli.rs: --output-dir now writes all modules as .js files
- 1,029 Louvain-detected modules written to source/ directory
- Auto-balances braces, parens, brackets on each module
- Auto-fixes try-without-catch patterns
- Writes witness.json and metrics.json
- Writes tree hierarchy to tree/ subdirectory
Claude Code results: 722/863 modules parse (83.6%)
Remaining 141 failures mostly from paren imbalance in string edge cases.
Co-Authored-By: claude-flow <ruv@ruv.net>
Folder structure emerges from the dependency graph — not hardcoded keywords.
tree.rs (362 lines):
- Agglomerative clustering on inter-module edge weights
- TF-IDF naming: most discriminative strings name each folder
- Recursive depth control (configurable max_depth, min_folder_size)
inferrer.rs: infer_folder_name() with TF-IDF scoring
types.rs: ModuleTree struct, hierarchical config options
run_on_cli.rs: --output-dir prints folder tree to disk
module-splitter.js: JS-side tree builder with same approach
Key principle: tightly-coupled code shares a folder,
MinCut boundaries become folder boundaries, names from context.
59 tests passing, zero warnings.
Co-Authored-By: claude-flow <ruv@ruv.net>
Bottleneck 1 - Parser: 18.3s → 4.5s (4x faster)
- Single-pass body scanner replaces 3 regex passes per declaration
- scan_body_single_pass() collects strings, props, idents in one traversal
Bottleneck 2 - Partitioning: skipped → 33s (now works on 27K nodes)
- Louvain community detection for graphs ≥5K nodes
- Detects 1,029 modules in Claude Code (was 1 or skipped)
- Falls back to exact MinCut for <5K nodes
Bottleneck 3 - Memory: 592MB → 568MB (incremental, more needed)
- Pre-allocated output buffers in beautifier
- Direct write via format_declaration_into() / indent_braces_into()
Bottleneck 4 - Name inference: 5.2% → 5.2% HIGH (training data loaded)
- 50 domain-specific patterns in data/claude-code-patterns.json
- TrainingCorpus with compile-time embedding via include_str!()
- Runtime corpus loading via TrainingCorpus::from_json()
51 tests passing, zero warnings.
Co-Authored-By: claude-flow <ruv@ruv.net>