MCPcopy
hub / github.com/usestrix/strix / build_live_stats_text

Function build_live_stats_text

strix/interface/utils.py:328–368  ·  view source on GitHub ↗
(report_state: Any)

Source from the content-addressed store, hash-verified

326
327
328def build_live_stats_text(report_state: Any) -> Text:
329 stats_text = Text()
330 if not report_state:
331 return stats_text
332
333 model = load_settings().llm.model or "unknown"
334 stats_text.append("Model ", style="dim")
335 stats_text.append(str(model), style="white")
336 stats_text.append("\n")
337
338 vuln_count = len(report_state.vulnerability_reports)
339 stats_text.append("Vulnerabilities ", style="dim")
340 stats_text.append(f"{vuln_count}", style="white")
341 stats_text.append("\n")
342 if vuln_count > 0:
343 severity_counts = {"critical": 0, "high": 0, "medium": 0, "low": 0, "info": 0}
344 for report in report_state.vulnerability_reports:
345 severity = report.get("severity", "").lower()
346 if severity in severity_counts:
347 severity_counts[severity] += 1
348
349 severity_parts = []
350 for severity in ["critical", "high", "medium", "low", "info"]:
351 count = severity_counts[severity]
352 if count > 0:
353 severity_color = get_severity_color(severity)
354 severity_text = Text()
355 severity_text.append(f"{severity.upper()}: ", style=severity_color)
356 severity_text.append(str(count), style=f"bold {severity_color}")
357 severity_parts.append(severity_text)
358
359 for i, part in enumerate(severity_parts):
360 stats_text.append(part)
361 if i < len(severity_parts) - 1:
362 stats_text.append(" | ", style="dim white")
363
364 stats_text.append("\n")
365
366 _build_llm_usage_stats(stats_text, report_state, live=True)
367
368 return stats_text
369
370
371def build_tui_stats_text(report_state: Any) -> Text:

Callers 1

create_live_statusFunction · 0.85

Calls 3

load_settingsFunction · 0.90
get_severity_colorFunction · 0.85
_build_llm_usage_statsFunction · 0.85

Tested by

no test coverage detected