refactor(heartbeat): remove Completed section and tighten section gating

- Remove ## Completed section from HEARTBEAT.md template; completed
  tasks should be deleted, not accumulated
- Change in_active_section from tri-state (None/True/False) to bool
  (True/False) so stray text before any ## heading no longer triggers
  heartbeat
- Add test cases for stray pre-heading text and ## Notes section
- Update docs/chat-commands.md to reference ## Active Tasks
This commit is contained in:
chengyongru
2026-05-31 15:15:37 +08:00
committed by Xubin Ren
parent 2671c8fe55
commit 15c2bd25b3
4 changed files with 8 additions and 10 deletions
+1 -1
View File
@@ -107,7 +107,7 @@ _HEARTBEAT_PREAMBLE = (
def _heartbeat_has_active_tasks(content: str) -> bool:
"""True if HEARTBEAT.md has task lines, ignoring headers, blanks and comments."""
in_comment = False
in_active_section: bool | None = None
in_active_section: bool = False
for line in content.splitlines():
stripped = line.strip()
if in_comment:
+1 -5
View File
@@ -5,14 +5,10 @@ This file is checked periodically by your nanobot agent.
Register it as a cron job (e.g. `cron add --name heartbeat --schedule "every 30m" --message "Check HEARTBEAT.md"`) to get the same behavior as the legacy heartbeat service.
If this file has no tasks (only headers and comments), the agent will skip it.
Completed tasks should be deleted, not kept — heartbeat only reads "Active Tasks".
-->
## Active Tasks
<!-- Add your periodic tasks below this line -->
## Completed
<!-- Move completed tasks here or delete them -->