Skip to content

fix: resolve remaining import.meta.url paths broken by airgap bundling#24

Open
DeDuva wants to merge 1 commit into
devfrom
fix/bundled-import-meta-url-paths
Open

fix: resolve remaining import.meta.url paths broken by airgap bundling#24
DeDuva wants to merge 1 commit into
devfrom
fix/bundled-import-meta-url-paths

Conversation

@DeDuva

@DeDuva DeDuva commented Jul 12, 2026

Copy link
Copy Markdown
Owner

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-file dist/squad.js:

  • packages/squad-cli/src/cli/commands/loop.tsgenerateLoopFile() (squad loop --init)
  • packages/squad-cli/src/cli/commands/rc.ts and start.ts — remote-ui static asset serving (squad rc / squad start)
  • packages/squad-sdk/src/sharing/consult.tsgetSquadAgentTemplatePath()
  • packages/squad-sdk/src/presets/index.tsgetBuiltinPresetsDir(), 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's dist/presets/builtin into squad-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.ts share a new resolveRemoteUiDir() helper since they had identical logic.

Test plan

  • Rebuilt (npm run build) and confirmed dist/presets/builtin is now populated in the shipped bundle (previously empty/absent)
  • Manual repro via the bundled CLI: squad loop --init in a fresh scratch repo — creates loop.md with 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 passing
  • npm run lint (typecheck both packages) — clean

🤖 Generated with Claude Code

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
DeDuva force-pushed the fix/bundled-import-meta-url-paths branch from 2f4fa8d to 8a6f597 Compare July 12, 2026 20:39
@DeDuva
DeDuva changed the base branch from replatform-0.11 to dev July 12, 2026 20:39
@github-actions

github-actions Bot commented Jul 12, 2026

Copy link
Copy Markdown

🛫 PR Readiness Check

ℹ️ This comment updates on each push. Last checked: commit 8a6f597

PR Scope: 📦🔧 Mixed (product + infrastructure)

⚠️ 3 item(s) to address before review

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.

@github-actions

Copy link
Copy Markdown

👋 Friendly nudge — this PR has had no activity for 7 days.

What needs attention:

  • 🔴 3 CI check(s) failing: samples-build, test, Policy Gates. Fix these first.
  • 👀 No approving reviews yet. Request a review from a teammate.
  • ⬇️ 23 commits behind dev. Rebase to pick up latest changes.

If this PR is abandoned, please close it. If it's blocked on something external, leave a comment so the team knows.
This is an automated check that runs on weekdays. It won't nudge the same PR more than once per week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant