@compilr-dev/sdk 0.9.3 → 0.9.5
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/compressors/bash.js +39 -33
- package/package.json +1 -1
package/dist/compressors/bash.js
CHANGED
|
@@ -36,9 +36,11 @@ export function compressBashOutput(command, stdout) {
|
|
|
36
36
|
// Direct linters
|
|
37
37
|
if (cmd.match(/^(eslint|tsc|ruff|cargo\s+clippy|golangci-lint)/))
|
|
38
38
|
return compressLintOutput(stdout);
|
|
39
|
-
// ls
|
|
40
|
-
if (cmd.match(/^
|
|
41
|
-
return
|
|
39
|
+
// ls (strip metadata, keep filenames)
|
|
40
|
+
if (cmd.match(/^ls\b/))
|
|
41
|
+
return compressLsOutput(stdout);
|
|
42
|
+
// find / fd — already minimal (just paths), pass through unchanged
|
|
43
|
+
// tree — already structured, pass through unchanged
|
|
42
44
|
// curl / wget (HTTP responses)
|
|
43
45
|
if (cmd.match(/^(curl|wget)\b/))
|
|
44
46
|
return compressCurlOutput(stdout);
|
|
@@ -173,7 +175,7 @@ function compressNpmInstall(output) {
|
|
|
173
175
|
// ─── Test Output ────────────────────────────────────────────────────────────
|
|
174
176
|
function compressTestOutput(output) {
|
|
175
177
|
const lines = output.split('\n');
|
|
176
|
-
if (lines.length <=
|
|
178
|
+
if (lines.length <= 15)
|
|
177
179
|
return output;
|
|
178
180
|
const result = [];
|
|
179
181
|
let inFailure = false;
|
|
@@ -181,11 +183,15 @@ function compressTestOutput(output) {
|
|
|
181
183
|
const maxFailureLines = 20;
|
|
182
184
|
for (const line of lines) {
|
|
183
185
|
const t = line.trim();
|
|
184
|
-
// Always keep: summary lines,
|
|
185
|
-
if (t.match(/^(Tests
|
|
186
|
+
// Always keep: summary lines, suite headers, failure markers
|
|
187
|
+
if (t.match(/^(Tests?:|Test Suites?:|FAIL |PASS |ERROR|✗|✘|×|●|Ran \d|passed|failed|\d+ passing|\d+ failing|Test Files|Duration)/i)) {
|
|
186
188
|
result.push(line);
|
|
187
189
|
continue;
|
|
188
190
|
}
|
|
191
|
+
// Skip passing test lines (✓ checkmarks) — these are the bulk of output
|
|
192
|
+
if (t.match(/^✓|^✔|^\s*✓|^\s*✔/)) {
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
189
195
|
// Keep failure context (limited)
|
|
190
196
|
if (t.match(/^(FAIL|✗|✘|×|Error:|AssertionError|Expected|Received|at\s)/i) || inFailure) {
|
|
191
197
|
if (t.match(/^(FAIL|✗|✘|×)/i)) {
|
|
@@ -213,7 +219,7 @@ function compressTestOutput(output) {
|
|
|
213
219
|
// ─── Lint Output ────────────────────────────────────────────────────────────
|
|
214
220
|
function compressLintOutput(output) {
|
|
215
221
|
const lines = output.split('\n');
|
|
216
|
-
if (lines.length <=
|
|
222
|
+
if (lines.length <= 15)
|
|
217
223
|
return output;
|
|
218
224
|
// Group errors by rule, cap per rule
|
|
219
225
|
const errors = [];
|
|
@@ -288,41 +294,41 @@ function compressBuildOutput(output) {
|
|
|
288
294
|
}
|
|
289
295
|
return output;
|
|
290
296
|
}
|
|
291
|
-
// ───
|
|
292
|
-
function
|
|
293
|
-
const lines = output.split('\n')
|
|
294
|
-
if (lines.length <=
|
|
297
|
+
// ─── ls Output (strip metadata, keep filenames) ────────────────────────────
|
|
298
|
+
function compressLsOutput(output) {
|
|
299
|
+
const lines = output.split('\n');
|
|
300
|
+
if (lines.length <= 10)
|
|
295
301
|
return output;
|
|
296
|
-
//
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
groups.set(dir, arr);
|
|
304
|
-
}
|
|
305
|
-
const maxPerDir = 5;
|
|
302
|
+
// Detect ls -l style output (permissions + metadata + filename)
|
|
303
|
+
// e.g., "drwxr-xr-x@ 15 scozzola staff 480 Apr 11 16:16 .compilr"
|
|
304
|
+
const lsLongPattern = /^[dlrwx\-@+.]{10,}\s+\d+\s+\S+\s+\S+\s+\d+\s+\w+\s+\d+\s+[\d:]+\s+(.+)$/;
|
|
305
|
+
const hasMetadata = lines.some((l) => lsLongPattern.test(l.trim()));
|
|
306
|
+
if (!hasMetadata)
|
|
307
|
+
return output; // Plain ls or unknown format — pass through
|
|
308
|
+
// Strip metadata, keep only filenames with dir/file indicator
|
|
306
309
|
const result = [];
|
|
307
|
-
for (const
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
310
|
+
for (const line of lines) {
|
|
311
|
+
const trimmed = line.trim();
|
|
312
|
+
if (!trimmed)
|
|
313
|
+
continue;
|
|
314
|
+
if (trimmed.startsWith('total '))
|
|
315
|
+
continue; // Skip "total N" line
|
|
316
|
+
const match = trimmed.match(lsLongPattern);
|
|
317
|
+
if (match) {
|
|
318
|
+
const name = match[1];
|
|
319
|
+
const isDir = trimmed.startsWith('d');
|
|
320
|
+
result.push(isDir ? `${name}/` : name);
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
result.push(trimmed); // Keep unrecognized lines as-is
|
|
315
324
|
}
|
|
316
|
-
}
|
|
317
|
-
if (result.length < lines.length) {
|
|
318
|
-
result.push(`\n(${String(lines.length)} total entries, showing ${String(result.length)} lines)`);
|
|
319
325
|
}
|
|
320
326
|
return result.join('\n');
|
|
321
327
|
}
|
|
322
328
|
// ─── curl / wget ────────────────────────────────────────────────────────────
|
|
323
329
|
function compressCurlOutput(output) {
|
|
324
330
|
const lines = output.split('\n');
|
|
325
|
-
if (lines.length <=
|
|
331
|
+
if (lines.length <= 10)
|
|
326
332
|
return output;
|
|
327
333
|
// Strip progress bars (curl -# output), keep headers and body
|
|
328
334
|
const kept = lines.filter((l) => {
|