feat(task-018): add role-based context selection
This commit is contained in:
@@ -322,3 +322,94 @@ def test_generate_agent_prompt_with_custom_role(tmp_path: Path) -> None:
|
||||
prompt = generate_agent_prompt(tmp_path)
|
||||
|
||||
assert "You are a devops engineer." in prompt
|
||||
|
||||
|
||||
def test_architecture_agent_receives_architecture_context(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"
|
||||
"Role: Architecture Agent\n"
|
||||
"Goal: y.\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
prompt = generate_agent_prompt(tmp_path)
|
||||
|
||||
assert "context/architecture.md" in prompt
|
||||
assert "context/product-brief.md" in prompt
|
||||
assert "context/decisions.md" in prompt
|
||||
|
||||
|
||||
def test_implementation_agent_receives_implementation_context(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"
|
||||
"Role: Implementation Agent\n"
|
||||
"Goal: y.\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
prompt = generate_agent_prompt(tmp_path)
|
||||
|
||||
assert "AGENT_HANDOFF.md" in prompt
|
||||
assert "context/agent-guidelines.md" in prompt
|
||||
assert "CLAUDE.md" in prompt
|
||||
|
||||
|
||||
def test_documentation_agent_receives_documentation_context(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"
|
||||
"Role: Documentation Agent\n"
|
||||
"Goal: y.\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
prompt = generate_agent_prompt(tmp_path)
|
||||
|
||||
assert "TEST_PLAN.md" in prompt
|
||||
assert "AGENT_HANDOFF.md" in prompt
|
||||
|
||||
|
||||
def test_context_files_differ_by_role(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 — Architect\nStatus: Todo\n\n"
|
||||
"Role: Architecture Agent\n"
|
||||
"Goal: y.\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
prompt = generate_agent_prompt(tmp_path)
|
||||
|
||||
# Architecture role should have architecture-specific files
|
||||
assert "context/architecture.md" in prompt
|
||||
|
||||
|
||||
def test_no_role_uses_default_context(tmp_path: Path) -> None:
|
||||
"""When no Role is set, the default file list is used (backward compatible)."""
|
||||
(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)
|
||||
|
||||
# Default files must still be present
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user