Wrap os.scandir() with PermissionError guard in _iter_gitignore_files'
scan() function to prevent crash when a subdirectory is not readable.
Previously, PermissionError on the scandir call itself crashed the
entire gitignore walker, even when the path was listed in ignored_paths.
Fixesoraios/serena#1624
Co-authored-by: Claude <noreply@anthropic.com>
Add activation_command to project config
Adds two optional fields to ProjectConfig:
- activation_command: shell command run in the project root before the
language backend (LSP or JetBrains) initialises
- activation_command_timeout: safety backstop (default 180s); on expiry
the process tree is killed and activation continues
The command is only executed for trusted projects (trusted_project_path_patterns).
Exit code is the primary completion signal; failures and timeouts are logged
but never abort activation (no return channel to the LLM at that point).
Closes#1606
---------
Co-authored-by: Dominik Jain <dominik.jain@oraios-ai.de>
* Introduce abstractions: FileCollection, FileProxy
* Unify handling of pattern search in project files
(source code vs. all files)
This prepares for processing of external files,
which can implement FileProxy differently.
A plain truncate-and-write (open(path,"w")) is not atomic: a concurrent writer
(a second Serena process updating the auto-managed registered-projects list) or an
interrupted write can leave the file half-overwritten -- a shorter value over a longer
one leaves a stale tail, corrupting the YAML so every later load fails. This is what
wedged native benchmark runs (serena MCP crashed at startup with a ruamel ScannerError
-> 0 tools registered -> agent silently degraded to Bash).
Write to a temp file in the same dir, then os.replace onto the target (atomic;
last-writer-wins, never a corrupt interleave). Retry os.replace on Windows
PermissionError (WinError 5/32 sharing violation under contention). Adds
test/serena/util/test_yaml.py covering the shorter-over-longer corruption signature
plus a concurrent-writers stress.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Render the system prompt without activating a project: `project` is now an
optional positional (default None -> project-independent prompt). Drop the
--log-level option / logging.configure call so CLI logging stays off and only
the prompt reaches stdout, and remove two stray debug print()s
(default_modes/base_modes) that leaked onto stdout. IDE autostart is already
disabled here via with_headless_mode_overrides() (it nulls
jetbrains_launch_command). Also drop an accidental unused sqlalchemy import.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>