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.
- tsugite/__init__.py +6 -0
- tsugite/agent_composition.py +163 -0
- tsugite/agent_inheritance.py +479 -0
- tsugite/agent_preparation.py +236 -0
- tsugite/agent_runner/__init__.py +45 -0
- tsugite/agent_runner/helpers.py +106 -0
- tsugite/agent_runner/history_integration.py +248 -0
- tsugite/agent_runner/metrics.py +100 -0
- tsugite/agent_runner/runner.py +1879 -0
- tsugite/agent_runner/validation.py +70 -0
- tsugite/agent_utils.py +167 -0
- tsugite/attachments/__init__.py +65 -0
- tsugite/attachments/auto_context.py +199 -0
- tsugite/attachments/base.py +34 -0
- tsugite/attachments/file.py +51 -0
- tsugite/attachments/inline.py +31 -0
- tsugite/attachments/storage.py +178 -0
- tsugite/attachments/url.py +59 -0
- tsugite/attachments/youtube.py +101 -0
- tsugite/benchmark/__init__.py +62 -0
- tsugite/benchmark/config.py +183 -0
- tsugite/benchmark/core.py +292 -0
- tsugite/benchmark/discovery.py +377 -0
- tsugite/benchmark/evaluators.py +671 -0
- tsugite/benchmark/execution.py +657 -0
- tsugite/benchmark/metrics.py +204 -0
- tsugite/benchmark/reports.py +420 -0
- tsugite/benchmark/utils.py +288 -0
- tsugite/builtin_agents/chat-assistant.md +53 -0
- tsugite/builtin_agents/default.md +140 -0
- tsugite/builtin_agents.py +5 -0
- tsugite/cache.py +195 -0
- tsugite/cli/__init__.py +1042 -0
- tsugite/cli/agents.py +148 -0
- tsugite/cli/attachments.py +193 -0
- tsugite/cli/benchmark.py +663 -0
- tsugite/cli/cache.py +113 -0
- tsugite/cli/config.py +272 -0
- tsugite/cli/helpers.py +534 -0
- tsugite/cli/history.py +193 -0
- tsugite/cli/init.py +387 -0
- tsugite/cli/mcp.py +193 -0
- tsugite/cli/tools.py +419 -0
- tsugite/config.py +204 -0
- tsugite/console.py +48 -0
- tsugite/constants.py +21 -0
- tsugite/core/__init__.py +19 -0
- tsugite/core/agent.py +774 -0
- tsugite/core/executor.py +300 -0
- tsugite/core/memory.py +67 -0
- tsugite/core/tools.py +271 -0
- tsugite/docker_cli.py +270 -0
- tsugite/events/__init__.py +55 -0
- tsugite/events/base.py +46 -0
- tsugite/events/bus.py +62 -0
- tsugite/events/events.py +224 -0
- tsugite/exceptions.py +40 -0
- tsugite/history/__init__.py +29 -0
- tsugite/history/index.py +210 -0
- tsugite/history/models.py +106 -0
- tsugite/history/storage.py +157 -0
- tsugite/mcp_client.py +219 -0
- tsugite/mcp_config.py +174 -0
- tsugite/md_agents.py +751 -0
- tsugite/models.py +257 -0
- tsugite/renderer.py +151 -0
- tsugite/shell_tool_config.py +265 -0
- tsugite/templates/assistant.md +14 -0
- tsugite/tools/__init__.py +265 -0
- tsugite/tools/agents.py +312 -0
- tsugite/tools/edit_strategies.py +393 -0
- tsugite/tools/fs.py +329 -0
- tsugite/tools/http.py +239 -0
- tsugite/tools/interactive.py +430 -0
- tsugite/tools/shell.py +129 -0
- tsugite/tools/shell_tools.py +214 -0
- tsugite/tools/tasks.py +339 -0
- tsugite/tsugite.py +7 -0
- tsugite/ui/__init__.py +46 -0
- tsugite/ui/base.py +638 -0
- tsugite/ui/chat.py +265 -0
- tsugite/ui/chat.tcss +92 -0
- tsugite/ui/chat_history.py +286 -0
- tsugite/ui/helpers.py +102 -0
- tsugite/ui/jsonl.py +125 -0
- tsugite/ui/live_template.py +529 -0
- tsugite/ui/plain.py +419 -0
- tsugite/ui/textual_chat.py +642 -0
- tsugite/ui/textual_handler.py +225 -0
- tsugite/ui/widgets/__init__.py +6 -0
- tsugite/ui/widgets/base_scroll_log.py +27 -0
- tsugite/ui/widgets/message_list.py +121 -0
- tsugite/ui/widgets/thought_log.py +80 -0
- tsugite/ui_context.py +90 -0
- tsugite/utils.py +367 -0
- tsugite/xdg.py +104 -0
- tsugite_cli-0.3.3.dist-info/METADATA +325 -0
- tsugite_cli-0.3.3.dist-info/RECORD +101 -0
- tsugite_cli-0.3.3.dist-info/WHEEL +4 -0
- tsugite_cli-0.3.3.dist-info/entry_points.txt +5 -0
- 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()))
|