From 695dcf027fbbc95957eedb5aa11e9a6c66731a2b Mon Sep 17 00:00:00 2001 From: Rudy Celekli Date: Sat, 10 Oct 2026 12:27:34 -0400 Subject: [PATCH 1/2] fix(cli-core): include table padding in width constraints Signed-off-by: Rudy Celekli --- tests/output-table-padding.test.mjs | 7 +++++++ v3/@claude-flow/cli-core/src/output.ts | 7 ++++--- 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 tests/output-table-padding.test.mjs diff --git a/tests/output-table-padding.test.mjs b/tests/output-table-padding.test.mjs new file mode 100644 index 0000000000..701c2a65fc --- /dev/null +++ b/tests/output-table-padding.test.mjs @@ -0,0 +1,7 @@ +import test from 'node:test'; +import assert from 'node:assert/strict'; +import { OutputFormatter } from '../v3/@claude-flow/cli-core/src/output.ts'; +test('maxWidth accounts for configured padding', () => { + const f = new OutputFormatter({ color: false }); + for (const padding of [0, 1, 2, 3]) { const table = f.table({ columns: [{ key: 'a', header: 'A' }, { key: 'b', header: 'B' }], data: [{ a: 'a'.repeat(30), b: 'b'.repeat(30) }], padding, maxWidth: 40 }); for (const line of table.split('\n')) assert.ok(line.length <= 40, `padding=${padding} width=${line.length}`); } +}); diff --git a/v3/@claude-flow/cli-core/src/output.ts b/v3/@claude-flow/cli-core/src/output.ts index 9052a53923..ba9d0f6079 100644 --- a/v3/@claude-flow/cli-core/src/output.ts +++ b/v3/@claude-flow/cli-core/src/output.ts @@ -224,7 +224,7 @@ export class OutputFormatter { const { columns, data, border = true, header = true, padding = 1, maxWidth } = options; // Calculate column widths - const widths = this.calculateColumnWidths(columns, data, maxWidth); + const widths = this.calculateColumnWidths(columns, data, maxWidth, padding); const lines: string[] = []; const pad = ' '.repeat(padding); @@ -294,7 +294,8 @@ export class OutputFormatter { private calculateColumnWidths( columns: TableColumn[], data: Record[], - maxWidth?: number + maxWidth?: number, + padding: number = 1 ): number[] { const widths = columns.map((col, i) => { // Start with header width @@ -320,7 +321,7 @@ export class OutputFormatter { // Apply max width constraint if (maxWidth) { - const totalWidth = widths.reduce((a, b) => a + b, 0) + (columns.length * 3) + 1; + const totalWidth = widths.reduce((a, b) => a + b, 0) + (columns.length * (2 * padding + 1)) + 1; if (totalWidth > maxWidth) { const reduction = (totalWidth - maxWidth) / columns.length; return widths.map(w => Math.max(3, Math.floor(w - reduction))); From 2af1fee0b0ee9409f1e23949a8929742327c8415 Mon Sep 17 00:00:00 2001 From: Rudy Celekli Date: Sat, 10 Oct 2026 15:35:01 -0400 Subject: [PATCH 2/2] test: run focused regressions with the repository Vitest runner Signed-off-by: Rudy Celekli --- tests/output-table-padding.test.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/output-table-padding.test.mjs b/tests/output-table-padding.test.mjs index 701c2a65fc..fe8df5276f 100644 --- a/tests/output-table-padding.test.mjs +++ b/tests/output-table-padding.test.mjs @@ -1,4 +1,4 @@ -import test from 'node:test'; +import { test } from 'vitest'; import assert from 'node:assert/strict'; import { OutputFormatter } from '../v3/@claude-flow/cli-core/src/output.ts'; test('maxWidth accounts for configured padding', () => {