A self-improving RLM agent for coding workflows and long-running autonomous tasks.
Rust
fix(coding-agent): preserve Homebrew ownership (#846)
fettpl10fb172b9298
diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.mdindex d241c70a73..83cd6fefc6 100644--- a/packages/coding-agent/CHANGELOG.md+++ b/packages/coding-agent/CHANGELOG.md@@ -2,6 +2,8 @@## [Unreleased]+- Fixed Homebrew installs attempting to self-update their versioned Cellar keg instead of directing users to `brew upgrade prime-agent` ([#844](https://github.com/PrimeIntellect-ai/prime-agent/issues/844))+## [0.7.1] - 2026-08-07- Fixed the bundled `websearch` skill description and missing-key guidance omitting the `/login` → **MCP Connections** step required to configure Serper.diff --git a/packages/coding-agent/src/config.ts b/packages/coding-agent/src/config.tsindex b94452ec21..b709ab10e9 100644--- a/packages/coding-agent/src/config.ts+++ b/packages/coding-agent/src/config.ts@@ -41,7 +41,7 @@ export const SELF_UPDATE_NOT_ATTEMPTED_EXIT_CODE = 75;// Install Method Detection// =============================================================================-export type InstallMethod = "bun-binary" | "npm" | "pnpm" | "yarn" | "bun" | "unknown";+export type InstallMethod = "bun-binary" | "homebrew" | "npm" | "pnpm" | "yarn" | "bun" | "unknown";interface SelfUpdateCommandStep {command: string;@@ -85,6 +85,9 @@ export function detectInstallMethod(): InstallMethod {if (isBunBinary) {return "bun-binary";}+ if (isHomebrewInstall()) {+ return "homebrew";+ }const resolvedPath = `${__dirname}\0${process.execPath || ""}`.toLowerCase().replace(/\\/g, "/");@@ -104,6 +107,11 @@ export function detectInstallMethod(): InstallMethod {return "unknown";}+function isHomebrewInstall(): boolean {+ const packageDir = getPackageDir().toLowerCase().replace(/\\/g, "/");+ return packageDir.includes("/cellar/") && packageDir.includes("/libexec/lib/node_modules/");+}+function getInferredNpmInstall(): { root: string; prefix: string } | undefined {const packageDir = getPackageDir();const path = process.platform === "win32" || packageDir.includes("\\") ? win32 : { basename, dirname };@@ -151,6 +159,7 @@ function getSelfUpdateCommandForMethod(const uninstallAfterInstall = isDirectPackageArtifactSpec(updateSpec);switch (method) {case "bun-binary":+ case "homebrew":return undefined;case "pnpm":return makeSelfUpdateCommand(@@ -248,6 +257,7 @@ function getGlobalPackageRoots(method: InstallMethod, _packageName: string, npmCreturn roots;}case "bun-binary":+ case "homebrew":case "unknown":return [];}@@ -319,6 +329,9 @@ export function getSelfUpdateUnavailableInstruction(if (method === "bun-binary") {return `Download from: https://github.com/PrimeIntellect-ai/prime-agent/releases/latest`;}+ if (method === "homebrew") {+ return `Update with: brew upgrade ${APP_NAME}`;+ }const command = getSelfUpdateCommandForMethod(method, packageName, updateSpec, npmCommand, updatePackageName);if (command) {if (isManagedByGlobalPackageManager(method, packageName, npmCommand) && !isSelfUpdatePathWritable()) {diff --git a/packages/coding-agent/test/config.test.ts b/packages/coding-agent/test/config.test.tsindex 89be54502b..b21443c562 100644--- a/packages/coding-agent/test/config.test.ts+++ b/packages/coding-agent/test/config.test.ts@@ -70,6 +70,16 @@ function createNpmPrefixInstall(template = "pi-prefix-"): { prefix: string; packreturn { prefix, packageDir };}+function createHomebrewInstall(): { packageDir: string } {+ const prefix = mkdtempSync(join(tmpdir(), "pi-homebrew-"));+ const packageDir = join(prefix, "Cellar", "prime-agent", "0.7.0", "libexec", "lib", "node_modules", "prime-agent");+ mkdirSync(packageDir, { recursive: true });+ tempDir = prefix;+ process.env.PI_PACKAGE_DIR = packageDir;+ setExecPath(join(packageDir, "dist", "cli.js"));+ return { packageDir };+}+function createPnpmGlobalInstall(): { root: string; packageDir: string } {const temp = mkdtempSync(join(tmpdir(), "pi-pnpm-"));const binDir = join(temp, "bin");@@ -177,6 +187,15 @@ describe("detectInstallMethod", () => {);});+ test("leaves Homebrew installs under Homebrew ownership", () => {+ createHomebrewInstall();++ expect(detectInstallMethod()).toBe("homebrew");+ expect(getSelfUpdateCommand("prime-agent")).toBeUndefined();+ expect(getSelfUpdateUnavailableInstruction("prime-agent")).toBe("Update with: brew upgrade prime-agent");+ expect(getUpdateInstruction("prime-agent")).toBe("Update with: brew upgrade prime-agent");+ });+test("self-updates npm installs from custom prefixes", () => {const { prefix } = createNpmPrefixInstall();