@synsci/cli 1.1.46 → 1.1.47

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,96 @@
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
+ const result = childProcess.spawnSync(target, process.argv.slice(2), {
10
+ stdio: "inherit",
11
+ })
12
+ if (result.error) {
13
+ console.error(result.error.message)
14
+ process.exit(1)
15
+ }
16
+ const code = typeof result.status === "number" ? result.status : 0
17
+ process.exit(code)
18
+ }
19
+
20
+ // Helper: check if a path points to a real binary (not this wrapper script)
21
+ function isBinary(p) {
22
+ try {
23
+ if (!fs.existsSync(p)) return false
24
+ const real = fs.realpathSync(p)
25
+ // Skip if it resolves to this script (self-reference via symlink)
26
+ if (real === fs.realpathSync(__filename)) return false
27
+ // Skip if it's a .js file (another wrapper)
28
+ if (real.endsWith(".js")) return false
29
+ return true
30
+ } catch {
31
+ return false
32
+ }
33
+ }
34
+
35
+ // 1. Check SYNSCI_BIN_PATH env var
9
36
  const envPath = process.env.SYNSCI_BIN_PATH
10
- if (envPath && fs.existsSync(envPath)) {
37
+ if (envPath && isBinary(envPath)) {
11
38
  run(envPath)
12
39
  }
13
40
 
14
41
  const binary = os.platform() === "win32" ? "synsc.exe" : "synsc"
15
42
 
16
- // Check ~/.synsc/bin first
43
+ // 2. Check ~/.synsc/bin (primary install location)
17
44
  const homeBin = path.join(os.homedir(), ".synsc", "bin", binary)
18
- if (fs.existsSync(homeBin)) {
45
+ if (isBinary(homeBin)) {
19
46
  run(homeBin)
20
47
  }
21
48
 
22
- // Check /opt/homebrew/bin (macOS)
23
- const brewBin = "/opt/homebrew/bin/synsc"
24
- if (os.platform() === "darwin" && fs.existsSync(brewBin)) {
25
- run(brewBin)
49
+ // 3. Check /opt/homebrew/bin (macOS)
50
+ if (os.platform() === "darwin" && isBinary("/opt/homebrew/bin/synsc")) {
51
+ run("/opt/homebrew/bin/synsc")
26
52
  }
27
53
 
28
- // Check /usr/local/bin
29
- const localBin = "/usr/local/bin/synsc"
30
- if (fs.existsSync(localBin)) {
31
- run(localBin)
54
+ // 4. Check /usr/local/bin
55
+ if (isBinary("/usr/local/bin/synsc")) {
56
+ run("/usr/local/bin/synsc")
32
57
  }
33
58
 
34
- // Check sibling platform package
35
- const scriptDir = path.dirname(fs.realpathSync(__filename))
59
+ // 5. Search node_modules for platform package
60
+ const scriptPath = fs.realpathSync(__filename)
61
+ const scriptDir = path.dirname(scriptPath)
62
+
36
63
  const platformMap = { darwin: "darwin", linux: "linux", win32: "windows" }
37
- const archMap = { x64: "x64", arm64: "arm64" }
64
+ const archMap = { x64: "x64", arm64: "arm64", arm: "arm" }
38
65
  const platform = platformMap[os.platform()] || os.platform()
39
66
  const arch = archMap[os.arch()] || os.arch()
67
+ const base = "synsc-" + platform + "-" + arch
68
+ const scopedBase = "cli-" + platform + "-" + arch
40
69
 
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
70
  let current = scriptDir
50
71
  while (true) {
51
72
  const modules = path.join(current, "node_modules")
52
73
  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)
74
+ try {
75
+ const entries = fs.readdirSync(modules)
76
+ for (const entry of entries) {
77
+ if (entry.startsWith(base)) {
78
+ const candidate = path.join(modules, entry, "bin", binary)
79
+ if (isBinary(candidate)) run(candidate)
59
80
  }
60
81
  }
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)
82
+ // Check scoped packages (@synsci/cli-darwin-arm64)
83
+ const scoped = path.join(modules, "@synsci")
84
+ if (fs.existsSync(scoped)) {
85
+ const scopedEntries = fs.readdirSync(scoped)
86
+ for (const entry of scopedEntries) {
87
+ if (entry.startsWith(scopedBase)) {
88
+ const candidate = path.join(scoped, entry, "bin", binary)
89
+ if (isBinary(candidate)) run(candidate)
71
90
  }
72
91
  }
73
92
  }
74
- }
93
+ } catch {}
75
94
  }
76
95
  const parent = path.dirname(current)
77
96
  if (parent === current) break
@@ -82,12 +101,3 @@ console.error("synsc binary not found.")
82
101
  console.error("Install with: curl -fsSL https://syntheticsciences.ai/install | bash")
83
102
  console.error("Or set SYNSCI_BIN_PATH environment variable.")
84
103
  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.47",
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)