Repository navigation
feat(desktop,computer,agent): bundle PortableGit and enable dual bash+powershell on Windows Pi - #1182
LeoXing1996 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Request changes (3 P1, 4 P2) · merge base 5985e03 · 3 commits, 26 files
Findings
P1
-
apps/computer/tools/pi-mcp.mjs:2687(andapps/computer/local-daemon/cmd/linger-computer-daemon/main.go:1254-1294) — WSLSystem32\bash.exehijacks Pi'sbashtool ahead of bundled PortableGit
withBundledGitBashPathappendsresources\runtime\git-bash\binto the end of WindowsPATH(afterC:\Windows\System32), whilemanagedExtensioncallsregisterWindowsBashTool(pi)without passingshellPath. In@earendil-works/pi-coding-agent(dist/utils/shell.js:76-110),getShellConfig(undefined)onwin32checks%ProgramFiles%\Git\bin\bash.exe/%ProgramFiles(x86)%\Git\bin\bash.exeand then takes the first line ofwhere bash.exe. On any Windows machine without Git for Windows inProgram Fileswhere WSL is enabled (soC:\Windows\System32\bash.exeexists, which Pi's ownisLegacyWslBashPathhandles),where bash.exepicksC:\Windows\System32\bash.exebefore the bundled PortableGit. If WSL has no distro installed, everybashcall fails immediately; if a WSL distro is installed,bashruns in Linux WSL whereWINDOWS_BASH_PREFIXhijacksteamhubtoteamhub.exe(bypassingteamhub.sh'swslpath -wconversion),WINDOWS_BASH_ENVis not forwarded viaWSLENV, andC:/Users/...paths frompiWindowsDualShellGuidefail. Pass the resolvedGitBashPathfrom the Daemon intopi-mcp.mjs(via a consumed-on-load env var likeLINGER_PI_SHELL_TEXT_HOOK) and pass it asshellPathinregisterWindowsBashToolwhenever a native Git for Windows binary is absent (or unconditionally prefer the bundled PortableGit). -
apps/computer/local-daemon/internal/provider/native/pi_runtime.go:18(andapps/computer/local-daemon/internal/linger/context/resolver.go:129,155,apps/node-services/src/agent/prompt/environment-knowledge.ts:25) — Unconditional Windowsbashenablement and"posix"dialect break bash-less hosts and older Daemons- Daemon side: On
goos == "windows",piBaseToolsForunconditionally enablesread,bash,powershell,...andresolver.gounconditionally injectswindowsBashHostEnvironmentGuideandpiWindowsDualShellGuide("Default tobashforteamhub..."), even whentoolInstallation.GitBashPath == "". This breaks Windows Desktop installations receiving a V2 backend update on an older Shell withoutresources/runtime/git-bash/(apps/desktop/src/main/index.ts:701-739,minShellVersion: "0.2.0"inapps/desktop/scripts/build-app-bundles.mjs:486) and standalone Windows CLI Computers (scripts/prepare-local-computer-release.mjs), which do not bundle PortableGit: on hosts without Git for Windows, everybashcall throwsNo bash shell found(dist/utils/shell.js:105-109). - Agent Service side:
shellDialectFromPlatform("win32"|"windows", "pi")unconditionally returns"posix"in bothlocal-backend.ts:242andrunner-gateway.ts:260with no Daemon version or capability gate. When a newer Agent Service talks to an older Windows Daemon (whose Pi only exposespowershelland appendspiWindowsPowerShellGuide/WindowsHostEnvironmentGuide), the static prefix tells the model to use<<'EOF'andfind -L, contradicting the Daemon's guides and trippingshell-text-hook. Meanwhile the"windows-pi"dialect is now unreachable from production code. - Fix: On the Daemon, enable
bashand dual-shell guides on Windows only when a usable Git Bash is present (bundledGitBashPath,%ProgramFiles%\Git\bin\bash.exe, or non-WSLbash.exeonPATH), falling back to PowerShell-only otherwise. On Agent Service, gate"posix"for Windows Pi on a Computer version/capability check and keep"windows-pi"for older Daemons.
- Daemon side: On
-
apps/computer/local-daemon/internal/permission/shell.go:401-414—shellPaths.cd()skipsnormalizeMSYSDrivePath, allowing workspace symlink/junction escape on Windows
shellPaths.inside()normalizes/c/...toC:\...before checkingfilepath.IsAbsandwithinWorkspace, sop.inside(words[1])atshell.go:403returnstrueforcd /c/Users/alice/work/sub. However,shell.go:407-411then passes the rawwords[1]tofilepath.IsAbs(words[1])(which isfalseon Windows for/c/...), appendingC:\Users\alice\work\c\Users\alice\work\subinstead ofC:\Users\alice\work\subtop.places. IfC:\Users\alice\work\sub\linkis a symlink or directory junction pointing outside the workspace,cd /c/Users/alice/work/sub && cat <<'EOF' > link/evil.txt && teamhub message listevaluateswithinWorkspaceonly against nonexistent...\link\evil.txtand...\c\Users\alice\work\sub\link\evil.txtwithout ever inspectingsub\linkon disk, returningShellAllowand writing outside the workspace without review. Normalizetarget := normalizeMSYSDrivePath(words[1], p.workspace)insidecd()and usetargetin lines 407-411, with a regression test inshell_test.go.
P2
-
apps/computer/local-daemon/internal/permission/shell_text_powershell.go:374-386— Multi-line PowerShell pipe (|\n) splitspipelineIDand misses corrupted$
In PowerShell,|followed by a newline continues the same pipeline (e.g.,@"\nARR is $6.4M\n"@ |\nteamhub message send --file -). At line 383|callsflushSegment(false)keepingpipelineID == 0, but the immediately following\nhits line 374 (flushSegment(true)) and incrementspipelineIDto1, soteamHubPipelines[0]isfalseandPowerShellTextProblemallows the corrupted$6.4Mthrough. Track anafterPipeflag across whitespace after|/|&, callflushSegment(!afterPipe)on\n, and add a test case inshell_text_powershell_test.go. -
apps/computer/tools/pi-mcp.mjs:119-122(andapps/computer/local-daemon/cmd/linger-computer-daemon/main.go:1259-1264) — Inherited host env vars overrideWINDOWS_BASH_ENV
spawnHookspreads...WINDOWS_BASH_ENVbefore...context.env(populated fromprocess.envindist/core/tools/bash.js:160), so inherited values such asMSYS_NO_PATHCONV=0,MSYS2_ARG_CONV_EXCL="",LC_ALL=C, or a non-UTF-8LANGoverride the guard (contradicting the PR description's claim thatpi-mcp.mjsenforces them, and leavingcomputer-tools.test.ts:340dependent on hostprocess.env.LANGcontainingUTF-8). Inmain.go:1259-1264, checkingupdated["MSYS_NO_PATHCONV"]is also case-sensitive on Windows, unlikewithBundledWindowsRuntimeDir. Strip case-insensitive duplicates and spread...WINDOWS_BASH_ENVafter...context.envinpi-mcp.mjs, and use case-insensitive lookup/set inwithBundledGitBashPath. -
apps/desktop/packaging/win/package.py:100-109, 172-197— Duplicated archive download and zip-entry verification helpers
verify_git_bash_archive(lines 100-109) andgit_bash_archive(lines 172-197) are verbatim copies ofverify_pwsh_archive(lines 88-97) andpwsh_zip(lines 134-159). Extract shared_verify_archive_entry(archive, entry)and_cached_verified_archive(...)helpers and call them from bothpwshandgit-bashpaths. -
scripts/ci/desktop-smoke-helpers.mjs:147-154(andscripts/ci/windows-pi-smoke.mjs:112-137,docs/desktop-release.md:525-530,apps/computer/benchmarks/real-app-eval/lib/product_chain.mjs:258) — Smoke checks, release docs, and eval dialect left on PowerShell-only Windows Pi
piToolsForPlatform(explicitly commented as matchingpiWindowsBaseTools) still returns"read,powershell,edit,write,grep,find,ls,mcp__*"onwin32,windows-pi-smoke.mjsverifiespwsh.exewithout checkingresources/runtime/git-bash/bin/bash.exe,docs/desktop-release.mddocumentspwsh/PWSH_MIRRORwithout PortableGit/GIT_BASH_MIRROR, andproduct_chain.mjsstill hardcodes"windows-pi". Update all four to stay aligned with dual-shell Windows Pi.
Checked: Pi tool review routing (apps/computer/local-daemon/internal/provider/native/pi_review.go:153) · Pi command activity classification (apps/computer/local-daemon/internal/provider/activity_status.go:42) · Desktop teamhub.sh/exe staging (apps/desktop/scripts/build-steps.mjs:282)
Unverified: live Windows execution of PortableGit packaging, teamhub.sh MINGW dispatch, and dual-shell Pi runs
Process: needs rebase onto main (1 commit behind)
CI: 9 checks passed; CI does not run computer TS or node-services tests
Automated review of f817332 by Antigravity.
f817332 to
5d58da3
Compare
There was a problem hiding this comment.
Request changes (1 P0, 2 P2) · follow-up on f817332 · merge base 4c095c0 · 4 commits, 52 files
Resolved: WSL bash hijacking (installation.go:244, pi-mcp.mjs:19) · bash-less & older-Daemon fallback (pi_runtime.go:27, environment-knowledge.ts:22) · MSYS cd symlink escape (shell.go:406) · multi-line PowerShell pipe (shell_text_powershell.go:377) · WINDOWS_BASH_ENV precedence (pi-mcp.mjs:92, main.go:1264) · package.py helper duplication (package.py:88,132) · Windows smoke/docs/eval sync (windows-pi-smoke.mjs:98, docs/desktop-release.md:526)
Findings
P0
apps/computer/local-daemon/internal/daemon/connection.go:650(andcontracts/runner-gateway/envelope.schema.json:266) — Addingwindows_git_bashtorunner.hello.capabilitiesbreaks older Agent Services with a1002protocol disconnect
buildHello()(connection.go:125) sendsd.capabilities()inrunner.hellobeforerunner.welcomerevealsservice_features, andcapabilities()(connection.go:649-651) now unconditionally appends"windows_git_bash"on every Windows Computer with bundled PortableGit or installed Git for Windows. However, every already-deployed Agent Service validatesrunner.hellostrictly throughparseDaemonToAgentEnvelope(apps/node-services/src/agent/runner-gateway/runner-gateway-websocket.ts:854) against the closed Ajv enumRunnerCapability: ["browser_connection", "computer_permissions"](envelope.schema.json:264-267,5362-5368). During rolling deploys, self-hosted mixed-version runs, or whenever a Windows Desktop upgrade replaces the Daemon ahead of local installed services (the scenarioapps/computer/AGENTS.md:286-289andconnection.go:109-112explicitly guard against), the older Agent Service rejectsrunner.hellowithInvalidRunnerFrameErrorand closes the WebSocket with1002(Runner protocol violation,runner-gateway-websocket.ts:422,689-695), trapping the Windows Computer in an offline reconnect loop. Keeprunner.hello.capabilitiesrestricted to["browser_connection", "computer_permissions"], negotiate support via a newrunner.welcomeservice_featuresentry (e.g.windows_git_bash, ignored by older Daemons perrunner-connections.ts:550-551), report the host's Git Bash availability post-welcome only when advertised (mirroringdynamic_reasoning_effortsinconnection.go:780-819), and keep Daemon dual-shell tools and guides on PowerShell-only when connected to an older Agent Service that does not advertise it.
P2
-
apps/computer/tests/computer-tools.test.ts:329-340— Windows bash test short-circuitsshellPathand never testsLINGER_PI_GIT_BASH_PATHconsumption
Passing customoperationstoregisterWindowsBashToolcausescreateShellToolDefinition(@earendil-works/pi-coding-agent/dist/core/tools/bash.js:183) to skipcreateLocalBashOperations({ shellPath: options?.shellPath }), so droppingshellPathwould still pass. Likewise, module-load consumption and deletion ofprocess.env.LINGER_PI_GIT_BASH_PATH(apps/computer/tools/pi-mcp.mjs:19-20,123) has no test coverage. Add assertions using a stubcreateToolDefinitionto verifyshellPathforwarding, plus a child-process import withLINGER_PI_GIT_BASH_PATHset verifying both defaultshellPathwiring andprocess.env.LINGER_PI_GIT_BASH_PATH === undefinedafter load. -
apps/computer/local-daemon/README.md:722-725(andcontracts/README.md, PR description) — Stale Windows Pi docs and outdated PR summary
apps/computer/local-daemon/README.md:722-725(immediately above the edited lines) still states that Windows Pi usespowershellinstead ofbashand skipspipefail, which is now inaccurate whenever Git Bash is available;contracts/README.mddoes not document the new Runner Gateway wire gate; and the PR description still claims "No cross-process OpenAPI contract changes" and describes unconditional dual-shell enablement from commits 1-3 without commit 4's capability gating and fallback. Update the README paragraph, document the negotiated wire gate incontracts/README.md, and refresh the PR body.
Checked: Pi bash shellPath precedence (@earendil-works/pi-coding-agent/dist/utils/shell.js:78) · Gateway passthrough to preflight (apps/node-services/src/agent/executor/application.ts:631) · Permission review bash/PowerShell routing (apps/computer/local-daemon/internal/permission/reviewer.go:178)
Unverified: live Windows execution of PortableGit packaging, teamhub.sh MINGW dispatch, and dual-shell Pi runs
Process: squash review-fixup commit 5d58da3 into the earlier commits it patches before rebase-merge
CI: 17 checks passed; CI skips computer TS and node-services tests
Automated review of 5d58da3 by Antigravity.
…+PowerShell on Windows Pi - Bundle SHA-256-verified PortableGit 2.56.0.4 into Windows Desktop packages (resources/runtime/git-bash/bin/bash.exe), prune GUI/docs, and add Git Bash smoke probes and release documentation. - Resolve non-WSL Git Bash in the Windows Local Computer Daemon (bundled PortableGit -> Program Files Git -> non-WSL PATH), pass LINGER_PI_GIT_BASH_PATH (consumed at load) into pi-mcp.mjs as shellPath, enforce MSYS_NO_PATHCONV=1 / MSYS2_ARG_CONV_EXCL=* / UTF-8 locale case-insensitively, and route teamhub to teamhub.exe in MINGW/Git Bash. - Negotiate dual-shell Windows Pi support via runner.welcome service_features (windows_git_bash) and post-welcome runner.runtime_diagnostics.windows_git_bash, keeping runner.hello.capabilities backward-compatible with older Agent Services and falling back to PowerShell-only on bash-less hosts or older Agent Services. - Harden PowerShell shell-text-hook against numeric/escaped dollar expansion across double quotes, here-strings, bare words, and multi-line pipes, and normalize MSYS drive paths in shellPaths.cd to preserve workspace symlink/junction checks.
5d58da3 to
446d0b3
Compare
There was a problem hiding this comment.
Request changes (1 P0, 1 P1) · follow-up on 5d58da3 · merge base 9ef0028 · 1 commit, 59 files
Resolved: runner.hello capability disconnect (apps/computer/local-daemon/internal/daemon/connection.go:425,652) · Windows bash shellPath test (apps/computer/tests/computer-tools.test.ts:342-398) · stale docs and PR body (apps/computer/local-daemon/README.md:733, contracts/README.md:126)
Findings
P0
apps/computer/local-daemon/internal/linger/transport/gateway_test.go:411—TestGatewayStreamEncodesRuntimeDiagnosticsRevisiondeadlocks on the second frame, failing CI
Thehttptest.NewServerWebSocket handler (gateway_test.go:372-375) callssocket.ReadJSON(&envelope)only once and then returns, closing the server socket. The newly added secondstream.Send(...)withWindowsGitBash: true(gateway_test.go:404-410) is therefore never read, andwithBash := <-received(gateway_test.go:411) blocks permanently until Go's 10-minute test timeout panics (CI/check (computer-go)failed deterministically at line 411). Read frames in a loop inside the test server handler untilsocket.ReadJSONreturns an error (withreceivedbuffered to 2) so both diagnostic envelopes are received.
P1
apps/node-services/src/agent/runner-gateway/runner-connections.ts:350,454,691(andapps/computer/local-daemon/internal/daemon/connection.go:392,435,441,apps/computer/local-daemon/internal/daemon/prefix_warmup.go:88,111) — Post-welcomewindows_git_bashreporting races with Context activation and PolyStrata prefix warm-up- Context activation / reconnect race:
#replaceConnection(runner-connections.ts:454) resetsconnection.windowsGitBash = false. On steady-state reconnects or Agent Service restarts wherehello.agent_runnersalready matchplacements,agentRunnerReconciliation.start(agent-runner-reconciliation.ts:53-54) synchronously invokescompleteOperationReconciliation(runner-operations.ts:541-542), firingnotifyLocalComputerReadyinside#acceptConnectionInternalbefore the Daemon receivesrunner.welcomeor sends post-welcomerunner.runtime_diagnostics. Wokenrestart-restore(restart-restore.ts:110) andawaitLocalComputerReconnect(local-backend.ts:228) callers immediately runpreflight()withlocalComputerHasWindowsGitBash() === false, rendering"windows-pi"(PowerShell-only) developer instructions while the Daemon already hasWindowsGitBashActive() == trueand appendspiWindowsDualShellGuide+--tools read,bash,powershell,.... BecauseActivatedContextRuntime.prepareNextRun()(activation.ts:933-948) only checksinstructionTierand nevershellDialect, the Context stays stuck with conflicting prompts until recycled. - PolyStrata prefix warm-up race:
acceptRunnerWelcomepublishesd.contentURL(connection.go:392) before storingd.windowsGitBashFeature(connection.go:425) and beforeactivateStreamAndReplaysendsrunner.runtime_diagnostics(connection.go:435), then immediately startsbootstrapLocalCapabilities(connection.go:441).PrefixWarmupRunner.Warmup()(prefix_warmup.go:88) fetches/static-prefixes/v1over a separate HTTP connection that races WebSocket delivery and async#checkCredential()(runner-gateway-websocket.ts:486). If HTTP wins, Agent Service returns"windows-pi"whileprefix_warmup.go:111-115stitches onpiWindowsDualShellGuideand dual-shell tools, pinning a mismatched prefix in PolyStrata RAM and recordingprefixWarmed(localmodels/prefix_warmup.go:139) so it never re-warms until model reload. - Fix: Store
d.contentURLonly after storingservice_featuresand sending post-welcome diagnostics inconnection.go, and havePrefixWarmupRunnerpass the negotiated flag (for example?windows_git_bash=1) on/static-prefixes/v1(falling back to connection state when absent) so warm-up never races the WebSocket. InActivatedContextRuntime.prepareNextRun()(activation.ts:933-948), re-checkshellDialectalongsideinstructionTierso any Context activated during handshake recycles on the next Run, and preserveprevious?.windowsGitBashacross reconnects (or gatewin32readiness on post-welcome diagnostics behind a bumpeddaemon_version) so the first post-restart Run also receives the matching dialect.
- Context activation / reconnect race:
Checked: Pi --tools filtering (@earendil-works/pi-coding-agent/dist/core/agent-session.js:2979) · Pi resident shape args (apps/computer/local-daemon/internal/provider/native/pi_resident.go:109) · Go service_features decoding (contracts/generated/go/runnergateway/wire.gen.go:2821)
Unverified: live Windows PortableGit packaging, teamhub.sh MINGW dispatch, and Go -race daemon tests
CI: check (computer-go) failed (transport timeout); 16 passed; CI skips computer TS and node-services
Automated review of 446d0b3 by Antigravity.
Summary
Bundles PortableGit 2.56.0.4 into Windows Desktop releases and enables negotiated dual
bash+powershelltools for Windows Pi, backed by full 31-task Windows ablation results (11/31 pass, 8.04 avg score vs 6/31 pass, 6.05 avg score on PowerShell-only, 0run_aborted, 0exam_broke).Key Changes
apps/desktop/packaging/win/package.py: downloads, SHA-256-verifies, unpacks, and trims PortableGit 2.56.0.4 intoresources/runtime/git-bash/bin/bash.exealongside PowerShell 7.6.10, deduplicating cached-download and zip-entry verification helpers.apps/desktop/scripts/teamhub.sh: dispatches MINGW/Git Bash invocations directly toteamhub.exe.scripts/ci/windows-pi-smoke.mjs&scripts/ci/desktop-smoke-helpers.mjs: probe bundledbash.exeand passLINGER_PI_GIT_BASH_PATHwith dual-shell--tools.apps/computer/local-daemon/internal/linger/localtools/installation.go: resolves non-WSL Git Bash (bundled PortableGit ->Program Files\Git\bin\bash.exe-> non-WSLbash.exeonPATH), rejectingSystem32\bash.exe,SysWOW64\bash.exe, andWindowsApps\bash.exe.apps/computer/local-daemon/cmd/linger-computer-daemon/main.go&apps/computer/tools/pi-mcp.mjs: passes resolved Git Bash explicitly viaLINGER_PI_GIT_BASH_PATH(consumed and deleted on load) toregisterWindowsBashToolasshellPath, and enforcesMSYS_NO_PATHCONV=1,MSYS2_ARG_CONV_EXCL=*,LANG=C.UTF-8, andLC_ALL=C.UTF-8case-insensitively with precedence over inherited env vars.contracts/runner-gateway/envelope.schema.json(plus regenerated Go/TS contracts): keepsrunner.hello.capabilitiesrestricted to the closed legacy enum["browser_connection", "computer_permissions"], addswindows_git_bashtorunner.welcome.service_features, and adds optionalwindows_git_bashto post-welcomerunner.runtime_diagnostics.bash+powershelltools, dual-shell guides, and reportswindows_git_bash: trueon post-welcomerunner.runtime_diagnosticsonly when both a non-WSL Git Bash binary is present andrunner.welcome.service_featuresadvertiseswindows_git_bash; bash-less hosts and connections to older Agent Services stay on PowerShell-only without1002protocol errors."posix"dialect for Windows Pi (bothpreflightand/static-prefixes/v1) only after the Computer reportswindows_git_bash: true, keeping"windows-pi"for bash-less hosts and older Daemons.apps/computer/local-daemon/internal/permission/shell_text_powershell.go: blocks corrupted numeric/escaped$across double quotes, here-strings, bare words, and multi-line PowerShell pipes (|/|&+ newline).apps/computer/local-daemon/internal/permission/shell.go: normalizes MSYS/c/...drive paths insideshellPaths.cd()so workspace symlink/junction escape checks remain accurate on Windows.Boundary
windows_git_bashtoServiceFeatureand optionalwindows_git_bashboolean toRunnerRuntimeDiagnosticsincontracts/runner-gateway/envelope.schema.json, regenerated viapnpm contracts:generate && pnpm contracts:verify, and documented incontracts/README.md. No OpenAPI contract changes.docs/desktop-release.md,apps/computer/local-daemon/README.md,apps/desktop/AGENTS.md,contracts/README.md, andscripts/env-inventory.json.provider_readycritical path: No additional network round trips or file walks; Git Bash path resolution runs once at Daemon startup.Verification
pnpm contracts:generate && pnpm contracts:verifyGOOS=windows GOARCH=amd64 go build ./...,go vet ./...,gofmt, and Go unit tests acrosspermission,localtools,context,daemon,cmd/linger-computer-daemon, andprovider/nativepnpm --filter @linger/node-services run typecheckand 241/241 Vitest tests (context-instructions,static-prefixes,local-backend,runner-connections-public,context-view-content)pnpm --filter @linger/computer run typecheckand Windows bashshellPath/LINGER_PI_GIT_BASH_PATH/applyWindowsBashEnvtestspython3 -m unittest discover -s apps/desktop/packaging -p 'win_*_test.py'(7/7) andscripts/ci/windows-pi-smoke.test.ts(9/9)pnpm env:inventory:check, ESLint, Prettier, andlint-staged