gitnexus 1.6.6-rc.19 → 1.6.6-rc.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -191,6 +191,26 @@ function tryRealpath(p) {
191
191
  */
192
192
  export function resolveWorktreeCwd(repoPath, launchCwd) {
193
193
  try {
194
+ // Verify repoPath is a git root before comparing against its canonical
195
+ // root. If getGitRoot returns a different path, repoPath is an arbitrary
196
+ // subdirectory — skip both the linked-worktree guard and auto-detection
197
+ // and fall through to the repoPath fallback.
198
+ const repoGitRoot = getGitRoot(repoPath);
199
+ const repoCanonical = repoGitRoot && tryRealpath(repoGitRoot) === tryRealpath(repoPath)
200
+ ? getCanonicalRepoRoot(repoPath)
201
+ : null;
202
+ // Early exit: if repoPath is a linked worktree (differs from its canonical
203
+ // main-checkout root), return it unchanged. Do NOT override it with the
204
+ // server's launch directory — that would silently replace the explicitly-
205
+ // resolved worktree index with the main checkout.
206
+ //
207
+ // getCanonicalRepoRoot returns the main-checkout path for both the checkout
208
+ // and all linked worktrees:
209
+ // repoPath === canonical → main checkout (auto-detect may fire below)
210
+ // repoPath !== canonical → linked worktree (return as-is)
211
+ if (repoCanonical && tryRealpath(repoPath) !== tryRealpath(repoCanonical)) {
212
+ return repoPath;
213
+ }
194
214
  const launchGitRoot = getGitRoot(launchCwd);
195
215
  if (launchGitRoot) {
196
216
  // Normalise via realpathSync before comparing so macOS /var → /private/var
@@ -199,8 +219,10 @@ export function resolveWorktreeCwd(repoPath, launchCwd) {
199
219
  const realRepo = tryRealpath(repoPath);
200
220
  if (realLaunch !== realRepo) {
201
221
  const launchCanonical = getCanonicalRepoRoot(launchCwd);
202
- const repoCanonical = getCanonicalRepoRoot(repoPath);
203
- if (launchCanonical && repoCanonical && launchCanonical === repoCanonical) {
222
+ // Use tryRealpath on both canonical values for cross-platform safety.
223
+ if (launchCanonical &&
224
+ repoCanonical &&
225
+ tryRealpath(launchCanonical) === tryRealpath(repoCanonical)) {
204
226
  return launchGitRoot;
205
227
  }
206
228
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitnexus",
3
- "version": "1.6.6-rc.19",
3
+ "version": "1.6.6-rc.20",
4
4
  "description": "Graph-powered code intelligence for AI agents. Index any codebase, query via MCP or CLI.",
5
5
  "author": "Abhigyan Patwari",
6
6
  "license": "PolyForm-Noncommercial-1.0.0",