|
| 1 | +""" |
| 2 | +Specialized Sub-Agent definitions for Plexir. |
| 3 | +Defines roles, prompts, and tool whitelists for delegated tasks. |
| 4 | +""" |
| 5 | + |
| 6 | +from typing import List, Dict, Optional |
| 7 | + |
| 8 | +class AgentRole: |
| 9 | + def __init__(self, name: str, description: str, system_prompt: str, tool_whitelist: Optional[List[str]] = None): |
| 10 | + self.name = name |
| 11 | + self.description = description |
| 12 | + self.system_prompt = system_prompt |
| 13 | + self.tool_whitelist = tool_whitelist # None means all tools |
| 14 | + |
| 15 | +SUB_AGENTS = { |
| 16 | + "codebase_investigator": AgentRole( |
| 17 | + name="codebase_investigator", |
| 18 | + description="Specialist in analyzing codebase structure, finding symbols, and mapping dependencies.", |
| 19 | + system_prompt=( |
| 20 | + "You are a Codebase Investigator. Your goal is to map the project architecture and find specific implementation details.\n" |
| 21 | + "Use tools like `get_repo_map`, `codebase_search`, and `get_definitions` extensively.\n" |
| 22 | + "Provide a structured report of your findings. DO NOT perform any file edits unless strictly necessary for exploration." |
| 23 | + ), |
| 24 | + tool_whitelist=["get_repo_map", "codebase_search", "get_definitions", "read_file", "list_directory", "grep_search", "scratchpad"] |
| 25 | + ), |
| 26 | + "coder": AgentRole( |
| 27 | + name="coder", |
| 28 | + description="Specialist in implementing features, fixing bugs, and adding documentation.", |
| 29 | + system_prompt=( |
| 30 | + "You are a Coder Agent. Your goal is to write high-quality, maintainable code and documentation. " |
| 31 | + "Follow the project's coding style and ensure all changes are precise and correct. " |
| 32 | + "When adding docstrings, use Google style." |
| 33 | + ), |
| 34 | + tool_whitelist=["write_file", "edit_file", "read_file", "list_directory", "grep_search", "scratchpad"] |
| 35 | + ), |
| 36 | + "tester": AgentRole( |
| 37 | + name="tester", |
| 38 | + description="Specialist in creating and running tests to verify behavior or reproduce bugs.", |
| 39 | + system_prompt=( |
| 40 | + "You are a Quality Assurance Agent. Your goal is to ensure code correctness.\n" |
| 41 | + "Create test files, run them in the sandbox, and analyze failures.\n" |
| 42 | + "If a test fails, explain why and provide a reproduction script." |
| 43 | + ), |
| 44 | + tool_whitelist=["write_file", "run_shell", "python_sandbox", "read_file", "list_directory", "scratchpad"] |
| 45 | + ), |
| 46 | + "researcher": AgentRole( |
| 47 | + name="researcher", |
| 48 | + description="Specialist in web search and documentation analysis.", |
| 49 | + system_prompt=( |
| 50 | + "You are a Research Agent. Your goal is to find information from external sources.\n" |
| 51 | + "Use `web_search` and `browse_url` to find documentation, latest library versions, or solution patterns." |
| 52 | + ), |
| 53 | + tool_whitelist=["web_search", "browse_url", "scratchpad"] |
| 54 | + ), |
| 55 | + "reviewer": AgentRole( |
| 56 | + name="reviewer", |
| 57 | + description="Specialist in reviewing code changes for correctness, style, and documentation.", |
| 58 | + system_prompt=( |
| 59 | + "You are a Reviewer Agent. Your goal is to verify that code changes meet the requirements and maintain high quality. " |
| 60 | + "Check for bugs, style issues, and missing documentation. Provide a detailed report of your findings." |
| 61 | + ), |
| 62 | + tool_whitelist=["read_file", "list_directory", "grep_search", "scratchpad"] |
| 63 | + ) |
| 64 | +} |
| 65 | + |
| 66 | +def get_agent_role(name: str) -> Optional[AgentRole]: |
| 67 | + return SUB_AGENTS.get(name.lower()) |
0 commit comments