feat(worktree): add Git worktree support for isolated parallel sessions (#22973)

This commit is contained in:
Jerop Kipruto
2026-03-20 10:10:51 -04:00
committed by GitHub
parent 1f650a602f
commit 894190b0ca
23 changed files with 1090 additions and 9 deletions
@@ -48,16 +48,16 @@ export interface ProcessImportsResult {
importTree: MemoryFile;
}
// Helper to find the project root (looks for .git directory)
// Helper to find the project root (looks for .git directory or file for worktrees)
async function findProjectRoot(startDir: string): Promise<string> {
let currentDir = path.resolve(startDir);
while (true) {
const gitPath = path.join(currentDir, '.git');
try {
const stats = await fs.lstat(gitPath);
if (stats.isDirectory()) {
return currentDir;
}
// Check for existence only — .git can be a directory (normal repos)
// or a file (submodules / worktrees).
await fs.access(gitPath);
return currentDir;
} catch {
// .git not found, continue to parent
}