From eb453976e2b06f42b9597b61e53cd7978a860291 Mon Sep 17 00:00:00 2001 From: Michael Panchenko Date: Mon, 6 Apr 2026 19:17:23 +0200 Subject: [PATCH 1/3] CLI: removed deprecated commands --- pyproject.toml | 2 -- scripts/mcp_server.py | 4 ++-- src/serena/cli.py | 23 ++++++++--------------- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 680d8599..667214c7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -61,8 +61,6 @@ explicit = true [project.scripts] serena = "serena.cli:top_level" -serena-mcp-server = "serena.cli:start_mcp_server" -index-project = "serena.cli:index_project" # deprecated [project.license] text = "MIT" diff --git a/scripts/mcp_server.py b/scripts/mcp_server.py index 74d2ae52..9b5c3f5a 100644 --- a/scripts/mcp_server.py +++ b/scripts/mcp_server.py @@ -1,4 +1,4 @@ -from serena.cli import start_mcp_server +from serena.cli import top_level if __name__ == "__main__": - start_mcp_server() + top_level.start_mcp_server() diff --git a/src/serena/cli.py b/src/serena/cli.py index 7ad3fb2d..666815ee 100644 --- a/src/serena/cli.py +++ b/src/serena/cli.py @@ -1109,23 +1109,16 @@ class PromptCommands(AutoRegisteringGroup): click.echo(f"Deleted override file '{prompt_yaml_name}'.") -# Expose groups so we can reference them in pyproject.toml -mode = ModeCommands() -context = ContextCommands() -project = ProjectCommands() -config = SerenaConfigCommands() -tools = ToolCommands() -prompts = PromptCommands() +_mode = ModeCommands() +_context = ContextCommands() +_project = ProjectCommands() +_config = SerenaConfigCommands() +_tools = ToolCommands() +_prompts = PromptCommands() -# Expose toplevel commands for the same reason +# Expose so we can use this as an entrypoint top_level = TopLevelCommands() -start_mcp_server = top_level.start_mcp_server # needed for the help script to work - register all subcommands to the top-level group -for subgroup in (mode, context, project, config, tools, prompts): +for subgroup in (_mode, _context, _project, _config, _tools, _prompts): top_level.add_command(subgroup) - - -def get_help() -> str: - """Retrieve the help text for the top-level Serena CLI.""" - return top_level.get_help(click.Context(top_level, info_name="serena")) From d525db7c012cccb87339e2fde3a99777dc5f0852 Mon Sep 17 00:00:00 2001 From: Michael Panchenko Date: Mon, 6 Apr 2026 19:32:14 +0200 Subject: [PATCH 2/3] Added init command to CLI --- src/serena/cli.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/serena/cli.py b/src/serena/cli.py index 666815ee..480821c9 100644 --- a/src/serena/cli.py +++ b/src/serena/cli.py @@ -45,7 +45,7 @@ from solidlsp.util.subprocess_util import subprocess_kwargs log = logging.getLogger(__name__) -_MAX_CONTENT_WIDTH = 100 +_MAX_CONTENT_WIDTH = 200 _MODES_EXPLANATION = f"""\b\nBuilt-in mode names or paths to custom mode YAMLs with which to override the default modes defined in the global Serena configuration or the active project. @@ -155,6 +155,28 @@ class TopLevelCommands(AutoRegisteringGroup): def __init__(self) -> None: super().__init__(name="serena", help="Serena CLI commands. You can run ` --help` for more info on each command.") + @staticmethod + @click.command( + "init", + help="Initialize Serena by creating a global config file with the specified default language backend.", + context_settings={"max_content_width": _MAX_CONTENT_WIDTH}, + ) + @click.option( + "--language-backend", + "-b", + type=click.Choice([b.value for b in LanguageBackend]), + default=LanguageBackend.LSP.value, + show_default=True, + help="Default code intelligence backend (can be overridden in the project config).", + ) + def init(language_backend: Literal["LSP", "JetBrains"] = "LSP"): + serena_config = SerenaConfig.from_config_file() + serena_config.language_backend = LanguageBackend(language_backend) + serena_config.save() + click.echo( + f"Initialized Serena with default backend: {language_backend}.\nFind the global Serena config in:\n {serena_config.config_file_path}" + ) + @staticmethod @click.command("start-mcp-server", help="Starts the Serena MCP server.", context_settings={"max_content_width": _MAX_CONTENT_WIDTH}) @click.option("--project", "project", type=PROJECT_TYPE, default=None, help="Path or name of project to activate at startup.") From 318d2f4204656ff1c489b95281515a65c07e6862 Mon Sep 17 00:00:00 2001 From: Michael Panchenko Date: Mon, 6 Apr 2026 20:20:18 +0200 Subject: [PATCH 3/3] Readme, docs: recommend init command instead of start-mcp-server --- CHANGELOG.md | 2 ++ README.md | 22 ++++++++++++---------- docs/02-usage/025_jetbrains_plugin.md | 14 ++++++-------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c3db50aa..699c509a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ Status of the `main` branch. Changes prior to the next official version change will appear here. +* General: + - Added `serena init` command * Fixes: - Fix reactivation of the same project restarting language servers #1280 diff --git a/README.md b/README.md index be17cde6..d69520d5 100644 --- a/README.md +++ b/README.md @@ -178,24 +178,26 @@ https://github.com/user-attachments/assets/6eaa9aa1-610d-4723-a2d6-bf1e487ba753 **Prerequisites**. Serena is managed by *uv*. If you don’t already have it, you need to [install uv](https://docs.astral.sh/uv/getting-started/installation/) before proceeding. -> [!NOTE] -> When using the language server backend, some additional dependencies to be installed for certain languages; see the [Language Support](https://oraios.github.io/serena/01-about/020_programming-languages.html) page for details. - -**Starting the MCP Server**. The easiest way to start the Serena MCP server is by running the latest version from GitHub using uvx: +**Initialize Serena**. To initialize Serena, simply run: ```bash -uvx -p 3.13 --from git+https://github.com/oraios/serena serena start-mcp-server +uvx -p 3.13 --from git+https://github.com/oraios/serena serena init ``` -If this is the first time you are starting Serena, the necessary configuration files will be created, and -you should see the Serena dashboard appear. You can terminate the server by pressing Ctrl+C (multiple times, if necessary). +This will create the global configuration file `~/.serena/config.yaml`. + +The default code intelligence backend for Serena is the free LSP backend. You can add `-b JetBrains` to the `init` command +to set up the JetBrains as the default code intelligence backend instead, see [JetBrains Plugin page](https://oraios.github.io/serena/02-usage/025_jetbrains_plugin.html) for more details. + + +> [!NOTE] +> When using the language server backend, some additional dependencies to be installed for certain languages; +> see the [Language Support](https://oraios.github.io/serena/01-about/020_programming-languages.html) page for details. + **Configuring Your Client**. To connect Serena to your preferred MCP client, you typically need to [configure a launch command in your client](https://oraios.github.io/serena/02-usage/030_clients.html). Follow the link for specific instructions on how to set up Serena for Claude Code, Codex, Claude Desktop, MCP-enabled IDEs and other clients (such as local and web-based GUIs). -**Switching to the JetBrains Backend**. The default code intelligence backend for Serena is the free LSP backend. -For using the more powerful JetBrains backend, follow the instructions on the [JetBrains Plugin page](https://oraios.github.io/serena/02-usage/025_jetbrains_plugin.html). - > [!TIP] > While getting started quickly is easy, Serena is a powerful toolkit with many configuration options. > We highly recommend reading through the [user guide](https://oraios.github.io/serena/02-usage/000_intro.html) to get the most out of Serena. diff --git a/docs/02-usage/025_jetbrains_plugin.md b/docs/02-usage/025_jetbrains_plugin.md index 89007a6a..e7f425a6 100644 --- a/docs/02-usage/025_jetbrains_plugin.md +++ b/docs/02-usage/025_jetbrains_plugin.md @@ -65,24 +65,22 @@ After installing the plugin, you need to configure Serena to use it. **Central Configuration**. -If you ever executed Serena before, you will have the global Serena configuration file located at `~/.serena/serena_config.yml` -(`%USERPROFILE%\.serena\serena_config.yml` on Windows). - -If the configuration file does not exist, run +You can run ```shell -uvx -p 3.13 --from git+https://github.com/oraios/serena serena start-mcp-server +uvx -p 3.13 --from git+https://github.com/oraios/serena serena init -b JetBrains ``` -(see [running Serena](020_running.md) for alternative options) to install all dependencies and create configuration files. Terminate the server with `Ctrl+C` after it has started. +to set the default code intelligence backend to JetBrains in the global Serena configuration file. -In your configuration, change the `language_backend` setting as follows: +Alternatively, you can also manually edit the configuration file `~/.serena/serena_config.yml` +(`%USERPROFILE%\.serena\serena_config.yml` on Windows) and set ```yaml language_backend: JetBrains ``` -*Note*: you can also use the button `Edit Global Serena Config` in the Serena MCP dashboard to open the config file in your default editor. +Note that the file might not exist yet if you never executed Serena before. **Per-Instance Configuration**. The configuration setting in the global config file can be overridden on a