Skip to content

Create AGENTS.md Repository Guidelines Document #9

@TerminallyLazy

Description

@TerminallyLazy

You're given a task to write a collection of rules, context and guidelines on the repository you're provided. Please gather context on the following categories, then write an AGENTS.md file in the root of the repository.

  • General Rules: These are general rules any developer/agent should follow when writing code. It should contain rules such as "When creating new XYZ functions, always first search in the XYZ/ directory to see if one exists, and if not, create it and place it in an existing or new file". Additionally, here is where you'd include context about scripts which are commonly executed, such as linter and formatter scripts.
  • Repository Structure: This section is where you'll include high level context about how the repository is laid out, any highly useful and not overly obvious information about how the directories/files are structured, different apps/packages/services inside the repository, etc. Do not include every last detail about the repository contents, only a high level technical overview on the repository structure.
  • Dependencies and Installation: This section should include high level context about how to install dependencies, where to install them, package managers, etc. Do not include overly verbose context in this section as most repositories typically have straightforward dependency management.
  • Testing Instructions: A general guide on testing in this repository. It should include context such as testing frameworks, roughly what types of modules should be tested, how to run tests, and any other context a developer wouldn't be able to infer by looking at test files on how to write & run tests. Do not include every last detail about testing in this section, only the most used/important context necessary to run tests.
  • Pull request formatting: Rules and guidelines around how to format pull request titles and descriptions. This should only be populated if you find specific instructions in the repository around how to format pull request titles and descriptions. If the repository does not have specific instructions, leave this section empty. The agent will already generate well thought out titles and descriptions, so unless there are special rules specific to this repository, leave this section empty.

Ensure each category is properly wrapped in opening and closing XML tags. The tags to use are as follows:
<general_rules>
</general_rules>
<repository_structure>
</repository_structure>
<dependencies_and_installation>
</dependencies_and_installation>
<testing_instructions>
</testing_instructions>
<pull_request_formatting>
</pull_request_formatting>

It is incredibly important that you ALWAYS wrap your sections in the opening and closing XML tags. Failure to do so will result in an invalid file and will not be accepted.

The file should not contain any other content besides those tags, and the rules/context/instructions they contain. Ensure your rules are thoughtful, concise and actually useful to a developer who's never contributed to the repository before. You can think of it as a more structured and directed CONTRIBUTING.md file.

With all of this in mind, please explore the repository and write this single AGENTS.md file with the rules/context/instructions gathered!

Agent Context [ "**Implement Planner Agent Tools:**\n- Create the `agents/swe-planner/tools/plan_manager.py` file with the following content to manage the development plan within the `GraphState`:\n```python\nfrom python.helpers.tool import Tool\nfrom python.helpers.tool_response import ToolResponse\nfrom python.helpers.swe_graph_state import GraphState, Plan, Task\n\nclass PlanManager(Tool):\n \"\"\"\n A tool for creating and managing the development plan.\n \"\"\"\n def __init__(self, agent_context):\n super().__init__(agent_context)\n self.register_tool(\n \"create_plan\",\n \"Creates the initial development plan.\",\n {\"goal\": \"The high-level goal of the plan.\"}\n )\n self.register_tool(\n \"add_task\",\n \"Adds a new task to the existing plan.\",\n {\"description\": \"The detailed description of the task.\"}\n )\n\n async def create_plan(self, **kwargs) -> ToolResponse:\n goal = kwargs.get(\"goal\")\n if not goal:\n return ToolResponse.error(\"The 'goal' argument is required.\")\n \n state: GraphState = self.agent_context.get_state()\n state.plan = Plan(goal=goal)\n self.agent_context.set_state(state)\n \n return ToolResponse.success(f\"Successfully created a new plan with the goal: {goal}\")\n\n async def add_task(self, **kwargs) -> ToolResponse:\n description = kwargs.get(\"description\")\n if not description:\n return ToolResponse.error(\"The 'description' argument is required.\")\n \n state: GraphState = self.agent_context.get_state()\n if not state.plan:\n return ToolResponse.error(\"A plan must be created before adding tasks.\")\n \n new_task_id = len(state.plan.tasks) + 1\n new_task = Task(id=new_task_id, description=description)\n state.plan.tasks.append(new_task)\n self.agent_context.set_state(state)\n \n return ToolResponse.success(f\"Successfully added task {new_task_id}: {description}\")\n```\n- Create the `agents/swe-planner/tools/rules_parser.py` file with the following content to parse `AGENTS.md`:\n```python\nimport re\nfrom python.helpers.tool import Tool\nfrom python.helpers.tool_response import ToolResponse\nfrom python.helpers.swe_graph_state import GraphState\n\nclass RulesParser(Tool):\n \"\"\"\n A tool for parsing AGENTS.md and loading custom rules into the GraphState.\n \"\"\"\n def __init__(self, agent_context):\n super().__init__(agent_context)\n self.register_tool(\n \"parse_agents_md\",\n \"Parses the AGENTS.md file from the target repository.\",\n {\"file_content\": \"The full content of the AGENTS.md file.\"}\n )\n\n async def parse_agents_md(self, **kwargs) -> ToolResponse:\n content = kwargs.get(\"file_content\")\n if not content:\n return ToolResponse.error(\"The 'file_content' argument is required.\")\n\n state: GraphState = self.agent_context.get_state()\n \n tags = [\n \"general_rules\", \"repository_structure\", \"dependencies_and_installation\",\n \"testing_instructions\", \"pull_request_formatting\"\n ]\n \n for tag in tags:\n pattern = f\"<{tag}>(.*?)\"\n match = re.search(pattern, content, re.DOTALL)\n if match:\n state.custom_rules.rules[tag] = match.group(1).strip()\n \n self.agent_context.set_state(state)\n return ToolResponse.success(\"Successfully parsed AGENTS.md and updated custom rules in the state.\")\n```", "**Implement Programmer Agent Tools:**\n- Create the `agents/swe-programmer/tools/file_operations.py` file with functions for file manipulation:\n```python\nfrom python.helpers.tool import Tool\nfrom python.helpers.tool_response import ToolResponse\nimport os\n\nclass FileOperations(Tool):\n \"\"\"\n A tool for performing file operations like view, create, and modify.\n \"\"\"\n def __init__(self, agent_context):\n super().__init__(agent_context)\n self.register_tool(\"view_file\", \"Views the content of a file.\", {\"path\": \"The path to the file.\"})\n self.register_tool(\"create_file\", \"Creates a new file with content.\", {\"path\": \"The path to the new file.\", \"content\": \"The content to write.\"})\n self.register_tool(\"replace_in_file\", \"Replaces a string in a file.\", {\"path\": \"The path to the file.\", \"old_string\": \"The string to replace.\", \"new_string\": \"The new string.\"})\n\n async def view_file(self, **kwargs) -> ToolResponse:\n path = kwargs.get(\"path\")\n try:\n with open(path, 'r') as f:\n content = f.read()\n return ToolResponse.success(content)\n except Exception as e:\n return ToolResponse.error(f\"Failed to view file: {e}\")\n\n async def create_file(self, **kwargs) -> ToolResponse:\n path = kwargs.get(\"path\")\n content = kwargs.get(\"content\", \"\")\n try:\n os.makedirs(os.path.dirname(path), exist_ok=True)\n with open(path, 'w') as f:\n f.write(content)\n return ToolResponse.success(f\"File '{path}' created successfully.\")\n except Exception as e:\n return ToolResponse.error(f\"Failed to create file: {e}\")\n\n async def replace_in_file(self, **kwargs) -> ToolResponse:\n path = kwargs.get(\"path\")\n old_string = kwargs.get(\"old_string\")\n new_string = kwargs.get(\"new_string\")\n try:\n with open(path, 'r') as f:\n content = f.read()\n content = content.replace(old_string, new_string)\n with open(path, 'w') as f:\n f.write(content)\n return ToolResponse.success(f\"Replaced string in '{path}'.\")\n except Exception as e:\n return ToolResponse.error(f\"Failed to replace string in file: {e}\")\n```\n- Create the `agents/swe-programmer/tools/task_manager.py` file to update task status:\n```python\nfrom python.helpers.tool import Tool\nfrom python.helpers.tool_response import ToolResponse\nfrom python.helpers.swe_graph_state import GraphState\n\nclass TaskManager(Tool):\n \"\"\"\n A tool for managing the status of tasks in the plan.\n \"\"\"\n def __init__(self, agent_context):\n super().__init__(agent_context)\n self.register_tool(\n \"update_task_status\",\n \"Updates the status of a specific task.\",\n {\"task_id\": \"The ID of the task.\", \"status\": \"The new status (e.g., 'in-progress', 'completed').\"}\n )\n\n async def update_task_status(self, **kwargs) -> ToolResponse:\n task_id = kwargs.get(\"task_id\")\n status = kwargs.get(\"status\")\n if not task_id or not status:\n return ToolResponse.error(\"Both 'task_id' and 'status' are required.\")\n\n state: GraphState = self.agent_context.get_state()\n task_found = False\n for task in state.plan.tasks:\n if task.id == task_id:\n task.status = status\n task_found = True\n break\n \n if not task_found:\n return ToolResponse.error(f\"Task with ID {task_id} not found.\")\n \n self.agent_context.set_state(state)\n return ToolResponse.success(f\"Task {task_id} status updated to '{status}'.\")\n```", "**Implement Orchestration Logic and Update Documentation:**\n- Create a new tool `agents/swe-agent/tools/orchestrator.py` to manage the multi-agent workflow. This tool will use `call_subordinate` to chain the agents together.\n```python\nfrom python.helpers.tool import Tool\nfrom python.helpers.tool_response import ToolResponse\nfrom python.helpers.swe_graph_state import GraphState\nimport json\n\nclass Orchestrator(Tool):\n \"\"\"\n Orchestrates the SWE agent workflow by calling planner, programmer, and reviewer agents in sequence.\n \"\"\"\n def __init__(self, agent_context):\n super().__init__(agent_context)\n self.register_tool(\n \"run_swe_workflow\",\n \"Executes the full software engineering workflow for a given user request.\",\n {\"user_request\": \"The user's request for a software change.\"}\n )\n\n async def run_swe_workflow(self, **kwargs) -> ToolResponse:\n user_request = kwargs.get(\"user_request\")\n if not user_request:\n return ToolResponse.error(\"The 'user_request' argument is required.\")\n\n # Initialize the shared state\n graph_state = GraphState(plan=Plan(goal=user_request))\n state_json = json.dumps(graph_state.__dict__)\n\n # 1. Call Planner\n planner_response = await self.agent_context.call_subordinate(\n profile=\"swe-planner\",\n user_message=f\"Create a development plan for the following request: {user_request}\",\n state=state_json\n )\n if not planner_response.is_success():\n return ToolResponse.error(f\"Planner failed: {planner_response.message}\")\n \n state_json = planner_response.state\n \n # 2. Call Programmer for each task\n current_state = json.loads(state_json)\n tasks = current_state.get(\"plan\", {}).get(\"tasks\", [])\n for task in tasks:\n task_id = task.get(\"id\")\n task_description = task.get(\"description\")\n \n programmer_response = await self.agent_context.call_subordinate(\n profile=\"swe-programmer\",\n user_message=f\"Execute task {task_id}: {task_description}\",\n state=state_json\n )\n if not programmer_response.is_success():\n return ToolResponse.error(f\"Programmer failed on task {task_id}: {programmer_response.message}\")\n state_json = programmer_response.state\n\n # 3. Call Reviewer\n reviewer_response = await self.agent_context.call_subordinate(\n profile=\"swe-reviewer\",\n user_message=\"Review the implemented code against the original goal.\",\n state=state_json\n )\n if not reviewer_response.is_success():\n # Handle review feedback - for now, just report it\n return ToolResponse.warning(f\"Reviewer feedback: {reviewer_response.message}\")\n\n return ToolResponse.success(\"SWE workflow completed successfully.\")\n```\n- Update the `agents/swe-agent/README.md` to include details about the new tools and the orchestration logic.", "**Implement Core Settings Changes:**\n- Modify `python/helpers/settings.py` to recognize the new agent profiles. This involves adding `swe-planner`, `swe-programmer`, and `swe-reviewer` to the list of available profiles, likely within a function responsible for loading agent configurations.\n- A conceptual change to the `get_agent_config` function in `python/helpers/settings.py` would look like this:\n```python\n# This is a conceptual change and might not map directly to the existing code.\n# The goal is to show how the new profiles would be added.\n\ndef get_agent_config(profile_name: str):\n # ... existing logic to load default configs ...\n\n # Add new profiles to the list of valid profiles\n VALID_PROFILES = [\"default\", \"developer\", \"swe-planner\", \"swe-programmer\", \"swe-reviewer\"]\n if profile_name not in VALID_PROFILES:\n raise ValueError(f\"Unknown agent profile: {profile_name}\")\n\n # Load the base configuration for the profile\n profile_config = load_profile_config_from_file(f\"agents/{profile_name}/config.json\")\n \n # Merge with user settings and return\n # ... existing logic ...\n \n return final_config\n```\n- Ensure that the agent loading mechanism in `agent.py` can correctly instantiate an agent with one of the new profiles, loading the corresponding prompts and tools from the correct directories (`agents/swe-planner/`, etc.). This should work automatically if the directory structure is correct and the settings are loaded properly." ]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions