NEP框架重构00阶段

This commit is contained in:
2025-12-09 11:21:00 +08:00
parent 7b0db3c399
commit 0a9dc8d8f5
3 changed files with 182 additions and 129 deletions

31
src/state.py Normal file
View File

@@ -0,0 +1,31 @@
# src/state.py
import os
import json
class StateTracker:
def __init__(self, workspace_dir):
self.state_file = os.path.join(workspace_dir, "workflow_status.json")
self.completed_tasks = set()
self.load()
def load(self):
if os.path.exists(self.state_file):
try:
with open(self.state_file, 'r') as f:
data = json.load(f)
self.completed_tasks = set(data.get("completed", []))
except:
self.completed_tasks = set()
def mark_done(self, task_id):
"""标记任务完成并保存"""
self.completed_tasks.add(task_id)
self.save()
def is_done(self, task_id):
"""检查任务是否已完成"""
return task_id in self.completed_tasks
def save(self):
with open(self.state_file, 'w') as f:
json.dump({"completed": list(self.completed_tasks)}, f, indent=2)