#!/usr/bin/env bun import { fileURLToPath } from "node:url"; import { runCli } from "./cli/runner.js"; import { isCompiledBinary, performRuntimeSelfHealing, resolveAppRoot, resolveDefaultLauncher } from "./core/runtime.js"; process.stdout.on("error", (err: any) => { if (err?.code === "EPIPE") process.exit(0); }); process.stderr.on("error", (err: any) => { if (err?.code === "EPIPE") process.exit(0); }); await performRuntimeSelfHealing(); const entryFile = fileURLToPath(import.meta.url); const isCompiled = isCompiledBinary(); const appRoot = resolveAppRoot(entryFile, isCompiled); const launcher = resolveDefaultLauncher(entryFile, isCompiled); const result = await runCli(Bun.argv.slice(2), { appRoot, entryFile, launcher }); try { if (result.stdout) process.stdout.write(result.stdout); } catch (err: any) { if (err?.code !== "EPIPE") throw err; } try { if (result.stderr) process.stderr.write(`${result.stderr}${result.stderr.endsWith("\n") ? "" : "\n"}`); } catch (err: any) { if (err?.code !== "EPIPE") throw err; } process.exitCode = result.exitCode;