Skip to content

Commit 5d99234

Browse files
saravmajesticclaude
andcommitted
fix: one resolved identity; report the upgrade that actually happened (#1305)
Addresses the CHANGES_REQUESTED review on 40779c5. Its three MAJOR findings are not independent — they are two invariants this change had not finished — so they are fixed together rather than patched individually. **One identity, resolved once.** Ownership was verified in `method()`, then independently re-probed in `preflight()`, again when building the install command, and once more in `uninstall`. Each was a separate manager query that could fail or race independent of the one before it, and `owningPackageOrScoped()` turned a later failure into a silent substitution of the scoped package name. For a confirmed UNSCOPED install that meant upgrade installed a second, scoped copy while the real one stayed stale — reporting success — and uninstall deleted the user's data, then removed a package that was never installed. `identity()` now resolves once and is memoised for the process; nothing it reads can change while the binary is running. `packageFor()` uses the verified owner, and when a caller forces `--method`, or ownership is unconfirmed, it logs that it is assuming the scoped name rather than substituting quietly. That also answers the third finding: an upgrade previously spawned ~7 manager subprocesses because every call site re-derived the answer. It is now a single query (two spawns for npm), while keeping verification before any mutating action. **Report what actually happened.** Telemetry recorded `status: "success"` and the CLI printed "Upgrade complete" BEFORE checking whether the running binary had changed; a mismatch only wrote a log warning. The check also used `text()`, which swallows a failed spawn and returns "", and an empty string was read as "nothing to verify" — so an upgrade that left the binary unrunnable reported success. Verification now runs first, via `run()` so the exit status is visible, and distinguishes three outcomes: a non-zero exit (the binary cannot start) and a contradicting version both fail the upgrade and record an error; exit 0 with no output is reported as unverifiable rather than being claimed either way. Review minors, all fixed: * uninstall no longer tells the user to "re-run" a command whose binary they have just removed; it names the data/config/cache/state directories to delete by hand. * per-manager removal and upgrade syntax — `bun remove -g` and `yarn global remove` are not `<manager> uninstall -g`. * Windows recovery text no longer prints POSIX-only paths and `curl … | bash`; it uses `%USERPROFILE%\.altimate\bin` and the PowerShell installer. * `--method` no longer offers `choco`/`scoop`, which `Installation.upgrade()` always refuses. Help snapshot updated. * the ambiguous trailing "(or altimate-code)" is now an explicit sentence about the scoped vs unscoped package name. * `bunGlobalRoot()` falls back to BUN_INSTALL when a configured `install.globalBinDir` breaks the derivation, and returns "" when bun reports nothing. * stale comment claiming the failure log "stays local" — the claim `redactSecrets()`'s own docblock calls false — removed. * `ownership.test.ts` no longer leaks a temp directory per run; short-token redaction shapes pinned. Known limitation, deliberate: only the manager the path points at is queried. Probing every manager would resolve a custom layout whose directory carries no recognisable segment, but it multiplies the subprocess count this change exists to reduce, to rescue a case that already degrades safely to notify-only. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
1 parent 40779c5 commit 5d99234

7 files changed

Lines changed: 211 additions & 74 deletions

File tree

‎packages/opencode/src/cli/cmd/uninstall.ts‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,24 @@ export const UninstallCommand = {
7171
// cares about and left the installation running, with no indication that had happened.
7272
// Data loss with nothing uninstalled is strictly worse than declining.
7373
if (method === "unknown") {
74+
const win = process.platform === "win32"
75+
const standalone = win ? "%USERPROFILE%\\.altimate\\bin" : "~/.altimate/bin"
7476
prompts.log.error(`Cannot determine how altimate was installed (running from ${process.execPath}).`)
7577
prompts.log.info("Uninstalling now would delete your data and config while leaving the program installed.")
76-
prompts.log.info("Remove it with the tool you installed it with, then re-run to clean up data:")
77-
prompts.log.info(" npm/pnpm/bun/yarn: <manager> uninstall -g @altimateai/altimate-code (or altimate-code)")
78-
prompts.log.info(" Homebrew: brew uninstall altimate-code")
79-
prompts.log.info(" install script: rm the binary from ~/.altimate/bin")
78+
prompts.log.info("Remove the program with whichever tool installed it — each has its own syntax:")
79+
prompts.log.info(" npm: npm uninstall -g altimate-code")
80+
prompts.log.info(" pnpm: pnpm uninstall -g altimate-code")
81+
prompts.log.info(" bun: bun remove -g altimate-code")
82+
prompts.log.info(" yarn: yarn global remove altimate-code")
83+
prompts.log.info(" Homebrew: brew uninstall altimate-code")
84+
prompts.log.info(` installer: delete the binary from ${standalone}`)
85+
prompts.log.info("If you installed the scoped package, use @altimateai/altimate-code as the name instead.")
86+
// Do not tell the user to "re-run" this command: once the package is gone, so is the
87+
// binary that would run it. Name the directories so data can be cleaned up by hand.
88+
prompts.log.info("Then delete these directories to remove data, config, cache and state:")
89+
for (const dir of [Global.Path.data, Global.Path.config, Global.Path.cache, Global.Path.state]) {
90+
prompts.log.info(` ${dir}`)
91+
}
8092
prompts.outro("Nothing was removed")
8193
return
8294
}

‎packages/opencode/src/cli/cmd/upgrade.ts‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ export const UpgradeCommand = {
2323
alias: "m",
2424
describe: "installation method to use",
2525
type: "string",
26-
choices: ["curl", "npm", "pnpm", "bun", "brew", "choco", "scoop"],
26+
// altimate_change start — #1305: keep in step with UNSUPPORTED_UPGRADE_METHODS.
27+
// choco/scoop were offered here but Installation.upgrade() always refuses them, so
28+
// selecting either could only fail.
29+
choices: ["curl", "npm", "pnpm", "bun", "brew"],
30+
// altimate_change end
2731
})
2832
},
2933
handler: async (args: { target?: string; method?: string }) => {
@@ -57,10 +61,17 @@ export const UpgradeCommand = {
5761
? `Cannot determine how altimate was installed (running from ${process.execPath}).`
5862
: `Upgrading a ${method} installation is not supported.`,
5963
)
60-
prompts.log.info("Upgrade with the tool you installed it with:")
61-
prompts.log.info(" npm/pnpm/bun: <manager> install -g @altimateai/altimate-code@latest (or altimate-code)")
62-
prompts.log.info(" Homebrew: brew upgrade altimate-code")
63-
prompts.log.info(" install script: curl -fsSL https://www.altimate.sh/install | bash")
64+
prompts.log.info("Upgrade with whichever tool installed it:")
65+
prompts.log.info(" npm: npm install -g altimate-code@latest")
66+
prompts.log.info(" pnpm: pnpm install -g altimate-code@latest")
67+
prompts.log.info(" bun: bun install -g altimate-code@latest")
68+
prompts.log.info(" Homebrew: brew upgrade altimate-code")
69+
prompts.log.info(
70+
process.platform === "win32"
71+
? " installer: irm https://www.altimate.sh/install.ps1 | iex"
72+
: " installer: curl -fsSL https://www.altimate.sh/install | bash",
73+
)
74+
prompts.log.info("If you installed the scoped package, use @altimateai/altimate-code as the name instead.")
6475
prompts.log.info("Or force a specific manager with --method <npm|pnpm|bun|brew|curl>.")
6576
prompts.outro("Done")
6677
return

0 commit comments

Comments
 (0)