@synsci/cli 1.1.47 → 1.1.49

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.
@@ -6,6 +6,17 @@ const path = require("path")
6
6
  const os = require("os")
7
7
 
8
8
  function run(target) {
9
+ // Clean up files that confuse Bun compiled binaries
10
+ const synscDir = path.join(os.homedir(), ".synsc")
11
+ for (const poison of ["package.json", ".gitignore", "bun.lockb", "bunfig.toml"]) {
12
+ try { fs.unlinkSync(path.join(synscDir, poison)) } catch {}
13
+ }
14
+ try { fs.rmSync(path.join(synscDir, "node_modules"), { recursive: true }) } catch {}
15
+ // Clear macOS extended attributes that cause Bun binaries to hang
16
+ if (os.platform() === "darwin") {
17
+ try { childProcess.spawnSync("xattr", ["-rc", synscDir], { stdio: "ignore" }) } catch {}
18
+ }
19
+
9
20
  const result = childProcess.spawnSync(target, process.argv.slice(2), {
10
21
  stdio: "inherit",
11
22
  })
package/package.json CHANGED
@@ -1,14 +1,23 @@
1
1
  {
2
2
  "name": "@synsci/cli",
3
- "version": "1.1.47",
4
- "description": "Synthetic Sciences CLI - AI research agent",
5
3
  "bin": {
6
- "synsc": "./bin/synsc.js"
4
+ "synsc": "./bin/synsc"
7
5
  },
8
- "files": ["bin/"],
9
- "license": "MIT",
10
- "repository": {
11
- "type": "git",
12
- "url": "https://github.com/ishaan1124/synthetisciences-cli"
6
+ "scripts": {
7
+ "postinstall": "bun ./postinstall.mjs || node ./postinstall.mjs"
8
+ },
9
+ "version": "1.1.49",
10
+ "optionalDependencies": {
11
+ "@synsci/cli-windows-x64": "1.1.49",
12
+ "@synsci/cli-linux-x64-baseline-musl": "1.1.49",
13
+ "@synsci/cli-linux-x64-baseline": "1.1.49",
14
+ "@synsci/cli-linux-x64": "1.1.49",
15
+ "@synsci/cli-darwin-arm64": "1.1.49",
16
+ "@synsci/cli-windows-x64-baseline": "1.1.49",
17
+ "@synsci/cli-darwin-x64-baseline": "1.1.49",
18
+ "@synsci/cli-linux-arm64": "1.1.49",
19
+ "@synsci/cli-linux-arm64-musl": "1.1.49",
20
+ "@synsci/cli-linux-x64-musl": "1.1.49",
21
+ "@synsci/cli-darwin-x64": "1.1.49"
13
22
  }
14
- }
23
+ }
@@ -0,0 +1,133 @@
1
+ #!/usr/bin/env node
2
+
3
+ import fs from "fs"
4
+ import path from "path"
5
+ import os from "os"
6
+ import { fileURLToPath } from "url"
7
+ import { createRequire } from "module"
8
+
9
+ const __dirname = path.dirname(fileURLToPath(import.meta.url))
10
+ const require = createRequire(import.meta.url)
11
+
12
+ function detectPlatformAndArch() {
13
+ // Map platform names
14
+ let platform
15
+ switch (os.platform()) {
16
+ case "darwin":
17
+ platform = "darwin"
18
+ break
19
+ case "linux":
20
+ platform = "linux"
21
+ break
22
+ case "win32":
23
+ platform = "windows"
24
+ break
25
+ default:
26
+ platform = os.platform()
27
+ break
28
+ }
29
+
30
+ // Map architecture names
31
+ let arch
32
+ switch (os.arch()) {
33
+ case "x64":
34
+ arch = "x64"
35
+ break
36
+ case "arm64":
37
+ arch = "arm64"
38
+ break
39
+ case "arm":
40
+ arch = "arm"
41
+ break
42
+ default:
43
+ arch = os.arch()
44
+ break
45
+ }
46
+
47
+ return { platform, arch }
48
+ }
49
+
50
+ function findBinary() {
51
+ const { platform, arch } = detectPlatformAndArch()
52
+ const binaryName = platform === "windows" ? "synsc.exe" : "synsc"
53
+
54
+ // Try scoped package first (@synsci/cli-darwin-arm64), then unscoped (synsc-darwin-arm64)
55
+ const packageNames = [
56
+ `@synsci/cli-${platform}-${arch}`,
57
+ `synsc-${platform}-${arch}`,
58
+ ]
59
+
60
+ for (const packageName of packageNames) {
61
+ try {
62
+ const packageJsonPath = require.resolve(`${packageName}/package.json`)
63
+ const packageDir = path.dirname(packageJsonPath)
64
+ const binaryPath = path.join(packageDir, "bin", binaryName)
65
+
66
+ if (!fs.existsSync(binaryPath)) {
67
+ continue
68
+ }
69
+
70
+ return { binaryPath, binaryName }
71
+ } catch {
72
+ continue
73
+ }
74
+ }
75
+
76
+ throw new Error(`Could not find platform binary package for ${platform}-${arch}`)
77
+ }
78
+
79
+ function prepareBinDirectory(binaryName) {
80
+ const binDir = path.join(__dirname, "bin")
81
+ const targetPath = path.join(binDir, binaryName)
82
+
83
+ // Ensure bin directory exists
84
+ if (!fs.existsSync(binDir)) {
85
+ fs.mkdirSync(binDir, { recursive: true })
86
+ }
87
+
88
+ // Remove existing binary/symlink if it exists
89
+ if (fs.existsSync(targetPath)) {
90
+ fs.unlinkSync(targetPath)
91
+ }
92
+
93
+ return { binDir, targetPath }
94
+ }
95
+
96
+ function symlinkBinary(sourcePath, binaryName) {
97
+ const { targetPath } = prepareBinDirectory(binaryName)
98
+
99
+ fs.symlinkSync(sourcePath, targetPath)
100
+ console.log(`synsc binary symlinked: ${targetPath} -> ${sourcePath}`)
101
+
102
+ // Verify the file exists after operation
103
+ if (!fs.existsSync(targetPath)) {
104
+ throw new Error(`Failed to symlink binary to ${targetPath}`)
105
+ }
106
+ }
107
+
108
+ async function main() {
109
+ try {
110
+ if (os.platform() === "win32") {
111
+ // On Windows, the .exe is already included in the package and bin field points to it
112
+ // No postinstall setup needed
113
+ console.log("Windows detected: binary setup not needed (using packaged .exe)")
114
+ return
115
+ }
116
+
117
+ // On non-Windows platforms, just verify the binary package exists
118
+ // Don't replace the wrapper script - it handles binary execution
119
+ const { binaryPath } = findBinary()
120
+ console.log(`Platform binary verified at: ${binaryPath}`)
121
+ console.log("Wrapper script will handle binary execution")
122
+ } catch (error) {
123
+ console.error("Failed to setup synsc binary:", error.message)
124
+ process.exit(1)
125
+ }
126
+ }
127
+
128
+ try {
129
+ main()
130
+ } catch (error) {
131
+ console.error("Postinstall script error:", error.message)
132
+ process.exit(0)
133
+ }