Repository navigation
feat(windows): bash + Git Bash compat (Tier 1) + PowerShell scaffold (Tier 2 fallback) - #63
Merged
Merged
Conversation
Joel 2026-04-24: "we should remain 'pure shell' just do same for powershell yeah and in a PR" + "i bet all of them use terminal and hate ming" — no mingw / Cygwin / Git Bash middle ground; native PowerShell or WSL only. Architecture (project memory project_airc_pure_shell_per_platform.md): two pure-shell implementations of the same protocol, NOT a single binary. Bash for POSIX (incl. WSL); PowerShell for Windows-native. Skills layer is platform-blind. Drift mitigation: scenario suite runs both. This commit is the SCAFFOLD only — a Windows-native Claude (running in Windows Terminal with pwsh, NOT under WSL) will pick up commands from WINDOWS-PORT-STATUS.md and port them one at a time. What this commit ships: - airc.ps1 — skeleton with scope detection, config helpers, version, help, and stub functions for every other command. Each stub references the corresponding bash line range so the porter can compare implementations. - install.ps1 — Windows-native installer (mirrors install.sh structure, including the old-symlink cleanup list that MUST stay in sync). - WINDOWS-PORT-STATUS.md — checklist tracking which commands are ported, collaboration model for multi-Claude PR work, three-peer dogfood gate, promotion path. What's INTENTIONALLY out of scope here: - Port of any actual command beyond version/help (those are demonstration of the architecture) - test/integration.ps1 — Windows-Claude will write the parallel test rig - Daemon install via Task Scheduler (Windows divergence — bash uses launchd/systemd) - Decision on Strategy A (keep python heredocs, invoke via python.exe) vs Strategy B (rewrite heredocs in pure PowerShell). Recommend A first. Promotion gate: feature-branch → canary → three-peer dogfood (anvil, bigmama-wsl, windows-claude) → main. NOT canary-direct because there's no dogfood-able state until parity exists.
Toby reported he runs Git Bash as his Windows Terminal default (not
PowerShell). Strategy reversed: try bash + Git Bash compat first,
treat the PowerShell port (still scaffolded on this branch) as Tier 2
fallback only if Tier 1 can't be made to work.
Two real Windows-Python compatibility fixes in the bash binary:
1. Cross-platform watchdog (replaces signal.SIGALRM-only path).
Windows Python has no SIGALRM. New code: try/except picks
signal.alarm on POSIX (cheaper, single-thread), threading.Timer
fallback on Windows. `_arm_watchdog()` wrapper handles both.
The fmt_exit=2 contract is preserved either way, so the bash
probe-before-count loop doesn't change.
2. python3 → python fallback. Git Bash on Windows typically ships
python (the launcher from python.org) but not python3. New top-of-
file shim: if python3 is missing but python exists, define a bash
function wrapper so all downstream `python3 ...` calls resolve.
Hard fail with install hints if neither is present.
WINDOWS-PORT-STATUS.md rewritten as two-tier strategy:
- Tier 1 (Tier 1 active): bash + Git Bash compat. ~2 fixes
(this commit), then Windows-Claude tests on a real Windows machine.
- Tier 2 (on ice): airc.ps1 + install.ps1 stay on the branch as
fallback insurance. Don't iterate unless Tier 1 fails.
Tests: 97/97 (POSIX scenarios still pass — refactor is additive on
mac/linux/WSL).
Promotion gate unchanged: feature-branch → canary → three-peer dogfood
(anvil, bigmama-wsl, windows-claude in Git Bash) → main.
Replaces the Tier 2 PowerShell scaffold (every command was 'TODO: exit 99') with a real native port of airc to PowerShell 7. Joel's call after Toby's Git-Bash-default setup turned out to be the exception, not the rule: "REAL port please or whats the point" -- the typical Windows install path must be PowerShell-native, not bash-shimmed. airc.ps1 (~1100 lines): full port covering connect (host + joiner + resume with self-heal), send (local mirror + queued-on-network-fail + auth-vs-net distinction), monitor (SSH tail + python formatter heredoc, retained verbatim from bash for protocol parity), teardown (taskkill /T /F walks the process tree -- the Windows analog of pgrep -P + kill), peers, rooms, invite, part, status, doctor, channel, update, ping, send-file, daemon (Task Scheduler analog of launchd/systemd), reminder, logs, version, help, debug-* introspection. Pair handshake uses .NET TcpClient / TcpListener directly (no embedded Python). LAN-IP probe also pure .NET via UdpClient. install.ps1: rewritten to bootstrap from Windows PowerShell 5.1 (the default that ships with Win10/11 -- pwsh is not yet installed) and use winget to silently install every prereq: pwsh, git, python, gh, tailscale. OpenSSH client enabled via Add-WindowsCapability when missing. Designed for FIRST-TIME Windows users with nothing pre-installed -- "if we cheat we screw the first real windows user" (Joel). Refreshes session PATH between winget invocations so subsequent probes see freshly-installed binaries. Drops airc.cmd shim into %LOCALAPPDATA%\Programs\airc and adds that dir to user PATH so 'airc <verb>' works from PowerShell, cmd.exe, Run dialog, and Task Scheduler with no shell-aware launcher. airc.cmd: one-line shim. Launches pwsh on the sibling airc.ps1 with forwarded args. Makes airc indistinguishable from a Windows-native binary to anything that resolves commands via PATH. doctor: per Joel's "if they dont have gh for example doctor would say hey get that" -- enumerates every prereq with the exact winget install command to fix it (and notes which are optional, like tailscale). Files are ASCII-only; em-dashes / box-drawing chars stripped to keep PowerShell 5.1 (which reads .ps1 as cp1252 by default) parsing clean. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…ershell-native-port
…f8d8a7 / 64b604d) Bring three canary tailscale changes to the PowerShell port: - Resolve-TailscaleBin: extracted from Get-AircHost so every caller resolves the binary the same way. Checks tailscale + tailscale.exe on PATH, then C:\Program Files\Tailscale\tailscale.exe (and x86 variant). Parity with bash resolve_tailscale_bin (4d41dab) but pure-Windows path list -- no /Applications bundle, no /mnt/c WSL shim, no Git Bash PATHEXT quirks to work around. - Test-CgnatIp / Test-PeerOfflineInTailnet + Invoke-Send fast-path: when host_target is a 100.64.0.0/10 address and local tailscale status already reports the peer as offline, skip the 10s SSH ConnectTimeout and queue immediately with a "peer offline in tailnet, auto-delivers on wake" marker. Mirrors bash is_peer_offline_in_tailnet (64b604d). CGNAT-only gate; LAN / DNS targets fall through to the normal ssh path untouched. - Advise-TailscaleIfDown + Invoke-Connect resume hook: when the saved host is CGNAT and tailscale is not running locally, print Windows- specific start instructions ("Click the Tailscale tray icon" or "Start-Service Tailscale" from elevated pwsh) and abort, instead of silently hanging in the SSH ConnectTimeout and retrying forever. Mirrors bash advise_tailscale_if_down (0f8d8a7). Get-AircHost refactored to use Resolve-TailscaleBin -- behavior unchanged on the happy path; just one place to update when new tailscale.exe locations show up. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
PS 5.1 surfaced this as a misleading "ForEach-Object : Cannot bind argument to parameter 'Path' because it is null." against the outer pipeline. Real failure was inside the script block when an inner cmdlet got a null arg. Switch to the foreach keyword over @(Get-ChildItem) with explicit local variables for $skill.Name / $skill.FullName, plus skip-on-null guards. Also pin -Path explicitly on Get-ChildItem (rather than relying on -Directory + positional binding) for parser robustness. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…Error `& ssh '-i', $sshKey, @opts, @SshArgs` is a PowerShell parser error: splatted variables (@opts, @SshArgs) cannot appear in a comma-separated argument list. The other ssh call sites use comma-only (no splat) which unrolls correctly for native commands; only this wrapper mixed the two. Switched to space-separated form: `& ssh '-i' $sshKey @opts @SshArgs`, which is the canonical PS pattern for native invocation with splat. Caught when running `airc version` end-to-end after install -- the parser error fired at script-load time and blocked every command. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
When $_ is an ErrorRecord, PowerShell binds its properties as named
parameters and trips on -Out* prefix ambiguity ("parameter name 'out'
is ambiguous: -OutVariable, -OutBuffer"). The reporter died and the
real error never reached the user.
Switch to [Console]::Error.WriteLine with a hand-formatted message +
script location. The actual error now surfaces, including the
script:line where it threw.
Caught when running airc join end-to-end -- gist discovery + resolve
worked, then *something* threw, and the catch swallowed it behind this
ParserError.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
`-out` is a valid openssl flag (used by genpkey, pkey, dgst, et al). With param([Parameter()]) on the wrapper, PowerShell promotes the function to advanced-function semantics and auto-injects common parameters (-OutBuffer, -OutVariable). Any openssl invocation with `-out` then fails at the PS layer before openssl ever runs: "Parameter cannot be processed because the parameter name 'out' is ambiguous. Possible matches include: -OutVariable -OutBuffer." Caught when Init-Identity called `Invoke-OpenSSL genpkey -algorithm Ed25519 -out $privPem` during airc join's first run -- pair handshake never started because identity init blew up. Fix: drop the param() block, collect args via $args and splat through to & $script:OpenSSLBin. No longer an advanced function, no common parameters injected, no prefix collision. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…atic Every command function had `param([string[]]$Args)`. PowerShell's $Args is an automatic variable -- declaring a parameter with the same name breaks pipeline arg passing in non-obvious ways. Caller-side `-Args` also collides with PS common-parameter prefix matching. Symptom: `airc msg @peer 'hello'` reported the usage error -- meaning the function received zero arguments even though three were passed. Same affected ping, send-file, rename, status, teardown, channel, update, daemon, reminder, logs, connect. Renamed parameter + every call site to `Argv` / `-Argv`. No more shadowing, no more prefix collision. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
`($stderrRaw -replace "\`r?\`n", ' ').Substring(0, [Math]::Min(300, $stderrRaw.Length))` threw ArgumentOutOfRangeException when the replaced string was shorter than the original (newlines collapsed shrunk it) and the original length exceeded the replaced length. Trim and use the *replaced* string's length as the clamp source. Caught when SSH stderr came back from a refused-connection peer and masked the real auth/network error behind a Substring crash. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
PowerShell's comma operator across multi-line continuations was producing surprising values when passed to native commands -- ssh ended up seeing literal '-i,' as a hostname argument: ssh: Could not resolve hostname '-i',: No such host is known. Build the args as a typed @() array first, then splat with @arrName. This is unambiguous: PS unrolls splatted arrays to positional args reliably for native commands, with no comma artifacts. Affects: monitor SSH tail, monitor probe, status --probe, cmd_send SSH append, cmd_connect resume auth-probe, cmd_send_file scp. Caught when `airc msg @peer 'hi'` queued with a refusal stderr that named '-i,' as the hostname -- the joiner's outbound was completely non-functional. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…ssphrase Init-Identity used `-N '""'` which on some Windows PS / ssh-keygen combinations passed the literal two-character string `""` as the passphrase, encrypting the SSH key with that as the secret. ssh.exe would then fail auth at use time despite the key being correctly placed in the host's authorized_keys -- because Windows OpenSSH needed the passphrase and there was no way to supply it non- interactively from inside airc. Single-quoted empty string in PS is a true zero-length string. ssh- keygen accepts it as "no passphrase" and produces an unencrypted key that ssh.exe can use directly via -i. Caught when fresh pair succeeded over TCP (joiner registered, host's welcome message landed) but every subsequent SSH (msg, monitor tail) failed auth despite the just-exchanged key being on the wire. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Python's subprocess.Popen with shell=False uses Windows CreateProcess under the hood. CreateProcess can only execute real PE binaries directly -- not .cmd / .bat files. The original `[airc.cmd, ...]` list-form launch silently failed on Windows with no pong emitted, so peers' `airc ping` against a Windows joiner timed out even though inbound + outbound were both working. Add a sys.platform == "win32" branch that routes through cmd.exe /c. shell=False is preserved (we control every argv element -- peer name is regex-validated upstream, uuid is generated locally), so no injection surface. POSIX path unchanged. Caught when continuum-b741's `airc ping @green-022a` timed out: their log showed inbound from me reached them and my SSH-write to their log delivered fine, but no pong returned -- exactly the auto-pong gap. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
$Pid is a PowerShell automatic variable (the current process's PID, read-only). Declaring `param([int]$Pid)` triggers "Cannot overwrite variable Pid because it is read-only or constant." the first time the function tries to bind the incoming PID. Symptom: airc teardown crashed mid-loop after killing the first scoped PID. Same class as the earlier $Args -> $Argv rename. Renamed parameter and every call site to ProcId. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Fresh-pair (joiner) and host paths both print this banner before falling into Start-AircMonitor. The resume path didn't, so a successful restart looked indistinguishable from a hung process -- no console signal that the monitor was up. Joel flagged this is a parity gap across implementations: bash + the PS port both omit the banner on resume. This commit fixes the PS side; bash worth a follow-up. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Two related fixes for the silent auto-pong failure on Windows:
(1) Pass AIRC_HOME explicitly to the subprocess env. The subprocess
chain (Python -> cmd.exe -> airc.cmd -> pwsh -> airc.ps1) has
several cwd-inheritance hops; if any of them resets cwd, the
spawned `airc send` lands in a sibling scope with no host_target
and writes only to a local mirror -- pong never reaches the wire.
Setting AIRC_HOME makes the spawned scope unambiguous.
(2) Capture auto-pong stdout/stderr to <scope>/auto_pong.log instead
of DEVNULL. Every link in the chain was swallowing errors with no
surface. Now we have a per-scope diagnostic file we can paste into
the PR thread when peers report a ping timeout.
Continuum-b741's debugging note pointed at exactly these two as the
likely root causes. (1) is the most plausible silent failure; (2) is
the diagnostic to confirm next time.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Same pattern as auto_pong.log -- replace 2>null swallow on the long-running monitor tail with a per-scope log file so we can see why the formatter never receives input even when the host is sending lines (auto_pong never fires, monitor_offset never written). Symptom: airc logs (one-shot tail) works fine, but airc join's tail -F produces no stdin to the formatter for 150s at a time. SSH stderr is the only place that diagnostic could be hiding. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…tor pre-flights it
Two related fixes for the silent monitor-pipeline failure on Windows:
(1) Resolve-PythonBin probed only PATH and skipped the WindowsApps
stub. winget's Python.Python.3.12 lands at
%LOCALAPPDATA%\Programs\Python\Python3XX\python.exe and is added
to User PATH by the installer. Any pwsh process launched with a
snapshotted/stale PATH (Bash session that started before install,
Task Scheduler with cached env, anything inheriting from a parent
process older than the install) sees only the WindowsApps stub
and Resolve returns $null. Now also walks
%LOCALAPPDATA%\Programs\Python\Python3*\python.exe
%ProgramFiles%\Python3*\python.exe
%ProgramFiles(x86)%\Python3*\python.exe
same defensive pattern as Resolve-OpenSSL / Resolve-TailscaleBin.
(2) Start-AircMonitor pre-flights $script:PythonResolved with Die.
Without this, a missing Python surfaced as
"The expression after '&' in a pipeline element produced an
object that was not valid."
at the formatter pipeline -- confusing because the error doesn't
name Python. Now the user gets a direct "install Python or run
airc doctor" message.
Caught when Monitor tool surfaced the pipeline error that the prior
Bash bg run had been silently hiding for hours -- without Python the
whole monitor loop was no-op and inbound never got mirrored locally
(no auto-pong, peers' pings just timed out).
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…eam copy PowerShell's `& ssh ... | & python ...` native pipeline never flushed bytes from ssh.exe to python.exe on a long-running tail -F producer. Symptom: formatter's watchdog fired every 150s with zero inbound even though the host was actively posting -- all messages visible via `airc logs` (one-shot tail, no long-running pipeline), none visible via the join-path monitor. POSIX bash pipes handle this fine (GNU/BSD tail line-flushes, pipe passes through). On Windows, some layer (ssh.exe CRT stdio? PS ObjectStream conversion? CreateProcess pipe buffering?) holds the bytes and watchdog eventually kills the downstream reader. Replace with explicit [System.Diagnostics.Process] for ssh and python, plus a synchronous pump that reads each ssh stdout line and writes it + flushes to python stdin. No PS pipeline layer -- bytes go straight from one Process StandardOutput to the other's StandardInput. Formatter runs off a .py file on disk (cleaner than passing a multi-line heredoc through .NET CreateProcess argv), keeps the AIRC_HOME / PEERS_DIR / AIRC_CMD_PATH env vars for the subprocess. ssh stderr is async-copied to <scope>/monitor_ssh.log via CopyToAsync. Caught when Monitor tool surfaced the watchdog message that the prior Bash bg launch was swallowing for hours. Mesh peers (continuum- b741, anvil) were pinging into the void; auto-pong couldn't fire because the formatter never saw the PINGs. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
joelteply
marked this pull request as ready for review
April 24, 2026 23:09
joelteply
added a commit
that referenced
this pull request
Apr 24, 2026
The literal IP was the airc author's tailnet address -- a dead branch for any other user AND a low-grade PII leak in the repo. Replaced with a dynamic `tailscale ip -4` probe so the cleanup now targets THIS machine's actual tailnet IP whenever Tailscale is up, falls through silently otherwise. Caught during canary-cleanup audit (PR #63 follow-up). Was the only test-side hardcode found. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
joelteply
added a commit
that referenced
this pull request
Apr 24, 2026
Mirrors the Windows install.ps1 winget bootstrap. Designed for FIRST-TIME POSIX users with nothing pre-installed: - detect_pkgmgr: probes brew (mac), apt-get (debian/ubuntu/wsl), dnf (fedora/rhel), pacman (arch), apk (alpine). - ensure_prereqs: scans for missing git/gh/openssl/ssh-keygen/python3, installs the missing set via the detected pkgmgr. Each prereq has a pkgname_for() shim covering the cases where the package id differs across managers (openssh-client vs openssh-clients vs openssh, python vs python3). - install_tailscale: optional. brew --cask on mac, the official curl|sh installer on Linux. Failures warn but don't block -- LAN mesh works without it, gist substrate handles either path. - gh auth: surfaces the exact `gh auth login -s gist` command after install so the user knows the one-time interactive step. - AIRC_SKIP_PREREQS=1 escape hatch for CI / sandboxed installs / users who manage their own packages. Final-screen text rewritten to: - Drop "Requires Tailscale" framing (gist orchestrates regardless) - Surface gh auth as step 1 of "Next" - Mention `airc doctor` for diagnosis Audit finding #1 from PR #63 follow-up. Closes the install.sh prereq gap that left fresh users stranded the moment they typed `airc join` without gh installed. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
joelteply
added a commit
that referenced
this pull request
Apr 24, 2026
…-tests cmd_doctor was a thin exec wrapper around test/integration.sh, but /doctor SKILL.md promised "checks environment health, proactively fixes recoverable issues (install gh, etc.)." Audit fix #2 from PR #63 follow-up -- bring command up to spec. cmd_doctor (default mode) now: - Detects platform pkgmgr (brew/apt/dnf/pacman/apk). - Probes git, gh, openssl, ssh, ssh-keygen, python3 + emits exact install command for the detected pkgmgr on each [MISSING] line. - Probes gh auth status (gist scope) -- the #1 cause of "airc feels broken" silently. - Probes tailscale separately as [info] (optional, never blocks). - Reports scope + identity state. - Tail line tells the user re-running install.sh is the fastest path if multiple things are missing. Same shape as the install.ps1 winget probe pattern (Windows side already uses this for parity with the bash 'curl|sh') -- now bash behaves the same. `airc doctor --tests` (or `airc tests` / `airc test`) routes to _doctor_run_tests, which is the prior cmd_doctor body verbatim, so existing CI / muscle-memory keeps working. Dispatch updated: `doctor` -> cmd_doctor; `tests|test` -> _doctor_run_tests. SKILL.md rewritten to: (Step 1) just run `airc doctor`, act on [MISSING] lines; (Step 2) `airc doctor --tests $ARGUMENTS` for behavioral suite. The prior 30-line inline shell probes in Step 1 are gone -- they're now built into the binary. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
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.
Strategy reversed mid-branch
Toby reported he uses Git Bash as his Windows Terminal default, not PowerShell. So the right first move is bash + Git Bash compat (single codebase across mac / linux / WSL / Git Bash) — NOT a PowerShell port.
Two-tier strategy this branch now carries:
aircwork in Git Bash on Windows. Single codebase preserved. Preferred outcome.airc.ps1+install.ps1scaffold remain on this branch as fallback insurance. Don't iterate unless Tier 1 is shown to be infeasible.What's in this PR
Tier 1 commit (
9ab1430) — Windows-Python compat fixes in bashsignal.SIGALRMon POSIX,threading.Timerfallback on Windows._arm_watchdog()wrapper.python3→pythonfallback — bash function wrapper at top of file. Hard fail with install hints if neither exists.python(the python.org launcher) but notpython3.POSIX tests: 97/97 still passing — refactor is additive.
Tier 2 scaffold (
1578f50) — PowerShell port files (insurance)Preserved on this branch but DON'T iterate yet:
airc.ps1— skeleton with scope detection, config helpers, version, help, command-dispatch stubsinstall.ps1— Windows-native installerWINDOWS-PORT-STATUS.md— now framed as two-tier (Tier 1 active, Tier 2 on ice)If Tier 1 succeeds, delete the Tier 2 files in a follow-up commit. If Tier 1 fails, resurrect Tier 2 work.
Handoff to Windows-Claude
Joel will bring up a Claude Code session on his Windows machine inside Windows Terminal with Git Bash as the default profile (NOT PowerShell, NOT WSL). That Claude:
git fetch && git checkout feat/powershell-native-portbash install.sh— should detect Git Bash + installairc version/airc help— sanityairc connect— host mode; expect Windows Defender firewall prompt on first TCP bindairc msgairc teardown→ clean exit, no orphansairc connectagain → resume worksAny failure: file the symptom + stderr in this PR thread.
Promotion gate
Joel's directive (verbatim, for context)