From da07e72b4ff1ca83fbe71432ef8c94b3e90388a6 Mon Sep 17 00:00:00 2001 From: Zendril Date: Sun, 26 Oct 2025 01:35:24 -0400 Subject: [PATCH 1/6] fix: windows not loading due to getContextId non-hydrating error --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 48bf87ea90..a2f3ca95e7 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "type": "module", "packageManager": "bun@1.3.0", "scripts": { - "dev": "bun run --cwd packages/opencode src/index.ts", + "dev": "bun --cwd packages/opencode --conditions=browser src/index.ts", "typecheck": "bun turbo typecheck", "prepare": "husky", "random": "echo 'Random script'" From 64eec4e205fe636bf072d9a4f58d948bef7ece23 Mon Sep 17 00:00:00 2001 From: Zendril Date: Sun, 26 Oct 2025 01:39:47 -0400 Subject: [PATCH 2/6] fix: putting run back, seems like only the conditions=browser was the difference --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a2f3ca95e7..01a94e3da7 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "type": "module", "packageManager": "bun@1.3.0", "scripts": { - "dev": "bun --cwd packages/opencode --conditions=browser src/index.ts", + "dev": "bun run --cwd packages/opencode --conditions=browser src/index.ts", "typecheck": "bun turbo typecheck", "prepare": "husky", "random": "echo 'Random script'" From a26ab7b509e02ecc14e891fc6eea32edb73e3f63 Mon Sep 17 00:00:00 2001 From: Zendril Date: Sun, 26 Oct 2025 19:28:32 -0400 Subject: [PATCH 3/6] fix: made it so that the bin is aware of windows vs linux --- packages/opencode/bin/run.js | 25 +++++++++++++++++++++++++ packages/opencode/package.json | 2 +- packages/script/src/index.ts | 4 ++-- 3 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 packages/opencode/bin/run.js diff --git a/packages/opencode/bin/run.js b/packages/opencode/bin/run.js new file mode 100644 index 0000000000..58afde68c8 --- /dev/null +++ b/packages/opencode/bin/run.js @@ -0,0 +1,25 @@ +#!/usr/bin/env node +import { spawn } from 'child_process'; +import path from 'path'; +import { fileURLToPath } from 'url'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); + +const command = process.platform === 'win32' ? 'opencode.cmd' : 'opencode'; +const commandPath = path.join(__dirname, command); +const args = process.argv.slice(2); + +const child = spawn(commandPath, args, { + stdio: 'inherit', + shell: process.platform === 'win32' +}); + +child.on('exit', (code) => { + process.exit(code === null ? 1 : code); +}); + +child.on('error', (err) => { + console.error(`Failed to start subprocess: ${err}`); + process.exit(1); +}); diff --git a/packages/opencode/package.json b/packages/opencode/package.json index aef7ca3a3e..cc0d4e48e0 100644 --- a/packages/opencode/package.json +++ b/packages/opencode/package.json @@ -12,7 +12,7 @@ "random": "echo 'Random script updated at $(date)'" }, "bin": { - "opencode": "./bin/opencode" + "opencode": "./bin/run.js" }, "exports": { "./*": "./src/*.ts" diff --git a/packages/script/src/index.ts b/packages/script/src/index.ts index d5b2c9e4a5..979c2e37cd 100644 --- a/packages/script/src/index.ts +++ b/packages/script/src/index.ts @@ -1,7 +1,7 @@ import { $ } from "bun" -if (process.versions.bun !== "1.3.0") { - throw new Error("This script requires bun@1.3.0") +if (!process.versions.bun.startsWith("1.3.")) { + throw new Error("This script requires bun@1.3+") } const CHANNEL = process.env["OPENCODE_CHANNEL"] ?? (await $`git branch --show-current`.text().then((x) => x.trim())) From d8ffe2d15c083ac7efe8217c043206ae65f4ec39 Mon Sep 17 00:00:00 2001 From: Zendril Date: Sun, 26 Oct 2025 19:44:18 -0400 Subject: [PATCH 4/6] applying the format.ts changes --- packages/opencode/bin/run.js | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/packages/opencode/bin/run.js b/packages/opencode/bin/run.js index 58afde68c8..855c3cf49f 100644 --- a/packages/opencode/bin/run.js +++ b/packages/opencode/bin/run.js @@ -1,25 +1,25 @@ #!/usr/bin/env node -import { spawn } from 'child_process'; -import path from 'path'; -import { fileURLToPath } from 'url'; +import { spawn } from "child_process" +import path from "path" +import { fileURLToPath } from "url" -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); +const __filename = fileURLToPath(import.meta.url) +const __dirname = path.dirname(__filename) -const command = process.platform === 'win32' ? 'opencode.cmd' : 'opencode'; -const commandPath = path.join(__dirname, command); -const args = process.argv.slice(2); +const command = process.platform === "win32" ? "opencode.cmd" : "opencode" +const commandPath = path.join(__dirname, command) +const args = process.argv.slice(2) const child = spawn(commandPath, args, { - stdio: 'inherit', - shell: process.platform === 'win32' -}); + stdio: "inherit", + shell: process.platform === "win32", +}) -child.on('exit', (code) => { - process.exit(code === null ? 1 : code); -}); +child.on("exit", (code) => { + process.exit(code === null ? 1 : code) +}) -child.on('error', (err) => { - console.error(`Failed to start subprocess: ${err}`); - process.exit(1); -}); +child.on("error", (err) => { + console.error(`Failed to start subprocess: ${err}`) + process.exit(1) +}) From 9d158f2c839a4362564d082a7abd5bbdd88745f5 Mon Sep 17 00:00:00 2001 From: Zendril Date: Sun, 26 Oct 2025 20:53:06 -0400 Subject: [PATCH 5/6] removed the node shebang as this is run by bun --- packages/opencode/bin/run.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/opencode/bin/run.js b/packages/opencode/bin/run.js index 855c3cf49f..678689c4d1 100644 --- a/packages/opencode/bin/run.js +++ b/packages/opencode/bin/run.js @@ -1,4 +1,3 @@ -#!/usr/bin/env node import { spawn } from "child_process" import path from "path" import { fileURLToPath } from "url" From 0d373090d343955f3cb8396c0c8489f3fd891813 Mon Sep 17 00:00:00 2001 From: Zendril Date: Sun, 26 Oct 2025 21:54:58 -0400 Subject: [PATCH 6/6] fix: arguments were not being handled properly in opencode.cmd --- packages/opencode/bin/opencode.cmd | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/opencode/bin/opencode.cmd b/packages/opencode/bin/opencode.cmd index 775bfe6886..61dc204052 100644 --- a/packages/opencode/bin/opencode.cmd +++ b/packages/opencode/bin/opencode.cmd @@ -52,6 +52,8 @@ echo It seems that your package manager failed to install the right version of t exit /b 1 :execute +rem Remove quotes from resolved path if present +set "resolved=%resolved:"=%" rem Execute the binary with all arguments in the same console window rem Use start /b /wait to ensure it runs in the current shell context for all shells start /b /wait "" "%resolved%" %*