(
self,
event: str,
task: dict | None = None,
worktree: dict | None = None,
error: str | None = None,
)
| 88 | self.path.write_text("") |
| 89 | |
| 90 | def emit( |
| 91 | self, |
| 92 | event: str, |
| 93 | task: dict | None = None, |
| 94 | worktree: dict | None = None, |
| 95 | error: str | None = None, |
| 96 | ): |
| 97 | payload = { |
| 98 | "event": event, |
| 99 | "ts": time.time(), |
| 100 | "task": task or {}, |
| 101 | "worktree": worktree or {}, |
| 102 | } |
| 103 | if error: |
| 104 | payload["error"] = error |
| 105 | with self.path.open("a", encoding="utf-8") as f: |
| 106 | f.write(json.dumps(payload) + "\n") |
| 107 | |
| 108 | def list_recent(self, limit: int = 20) -> str: |
| 109 | n = max(1, min(int(limit or 20), 200)) |