Plugin loader incorrectly appends @latest to GitHub references #6361

Open
opened 2026-02-16 18:03:32 -05:00 by yindo · 0 comments
Owner

Originally created by @frankekn on GitHub (Jan 15, 2026).

Originally assigned to: @thdxr on GitHub.

Description

When using a GitHub-hosted plugin like github:owner/repo, OpenCode appends @latest to form github:owner/repo@latest, which Bun cannot resolve.

Root Cause

In packages/opencode/src/plugin/index.ts:

const lastAtIndex = plugin.lastIndexOf("@")
const pkg = lastAtIndex > 0 ? plugin.substring(0, lastAtIndex) : plugin
const version = lastAtIndex > 0 ? plugin.substring(lastAtIndex + 1) : "latest"
plugin = await BunProc.install(pkg, version)  // becomes pkg + "@" + version

This creates github:owner/repo@latest which Bun fails to resolve with:

error: GET https://api.github.com/repos//latest/tarball/ - 404
error: github:owner/repo@latest failed to resolve

Bun's GitHub Dependency Format

According to Bun documentation, GitHub dependencies use # for version/tag specifiers, not @:

{
  "lodash": "git+ssh://github.com/lodash/lodash.git#4.17.21",
  "zod": "github:colinhacks/zod"
}

The @ syntax is only for npm registry packages.

Reproduction

bun add "github:lodash/lodash@latest"
# error: GET https://api.github.com/repos//latest/tarball/ - 404

bun add "github:lodash/lodash"
# Success - installs from default branch

bun add "github:lodash/lodash#main"
# Success - installs from main branch

Suggested Fix

Check if the plugin string starts with github: or git+ before appending version:

const isGitDependency = plugin.startsWith("github:") || plugin.startsWith("git+") || plugin.startsWith("git://")

if (isGitDependency) {
  // Don't append @latest for git dependencies
  // Or use # instead: pkg + "#" + version
  plugin = await BunProc.install(pkg, undefined)
} else {
  plugin = await BunProc.install(pkg, version)
}

Workaround

Publish the plugin to npm registry instead of using GitHub reference.

Originally created by @frankekn on GitHub (Jan 15, 2026). Originally assigned to: @thdxr on GitHub. ## Description When using a GitHub-hosted plugin like `github:owner/repo`, OpenCode appends `@latest` to form `github:owner/repo@latest`, which Bun cannot resolve. ## Root Cause In `packages/opencode/src/plugin/index.ts`: ```typescript const lastAtIndex = plugin.lastIndexOf("@") const pkg = lastAtIndex > 0 ? plugin.substring(0, lastAtIndex) : plugin const version = lastAtIndex > 0 ? plugin.substring(lastAtIndex + 1) : "latest" plugin = await BunProc.install(pkg, version) // becomes pkg + "@" + version ``` This creates `github:owner/repo@latest` which Bun fails to resolve with: ``` error: GET https://api.github.com/repos//latest/tarball/ - 404 error: github:owner/repo@latest failed to resolve ``` ## Bun's GitHub Dependency Format According to [Bun documentation](https://bun.sh/docs/cli/add#git-dependencies), GitHub dependencies use `#` for version/tag specifiers, not `@`: ```json { "lodash": "git+ssh://github.com/lodash/lodash.git#4.17.21", "zod": "github:colinhacks/zod" } ``` The `@` syntax is only for npm registry packages. ## Reproduction ```bash bun add "github:lodash/lodash@latest" # error: GET https://api.github.com/repos//latest/tarball/ - 404 bun add "github:lodash/lodash" # Success - installs from default branch bun add "github:lodash/lodash#main" # Success - installs from main branch ``` ## Suggested Fix Check if the plugin string starts with `github:` or `git+` before appending version: ```typescript const isGitDependency = plugin.startsWith("github:") || plugin.startsWith("git+") || plugin.startsWith("git://") if (isGitDependency) { // Don't append @latest for git dependencies // Or use # instead: pkg + "#" + version plugin = await BunProc.install(pkg, undefined) } else { plugin = await BunProc.install(pkg, version) } ``` ## Workaround Publish the plugin to npm registry instead of using GitHub reference.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#6361