Splice
Span-safe refactoring kernel for Rust using tree-sitter and cargo check.
Status: MVP / Proof of Concept Version: 0.1.0 License: GPL-3.0-or-later
What This Is
Splice is a command-line tool that performs byte-accurate, AST-validated replacements of Rust code. It replaces function bodies, struct definitions, and enum variants with validation.
What This Is NOT
- An IDE - Use Rust Analyzer or IntelliJ Rust
- A semantic refactoring tool - It doesn't track cross-file references
- A complete solution - It's a focused tool for one specific job
- Production-hardened - It's an MVP with known limitations
What It Does
- Replaces function bodies, struct definitions, enum variants
- Validates syntax with tree-sitter after every patch
- Validates compilation with cargo check after every patch
- Rolls back atomically on any failure
- Orchestrates multi-step refactors via JSON plans
Known Limitations
- No cross-file reference tracking
- No persistent database
- No resume mode for failed plans
- No dry-run mode
- No auto-discovery of symbols
- Single-file symbol resolution only
Installation
Quick Start
Single Patch
# Create replacement file
# Apply patch
Multi-Step Plan
# Create plan.json
# Execute plan
Documentation
- manual.md - Complete user manual
- QUICKSTART.md - Quick reference
Requirements
- Rust 1.70+ (for building)
- Cargo workspace (for validation)
- tree-sitter-rust (bundled)
Architecture
- src/cli/ - CLI argument parsing
- src/ingest/ - Rust file parsing
- src/graph/ - SQLiteGraph integration
- src/resolve/ - Symbol to byte span resolution
- src/patch/ - Span-safe replacement + validation
- src/validate/ - Tree-sitter + cargo check validation
- src/plan/ - JSON plan orchestration
Validation Gates
Every patch passes:
- UTF-8 boundary validation
- Tree-sitter reparse (syntax check)
- Cargo check (compilation check)
Development Status
Complete Features:
- Span-safe byte replacement
- Tree-sitter validation
- Cargo check validation
- Atomic rollback
- Multi-step plan execution
- CLI interface
Not Implemented:
- Cross-file reference tracking
- Persistent symbol database
- Resume mode for failed plans
- Dry-run mode
- Auto-discovery of symbols
Testing
Test Coverage: 22/22 tests passing
Examples
tests/cli_tests.rs- CLI integrationtests/patch_tests.rs- Patch validationtests/integration_refactor.rs- Symbol resolution
Contributing
This is an MVP / proof-of-concept. The codebase is feature-complete as of v0.1.0. No new features are planned.
License
GPL-3.0-or-later
Disclaimer
This is experimental software. Use at your own risk. Always commit your changes before running Splice.