synsci 1.1.121 → 1.1.123

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 +32 -2
  2. package/package.json +3 -6
package/bin/synsci.mjs CHANGED
@@ -1,10 +1,27 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ // Hard guard against recursive invocation. The launcher binary and the real
4
+ // @synsci/cli binary share the name `synsci`; if a check ever resolves to
5
+ // the launcher itself, this prevents an infinite spawn chain that exhausts
6
+ // memory.
7
+ if (process.env.__SYNSCI_LAUNCHER_PID) {
8
+ process.stderr.write(
9
+ `synsci: launcher invoked recursively (parent pid ${process.env.__SYNSCI_LAUNCHER_PID}). Exiting.\n`,
10
+ )
11
+ process.exit(2)
12
+ }
13
+ process.env.__SYNSCI_LAUNCHER_PID = String(process.pid)
14
+
3
15
  import { execSync, spawn } from "node:child_process"
4
- import { existsSync, readFileSync } from "node:fs"
16
+ import { existsSync, readFileSync, realpathSync } from "node:fs"
5
17
  import { homedir } from "node:os"
6
18
  import { join } from "node:path"
7
19
  import { createInterface } from "node:readline"
20
+ import { fileURLToPath } from "node:url"
21
+
22
+ const SELF_PATH = (() => {
23
+ try { return realpathSync(fileURLToPath(import.meta.url)) } catch { return "" }
24
+ })()
8
25
 
9
26
  const BOLD = "\x1b[1m"
10
27
  const DIM = "\x1b[2m"
@@ -49,7 +66,20 @@ function runQuiet(cmd) {
49
66
  catch { return null }
50
67
  }
51
68
 
52
- function isInstalled() { return runQuiet("which synsci") !== null }
69
+ function isInstalled() {
70
+ const found = runQuiet("which synsci")
71
+ if (!found) return false
72
+ try {
73
+ const real = realpathSync(found)
74
+ // Skip if resolves to this launcher itself — prevents the npx-cache recursion
75
+ // where `which synsci` finds the launcher's own bin and `synsci --version`
76
+ // re-invokes main() forever.
77
+ if (SELF_PATH && real === SELF_PATH) return false
78
+ // Belt-and-suspenders: an npx shim also routes back to a launcher
79
+ if (real.includes("/_npx/")) return false
80
+ return true
81
+ } catch { return false }
82
+ }
53
83
 
54
84
  function isConnected() {
55
85
  const xdgData = process.env.XDG_DATA_HOME || join(homedir(), ".local", "share")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "synsci",
3
- "version": "1.1.121",
3
+ "version": "1.1.123",
4
4
  "description": "One command to install, connect, and launch Synthetic Sciences CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -20,10 +20,7 @@
20
20
  ],
21
21
  "repository": {
22
22
  "type": "git",
23
- "url": "git+https://github.com/ishaan1124/synthetisciences-cli.git"
23
+ "url": "git+https://github.com/synthetic-sciences/synsci-cli.git"
24
24
  },
25
- "homepage": "https://syntheticsciences.ai",
26
- "dependencies": {
27
- "@synsci/cli": "1.1.121"
28
- }
25
+ "homepage": "https://syntheticsciences.ai"
29
26
  }