synsci 1.1.76 → 1.1.77

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 (3) hide show
  1. package/bin/synsci.mjs +114 -0
  2. package/package.json +19 -8
  3. package/README.md +0 -17
package/bin/synsci.mjs ADDED
@@ -0,0 +1,114 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { execSync, spawn } from "node:child_process"
4
+ import { existsSync, readFileSync } from "node:fs"
5
+ import { homedir } from "node:os"
6
+ import { join } from "node:path"
7
+ import { createInterface } from "node:readline"
8
+
9
+ const BOLD = "\x1b[1m"
10
+ const DIM = "\x1b[2m"
11
+ const CYAN = "\x1b[36m"
12
+ const GREEN = "\x1b[32m"
13
+ const YELLOW = "\x1b[33m"
14
+ const RESET = "\x1b[0m"
15
+
16
+ function log(msg) {
17
+ console.log(`${CYAN}synsc${RESET} ${msg}`)
18
+ }
19
+
20
+ function run(cmd, opts = {}) {
21
+ return execSync(cmd, { stdio: "inherit", ...opts })
22
+ }
23
+
24
+ function runQuiet(cmd) {
25
+ try {
26
+ return execSync(cmd, { encoding: "utf-8", stdio: "pipe" }).trim()
27
+ } catch {
28
+ return null
29
+ }
30
+ }
31
+
32
+ function isInstalled() {
33
+ return runQuiet("which synsc") !== null
34
+ }
35
+
36
+ function isConnected() {
37
+ const authPath = join(homedir(), ".synsc", "auth.json")
38
+ if (!existsSync(authPath)) return false
39
+ try {
40
+ const content = readFileSync(authPath, "utf-8").trim()
41
+ if (!content || content === "{}") return false
42
+ const parsed = JSON.parse(content)
43
+ return Object.keys(parsed).length > 0
44
+ } catch {
45
+ return false
46
+ }
47
+ }
48
+
49
+ async function prompt(question) {
50
+ const rl = createInterface({ input: process.stdin, output: process.stdout })
51
+ return new Promise((resolve) => {
52
+ rl.question(question, (answer) => {
53
+ rl.close()
54
+ resolve(answer.trim())
55
+ })
56
+ })
57
+ }
58
+
59
+ async function main() {
60
+ console.log()
61
+ console.log(`${BOLD}Synthetic Sciences CLI${RESET}`)
62
+ console.log()
63
+
64
+ // Step 1: Install or upgrade
65
+ if (isInstalled()) {
66
+ log(`already installed ${DIM}(upgrading...)${RESET}`)
67
+ try {
68
+ run("synsc upgrade")
69
+ } catch {
70
+ log(`${YELLOW}upgrade skipped${RESET} ${DIM}(already on latest)${RESET}`)
71
+ }
72
+ } else {
73
+ log("installing @synsci/cli...")
74
+ run("npm i -g @synsci/cli")
75
+ }
76
+
77
+ console.log()
78
+
79
+ // Step 2: Connect (only if not already connected)
80
+ if (isConnected()) {
81
+ log(`${GREEN}already connected${RESET}`)
82
+ } else {
83
+ log("connecting...")
84
+ run("synsc connect login")
85
+ }
86
+
87
+ console.log()
88
+
89
+ // Step 3: Choose how to launch
90
+ console.log(`${BOLD}How would you like to use synsc?${RESET}`)
91
+ console.log()
92
+ console.log(` ${BOLD}1${RESET} ${CYAN}synsc web${RESET} ${DIM}browser UI at localhost${RESET}`)
93
+ console.log(` ${BOLD}2${RESET} ${CYAN}synsc${RESET} ${DIM}terminal TUI${RESET}`)
94
+ console.log()
95
+
96
+ const choice = await prompt(`${BOLD}Choose [1/2]: ${RESET}`)
97
+
98
+ console.log()
99
+
100
+ if (choice === "1") {
101
+ log("launching web UI...")
102
+ const child = spawn("synsc", ["web"], { stdio: "inherit" })
103
+ child.on("close", (code) => process.exit(code ?? 0))
104
+ } else {
105
+ log("launching terminal...")
106
+ const child = spawn("synsc", [], { stdio: "inherit" })
107
+ child.on("close", (code) => process.exit(code ?? 0))
108
+ }
109
+ }
110
+
111
+ main().catch((err) => {
112
+ console.error(err)
113
+ process.exit(1)
114
+ })
package/package.json CHANGED
@@ -1,15 +1,26 @@
1
1
  {
2
2
  "name": "synsci",
3
- "version": "1.1.76",
4
- "description": "Synthetic Sciences CLI AI coding agent for ML research",
3
+ "version": "1.1.77",
4
+ "description": "One command to install, connect, and launch Synthetic Sciences CLI",
5
5
  "license": "MIT",
6
+ "type": "module",
7
+ "bin": {
8
+ "synsci": "./bin/synsci.mjs"
9
+ },
10
+ "files": [
11
+ "bin"
12
+ ],
13
+ "keywords": [
14
+ "synsc",
15
+ "synthetic-sciences",
16
+ "ai",
17
+ "ml",
18
+ "research",
19
+ "cli"
20
+ ],
6
21
  "repository": {
7
22
  "type": "git",
8
- "url": "https://github.com/SyntheticSciences/cli"
23
+ "url": "https://github.com/ishaan1124/synthetisciences-cli"
9
24
  },
10
- "homepage": "https://syntheticsciences.ai",
11
- "keywords": ["ai", "ml", "cli", "coding-agent", "synthetic-sciences"],
12
- "dependencies": {
13
- "@synsci/cli": "^1.1.75"
14
- }
25
+ "homepage": "https://syntheticsciences.ai"
15
26
  }
package/README.md DELETED
@@ -1,17 +0,0 @@
1
- # synsci
2
-
3
- This is the install alias for [@synsci/cli](https://www.npmjs.com/package/@synsci/cli) — the Synthetic Sciences CLI.
4
-
5
- ## Install
6
-
7
- ```bash
8
- npm install -g synsci
9
- ```
10
-
11
- ## Usage
12
-
13
- ```bash
14
- synsc
15
- ```
16
-
17
- For full documentation, visit [syntheticsciences.ai](https://syntheticsciences.ai).