DEV Community

Cover image for forma: AI‑Generated Terminal Prompt Animations on GitHub
vlad Baklytskyi
vlad Baklytskyi

Posted on

forma: AI‑Generated Terminal Prompt Animations on GitHub

Terminal eye candy is usually a hardcoded GIF or a 400-line bash script nobody wants to maintain. forma takes a different swing: describe the vibe in plain English, let a model compile it into a scene, and let a deterministic renderer paint it into your terminal at frame rate.

TL;DR: wrong-nebula/forma is a trending open-source project for AI-driven terminal prompt animations. The interesting engineering isn't the prompt — it's the hard boundary between a slow, non-deterministic LLM "compile" step and a fast, seeded render loop that never touches the network. Get that boundary wrong and you get flicker, torn frames, and a $40 API bill from an idle shell.

The Problem With Current AI Workflows

The failure mode I keep seeing in generative-terminal tools is putting the model inside the animation loop. Someone wires an LLM call to "generate the next frame," and the arithmetic kills it immediately: a 60 FPS loop has a 16.6 ms budget per frame, and even a fast small model streaming 20 tokens is a 200–600 ms round trip. You are three orders of magnitude off.

The second failure mode is subtler: non-reproducibility. Generative art that can't be replayed isn't art tooling, it's a slot machine. If your seed lives in a model's sampling temperature instead of in a file, you can never render the same scene twice, diff two variants, or commit a look to a repo.

The third is terminal reality. A TUI that looks perfect in Kitty on Linux can shred itself in tmux, in a CI log, or on a legacy conhost window — because the author assumed truecolor SGR and cursor addressing that the target emulator doesn't honor.

How the Architecture Actually Works

I haven't audited every line of forma, so treat this as the pipeline shape any tool in this class must converge on — verify against the source before you build on it. The load-bearing idea is compile once, render deterministically.

  ┌──────────────┐   intent (natural language)
  │  user / CLI  │──────────────────────────────┐
  └──────────────┘                              ▼
                                    ┌───────────────────────┐
                                    │  LLM scene compiler   │  ~0.5–3 s, ONCE
                                    │  text → JSON scene    │  schema-validated
                                    └───────────┬───────────┘
                                                │ scene.json (seed, palette, motion)
                                                ▼
   SIGWINCH ──▶ ┌──────────────┐    ┌───────────────────────┐
                │ term caps /  │───▶│  deterministic frame  │  16.6 ms budget
                │ size probe   │    │  evaluator f(t, seed) │  ZERO network
                └──────────────┘    └───────────┬───────────┘
                                                │ cell grid [rows][cols]
                                                ▼
                                    ┌───────────────────────┐
                                    │  diff → ANSI encoder  │  dirty cells only
                                    └───────────┬───────────┘
                                                │ write(2) → PTY
                                                ▼
                                          terminal emulator
Enter fullscreen mode Exit fullscreen mode

1. Scene compiler (LLM, offline path). The model's job is parameter synthesis, not pixels. It emits a constrained JSON document — seed, palette, motion field, glyph set, density — validated against a schema with a retry-on-invalid loop. Constrain the output with a JSON schema or grammar, not a polite request in the system prompt. Cache the result keyed on hash(intent + model + schema_version) so the same phrase never re-bills you.

2. Capability probe. Read TERM, COLORTERM, and isatty(); query size via ioctl(TIOCGWINSZ); install a SIGWINCH handler. Degrade deliberately: truecolor → 256 → 16 → monochrome glyphs. If stdout isn't a TTY, emit nothing or a single static frame. This one check is the difference between a tool people keep and one they uninstall.

3. Frame evaluator. Pure function f(t, seed) → grid. Same seed, same t, same grid — on any machine. This is what makes scenes committable and reviewable.

4. Diff + ANSI encoder. Keep two buffers, compare cells, and emit only what changed: \x1b[<row>;<col>H to position, \x1b[38;2;R;G;Bm for truecolor. Full-screen repaints at 60 FPS on a 200×50 grid is ~600 KB/s of escape codes; dirty-cell diffing typically cuts that by 90%+ and eliminates tearing. Wrap the whole session in the alternate screen (\x1b[?1049h) and hide the cursor (\x1b[?25l), with restore in a finally/atexit and a signal handler — otherwise a Ctrl-C leaves the user's shell cursorless.

Quick Start (Copy-Paste Setup)

Flag names below are the shape to look for; run --help and trust the source over any snippet, including this one.

git clone https://github.com/wrong-nebula/forma.git
cd forma

# Detect the stack before you install anything.
ls -1 | grep -Ei 'pyproject|requirements|package.json|Cargo.toml|go.mod'
cat README.md | head -60
Enter fullscreen mode Exit fullscreen mode

Python path:

python3 -m venv .venv && source .venv/bin/activate
pip install -e .            # or: pip install -r requirements.txt
forma --help
Enter fullscreen mode Exit fullscreen mode

Node path:

corepack enable && pnpm install
pnpm run build && pnpm start -- --help
Enter fullscreen mode Exit fullscreen mode

Keep credentials out of your shell history and out of the repo:

export FORMA_API_KEY="$(pass show ai/anthropic)"   # or your secret manager
printf '.venv/\n.env\n*.scene.cache.json\n' >> .gitignore
Enter fullscreen mode Exit fullscreen mode

A scene descriptor worth committing looks roughly like this — the point is that it's small, diffable, and replayable without an API key:

{
  "seed": 20240917,
  "palette": ["#0b0f14", "#3ddc97", "#f5f7fa"],
  "motion": { "kind": "drift", "hz": 0.25 },
  "glyphs": " .:-=+*#%@",
  "fps": 30,
  "color_mode": "auto"
}
Enter fullscreen mode Exit fullscreen mode

Smoke-test the degradation path before you demo it anywhere:

TERM=xterm-256color forma --scene scene.json
forma --scene scene.json | cat        # must not spew raw escapes
tmux new-session 'forma --scene scene.json'
Enter fullscreen mode Exit fullscreen mode

Real-World Use Cases & Honest Trade-Offs

Win 1 — reviewable generative assets. Because the scene is a seeded JSON file, a "look" becomes a PR diff. Designers and CLI authors can iterate on palette and motion in code review instead of trading screen recordings.

Win 2 — zero-cost idle. The LLM runs once at authoring time. An ambient animation on a dashboard box or a kiosk consumes CPU, not tokens. That's the correct cost topology for anything long-running.

Win 3 — a genuinely good ANSI test harness. Tools like this stress cursor addressing, resize handling, and color fallback harder than most unit suites. I've found real emulator bugs by running cell-based renderers across Kitty, Alacritty, WezTerm, and tmux.

Limitation 1 — emulator variance is not solved, only managed. tmux passthrough, SSH latency, Windows legacy consoles, and multiplexer color quantization all produce different output. Budget real time for a compatibility matrix; "works on my Kitty" is not a release criterion.

Limitation 2 — this is not your shell prompt. A PS1/precmd hook has a ~50 ms tolerance before humans perceive lag. Anything with a network call or a 30 FPS loop belongs in a dedicated pane or a screensaver mode, never in the interactive prompt path. Also: cell-based animation is hostile to screen readers, so ship a --static/--no-motion flag and mean it.

📡 Daily drops: I post one vetted open-source AI repo a day on VibeNode AI on Telegram — plus Claude Code hooks and ready-to-import n8n JSON workflows. Search #Drop09 in the channel for the companion notes and config files for this one. No drip campaigns, just the artifacts.

Direct Links & Daily Open-Source Drops

Your turn: where do you draw the line between the LLM and the render loop in your own tools — do you cache a compiled artifact like a scene file, or keep the model in the loop and eat the latency? And has anyone shipped cell-based animation that behaves correctly under tmux and legacy conhost without a fork in the codepath? I'd genuinely like to see that diff.

Top comments (0)