@snapcommit/cli 2.0.3 → 2.0.4
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 +23 -11
- package/package.json +1 -1
|
@@ -10,7 +10,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.executeCursorStyle = executeCursorStyle;
|
|
11
11
|
const chalk_1 = __importDefault(require("chalk"));
|
|
12
12
|
const child_process_1 = require("child_process");
|
|
13
|
-
const readline_1 = __importDefault(require("readline"));
|
|
14
13
|
const git_1 = require("../utils/git");
|
|
15
14
|
const auth_1 = require("../lib/auth");
|
|
16
15
|
async function executeCursorStyle(userInput) {
|
|
@@ -142,8 +141,10 @@ async function getChangeDiff() {
|
|
|
142
141
|
}
|
|
143
142
|
async function generateCommitMessage(diff) {
|
|
144
143
|
const token = (0, auth_1.getToken)();
|
|
145
|
-
if (!token)
|
|
144
|
+
if (!token) {
|
|
145
|
+
console.log(chalk_1.default.yellow('⚠️ No auth token - using default message'));
|
|
146
146
|
return 'Update changes';
|
|
147
|
+
}
|
|
147
148
|
try {
|
|
148
149
|
// Truncate large diffs
|
|
149
150
|
if (diff.length > 40000) {
|
|
@@ -154,10 +155,19 @@ async function generateCommitMessage(diff) {
|
|
|
154
155
|
headers: { 'Content-Type': 'application/json' },
|
|
155
156
|
body: JSON.stringify({ diff, token }),
|
|
156
157
|
});
|
|
158
|
+
if (!response.ok) {
|
|
159
|
+
console.log(chalk_1.default.yellow(`⚠️ AI request failed (${response.status}) - using default message`));
|
|
160
|
+
return 'Update changes';
|
|
161
|
+
}
|
|
157
162
|
const data = await response.json();
|
|
163
|
+
if (data.error) {
|
|
164
|
+
console.log(chalk_1.default.yellow(`⚠️ AI error: ${data.error} - using default message`));
|
|
165
|
+
return 'Update changes';
|
|
166
|
+
}
|
|
158
167
|
return data.message || 'Update changes';
|
|
159
168
|
}
|
|
160
|
-
catch {
|
|
169
|
+
catch (error) {
|
|
170
|
+
console.log(chalk_1.default.yellow(`⚠️ Network error: ${error.message} - using default message`));
|
|
161
171
|
return 'Update changes';
|
|
162
172
|
}
|
|
163
173
|
}
|
|
@@ -277,15 +287,17 @@ async function tryAutoFix(error, action) {
|
|
|
277
287
|
return false;
|
|
278
288
|
}
|
|
279
289
|
function askQuestion(query) {
|
|
280
|
-
const rl = readline_1.default.createInterface({
|
|
281
|
-
input: process.stdin,
|
|
282
|
-
output: process.stdout,
|
|
283
|
-
});
|
|
284
290
|
return new Promise((resolve) => {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
291
|
+
process.stdout.write(query);
|
|
292
|
+
process.stdin.setRawMode(false);
|
|
293
|
+
process.stdin.resume();
|
|
294
|
+
process.stdin.setEncoding('utf8');
|
|
295
|
+
const onData = (data) => {
|
|
296
|
+
process.stdin.removeListener('data', onData);
|
|
297
|
+
process.stdin.pause();
|
|
298
|
+
resolve(data.toString().trim());
|
|
299
|
+
};
|
|
300
|
+
process.stdin.once('data', onData);
|
|
289
301
|
});
|
|
290
302
|
}
|
|
291
303
|
async function editMessage(originalMessage) {
|