mirror of
https://github.com/tiennm99/serena.git
synced 2026-10-14 10:19:02 +00:00
Fix context and mode file detection logic
- Replace .yml extension check with proper file existence check - Check if path exists as a file first before treating as name - Raise FileNotFoundError for paths that look like files but don't exist (contains path separators or ends with .yml/.yaml) - Improves error messages when file paths are invalid
This commit is contained in:
1 parent
4cdc2a7405
commit
ff68b53397
1 file changed
+2
-10
@@ -131,11 +131,7 @@ class SerenaAgentMode(ToolInclusionDefinition, ToStringMixin):
|
||||
|
||||
# If it looks like a file path but doesn't exist, raise FileNotFoundError
|
||||
name_or_path_str = str(name_or_path)
|
||||
if (
|
||||
os.sep in name_or_path_str
|
||||
or (os.altsep and os.altsep in name_or_path_str)
|
||||
or name_or_path_str.endswith((".yml", ".yaml"))
|
||||
):
|
||||
if os.sep in name_or_path_str or (os.altsep and os.altsep in name_or_path_str) or name_or_path_str.endswith((".yml", ".yaml")):
|
||||
raise FileNotFoundError(f"Mode file not found: {path.resolve()}")
|
||||
|
||||
return cls.from_name(str(name_or_path))
|
||||
@@ -244,11 +240,7 @@ class SerenaAgentContext(ToolInclusionDefinition, ToStringMixin):
|
||||
|
||||
# If it looks like a file path but doesn't exist, raise FileNotFoundError
|
||||
name_or_path_str = str(name_or_path)
|
||||
if (
|
||||
os.sep in name_or_path_str
|
||||
or (os.altsep and os.altsep in name_or_path_str)
|
||||
or name_or_path_str.endswith((".yml", ".yaml"))
|
||||
):
|
||||
if os.sep in name_or_path_str or (os.altsep and os.altsep in name_or_path_str) or name_or_path_str.endswith((".yml", ".yaml")):
|
||||
raise FileNotFoundError(f"Context file not found: {path.resolve()}")
|
||||
|
||||
return cls.from_name(str(name_or_path))
|
||||
|
||||
Reference in new issue
Block a user