docs: add task for agent prompt generation

This commit is contained in:
2026-06-02 06:44:03 +01:00
parent 6211a391b5
commit 6430a16050
6 changed files with 255 additions and 2 deletions
+9 -1
View File
@@ -10,7 +10,7 @@ from rich.table import Table
from .discovery import append_discovery_answer, core_questions
from .handoff import build_handoff
from .status import project_stage, task_counts
from .tasks import get_next_task, update_task_status
from .tasks import generate_agent_prompt, get_next_task, update_task_status
from .templates import CONTEXT_FILES, write_file_if_missing
app = typer.Typer(help="RDB discovery and delivery workflow CLI.")
@@ -131,3 +131,11 @@ def complete(task_id: str) -> None:
def handoff() -> None:
"""Print an AI-agent handoff summary."""
console.print(build_handoff(root_path()))
@app.command()
def prompt() -> None:
"""Generate a ready-to-paste implementation prompt for the next Todo task."""
root = root_path()
result = generate_agent_prompt(root)
console.print(result)
+97
View File
@@ -8,6 +8,10 @@ TASK_HEADING_RE = re.compile(r"^##\s+(TASK-\d+)\s+[-–—]\s+(.+)$", re.MULTILI
STATUS_RE = re.compile(r"^Status:\s*(.+)$", re.MULTILINE)
GOAL_RE = re.compile(r"^Goal:\s*(.+)", re.MULTILINE)
AC_RE = re.compile(r"^- (.+)$", re.MULTILINE)
@dataclass
class Task:
task_id: str
@@ -15,6 +19,15 @@ class Task:
status: str
body: str
def goal(self, root: Path) -> str:
match = GOAL_RE.search(self.body)
if match:
return match.group(1).strip()
return ""
def ac_lines(self) -> list[str]:
return AC_RE.findall(self.body)
def read_tasks(root: Path) -> list[Task]:
tasks_path = root / "TASKS.md"
@@ -69,3 +82,87 @@ def update_task_status(root: Path, task_id: str, new_status: str) -> bool:
return True
return False
CONTEXT_FILES_TO_READ = [
"README.md",
"TASKS.md",
"PROJECT_STATE.md",
"AGENT_HANDOFF.md",
"context/agent-guidelines.md",
]
def _read_file_safe(root: Path, relative: str) -> str:
path = root / relative
if path.exists():
return path.read_text(encoding="utf-8")
return f"# {relative} — not found"
def generate_agent_prompt(root: Path) -> str:
task = get_next_task(root)
if not task:
return "No Todo task found."
sections = [
"You are an implementation agent.",
"",
"---",
"",
"# Read these files first",
"",
f"""- README.md
- TASKS.md
- PROJECT_STATE.md
- AGENT_HANDOFF.md""",
"",
"- context/agent-guidelines.md",
"",
"---",
"",
"# Task",
"",
f"## {task.task_id}{task.title}",
"",
f"Status: {task.status}",
"",
f"Goal:\n{task.goal(root)}",
"",
"Acceptance Criteria:",
]
for line in task.ac_lines():
sections.append(f"- {line}")
sections.extend([
"",
"---",
"",
"# Constraints",
"",
"- Implement ONE task only. Do not combine with other tasks.",
"- Make the smallest useful change possible.",
"",
"---",
"",
"# Validation",
"",
"- Run `rdb status` to confirm stage and task state.",
"- Run tests: `python -m pytest`.",
"- Verify acceptance criteria are met.",
"",
"---",
"",
"# Reporting",
"",
"When complete, provide:",
"- Summary of changes",
"- Files modified",
"- Test results",
"- Validation notes",
"- Update TASKS.md status to Done if all criteria pass",
"",
])
return "\n".join(sections)