INNER CODE UNIT · TypeScript
portFree
AmrDab/clawdcursor · src/surface/cli.ts:295
const portFree = await new Promise<boolean>((resolve) => {
const tester = net.createServer()
.once('error', () => resolve(false))
.once('listening', () => { tester.close(); resolve(true); });
tester.listen(requestedPort, requestedHost);
});
if (!portFree) {
console.error(`\n${e('❌', '[ERR]')} Port ${requestedPort} is already in use.`);
console.error(`Another clawdcursor instance may be running.`);
console.error(`Run 'clawdcursor stop' first, or use --port <other_port>`);
process.exit(1);
}
// ── First-run auto-setup — best-effort, never fatal. ──
// If no AI providers are found we still boot: the MCP tool surface
// works fine without an LLM (the host's brain drives it).
//
// Skip auto-detect entirely when CLI flags already supply a usable