fix(coding-agent): remove install method cache

This commit is contained in:
Mario Zechner 2026-02-03 01:45:35 +01:00
parent 4137ed787b
commit 494a7750ef
2 changed files with 13 additions and 24 deletions

View file

@ -5,6 +5,7 @@
### Added ### Added
- Added ExtensionUIContext getToolsExpanded and setToolsExpanded for controlling tool output expansion ([#1199](https://github.com/badlogic/pi-mono/pull/1199) by [@academo](https://github.com/academo)) - Added ExtensionUIContext getToolsExpanded and setToolsExpanded for controlling tool output expansion ([#1199](https://github.com/badlogic/pi-mono/pull/1199) by [@academo](https://github.com/academo))
- Added install method detection to show package manager specific update instructions ([#1203](https://github.com/badlogic/pi-mono/pull/1203) by [@Itsnotaka](https://github.com/Itsnotaka))
### Fixed ### Fixed

View file

@ -26,39 +26,27 @@ export const isBunRuntime = !!process.versions.bun;
export type InstallMethod = "bun-binary" | "npm" | "pnpm" | "yarn" | "bun" | "unknown"; export type InstallMethod = "bun-binary" | "npm" | "pnpm" | "yarn" | "bun" | "unknown";
let _cachedInstallMethod: InstallMethod | undefined;
export function detectInstallMethod(): InstallMethod { export function detectInstallMethod(): InstallMethod {
if (_cachedInstallMethod) return _cachedInstallMethod;
if (isBunBinary) { if (isBunBinary) {
_cachedInstallMethod = "bun-binary"; return "bun-binary";
return _cachedInstallMethod;
} }
const resolvedPath = `${__dirname}\0${process.execPath || ""}`.toLowerCase(); const resolvedPath = `${__dirname}\0${process.execPath || ""}`.toLowerCase();
if (resolvedPath.includes("/pnpm/") || resolvedPath.includes("/.pnpm/") || resolvedPath.includes("\\pnpm\\")) { if (resolvedPath.includes("/pnpm/") || resolvedPath.includes("/.pnpm/") || resolvedPath.includes("\\pnpm\\")) {
_cachedInstallMethod = "pnpm"; return "pnpm";
} else if ( }
resolvedPath.includes("/yarn/") || if (resolvedPath.includes("/yarn/") || resolvedPath.includes("/.yarn/") || resolvedPath.includes("\\yarn\\")) {
resolvedPath.includes("/.yarn/") || return "yarn";
resolvedPath.includes("\\yarn\\") }
) { if (isBunRuntime) {
_cachedInstallMethod = "yarn"; return "bun";
} else if (isBunRuntime) { }
_cachedInstallMethod = "bun"; if (resolvedPath.includes("/npm/") || resolvedPath.includes("/node_modules/") || resolvedPath.includes("\\npm\\")) {
} else if ( return "npm";
resolvedPath.includes("/npm/") ||
resolvedPath.includes("/node_modules/") ||
resolvedPath.includes("\\npm\\")
) {
_cachedInstallMethod = "npm";
} else {
_cachedInstallMethod = "unknown";
} }
return _cachedInstallMethod; return "unknown";
} }
export function getUpdateInstruction(packageName: string): string { export function getUpdateInstruction(packageName: string): string {