@snapcommit/cli 2.3.1 → 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.
- package/dist/commands/cursor-style.js +76 -11
- package/package.json +1 -1
|
@@ -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
|
-
|
|
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,12 +133,36 @@ async function showStatus() {
|
|
|
129
133
|
}
|
|
130
134
|
/**
|
|
131
135
|
* Execute commit with AI-generated message
|
|
136
|
+
* Interactive flow: select files → preview message → edit → confirm → commit
|
|
132
137
|
*/
|
|
133
138
|
async function executeCommitWithAI(intent) {
|
|
134
139
|
const status = (0, git_1.getGitStatus)();
|
|
135
140
|
const hasChanges = status.staged > 0 || status.unstaged > 0 || status.untracked > 0;
|
|
136
141
|
if (!hasChanges) {
|
|
137
|
-
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'));
|
|
138
166
|
return;
|
|
139
167
|
}
|
|
140
168
|
// Stage all
|
|
@@ -142,36 +170,73 @@ async function executeCommitWithAI(intent) {
|
|
|
142
170
|
(0, git_1.stageAllChanges)();
|
|
143
171
|
}
|
|
144
172
|
catch (error) {
|
|
145
|
-
console.log(chalk_1.default.red(
|
|
173
|
+
console.log(chalk_1.default.red(`\n❌ ${error.message}\n`));
|
|
146
174
|
return;
|
|
147
175
|
}
|
|
148
176
|
// Generate AI commit message
|
|
177
|
+
console.log(chalk_1.default.blue('🤖 Generating commit message...\n'));
|
|
149
178
|
const diff = (0, git_1.getGitDiff)(true);
|
|
150
|
-
|
|
179
|
+
let commitMessage = await generateCommitMessage(diff);
|
|
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({
|
|
185
|
+
input: process.stdin,
|
|
186
|
+
output: process.stdout,
|
|
187
|
+
});
|
|
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();
|
|
191
|
+
resolve(ans);
|
|
192
|
+
});
|
|
193
|
+
});
|
|
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
|
+
});
|
|
210
|
+
console.log(chalk_1.default.green('\n✓ Message updated\n'));
|
|
211
|
+
}
|
|
151
212
|
// Commit
|
|
152
213
|
try {
|
|
153
214
|
(0, child_process_1.execSync)(`git commit -m "${commitMessage.replace(/"/g, '\\"')}"`, { encoding: 'utf-8', stdio: 'pipe' });
|
|
154
|
-
console.log(chalk_1.default.green(`✓ ${commitMessage.split('\n')[0]}`));
|
|
215
|
+
console.log(chalk_1.default.green(`✓ Committed: ${commitMessage.split('\n')[0]}`));
|
|
155
216
|
}
|
|
156
217
|
catch (error) {
|
|
157
|
-
console.log(chalk_1.default.red(
|
|
218
|
+
console.log(chalk_1.default.red(`\n❌ Commit failed: ${error.message}\n`));
|
|
158
219
|
return;
|
|
159
220
|
}
|
|
160
221
|
// Push if requested
|
|
161
|
-
|
|
222
|
+
const shouldPush = intent.shouldPush || intent.gitCommands?.some((cmd) => cmd.includes('push'));
|
|
223
|
+
if (shouldPush) {
|
|
162
224
|
try {
|
|
163
225
|
(0, child_process_1.execSync)('git push', { encoding: 'utf-8', stdio: 'pipe' });
|
|
164
|
-
console.log(chalk_1.default.green('✓ Pushed'));
|
|
226
|
+
console.log(chalk_1.default.green('✓ Pushed\n'));
|
|
165
227
|
}
|
|
166
228
|
catch (error) {
|
|
167
229
|
if (error.message.includes('no configured push destination')) {
|
|
168
|
-
console.log(chalk_1.default.gray('✓ Committed locally (no remote)'));
|
|
230
|
+
console.log(chalk_1.default.gray('✓ Committed locally (no remote)\n'));
|
|
169
231
|
}
|
|
170
232
|
else {
|
|
171
|
-
console.log(chalk_1.default.yellow(
|
|
233
|
+
console.log(chalk_1.default.yellow(`\n⚠️ Push failed: ${error.message}\n`));
|
|
172
234
|
}
|
|
173
235
|
}
|
|
174
236
|
}
|
|
237
|
+
else {
|
|
238
|
+
console.log();
|
|
239
|
+
}
|
|
175
240
|
}
|
|
176
241
|
/**
|
|
177
242
|
* Execute Git commands with auto-retry on errors
|