32 lines
825 B
Python
32 lines
825 B
Python
|
|
from __future__ import annotations
|
|||
|
|
|
|||
|
|
from dataclasses import asdict, dataclass
|
|||
|
|
from typing import Any
|
|||
|
|
from uuid import uuid4
|
|||
|
|
|
|||
|
|
|
|||
|
|
@dataclass(slots=True)
|
|||
|
|
class Task:
|
|||
|
|
id: str
|
|||
|
|
title: str
|
|||
|
|
description: str
|
|||
|
|
status: str = "ready"
|
|||
|
|
|
|||
|
|
def to_dict(self) -> dict[str, Any]:
|
|||
|
|
return asdict(self)
|
|||
|
|
|
|||
|
|
|
|||
|
|
class TaskDispatcher:
|
|||
|
|
"""Small task-board placeholder matching the reference project's extension point."""
|
|||
|
|
|
|||
|
|
def __init__(self) -> None:
|
|||
|
|
self._tasks: dict[str, Task] = {}
|
|||
|
|
|
|||
|
|
def create_task(self, *, title: str, description: str) -> Task:
|
|||
|
|
task = Task(id=f"task_{uuid4().hex[:8]}", title=title, description=description)
|
|||
|
|
self._tasks[task.id] = task
|
|||
|
|
return task
|
|||
|
|
|
|||
|
|
def list_tasks(self) -> list[dict[str, Any]]:
|
|||
|
|
return [task.to_dict() for task in self._tasks.values()]
|