@satori-sh/cli 0.0.16 → 0.0.17

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 +35 -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,38 @@ ${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 bunPath = join2(bunBinDir, "bun");
238
+ const baseEnv = { ...process.env, PATH: `${bunBinDir}:${process.env.PATH ?? ""}` };
239
+ const bunCheck = spawnSync("bun", ["--version"], { stdio: "ignore", env: baseEnv });
240
+ if (bunCheck.status !== 0) {
241
+ const installResult = spawnSync(
242
+ "bash",
243
+ ["-lc", "curl -fsSL https://bun.sh/install | bash"],
244
+ { stdio: "inherit" }
245
+ );
246
+ if (installResult.status !== 0) {
247
+ console.error("Failed to install Bun. Please install manually and retry.");
248
+ process.exit(1);
249
+ }
250
+ }
251
+ const bunProcess = spawn(
252
+ bunPath,
253
+ [modulePath2, ...process.argv.slice(2)],
254
+ { env: { ...baseEnv, SATORI_BUN_REEXEC: "1" }, stdio: "inherit" }
255
+ );
256
+ bunProcess.on("error", (error) => {
257
+ console.error("Failed to launch Bun:", error.message);
258
+ process.exit(1);
259
+ });
260
+ bunProcess.on("exit", (code) => {
261
+ process.exit(code ?? 0);
262
+ });
263
+ return;
264
+ }
232
265
  const argv = process.argv.slice(2);
233
266
  const isGetApiKey = argv[0] === "get" && argv[1] === "api-key";
234
267
  if (!isGetApiKey) {
@@ -333,9 +366,7 @@ ${instruction}`);
333
366
  return;
334
367
  }
335
368
  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
- });
369
+ const { runInteractiveApp } = await import("./ui-AFMM6JTQ.js");
339
370
  await runInteractiveApp({
340
371
  initialPrompt,
341
372
  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.17",
4
4
  "description": "CLI tool for Satori memory server",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",