feat(#153): compile-level Windows support + CI guard#161
Open
justrach wants to merge 4 commits into
Open
Conversation
Closed
92f583e to
95bd858
Compare
Windows users were hitting a generic "Unsupported OS" error with no context. Add a Platform-support table to readme.md (macOS + Linux only, WSL2 as fallback), and route win32 / MINGW / MSYS / CYGWIN through explicit messages in both install.sh and npm/bin/install.js that link issue #153. The npm self-test still passes — the existing `/unsupported platform: win32/` assertion still matches the new message. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`std.c.clock_gettime` and `std.c.isatty` are POSIX-only — they're the easiest sites blocking a `-Dtarget=x86_64-windows` build. Route the three time wrappers in src/compat.zig through a single `realtimeNanos()` that picks `GetSystemTimeAsFileTime` on Windows and `clock_gettime` on POSIX. Add `compat.isTtyStderr()` using `GetConsoleMode` on Windows and `isatty(2)` on POSIX, and switch the three call sites in browse_main, fetch_main, and server/api_token to it. macOS build + tests unchanged (the Windows branch is comptime-unreachable on non-Windows targets). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…s-gnu` is green (#153) Adds enough cross-platform and stub code to make all five binaries (`kuri`, `kuri-agent`, `kuri-browse`, `kuri-fetch`, `merjs-e2e`) build clean for `x86_64-windows-gnu`. macOS + Linux builds are unchanged. What works on Windows: - Realtime clock, monotonic sleep, TTY detection (compat.zig). - Mutex / RwLock via Win32 SRWLOCK instead of pthread. - Stdout/stderr writes via `WriteFile(GetStdHandle(...))`. - `--version` / `--help` paths through `main` for each binary. What is stubbed with `error.UnsupportedOnWindows` on Windows (returns the error at runtime; does not silently no-op): - `compat.cwd*` file ops, `compat.runCommand`, `compat.tcp*` / `TcpStream` / `TcpServer` (raw BSD-socket code). - `chrome/launcher.zig` Chrome spawn + reaper (uses `fork`+`SIG.KILL`). - `cdp/websocket.zig` connect + raw socket read; `cdp/client.zig` `drainWsEvents`. - `server/router.zig` `discoverTabs` (uses `std.posix.setsockopt` and `std.posix.read` on the raw CDP socket); gets an explicit `DiscoverTabsError` so the handler's switch stays exhaustive on both platforms. - `storage/auth_profiles.zig` `deleteProfile` / `listProfiles` (uses POSIX `opendir`/`readdir`). - `server/api_token.zig` `writeMode0600` (uses POSIX `open` + `fchmod`). - `agent_main.zig` `cmdOpen` (fork+exec Chrome) and `fetchChromeTabs` (raw socket). - `browse_main.zig` `repl` (POSIX stdin fd) and `readLine` (`std.posix.read`). - `lifecycle.zig` `install` (POSIX `sigaction`). Real Chrome automation, signal-based shutdown, daemonization, the agent's HAR recorder, and the file-backed auth store are all follow-up work — none of them are wired up on Windows yet, but the build succeeds and a Windows binary will load and respond to `--version`/`--help` / static commands. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add a `windows-cross-compile` CI job that runs `zig build -Dtarget=x86_64-windows-gnu -Doptimize=ReleaseSafe` and asserts that all four user-facing binaries land as PE32+ executables. This pins the compile-level Windows baseline introduced in the previous commit so a future patch can't quietly re-introduce an ungated POSIX call (`fork`, `std.c.open`, raw `setsockopt`/`read` on a socket) without breaking CI. Also widen the readme Platform-support table: Windows is no longer "Not supported yet" but "Experimental — cross-compile only", with the runtime caveats (Chrome / daemonize / sockets stubbed) spelled out. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
95bd858 to
5ae45a0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #153.
Summary
Adds compile-level Windows support:
zig build -Dtarget=x86_64-windows-gnu -Doptimize=ReleaseSafeproduces all four user-facing PE32+ binaries (kuri.exe,kuri-agent.exe,kuri-browse.exe,kuri-fetch.exe) plusmerjs-e2e.exe. A newwindows-cross-compileCI job pins this baseline so a future refactor can't quietly re-introduce an ungated POSIX call (fork,std.c.open, rawsetsockopt/readon a socket) without breaking CI.macOS and Linux builds are unchanged; this is additive.
Commits
docs(install): mark Windows unsupported and link tracking issue #153— Original "punt" commit: a Platform-support table inreadme.md, plusMINGW*/MSYS*/CYGWIN*detection ininstall.shand awin32branch innpm/bin/install.jsso users get a tailored error pointing at this issue instead of a genericUnsupported OS. (The npm self-test still passes — the existing/unsupported platform: win32/assertion still matches the new message.)refactor(compat): cross-platform realtime clock + isatty (towards #153)— Routes the three time wrappers insrc/compat.zigthrough a singlerealtimeNanos()that picksGetSystemTimeAsFileTimeon Windows andclock_gettimeon POSIX. Addscompat.isTtyStderr()(GetConsoleModeon Windows,isatty(2)on POSIX). Switches the three call sites to it.feat(compat): compile-level Windows support— The big one. Adds enough cross-platform / stub code to make every Zig-side POSIX assumption Windows-compatible.ci(windows): cross-compile guard + docs update— The CI job + a more accurate readme entry ("Experimental — cross-compile only").What works on Windows
compat.zig).SRWLOCKinstead of pthread.WriteFile(GetStdHandle(...)).--version/--helppaths throughmainfor each binary.What's stubbed with
error.UnsupportedOnWindowsThese return an error at runtime, they do not silently no-op:
compat.cwd*file ops,compat.runCommand,compat.tcp*/TcpStream/TcpServer(raw BSD-socket code).chrome/launcher.zigChrome spawn + reaper (fork+SIG.KILL).cdp/websocket.zigconnect + raw socket read;cdp/client.zigdrainWsEvents.server/router.zigdiscoverTabs(rawsetsockopt/readon the CDP socket) — gets an explicitDiscoverTabsErrorso the handler's switch stays exhaustive on both platforms.storage/auth_profiles.zigdeleteProfile/listProfiles(POSIXopendir/readdir).server/api_token.zigwriteMode0600(POSIXopen+fchmod).agent_main.zigcmdOpen(fork+exec Chrome) andfetchChromeTabs(raw socket).browse_main.zigrepl(POSIX stdin fd) andreadLine(std.posix.read).lifecycle.ziginstall(POSIXsigaction).Out of scope for this PR (follow-up Windows work)
CreateProcess+JobObjectfor cleanup).CreateProcesswithDETACHED_PROCESS).SetConsoleCtrlHandler).windows-latestjob, not just cross-compile).Test plan
zig buildclean on macOS (Apple Silicon, Zig 0.16.0).zig build -Dtarget=x86_64-windows-gnuclean on macOS — produces 5 PE32+ x86_64 binaries.node -e "require('./npm/bin/install.js').runSelfTest()"passes.sh -n install.shclean.windows-cross-compilejob passes.kuri.exe --versionon a real Windows box (or under Wine) — out of scope for me to verify here.🤖 Generated with Claude Code