from pathlib import Path import pytest from rdb_discovery.tasks import generate_agent_prompt, get_next_task def test_generate_agent_prompt_includes_task_info(tmp_path: Path) -> None: (tmp_path / "TASKS.md").write_text( "# TASKS\n\n" "## TASK-001 — First\nStatus: Done\n\n" "Goal: First goal.\n\n" "Acceptance Criteria:\n" "- a\n\n" "## TASK-002 — Second\nStatus: Todo\n\n" "Goal: Second goal.\n\n" "Acceptance Criteria:\n" "- b\n" "- c\n", encoding="utf-8", ) prompt = generate_agent_prompt(tmp_path) assert "TASK-002" in prompt assert "Second" in prompt assert "Todo" in prompt assert "Second goal." in prompt def test_generate_agent_prompt_includes_acceptance_criteria(tmp_path: Path) -> None: (tmp_path / "TASKS.md").write_text( "# TASKS\n\n" "## TASK-001 — First\nStatus: Done\n\n" "Goal: x.\n\n" "Acceptance Criteria:\n" "- alpha\n\n" "## TASK-002 — Second\nStatus: Todo\n\n" "Goal: y.\n\n" "Acceptance Criteria:\n" "- bravo\n", encoding="utf-8", ) prompt = generate_agent_prompt(tmp_path) assert "- alpha" not in prompt assert "- bravo" in prompt def test_generate_agent_prompt_includes_read_instructions(tmp_path: Path) -> None: (tmp_path / "TASKS.md").write_text( "# TASKS\n\n" "## TASK-001 — First\nStatus: Done\n\n" "Goal: x.\n\n" "## TASK-002 — Second\nStatus: Todo\n\n" "Goal: y.\n", encoding="utf-8", ) prompt = generate_agent_prompt(tmp_path) assert "README.md" in prompt assert "TASKS.md" in prompt assert "PROJECT_STATE.md" in prompt assert "AGENT_HANDOFF.md" in prompt assert "context/agent-guidelines.md" in prompt def test_generate_agent_prompt_includes_one_task_constraint(tmp_path: Path) -> None: (tmp_path / "TASKS.md").write_text( "# TASKS\n\n" "## TASK-001 — First\nStatus: Done\n\n" "Goal: x.\n\n" "## TASK-002 — Second\nStatus: Todo\n\n" "Goal: y.\n", encoding="utf-8", ) prompt = generate_agent_prompt(tmp_path) assert "ONE task only" in prompt or "one task only" in prompt def test_generate_agent_prompt_includes_validation(tmp_path: Path) -> None: (tmp_path / "TASKS.md").write_text( "# TASKS\n\n" "## TASK-001 — First\nStatus: Done\n\n" "Goal: x.\n\n" "## TASK-002 — Second\nStatus: Todo\n\n" "Goal: y.\n", encoding="utf-8", ) prompt = generate_agent_prompt(tmp_path) assert "Validation" in prompt assert "pytest" in prompt def test_generate_agent_prompt_includes_reporting(tmp_path: Path) -> None: (tmp_path / "TASKS.md").write_text( "# TASKS\n\n" "## TASK-001 — First\nStatus: Done\n\n" "Goal: x.\n\n" "## TASK-002 — Second\nStatus: Todo\n\n" "Goal: y.\n", encoding="utf-8", ) prompt = generate_agent_prompt(tmp_path) assert "Reporting" in prompt def test_generate_agent_prompt_no_todo_task(tmp_path: Path) -> None: (tmp_path / "TASKS.md").write_text( "# TASKS\n\n" "## TASK-001 — First\nStatus: Done\n\n", encoding="utf-8", ) prompt = generate_agent_prompt(tmp_path) assert prompt == "No Todo task found." def test_generate_agent_prompt_no_tasks_file(tmp_path: Path) -> None: prompt = generate_agent_prompt(tmp_path) assert prompt == "No Todo task found."