UNPKG

alnilam-cli

Version:

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

132 lines (131 loc) • 5.92 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.planCommand = void 0; const commander_1 = require("commander"); const api_js_1 = require("../lib/api.js"); const planCommand = new commander_1.Command('plan'); exports.planCommand = planCommand; planCommand .description('Generate and manage weekly plans') .option('--week <week>', 'Target week start date (YYYY-MM-DD), defaults to next week') .option('--force', 'Force regeneration if plan exists') .option('--auto-approve', 'Auto-approve the generated plan') .option('--json', 'Output as JSON') .action(async (options) => { try { console.log('Generating weekly plan...'); const requestData = {}; if (options.week) { requestData.target_week = options.week; } if (options.force) { requestData.force = true; } if (options.autoApprove) { requestData.auto_approve = true; } const response = await api_js_1.apiClient.post('/weekly_planner', requestData); const result = response.data; if (options.json) { console.log(JSON.stringify(result, null, 2)); } else { if (result.success && result.plan) { const plan = result.plan; const metadata = plan.metadata || {}; console.log(`\nšŸ“‹ Weekly Plan for ${metadata.target_week || 'next week'}`); console.log(`Status: ${plan.approved ? 'āœ… Approved' : 'ā³ Pending Approval'}`); if (metadata.proposed_goals && metadata.proposed_goals.length > 0) { console.log('\nšŸŽÆ Proposed Goals:'); metadata.proposed_goals.forEach((goal, index) => { const priorityEmoji = goal.priority === 'high' ? 'šŸ”“' : goal.priority === 'medium' ? '🟔' : '🟢'; console.log(`\n ${index + 1}. ${goal.title} ${priorityEmoji}`); console.log(` ${goal.description}`); console.log(` Estimated: ${goal.estimated_hours}h | Priority: ${goal.priority}`); if (goal.rationale) { console.log(` Rationale: ${goal.rationale}`); } }); } if (metadata.focus_areas && metadata.focus_areas.length > 0) { console.log('\nšŸŽÆ Focus Areas:'); metadata.focus_areas.forEach((area) => { console.log(` • ${area}`); }); } if (metadata.risk_mitigations && metadata.risk_mitigations.length > 0) { console.log('\nšŸ›”ļø Risk Mitigations:'); metadata.risk_mitigations.forEach((mitigation) => { console.log(` • ${mitigation}`); }); } if (metadata.success_metrics && metadata.success_metrics.length > 0) { console.log('\nšŸ“Š Success Metrics:'); metadata.success_metrics.forEach((metric) => { console.log(` • ${metric}`); }); } console.log(`\nšŸ’° Estimated Cost: $${metadata.estimated_cost || 0}`); console.log(`šŸ¤– Generated: ${new Date(plan.created_at).toLocaleString()}`); if (!plan.approved) { console.log('\nšŸ’” To approve this plan, update the nudge in your workflow system.'); } } else { console.log(`Error: ${result.error || 'Unknown error'}`); process.exit(1); } } } catch (error) { console.error('Error generating plan:', error.response?.data?.error || error.message); process.exit(1); } }); // Add subcommand for viewing existing plans const listPlanCommand = new commander_1.Command('list'); listPlanCommand .description('List recent weekly plans') .option('--limit <n>', 'Number of plans to show', '5') .option('--json', 'Output as JSON') .action(async (options) => { try { const limit = parseInt(options.limit); const response = await api_js_1.restClient.get('/nudges', { params: { type: 'eq.weekly_plan', order: 'created_at.desc', limit: limit } }); const result = response.data; if (options.json) { console.log(JSON.stringify(result, null, 2)); } else { if (Array.isArray(result) && result.length > 0) { console.log(`\nšŸ“‹ Recent Weekly Plans (${result.length}):`); result.forEach((plan, index) => { const metadata = plan.metadata || {}; const status = plan.approved ? 'āœ… Approved' : 'ā³ Pending'; const targetWeek = metadata.target_week || 'Unknown'; const goalCount = metadata.proposed_goals?.length || 0; console.log(`\n${index + 1}. Week ${targetWeek} - ${status}`); console.log(` Goals: ${goalCount} | Cost: $${metadata.estimated_cost || 0}`); console.log(` Created: ${new Date(plan.created_at).toLocaleString()}`); }); } else { console.log('No weekly plans found.'); } } } catch (error) { console.error('Error listing plans:', error.response?.data?.error || error.message); process.exit(1); } }); planCommand.addCommand(listPlanCommand); // Import and add review command const plan_review_js_1 = require("./plan-review.js"); planCommand.addCommand(plan_review_js_1.planReviewCommand);