@vigilbase/cli
Version:
Vigilbase CLI — security scanners, agent tools, and Vigilbase One from the terminal.
68 lines (67 loc) • 2.6 kB
JavaScript
/**
* Compact Vigilbase flare mark + wordmark for human CLI surfaces.
* Static strings only — no I/O, no deps, skipped entirely in --json mode.
*/
/**
* Compact square Vigilbase flare (inverted V).
* Left wing (full block) = terminal default fg; right wing (medium shade) = brand yellow.
*/
/** Compact flare used on help/version (keeps the first viewport short). */
export const VIGILBASE_ASCII_MARK = [
'\u2588\u2588\u2588\u2588\u2588 \u2592\u2592\u2592',
' \u2588\u2588\u2588\u2588 \u2592\u2592\u2592\u2592',
' \u2588\u2588\u2588 \u2592\u2592\u2592\u2592 ',
' \u2588\u2592\u2592\u2592\u2592 ',
' \u2592\u2592\u2592 ',
].join('\n');
const ANSI = {
reset: '\u001b[0m',
dim: '\u001b[2m',
bold: '\u001b[1m',
/** Brand yellow (#f9e75e / #FFE74D family) — 256-color approximation. */
brand: '\u001b[38;5;221m',
};
export function shouldUseColor(stream, env = process.env) {
if (env.NO_COLOR != null && env.NO_COLOR !== '')
return false;
if (env.FORCE_COLOR === '0')
return false;
if (env.FORCE_COLOR && env.FORCE_COLOR !== '0')
return true;
if (env.CI === '1' || env.CI === 'true')
return false;
return Boolean(stream?.isTTY);
}
export function shouldShowBanner(mode = 'text', env = process.env) {
if (mode === 'json')
return false;
if (env.VIGILBASE_CLI_NO_BANNER === '1')
return false;
return true;
}
function paintMarkLine(line, useColor) {
if (!useColor)
return line;
// Left wing stays terminal default fg; right wing is brand yellow.
return line.replace(/\u2592+/g, (run) => `${ANSI.brand}${run}${ANSI.reset}`);
}
/**
* Banner composition (flare + wordmark + tagline).
*/
export function renderBanner(options = {}, stream = process.stdout, env = process.env) {
const useColor = options.useColor ?? shouldUseColor(stream, env);
const tagline = options.tagline ?? 'one \u00b7 tools';
const version = options.version ? ` \u00b7 v${options.version}` : '';
const mark = VIGILBASE_ASCII_MARK.split('\n');
const brand = (text) => useColor ? `${ANSI.brand}${ANSI.bold}${text}${ANSI.reset}` : text;
const dim = (text) => useColor ? `${ANSI.dim}${text}${ANSI.reset}` : text;
const painted = mark.map((line) => paintMarkLine(line, useColor));
const lines = painted.map((line, index) => {
if (index === 0)
return `${line} ${brand('vigilbase')}`;
if (index === 1)
return `${line} ${dim(`${tagline}${version}`)}`;
return line;
});
return lines.join('\n');
}