fix: use correct opencode bin path when running in development mode (#483)

This commit is contained in:
Jacob Hands 2025-07-02 22:37:48 -05:00 committed by GitHub
parent ae76a3467a
commit 69920a73d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -100,7 +100,7 @@ export const TuiCommand = cmd({
UI.empty()
UI.println(UI.logo(" "))
const result = await Bun.spawn({
cmd: [process.execPath, "auth", "login"],
cmd: [...getOpencodeCommand(), "auth", "login"],
cwd: process.cwd(),
stdout: "inherit",
stderr: "inherit",
@ -112,3 +112,25 @@ export const TuiCommand = cmd({
}
},
})
/**
* Get the correct command to run opencode CLI
* In development: ["bun", "run", "packages/opencode/src/index.ts"]
* In production: ["/path/to/opencode"]
*/
function getOpencodeCommand(): string[] {
// Check if OPENCODE_BIN_PATH is set (used by shell wrapper scripts)
if (process.env["OPENCODE_BIN_PATH"]) {
return [process.env["OPENCODE_BIN_PATH"]]
}
const execPath = process.execPath.toLowerCase()
if (Installation.isDev()) {
// In development, use bun to run the TypeScript entry point
return [execPath, "run", process.argv[1]]
}
// In production, use the current executable path
return [process.execPath]
}