UNPKG

alnilam-cli

Version:

Git-native AI career coach that converts multi-year ambitions into weekly execution

185 lines (184 loc) • 8.56 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.statusCommand = exports.dashboardCommand = void 0; const commander_1 = require("commander"); const api_js_1 = require("../lib/api.js"); const asciichart_1 = __importDefault(require("asciichart")); const dashboardCommand = new commander_1.Command('dashboard'); exports.dashboardCommand = dashboardCommand; dashboardCommand .description('Visual dashboard with progress tracking') .option('--refresh', 'Refresh and display latest data') .option('--compact', 'Compact display for smaller terminals') .option('--json', 'Output as JSON') .action(async (options) => { try { console.log('šŸœļø ALNILAM DASHBOARD - BORDERLANDS EDITION šŸ”ļø'); console.log('═'.repeat(60)); // Fetch dashboard data console.log('šŸ“Š Loading dashboard data...'); const [goalsRes, evidenceRes, evaluationRes, summariesRes, nudgesRes] = await Promise.all([ api_js_1.restClient.get('/goals', { params: { select: '*', order: 'created_at.desc', limit: 10 } }), api_js_1.restClient.get('/evidence', { params: { select: '*', order: 'created_at.desc', limit: 20 } }), api_js_1.restClient.get('/evaluations', { params: { select: '*', order: 'week_start.desc', limit: 1 } }), api_js_1.restClient.get('/summaries', { params: { select: 'date,content,evidence_count', order: 'date.desc', limit: 7 } }), api_js_1.restClient.get('/nudges', { params: { select: '*', 'requires_approval': 'eq.true', 'approved': 'eq.false', limit: 5 } }) ]); const data = { goals: goalsRes.data || [], recentEvidence: evidenceRes.data || [], latestEvaluation: evaluationRes.data?.[0] || null, recentSummaries: summariesRes.data || [], pendingNudges: nudgesRes.data || [] }; if (options.json) { console.log(JSON.stringify(data, null, 2)); return; } // Calculate stats const stats = { totalGoals: data.goals.length, activeGoals: data.goals.filter(g => g.status === 'active').length, completedGoals: data.goals.filter(g => g.status === 'completed').length, weeklyEvidence: data.recentEvidence.filter(e => { const weekAgo = new Date(); weekAgo.setDate(weekAgo.getDate() - 7); return new Date(e.created_at) > weekAgo; }).length, currentMomentum: data.latestEvaluation?.momentum_score || 0, pendingApprovals: data.pendingNudges.length }; // Quick Stats Overview console.log('\nšŸ“ˆ Quick Stats'); console.log('─'.repeat(30)); console.log(`šŸŽÆ Goals: ${stats.activeGoals}/${stats.totalGoals} active`); console.log(`āœ… Completed: ${stats.completedGoals}`); console.log(`šŸ“ Weekly Evidence: ${stats.weeklyEvidence}`); console.log(`⚔ Current Momentum: ${stats.currentMomentum}/100`); console.log(`ā³ Pending Approvals: ${stats.pendingApprovals}`); // Momentum Gauge if (stats.currentMomentum > 0) { console.log('\nšŸŽÆ Momentum Score'); console.log('─'.repeat(30)); const barLength = options.compact ? 20 : 40; const filled = Math.round((stats.currentMomentum / 100) * barLength); const gauge = 'ā–ˆ'.repeat(filled) + 'ā–‘'.repeat(barLength - filled); const scoreColor = stats.currentMomentum >= 80 ? '🟢' : stats.currentMomentum >= 60 ? '🟔' : stats.currentMomentum >= 40 ? 'šŸ”µ' : 'šŸ”“'; console.log(`[${gauge}] ${stats.currentMomentum}/100 ${scoreColor}`); if (data.latestEvaluation?.summary) { console.log(`\nšŸ“Š ${data.latestEvaluation.summary.substring(0, 100)}...`); } } // Goals by Horizon if (data.goals.length > 0) { console.log('\nšŸ“‹ Goals by Horizon'); console.log('─'.repeat(30)); const horizonCounts = data.goals.reduce((acc, goal) => { if (!acc[goal.horizon]) acc[goal.horizon] = { active: 0, total: 0 }; if (goal.status === 'active') acc[goal.horizon].active++; acc[goal.horizon].total++; return acc; }, {}); ['weekly', 'quarterly', 'annual', 'multi-year'].forEach(horizon => { const count = horizonCounts[horizon]; if (count) { const emoji = horizon === 'weekly' ? 'šŸ“…' : horizon === 'quarterly' ? 'šŸ“Š' : horizon === 'annual' ? 'šŸ—“ļø' : 'šŸ”­'; console.log(`${emoji} ${horizon}: ${count.active}/${count.total}`); } }); } // Recent Activity if (data.recentEvidence.length > 0) { console.log('\nšŸ”„ Recent Activity'); console.log('─'.repeat(30)); data.recentEvidence.slice(0, 5).forEach(evidence => { const emoji = evidence.type === 'commit' ? 'šŸ’¾' : evidence.type === 'pr' ? 'šŸ”€' : evidence.type === 'time' ? 'ā±ļø' : 'šŸ“'; const timeAgo = getTimeAgo(evidence.created_at); console.log(`${emoji} ${evidence.message.substring(0, 40)}... (${timeAgo})`); }); } // Pending Approvals if (data.pendingNudges.length > 0) { console.log('\nā³ Pending Approvals'); console.log('─'.repeat(30)); data.pendingNudges.forEach(nudge => { const emoji = nudge.type === 'weekly_plan' ? 'šŸ“‹' : 'šŸ’”'; console.log(`${emoji} ${nudge.content}`); }); console.log('\nšŸ’” Review plans with: alnl plan list'); } // Trend Analysis (if we have evaluation history) if (data.latestEvaluation) { console.log('\nšŸ“ˆ Momentum Trend (simulated)'); console.log('─'.repeat(30)); // Generate sample trend data for demonstration const trendData = [45, 52, 48, 65, 72, 68, stats.currentMomentum]; const chart = asciichart_1.default.plot(trendData, { height: 6, width: options.compact ? 30 : 50, format: (x) => x.toFixed(0) }); console.log(chart); console.log('Last 7 weeks momentum progression'); } console.log('\n' + '═'.repeat(60)); console.log('šŸ’” Commands: alnl evaluate | alnl plan | alnl goal list'); console.log(`šŸ”„ Last updated: ${new Date().toLocaleTimeString()}`); } catch (error) { console.error('āŒ Dashboard error:', error.message); process.exit(1); } }); // Helper function for relative time function getTimeAgo(dateString) { const date = new Date(dateString); const now = new Date(); const diffMs = now.getTime() - date.getTime(); const diffMins = Math.floor(diffMs / (1000 * 60)); const diffHours = Math.floor(diffMs / (1000 * 60 * 60)); const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24)); if (diffMins < 1) return 'just now'; if (diffMins < 60) return `${diffMins}m ago`; if (diffHours < 24) return `${diffHours}h ago`; return `${diffDays}d ago`; } // Simple status command const statusCommand = new commander_1.Command('status'); exports.statusCommand = statusCommand; statusCommand .description('Quick status overview') .option('--visual', 'Show visual indicators') .action(async (options) => { try { if (options.visual) { console.log('šŸŽÆ Alnilam Status'); console.log('═'.repeat(40)); console.log('šŸ“Š For full dashboard: alnl dashboard'); console.log('šŸ”„ For momentum: alnl evaluate'); console.log('šŸ“‹ For planning: alnl plan'); console.log('šŸŽÆ For goals: alnl goal list'); } else { console.log('Use --visual for enhanced display'); } } catch (error) { console.error('Error:', error.message); process.exit(1); } });