UNPKG

pr-vibe

Version:

AI-powered PR review responder that vibes with CodeRabbit, DeepSource, and other bots to automate repetitive feedback

87 lines (73 loc) • 3.43 kB
#!/usr/bin/env node import chalk from 'chalk'; import ora from 'ora'; import { demoPRData, demoPatterns, demoBotResponses, getDemoSummary } from './demo-data.js'; export async function runDemo() { console.log('\nšŸŽµ ' + chalk.magenta('Welcome to pr-vibe!') + ' Let\'s see how it handles bot comments.\n'); // Simulate fetching PR const fetchSpinner = ora('Fetching PR #42 from awesome-app/backend...').start(); await sleep(1000); fetchSpinner.succeed('Found PR with 5 bot comments'); console.log('\n' + chalk.gray('─'.repeat(60)) + '\n'); console.log(chalk.bold('PR #42:'), demoPRData.title); console.log(chalk.gray(`By @${demoPRData.author} • ${demoPRData.repository}`)); console.log('\n' + chalk.gray('─'.repeat(60)) + '\n'); // Show bot comments console.log(chalk.yellow('šŸ“‹ Bot Comments Found:\n')); for (const comment of demoPRData.comments) { console.log(` ${chalk.cyan(`@${comment.user.login}`)}: ${truncate(comment.body, 60)}`); console.log(` ${chalk.gray(`${comment.path}:${comment.line}`)}\n`); } await sleep(1500); // Simulate pattern analysis const analyzeSpinner = ora('Analyzing patterns and preparing responses...').start(); await sleep(1500); analyzeSpinner.succeed('Analysis complete!'); console.log('\n' + chalk.green('✨ Actions Taken:\n')); // Show decisions for (const [commentId, response] of Object.entries(demoBotResponses)) { const comment = demoPRData.comments[parseInt(commentId) - 1]; const icon = getDecisionIcon(response.decision); console.log(`${icon} ${chalk.bold(response.decision)}: ${chalk.cyan(`@${comment.user.login}`)}`); console.log(` → ${response.response}`); if (response.fix) { console.log(chalk.gray(` → Applied fix: ${response.fix}`)); } if (response.pattern_learned) { console.log(chalk.magenta(' → Pattern learned for future PRs')); } console.log(); await sleep(800); } // Show summary const summary = getDemoSummary(); console.log(chalk.gray('─'.repeat(60)) + '\n'); console.log(chalk.bold.green('šŸ“Š Summary:\n')); console.log(` ⚔ Time saved: ${chalk.yellow(`${summary.time_saved_minutes} minutes`)}`); console.log(` šŸ”§ Auto-fixed: ${chalk.green(summary.auto_fixed)}`); console.log(` šŸ’¬ Explained: ${chalk.blue(summary.rejected_with_explanation)}`); console.log(` šŸ“ Deferred: ${chalk.gray(summary.deferred)}`); console.log(` 🚨 Escalated: ${chalk.red(summary.escalated)}`); console.log(` 🧠 Patterns learned: ${chalk.magenta(summary.patterns_learned)}`); console.log('\n' + chalk.gray('─'.repeat(60)) + '\n'); console.log(chalk.bold('šŸš€ Ready to try on your own PRs?\n')); console.log(` 1. Install: ${chalk.cyan('npm install -g pr-vibe')}`); console.log(` 2. Set up: ${chalk.cyan('pr-vibe auth')} ${chalk.gray('(30 seconds)')}`); console.log(` 3. Use it: ${chalk.cyan('pr-vibe pr <number>')}`); console.log('\n' + chalk.gray('Learn more at https://github.com/stroupaloop/pr-vibe') + '\n'); } function getDecisionIcon(decision) { const icons = { AUTO_FIX: 'šŸ”§', REJECT: 'āŒ', DEFER: 'šŸ“', ESCALATE: '🚨' }; return icons[decision] || '•'; } function truncate(str, length) { return str.length > length ? str.substring(0, length) + '...' : str; } function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); }