-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
48 lines (38 loc) · 1.25 KB
/
Copy pathmodels.py
File metadata and controls
48 lines (38 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from __future__ import annotations
from dataclasses import dataclass, field
from typing import Any, Dict, List, Literal, Optional
RiskLevel = Literal["low", "medium"]
@dataclass(frozen=True)
class FailureContext:
command: str
exit_code: int
cwd: str
timestamp_utc: str
stderr_tail: str
stdout_tail: str
last_commands: List[str] = field(default_factory=list)
env_signals: Dict[str, Any] = field(default_factory=dict)
project_signals: Dict[str, Any] = field(default_factory=dict)
def to_prompt_dict(self) -> Dict[str, Any]:
return {
"command": self.command,
"exit_code": self.exit_code,
"cwd": self.cwd,
"timestamp_utc": self.timestamp_utc,
"stderr_tail": self.stderr_tail,
"stdout_tail": self.stdout_tail,
"last_commands": self.last_commands,
"env_signals": self.env_signals,
"project_signals": self.project_signals,
}
@dataclass(frozen=True)
class FixSuggestion:
risk: RiskLevel
commands: List[str]
explanation: str
@dataclass(frozen=True)
class FailureAnalysis:
reason: str
details: str
fixes: List[FixSuggestion] = field(default_factory=list)
provider: Optional[str] = None