mirror of
https://github.com/tiennm99/serena.git
synced 2026-10-12 16:15:33 +00:00
Fix find_project_root hijacking git worktrees nested under a Serena project (#1550)
* Fix find_project_root hijacking git worktrees nested under a Serena project find_project_root searched all ancestor levels for .serena/project.yml before ever looking for .git. A git worktree whose own .git is a pointer file, nested under a directory that is an explicit Serena project, was resolved to the ancestor project instead of the worktree. With CLI agents that launch via --project-from-cwd (Claude Code, Codex, Gemini), this silently bound the server to the wrong working tree: reads returned stale symbols and edits landed in the parent repo. Walk up in a single pass so the nearest project boundary wins, whether it is a .serena/project.yml or a .git (dir or worktree/submodule pointer file). Same-level behavior is unchanged. Adds a regression test. * Document worktree project-root fix in changelog and usage docs
This commit is contained in:
1 parent
577931c8cf
commit
b5b9cc4ffc
5 files changed
+54
-9
No files matched your search
@@ -92,7 +92,9 @@ Some useful options include:
|
||||
|
||||
* `--project <path|name>`: specify the project to work on by name or path.
|
||||
* `--project-from-cwd`: auto-detect the project from current working directory
|
||||
(looking for a directory containing `.serena/project.yml` or `.git` in parent directories and activating the containing directory as the project root, if any).
|
||||
(walking up the parent directories and activating the nearest one that contains either `.serena/project.yml`
|
||||
or `.git`, if any). The nearest boundary wins, so a git worktree nested under another Serena project resolves
|
||||
to the worktree itself rather than the ancestor project.
|
||||
This option is intended for CLI-based agents like Claude Code, Gemini and Codex, which are typically started from within the project directory
|
||||
and which do not change directories during their operation.
|
||||
* `--language-backend JetBrains`: use the Serena JetBrains Plugin as the language backend (overriding the default backend configured in the central configuration)
|
||||
|
||||
@@ -14,3 +14,5 @@ having persisted the plan in a memory or dedicated file.
|
||||
[git-worktree](https://git-scm.com/docs/git-worktree) can be an excellent way to parallelize your work. More on this in [Anthropic: Run parallel Claude Code sessions with Git worktrees](https://docs.claude.com/en/docs/claude-code/common-workflows#run-parallel-claude-code-sessions-with-git-worktrees).
|
||||
|
||||
Be sure to add the `.serena` folder to version control, such that your project-specific settings and memories are available across worktrees.
|
||||
|
||||
When you launch a CLI agent from inside a worktree using `--project-from-cwd`, Serena activates the worktree itself, even if the worktree lives under another Serena project (for example `<repo>/.claude/worktrees/<name>`, where Claude Code creates them natively). The nearest project boundary wins: the worktree's own `.git` pointer file takes precedence over an ancestor's `.serena/project.yml`, so file operations always resolve against the correct working tree.
|
||||
Reference in new issue
Block a user