From 6052f7b0aea67828ca2431c83d7e95707c33ecc5 Mon Sep 17 00:00:00 2001 From: Michael Panchenko Date: Sun, 6 Apr 2025 13:22:39 +0200 Subject: [PATCH] Minor docstring changes --- CHANGELOG.md | 4 ++++ src/serena/agent.py | 21 +++++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7128943c..599b9d96 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ # Changelog +## 06.04.2025 +- New tool: FindReferencingCodeSnippets +- Adjusted prompt in CreateTextFileTool to prevent writing partial content (see [here](https://www.reddit.com/r/ClaudeAI/comments/1jpavtm/comment/mloek1x/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button)). + ## 01.04.2025: Initial Release \ No newline at end of file diff --git a/src/serena/agent.py b/src/serena/agent.py index bcbe4bb8..f9175b65 100644 --- a/src/serena/agent.py +++ b/src/serena/agent.py @@ -332,6 +332,10 @@ class CreateTextFileTool(Tool): You can also use insert_at_line to insert content at a specific line for existing files if the symbolic operations are not the right choice for what you want to do. + If ever used on an existing file, the content has to be the complete content of that file (so it + may never end with something like "The remaining content of the file is left unchanged."). + For operations that just replace a part of a file, use the replace_lines or the symbolic editing tools instead. + :param relative_path: the relative path to the file to create :param content: the (utf-8-encoded) content to write to the file :return: a message indicating success or failure @@ -536,9 +540,9 @@ class FindReferencingSymbolsTool(Tool): return self._limit_length(result, max_answer_chars) -class GetReferencingCodeExtractsTool(Tool): +class FindReferencingCodeSnippetsTool(Tool): """ - Gets the code blocks that reference the symbol at the given location. + Finds code snippets in which the symbol at the given location is referenced. """ def apply( @@ -551,19 +555,20 @@ class GetReferencingCodeExtractsTool(Tool): max_answer_chars: int = _DEFAULT_MAX_ANSWER_LENGTH, ) -> str: """ - Returns short code extracts where the symbol at the given location is referenced. + Returns short code snippets where the symbol at the given location is referenced. Contrary to the `find_referencing_symbols` tool, this tool returns references that are not symbols but instead - code extracts that may or may not be contained in a symbol (for example, file-level calls). - It may make sense to use this tool if you want to get a quick and dirty overview of the code that references - the symbol. Usually, just looking at the code extracts is not enough to understand the context, + code snippets that may or may not be contained in a symbol (for example, file-level calls). + It may make sense to use this tool to get a quick overview of the code that references + the symbol. Usually, just looking at code snippets is not enough to understand the full context, unless the case you are investigating is very simple, or you already have read the relevant symbols using the find_referencing_symbols tool and now want to get an overview of how the referenced symbol (at the given location) is used in them. + The size of the snippets is controlled by the context_lines_before and context_lines_after parameters. :param relative_path: the relative path to the file containing the symbol - :param line: the line number - :param column: the column + :param line: the line number of the symbol to find references for + :param column: the column of the symbol to find references for :param context_lines_before: the number of lines to include before the line containing the reference :param context_lines_after: the number of lines to include after the line containing the reference :param max_answer_chars: if the output is longer than this number of characters,