How charmbracelet/vhs works
VHS is a Go tool for scripting terminal sessions into GIFs and other video outputs, with additional recording, publishing, and SSH-server workflows. The main workflow accepts a tape from a user or stdin, lexes and parses its commands, evaluates them against a terminal/browser session, captures frames, and renders output. The graph also includes documented CLI capabilities whose implementation details were not fully sampled; those links are marked accordingly. Evidence is limited to the provided excerpts, source index, and README.
Main entry points: evaluator.go Command evaluator · vhs.go Terminal session · main.go VHS CLI · command.go Command handlers
Components 20
CLI and authoring
- VHS CLI
main.go - Action recorder
record.go - Command formatting
syntax.go
Tape language
- Tape lexer
lexer/lexer.go - Token definitions
token/token.go - Tape parser
parser/parser.go
Terminal runtime
- Command evaluator
evaluator.go - Command handlers
command.go - Terminal session
vhs.go - PTY shell
shell.go - Virtual terminal
- Theme catalog
themes.go
Capture and output
- Frame capture
vhs.go - Frame decoration
draw.go - Video renderer
ffmpeg.go - Rendered video
Sharing and access
- Tape publisher
publish.go - SSH server
serve.go
Other components
- Tape author
- SSH user
Connections 25
- Tape author → VHS CLI: runs tape
README.md - VHS CLI → Command evaluator: evaluates tape
main.go - Command evaluator → Tape lexer: lexes input
evaluator.go - Command evaluator → Tape parser: parses tokens
evaluator.go - Tape lexer → Token definitions: emits tokens
lexer/lexer.go - Tape parser → Token definitions: uses token types
parser/parser.go - Tape parser → Tape lexer: reads tokens
parser/parser.go - Command evaluator → Command handlers: executes commands
evaluator.go - Command evaluator → Terminal session: starts and configures
evaluator.go - Command handlers → Terminal session: updates session
command.go - Terminal session → PTY shell: starts shell
vhs.go - Terminal session → Virtual terminal: connects browser terminal
vhs.go - Command handlers → Virtual terminal: sends key input
command.go - Terminal session → Frame capture: records frames
vhs.go - Frame capture → Frame decoration: adds window styling
- Terminal session → Video renderer: renders recording
- Video renderer → Rendered video: writes video output
- VHS CLI → Action recorder: starts recording
main.go - Action recorder → Tape author: writes tape text
README.md - VHS CLI → Tape publisher: publishes output
README.md - VHS CLI → SSH server: starts server
README.md - SSH user → SSH server: submits tape
README.md - SSH server → Rendered video: returns rendered output
- Command evaluator → Command formatting: formats commands
evaluator.go - Command handlers → Theme catalog: applies theme