synsci 1.1.76 → 1.1.114

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 +148 -0
  2. package/package.json +19 -8
  3. package/README.md +0 -17
package/bin/synsci.mjs ADDED
@@ -0,0 +1,148 @@
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 RED = "\x1b[31m"
15
+ const RESET = "\x1b[0m"
16
+ const HIDE_CURSOR = "\x1b[?25l"
17
+ const SHOW_CURSOR = "\x1b[?25h"
18
+ const CLEAR_LINE = "\x1b[2K\r"
19
+
20
+ const LOGO = [
21
+ "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557",
22
+ "\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255d\u255a\u2588\u2588\u2557 \u2588\u2588\u2554\u255d\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255d\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255d\u2588\u2588\u2551",
23
+ "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u255a\u2588\u2588\u2588\u2588\u2554\u255d \u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551",
24
+ "\u255a\u2550\u2550\u2550\u2550\u2588\u2588\u2551 \u255a\u2588\u2588\u2554\u255d \u2588\u2588\u2551\u255a\u2588\u2588\u2557\u2588\u2588\u2551\u255a\u2550\u2550\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551",
25
+ "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u255a\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u255a\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551",
26
+ "\u255a\u2550\u2550\u2550\u2550\u2550\u2550\u255d \u255a\u2550\u255d \u255a\u2550\u255d \u255a\u2550\u2550\u2550\u255d\u255a\u2550\u2550\u2550\u2550\u2550\u2550\u255d \u255a\u2550\u2550\u2550\u2550\u2550\u255d\u255a\u2550\u255d",
27
+ ]
28
+
29
+ function ok(msg) { console.log(` ${GREEN}\u2713${RESET} ${msg}`) }
30
+ function warn(msg) { console.log(` ${YELLOW}\u26A0${RESET} ${msg}`) }
31
+
32
+ function spinner(msg) {
33
+ const frames = ["\u25D2", "\u25D0", "\u25D3", "\u25D1"]
34
+ let i = 0
35
+ process.stdout.write(HIDE_CURSOR)
36
+ const id = setInterval(() => {
37
+ process.stdout.write(`${CLEAR_LINE} ${CYAN}${frames[i++ % frames.length]}${RESET} ${msg}`)
38
+ }, 80)
39
+ return {
40
+ ok(result) { clearInterval(id); process.stdout.write(`${CLEAR_LINE}${SHOW_CURSOR}`); ok(result) },
41
+ warn(result) { clearInterval(id); process.stdout.write(`${CLEAR_LINE}${SHOW_CURSOR}`); warn(result) },
42
+ fail(result) { clearInterval(id); process.stdout.write(`${CLEAR_LINE}${SHOW_CURSOR}`); console.log(` ${RED}\u2717${RESET} ${result}`) },
43
+ update(m) { msg = m },
44
+ }
45
+ }
46
+
47
+ function runQuiet(cmd) {
48
+ try { return execSync(cmd, { encoding: "utf-8", stdio: "pipe" }).trim() }
49
+ catch { return null }
50
+ }
51
+
52
+ function isInstalled() { return runQuiet("which synsc") !== null }
53
+
54
+ function isConnected() {
55
+ const xdgData = process.env.XDG_DATA_HOME || join(homedir(), ".local", "share")
56
+ const sessionPath = join(xdgData, "synsc", "synsci-session.json")
57
+ if (!existsSync(sessionPath)) return false
58
+ try {
59
+ const data = JSON.parse(readFileSync(sessionPath, "utf-8"))
60
+ if (!data.access_token || !data.expires_at) return false
61
+ return new Date(data.expires_at) > new Date()
62
+ } catch { return false }
63
+ }
64
+
65
+ async function ask(question) {
66
+ const rl = createInterface({ input: process.stdin, output: process.stdout })
67
+ return new Promise((resolve) => {
68
+ rl.question(question, (answer) => { rl.close(); resolve(answer.trim()) })
69
+ })
70
+ }
71
+
72
+ async function main() {
73
+ process.on("exit", () => process.stdout.write(SHOW_CURSOR))
74
+ process.on("SIGINT", () => { process.stdout.write(SHOW_CURSOR); process.exit(130) })
75
+
76
+ // --- Logo ---
77
+ console.log()
78
+ for (const line of LOGO) console.log(` ${CYAN}${line}${RESET}`)
79
+ console.log()
80
+ console.log(` ${BOLD}Synthetic Sciences CLI${RESET}`)
81
+ console.log()
82
+
83
+ // --- Step 1: Install or upgrade ---
84
+ if (isInstalled()) {
85
+ const raw = runQuiet("synsc --version") || "unknown"
86
+ const isDev = raw === "local" || raw.includes("-")
87
+ if (isDev) {
88
+ ok(`synsc ${DIM}(dev build)${RESET}`)
89
+ } else {
90
+ const s = spinner("Checking for updates...")
91
+ const current = raw.replace(/[^0-9.]/g, "")
92
+ const latest = runQuiet("npm view @synsci/cli version")
93
+ if (!latest || current === latest) {
94
+ s.ok(`synsc ${current} ${DIM}(up to date)${RESET}`)
95
+ } else {
96
+ s.update(`Upgrading ${current} \u2192 ${latest}...`)
97
+ try {
98
+ execSync("synsc upgrade", { stdio: "pipe" })
99
+ s.ok(`Upgraded to ${latest}`)
100
+ } catch {
101
+ s.warn(`Upgrade failed, continuing with ${current}`)
102
+ }
103
+ }
104
+ }
105
+ } else {
106
+ const s = spinner("Installing synsc...")
107
+ try {
108
+ execSync("npm i -g @synsci/cli@latest", { stdio: "pipe" })
109
+ s.ok("Installed synsc")
110
+ } catch {
111
+ s.fail("Install failed")
112
+ console.log(`\n Try manually: ${CYAN}npm i -g @synsci/cli${RESET}\n`)
113
+ process.exit(1)
114
+ }
115
+ }
116
+
117
+ // --- Step 2: Connect ---
118
+ if (isConnected()) {
119
+ ok("Connected to Synthetic Sciences")
120
+ } else {
121
+ console.log()
122
+ try {
123
+ execSync("synsc connect login", { stdio: "inherit" })
124
+ } catch {}
125
+ }
126
+
127
+ console.log()
128
+
129
+ // --- Step 3: Launch mode ---
130
+ console.log(` ${BOLD}How would you like to use synsc?${RESET}`)
131
+ console.log()
132
+ console.log(` ${BOLD}1${RESET} ${CYAN}synsc${RESET} ${DIM}terminal TUI${RESET}`)
133
+ console.log(` ${BOLD}2${RESET} ${CYAN}synsc web${RESET} ${DIM}browser UI at localhost${RESET}`)
134
+ console.log()
135
+
136
+ const choice = await ask(` ${DIM}\u276F${RESET} Choose [1/2]: `)
137
+ console.log()
138
+
139
+ const cmd = choice === "2" ? ["web"] : []
140
+ const child = spawn("synsc", cmd, { stdio: "inherit" })
141
+ child.on("close", (code) => process.exit(code ?? 0))
142
+ }
143
+
144
+ main().catch((err) => {
145
+ process.stdout.write(SHOW_CURSOR)
146
+ console.error(err)
147
+ process.exit(1)
148
+ })
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.114",
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).