@hasna/terminal 3.3.6 → 3.3.7
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/compression.js +6 -0
- package/package.json +1 -1
- package/src/compression.ts +7 -0
package/dist/compression.js
CHANGED
|
@@ -64,6 +64,12 @@ function smartTruncate(text, maxTokens) {
|
|
|
64
64
|
export function compress(command, output, options = {}) {
|
|
65
65
|
const { maxTokens, stripAnsi: doStrip = true } = options;
|
|
66
66
|
const originalTokens = estimateTokens(output);
|
|
67
|
+
// Short output — no-op, skip all processing
|
|
68
|
+
if (output.split("\n").length <= 20 && !maxTokens) {
|
|
69
|
+
const clean = doStrip ? stripAnsi(output) : output;
|
|
70
|
+
const cleanTokens = estimateTokens(clean);
|
|
71
|
+
return { content: clean, originalTokens, compressedTokens: cleanTokens, tokensSaved: Math.max(0, originalTokens - cleanTokens), savingsPercent: 0 };
|
|
72
|
+
}
|
|
67
73
|
// Step 1: Strip ANSI codes
|
|
68
74
|
let text = doStrip ? stripAnsi(output) : output;
|
|
69
75
|
// Step 2: Deduplicate similar lines
|
package/package.json
CHANGED
package/src/compression.ts
CHANGED
|
@@ -89,6 +89,13 @@ export function compress(command: string, output: string, options: CompressOptio
|
|
|
89
89
|
const { maxTokens, stripAnsi: doStrip = true } = options;
|
|
90
90
|
const originalTokens = estimateTokens(output);
|
|
91
91
|
|
|
92
|
+
// Short output — no-op, skip all processing
|
|
93
|
+
if (output.split("\n").length <= 20 && !maxTokens) {
|
|
94
|
+
const clean = doStrip ? stripAnsi(output) : output;
|
|
95
|
+
const cleanTokens = estimateTokens(clean);
|
|
96
|
+
return { content: clean, originalTokens, compressedTokens: cleanTokens, tokensSaved: Math.max(0, originalTokens - cleanTokens), savingsPercent: 0 };
|
|
97
|
+
}
|
|
98
|
+
|
|
92
99
|
// Step 1: Strip ANSI codes
|
|
93
100
|
let text = doStrip ? stripAnsi(output) : output;
|
|
94
101
|
|