@mistweaverco/kulala-cli 0.9.0 → 0.10.1

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/dist/cli.cjs CHANGED
@@ -46,7 +46,7 @@ node_readline = __toESM(node_readline, 1);
46
46
  let node_async_hooks = require("node:async_hooks");
47
47
  var package_default = {
48
48
  name: "@mistweaverco/kulala-cli",
49
- version: "0.9.0",
49
+ version: "0.10.1",
50
50
  repository: {
51
51
  "type": "git",
52
52
  "url": "https://github.com/mistweaverco/kulala-cli"
@@ -3473,6 +3473,60 @@ function fileWalker(inputPath, extensions) {
3473
3473
  return filePaths;
3474
3474
  }
3475
3475
  //#endregion
3476
+ //#region src/lib/spinner.ts
3477
+ var SPINNER_FRAMES = [
3478
+ "⠋",
3479
+ "⠙",
3480
+ "⠹",
3481
+ "⠸",
3482
+ "⠼",
3483
+ "⠴",
3484
+ "⠦",
3485
+ "⠧",
3486
+ "⠇",
3487
+ "⠏"
3488
+ ];
3489
+ function isInteractiveTerminal() {
3490
+ return process.stderr.isTTY === true;
3491
+ }
3492
+ function createSpinner() {
3493
+ let timer;
3494
+ let frame = 0;
3495
+ let message = "";
3496
+ const stop = () => {
3497
+ if (timer) {
3498
+ clearInterval(timer);
3499
+ timer = void 0;
3500
+ }
3501
+ if (isInteractiveTerminal()) process.stderr.write("\r\x1B[K");
3502
+ };
3503
+ return {
3504
+ start(msg) {
3505
+ message = msg;
3506
+ if (!isInteractiveTerminal()) {
3507
+ console.error(message);
3508
+ return;
3509
+ }
3510
+ const render = () => {
3511
+ process.stderr.write(`\r${SPINNER_FRAMES[frame]} ${message}`);
3512
+ frame = (frame + 1) % SPINNER_FRAMES.length;
3513
+ };
3514
+ render();
3515
+ timer = setInterval(render, 80);
3516
+ },
3517
+ stop
3518
+ };
3519
+ }
3520
+ async function withSpinner(message, fn) {
3521
+ const spinner = createSpinner();
3522
+ spinner.start(message);
3523
+ try {
3524
+ return await fn();
3525
+ } finally {
3526
+ spinner.stop();
3527
+ }
3528
+ }
3529
+ //#endregion
3476
3530
  //#region src/versions/backend.ts
3477
3531
  var KULALA_CORE_VERSION = "0.24.4";
3478
3532
  //#endregion
@@ -3517,52 +3571,18 @@ function versionMatches() {
3517
3571
  function makeExecutable(filePath) {
3518
3572
  if (process.platform !== "win32") (0, fs.chmodSync)(filePath, 493);
3519
3573
  }
3520
- var SPINNER_FRAMES = [
3521
- "⠋",
3522
- "⠙",
3523
- "⠹",
3524
- "⠸",
3525
- "⠼",
3526
- "⠴",
3527
- "⠦",
3528
- "⠧",
3529
- "⠇",
3530
- "⠏"
3531
- ];
3532
- function isInteractiveTerminal() {
3533
- return process.stderr.isTTY === true;
3534
- }
3535
3574
  function createDownloadProgress() {
3536
- let timer;
3537
- let frame = 0;
3538
- let message = "";
3539
- const clearLine = () => {
3540
- if (timer) {
3541
- clearInterval(timer);
3542
- timer = void 0;
3543
- }
3544
- if (isInteractiveTerminal()) process.stderr.write("\r\x1B[K");
3545
- };
3575
+ const spinner = createSpinner();
3546
3576
  return {
3547
- start(msg) {
3548
- message = msg;
3549
- if (!isInteractiveTerminal()) {
3550
- console.error(message);
3551
- return;
3552
- }
3553
- const render = () => {
3554
- process.stderr.write(`\r${SPINNER_FRAMES[frame]} ${message}`);
3555
- frame = (frame + 1) % SPINNER_FRAMES.length;
3556
- };
3557
- render();
3558
- timer = setInterval(render, 80);
3577
+ start(message) {
3578
+ spinner.start(message);
3559
3579
  },
3560
- succeed(msg) {
3561
- clearLine();
3562
- console.error(msg);
3580
+ succeed(message) {
3581
+ spinner.stop();
3582
+ console.error(message);
3563
3583
  },
3564
3584
  fail() {
3565
- clearLine();
3585
+ spinner.stop();
3566
3586
  }
3567
3587
  };
3568
3588
  }
@@ -3918,20 +3938,38 @@ async function executablePath() {
3918
3938
  }
3919
3939
  function invokeRaw(payload, options = {}) {
3920
3940
  const exe = cachedExecutable;
3921
- if (!exe) throw new Error("kulala-core executable not resolved");
3922
- const result = (0, node_child_process.spawnSync)(exe, [], {
3923
- input: `${JSON.stringify(payload)}\n`,
3924
- encoding: "utf-8",
3925
- maxBuffer: 50 * 1024 * 1024,
3926
- cwd: options.cwd,
3927
- env: process.env
3941
+ if (!exe) return Promise.reject(/* @__PURE__ */ new Error("kulala-core executable not resolved"));
3942
+ return new Promise((resolve, reject) => {
3943
+ const child = (0, node_child_process.spawn)(exe, [], {
3944
+ cwd: options.cwd,
3945
+ env: process.env,
3946
+ stdio: [
3947
+ "pipe",
3948
+ "pipe",
3949
+ "pipe"
3950
+ ]
3951
+ });
3952
+ let stdout = "";
3953
+ let stderr = "";
3954
+ child.stdout.setEncoding("utf-8");
3955
+ child.stderr.setEncoding("utf-8");
3956
+ child.stdout.on("data", (chunk) => {
3957
+ stdout += chunk;
3958
+ });
3959
+ child.stderr.on("data", (chunk) => {
3960
+ stderr += chunk;
3961
+ });
3962
+ child.on("error", reject);
3963
+ child.on("close", (status) => {
3964
+ resolve({
3965
+ stdout,
3966
+ stderr,
3967
+ status
3968
+ });
3969
+ });
3970
+ child.stdin.write(`${JSON.stringify(payload)}\n`);
3971
+ child.stdin.end();
3928
3972
  });
3929
- if (result.error) throw result.error;
3930
- return {
3931
- stdout: result.stdout ?? "",
3932
- stderr: result.stderr ?? "",
3933
- status: result.status
3934
- };
3935
3973
  }
3936
3974
  function tryDecodeWrapper(stdout) {
3937
3975
  const raw = stdout.trim();
@@ -3953,7 +3991,7 @@ function parseInvokeResponse(job) {
3953
3991
  }
3954
3992
  async function runHttp(options, invokeOptions = {}) {
3955
3993
  await executablePath();
3956
- return parseInvokeResponse(invokeRaw({
3994
+ return parseInvokeResponse(await invokeRaw({
3957
3995
  action: "run",
3958
3996
  content: options.content,
3959
3997
  filepath: options.filepath,
@@ -3964,7 +4002,7 @@ async function runHttp(options, invokeOptions = {}) {
3964
4002
  }
3965
4003
  async function continueHttp(options, invokeOptions = {}) {
3966
4004
  await executablePath();
3967
- return parseInvokeResponse(invokeRaw({
4005
+ return parseInvokeResponse(await invokeRaw({
3968
4006
  action: "continue",
3969
4007
  promptId: options.promptId,
3970
4008
  inputs: options.inputs
@@ -3972,7 +4010,7 @@ async function continueHttp(options, invokeOptions = {}) {
3972
4010
  }
3973
4011
  async function environments(options = {}, invokeOptions = {}) {
3974
4012
  await executablePath();
3975
- const job = invokeRaw({
4013
+ const job = await invokeRaw({
3976
4014
  action: "environments",
3977
4015
  cwd: options.cwd,
3978
4016
  filepath: options.filepath
@@ -3984,7 +4022,7 @@ async function environments(options = {}, invokeOptions = {}) {
3984
4022
  }
3985
4023
  async function curl$1(options, invokeOptions = {}) {
3986
4024
  await executablePath();
3987
- return parseInvokeResponse(invokeRaw({
4025
+ return parseInvokeResponse(await invokeRaw({
3988
4026
  action: "curl",
3989
4027
  argv: options.argv
3990
4028
  }, invokeOptions));
@@ -67536,7 +67574,7 @@ async function runFileWithPromptRetry(relativePath, env, limit, halt, output, de
67536
67574
  limit,
67537
67575
  haltOnError: halt
67538
67576
  };
67539
- const response = await kulalaCore.runHttp(runOptions, { cwd });
67577
+ const response = isInteractiveTerminal() ? await withSpinner(`Running requests in file ${relativePath}`, () => kulalaCore.runHttp(runOptions, { cwd })) : await kulalaCore.runHttp(runOptions, { cwd });
67540
67578
  const promptItem = response.type === "responses" ? findFirstPromptItem(response) : void 0;
67541
67579
  if (!promptItem) {
67542
67580
  const final = mergeRunResponses(accumulated, response);
@@ -67567,7 +67605,10 @@ async function runFileWithPromptRetry(relativePath, env, limit, halt, output, de
67567
67605
  outputStreamed: shouldStreamOutput(output)
67568
67606
  };
67569
67607
  }
67570
- const continued = await kulalaCore.continueHttp({
67608
+ const continued = isInteractiveTerminal() ? await withSpinner(`Running requests in file ${relativePath}`, () => kulalaCore.continueHttp({
67609
+ promptId: promptItem.promptId,
67610
+ inputs
67611
+ }, { cwd })) : await kulalaCore.continueHttp({
67571
67612
  promptId: promptItem.promptId,
67572
67613
  inputs
67573
67614
  }, { cwd });
@@ -67665,7 +67706,7 @@ async function curl(argv, options = {}) {
67665
67706
  console.error(" kulala curl -H \"Accept: application/json\" https://echo.kulala.app/get");
67666
67707
  process.exit(1);
67667
67708
  }
67668
- const response = await kulalaCore.curl({ argv: curlArgv });
67709
+ const response = isInteractiveTerminal() ? await withSpinner("Running request", () => kulalaCore.curl({ argv: curlArgv })) : await kulalaCore.curl({ argv: curlArgv });
67669
67710
  const result = {
67670
67711
  filepath: formatCurlLabel(curlArgv),
67671
67712
  response
@@ -28,6 +28,51 @@ fs = __toESM(fs, 1);
28
28
  let path = require("path");
29
29
  path = __toESM(path, 1);
30
30
  let stream_promises = require("stream/promises");
31
+ //#region src/lib/spinner.ts
32
+ var SPINNER_FRAMES = [
33
+ "⠋",
34
+ "⠙",
35
+ "⠹",
36
+ "⠸",
37
+ "⠼",
38
+ "⠴",
39
+ "⠦",
40
+ "⠧",
41
+ "⠇",
42
+ "⠏"
43
+ ];
44
+ function isInteractiveTerminal() {
45
+ return process.stderr.isTTY === true;
46
+ }
47
+ function createSpinner() {
48
+ let timer;
49
+ let frame = 0;
50
+ let message = "";
51
+ const stop = () => {
52
+ if (timer) {
53
+ clearInterval(timer);
54
+ timer = void 0;
55
+ }
56
+ if (isInteractiveTerminal()) process.stderr.write("\r\x1B[K");
57
+ };
58
+ return {
59
+ start(msg) {
60
+ message = msg;
61
+ if (!isInteractiveTerminal()) {
62
+ console.error(message);
63
+ return;
64
+ }
65
+ const render = () => {
66
+ process.stderr.write(`\r${SPINNER_FRAMES[frame]} ${message}`);
67
+ frame = (frame + 1) % SPINNER_FRAMES.length;
68
+ };
69
+ render();
70
+ timer = setInterval(render, 80);
71
+ },
72
+ stop
73
+ };
74
+ }
75
+ //#endregion
31
76
  //#region src/versions/backend.ts
32
77
  var KULALA_CORE_VERSION = "0.24.4";
33
78
  //#endregion
@@ -72,52 +117,18 @@ function versionMatches() {
72
117
  function makeExecutable(filePath) {
73
118
  if (process.platform !== "win32") (0, fs.chmodSync)(filePath, 493);
74
119
  }
75
- var SPINNER_FRAMES = [
76
- "⠋",
77
- "⠙",
78
- "⠹",
79
- "⠸",
80
- "⠼",
81
- "⠴",
82
- "⠦",
83
- "⠧",
84
- "⠇",
85
- "⠏"
86
- ];
87
- function isInteractiveTerminal() {
88
- return process.stderr.isTTY === true;
89
- }
90
120
  function createDownloadProgress() {
91
- let timer;
92
- let frame = 0;
93
- let message = "";
94
- const clearLine = () => {
95
- if (timer) {
96
- clearInterval(timer);
97
- timer = void 0;
98
- }
99
- if (isInteractiveTerminal()) process.stderr.write("\r\x1B[K");
100
- };
121
+ const spinner = createSpinner();
101
122
  return {
102
- start(msg) {
103
- message = msg;
104
- if (!isInteractiveTerminal()) {
105
- console.error(message);
106
- return;
107
- }
108
- const render = () => {
109
- process.stderr.write(`\r${SPINNER_FRAMES[frame]} ${message}`);
110
- frame = (frame + 1) % SPINNER_FRAMES.length;
111
- };
112
- render();
113
- timer = setInterval(render, 80);
123
+ start(message) {
124
+ spinner.start(message);
114
125
  },
115
- succeed(msg) {
116
- clearLine();
117
- console.error(msg);
126
+ succeed(message) {
127
+ spinner.stop();
128
+ console.error(message);
118
129
  },
119
130
  fail() {
120
- clearLine();
131
+ spinner.stop();
121
132
  }
122
133
  };
123
134
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mistweaverco/kulala-cli",
3
- "version": "0.9.0",
3
+ "version": "0.10.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/mistweaverco/kulala-cli"