fix non-node worktree agent startup

This commit is contained in:
gsxdsm
2026-04-12 22:34:46 -07:00
parent 6ab4a899e6
commit f88d04ae03
3 changed files with 34 additions and 11 deletions

View File

@@ -292,11 +292,23 @@ async function isRegisteredGitWorktree(projectRoot: string, worktreePath: string
}
}
async function isCompleteGitWorktree(worktreePath: string): Promise<boolean> {
try {
const { stdout } = await execAsync("git rev-parse --show-toplevel", {
cwd: worktreePath,
encoding: "utf-8",
});
return resolve(stdout.trim()) === resolve(worktreePath);
} catch {
return false;
}
}
async function assertValidWorktreeSession(cwd: string, projectRoot: string): Promise<void> {
if (!existsSync(cwd)) {
throw new Error(`Refusing to start coding agent in missing worktree: ${cwd}`);
}
if (!existsSync(join(cwd, ".git")) || !existsSync(join(cwd, "package.json"))) {
if (!existsSync(join(cwd, ".git")) || !await isCompleteGitWorktree(cwd)) {
throw new Error(`Refusing to start coding agent in incomplete worktree: ${cwd}`);
}
if (!await isRegisteredGitWorktree(projectRoot, cwd)) {