summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAiden Cline <[email protected]>2026-02-20 12:19:17 -0600
committerGitHub <[email protected]>2026-02-20 12:19:17 -0600
commit1d9f05e4f5cdda1d1aa9675444ee83c57ae9951e (patch)
tree6bb914d0db0c456156ad5df34b6cca331b32b766
parent46361cf35ce39c5b233fb5a727744255312c85d6 (diff)
downloadopencode-1d9f05e4f5cdda1d1aa9675444ee83c57ae9951e.tar.gz
opencode-1d9f05e4f5cdda1d1aa9675444ee83c57ae9951e.zip
cache platform binary in postinstall for faster startup (#14467)
-rwxr-xr-xpackages/opencode/bin/opencode6
-rw-r--r--packages/opencode/script/postinstall.mjs10
2 files changed, 14 insertions, 2 deletions
diff --git a/packages/opencode/bin/opencode b/packages/opencode/bin/opencode
index d73bbce26..a7674ce2f 100755
--- a/packages/opencode/bin/opencode
+++ b/packages/opencode/bin/opencode
@@ -25,6 +25,12 @@ if (envPath) {
const scriptPath = fs.realpathSync(__filename)
const scriptDir = path.dirname(scriptPath)
+//
+const cached = path.join(scriptDir, ".opencode")
+if (fs.existsSync(cached)) {
+ run(cached)
+}
+
const platformMap = {
darwin: "darwin",
linux: "linux",
diff --git a/packages/opencode/script/postinstall.mjs b/packages/opencode/script/postinstall.mjs
index e8b5e995c..98f23e16f 100644
--- a/packages/opencode/script/postinstall.mjs
+++ b/packages/opencode/script/postinstall.mjs
@@ -109,8 +109,14 @@ async function main() {
// On non-Windows platforms, just verify the binary package exists
// Don't replace the wrapper script - it handles binary execution
const { binaryPath } = findBinary()
- console.log(`Platform binary verified at: ${binaryPath}`)
- console.log("Wrapper script will handle binary execution")
+ const target = path.join(__dirname, "bin", ".opencode")
+ if (fs.existsSync(target)) fs.unlinkSync(target)
+ try {
+ fs.linkSync(binaryPath, target)
+ } catch {
+ fs.copyFileSync(binaryPath, target)
+ }
+ fs.chmodSync(target, 0o755)
} catch (error) {
console.error("Failed to setup opencode binary:", error.message)
process.exit(1)