synsci 1.1.124 → 1.1.126

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.
Files changed (2) hide show
  1. package/bin/synsci.mjs +16 -12
  2. package/package.json +2 -2
package/bin/synsci.mjs CHANGED
@@ -81,22 +81,26 @@ function isLauncherPath(p) {
81
81
  }
82
82
 
83
83
  // Returns the absolute path to the real @synsci/cli binary, never the launcher
84
- // itself. Walks past PATH entries pointing at this script or any npx shim.
84
+ // itself. Only trusts canonical install locations — no `$PATH` walk — to avoid
85
+ // picking up dev shims or workspace symlinks that point at unrunnable sources.
86
+ // Each candidate is verified by invoking `--version` and checking the output
87
+ // is version-shaped, so half-broken installs are skipped instead of accepted.
85
88
  function resolveCli() {
89
+ const candidates = []
86
90
  // 1. Global npm prefix (where `npm i -g @synsci/cli` puts it)
87
91
  const prefix = runQuiet("npm prefix -g")
88
- if (prefix) {
89
- const cand = join(prefix, "bin", "synsci")
90
- if (existsSync(cand) && !isLauncherPath(cand)) return cand
91
- }
92
+ if (prefix) candidates.push(join(prefix, "bin", "synsci"))
92
93
  // 2. ~/.synsc/bin/synsci (used by @synsci/cli postinstall on some setups)
93
- const synscBin = join(homedir(), ".synsc", "bin", "synsci")
94
- if (existsSync(synscBin) && !isLauncherPath(synscBin)) return synscBin
95
- // 3. Walk every PATH entry, return first that is NOT a launcher
96
- for (const dir of (process.env.PATH || "").split(":")) {
97
- if (!dir) continue
98
- const cand = join(dir, "synsci")
99
- if (existsSync(cand) && !isLauncherPath(cand)) return cand
94
+ candidates.push(join(homedir(), ".synsc", "bin", "synsci"))
95
+
96
+ for (const cand of candidates) {
97
+ if (!existsSync(cand) || isLauncherPath(cand)) continue
98
+ try {
99
+ const ver = execFileSync(cand, ["--version"], {
100
+ encoding: "utf-8", stdio: "pipe", timeout: 5000,
101
+ }).trim()
102
+ if (/^\d/.test(ver)) return cand
103
+ } catch { /* unrunnable candidate, try next */ }
100
104
  }
101
105
  return null
102
106
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "synsci",
3
- "version": "1.1.124",
3
+ "version": "1.1.126",
4
4
  "description": "One command to install, connect, and launch Synthetic Sciences CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -23,4 +23,4 @@
23
23
  "url": "git+https://github.com/synthetic-sciences/synsci-cli.git"
24
24
  },
25
25
  "homepage": "https://syntheticsciences.ai"
26
- }
26
+ }