UNPKG

mira-consciousness

Version:

Memory & Intelligence Retention Archive - Preserving The Spark

95 lines 4.38 kB
import chalk from 'chalk'; import { CATEGORIZED_COMMANDS, CommandCategory } from '../config/command-definitions.js'; /** * Custom help formatter that respects hidden commands */ export class HelpFormatter { /** * Configure custom help for a program */ static configureHelp(program) { program.configureHelp({ formatHelp: (cmd, helper) => { const termWidth = helper.padWidth(cmd, helper); const helpWidth = helper.helpWidth || 80; const itemIndentWidth = 2; const itemSeparatorWidth = 2; let output = ''; // Usage output += helper.commandUsage(cmd) + '\n'; // Description if (cmd.description()) { output += '\n' + cmd.description() + '\n'; } // Commands - all commands are now visible (no hidden legacy commands) const visibleCommands = cmd.commands; if (visibleCommands.length > 0) { // Group commands by category const commandsByCategory = new Map(); visibleCommands.forEach(cmd => { const config = findCommandConfig(cmd.name()); const category = findCommandCategory(cmd.name()) || CommandCategory.UNIFIED; if (!commandsByCategory.has(category)) { commandsByCategory.set(category, []); } commandsByCategory.get(category).push(cmd); }); // Display by category with MCP Final Vision priority const categoryOrder = [CommandCategory.UNIFIED, CommandCategory.SYSTEM]; categoryOrder.forEach(category => { const commands = commandsByCategory.get(category); if (commands && commands.length > 0) { output += '\n' + chalk.bold(category + ':') + '\n'; commands.forEach(cmd => { const name = cmd.name(); const description = cmd.description(); const alias = cmd.aliases().length > 0 ? chalk.gray(` (${cmd.aliases().join(', ')})`) : ''; output += ' ' + chalk.cyan(name) + alias; if (description) { const descriptionWidth = helpWidth - termWidth - itemIndentWidth - itemSeparatorWidth; output += ' '.repeat(Math.max(0, termWidth - name.length - alias.length)) + ' ' + description; } output += '\n'; }); } }); // Removed --all option since we removed legacy commands } // Options const visibleOptions = helper.visibleOptions(cmd); if (visibleOptions.length > 0) { output += '\n' + chalk.bold('Options:') + '\n'; output += visibleOptions.map(opt => { return ' ' + helper.optionTerm(opt) + ' '.repeat(Math.max(0, termWidth - opt.flags.length)) + ' ' + opt.description; }).join('\n') + '\n'; } return output; } }); // Simple help command - no need for --all since no hidden commands program .command('help') .description('Display help information') .action(() => { program.help(); }); } } function findCommandConfig(name) { for (const category of CATEGORIZED_COMMANDS) { const config = category.commands.find(cmd => cmd.name === name); if (config) return config; } return undefined; } function findCommandCategory(name) { for (const category of CATEGORIZED_COMMANDS) { if (category.commands.find(cmd => cmd.name === name)) { return category.category; } } return undefined; } // Removed showAllCommands - no longer needed without legacy commands //# sourceMappingURL=help-formatter.js.map