Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

fix(cli-core): include table padding in width constraints

Rudy Celekli695dcf027fbb
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<string, unknown>[],
- 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)));