alnilam-cli
Version:
Git-native AI career coach that converts multi-year ambitions into weekly execution
69 lines (68 loc) ⢠2.93 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.askcoachCommand = void 0;
const commander_1 = require("commander");
const auth_1 = require("../lib/auth");
exports.askcoachCommand = new commander_1.Command('askcoach')
.description('Test ChatGPT coaching endpoint')
.option('--json', 'Output raw JSON response')
.action(async (options) => {
try {
const authToken = await (0, auth_1.getCurrentAuthToken)();
if (!authToken) {
console.error('ā Not authenticated. Run `alnl auth login` first.');
process.exit(1);
}
console.log('š¤ Fetching coaching data...');
// Use Cloudflare Worker API directly for askcoach
const workerUrl = 'https://alnilam-api-prod.sergio-69a.workers.dev';
// Make request to askcoach endpoint
const response = await fetch(`${workerUrl}/api/v1/askcoach`, {
method: 'GET',
headers: {
'Authorization': `Bearer ${authToken}`,
'Content-Type': 'application/json',
},
});
if (!response.ok) {
const errorData = await response.text();
console.error(`ā API Error (${response.status}): ${errorData}`);
process.exit(1);
}
const data = await response.json();
if (options.json) {
console.log(JSON.stringify(data, null, 2));
return;
}
// Format for human reading
console.log('\n' + data.coaching_summary.greeting);
if (data.coaching_summary.next_actions.length > 0) {
console.log('\nšÆ Next Actions:');
data.coaching_summary.next_actions.forEach((action, i) => {
const daysText = action.days_remaining ?
` (${action.days_remaining} days remaining)` : '';
console.log(` ${i + 1}. ${action.title} [${action.horizon}]${daysText}`);
if (action.progress > 0) {
console.log(` Progress: ${action.progress}%`);
}
});
}
const momentum = data.coaching_summary.recent_momentum;
console.log(`\nš Momentum Score: ${momentum.score}`);
console.log(`š Evidence This Week: ${momentum.evidence_count_this_week}`);
if (momentum.last_evidence) {
console.log(`š Last Evidence: ${momentum.last_evidence.description} (${momentum.last_evidence.type})`);
}
if (data.coaching_summary.recommendations.length > 0) {
console.log('\nš” Recommendations:');
data.coaching_summary.recommendations.forEach((rec) => {
console.log(` ⢠${rec.message}`);
});
}
console.log('\n⨠Ready to use in ChatGPT!');
}
catch (error) {
console.error('ā Error:', error.message);
process.exit(1);
}
});