diff --git a/serena_config.template.yml b/serena_config.template.yml index 269c01f8..33a9cd3b 100644 --- a/serena_config.template.yml +++ b/serena_config.template.yml @@ -24,11 +24,13 @@ gui_log_level: 20 # minimum log level for the GUI log window (10 = debug, 20 = info, 30 = warning, 40 = error) -# The list of registered projects (which you can switch between using "activate_project"). -# MANAGED BY SERENA, KEEP AT THE BOTTOM OF THE YAML AND DON'T ADJUST WITHOUT NEED (you may add paths though) -# Whenever a project is activated (either by using the tool or by starting the server with --project), -# the project's path will be added here and you will be able to activate it by its name in the future. +# MANAGED BY SERENA, KEEP AT THE BOTTOM OF THE YAML AND DON'T EDIT WITHOUT NEED +# The list of registered projects. +# To add a project, within a chat, simply ask Serena to "activate the project /path/to/project" or, +# if the project was previously added, "activate the project ". # By default, the project's name will be the name of the directory containing the project, but you may change it -# by changing the entry in the (autogenerated) `.serena/project.yml` file. -# Note: make sure there are no name collisions in the names of registered projects +# by editing the (auto-generated) project configuration file `/path/project/project/.serena/project.yml` file. +# If you want to maintain full control of the project configuration, create the project.yml file manually and then +# instruct Serena to activate the project by its path for first-time activation. +# NOTE: Make sure there are no name collisions in the names of registered projects. projects: [] diff --git a/src/serena/agent.py b/src/serena/agent.py index 15124b55..0810448e 100644 --- a/src/serena/agent.py +++ b/src/serena/agent.py @@ -340,19 +340,10 @@ class SerenaConfig(SerenaConfigBase): num_project_migrations = 0 for path in loaded_commented_yaml["projects"]: path = Path(path).resolve() - if not path.exists(): - log.warning(f"Project path {path} does not exist, skipping.") + if not path.exists() or (path.is_dir() and not (path / ProjectConfig.rel_path_to_project_yml()).exists()): + log.warning(f"Project path {path} does not exist or does not contain a project configuration file, skipping.") continue - if path.is_dir(): - project_yml_path = path / ProjectConfig.rel_path_to_project_yml() - if not project_yml_path.exists(): - log.info(f"Project path {path} does not contain a project configuration file, creating one.") - ProjectConfig.autogenerate(path, save_to_disk=True) - continue if path.is_file(): - log.info( - f"Project path {path} is a file, migrating to in-project configuration. This is a legacy feature for backwards compatibility." - ) path = cls._migrate_out_of_project_config_file(path) if path is None: continue diff --git a/src/serena/util/general.py b/src/serena/util/general.py index b350ae18..bfddaf47 100644 --- a/src/serena/util/general.py +++ b/src/serena/util/general.py @@ -1,4 +1,3 @@ -import os from typing import Literal, overload from ruamel.yaml import YAML @@ -27,6 +26,5 @@ def load_yaml(path: str, preserve_comments: bool = False) -> dict | CommentedMap def save_yaml(path: str, data: dict | CommentedMap, preserve_comments: bool = False) -> None: yaml = _create_YAML(preserve_comments) - os.makedirs(os.path.dirname(path), exist_ok=True) with open(path, "w", encoding="utf-8") as f: yaml.dump(data, f)