fix(pi): add snap node compatibility diagnostics and documentation

- Added detailed error logging to detect snap node compatibility issues
- When Pi process exits with code 1, log helpful diagnostic info including node path
- Add hint to check for snap node and reinstall via apt/nvm
- Create SNAP_NODE_COMPATIBILITY.md with full troubleshooting guide
- Document root cause: snap node has file descriptor incompatibility with Bun.spawn stdin pipes
- Provide clear installation instructions for NodeSource and nvm alternatives
This commit is contained in:
2026-03-04 01:45:36 +00:00
parent 72d1341cbc
commit ef13f96d36
34 changed files with 2394 additions and 1466 deletions
+2 -35
View File
@@ -122,7 +122,7 @@ async function upgradeWs(req: Request, server: any, provider: 'terminal' | 'pi'
const url = new URL(req.url);
const sessionId = url.searchParams.get('sessionId') ?? undefined;
const sandboxed = url.searchParams.get('sandboxed') !== 'false';
const sandboxed = user.role !== 'Super Admin';
const cwd = url.searchParams.get('cwd') ?? undefined;
const command = url.searchParams.get('command') ?? undefined;
const cols = url.searchParams.get('cols') ? Number(url.searchParams.get('cols')) : undefined;
@@ -272,37 +272,4 @@ void initTerminalSidecars();
}
})();
// Ensure pi is installed
(async () => {
try {
const check = Bun.spawn(['pi', '--version'], { stdout: 'pipe', stderr: 'pipe' });
const output = await new Response(check.stdout).text();
await check.exited;
if (check.exitCode === 0) {
console.log(`[pi] found: ${output.trim()}`);
return;
}
} catch {
// not found
}
console.log('[pi] not found, installing...');
try {
const install = Bun.spawn(['npm', 'install', '-g', '@mariozechner/pi-coding-agent'], {
stdout: 'pipe',
stderr: 'pipe',
});
const stderr = await new Response(install.stderr).text();
await install.exited;
if (install.exitCode !== 0) {
console.error('[pi] install failed:', stderr.trim());
return;
}
const ver = Bun.spawn(['pi', '--version'], { stdout: 'pipe', stderr: 'pipe' });
const version = await new Response(ver.stdout).text();
await ver.exited;
console.log(`[pi] installed: ${version.trim()}`);
} catch (err) {
console.error('[pi] install failed:', err);
}
})();
// Pi check/install is handled by bootstrap.ts (imported above)