SuperAPIAI Directory

SmartCLI

github.com · AI developer platforms

Drive full-screen terminal programs such as vim, htop and lazygit by reading the screen as a live cell grid with cursor, selection and alt-screen state.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsWindows · Linux · API

About this tool

SmartCLI is a local Python toolkit for driving, sensing, and rendering terminals. It is built on a shared pluggable PTY backend and the pyte screen model, and provides three Agent skills, each of which is an independently runnable tool.

Purpose

SmartCLI is designed to enable AI to drive, sense, and render real terminal programs. It reads the actual screen cell model (pyte) rather than a byte pipe, so it can know which menu row is highlighted, press the correct keys, and wait for the screen to stabilize. It is suitable for driving full-screen terminal programs (such as vim, htop, lazygit), designing terminal visual effects, and rendering cell-exact terminal UI.

Main capabilities

Three Agent skills

  1. drive-tui: Drives interactive terminal programs (REPLs, menus, pagers, y/N prompts, wizards) through a PTY, using a sense -> decide -> act -> wait -> confirm loop, and never blindly sleeps. It provides persistent detached sessions and one-shot run modes, as well as an importable pattern library (8 recipes: repl, menu_select, pager, search_filter, confirm, form, progress, wizard).

  2. cmd-art: A terminal visual effects engine using a "live template" design (Effect ABC + @register decorator + auto-discovery). It includes 30 effects (donut, solarsystem, fire, plasma, rain, starfield, tunnel, text3d, cube, sphere, boids, life, fireworks, sparkle, decrypt, gradient_text, banner_scroll, image2ascii, typewriter, julia, mandelbrot, perlin, flames, water, nebula, text_flyin, text_converge, text_decrypt, spectrum_bars, cbonsai) and 8 themes (mono, fire, ocean, synthwave, viridis, pastel, matrix-green, rainbow). Effects are pure frame generators, playback is bounded by default and always restores the terminal.

  3. tui-ui: A web-like terminal layout engine that outputs tmux-safe ANSI frames (only SGR color sequences and newlines; no cursor movement, no alternate screen). It includes 17 components (badge, banner, braille_chart, card, fuzzy_filter_list, gradient_rule, kv, meter, panel, preview_pane, progress, radial_glow, rule, slider_track, table, tabs, tree), based on two modules, field.py (shader compositor) and raster.py (subcell half/quad/braille pixels). It is display-cell exact for CJK/emoji/ZWJ, and columns will not become misaligned.

Shared core

smartcli_core provides a pluggable PTY backend, the pyte screen model, semantic snapshots, and readiness synchronization. Since 0.3.0, every observation comes with a budgeted read path and io block, and callers can distinguish "quiet" from "not yet read" (local_cut, byte watermark, pending facts - unknown values are null, not 0), STABLE requires a drained observation, and close reports closed_confirmed or close_unconfirmed along with the last progress.

Knowledge graph

The knowledge/ directory contains a wiki-linked graph of 140+ .md files, documenting exact rendering formulas, ANSI sequences, and measurement constants, and every note has sources and cross-links.

Usage

Installation

Primary method (install the library, CLI, and MCP server from PyPI):

pip install smartcli-toolkit

Note: the PyPI distribution name is smartcli-toolkit, but the importable package is smartcli_core. After installation, you still need from smartcli_core import PtySession.

Alternative method (reproduce the full development environment from a source checkout):

git clone https://github.com/dwgx/SmartCLI
cd SmartCLI
pip install -r requirements.txt
pip install .

requirements.txt installs pyte, the MCP SDK, and pywinpty only on Windows (POSIX uses the standard library pty backend). pip install . installs smartcli_core as well as the smartcli-tui, smartcli-mcp, and smartcli-toolkit commands. The visual skills cmd-art and tui-ui are still available through python -m fx and python -m ui Run in place from the checkout directory.

Optional extra dependencies (real FIGlet fonts, raster images, authoritative cell widths — gracefully fall back to the standard library when missing):

pip install pyfiglet Pillow wcwidth

Windows note: set UTF-8 output before running any skill so box-drawing characters and CJK glyphs are encoded correctly:

set PYTHONUTF8=1

Quick start

30-second driving example: launch a real Python REPL (under a PTY), wait for the prompt (never blindly sleep), type content and read the screen back.

On Windows use --cmd "py -i -q". Replace the command with vim, htop or lazygit, and the same five verbs can drive them too.

Persistent session CLI

State is maintained between shell invocations:

smartcli-tui start --cmd "bash"
smartcli-tui send --text "ls\n"
smartcli-tui wait --regex "\$"
smartcli-tui screen
smartcli-tui close

On Windows use py -i -q as the subcommand. When checking out from source, replace smartcli-tui with python skills/drive-tui/scripts/tui.py.

MCP client

Already running an MCP client (Claude Code, Cursor, VS Code)? The same verbs as MCP tools, automatically attaching a per-session token.

Import the core directly

from smartcli_core import PtySession

Diagnostics

python -m smartcli_core prints the OS, Python, terminal, PTY backend and dependency versions.smartcli-tui doctor reports where the core is loaded from and whether the driving dependencies are present. Please include both outputs when submitting terminal-sensitive bugs.

Only three Claude Code skills needed

Download one zip, unzip and it works — no git, pip or marketplace needed. This provides cmd-art, drive-tui and tui-ui (309 KiB in total). cmd-art and tui-ui only need CPython 3.10+ to work (verified in a bare virtual environment, all 30 effects and 17 components load). drive-tui additionally needs pyte, provided by the PyPI installation above. Or install all three via the plugin marketplace:/plugin marketplace add dwgx/SmartCLI.

When to use

  • Let AI agents drive real interactive terminal programs (editors, system monitors, Git clients, etc.).
  • Create visual effects and animations in the terminal.
  • Build cell-exact terminal user interfaces.
  • Integrate into clients such as Claude Code, Cursor, VS Code via MCP.
  • Automation tasks that need awareness of terminal screen state (such as highlighted lines, alternate screen differences).

Limitations

  • Requires Python 3.10 or higher.
  • The screen model is verified, but still has known boundaries, see LIMITATIONS.md for details.
  • The verification evidence tree (formerly the verification/ directory) was archived on 2026-10-01 and is no longer part of this repository, nor distributed with the package.
  • Some waiting capabilities (subprocess exit detection) are optional and disabled by default.
  • Three core capabilities (screen revision wait baseline, terminal mode registry, session event log) are library-only and not on the CLI or MCP surface.
  • License: MIT.

Platform and dependencies

  • Local development runs on Windows via ConPTY (pywinpty), target programs can run under a POSIX pty or tmux.
  • Verified dependency versions (Windows 11, CPython 3.14.6): pyte 0.8.2, pywinpty 3.0.5, pyfiglet 1.0.4, Pillow 12.2.0, wcwidth 0.8.1.

Project structure

  • README-USAGE.md: complete usage cheat sheet.
  • knowledge/INDEX.md: knowledge graph (140+ .md files).
  • AGENTCLI-VALIDATION.md: agent CLI control test matrix.
  • CHANGELOG.md: release history.
  • LICENSE: MIT license.
Up/Down to navigate · Enter to open · ESC to closeBrowse all tools