baml_language/crates/tools_onionskin/README.md
A live TUI (Text User Interface) for exploring BAML compiler phases in real-time, inspired by animation onion skinning techniques.
In animation, onion skinning displays ghosted versions of previous and next frames overlaid on the current frame, allowing animators to see how their work changes over time. BAML Onionskin applies this concept to compiler development - create a snapshot of your compiler output, make changes, and see a live diff showing exactly what changed.
Run the tool by specifying a BAML file or directory to watch:
# Watch a single file
cargo run --bin tools_onionskin -- --from path/to/your/file.baml
# Watch an entire directory
cargo run --bin tools_onionskin -- --from path/to/your/directory
When running from within the baml_language workspace, onionskin automatically enables hot-reload for compiler development. It detects the workspace by looking for the crates/baml_compiler_lexer directory.
# Hot-reload is automatic when running from the workspace
cd /path/to/baml_language
cargo run --bin tools_onionskin -- --from test.baml
# Explicitly specify workspace root (if auto-detection fails)
cargo run --bin tools_onionskin -- --from path/to/file.baml --workspace /path/to/baml_language
# Disable hot-reload if you don't want it
cargo run --bin tools_onionskin -- --from test.baml --no-hot-reload
With hot-reload enabled (shown as 🔥 Hot-Reload in the header):
baml_compiler_lexer, baml_compiler_hir, etc.).rs file in any compiler crate changes, a banner appears prompting you to rebuild| Key | Action |
|---|---|
← / → | Navigate between compiler phases |
↑ / ↓ | Scroll output up/down |
PgUp / PgDn | Scroll page up/down |
Home | Scroll to top |
Mouse Wheel | Scroll output |
s | Create/update snapshot (onion skin) |
S (Shift+S) | Delete snapshot |
c / y | Copy current output to clipboard |
p | Paste/show clipboard contents |
R (Shift+R) | Trigger compiler rebuild (with --workspace) |
Enter | Confirm pending rebuild |
Esc | Dismiss rebuild prompt |
q | Quit |
Ctrl+C | Exit |
Navigate through these compiler phases using the arrow keys:
.baml file. Shows lexer/parser output for that file, and project-wide HIR/THIR/Codegen..baml files in a directory. Shows aggregated output across all files.
Press s to create an onion skin snapshot of the current compiler output. Once a snapshot exists:
s again to update the snapshot to the current stateThis is useful for:
Start watching a file:
cargo run --bin tools_onionskin -- --from test.baml
The TUI shows the lexer output by default
Press → to navigate to the Parser view
Press s to create an onion skin snapshot
Edit test.baml in your editor - the view updates automatically
See the diff between your snapshot and the new compiler output
Navigate phases with ← → - both panes update to show that phase
Press s again to update the snapshot
cargo build --bin tools_onionskin
The tool uses: