Files
gabrielvidalandClaude Fable 5.2 b32458e821 feat(trackers): tasks leave the core for the tasks plugin — tool trackers, checklists
Generic points the plugin stands on (docs/plugins.md → "Trackers" → Tool
trackers, "Checklists"):
- trackers[]: tool-call rules — `tool` (a neutral tool name) + `ops` (create /
  update by id / whole-list snapshot, told apart by the input's field paths) +
  `statuses`; items gain `status` and `startedAt`, keep the list's order; the
  re-derive pass finds the transcripts by the tool's quoted names
  (toolnames.byte_hints), no PARSER_VERSION bump (48: the unshipped v49 goes)
- provides tasks.list: the completion scaffold reads the task list through
  trackers.provided; an older row's `tasks` is carried over until re-read
- ui.card[].list.style "checklist" (the ✓ done/total pill and its card),
  ui.panels[] (the floating checklist over the thread) and ui.toolCards[]
  naming a tracker (the calls' rows) — declared by the plugin, drawn by the
  app: Checklist.tsx (the old TaskPanel, moved), PluginPanels, trackerCards;
  the tool-card registry has an epoch so mounted rows follow a declared card

Removed from core: todo_op / _task_times and the summary's `tasks`, the card
field, the Task schema, the registered `todo` card (its bucket stays), the
taskPanel switch (a hidden one carries over to plugin:tasks:panel), their
i18n keys.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 22:30:48 +01:00

69 lines
2.0 KiB
Python

"""The reference tracker plugins (``worktrees.json`` — the shape the
``worktrees`` hub plugin ships: shell commands; ``tasks.json`` — the ``tasks``
plugin's: a tool's calls) and a fake plugin store to run the parser and the
cards on them, as ``fixtures/resource_plugins/kit.py`` does for resources."""
from __future__ import annotations
import contextlib
import copy
import json
import pathlib
import types
from plugins import trackers as plugin_trackers
HERE = pathlib.Path(__file__).resolve().parent
KEY = "worktrees:worktrees"
TASKS = "tasks:tasks"
def manifest(name: str = "worktrees") -> dict:
return json.loads((HERE / f"{name}.json").read_text())
class FakePluginStore:
def __init__(self, manifests=None):
self.version = 1
self.rows = {m["id"]: m for m in (manifests if manifests is not None else [manifest()])}
def active_manifests(self, uid):
return [(p, copy.deepcopy(m), {}) for p, m in sorted(self.rows.items())]
def put(self, mf: dict) -> None:
self.rows[mf["id"]] = mf
self.version += 1
def remove(self, pid: str) -> None:
self.rows.pop(pid, None)
self.version += 1
def deps_with(store) -> types.SimpleNamespace:
return types.SimpleNamespace(plugin_store=store)
def registry(manifests=None):
return plugin_trackers.registry(deps_with(FakePluginStore(manifests)))
def tasks_store() -> FakePluginStore:
"""A store with the tasks plugin alone."""
return FakePluginStore([manifest("tasks")])
def task_list(summary: dict) -> list[dict]:
"""The tasks tracker's items in a parse (``[]`` when it read none)."""
return ((summary.get("trackersAuto") or {}).get(TASKS) or {}).get("items") or []
@contextlib.contextmanager
def bound(store=None):
"""The parser and the deps-less accessors read ``store``'s trackers."""
prev = plugin_trackers._bound
plugin_trackers.bind(deps_with(store if store is not None else FakePluginStore()))
try:
yield
finally:
plugin_trackers._bound = prev