The open source coding agent.
TypeScript
feat(cli): uninstall opencode installed via windows package managers (#8571)
Mani Sundararajan0ccf9bd9acf5
diff --git a/packages/opencode/src/cli/cmd/uninstall.ts b/packages/opencode/src/cli/cmd/uninstall.tsindex 62210d57586..704d3572bbb 100644--- a/packages/opencode/src/cli/cmd/uninstall.ts+++ b/packages/opencode/src/cli/cmd/uninstall.ts@@ -133,6 +133,8 @@ async function showRemovalSummary(targets: RemovalTargets, method: Installation.bun: "bun remove -g opencode-ai",yarn: "yarn global remove opencode-ai",brew: "brew uninstall opencode",+ choco: "choco uninstall opencode",+ scoop: "scoop uninstall opencode",}prompts.log.info(` ✓ Package: ${cmds[method] || method}`)}@@ -182,16 +184,27 @@ async function executeUninstall(method: Installation.Method, targets: RemovalTarbun: ["bun", "remove", "-g", "opencode-ai"],yarn: ["yarn", "global", "remove", "opencode-ai"],brew: ["brew", "uninstall", "opencode"],+ choco: ["choco", "uninstall", "opencode"],+ scoop: ["scoop", "uninstall", "opencode"],}const cmd = cmds[method]if (cmd) {spinner.start(`Running ${cmd.join(" ")}...`)- const result = await $`${cmd}`.quiet().nothrow()+ const result =+ method === "choco"+ ? await $`echo Y | choco uninstall opencode -y -r`.quiet().nothrow()+ : await $`${cmd}`.quiet().nothrow()if (result.exitCode !== 0) {- spinner.stop(`Package manager uninstall failed`, 1)- prompts.log.warn(`You may need to run manually: ${cmd.join(" ")}`)- errors.push(`Package manager: exit code ${result.exitCode}`)+ spinner.stop(`Package manager uninstall failed: exit code ${result.exitCode}`, 1)+ if (+ method === "choco" &&+ result.stdout.toString("utf8").includes("not running from an elevated command shell")+ ) {+ prompts.log.warn(`You may need to run '${cmd.join(" ")}' from an elevated command shell`)+ } else {+ prompts.log.warn(`You may need to run manually: ${cmd.join(" ")}`)+ }} else {spinner.stop("Package removed")}