splice
Precision Code Editing with Graph Algorithm Analysis
Span-safe refactoring kernel for 7 languages with Magellan code graph integration.
⚠️ Requires Magellan
splice requires Magellan for full functionality.
Magellan provides the code graph database that splice uses for cross-file operations, impact analysis, and graph algorithms. You must run magellan watch on your codebase before using splice's advanced features.
# Install Magellan first
# Watch your project (builds database)
# Now splice can perform graph-aware operations
The Code Intelligence Toolset
splice is part of a coordinated toolset built on sqlitegraph. All tools share a common SQLite graph database and are designed to work together for AI-assisted code understanding and transformation.
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Magellan │ ───► │ llmgrep │ ───► │ Mirage │
│(Symbols & │ │ (Semantic │ │(CFG & Paths)│
│ Call Graph)│ │ Search) │ │ │
└─────────────┘ └─────────────┘ └─────────────┘
│ │ │
└────────────────────┴─────────────────────┘
│
┌──────▼──────┐
│ sqlitegraph │
│ (Database) │
└─────────────┘
│
┌──────▼──────┐
│ splice │
│(Edit using │
│ spans) │
└─────────────┘
| Tool | Purpose | Repository | Install |
|---|---|---|---|
| sqlitegraph | Graph database foundation | github.com/oldnordic/sqlitegraph | cargo add sqlitegraph |
| Magellan | Call graph indexing, symbol navigation | github.com/oldnordic/magellan | cargo install magellan |
| llmgrep | Semantic code search | github.com/oldnordic/llmgrep | cargo install llmgrep |
| Mirage | CFG analysis, path enumeration | github.com/oldnordic/mirage | cargo install mirage-analyzer |
| splice | Precision code editing | github.com/oldnordic/splice | cargo install splice |
What is splice?
splice performs byte-accurate, AST-validated refactoring operations on code in 7 languages: Rust, Python, C, C++, Java, JavaScript, and TypeScript. It can replace function bodies, delete symbols, perform cross-file rename, analyze code graphs, and generate refactoring proofs.
What splice is NOT
- ❌ A code indexer (use Magellan)
- ❌ A semantic search tool (use llmgrep)
- ❌ A CFG analysis tool (use Mirage)
- ❌ An IDE or LSP server (use rust-analyzer, IntelliJ, PyCharm, VSCode)
What splice IS
- ✅ Span-safe code editing with byte-accurate replacements
- ✅ Cross-file symbol rename using Magellan ReferenceFact data
- ✅ Graph algorithm analysis (reachability, dead-code, cycles, condense, slice)
- ✅ Proof-based refactoring with machine-checkable behavioral equivalence
- ✅ Multi-language validation (tree-sitter + compiler gates)
- ✅ Backup and rollback with automatic checksum verification
Installation
Or build from source:
Quick Start
1. Install the Toolset
# Install all tools for complete workflow
2. Index Your Project
# Magellan watches your source and builds database
3. Edit with Splice
# Patch a function body
# Preview before applying
# Cross-file rename
# Impact analysis
Commands
Edit Commands
| Command | Description |
|---|---|
patch |
Replace function bodies, class definitions with validation |
delete |
Remove symbol definitions and all references |
apply-files |
Multi-file pattern replacement with AST confirmation |
rename |
Cross-file symbol rename using Magellan ReferenceFact |
Graph Algorithm Commands
| Command | Description |
|---|---|
reachable |
Show caller/callee chains and affected files |
dead-code |
Find unused symbols from entry points |
cycles |
Find circular dependencies in call graph |
condense |
Collapse SCCs to DAG for dependency analysis |
slice |
Forward/backward program slicing |
Query Commands (Magellan)
| Command | Description |
|---|---|
status |
Display database statistics |
find |
Locate symbols by name or symbol_id |
refs |
Show callers/callees for a symbol |
files |
List indexed files |
export |
Export graph data (JSON, JSONL, CSV) |
Utility Commands
| Command | Description |
|---|---|
undo |
Restore files from backup manifest |
log |
Query execution audit trail |
explain |
Get detailed explanations for error codes |
validate-proof |
Validate refactoring proof files |
Examples
Cross-File Rename with Preview
# Find symbol ID first
# Preview rename (no changes)
# Apply rename with backup
# Generate proof for audit trail
Impact Analysis Before Refactoring
# See what code is reachable from a symbol
# Find dead code from main entry point
# Detect circular dependencies
# Slice forward from a target (what it affects)
Patch with Preview
# Create replacement
# Preview with JSON output
# Output:
# {
# "status": "ok",
# "message": "Previewed patch 'greet' at bytes 0..42 (dry-run)",
# "data": {
# "symbol": "greet",
# "preview_report": {
# "file": "src/lib.rs",
# "line_start": 1,
# "line_end": 3,
# "lines_added": 3,
# "lines_removed": 3,
# "bytes_added": 45,
# "bytes_removed": 42
# },
# "files": [{"file": "src/lib.rs"}]
# }
# }
Batch Pattern Replacement
# Replace across multiple files
# With validation and backup
Supported Languages
| Language | Extensions | Patch | Delete | Validation |
|---|---|---|---|---|
| Rust | .rs |
Full | Full | cargo check |
| Python | .py |
Full | Basic | python -m py_compile |
| C | .c, .h |
Full | Basic | gcc -fsyntax-only |
| C++ | .cpp, .hpp, .cc, .cxx |
Full | Basic | g++ -fsyntax-only |
| Java | .java |
Full | Basic | javac |
| JavaScript | .js, .mjs, .cjs |
Full | Basic | node --check |
| TypeScript | .ts, .tsx |
Full | Basic | tsc --noEmit |
Requirements
- Magellan 2.1.0+ — Required for code graph operations
- sqlitegraph 1.4.2+ — Included automatically
Documentation
splice <command> --help— Built-in usage examples- MANUAL.md — Complete CLI reference manual
- CHANGELOG.md — Version history
- docs/examples/rename_examples.md — Cross-file rename examples
- docs/examples/graph_algorithm_examples.md — Graph algorithm usage
- docs/examples/proof_examples.md — Proof-based refactoring
License
GPL-3.0-only. See LICENSE.md.
Related Projects
- sqlitegraph — Graph database library
- Magellan — Call graph indexer
- llmgrep — Semantic code search
- Mirage — CFG analysis