All files / lib utils.js

40.9% Statements 9/22
72.72% Branches 8/11
60% Functions 3/5
40.9% Lines 9/22

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59                                                                        3x 3x       2x 2x 2x                 2x 1x 1x   1x    
import chalk from 'chalk';
 
/**
 * Beautiful ASCII Banner
 */
export function showBanner() {
  const width = process.stdout.columns || 80;
  const line = '━'.repeat(Math.max(0, Math.min(width, 60)));
 
  const banner = [
    ' ██████╗  ██████╗ ███████╗███████╗████████╗████████╗ █████╗ ',
    ' ██╔══██╗██╔═══██╗██╔════╝██╔════╝╚══██╔══╝╚══██╔══╝██╔══██╗',
    ' ██████╔╝██║   ██║███████╗█████╗     ██║      ██║   ███████║',
    ' ██╔══██╗██║   ██║╚════██║██╔══╝     ██║      ██║   ██╔══██║',
    ' ██║  ██║╚██████╔╝███████║███████╗    ██║      ██║   ██║  ██║',
    ' ╚═╝  ╚═╝ ╚═════╝ ╚══════╝╚══════╝    ╚═╝      ╚═╝   ╚═╝  ╚═╝'
  ].map(l => l.padStart(l.length + Math.max(0, Math.floor((width - 61) / 2)))).join('\n');
 
  const versionPill = chalk.bgBlue.white.bold(' 🏷️ v0.4.0 ');
  const statusPill = chalk.bgGreen.black.bold(' ✨ STABLE ');
  const modePill = chalk.bgMagenta.white.bold(' ⚡ CLI ');
 
  const pills = `${versionPill} ${statusPill} ${modePill}`;
  const pillPadding = ' '.repeat(Math.max(0, Math.floor((width - 34) / 2))); // 34 is approx width of 3 pills
 
  console.log('\n' + banner);
  console.log(`${pillPadding}${pills}\n`);
  console.log(chalk.gray(`${' '.repeat(Math.max(0, Math.floor((width - 40) / 2)))}Single Source of Truth for AI Agents\n`));
  console.log(chalk.gray(`${' '.repeat(Math.max(0, Math.floor((width - Math.min(width, 60)) / 2)))}${line}\n`));
}
 
/**
 * Tree logger for progress indicators.
 */
export class TreeLogger {
  constructor(rootLabel) {
    this.rootLabel = rootLabel;
    console.log(chalk.magenta.bold(`\n${rootLabel}`));
  }
 
  logStep(message, status = 'OK', isLast = false) {
    const prefix = isLast ? '┗━ ' : '┣━ ';
    const statusColor = status === 'OK' ? chalk.green : chalk.yellow;
    console.log(`${chalk.gray(prefix)}${message} ${statusColor(status)}`);
  }
}
 
/**
 * Helper for dry-run mode.
 * Returns true if in dry-run mode, otherwise false.
 */
export async function dryRunWrite(filePath, action, options = {}) {
  if (options.dryRun) {
    console.log(chalk.yellow(`[Dry-run] Would ${action}: ${filePath}`));
    return true;
  }
  return false;
}