Prime Agent's installation and self-update system detects how the package was installed — whether via Bun binary, Homebrew, or a package manager — by inspecting runtime signatures and filesystem paths, then routes self-update requests appropriately or reports when updates are unavailable. Self-update detection checks path writability and global package-manager scope; Bun binaries and Homebrew installs signal unavailability and return a manual GitHub download URL, while package-manager installs route through npm, yarn, or pnpm update commands.
packages/coding-agent/src/config.ts detects whether the process is running as a Bun compiled binary by checking if import.meta.url contains "$bunfs", "~BUN", or "%7EBUN" — Bun's virtual filesystem path indicators.[1] Whether Bun is the runtime at all (compiled binary or bun run) is detected separately via !!process.versions.bun, exported as isBunRuntime.[1] The InstallMethod type enumerates seven values: "bun-binary", "homebrew", "npm", "pnpm", "yarn", "bun", and "unknown".[1] detectInstallMethod() resolves the active method in priority order: "bun-binary" first (when isBunBinary is true), then Homebrew, then inspection of __dirname and process.execPath for package-manager path fragments (/pnpm/, /yarn/, /npm/, etc.).[1] A Homebrew install is identified by the package directory containing both "/cellar/" and "/libexec/lib/node_modules/" in its path.[1] install.sh and package.json comply with npm 12's remote dependency policy, which rejects installation patterns that earlier npm versions permitted. scripts/check-installer.mjs validates install.sh for npm 12 compatibility and is integrated into the build-binaries.yml CI workflow; changes to install.sh that fail this check will break binary builds.
getSelfUpdateCommand() returns undefined — signalling that self-update is unavailable — when any of three conditions hold: the detected install method carries no update command, the package is not under the global package manager's root, or the install path is not writable.[1] Both "bun-binary" and "homebrew" install methods return undefined from getSelfUpdateCommandForMethod(), as neither supports a programmatic self-update via a package manager command.[1] For a "bun-binary" install, getSelfUpdateUnavailableInstruction() returns a manual download URL: https://github.com/PrimeIntellect-ai/prime-agent/releases/latest.[1] On Windows, isManagedByGlobalPackageManager() does not infer the npm global prefix from path shape alone, because Windows global npm uses <prefix>\node_modules — indistinguishable from a local project install without npm root -g evidence.[1] When bun is configured as the npm command, the global package root is derived from bun pm bin -g output and the default path ~/.bun/install/global/node_modules.[1] When getSelfUpdateCommand() returns undefined, getSelfUpdateUnavailableInstruction() provides a human-readable fallback message containing a manual download URL so users can update without a package manager command.
The environment variable PRIME_AGENT_INTERACTIVE_SELF_UPDATE (exported as SELF_UPDATE_INTERACTIVE_CHILD_ENV) is the sentinel used to mark an interactive self-update child process.[1] Exit code 75 (SELF_UPDATE_NOT_ATTEMPTED_EXIT_CODE) signals that a self-update was not attempted.[1] When the update spec is a direct artifact — a URL, file: path, .tgz, or .tar.gz — the self-update logic installs the new package first and then uninstalls the old one (uninstallAfterInstall: true), reversing the usual order to avoid a gap in availability.[1]
Sources