fix: correct box() off-by-one width calculation in skill-create-output

The box() helper produced lines that were width+1 characters instead of
the requested width. Adjusted all three formulas (top border, middle
content, bottom border) by -1 each. Added 4 tests verifying box width
accuracy across instincts(), analysisResults(), and nextSteps() output.
This commit is contained in:
Affaan Mustafa
2026-02-13 04:05:12 -08:00
parent 554b5d6704
commit b497135b95
2 changed files with 80 additions and 3 deletions

View File

@@ -38,10 +38,10 @@ const SPINNER = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇',
// Helper functions
function box(title, content, width = 60) {
const lines = content.split('\n');
const top = `${BOX.topLeft}${BOX.horizontal} ${chalk.bold(chalk.cyan(title))} ${BOX.horizontal.repeat(Math.max(0, width - title.length - 4))}${BOX.topRight}`;
const bottom = `${BOX.bottomLeft}${BOX.horizontal.repeat(width - 1)}${BOX.bottomRight}`;
const top = `${BOX.topLeft}${BOX.horizontal} ${chalk.bold(chalk.cyan(title))} ${BOX.horizontal.repeat(Math.max(0, width - title.length - 5))}${BOX.topRight}`;
const bottom = `${BOX.bottomLeft}${BOX.horizontal.repeat(width - 2)}${BOX.bottomRight}`;
const middle = lines.map(line => {
const padding = width - 3 - stripAnsi(line).length;
const padding = width - 4 - stripAnsi(line).length;
return `${BOX.vertical} ${line}${' '.repeat(Math.max(0, padding))} ${BOX.vertical}`;
}).join('\n');
return `${top}\n${middle}\n${bottom}`;