fix(plugin): parse package specifiers with npm-package-arg and sanitize win32 cache paths#21135
Merged
thdxr merged 4 commits intoanomalyco:devfrom Apr 6, 2026
Merged
Conversation
Replace filesystem-illegal characters in package cache directory names on Windows by adding a sanitize() helper and using it in directory(). Fix parsing of plugin specifiers by splitting on the first "@" after position 0 so scoped names and git URLs are handled correctly. Add unit tests for parsePluginSpecifier covering plain, scoped, and git URL cases.
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes plugin spec parsing for npm/git URL forms and improves Windows compatibility when deriving npm install cache directories.
Changes:
- Add unit tests covering
parsePluginSpecifierfor unscoped/scoped packages, semver versions, and git URL versions (includinggit@...). - Update
parsePluginSpecifierto split on the version separator without breaking git+ssh URLs that include an additional@. - Sanitize npm package cache directory names on Windows to avoid illegal filename characters.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/opencode/test/plugin/shared.test.ts | Adds coverage for plugin specifier parsing across common npm and git URL patterns. |
| packages/opencode/src/plugin/shared.ts | Adjusts parsing logic to correctly separate package name and version for git URL specs. |
| packages/opencode/src/npm/index.ts | Adds Win32 directory-name sanitization for npm cache install directories. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Always define the illegal-character set and export Npm.sanitize, but only perform character substitution on Windows (no-op on other platforms). This exposes sanitize for testing and avoids unnecessary replacements on non-Windows systems. Adds unit tests to verify scoped package handling and git+https spec sanitization on Windows.
Add npm-package-arg (and types) and switch plugin specifier parsing to use it. parsePluginSpecifier now relies on npa to correctly handle aliases, npm: protocol specs, git URLs and unversioned specs; resolvePluginTarget builds the install target from the parsed result. Npm.sanitize was simplified to only apply Windows-specific illegal-character replacement, and tests were updated/added to cover the new parsing and sanitize behaviors. Package.json and lockfile updated to include the new dependency.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 6 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Member
Author
|
/review |
Contributor
|
lgtm |
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.
Fixes #21126
Fixes #21099