Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,14 @@ All notable changes to SkillEvaluator are documented in this file.
include accessible descriptions, links to data tables and visible fallbacks
when canvas initialization is unavailable; Tier 1 reports omit chart assets.

- Root help shows the SkillEvaluator wordmark in more terminals: the
one-line wordmark still needs 115 columns, 76-114 columns now get the same
letters stacked (SKILL over EVALUATOR), and 60-75 columns get a two-row
wordmark. Narrower terminals keep the plain title. A wordmark that the
terminal's output encoding cannot print is skipped: gbk and big5hkscs lack
the half blocks of the two-row one, so they get the plain title at 60-75
columns.

- Separate HTML Tier 2 evidence into within-skill and across-skill comparisons,
with recorded completion, duplicate, affected-path, and catalog counts. Keep
skipped or unavailable comparisons distinct from completed zero-match scans.
Expand Down
43 changes: 34 additions & 9 deletions src/skillevaluator/cli_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,33 @@
_INDENT = (0, 0, 0, 2)

# ANSI Shadow lettering, stored as text so no font dependency is needed at runtime.
# Keep the full letter shapes; smaller terminals get a plain title, not squeezed art.
# Narrower terminals get the same letters stacked, then a two-row wordmark, then a plain title.
_WORDMARK = """███████╗██╗ ██╗██╗██╗ ██╗ ███████╗██╗ ██╗ █████╗ ██╗ ██╗ ██╗ █████╗ ████████╗ ██████╗ ██████╗
██╔════╝██║ ██╔╝██║██║ ██║ ██╔════╝██║ ██║██╔══██╗██║ ██║ ██║██╔══██╗╚══██╔══╝██╔═══██╗██╔══██╗
███████╗█████╔╝ ██║██║ ██║ █████╗ ██║ ██║███████║██║ ██║ ██║███████║ ██║ ██║ ██║██████╔╝
╚════██║██╔═██╗ ██║██║ ██║ ██╔══╝ ╚██╗ ██╔╝██╔══██║██║ ██║ ██║██╔══██║ ██║ ██║ ██║██╔══██╗
███████║██║ ██╗██║███████╗███████╗ ███████╗ ╚████╔╝ ██║ ██║███████╗╚██████╔╝██║ ██║ ██║ ╚██████╔╝██║ ██║
╚══════╝╚═╝ ╚═╝╚═╝╚══════╝╚══════╝ ╚══════╝ ╚═══╝ ╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝"""

_WORDMARK_STACKED = "\n".join(
[line[:35].rstrip() for line in _WORDMARK.splitlines()] + [line[39:].rstrip() for line in _WORDMARK.splitlines()]
)

_WORDMARK_SMALL = """█▀ █▄▀ █ █ █ █▀▀ █ █ ▄▀█ █ █ █ ▄▀█ ▀█▀ █▀█ █▀█
▄█ █ █ █ █▄▄ █▄▄ ██▄ ▀▄▀ █▀█ █▄▄ █▄█ █▀█ █ █▄█ █▀▄"""

# Narrowest terminal that gets any wordmark. The version line can be as wide as the small
# one, so fitting alone would show it at 58-59 columns, where the plain title is intended.
_WORDMARK_MIN_WIDTH = 60


def _encodes(text: str, encoding: str) -> bool:
try:
text.encode(encoding)
except UnicodeEncodeError:
return False
return True


def _welcome_banner(command: click.Command, ctx: click.Context, *, width: int) -> RenderableType | None:
"""Brand interactive root help without adding output to command execution."""
Expand All @@ -69,16 +88,22 @@ def _welcome_banner(command: click.Command, ctx: click.Context, *, width: int) -
):
return None

try:
_WORDMARK.encode(sys.stdout.encoding or "utf-8")
supports_blocks = True
except UnicodeEncodeError:
supports_blocks = False
encoding = sys.stdout.encoding or "utf-8"
tagline = "Static checks · Deduplication · Live evaluation"
if supports_blocks and width >= max(map(len, _WORDMARK.splitlines())):
heading = Text(_WORDMARK, style="bold #76b900")
subtitle = f"v{__version__} · {tagline}"
wordmark = next(
(
art
for art in (_WORDMARK, _WORDMARK_STACKED, _WORDMARK_SMALL)
# Each art needs its own glyphs: gbk and big5hkscs take the full letters but not the half blocks.
if _encodes(art, encoding) and width >= max(_WORDMARK_MIN_WIDTH, len(subtitle), *map(len, art.splitlines()))
),
None,
)
if wordmark is not None:
heading = Text(wordmark, style="bold #76b900")
heading.highlight_regex(r"[╔╗╚╝═║]+", style="dim #76b900")
lines = [Text(""), heading, Text(""), Text(f"v{__version__} · {tagline}", style="dim")]
lines = [Text(""), heading, Text(""), Text(subtitle, style="dim")]
else:
lines = [Text(f"SKILLEVALUATOR v{__version__}", style="bold #76b900"), Text(tagline, style="dim")]
return Group(*lines)
Expand Down
45 changes: 44 additions & 1 deletion tests/test_cli_banner.py
Comment thread
devin-ai-integration[bot] marked this conversation as resolved.
Resolved
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

"""The welcome banner must not change the CLI's output contracts."""

import io
import os
import shutil
import sys
Expand Down Expand Up @@ -47,7 +48,29 @@ def test_interactive_root_help_has_wordmark_and_installed_version(terminal, monk
assert all(len(line) <= 80 for line in help_text.splitlines())


@pytest.mark.parametrize("formatter_width,terminal_width", [(78, 40), (78, 80), (78, 114)])
@pytest.mark.parametrize("terminal_width", [76, 114])
def test_medium_help_stacks_the_full_wordmark(terminal, monkeypatch, terminal_width):
monkeypatch.setattr(shutil, "get_terminal_size", lambda: os.terminal_size((terminal_width, 40)))
banner = root_help(78).split("Usage:", 1)[0]

assert len([line for line in banner.splitlines() if "█" in line]) == 10
assert "╚══════╝" in banner
assert f"v{__version__}" in banner
assert all(len(line) <= terminal_width for line in banner.splitlines())


@pytest.mark.parametrize("terminal_width", [60, 75])
def test_small_help_uses_two_row_wordmark(terminal, monkeypatch, terminal_width):
monkeypatch.setattr(shutil, "get_terminal_size", lambda: os.terminal_size((terminal_width, 40)))
banner = root_help(78).split("Usage:", 1)[0]

assert len([line for line in banner.splitlines() if "█" in line]) == 2
assert "╚══════╝" not in banner
assert f"v{__version__}" in banner
assert all(len(line) <= terminal_width for line in banner.splitlines())


@pytest.mark.parametrize("formatter_width,terminal_width", [(78, 40), (78, 57), (78, 58), (78, 59)])
def test_narrow_help_uses_compact_banner(terminal, monkeypatch, formatter_width, terminal_width):
monkeypatch.setattr(shutil, "get_terminal_size", lambda: os.terminal_size((terminal_width, 40)))
banner = root_help(formatter_width).split("Usage:", 1)[0]
Expand All @@ -58,6 +81,26 @@ def test_narrow_help_uses_compact_banner(terminal, monkeypatch, formatter_width,
assert all(len(line) <= terminal_width for line in banner.splitlines())


class _TtyTextStream(io.TextIOWrapper):
def isatty(self):
return True


@pytest.mark.parametrize(
"encoding,terminal_width,art_rows",
[("gbk", 70, 0), ("big5hkscs", 70, 0), ("gbk", 80, 10), ("gbk", 120, 5), ("cp437", 70, 2)],
)
def test_wordmark_must_fit_the_stdout_encoding(terminal, monkeypatch, encoding, terminal_width, art_rows):
monkeypatch.setattr(sys, "stdout", _TtyTextStream(io.BytesIO(), encoding=encoding))
monkeypatch.setattr(shutil, "get_terminal_size", lambda: os.terminal_size((terminal_width, 40)))
banner = root_help(78).split("Usage:", 1)[0]

assert len([line for line in banner.splitlines() if "█" in line]) == art_rows
assert f"v{__version__}" in banner
# The two-row art adds half blocks that gbk and big5hkscs lack; printing it would raise.
banner.encode(encoding)


@pytest.mark.parametrize("redirected", ["stdout", "stderr"])
def test_redirected_stream_suppresses_banner_even_with_forced_color(terminal, monkeypatch, redirected):
monkeypatch.setattr(getattr(sys, redirected), "isatty", lambda: False)
Expand Down
Loading