opencode icon indicating copy to clipboard operation
opencode copied to clipboard

feat: add choco and scoop to opencode upgrade methods

Open itsrainingmani opened this issue 13 hours ago • 2 comments

What does this PR do?

Adds support for opencode upgrade to work with Chocolatey and Scoop installations. This works by adding choco and scoop commands to the relevant methods in the Installation namespace -

  • Installation.method: add choco list and scoop list commands
  • Installation.upgrade: add choco upgrade --version=<target> and scoop install opencode@<target> commands
  • Installation.latest: fetch the latest version number of the choco and scoop opencode packages from public manifest URLs

How did you verify your code works?

Chocolatey

PS C:\Users\Mani\repos\opencode\dev--win-auto-update> opencode -v
1.1.17
PS C:\Users\Mani\repos\opencode\dev--win-auto-update> bun dev upgrade
$ bun run --cwd packages/opencode --conditions=browser src/index.ts upgrade

                                   ▄
  █▀▀█ █▀▀█ █▀▀█ █▀▀▄ █▀▀▀ █▀▀█ █▀▀█ █▀▀█
  █░░█ █░░█ █▀▀▀ █░░█ █░░░ █░░█ █░░█ █▀▀▀
  ▀▀▀▀ █▀▀▀ ▀▀▀▀ ▀  ▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀


┌  Upgrade
│
●  Using method: choco
│
●  From v1.1.17 → 1.1.18
│
◇  Upgrade complete
│
└  Done

PS C:\Users\Mani\repos\opencode\dev--win-auto-update> opencode -v
1.1.18

Scoop

PS C:\Users\Mani\repos\opencode\dev--win-auto-update> opencode -v
1.1.17
PS C:\Users\Mani\repos\opencode\dev--win-auto-update> bun dev upgrade
$ bun run --cwd packages/opencode --conditions=browser src/index.ts upgrade

                                   ▄
  █▀▀█ █▀▀█ █▀▀█ █▀▀▄ █▀▀▀ █▀▀█ █▀▀█ █▀▀█
  █░░█ █░░█ █▀▀▀ █░░█ █░░░ █░░█ █░░█ █▀▀▀
  ▀▀▀▀ █▀▀▀ ▀▀▀▀ ▀  ▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀


┌  Upgrade
│
●  Using method: scoop
│
●  From v1.1.17 → 1.1.18
│
◇  Upgrade complete
│
└  Done

PS C:\Users\Mani\repos\opencode\dev--win-auto-update> opencode -v
1.1.18

Notify Update

latest() pulls in the right version for our chocolatey based install (1.1.18 at the time of this PR whereas latest release is on 1.1.19

image

Not an Elevated Command Shell

Chocolatey has an annoying issue where it doesn't allow installation or upgrading a package if you're not in an elevated command shell. This "error" also passes to stdout and not stderr so we pass a custom error message to the UpgradeFailedError so we can capture it in the upgrade.ts and communicate this to the user.

image

Output of upgrade w/ a non-elevated command shell (this has been tested on cmd and non-elevated powershell.

PS C:\Users\Mani\repos\opencode\dev--win-auto-update> bun dev upgrade
$ bun run --cwd packages/opencode --conditions=browser src/index.ts upgrade

                                   ▄
  █▀▀█ █▀▀█ █▀▀█ █▀▀▄ █▀▀▀ █▀▀█ █▀▀█ █▀▀█
  █░░█ █░░█ █▀▀▀ █░░█ █░░░ █░░█ █░░█ █▀▀▀
  ▀▀▀▀ █▀▀▀ ▀▀▀▀ ▀  ▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀


┌  Upgrade
│
●  Using method: choco
│
●  From v1.1.17 → 1.1.18
│
■  Upgrade failed
│
■  Please run the terminal as Administrator and try again
│
└  Done

itsrainingmani avatar Jan 14 '26 12:01 itsrainingmani