🌊 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
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
fix(cli-core): measure visible widths for colored headers
Rudy Celeklibca48964ac21
diff --git a/tests/output-colored-headers.test.mjs b/tests/output-colored-headers.test.mjsnew file mode 100644index 0000000000..f90dc8ac73--- /dev/null+++ b/tests/output-colored-headers.test.mjs@@ -0,0 +1,13 @@+import test from 'node:test';+import assert from 'node:assert/strict';+import { OutputFormatter } from '../v3/@claude-flow/cli-core/src/output.ts';+const visible = text => text.replace(/\x1b\[[0-9;]*m/g, '');+test('colored table headers use their visible width', () => {+ const f = new OutputFormatter({ color: true });+ const plain = f.table({ columns: [{ key: 'v', header: 'Header' }], data: [{ v: 'value' }] });+ const colored = f.table({ columns: [{ key: 'v', header: f.color('Header', 'red') }], data: [{ v: 'value' }] });+ assert.equal(visible(colored), visible(plain));+});+test('colored box titles align with every border and content row', () => {+ const f = new OutputFormatter({ color: true }); const plain = f.box('body', 'Title'); const colored = f.box('body', f.color('Title', 'red')); assert.equal(visible(colored), visible(plain));+});diff --git a/v3/@claude-flow/cli-core/src/output.ts b/v3/@claude-flow/cli-core/src/output.tsindex 9052a53923..90bb7c0552 100644--- a/v3/@claude-flow/cli-core/src/output.ts+++ b/v3/@claude-flow/cli-core/src/output.ts@@ -298,7 +298,7 @@ export class OutputFormatter {): number[] {const widths = columns.map((col, i) => {// Start with header width- let width = col.header.length;+ let width = this.stripAnsi(col.header).length;// Check all data valuesfor (const row of data) {@@ -442,7 +442,7 @@ export class OutputFormatter {box(content: string, title?: string): string {const lines = content.split('\n');- const maxLen = Math.max(...lines.map(l => this.stripAnsi(l).length), title?.length ?? 0);+ const maxLen = Math.max(...lines.map(l => this.stripAnsi(l).length), this.stripAnsi(title ?? '').length);const width = maxLen + 4;const border = {@@ -456,8 +456,9 @@ export class OutputFormatter {// Top border with optional titleif (title) {const titleText = ` ${title} `;- const leftPad = Math.floor((width - titleText.length - 2) / 2);- const rightPad = width - titleText.length - leftPad - 2;+ const titleWidth = this.stripAnsi(titleText).length;+ const leftPad = Math.floor((width - titleWidth - 2) / 2);+ const rightPad = width - titleWidth - leftPad - 2;result.push(border.topLeft +border.horizontal.repeat(leftPad) +