@wrongstack/tui 0.276.4 → 0.277.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/index.js CHANGED
@@ -4265,11 +4265,46 @@ function formatToolOutput(toolName, output, ok, _outputBytes, outputLines) {
4265
4265
  if (json && typeof json === "object") {
4266
4266
  const o = json;
4267
4267
  const exit = numOf(o["exit_code"]) ?? numOf(o["exitCode"]);
4268
+ const stdout = stringOf(o["stdout"]) ?? stringOf(o["output"]) ?? "";
4269
+ const stderr = stringOf(o["stderr"]) ?? stringOf(o["error"]) ?? "";
4270
+ const timedOut = o["timed_out"] === true || o["timedOut"] === true;
4271
+ const stdoutLines = countLines(stdout);
4272
+ const stderrLines = countLines(stderr);
4273
+ const head = [];
4274
+ if (exit !== void 0) head.push(`exit ${exit}`);
4275
+ if (timedOut) head.push("timed out");
4276
+ const lineParts = [];
4277
+ if (stdoutLines > 0) lineParts.push(`${stdoutLines} out`);
4278
+ if (stderrLines > 0) lineParts.push(`${stderrLines} err`);
4279
+ if (lineParts.length > 0) head.push(lineParts.join(" \xB7 "));
4280
+ const lines = [];
4281
+ if (head.length > 0) lines.push(head.join(" \xB7 "));
4282
+ const stdoutPreview = firstNonEmpty(stdout);
4283
+ const stderrPreview = firstNonEmpty(stderr);
4284
+ if (stdoutPreview) lines.push(`"${truncMid(stdoutPreview, 70)}"`);
4285
+ if (stderrPreview && stderrPreview !== stdoutPreview) {
4286
+ lines.push(`! "${truncMid(stderrPreview, 70)}"`);
4287
+ }
4288
+ if (lines.length > 0) return lines;
4289
+ }
4290
+ }
4291
+ if (toolName === "exec") {
4292
+ if (json && typeof json === "object") {
4293
+ const o = json;
4294
+ const danger = o["danger"];
4295
+ const level = danger && typeof danger === "object" ? danger["level"] : void 0;
4296
+ const reasons = danger && typeof danger === "object" ? danger["reasons"] : void 0;
4297
+ const exit = numOf(o["exit_code"]) ?? numOf(o["exitCode"]);
4268
4298
  const stdout = stringOf(o["stdout"]) ?? "";
4269
4299
  const stderr = stringOf(o["stderr"]) ?? "";
4270
4300
  const stdoutLines = countLines(stdout);
4271
4301
  const stderrLines = countLines(stderr);
4272
4302
  const head = [];
4303
+ if (level === "destructive" || level === "caution") {
4304
+ const chip = level === "destructive" ? "\u26A0 DESTRUCTIVE" : "! CAUTION";
4305
+ const reasonText = Array.isArray(reasons) && reasons.length > 0 ? String(reasons[0]) : level === "destructive" ? "destructive command" : "caution-level command";
4306
+ head.push(`${chip} ${reasonText}`);
4307
+ }
4273
4308
  if (exit !== void 0) head.push(`exit ${exit}`);
4274
4309
  const lineParts = [];
4275
4310
  if (stdoutLines > 0) lineParts.push(`${stdoutLines} out`);
@@ -4277,6 +4312,11 @@ function formatToolOutput(toolName, output, ok, _outputBytes, outputLines) {
4277
4312
  if (lineParts.length > 0) head.push(lineParts.join(" \xB7 "));
4278
4313
  const lines = [];
4279
4314
  if (head.length > 0) lines.push(head.join(" \xB7 "));
4315
+ if (Array.isArray(reasons) && reasons.length > 1) {
4316
+ for (let i = 1; i < reasons.length; i++) {
4317
+ lines.push(` \xB7 ${String(reasons[i])}`);
4318
+ }
4319
+ }
4280
4320
  const stdoutPreview = firstNonEmpty(stdout);
4281
4321
  const stderrPreview = firstNonEmpty(stderr);
4282
4322
  if (stdoutPreview) lines.push(`"${truncMid(stdoutPreview, 70)}"`);