8f11340b38
Per post_module_taxonomy_de_cruft_20260627 Phase 2 (FR7). Each
'from src.models import X' for a moved class is rewritten to
'from src.<destination> import X':
Ticket, Track, WorkerContext, TrackState, TrackMetadata,
ThinkingSegment, EMPTY_TRACK_STATE -> src.mma
ProjectContext, ProjectMeta, ProjectOutput, ProjectFiles,
ProjectScreenshots, ProjectDiscussion, EMPTY_PROJECT_CONTEXT -> src.project
FileItem, Preset, ContextPreset, ContextFileEntry,
NamedViewPreset -> src.project_files
Tool, ToolPreset -> src.tool_presets
BiasProfile -> src.tool_bias
TextEditorConfig, ExternalEditorConfig,
EMPTY_TEXT_EDITOR_CONFIG -> src.external_editor
Persona -> src.personas
WorkspaceProfile -> src.workspace_manager
MCPServerConfig, MCPConfiguration, VectorStoreConfig,
RAGConfig, load_mcp_config -> src.mcp_client
NOT touched (kept on src.models; Phase 3 or Phase 4 will move them):
GenerateRequest, ConfirmRequest, DEFAULT_TOOL_CATEGORIES, Metadata, PROVIDERS
Migration was performed by the one-time script
scripts/tier2/artifacts/post_module_taxonomy_de_cruft_20260627/migrate_imports.py
which uses a class-to-module map and re.sub() to rewrite each
'from src.models import X' line.
Total: 85 import lines rewritten across 71 files.
Note: this commit depends on the v2 SHIPPED work
(origin/tier2/module_taxonomy_refactor_20260627) being merged into
this branch NEXT. On master (without the v2 SHIPPED commits), the
destination modules do not exist and these imports would fail.
32 lines
1.4 KiB
Python
32 lines
1.4 KiB
Python
from typing import Dict, Any
|
|
|
|
from src.project_files import ContextPreset
|
|
from src.result_types import Result, ErrorInfo, ErrorKind
|
|
|
|
|
|
class ContextPresetManager:
|
|
"""Manages context presets within the project dictionary (manual_slop.toml)."""
|
|
|
|
def load_all(self, project_dict: Dict[str, Any]) -> Result[Dict[str, ContextPreset]]:
|
|
"""Loads all context presets from the project dictionary."""
|
|
presets: Dict[str, ContextPreset] = {}
|
|
errors: list[ErrorInfo] = []
|
|
presets_data = project_dict.get("context_presets", {})
|
|
for name, data in presets_data.items():
|
|
try:
|
|
presets[name] = ContextPreset.from_dict(name, data)
|
|
except (ValueError, KeyError, TypeError) as e:
|
|
errors.append(ErrorInfo(kind=ErrorKind.INTERNAL, message=str(e), source=f"context_presets.load_all[{name}]", original=e))
|
|
return Result(data=presets, errors=errors)
|
|
|
|
def save_preset(self, project_dict: Dict[str, Any], preset: ContextPreset) -> None:
|
|
"""Saves a context preset into the project dictionary."""
|
|
if "context_presets" not in project_dict:
|
|
project_dict["context_presets"] = {}
|
|
project_dict["context_presets"][preset.name] = preset.to_dict()
|
|
|
|
def delete_preset(self, project_dict: Dict[str, Any], name: str) -> None:
|
|
"""Deletes a context preset from the project dictionary."""
|
|
if "context_presets" in project_dict and name in project_dict["context_presets"]:
|
|
del project_dict["context_presets"][name]
|