Multi-tier framework for evaluating AI agent skills and plugins with quality gates, security scanning, harness compatibility checks, semantic overlap detection, synthetic evaluation dataset generation, and live agent evaluation that measures how skills affect agent behavior. Ships reusable CI templates that bring every check to any repository.
Python agent-evaluationagent-pluginsagent-securityagent-skillsagentic-aibenchmarkci-templatesclaude-codecodexevaluateevaluationharnesspluginplugin-evaluationsecurity-scannerskill-evalskill-evaluationskill-evaluatorskill-gap-analysisskills
fix(reporting): strip terminal controls from catalog and view output (#175)
Narendran Raghavan6670c9010525
diff --git a/src/skillevaluator/cli.py b/src/skillevaluator/cli.pyindex 7a7d76e6..baf91933 100644--- a/src/skillevaluator/cli.py+++ b/src/skillevaluator/cli.py@@ -57,7 +57,7 @@ from skillevaluator.tier1.commands import ()from skillevaluator.tier3_environments import HARBOR_ENVIRONMENTSfrom skillevaluator.tier_group import TierGroup-from skillevaluator.utils.rich_markup import escape_markup+from skillevaluator.utils.rich_markup import escape_markup, strip_terminal_controlsfrom skillevaluator.utils.tier2_paths import (is_link_or_reparse,paths_refer_to_same_location,@@ -788,7 +788,7 @@ def _print_catalog_divider(index: int, total: int, name: str) -> None:("━━ ", FAINT),(f"skill {index}/{total}", f"bold {GREEN}"),(" · ", FAINT),- (name, "bold"),+ (strip_terminal_controls(name), "bold"),(" ", ""),)fill = max(0, width - label.cell_len)@@ -824,7 +824,11 @@ def _print_catalog_summary(total: int, failures: list[tuple[str, str]], reports_)lines: list = [headline, Text()]for name, reason in failures[:10]:- lines.append(Text.assemble((" ✗ ", f"bold {RED}"), (f"{name:<28}", TEXT), (reason[:56], MUTED)))+ # Strip before padding and truncating, so controls neither print nor count toward the widths.+ name_text = f"{strip_terminal_controls(name):<28}"+ lines.append(+ Text.assemble((" ✗ ", f"bold {RED}"), (name_text, TEXT), (strip_terminal_controls(reason)[:56], MUTED))+ )if len(failures) > 10:lines.append(Text(f" … {len(failures) - 10} more — see per-skill reports", style=MUTED))body = Group(*lines)@@ -848,7 +852,8 @@ def _print_catalog_summary(total: int, failures: list[tuple[str, str]], reports_title_align="left",))- console_.print(Text.assemble((" reports ", MUTED), (f"{reports_root}/<skill>/", MUTED)))+ reports = f"{strip_terminal_controls(str(reports_root))}/<skill>/"+ console_.print(Text.assemble((" reports ", MUTED), (reports, MUTED)))CATALOG_SUMMARY_FILENAME = "catalog-summary.json"@@ -1130,7 +1135,7 @@ def _validate_catalog(if failures:raise click.ClickException(f"{len(failures)}/{len(skill_dirs)} skills failed validation: "- + ", ".join(name for name, _reason in failures)+ + ", ".join(strip_terminal_controls(name) for name, _reason in failures))@@ -1191,7 +1196,7 @@ def _validate_catalog_parallel(if failures:raise click.ClickException(f"{len(failures)}/{len(skill_dirs)} skills failed validation: "- + ", ".join(name for name, _reason in failures)+ + ", ".join(strip_terminal_controls(name) for name, _reason in failures))diff --git a/src/skillevaluator/reporting/console_ui.py b/src/skillevaluator/reporting/console_ui.pyindex 74f71f24..e8f0b78a 100644--- a/src/skillevaluator/reporting/console_ui.py+++ b/src/skillevaluator/reporting/console_ui.py@@ -18,6 +18,10 @@ once, statically, as it completes.``validate --verbose`` bypasses this module entirely and keeps the historicalfull-detail stream.++Skill names, finding messages, failure reasons and paths are untrusted. The+view strips terminal control sequences from every string it renders, and its+consoles are created with ``emoji=False`` so ``:name:`` codes print literally."""from __future__ import annotations@@ -33,6 +37,8 @@ from rich.live import Livefrom rich.panel import Panelfrom rich.text import Text+from skillevaluator.utils.rich_markup import strip_terminal_controls+if TYPE_CHECKING:from skillevaluator.models.result import ValidationResult@@ -136,7 +142,7 @@ def make_view_console(file: TextIO | None = None) -> Console:engine-capture window (``redirect_stdout``) or the output lands in thecapture buffer -- pass the already-pinned view console's file instead."""- return Console(highlight=False, file=file if file is not None else sys.stdout)+ return Console(highlight=False, emoji=False, file=file if file is not None else sys.stdout)def _pill(label: str, color: str, ink: str = INK) -> Text:@@ -226,7 +232,7 @@ class ValidateView:# Pin the output stream at construction: the Tier 3 engine's narration# is captured via redirect_stdout, and the view must keep writing to# the real stream (or the test runner's buffer) while that happens.- self.console = console or Console(highlight=False, file=sys.stdout)+ self.console = console or Console(highlight=False, emoji=False, file=sys.stdout)# Design width is 98 columns; degrade gracefully on narrower terminals.self.width = max(60, min(WIDTH, self.console.width))self.blocks = [TierBlock(number=number, name=name, caption=caption) for number, name, caption in tiers]@@ -333,7 +339,7 @@ class ValidateView:("skillevaluator", f"bold {TEXT}"),(f" {self.command}", MUTED),)- right = _pill(self.skill, GREEN)+ right = _pill(strip_terminal_controls(self.skill), GREEN)pad = max(1, inner - left.cell_len - right.cell_len)return Panel(left + Text(" " * pad) + right,@@ -415,9 +421,9 @@ class ValidateView:for row in block.rows:t = Text()t.append(f"{row.glyph} ", style=row.glyph_style)- t.append(f"{row.label:<{LABEL}}", style=MUTED)+ t.append(f"{strip_terminal_controls(row.label):<{LABEL}}", style=MUTED)for chunk, style in row.segments:- t.append(chunk, style=style)+ t.append(strip_terminal_controls(chunk), style=style)lines.append(t)body = Group(*lines) if lines else Text("…", style=FAINT)return Panel(@@ -433,27 +439,32 @@ class ValidateView:)def _verdict_panel(self, verdict: Verdict) -> Panel:+ headline = strip_terminal_controls(verdict.headline)if verdict.passed:body = _pill("✓ PASS", GREEN) + Text.assemble(- (" ", ""), (verdict.headline, f"bold {TEXT}"), (" · exit 0", MUTED)+ (" ", ""), (headline, f"bold {TEXT}"), (" · exit 0", MUTED))return Panel(body, box=box.ROUNDED, border_style=GREEN, width=self.width, padding=(0, 2))line1 = _pill("✗ FAIL", RED, ink="#1C0605") + Text.assemble(- (" ", ""), (verdict.headline, f"bold {TEXT}"), (" · exit 1", MUTED)+ (" ", ""), (headline, f"bold {TEXT}"), (" · exit 1", MUTED))parts: list = [line1]if verdict.fix:fix = Text.assemble(("fix ", f"bold {MUTED}"))for chunk, style in verdict.fix:- fix.append(chunk, style=style)+ fix.append(strip_terminal_controls(chunk), style=style)parts.extend([Text(), fix])if verdict.rerun:- parts.append(Text.assemble((" ", ""), (verdict.rerun, GREEN)))+ parts.append(Text.assemble((" ", ""), (strip_terminal_controls(verdict.rerun), GREEN)))return Panel(Group(*parts), box=box.ROUNDED, border_style=RED, width=self.width, padding=(0, 2))def _footer_lines(self):for label, target in self.links:- yield Text.assemble((" ", ""), (f"{label:<{LABEL}}", MUTED), (target, MUTED))+ yield Text.assemble(+ (" ", ""),+ (f"{strip_terminal_controls(label):<{LABEL}}", MUTED),+ (strip_terminal_controls(target), MUTED),+ )def _refresh(self) -> None:if self._live is not None:diff --git a/tests/reporting/test_rich_markup_escaping.py b/tests/reporting/test_rich_markup_escaping.pyindex be780b69..615b9aa8 100644--- a/tests/reporting/test_rich_markup_escaping.py+++ b/tests/reporting/test_rich_markup_escaping.py@@ -57,6 +57,20 @@ CONTROL_PAYLOADS = {_SGR = re.compile(r"\x1b\[[0-9;]*m")_CONTROL = re.compile(r"[\x00-\x08\x0b-\x1f\x7f-\x9f]")+# Untrusted text (a skill name or failure reason) with control sequences between+# visible words and an emoji code, and exactly what the terminal must show for it.+HOSTILE_TEXT = (+ "alpha\x1b[2J" # clear the screen+ "bravo\x1b]8;;https://evil.test/\x1b\\x\x1b]8;;\x1b\\" # OSC 8 hyperlink around "x"+ "charlie\x1bc" # RIS: full terminal reset+ "delta\x9b2J" # 8-bit CSI: only the C1 byte is a control character+ "echo :white_check_mark:"+)+HOSTILE_VISIBLE = "alphabravoxcharliedelta2Jecho :white_check_mark:"+# A path component cannot hold the OSC 8 URL's "/", and ":" is not valid in Windows file names.+HOSTILE_PATH_PART = "run\x1b[2J\x1bc\x9b2J"+HOSTILE_PATH_PART_VISIBLE = "run2J"+def _recording_console(width: int = 200) -> Console:# Tests that print absolute tmp paths pass a wider width so long paths do not wrap.@@ -74,6 +88,20 @@ def _terminal_text(output: str) -> str:return text+def _plain_output_env(monkeypatch: pytest.MonkeyPatch) -> None:+ """Keep the real consoles out of terminal mode, so Rich adds no escape sequences of its own."""+ monkeypatch.setenv("COLUMNS", "200")+ for name in ("FORCE_COLOR", "TTY_COMPATIBLE"):+ monkeypatch.delenv(name, raising=False)+++def _assert_no_controls_or_emoji(output: str) -> None:+ """No ESC, C1 or other control byte reaches the output, and emoji codes stay literal."""+ assert _CONTROL.search(output) is None, repr(output)+ assert "evil.test" not in output # the OSC 8 target goes with its sequence+ assert [glyph for glyph in EMOJI_GLYPHS if glyph in output] == []++def _quality_result(payload: str) -> ValidationResult:result = ValidationResult(validator_name="QUALITY", validator_description=f"Quality of {payload}")dimensions = {name: {"score": 90.0} for name in ("correctness", "discoverability", "reliability", "efficiency")}@@ -627,3 +655,109 @@ def test_rubric_progress_status_renders_skill_name_literally(assert all(isinstance(status, Text) for status in statuses)assert [status.plain for status in statuses] == [f"Evaluating {name} with LLM judge..."]+++def test_catalog_divider_and_scoreboard_strip_terminal_controls(+ capsys: pytest.CaptureFixture[str], monkeypatch: pytest.MonkeyPatch+) -> None:+ from skillevaluator import cli as cli_module++ _plain_output_env(monkeypatch)++ # Both print through the view console, which resolves sys.stdout per call.+ cli_module._print_catalog_divider(1, 2, HOSTILE_TEXT)+ cli_module._print_catalog_summary(+ 2,+ [(HOSTILE_TEXT, "validation failed"), ("plain-skill", HOSTILE_TEXT)],+ Path("reports") / HOSTILE_PATH_PART,+ )++ output = capsys.readouterr().out+ _assert_no_controls_or_emoji(output)+ assert f"skill 1/2 · {HOSTILE_VISIBLE}" in output+ assert f"✗ {HOSTILE_VISIBLE}validation failed" in output+ assert f"✗ {'plain-skill':<28}{HOSTILE_VISIBLE}" in output+ assert f"reports {Path('reports') / HOSTILE_PATH_PART_VISIBLE}/<skill>/" in output+++def test_validate_view_strips_terminal_controls(+ capsys: pytest.CaptureFixture[str], monkeypatch: pytest.MonkeyPatch+) -> None:+ from skillevaluator import cli as cli_module+ from skillevaluator.reporting.console_ui import ValidateView, detail_row, summarize_tier1++ _plain_output_env(monkeypatch)+ failing = ValidationResult(validator_name="SECURITY", validator_description="Security checks")+ failing.add_finding(+ Finding(+ category="SECURITY",+ severity=Severity.HIGH,+ check_name="mcp-least-privilege",+ message=HOSTILE_TEXT,+ file_path="SKILL.md",+ suggestion=HOSTILE_TEXT,+ )+ )+ # No console argument: the view prints through its own default console.+ view = ValidateView(+ skill=f"skill: {HOSTILE_TEXT}",+ tiers=[(1, "Static & Security", "static & security"), (3, "Live Agent Eval", "live agent eval")],+ )++ view.start()+ view.tier_start(0)+ _passed, rows = summarize_tier1([failing])+ view.tier_done(0, failed=True, rows=[*rows, detail_row("dataset", HOSTILE_TEXT)])+ view.tier_skip(1, HOSTILE_TEXT)+ cli_module._finish_pipeline_view(+ view,+ tier_gate_results=[failing],+ tier3_result=None,+ gate_failed=True,+ output_dir=Path("reports"),+ basename=HOSTILE_PATH_PART,+ report_formats=("html",),+ target_path=Path("skills") / HOSTILE_PATH_PART,+ agent_eval=False,+ )++ output = capsys.readouterr().out+ _assert_no_controls_or_emoji(output)+ assert f" skill: {HOSTILE_VISIBLE} " in output # header pill+ assert f"SECURITY — {HOSTILE_VISIBLE}" in output # failed check row+ assert f"{'dataset':<12}{HOSTILE_VISIBLE}" in output+ assert f"{'skipped':<12}{HOSTILE_VISIBLE}" in output+ assert f"fix {HOSTILE_VISIBLE}" in output+ assert f"skillevaluator validate {Path('skills') / HOSTILE_PATH_PART_VISIBLE}" in output # rerun hint+ assert f"{'report':<12}{Path('reports') / (HOSTILE_PATH_PART_VISIBLE + '.html')}" in output++[email protected](_WINDOWS, reason="Windows file names cannot contain control characters")+def test_catalog_run_strips_terminal_controls_from_skill_names_and_reasons(+ tmp_path: Path, monkeypatch: pytest.MonkeyPatch+) -> None:+ import click+ from click.testing import CliRunner++ from skillevaluator import cli as cli_module++ _plain_output_env(monkeypatch)+ skill_dir = tmp_path / "catalog" / HOSTILE_PATH_PART+ skill_dir.mkdir(parents=True)+ (skill_dir / "SKILL.md").write_text("---\nname: demo\ndescription: test\n---\n# Demo\n", encoding="utf-8")++ def _failing_validate(**_params: object) -> None:+ raise click.ClickException(HOSTILE_TEXT)++ # Only the per-skill run is replaced: the catalog loop, divider, scoreboard and exit error are real.+ monkeypatch.setattr(cli_module, "validate", _failing_validate)+ result = CliRunner().invoke(+ cli_module.cli,+ ["validate", str(tmp_path / "catalog"), "--no-llm", "--no-dedup", "--no-tier3", "-o", str(tmp_path / "out")],+ )++ assert result.exit_code == 1, result.output+ _assert_no_controls_or_emoji(result.output)+ assert f"skill 1/1 · {HOSTILE_PATH_PART_VISIBLE}" in result.output+ assert f"✗ {HOSTILE_PATH_PART_VISIBLE:<28}{HOSTILE_VISIBLE}" in result.output+ assert f"1/1 skills failed validation: {HOSTILE_PATH_PART_VISIBLE}" in result.output