@socrates-ai/cli 0.1.2 → 0.1.4

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/README.md CHANGED
@@ -7,3 +7,9 @@ npx @socrates-ai/cli
7
7
  ```
8
8
 
9
9
  The CLI downloads the matching runtime bundle from GitHub Releases, stores it under `~/.Socrates/runtimes/`, starts local services on `127.0.0.1`, and opens the browser.
10
+
11
+ Force a fresh runtime download/extract with:
12
+
13
+ ```bash
14
+ npx @socrates-ai/cli --reset-runtime
15
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@socrates-ai/cli",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "type": "module",
5
5
  "description": "Launch Socrates as a local-first AI workspace from npm.",
6
6
  "bin": {
@@ -12,6 +12,9 @@
12
12
  "src/runtime.mjs",
13
13
  "README.md"
14
14
  ],
15
+ "scripts": {
16
+ "test": "vitest run"
17
+ },
15
18
  "engines": {
16
19
  "node": ">=20"
17
20
  },
@@ -23,8 +26,5 @@
23
26
  "url": "git+https://github.com/Ayushbh6/Socrates.git",
24
27
  "directory": "apps/cli"
25
28
  },
26
- "license": "UNLICENSED",
27
- "scripts": {
28
- "test": "vitest run"
29
- }
30
- }
29
+ "license": "UNLICENSED"
30
+ }
package/src/runtime.mjs CHANGED
@@ -29,6 +29,7 @@ export const parseArgs = (argv) => {
29
29
  options.noOpen = true;
30
30
  break;
31
31
  case "--reset-runtime":
32
+ case "--resest-runtime":
32
33
  options.resetRuntime = true;
33
34
  break;
34
35
  case "--home":
@@ -261,17 +262,43 @@ const downloadFile = async (url, target) => {
261
262
  };
262
263
 
263
264
  const extractZip = async (archivePath, targetDir) => {
264
- if (process.platform === "win32") {
265
- await run("powershell.exe", [
266
- "-NoProfile",
267
- "-Command",
268
- `Expand-Archive -LiteralPath '${archivePath}' -DestinationPath '${targetDir}' -Force`,
269
- ]);
270
- return;
265
+ const commands = zipExtractCommandsFor(process.platform, archivePath, targetDir);
266
+ let lastError;
267
+ for (let index = 0; index < commands.length; index += 1) {
268
+ const { command, args } = commands[index];
269
+ try {
270
+ await run(command, args);
271
+ return;
272
+ } catch (error) {
273
+ lastError = error;
274
+ if (index < commands.length - 1) {
275
+ fs.rmSync(targetDir, { recursive: true, force: true });
276
+ fs.mkdirSync(targetDir, { recursive: true });
277
+ }
278
+ }
271
279
  }
272
- await run("unzip", ["-q", archivePath, "-d", targetDir]);
280
+ throw lastError;
273
281
  };
274
282
 
283
+ export const zipExtractCommandsFor = (platform, archivePath, targetDir) => {
284
+ if (platform === "win32") {
285
+ return [
286
+ { command: "tar.exe", args: ["-xf", archivePath, "-C", targetDir] },
287
+ {
288
+ command: "powershell.exe",
289
+ args: [
290
+ "-NoProfile",
291
+ "-Command",
292
+ `Expand-Archive -LiteralPath ${powerShellSingleQuoted(archivePath)} -DestinationPath ${powerShellSingleQuoted(targetDir)} -Force`,
293
+ ],
294
+ },
295
+ ];
296
+ }
297
+ return [{ command: "unzip", args: ["-q", archivePath, "-d", targetDir] }];
298
+ };
299
+
300
+ export const powerShellSingleQuoted = (value) => `'${String(value).replaceAll("'", "''")}'`;
301
+
275
302
  const run = (command, args) =>
276
303
  new Promise((resolve, reject) => {
277
304
  const child = defaultSpawn(command, args, { stdio: "ignore" });