UNPKG

mega-minds

Version:

Enhanced multi-agent workflow system for Claude Code projects with automated handoff management and Claude Code hooks integration

148 lines (120 loc) โ€ข 5.12 kB
// lib/commands/hook-status.js // Display Claude Code hooks status and configuration const fs = require('fs-extra'); const path = require('path'); const HookManager = require('../core/HookManager'); /** * Display comprehensive hook status information */ async function showHookStatus() { console.log('๐Ÿ”— Claude Code Hooks Status'); console.log('===========================\n'); const projectPath = process.cwd(); // Initialize HookManager to check status const hookManager = new HookManager(); await hookManager.initialize(); const status = hookManager.getHookStatus(); // Display basic status console.log('๐Ÿ“Š Basic Status:'); console.log(` Hooks Enabled: ${status.enabled ? 'โœ… Yes' : 'โŒ No'}`); console.log(` Config File: ${status.configPath ? path.relative(projectPath, status.configPath) : 'Not found'}`); console.log(` Session Manager: ${status.sessionManagerConnected ? 'โœ… Connected' : 'โš ๏ธ Not connected'}`); if (!status.enabled) { console.log('\n๐Ÿ’ก To enable hooks, run: mega-minds setup-hooks'); return; } // Display detailed configuration await showDetailedConfiguration(status.configPath, projectPath); // Show supported hooks console.log('\n๐Ÿ› ๏ธ Supported Hook Types:'); status.supportedHooks.forEach(hookType => { console.log(` โ€ข ${hookType}`); }); // Show mega-minds specific commands console.log('\n๐Ÿค– Mega-Minds Hook Commands:'); const commands = [ 'npx mega-minds trigger-quality-gates', 'npx mega-minds save-session-auto', 'npx mega-minds preserve-context' ]; commands.forEach(cmd => { console.log(` โ€ข ${cmd}`); }); // Check if commands exist await checkCommandAvailability(); } /** * Show detailed hook configuration */ async function showDetailedConfiguration(configPath, projectPath) { try { const config = await fs.readJSON(configPath); if (!config.hooks || Object.keys(config.hooks).length === 0) { console.log('\nโš ๏ธ No hooks configured in settings file'); return; } console.log('\nโš™๏ธ Active Hook Configuration:'); Object.entries(config.hooks).forEach(([hookType, hookConfigs]) => { console.log(`\n ๐Ÿ“Œ ${hookType}:`); hookConfigs.forEach((hookConfig, index) => { console.log(` ${index + 1}. Matcher: "${hookConfig.matcher || 'any'}"`); if (hookConfig.hooks && hookConfig.hooks.length > 0) { hookConfig.hooks.forEach((hook, hookIndex) => { console.log(` Command: ${hook.command}`); }); } }); }); // Show mega-minds specific configuration if (config.megaMindsHookConfig) { console.log('\n๐Ÿค– Mega-Minds Configuration:'); console.log(` Debug Logging: ${config.megaMindsHookConfig.debugLogging ? 'โœ… Enabled' : 'โŒ Disabled'}`); console.log(` Config Version: ${config.megaMindsHookConfig.version || 'Unknown'}`); } } catch (error) { console.log('\nโš ๏ธ Could not read hook configuration:', error.message); } } /** * Check if mega-minds hook commands are available */ async function checkCommandAvailability() { console.log('\n๐Ÿ” Command Availability Check:'); const commandsToCheck = [ { name: 'trigger-quality-gates', file: 'lib/commands/trigger-quality-gates.js' }, { name: 'save-session-auto', file: 'lib/commands/save-session-auto.js' }, { name: 'preserve-context', file: 'lib/commands/preserve-context.js' } ]; for (const cmd of commandsToCheck) { const cmdPath = path.join(__dirname, '..', '..', cmd.file); const exists = await fs.pathExists(cmdPath); console.log(` ${cmd.name}: ${exists ? 'โœ… Available' : 'โš ๏ธ Not implemented yet'}`); } } /** * Show hook testing information */ async function showTestingInfo() { console.log('\n๐Ÿงช Testing Your Hooks:'); console.log('1. Make a code change with Claude Code (Edit/Write tool)'); console.log('2. Check if quality gates trigger automatically'); console.log('3. Stop Claude Code session and check if auto-save occurs'); console.log('4. Monitor console output for hook execution logs'); console.log('\n๐Ÿ“ Troubleshooting:'); console.log('โ€ข Hooks not triggering? Restart Claude Code'); console.log('โ€ข Commands failing? Check file permissions'); console.log('โ€ข Need more info? Enable debug logging in setup'); } /** * Main export function */ async function hookStatus() { try { await showHookStatus(); await showTestingInfo(); } catch (error) { console.error('โŒ Error checking hook status:', error.message); console.log('\n๐Ÿ’ก Try running "mega-minds setup-hooks" to initialize hook configuration'); } } module.exports = { hookStatus };