Merge branch 'main' of github.com:oraios/serena

This commit is contained in:
Dominik Jain committed 2025-06-23 21:40:20 +02:00
commit 15e835da75
4 files changed
+30 -12

No files matched your search

+1
View File
@@ -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
+20 -6
View File
@@ -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", [])),
@@ -2125,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:
"""
@@ -2138,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,
@@ -2159,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)
+2 -2
View File
@@ -139,7 +139,7 @@ class SolidLanguageServer(ABC):
ls = 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,
)
@@ -1536,7 +1536,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.
+7 -4
View File
@@ -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: