@snapcommit/cli 3.9.0 → 3.9.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.
@@ -1311,12 +1311,30 @@ async function getAIInterpretation(userInput, token) {
1311
1311
  },
1312
1312
  }),
1313
1313
  });
1314
- if (!response.ok)
1314
+ if (!response.ok) {
1315
+ const errorData = await response.json().catch(() => ({ error: 'Unknown error' }));
1316
+ // Handle authentication errors gracefully
1317
+ if (response.status === 401 || response.status === 403) {
1318
+ console.log(chalk_1.default.red('\n❌ Authentication expired or invalid'));
1319
+ console.log(chalk_1.default.yellow('\n💡 To fix this:'));
1320
+ console.log(chalk_1.default.white(' 1. Exit snap (type: ') + chalk_1.default.cyan('exit') + chalk_1.default.white(')'));
1321
+ console.log(chalk_1.default.white(' 2. Run: ') + chalk_1.default.cyan('snap login'));
1322
+ console.log(chalk_1.default.white(' 3. Get a new token from: ') + chalk_1.default.cyan('https://www.snapcommit.dev/dashboard'));
1323
+ console.log();
1324
+ return null;
1325
+ }
1326
+ console.error(chalk_1.default.red(`\n❌ AI API Error (${response.status}):`), errorData);
1315
1327
  return null;
1328
+ }
1316
1329
  const data = await response.json();
1330
+ // Debug: Show what AI returned
1331
+ if (process.env.DEBUG === 'true') {
1332
+ console.log(chalk_1.default.gray('[DEBUG] AI Response:'), JSON.stringify(data, null, 2));
1333
+ }
1317
1334
  return data.intent;
1318
1335
  }
1319
- catch {
1336
+ catch (error) {
1337
+ console.error(chalk_1.default.red('\n❌ Network/Parse Error:'), error.message);
1320
1338
  return null;
1321
1339
  }
1322
1340
  }
@@ -0,0 +1,25 @@
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.handleLogout = handleLogout;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const os_1 = __importDefault(require("os"));
10
+ const chalk_1 = __importDefault(require("chalk"));
11
+ const AUTH_FILE = path_1.default.join(os_1.default.homedir(), '.snapcommit', 'auth.json');
12
+ async function handleLogout() {
13
+ if (!fs_1.default.existsSync(AUTH_FILE)) {
14
+ console.log(chalk_1.default.yellow('\n⚠️ You are not logged in\n'));
15
+ return;
16
+ }
17
+ try {
18
+ fs_1.default.unlinkSync(AUTH_FILE);
19
+ console.log(chalk_1.default.green('\n✅ Logged out successfully!\n'));
20
+ console.log(chalk_1.default.gray('To log back in, run: ') + chalk_1.default.cyan('snap login\n'));
21
+ }
22
+ catch (error) {
23
+ console.log(chalk_1.default.red(`\n❌ Failed to logout: ${error.message}\n`));
24
+ }
25
+ }
package/dist/repl.js CHANGED
@@ -119,6 +119,20 @@ async function startREPL() {
119
119
  rl.close();
120
120
  process.exit(0);
121
121
  }
122
+ // Logout command (NEW!)
123
+ if (line === 'logout' || line === 'log out') {
124
+ const { handleLogout } = await Promise.resolve().then(() => __importStar(require('./commands/logout')));
125
+ await handleLogout();
126
+ rl.close();
127
+ process.exit(0);
128
+ }
129
+ // Login command (NEW!)
130
+ if (line === 'login' || line === 'log in') {
131
+ console.log(chalk_1.default.yellow('\n⚠️ Please exit snap first (type: ') + chalk_1.default.cyan('exit') + chalk_1.default.yellow(')'));
132
+ console.log(chalk_1.default.gray(' Then run: ') + chalk_1.default.cyan('snap login\n'));
133
+ rl.prompt();
134
+ return;
135
+ }
122
136
  // Stats command - show commit stats
123
137
  if (line === 'stats' || line.startsWith('stats ')) {
124
138
  const parts = line.split(' ');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snapcommit/cli",
3
- "version": "3.9.0",
3
+ "version": "3.9.2",
4
4
  "description": "Instant AI commits. Beautiful progress tracking. Never write commit messages again.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {