@paretools/python 0.21.0 → 0.22.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/lib/formatters.d.ts +95 -10
- package/dist/lib/formatters.d.ts.map +1 -1
- package/dist/lib/formatters.js +355 -39
- package/dist/lib/formatters.js.map +1 -1
- package/dist/lib/parsers.d.ts +11 -5
- package/dist/lib/parsers.d.ts.map +1 -1
- package/dist/lib/parsers.js +141 -36
- package/dist/lib/parsers.js.map +1 -1
- package/dist/lib/python-runner.d.ts +1 -1
- package/dist/lib/python-runner.d.ts.map +1 -1
- package/dist/lib/python-runner.js +2 -2
- package/dist/lib/python-runner.js.map +1 -1
- package/dist/schemas/index.d.ts +40 -3
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +75 -2
- package/dist/schemas/index.js.map +1 -1
- package/dist/tools/mypy.js +1 -1
- package/dist/tools/mypy.js.map +1 -1
- package/dist/tools/pip-audit.js +1 -1
- package/dist/tools/pip-audit.js.map +1 -1
- package/dist/tools/pytest.d.ts.map +1 -1
- package/dist/tools/pytest.js +34 -3
- package/dist/tools/pytest.js.map +1 -1
- package/package.json +5 -5
package/dist/lib/formatters.js
CHANGED
|
@@ -1,10 +1,28 @@
|
|
|
1
|
+
import { compactStreamFields } from "@paretools/shared";
|
|
2
|
+
/** Maximum diagnostic entries kept in compact mode (mypy/ruff). */
|
|
3
|
+
const COMPACT_MAX_DIAGNOSTICS = 20;
|
|
4
|
+
/** Maximum vulnerability entries kept in compact mode (pip-audit). */
|
|
5
|
+
const COMPACT_MAX_VULNS = 10;
|
|
6
|
+
/** Maximum characters of a vulnerability description kept in compact mode. */
|
|
7
|
+
const COMPACT_VULN_DESCRIPTION_MAX = 140;
|
|
8
|
+
/** Maximum package/artifact/version entries kept in compact mode (pip-list/poetry/pyenv). */
|
|
9
|
+
const COMPACT_MAX_ENTRIES = 50;
|
|
10
|
+
/** Maximum message lines kept in compact mode (poetry). */
|
|
11
|
+
const COMPACT_MAX_MESSAGES = 20;
|
|
1
12
|
/** Formats structured pip install results into a human-readable summary of installed packages. */
|
|
2
13
|
export function formatPipInstall(data) {
|
|
3
14
|
const total = (data.installed ?? []).length;
|
|
4
|
-
if (data.alreadySatisfied && total === 0)
|
|
15
|
+
if (data.alreadySatisfied && total === 0 && data.success) {
|
|
5
16
|
return "All requirements already satisfied.";
|
|
6
|
-
|
|
7
|
-
|
|
17
|
+
}
|
|
18
|
+
if (!data.success) {
|
|
19
|
+
const lines = [
|
|
20
|
+
`pip install failed${data.exitCode !== undefined ? ` (exit code ${data.exitCode})` : ""}.`,
|
|
21
|
+
];
|
|
22
|
+
if (data.error)
|
|
23
|
+
lines.push(data.error);
|
|
24
|
+
return lines.join("\n");
|
|
25
|
+
}
|
|
8
26
|
const verb = data.dryRun ? "Would install" : "Installed";
|
|
9
27
|
const lines = [`${verb} ${total} packages:`];
|
|
10
28
|
for (const pkg of data.installed ?? []) {
|
|
@@ -15,6 +33,9 @@ export function formatPipInstall(data) {
|
|
|
15
33
|
/** Formats structured mypy type-check results into a human-readable diagnostic summary. */
|
|
16
34
|
export function formatMypy(data) {
|
|
17
35
|
const diagnostics = data.diagnostics ?? [];
|
|
36
|
+
if (data.error && diagnostics.length === 0) {
|
|
37
|
+
return [`mypy: run failed (exit code ${data.exitCode ?? "?"}).`, data.error].join("\n");
|
|
38
|
+
}
|
|
18
39
|
if (data.success && diagnostics.length === 0)
|
|
19
40
|
return "mypy: no errors found.";
|
|
20
41
|
const errors = diagnostics.filter((d) => d.severity === "error").length;
|
|
@@ -26,12 +47,17 @@ export function formatMypy(data) {
|
|
|
26
47
|
const code = d.code ? ` [${d.code}]` : "";
|
|
27
48
|
lines.push(` ${d.file}:${d.line}${col} ${d.severity}: ${d.message}${code}`);
|
|
28
49
|
}
|
|
50
|
+
if (data.error)
|
|
51
|
+
lines.push(data.error);
|
|
29
52
|
return lines.join("\n");
|
|
30
53
|
}
|
|
31
54
|
/** Formats structured ruff lint results into a human-readable diagnostic listing. */
|
|
32
55
|
export function formatRuff(data) {
|
|
33
56
|
const diagnostics = data.diagnostics ?? [];
|
|
34
57
|
const total = diagnostics.length;
|
|
58
|
+
if (data.error && total === 0) {
|
|
59
|
+
return [`ruff: run failed (exit code ${data.exitCode ?? "?"}).`, data.error].join("\n");
|
|
60
|
+
}
|
|
35
61
|
if (total === 0)
|
|
36
62
|
return "ruff: no issues found.";
|
|
37
63
|
const fixable = diagnostics.filter((d) => d.fixable).length;
|
|
@@ -47,6 +73,12 @@ export function formatRuff(data) {
|
|
|
47
73
|
export function formatPipAudit(data) {
|
|
48
74
|
const vulns = data.vulnerabilities ?? [];
|
|
49
75
|
const total = vulns.length;
|
|
76
|
+
if (data.error && total === 0) {
|
|
77
|
+
return [
|
|
78
|
+
`pip-audit: audit failed (exit code ${data.exitCode ?? "?"}) — result is NOT a clean scan.`,
|
|
79
|
+
data.error,
|
|
80
|
+
].join("\n");
|
|
81
|
+
}
|
|
50
82
|
if (total === 0)
|
|
51
83
|
return "No vulnerabilities found.";
|
|
52
84
|
const lines = [`${total} vulnerabilities:`];
|
|
@@ -61,8 +93,14 @@ export function formatPipAudit(data) {
|
|
|
61
93
|
/** Formats structured pytest results into a human-readable test summary. */
|
|
62
94
|
export function formatPytest(data) {
|
|
63
95
|
const total = data.passed + data.failed + data.errors + data.skipped;
|
|
64
|
-
if (total === 0)
|
|
65
|
-
|
|
96
|
+
if (total === 0) {
|
|
97
|
+
if (data.success)
|
|
98
|
+
return "pytest: no tests collected.";
|
|
99
|
+
const lines = [`pytest: run failed with no test results (exit code ${data.exitCode ?? "?"}).`];
|
|
100
|
+
if (data.errorOutput)
|
|
101
|
+
lines.push(data.errorOutput);
|
|
102
|
+
return lines.join("\n");
|
|
103
|
+
}
|
|
66
104
|
const parts = [];
|
|
67
105
|
if (data.passed > 0)
|
|
68
106
|
parts.push(`${data.passed} passed`);
|
|
@@ -78,6 +116,9 @@ export function formatPytest(data) {
|
|
|
78
116
|
for (const f of data.failures ?? []) {
|
|
79
117
|
lines.push(` FAILED ${f.test}: ${f.message}`);
|
|
80
118
|
}
|
|
119
|
+
if (data.errorOutput) {
|
|
120
|
+
lines.push(data.errorOutput);
|
|
121
|
+
}
|
|
81
122
|
return lines.join("\n");
|
|
82
123
|
}
|
|
83
124
|
/** Formats structured uv install results into a human-readable summary. */
|
|
@@ -157,7 +198,7 @@ export function formatBlack(data) {
|
|
|
157
198
|
return lines.join("\n");
|
|
158
199
|
}
|
|
159
200
|
export function compactPytestMap(data) {
|
|
160
|
-
|
|
201
|
+
const compact = {
|
|
161
202
|
success: data.success,
|
|
162
203
|
passed: data.passed,
|
|
163
204
|
failed: data.failed,
|
|
@@ -166,11 +207,22 @@ export function compactPytestMap(data) {
|
|
|
166
207
|
warnings: data.warnings,
|
|
167
208
|
failedTests: (data.failures ?? []).map((f) => f.test),
|
|
168
209
|
};
|
|
210
|
+
if (data.exitCode !== undefined)
|
|
211
|
+
compact.exitCode = data.exitCode;
|
|
212
|
+
if (data.errorOutput !== undefined)
|
|
213
|
+
compact.errorOutput = data.errorOutput;
|
|
214
|
+
return compact;
|
|
169
215
|
}
|
|
170
216
|
export function formatPytestCompact(data) {
|
|
171
217
|
const total = data.passed + data.failed + data.errors + data.skipped;
|
|
172
|
-
if (total === 0)
|
|
173
|
-
|
|
218
|
+
if (total === 0) {
|
|
219
|
+
if (data.success)
|
|
220
|
+
return "pytest: no tests collected.";
|
|
221
|
+
const lines = [`pytest: run failed with no test results (exit code ${data.exitCode ?? "?"}).`];
|
|
222
|
+
if (data.errorOutput)
|
|
223
|
+
lines.push(data.errorOutput);
|
|
224
|
+
return lines.join("\n");
|
|
225
|
+
}
|
|
174
226
|
const parts = [];
|
|
175
227
|
if (data.passed > 0)
|
|
176
228
|
parts.push(`${data.passed} passed`);
|
|
@@ -186,29 +238,97 @@ export function formatPytestCompact(data) {
|
|
|
186
238
|
for (const t of data.failedTests) {
|
|
187
239
|
lines.push(` FAILED ${t}`);
|
|
188
240
|
}
|
|
241
|
+
if (data.errorOutput) {
|
|
242
|
+
lines.push(data.errorOutput);
|
|
243
|
+
}
|
|
189
244
|
return lines.join("\n");
|
|
190
245
|
}
|
|
191
246
|
export function compactMypyMap(data) {
|
|
192
|
-
|
|
247
|
+
const diagnostics = data.diagnostics ?? [];
|
|
248
|
+
const compact = {
|
|
193
249
|
success: data.success,
|
|
250
|
+
errorCount: diagnostics.filter((d) => d.severity === "error").length,
|
|
251
|
+
warningCount: diagnostics.filter((d) => d.severity === "warning").length,
|
|
194
252
|
};
|
|
253
|
+
if (diagnostics.length > 0) {
|
|
254
|
+
compact.diagnostics = diagnostics.slice(0, COMPACT_MAX_DIAGNOSTICS).map((d) => ({
|
|
255
|
+
file: d.file,
|
|
256
|
+
line: d.line,
|
|
257
|
+
severity: d.severity,
|
|
258
|
+
message: d.message,
|
|
259
|
+
...(d.code ? { code: d.code } : {}),
|
|
260
|
+
}));
|
|
261
|
+
if (diagnostics.length > COMPACT_MAX_DIAGNOSTICS)
|
|
262
|
+
compact.truncated = true;
|
|
263
|
+
}
|
|
264
|
+
if (data.error !== undefined)
|
|
265
|
+
compact.error = data.error;
|
|
266
|
+
if (data.exitCode !== undefined)
|
|
267
|
+
compact.exitCode = data.exitCode;
|
|
268
|
+
return compact;
|
|
195
269
|
}
|
|
196
270
|
export function formatMypyCompact(data) {
|
|
197
|
-
|
|
271
|
+
const diagnostics = data.diagnostics ?? [];
|
|
272
|
+
if (data.error && diagnostics.length === 0) {
|
|
273
|
+
return [`mypy: run failed (exit code ${data.exitCode ?? "?"}).`, data.error].join("\n");
|
|
274
|
+
}
|
|
275
|
+
if (data.success && diagnostics.length === 0)
|
|
198
276
|
return "mypy: no errors found.";
|
|
199
|
-
|
|
277
|
+
const lines = [`mypy: ${data.errorCount} errors, ${data.warningCount} warnings`];
|
|
278
|
+
for (const d of diagnostics) {
|
|
279
|
+
const code = d.code ? ` [${d.code}]` : "";
|
|
280
|
+
lines.push(` ${d.file}:${d.line} ${d.severity}: ${d.message}${code}`);
|
|
281
|
+
}
|
|
282
|
+
if (data.truncated) {
|
|
283
|
+
lines.push(" … more diagnostics omitted (run with compact:false for the full list)");
|
|
284
|
+
}
|
|
285
|
+
if (data.error)
|
|
286
|
+
lines.push(data.error);
|
|
287
|
+
return lines.join("\n");
|
|
200
288
|
}
|
|
201
289
|
export function compactRuffMap(data) {
|
|
202
|
-
|
|
290
|
+
const diagnostics = data.diagnostics ?? [];
|
|
291
|
+
const compact = {
|
|
203
292
|
success: data.success,
|
|
293
|
+
total: diagnostics.length,
|
|
294
|
+
fixableCount: diagnostics.filter((d) => d.fixable).length,
|
|
204
295
|
fixedCount: data.fixedCount,
|
|
205
296
|
};
|
|
297
|
+
if (diagnostics.length > 0) {
|
|
298
|
+
compact.diagnostics = diagnostics.slice(0, COMPACT_MAX_DIAGNOSTICS).map((d) => ({
|
|
299
|
+
file: d.file,
|
|
300
|
+
line: d.line,
|
|
301
|
+
column: d.column,
|
|
302
|
+
code: d.code,
|
|
303
|
+
message: d.message,
|
|
304
|
+
fixable: d.fixable,
|
|
305
|
+
}));
|
|
306
|
+
if (diagnostics.length > COMPACT_MAX_DIAGNOSTICS)
|
|
307
|
+
compact.truncated = true;
|
|
308
|
+
}
|
|
309
|
+
if (data.error !== undefined)
|
|
310
|
+
compact.error = data.error;
|
|
311
|
+
if (data.exitCode !== undefined)
|
|
312
|
+
compact.exitCode = data.exitCode;
|
|
313
|
+
return compact;
|
|
206
314
|
}
|
|
207
315
|
export function formatRuffCompact(data) {
|
|
208
|
-
if (data.
|
|
316
|
+
if (data.error && data.total === 0) {
|
|
317
|
+
return [`ruff: run failed (exit code ${data.exitCode ?? "?"}).`, data.error].join("\n");
|
|
318
|
+
}
|
|
319
|
+
if (data.total === 0 && !data.fixedCount)
|
|
209
320
|
return "ruff: no issues found.";
|
|
210
321
|
const fixedPart = data.fixedCount !== undefined ? `, ${data.fixedCount} fixed` : "";
|
|
211
|
-
|
|
322
|
+
const lines = [`ruff: ${data.total} issues (${data.fixableCount} fixable${fixedPart})`];
|
|
323
|
+
for (const d of data.diagnostics ?? []) {
|
|
324
|
+
lines.push(` ${d.file}:${d.line}:${d.column} ${d.code}: ${d.message}`);
|
|
325
|
+
}
|
|
326
|
+
if (data.truncated) {
|
|
327
|
+
lines.push(` … ${data.total - (data.diagnostics ?? []).length} more issues omitted (run with compact:false for the full list)`);
|
|
328
|
+
}
|
|
329
|
+
if (data.error)
|
|
330
|
+
lines.push(data.error);
|
|
331
|
+
return lines.join("\n");
|
|
212
332
|
}
|
|
213
333
|
export function compactBlackMap(data) {
|
|
214
334
|
return {
|
|
@@ -230,29 +350,89 @@ export function formatBlackCompact(data) {
|
|
|
230
350
|
return `black: ${data.filesChanged} reformatted, ${data.filesUnchanged} unchanged`;
|
|
231
351
|
}
|
|
232
352
|
export function compactPipInstallMap(data) {
|
|
233
|
-
|
|
353
|
+
const compact = {
|
|
234
354
|
success: data.success,
|
|
235
355
|
alreadySatisfied: data.alreadySatisfied,
|
|
236
356
|
dryRun: data.dryRun || undefined,
|
|
237
357
|
};
|
|
358
|
+
if (data.error !== undefined)
|
|
359
|
+
compact.error = data.error;
|
|
360
|
+
if (data.exitCode !== undefined)
|
|
361
|
+
compact.exitCode = data.exitCode;
|
|
362
|
+
return compact;
|
|
238
363
|
}
|
|
239
364
|
export function formatPipInstallCompact(data) {
|
|
365
|
+
if (!data.success) {
|
|
366
|
+
const lines = [
|
|
367
|
+
`pip install failed${data.exitCode !== undefined ? ` (exit code ${data.exitCode})` : ""}.`,
|
|
368
|
+
];
|
|
369
|
+
if (data.error)
|
|
370
|
+
lines.push(data.error);
|
|
371
|
+
return lines.join("\n");
|
|
372
|
+
}
|
|
240
373
|
if (data.alreadySatisfied)
|
|
241
374
|
return "All requirements already satisfied.";
|
|
242
|
-
if (!data.success)
|
|
243
|
-
return "pip install failed.";
|
|
244
375
|
const verb = data.dryRun ? "Would install" : "Installed";
|
|
245
376
|
return `${verb} packages.`;
|
|
246
377
|
}
|
|
247
378
|
export function compactPipAuditMap(data) {
|
|
248
|
-
|
|
379
|
+
const vulns = data.vulnerabilities ?? [];
|
|
380
|
+
const compact = {
|
|
249
381
|
success: data.success,
|
|
382
|
+
total: vulns.length,
|
|
250
383
|
};
|
|
384
|
+
if (vulns.length > 0) {
|
|
385
|
+
const severityCounts = {};
|
|
386
|
+
for (const v of vulns) {
|
|
387
|
+
const severity = v.severity ?? "unknown";
|
|
388
|
+
severityCounts[severity] = (severityCounts[severity] ?? 0) + 1;
|
|
389
|
+
}
|
|
390
|
+
compact.severityCounts = severityCounts;
|
|
391
|
+
compact.vulnerabilities = vulns.slice(0, COMPACT_MAX_VULNS).map((v) => ({
|
|
392
|
+
name: v.name,
|
|
393
|
+
version: v.version,
|
|
394
|
+
id: v.id,
|
|
395
|
+
description: v.description.length > COMPACT_VULN_DESCRIPTION_MAX
|
|
396
|
+
? v.description.slice(0, COMPACT_VULN_DESCRIPTION_MAX) + "…"
|
|
397
|
+
: v.description,
|
|
398
|
+
fixVersions: v.fixVersions,
|
|
399
|
+
...(v.severity ? { severity: v.severity } : {}),
|
|
400
|
+
}));
|
|
401
|
+
if (vulns.length > COMPACT_MAX_VULNS)
|
|
402
|
+
compact.truncated = true;
|
|
403
|
+
}
|
|
404
|
+
if (data.skipped && data.skipped.length > 0)
|
|
405
|
+
compact.skippedCount = data.skipped.length;
|
|
406
|
+
if (data.error !== undefined)
|
|
407
|
+
compact.error = data.error;
|
|
408
|
+
if (data.exitCode !== undefined)
|
|
409
|
+
compact.exitCode = data.exitCode;
|
|
410
|
+
return compact;
|
|
251
411
|
}
|
|
252
412
|
export function formatPipAuditCompact(data) {
|
|
253
|
-
if (data.
|
|
413
|
+
if (data.error && data.total === 0) {
|
|
414
|
+
return [
|
|
415
|
+
`pip-audit: audit failed (exit code ${data.exitCode ?? "?"}) — result is NOT a clean scan.`,
|
|
416
|
+
data.error,
|
|
417
|
+
].join("\n");
|
|
418
|
+
}
|
|
419
|
+
if (data.total === 0)
|
|
254
420
|
return "No vulnerabilities found.";
|
|
255
|
-
|
|
421
|
+
const severityPart = data.severityCounts
|
|
422
|
+
? ` (${Object.entries(data.severityCounts)
|
|
423
|
+
.map(([sev, count]) => `${count} ${sev}`)
|
|
424
|
+
.join(", ")})`
|
|
425
|
+
: "";
|
|
426
|
+
const lines = [`${data.total} vulnerabilities${severityPart}:`];
|
|
427
|
+
for (const v of data.vulnerabilities ?? []) {
|
|
428
|
+
const fix = v.fixVersions.length ? ` (fix: ${v.fixVersions.join(", ")})` : "";
|
|
429
|
+
const severity = v.severity ? ` [${v.severity}]` : "";
|
|
430
|
+
lines.push(` ${v.name}==${v.version} ${v.id}${severity}${fix}`);
|
|
431
|
+
}
|
|
432
|
+
if (data.truncated) {
|
|
433
|
+
lines.push(` … ${data.total - (data.vulnerabilities ?? []).length} more omitted (run with compact:false for the full list)`);
|
|
434
|
+
}
|
|
435
|
+
return lines.join("\n");
|
|
256
436
|
}
|
|
257
437
|
export function compactUvInstallMap(data) {
|
|
258
438
|
return {
|
|
@@ -278,12 +458,23 @@ export function compactUvRunMap(data) {
|
|
|
278
458
|
exitCode: data.exitCode,
|
|
279
459
|
success: data.success,
|
|
280
460
|
truncated: data.truncated,
|
|
461
|
+
...compactStreamFields(data.stdout, data.commandStderr ?? data.stderr),
|
|
281
462
|
};
|
|
282
463
|
}
|
|
283
464
|
export function formatUvRunCompact(data) {
|
|
284
465
|
const status = data.success ? "completed" : `failed (exit ${data.exitCode})`;
|
|
285
466
|
const truncated = data.truncated ? " (truncated)" : "";
|
|
286
|
-
|
|
467
|
+
const lines = [`uv run ${status}${truncated}`];
|
|
468
|
+
if (data.stdout?.trim()) {
|
|
469
|
+
lines.push("stdout:", data.stdout.trim());
|
|
470
|
+
}
|
|
471
|
+
if (data.stderr?.trim()) {
|
|
472
|
+
lines.push("stderr:", data.stderr.trim());
|
|
473
|
+
}
|
|
474
|
+
if (data.stdoutTruncated || data.stderrTruncated) {
|
|
475
|
+
lines.push("… streams truncated to compact budget (run with compact:false for full output)");
|
|
476
|
+
}
|
|
477
|
+
return lines.join("\n");
|
|
287
478
|
}
|
|
288
479
|
// ── pip-list formatters ──────────────────────────────────────────────
|
|
289
480
|
/** Formats structured pip list results into a human-readable package listing. */
|
|
@@ -301,17 +492,37 @@ export function formatPipList(data) {
|
|
|
301
492
|
return lines.join("\n");
|
|
302
493
|
}
|
|
303
494
|
export function compactPipListMap(data) {
|
|
304
|
-
|
|
495
|
+
const packages = data.packages ?? [];
|
|
496
|
+
const compact = {
|
|
305
497
|
success: data.success,
|
|
498
|
+
total: packages.length,
|
|
306
499
|
error: data.error,
|
|
307
500
|
};
|
|
501
|
+
if (packages.length > 0) {
|
|
502
|
+
compact.packages = packages.slice(0, COMPACT_MAX_ENTRIES).map((p) => ({
|
|
503
|
+
name: p.name,
|
|
504
|
+
version: p.version,
|
|
505
|
+
...(p.latestVersion ? { latestVersion: p.latestVersion } : {}),
|
|
506
|
+
}));
|
|
507
|
+
if (packages.length > COMPACT_MAX_ENTRIES)
|
|
508
|
+
compact.truncated = true;
|
|
509
|
+
}
|
|
510
|
+
return compact;
|
|
308
511
|
}
|
|
309
512
|
export function formatPipListCompact(data) {
|
|
310
513
|
if (data.error)
|
|
311
514
|
return `pip list error: ${data.error}`;
|
|
312
|
-
if (data.
|
|
313
|
-
return "
|
|
314
|
-
|
|
515
|
+
if (data.total === 0)
|
|
516
|
+
return "No packages installed.";
|
|
517
|
+
const lines = [`${data.total} packages installed:`];
|
|
518
|
+
for (const pkg of data.packages ?? []) {
|
|
519
|
+
const latest = pkg.latestVersion ? ` (latest: ${pkg.latestVersion})` : "";
|
|
520
|
+
lines.push(` ${pkg.name}==${pkg.version}${latest}`);
|
|
521
|
+
}
|
|
522
|
+
if (data.truncated) {
|
|
523
|
+
lines.push(` … ${data.total - (data.packages ?? []).length} more omitted (run with compact:false for the full list)`);
|
|
524
|
+
}
|
|
525
|
+
return lines.join("\n");
|
|
315
526
|
}
|
|
316
527
|
// ── pip-show formatters ──────────────────────────────────────────────
|
|
317
528
|
/** Formats structured pip show results into a human-readable package info display. */
|
|
@@ -376,6 +587,9 @@ export function formatPipShowCompact(data) {
|
|
|
376
587
|
// ── ruff-format formatters ───────────────────────────────────────────
|
|
377
588
|
/** Formats structured ruff format results into a human-readable summary. */
|
|
378
589
|
export function formatRuffFormat(data) {
|
|
590
|
+
if (data.error && data.filesChanged === 0) {
|
|
591
|
+
return [`ruff format: run failed (exit code ${data.exitCode ?? "?"}).`, data.error].join("\n");
|
|
592
|
+
}
|
|
379
593
|
if (data.success && data.filesChanged === 0) {
|
|
380
594
|
const unchanged = data.filesUnchanged > 0 ? ` (${data.filesUnchanged} unchanged)` : "";
|
|
381
595
|
return `ruff format: all files already formatted.${unchanged}`;
|
|
@@ -392,14 +606,22 @@ export function formatRuffFormat(data) {
|
|
|
392
606
|
return lines.join("\n");
|
|
393
607
|
}
|
|
394
608
|
export function compactRuffFormatMap(data) {
|
|
395
|
-
|
|
609
|
+
const compact = {
|
|
396
610
|
success: data.success,
|
|
397
611
|
filesChanged: data.filesChanged,
|
|
398
612
|
filesUnchanged: data.filesUnchanged,
|
|
399
613
|
checkMode: data.checkMode || undefined,
|
|
400
614
|
};
|
|
615
|
+
if (data.error !== undefined)
|
|
616
|
+
compact.error = data.error;
|
|
617
|
+
if (data.exitCode !== undefined)
|
|
618
|
+
compact.exitCode = data.exitCode;
|
|
619
|
+
return compact;
|
|
401
620
|
}
|
|
402
621
|
export function formatRuffFormatCompact(data) {
|
|
622
|
+
if (data.error && data.filesChanged === 0) {
|
|
623
|
+
return [`ruff format: run failed (exit code ${data.exitCode ?? "?"}).`, data.error].join("\n");
|
|
624
|
+
}
|
|
403
625
|
if (data.success && data.filesChanged === 0) {
|
|
404
626
|
const unchanged = data.filesUnchanged > 0 ? ` (${data.filesUnchanged} unchanged)` : "";
|
|
405
627
|
return `ruff format: all files already formatted.${unchanged}`;
|
|
@@ -672,6 +894,29 @@ export function formatPyenv(data) {
|
|
|
672
894
|
}
|
|
673
895
|
}
|
|
674
896
|
export function compactPyenvMap(data) {
|
|
897
|
+
const compact = {
|
|
898
|
+
action: data.action,
|
|
899
|
+
success: data.success,
|
|
900
|
+
};
|
|
901
|
+
if (data.error !== undefined)
|
|
902
|
+
compact.error = data.error;
|
|
903
|
+
if (data.action === "versions") {
|
|
904
|
+
if (data.versions)
|
|
905
|
+
compact.versions = data.versions;
|
|
906
|
+
if (data.current)
|
|
907
|
+
compact.current = data.current;
|
|
908
|
+
return compact;
|
|
909
|
+
}
|
|
910
|
+
if (data.action === "installList") {
|
|
911
|
+
const avail = data.availableVersions ?? [];
|
|
912
|
+
compact.availableVersionCount = avail.length;
|
|
913
|
+
if (avail.length > 0) {
|
|
914
|
+
compact.availableVersions = avail.slice(0, COMPACT_MAX_ENTRIES);
|
|
915
|
+
if (avail.length > COMPACT_MAX_ENTRIES)
|
|
916
|
+
compact.truncated = true;
|
|
917
|
+
}
|
|
918
|
+
return compact;
|
|
919
|
+
}
|
|
675
920
|
let keyValue;
|
|
676
921
|
if (data.action === "version")
|
|
677
922
|
keyValue = data.current;
|
|
@@ -685,15 +930,31 @@ export function compactPyenvMap(data) {
|
|
|
685
930
|
keyValue = data.uninstalled;
|
|
686
931
|
if (data.action === "which")
|
|
687
932
|
keyValue = data.commandPath;
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
success: data.success,
|
|
691
|
-
keyValue,
|
|
692
|
-
};
|
|
933
|
+
compact.keyValue = keyValue;
|
|
934
|
+
return compact;
|
|
693
935
|
}
|
|
694
936
|
export function formatPyenvCompact(data) {
|
|
695
|
-
if (!data.success)
|
|
696
|
-
return `pyenv ${data.action} failed
|
|
937
|
+
if (!data.success) {
|
|
938
|
+
return `pyenv ${data.action} failed${data.error ? `: ${data.error}` : "."}`;
|
|
939
|
+
}
|
|
940
|
+
if (data.versions) {
|
|
941
|
+
const lines = [`${data.versions.length} versions installed:`];
|
|
942
|
+
for (const v of data.versions) {
|
|
943
|
+
const marker = v === data.current ? " *" : "";
|
|
944
|
+
lines.push(` ${v}${marker}`);
|
|
945
|
+
}
|
|
946
|
+
return lines.join("\n");
|
|
947
|
+
}
|
|
948
|
+
if (data.availableVersionCount !== undefined) {
|
|
949
|
+
const lines = [`${data.availableVersionCount} versions available for installation:`];
|
|
950
|
+
for (const v of data.availableVersions ?? []) {
|
|
951
|
+
lines.push(` ${v}`);
|
|
952
|
+
}
|
|
953
|
+
if (data.truncated) {
|
|
954
|
+
lines.push(` … ${data.availableVersionCount - (data.availableVersions ?? []).length} more omitted (run with compact:false for the full list)`);
|
|
955
|
+
}
|
|
956
|
+
return lines.join("\n");
|
|
957
|
+
}
|
|
697
958
|
if (data.keyValue)
|
|
698
959
|
return `pyenv ${data.action}: ${data.keyValue}`;
|
|
699
960
|
return `pyenv ${data.action}: success.`;
|
|
@@ -702,8 +963,17 @@ export function formatPyenvCompact(data) {
|
|
|
702
963
|
/** Formats structured poetry results into a human-readable summary.
|
|
703
964
|
* action is passed separately since it is not included in the output schema. */
|
|
704
965
|
export function formatPoetry(data, action) {
|
|
705
|
-
if (!data.success)
|
|
706
|
-
|
|
966
|
+
if (!data.success) {
|
|
967
|
+
const lines = [
|
|
968
|
+
`poetry ${action} failed${data.exitCode !== undefined ? ` (exit code ${data.exitCode})` : ""}.`,
|
|
969
|
+
];
|
|
970
|
+
for (const m of data.messages ?? []) {
|
|
971
|
+
lines.push(` ${m}`);
|
|
972
|
+
}
|
|
973
|
+
if (data.error)
|
|
974
|
+
lines.push(data.error);
|
|
975
|
+
return lines.join("\n");
|
|
976
|
+
}
|
|
707
977
|
if (action === "show") {
|
|
708
978
|
const pkgs = data.packages ?? [];
|
|
709
979
|
if (pkgs.length === 0)
|
|
@@ -746,13 +1016,59 @@ export function formatPoetry(data, action) {
|
|
|
746
1016
|
return lines.join("\n");
|
|
747
1017
|
}
|
|
748
1018
|
export function compactPoetryMap(data) {
|
|
749
|
-
|
|
1019
|
+
const compact = {
|
|
750
1020
|
success: data.success,
|
|
751
1021
|
};
|
|
1022
|
+
if (data.packages) {
|
|
1023
|
+
compact.packageCount = data.packages.length;
|
|
1024
|
+
compact.packages = data.packages
|
|
1025
|
+
.slice(0, COMPACT_MAX_ENTRIES)
|
|
1026
|
+
.map((p) => ({ name: p.name, version: p.version }));
|
|
1027
|
+
if (data.packages.length > COMPACT_MAX_ENTRIES)
|
|
1028
|
+
compact.truncated = true;
|
|
1029
|
+
}
|
|
1030
|
+
if (data.artifacts) {
|
|
1031
|
+
compact.artifactCount = data.artifacts.length;
|
|
1032
|
+
compact.artifacts = data.artifacts.slice(0, COMPACT_MAX_ENTRIES).map((a) => ({ file: a.file }));
|
|
1033
|
+
if (data.artifacts.length > COMPACT_MAX_ENTRIES)
|
|
1034
|
+
compact.truncated = true;
|
|
1035
|
+
}
|
|
1036
|
+
if (data.messages) {
|
|
1037
|
+
compact.messageCount = data.messages.length;
|
|
1038
|
+
compact.messages = data.messages.slice(0, COMPACT_MAX_MESSAGES);
|
|
1039
|
+
if (data.messages.length > COMPACT_MAX_MESSAGES)
|
|
1040
|
+
compact.truncated = true;
|
|
1041
|
+
}
|
|
1042
|
+
if (data.error !== undefined)
|
|
1043
|
+
compact.error = data.error;
|
|
1044
|
+
if (data.exitCode !== undefined)
|
|
1045
|
+
compact.exitCode = data.exitCode;
|
|
1046
|
+
return compact;
|
|
752
1047
|
}
|
|
753
1048
|
export function formatPoetryCompact(data) {
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
1049
|
+
const lines = [data.success ? "poetry: success." : "poetry: failed."];
|
|
1050
|
+
if (data.packageCount !== undefined) {
|
|
1051
|
+
lines.push(`${data.packageCount} packages:`);
|
|
1052
|
+
for (const pkg of data.packages ?? []) {
|
|
1053
|
+
lines.push(` ${pkg.name}==${pkg.version}`);
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
if (data.artifactCount !== undefined) {
|
|
1057
|
+
lines.push(`${data.artifactCount} artifacts:`);
|
|
1058
|
+
for (const a of data.artifacts ?? []) {
|
|
1059
|
+
lines.push(` ${a.file}`);
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
if (data.messages && data.messages.length > 0) {
|
|
1063
|
+
for (const m of data.messages) {
|
|
1064
|
+
lines.push(` ${m}`);
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
if (data.truncated) {
|
|
1068
|
+
lines.push(" … entries omitted (run with compact:false for the full list)");
|
|
1069
|
+
}
|
|
1070
|
+
if (data.error)
|
|
1071
|
+
lines.push(data.error);
|
|
1072
|
+
return lines.join("\n");
|
|
757
1073
|
}
|
|
758
1074
|
//# sourceMappingURL=formatters.js.map
|