Files
rdb-discovery/src/rdb_discovery/handoff.py
T

46 lines
1.2 KiB
Python

from __future__ import annotations
from pathlib import Path
from .status import project_stage, task_counts
from .tasks import get_next_task
def build_handoff(root: Path) -> str:
next_task = get_next_task(root)
counts = task_counts(root)
lines = [
"# AI Agent Handoff",
"",
f"Project stage: {project_stage(root)}",
"",
"## Task Counts",
]
if counts:
for status, count in counts.items():
lines.append(f"- {status}: {count}")
else:
lines.append("- No tasks found")
lines.extend(["", "## Next Task"])
if next_task:
lines.extend([
f"- ID: {next_task.task_id}",
f"- Title: {next_task.title}",
f"- Status: {next_task.status}",
])
else:
lines.append("No Todo task found.")
lines.extend([
"",
"## Agent Rules",
"- Implement one task only.",
"- Make the smallest useful change possible.",
"- Do not rewrite unrelated code.",
"- Run relevant tests.",
"- Update documentation if behaviour changes.",
"- Report files changed, validation, risks, and next recommended task.",
])
return "\n".join(lines) + "\n"