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
+24 -7
View File
@@ -1,4 +1,6 @@
import { mkdirSync } from 'node:fs';
import { join } from 'node:path';
import { homedir } from 'node:os';
import { DATA_PATH } from './data-path';
import { syncSeedSkills } from './sync-skills';
import { syncSeedTools } from './sync-tools';
@@ -13,14 +15,29 @@ import { startWhatsAppBotIfConfigured } from './channels/whatsapp/bot';
mkdirSync(DATA_PATH, { recursive: true });
async function ensurePiInstalled(): Promise<boolean> {
try {
const proc = Bun.spawn(['pi', '--version'], { stdout: 'pipe', stderr: 'pipe' });
await proc.exited;
return proc.exitCode === 0;
} catch {
return false;
/** Check common locations for the Pi package directory. */
async function findPiPackageDir(): Promise<string | null> {
const candidates = [
join(homedir(), '.npm-global', 'lib', 'node_modules', '@mariozechner', 'pi-coding-agent'),
'/usr/local/lib/node_modules/@mariozechner/pi-coding-agent',
];
for (const dir of candidates) {
if (await Bun.file(join(dir, 'package.json')).exists()) return dir;
}
return null;
}
async function ensurePiInstalled(): Promise<boolean> {
const dir = await findPiPackageDir();
if (!dir) return false;
try {
const pkg = await Bun.file(join(dir, 'package.json')).json();
if (pkg.version) {
console.log(`[bootstrap] Pi found: ${pkg.version}`);
return true;
}
} catch {}
return false;
}
async function installPi(): Promise<boolean> {