rampup 0.1.9 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +102 -32
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1126,8 +1126,19 @@ Be friendly, practical, and reference specific files when relevant. If asked abo
1126
1126
 
1127
1127
  console.log(chalk.cyan('\nšŸ‘‹ Ending voice session...'));
1128
1128
  console.log(chalk.dim(`Session: ${totalSessionMinutes.toFixed(2)} min`));
1129
- console.log(chalk.dim(`Total usage: ${usage.totalMinutes.toFixed(2)} min\n`));
1130
1129
 
1130
+ // Show credits used and remaining
1131
+ try {
1132
+ const balance = await getTokenBalance();
1133
+ if (balance?.balances?.[0]) {
1134
+ const credits = balance.balances[0];
1135
+ const creditsUsed = Math.max(2, Math.ceil(totalSessionMinutes * 4));
1136
+ console.log(chalk.dim(`Credits used: ${creditsUsed}`));
1137
+ console.log(chalk.cyan(`Credits remaining: ${credits.balance}`));
1138
+ }
1139
+ } catch {}
1140
+
1141
+ console.log();
1131
1142
  process.exit(0);
1132
1143
  }
1133
1144
 
@@ -1386,47 +1397,106 @@ program
1386
1397
  console.log(banner);
1387
1398
  console.log(chalk.bold.blue('⚔ Upgrade Plan\n'));
1388
1399
 
1389
- // Check current usage
1390
- const usageFile = path.join(process.env.HOME, '.ramp', 'voice-usage.json');
1391
- let usage = { totalMinutes: 0 };
1400
+ const ENTITLEMENT_API_URL = process.env.ENTITLEMENT_API_URL ||
1401
+ 'https://entitlement-service.rian-19c.workers.dev';
1402
+
1403
+ // Check if user is logged in
1404
+ const token = await getIdToken();
1405
+ if (!token) {
1406
+ console.log(chalk.yellow('Please log in first to upgrade your plan.\n'));
1407
+ console.log(chalk.dim('Run: ramp login\n'));
1408
+ return;
1409
+ }
1410
+
1411
+ const spinner = ora('Loading plans...').start();
1412
+
1392
1413
  try {
1393
- usage = JSON.parse(await fs.readFile(usageFile, 'utf8'));
1394
- } catch {}
1414
+ // Get current balance
1415
+ const balance = await getTokenBalance();
1416
+ const currentCredits = balance?.balances?.[0]?.balance || 0;
1395
1417
 
1396
- console.log(chalk.bold('Current: Free Tier'));
1397
- console.log(chalk.dim(` Voice: ${usage.totalMinutes.toFixed(2)} / 10 min used\n`));
1418
+ // Fetch plans from API
1419
+ const plansResponse = await fetch(`${ENTITLEMENT_API_URL}/billing/ramp/plans`);
1420
+ if (!plansResponse.ok) {
1421
+ throw new Error('Failed to fetch plans');
1422
+ }
1423
+ const { plans } = await plansResponse.json();
1398
1424
 
1399
- console.log(chalk.bold('Available Plans:\n'));
1425
+ spinner.succeed('Plans loaded!\n');
1400
1426
 
1401
- console.log(chalk.cyan(' Starter - $29/mo'));
1402
- console.log(chalk.dim(' • 100 voice minutes'));
1403
- console.log(chalk.dim(' • Unlimited text queries'));
1404
- console.log(chalk.dim(' • 5 team members\n'));
1427
+ // Show current balance
1428
+ console.log(chalk.bold('Current Balance:'), chalk.cyan(`${currentCredits} credits\n`));
1405
1429
 
1406
- console.log(chalk.cyan(' Pro - $99/mo'));
1407
- console.log(chalk.dim(' • 500 voice minutes'));
1408
- console.log(chalk.dim(' • Unlimited everything'));
1409
- console.log(chalk.dim(' • 25 team members'));
1410
- console.log(chalk.dim(' • Priority support\n'));
1430
+ console.log(chalk.bold('Available Plans:\n'));
1411
1431
 
1412
- console.log(chalk.cyan(' Enterprise - Custom'));
1413
- console.log(chalk.dim(' • Unlimited voice minutes'));
1414
- console.log(chalk.dim(' • Unlimited team members'));
1415
- console.log(chalk.dim(' • SSO, audit logs'));
1416
- console.log(chalk.dim(' • Dedicated support\n'));
1432
+ // Display plans
1433
+ for (const plan of plans) {
1434
+ const priceStr = plan.price === 0 ? 'Free' : `$${plan.price}/mo`;
1435
+ const label = plan.popular ? `${plan.name} ⭐` : plan.name;
1436
+ console.log(chalk.cyan(` ${label} - ${priceStr}`));
1437
+ for (const feature of plan.features) {
1438
+ console.log(chalk.dim(` • ${feature}`));
1439
+ }
1440
+ console.log();
1441
+ }
1417
1442
 
1418
- console.log(chalk.dim('Upgrade at: https://rampup.dev/pricing\n'));
1443
+ // Get paid plans for selection
1444
+ const paidPlans = plans.filter(p => p.price > 0);
1419
1445
 
1420
- const { openBrowser } = await inquirer.prompt([{
1421
- type: 'confirm',
1422
- name: 'openBrowser',
1423
- message: 'Open pricing page?',
1424
- default: true
1425
- }]);
1446
+ const { selectedPlan } = await inquirer.prompt([{
1447
+ type: 'list',
1448
+ name: 'selectedPlan',
1449
+ message: 'Select a plan to upgrade:',
1450
+ choices: [
1451
+ ...paidPlans.map(p => ({
1452
+ name: `${p.name} ($${p.price}/mo) - ${p.credits} credits`,
1453
+ value: p.id
1454
+ })),
1455
+ { name: 'Cancel', value: null }
1456
+ ]
1457
+ }]);
1458
+
1459
+ if (!selectedPlan) {
1460
+ console.log(chalk.dim('\nNo plan selected.\n'));
1461
+ return;
1462
+ }
1463
+
1464
+ // Create checkout session
1465
+ const checkoutSpinner = ora('Creating checkout session...').start();
1466
+
1467
+ const checkoutResponse = await fetch(`${ENTITLEMENT_API_URL}/billing/ramp/checkout`, {
1468
+ method: 'POST',
1469
+ headers: {
1470
+ 'Authorization': `Bearer ${token}`,
1471
+ 'Content-Type': 'application/json'
1472
+ },
1473
+ body: JSON.stringify({
1474
+ plan: selectedPlan,
1475
+ successUrl: 'https://rampup.dev/billing?checkout=success',
1476
+ cancelUrl: 'https://rampup.dev/pricing?checkout=cancelled'
1477
+ })
1478
+ });
1479
+
1480
+ if (!checkoutResponse.ok) {
1481
+ const error = await checkoutResponse.json().catch(() => ({}));
1482
+ throw new Error(error.message || 'Failed to create checkout session');
1483
+ }
1426
1484
 
1427
- if (openBrowser) {
1485
+ const { url } = await checkoutResponse.json();
1486
+ checkoutSpinner.succeed('Checkout ready!\n');
1487
+
1488
+ console.log(chalk.green('Opening Stripe checkout in your browser...\n'));
1428
1489
  const open = (await import('open')).default;
1429
- await open('https://rampup.dev/pricing');
1490
+ await open(url);
1491
+
1492
+ console.log(chalk.dim('If browser doesn\'t open, visit:'));
1493
+ console.log(chalk.cyan(url));
1494
+ console.log();
1495
+
1496
+ } catch (error) {
1497
+ spinner.fail('Failed to load upgrade options');
1498
+ console.error(chalk.red(error.message));
1499
+ console.log(chalk.dim('\nYou can also upgrade at: https://rampup.dev/pricing\n'));
1430
1500
  }
1431
1501
  });
1432
1502
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rampup",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "Ramp - Understand any codebase in hours. AI-powered developer onboarding CLI.",
5
5
  "type": "module",
6
6
  "bin": {