@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.
@@ -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 confirmOptions = plan.commitMessage
43
- ? chalk_1.default.yellow('Continue? (Y/n/e to edit message): ')
44
- : chalk_1.default.yellow('Continue? (Y/n): ');
45
- const answer = await askQuestion(confirmOptions);
46
- if (answer.toLowerCase() === 'n') {
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
- if (answer.toLowerCase() === 'e' && plan.commitMessage) {
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
- rl.question(query, (answer) => {
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snapcommit/cli",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "description": "Instant AI commits. Beautiful progress tracking. Never write commit messages again.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {