import json import os from pathlib import Path class StatusManager: def __init__(self, workspace_path): self.workspace = Path(workspace_path) self.status_file = self.workspace / "status.json" if not self.workspace.exists(): self.workspace.mkdir(parents=True) # 如果没有状态文件,创建一个初始的 if not self.status_file.exists(): self._save_status({"current_iter": 1, "stages": {}}) def _save_status(self, data): with open(self.status_file, 'w') as f: json.dump(data, f, indent=4) def get_current_iter(self): if self.status_file.exists(): with open(self.status_file, 'r') as f: data = json.load(f) return data.get("current_iter", 1) return 1