claudmax 1.0.2 → 1.0.3

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 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -413,8 +413,110 @@ function printBanner() {
413
413
  console.log('');
414
414
  }
415
415
 
416
+ // ── CLI argument parsing ────────────────────────────────────────────────────────
417
+ const args = process.argv.slice(2);
418
+ const command = args[0];
419
+
420
+ // ── Status command ─────────────────────────────────────────────────────────────
421
+ async function showStatus() {
422
+ const config = readJson(CONFIG_FILE);
423
+ if (!config || !config.apiKey) {
424
+ console.log(`\n${WARN} No API key configured. Run ${C.bold('npx claudmax')} first.\n`);
425
+ process.exit(1);
426
+ }
427
+
428
+ console.log(`\n${C.magenta('\u2554' + '\u2550'.repeat(48) + '\u2557')}`);
429
+ console.log(C.magenta('\u2551') + C.bold(' \u2726 ClaudMax Status \u2726 ') + C.magenta('\u2551'));
430
+ console.log(C.magenta('\u255A' + '\u2550'.repeat(48) + '\u255D'));
431
+ console.log('');
432
+
433
+ // Fetch key status
434
+ const body = JSON.stringify({ apiKey: config.apiKey });
435
+ const postData = Buffer.from(body);
436
+
437
+ const options = {
438
+ hostname: 'api.claudmax.pro',
439
+ port: 443,
440
+ path: '/v1/key-status',
441
+ method: 'POST',
442
+ headers: {
443
+ 'Content-Type': 'application/json',
444
+ 'Content-Length': postData.length,
445
+ 'User-Agent': 'ClaudMax-CLI/1.0.0',
446
+ },
447
+ timeout: 15000,
448
+ };
449
+
450
+ return new Promise((resolve) => {
451
+ const req = https.request(options, (res) => {
452
+ let data = '';
453
+ res.on('data', (chunk) => { data += chunk; });
454
+ res.on('end', () => {
455
+ try {
456
+ const json = JSON.parse(data);
457
+ if (res.statusCode === 200) {
458
+ const pct = json.tokensLimit > 0 ? Math.min(100, (json.tokensUsed / json.tokensLimit) * 100) : 0;
459
+ const tierColors = { free: C.dim('Gray'), '5x': C.cyan('Blue'), '20x': C.magenta('Purple'), unlimited: C.green('Gold') };
460
+ console.log(` ${CHECK} ${C.green('API Key is active')}`);
461
+ console.log(` ${INFO} Name: ${C.bold(json.name || 'ClaudMax Key')}`);
462
+ console.log(` ${INFO} Prefix: ${C.magenta(json.prefix)}••••••`);
463
+ console.log(` ${INFO} Tier: ${tierColors[json.tier] || C.dim('Free')} (${C.bold(json.tier?.toUpperCase() || 'FREE')})`);
464
+ console.log(` ${INFO} Status: ${json.isActive ? C.green('Active') : C.red('Inactive')}`);
465
+ console.log('');
466
+ console.log(` ${C.bold('Usage (5h window):')}`);
467
+ const barLen = 30;
468
+ const filled = Math.round((pct / 100) * barLen);
469
+ const bar = C.purple('\u2588'.repeat(filled)) + C.dim('\u2591'.repeat(barLen - filled));
470
+ console.log(` ${bar} ${C.dim(`${pct.toFixed(1)}%`)}`);
471
+ console.log(` ${INFO} Requests: ${C.cyan(json.requestsUsed?.toLocaleString() || 0)} / ${C.cyan(json.requestsLimit?.toLocaleString() || 'N/A')}`);
472
+ console.log(` ${INFO} Tokens: ${C.cyan((json.tokensUsed || 0).toLocaleString())} / ${C.cyan((json.tokensLimit || 0).toLocaleString())}`);
473
+ console.log('');
474
+ if (json.windowResetAt) {
475
+ const reset = new Date(json.windowResetAt);
476
+ console.log(` ${INFO} Resets: ${C.dim(reset.toLocaleString())}`);
477
+ }
478
+ } else {
479
+ console.log(` ${CROSS} ${C.red('Failed to fetch status: ' + (json.error || `HTTP ${res.statusCode}`))}`);
480
+ }
481
+ } catch {
482
+ console.log(` ${CROSS} ${C.red('Failed to parse response')}`);
483
+ }
484
+ console.log('');
485
+ resolve();
486
+ });
487
+ });
488
+ req.on('error', (err) => {
489
+ console.log(` ${WARN} ${C.yellow('Network error: ' + err.message)}`);
490
+ console.log('');
491
+ resolve();
492
+ });
493
+ req.on('timeout', () => { req.destroy(); console.log(` ${CROSS} ${C.red('Request timed out')}\n`); resolve(); });
494
+ req.write(postData);
495
+ req.end();
496
+ });
497
+ }
498
+
499
+ // ── Help ───────────────────────────────────────────────────────────────────────
500
+ function showHelp() {
501
+ console.log(`\n${C.bold('ClaudMax CLI')} — Configure Claude Code and other IDEs to use ClaudMax API.\n`);
502
+ console.log(` ${C.cyan('npx claudmax')} ${C.dim('Launch the interactive setup wizard')}`);
503
+ console.log(` ${C.cyan('npx claudmax status')} ${C.dim('Check your API key usage and limits')}`);
504
+ console.log(` ${C.cyan('npx claudmax --help')} ${C.dim('Show this help message')}`);
505
+ console.log('');
506
+ }
507
+
416
508
  // ── Main ──────────────────────────────────────────────────────────────────────
417
509
  async function main() {
510
+ if (command === 'status') {
511
+ await showStatus();
512
+ return;
513
+ }
514
+ if (command === '--help' || command === '-h') {
515
+ showHelp();
516
+ return;
517
+ }
518
+
519
+ // Default: interactive setup wizard
418
520
  const rl = createRL();
419
521
 
420
522
  printBanner();
@@ -473,7 +575,6 @@ async function main() {
473
575
 
474
576
  // ── Step 2: API key prompt ───────────────────────────────────────────────
475
577
  console.log(C.bold('Step 2: Enter your ClaudMax API key\n'));
476
- console.log(` ${INFO} Get your API key from the ${C.bold('ClaudMax Admin Dashboard')}: ${C.cyan('https://claudmax.pro/admin/dashboard')}`);
477
578
  console.log('');
478
579
 
479
580
  let apiKey = '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claudmax",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "ClaudMax CLI — Configure Claude Code, Cursor, Windsurf, Cline, and Roo Code to use ClaudMax API gateway with one command",
5
5
  "main": "index.js",
6
6
  "bin": {