@satori-sh/cli 0.0.16 → 0.0.18

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/dist/index.js +34 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3,7 +3,8 @@
3
3
  // src/index.ts
4
4
  import { Command } from "commander";
5
5
  import { readFileSync, realpathSync } from "fs";
6
- import { execFile } from "child_process";
6
+ import { homedir as homedir2 } from "os";
7
+ import { execFile, spawn, spawnSync } from "child_process";
7
8
  import { dirname, join as join2 } from "path";
8
9
  import { fileURLToPath } from "url";
9
10
  import chalk from "chalk";
@@ -229,6 +230,37 @@ ${memoryText}`
229
230
 
230
231
  // src/index.ts
231
232
  async function main() {
233
+ const modulePath2 = realpathSync(fileURLToPath(import.meta.url));
234
+ const isInteractive = process.stdin.isTTY && process.stdout.isTTY;
235
+ if (isInteractive && !globalThis.Bun && !process.env.SATORI_BUN_REEXEC) {
236
+ const bunBinDir = join2(homedir2(), ".bun", "bin");
237
+ const baseEnv = { ...process.env, PATH: `${bunBinDir}:${process.env.PATH ?? ""}` };
238
+ const ensureBun = () => spawnSync("bun", ["--version"], { stdio: "ignore", env: baseEnv }).status === 0;
239
+ if (!ensureBun()) {
240
+ const installResult = spawnSync(
241
+ "bash",
242
+ ["-lc", "curl -fsSL https://bun.sh/install | bash"],
243
+ { stdio: "inherit" }
244
+ );
245
+ if (installResult.status !== 0 || !ensureBun()) {
246
+ console.error("Failed to install Bun. Please install manually and retry.");
247
+ process.exit(1);
248
+ }
249
+ }
250
+ const bunProcess = spawn(
251
+ "bun",
252
+ [modulePath2, ...process.argv.slice(2)],
253
+ { env: { ...baseEnv, SATORI_BUN_REEXEC: "1" }, stdio: "inherit" }
254
+ );
255
+ bunProcess.on("error", (error) => {
256
+ console.error("Failed to launch Bun:", error.message);
257
+ process.exit(1);
258
+ });
259
+ bunProcess.on("exit", (code) => {
260
+ process.exit(code ?? 0);
261
+ });
262
+ return;
263
+ }
232
264
  const argv = process.argv.slice(2);
233
265
  const isGetApiKey = argv[0] === "get" && argv[1] === "api-key";
234
266
  if (!isGetApiKey) {
@@ -333,9 +365,7 @@ ${instruction}`);
333
365
  return;
334
366
  }
335
367
  const info = await getInfoDisplay();
336
- const { runInteractiveApp } = await import("./ui-AFMM6JTQ.js").catch(() => {
337
- throw new Error("Interactive mode requires Bun. Run `bunx @satori-sh/cli`.");
338
- });
368
+ const { runInteractiveApp } = await import("./ui-AFMM6JTQ.js");
339
369
  await runInteractiveApp({
340
370
  initialPrompt,
341
371
  options,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@satori-sh/cli",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
4
4
  "description": "CLI tool for Satori memory server",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",