fix: clamp progressBar to prevent RangeError on overflow, add 10 tests

progressBar() in skill-create-output.js could crash with RangeError when
percent > 100 because repeat() received a negative count. Fixed by
clamping filled to [0, width].

New tests:
- progressBar edge cases: 0%, 100%, and >100% confidence
- Empty patterns/instincts arrays
- post-edit-format: null tool_input, missing file_path, prettier failure
- setup-package-manager: --detect output completeness, current marker
This commit is contained in:
Affaan Mustafa
2026-02-13 02:01:57 -08:00
parent 0e0319a1c2
commit 5398ac793d
4 changed files with 86 additions and 1 deletions

View File

@@ -53,7 +53,7 @@ function stripAnsi(str) {
}
function progressBar(percent, width = 30) {
const filled = Math.round(width * percent / 100);
const filled = Math.min(width, Math.max(0, Math.round(width * percent / 100)));
const empty = width - filled;
const bar = chalk.green('█'.repeat(filled)) + chalk.gray('░'.repeat(empty));
return `${bar} ${chalk.bold(percent)}%`;