opencode-ai 0.9.3 → 0.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -7,14 +7,14 @@
7
7
  "preinstall": "node ./preinstall.mjs",
8
8
  "postinstall": "node ./postinstall.mjs"
9
9
  },
10
- "version": "0.9.3",
10
+ "version": "0.9.4",
11
11
  "optionalDependencies": {
12
- "opencode-windows-x64": "0.9.3",
13
- "opencode-linux-arm64": "0.9.3",
14
- "opencode-linux-x64": "0.9.3",
15
- "opencode-linux-x64-baseline": "0.9.3",
16
- "opencode-darwin-x64": "0.9.3",
17
- "opencode-darwin-x64-baseline": "0.9.3",
18
- "opencode-darwin-arm64": "0.9.3"
12
+ "opencode-windows-x64": "0.9.4",
13
+ "opencode-linux-arm64": "0.9.4",
14
+ "opencode-linux-x64": "0.9.4",
15
+ "opencode-linux-x64-baseline": "0.9.4",
16
+ "opencode-darwin-x64": "0.9.4",
17
+ "opencode-darwin-x64-baseline": "0.9.4",
18
+ "opencode-darwin-arm64": "0.9.4"
19
19
  }
20
20
  }
package/postinstall.mjs CHANGED
@@ -68,10 +68,45 @@ function findBinary() {
68
68
  }
69
69
  }
70
70
 
71
- function main() {
71
+ async function regenerateWindowsCmdWrappers() {
72
+ console.log("Windows + npm detected: Forcing npm to rebuild bin links")
73
+
74
+ try {
75
+ const { execSync } = require("child_process")
76
+ const pkgPath = path.join(__dirname, "..")
77
+
78
+ // npm_config_global is string | undefined
79
+ // if it exists, the value is true
80
+ const isGlobal = process.env.npm_config_global === "true" || pkgPath.includes(path.join("npm", "node_modules"))
81
+
82
+ // The npm rebuild command does 2 things - Execute lifecycle scripts and rebuild bin links
83
+ // We want to skip lifecycle scripts to avoid infinite loops, so we use --ignore-scripts
84
+ const cmd = `npm rebuild opencode-ai --ignore-scripts${isGlobal ? " -g" : ""}`
85
+ const opts = {
86
+ stdio: "inherit",
87
+ shell: true,
88
+ ...(isGlobal ? {} : { cwd: path.join(pkgPath, "..", "..") }), // For local, run from project root
89
+ }
90
+
91
+ console.log(`Running: ${cmd}`)
92
+ execSync(cmd, opts)
93
+ console.log("Successfully rebuilt npm bin links")
94
+ } catch (error) {
95
+ console.error("Error rebuilding npm links:", error.message)
96
+ console.error("npm rebuild failed. You may need to manually run: npm rebuild opencode-ai --ignore-scripts")
97
+ }
98
+ }
99
+
100
+ async function main() {
72
101
  try {
73
102
  if (os.platform() === "win32") {
74
- console.log("Windows detected, skipping postinstall")
103
+ // NPM eg format - npm/11.4.2 node/v24.4.1 win32 x64
104
+ // Bun eg format - bun/1.2.19 npm/? node/v24.3.0 win32 x64
105
+ if (process.env.npm_config_user_agent.startsWith("npm")) {
106
+ await regenerateWindowsCmdWrappers()
107
+ } else {
108
+ console.log("Windows detected but not npm, skipping postinstall")
109
+ }
75
110
  return
76
111
  }
77
112
 
@@ -92,4 +127,9 @@ function main() {
92
127
  }
93
128
  }
94
129
 
95
- main()
130
+ try {
131
+ main()
132
+ } catch (error) {
133
+ console.error("Postinstall script error:", error.message)
134
+ process.exit(0)
135
+ }
package/preinstall.mjs CHANGED
@@ -13,13 +13,25 @@ function main() {
13
13
  return
14
14
  }
15
15
 
16
- const binDir = path.join(__dirname, "bin")
17
- const unixScript = path.join(binDir, "opencode")
16
+ console.log("Windows detected: Modifying package.json bin entry")
18
17
 
19
- console.log("Windows detected: Configuring bin scripts for Windows")
18
+ // Read package.json
19
+ const packageJsonPath = path.join(__dirname, "package.json")
20
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"))
20
21
 
22
+ // Modify bin to point to .cmd file on Windows
23
+ packageJson.bin = {
24
+ opencode: "./bin/opencode.cmd",
25
+ }
26
+
27
+ // Write it back
28
+ fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2))
29
+ console.log("Updated package.json bin to use opencode.cmd")
30
+
31
+ // Now you can also remove the Unix script if you want
32
+ const unixScript = path.join(__dirname, "bin", "opencode")
21
33
  if (fs.existsSync(unixScript)) {
22
- console.log("Removing Unix shell script from bin/")
34
+ console.log("Removing Unix shell script")
23
35
  fs.unlinkSync(unixScript)
24
36
  }
25
37
  }