@snapcommit/cli 3.9.1 → 3.9.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.
- package/dist/commands/cursor-style.js +26 -2
- package/dist/commands/logout.js +25 -0
- package/dist/repl.js +14 -0
- package/package.json +1 -1
|
@@ -1313,18 +1313,42 @@ async function getAIInterpretation(userInput, token) {
|
|
|
1313
1313
|
});
|
|
1314
1314
|
if (!response.ok) {
|
|
1315
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
|
+
}
|
|
1316
1326
|
console.error(chalk_1.default.red(`\n❌ AI API Error (${response.status}):`), errorData);
|
|
1317
1327
|
return null;
|
|
1318
1328
|
}
|
|
1319
|
-
|
|
1329
|
+
let data;
|
|
1330
|
+
try {
|
|
1331
|
+
data = await response.json();
|
|
1332
|
+
}
|
|
1333
|
+
catch (parseError) {
|
|
1334
|
+
console.error(chalk_1.default.red('\n❌ JSON Parse Error:'), parseError.message);
|
|
1335
|
+
console.error(chalk_1.default.gray('Response was not valid JSON'));
|
|
1336
|
+
return null;
|
|
1337
|
+
}
|
|
1320
1338
|
// Debug: Show what AI returned
|
|
1321
1339
|
if (process.env.DEBUG === 'true') {
|
|
1322
1340
|
console.log(chalk_1.default.gray('[DEBUG] AI Response:'), JSON.stringify(data, null, 2));
|
|
1323
1341
|
}
|
|
1342
|
+
if (!data || !data.intent) {
|
|
1343
|
+
console.error(chalk_1.default.red('\n❌ Invalid AI response structure'));
|
|
1344
|
+
console.error(chalk_1.default.gray('Expected: {intent: {...}}'));
|
|
1345
|
+
console.error(chalk_1.default.gray('Got:'), JSON.stringify(data).substring(0, 200));
|
|
1346
|
+
return null;
|
|
1347
|
+
}
|
|
1324
1348
|
return data.intent;
|
|
1325
1349
|
}
|
|
1326
1350
|
catch (error) {
|
|
1327
|
-
console.error(chalk_1.default.red('\n❌ Network
|
|
1351
|
+
console.error(chalk_1.default.red('\n❌ Network Error:'), error.message);
|
|
1328
1352
|
return null;
|
|
1329
1353
|
}
|
|
1330
1354
|
}
|
|
@@ -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(' ');
|