empathy-framework 4.7.1__py3-none-any.whl → 4.8.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. {empathy_framework-4.7.1.dist-info → empathy_framework-4.8.0.dist-info}/METADATA +65 -2
  2. {empathy_framework-4.7.1.dist-info → empathy_framework-4.8.0.dist-info}/RECORD +73 -52
  3. {empathy_framework-4.7.1.dist-info → empathy_framework-4.8.0.dist-info}/WHEEL +1 -1
  4. {empathy_framework-4.7.1.dist-info → empathy_framework-4.8.0.dist-info}/entry_points.txt +2 -1
  5. {empathy_framework-4.7.1.dist-info → empathy_framework-4.8.0.dist-info}/top_level.txt +0 -1
  6. empathy_os/__init__.py +2 -0
  7. empathy_os/cache/hash_only.py +6 -3
  8. empathy_os/cache/hybrid.py +6 -3
  9. empathy_os/cli/__init__.py +128 -238
  10. empathy_os/cli/__main__.py +5 -33
  11. empathy_os/cli/commands/__init__.py +1 -8
  12. empathy_os/cli/commands/help.py +331 -0
  13. empathy_os/cli/commands/info.py +140 -0
  14. empathy_os/cli/commands/inspect.py +437 -0
  15. empathy_os/cli/commands/metrics.py +92 -0
  16. empathy_os/cli/commands/orchestrate.py +184 -0
  17. empathy_os/cli/commands/patterns.py +207 -0
  18. empathy_os/cli/commands/provider.py +93 -81
  19. empathy_os/cli/commands/setup.py +96 -0
  20. empathy_os/cli/commands/status.py +235 -0
  21. empathy_os/cli/commands/sync.py +166 -0
  22. empathy_os/cli/commands/tier.py +121 -0
  23. empathy_os/cli/commands/workflow.py +574 -0
  24. empathy_os/cli/parsers/__init__.py +62 -0
  25. empathy_os/cli/parsers/help.py +41 -0
  26. empathy_os/cli/parsers/info.py +26 -0
  27. empathy_os/cli/parsers/inspect.py +66 -0
  28. empathy_os/cli/parsers/metrics.py +42 -0
  29. empathy_os/cli/parsers/orchestrate.py +61 -0
  30. empathy_os/cli/parsers/patterns.py +54 -0
  31. empathy_os/cli/parsers/provider.py +40 -0
  32. empathy_os/cli/parsers/setup.py +42 -0
  33. empathy_os/cli/parsers/status.py +47 -0
  34. empathy_os/cli/parsers/sync.py +31 -0
  35. empathy_os/cli/parsers/tier.py +33 -0
  36. empathy_os/cli/parsers/workflow.py +77 -0
  37. empathy_os/cli/utils/__init__.py +1 -0
  38. empathy_os/cli/utils/data.py +242 -0
  39. empathy_os/cli/utils/helpers.py +68 -0
  40. empathy_os/{cli.py → cli_legacy.py} +27 -27
  41. empathy_os/cli_minimal.py +662 -0
  42. empathy_os/cli_router.py +384 -0
  43. empathy_os/cli_unified.py +38 -2
  44. empathy_os/memory/__init__.py +19 -5
  45. empathy_os/memory/short_term.py +14 -404
  46. empathy_os/memory/types.py +437 -0
  47. empathy_os/memory/unified.py +61 -48
  48. empathy_os/models/fallback.py +1 -1
  49. empathy_os/models/provider_config.py +59 -344
  50. empathy_os/models/registry.py +31 -180
  51. empathy_os/monitoring/alerts.py +14 -20
  52. empathy_os/monitoring/alerts_cli.py +24 -7
  53. empathy_os/project_index/__init__.py +2 -0
  54. empathy_os/project_index/index.py +210 -5
  55. empathy_os/project_index/scanner.py +45 -14
  56. empathy_os/project_index/scanner_parallel.py +291 -0
  57. empathy_os/socratic/ab_testing.py +1 -1
  58. empathy_os/workflows/__init__.py +31 -2
  59. empathy_os/workflows/base.py +349 -325
  60. empathy_os/workflows/bug_predict.py +8 -0
  61. empathy_os/workflows/builder.py +273 -0
  62. empathy_os/workflows/caching.py +253 -0
  63. empathy_os/workflows/code_review_pipeline.py +1 -0
  64. empathy_os/workflows/history.py +510 -0
  65. empathy_os/workflows/output.py +410 -0
  66. empathy_os/workflows/perf_audit.py +125 -19
  67. empathy_os/workflows/progress.py +324 -22
  68. empathy_os/workflows/routing.py +168 -0
  69. empathy_os/workflows/secure_release.py +1 -0
  70. empathy_os/workflows/security_audit.py +190 -0
  71. empathy_os/workflows/security_audit_phase3.py +328 -0
  72. empathy_os/workflows/telemetry_mixin.py +269 -0
  73. empathy_os/dashboard/__init__.py +0 -15
  74. empathy_os/dashboard/server.py +0 -941
  75. patterns/README.md +0 -119
  76. patterns/__init__.py +0 -95
  77. patterns/behavior.py +0 -298
  78. patterns/code_review_memory.json +0 -441
  79. patterns/core.py +0 -97
  80. patterns/debugging.json +0 -3763
  81. patterns/empathy.py +0 -268
  82. patterns/health_check_memory.json +0 -505
  83. patterns/input.py +0 -161
  84. patterns/memory_graph.json +0 -8
  85. patterns/refactoring_memory.json +0 -1113
  86. patterns/registry.py +0 -663
  87. patterns/security_memory.json +0 -8
  88. patterns/structural.py +0 -415
  89. patterns/validation.py +0 -194
  90. {empathy_framework-4.7.1.dist-info → empathy_framework-4.8.0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,410 @@
1
+ """Unified output formatting for workflows.
2
+
3
+ Provides consistent Rich-based output components for workflow results:
4
+ - WorkflowReport: Main report container with sections
5
+ - FindingsTable: Render findings as Rich Table or plain text
6
+ - MetricsPanel: Color-coded score display
7
+ - ReportSection: Individual report sections
8
+
9
+ Supports graceful fallback to plain text when Rich is unavailable.
10
+
11
+ Copyright 2025 Smart-AI-Memory
12
+ Licensed under Fair Source License 0.9
13
+ """
14
+
15
+ from __future__ import annotations
16
+
17
+ from dataclasses import dataclass, field
18
+ from typing import TYPE_CHECKING, Any
19
+
20
+ # Rich imports with fallback
21
+ try:
22
+ from rich.console import Console
23
+ from rich.panel import Panel
24
+ from rich.table import Table
25
+ from rich.text import Text
26
+
27
+ RICH_AVAILABLE = True
28
+ except ImportError:
29
+ RICH_AVAILABLE = False
30
+ Console = None # type: ignore
31
+ Panel = None # type: ignore
32
+ Table = None # type: ignore
33
+ Text = None # type: ignore
34
+
35
+ if TYPE_CHECKING:
36
+ from rich.console import Console as ConsoleType
37
+
38
+
39
+ # =============================================================================
40
+ # DATA CLASSES
41
+ # =============================================================================
42
+
43
+
44
+ @dataclass
45
+ class Finding:
46
+ """Individual finding from a workflow."""
47
+
48
+ severity: str # "high", "medium", "low", "info"
49
+ file: str
50
+ line: int | None = None
51
+ message: str = ""
52
+ code: str | None = None
53
+
54
+ @property
55
+ def severity_icon(self) -> str:
56
+ """Get icon for severity level."""
57
+ icons = {
58
+ "high": "[red]:x:[/red]" if RICH_AVAILABLE else "X",
59
+ "medium": "[yellow]:warning:[/yellow]" if RICH_AVAILABLE else "!",
60
+ "low": "[blue]:information:[/blue]" if RICH_AVAILABLE else "i",
61
+ "info": "[dim]o[/dim]" if RICH_AVAILABLE else "o",
62
+ }
63
+ return icons.get(self.severity.lower(), "o")
64
+
65
+ @property
66
+ def location(self) -> str:
67
+ """Get file:line location string."""
68
+ if self.line:
69
+ return f"{self.file}:{self.line}"
70
+ return self.file
71
+
72
+
73
+ @dataclass
74
+ class ReportSection:
75
+ """Individual section of a workflow report."""
76
+
77
+ title: str
78
+ content: Any # str, list[Finding], dict, or Rich renderable
79
+ collapsed: bool = False
80
+ style: str = "default" # "default", "success", "warning", "error"
81
+
82
+
83
+ @dataclass
84
+ class WorkflowReport:
85
+ """Main workflow report container."""
86
+
87
+ title: str
88
+ summary: str = ""
89
+ sections: list[ReportSection] = field(default_factory=list)
90
+ score: int | None = None
91
+ level: str = "info" # "info", "success", "warning", "error"
92
+ metadata: dict[str, Any] = field(default_factory=dict)
93
+
94
+ def add_section(
95
+ self,
96
+ title: str,
97
+ content: Any,
98
+ collapsed: bool = False,
99
+ style: str = "default",
100
+ ) -> None:
101
+ """Add a section to the report."""
102
+ self.sections.append(
103
+ ReportSection(title=title, content=content, collapsed=collapsed, style=style)
104
+ )
105
+
106
+ def render(self, console: ConsoleType | None = None, use_rich: bool = True) -> str:
107
+ """Render the report.
108
+
109
+ Args:
110
+ console: Rich Console instance (optional)
111
+ use_rich: Whether to use Rich formatting
112
+
113
+ Returns:
114
+ Rendered report as string (for plain text) or prints to console (for Rich)
115
+ """
116
+ if use_rich and RICH_AVAILABLE and console is not None:
117
+ self._render_rich(console)
118
+ return ""
119
+ return self._render_plain()
120
+
121
+ def _render_rich(self, console: ConsoleType) -> None:
122
+ """Render report using Rich."""
123
+ # Header with score
124
+ header_parts = [f"[bold]{self.title}[/bold]"]
125
+ if self.score is not None:
126
+ score_panel = MetricsPanel.render_score(self.score)
127
+ console.print(score_panel)
128
+
129
+ if self.summary:
130
+ console.print(f"\n{self.summary}\n")
131
+
132
+ # Sections
133
+ for section in self.sections:
134
+ self._render_section_rich(console, section)
135
+
136
+ def _render_section_rich(self, console: ConsoleType, section: ReportSection) -> None:
137
+ """Render a single section using Rich."""
138
+ border_style = {
139
+ "success": "green",
140
+ "warning": "yellow",
141
+ "error": "red",
142
+ "default": "blue",
143
+ }.get(section.style, "blue")
144
+
145
+ if isinstance(section.content, str):
146
+ console.print(
147
+ Panel(section.content, title=section.title, border_style=border_style)
148
+ )
149
+ elif isinstance(section.content, list) and all(
150
+ isinstance(f, Finding) for f in section.content
151
+ ):
152
+ table = FindingsTable(section.content).to_rich_table()
153
+ console.print(Panel(table, title=section.title, border_style=border_style))
154
+ elif isinstance(section.content, dict):
155
+ # Render dict as key-value table
156
+ table = Table(show_header=False, box=None)
157
+ table.add_column("Key", style="cyan")
158
+ table.add_column("Value")
159
+ for key, value in section.content.items():
160
+ table.add_row(str(key), str(value))
161
+ console.print(Panel(table, title=section.title, border_style=border_style))
162
+ else:
163
+ # Try to print directly (might be a Rich renderable)
164
+ try:
165
+ console.print(
166
+ Panel(section.content, title=section.title, border_style=border_style)
167
+ )
168
+ except Exception: # noqa: BLE001
169
+ # INTENTIONAL: Graceful fallback for unknown content types
170
+ console.print(f"\n[bold]{section.title}[/bold]")
171
+ console.print(str(section.content))
172
+
173
+ def _render_plain(self) -> str:
174
+ """Render report as plain text."""
175
+ lines = []
176
+ separator = "=" * 60
177
+
178
+ # Header
179
+ lines.append(separator)
180
+ lines.append(self.title.upper())
181
+ lines.append(separator)
182
+
183
+ if self.score is not None:
184
+ level = MetricsPanel.get_level(self.score)
185
+ lines.append(f"Score: {self.score}/100 ({level.upper()})")
186
+ lines.append("")
187
+
188
+ if self.summary:
189
+ lines.append(self.summary)
190
+ lines.append("")
191
+
192
+ # Sections
193
+ for section in self.sections:
194
+ lines.append("-" * 60)
195
+ lines.append(section.title.upper())
196
+ lines.append("-" * 60)
197
+
198
+ if isinstance(section.content, str):
199
+ lines.append(section.content)
200
+ elif isinstance(section.content, list) and all(
201
+ isinstance(f, Finding) for f in section.content
202
+ ):
203
+ lines.append(FindingsTable(section.content).to_plain())
204
+ elif isinstance(section.content, dict):
205
+ for key, value in section.content.items():
206
+ lines.append(f" {key}: {value}")
207
+ else:
208
+ lines.append(str(section.content))
209
+
210
+ lines.append("")
211
+
212
+ lines.append(separator)
213
+ return "\n".join(lines)
214
+
215
+
216
+ # =============================================================================
217
+ # FINDINGS TABLE
218
+ # =============================================================================
219
+
220
+
221
+ class FindingsTable:
222
+ """Render findings as Rich Table or plain text."""
223
+
224
+ def __init__(self, findings: list[Finding]) -> None:
225
+ """Initialize with list of findings."""
226
+ self.findings = findings
227
+
228
+ def to_rich_table(self) -> Table:
229
+ """Convert findings to Rich Table."""
230
+ table = Table(show_header=True, header_style="bold magenta")
231
+ table.add_column("Severity", style="bold", width=8)
232
+ table.add_column("Location", style="cyan")
233
+ table.add_column("Message")
234
+
235
+ for finding in self.findings:
236
+ severity_style = {
237
+ "high": "red",
238
+ "medium": "yellow",
239
+ "low": "blue",
240
+ "info": "dim",
241
+ }.get(finding.severity.lower(), "white")
242
+
243
+ table.add_row(
244
+ Text(finding.severity.upper(), style=severity_style),
245
+ finding.location,
246
+ finding.message,
247
+ )
248
+
249
+ return table
250
+
251
+ def to_plain(self) -> str:
252
+ """Convert findings to plain text."""
253
+ if not self.findings:
254
+ return " No findings."
255
+
256
+ lines = []
257
+ for finding in self.findings:
258
+ lines.append(f" [{finding.severity.upper()}] {finding.location}")
259
+ if finding.message:
260
+ lines.append(f" {finding.message}")
261
+
262
+ return "\n".join(lines)
263
+
264
+
265
+ # =============================================================================
266
+ # METRICS PANEL
267
+ # =============================================================================
268
+
269
+
270
+ class MetricsPanel:
271
+ """Display score with color-coded indicator."""
272
+
273
+ @staticmethod
274
+ def get_level(score: int) -> str:
275
+ """Get level name for score."""
276
+ if score >= 85:
277
+ return "excellent"
278
+ elif score >= 70:
279
+ return "good"
280
+ elif score >= 50:
281
+ return "needs work"
282
+ return "critical"
283
+
284
+ @staticmethod
285
+ def get_style(score: int) -> str:
286
+ """Get Rich style for score."""
287
+ if score >= 85:
288
+ return "green"
289
+ elif score >= 70:
290
+ return "yellow"
291
+ elif score >= 50:
292
+ return "orange1"
293
+ return "red"
294
+
295
+ @staticmethod
296
+ def get_icon(score: int) -> str:
297
+ """Get icon for score."""
298
+ if score >= 85:
299
+ return "[green]:heavy_check_mark:[/green]"
300
+ elif score >= 70:
301
+ return "[yellow]:large_yellow_circle:[/yellow]"
302
+ elif score >= 50:
303
+ return "[orange1]:warning:[/orange1]"
304
+ return "[red]:x:[/red]"
305
+
306
+ @staticmethod
307
+ def get_plain_icon(score: int) -> str:
308
+ """Get plain text icon for score."""
309
+ if score >= 85:
310
+ return "[OK]"
311
+ elif score >= 70:
312
+ return "[--]"
313
+ elif score >= 50:
314
+ return "[!!]"
315
+ return "[XX]"
316
+
317
+ @classmethod
318
+ def render_score(cls, score: int, label: str = "Score") -> Panel:
319
+ """Render score as Rich Panel.
320
+
321
+ Args:
322
+ score: Score value (0-100)
323
+ label: Label for the score
324
+
325
+ Returns:
326
+ Rich Panel with formatted score
327
+ """
328
+ if not RICH_AVAILABLE or Panel is None:
329
+ raise RuntimeError("Rich is not available")
330
+
331
+ style = cls.get_style(score)
332
+ icon = cls.get_icon(score)
333
+ level = cls.get_level(score)
334
+
335
+ content = f"{icon} [bold]{score}[/bold]/100 ({level.upper()})"
336
+ return Panel(content, title=f"[bold]{label}[/bold]", border_style=style)
337
+
338
+ @classmethod
339
+ def render_plain(cls, score: int, label: str = "Score") -> str:
340
+ """Render score as plain text.
341
+
342
+ Args:
343
+ score: Score value (0-100)
344
+ label: Label for the score
345
+
346
+ Returns:
347
+ Plain text score display
348
+ """
349
+ icon = cls.get_plain_icon(score)
350
+ level = cls.get_level(score)
351
+ return f"{label}: {icon} {score}/100 ({level.upper()})"
352
+
353
+
354
+ # =============================================================================
355
+ # HELPER FUNCTIONS
356
+ # =============================================================================
357
+
358
+
359
+ def format_workflow_result(
360
+ title: str,
361
+ summary: str = "",
362
+ findings: list[dict] | None = None,
363
+ score: int | None = None,
364
+ recommendations: str = "",
365
+ metadata: dict[str, Any] | None = None,
366
+ ) -> WorkflowReport:
367
+ """Create a standardized workflow report.
368
+
369
+ Args:
370
+ title: Report title
371
+ summary: Brief summary text
372
+ findings: List of finding dicts with severity, file, line, message
373
+ score: Overall score (0-100)
374
+ recommendations: Recommendations text
375
+ metadata: Additional metadata
376
+
377
+ Returns:
378
+ WorkflowReport instance
379
+ """
380
+ report = WorkflowReport(
381
+ title=title,
382
+ summary=summary,
383
+ score=score,
384
+ metadata=metadata or {},
385
+ )
386
+
387
+ if findings:
388
+ finding_objs = [
389
+ Finding(
390
+ severity=f.get("severity", "info"),
391
+ file=f.get("file", "unknown"),
392
+ line=f.get("line"),
393
+ message=f.get("message", ""),
394
+ code=f.get("code"),
395
+ )
396
+ for f in findings
397
+ ]
398
+ report.add_section("Findings", finding_objs)
399
+
400
+ if recommendations:
401
+ report.add_section("Recommendations", recommendations)
402
+
403
+ return report
404
+
405
+
406
+ def get_console() -> Console | None:
407
+ """Get Rich Console if available."""
408
+ if RICH_AVAILABLE and Console is not None:
409
+ return Console()
410
+ return None
@@ -20,6 +20,7 @@ from pathlib import Path
20
20
  from typing import Any
21
21
 
22
22
  from .base import BaseWorkflow, ModelTier
23
+ from .output import Finding, WorkflowReport, get_console
23
24
  from .step_config import WorkflowStepConfig
24
25
 
25
26
  # Define step configurations for executor-based execution
@@ -483,6 +484,9 @@ Provide detailed optimization strategies."""
483
484
  # Add formatted report for human readability
484
485
  result["formatted_report"] = format_perf_audit_report(result, input_data)
485
486
 
487
+ # Add structured WorkflowReport for Rich rendering
488
+ result["workflow_report"] = create_perf_audit_workflow_report(result, input_data)
489
+
486
490
  return (result, input_tokens, output_tokens)
487
491
 
488
492
  def _get_optimization_action(self, concern: str) -> dict | None:
@@ -532,6 +536,92 @@ Provide detailed optimization strategies."""
532
536
  return actions.get(concern)
533
537
 
534
538
 
539
+ def create_perf_audit_workflow_report(result: dict, input_data: dict) -> WorkflowReport:
540
+ """Create a WorkflowReport from performance audit results.
541
+
542
+ Args:
543
+ result: The optimize stage result
544
+ input_data: Input data from previous stages
545
+
546
+ Returns:
547
+ WorkflowReport instance for Rich or plain text rendering
548
+ """
549
+ perf_score = result.get("perf_score", 0)
550
+ perf_level = result.get("perf_level", "unknown")
551
+
552
+ # Determine report level
553
+ if perf_score >= 85:
554
+ level = "success"
555
+ elif perf_score >= 50:
556
+ level = "warning"
557
+ else:
558
+ level = "error"
559
+
560
+ # Build summary
561
+ files_scanned = input_data.get("files_scanned", 0)
562
+ finding_count = input_data.get("finding_count", 0)
563
+ by_impact = input_data.get("by_impact", {})
564
+
565
+ summary = (
566
+ f"Scanned {files_scanned} files, found {finding_count} issues. "
567
+ f"High: {by_impact.get('high', 0)}, Medium: {by_impact.get('medium', 0)}, "
568
+ f"Low: {by_impact.get('low', 0)}"
569
+ )
570
+
571
+ report = WorkflowReport(
572
+ title="Performance Audit Report",
573
+ summary=summary,
574
+ score=perf_score,
575
+ level=level,
576
+ metadata={
577
+ "perf_level": perf_level,
578
+ "files_scanned": files_scanned,
579
+ "finding_count": finding_count,
580
+ },
581
+ )
582
+
583
+ # Add top issues section
584
+ top_issues = result.get("top_issues", [])
585
+ if top_issues:
586
+ issues_content = {
587
+ issue.get("type", "unknown").replace("_", " ").title(): f"{issue.get('count', 0)} occurrences"
588
+ for issue in top_issues
589
+ }
590
+ report.add_section("Top Performance Issues", issues_content)
591
+
592
+ # Add hotspots section
593
+ hotspot_result = input_data.get("hotspot_result", {})
594
+ hotspots = hotspot_result.get("hotspots", [])
595
+ if hotspots:
596
+ hotspot_content = {
597
+ "Critical Hotspots": hotspot_result.get("critical_count", 0),
598
+ "Moderate Hotspots": hotspot_result.get("moderate_count", 0),
599
+ }
600
+ report.add_section("Hotspot Summary", hotspot_content)
601
+
602
+ # Add findings section
603
+ findings = input_data.get("findings", [])
604
+ high_impact = [f for f in findings if f.get("impact") == "high"]
605
+ if high_impact:
606
+ finding_objs = [
607
+ Finding(
608
+ severity="high",
609
+ file=f.get("file", "unknown"),
610
+ line=f.get("line"),
611
+ message=f.get("description", ""),
612
+ )
613
+ for f in high_impact[:10]
614
+ ]
615
+ report.add_section("High Impact Findings", finding_objs, style="error")
616
+
617
+ # Add recommendations section
618
+ optimization_plan = result.get("optimization_plan", "")
619
+ if optimization_plan:
620
+ report.add_section("Optimization Recommendations", optimization_plan)
621
+
622
+ return report
623
+
624
+
535
625
  def format_perf_audit_report(result: dict, input_data: dict) -> str:
536
626
  """Format performance audit output as a human-readable report.
537
627
 
@@ -660,26 +750,42 @@ def main():
660
750
  workflow = PerformanceAuditWorkflow()
661
751
  result = await workflow.execute(path=".", file_types=[".py"])
662
752
 
663
- print("\nPerformance Audit Results")
664
- print("=" * 50)
665
- print(f"Provider: {result.provider}")
666
- print(f"Success: {result.success}")
667
-
668
753
  output = result.final_output
669
- print(f"Performance Level: {output.get('perf_level', 'N/A')}")
670
- print(f"Performance Score: {output.get('perf_score', 0)}/100")
671
- print(f"Recommendations: {output.get('recommendation_count', 0)}")
672
-
673
- if output.get("top_issues"):
674
- print("\nTop Issues:")
675
- for issue in output["top_issues"]:
676
- print(f" - {issue['type']}: {issue['count']} occurrences")
677
-
678
- print("\nCost Report:")
679
- print(f" Total Cost: ${result.cost_report.total_cost:.4f}")
680
- savings = result.cost_report.savings
681
- pct = result.cost_report.savings_percent
682
- print(f" Savings: ${savings:.4f} ({pct:.1f}%)")
754
+
755
+ # Try Rich output first
756
+ console = get_console()
757
+ workflow_report = output.get("workflow_report")
758
+
759
+ if console and workflow_report:
760
+ # Render with Rich
761
+ workflow_report.render(console, use_rich=True)
762
+ console.print()
763
+ console.print(f"[dim]Provider: {result.provider}[/dim]")
764
+ console.print(f"[dim]Cost: ${result.cost_report.total_cost:.4f}[/dim]")
765
+ savings = result.cost_report.savings
766
+ pct = result.cost_report.savings_percent
767
+ console.print(f"[dim]Savings: ${savings:.4f} ({pct:.1f}%)[/dim]")
768
+ else:
769
+ # Fallback to plain text
770
+ print("\nPerformance Audit Results")
771
+ print("=" * 50)
772
+ print(f"Provider: {result.provider}")
773
+ print(f"Success: {result.success}")
774
+
775
+ print(f"Performance Level: {output.get('perf_level', 'N/A')}")
776
+ print(f"Performance Score: {output.get('perf_score', 0)}/100")
777
+ print(f"Recommendations: {output.get('recommendation_count', 0)}")
778
+
779
+ if output.get("top_issues"):
780
+ print("\nTop Issues:")
781
+ for issue in output["top_issues"]:
782
+ print(f" - {issue['type']}: {issue['count']} occurrences")
783
+
784
+ print("\nCost Report:")
785
+ print(f" Total Cost: ${result.cost_report.total_cost:.4f}")
786
+ savings = result.cost_report.savings
787
+ pct = result.cost_report.savings_percent
788
+ print(f" Savings: ${savings:.4f} ({pct:.1f}%)")
683
789
 
684
790
  asyncio.run(run())
685
791