"""
Goal Manager - Generate and track goals
"""

class GoalManager:
    def __init__(self):
        self.goals = []
        self.completed = []
    
    def create_goal(self, description, priority="medium"):
        """Create a new goal"""
        goal = {
            "id": len(self.goals) + 1,
            "description": description,
            "priority": priority,
            "status": "active",
            "sub_goals": []
        }
        self.goals.append(goal)
        return goal
    
    def break_down_goal(self, goal_id, sub_goals):
        """Break goal into sub-goals"""
        for goal in self.goals:
            if goal["id"] == goal_id:
                goal["sub_goals"] = sub_goals
                return True
        return False
    
    def complete_goal(self, goal_id):
        """Mark goal as complete"""
        for i, goal in enumerate(self.goals):
            if goal["id"] == goal_id:
                goal["status"] = "complete"
                self.completed.append(self.goals.pop(i))
                return True
        return False
    
    def get_active_goals(self):
        """Get all active goals"""
        return [g for g in self.goals if g["status"] == "active"]
    
    def get_stats(self):
        return {"active": len(self.goals), "completed": len(self.completed)}

if __name__ == "__main__":
    gm = GoalManager()
    goal = gm.create_goal("Complete Phase 1", "high")
    gm.break_down_goal(1, ["Build tools", "Create memory", "Enable autonomy"])
    print("Active goals:", gm.get_active_goals())
    gm.complete_goal(1)
    print("Stats:", gm.get_stats())
