@snapcommit/cli 3.9.17 → 3.9.18

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.
@@ -861,12 +861,73 @@ async function executeGitHubCommand(intent) {
861
861
  prNumber = await github.findPRNumber('current');
862
862
  if (!prNumber) {
863
863
  console.log(chalk_1.default.red('\n❌ No PR found for current branch\n'));
864
+ console.log(chalk_1.default.white('Why this fails:'));
865
+ console.log(chalk_1.default.gray(' • This branch doesn\'t have an open PR\n'));
866
+ console.log(chalk_1.default.cyan('💡 Here\'s what to do:\n'));
867
+ console.log(chalk_1.default.white('1. Check if a PR exists:'));
868
+ console.log(chalk_1.default.cyan(' show all PRs\n'));
869
+ console.log(chalk_1.default.white('2. Or create a PR first:'));
870
+ console.log(chalk_1.default.cyan(' create a PR to main\n'));
871
+ console.log(chalk_1.default.white('3. Then merge it:'));
872
+ console.log(chalk_1.default.cyan(' merge my PR\n'));
864
873
  return;
865
874
  }
866
875
  }
867
876
  console.log(chalk_1.default.blue(`\n🔄 Merging PR #${prNumber}...`));
868
- await github.mergePullRequest(prNumber);
869
- console.log(chalk_1.default.green(`✓ PR #${prNumber} merged\n`));
877
+ try {
878
+ await github.mergePullRequest(prNumber);
879
+ console.log(chalk_1.default.green(`✓ PR #${prNumber} merged\n`));
880
+ }
881
+ catch (error) {
882
+ console.log(chalk_1.default.red('\n❌ Cannot merge PR\n'));
883
+ const errorMsg = error.message?.toLowerCase() || '';
884
+ if (errorMsg.includes('not mergeable') || errorMsg.includes('merge conflict')) {
885
+ console.log(chalk_1.default.yellow('⚠️ PR has merge conflicts!\n'));
886
+ console.log(chalk_1.default.white('Why this fails:'));
887
+ console.log(chalk_1.default.gray(' • Changes in this PR conflict with main branch'));
888
+ console.log(chalk_1.default.gray(' • You need to resolve conflicts first\n'));
889
+ console.log(chalk_1.default.cyan('💡 Here\'s what to do:\n'));
890
+ console.log(chalk_1.default.white('1. Pull latest changes from main:'));
891
+ console.log(chalk_1.default.cyan(' merge main into this branch\n'));
892
+ console.log(chalk_1.default.white('2. SnapCommit will auto-resolve conflicts'));
893
+ console.log(chalk_1.default.white('3. Then try merging PR again:'));
894
+ console.log(chalk_1.default.cyan(' merge my PR\n'));
895
+ }
896
+ else if (errorMsg.includes('required status check') || errorMsg.includes('checks')) {
897
+ console.log(chalk_1.default.yellow('⚠️ CI checks haven\'t passed!\n'));
898
+ console.log(chalk_1.default.white('Why this fails:'));
899
+ console.log(chalk_1.default.gray(' • GitHub requires all checks to pass before merging'));
900
+ console.log(chalk_1.default.gray(' • Your tests/build might be failing\n'));
901
+ console.log(chalk_1.default.cyan('💡 Here\'s what to do:\n'));
902
+ console.log(chalk_1.default.white('1. Check CI status:'));
903
+ console.log(chalk_1.default.cyan(' check if my build passed\n'));
904
+ console.log(chalk_1.default.white('2. Fix any failing tests'));
905
+ console.log(chalk_1.default.white('3. Push fixes:'));
906
+ console.log(chalk_1.default.cyan(' commit and push changes\n'));
907
+ console.log(chalk_1.default.white('4. Then try merging again'));
908
+ }
909
+ else if (errorMsg.includes('review') || errorMsg.includes('approval')) {
910
+ console.log(chalk_1.default.yellow('⚠️ PR needs approval!\n'));
911
+ console.log(chalk_1.default.white('Why this fails:'));
912
+ console.log(chalk_1.default.gray(' • Repository requires code review approval'));
913
+ console.log(chalk_1.default.gray(' • You need a teammate to review and approve\n'));
914
+ console.log(chalk_1.default.cyan('💡 Here\'s what to do:\n'));
915
+ console.log(chalk_1.default.white('1. Ask a teammate to review your PR'));
916
+ console.log(chalk_1.default.white('2. Wait for approval'));
917
+ console.log(chalk_1.default.white('3. Then try merging again\n'));
918
+ }
919
+ else {
920
+ console.log(chalk_1.default.white('Common reasons:'));
921
+ console.log(chalk_1.default.gray(' • CI checks still running'));
922
+ console.log(chalk_1.default.gray(' • Required reviews not approved'));
923
+ console.log(chalk_1.default.gray(' • Merge conflicts exist\n'));
924
+ console.log(chalk_1.default.cyan('💡 Try:\n'));
925
+ console.log(chalk_1.default.cyan(' check if my build passed\n'));
926
+ if (error.message) {
927
+ console.log(chalk_1.default.gray(`Error: ${error.message}\n`));
928
+ }
929
+ }
930
+ }
870
931
  break;
871
932
  case 'ci_check':
872
933
  case 'ci_status':
@@ -879,26 +940,52 @@ async function executeGitHubCommand(intent) {
879
940
  const totalChecks = ciStatus.checks.length;
880
941
  const failedChecks = ciStatus.checks.filter((c) => c.conclusion === 'failure').length;
881
942
  if (state === 'success' || (totalChecks > 0 && failedChecks === 0)) {
882
- console.log(chalk_1.default.green(`✓ All checks passed (${totalChecks} checks)\n`));
943
+ console.log(chalk_1.default.green(`✅ All checks passed (${totalChecks} checks)\n`));
883
944
  }
884
945
  else if (state === 'pending') {
885
946
  console.log(chalk_1.default.yellow(`⏳ Checks running (${totalChecks} checks)\n`));
947
+ console.log(chalk_1.default.gray('💡 Wait a few minutes and check again\n'));
886
948
  }
887
949
  else {
888
950
  console.log(chalk_1.default.red(`❌ ${failedChecks}/${totalChecks} checks failed\n`));
951
+ console.log(chalk_1.default.white('Why this matters:'));
952
+ console.log(chalk_1.default.gray(' • Failed checks block PR merging'));
953
+ console.log(chalk_1.default.gray(' • Something is broken in your code\n'));
954
+ console.log(chalk_1.default.cyan('💡 Here\'s what to do:\n'));
955
+ console.log(chalk_1.default.white('1. View full details on GitHub:'));
956
+ console.log(chalk_1.default.cyan(' show my PR\n'));
957
+ console.log(chalk_1.default.white('2. Fix the failing tests/build'));
958
+ console.log(chalk_1.default.white('3. Push the fixes:'));
959
+ console.log(chalk_1.default.cyan(' commit and push changes\n'));
960
+ console.log(chalk_1.default.white('4. Check status again:'));
961
+ console.log(chalk_1.default.cyan(' check if my build passed\n'));
889
962
  }
890
963
  }
891
964
  catch (error) {
892
- console.log(chalk_1.default.gray(' No CI checks found\n'));
965
+ console.log(chalk_1.default.gray('\n✓ No CI checks configured\n'));
966
+ console.log(chalk_1.default.white('This is fine! Not all repos need CI.\n'));
893
967
  }
894
968
  break;
895
969
  case 'issue_create':
896
970
  case 'create_issue':
897
971
  case 'new_issue':
898
972
  console.log(chalk_1.default.blue('\n🔄 Creating issue...'));
899
- const issue = await github.createIssue(intent.options || {});
900
- console.log(chalk_1.default.green(`✓ Issue #${issue.number} created`));
901
- console.log(chalk_1.default.cyan(` ${issue.html_url}\n`));
973
+ try {
974
+ const issue = await github.createIssue(intent.options || {});
975
+ console.log(chalk_1.default.green(`✓ Issue #${issue.number} created`));
976
+ console.log(chalk_1.default.cyan(` ${issue.html_url}\n`));
977
+ }
978
+ catch (error) {
979
+ console.log(chalk_1.default.red('\n❌ Cannot create issue\n'));
980
+ console.log(chalk_1.default.white('Common reasons:'));
981
+ console.log(chalk_1.default.gray(' • Missing title or description'));
982
+ console.log(chalk_1.default.gray(' • No permission to create issues\n'));
983
+ console.log(chalk_1.default.cyan('💡 Try:\n'));
984
+ console.log(chalk_1.default.cyan(' create an issue with title "Bug in login" and description "Users cant login"\n'));
985
+ if (error.message) {
986
+ console.log(chalk_1.default.gray(`Error: ${error.message}\n`));
987
+ }
988
+ }
902
989
  break;
903
990
  case 'issue_list':
904
991
  case 'list_issues':
@@ -1308,7 +1395,76 @@ async function executeGitHubCommand(intent) {
1308
1395
  }
1309
1396
  }
1310
1397
  catch (error) {
1311
- console.log(chalk_1.default.red(`\n❌ ${error.message}\n`));
1398
+ // Intelligent error handling - NEVER show raw API errors
1399
+ const errorMsg = error.message?.toLowerCase() || '';
1400
+ // GitHub authentication errors
1401
+ if (errorMsg.includes('bad credentials') || errorMsg.includes('unauthorized') || errorMsg.includes('401')) {
1402
+ console.log(chalk_1.default.red('\n❌ GitHub authentication failed\n'));
1403
+ console.log(chalk_1.default.white('Why this fails:'));
1404
+ console.log(chalk_1.default.gray(' • Your GitHub connection expired'));
1405
+ console.log(chalk_1.default.gray(' • Invalid or revoked access token\n'));
1406
+ console.log(chalk_1.default.cyan('💡 Here\'s what to do:\n'));
1407
+ console.log(chalk_1.default.white('1. Reconnect GitHub:'));
1408
+ console.log(chalk_1.default.cyan(' github connect\n'));
1409
+ console.log(chalk_1.default.white('2. Then try your command again\n'));
1410
+ return;
1411
+ }
1412
+ // Permission errors
1413
+ if (errorMsg.includes('not found') || errorMsg.includes('404')) {
1414
+ console.log(chalk_1.default.red('\n❌ Repository or resource not found\n'));
1415
+ console.log(chalk_1.default.white('Common reasons:'));
1416
+ console.log(chalk_1.default.gray(' • Repository is private and you don\'t have access'));
1417
+ console.log(chalk_1.default.gray(' • PR/issue number doesn\'t exist'));
1418
+ console.log(chalk_1.default.gray(' • Repository name changed\n'));
1419
+ console.log(chalk_1.default.cyan('💡 Try:\n'));
1420
+ console.log(chalk_1.default.white('• Check repository access'));
1421
+ console.log(chalk_1.default.white('• Verify PR/issue numbers:'));
1422
+ console.log(chalk_1.default.cyan(' show all PRs\n'));
1423
+ return;
1424
+ }
1425
+ // Rate limit errors
1426
+ if (errorMsg.includes('rate limit') || errorMsg.includes('403')) {
1427
+ console.log(chalk_1.default.red('\n❌ GitHub rate limit exceeded\n'));
1428
+ console.log(chalk_1.default.white('Why this fails:'));
1429
+ console.log(chalk_1.default.gray(' • Too many API requests in a short time'));
1430
+ console.log(chalk_1.default.gray(' • GitHub limits API calls per hour\n'));
1431
+ console.log(chalk_1.default.cyan('💡 Here\'s what to do:\n'));
1432
+ console.log(chalk_1.default.white('Wait 10-15 minutes and try again'));
1433
+ console.log(chalk_1.default.gray('(Rate limits reset hourly)\n'));
1434
+ return;
1435
+ }
1436
+ // Validation errors
1437
+ if (errorMsg.includes('validation') || errorMsg.includes('invalid')) {
1438
+ console.log(chalk_1.default.red('\n❌ Invalid input\n'));
1439
+ console.log(chalk_1.default.white('Common reasons:'));
1440
+ console.log(chalk_1.default.gray(' • Missing required information (title, body, etc.)'));
1441
+ console.log(chalk_1.default.gray(' • Invalid format or parameters\n'));
1442
+ console.log(chalk_1.default.cyan('💡 Try:\n'));
1443
+ console.log(chalk_1.default.white('Be more specific with your command'));
1444
+ console.log(chalk_1.default.gray('Example: "create a PR with title \'Fix bug\' and description \'Fixes #123\'"\n'));
1445
+ return;
1446
+ }
1447
+ // Network errors
1448
+ if (errorMsg.includes('network') || errorMsg.includes('fetch failed') || errorMsg.includes('econnrefused')) {
1449
+ console.log(chalk_1.default.red('\n❌ Network error\n'));
1450
+ console.log(chalk_1.default.white('Why this fails:'));
1451
+ console.log(chalk_1.default.gray(' • No internet connection'));
1452
+ console.log(chalk_1.default.gray(' • GitHub API is down (rare)\n'));
1453
+ console.log(chalk_1.default.cyan('💡 Here\'s what to do:\n'));
1454
+ console.log(chalk_1.default.white('1. Check your internet connection'));
1455
+ console.log(chalk_1.default.white('2. Try again in a few seconds\n'));
1456
+ return;
1457
+ }
1458
+ // Generic fallback with helpful context
1459
+ console.log(chalk_1.default.red('\n❌ Command failed\n'));
1460
+ console.log(chalk_1.default.white('What happened:'));
1461
+ console.log(chalk_1.default.gray(` ${error.message}\n`));
1462
+ console.log(chalk_1.default.cyan('💡 Try:\n'));
1463
+ console.log(chalk_1.default.white('• Check your command:'));
1464
+ console.log(chalk_1.default.cyan(' what branch am i on'));
1465
+ console.log(chalk_1.default.cyan(' show last 5 commits\n'));
1466
+ console.log(chalk_1.default.white('• Reconnect GitHub if needed:'));
1467
+ console.log(chalk_1.default.cyan(' github connect\n'));
1312
1468
  }
1313
1469
  }
1314
1470
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snapcommit/cli",
3
- "version": "3.9.17",
3
+ "version": "3.9.18",
4
4
  "description": "Instant AI commits. Beautiful progress tracking. Never write commit messages again.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {