@wrongstack/tui 0.276.3 → 0.277.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.
- package/dist/index.js +58 -3
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -45,6 +45,17 @@ function softColor(color) {
|
|
|
45
45
|
if (!color) return color;
|
|
46
46
|
return pastel[color] ?? color;
|
|
47
47
|
}
|
|
48
|
+
function detectSupportsBackground(env = process.env, isTTY = process.stdout.isTTY ?? false) {
|
|
49
|
+
if (!isTTY) return false;
|
|
50
|
+
if (typeof env.NO_COLOR === "string" && env.NO_COLOR !== "") return false;
|
|
51
|
+
const colorterm = env.COLORTERM ?? "";
|
|
52
|
+
if (/^(truecolor|24bit)$/i.test(colorterm)) return true;
|
|
53
|
+
const term = env.TERM ?? "";
|
|
54
|
+
if (/truecolor|24bit/i.test(term)) return true;
|
|
55
|
+
if (/256(color)?/i.test(term)) return true;
|
|
56
|
+
if (colorterm !== "" && colorterm !== "false") return true;
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
48
59
|
var theme = Object.freeze({
|
|
49
60
|
accent: pastel.cyan,
|
|
50
61
|
user: pastel.yellow,
|
|
@@ -66,7 +77,11 @@ var theme = Object.freeze({
|
|
|
66
77
|
},
|
|
67
78
|
// Diff blocks render dark text on a pastel wash (see DiffBlock).
|
|
68
79
|
diffAddBg: pastel.green,
|
|
69
|
-
diffDelBg: pastel.red
|
|
80
|
+
diffDelBg: pastel.red,
|
|
81
|
+
// Whether the host terminal can render truecolor backgrounds. Diff blocks
|
|
82
|
+
// downgrade to marker-only rendering when this is false (e.g. `TERM=xterm`,
|
|
83
|
+
// `NO_COLOR=1`, captured/piped output).
|
|
84
|
+
supportsBackground: detectSupportsBackground()
|
|
70
85
|
});
|
|
71
86
|
var colorProps = (color, backgroundColor) => {
|
|
72
87
|
const c = softColor(color);
|
|
@@ -4250,11 +4265,46 @@ function formatToolOutput(toolName, output, ok, _outputBytes, outputLines) {
|
|
|
4250
4265
|
if (json && typeof json === "object") {
|
|
4251
4266
|
const o = json;
|
|
4252
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"]);
|
|
4253
4298
|
const stdout = stringOf(o["stdout"]) ?? "";
|
|
4254
4299
|
const stderr = stringOf(o["stderr"]) ?? "";
|
|
4255
4300
|
const stdoutLines = countLines(stdout);
|
|
4256
4301
|
const stderrLines = countLines(stderr);
|
|
4257
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
|
+
}
|
|
4258
4308
|
if (exit !== void 0) head.push(`exit ${exit}`);
|
|
4259
4309
|
const lineParts = [];
|
|
4260
4310
|
if (stdoutLines > 0) lineParts.push(`${stdoutLines} out`);
|
|
@@ -4262,6 +4312,11 @@ function formatToolOutput(toolName, output, ok, _outputBytes, outputLines) {
|
|
|
4262
4312
|
if (lineParts.length > 0) head.push(lineParts.join(" \xB7 "));
|
|
4263
4313
|
const lines = [];
|
|
4264
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
|
+
}
|
|
4265
4320
|
const stdoutPreview = firstNonEmpty(stdout);
|
|
4266
4321
|
const stderrPreview = firstNonEmpty(stderr);
|
|
4267
4322
|
if (stdoutPreview) lines.push(`"${truncMid(stdoutPreview, 70)}"`);
|
|
@@ -6206,7 +6261,7 @@ var Entry = React5.memo(function Entry2({
|
|
|
6206
6261
|
);
|
|
6207
6262
|
return summaryLine ? /* @__PURE__ */ jsx(Text, { dimColor: true, italic: true, children: summaryLine }) : null;
|
|
6208
6263
|
})(),
|
|
6209
|
-
multiDiffs.map((item) => /* @__PURE__ */ jsx(DiffFileBlock, { path: item.path, preview: item.preview, useColor:
|
|
6264
|
+
multiDiffs.map((item) => /* @__PURE__ */ jsx(DiffFileBlock, { path: item.path, preview: item.preview, useColor: theme.supportsBackground }, item.path))
|
|
6210
6265
|
] }) : entry.resultRenderMode !== "simple" && diff ? /* @__PURE__ */ jsx(
|
|
6211
6266
|
DiffBlock,
|
|
6212
6267
|
{
|
|
@@ -6216,7 +6271,7 @@ var Entry = React5.memo(function Entry2({
|
|
|
6216
6271
|
removed: diff.removed,
|
|
6217
6272
|
hiddenAdded: diff.hiddenAdded,
|
|
6218
6273
|
hiddenRemoved: diff.hiddenRemoved,
|
|
6219
|
-
useColor:
|
|
6274
|
+
useColor: theme.supportsBackground
|
|
6220
6275
|
}
|
|
6221
6276
|
) : null
|
|
6222
6277
|
] });
|