fix(installation): use package-manager metadata for upgrade checks#23778
Closed
lawrence3699 wants to merge 1 commit intoanomalyco:devfrom
Closed
fix(installation): use package-manager metadata for upgrade checks#23778lawrence3699 wants to merge 1 commit intoanomalyco:devfrom
lawrence3699 wants to merge 1 commit intoanomalyco:devfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates Installation.latest() to query npm-like package managers for the latest version using their own metadata commands (instead of raw HTTP registry requests), which preserves auth/config handling for private registries and improves upgrade reliability.
Changes:
- Replace raw HTTP registry lookups for npm/pnpm/bun with
view ... version --jsonpackage-manager commands executed from the user’s home directory. - Add tests asserting that npm/pnpm/bun paths do not perform HTTP requests and that an empty metadata response becomes a failure.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/opencode/src/installation/index.ts | Switches npm-like latest-version checks from HTTP registry calls to package-manager view commands and adds stricter “empty output” handling. |
| packages/opencode/test/installation/installation.test.ts | Updates/extends tests to validate the new npm/pnpm/bun view-based behavior and the empty-output failure case. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+151
to
+156
| return yield* Effect.try({ | ||
| try: () => { | ||
| const parsed = JSON.parse(raw) | ||
| return typeof parsed === "string" ? parsed : raw.replace(/^"|"$/g, "") | ||
| }, | ||
| catch: () => raw.replace(/^"|"$/g, ""), |
Author
|
Closing this because the underlying issue appears to have been resolved by #24016. This PR is no longer needed. |
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.
Issue for this PR
Closes #23434
Type of change
What does this PR do?
Installation.latest()was resolving npm-like upgrades by reading the registry URL and performing a raw HTTP request. That bypassed the package manager's auth/config handling, soopencode upgradecould fail against private registries even whennpm,pnpm, orbunwere already configured correctly.This switches npm, pnpm, and bun installs to use their own
view ... version --jsoncommands from a neutral working directory, and it now fails instead of returning a blank version if the metadata lookup produces no output.How did you verify your code works?
bun test test/installation/installation.test.tsbun typecheckcd ~ && npm view opencode-ai version --jsoncd ~ && pnpm view opencode-ai version --jsoncd ~ && bun pm view opencode-ai version --jsonScreenshots / recordings
N/A
Checklist