diff --git a/bun.lock b/bun.lock index 7b3bfa74520c..f9697559110e 100644 --- a/bun.lock +++ b/bun.lock @@ -157,8 +157,11 @@ "@opencode-ai/protocol": "workspace:*", "@opencode-ai/script": "workspace:*", "@parcel/watcher-darwin-arm64": "2.5.1", + "@parcel/watcher-darwin-x64": "2.5.1", "@parcel/watcher-linux-arm64-glibc": "2.5.1", + "@parcel/watcher-linux-arm64-musl": "2.5.1", "@parcel/watcher-linux-x64-glibc": "2.5.1", + "@parcel/watcher-linux-x64-musl": "2.5.1", "@parcel/watcher-win32-arm64": "2.5.1", "@parcel/watcher-win32-x64": "2.5.1", "@tsconfig/bun": "catalog:", diff --git a/packages/cli/package.json b/packages/cli/package.json index 4859175a0197..51d7e0581cd4 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -69,8 +69,11 @@ "@lydell/node-pty-win32-arm64": "1.2.0-beta.12", "@lydell/node-pty-win32-x64": "1.2.0-beta.12", "@parcel/watcher-darwin-arm64": "2.5.1", + "@parcel/watcher-darwin-x64": "2.5.1", "@parcel/watcher-linux-arm64-glibc": "2.5.1", + "@parcel/watcher-linux-arm64-musl": "2.5.1", "@parcel/watcher-linux-x64-glibc": "2.5.1", + "@parcel/watcher-linux-x64-musl": "2.5.1", "@parcel/watcher-win32-arm64": "2.5.1", "@parcel/watcher-win32-x64": "2.5.1", "vite": "catalog:", diff --git a/packages/cli/script/build.ts b/packages/cli/script/build.ts index ca3b84bb06d2..20109e5f6a76 100755 --- a/packages/cli/script/build.ts +++ b/packages/cli/script/build.ts @@ -1,8 +1,9 @@ #!/usr/bin/env bun import { $ } from "bun" -import { rm } from "fs/promises" +import { copyFile, rm } from "fs/promises" import path from "path" +import { fileURLToPath } from "node:url" import { Script } from "@opencode-ai/script" import { createSolidTransformPlugin } from "@opentui/solid/bun-plugin" import pkg from "../package.json" @@ -52,7 +53,9 @@ const targets = singleFlag }) : allTargets -if (!skipInstall) await $`bun install --os="*" --cpu="*" @opentui/core@${pkg.dependencies["@opentui/core"]}` +if (!skipInstall) { + await $`bun install --os="*" --cpu="*" @opentui/core@${pkg.dependencies["@opentui/core"]} @parcel/watcher@${pkg.dependencies["@parcel/watcher"]}` +} for (const item of targets) { const target = [ @@ -102,6 +105,9 @@ for (const item of targets) { process.exit(1) } + const watcher = `@parcel/watcher-${item.os}-${item.arch}${item.os === "linux" ? `-${item.abi ?? "glibc"}` : ""}` + await copyFile(fileURLToPath(import.meta.resolve(watcher)), path.join(outdir, name, "bin", "watcher.node")) + await Bun.write( path.join(outdir, name, "package.json"), JSON.stringify( diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index 7ee80846ed45..fb3ac2f7b2cc 100755 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -12,6 +12,12 @@ import { Global } from "@opencode-ai/core/global" import { AppProcess } from "@opencode-ai/core/process" import { Config } from "./config" import { Npm } from "@opencode-ai/core/npm" +import path from "node:path" + +const runtime = path.basename(process.execPath, path.extname(process.execPath)).toLowerCase() +if (!process.env.OPENCODE_PARCEL_WATCHER_PATH && runtime !== "bun" && runtime !== "node" && runtime !== "nodejs") { + process.env.OPENCODE_PARCEL_WATCHER_PATH = path.join(path.dirname(process.execPath), "watcher.node") +} const Handlers = Runtime.handlers(Commands, { $: () => import("./commands/handlers/default"),