fix: [AI-734] route Windows upgrade/uninstall to altimate-code, not upstream opencode#735
fix: [AI-734] route Windows upgrade/uninstall to altimate-code, not upstream opencode#735anandgupta42 wants to merge 1 commit intomainfrom
Conversation
…pstream `opencode`
Production telemetry showed Windows users being auto-upgraded to `1.14.19` —
the upstream `sst/opencode` version — and hitting "not running from an
elevated command shell" in a retry loop. Root cause: four code paths still
referenced upstream package identifiers (`opencode-ai` for npm/pnpm/bun/yarn,
`opencode` for brew/choco/scoop registries).
altimate-code is not distributed via chocolatey or scoop (verified against
`publish.ts` — only npm / Docker / AUR / Homebrew). Any match against those
managers was pointing at the wrong product.
### `packages/opencode/src/installation/index.ts`
- `method()`: choco/scoop entries reduced to sentinels (`Promise.resolve("")`)
that never match. Keeps the `Method` type union intact for `--method=choco`
callers but can never auto-detect.
- `latest()`: choco/scoop branches removed; these methods now fall through to
the GitHub releases API. Returns `0.6.0` instead of `1.14.19`.
- `upgrade()`: choco/scoop cases synthesize an `UpgradeResult` with `code: 1`
and a helpful stderr that points users to npm / Homebrew / altimate.ai/install.
Flows through the existing `upgrade_attempted status=error` telemetry so we
can measure how often users hit this.
- Extracted `type UpgradeResult = { code: number; stdout: Buffer; stderr: Buffer }`
— replaces the fragile `as Awaited<ReturnType<typeof upgradeCurl>>` cast.
- `telemetryMethod` keeps choco/scoop as distinct values (not collapsed into
`"other"`) so Windows misrouting is separable from generic failures.
- Removed the hardcoded `method === "choco" ? "not running from an elevated
command shell" : ...` special case — real stderr now propagates.
### `packages/opencode/src/cli/cmd/upgrade.ts`
- `--method` `choices` array no longer exposes `choco` / `scoop` to users.
- Removed the unreachable `method === "choco" && stderr.includes("elevated
command shell")` branch in the error handler.
### `packages/opencode/src/cli/cmd/uninstall.ts`
- Same class of bug. Package-name maps in `showRemovalSummary` and
`executeUninstall` updated to `@altimateai/altimate-code` / `altimate-code`.
- choco/scoop entries dropped (not published there). Removed the choco-specific
`["choco", "uninstall", "opencode", "-y", "-r"]` branch and the UAC fallback.
### `packages/opencode/src/cli/upgrade.ts` + `telemetry/index.ts`
New `upgrade_available` telemetry event, emitted from `notify()` when the user
is PROACTIVELY shown an "upgrade available" toast. Pair with `upgrade_attempted`
to compute the notification → action funnel (shown vs acted-on).
- Emitted ONLY on proactive paths (autoupdate=disabled, autoupdate=notify,
method=unknown|yarn). NOT emitted from the auto-upgrade error-recovery
catch handler — that path already signals via `upgrade_attempted status=error`,
and emitting both inverts the natural funnel order.
- Deduped per `(correlationId:version)` via a module-level `Set` so repeated
`upgrade()` calls in the same process don't inflate the notified-denominator.
- `correlationId` falls back `sessionId → machineId → "cli"` so the key is
stable even when `upgrade()` runs before session_start.
- Telemetry wrapped in try/catch; failures never block the `Bus.publish` that
shows the toast.
- Factored out `publishUpdate()` helper so the catch handler can show the
toast without triggering telemetry.
- Exposed `machineId` on `Telemetry.getContext()` return.
### Tests
Added runtime behavioral tests (previously only source-level):
- `upgrade("choco", ...)` and `upgrade("scoop", ...)` throw `UpgradeFailedError`
with the expected helpful message.
- Fall-through `latest("choco"/"scoop")` hits GitHub API, not upstream feeds.
Added source-level guards for: `--method` CLI choices excluding choco/scoop,
`cmd/upgrade.ts` dead-branch removal, `cmd/uninstall.ts` package names,
`telemetryMethod` union preserving choco/scoop, `notify()` dedup,
error-recovery suppression, machineId fallback, and `UpgradeResult` named
type replacing the loose cast.
Updated `test/altimate/telemetry-safety.test.ts` mock to include `machineId`
in the `getContext()` return shape.
### Verification
- `bun turbo typecheck` — 5/5 packages pass
- 88 relevant installation/upgrade/uninstall tests pass (225 assertions)
- 2,856 altimate-area tests + 490 CLI tests pass
- Marker check passes
Closes #734
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR fixes Windows users being routed to the upstream Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
👋 This PR was automatically closed by our quality checks. Common reasons:
If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you. |
|
👋 This PR was automatically closed by our quality checks. Common reasons:
If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you. |
|
👋 This PR was automatically closed by our quality checks. Common reasons:
If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you. |
What does this PR do?
Fixes a production bug where Windows users were being auto-upgraded to
1.14.19— the upstreamsst/opencodeversion — because four code paths still referenced upstream package identifiers. Also closes the adjacent bug inaltimate uninstallthat had the same class of misrouting.Observed in telemetry:
Scope of the fix (
packages/opencode/src/paths):installation/index.ts—method()no longer auto-detects choco/scoop (sentinel entries keep theMethodtype union intact without matching);latest()falls through to GitHub releases;upgrade()synthesizes a helpful error result that flows through existing telemetry; extractedtype UpgradeResultto replace a fragileas Awaited<ReturnType<...>>cast;telemetryMethodpreserves choco/scoop granularity.cli/cmd/upgrade.ts— removedchoco/scoopfrom--methodchoices, removed dead "elevated command shell" branch.cli/cmd/uninstall.ts— updated package names to@altimateai/altimate-code/altimate-code, dropped choco/scoop commands, removed UAC fallback.cli/upgrade.ts+altimate/telemetry/index.ts— newupgrade_availabletelemetry event. Emitted only on proactive notification paths (NOT from the auto-upgrade error-recovery catch). Deduped per(correlationId:version)via a module-level Set.correlationIdfalls backsessionId → machineId → "cli". Telemetry failure never blocks the Bus.publish that shows the toast. ExposedmachineIdonTelemetry.getContext()return.Type of change
Issue for this PR
Closes #734
How did you verify your code works?
bun turbo typecheck— 5/5 packages passbun run script/upstream/analyze.ts --markers --base main --strictcleanInstallation.upgrade("choco"/"scoop", ...)throwing with the expected message--methodchoices, dead-branch removal, package names, telemetryMethod union, notify dedup, error-recovery suppression, machineId fallback, and UpgradeResult named typeChecklist
fix: [AI-734] ...)// altimate_change start / endmarkers/consensus:code-reviewbefore commit (9-model panel)12c7c779)🤖 Generated with Claude Code
Summary by CodeRabbit
Removed Features
New Features
Changes
@altimateai/altimate-code, Homebrew usesaltimate-code.Summary by cubic
Fixes Windows upgrade/uninstall routing to target
@altimateai/altimate-code(npm-family) andaltimate-code(Homebrew), preventing accidental upgrades to upstreamopencode. Adds proactiveupgrade_availabletelemetry to measure the notify → upgrade funnel. Addresses AI-734.Bug Fixes
choco/scoopfrom auto-detect and CLI--methodchoices;latest()now falls back to GitHub releases;upgrade()forchoco/scoopreturns a clear “not distributed here” error.@altimateai/altimate-codeandaltimate-code; removed Windows UAC branch tied to Chocolatey.choco/scoopin upgrade telemetry method for analytics; propagate real stderr; introducedUpgradeResulttype.New Features
upgrade_availabletelemetry: emitted only on proactive notifications, deduped per(correlationId:version), with correlation falling backsessionId → machineId → "cli". Telemetry failures never block the toast.Written for commit d2531c8. Summary will update on new commits.