@mistweaverco/kulala-cli 0.4.0 → 0.5.0

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/README.md +57 -0
  2. package/dist/cli.cjs +64 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -151,6 +151,63 @@ export KULALA_CORE_PATH=/path/to/kulala-core/dist/kulala-core
151
151
  node dist/cli.cjs run file.http
152
152
  ```
153
153
 
154
+ ## Docker
155
+
156
+ ### Run docker interactively and pseudo-TTY:
157
+
158
+ Run interactively with a mounted `.http` file:
159
+
160
+ ```sh
161
+ docker run -it \
162
+ -v ${PWD}/test.http:/app/test.http \
163
+ ghcr.io/mistweaverco/kulala-cli:latest \
164
+ run test.http \
165
+ --name
166
+ ```
167
+
168
+ ### Run docker non-interactively, but with a pseudo-TTY:
169
+
170
+ Run one request by block name (`###` name) with
171
+ a mounted `.http` file and pseudo-TTY:
172
+
173
+ ```sh
174
+ docker run -t \
175
+ -v ${PWD}/test.http:/app/test.http \
176
+ ghcr.io/mistweaverco/kulala-cli:latest \
177
+ run test.http \
178
+ --name "My Request Name"
179
+ ```
180
+
181
+ ### Run docker non-interactively and without a pseudo-TTY; all requests in a directory:
182
+
183
+ Run all requests in a directory without
184
+ a pseudo-TTY (for example, in CI):
185
+
186
+ ```sh
187
+ docker run \
188
+ -v ${PWD}/http-files-dir:/app/http-files-dir \
189
+ ghcr.io/mistweaverco/kulala-cli:latest \
190
+ run ./http-files-dir
191
+ ```
192
+
193
+ ### Build docker and push to GitHub Container Registry:
194
+
195
+ #### Build and push to GitHub Container Registry:
196
+
197
+ ```sh
198
+ docker buildx build --push \
199
+ -t ghcr.io/mistweaverco/kulala-cli:latest \
200
+ -f Dockerfile .
201
+ ```
202
+
203
+ #### Build and push to Docker Hub:
204
+
205
+ ```sh
206
+ docker buildx build --push \
207
+ -t mistweaverco/kulala-cli:latest \
208
+ -f Dockerfile .
209
+ ```
210
+
154
211
  [logo]: https://raw.githubusercontent.com/mistweaverco/kulala-cli/main/assets/logo.svg
155
212
  [discord]: https://mistweaverco.com/discord
156
213
  [badge-discord]: https://mistweaverco.com/assets/badges/discord.svg
package/dist/cli.cjs CHANGED
@@ -46,7 +46,7 @@ let node_readline = require("node:readline");
46
46
  node_readline = __toESM(node_readline, 1);
47
47
  var package_default = {
48
48
  name: "@mistweaverco/kulala-cli",
49
- version: "0.4.0",
49
+ version: "0.5.0",
50
50
  repository: {
51
51
  "type": "git",
52
52
  "url": "https://github.com/mistweaverco/kulala-cli"
@@ -62834,6 +62834,59 @@ function highlightCode(text, language) {
62834
62834
  }
62835
62835
  }
62836
62836
  //#endregion
62837
+ //#region src/lib/output/binary.ts
62838
+ function isGhostty() {
62839
+ if (process.env.GHOSTTY_RESOURCES_DIR) return true;
62840
+ if ((process.env.TERM ?? "").includes("ghostty")) return true;
62841
+ return (process.env.TERM_PROGRAM ?? "").toLowerCase().includes("ghostty");
62842
+ }
62843
+ function isWezTerm() {
62844
+ if (process.env.WEZTERM_EXECUTABLE || process.env.WEZTERM_PANE) return true;
62845
+ return (process.env.TERM_PROGRAM ?? "").toLowerCase().includes("wezterm");
62846
+ }
62847
+ function detectTerminalImageProtocol() {
62848
+ if (process.env.KITTY_WINDOW_ID || (process.env.TERM ?? "").includes("xterm-kitty")) return "kitty";
62849
+ if (isGhostty()) return "ghostty";
62850
+ if (isWezTerm()) return "wezterm";
62851
+ if (process.env.TERM_PROGRAM === "iTerm.app" || process.env.ITERM_SESSION_ID) return "iterm2";
62852
+ return null;
62853
+ }
62854
+ function isBinaryBody(body) {
62855
+ return body?.type === "binary";
62856
+ }
62857
+ function isImageBody(body) {
62858
+ if (!body || body.type !== "text" && body.type !== "binary") return false;
62859
+ return (body.mediaType?.toLowerCase() ?? "").startsWith("image/");
62860
+ }
62861
+ function formatByteSize(bytes) {
62862
+ if (!Number.isFinite(bytes) || bytes < 0) return `${bytes} B`;
62863
+ if (bytes < 1024) return `${bytes} B`;
62864
+ const kb = bytes / 1024;
62865
+ if (kb < 1024) return `${kb.toFixed(1)} KB`;
62866
+ return `${(kb / 1024).toFixed(1)} MB`;
62867
+ }
62868
+ function kittyImageEscape(base64) {
62869
+ const CHUNK = 4096;
62870
+ let out = "";
62871
+ for (let i = 0; i < base64.length; i += CHUNK) {
62872
+ const chunk = base64.slice(i, i + CHUNK);
62873
+ const more = i + CHUNK < base64.length ? 1 : 0;
62874
+ out += `\u001b_Ga=T,t=d,m=${more};${chunk}\u001b\\`;
62875
+ }
62876
+ return out;
62877
+ }
62878
+ function iterm2ImageEscape(base64, byteLength) {
62879
+ return `\u001b]1337;File=inline=1;size=${byteLength};width=auto;height=auto;preserveAspectRatio=1:${base64}\u0007`;
62880
+ }
62881
+ function renderImageInline(body) {
62882
+ const protocol = detectTerminalImageProtocol();
62883
+ if (!protocol) return null;
62884
+ if (body.encoding !== "base64") return null;
62885
+ if (protocol === "kitty" || protocol === "ghostty") return kittyImageEscape(body.content);
62886
+ if (protocol === "iterm2" || protocol === "wezterm") return iterm2ImageEscape(body.content, body.byteLength);
62887
+ return null;
62888
+ }
62889
+ //#endregion
62837
62890
  //#region src/lib/output/shared.ts
62838
62891
  function isPromptResponse(item) {
62839
62892
  return "prompt" in item && item.prompt === true;
@@ -62853,11 +62906,13 @@ function isSuccessResponse(item) {
62853
62906
  function responseBodyText(body) {
62854
62907
  if (!body) return "";
62855
62908
  if (body.type === "json") return body.formatted ?? JSON.stringify(body.content, null, 2);
62909
+ if (body.type === "binary") return "";
62856
62910
  return body.content;
62857
62911
  }
62858
62912
  function responseBodyLanguage(body) {
62859
62913
  if (!body) return "text";
62860
62914
  if (body.type === "json") return "json";
62915
+ if (body.type === "binary") return "text";
62861
62916
  const mediaType = body.mediaType?.toLowerCase() ?? "";
62862
62917
  if (mediaType.includes("json")) return "json";
62863
62918
  if (mediaType.includes("xml")) return "xml";
@@ -63044,6 +63099,14 @@ function formatHeaders(headers) {
63044
63099
  return Object.entries(headers).map(([name, value]) => import_picocolors.default.dim(`${name}: ${value}`)).join("\n");
63045
63100
  }
63046
63101
  function formatBody(body) {
63102
+ if (isBinaryBody(body)) {
63103
+ const mediaType = body.mediaType ?? "application/octet-stream";
63104
+ if (isImageBody(body)) {
63105
+ const rendered = renderImageInline(body);
63106
+ if (rendered) return rendered;
63107
+ }
63108
+ return import_picocolors.default.dim(`Binary response body omitted (${mediaType}, ${formatByteSize(body.byteLength)})`);
63109
+ }
63047
63110
  const text = responseBodyText(body);
63048
63111
  if (!text) return "";
63049
63112
  return highlightCode(text, responseBodyLanguage(body));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mistweaverco/kulala-cli",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/mistweaverco/kulala-cli"