feat(context): Implement ContextPreset and FileViewPreset infrastructure
This commit is contained in:
@@ -907,3 +907,42 @@ def load_mcp_config(path: str) -> MCPConfiguration:
|
||||
return MCPConfiguration.from_dict(data)
|
||||
except Exception:
|
||||
return MCPConfiguration()
|
||||
|
||||
@dataclass
|
||||
class FileViewPreset:
|
||||
path: str
|
||||
view_mode: str = "summary"
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
return {
|
||||
"path": self.path,
|
||||
"view_mode": self.view_mode
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, data: dict[str, Any]) -> "FileViewPreset":
|
||||
return cls(
|
||||
path=data.get("path", ""),
|
||||
view_mode=data.get("view_mode", "summary")
|
||||
)
|
||||
|
||||
@dataclass
|
||||
class ContextPreset:
|
||||
name: str
|
||||
files: list[FileViewPreset] = field(default_factory=list)
|
||||
screenshots: list[str] = field(default_factory=list)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
return {
|
||||
"files": [f.to_dict() for f in self.files],
|
||||
"screenshots": self.screenshots
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, name: str, data: dict[str, Any]) -> "ContextPreset":
|
||||
files_data = data.get("files", [])
|
||||
return cls(
|
||||
name=name,
|
||||
files=[FileViewPreset.from_dict(f) if isinstance(f, dict) else FileViewPreset(path=str(f)) for f in files_data],
|
||||
screenshots=data.get("screenshots", [])
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user