fix: resolve remaining import.meta.url paths broken by airgap bundling#24
Open
DeDuva wants to merge 1 commit into
Open
fix: resolve remaining import.meta.url paths broken by airgap bundling#24DeDuva wants to merge 1 commit into
DeDuva wants to merge 1 commit into
Conversation
Same failure mode as the templates-dir fix (#23): several other modules resolved package-relative paths off their own compiled file's import.meta.url, which only holds when squad-sdk runs unbundled. Once bundled into squad-cli's single-file dist/squad.js, every inlined module shares that file's location instead, breaking the relative-path arithmetic. Fixes flagged by review of #22: - squad-cli's loop.ts (generateLoopFile, squad loop --init), rc.ts and start.ts (remote-ui static assets for squad rc / squad start) now try both the unbundled and bundled offsets and use whichever exists. rc.ts/start.ts share the new resolveRemoteUiDir() helper. - squad-sdk's consult.ts (getSquadAgentTemplatePath) gets the same sibling-of-dist candidate added in the templates-dir fix. - squad-sdk's presets/index.ts (getBuiltinPresetsDir) previously had no bundled fallback at all — squad-cli's built files never shipped the built-in presets directory. Added a postbuild step to copy squad-sdk's dist/presets/builtin into squad-cli/dist/presets/builtin, and a second candidate path so getBuiltinPresetsDir() finds it there when bundled. Verified: rebuilt, ran `squad loop --init` end-to-end via the bundled CLI (previously would have silently resolved the wrong template path), confirmed dist/presets/builtin is now populated in the shipped bundle. Full relevant suites green (test/remote-control.test.ts, test/presets.test.ts, test/init-sdk.test.ts, test/sdk-templates-dir-resolution.test.ts). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
DeDuva
force-pushed
the
fix/bundled-import-meta-url-paths
branch
from
July 12, 2026 20:39
2f4fa8d to
8a6f597
Compare
🛫 PR Readiness Check
PR Scope: 📦🔧 Mixed (product + infrastructure)
|
| Status | Check | Details |
|---|---|---|
| ✅ | Single commit | 1 commit — clean history |
| ✅ | Not in draft | Ready for review |
| ✅ | Branch up to date | Up to date with dev |
| ❌ | Copilot review | No Copilot review yet — it may still be processing |
| ❌ | Changeset present | Missing .changeset/*.md or CHANGELOG.md edit — run npx changeset add (or add skip-changelog label) |
| ✅ | Scope clean | No .squad/ or docs/proposals/ files |
| ✅ | No merge conflicts | No merge conflicts |
| ✅ | Copilot threads resolved | No Copilot review threads |
| ❌ | CI passing | 3 check(s) failing: samples-build, test, Policy Gates |
Files Changed (7 files, +74 −17)
| File | +/− |
|---|---|
packages/squad-cli/package.json |
+1 −1 |
packages/squad-cli/src/cli/commands/loop.ts |
+10 −2 |
packages/squad-cli/src/cli/commands/rc.ts |
+2 −5 |
packages/squad-cli/src/cli/commands/start.ts |
+2 −2 |
packages/squad-cli/src/cli/core/remote-ui-dir.ts |
+26 −0 |
packages/squad-sdk/src/presets/index.ts |
+17 −2 |
packages/squad-sdk/src/sharing/consult.ts |
+16 −5 |
Total: +74 −17
This check runs automatically on every push. Fix any ❌ items and push again.
See CONTRIBUTING.md and PR Requirements for details.
|
👋 Friendly nudge — this PR has had no activity for 7 days. What needs attention:
If this PR is abandoned, please close it. If it's blocked on something external, leave a comment so the team knows. |
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.
Summary
Follow-up to #23. A reviewer subagent audit of the M1+M2 replay flagged 5 more spots using the same
import.meta.url-relative-offset pattern that breaks once squad-sdk's source is esbuild-bundled into squad-cli's single-filedist/squad.js:packages/squad-cli/src/cli/commands/loop.ts—generateLoopFile()(squad loop --init)packages/squad-cli/src/cli/commands/rc.tsandstart.ts— remote-ui static asset serving (squad rc/squad start)packages/squad-sdk/src/sharing/consult.ts—getSquadAgentTemplatePath()packages/squad-sdk/src/presets/index.ts—getBuiltinPresetsDir(), which had no bundled fallback at all — squad-cli's built package never shipped the built-in presets directory in the first place. Added a postbuild step (packages/squad-cli/package.json) that copies squad-sdk'sdist/presets/builtinintosquad-cli/dist/presets/builtin.All fixes follow the same shape as #23: try both the unbundled offset and the bundled (sibling-of-dist) offset, use whichever exists.
rc.ts/start.tsshare a newresolveRemoteUiDir()helper since they had identical logic.Test plan
npm run build) and confirmeddist/presets/builtinis now populated in the shipped bundle (previously empty/absent)squad loop --initin a fresh scratch repo — createsloop.mdwith real template content (previously would have silently resolved to the wrong/stale path)npx vitest run test/remote-control.test.ts test/presets.test.ts test/init-sdk.test.ts test/sdk-templates-dir-resolution.test.ts— 152/152 passingnpm run lint(typecheck both packages) — clean🤖 Generated with Claude Code