tsugite-cli 0.3.3__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 (101) hide show
  1. tsugite/__init__.py +6 -0
  2. tsugite/agent_composition.py +163 -0
  3. tsugite/agent_inheritance.py +479 -0
  4. tsugite/agent_preparation.py +236 -0
  5. tsugite/agent_runner/__init__.py +45 -0
  6. tsugite/agent_runner/helpers.py +106 -0
  7. tsugite/agent_runner/history_integration.py +248 -0
  8. tsugite/agent_runner/metrics.py +100 -0
  9. tsugite/agent_runner/runner.py +1879 -0
  10. tsugite/agent_runner/validation.py +70 -0
  11. tsugite/agent_utils.py +167 -0
  12. tsugite/attachments/__init__.py +65 -0
  13. tsugite/attachments/auto_context.py +199 -0
  14. tsugite/attachments/base.py +34 -0
  15. tsugite/attachments/file.py +51 -0
  16. tsugite/attachments/inline.py +31 -0
  17. tsugite/attachments/storage.py +178 -0
  18. tsugite/attachments/url.py +59 -0
  19. tsugite/attachments/youtube.py +101 -0
  20. tsugite/benchmark/__init__.py +62 -0
  21. tsugite/benchmark/config.py +183 -0
  22. tsugite/benchmark/core.py +292 -0
  23. tsugite/benchmark/discovery.py +377 -0
  24. tsugite/benchmark/evaluators.py +671 -0
  25. tsugite/benchmark/execution.py +657 -0
  26. tsugite/benchmark/metrics.py +204 -0
  27. tsugite/benchmark/reports.py +420 -0
  28. tsugite/benchmark/utils.py +288 -0
  29. tsugite/builtin_agents/chat-assistant.md +53 -0
  30. tsugite/builtin_agents/default.md +140 -0
  31. tsugite/builtin_agents.py +5 -0
  32. tsugite/cache.py +195 -0
  33. tsugite/cli/__init__.py +1042 -0
  34. tsugite/cli/agents.py +148 -0
  35. tsugite/cli/attachments.py +193 -0
  36. tsugite/cli/benchmark.py +663 -0
  37. tsugite/cli/cache.py +113 -0
  38. tsugite/cli/config.py +272 -0
  39. tsugite/cli/helpers.py +534 -0
  40. tsugite/cli/history.py +193 -0
  41. tsugite/cli/init.py +387 -0
  42. tsugite/cli/mcp.py +193 -0
  43. tsugite/cli/tools.py +419 -0
  44. tsugite/config.py +204 -0
  45. tsugite/console.py +48 -0
  46. tsugite/constants.py +21 -0
  47. tsugite/core/__init__.py +19 -0
  48. tsugite/core/agent.py +774 -0
  49. tsugite/core/executor.py +300 -0
  50. tsugite/core/memory.py +67 -0
  51. tsugite/core/tools.py +271 -0
  52. tsugite/docker_cli.py +270 -0
  53. tsugite/events/__init__.py +55 -0
  54. tsugite/events/base.py +46 -0
  55. tsugite/events/bus.py +62 -0
  56. tsugite/events/events.py +224 -0
  57. tsugite/exceptions.py +40 -0
  58. tsugite/history/__init__.py +29 -0
  59. tsugite/history/index.py +210 -0
  60. tsugite/history/models.py +106 -0
  61. tsugite/history/storage.py +157 -0
  62. tsugite/mcp_client.py +219 -0
  63. tsugite/mcp_config.py +174 -0
  64. tsugite/md_agents.py +751 -0
  65. tsugite/models.py +257 -0
  66. tsugite/renderer.py +151 -0
  67. tsugite/shell_tool_config.py +265 -0
  68. tsugite/templates/assistant.md +14 -0
  69. tsugite/tools/__init__.py +265 -0
  70. tsugite/tools/agents.py +312 -0
  71. tsugite/tools/edit_strategies.py +393 -0
  72. tsugite/tools/fs.py +329 -0
  73. tsugite/tools/http.py +239 -0
  74. tsugite/tools/interactive.py +430 -0
  75. tsugite/tools/shell.py +129 -0
  76. tsugite/tools/shell_tools.py +214 -0
  77. tsugite/tools/tasks.py +339 -0
  78. tsugite/tsugite.py +7 -0
  79. tsugite/ui/__init__.py +46 -0
  80. tsugite/ui/base.py +638 -0
  81. tsugite/ui/chat.py +265 -0
  82. tsugite/ui/chat.tcss +92 -0
  83. tsugite/ui/chat_history.py +286 -0
  84. tsugite/ui/helpers.py +102 -0
  85. tsugite/ui/jsonl.py +125 -0
  86. tsugite/ui/live_template.py +529 -0
  87. tsugite/ui/plain.py +419 -0
  88. tsugite/ui/textual_chat.py +642 -0
  89. tsugite/ui/textual_handler.py +225 -0
  90. tsugite/ui/widgets/__init__.py +6 -0
  91. tsugite/ui/widgets/base_scroll_log.py +27 -0
  92. tsugite/ui/widgets/message_list.py +121 -0
  93. tsugite/ui/widgets/thought_log.py +80 -0
  94. tsugite/ui_context.py +90 -0
  95. tsugite/utils.py +367 -0
  96. tsugite/xdg.py +104 -0
  97. tsugite_cli-0.3.3.dist-info/METADATA +325 -0
  98. tsugite_cli-0.3.3.dist-info/RECORD +101 -0
  99. tsugite_cli-0.3.3.dist-info/WHEEL +4 -0
  100. tsugite_cli-0.3.3.dist-info/entry_points.txt +5 -0
  101. tsugite_cli-0.3.3.dist-info/licenses/LICENSE +235 -0
@@ -0,0 +1,100 @@
1
+ """Metrics tracking and display for multi-step agent execution."""
2
+
3
+ from dataclasses import dataclass
4
+ from typing import Any, List, Optional
5
+
6
+ from rich.table import Table
7
+
8
+ from .helpers import get_display_console
9
+
10
+
11
+ @dataclass
12
+ class StepMetrics:
13
+ """Metrics for a single step execution."""
14
+
15
+ step_name: str
16
+ step_number: int
17
+ duration: float # seconds
18
+ tokens_used: Optional[int] = None
19
+ cost: Optional[float] = None
20
+ status: str = "success" # success, failed, skipped
21
+ error: Optional[str] = None
22
+
23
+
24
+ def display_step_metrics(metrics: List[StepMetrics], custom_logger: Optional[Any] = None):
25
+ """Display step execution metrics in a table using event system."""
26
+ from tsugite.events import EventBus
27
+
28
+ from .helpers import get_ui_handler
29
+
30
+ # Build metrics table
31
+ table = Table(title="Multi-Step Execution Metrics", show_header=True)
32
+ table.add_column("Step", style="cyan")
33
+ table.add_column("Duration", justify="right", style="yellow")
34
+ table.add_column("Status", justify="center")
35
+
36
+ total_duration = 0
37
+ successful = 0
38
+ failed = 0
39
+ skipped = 0
40
+
41
+ for m in metrics:
42
+ status_color = {
43
+ "success": "green",
44
+ "failed": "red",
45
+ "skipped": "yellow",
46
+ }.get(m.status, "white")
47
+
48
+ status_symbol = {
49
+ "success": "✓",
50
+ "failed": "✗",
51
+ "skipped": "⚠",
52
+ }.get(m.status, "?")
53
+
54
+ table.add_row(
55
+ f"{m.step_number}. {m.step_name}",
56
+ f"{m.duration:.1f}s",
57
+ f"[{status_color}]{status_symbol} {m.status}[/{status_color}]",
58
+ )
59
+
60
+ total_duration += m.duration
61
+ if m.status == "success":
62
+ successful += 1
63
+ elif m.status == "failed":
64
+ failed += 1
65
+ elif m.status == "skipped":
66
+ skipped += 1
67
+
68
+ # Build summary line
69
+ summary_parts = []
70
+ summary_parts.append(f"Total: {total_duration:.1f}s")
71
+ if successful > 0:
72
+ summary_parts.append(f"[green]Success: {successful}[/green]")
73
+ if skipped > 0:
74
+ summary_parts.append(f"[yellow]Skipped: {skipped}[/yellow]")
75
+ if failed > 0:
76
+ summary_parts.append(f"[red]Failed: {failed}[/red]")
77
+
78
+ summary = " | ".join(summary_parts)
79
+
80
+ # Emit through event system
81
+ ui_handler = get_ui_handler(custom_logger)
82
+ if ui_handler:
83
+ from io import StringIO
84
+
85
+ from tsugite.events import EventBus, InfoEvent
86
+
87
+ event_bus = EventBus()
88
+ event_bus.subscribe(ui_handler.handle_event)
89
+
90
+ # Render table to string
91
+ buffer = StringIO()
92
+ temp_console = get_display_console(custom_logger)
93
+ temp_console.file = buffer
94
+ temp_console.print() # noqa: T201 - Rendering to buffer
95
+ temp_console.print(table) # noqa: T201 - Rendering to buffer
96
+ temp_console.print() # noqa: T201 - Rendering to buffer
97
+ temp_console.print(summary) # noqa: T201 - Rendering to buffer
98
+ temp_console.print() # noqa: T201 - Rendering to buffer
99
+
100
+ event_bus.emit(InfoEvent(message=buffer.getvalue()))