From 299d6aeab4e10f6989b0c8eaa068228b92bba6ef Mon Sep 17 00:00:00 2001 From: Luke Parker <10430890+Hona@users.noreply.github.com> Date: Wed, 19 Nov 2025 18:35:46 +1000 Subject: [PATCH] fix: Bun single file exe paths for highlighting --- nix/scripts/bun-build.ts | 10 ++++++++-- packages/opencode/script/build.ts | 19 ++++++++++++++----- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/nix/scripts/bun-build.ts b/nix/scripts/bun-build.ts index a227081639..879d480816 100644 --- a/nix/scripts/bun-build.ts +++ b/nix/scripts/bun-build.ts @@ -4,7 +4,7 @@ import fs from "fs" const version = "@VERSION@" const pkg = path.join(process.cwd(), "packages/opencode") -const parser = fs.realpathSync(path.join(pkg, "./node_modules/@opentui/core/parser.worker.js")) +const parser = path.join(pkg, "./node_modules/@opentui/core/lib/tree-sitter/parser.worker.js") const worker = "./src/cli/cmd/tui/worker.ts" const target = process.env["BUN_COMPILE_TARGET"] @@ -12,6 +12,10 @@ if (!target) { throw new Error("BUN_COMPILE_TARGET not set") } +if (!fs.existsSync(parser)) { + throw new Error(`Parser worker not found at: ${parser}`) +} + process.chdir(pkg) const manifestName = "opencode-assets.manifest" @@ -46,6 +50,8 @@ const addAsset = async (p: string) => { removeTrackedAssets() +const workerBunfsPath = "./" + path.relative(pkg, parser).split(path.sep).join("/") + const result = await Bun.build({ conditions: ["browser"], tsconfig: "./tsconfig.json", @@ -54,7 +60,7 @@ const result = await Bun.build({ entrypoints: ["./src/index.ts", parser, worker], define: { OPENCODE_VERSION: `'@VERSION@'`, - OTUI_TREE_SITTER_WORKER_PATH: "/$bunfs/root/" + path.relative(pkg, parser).replace(/\\/g, "/"), + OTUI_TREE_SITTER_WORKER_PATH: `'${workerBunfsPath}'`, OPENCODE_CHANNEL: "'latest'", }, compile: { diff --git a/packages/opencode/script/build.ts b/packages/opencode/script/build.ts index 502baed023..8e4f01df08 100755 --- a/packages/opencode/script/build.ts +++ b/packages/opencode/script/build.ts @@ -16,6 +16,7 @@ import pkg from "../package.json" import { Script } from "@opencode-ai/script" const singleFlag = process.argv.includes("--single") +const skipInstall = process.argv.includes("--skip-install") const allTargets: { os: string @@ -83,8 +84,10 @@ const targets = singleFlag await $`rm -rf dist` const binaries: Record = {} -await $`bun install --os="*" --cpu="*" @opentui/core@${pkg.dependencies["@opentui/core"]}` -await $`bun install --os="*" --cpu="*" @parcel/watcher@${pkg.dependencies["@parcel/watcher"]}` +if (!skipInstall) { + await $`bun install --os="*" --cpu="*" @opentui/core@${pkg.dependencies["@opentui/core"]}` + await $`bun install --os="*" --cpu="*" @parcel/watcher@${pkg.dependencies["@parcel/watcher"]}` +} for (const item of targets) { const name = [ pkg.name, @@ -99,9 +102,15 @@ for (const item of targets) { console.log(`building ${name}`) await $`mkdir -p dist/${name}/bin` - const parserWorker = fs.realpathSync(path.resolve(dir, "./node_modules/@opentui/core/parser.worker.js")) + const parserWorker = path.resolve(dir, "./node_modules/@opentui/core/lib/tree-sitter/parser.worker.js") const workerPath = "./src/cli/cmd/tui/worker.ts" + if (!fs.existsSync(parserWorker)) { + throw new Error(`Parser worker not found at: ${parserWorker}`) + } + + const workerBunfsPath = "./" + path.relative(dir, parserWorker).split(path.sep).join("/") + await Bun.build({ conditions: ["browser"], tsconfig: "./tsconfig.json", @@ -116,8 +125,8 @@ for (const item of targets) { entrypoints: ["./src/index.ts", parserWorker, workerPath], define: { OPENCODE_VERSION: `'${Script.version}'`, - OTUI_TREE_SITTER_WORKER_PATH: "/$bunfs/root/" + path.relative(dir, parserWorker).replaceAll("\\", "/"), - OPENCODE_WORKER_PATH: workerPath, + OTUI_TREE_SITTER_WORKER_PATH: `'${workerBunfsPath}'`, + OPENCODE_WORKER_PATH: `'${workerPath}'`, OPENCODE_CHANNEL: `'${Script.channel}'`, }, })