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.

patterns/__init__.py

View on GitHub
"""drive-tui patterns -- pluggable interaction paradigms for TUI screens.

A :class:`Pattern` looks at a :class:`smartcli_core.Snapshot` and answers two
questions: "is this MY kind of screen?" (:meth:`Pattern.matches`, 0..1
confidence) and "how do I operate it?" (:meth:`Pattern.drive`, running the
perceive->act->wait loop against a live :class:`smartcli_core.PtySession`).

Add a paradigm = drop a module into ``patterns/recipes/`` with an
``@register``-ed Pattern subclass; :func:`patterns.registry.load_all` imports
the folder automatically, and :func:`patterns.classify.classify` starts
ranking it immediately.
"""
from __future__ import annotations

import os
import sys

# Make smartcli_core importable no matter where the caller sits: the repo root
# is three levels up (patterns/ -> drive-tui/ -> skills/ -> ROOT), overridable
# with SMARTCLI_ROOT.
_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(
    os.path.dirname(os.path.abspath(__file__)))))
for _p in ([os.environ.get("SMARTCLI_ROOT")] if os.environ.get("SMARTCLI_ROOT")
           else []) + [_ROOT]:
    if _p and _p not in sys.path:
        sys.path.insert(0, _p)

from .base import Pattern, PatternResult  # noqa: E402
from .registry import all_patterns, get, load_all, register  # noqa: E402
from .classify import classify, explain  # noqa: E402

__all__ = [
    "Pattern", "PatternResult",
    "register", "get", "all_patterns", "load_all",
    "classify", "explain",
]
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: 321kUpdated 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