From ba74c059700e6d2641a877110d00d61f6ffcbb3d Mon Sep 17 00:00:00 2001 From: Michael Panchenko Date: Mon, 23 Jun 2025 21:00:20 +0200 Subject: [PATCH 1/5] Removed javascript from languages (just ts is enough), enhanced ts file matching --- src/solidlsp/ls.py | 2 +- src/solidlsp/ls_config.py | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/solidlsp/ls.py b/src/solidlsp/ls.py index 0d4dcaa8..cf5f3bb1 100644 --- a/src/solidlsp/ls.py +++ b/src/solidlsp/ls.py @@ -144,7 +144,7 @@ class SolidLanguageServer(ABC): return OmniSharp(config, logger, repository_root_path) - elif config.code_language in [Language.TYPESCRIPT, Language.JAVASCRIPT]: + elif config.code_language == Language.TYPESCRIPT: from solidlsp.language_servers.typescript_language_server.typescript_language_server import ( TypeScriptLanguageServer, ) diff --git a/src/solidlsp/ls_config.py b/src/solidlsp/ls_config.py index 27deaf15..abe9e273 100644 --- a/src/solidlsp/ls_config.py +++ b/src/solidlsp/ls_config.py @@ -32,7 +32,6 @@ class Language(str, Enum): JAVA = "java" KOTLIN = "kotlin" TYPESCRIPT = "typescript" - JAVASCRIPT = "javascript" GO = "go" RUBY = "ruby" DART = "dart" @@ -49,9 +48,13 @@ class Language(str, Enum): case self.JAVA: return FilenameMatcher("*.java") case self.TYPESCRIPT: - return FilenameMatcher("*.ts", "*.js", "*.jsx", "*.tsx") - case self.JAVASCRIPT: - return FilenameMatcher("*.js", "*.jsx") + # see https://github.com/oraios/serena/issues/204 + path_patterns = [] + for prefix in ["c", "m", ""]: + for postfix in ["x", ""]: + for base_pattern in ["ts", "js"]: + path_patterns.append(f"*.{prefix}{base_pattern}{postfix}") + return FilenameMatcher(*path_patterns) case self.CSHARP: return FilenameMatcher("*.cs") case self.RUST: From 769fc798509fa67d77d9ffa7142f49ee1ecd5961 Mon Sep 17 00:00:00 2001 From: Michael Panchenko Date: Mon, 23 Jun 2025 21:05:05 +0200 Subject: [PATCH 2/5] Backwards compat restored for activating javascript projects [ci skip] --- src/serena/agent.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/serena/agent.py b/src/serena/agent.py index f2c09416..0ff552e1 100644 --- a/src/serena/agent.py +++ b/src/serena/agent.py @@ -177,12 +177,18 @@ class ProjectConfig(ToStringMixin): """ Create a ProjectConfig instance from a configuration dictionary """ + language_str = data["language"].lower() + project_name = data["project_name"] + # backwards compatibility + if language_str == "javascript": + log.warning(f"Found deprecated project language `javascript` in project {project_name}, please change to `typescript`") + language_str = "typescript" try: - language = Language(data["language"].lower()) + language = Language(language_str) except ValueError as e: raise ValueError(f"Invalid language: {data['language']}.\nValid languages are: {[l.value for l in Language]}") from e return cls( - project_name=data["project_name"], + project_name=project_name, language=language, ignored_paths=data.get("ignored_paths", []), excluded_tools=set(data.get("excluded_tools", [])), From 42a8796353d7a06e253ddfc04e18a4f195c45ce9 Mon Sep 17 00:00:00 2001 From: Michael Panchenko Date: Mon, 23 Jun 2025 21:22:59 +0200 Subject: [PATCH 3/5] search_for_pattern: better default and description of `restrict_search_to_code_files` param --- src/serena/agent.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/serena/agent.py b/src/serena/agent.py index 0ff552e1..114d3b0f 100644 --- a/src/serena/agent.py +++ b/src/serena/agent.py @@ -2131,7 +2131,7 @@ class SearchForPatternTool(Tool): context_lines_after: int = 0, paths_include_glob: str | None = None, paths_exclude_glob: str | None = None, - only_in_code_files: bool = True, + restrict_search_to_code_files: bool = False, max_answer_chars: int = _DEFAULT_MAX_ANSWER_LENGTH, ) -> str: """ @@ -2144,15 +2144,22 @@ class SearchForPatternTool(Tool): :param context_lines_after: Number of lines of context to include after each match :param paths_include_glob: optional glob pattern specifying files to include in the search; if not provided, search globally. :param paths_exclude_glob: optional glob pattern specifying files to exclude from the search (takes precedence over paths_include_glob). - :param only_in_code_files: whether to search only in code files or in the entire code base. - The explicitly ignored files (from serena config and gitignore) are never searched. :param max_answer_chars: if the output is longer than this number of characters, no content will be returned. Don't adjust unless there is really no other way to get the content required for the task. Instead, if the output is too long, you should make a stricter query. + :param restrict_search_to_code_files: whether to restrict the search to only those files where + analyzed code symbols can be found. Otherwise, will search all non-ignored files. + Set this to True if your search is only meant to discover code that can be manipulated with symbolic tools. + For example, for finding classes or methods from a name pattern. + Setting to False is a better choice if you also want to search in non-code files, like in html or yaml files, + which is why it is the default. :return: A JSON object mapping file paths to lists of matched consecutive lines (with context, if requested). """ - if only_in_code_files: + # this was previously a kwarg and was true by default + # However, the LLM doesn't really know which files are taken into account by the language server + # and which onees + if restrict_search_to_code_files: matches = self.language_server.search_files_for_pattern( pattern=pattern, context_lines_before=context_lines_before, @@ -2165,6 +2172,7 @@ class SearchForPatternTool(Tool): project_root = self.get_project_root() rel_paths_to_search = [] for root, dirs, files in os.walk(project_root): + # don't explore ignored dirs dirs[:] = [d for d in dirs if not self.agent.path_is_gitignored(os.path.join(root, d))] for file in files: file_path = os.path.join(root, file) From ac4ef9911e3f8f6ef2bd126721f5a442b7d1472d Mon Sep 17 00:00:00 2001 From: Michael Panchenko Date: Mon, 23 Jun 2025 21:26:38 +0200 Subject: [PATCH 4/5] changelog [ci skip] --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 575952dd..00d50230 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ Status of the `main` branch. Changes prior to the next official version change w * The MCP server is the only asynchronous component now, which resolves cross-component loop contamination, such that process isolation is no longer required. Neither are non-graceful shutdowns on Windows. +* Better default and description for restricting the search in `search_for_pattern` Fixes: * Fix `ExecuteShellCommandTool` and `GetCurrentConfigTool` hanging on Windows From 1de0a186ce69c873b3c2775cf974d9e58e373e6f Mon Sep 17 00:00:00 2001 From: Michael Panchenko Date: Mon, 23 Jun 2025 21:29:20 +0200 Subject: [PATCH 5/5] Bumped cache version [ci skip] --- src/solidlsp/ls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/solidlsp/ls.py b/src/solidlsp/ls.py index cf5f3bb1..e9df1358 100644 --- a/src/solidlsp/ls.py +++ b/src/solidlsp/ls.py @@ -1533,7 +1533,7 @@ class SolidLanguageServer(ABC): """ The path to the cache file for the document symbols. """ - return Path(self.repository_root_path) / ".serena" / "cache" / self.language_id / "document_symbols_cache_v20-05-25.pkl" + return Path(self.repository_root_path) / ".serena" / "cache" / self.language_id / "document_symbols_cache_v23-06-25.pkl" def index_repository(self, progress_bar: bool = True, save_after_n_files: int = 10) -> None: """Will go through the entire repository and "index" all files, meaning save their symbols to the cache.