npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

tui-agent-use

v0.1.3

Published

Deterministic OpenTUI driver for agent-operated TUI debugging

Readme

TUI Agent

Deterministic eyes and hands for OpenTUI applications. Renders a real application into OpenTUI's memory terminal, drives keyboard, paste, mouse, and resize events, and saves text, styled spans, SVG frames, focus state, layout diagnostics, and adapter-owned semantic state after every action.

It is an installable npm package and a Bun CLI. The harness is application-neutral; a small trusted adapter mounts your TUI and optionally exposes routes, dialogs, backend requests, or other state useful for assertions.

Requirements and installation

  • Bun 1.2 or newer
  • OpenTUI 0.3.4 or newer
  • macOS, Linux, or Windows supported by OpenTUI's native packages
bun add --dev tui-agent @opentui/core
bunx tui-agent doctor

The tarball follows normal npm package conventions and can also be installed with npm install --save-dev. The executable requires bun because OpenTUI's test renderer and TypeScript adapter loading use Bun at runtime.

Quick start

Create test/tui/adapter.tsx:

/** @jsxImportSource @opentui/solid */
import { render } from "@opentui/solid"
import type { TuiAgentAdapter } from "tui-agent"

const adapter: TuiAgentAdapter = {
  name: "my-tui",
  async launch({ setup }) {
    await render(() => <App />, setup.renderer)
    return {
      inspect: () => ({ route: "home", state: { ready: true } }),
      dispose() {},
    }
  },
}

export default adapter

Create test/tui/smoke.json:

{
  "$schema": "node_modules/tui-agent/scenario.schema.json",
  "name": "smoke",
  "adapter": "./adapter.tsx",
  "terminal": { "width": 100, "height": 30 },
  "steps": [
    { "action": "waitForText", "text": "Describe the task" },
    { "action": "type", "text": "hello" },
    { "action": "assert", "visible": ["hello"] }
  ]
}

Run it:

bunx tui-agent run test/tui/smoke.json
bunx tui-agent run test/tui/smoke.json --json --artifacts /tmp/tui-smoke

CLI

tui-agent list [--json]
tui-agent run <scenario> [--adapter <module>] [--artifacts <dir>] [--keep-fixture] [--json]
tui-agent interact <scenario> [--adapter <module>] [--artifacts <dir>] [--keep-fixture]
tui-agent show <run-directory> [--json]
tui-agent doctor [--json]

Every command supports --help; failures are written to stderr and return a nonzero exit code.

Scenario model

Scenarios are plain JSON validated against the schema. Available actions:

| Action | Purpose | | --- | --- | | waitForText, waitForAbsent, waitForFocus, waitForIdle | Wait for visual, focus, or idle state | | key, type, paste | Keyboard input, modifiers, repetition, and bracketed paste | | click, doubleClick, clickText, move, drag, scroll | Mouse input | | resize | Trigger real terminal reflow | | wait | Pause | | capture | Name an evidence frame | | find | Search current frame + scrollback buffer for a regex pattern | | scrollback | Scroll the in-memory scrollback buffer | | assert | Check text, cursor, focus, request evidence, route, dialog, state, and highlights |

Each step captures: .txt (text), .svg (styled frame), .spans.json (spans), .tree.json (renderable hierarchy), .state.json (renderer metrics + adapter inspection).

Highlights

Every snapshot includes a highlights field listing background-highlighted spans on screen — the standard way TUI programs indicate selected items, active tabs, or focused buttons. Agents can assert on highlights directly:

{ "action": "assert", "highlights": [{ "text": "Settings" }] }

Adapter API

type TuiAgentAdapter = {
  name: string
  prepare?: (context: AdapterPrepareContext) => AdapterPreparation | Promise<AdapterPreparation>
  launch: (context: AdapterLaunchContext) => RunningTui | Promise<RunningTui>
}
  • prepare() — optional setup before scenario runs. Create fixture files, set environment.
  • launch() — mount the real TUI on context.setup.renderer. Return dispose + optional inspect.

The inspect() method returns semantic state (route, dialog, mode) that powers declarative assertions without parsing text.

Examples

This repo includes a Spinosa TUI adapter at adapters/spinosa.ts and several scenarios in scenarios/. These demonstrate fixture preparation, renderer factory interception, fake SDK transport, request capture, Effect cleanup, and JSON-safe semantic inspection:

cd packages/tui
bun tools/tui-agent/cli.ts run workspace-session
bun tools/tui-agent/cli.ts interact workspace-session

License

MIT