Repository navigation
fix: relative paths in a git worktree resolve against that worktree (0.53.1) - #70
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reported from a real session: it started in the main checkout, moved into
.worktrees/dev4320-impl, and from then on token-pilot returned the maincheckout's version of every file read by relative path — code from another
branch, with nothing to show it. It happened on a payment code path during a
rebase.
Cause: the MCP server fixes its project root once, at start-up
(
CLAUDE_PROJECT_DIR), and resolves every relative path against it. Rootauto-detection only runs for a "dangerous" root, and
roots/list_changeddeliberately never re-points a session that already has one — so moving into a
worktree goes unnoticed.
Fix
session's current directory and applies
updatedInputto MCP calls (bothverified live on 2.1.281). When the session is in a different checkout from the
server, the hook resolves relative
path/pathsagainst the checkout thesession is in. In the server's own checkout it prints nothing. It has its own
entry point: 23 ms per call instead of ~200 ms through the full CLI.
runs — still answer from the server's checkout; in a worktree session they now
carry a note saying so. A per-worktree index is the follow-up.
repository, so a sibling checkout (
git worktree add ../feature) can be read.The session's own checkout keeps its old boundary.
fast-uriandip-addresspinned past two new production advisories.Verified live (headless Claude Code with this build, throwaway repository):
cd .worktrees/wt,smart_read("a.ts")returns theworktree's file, where the installed 0.53.0 returns the main checkout's;
project_overviewarrives with the note;"resolves outside project root".
Claude Code resets a Bash
cdthat leaves the project directory, so siblingworktrees are reached by absolute path or
--add-dir.19 new tests; full suite 1507/1507,
tsc --noEmitclean, audit clean.