@snapcommit/cli 2.3.0 → 2.4.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.
@@ -69,26 +69,67 @@ async function handleAICommand(userInput) {
69
69
  // Get AI interpretation for EVERYTHING
70
70
  const intent = await getAIInterpretation(userInput, token);
71
71
  if (!intent) {
72
- console.log(chalk_1.default.red('❌ Could not understand command\n'));
72
+ console.log(chalk_1.default.red('❌ Could not understand command'));
73
+ console.log(chalk_1.default.gray('Tip: Try "commit and push" or "show me changes"\n'));
73
74
  return;
74
75
  }
76
+ // Debug: Show what AI understood (for now)
77
+ if (process.env.DEBUG) {
78
+ console.log(chalk_1.default.gray(`[DEBUG] Intent: ${JSON.stringify(intent, null, 2)}`));
79
+ }
75
80
  // Execute based on type
76
81
  if (intent.type === 'git') {
82
+ // Status check
83
+ if (intent.action === 'status') {
84
+ await showStatus();
85
+ return;
86
+ }
77
87
  // For commits, generate AI message first
78
88
  if (intent.action === 'commit') {
79
89
  await executeCommitWithAI(intent);
90
+ return;
91
+ }
92
+ // Other git commands
93
+ if (intent.gitCommands && intent.gitCommands.length > 0) {
94
+ await executeGitCommands(intent.gitCommands);
95
+ console.log(chalk_1.default.green('✓ Done\n'));
80
96
  }
81
97
  else {
82
- await executeGitCommands(intent.gitCommands || []);
98
+ console.log(chalk_1.default.yellow('⚠️ No commands to execute\n'));
83
99
  }
84
100
  }
85
101
  else if (intent.type === 'github') {
86
102
  await executeGitHubCommand(intent);
103
+ console.log(chalk_1.default.green('✓ Done\n'));
104
+ }
105
+ else {
106
+ console.log(chalk_1.default.yellow(`⚠️ Unknown intent type: ${intent.type}\n`));
107
+ }
108
+ }
109
+ /**
110
+ * Show git status
111
+ */
112
+ async function showStatus() {
113
+ const status = (0, git_1.getGitStatus)();
114
+ const branch = (0, git_1.getCurrentBranch)();
115
+ const hasChanges = status.staged > 0 || status.unstaged > 0 || status.untracked > 0;
116
+ console.log(chalk_1.default.blue(`\nBranch: ${branch}`));
117
+ if (!hasChanges) {
118
+ console.log(chalk_1.default.gray('✓ Branch clean - no changes\n'));
119
+ return;
87
120
  }
88
- console.log(chalk_1.default.green(' Done\n'));
121
+ console.log(chalk_1.default.yellow('\nChanges detected:'));
122
+ if (status.unstaged > 0)
123
+ console.log(chalk_1.default.yellow(` • ${status.unstaged} modified`));
124
+ if (status.untracked > 0)
125
+ console.log(chalk_1.default.yellow(` • ${status.untracked} new`));
126
+ if (status.staged > 0)
127
+ console.log(chalk_1.default.green(` • ${status.staged} staged`));
128
+ console.log();
89
129
  }
90
130
  /**
91
131
  * Execute commit with AI-generated message
132
+ * Shows message and allows editing (like Cursor!)
92
133
  */
93
134
  async function executeCommitWithAI(intent) {
94
135
  const status = (0, git_1.getGitStatus)();
@@ -107,11 +148,30 @@ async function executeCommitWithAI(intent) {
107
148
  }
108
149
  // Generate AI commit message
109
150
  const diff = (0, git_1.getGitDiff)(true);
110
- const commitMessage = await generateCommitMessage(diff);
151
+ 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({
157
+ input: process.stdin,
158
+ output: process.stdout,
159
+ });
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();
163
+ resolve(ans);
164
+ });
165
+ });
166
+ // If user typed something, use that instead
167
+ if (answer.trim()) {
168
+ commitMessage = answer.trim();
169
+ console.log(chalk_1.default.green('\n✓ Message updated\n'));
170
+ }
111
171
  // Commit
112
172
  try {
113
173
  (0, child_process_1.execSync)(`git commit -m "${commitMessage.replace(/"/g, '\\"')}"`, { encoding: 'utf-8', stdio: 'pipe' });
114
- console.log(chalk_1.default.green(`✓ ${commitMessage.split('\n')[0]}`));
174
+ console.log(chalk_1.default.green(`✓ Committed`));
115
175
  }
116
176
  catch (error) {
117
177
  console.log(chalk_1.default.red(`❌ Commit failed`));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snapcommit/cli",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "description": "Instant AI commits. Beautiful progress tracking. Never write commit messages again.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {