@snapcommit/cli 1.0.1 → 1.0.2

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.
@@ -52,6 +52,7 @@ const database_1 = require("../db/database");
52
52
  const analytics_1 = require("../utils/analytics");
53
53
  const manager_1 = require("../license/manager");
54
54
  const smart_solver_1 = require("../ai/smart-solver");
55
+ const auth_1 = require("../lib/auth");
55
56
  function askQuestion(query) {
56
57
  const rl = readline_1.default.createInterface({
57
58
  input: process.stdin,
@@ -93,6 +94,12 @@ function executeGitCommands(commands, showCommands = true) {
93
94
  * Main natural language command handler
94
95
  */
95
96
  async function naturalCommand(userInput) {
97
+ // Ensure authentication first
98
+ const authConfig = await (0, auth_1.ensureAuth)();
99
+ if (!authConfig) {
100
+ console.log(chalk_1.default.red('\n❌ Authentication required to use SnapCommit\n'));
101
+ process.exit(1);
102
+ }
96
103
  // Check if in git repo
97
104
  if (!(0, git_1.isGitRepo)()) {
98
105
  console.log(chalk_1.default.red('\n❌ Not a git repository'));
package/dist/lib/auth.js CHANGED
@@ -96,18 +96,24 @@ async function verifyToken(token) {
96
96
  * Prompt user to authenticate
97
97
  */
98
98
  async function promptAuth() {
99
- console.log(chalk_1.default.bold.cyan('\n🔐 Welcome to SnapCommit!\n'));
100
- console.log(chalk_1.default.gray('To use SnapCommit, you need to authenticate.\n'));
101
- console.log(chalk_1.default.bold('Step 1:') + chalk_1.default.gray(' Sign up or log in at:'));
102
- console.log(chalk_1.default.cyan.underline(' 👉 https://snapcommit.dev/login\n'));
103
- console.log(chalk_1.default.bold('Step 2:') + chalk_1.default.gray(' Generate a token from your dashboard'));
104
- console.log(chalk_1.default.gray(' (You\'ll see a "Generate Token" button)\n'));
105
- const token = await askQuestion(chalk_1.default.yellow('Step 3: Paste your token here: '));
99
+ console.log(chalk_1.default.bold.cyan('\n╔════════════════════════════════════════╗'));
100
+ console.log(chalk_1.default.bold.cyan('║ 🔐 Authentication Required 🔐 ║'));
101
+ console.log(chalk_1.default.bold.cyan('╚════════════════════════════════════════╝\n'));
102
+ console.log(chalk_1.default.gray('SnapCommit needs authentication to provide AI-powered features.\n'));
103
+ console.log(chalk_1.default.yellow('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'));
104
+ console.log(chalk_1.default.bold.white('Step 1: ') + chalk_1.default.gray('Sign up or log in'));
105
+ console.log(chalk_1.default.cyan(' 👉 https://snapcommit.dev/login\n'));
106
+ console.log(chalk_1.default.bold.white('Step 2: ') + chalk_1.default.gray('Go to your dashboard and click "Generate Token"'));
107
+ console.log(chalk_1.default.cyan(' 👉 https://snapcommit.dev/dashboard\n'));
108
+ console.log(chalk_1.default.bold.white('Step 3: ') + chalk_1.default.gray('Copy the token and paste it below\n'));
109
+ console.log(chalk_1.default.yellow('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'));
110
+ const token = await askQuestion(chalk_1.default.yellow('🔑 Paste your authentication token: '));
106
111
  if (!token || token.trim().length === 0) {
107
112
  console.log(chalk_1.default.red('\n❌ No token provided. Authentication cancelled.\n'));
113
+ console.log(chalk_1.default.gray('Run "snap" again when you\'re ready to authenticate.\n'));
108
114
  return false;
109
115
  }
110
- console.log(chalk_1.default.gray('\n🔄 Verifying token...\n'));
116
+ console.log(chalk_1.default.gray('\n🔄 Verifying token with SnapCommit servers...\n'));
111
117
  try {
112
118
  const result = await verifyToken(token.trim());
113
119
  if (result.valid && result.user) {
@@ -118,20 +124,29 @@ async function promptAuth() {
118
124
  name: result.user.name || 'Developer',
119
125
  };
120
126
  saveAuthConfig(config);
121
- console.log(chalk_1.default.green(`✅ Authenticated successfully! Welcome, ${chalk_1.default.bold(config.name)}!\n`));
122
- console.log(chalk_1.default.gray('💎 SnapCommit Pro - Unlimited AI commits'));
123
- console.log(chalk_1.default.gray('🔥 Your coding journey starts now!\n'));
124
- console.log(chalk_1.default.gray('Try: snap quick (in any git repo)\n'));
127
+ console.log(chalk_1.default.green.bold('✅ AUTHENTICATION SUCCESSFUL! 🎉\n'));
128
+ console.log(chalk_1.default.white(` Welcome back, ${chalk_1.default.bold(config.name)}!`));
129
+ console.log(chalk_1.default.gray(` Email: ${config.email}`));
130
+ console.log(chalk_1.default.gray(` Plan: SnapCommit Pro (Active)\n`));
131
+ console.log(chalk_1.default.yellow('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'));
132
+ console.log(chalk_1.default.bold('🚀 Quick Start:\n'));
133
+ console.log(chalk_1.default.gray(' • ') + chalk_1.default.cyan('snap quick') + chalk_1.default.gray(' - AI commit in any repo'));
134
+ console.log(chalk_1.default.gray(' • ') + chalk_1.default.cyan('snap') + chalk_1.default.gray(' - Natural language Git commands'));
135
+ console.log(chalk_1.default.gray(' • ') + chalk_1.default.cyan('snap stats') + chalk_1.default.gray(' - View your coding stats\n'));
125
136
  return true;
126
137
  }
127
138
  else {
128
139
  console.log(chalk_1.default.red('\n❌ Invalid token. Please try again.\n'));
129
- console.log(chalk_1.default.gray('Make sure you copied the entire token from your dashboard.\n'));
140
+ console.log(chalk_1.default.yellow('Troubleshooting:'));
141
+ console.log(chalk_1.default.gray(' • Make sure you copied the ENTIRE token'));
142
+ console.log(chalk_1.default.gray(' • Generate a new token at: https://snapcommit.dev/dashboard'));
143
+ console.log(chalk_1.default.gray(' • Ensure you have an active SnapCommit subscription\n'));
130
144
  return false;
131
145
  }
132
146
  }
133
147
  catch (error) {
134
148
  console.log(chalk_1.default.red(`\n❌ ${error.message}\n`));
149
+ console.log(chalk_1.default.gray('Please check your internet connection and try again.\n'));
135
150
  return false;
136
151
  }
137
152
  }
package/dist/repl.js ADDED
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.startREPL = startREPL;
7
+ const readline_1 = __importDefault(require("readline"));
8
+ const chalk_1 = __importDefault(require("chalk"));
9
+ const auth_1 = require("./lib/auth");
10
+ const natural_1 = require("./commands/natural");
11
+ const quick_1 = require("./commands/quick");
12
+ const stats_1 = require("./commands/stats");
13
+ /**
14
+ * Start SnapCommit REPL (Read-Eval-Print-Loop)
15
+ * Interactive mode for natural language Git commands
16
+ */
17
+ async function startREPL() {
18
+ console.log(chalk_1.default.bold.cyan('\n╔════════════════════════════════════════╗'));
19
+ console.log(chalk_1.default.bold.cyan('║ Welcome to SnapCommit! 🚀 ║'));
20
+ console.log(chalk_1.default.bold.cyan('╚════════════════════════════════════════╝\n'));
21
+ console.log(chalk_1.default.gray(' The AI-powered Git assistant that speaks your language.\n'));
22
+ // Ensure user is authenticated before proceeding
23
+ const authConfig = await (0, auth_1.ensureAuth)();
24
+ if (!authConfig) {
25
+ console.log(chalk_1.default.red('❌ Authentication required to use SnapCommit.\n'));
26
+ console.log(chalk_1.default.gray('Please authenticate to continue.\n'));
27
+ process.exit(1);
28
+ }
29
+ console.log(chalk_1.default.green(`✅ Logged in as ${chalk_1.default.bold(authConfig.email)}\n`));
30
+ console.log(chalk_1.default.gray('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'));
31
+ console.log(chalk_1.default.bold('💡 What can SnapCommit do?\n'));
32
+ console.log(chalk_1.default.gray(' • ') + chalk_1.default.white('Natural language Git: ') + chalk_1.default.cyan('"undo my last commit"'));
33
+ console.log(chalk_1.default.gray(' • ') + chalk_1.default.white('Quick AI commits: ') + chalk_1.default.cyan('quick'));
34
+ console.log(chalk_1.default.gray(' • ') + chalk_1.default.white('Show your stats: ') + chalk_1.default.cyan('stats'));
35
+ console.log(chalk_1.default.gray(' • ') + chalk_1.default.white('Exit SnapCommit: ') + chalk_1.default.cyan('exit') + chalk_1.default.gray(' or ') + chalk_1.default.cyan('quit\n'));
36
+ console.log(chalk_1.default.gray('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'));
37
+ console.log(chalk_1.default.bold.yellow('🎯 Try it now! Type what you want to do:\n'));
38
+ const rl = readline_1.default.createInterface({
39
+ input: process.stdin,
40
+ output: process.stdout,
41
+ prompt: chalk_1.default.cyan('snap> '),
42
+ });
43
+ rl.prompt();
44
+ rl.on('line', async (input) => {
45
+ const line = input.trim();
46
+ if (!line) {
47
+ rl.prompt();
48
+ return;
49
+ }
50
+ // Exit commands
51
+ if (line === 'exit' || line === 'quit' || line === 'q') {
52
+ console.log(chalk_1.default.gray('\n👋 See you later! Happy coding!\n'));
53
+ rl.close();
54
+ process.exit(0);
55
+ }
56
+ // Built-in commands
57
+ if (line === 'quick' || line === 'q') {
58
+ await (0, quick_1.quickCommand)();
59
+ rl.prompt();
60
+ return;
61
+ }
62
+ if (line === 'stats' || line === 's') {
63
+ (0, stats_1.statsCommand)();
64
+ rl.prompt();
65
+ return;
66
+ }
67
+ if (line === 'help' || line === 'h') {
68
+ console.log(chalk_1.default.bold('\n💡 SnapCommit Commands:\n'));
69
+ console.log(chalk_1.default.gray(' • ') + chalk_1.default.cyan('quick') + chalk_1.default.gray(' - Quick AI commit (stage all + commit)'));
70
+ console.log(chalk_1.default.gray(' • ') + chalk_1.default.cyan('stats') + chalk_1.default.gray(' - Show your coding stats'));
71
+ console.log(chalk_1.default.gray(' • ') + chalk_1.default.cyan('exit/quit') + chalk_1.default.gray(' - Exit SnapCommit'));
72
+ console.log(chalk_1.default.gray(' • ') + chalk_1.default.white('Or just type what you want: ') + chalk_1.default.cyan('"create a new branch called feature-x"\n'));
73
+ rl.prompt();
74
+ return;
75
+ }
76
+ // Everything else is natural language
77
+ try {
78
+ await (0, natural_1.naturalCommand)(line);
79
+ }
80
+ catch (error) {
81
+ console.log(chalk_1.default.red(`\n❌ Error: ${error.message}\n`));
82
+ }
83
+ rl.prompt();
84
+ });
85
+ rl.on('close', () => {
86
+ console.log(chalk_1.default.gray('\n👋 See you later! Happy coding!\n'));
87
+ process.exit(0);
88
+ });
89
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snapcommit/cli",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Instant AI commits. Beautiful progress tracking. Never write commit messages again.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {