ownsight-cli-0.1.0 is not a library.
Ownsight - Rust Ownership Visualizer
A dynamic, interactive tool for visualizing Rust ownership, borrowing, and lifetimes. Built with a two-layer architecture: Layer 1 for exam/learning use cases, Layer 2 for real debugging and code intelligence.
Features
Layer 1 - Learning & Exam Tool
- ✨ Interactive Timeline View: Step through ownership events line by line
- 📊 Visual Source Highlighting: See ownership changes directly in your code
- 🎯 Teaching Mode: Simplified explanations optimized for learning
- 🔄 Step Controller: Play, pause, and navigate through ownership events
- 📝 Event Explanations: Human-readable descriptions of what happens to each variable
Layer 2 - Debugging & Intelligence
- 🔍 Query Interface: Ask "Why can't I use X here?", "Where was X moved?", "What is borrowing Y?"
- 📈 Ownership Graph: Visualize relationships between variables, references, and scopes
- 🐛 Debug Mode: Precise, compiler-backed analysis
- 🎨 Graph Visualization: Interactive graph showing ownership relationships
Architecture
ownsight/
├── crates/
│ ├── ownsight-core/ # Core analysis engine (data model, events, graphs)
│ ├── ownsight-driver/ # Rust compiler integration (MIR-based analysis)
│ └── ownsight-cli/ # Command-line interface (cargo ownership-viz)
└── ui/ # Tauri desktop app (React + TypeScript)
Installation
Prerequisites
- Rust (stable + nightly)
- Bun (for UI development)
- Tauri CLI
Build from Source
- Clone the repository:
- Build the Rust workspace:
- Install the CLI tool:
- Build the desktop app:
Usage
CLI Tool
Analyze a Rust snippet:
Analyze from stdin:
|
Output as JSON:
Teaching mode vs Debug mode:
Desktop App
Run in development mode:
The desktop app provides:
- Source Editor: Write or paste Rust code
- Timeline View: Step-by-step ownership events
- Graph View: Visual ownership relationships
- Query Panel: Ask questions about ownership
- Interactive Stepping: Play/pause through events with speed control
Example
Ownsight will show:
- Line 2:
screated and owns the String - Line 3:
r1borrowssimmutably - Line 4:
r1is used (borrow is valid) - Line 5:
sis moved intos2 - Query: "Why can't I use
sat line 6?" → "swas moved at line 5"
Data Model
The core analysis produces:
- Variables: Name, type, scope, mutability
- Events: Create, Move, Borrow, Drop, etc.
- Ownership Graph: Nodes (variables, references) and edges (owns, borrows, moves)
- Diagnostics: Compiler errors and suggestions
- Ownership State: Valid/moved status at each line
Development
Running Tests
Snapshot Tests
Development Workflow
# Terminal 1: Watch Rust changes
# Terminal 2: Run UI in dev mode
&&
Roadmap
Current (MVP - Layer 1)
- Core data model
- Simple syntax-based analysis
- CLI tool with timeline output
- Tauri desktop app
- Source view with highlighting
- Timeline view
- Interactive stepping
- Graph visualization
- Query interface
Next (Layer 2 Enhancements)
- MIR-based analysis using rustc internals
- Cargo workspace support
- Function summaries
- Partial moves (struct fields)
- Pattern matching flows
- Non-lexical lifetimes (NLL)
- Closure capture analysis
- Async/await support
Future
- VS Code extension
- Rust Analyzer integration
- Web-based version (WASM)
- CI integration
- Team collaboration features
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.
Acknowledgments
Built with:
- Rust compiler internals for accurate analysis
- Tauri for cross-platform desktop apps
- React Flow for graph visualization
- Monaco Editor for code editing