@snapcommit/cli 3.1.0 → 3.2.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 +37 -15
- package/dist/lib/github.js +37 -0
- package/package.json +1 -1
|
@@ -292,10 +292,14 @@ async function executeGitHubCommand(intent) {
|
|
|
292
292
|
}
|
|
293
293
|
break;
|
|
294
294
|
case 'pr_merge':
|
|
295
|
-
|
|
295
|
+
let prNumber = intent.target || intent.options?.number;
|
|
296
|
+
// Smart PR detection: "merge my PR" / "merge this PR"
|
|
296
297
|
if (!prNumber) {
|
|
297
|
-
|
|
298
|
-
|
|
298
|
+
prNumber = await github.findPRNumber('current');
|
|
299
|
+
if (!prNumber) {
|
|
300
|
+
console.log(chalk_1.default.red('\n❌ No PR found for current branch\n'));
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
299
303
|
}
|
|
300
304
|
console.log(chalk_1.default.blue(`\n🔄 Merging PR #${prNumber}...`));
|
|
301
305
|
await github.mergePullRequest(prNumber);
|
|
@@ -362,10 +366,16 @@ async function executeGitHubCommand(intent) {
|
|
|
362
366
|
console.log(chalk_1.default.green(`✓ Issue #${reopenIssueNum} reopened\n`));
|
|
363
367
|
break;
|
|
364
368
|
case 'pr_review':
|
|
365
|
-
|
|
369
|
+
let reviewPrNum = intent.target || intent.options?.number;
|
|
370
|
+
// Smart PR detection: "approve this PR" / "approve my PR"
|
|
366
371
|
if (!reviewPrNum) {
|
|
367
|
-
|
|
368
|
-
|
|
372
|
+
const context = intent.options?.context || 'current';
|
|
373
|
+
reviewPrNum = await github.findPRNumber(context);
|
|
374
|
+
if (!reviewPrNum) {
|
|
375
|
+
console.log(chalk_1.default.red('\n❌ No PR found for current branch'));
|
|
376
|
+
console.log(chalk_1.default.gray(' Try: "approve PR #123" or create a PR first\n'));
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
369
379
|
}
|
|
370
380
|
const reviewType = intent.options?.type || 'APPROVE';
|
|
371
381
|
const reviewBody = intent.options?.body || '';
|
|
@@ -385,10 +395,14 @@ async function executeGitHubCommand(intent) {
|
|
|
385
395
|
}
|
|
386
396
|
break;
|
|
387
397
|
case 'pr_comment':
|
|
388
|
-
|
|
398
|
+
let commentPrNum = intent.target || intent.options?.number;
|
|
399
|
+
// Smart PR detection
|
|
389
400
|
if (!commentPrNum) {
|
|
390
|
-
|
|
391
|
-
|
|
401
|
+
commentPrNum = await github.findPRNumber('current');
|
|
402
|
+
if (!commentPrNum) {
|
|
403
|
+
console.log(chalk_1.default.red('\n❌ No PR found for current branch\n'));
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
392
406
|
}
|
|
393
407
|
const prComment = intent.options?.body || intent.options?.comment || '';
|
|
394
408
|
if (!prComment) {
|
|
@@ -416,10 +430,14 @@ async function executeGitHubCommand(intent) {
|
|
|
416
430
|
break;
|
|
417
431
|
case 'pr_show':
|
|
418
432
|
case 'pr_status':
|
|
419
|
-
|
|
433
|
+
let showPrNum = intent.target || intent.options?.number;
|
|
434
|
+
// Smart PR detection: "show my PR" / "show this PR"
|
|
420
435
|
if (!showPrNum) {
|
|
421
|
-
|
|
422
|
-
|
|
436
|
+
showPrNum = await github.findPRNumber('current');
|
|
437
|
+
if (!showPrNum) {
|
|
438
|
+
console.log(chalk_1.default.red('\n❌ No PR found for current branch\n'));
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
423
441
|
}
|
|
424
442
|
console.log(chalk_1.default.blue(`\n📋 PR #${showPrNum}:\n`));
|
|
425
443
|
const prDetails = await github.getPullRequest(showPrNum);
|
|
@@ -442,10 +460,14 @@ async function executeGitHubCommand(intent) {
|
|
|
442
460
|
}
|
|
443
461
|
break;
|
|
444
462
|
case 'pr_diff':
|
|
445
|
-
|
|
463
|
+
let diffPrNum = intent.target || intent.options?.number;
|
|
464
|
+
// Smart PR detection: "what changed in my PR"
|
|
446
465
|
if (!diffPrNum) {
|
|
447
|
-
|
|
448
|
-
|
|
466
|
+
diffPrNum = await github.findPRNumber('current');
|
|
467
|
+
if (!diffPrNum) {
|
|
468
|
+
console.log(chalk_1.default.red('\n❌ No PR found for current branch\n'));
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
449
471
|
}
|
|
450
472
|
console.log(chalk_1.default.blue(`\n📄 PR #${diffPrNum} changes:\n`));
|
|
451
473
|
const files = await github.getPullRequestFiles(diffPrNum);
|
package/dist/lib/github.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getCurrentRepo = getCurrentRepo;
|
|
4
4
|
exports.getCurrentBranch = getCurrentBranch;
|
|
5
|
+
exports.findPRNumber = findPRNumber;
|
|
6
|
+
exports.findIssueNumber = findIssueNumber;
|
|
5
7
|
exports.createPullRequest = createPullRequest;
|
|
6
8
|
exports.listPullRequests = listPullRequests;
|
|
7
9
|
exports.getPullRequest = getPullRequest;
|
|
@@ -63,6 +65,41 @@ function getCurrentBranch() {
|
|
|
63
65
|
return 'main';
|
|
64
66
|
}
|
|
65
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Find PR number from context (current branch, latest, etc.)
|
|
70
|
+
*/
|
|
71
|
+
async function findPRNumber(context) {
|
|
72
|
+
try {
|
|
73
|
+
if (context === 'current' || !context) {
|
|
74
|
+
// Find PR for current branch
|
|
75
|
+
const branch = getCurrentBranch();
|
|
76
|
+
const prs = await listPullRequests({ state: 'open', limit: 50 });
|
|
77
|
+
const pr = prs.find((p) => p.head.ref === branch);
|
|
78
|
+
return pr ? pr.number : null;
|
|
79
|
+
}
|
|
80
|
+
else if (context === 'latest' || context === 'mine') {
|
|
81
|
+
// Get latest PR
|
|
82
|
+
const prs = await listPullRequests({ state: 'open', limit: 1 });
|
|
83
|
+
return prs.length > 0 ? prs[0].number : null;
|
|
84
|
+
}
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Find issue number from context (latest, etc.)
|
|
93
|
+
*/
|
|
94
|
+
async function findIssueNumber(context) {
|
|
95
|
+
try {
|
|
96
|
+
const issues = await listIssues({ state: 'open', limit: 1 });
|
|
97
|
+
return issues.length > 0 ? issues[0].number : null;
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
66
103
|
/**
|
|
67
104
|
* GitHub API request helper - uses locally stored token
|
|
68
105
|
*/
|