From cf92c10eda651cdad882aa050439c80d2f40b4b1 Mon Sep 17 00:00:00 2001 From: Aman Kumar <145339995+amankumarsingh77@users.noreply.github.com> Date: Sun, 12 Jul 2026 22:03:43 +0530 Subject: fix: make browser daemon setup work on Windows (#7) (#12) The Unix socket daemon introduced in v0.6.0 made several POSIX-only assumptions that break setup on Windows: - protocol.ts hardcoded a Unix socket path (/tmp/pi-browser-daemon.sock). Node IPC on Windows requires a named pipe (\\.\pipe\); a /tmp path is not a valid net listen/connect target there. - spawn.ts spawned the bare tsx binary / `npx` and probed the non-Windows .bin/tsx shim. On Windows npm binaries are .cmd shims that must run via a shell, and spawning them directly fails with EINVAL / ENOENT. - isDaemonRunning() pre-checked the socket with fs.access(), which always fails for a named pipe and would report a live daemon as dead. - stale-socket unlink() would throw on a named pipe path. Changes: - DAEMON_SOCKET_PATH is now platform-aware: named pipe on win32, Unix socket elsewhere. - spawnDaemon() resolves tsx.cmd / npx.cmd on Windows, runs via shell with per-token quoting (paths with spaces) and windowsVerbatimArguments. - isDaemonRunning() skips the fs.access pre-check on Windows and probes the pipe directly. - stale-socket cleanup is a no-op on Windows (named pipes self-clean). - setup.ts daemon-failure message uses the actual DAEMON_SOCKET_PATH. Closes #7 --- src/setup.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/setup.ts') diff --git a/src/setup.ts b/src/setup.ts index 561a343..1ff7c36 100644 --- a/src/setup.ts +++ b/src/setup.ts @@ -8,6 +8,7 @@ import type { ExtensionAPI } from "@mariozechner/pi-coding-agent"; import { execSync } from "node:child_process"; import type { BrowserClient } from "./client"; import { ensureDaemon } from "./daemon/spawn"; +import { DAEMON_SOCKET_PATH } from "./daemon/protocol"; // ── Public: register the /browser-setup slash command ────────────────────── @@ -41,7 +42,7 @@ export async function performSetup(client: BrowserClient): Promise // Step 2: Start the browser daemon (spawns if not running, silently reuses if alive) const daemonReady = await ensureDaemon(); if (!daemonReady) { - return { success: false, error: "Could not start the browser daemon. Check /tmp/pi-browser-daemon.sock." }; + return { success: false, error: `Could not start the browser daemon. Check ${DAEMON_SOCKET_PATH}.` }; } // Step 3: Connect to Chrome DevTools -- cgit v1.2.3