beetlebug

UIs that agents can drive and test

Build a window that a coding agent can see, click, and check with no display. The agent writes the script, runs it headless, and reads the result as text or as a picture.

A window with a Count button and the count 1
The counter of the check script below, after the click of ztk::inject.

How it works

ztk --headless runs a script with no display and the CPU renderer, so a window gives the same picture on each platform. Four commands let a script look at the window and drive it:

This check script builds a counter, finds the button in the tree, and clicks it. ztk --headless check.tcl prints n = 1:

set n 0
button .go -text Count -command {incr ::n}
label .count -textvariable n
pack .go .count -padx 12 -pady 8

update
foreach row [ztk::tree .] {
    lassign $row path class x y w h mapped
    if {$path eq ".go"} {
        set cx [expr {$x + $w / 2}]
        set cy [expr {$y + $h / 2}]
    }
}
ztk::inject . motion $cx $cy
ztk::inject . press 1 $cx $cy
ztk::inject . release 1 $cx $cy
update
puts "n = $n"
exit

ztk --mcp app.tcl runs the app headless and serves the answers of ztk::debug as MCP tools. The site has llms.txt, llms-full.txt, and api.json for agents, and the repository has a skill for an agent that builds a ztk app.

ztk code claude shows a coding agent in a window: its terminal on the left, and a panel with its tasks, its changed files, and each tool call on the right. The agent runs in the sandbox of the system by default.

Real today

The commands, the MCP server, and the files for agents are part of ztk. The check script above runs in the tests of this repository.