README
¶
kitty-browse
A small Go terminal browser: real Chromium pixels in Kitty/iTerm2/Sixel terminals, without the Electron/Rust stack.
Status: functional prototype. Clickable tabs and navigation/address toolbar, mouse, hints, history/bookmarks, screenshots, text fallback and optional tuios title reporting are implemented; richer page input controls are future work.
How it works
chromedp ──CDP screencast──> internal/render ──rasterm/Kitty──> terminal
│
└── navigation, clicks, input, JS, cookies, downloads
chromedpowns Chromium and exposes navigation/automation.internal/renderis a small region-aware renderer derived fromtermcast: it streams Chromium's viewport to terminals that speak Kitty, iTerm2 or Sixel graphics, but leaves two top rows for a tab strip and navigation/address toolbar.- The browser lifecycle stays separate so a future
tuiospane or automation tool can reuse the same session.
Install
curl -fsSL https://raw.githubusercontent.com/getan/kitty-browse/master/install.sh | sh
The script downloads the archive for this platform, verifies it against the
release's checksums.txt, and installs to /usr/local/bin (or ~/.local/bin
when that is not writable).
When GitHub is unreachable it retries through the same mirror list golder uses,
for the version query as well as the download — on mainland networks
api.github.com usually fails before github.com does. A mirror's copy of
checksums.txt is only accepted when every responding mirror agrees on the
archive's hash, so one poisoned mirror cannot pass both the archive and its
digest.
| variable | meaning |
|---|---|
KITTY_BROWSE_VERSION |
install a specific tag instead of the latest |
KITTY_BROWSE_INSTALL_DIR |
install somewhere else |
KITTY_BROWSE_MIRROR |
replace the mirror list; off uses GitHub only |
KITTY_BROWSE_API |
use a different "latest release" endpoint |
GITHUB_TOKEN |
raise the API rate limit (sent to GitHub only, never a mirror) |
Chromium is not installed by the script; see Requirements.
Requirements
- Go 1.25+
- Chrome or
chrome-headless-shell - A terminal with graphics support: Kitty, Ghostty, WezTerm, iTerm2, or a Sixel-capable terminal
- Inside tmux, enable passthrough so the graphics escapes reach the terminal
Chinese / Unicode and portable fonts
Tab titles, the address field, status and text mode preserve UTF-8. Their layout
uses Unicode grapheme clusters and terminal-cell widths (CJK characters normally
occupy two cells), not byte counts. Truncation and Backspace do not split an emoji
or combining sequence. Untrusted terminal control/bidi formatting characters are
still sanitized; Chinese is not replaced with ?.
There are two separate font environments:
- TUI labels are drawn by the host terminal. Keep a normal monospace primary font and allow a CJK fallback. macOS normally supplies PingFang SC automatically.
- Webpage pixels are drawn by Chromium, using fonts installed where Chromium runs. The program respects website CSS/webfonts and system fallback; it does not force a font over every page or its icon fonts.
For a common Linux setup, install Noto CJK. Debian/Ubuntu:
sudo apt-get update
sudo apt-get install --no-install-recommends fontconfig fonts-noto-cjk
# The family must actually exist; fc-match alone can silently select another font.
fc-list ':family=Noto Sans CJK SC' family file
fc-list ':family=Noto Sans Mono CJK SC' family file
fc-match -f '%{family[0]} | %{file}\n' 'sans-serif:lang=zh-cn'
Other Linux distributions provide equivalent noto-fonts-cjk/Noto CJK packages.
For Linux Ghostty, an optional user-selected fallback configuration is:
font-family = ""
font-family = "JetBrains Mono"
font-family = "Noto Sans Mono CJK SC"
The application does not edit terminal/global font settings or bundle a large font file. With SSH, install the TUI fallback on the terminal/client machine and webpage fonts on the Chromium/server machine. Installing one does not fix missing glyphs in the other. Use a UTF-8 terminal/locale on Linux.
Run
go run ./cmd/kitty-browse https://example.com
go run ./cmd/kitty-browse -fps 12 -quality 90 example.com
Project-local Chromium on macOS ARM64
Use an explicit executable path when Chromium is not installed system-wide.
This also works with the executable inside a Chrome, Brave or Edge .app.
For the project-local Chromium installation used on this Mac:
export KITTY_BROWSE_CHROME="$PWD/.local/chromium/chrome-mac/Chromium.app/Contents/MacOS/Chromium"
go run ./cmd/kitty-browse https://example.com
# Or pass -chrome /absolute/path/to/Chromium without setting the environment.
The local install is Chromium 158.0.8117.0, official Mac_Arm snapshot
1724382 from
https://storage.googleapis.com/chromium-browser-snapshots/Mac_Arm/1724382/chrome-mac.zip.
.local/ is gitignored; no system browser or personal browser profile is used.
Snapshots are development builds, not an automatically updated stable browser.
To verify the whole CDP path without a terminal or external network:
make test-chromium # uses KITTY_BROWSE_CHROME from above
go run ./cmd/kitty-browse "file://$PWD/internal/render/testdata/page.html"
The test checks rendered JPEG screencast frames, PNG still capture with an ordinary caller context, and that navigation leaves the browser alive.
Profiles, private browsing and optional identity compatibility
Normal launches now use a dedicated persistent Chromium profile. Nothing is imported from personal Chrome/Edge/Brave profiles or earlier temporary sessions. Default locations:
- macOS:
~/Library/Application Support/kitty-browse/profiles/default - Linux:
$XDG_CONFIG_HOME/kitty-browse/profiles/default, normally~/.config/kitty-browse/profiles/default - An explicit
XDG_CONFIG_HOMEoverrides the base directory on either platform.
Use an independent profile for each account/work context:
./bin/kitty-browse -profile-dir "$PWD/.local/profiles/work" https://example.com
./bin/kitty-browse -private https://example.com
./bin/kitty-browse -stealth=false https://example.com
The profile directory is private (0700) and process-locked on macOS/Linux. Two
running instances must not use the same profile; use another directory or private
mode instead. The program never deletes Chromium's own singleton lock to force
access to an occupied profile. Cookies/localStorage and profile-local history /
bookmarks (kitty-browse-state.json) can survive a normal close and restart.
Session-only cookies, expiry, logout and server-side session policies still apply:
a persistent profile does not guarantee that every site keeps you logged in.
Treat the profile as login credentials: do not commit it, share it or point the
application at a personal browser's profile. Chromium allocator defaults may use
basic password/mock-keychain storage; filesystem permissions are not a guarantee
of credential encryption at rest. Keep project-local profiles under .local/.
-private creates an isolated temporary Chromium profile, removed on normal exit.
It neither reads nor writes normal profile cookies or application history and
bookmarks; those application lists are memory-only in private mode. The footer
shows PRIVATE, and KITTY_BROWSE_DEBUG file logging is disabled. Combining
-private with an explicit -profile-dir is an error, not an implicit fallback.
Tabs in one private process share that process's private session.
Private mode is not anonymity or secure erasure. Temporary browser files may exist while it runs; crashes/forced termination may leave remnants. Explicitly saved screenshots, shell/terminal/tuios logs, OS traces and the site's own records are outside this cleanup guarantee. The old global history file is not migrated automatically into the new per-profile stores.
Headless User-Agent and -stealth
kitty-browse normalizes the browser identity by default, because sites
commonly reject Chromium's headless token outright (Baidu's risk control is one
example). -stealth is enabled unless it is explicitly turned off with
-stealth=false, which restores Chromium's native headless identity. This is a
compatibility default, not a guarantee of passing anti-bot systems. It:
- derives UA from the actual running Chromium, changing only
HeadlessChrome/toChrome/, without inventing a browser version or OS; - aligns the HTTP UA and
navigator.userAgentthrough per-tab CDP configuration; - disables the automation switch / Blink
AutomationControlledmarker, so the normalnavigator.webdrivervalue is nottrue; - preserves native UA Client Hints metadata when it is available, normalizing the headless brand. If an initial target cannot supply it, it omits those hints rather than fabricating hardware/platform details.
-user-agent '...' provides an explicit override and takes priority over the
derived UA. For arbitrary custom strings, Client Hints are omitted to avoid
attaching unrelated real-Chromium metadata. Prefer the matching-version derived
UA unless testing a specific compatibility issue.
This does not randomize fingerprints, spoof all graphics/plugins/devices, rotate IPs, defeat challenges/captchas, or manufacture human behavior. The normal UI is already driven by the user's clicks and typing; adding random delays does not make automation genuinely human. Respect each site's access rules and limits.
Native actions for golder and automation
kitty-browse exposes a versioned, owner-only JSON API on its optional Unix
socket. The implementation is compiled into this Go binary and talks over the
existing private CDP pipe: runtime dependencies remain only kitty-browse and
Chromium. It does not invoke terminal-browser, agent-browser, Node.js,
Playwright, Python or a remote-debugging TCP endpoint.
./bin/kitty-browse \
-profile-dir "$PWD/.local/profiles/work" \
-control-socket "$PWD/.local/live.sock" \
https://example.com
./bin/kitty-browse info -socket "$PWD/.local/live.sock"
./bin/kitty-browse action -socket "$PWD/.local/live.sock" -- snapshot -i -c
./bin/kitty-browse action -socket "$PWD/.local/live.sock" -- click @e12
./bin/kitty-browse action -socket "$PWD/.local/live.sock" -- fill @e9 'hello'
./bin/kitty-browse action -socket "$PWD/.local/live.sock" -- get url
./bin/kitty-browse action -socket "$PWD/.local/live.sock" -- done
The CLI is a convenience client for the same /v1/info and /v1/actions API
that a future golder built-in tool should call directly. /v1/info returns
stable browser/tab/target IDs and machine-readable capability schemas; clients
must pin those IDs and re-discover after tab/navigation lifecycle changes.
Implemented native capabilities include AX snapshot/refs, CSS and accessible locators, safe pointer/input/keyboard actions, waits, same-process and OOPIF frames, dialogs, popup observation, tab/navigation/viewport lifecycle, bounded network/console/error observation, response bodies, cookies/storage, browser-scoped downloads, screenshots and PDF. Prefer snapshot/ref over visual coordinate guessing. SSO, MFA, QR scan and consequential business writes remain human-in-the-loop operations.
This is a stable typed API, not a claim of byte-for-byte agent-browser CLI
compatibility. Network interception/mock/HAR, video/trace, full device emulation,
closed-shadow piercing and WebMCP are not currently exposed. See
docs/action-api.md for the full contract and
skill/kitty-browse/SKILL.md for the golder
workflow.
Controls
The top two rows are mouse-clickable TUI controls, not part of the webpage:
[1 The Go Programming x][2 Example Domain x][+]
[<] [>] [R] https://go.dev/ [Go] [Shot]
- Click a tab to switch without reloading;
xcloses it;[+]opens a blank tab. [<]/[>]use the current tab's actual Chromium history, including links clicked inside pages. Disabled controls are dimmed.[R]reloads. Click the address field, type a replacement URL, then click[Go]or press Enter.[Shot]saves a screenshot of the current viewport.- Each tab retains its own page, scroll position and address-editor state.
The last tab remains open; use
qto quit the browser. - These are styled terminal-cell buttons, not an embedded OS window. Page clicks and scrolling are sent to Chromium. Existing keyboard controls remain available.
| Key | Action |
|---|---|
Ctrl+L / l |
edit the address bar |
Enter |
navigate to the address |
Esc |
cancel editing / hint / picker |
Alt+Left / Left |
back |
Alt+Right / Right |
forward |
Ctrl+R / r |
reload |
q / Ctrl+C / Ctrl+Q |
quit |
Alt+F |
hint mode; type a label to click/focus |
H |
history picker (j/k, Enter) |
B |
bookmarks picker |
b |
toggle bookmark for the current page |
t |
toggle readable text mode |
s / S |
save viewport / full-page PNG screenshot |
T / W |
new tab / close active tab (outside address editing) |
| mouse click | left-click the page |
| mouse wheel | scroll the page |
Useful flags:
-fps maximum frames per second (default 24; supports fractional FPS)
-scroll-lines cell heights per wheel step (default 2; use 1 for gentler touchpad movement)
-quality JPEG quality, 0-100 (default 85)
-width maximum frame width in pixels
-height maximum frame height in pixels
-load-timeout page load timeout (default 30s)
-measure-cells asynchronous pixel-size query (default true; use =false to disable)
-chrome Chromium executable path (default: KITTY_BROWSE_CHROME, then auto-detect)
-control-socket optional local Unix socket for screenshots of this live browser
-screenshot-dir hotkey screenshot directory (default .local/screenshots)
-download-dir browser download directory (default: profile Downloads; temporary in private mode)
-profile-dir dedicated persistent profile (default: user config directory)
-private isolated temporary profile and memory-only application history
-stealth remove headless UA token + automation markers (default on; =false for native identity)
-user-agent explicit UA override (otherwise the normalized desktop UA)
Screenshots of the live page
Screenshots come directly from Chromium, not the terminal cell grid. They
contain page pixels, but not the TUI address/help rows. In browse mode press
s for the current viewport or S for the full scrollable page. Files go to
.local/screenshots/ with timestamped names; -screenshot-dir changes this.
For scripts or another pane, enable a local control socket at startup:
# In the browser pane (KITTY_BROWSE_CHROME configured as above):
./bin/kitty-browse -control-socket "$PWD/.local/live.sock" https://go.dev/
# From another shell, screenshot that SAME live tab:
./bin/kitty-browse screenshot -socket "$PWD/.local/live.sock" \
-out .local/screenshots/viewport.png -json
./bin/kitty-browse screenshot -socket "$PWD/.local/live.sock" \
-out .local/screenshots/full.png -full-page -json
KITTY_BROWSE_SOCKET supplies the socket path to either command. Use a separate
socket per browser instance; no guessing of which pane is active. The screenshot
command captures the selected tab; it never launches a fresh tab, reloads the URL, or changes viewport/scroll
position. Login and interactive state remain intact. Full-page capture includes
the current rendered document, not lazy content the site has not loaded yet.
Extremely large full-page captures are rejected at 100 million CSS pixels.
PNG files are private (0600) and existing files/symlinks are never overwritten.
The socket is also 0600, offers only screenshots, never listens on TCP, and
is removed on a normal exit. If a browser crashes and leaves a stale socket,
use a new path or remove it only after confirming the old process has stopped.
On macOS keep the socket path short enough for the Unix socket path limit.
Roadmap
- Chromium lifecycle and page navigation
- Kitty/iTerm2/Sixel frame streaming
- Address bar and navigation keys
- Mouse cell → viewport pixel mapping
- Hint mode (
Alt+F) driven by a page-side DOM query - History and bookmarks
- Region rendering so a TUI can keep its own chrome
- Idle PNG still frames, JPEG while the page is moving
- Text extraction fallback for copy/readability
- Optional
tuiospane integration - Viewport/full-page screenshots of the live tab, via hotkeys or CLI
- Clickable tab strip, address/navigation toolbar, and real Chromium tabs
- Dedicated persistent profiles, private sessions and opt-in identity compatibility
Design notes
termcast is a display transport, not a browser UI. This project's renderer
keeps tabs on row 1, navigation/address on row 2, and status on the last row:
- it uses kernel-reported pixel dimensions or asynchronous
CSI 14t/16treplies, which the normal input parser consumes as geometry, not keystrokes; - it switches to a lossless PNG once after a content change becomes idle;
- it maps terminal mouse coordinates proportionally through the rendered viewport, including custom resolutions;
- it places Kitty images into an explicit cell rectangle (
c/r) from row 3 to the row above status, so an 8x16 fallback on an 8x18 terminal cannot leave a black gap underneath; no webpage graphics overlap the two chrome rows.
Normal updates keep fixed Kitty image/placement IDs (i=1,p=1) and never clear
the body or delete the visible image before uploading its replacement. Identical
screencast frames are ACKed but dropped, and an unchanged idle page is not
periodically captured/redrawn. This avoids black flashes and JPEG/PNG cycling.
Scrolling and latency
- Terminal input is bounded. Adjacent wheel reports are combined without crossing keyboard/click boundaries; reversed input replaces an unsent old direction tail. Horizontal touchpad drift is not treated as vertical input.
- A cancellable, serial worker sends accumulated wheel movement roughly every 16ms, rather than blocking the UI on one CDP round trip per report. Changing tabs, navigating, resizing or clicking cancels pending old-target movement.
- CDP frames are ACKed independently of image decoding. Both raw and decoded
frame mailboxes keep only the latest frame; stale frames are discarded before
expensive decoding. Decoding is paced by
-fps, and a final frame is retained. - Ready frames are drawn immediately, without waiting for a second UI ticker. Scroll events do not redraw the toolbar. Idle PNG capture and title/history polling yield while input is busy.
- Opaque Kitty frames use lossless packed RGB with fast zlib compression
(
f=24,o=z), reused buffers, and one write per frame. Transparent images fall back to fast PNG. This avoids PNG re-encoding on the common scrolling path; the screenshot command still saves PNG files as before.
On the development Mac (Apple M1), the same 856x900 webpage screenshot measured about 18.8ms / 45 writes / 180,798 wire bytes with the previous PNG transport, versus 5.3ms / 1 write / 149,101 wire bytes with RGB+zlib. This is an encoding benchmark, not an end-to-end display FPS guarantee. Terminal/tuios throughput, viewport size and page complexity still limit the achieved frame rate.
To tune movement independently of frame rate:
./bin/kitty-browse -fps 30 -scroll-lines 1 https://go.dev/
SGR mouse reports provide quantized wheel steps, not macOS's original precise touchpad pixel deltas. This improves response and removes queued work, but does not make terminal scrolling identical to a native 60/120Hz browser.
For repeatable local encoding comparisons, first save a representative page PNG:
KITTY_BROWSE_BENCH_PNG="$PWD/.local/screenshots/viewport.png" \
go test ./internal/render -run '^$' -bench BenchmarkKittyEncode -benchmem
tuios integration
When kitty-browse runs inside a tuios pane (TUIOS_ENV=1 plus a pane id and
socket), it renames the pane to the current page title. This is cosmetic and
best-effort: outside tuios, or when the tuios binary is unavailable, it is a
no-op. Exiting restores the shell-derived pane name.
Kitty frames use a first packet containing image data and explicit pixel dimensions. This avoids a rasterm v0.1.17 / tuios compatibility issue: an empty PNG first packet with no dimensions can upload the image but leave it with a zero-cell placement, making the page invisible.
For startup, frame and draw diagnostics:
KITTY_BROWSE_DEBUG="$PWD/.local/render.log" go run ./cmd/kitty-browse \
"file://$PWD/internal/render/testdata/page.html"
Distinguish the layers when debugging: first screencast frame means Chromium
produced pixels; still frame means PNG capture succeeded. Once-per-second
perf lines report input coalescing, pending/in-flight scroll movement, CDP
calls, frames received/ACKed/decoded/dropped, terminal writes (Drawn) and
WireBytes. DrawLast/DrawTotal include encoding and writing to the PTY;
they do not measure when the host terminal actually displayed the pixels.
tuios capture-pane and tuios screenshot capture character cells, not Kitty
image pixels; a blank body in those captures is not evidence of missing frames.
Check the visible pane for the blue test page and orange swatch.
Render health and bounded recovery
A successful StartScreencast command is only transport readiness. The footer
initially says Waiting for first page image...; only an image actually written
to the terminal marks rendering ready. If no image arrives within five seconds,
the footer reports that explicitly. PNG fallback requests run off the UI loop,
one at a time, with a five-second deadline. Switching tabs, navigating or resizing
cancels the old request, so a late image cannot overwrite a different page.
Two consecutive failed PNG captures, or a screencast transport error, trigger a stop/start of image transport on the same tab. There are at most two automatic restarts per selected-tab/navigation cycle, with backoff; briefly receiving an image does not replenish that budget. Static pages are not failures just because they stop emitting new frames. The browser is never restarted and the document is not reloaded, preserving logins and unsaved page state.
If recovery is exhausted, automatic capture attempts stop. The footer says
Page image unavailable; automatic recovery stopped. The last good image stays
visible; if there was none, the body shows a textual explanation instead of an
unexplained black pane. Reload or switch tabs to explicitly retry; a late real
frame can also clear the warning.
With KITTY_BROWSE_DEBUG enabled, the log includes Chromium version/PID, target,
viewport, pipeline counters, recovery attempts and quoted Chromium output.
Logging is opt-in and disabled in private mode. Browser diagnostic output can
contain browsing information; do not publish it without reviewing it.
References
chromedp/termcast— MITchromedp/chromedp— MITsanohiro/casty— MIT; input/hint/address bar reference implementation
License
MIT. See LICENSE.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
kitty-browse
command
Command kitty-browse draws a real Chromium page in a terminal that supports the Kitty graphics protocol (or iTerm2/Sixel through rasterm).
|
Command kitty-browse draws a real Chromium page in a terminal that supports the Kitty graphics protocol (or iTerm2/Sixel through rasterm). |
|
internal
|
|
|
action
Package action exposes kitty-browse's versioned, native Chromium automation API.
|
Package action exposes kitty-browse's versioned, native Chromium automation API. |
|
browser
Package browser owns the Chromium lifecycle and page navigation.
|
Package browser owns the Chromium lifecycle and page navigation. |
|
captureguard
Package captureguard coordinates CDP screenshots with screencast consumers.
|
Package captureguard coordinates CDP screenshots with screencast consumers. |
|
control
Package control provides a local control channel for a running kitty-browse process.
|
Package control provides a local control channel for a running kitty-browse process. |
|
history
Package history persists recently visited URLs and bookmarks.
|
Package history persists recently visited URLs and bookmarks. |
|
render
Package render turns a Chromium screencast into terminal image frames.
|
Package render turns a Chromium screencast into terminal image frames. |
|
screenshot
Package screenshot validates and securely stores PNG screenshots.
|
Package screenshot validates and securely stores PNG screenshots. |
|
term
Package term owns the terminal mode and the cell grid around the browser image.
|
Package term owns the terminal mode and the cell grid around the browser image. |
|
textutil
Package textutil provides terminal-cell-aware operations on Unicode text.
|
Package textutil provides terminal-cell-aware operations on Unicode text. |
|
tuios
Package tuios provides the optional, best-effort integration with a tuios pane.
|
Package tuios provides the optional, best-effort integration with a tuios pane. |
|
ui
Package ui holds the browser chrome state independent of terminal I/O.
|
Package ui holds the browser chrome state independent of terminal I/O. |