@snapcommit/cli 2.4.0 → 2.5.0

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.
@@ -85,7 +85,8 @@ async function handleAICommand(userInput) {
85
85
  return;
86
86
  }
87
87
  // For commits, generate AI message first
88
- if (intent.action === 'commit') {
88
+ if (intent.action === 'commit' || intent.action === 'push' ||
89
+ (intent.gitCommands && intent.gitCommands.some((cmd) => cmd.includes('commit')))) {
89
90
  await executeCommitWithAI(intent);
90
91
  return;
91
92
  }
@@ -95,7 +96,10 @@ async function handleAICommand(userInput) {
95
96
  console.log(chalk_1.default.green('✓ Done\n'));
96
97
  }
97
98
  else {
98
- console.log(chalk_1.default.yellow('⚠️ No commands to execute\n'));
99
+ // Debug: show what we got
100
+ console.log(chalk_1.default.yellow('⚠️ No commands to execute'));
101
+ console.log(chalk_1.default.gray(`Intent action: ${intent.action || 'none'}`));
102
+ console.log(chalk_1.default.gray(`Git commands: ${intent.gitCommands?.length || 0}\n`));
99
103
  }
100
104
  }
101
105
  else if (intent.type === 'github') {
@@ -129,13 +133,36 @@ async function showStatus() {
129
133
  }
130
134
  /**
131
135
  * Execute commit with AI-generated message
132
- * Shows message and allows editing (like Cursor!)
136
+ * Interactive flow: select files → preview message edit confirm → commit
133
137
  */
134
138
  async function executeCommitWithAI(intent) {
135
139
  const status = (0, git_1.getGitStatus)();
136
140
  const hasChanges = status.staged > 0 || status.unstaged > 0 || status.untracked > 0;
137
141
  if (!hasChanges) {
138
- console.log(chalk_1.default.gray('✓ Branch clean'));
142
+ console.log(chalk_1.default.gray('\n✓ Branch clean\n'));
143
+ return;
144
+ }
145
+ // Show what changed
146
+ console.log(chalk_1.default.blue('\n📦 Changes detected:'));
147
+ if (status.unstaged > 0)
148
+ console.log(chalk_1.default.yellow(` • ${status.unstaged} modified`));
149
+ if (status.untracked > 0)
150
+ console.log(chalk_1.default.yellow(` • ${status.untracked} new`));
151
+ console.log();
152
+ // Ask if they want to commit all files
153
+ const readline = await Promise.resolve().then(() => __importStar(require('readline')));
154
+ const rl = readline.createInterface({
155
+ input: process.stdin,
156
+ output: process.stdout,
157
+ });
158
+ const commitAll = await new Promise((resolve) => {
159
+ rl.question(chalk_1.default.cyan('Commit all files? (Y/n): '), (ans) => {
160
+ rl.close();
161
+ resolve(ans);
162
+ });
163
+ });
164
+ if (commitAll.toLowerCase() === 'n') {
165
+ console.log(chalk_1.default.yellow('\n💡 Tip: Use "git add <files>" to stage specific files, then try again\n'));
139
166
  return;
140
167
  }
141
168
  // Stage all
@@ -143,55 +170,73 @@ async function executeCommitWithAI(intent) {
143
170
  (0, git_1.stageAllChanges)();
144
171
  }
145
172
  catch (error) {
146
- console.log(chalk_1.default.red(`❌ ${error.message}`));
173
+ console.log(chalk_1.default.red(`\n❌ ${error.message}\n`));
147
174
  return;
148
175
  }
149
176
  // Generate AI commit message
177
+ console.log(chalk_1.default.blue('🤖 Generating commit message...\n'));
150
178
  const diff = (0, git_1.getGitDiff)(true);
151
179
  let commitMessage = await generateCommitMessage(diff);
152
- // Show message and ask if they want to edit (like Cursor!)
153
- console.log(chalk_1.default.cyan('\n📝 Commit message:'));
154
- console.log(chalk_1.default.white(` ${commitMessage.split('\n')[0]}\n`));
155
- const readline = await Promise.resolve().then(() => __importStar(require('readline')));
156
- const rl = readline.createInterface({
180
+ // Show message
181
+ console.log(chalk_1.default.cyan('📝 Commit message:'));
182
+ console.log(chalk_1.default.white.bold(` ${commitMessage.split('\n')[0]}\n`));
183
+ // Ask if message is good
184
+ const rl2 = readline.createInterface({
157
185
  input: process.stdin,
158
186
  output: process.stdout,
159
187
  });
160
- const answer = await new Promise((resolve) => {
161
- rl.question(chalk_1.default.gray('Press Enter to commit, or type new message: '), (ans) => {
162
- rl.close();
188
+ const messageOk = await new Promise((resolve) => {
189
+ rl2.question(chalk_1.default.cyan('Is this message okay? ') + chalk_1.default.gray('(Y/n/edit): '), (ans) => {
190
+ rl2.close();
163
191
  resolve(ans);
164
192
  });
165
193
  });
166
- // If user typed something, use that instead
167
- if (answer.trim()) {
168
- commitMessage = answer.trim();
194
+ // Handle response
195
+ if (messageOk.toLowerCase() === 'n') {
196
+ console.log(chalk_1.default.gray('\n✗ Cancelled\n'));
197
+ return;
198
+ }
199
+ if (messageOk.toLowerCase() === 'edit' || messageOk.toLowerCase() === 'e') {
200
+ const rl3 = readline.createInterface({
201
+ input: process.stdin,
202
+ output: process.stdout,
203
+ });
204
+ commitMessage = await new Promise((resolve) => {
205
+ rl3.question(chalk_1.default.cyan('New message: '), (ans) => {
206
+ rl3.close();
207
+ resolve(ans || commitMessage);
208
+ });
209
+ });
169
210
  console.log(chalk_1.default.green('\n✓ Message updated\n'));
170
211
  }
171
212
  // Commit
172
213
  try {
173
214
  (0, child_process_1.execSync)(`git commit -m "${commitMessage.replace(/"/g, '\\"')}"`, { encoding: 'utf-8', stdio: 'pipe' });
174
- console.log(chalk_1.default.green(`✓ Committed`));
215
+ console.log(chalk_1.default.green(`✓ Committed: ${commitMessage.split('\n')[0]}`));
175
216
  }
176
217
  catch (error) {
177
- console.log(chalk_1.default.red(`❌ Commit failed`));
218
+ console.log(chalk_1.default.red(`\n❌ Commit failed: ${error.message}\n`));
178
219
  return;
179
220
  }
180
221
  // Push if requested
181
- if (intent.shouldPush || intent.gitCommands?.some((cmd) => cmd.includes('push'))) {
222
+ const shouldPush = intent.shouldPush || intent.gitCommands?.some((cmd) => cmd.includes('push'));
223
+ if (shouldPush) {
182
224
  try {
183
225
  (0, child_process_1.execSync)('git push', { encoding: 'utf-8', stdio: 'pipe' });
184
- console.log(chalk_1.default.green('✓ Pushed'));
226
+ console.log(chalk_1.default.green('✓ Pushed\n'));
185
227
  }
186
228
  catch (error) {
187
229
  if (error.message.includes('no configured push destination')) {
188
- console.log(chalk_1.default.gray('✓ Committed locally (no remote)'));
230
+ console.log(chalk_1.default.gray('✓ Committed locally (no remote)\n'));
189
231
  }
190
232
  else {
191
- console.log(chalk_1.default.yellow(`⚠️ ${error.message}`));
233
+ console.log(chalk_1.default.yellow(`\n⚠️ Push failed: ${error.message}\n`));
192
234
  }
193
235
  }
194
236
  }
237
+ else {
238
+ console.log();
239
+ }
195
240
  }
196
241
  /**
197
242
  * Execute Git commands with auto-retry on errors
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snapcommit/cli",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "description": "Instant AI commits. Beautiful progress tracking. Never write commit messages again.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {