fix(core): use file:// URLs for local dynamic import() on Windows+Node#23639
Merged
Hona merged 2 commits intoanomalyco:devfrom Apr 21, 2026
Merged
fix(core): use file:// URLs for local dynamic import() on Windows+Node#23639Hona merged 2 commits intoanomalyco:devfrom
Hona merged 2 commits intoanomalyco:devfrom
Conversation
Node's ESM loader on Windows rejects bare absolute paths for dynamic import() and requires file:// URLs. This path is exercised by the Electron desktop app, whose server runs in Node (not Bun), causing provider SDK loading and custom tool discovery to fail with 'Received protocol c:'. Always convert to pathToFileURL(...).href before import(); safe on Bun too.
Brendonovich
approved these changes
Apr 21, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes dynamic import() behavior on Windows under Node by consistently using file:// URLs when importing modules by absolute filesystem path, aligning tool/provider loading with Node’s ESM loader requirements.
Changes:
- Tool registry plugin loader now always imports discovered tool files via
pathToFileURL(...).href. - Provider SDK loader now normalizes non-
file://entrypoints tofile://URLs before dynamic import.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/opencode/src/tool/registry.ts | Ensures tool modules discovered via glob are imported using file:// URLs for Windows+Node compatibility. |
| packages/opencode/src/provider/provider.ts | Normalizes installed/local provider entrypoints to file:// URLs before importing to avoid Node ESM loader failures on Windows. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
metyatech
pushed a commit
to metyatech/opencode
that referenced
this pull request
Apr 22, 2026
xywsxp
pushed a commit
to xywsxp/opencode
that referenced
this pull request
Apr 24, 2026
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
import()intofile://URLs for Windows Node compatibilityReceived protocol 'c:'Notes
packages/opencode/src/tool/registry.ts: discovered tool files are absolute filesystem paths fromGlob.scanSync(..., { absolute: true })packages/opencode/src/provider/provider.ts: provider entrypoints are normalized only when they are local paths and left unchanged when alreadyfile://file://for these paths; a separate Bun 1.3.10Npm.add()package-layout issue is unrelated to this PR