{"id":31776868,"url":"https://github.com/cool-japan/splitrs","last_synced_at":"2026-07-06T06:01:20.716Z","repository":{"id":317681716,"uuid":"1068432182","full_name":"cool-japan/splitrs","owner":"cool-japan","description":"SplitRS uses AST-based analysis to automatically refactor large Rust source files (\u003e1000 lines) into well-organized, compilable modules. ","archived":false,"fork":false,"pushed_at":"2026-07-06T04:40:27.000Z","size":363,"stargazers_count":18,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-07-06T06:00:18.664Z","etag":null,"topics":["cli","refactoring","refactoring-tools","rust","rust-lang"],"latest_commit_sha":null,"homepage":"https://github.com/cool-japan/splitrs","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cool-japan.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"cool-japan"}},"created_at":"2025-10-02T11:28:27.000Z","updated_at":"2026-07-06T04:31:56.000Z","dependencies_parsed_at":"2025-10-02T12:40:22.821Z","dependency_job_id":null,"html_url":"https://github.com/cool-japan/splitrs","commit_stats":null,"previous_names":["cool-japan/splitrs"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/cool-japan/splitrs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cool-japan%2Fsplitrs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cool-japan%2Fsplitrs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cool-japan%2Fsplitrs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cool-japan%2Fsplitrs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cool-japan","download_url":"https://codeload.github.com/cool-japan/splitrs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cool-japan%2Fsplitrs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35179683,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-06T02:00:07.184Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","refactoring","refactoring-tools","rust","rust-lang"],"created_at":"2025-10-10T05:58:56.398Z","updated_at":"2026-07-06T06:01:20.698Z","avatar_url":"https://github.com/cool-japan.png","language":"Rust","funding_links":["https://github.com/sponsors/cool-japan"],"categories":[],"sub_categories":[],"readme":"# SplitRS 🦀✂️\n\n[![Crates.io](https://img.shields.io/crates/v/splitrs.svg)](https://crates.io/crates/splitrs)\n[![Documentation](https://docs.rs/splitrs/badge.svg)](https://docs.rs/splitrs)\n[![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)\n\n**A production-ready Rust refactoring tool that intelligently splits large files into maintainable modules**\n\nSplitRS uses AST-based analysis to automatically refactor large Rust source files (\u003e1000 lines) into well-organized, compilable modules. It handles complex generics, async functions, Arc/Mutex patterns, and automatically generates correct imports and visibility modifiers.\n\n## ✨ Features\n\n### Core Refactoring\n- 🎯 **AST-Based Refactoring**: Uses `syn` for accurate Rust parsing\n- 🧠 **Intelligent Method Clustering**: Groups related methods using call graph analysis\n- 📦 **Auto-Generated Imports**: Context-aware `use` statements with proper paths\n- 🔒 **Visibility Inference**: Automatically applies `pub(super)`, `pub(crate)`, or `pub`\n- 🚀 **Complex Type Support**: Handles generics, async, Arc/Mutex, nested types\n- ⚡ **Fast**: Processes 1600+ line files in \u003c1 second\n- ✅ **Production-Tested**: Successfully refactored 10,000+ lines of real code\n\n### Advanced Features (v0.2.0+)\n- ⚙️ **Configuration Files**: `.splitrs.toml` support for project-specific settings\n- 🎭 **Trait Implementation Support**: Automatic separation of trait impls into dedicated modules\n- 🔗 **Type Alias Resolution**: Intelligent handling of type aliases in import generation\n- 🔍 **Circular Dependency Detection**: DFS-based cycle detection with Graphviz export\n- 👀 **Enhanced Preview Mode**: Beautiful formatted preview with statistics before refactoring\n- 💬 **Interactive Mode**: Confirmation prompts before file generation\n- 🔄 **Automatic Rollback Support**: Backup creation for safe refactoring\n- 📝 **Smart Documentation**: Auto-generated module docs with trait listings\n\n### v0.3.x Features\n- 🔬 **Macro Analyzer**: Detects `macro_rules!` definitions and `#[derive]` usage with placement suggestions\n- 📊 **Metrics Dashboard**: Cyclomatic complexity analysis with HTML/JSON/text reports (`--metrics`)\n- 🗂️ **Field Access Tracker**: Detects field access patterns to prevent broken visibility during splits\n- 🔗 **Trait Method Tracker**: Ensures trait method implementations stay coherent after splitting\n- 🖥️ **LSP Integration** (`splitrs-lsp`): Language server for real-time refactoring guidance\n  - Diagnostics for oversized files and impl blocks\n  - Code action `Refactor with splitrs` (applies a `WorkspaceEdit`)\n  - Hover showing file metrics (LoC, methods, complexity)\n  - `.splitrs.toml` config watch with hot reload\n\n### v0.3.3 Features\n- 🗺️ **Domain-Mapping for `--target-modules`**: seeded assignment pulls unlisted items into the module with the strongest reference affinity, unknown-name validation with near-miss suggestions, dry-run attribution, and an extended schema (`parent`, `pull_dependencies`, `doc`, `max_lines`) plus infix/multi-segment glob patterns\n- 🌲 **Nested Inline-Mod Descent** (`--split-nested-mods`, `--max-mod-depth`): recursively splits over-budget inline `mod x { ... }` blocks through the same analyze → group → generate pipeline\n- 🎭 **Facade Style Control** (`--facade \u003cglob|named|none\u003e`): choose glob re-exports, explicit named re-exports, or declarations-only for generated `mod.rs` facades\n- ✂️ **Verbatim Method Extraction**: `SourceMap` now covers individual extracted impl methods, preserving original formatting byte-for-byte\n- 🧪 **New Integration Test Suites**: `acceptance_e2e_tests`, `domain_mapping_tests`, `nested_mod_tests`\n\n## 📦 Installation\n\n```bash\ncargo install splitrs\n```\n\nOr build from source:\n\n```bash\ngit clone https://github.com/cool-japan/splitrs\ncd splitrs\ncargo build --release\n```\n\n## 🚀 Quick Start\n\n### Basic Usage\n\n```bash\n# Split a large file into modules\nsplitrs --input src/large_file.rs --output src/large_file/\n\n# Preview what will be created (no files written)\nsplitrs --input src/large_file.rs --output src/large_file/ --dry-run\n\n# Interactive mode with confirmation\nsplitrs --input src/large_file.rs --output src/large_file/ --interactive\n```\n\n### Recommended Usage (with impl block splitting)\n\n```bash\nsplitrs \\\n  --input src/large_file.rs \\\n  --output src/large_file/ \\\n  --split-impl-blocks \\\n  --max-impl-lines 200\n```\n\n### Using Configuration Files\n\nCreate a `.splitrs.toml` in your project root:\n\n```toml\n[splitrs]\nmax_lines = 1000\nmax_impl_lines = 500\nsplit_impl_blocks = true\n\n[naming]\ntype_module_suffix = \"_type\"\nimpl_module_suffix = \"_impl\"\n\n[output]\npreserve_comments = true\nformat_output = true\n```\n\nThen simply run:\n\n```bash\nsplitrs --input src/large_file.rs --output src/large_file/\n```\n\n### LSP Integration (Editor Support)\n\n`splitrs-lsp` is included when you `cargo install splitrs` (LSP is a default feature). It speaks the Language Server Protocol over stdio and provides:\n\n- 🔴 **Diagnostics** when files exceed your `.splitrs.toml` `max_lines` limit (`source: \"splitrs\"`, severity: Information)\n- ⚡ **Code action** `Refactor with splitrs` to split large files directly from your editor\n- ℹ️  **Hover** at the top of any Rust file showing metrics (lines of code, method count, avg complexity)\n\n---\n\n#### Zero-config quickstart\n\n**Neovim (via `vim.lsp.start`):**\n```lua\nrequire('lspconfig').splitrs_lsp.setup{}\n-- Or manually:\nvim.lsp.start({ name = 'splitrs-lsp', cmd = { 'splitrs-lsp' } })\n```\n\n**Helix (`languages.toml`):**\n```toml\n[[language]]\nname = \"rust\"\nlanguage-servers = [\"rust-analyzer\", \"splitrs-lsp\"]\n\n[language-server.splitrs-lsp]\ncommand = \"splitrs-lsp\"\n```\n\n---\n\n#### Rich editor plugins (in `editors/`)\n\nFor a full-featured experience (config-watch, `:SplitrsRefactor` command, settings UI), use the plugins in the `editors/` directory:\n\n**Neovim — `editors/nvim/`**\n\nFull Lua plugin with `setup{}` API, `.splitrs.toml` watcher, and `:SplitrsRefactor` command:\n\n```lua\n-- With lazy.nvim (from a local checkout):\n{ dir = '/path/to/splitrs/editors/nvim', config = true }\n\n-- Manual setup:\nvim.opt.rtp:prepend('/path/to/splitrs/editors/nvim')\nrequire('splitrs').setup()\n\n-- Custom options:\nrequire('splitrs').setup({\n  cmd = { '/usr/local/bin/splitrs-lsp' },  -- custom binary path\n  enabled = true,\n})\n```\n\n**VSCode — `editors/vscode/`**\n\nTypeScript extension activating on `onLanguage:rust`. Sideload:\n\n```bash\ncd editors/vscode\nnpm install\nnpx vsce package          # creates splitrs-*.vsix\ncode --install-extension splitrs-*.vsix\n```\n\nConfigure via `settings.json`:\n```json\n{\n  \"splitrs.serverPath\": \"splitrs-lsp\",\n  \"splitrs.enable\": true,\n  \"splitrs.trace.server\": \"off\"\n}\n```\n\nUse the Command Palette (`Ctrl+Shift+P`) → `splitrs: Refactor current file`.\n\n**Emacs — `editors/emacs/`**\n\nSupports both built-in `eglot` (Emacs 29.1+) and `lsp-mode`:\n\n```elisp\n;; With use-package:\n(use-package splitrs\n  :load-path \"path/to/splitrs/editors/emacs\"\n  :hook ((rust-mode . splitrs-mode)\n         (rust-ts-mode . splitrs-mode)))\n\n;; Manual:\n(add-to-list 'load-path \"path/to/splitrs/editors/emacs\")\n(require 'splitrs)\n(splitrs-setup)  ; registers with eglot and lsp-mode\n\n;; Refactor from a Rust buffer:\n;; M-x splitrs-refactor-current-file\n```\n\nsplitrs-lsp runs **alongside** rust-analyzer — it uses `:add-on? t` in lsp-mode and appends to `eglot-server-programs` so neither server displaces the other.\n\n**IntelliJ IDEA — `editors/intellij/`**\n\nKotlin/Gradle plugin using IntelliJ 2024.2+'s built-in LSP API. Build:\n\n```bash\ncd editors/intellij\ngradle wrapper --gradle-version 8.10   # one-time setup\n./gradlew buildPlugin\n# Install: Settings → Plugins → Install Plugin from Disk → build/distributions/*.zip\n```\n\nRequires: IntelliJ IDEA 2024.2 or later, JDK 21, `splitrs-lsp` on `$PATH`.\n\n---\n\n#### Configuration (all editors)\n\nCreate `.splitrs.toml` in your project root to customise the server:\n\n```toml\n[splitrs]\nmax_lines = 1000       # warn when a file exceeds this many lines\nmax_impl_lines = 300   # warn on oversized impl blocks (if split_impl_blocks = true)\nsplit_impl_blocks = true\n```\n\nThe server hot-reloads `.splitrs.toml` whenever the file changes.\n\nTo use LSP-only (without the full splitrs CLI):\n```bash\ncargo install splitrs --no-default-features --features lsp\n```\n\n## 📖 Examples\n\n### Example 1: Trait Implementations\n\nSplitRS automatically detects and separates trait implementations:\n\n**Input**: `user.rs`\n```rust\npub struct User {\n    pub name: String,\n    pub age: u32,\n}\n\nimpl User {\n    pub fn new(name: String, age: u32) -\u003e Self { /* ... */ }\n}\n\nimpl Debug for User { /* ... */ }\nimpl Display for User { /* ... */ }\nimpl Clone for User { /* ... */ }\nimpl Default for User { /* ... */ }\n```\n\n**Command**:\n```bash\nsplitrs --input user.rs --output user/ --dry-run\n```\n\n**Output**:\n```\nuser/\n├── types.rs         # struct User definition + inherent impl\n├── user_traits.rs   # All trait implementations (Debug, Display, Clone, Default)\n└── mod.rs          # Module organization\n```\n\n**Generated `user_traits.rs`**:\n```rust\n//! # User - Trait Implementations\n//!\n//! This module contains trait implementations for `User`.\n//!\n//! ## Implemented Traits\n//!\n//! - `Debug`\n//! - `Display`\n//! - `Clone`\n//! - `Default`\n//!\n//! 🤖 Generated with [SplitRS](https://github.com/cool-japan/splitrs)\n\nuse super::types::User;\n\nimpl Debug for User { /* ... */ }\nimpl Display for User { /* ... */ }\nimpl Clone for User { /* ... */ }\nimpl Default for User { /* ... */ }\n```\n\n### Example 2: Basic Refactoring\n\n**Input**: `connection_pool.rs` (1660 lines)\n\n```rust\npub struct ConnectionPool\u003cT\u003e {\n    connections: Arc\u003cMutex\u003cVec\u003cT\u003e\u003e\u003e,\n    config: PoolConfig,\n    // ... 50 fields\n}\n\nimpl\u003cT: Clone + Send + Sync\u003e ConnectionPool\u003cT\u003e {\n    pub fn new(config: PoolConfig) -\u003e Self { ... }\n    pub async fn acquire(\u0026self) -\u003e Result\u003cT\u003e { ... }\n    pub async fn release(\u0026self, conn: T) -\u003e Result\u003c()\u003e { ... }\n    // ... 80 methods\n}\n```\n\n**Command**:\n```bash\nsplitrs --input connection_pool.rs --output connection_pool/ --split-impl-blocks\n```\n\n**Output**: 25 well-organized modules\n\n```\nconnection_pool/\n├── mod.rs                          # Module organization \u0026 re-exports\n├── connectionpool_type.rs          # Type definition with proper visibility\n├── connectionpool_new_group.rs     # Constructor methods\n├── connectionpool_acquire_group.rs # Connection acquisition\n├── connectionpool_release_group.rs # Connection release\n└── ... (20 more focused modules)\n```\n\n### Example 3: Preview Mode\n\nGet detailed information before refactoring:\n\n```bash\nsplitrs --input examples/trait_impl_example.rs --output /tmp/preview -n\n```\n\n**Output**:\n```\n============================================================\nDRY RUN - Preview Mode\n============================================================\n\n📊 Statistics:\n  Original file: 82 lines\n  Total modules to create: 4\n\n📁 Module Structure:\n  📄 product_traits.rs (2 trait impls)\n  📄 user_traits.rs (4 trait impls)\n  📄 types.rs (2 types)\n  📄 functions.rs (1 items)\n\n💾 Files that would be created:\n  📁 /tmp/preview/\n    📄 product_traits.rs\n    📄 user_traits.rs\n    📄 types.rs\n    📄 functions.rs\n    📄 mod.rs\n\n============================================================\n✓ Preview complete - no files were created\n============================================================\n```\n\n### Example 4: Complex Types\n\nSplitRS correctly handles complex Rust patterns:\n\n```rust\n// Input\npub struct Cache\u003cK, V\u003e\nwhere\n    K: Hash + Eq + Clone,\n    V: Clone + Send + Sync + 'static,\n{\n    data: Arc\u003cRwLock\u003cHashMap\u003cK, V\u003e\u003e\u003e,\n    eviction: EvictionPolicy,\n}\n\n// Output (auto-generated)\n// cache_type.rs\nuse std::collections::HashMap;\nuse std::sync::{Arc, RwLock};\n\npub struct Cache\u003cK, V\u003e\nwhere\n    K: Hash + Eq + Clone,\n    V: Clone + Send + Sync + 'static,\n{\n    pub(super) data: Arc\u003cRwLock\u003cHashMap\u003cK, V\u003e\u003e\u003e,\n    pub(super) eviction: EvictionPolicy,\n}\n\n// cache_insert_group.rs\nuse super::cache_type::Cache;\nuse std::collections::HashMap;\n\nimpl\u003cK, V\u003e Cache\u003cK, V\u003e\nwhere\n    K: Hash + Eq + Clone,\n    V: Clone + Send + Sync + 'static,\n{\n    pub async fn insert(\u0026mut self, key: K, value: V) -\u003e Result\u003c()\u003e {\n        // ... implementation\n    }\n}\n```\n\n## 🎛️ Command-Line Options\n\n| Option | Short | Description | Default |\n|--------|-------|-------------|---------|\n| `--input \u003cFILE\u003e` | `-i` | Input Rust source file (required) | - |\n| `--output \u003cDIR\u003e` | `-o` | Output directory for modules (required) | - |\n| `--max-lines \u003cN\u003e` | `-m` | Maximum lines per module | 1000 |\n| `--split-impl-blocks` | | Split large impl blocks into method groups | false |\n| `--max-impl-lines \u003cN\u003e` | | Maximum lines per impl block before splitting | 500 |\n| `--dry-run` | `-n` | Preview without creating files | false |\n| `--interactive` | `-I` | Prompt for confirmation before creating files | false |\n| `--config \u003cFILE\u003e` | `-c` | Path to configuration file | `.splitrs.toml` |\n\n### Configuration File Options\n\nWhen using a `.splitrs.toml` file, you can configure:\n\n**`[splitrs]` section:**\n- `max_lines` - Maximum lines per module\n- `max_impl_lines` - Maximum lines per impl block\n- `split_impl_blocks` - Enable impl block splitting\n\n**`[naming]` section:**\n- `type_module_suffix` - Suffix for type modules (default: `\"_type\"`)\n- `impl_module_suffix` - Suffix for impl modules (default: `\"_impl\"`)\n- `use_snake_case` - Use snake_case for module names (default: `true`)\n\n**`[output]` section:**\n- `module_doc_template` - Template for module documentation\n- `preserve_comments` - Preserve original comments (default: `true`)\n- `format_output` - Format with prettyplease (default: `true`)\n\nCommand-line arguments always override configuration file settings.\n\n## 🔬 SMT-verified refactoring (experimental — `--features smt`)\n\nSplitRS can *prove* certain refactorings preserve semantics before applying\nthem, using [OxiZ](https://github.com/cool-japan/oxiz) — a Pure-Rust SMT solver\n— as the verification backend. This is **off by default**; build it in with:\n\n```bash\ncargo build --features smt\ncargo run --features smt -- \u003cargs\u003e\n```\n\nThree capabilities are exposed:\n\n**`--verify-equiv --left FILE::FN --right FILE::FN`** — prove two pure\nfixed-width-integer functions compute the same result for *all* inputs, or get a\nconcrete counterexample:\n\n```bash\n# Proves `a` and `b` are equivalent (QF_BV, all inputs)\nsplitrs --features smt --verify-equiv --left calc.rs::a --right calc.rs::b\n```\n\n**`--extract-pure`** — an SMT-verified pre-pass that runs *before* the split. It\nscans every over-budget free function for a pure-integer sub-run, factors it\ninto a helper, and **commits the rewrite only when the solver proves it\nequivalent** to the original. Committed helpers are ordinary functions that then\nflow through the normal split/write pipeline. Non-equivalent or out-of-fragment\ncandidates are skipped (with a reason) and the original is left untouched.\n\n**`--verify`** — emit an honest *Semantic verification report* that separates\nwhat was **proven** from what is merely **assumed**:\n\n- Each `--extract-pure` body rewrite that committed → *SMT-Verified equivalent\n  (QF_BV, all inputs)*.\n- The default whole-item module moves → *structural identity*: a byte-identical\n  relocation. SplitRS does **not** claim to SMT-prove move safety;\n  name-resolution and visibility correctness is the Rust compiler's job — verify\n  with `cargo check`.\n\n```bash\nsplitrs --features smt -i big.rs -o out/ --extract-pure --verify\n```\n\n**Soundness boundary.** The proven fragment is *pure, fixed-width integers only*:\n`+ - * \u0026 | ^ \u003c\u003c \u003e\u003e`, comparisons, `if`/`else`, `let`, and integer casts.\nAnything outside it — division/remainder, function calls, references, loops,\nfloats — is reported as **Unsupported** and never committed (the gate refuses to\nrubber-stamp it). Whole-item relocations remain *structural identity*, not\nSMT-proven.\n\n## 🏗️ How It Works\n\nSplitRS uses a multi-stage analysis pipeline:\n\n1. **AST Parsing**: Parse input file with `syn`\n2. **Scope Analysis**: Determine organization strategy and visibility\n3. **Method Clustering**: Build call graph and cluster related methods\n4. **Type Extraction**: Extract types from fields for import generation\n5. **Module Generation**: Generate well-organized modules with correct imports\n6. **Code Formatting**: Format output with `prettyplease`\n\n### Organization Strategies\n\n**Inline** - Keep impl blocks with type definition:\n```\ntypename_module.rs\n  ├── struct TypeName { ... }\n  └── impl TypeName { ... }\n```\n\n**Submodule** - Split type and impl blocks (recommended for large files):\n```\ntypename_type.rs       # Type definition\ntypename_new_group.rs  # Constructor methods\ntypename_getters.rs    # Getter methods\nmod.rs                 # Module organization\n```\n\n**Wrapper** - Wrap in parent module:\n```\ntypename/\n  ├── type.rs\n  ├── methods.rs\n  └── mod.rs\n```\n\n## 📊 Performance\n\nTested on real-world codebases:\n\n| File Size | Lines | Time | Modules Generated |\n|-----------|-------|------|-------------------|\n| Small | 500-1000 | \u003c100ms | 3-5 |\n| Medium | 1000-1500 | \u003c500ms | 5-12 |\n| Large | 1500-2000 | \u003c1s | 10-25 |\n| Very Large | 2000+ | \u003c2s | 25-40 |\n\n## 🧪 Testing\n\nSplitRS includes **450 comprehensive tests** covering all analysis components:\n\n```bash\n# Run all tests (recommended)\ncargo nextest run --all-features\n\n# Or with the built-in test runner\ncargo test --all-features\n\n# Test on example files\ncargo run -- --input examples/large_struct.rs --output /tmp/test_output\n```\n\n## 📚 Documentation\n\n### API Documentation (docs.rs)\n\nFull API documentation is available at [docs.rs/splitrs](https://docs.rs/splitrs).\n\n**Generate documentation locally:**\n\n```bash\n# Generate and open documentation\ncargo doc --no-deps --open\n\n# Generate documentation for all features\ncargo doc --all-features --no-deps\n```\n\n### Module Structure\n\nThe codebase is organized into these main modules:\n\n- **`main.rs`** - CLI interface, file analysis, and module generation\n- **`config.rs`** - Configuration file parsing and management (`.splitrs.toml`)\n- **`method_analyzer.rs`** - Method dependency analysis and grouping\n- **`import_analyzer.rs`** - Type usage tracking and import generation\n- **`scope_analyzer.rs`** - Module scope analysis and visibility inference\n- **`dependency_analyzer.rs`** - Circular dependency detection and graph visualization\n\n### Key Types and Traits\n\n**Core Types:**\n- `FileAnalyzer` - Main analyzer for processing Rust files\n- `TypeInfo` - Information about a Rust type and its implementations\n- `Module` - Represents a generated module\n- `Config` - Configuration loaded from `.splitrs.toml`\n\n**Analysis Types:**\n- `ImplBlockAnalyzer` - Analyzes impl blocks for splitting\n- `MethodGroup` - Groups related methods together\n- `ImportAnalyzer` - Tracks type usage and generates imports\n- `DependencyGraph` - Detects circular dependencies\n\n## 📚 Use Cases\n\n### When to Use SplitRS\n\n✅ **Perfect for**:\n- Files \u003e1000 lines with large impl blocks\n- Monolithic modules that need organization\n- Legacy code refactoring\n- Improving code maintainability\n\n⚠️ **Consider Carefully**:\n- Files with circular dependencies (will generate modules but may need manual fixes)\n- Files with heavy macro usage (basic support, may need manual review)\n\n❌ **Not Recommended**:\n- Files \u003c500 lines (probably already well-organized)\n- Files with complex conditional compilation (`#[cfg]`)\n\n## 🔧 Integration\n\n### CI/CD Pipeline\n\n```yaml\n# .github/workflows/refactor.yml\nname: Auto-refactor\non:\n  workflow_dispatch:\n    inputs:\n      file:\n        description: 'File to refactor'\n        required: true\n\njobs:\n  refactor:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v3\n      - uses: actions-rs/toolchain@v1\n        with:\n          toolchain: stable\n      - run: cargo install splitrs\n      - run: |\n          splitrs --input ${{ github.event.inputs.file }} \\\n                  --output $(dirname ${{ github.event.inputs.file }})/refactored \\\n                  --split-impl-blocks\n      - uses: peter-evans/create-pull-request@v5\n        with:\n          title: \"Refactor: Split ${{ github.event.inputs.file }}\"\n```\n\n## 🤝 Contributing\n\nContributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.\n\n### Development Setup\n\n```bash\ngit clone https://github.com/cool-japan/splitrs\ncd splitrs\ncargo build\ncargo test\n```\n\n### Implemented Features (v0.3.3 — Latest Release)\n\n**v0.3.3 Highlights (2026-07-06):**\n- ✅ Domain-mapping for `--target-modules` (seeded assignment, unknown-name validation, dry-run attribution, extended schema: `parent`/`pull_dependencies`/`doc`/`max_lines`, infix/multi-segment glob patterns, `validate_target_modules()`)\n- ✅ Nested inline-mod descent (`--split-nested-mods`, `--max-mod-depth`): recursively splits over-budget inline `mod x { ... }` blocks\n- ✅ `--facade \u003cglob|named|none\u003e` flag / `[output] facade` config option for controlling generated `mod.rs` re-export style\n- ✅ Verbatim source slicing (`src/source_map.rs`) extended to cover individual extracted impl methods\n- ✅ New integration test suites: `acceptance_e2e_tests`, `domain_mapping_tests`, `nested_mod_tests`\n- ✅ `run_workspace_mode` extracted into its own module, `src/workspace_mode.rs`\n- ✅ Dependency bumps: `syn` gained `visit-mut` feature, `proc-macro2` added (`span-locations`), tokio 1.52.1→1.52.3, dashmap 6.1.0→6.2.1\n- ✅ Test suite: 565 tests passing with `--all-features` (494 with default features), was 450 in v0.3.2\n\n**v0.3.2 Highlights (2026-06-09):**\n- ✅ SMT-verified function extraction (`--features smt --extract-pure`): extracts pure integer sub-blocks from over-budget free functions, committing only when OxiZ proves semantic equivalence\n- ✅ SMT equivalence oracle (`splitrs smt-verify-equiv`): standalone equivalence checker between two Rust functions using QF_BV theory\n- ✅ Array-splitting mode (`--split-arrays`): splits oversized `static`/`const` array literals across chunk files with `const fn` compile-time reconstruction\n- ✅ Test-module splitter (`--split-test-modules`): splits multiple `#[cfg(test)]` blocks into per-module `tests_NAME.rs` files\n- ✅ Editor integrations shipped in `editors/`: Emacs, IntelliJ, Neovim, VSCode\n- ✅ `module_generator` refactored into `src/module_generator/` (3 modules, all under 2000 lines)\n- ✅ Test suite: 450 tests passing (was 269 in v0.3.1)\n\n**v0.3.1 Highlights:**\n- ✅ LSP Integration (`splitrs-lsp` binary, tower-lsp, diagnostics, code actions, hover, config watch)\n- ✅ Batched trait implementations into shared modules to reduce file clutter\n- ✅ Accurate line count estimation via `prettyplease` formatting\n- ✅ Conditional `lib.rs` preservation (writes `mod.rs` instead of overwriting the crate root)\n- ✅ Deduplicated `std::collections` import handling across split modules\n\n**v0.3.0 Highlights:**\n- ✅ Macro Analyzer (`macro_rules!` detection, `#[derive]` tracking, placement suggestions)\n- ✅ Metrics Dashboard (cyclomatic complexity, HTML/JSON/text reports)\n- ✅ Field access tracking for smarter module splitting\n- ✅ Trait method tracking for coherent trait splitting\n- ✅ No-unwrap policy compliance (production code)\n- ✅ Refactored main.rs into file_analyzer.rs + module_generator.rs\n- ✅ Dependencies upgraded (toml 1.0, rayon 1.11)\n\n**v0.2.x Features:**\n- ✅ Configuration file support (`.splitrs.toml`)\n- ✅ Trait implementation separation \u0026 trait bound tracking\n- ✅ Type alias resolution \u0026 circular dependency detection\n- ✅ Incremental refactoring with merge strategies\n- ✅ Custom naming strategies (snake_case, domain-specific, kebab-case)\n- ✅ Workspace-level refactoring with parallel processing (rayon)\n- ✅ Enhanced error recovery, rollback support\n- ✅ CI/CD templates (GitHub Actions, GitLab CI)\n- ✅ Private helper dependency tracking \u0026 glob import analysis\n- ✅ Comprehensive benchmarking suite (Criterion)\n\n### Roadmap to v1.0\n\n**Current status:** 95% production-ready\n\n**Next features (v0.4.0+):**\n- Macro expansion support (full `cargo expand` integration)\n- Extended SMT fragment: division, loops, references\n\n**Future enhancements (v0.5.0+):**\n- Cross-language support exploration\n- AI-assisted refactoring\n\n## 📄 License\n\nLicensed under the Apache License, Version 2.0 ([LICENSE](LICENSE) or http://www.apache.org/licenses/LICENSE-2.0).\n\n## 🙏 Acknowledgments\n\n- Built with [syn](https://github.com/dtolnay/syn) for Rust parsing\n- Formatted with [prettyplease](https://github.com/dtolnay/prettyplease)\n- Developed during the OxiRS refactoring project (32,398 lines refactored)\n\n## 📞 Resources \u0026 Support\n\n- 📖 **API Documentation**: [docs.rs/splitrs](https://docs.rs/splitrs)\n- 📦 **Crate**: [crates.io/crates/splitrs](https://crates.io/crates/splitrs)\n- 💻 **Source Code**: [github.com/cool-japan/splitrs](https://github.com/cool-japan/splitrs)\n- 🐛 **Issue Tracker**: [github.com/cool-japan/splitrs/issues](https://github.com/cool-japan/splitrs/issues)\n- 💬 **Discussions**: [github.com/cool-japan/splitrs/discussions](https://github.com/cool-japan/splitrs/discussions)\n\n### Getting Help\n\n1. **Check the docs**: Read the [API documentation](https://docs.rs/splitrs) and examples\n2. **Search issues**: Check if your question is already answered in [issues](https://github.com/cool-japan/splitrs/issues)\n3. **Ask questions**: Start a [discussion](https://github.com/cool-japan/splitrs/discussions)\n4. **Report bugs**: Open an [issue](https://github.com/cool-japan/splitrs/issues/new) with a reproducible example\n\n---\n\n**Made with ❤️ by the OxiRS team** | **Star ⭐ us on GitHub!**\n\n## Sponsorship\n\nSplitRS is developed and maintained by **COOLJAPAN OU (Team Kitasan)**.\n\nIf you find SplitRS useful, please consider sponsoring the project to support continued development of the Pure Rust ecosystem.\n\n[![Sponsor](https://img.shields.io/badge/Sponsor-%E2%9D%A4-red?logo=github)](https://github.com/sponsors/cool-japan)\n\n**[https://github.com/sponsors/cool-japan](https://github.com/sponsors/cool-japan)**\n\nYour sponsorship helps us:\n- Maintain and improve the COOLJAPAN ecosystem\n- Keep the entire ecosystem (OxiBLAS, OxiFFT, SciRS2, etc.) 100% Pure Rust\n- Provide long-term support and security updates\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcool-japan%2Fsplitrs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcool-japan%2Fsplitrs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcool-japan%2Fsplitrs/lists"}