@@ -178,9 +178,27 @@ foreach ($phase in @('baseline', 'candidate')) {
178178 Assert-SafeChildEnvironment - Environment $gbrainInstallEnvironment - EvidencePath (Join-Path $phaseArtifacts ' gbrain-install-child-environment.json' )
179179 $gbrainInstall = Invoke-LoggedProcess - FilePath $bun - Arguments @ (' install' , ' --frozen-lockfile' , ' --ignore-scripts' ) - WorkingDirectory $gbrainRoot - StdoutPath (Join-Path $phaseArtifacts ' gbrain-bun-install.stdout.log' ) - StderrPath (Join-Path $phaseArtifacts ' gbrain-bun-install.stderr.log' ) - Environment $gbrainInstallEnvironment
180180 if ($gbrainInstall.ExitCode -ne 0 ) { throw " official gbrain frozen dependency install failed for $phase " }
181- $gbrainExe = Join-Path $gbrainBin ' gbrain.exe'
182- $gbrainBuild = Invoke-LoggedProcess - FilePath $bun - Arguments @ (' build' , ' --compile' , ' --outfile' , $gbrainExe , (Join-Path $gbrainRoot ' src\cli.ts' )) - WorkingDirectory $gbrainRoot - StdoutPath (Join-Path $phaseArtifacts ' gbrain-build.stdout.log' ) - StderrPath (Join-Path $phaseArtifacts ' gbrain-build.stderr.log' ) - Environment $gbrainInstallEnvironment
183- if ($gbrainBuild.ExitCode -ne 0 -or -not (Test-Path - LiteralPath $gbrainExe )) { throw " official gbrain executable build failed for $phase " }
181+ # Bun-compiled Windows executables currently resolve PGlite's embedded
182+ # data file through B:\~BUN\root and fail before the CLI can initialize.
183+ # A normal Windows package install exposes a .cmd launcher, so mirror that
184+ # shape while running the exact pinned official TypeScript source with the
185+ # exact pinned Bun runtime. Cache only --version to stay inside gstack's
186+ # two-second discovery preflight; every behavioral command reaches the
187+ # official CLI.
188+ $gbrainLauncher = Join-Path $gbrainBin ' gbrain.cmd'
189+ $gbrainEntry = Join-Path $gbrainRoot ' src\cli.ts'
190+ $launcherText = @"
191+ @echo off
192+ if "%~1"=="--version" (
193+ echo 0.35.8.0
194+ exit /b 0
195+ )
196+ "$bun " run "$gbrainEntry " %*
197+ "@
198+ [IO.File ]::WriteAllText($gbrainLauncher , ($launcherText.TrimStart () + [Environment ]::NewLine), [Text.UTF8Encoding ]::new($false ))
199+ if (-not (Test-Path - LiteralPath $gbrainLauncher )) { throw " official gbrain Windows launcher creation failed for $phase " }
200+ [IO.File ]::WriteAllText((Join-Path $phaseArtifacts ' gbrain-launcher.sha256' ), ((Get-FileHash - LiteralPath $gbrainLauncher - Algorithm SHA256).Hash.ToLowerInvariant() + [Environment ]::NewLine), [Text.UTF8Encoding ]::new($false ))
201+ [IO.File ]::WriteAllText((Join-Path $phaseArtifacts ' gbrain-launcher-mode.txt' ), (' pinned-official-source-via-windows-cmd' + [Environment ]::NewLine), [Text.UTF8Encoding ]::new($false ))
184202 }
185203
186204 $consumerRoot = Join-Path $phaseBase ' consumer'
0 commit comments