fix: prevent bundled OpenCode self-upgrades (#2525)

* fix: prevent bundled OpenCode self-upgrades

* feat(vscode): support OpenCode upgrades

* fix: refresh OpenCode update status on runtime switch

---------

Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
This commit is contained in:
𝖎𝖚𝖑𝖎𝖎𝖆
2026-07-29 19:59:41 +03:00
committed by GitHub
co-authored by Bohdan Triapitsyn
parent c0405d3fa4
commit c88dd16d2a
21 changed files with 620 additions and 84 deletions
@@ -301,6 +301,23 @@ export const createOpenCodeEnvRuntime = (deps) => {
return null;
};
const canonicalExecutablePath = (candidate) => {
if (typeof candidate !== 'string' || !candidate.trim()) return null;
try {
return fs.realpathSync.native(candidate.trim());
} catch {
return path.resolve(candidate.trim());
}
};
const isBundledOpenCodeCliPath = (candidate) => {
const canonicalCandidate = canonicalExecutablePath(candidate);
if (!canonicalCandidate) return false;
return bundledOpenCodeCliCandidates().some((bundledCandidate) => (
canonicalExecutablePath(bundledCandidate) === canonicalCandidate
));
};
const bundledOpenCodeCliFallback = () => {
const bundled = resolveBundledOpenCodeCliPath();
if (!bundled) return null;
@@ -1164,6 +1181,7 @@ export const createOpenCodeEnvRuntime = (deps) => {
applyOpencodeBinaryFromSettings,
getLoginShellEnvSnapshot,
resolveOpencodeCliPath,
isBundledOpenCodeCliPath,
resolveManagedOpenCodeLaunchSpec,
isExecutable,
searchPathFor,