@snapcommit/cli 3.9.17 → 3.9.19

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.
@@ -646,10 +646,21 @@ async function executeGitCommands(commands) {
646
646
  else if (cmd.includes('git stash')) {
647
647
  // Stashing
648
648
  if (cmd.includes('pop') || cmd.includes('apply')) {
649
- console.log(chalk_1.default.green('\n✓ Stash applied\n'));
649
+ // Only show message if there was actually something to pop
650
+ if (output.trim() && !output.includes('No stash entries')) {
651
+ console.log(chalk_1.default.green('\n✓ Stash applied\n'));
652
+ }
650
653
  }
651
- else {
652
- console.log(chalk_1.default.green('\n✓ Changes stashed\n'));
654
+ else if (!cmd.includes('list')) {
655
+ // Check if there was actually something to stash
656
+ if (output.includes('Saved working directory') || output.includes('No local changes')) {
657
+ if (output.includes('No local changes')) {
658
+ // Nothing to stash - that's fine, don't show message
659
+ }
660
+ else {
661
+ console.log(chalk_1.default.green('\n✓ Changes stashed\n'));
662
+ }
663
+ }
653
664
  }
654
665
  }
655
666
  else if (cmd.includes('git reset')) {
@@ -746,6 +757,11 @@ async function executeGitCommands(commands) {
746
757
  console.log(chalk_1.default.gray('💡 Tip: Most conflicts are simple! Just pick the better code.\n'));
747
758
  return;
748
759
  }
760
+ // Skip harmless errors
761
+ if (errorMsg.includes('no stash entries found') || errorMsg.includes('no local changes to save')) {
762
+ // Nothing to stash/pop - that's fine, continue silently
763
+ continue;
764
+ }
749
765
  // Try to auto-fix common errors
750
766
  const fixed = await tryAutoFix(error, cmd);
751
767
  if (!fixed) {
@@ -861,12 +877,73 @@ async function executeGitHubCommand(intent) {
861
877
  prNumber = await github.findPRNumber('current');
862
878
  if (!prNumber) {
863
879
  console.log(chalk_1.default.red('\n❌ No PR found for current branch\n'));
880
+ console.log(chalk_1.default.white('Why this fails:'));
881
+ console.log(chalk_1.default.gray(' • This branch doesn\'t have an open PR\n'));
882
+ console.log(chalk_1.default.cyan('💡 Here\'s what to do:\n'));
883
+ console.log(chalk_1.default.white('1. Check if a PR exists:'));
884
+ console.log(chalk_1.default.cyan(' show all PRs\n'));
885
+ console.log(chalk_1.default.white('2. Or create a PR first:'));
886
+ console.log(chalk_1.default.cyan(' create a PR to main\n'));
887
+ console.log(chalk_1.default.white('3. Then merge it:'));
888
+ console.log(chalk_1.default.cyan(' merge my PR\n'));
864
889
  return;
865
890
  }
866
891
  }
867
892
  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`));
893
+ try {
894
+ await github.mergePullRequest(prNumber);
895
+ console.log(chalk_1.default.green(`✓ PR #${prNumber} merged\n`));
896
+ }
897
+ catch (error) {
898
+ console.log(chalk_1.default.red('\n❌ Cannot merge PR\n'));
899
+ const errorMsg = error.message?.toLowerCase() || '';
900
+ if (errorMsg.includes('not mergeable') || errorMsg.includes('merge conflict')) {
901
+ console.log(chalk_1.default.yellow('⚠️ PR has merge conflicts!\n'));
902
+ console.log(chalk_1.default.white('Why this fails:'));
903
+ console.log(chalk_1.default.gray(' • Changes in this PR conflict with main branch'));
904
+ console.log(chalk_1.default.gray(' • You need to resolve conflicts first\n'));
905
+ console.log(chalk_1.default.cyan('💡 Here\'s what to do:\n'));
906
+ console.log(chalk_1.default.white('1. Pull latest changes from main:'));
907
+ console.log(chalk_1.default.cyan(' merge main into this branch\n'));
908
+ console.log(chalk_1.default.white('2. SnapCommit will auto-resolve conflicts'));
909
+ console.log(chalk_1.default.white('3. Then try merging PR again:'));
910
+ console.log(chalk_1.default.cyan(' merge my PR\n'));
911
+ }
912
+ else if (errorMsg.includes('required status check') || errorMsg.includes('checks')) {
913
+ console.log(chalk_1.default.yellow('⚠️ CI checks haven\'t passed!\n'));
914
+ console.log(chalk_1.default.white('Why this fails:'));
915
+ console.log(chalk_1.default.gray(' • GitHub requires all checks to pass before merging'));
916
+ console.log(chalk_1.default.gray(' • Your tests/build might be failing\n'));
917
+ console.log(chalk_1.default.cyan('💡 Here\'s what to do:\n'));
918
+ console.log(chalk_1.default.white('1. Check CI status:'));
919
+ console.log(chalk_1.default.cyan(' check if my build passed\n'));
920
+ console.log(chalk_1.default.white('2. Fix any failing tests'));
921
+ console.log(chalk_1.default.white('3. Push fixes:'));
922
+ console.log(chalk_1.default.cyan(' commit and push changes\n'));
923
+ console.log(chalk_1.default.white('4. Then try merging again'));
924
+ }
925
+ else if (errorMsg.includes('review') || errorMsg.includes('approval')) {
926
+ console.log(chalk_1.default.yellow('⚠️ PR needs approval!\n'));
927
+ console.log(chalk_1.default.white('Why this fails:'));
928
+ console.log(chalk_1.default.gray(' • Repository requires code review approval'));
929
+ console.log(chalk_1.default.gray(' • You need a teammate to review and approve\n'));
930
+ console.log(chalk_1.default.cyan('💡 Here\'s what to do:\n'));
931
+ console.log(chalk_1.default.white('1. Ask a teammate to review your PR'));
932
+ console.log(chalk_1.default.white('2. Wait for approval'));
933
+ console.log(chalk_1.default.white('3. Then try merging again\n'));
934
+ }
935
+ else {
936
+ console.log(chalk_1.default.white('Common reasons:'));
937
+ console.log(chalk_1.default.gray(' • CI checks still running'));
938
+ console.log(chalk_1.default.gray(' • Required reviews not approved'));
939
+ console.log(chalk_1.default.gray(' • Merge conflicts exist\n'));
940
+ console.log(chalk_1.default.cyan('💡 Try:\n'));
941
+ console.log(chalk_1.default.cyan(' check if my build passed\n'));
942
+ if (error.message) {
943
+ console.log(chalk_1.default.gray(`Error: ${error.message}\n`));
944
+ }
945
+ }
946
+ }
870
947
  break;
871
948
  case 'ci_check':
872
949
  case 'ci_status':
@@ -879,26 +956,52 @@ async function executeGitHubCommand(intent) {
879
956
  const totalChecks = ciStatus.checks.length;
880
957
  const failedChecks = ciStatus.checks.filter((c) => c.conclusion === 'failure').length;
881
958
  if (state === 'success' || (totalChecks > 0 && failedChecks === 0)) {
882
- console.log(chalk_1.default.green(`✓ All checks passed (${totalChecks} checks)\n`));
959
+ console.log(chalk_1.default.green(`✅ All checks passed (${totalChecks} checks)\n`));
883
960
  }
884
961
  else if (state === 'pending') {
885
962
  console.log(chalk_1.default.yellow(`⏳ Checks running (${totalChecks} checks)\n`));
963
+ console.log(chalk_1.default.gray('💡 Wait a few minutes and check again\n'));
886
964
  }
887
965
  else {
888
966
  console.log(chalk_1.default.red(`❌ ${failedChecks}/${totalChecks} checks failed\n`));
967
+ console.log(chalk_1.default.white('Why this matters:'));
968
+ console.log(chalk_1.default.gray(' • Failed checks block PR merging'));
969
+ console.log(chalk_1.default.gray(' • Something is broken in your code\n'));
970
+ console.log(chalk_1.default.cyan('💡 Here\'s what to do:\n'));
971
+ console.log(chalk_1.default.white('1. View full details on GitHub:'));
972
+ console.log(chalk_1.default.cyan(' show my PR\n'));
973
+ console.log(chalk_1.default.white('2. Fix the failing tests/build'));
974
+ console.log(chalk_1.default.white('3. Push the fixes:'));
975
+ console.log(chalk_1.default.cyan(' commit and push changes\n'));
976
+ console.log(chalk_1.default.white('4. Check status again:'));
977
+ console.log(chalk_1.default.cyan(' check if my build passed\n'));
889
978
  }
890
979
  }
891
980
  catch (error) {
892
- console.log(chalk_1.default.gray(' No CI checks found\n'));
981
+ console.log(chalk_1.default.gray('\n✓ No CI checks configured\n'));
982
+ console.log(chalk_1.default.white('This is fine! Not all repos need CI.\n'));
893
983
  }
894
984
  break;
895
985
  case 'issue_create':
896
986
  case 'create_issue':
897
987
  case 'new_issue':
898
988
  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`));
989
+ try {
990
+ const issue = await github.createIssue(intent.options || {});
991
+ console.log(chalk_1.default.green(`✓ Issue #${issue.number} created`));
992
+ console.log(chalk_1.default.cyan(` ${issue.html_url}\n`));
993
+ }
994
+ catch (error) {
995
+ console.log(chalk_1.default.red('\n❌ Cannot create issue\n'));
996
+ console.log(chalk_1.default.white('Common reasons:'));
997
+ console.log(chalk_1.default.gray(' • Missing title or description'));
998
+ console.log(chalk_1.default.gray(' • No permission to create issues\n'));
999
+ console.log(chalk_1.default.cyan('💡 Try:\n'));
1000
+ console.log(chalk_1.default.cyan(' create an issue with title "Bug in login" and description "Users cant login"\n'));
1001
+ if (error.message) {
1002
+ console.log(chalk_1.default.gray(`Error: ${error.message}\n`));
1003
+ }
1004
+ }
902
1005
  break;
903
1006
  case 'issue_list':
904
1007
  case 'list_issues':
@@ -1308,7 +1411,76 @@ async function executeGitHubCommand(intent) {
1308
1411
  }
1309
1412
  }
1310
1413
  catch (error) {
1311
- console.log(chalk_1.default.red(`\n❌ ${error.message}\n`));
1414
+ // Intelligent error handling - NEVER show raw API errors
1415
+ const errorMsg = error.message?.toLowerCase() || '';
1416
+ // GitHub authentication errors
1417
+ if (errorMsg.includes('bad credentials') || errorMsg.includes('unauthorized') || errorMsg.includes('401')) {
1418
+ console.log(chalk_1.default.red('\n❌ GitHub authentication failed\n'));
1419
+ console.log(chalk_1.default.white('Why this fails:'));
1420
+ console.log(chalk_1.default.gray(' • Your GitHub connection expired'));
1421
+ console.log(chalk_1.default.gray(' • Invalid or revoked access token\n'));
1422
+ console.log(chalk_1.default.cyan('💡 Here\'s what to do:\n'));
1423
+ console.log(chalk_1.default.white('1. Reconnect GitHub:'));
1424
+ console.log(chalk_1.default.cyan(' github connect\n'));
1425
+ console.log(chalk_1.default.white('2. Then try your command again\n'));
1426
+ return;
1427
+ }
1428
+ // Permission errors
1429
+ if (errorMsg.includes('not found') || errorMsg.includes('404')) {
1430
+ console.log(chalk_1.default.red('\n❌ Repository or resource not found\n'));
1431
+ console.log(chalk_1.default.white('Common reasons:'));
1432
+ console.log(chalk_1.default.gray(' • Repository is private and you don\'t have access'));
1433
+ console.log(chalk_1.default.gray(' • PR/issue number doesn\'t exist'));
1434
+ console.log(chalk_1.default.gray(' • Repository name changed\n'));
1435
+ console.log(chalk_1.default.cyan('💡 Try:\n'));
1436
+ console.log(chalk_1.default.white('• Check repository access'));
1437
+ console.log(chalk_1.default.white('• Verify PR/issue numbers:'));
1438
+ console.log(chalk_1.default.cyan(' show all PRs\n'));
1439
+ return;
1440
+ }
1441
+ // Rate limit errors
1442
+ if (errorMsg.includes('rate limit') || errorMsg.includes('403')) {
1443
+ console.log(chalk_1.default.red('\n❌ GitHub rate limit exceeded\n'));
1444
+ console.log(chalk_1.default.white('Why this fails:'));
1445
+ console.log(chalk_1.default.gray(' • Too many API requests in a short time'));
1446
+ console.log(chalk_1.default.gray(' • GitHub limits API calls per hour\n'));
1447
+ console.log(chalk_1.default.cyan('💡 Here\'s what to do:\n'));
1448
+ console.log(chalk_1.default.white('Wait 10-15 minutes and try again'));
1449
+ console.log(chalk_1.default.gray('(Rate limits reset hourly)\n'));
1450
+ return;
1451
+ }
1452
+ // Validation errors
1453
+ if (errorMsg.includes('validation') || errorMsg.includes('invalid')) {
1454
+ console.log(chalk_1.default.red('\n❌ Invalid input\n'));
1455
+ console.log(chalk_1.default.white('Common reasons:'));
1456
+ console.log(chalk_1.default.gray(' • Missing required information (title, body, etc.)'));
1457
+ console.log(chalk_1.default.gray(' • Invalid format or parameters\n'));
1458
+ console.log(chalk_1.default.cyan('💡 Try:\n'));
1459
+ console.log(chalk_1.default.white('Be more specific with your command'));
1460
+ console.log(chalk_1.default.gray('Example: "create a PR with title \'Fix bug\' and description \'Fixes #123\'"\n'));
1461
+ return;
1462
+ }
1463
+ // Network errors
1464
+ if (errorMsg.includes('network') || errorMsg.includes('fetch failed') || errorMsg.includes('econnrefused')) {
1465
+ console.log(chalk_1.default.red('\n❌ Network error\n'));
1466
+ console.log(chalk_1.default.white('Why this fails:'));
1467
+ console.log(chalk_1.default.gray(' • No internet connection'));
1468
+ console.log(chalk_1.default.gray(' • GitHub API is down (rare)\n'));
1469
+ console.log(chalk_1.default.cyan('💡 Here\'s what to do:\n'));
1470
+ console.log(chalk_1.default.white('1. Check your internet connection'));
1471
+ console.log(chalk_1.default.white('2. Try again in a few seconds\n'));
1472
+ return;
1473
+ }
1474
+ // Generic fallback with helpful context
1475
+ console.log(chalk_1.default.red('\n❌ Command failed\n'));
1476
+ console.log(chalk_1.default.white('What happened:'));
1477
+ console.log(chalk_1.default.gray(` ${error.message}\n`));
1478
+ console.log(chalk_1.default.cyan('💡 Try:\n'));
1479
+ console.log(chalk_1.default.white('• Check your command:'));
1480
+ console.log(chalk_1.default.cyan(' what branch am i on'));
1481
+ console.log(chalk_1.default.cyan(' show last 5 commits\n'));
1482
+ console.log(chalk_1.default.white('• Reconnect GitHub if needed:'));
1483
+ console.log(chalk_1.default.cyan(' github connect\n'));
1312
1484
  }
1313
1485
  }
1314
1486
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snapcommit/cli",
3
- "version": "3.9.17",
3
+ "version": "3.9.19",
4
4
  "description": "Instant AI commits. Beautiful progress tracking. Never write commit messages again.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {