Skip to content

armgit / rea

Public Imported from GitHub
0

Reverse engineer anything with agents, from app behavior down to native binaries.

fix(hopper): skip non-file launcher candidates

Ysopwnable044fb9127ac7
diff --git a/docs/installation.md b/docs/installation.md
index 7cd250772..92f82b0bf 100644
--- a/docs/installation.md
+++ b/docs/installation.md
@@ -585,6 +585,8 @@ system application, the canonical application installed by `rea setup` under
diagnostic; to use a Homebrew-installed launcher for CLI/MCP startup, set
`HOPPER_LAUNCHER_PATH` to the path reported by doctor. REA does not run Homebrew
while loading runtime configuration.
+Automatic discovery accepts executable regular files, including file symlinks,
+and skips directories.
On Linux, it prefers executable `/opt/hopper/bin/Hopper`, then executable
`~/.local/share/rea/hopper/bin/Hopper`, followed by `/opt/hopper-v4/bin/hopper`
and `/usr/bin/hopper`; if none exists, the former remains the diagnostic
diff --git a/src/config/parseConfig.ts b/src/config/parseConfig.ts
index 1dbeda757..a1c1e0b28 100644
--- a/src/config/parseConfig.ts
+++ b/src/config/parseConfig.ts
@@ -1,4 +1,4 @@
-import { accessSync, constants } from "node:fs";
+import { accessSync, constants, statSync } from "node:fs";
import type { ConfigurationError } from "../domain/configurationErrors.js";
import { ok, type Result } from "../domain/result.js";
@@ -16,7 +16,7 @@ import {
const executableAvailable = (path: string): boolean => {
try {
accessSync(path, constants.X_OK);
- return true;
+ return statSync(path).isFile();
} catch {
return false;
}
diff --git a/tests/boundary/filesystem/hopperLauncherSelection.test.ts b/tests/boundary/filesystem/hopperLauncherSelection.test.ts
new file mode 100644
index 000000000..5949ce23e
--- /dev/null
+++ b/tests/boundary/filesystem/hopperLauncherSelection.test.ts
@@ -0,0 +1,34 @@
+import { accessSync, constants, statSync } from "node:fs";
+import { mkdir, writeFile } from "node:fs/promises";
+import { dirname, join } from "node:path";
+
+import { expect, it } from "vitest";
+
+import { defaultHopperLauncherPath } from "../../../src/config/parseConfig.js";
+import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
+
+// A real system installation legitimately precedes this isolated user fixture.
+const installedSystemHopper = (home: string): boolean => {
+ try {
+ const launcher = defaultHopperLauncherPath("darwin", home);
+ accessSync(launcher, constants.X_OK);
+ return statSync(launcher).isFile();
+ } catch {
+ return false;
+ }
+};
+
+it.for(["Hopper Disassembler.app", "Hopper A.app"])(
+ "skips a directory launcher in %s and selects a real file",
+ async (name, context) => {
+ const home = await createTestTempDirectory("rea-hopper-selection-");
+ if (installedSystemHopper(home)) context.skip();
+ const invalid = join(home, "Applications", name, "Contents/MacOS/hopper");
+ const valid = join(home, "Applications/Hopper Z.app/Contents/MacOS/hopper");
+ await mkdir(invalid, { recursive: true });
+ await mkdir(dirname(valid), { recursive: true });
+ await writeFile(valid, "#!/bin/sh\nexit 0\n", { mode: 0o700 });
+
+ expect(defaultHopperLauncherPath("darwin", home)).toBe(valid);
+ },
+);