@snapcommit/cli 3.11.3 → 3.11.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/repl/interpreter.js +40 -5
- package/package.json +1 -1
package/dist/repl/interpreter.js
CHANGED
|
@@ -51,6 +51,11 @@ const gitAdvanced = __importStar(require("../commands/git-advanced"));
|
|
|
51
51
|
async function executeNaturalLanguageCommand(input, context) {
|
|
52
52
|
// Normalize input (handle references like "that", "it", etc.)
|
|
53
53
|
const normalizedInput = normalizeInput(input, context);
|
|
54
|
+
// Pattern matching for common commands (fast path) - MUST run before AI
|
|
55
|
+
const handled = await tryQuickCommands(normalizedInput, context);
|
|
56
|
+
if (handled) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
54
59
|
// Check for clarification needs
|
|
55
60
|
const clarification = await (0, gemini_client_1.needsClarificationGemini)(normalizedInput);
|
|
56
61
|
if (clarification.needsClarification && clarification.options) {
|
|
@@ -65,11 +70,6 @@ async function executeNaturalLanguageCommand(input, context) {
|
|
|
65
70
|
}
|
|
66
71
|
// Get Git context
|
|
67
72
|
const gitContext = getGitContext();
|
|
68
|
-
// Pattern matching for common commands (fast path)
|
|
69
|
-
const handled = await tryQuickCommands(normalizedInput, context);
|
|
70
|
-
if (handled) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
73
|
// AI interpretation
|
|
74
74
|
console.log(chalk_1.default.gray('\n🤖 Understanding your request...\n'));
|
|
75
75
|
try {
|
|
@@ -207,6 +207,41 @@ async function tryQuickCommands(input, context) {
|
|
|
207
207
|
return true;
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
|
+
// Stage commands
|
|
211
|
+
if (lower.startsWith('stage')) {
|
|
212
|
+
const rest = input.replace(/^stage\s*/i, '').trim();
|
|
213
|
+
const ALL_KEYWORDS = ['all', 'all changes', 'everything', 'everything please', 'it all', 'them all'];
|
|
214
|
+
try {
|
|
215
|
+
if (!rest || ALL_KEYWORDS.includes(rest.toLowerCase())) {
|
|
216
|
+
(0, child_process_1.execSync)('git add -A', { stdio: 'ignore' });
|
|
217
|
+
console.log(chalk_1.default.green('\n✓ Staged all changes\n'));
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
const files = rest
|
|
221
|
+
.replace(/\sand\s/gi, ',')
|
|
222
|
+
.split(',')
|
|
223
|
+
.map((segment) => segment
|
|
224
|
+
.replace(/^(the|file|files)\s+/i, '')
|
|
225
|
+
.replace(/\s+please$/i, '')
|
|
226
|
+
.trim())
|
|
227
|
+
.filter(Boolean);
|
|
228
|
+
if (files.length === 0) {
|
|
229
|
+
console.log(chalk_1.default.yellow('\n⚠️ No files specified to stage.\n'));
|
|
230
|
+
return true;
|
|
231
|
+
}
|
|
232
|
+
files.forEach((file) => {
|
|
233
|
+
const escaped = file.replace(/(["\\$`])/g, '\\$1');
|
|
234
|
+
(0, child_process_1.execSync)(`git add -- "${escaped}"`, { stdio: 'ignore' });
|
|
235
|
+
});
|
|
236
|
+
console.log(chalk_1.default.green(`\n✓ Staged ${files.length} ${files.length === 1 ? 'file' : 'files'}: ${files.join(', ')}\n`));
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
catch (error) {
|
|
240
|
+
console.log(chalk_1.default.red(`\n❌ Failed to stage changes: ${error.message}\n`));
|
|
241
|
+
}
|
|
242
|
+
context.lastAction = 'stage';
|
|
243
|
+
return true;
|
|
244
|
+
}
|
|
210
245
|
// Status commands
|
|
211
246
|
if (lower === 'status' || lower === 'show status' || lower === 'what changed') {
|
|
212
247
|
try {
|