diff --git a/CHANGELOG.md b/CHANGELOG.md index 896a39d..cb64508 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Added +- When key snippets are emitted, snippet files are auto added to related files. +- Add base task to research subtask prompt. +- Adjust research prompt to make sure related files are related to the base task, not just the research subtask. + ## [0.6.0] - 2024-12-17 ### Added diff --git a/ra_aid/__main__.py b/ra_aid/__main__.py index 4310d93..e243384 100644 --- a/ra_aid/__main__.py +++ b/ra_aid/__main__.py @@ -280,7 +280,7 @@ def run_research_subtasks(base_task: str, config: dict, model, expert_enabled: b ) # Run the subtask agent - subtask_prompt = f"Research Subtask: {subtask}\n\n{RESEARCH_PROMPT}" + subtask_prompt = f"Base Task: {base_task}\nResearch Subtask: {subtask}\n\n{RESEARCH_PROMPT}" run_agent_with_retry(subtask_agent, subtask_prompt, config) diff --git a/ra_aid/prompts.py b/ra_aid/prompts.py index 07a0e6f..bedafdc 100644 --- a/ra_aid/prompts.py +++ b/ra_aid/prompts.py @@ -47,12 +47,12 @@ Tools and Methodology Reporting Findings Use emit_research_notes to record detailed, fact-based observations about what currently exists. - For each significant file or directory that is part of the codebase, use emit_related_files to list it. Your research notes should be strictly about what you have observed: Document files by their names and locations. Document discovered documentation files and their contents at a high level (e.g., "There is a README.md in the root directory that explains the folder structure"). Document code files by type or apparent purpose (e.g., "There is a main.py file containing code to launch an application"). Document configuration files, dependencies (like package.json, requirements.txt), testing files, and anything else present. + Use emit_related_files to note all files that are relevant to the base task. No Planning or Problem-Solving @@ -154,6 +154,8 @@ Guidelines: API contracts, endpoints, or protocols it requires or provides Testing strategies appropriate to the complexity of that sub-task You may include pseudocode, but not full code. + + If you need to consult with the expert, do that *BEFORE* emitting any tasks. After finalizing the overall approach: Use emit_plan to store the high-level implementation plan. diff --git a/ra_aid/tools/memory.py b/ra_aid/tools/memory.py index 06f369d..8ef0d34 100644 --- a/ra_aid/tools/memory.py +++ b/ra_aid/tools/memory.py @@ -173,6 +173,7 @@ def skip_implementation(reason: str) -> str: @tool("emit_key_snippets") def emit_key_snippets(snippets: List[SnippetInfo]) -> str: """Store multiple key source code snippets in global memory. + Automatically adds the filepaths of the snippets to related files. Args: snippets: List of snippet information dictionaries containing: @@ -184,6 +185,9 @@ def emit_key_snippets(snippets: List[SnippetInfo]) -> str: Returns: List of stored snippet confirmation messages """ + # First collect unique filepaths to add as related files + _global_memory['related_files'].update(snippet_info['filepath'] for snippet_info in snippets) + results = [] for snippet_info in snippets: # Get and increment snippet ID diff --git a/tests/ra_aid/tools/test_memory.py b/tests/ra_aid/tools/test_memory.py index 0411f6d..db5a6b6 100644 --- a/tests/ra_aid/tools/test_memory.py +++ b/tests/ra_aid/tools/test_memory.py @@ -267,6 +267,8 @@ def test_key_snippets_integration(reset_memory): result = emit_key_snippets.invoke({"snippets": snippets}) assert result == "Snippets stored." assert _global_memory['key_snippet_id_counter'] == 3 + # Verify related files were tracked + assert _global_memory['related_files'] == {"file1.py", "file2.py", "file3.py"} # Verify all snippets were stored correctly assert len(_global_memory['key_snippets']) == 3 @@ -296,6 +298,8 @@ def test_key_snippets_integration(reset_memory): result = emit_key_snippets.invoke({"snippets": [new_snippet]}) assert result == "Snippets stored." assert _global_memory['key_snippet_id_counter'] == 4 + # Verify new file was added to related files + assert _global_memory['related_files'] == {"file1.py", "file2.py", "file3.py", "file4.py"} # Delete remaining snippets result = delete_key_snippets.invoke({"snippet_ids": [1, 3]})