@snapcommit/cli 3.11.4 → 3.11.6
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 +92 -2
- package/dist/index.js +0 -0
- package/dist/repl/index.js +3 -0
- package/dist/repl/interpreter.js +17 -5
- package/package.json +1 -1
|
@@ -54,10 +54,100 @@ async function executeCursorStyle(userInput) {
|
|
|
54
54
|
console.log(chalk_1.default.red('\n❌ Not a git repository\n'));
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
|
-
//
|
|
58
|
-
|
|
57
|
+
// Fast-path for common commands (pattern matching) - Cursor does this!
|
|
58
|
+
const handled = await tryQuickCommands(userInput);
|
|
59
|
+
if (handled) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
// Everything else goes through AI
|
|
59
63
|
await handleAICommand(userInput);
|
|
60
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Try to handle common commands with pattern matching (FAST PATH)
|
|
67
|
+
* Returns true if handled, false if should go to AI
|
|
68
|
+
*/
|
|
69
|
+
async function tryQuickCommands(input) {
|
|
70
|
+
const lower = input.toLowerCase().trim();
|
|
71
|
+
// Status commands
|
|
72
|
+
if (lower === 'status' || lower === 'show status' || lower === 'what changed' || lower === 'git status') {
|
|
73
|
+
await showStatus();
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
// Stage commands - MUST handle before AI!
|
|
77
|
+
if (lower.startsWith('stage')) {
|
|
78
|
+
const rest = input.replace(/^stage\s*/i, '').trim();
|
|
79
|
+
const ALL_KEYWORDS = ['all', 'all changes', 'everything', 'everything please', 'it all', 'them all'];
|
|
80
|
+
try {
|
|
81
|
+
if (!rest || ALL_KEYWORDS.includes(rest.toLowerCase())) {
|
|
82
|
+
(0, child_process_1.execSync)('git add -A', { stdio: 'ignore' });
|
|
83
|
+
console.log(chalk_1.default.green('\n✓ Staged all changes\n'));
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
// Parse file list (handle "and", commas, etc.)
|
|
87
|
+
const files = rest
|
|
88
|
+
.replace(/\sand\s/gi, ',')
|
|
89
|
+
.split(',')
|
|
90
|
+
.map((segment) => segment
|
|
91
|
+
.replace(/^(the|file|files)\s+/i, '')
|
|
92
|
+
.replace(/\s+please$/i, '')
|
|
93
|
+
.trim())
|
|
94
|
+
.filter(Boolean);
|
|
95
|
+
if (files.length === 0) {
|
|
96
|
+
console.log(chalk_1.default.yellow('\n⚠️ No files specified to stage.\n'));
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
files.forEach((file) => {
|
|
100
|
+
const escaped = file.replace(/(["\\$`])/g, '\\$1');
|
|
101
|
+
(0, child_process_1.execSync)(`git add -- "${escaped}"`, { stdio: 'ignore' });
|
|
102
|
+
});
|
|
103
|
+
console.log(chalk_1.default.green(`\n✓ Staged ${files.length} ${files.length === 1 ? 'file' : 'files'}: ${files.join(', ')}\n`));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
console.log(chalk_1.default.red(`\n❌ Failed to stage: ${error.message}\n`));
|
|
108
|
+
}
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
// Push commands
|
|
112
|
+
if (lower === 'push' || lower === 'push it' || lower === 'git push') {
|
|
113
|
+
try {
|
|
114
|
+
console.log(chalk_1.default.gray('\n📤 Pushing to remote...\n'));
|
|
115
|
+
(0, child_process_1.execSync)('git push', { stdio: 'inherit' });
|
|
116
|
+
console.log(chalk_1.default.green('\n✅ Pushed!\n'));
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
console.log(chalk_1.default.red('\n❌ Push failed\n'));
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
// Pull commands
|
|
125
|
+
if (lower === 'pull' || lower === 'pull latest' || lower === 'git pull') {
|
|
126
|
+
try {
|
|
127
|
+
console.log(chalk_1.default.gray('\n📥 Pulling from remote...\n'));
|
|
128
|
+
(0, child_process_1.execSync)('git pull', { stdio: 'inherit' });
|
|
129
|
+
console.log(chalk_1.default.green('\n✅ Pulled!\n'));
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
console.log(chalk_1.default.red('\n❌ Pull failed\n'));
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
// Diff commands
|
|
138
|
+
if (lower === 'diff' || lower === 'show diff' || lower === 'what changed' || lower === 'changes') {
|
|
139
|
+
try {
|
|
140
|
+
(0, child_process_1.execSync)('git diff', { stdio: 'inherit' });
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
console.log(chalk_1.default.red('\n❌ Failed to show diff\n'));
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
// Not handled - let AI process it
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
61
151
|
/**
|
|
62
152
|
* AI-powered command handler - CURSOR-STYLE!
|
|
63
153
|
* Pure AI interpretation, minimal output, instant feel
|
package/dist/index.js
CHANGED
|
File without changes
|
package/dist/repl/index.js
CHANGED
|
@@ -160,6 +160,9 @@ async function startREPL() {
|
|
|
160
160
|
}
|
|
161
161
|
// Natural language processing
|
|
162
162
|
try {
|
|
163
|
+
if (process.env.SNAP_DEBUG) {
|
|
164
|
+
console.log(chalk_1.default.gray(`[DEBUG] raw input: ${JSON.stringify(trimmed)}`));
|
|
165
|
+
}
|
|
163
166
|
await (0, interpreter_1.executeNaturalLanguageCommand)(trimmed, context);
|
|
164
167
|
}
|
|
165
168
|
catch (error) {
|
package/dist/repl/interpreter.js
CHANGED
|
@@ -51,6 +51,17 @@ 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
|
+
if (process.env.SNAP_DEBUG) {
|
|
55
|
+
console.log(chalk_1.default.gray(`[DEBUG] normalized input: ${JSON.stringify(normalizedInput)}`));
|
|
56
|
+
}
|
|
57
|
+
// Pattern matching for common commands (fast path) - MUST run before AI
|
|
58
|
+
const handled = await tryQuickCommands(normalizedInput, context);
|
|
59
|
+
if (handled) {
|
|
60
|
+
if (process.env.SNAP_DEBUG) {
|
|
61
|
+
console.log(chalk_1.default.gray('[DEBUG] handled via quick command'));
|
|
62
|
+
}
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
54
65
|
// Check for clarification needs
|
|
55
66
|
const clarification = await (0, gemini_client_1.needsClarificationGemini)(normalizedInput);
|
|
56
67
|
if (clarification.needsClarification && clarification.options) {
|
|
@@ -65,11 +76,6 @@ async function executeNaturalLanguageCommand(input, context) {
|
|
|
65
76
|
}
|
|
66
77
|
// Get Git context
|
|
67
78
|
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
79
|
// AI interpretation
|
|
74
80
|
console.log(chalk_1.default.gray('\n🤖 Understanding your request...\n'));
|
|
75
81
|
try {
|
|
@@ -212,6 +218,9 @@ async function tryQuickCommands(input, context) {
|
|
|
212
218
|
const rest = input.replace(/^stage\s*/i, '').trim();
|
|
213
219
|
const ALL_KEYWORDS = ['all', 'all changes', 'everything', 'everything please', 'it all', 'them all'];
|
|
214
220
|
try {
|
|
221
|
+
if (process.env.SNAP_DEBUG) {
|
|
222
|
+
console.log(chalk_1.default.gray(`[DEBUG] staging rest: ${JSON.stringify(rest)} cwd=${process.cwd()}`));
|
|
223
|
+
}
|
|
215
224
|
if (!rest || ALL_KEYWORDS.includes(rest.toLowerCase())) {
|
|
216
225
|
(0, child_process_1.execSync)('git add -A', { stdio: 'ignore' });
|
|
217
226
|
console.log(chalk_1.default.green('\n✓ Staged all changes\n'));
|
|
@@ -229,6 +238,9 @@ async function tryQuickCommands(input, context) {
|
|
|
229
238
|
console.log(chalk_1.default.yellow('\n⚠️ No files specified to stage.\n'));
|
|
230
239
|
return true;
|
|
231
240
|
}
|
|
241
|
+
if (process.env.SNAP_DEBUG) {
|
|
242
|
+
console.log(chalk_1.default.gray(`[DEBUG] staging files: ${JSON.stringify(files)} cwd=${process.cwd()}`));
|
|
243
|
+
}
|
|
232
244
|
files.forEach((file) => {
|
|
233
245
|
const escaped = file.replace(/(["\\$`])/g, '\\$1');
|
|
234
246
|
(0, child_process_1.execSync)(`git add -- "${escaped}"`, { stdio: 'ignore' });
|