Specter is a test harness for running and interacting with terminal applications (TUIs). It is designed to allow AI agents or automated scripts to test terminal interfaces by spawning processes, simulating input, and inspecting the terminal state.
Quick Start: Run
specter quickstartfor a concise guide optimized for LLM coding agents.
Specter operates as a self-contained process:
- Spawn: The
spawncommand starts a background process that manages a PTY (Pseudo-Terminal) and tracks the state of the running terminal application using a virtual terminal emulator (binding tolibvterm). - Commands: CLI commands connect to the running process to perform actions.
- Communication: Commands communicate via a Unix domain socket (
.specter.sock) located in the current working directory.
- Language: Go
- PTY Management: creack/pty
- Terminal Emulation: Bindings to
libvtermfor screen state tracking.
Start a new shell session:
specter spawn # Starts $SHELL (or /bin/sh)
specter spawn -- vim file.txt # Or run a specific command directlyThis starts the process and creates a hidden socket (.specter.sock) in the current directory.
Send key presses or text to the session.
specter type "ls -la\n" # Type command and press Enter
specter type "Hello World" # Type text without Enter
specter type "\t" # Press Tab (for autocomplete)
specter type "\x03" # Send Ctrl+C (interrupt)| Sequence | Description |
|---|---|
\n |
Enter/newline |
\t |
Tab |
\r |
Carriage return |
\\ |
Literal backslash |
\x03 |
Ctrl+C (interrupt) |
\x04 |
Ctrl+D (EOF) |
\x1b |
Escape key |
Capture the current state of the terminal screen.
specter capture # Get text content
specter capture --format png # Get screenshot imageUse --out <file> to specify a filename for PNG output.
Wait for a process to exit.
specter wait # Blocks until process exitsView the input history sent to the session.
specter historyKill the specter session and clean up.
specter kill- After sending input, wait briefly then capture to see the result
- Use capture frequently to verify the application state
- For interactive programs (vim, htop), use escape sequences for navigation
specter spawn
specter type "echo hello\n"
specter capture # Verify output
specter type "./my-cli-tool\n" # Run a program
specter capture
specter kill # Done- Go 1.23+
libvterm
go build -o specter cmd/specter/main.go