dwgx/SmartCLI / skills/tui-ui
tui-ui
VerifiedDesign web-like user interfaces in the terminal and inside tmux with a cell-grid Canvas, CSS-like box model, flexbox/grid layout, and 17 reusable widgets such as Panel, Table, Card, ProgressBar, Meter, Tabs, Tree, Badge, Banner, and a braille line chart. Use when an agent needs a dashboard, panel, table, status page, TUI layout, tmux dashboard, screenshot-driven CLI/TUI replica, ANSI frame, truecolor render, pyte PNG screenshot smoke test, wide-character alignment, or a new terminal widget.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 18.0 KB |
| _selftest_effort_widgets.py | script | 4.9 KB |
| _shot_effort_widgets.py | script | 4.7 KB |
| examples/effort_selector.py | script | 22.1 KB |
| references/HARD-LESSONS.md | markdown | 7.5 KB |
| references/RENDERING-MODEL.md | markdown | 5.4 KB |
| references/effort-replica-spec.md | markdown | 11.8 KB |
| self_test.py | script | 5.7 KB |
| ui/__init__.py | script | 1.4 KB |
| ui/__main__.py | script | 183 B |
| ui/box.py | script | 9.2 KB |
| ui/cli.py | script | 8.7 KB |
| ui/core.py | script | 26.0 KB |
| ui/field.py | script | 19.7 KB |
| ui/layout.py | script | 11.1 KB |
| ui/raster.py | script | 27.9 KB |
| ui/registry.py | script | 2.7 KB |
| ui/sixel.py | script | 9.2 KB |
| ui/widgets.py | script | 24.3 KB |
| ui/widgets_ext/__init__.py | script | 207 B |
| ui/widgets_ext/braille_chart.py | script | 6.7 KB |
| ui/widgets_ext/fuzzy_filter_list.py | script | 5.0 KB |
| ui/widgets_ext/gradient_rule.py | script | 3.5 KB |
| ui/widgets_ext/preview_pane.py | script | 3.1 KB |
| ui/widgets_ext/radial_glow.py | script | 8.8 KB |
| ui/widgets_ext/slider_track.py | script | 7.7 KB |
ui/widgets_ext/gradient_rule.py
View on GitHub"""gradient_rule.py — a SOLID horizontal rule filled with a truecolor gradient.
WHY
---
The plain :class:`~ui.widgets.Rule` draws one flat color. Real product chrome
(the terminal ``/effort``-style divider, section headers, brand bars) wants a rule
whose color *sweeps* across its width — an indigo→violet→lavender wash on a
single unbroken ``─`` line. Codex botched this by falling back to a gray dashed
``--------`` rule; the fix is a genuinely SOLID line (U+2500) whose EVERY CELL
gets its own interpolated color, so the seam reads as one smooth bar, not a
row of dashes.
This widget is the reusable primitive for that: give it a list of color stops
and it lays a solid glyph across the region, sampling the multi-stop gradient
per cell via :func:`ui.core.gradient`. Truecolor, wide-char-safe (the fill glyph
is width-1 by contract), drop-in for any Box/VStack.
Params
------
* ``stops`` : sequence of color specs (``'#RRGGBB'`` or ``(r,g,b)``), >=1.
The gradient runs left→right evenly across all stops.
* ``char`` : the fill glyph (default solid ``─``). Must be a 1-cell glyph.
* ``width`` : optional fixed cell width; otherwise fills the region handed down.
* ``attrs`` : optional text attrs (e.g. ``core.BOLD``); default 0 (full-bright).
* ``vertical``: if True, sweep top→bottom over the region height instead.
"""
from __future__ import annotations
from typing import Optional, Sequence
from .. import core
from ..core import Canvas, parse_color
from ..registry import register
from ..widgets import Widget
# The measured violet sweep from the /effort main rule (indigo → violet → lilac).
EFFORT_VIOLET_STOPS = ("#4C5BD4", "#7C5CE0", "#A78BFA")
@register
class GradientRule(Widget):
"""A solid horizontal (or vertical) rule with a per-cell multi-stop gradient."""
key = "gradient_rule"
summary = "Solid rule filled with a per-cell truecolor gradient"
def __init__(self, stops: Sequence = EFFORT_VIOLET_STOPS, *, char: str = "─",
width: Optional[int] = None, attrs: int = 0,
vertical: bool = False, theme=None):
super().__init__(theme)
self.stops = tuple(parse_color(s) for s in stops) or (self.theme.accent,)
self.char = char[:1] if char else "─"
self.width = width # honored by parent stacks when set
self.attrs = attrs
self.vertical = vertical
# -- gradient sampling -------------------------------------------------
def color_at(self, i: int, n: int) -> core.RGB:
"""RGB for cell *i* of *n* along the sweep (public: callers can reuse it)."""
t = 0.0 if n <= 1 else i / (n - 1)
return core.gradient(self.stops, t)
def measure(self, avail_w, avail_h):
if self.vertical:
return (1, avail_h if self.width is None else self.width)
return (self.width or max(2, avail_w), 1)
def render(self, region_w, region_h):
cv = Canvas(region_w, max(1, region_h), bg=self.theme.bg)
if self.vertical:
n = cv.h
for y in range(n):
cv.set(0, y, self.char, fg=self.color_at(y, n),
bg=self.theme.bg, attrs=self.attrs)
return cv
n = region_w
for x in range(n):
cv.set(x, 0, self.char, fg=self.color_at(x, n),
bg=self.theme.bg, attrs=self.attrs)
return cv
@classmethod
def sample(cls, theme):
# A vivid three-stop violet bar reads clearly in the gallery/demo.
return cls(EFFORT_VIOLET_STOPS, theme=theme)
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 321k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 321k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 321k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |