@snapcommit/cli 3.11.2 → 3.11.4
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.
|
@@ -391,16 +391,22 @@ const WORKFLOWS = [
|
|
|
391
391
|
`Title: ${title}`,
|
|
392
392
|
testResult ? `Tests: ${testResult}` : 'Tests: not provided',
|
|
393
393
|
]);
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
394
|
+
try {
|
|
395
|
+
const pr = await github.createPullRequest({
|
|
396
|
+
title: title || defaultTitle,
|
|
397
|
+
body: body || defaultBody,
|
|
398
|
+
});
|
|
399
|
+
ctx.recordInsight('pullRequest', `#${pr.number} ${pr.title}`);
|
|
400
|
+
ctx.recordInsight('prUrl', pr.html_url);
|
|
401
|
+
(0, ui_1.displaySuccess)('Pull request created.', [
|
|
402
|
+
`#${pr.number} ${pr.title}`,
|
|
403
|
+
pr.html_url,
|
|
404
|
+
]);
|
|
405
|
+
}
|
|
406
|
+
catch (error) {
|
|
407
|
+
ctx.recordInsight('pullRequest', 'Failed to open PR');
|
|
408
|
+
throw new Error(formatGitHubError(error));
|
|
409
|
+
}
|
|
404
410
|
},
|
|
405
411
|
},
|
|
406
412
|
],
|
|
@@ -744,3 +750,22 @@ function buildPRBody(summary, tests) {
|
|
|
744
750
|
lines.push('- [ ] Updated documentation (if needed)');
|
|
745
751
|
return lines.join('\n');
|
|
746
752
|
}
|
|
753
|
+
function formatGitHubError(error) {
|
|
754
|
+
const raw = (error?.message || String(error) || '').trim();
|
|
755
|
+
if (!raw) {
|
|
756
|
+
return 'GitHub request failed. Verify your connection with `snap github status`.';
|
|
757
|
+
}
|
|
758
|
+
if (/not connected/i.test(raw) || /github connect/i.test(raw)) {
|
|
759
|
+
return 'GitHub not connected. Run `snap github connect` and try again.';
|
|
760
|
+
}
|
|
761
|
+
if (/bad credentials/i.test(raw)) {
|
|
762
|
+
return 'GitHub authentication failed. Re-authorize with `snap github connect`.';
|
|
763
|
+
}
|
|
764
|
+
if (/not a github repository/i.test(raw)) {
|
|
765
|
+
return 'Origin remote is missing or not a GitHub repo. Add a GitHub remote and retry.';
|
|
766
|
+
}
|
|
767
|
+
if (/resource not accessible/i.test(raw)) {
|
|
768
|
+
return `${raw} — check that your GitHub user has access to this repository.`;
|
|
769
|
+
}
|
|
770
|
+
return raw;
|
|
771
|
+
}
|
|
@@ -41,6 +41,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
41
41
|
};
|
|
42
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
43
|
exports.executeCursorStyle = executeCursorStyle;
|
|
44
|
+
exports.showStatus = showStatus;
|
|
44
45
|
const chalk_1 = __importDefault(require("chalk"));
|
|
45
46
|
const fs_1 = __importDefault(require("fs"));
|
|
46
47
|
const child_process_1 = require("child_process");
|
|
@@ -19,6 +19,7 @@ exports.switchBranch = switchBranch;
|
|
|
19
19
|
exports.mergeBranch = mergeBranch;
|
|
20
20
|
exports.showLog = showLog;
|
|
21
21
|
exports.showDiff = showDiff;
|
|
22
|
+
exports.showDiffForFile = showDiffForFile;
|
|
22
23
|
const child_process_1 = require("child_process");
|
|
23
24
|
const chalk_1 = __importDefault(require("chalk"));
|
|
24
25
|
const readline_1 = __importDefault(require("readline"));
|
|
@@ -294,6 +295,21 @@ function showDiff(cached = false) {
|
|
|
294
295
|
console.log(chalk_1.default.red(`\n❌ Failed to show diff: ${error.message}\n`));
|
|
295
296
|
}
|
|
296
297
|
}
|
|
298
|
+
/**
|
|
299
|
+
* Show diff for a specific file
|
|
300
|
+
*/
|
|
301
|
+
function showDiffForFile(filePath, cached = false) {
|
|
302
|
+
try {
|
|
303
|
+
const flag = cached ? '--cached' : '';
|
|
304
|
+
const escapedPath = escapeFilePath(filePath.trim());
|
|
305
|
+
console.log(chalk_1.default.bold(`\n📄 Changes in ${filePath.trim()}:\n`));
|
|
306
|
+
(0, child_process_1.execSync)(`git diff ${flag} -- "${escapedPath}"`, { stdio: 'inherit' });
|
|
307
|
+
console.log('');
|
|
308
|
+
}
|
|
309
|
+
catch (error) {
|
|
310
|
+
console.log(chalk_1.default.red(`\n❌ Failed to show diff for ${filePath.trim()}: ${error.message}\n`));
|
|
311
|
+
}
|
|
312
|
+
}
|
|
297
313
|
/**
|
|
298
314
|
* Helper: Confirm action
|
|
299
315
|
*/
|
|
@@ -309,3 +325,6 @@ async function confirmAction(message) {
|
|
|
309
325
|
});
|
|
310
326
|
});
|
|
311
327
|
}
|
|
328
|
+
function escapeFilePath(path) {
|
|
329
|
+
return path.replace(/(["\\$`])/g, '\\$1');
|
|
330
|
+
}
|
package/dist/commands/stats.js
CHANGED
|
@@ -88,6 +88,7 @@ function formatEventLabel(eventId) {
|
|
|
88
88
|
const table = {
|
|
89
89
|
'autopilot:conflict-crusher': 'Autopilot – Conflict Crusher',
|
|
90
90
|
'autopilot:release-ready': 'Autopilot – Release Ready',
|
|
91
|
+
'autopilot:pr-polish': 'Autopilot – PR Polish',
|
|
91
92
|
'commit:interactive': 'Interactive AI commits',
|
|
92
93
|
'commit:quick': 'Quick commits',
|
|
93
94
|
'conflict:auto': 'AI conflict resolution',
|
package/dist/repl/interpreter.js
CHANGED
|
@@ -207,16 +207,50 @@ 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 {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
console.log('');
|
|
248
|
+
const { showStatus } = await Promise.resolve().then(() => __importStar(require('../commands/cursor-style')));
|
|
249
|
+
await showStatus();
|
|
216
250
|
return true;
|
|
217
251
|
}
|
|
218
252
|
catch (error) {
|
|
219
|
-
console.log(chalk_1.default.red(
|
|
253
|
+
console.log(chalk_1.default.red(`\n❌ Failed to get status: ${error.message}\n`));
|
|
220
254
|
return true;
|
|
221
255
|
}
|
|
222
256
|
}
|
|
@@ -345,7 +379,23 @@ async function tryQuickCommands(input, context) {
|
|
|
345
379
|
gitAdvanced.showLog();
|
|
346
380
|
return true;
|
|
347
381
|
}
|
|
348
|
-
// Git Advanced: Show diff
|
|
382
|
+
// Git Advanced: Show diff for specific file
|
|
383
|
+
const diffFileMatch = input.match(/(?:show|what).*(?:diff|changed).*(?:in|for|of)\s+(.+)/i) ||
|
|
384
|
+
input.match(/show diff (?:for|of|on)\s+(.+)/i) ||
|
|
385
|
+
input.match(/diff (?:for|of|on)\s+(.+)/i);
|
|
386
|
+
if (diffFileMatch) {
|
|
387
|
+
const raw = diffFileMatch[1]
|
|
388
|
+
.trim()
|
|
389
|
+
.replace(/^the\s+/i, '')
|
|
390
|
+
.replace(/^(file|files)\s+/i, '')
|
|
391
|
+
.replace(/\s+please$/i, '')
|
|
392
|
+
.replace(/[?]+$/g, '');
|
|
393
|
+
if (raw.length > 0) {
|
|
394
|
+
gitAdvanced.showDiffForFile(raw);
|
|
395
|
+
return true;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
// Git Advanced: Show diff (general)
|
|
349
399
|
if (lower === 'diff' || lower === 'show diff' || lower === 'what changed' || lower === 'changes') {
|
|
350
400
|
gitAdvanced.showDiff();
|
|
351
401
|
return true;
|