mirror of
https://github.com/tiennm99/serena.git
synced 2026-10-14 10:19:02 +00:00
Use depth=-1 to enable lang-specific default for overview tools
This commit is contained in:
1 parent
4dc0cd1453
commit
75410c78e7
3 files changed
+19
-5
No files matched your search
@@ -24,6 +24,7 @@ Status of the `main` branch. Changes prior to the next official version change w
|
||||
|
||||
* Tools:
|
||||
- New tool: `replace_in_files`
|
||||
- `get_symbols_overview`, `jet_brains_get_symbols_overview`: Improved default for `depth` parameter
|
||||
- Add tool parameter alias support, adding `name_path` as an alias for `name_path_pattern` in `find_symbol` tools
|
||||
- Allow `query_project` tool to access read-only tools that are not enabled in the current configuration
|
||||
- Make tool call errors surface explicitly as errors at the MCP protocol level
|
||||
|
||||
@@ -323,7 +323,7 @@ class JetBrainsGetSymbolsOverviewTool(Tool, ToolMarkerSymbolicRead, ToolMarkerOp
|
||||
def apply(
|
||||
self,
|
||||
relative_path: str,
|
||||
depth: int = 0,
|
||||
depth: int = -1,
|
||||
max_answer_chars: int = -1,
|
||||
include_file_documentation: bool = False,
|
||||
) -> str:
|
||||
@@ -335,10 +335,17 @@ class JetBrainsGetSymbolsOverviewTool(Tool, ToolMarkerSymbolicRead, ToolMarkerOp
|
||||
or by using the `list_dir` and `find_file` tools (or similar).
|
||||
|
||||
:param relative_path: the relative path to the file to get the overview of
|
||||
:param depth: depth up to which descendants shall be retrieved (e.g., use 1 to also retrieve immediate children).
|
||||
:param depth: depth up to which descendants shall be retrieved.
|
||||
Default (-1) results in a language specific choice: 1 for java and kotlin and 0 for other languages
|
||||
:param max_answer_chars: max characters for the result (-1 for default). If exceeded, no content/a shortened result is returned.
|
||||
:param include_file_documentation: whether to include the file's docstring. Default False.
|
||||
"""
|
||||
if depth == -1:
|
||||
if relative_path.endswith((".java", ".kt")):
|
||||
depth = 1
|
||||
else:
|
||||
depth = 0
|
||||
|
||||
relative_path = self._sanitize_input_param(relative_path)
|
||||
with JetBrainsPluginClient.from_project(self.project) as client:
|
||||
symbol_overview = client.get_symbols_overview(
|
||||
|
||||
@@ -40,20 +40,26 @@ class GetSymbolsOverviewTool(Tool, ToolMarkerSymbolicRead):
|
||||
|
||||
symbol_dict_grouper = LanguageServerSymbolDictGrouper(["kind"], ["kind"], collapse_singleton=True)
|
||||
|
||||
def apply(self, relative_path: str, depth: int = 0, max_answer_chars: int = -1) -> str:
|
||||
def apply(self, relative_path: str, depth: int = -1, max_answer_chars: int = -1) -> str:
|
||||
"""
|
||||
Use this tool to get a high-level understanding of the code symbols in a file.
|
||||
This should be the first tool to call when you want to understand a new file, unless you already know
|
||||
what you are looking for.
|
||||
|
||||
:param relative_path: the relative path to the file to get the overview of
|
||||
:param depth: depth up to which descendants of top-level symbols shall be retrieved
|
||||
(e.g. 1 retrieves immediate children). Default 0.
|
||||
:param depth: depth up to which descendants shall be retrieved.
|
||||
Default (-1) results in a language specific choice: 1 for java and kotlin and 0 for other languages
|
||||
:param max_answer_chars: if the overview is longer than this number of characters,
|
||||
no content will be returned. -1 means the default value from the config will be used.
|
||||
Don't adjust unless there is really no other way to get the content required for the task.
|
||||
:return: a JSON object containing symbols grouped by kind in a compact format.
|
||||
"""
|
||||
if depth == -1:
|
||||
if relative_path.endswith((".java", ".kt")):
|
||||
depth = 1
|
||||
else:
|
||||
depth = 0
|
||||
|
||||
result = self.get_symbol_overview(relative_path, depth=depth)
|
||||
|
||||
# capture kind names and depth-0 snapshots before grouping, which mutates the dicts
|
||||
|
||||
Reference in new issue
Block a user