@snapcommit/cli 2.0.3 â 2.0.5
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 +30 -11
- package/package.json +1 -1
|
@@ -36,20 +36,24 @@ async function executeCursorStyle(userInput) {
|
|
|
36
36
|
console.log(chalk_1.default.gray('đ Commit message: ') + chalk_1.default.cyan(`"${plan.commitMessage}"`));
|
|
37
37
|
console.log();
|
|
38
38
|
}
|
|
39
|
-
// Ask for confirmation
|
|
39
|
+
// Ask for confirmation (natural language!)
|
|
40
40
|
const needsConfirm = plan.actions.some(a => a.requiresConfirmation);
|
|
41
41
|
if (needsConfirm) {
|
|
42
|
-
const
|
|
43
|
-
? chalk_1.default.
|
|
44
|
-
: chalk_1.default.
|
|
45
|
-
const answer = await askQuestion(
|
|
46
|
-
|
|
42
|
+
const confirmPrompt = plan.commitMessage
|
|
43
|
+
? chalk_1.default.cyan('What next? ') + chalk_1.default.gray('(') + chalk_1.default.white('continue') + chalk_1.default.gray(' ⢠') + chalk_1.default.white('cancel') + chalk_1.default.gray(' ⢠') + chalk_1.default.white('edit message') + chalk_1.default.gray('): ')
|
|
44
|
+
: chalk_1.default.cyan('What next? ') + chalk_1.default.gray('(') + chalk_1.default.white('continue') + chalk_1.default.gray(' ⢠') + chalk_1.default.white('cancel') + chalk_1.default.gray('): ');
|
|
45
|
+
const answer = await askQuestion(confirmPrompt);
|
|
46
|
+
const input = answer.toLowerCase().trim();
|
|
47
|
+
// Cancel commands
|
|
48
|
+
if (input === 'cancel' || input === 'no' || input === 'n' || input === 'stop' || input === 'abort') {
|
|
47
49
|
console.log(chalk_1.default.gray('\nâ Cancelled\n'));
|
|
48
50
|
return;
|
|
49
51
|
}
|
|
50
|
-
|
|
52
|
+
// Edit commands
|
|
53
|
+
if (plan.commitMessage && (input === 'edit' || input === 'e' || input === 'change' || input === 'edit message')) {
|
|
51
54
|
plan.commitMessage = await editMessage(plan.commitMessage);
|
|
52
55
|
}
|
|
56
|
+
// Everything else (including "continue", "yes", "go ahead", "do it", "y", or just Enter) â proceed
|
|
53
57
|
}
|
|
54
58
|
// Execute the plan
|
|
55
59
|
console.log(chalk_1.default.blue('\nâď¸ Executing...\n'));
|
|
@@ -142,8 +146,10 @@ async function getChangeDiff() {
|
|
|
142
146
|
}
|
|
143
147
|
async function generateCommitMessage(diff) {
|
|
144
148
|
const token = (0, auth_1.getToken)();
|
|
145
|
-
if (!token)
|
|
149
|
+
if (!token) {
|
|
150
|
+
console.log(chalk_1.default.yellow('â ď¸ No auth token - using default message'));
|
|
146
151
|
return 'Update changes';
|
|
152
|
+
}
|
|
147
153
|
try {
|
|
148
154
|
// Truncate large diffs
|
|
149
155
|
if (diff.length > 40000) {
|
|
@@ -154,10 +160,19 @@ async function generateCommitMessage(diff) {
|
|
|
154
160
|
headers: { 'Content-Type': 'application/json' },
|
|
155
161
|
body: JSON.stringify({ diff, token }),
|
|
156
162
|
});
|
|
163
|
+
if (!response.ok) {
|
|
164
|
+
console.log(chalk_1.default.yellow(`â ď¸ AI request failed (${response.status}) - using default message`));
|
|
165
|
+
return 'Update changes';
|
|
166
|
+
}
|
|
157
167
|
const data = await response.json();
|
|
168
|
+
if (data.error) {
|
|
169
|
+
console.log(chalk_1.default.yellow(`â ď¸ AI error: ${data.error} - using default message`));
|
|
170
|
+
return 'Update changes';
|
|
171
|
+
}
|
|
158
172
|
return data.message || 'Update changes';
|
|
159
173
|
}
|
|
160
|
-
catch {
|
|
174
|
+
catch (error) {
|
|
175
|
+
console.log(chalk_1.default.yellow(`â ď¸ Network error: ${error.message} - using default message`));
|
|
161
176
|
return 'Update changes';
|
|
162
177
|
}
|
|
163
178
|
}
|
|
@@ -280,11 +295,15 @@ function askQuestion(query) {
|
|
|
280
295
|
const rl = readline_1.default.createInterface({
|
|
281
296
|
input: process.stdin,
|
|
282
297
|
output: process.stdout,
|
|
298
|
+
terminal: false, // Don't process terminal escape sequences
|
|
283
299
|
});
|
|
284
300
|
return new Promise((resolve) => {
|
|
285
|
-
|
|
301
|
+
// Write prompt manually
|
|
302
|
+
process.stdout.write(query);
|
|
303
|
+
// Listen for ONE line of input
|
|
304
|
+
rl.once('line', (answer) => {
|
|
286
305
|
rl.close();
|
|
287
|
-
resolve(answer);
|
|
306
|
+
resolve(answer.trim());
|
|
288
307
|
});
|
|
289
308
|
});
|
|
290
309
|
}
|