fix(opencode): select target fff binary

This commit is contained in:
Dax Raad 2026-06-09 15:43:21 -04:00
commit b5539f13c6
4 changed files with 10 additions and 9 deletions

View file

@ -525,6 +525,7 @@
"@clack/prompts": "1.0.0-alpha.1",
"@effect/opentelemetry": "catalog:",
"@effect/platform-node": "catalog:",
"@ff-labs/fff-bun": "0.9.3",
"@gitlab/opencode-gitlab-auth": "1.3.3",
"@modelcontextprotocol/sdk": "1.29.0",
"@octokit/graphql": "9.0.2",

View file

@ -78,6 +78,7 @@
"@clack/prompts": "1.0.0-alpha.1",
"@effect/opentelemetry": "catalog:",
"@effect/platform-node": "catalog:",
"@ff-labs/fff-bun": "0.9.3",
"@gitlab/opencode-gitlab-auth": "1.3.3",
"@modelcontextprotocol/sdk": "1.29.0",
"@octokit/graphql": "9.0.2",

View file

@ -140,6 +140,7 @@ const binaries: Record<string, string> = {}
if (!skipInstall) {
await $`bun install --os="*" --cpu="*" @opentui/core@${pkg.dependencies["@opentui/core"]}`
await $`bun install --os="*" --cpu="*" @parcel/watcher@${pkg.dependencies["@parcel/watcher"]}`
await $`bun install --os="*" --cpu="*" @ff-labs/fff-bun@${pkg.dependencies["@ff-labs/fff-bun"]}`
}
for (const item of targets) {
const name = [
@ -186,6 +187,7 @@ for (const item of targets) {
files: embeddedFileMap ? { "opencode-web-ui.gen.ts": embeddedFileMap } : {},
entrypoints: ["./src/index.ts", parserWorker, workerPath, ...(embeddedFileMap ? ["opencode-web-ui.gen.ts"] : [])],
define: {
FFF_LIBC: JSON.stringify(item.abi === "musl" ? "musl" : "gnu"),
OPENCODE_VERSION: `'${Script.version}'`,
OPENCODE_MODELS_DEV: generated.modelsData,
OTUI_TREE_SITTER_WORKER_PATH: bunfsRoot + workerRelativePath,

View file

@ -2,15 +2,16 @@ diff --git a/src/download.ts b/src/download.ts
index 3454256..6dca25a 100644
--- a/src/download.ts
+++ b/src/download.ts
@@ -7,7 +7,6 @@
@@ -7,7 +7,7 @@
*/
+declare const FFF_LIBC: "gnu" | "musl";
import { existsSync } from "node:fs";
-import { createRequire } from "node:module";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
import { getLibFilename, getNpmPackageName } from "./platform";
@@ -54,14 +53,14 @@ export function binaryExists(): boolean {
@@ -54,14 +54,10 @@ export function binaryExists(): boolean {
* in the same directory.
*/
function resolveFromNpmPackage(): string | null {
@ -22,13 +23,9 @@ index 3454256..6dca25a 100644
- const packageJsonPath = require.resolve(`${packageName}/package.json`);
- const packageDir = dirname(packageJsonPath);
- const binaryPath = join(packageDir, getLibFilename());
+ const binaryPath = process.platform === "win32"
+ ? require(`../../../../../@ff-labs+fff-bin-win32-${process.arch}@0.9.3/node_modules/@ff-labs/fff-bin-win32-${process.arch}/fff_c.dll`)
+ : process.platform === "darwin"
+ ? require(`../../../../../@ff-labs+fff-bin-darwin-${process.arch}@0.9.3/node_modules/@ff-labs/fff-bin-darwin-${process.arch}/libfff_c.dylib`)
+ : getNpmPackageName().endsWith("musl")
+ ? require(`../../../../../@ff-labs+fff-bin-linux-${process.arch}-musl@0.9.3/node_modules/@ff-labs/fff-bin-linux-${process.arch}-musl/libfff_c.so`)
+ : require(`../../../../../@ff-labs+fff-bin-linux-${process.arch}-gnu@0.9.3/node_modules/@ff-labs/fff-bin-linux-${process.arch}-gnu/libfff_c.so`);
+ const binaryPath = require(
+ `@ff-labs/fff-bin-${process.platform === "linux" ? `linux-${process.arch}-${typeof FFF_LIBC === "string" ? FFF_LIBC : getNpmPackageName().endsWith("musl") ? "musl" : "gnu"}` : `${process.platform}-${process.arch}`}/${process.platform === "win32" ? "fff_c.dll" : process.platform === "darwin" ? "libfff_c.dylib" : "libfff_c.so"}`,
+ );
if (existsSync(binaryPath)) {
return binaryPath;