Skip to content

Commit f69a9fa

Browse files
johnml1135jasonleenaylorCopilot
authored
Clean up workspace settings and stabilize Serena worktree setup (#884)
* Stabilize Serena worktree setup Co-authored-by: Jason Naylor <jasonleenaylor@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 4d22684 commit f69a9fa

6 files changed

Lines changed: 304 additions & 74 deletions

File tree

.serena/project.yml

Lines changed: 44 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11

22

33
# list of languages for which language servers are started; choose from:
4-
# al bash clojure cpp csharp
5-
# csharp_omnisharp dart elixir elm erlang
6-
# fortran fsharp go groovy haskell
7-
# java julia kotlin lua markdown
8-
# matlab nix pascal perl php
9-
# php_phpactor powershell python python_jedi r
10-
# rego ruby ruby_solargraph rust scala
11-
# swift terraform toml typescript typescript_vts
12-
# vue yaml zig
4+
# al angular ansible bash clojure
5+
# cpp cpp_ccls crystal csharp csharp_omnisharp
6+
# dart elixir elm erlang fortran
7+
# fsharp go groovy haskell haxe
8+
# hlsl html java json julia
9+
# kotlin lean4 lua luau markdown
10+
# matlab msl nix ocaml pascal
11+
# perl php php_phpactor powershell python
12+
# python_jedi python_ty r rego ruby
13+
# ruby_solargraph rust scala scss solidity
14+
# swift systemverilog terraform toml typescript
15+
# typescript_vts vue yaml zig
1316
# (This list may be outdated. For the current list, see values of Language enum here:
1417
# https://github.com/oraios/serena/blob/main/src/solidlsp/ls_config.py
1518
# For some languages, there are alternative language servers, e.g. csharp_omnisharp, ruby_solargraph.)
1619
# Note:
1720
# - For C, use cpp
1821
# - For JavaScript, use typescript
22+
# - For Angular projects, use angular (subsumes typescript+html; requires `npm install` in the project root)
23+
# - For SCSS / Sass / plain CSS, use scss (some-sass-language-server handles all three)
1924
# - For Free Pascal/Lazarus, use pascal
2025
# Special requirements:
2126
# Some languages require additional setup/installations.
@@ -64,49 +69,12 @@ initial_prompt: |
6469
6570
# list of tool names to exclude.
6671
# This extends the existing exclusions (e.g. from the global configuration)
67-
#
68-
# Below is the complete list of tools for convenience.
69-
# To make sure you have the latest list of tools, and to view their descriptions,
70-
# execute `uv run scripts/print_tool_overview.py`.
71-
#
72-
# * `activate_project`: Activates a project by name.
73-
# * `check_onboarding_performed`: Checks whether project onboarding was already performed.
74-
# * `create_text_file`: Creates/overwrites a file in the project directory.
75-
# * `delete_lines`: Deletes a range of lines within a file.
76-
# * `delete_memory`: Deletes a memory from Serena's project-specific memory store.
77-
# * `execute_shell_command`: Executes a shell command.
78-
# * `find_referencing_code_snippets`: Finds code snippets in which the symbol at the given location is referenced.
79-
# * `find_referencing_symbols`: Finds symbols that reference the symbol at the given location (optionally filtered by type).
80-
# * `find_symbol`: Performs a global (or local) search for symbols with/containing a given name/substring (optionally filtered by type).
81-
# * `get_current_config`: Prints the current configuration of the agent, including the active and available projects, tools, contexts, and modes.
82-
# * `get_symbols_overview`: Gets an overview of the top-level symbols defined in a given file.
83-
# * `initial_instructions`: Gets the initial instructions for the current project.
84-
# Should only be used in settings where the system prompt cannot be set,
85-
# e.g. in clients you have no control over, like Claude Desktop.
86-
# * `insert_after_symbol`: Inserts content after the end of the definition of a given symbol.
87-
# * `insert_at_line`: Inserts content at a given line in a file.
88-
# * `insert_before_symbol`: Inserts content before the beginning of the definition of a given symbol.
89-
# * `list_dir`: Lists files and directories in the given directory (optionally with recursion).
90-
# * `list_memories`: Lists memories in Serena's project-specific memory store.
91-
# * `onboarding`: Performs onboarding (identifying the project structure and essential tasks, e.g. for testing or building).
92-
# * `prepare_for_new_conversation`: Provides instructions for preparing for a new conversation (in order to continue with the necessary context).
93-
# * `read_file`: Reads a file within the project directory.
94-
# * `read_memory`: Reads the memory with the given name from Serena's project-specific memory store.
95-
# * `remove_project`: Removes a project from the Serena configuration.
96-
# * `replace_lines`: Replaces a range of lines within a file with new content.
97-
# * `replace_symbol_body`: Replaces the full definition of a symbol.
98-
# * `restart_language_server`: Restarts the language server, may be necessary when edits not through Serena happen.
99-
# * `search_for_pattern`: Performs a search for a pattern in the project.
100-
# * `summarize_changes`: Provides instructions for summarizing the changes made to the codebase.
101-
# * `switch_modes`: Activates modes by providing a list of their names
102-
# * `think_about_collected_information`: Thinking tool for pondering the completeness of collected information.
103-
# * `think_about_task_adherence`: Thinking tool for determining whether the agent is still on track with the current task.
104-
# * `think_about_whether_you_are_done`: Thinking tool for determining whether the task is truly completed.
105-
# * `write_memory`: Writes a named memory (for future reference) to Serena's project-specific memory store.
72+
# Find the list of tools here: https://oraios.github.io/serena/01-about/035_tools.html
10673
excluded_tools: []
10774

10875
# list of tools to include that would otherwise be disabled (particularly optional tools that are disabled by default).
10976
# This extends the existing inclusions (e.g. from the global configuration).
77+
# Find the list of tools here: https://oraios.github.io/serena/01-about/035_tools.html
11078
included_optional_tools: []
11179

11280
# list of mode names to that are always to be included in the set of active modes
@@ -117,21 +85,21 @@ included_optional_tools: []
11785
# Set this to a list of mode names to always include the respective modes for this project.
11886
base_modes:
11987

120-
# list of mode names that are to be activated by default.
121-
# The full set of modes to be activated is base_modes + default_modes.
122-
# If the setting is undefined, the default_modes from the global configuration (serena_config.yml) apply.
88+
# list of mode names that are to be activated by default, overriding the setting in the global configuration.
89+
# The full set of modes to be activated is base_modes (from global config) + default_modes + added_modes.
90+
# If the setting is undefined/empty, the default_modes from the global configuration (serena_config.yml) apply.
12391
# Otherwise, this overrides the setting from the global configuration (serena_config.yml).
92+
# Therefore, you can set this to [] if you do not want the default modes defined in the global config to apply
93+
# for this project.
12494
# This setting can, in turn, be overridden by CLI parameters (--mode).
95+
# See https://oraios.github.io/serena/02-usage/050_configuration.html#modes
12596
default_modes:
12697

12798
# fixed set of tools to use as the base tool set (if non-empty), replacing Serena's default set of tools.
12899
# This cannot be combined with non-empty excluded_tools or included_optional_tools.
100+
# Find the list of tools here: https://oraios.github.io/serena/01-about/035_tools.html
129101
fixed_tools: []
130102

131-
# project_name is intentionally omitted in shared config so Serena falls back to the
132-
# worktree folder name and multiple FieldWorks worktrees stay distinct.
133-
# If you need an explicit local override, put it in .serena/project.local.yml.
134-
135103
# time budget (seconds) per tool call for the retrieval of additional symbol information
136104
# such as docstrings or parameter information.
137105
# This overrides the corresponding setting in the global configuration; see the documentation there.
@@ -167,3 +135,24 @@ ignored_memory_patterns: []
167135
# Have a look at the docstring of the constructors of the LS implementations within solidlsp (e.g., for C# or PHP) to see which options are available.
168136
# No documentation on options means no options are available.
169137
ls_specific_settings: {}
138+
139+
# list of mode names to be activated additionally for this project, e.g. ["query-projects"]
140+
# The full set of modes to be activated is base_modes (from global config) + default_modes + added_modes.
141+
# See https://oraios.github.io/serena/02-usage/050_configuration.html#modes
142+
added_modes:
143+
144+
# list of additional workspace folder paths for cross-package reference support (e.g. in monorepos).
145+
# Paths can be absolute or relative to the project root.
146+
# Each folder is registered as an LSP workspace folder, enabling language servers to discover
147+
# symbols and references across package boundaries.
148+
# Currently supported for: TypeScript.
149+
# Example:
150+
# additional_workspace_folders:
151+
# - ../sibling-package
152+
# - ../shared-lib
153+
additional_workspace_folders: []
154+
# Keep a stable shared project_name here because current Serena rewrites incomplete
155+
# project.yml files and auto-adds this field if it is missing.
156+
# If you need a per-worktree name, override project_name in ignored
157+
# .serena/project.local.yml instead of editing the shared file.
158+
project_name: FieldWorks

.vscode/tasks.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
"label": "Setup: Colorize Worktree",
108108
"type": "shell",
109109
"command": "./scripts/Setup-WorktreeColor.ps1 -VSCodeWorkspaceFile \"${workspaceFile}\"",
110-
"detail": "Sets a unique window color from a deterministic palette slot",
110+
"detail": "Sets a unique window color from a rotating palette slot",
111111
"runOptions": {
112112
"runOn": "folderOpen"
113113
},
@@ -435,6 +435,10 @@
435435
"args": ["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command"]
436436
}
437437
},
438+
"presentation": {
439+
"reveal": "never",
440+
"panel": "shared"
441+
},
438442
"problemMatcher": []
439443
},
440444
{

Build/Agent/Setup-Serena.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ if (Test-Path $serenaConfig) {
195195
Write-Status "No languages found in .serena/project.yml" -Status "WARN"
196196
}
197197

198-
if ($configContent -match '^\s*project_name:\s*' -and $projectName) {
198+
if ($configContent -match '(?m)^\s*project_name:\s*' -and $projectName) {
199199
Write-Status "Configured project name: $projectName"
200200
}
201201
else {

Docs/mcp.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,13 @@ VS Code's user-level MCP config (`%APPDATA%\Code\User\mcp.json`) may have a Sere
6262
server that auto-discovers projects by scanning for `.serena` folders. Combined with
6363
workspace-level `mcp.json`, this creates duplicate project registrations.
6464

65-
This repo's shared `.serena/project.yml` intentionally leaves `project_name` unset so
66-
Serena falls back to the worktree folder name by default. That keeps worktrees easier
67-
to distinguish when multiple registrations exist.
65+
Current Serena releases normalize incomplete `project.yml` files and will write
66+
`project_name` back into the shared config if it is missing. To avoid that churn,
67+
this repo keeps a stable shared `project_name` in `.serena/project.yml`.
68+
69+
For worktree-specific naming, use the ignored `.serena/project.local.yml` file in
70+
each worktree to override `project_name` locally. That keeps Serena names distinct
71+
without causing repeated edits to the versioned config.
6872

6973
### Solution
7074
**Use only workspace-level Serena, and keep project names local to the worktree**
@@ -77,9 +81,12 @@ code "$env:APPDATA\Code\User\mcp.json"
7781
Remove the `"oraios/serena"` entry. The workspace `.vscode/mcp.json` provides Serena
7882
with explicit project targeting.
7983

80-
If you want a friendlier project name than the folder name, set it in
81-
`.serena/project.local.yml` for that worktree instead of committing a shared
82-
`project_name` in `.serena/project.yml`.
84+
If you want a worktree-specific Serena project name, set it in
85+
`.serena/project.local.yml` for that worktree. For example:
86+
87+
```yaml
88+
project_name: 010-advanced-entry-view
89+
```
8390
8491
## Best-practice profile for this repo
8592
@@ -93,7 +100,7 @@ If you want a friendlier project name than the folder name, set it in
93100
- Open one VS Code window per worktree; let that window use its own workspace `.vscode/mcp.json`.
94101
- Keep only one Serena server definition active (workspace-level), and remove user-level Serena.
95102
- Keep Serena pinned to the active workspace via `--project ${workspaceFolder}` (already configured).
96-
- If you want an explicit Serena project name, set it in `.serena/project.local.yml`; do not commit a shared `project_name` in `.serena/project.yml`.
103+
- If you want a worktree-specific Serena project name, set it in `.serena/project.local.yml`; keep the shared `.serena/project.yml` complete so Serena does not rewrite it.
97104
- After switching worktrees, run **MCP: Reset Cached Tools** if tool lists or capabilities look stale.
98105
- No extra GitHub MCP worktree settings are required beyond OAuth sign-in.
99106

0 commit comments

Comments
 (0)