fix(prompt-hook): skip unsafe roots during subproject down-scan (#1454) (#1812)

Reuse unsafeIndexRootReason before scanning indexed subprojects so stray manifests at home or broader roots cannot inject unrelated context. Preserve workspace adoption for #964.

Validation: four new regressions fail before the guard and pass after it; 48 relevant tests and npm run build pass. Confirmed the real os.homedir() leak before and after the fix with fixture cleanup.

Co-authored-by: Colby McHenry <colbymchenry@users.noreply.github.com>
This commit is contained in:
Colby Mchenry
2026-09-08 20:41:32 -05:00
committed by GitHub
co-authored by Colby McHenry
parent 4453310eef
commit 3193800bc8
3 changed files with 37 additions and 3 deletions
+2
View File
@@ -213,6 +213,8 @@ export function findIndexedSubprojectRoots(
root: string,
opts: { maxDepth?: number; max?: number } = {},
): string[] {
// A stray workspace manifest must not enable scanning home or broader roots (#1454).
if (unsafeIndexRootReason(root) !== null) return [];
const maxDepth = opts.maxDepth ?? 4;
const max = opts.max ?? 64;
const out: string[] = [];