Skip to content

dwgx/SmartCLI / skills/drive-tui

drive-tui

Verified

Drive interactive terminal (TUI) programs — CLIs, REPLs, installers, menu apps, agent CLIs, and editors like vim — through a PTY, reading semantic screen snapshots. A pattern library classifies a screen (REPL, menu, pager, fzf search, confirm dialog, form, spinner, wizard) and drives it with a ready recipe. Use when a program expects a live terminal (arrow-key menus, prompts, spinners, password fields, curses UIs), or when a piped command hangs or prints nothing.

_vendor/smartcli_core/__init__.py

View on GitHub
"""SmartCLI shared core.

A pluggable-PTY + pyte screen model + semantic snapshot + readiness stack for
driving interactive terminal programs. Both SmartCLI skills build on this.

Quick start::

    from smartcli_core import PtySession

    with PtySession(cols=100, rows=30) as sess:
        sess.start("python")
        # NOTE: pyte right-pads every screen line with spaces, so an end-anchored
        # marker like r">>> $" never matches. Use an unanchored marker (or r">>> *$"
        # with re.M). wait_ready also races screen-stability, so pass a real marker
        # for a known first prompt rather than relying on STABLE on startup.
        sess.wait_ready(marker=r">>> ")
        sess.send_line("print('hello')")
        reason, snap = sess.wait_ready(marker=r">>> ")
        print(snap.to_text())
"""

from __future__ import annotations

from .pty_backend import (
    PosixPtyBackend,
    PtyBackend,
    WinptyBackend,
    get_default_backend,
)
from .readiness import wait_any, wait_for_regex, wait_ready, wait_until_stable
from .screen_model import CellAttrs, ScreenModel, safe_screen_display
from .session import KEY_MAP, PtySession
from .snapshot import Snapshot, Span, build_snapshot

__all__ = [
    # backends
    "PtyBackend",
    "WinptyBackend",
    "PosixPtyBackend",
    "get_default_backend",
    # screen
    "ScreenModel",
    "CellAttrs",
    "safe_screen_display",
    # snapshot
    "Snapshot",
    "Span",
    "build_snapshot",
    # readiness
    "wait_until_stable",
    "wait_for_regex",
    "wait_ready",
    "wait_any",
    # session
    "PtySession",
    "KEY_MAP",
]

__version__ = "0.3.5"
brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).Stars: 322kUpdated Claude CodeCodexVerifiedInstall
brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.Stars: 197kUpdated Claude CodeCodexVerifiedInstall
frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.Stars: 197kUpdated Claude CodeCodexVerifiedInstall
mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).Stars: 197kUpdated Claude CodeCodexVerifiedInstall