Skip to content

Commit d7cee70

Browse files
johnml1135papehCopilot
authored
Serena project upgrade (#816)
* Serena project upgrade * Apply two suggestions from Copilot code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Serena config and setup guidance --------- Co-authored-by: papeh <hasso_pape@sil.org> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 4162a17 commit d7cee70

4 files changed

Lines changed: 152 additions & 46 deletions

File tree

.serena/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/cache
22
/logs
3+
/project.local.yml

.serena/project.yml

Lines changed: 68 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
1+
2+
13
# list of languages for which language servers are started; choose from:
2-
# al bash clojure cpp csharp csharp_omnisharp
3-
# dart elixir elm erlang fortran go
4-
# haskell java julia kotlin lua markdown
5-
# nix perl php python python_jedi r
6-
# rego ruby ruby_solargraph rust scala swift
7-
# terraform typescript typescript_vts zig
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
13+
# (This list may be outdated. For the current list, see values of Language enum here:
14+
# https://github.com/oraios/serena/blob/main/src/solidlsp/ls_config.py
15+
# For some languages, there are alternative language servers, e.g. csharp_omnisharp, ruby_solargraph.)
816
# Note:
917
# - For C, use cpp
1018
# - For JavaScript, use typescript
11-
# Language Server Details (Serena AUTO-DOWNLOADS these on first startup):
12-
# - csharp: Uses Microsoft.CodeAnalysis.LanguageServer (Roslyn) - same engine as VS Code's C# extension
13-
# Downloads from Azure NuGet feed; also downloads .NET 9 runtime if needed
14-
# ⚠️ KNOWN ISSUE: Fails on T-Mobile Home Internet due to IPv6 routing issues to Azure blob storage
15-
# - csharp_omnisharp: Uses OmniSharp (alternative) - also auto-downloads
16-
# - cpp: Uses clangd (auto-downloads v19.1.2 on Windows/Mac; Linux needs `apt install clangd`)
19+
# - For Free Pascal/Lazarus, use pascal
1720
# Special requirements:
18-
# - csharp: Requires the presence of a .sln file in the project folder.
21+
# Some languages require additional setup/installations.
22+
# See here for details: https://oraios.github.io/serena/01-about/020_programming-languages.html#language-servers
1923
# When using multiple languages, the first language server that supports a given file will be used for that file.
2024
# The first language is the default language and the respective language server will be used as a fallback.
2125
# Note that when using the JetBrains backend, language servers are not used and this list is correspondingly ignored.
22-
#
23-
# T-Mobile IPv6 workaround: Use csharp_omnisharp instead of csharp if you see Azure NuGet download errors.
24-
# The issue is that Python urllib prefers IPv6, and T-Mobile's IPv6 routing to Azure blob storage is broken.
2526
languages:
2627
- csharp_omnisharp
2728
- cpp
@@ -30,14 +31,12 @@ languages:
3031
# For a list of possible encodings, see https://docs.python.org/3.11/library/codecs.html#standard-encodings
3132
encoding: "utf-8"
3233

33-
# whether to use the project's gitignore file to ignore files
34-
# Added on 2025-04-07
34+
# whether to use project's .gitignore files to ignore files
3535
ignore_all_files_in_gitignore: true
3636

37-
# list of additional paths to ignore
38-
# same syntax as gitignore, so you can use * and **
39-
# Was previously called `ignored_dirs`, please update your config if you are using that.
40-
# Added (renamed) on 2025-04-07
37+
# list of additional paths to ignore in this project.
38+
# Same syntax as gitignore, so you can use * and **.
39+
# Note: global ignored_paths from serena_config.yml are also applied additively.
4140
ignored_paths:
4241
- Output/**
4342
- Obj/**
@@ -52,7 +51,20 @@ ignored_paths:
5251
# Added on 2025-04-18
5352
read_only: false
5453

55-
# list of tool names to exclude. We recommend not excluding any tools, see the readme for more details.
54+
# initial prompt for the project. It will always be given to the LLM upon activating the project
55+
# (contrary to the memories, which are loaded on demand).
56+
initial_prompt: |
57+
FieldWorks (FLEx) is a Windows/x64 linguistics suite by SIL International.
58+
Key repo facts:
59+
- Build with .\build.ps1; test with .\test.ps1.
60+
- FieldWorks.proj and FieldWorks.sln are the main build and solution entry points.
61+
- The codebase mixes native C++ and managed .NET; native builds must succeed before managed projects.
62+
- FieldWorks uses registration-free COM; do not add global COM registration hacks.
63+
- Keep localization in .resx and follow .github/instructions/*.instructions.md plus nearby AGENTS.md files.
64+
65+
# list of tool names to exclude.
66+
# This extends the existing exclusions (e.g. from the global configuration)
67+
#
5668
# Below is the complete list of tools for convenience.
5769
# To make sure you have the latest list of tools, and to view their descriptions,
5870
# execute `uv run scripts/print_tool_overview.py`.
@@ -86,20 +98,15 @@ read_only: false
8698
# * `restart_language_server`: Restarts the language server, may be necessary when edits not through Serena happen.
8799
# * `search_for_pattern`: Performs a search for a pattern in the project.
88100
# * `summarize_changes`: Provides instructions for summarizing the changes made to the codebase.
89-
# initial prompt for the project. It will always be given to the LLM upon activating the project
90-
# (contrary to the memories, which are loaded on demand).
91-
initial_prompt: |
92-
FieldWorks (FLEx) is a Windows-first linguistics suite by SIL International.
93-
Key build facts:
94-
- Uses MSBuild Traversal SDK via FieldWorks.proj (21 ordered phases, 110+ projects)
95-
- Native C++ (Phase 2) must build before managed code (Phases 3+)
96-
- Build command: .\build.ps1 or msbuild FieldWorks.proj /p:Configuration=Debug /p:Platform=x64 /m
97-
- Check .github/instructions/*.instructions.md for coding guidelines (managed, native, testing, etc.)
98-
- Per-folder AGENTS.md files describe component contracts and dependencies
99-
# project_name: Intentionally left out so that the folder name will be used and worktrees will not conflict
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.
100106
excluded_tools: []
101107

102-
# list of tools to include that would otherwise be disabled (particularly optional tools that are disabled by default)
108+
# list of tools to include that would otherwise be disabled (particularly optional tools that are disabled by default).
109+
# This extends the existing inclusions (e.g. from the global configuration).
103110
included_optional_tools: []
104111

105112
# list of mode names to that are always to be included in the set of active modes
@@ -120,9 +127,10 @@ default_modes:
120127
# fixed set of tools to use as the base tool set (if non-empty), replacing Serena's default set of tools.
121128
# This cannot be combined with non-empty excluded_tools or included_optional_tools.
122129
fixed_tools: []
123-
# the name by which the project can be referenced within Serena
124-
project_name: FieldWorks
125130

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.
126134

127135
# time budget (seconds) per tool call for the retrieval of additional symbol information
128136
# such as docstrings or parameter information.
@@ -136,3 +144,26 @@ symbol_info_budget:
136144
# Note: the backend is fixed at startup. If a project with a different backend
137145
# is activated post-init, an error will be returned.
138146
language_backend:
147+
148+
# line ending convention to use when writing source files.
149+
# Possible values: unset (use global setting), "lf", "crlf", or "native" (platform default)
150+
# This does not affect Serena's own files (e.g. memories and configuration files), which always use native line endings.
151+
line_ending:
152+
153+
# list of regex patterns which, when matched, mark a memory entry as read-only.
154+
# Extends the list from the global configuration, merging the two lists.
155+
read_only_memory_patterns: []
156+
157+
# list of regex patterns for memories to completely ignore.
158+
# Matching memories will not appear in list_memories or activate_project output
159+
# and cannot be accessed via read_memory or write_memory.
160+
# To access ignored memory files, use the read_file tool on the raw file path.
161+
# Extends the list from the global configuration, merging the two lists.
162+
# Example: ["_archive/.*", "_episodes/.*"]
163+
ignored_memory_patterns: []
164+
165+
# advanced configuration option allowing to configure language server-specific options.
166+
# Maps the language key to the options.
167+
# 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.
168+
# No documentation on options means no options are available.
169+
ls_specific_settings: {}

Build/Agent/Setup-Serena.ps1

Lines changed: 72 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,53 @@ function Set-EnvVar {
7070
}
7171
}
7272

73+
function Get-ConfiguredLanguages {
74+
param([string]$ConfigContent)
75+
76+
$languages = @()
77+
$inLanguagesBlock = $false
78+
79+
foreach ($line in ($ConfigContent -split "`r?`n")) {
80+
if (-not $inLanguagesBlock) {
81+
if ($line -match '^\s*languages:\s*$') {
82+
$inLanguagesBlock = $true
83+
}
84+
continue
85+
}
86+
87+
if ($line -match '^\s*-\s*(.+?)\s*$') {
88+
$languages += $matches[1].Trim()
89+
continue
90+
}
91+
92+
if ($line -match '^\s*$' -or $line -match '^\s*#') {
93+
continue
94+
}
95+
96+
break
97+
}
98+
99+
return $languages
100+
}
101+
102+
function Get-ConfiguredProjectName {
103+
param(
104+
[string]$ConfigContent,
105+
[string]$DefaultProjectName
106+
)
107+
108+
foreach ($line in ($ConfigContent -split "`r?`n")) {
109+
if ($line -match '^\s*project_name:\s*(.+?)\s*$') {
110+
$value = $matches[1].Trim()
111+
if ($value) {
112+
return $value.Trim('"', "'")
113+
}
114+
}
115+
}
116+
117+
return $DefaultProjectName
118+
}
119+
73120
# ============================================================================
74121
# MAIN SCRIPT
75122
# ============================================================================
@@ -135,21 +182,39 @@ Write-Host "--- Step 2: Serena Configuration ---" -ForegroundColor Cyan
135182
if (Test-Path $serenaConfig) {
136183
Write-Status "Found .serena/project.yml" -Status "OK"
137184

138-
# Show configured languages
185+
# Show configured languages and project identity
139186
$configContent = Get-Content $serenaConfig -Raw
140-
if ($configContent -match 'programming_languages:\s*\[([^\]]+)\]') {
141-
$languages = $matches[1]
142-
Write-Status "Configured languages: $languages"
187+
$languages = Get-ConfiguredLanguages -ConfigContent $configContent
188+
$defaultProjectName = Split-Path -Leaf $repoRoot
189+
$projectName = Get-ConfiguredProjectName -ConfigContent $configContent -DefaultProjectName $defaultProjectName
190+
191+
if ($languages.Count -gt 0) {
192+
Write-Status ("Configured languages: {0}" -f ($languages -join ', '))
193+
}
194+
else {
195+
Write-Status "No languages found in .serena/project.yml" -Status "WARN"
196+
}
197+
198+
if ($configContent -match '^\s*project_name:\s*' -and $projectName) {
199+
Write-Status "Configured project name: $projectName"
200+
}
201+
else {
202+
Write-Status "Project name defaults to worktree folder: $projectName"
143203
}
144204
}
145205
else {
146206
Write-Status "Missing .serena/project.yml - Serena not configured" -Status "ERROR"
147207
Write-Host ""
148208
Write-Host "Create .serena/project.yml with:" -ForegroundColor Yellow
149209
Write-Host @"
150-
name: FieldWorks
151-
project_root: .
152-
programming_languages: [csharp_omnisharp, cpp]
210+
languages:
211+
- csharp_omnisharp
212+
- cpp
213+
"@
214+
Write-Host ""
215+
Write-Host "Optional per-worktree override (.serena/project.local.yml):" -ForegroundColor Yellow
216+
Write-Host @"
217+
project_name: $(Split-Path -Leaf $repoRoot)
153218
"@
154219
exit 1
155220
}

Docs/mcp.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ each worktree contains its own `.serena/project.yml` file (shared via git). This
5353
issues when Serena auto-discovers projects:
5454

5555
### Symptoms
56-
- `get_current_config` shows multiple projects named "FieldWorks"
56+
- `get_current_config` shows multiple FieldWorks worktrees registered, or a project name that does not match the current folder
5757
- Language server errors that don't match your current worktree
5858
- Serena loads projects from worktrees you're not currently working in
5959

@@ -62,8 +62,12 @@ 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.
68+
6569
### Solution
66-
**Use only workspace-level Serena**
70+
**Use only workspace-level Serena, and keep project names local to the worktree**
6771

6872
Remove or disable the Serena entry from your user-level MCP config:
6973
```powershell
@@ -73,6 +77,10 @@ code "$env:APPDATA\Code\User\mcp.json"
7377
Remove the `"oraios/serena"` entry. The workspace `.vscode/mcp.json` provides Serena
7478
with explicit project targeting.
7579

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`.
83+
7684
## Best-practice profile for this repo
7785

7886
- Keep repo-level MCP servers minimal: `github` + `serena` only.
@@ -85,6 +93,7 @@ with explicit project targeting.
8593
- Open one VS Code window per worktree; let that window use its own workspace `.vscode/mcp.json`.
8694
- Keep only one Serena server definition active (workspace-level), and remove user-level Serena.
8795
- 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`.
8897
- After switching worktrees, run **MCP: Reset Cached Tools** if tool lists or capabilities look stale.
8998
- No extra GitHub MCP worktree settings are required beyond OAuth sign-in.
9099

0 commit comments

Comments
 (0)