fix: eliminate child process spawns during session startup (#162)

getAvailablePackageManagers() spawned where.exe/which for each package
manager (npm, pnpm, yarn, bun). During SessionStart hooks, these 4+
child processes combined with Bun's own initialization exceeded the
spawn limit on Windows, freezing the terminal.

Fix: Remove process spawning from the hot path. Steps 1-5 of detection
(env var, project config, package.json, lock file, global config) already
cover all file-based detection. If none match, default to npm without
spawning. Also fix getSelectionPrompt() to list supported PMs without
checking availability.
This commit is contained in:
Affaan Mustafa
2026-02-12 00:01:23 -08:00
parent 0f1597dccf
commit 75ab8e6194
2 changed files with 21 additions and 26 deletions

View File

@@ -66,8 +66,8 @@ async function main() {
const pm = getPackageManager();
log(`[SessionStart] Package manager: ${pm.name} (${pm.source})`);
// If package manager was detected via fallback, show selection prompt
if (pm.source === 'fallback' || pm.source === 'default') {
// If no explicit package manager config was found, show selection prompt
if (pm.source === 'default') {
log('[SessionStart] No package manager preference found.');
log(getSelectionPrompt());
}