Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 35 additions & 13 deletions server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -405,22 +405,44 @@ async function runSweepCycle() {
}

// === Startup ===
// Render the startup banner. The frame width is derived from the contents so the
// box stays aligned — and nothing is truncated — for any port, refresh interval
// or provider name. The previous hand-counted padding assumed a 4-digit port and
// threw `RangeError: Invalid count value: -1` for anything above 9999.
const BANNER_MIN_WIDTH = 46;

function renderBanner(title, subtitle, rows) {
const body = rows.map(([label, value]) => ` ${label.padEnd(12)}${value}`);
const width = Math.max(BANNER_MIN_WIDTH, ...body.map(l => l.length), title.length + 2, subtitle.length + 2);
const center = (s) => {
const left = Math.floor((width - s.length) / 2);
return ' '.repeat(left) + s + ' '.repeat(width - s.length - left);
};
const rule = '═'.repeat(width);

return [
'',
` ╔${rule}╗`,
` ║${center(title)}║`,
` ║${center(subtitle)}║`,
` ╠${rule}╣`,
...body.map(l => ` ║${l.padEnd(width)}║`),
` ╚${rule}╝`,
' ',
].join('\n');
}

async function start() {
const port = config.port;

console.log(`
╔══════════════════════════════════════════════╗
║ CRUCIX INTELLIGENCE ENGINE ║
║ Local Palantir · 26 Sources ║
╠══════════════════════════════════════════════╣
║ Dashboard: http://localhost:${port}${' '.repeat(14 - String(port).length)}║
║ Health: http://localhost:${port}/api/health${' '.repeat(4 - String(port).length)}║
║ Refresh: Every ${config.refreshIntervalMinutes} min${' '.repeat(20 - String(config.refreshIntervalMinutes).length)}║
║ LLM: ${(config.llm.provider || 'disabled').padEnd(31)}║
║ Telegram: ${config.telegram.botToken ? 'enabled' : 'disabled'}${' '.repeat(config.telegram.botToken ? 24 : 23)}║
║ Discord: ${config.discord?.botToken ? 'enabled' : config.discord?.webhookUrl ? 'webhook only' : 'disabled'}${' '.repeat(config.discord?.botToken ? 24 : config.discord?.webhookUrl ? 20 : 23)}║
╚══════════════════════════════════════════════╝
`);
console.log(renderBanner('CRUCIX INTELLIGENCE ENGINE', 'Local Palantir · 26 Sources', [
['Dashboard:', `http://localhost:${port}`],
['Health:', `http://localhost:${port}/api/health`],
['Refresh:', `Every ${config.refreshIntervalMinutes} min`],
['LLM:', config.llm.provider || 'disabled'],
['Telegram:', config.telegram.botToken ? 'enabled' : 'disabled'],
['Discord:', config.discord?.botToken ? 'enabled' : config.discord?.webhookUrl ? 'webhook only' : 'disabled'],
]));

const server = app.listen(port);

Expand Down