chore(conductor): Mark track 'Saved System Prompt Presets' as complete
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import sys
|
||||
import tomllib
|
||||
import tomli_w
|
||||
from pathlib import Path
|
||||
@@ -21,24 +22,21 @@ class PresetManager:
|
||||
presets: Dict[str, Preset] = {}
|
||||
|
||||
# Load global presets
|
||||
if self.global_path.exists():
|
||||
data_global = self._load_file(self.global_path)
|
||||
for name, p_data in data_global.get("presets", {}).items():
|
||||
try:
|
||||
with open(self.global_path, "rb") as f:
|
||||
data = tomllib.load(f)
|
||||
for name, p_data in data.get("presets", {}).items():
|
||||
presets[name] = Preset.from_dict(name, p_data)
|
||||
except Exception:
|
||||
pass
|
||||
presets[name] = Preset.from_dict(name, p_data)
|
||||
except Exception as e:
|
||||
print(f"Error parsing global preset '{name}': {e}", file=sys.stderr)
|
||||
|
||||
# Load project presets (overwriting global ones if names conflict)
|
||||
if self.project_path and self.project_path.exists():
|
||||
try:
|
||||
with open(self.project_path, "rb") as f:
|
||||
data = tomllib.load(f)
|
||||
for name, p_data in data.get("presets", {}).items():
|
||||
presets[name] = Preset.from_dict(name, p_data)
|
||||
except Exception:
|
||||
pass
|
||||
if self.project_path:
|
||||
data_project = self._load_file(self.project_path)
|
||||
for name, p_data in data_project.get("presets", {}).items():
|
||||
try:
|
||||
presets[name] = Preset.from_dict(name, p_data)
|
||||
except Exception as e:
|
||||
print(f"Error parsing project preset '{name}': {e}", file=sys.stderr)
|
||||
|
||||
return presets
|
||||
|
||||
@@ -75,8 +73,14 @@ class PresetManager:
|
||||
return {"presets": {}}
|
||||
try:
|
||||
with open(path, "rb") as f:
|
||||
return tomllib.load(f)
|
||||
except Exception:
|
||||
data = tomllib.load(f)
|
||||
if not isinstance(data, dict):
|
||||
return {"presets": {}}
|
||||
if "presets" not in data:
|
||||
data["presets"] = {}
|
||||
return data
|
||||
except Exception as e:
|
||||
print(f"Error loading presets from {path}: {e}", file=sys.stderr)
|
||||
return {"presets": {}}
|
||||
|
||||
def _save_file(self, path: Path, data: Dict[str, Any]) -> None:
|
||||
|
||||
Reference in New Issue
Block a user