mirror of
https://github.com/tiennm99/serena.git
synced 2026-10-18 12:14:37 +00:00
Record the correspondence between API methods and tools
FacadeMethodInfo gains corresponding_tool (the tool class offering the same functionality) and get_corresponding_tool_name, and every API method with a tool counterpart names it in its facade_method decorator. This enables applying tool-level exclusions to API methods and rendering prompt conditions based on tools. Since the API modules now refer to the tool classes, the tools import the APIs locally (in the mixins' _api methods), and the symbol tools' symbol_dict_grouper attributes become properties.
This commit is contained in:
1 parent
a46a465773
commit
07b6831c70
13 files changed
+201
-79
No files matched your search
@@ -11,7 +11,7 @@ from serena.config.serena_config import ApiInclusionDefinition
|
||||
from serena.repl.api.lsp_api import LspApi
|
||||
from serena.repl.facade import ApiScope, Facade, FacadeApi, FacadeMethodInfo, facade_method
|
||||
from serena.repl.repl import SerenaRepl
|
||||
from serena.tools import SerenaReplTool
|
||||
from serena.tools import FindSymbolTool, SerenaReplTool
|
||||
from solidlsp.ls_config import LanguageServerId
|
||||
from test.conftest import agent_for_project_context
|
||||
|
||||
@@ -165,6 +165,15 @@ class TestFacade:
|
||||
facade = Facade.from_api(self.DummyApi(MagicMock()), self._scope(included_apis=["dummy.extra"]))
|
||||
assert "extra" in facade.enabled_method_names
|
||||
|
||||
def test_corresponding_tool(self) -> None:
|
||||
facade = Facade.from_api(self.DummyApi(MagicMock()), ApiScope())
|
||||
assert facade.get_method("add").info.get_corresponding_tool_name() is None
|
||||
|
||||
lsp_facade = Facade.from_api(LspApi(MagicMock()), ApiScope())
|
||||
info = lsp_facade.get_method("find_symbol").info
|
||||
assert info.corresponding_tool is FindSymbolTool
|
||||
assert info.get_corresponding_tool_name() == "find_symbol"
|
||||
|
||||
def test_method_info_mirrors_decorator(self) -> None:
|
||||
facade = Facade.from_api(self.DummyApi(MagicMock()), ApiScope())
|
||||
assert facade.get_method("add").info == FacadeMethodInfo(name="add")
|
||||
|
||||
Reference in new issue
Block a user