fix: align TodoWrite memory model with task system docs

This commit is contained in:
Gui-Yue
2026-05-21 23:31:30 +08:00
parent 1baf1aca5a
commit 6d48bc978b
17 changed files with 85 additions and 72 deletions

View File

@@ -118,7 +118,7 @@ That means permission, logging, and audit logic all attach to the same hook poin
S20 keeps two planning layers:
- `todo_write`: lightweight plan for the current session, written to `.tasks/current_todos.json`
- `todo_write`: lightweight plan for the current session, kept in memory
- task graph: cross-session, dependency-aware, claimable task files under `.tasks/task_*.json`
The first keeps a single agent from drifting. The second supports team coordination.

View File

@@ -118,7 +118,7 @@ if blocked:
S20 には 2 層の plan がある:
- `todo_write`: current session 用の軽量 plan。`.tasks/current_todos.json` に保
- `todo_write`: current session 用の軽量 plan。メモリに保
- task graph: cross-session、dependency-aware、claimable な task file。`.tasks/task_*.json` に保存。
前者は単独 agent の drift を防ぐ。後者は team coordination の土台になる。

View File

@@ -118,7 +118,7 @@ if blocked:
S20 同时保留两层计划:
- `todo_write`:当前会话内的轻量计划,写入 `.tasks/current_todos.json`
- `todo_write`:当前会话内的轻量计划,保存在内存中
- task graph跨会话、可依赖、可认领的任务文件写入 `.tasks/task_*.json`
前者帮助单个 Agent 不漂移;后者支撑团队协作。

View File

@@ -73,6 +73,7 @@ def terminal_print(text: str):
# worktrees, and teammates on top of this same file-backed state.
TASKS_DIR = WORKDIR / ".tasks"
TASKS_DIR.mkdir(exist_ok=True)
CURRENT_TODOS: list[dict] = []
@dataclass
@@ -457,15 +458,15 @@ def call_tool_handler(handler, args: dict, name: str) -> str:
def run_todo_write(todos: list) -> str:
global CURRENT_TODOS
for i, todo in enumerate(todos):
if "content" not in todo or "status" not in todo:
return f"Error: todos[{i}] missing 'content' or 'status'"
if todo["status"] not in ("pending", "in_progress", "completed"):
return f"Error: todos[{i}] has invalid status '{todo['status']}'"
path = TASKS_DIR / "current_todos.json"
path.write_text(json.dumps(todos, indent=2, ensure_ascii=False))
print(f" \033[33m[todo] updated {len(todos)} item(s)\033[0m")
return f"Updated {len(todos)} todos"
CURRENT_TODOS = todos
print(f" \033[33m[todo] updated {len(CURRENT_TODOS)} item(s)\033[0m")
return f"Updated {len(CURRENT_TODOS)} todos"
# ── MessageBus ──