diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cd5f2ff4..5a3d7978 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -45,6 +45,13 @@ for you. Note: For the Windows subsystem for Linux (WSL), you may need to adjust the path for the volume. +## Running Tools Locally + +The Serena tools (and in fact all Serena code) can be executed without an LLM, and also without +any MCP specifics (though you can use the mcp inspector, if you want). + +An example script for running tools is provided in [scripts/demo_run_tools.py](scripts/demo_run_tools.py). + ## Adding a New Supported Language Serena interacts with code through language servers which are included in diff --git a/scripts/demo_run_tools.py b/scripts/demo_run_tools.py new file mode 100644 index 00000000..2eae23c6 --- /dev/null +++ b/scripts/demo_run_tools.py @@ -0,0 +1,26 @@ +""" +This script demonstrates how to use Serena's tools locally, useful +for testing or development. Here the config is pointing to the serena repo itself, +it assumes that you already have a serena_config.yml file setup. +""" + +import json +from pprint import pprint +from pathlib import Path + +from serena.agent import * + +project_root = Path(__file__).parent.parent + +if __name__ == "__main__": + agent = SerenaAgent(project_file_path=str(project_root / ".serena" / "project.yml")) + overview_tool = agent.get_tool(GetSymbolsOverviewTool) + find_symbol_tool = agent.get_tool(FindSymbolTool) + + print("Getting an overview of the util package\n") + pprint(json.loads(overview_tool.apply("src/serena/util"))) + + print("\n\n") + + print("Finding the symbol 'SerenaAgent'\n") + pprint(json.loads(find_symbol_tool.apply("SerenaAgent"))) \ No newline at end of file