@synsci/cli 1.1.46 → 1.1.48

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/bin/synsc.js CHANGED
@@ -1,77 +1,107 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const { spawnSync } = require("child_process")
3
+ const childProcess = require("child_process")
4
4
  const fs = require("fs")
5
5
  const path = require("path")
6
6
  const os = require("os")
7
7
 
8
- // Check SYNSCI_BIN_PATH env var
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
+
20
+ const result = childProcess.spawnSync(target, process.argv.slice(2), {
21
+ stdio: "inherit",
22
+ })
23
+ if (result.error) {
24
+ console.error(result.error.message)
25
+ process.exit(1)
26
+ }
27
+ const code = typeof result.status === "number" ? result.status : 0
28
+ process.exit(code)
29
+ }
30
+
31
+ // Helper: check if a path points to a real binary (not this wrapper script)
32
+ function isBinary(p) {
33
+ try {
34
+ if (!fs.existsSync(p)) return false
35
+ const real = fs.realpathSync(p)
36
+ // Skip if it resolves to this script (self-reference via symlink)
37
+ if (real === fs.realpathSync(__filename)) return false
38
+ // Skip if it's a .js file (another wrapper)
39
+ if (real.endsWith(".js")) return false
40
+ return true
41
+ } catch {
42
+ return false
43
+ }
44
+ }
45
+
46
+ // 1. Check SYNSCI_BIN_PATH env var
9
47
  const envPath = process.env.SYNSCI_BIN_PATH
10
- if (envPath && fs.existsSync(envPath)) {
48
+ if (envPath && isBinary(envPath)) {
11
49
  run(envPath)
12
50
  }
13
51
 
14
52
  const binary = os.platform() === "win32" ? "synsc.exe" : "synsc"
15
53
 
16
- // Check ~/.synsc/bin first
54
+ // 2. Check ~/.synsc/bin (primary install location)
17
55
  const homeBin = path.join(os.homedir(), ".synsc", "bin", binary)
18
- if (fs.existsSync(homeBin)) {
56
+ if (isBinary(homeBin)) {
19
57
  run(homeBin)
20
58
  }
21
59
 
22
- // Check /opt/homebrew/bin (macOS)
23
- const brewBin = "/opt/homebrew/bin/synsc"
24
- if (os.platform() === "darwin" && fs.existsSync(brewBin)) {
25
- run(brewBin)
60
+ // 3. Check /opt/homebrew/bin (macOS)
61
+ if (os.platform() === "darwin" && isBinary("/opt/homebrew/bin/synsc")) {
62
+ run("/opt/homebrew/bin/synsc")
26
63
  }
27
64
 
28
- // Check /usr/local/bin
29
- const localBin = "/usr/local/bin/synsc"
30
- if (fs.existsSync(localBin)) {
31
- run(localBin)
65
+ // 4. Check /usr/local/bin
66
+ if (isBinary("/usr/local/bin/synsc")) {
67
+ run("/usr/local/bin/synsc")
32
68
  }
33
69
 
34
- // Check sibling platform package
35
- const scriptDir = path.dirname(fs.realpathSync(__filename))
70
+ // 5. Search node_modules for platform package
71
+ const scriptPath = fs.realpathSync(__filename)
72
+ const scriptDir = path.dirname(scriptPath)
73
+
36
74
  const platformMap = { darwin: "darwin", linux: "linux", win32: "windows" }
37
- const archMap = { x64: "x64", arm64: "arm64" }
75
+ const archMap = { x64: "x64", arm64: "arm64", arm: "arm" }
38
76
  const platform = platformMap[os.platform()] || os.platform()
39
77
  const arch = archMap[os.arch()] || os.arch()
78
+ const base = "synsc-" + platform + "-" + arch
79
+ const scopedBase = "cli-" + platform + "-" + arch
40
80
 
41
- // Check local bin directory (set up by postinstall)
42
- const localBinary = path.join(scriptDir, binary)
43
- if (fs.existsSync(localBinary)) {
44
- run(localBinary)
45
- }
46
-
47
- // Search node_modules for platform package
48
- const base = `synsc-${platform}-${arch}`
49
81
  let current = scriptDir
50
82
  while (true) {
51
83
  const modules = path.join(current, "node_modules")
52
84
  if (fs.existsSync(modules)) {
53
- const entries = fs.readdirSync(modules)
54
- for (const entry of entries) {
55
- if (entry.startsWith(base)) {
56
- const candidate = path.join(modules, entry, "bin", binary)
57
- if (fs.existsSync(candidate)) {
58
- run(candidate)
85
+ try {
86
+ const entries = fs.readdirSync(modules)
87
+ for (const entry of entries) {
88
+ if (entry.startsWith(base)) {
89
+ const candidate = path.join(modules, entry, "bin", binary)
90
+ if (isBinary(candidate)) run(candidate)
59
91
  }
60
92
  }
61
- }
62
- // Also check scoped packages
63
- const scoped = path.join(modules, "@synsci")
64
- if (fs.existsSync(scoped)) {
65
- const scopedEntries = fs.readdirSync(scoped)
66
- for (const entry of scopedEntries) {
67
- if (entry.startsWith("cli-" + platform + "-" + arch)) {
68
- const candidate = path.join(scoped, entry, "bin", binary)
69
- if (fs.existsSync(candidate)) {
70
- run(candidate)
93
+ // Check scoped packages (@synsci/cli-darwin-arm64)
94
+ const scoped = path.join(modules, "@synsci")
95
+ if (fs.existsSync(scoped)) {
96
+ const scopedEntries = fs.readdirSync(scoped)
97
+ for (const entry of scopedEntries) {
98
+ if (entry.startsWith(scopedBase)) {
99
+ const candidate = path.join(scoped, entry, "bin", binary)
100
+ if (isBinary(candidate)) run(candidate)
71
101
  }
72
102
  }
73
103
  }
74
- }
104
+ } catch {}
75
105
  }
76
106
  const parent = path.dirname(current)
77
107
  if (parent === current) break
@@ -82,12 +112,3 @@ console.error("synsc binary not found.")
82
112
  console.error("Install with: curl -fsSL https://syntheticsciences.ai/install | bash")
83
113
  console.error("Or set SYNSCI_BIN_PATH environment variable.")
84
114
  process.exit(1)
85
-
86
- function run(target) {
87
- const result = spawnSync(target, process.argv.slice(2), { stdio: "inherit" })
88
- if (result.error) {
89
- console.error(result.error.message)
90
- process.exit(1)
91
- }
92
- process.exit(typeof result.status === "number" ? result.status : 0)
93
- }
package/package.json CHANGED
@@ -1,16 +1,14 @@
1
1
  {
2
2
  "name": "@synsci/cli",
3
- "version": "1.1.46",
4
- "description": "Synthetic Sciences CLI - AI coding agent for machine learning research",
5
- "license": "MIT",
3
+ "version": "1.1.48",
4
+ "description": "Synthetic Sciences CLI - AI research agent",
6
5
  "bin": {
7
6
  "synsc": "./bin/synsc.js"
8
7
  },
9
- "scripts": {
10
- "postinstall": "node postinstall.js"
11
- },
12
- "os": ["darwin", "linux", "win32"],
13
- "engines": {
14
- "node": ">=18"
8
+ "files": ["bin/"],
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/ishaan1124/synthetisciences-cli"
15
13
  }
16
14
  }
package/postinstall.js DELETED
@@ -1,89 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const https = require("https")
4
- const http = require("http")
5
- const fs = require("fs")
6
- const path = require("path")
7
- const os = require("os")
8
- const { execSync } = require("child_process")
9
-
10
- const VERSION = "1.1.46"
11
-
12
- const platformMap = { darwin: "darwin", linux: "linux", win32: "windows" }
13
- const archMap = { x64: "x64", arm64: "arm64" }
14
-
15
- const platform = platformMap[os.platform()]
16
- const arch = archMap[os.arch()]
17
-
18
- if (!platform || !arch) {
19
- console.error(`Unsupported platform: ${os.platform()} ${os.arch()}`)
20
- process.exit(1)
21
- }
22
-
23
- const binary = platform === "windows" ? "synsc.exe" : "synsc"
24
- const ext = platform === "linux" ? ".tar.gz" : ".zip"
25
- const filename = `synsc-${platform}-${arch}${ext}`
26
-
27
- const binDir = path.join(__dirname, "bin")
28
- const binPath = path.join(binDir, binary)
29
-
30
- // Skip if binary already exists
31
- if (fs.existsSync(binPath)) {
32
- try {
33
- const result = execSync(`"${binPath}" --version`, { encoding: "utf8", timeout: 5000 }).trim()
34
- if (result) {
35
- console.log(`synsc ${result} already installed`)
36
- process.exit(0)
37
- }
38
- } catch {}
39
- }
40
-
41
- // Try to find existing installation
42
- const homeBin = path.join(os.homedir(), ".synsc", "bin", binary)
43
- if (fs.existsSync(homeBin)) {
44
- console.log(`Found existing synsc at ${homeBin}`)
45
- fs.mkdirSync(binDir, { recursive: true })
46
- try {
47
- fs.symlinkSync(homeBin, binPath)
48
- console.log(`Linked to existing installation`)
49
- process.exit(0)
50
- } catch {
51
- fs.copyFileSync(homeBin, binPath)
52
- fs.chmodSync(binPath, 0o755)
53
- console.log(`Copied from existing installation`)
54
- process.exit(0)
55
- }
56
- }
57
-
58
- // Check system PATH for synsc
59
- try {
60
- const systemBin = execSync("which synsc 2>/dev/null || where synsc 2>nul", { encoding: "utf8" }).trim()
61
- if (systemBin && fs.existsSync(systemBin)) {
62
- console.log(`Found synsc at ${systemBin}`)
63
- fs.mkdirSync(binDir, { recursive: true })
64
- try {
65
- fs.symlinkSync(systemBin, binPath)
66
- process.exit(0)
67
- } catch {
68
- fs.copyFileSync(systemBin, binPath)
69
- fs.chmodSync(binPath, 0o755)
70
- process.exit(0)
71
- }
72
- }
73
- } catch {}
74
-
75
- // Download from GitHub releases (private repo - needs token)
76
- // or from the install script
77
- console.log(`\nsynsc binary not found. Install it with:`)
78
- console.log(` curl -fsSL https://syntheticsciences.ai/install | bash`)
79
- console.log(`\nThen run: npm rebuild @synsci/cli`)
80
- console.log(`Or set SYNSCI_BIN_PATH to point to your synsc binary.\n`)
81
-
82
- // Create a placeholder script that shows the install message
83
- fs.mkdirSync(binDir, { recursive: true })
84
- fs.writeFileSync(binPath, `#!/usr/bin/env node
85
- console.error("synsc binary not installed. Run: curl -fsSL https://syntheticsciences.ai/install | bash")
86
- console.error("Then run: npm rebuild @synsci/cli")
87
- process.exit(1)
88
- `)
89
- fs.chmodSync(binPath, 0o755)