Fix Windows build: exclude pi-coding-agent from packaged app#3727
Fix Windows build: exclude pi-coding-agent from packaged app#3727wojtekn wants to merge 4 commits into
Conversation
… path-too-long error @earendil-works/pi-coding-agent is a devDependency used only for TypeScript types (import type). Its transitive @mistralai/mistralai dep contains filenames like getchatcompletionfieldoptionscountsv1...post.js that, when nested under pi-coding-agent/node_modules/, exceed Windows' 260-char path limit and cause the Squirrel/NuGet maker to fail. galactus (DestroyerOfModules) should prune devDeps from the packaged output, but after install:bundle's standalone npm install the pruning doesn't reliably remove the nested node_modules. Adding an explicit forge ignore pattern is a reliable safety net.
📊 Performance Test ResultsComparing b4b995d vs trunk app-size
site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff) |
…Windows path limit
electron-winstaller ships nuget.exe v4.0, which predates long-path support. Long paths require nuget.exe >= 4.8 AND the LongPathsEnabled registry key. Download the latest nuget.exe at build time to satisfy both conditions. Also removes the forge ignore workarounds for pi-coding-agent, react-native and @react-native that were added to work around the old NuGet limitation.
| Write-Host "--- :windows: Enabling long path support" | ||
| New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" ` | ||
| -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force | ||
| If ($LastExitCode -ne 0) { Exit $LastExitCode } |
There was a problem hiding this comment.
Interesting. The AMI already should enable long paths with these instructions:
Write-Output "Enable long path behavior"
# See:
#
# - https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file#maximum-path-length-limitation
# - https://support.atlassian.com/bamboo/kb/git-checkouts-fail-on-windows-with-filename-too-long-error-unable-to-create-file-errors/
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -Value 1
git config --system core.longpaths true
I see this command adds -PropertyType DWORD -Force which maybe should be pushed upstream to the AMI, too.
However, it's hard to tell whether the issue is with the original command or with electron-winstaller below. That is, I wonder if the latest stable version of that package will work without the additional params in the long-path configuration.
|
Discovered with Claude: The The failure is in Squirrel's bundled The key frame is |
|
I researched an alternative with AI and pushed it in #3735 |
|
Closing in favor of #3735 |
<!-- blue --> > [!NOTE] > @wojtekn this JS/TS manipulation of the Electron build structure is outside my area of expertise, so it's possible the result is a big AI slop. At the same time, it does seem to address the build failure issue with the long path, so it might be a good place to start. > > I'm having my agent address the Copilot comments now. Next step will be to get a different one to look over the work for possible improvements. ## Related issues - Related to #3727 (alternative fix for the same Windows `PathTooLongException`) ## How AI was used in this PR Claude Code (Opus 4.8) diagnosed the root cause from the CI logs, verified the fix empirically against a reproduced bundle tree, and wrote the prune script and tests. I reviewed the analysis and the diff. ## Proposed Changes The Windows Squirrel maker crashes with `PathTooLongException` while packing the app. The real cause is `@earendil-works/pi-coding-agent`'s transitive `@mistralai/mistralai` — a speakeasy-generated SDK whose ~200-char filenames, nested under `pi-coding-agent/node_modules`, exceed Windows' 260-char path limit. The AWS Bedrock SDK (`@aws-sdk`/`@smithy`) overflows the same way. These are **lazy, dynamically-imported** `pi-ai` providers, and Studio only ever exposes the **Anthropic and OpenAI** model families (`tools/common/ai/models.ts`). Mistral, Bedrock and Google are therefore unreachable dead weight. This strips them from the bundled CLI during packaging, which: - fixes the path limit — **183 over-limit files → 0** (worst path drops to 236 / 260), and - reclaims tens of MB from the installer. A missing provider degrades gracefully through pi-ai's lazy loader, so removing them is safe. > Note: this is an alternative to #3727, opened in parallel rather than stacked because that PR's commits (forge `ignore`, registry key, `nuget.exe` swap) are no-ops for this failure — the exception is thrown by Squirrel's legacy `Update.exe` (`Path.LegacyNormalizePath`), which the `ignore`/registry/nuget levers don't reach. See #3727 for that analysis. ## Testing Instructions - `npm test -- --project scripts` — unit tests for the prune (removes targets in hoisted + nested locations; keeps Anthropic/OpenAI and unrelated `@google/*`). - Verified end-to-end against a reproduced bundle install: `pruneUnusedProviders` removed every offender at both the top level and under `pi-coding-agent`, taking over-260 files from 183 to 0. - The Windows build (`make:windows-*`) should now pass the Squirrel maker; macOS/Linux unaffected (and benefit from the smaller bundle). ## Pre-merge Checklist - [x] Have you checked for TypeScript, React or other console errors? (`npm run typecheck` and `eslint` pass) --- *Authored by Claude (Opus 4.8) on behalf of @mokagio with approval.* --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: Wojtek Naruniec <wojtek@naruniec.me> Co-authored-by: Wojtek Naruniec <wojtek.naruniec@automattic.com>
Related issues
Follows up on #3707 (migrate
@mariozechner/pi-*to@earendil-works/pi-*).How AI was used in this PR
Claude Code diagnosed the root cause and wrote the fix.
Proposed Changes
After #3707 landed, the Windows Squirrel build started failing with:
Root cause:
@earendil-works/pi-coding-agentis adevDependencyofapps/studio(only needed forimport type { SessionEntry }— erased at compile time). However, afterinstall:bundlerunsnpm install --no-workspaces, galactus (electron-packager'sDestroyerOfModules) doesn't reliably prune the nestednode_modulesunderpi-coding-agent. Its transitive@mistralai/mistralaidependency contains filenames likegetchatcompletionfieldoptionscountsv1observability...post.jsthat reach 200+ chars on their own. With the Windows build agent prefix (C:\buildkite-agent\builds\ci-windows-...\automattic\studio\) the total path hits ~295 chars — 35 over the 260-char limit.The fix adds an explicit
ignorepattern toforge.config.tsso electron-forge never copiespi-coding-agentinto the packaged output, regardless of whether the devDep prune works. This is a belt-and-suspenders approach since the package should already be excluded as a devDep.Testing Instructions
pi-coding-agentwas only imported for TypeScript types, not included at runtimePre-merge Checklist