claude-issue-solver 1.24.0 → 1.24.2
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/config.js +27 -0
- package/dist/commands/review.js +62 -8
- package/package.json +1 -1
package/dist/commands/config.js
CHANGED
|
@@ -81,6 +81,18 @@ function validateToken(token) {
|
|
|
81
81
|
return { valid: false, error: error.message };
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
+
function getCurrentUser() {
|
|
85
|
+
try {
|
|
86
|
+
const output = (0, child_process_1.execSync)('gh api user --jq .login', {
|
|
87
|
+
encoding: 'utf-8',
|
|
88
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
89
|
+
});
|
|
90
|
+
return output.trim();
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
84
96
|
async function configCommand(action, value) {
|
|
85
97
|
// Handle clear action
|
|
86
98
|
if (action === '--clear' || action === 'clear') {
|
|
@@ -244,6 +256,21 @@ async function promptForToken() {
|
|
|
244
256
|
console.log(chalk_1.default.dim('\nValidating token...'));
|
|
245
257
|
const result = validateToken(token);
|
|
246
258
|
if (result.valid) {
|
|
259
|
+
// Check if token belongs to the same user as current gh auth
|
|
260
|
+
const currentUser = getCurrentUser();
|
|
261
|
+
if (currentUser && result.login === currentUser) {
|
|
262
|
+
console.log(chalk_1.default.red(`\n❌ This token belongs to your current account (${currentUser}).`));
|
|
263
|
+
console.log(chalk_1.default.yellow('\n⚠️ To approve your own PRs, you need a DIFFERENT account.'));
|
|
264
|
+
console.log(chalk_1.default.dim('\nGitHub doesn\'t allow approving your own PRs, even with a different token.'));
|
|
265
|
+
console.log(chalk_1.default.dim('The bot must be a separate GitHub account.\n'));
|
|
266
|
+
console.log('Steps to create a bot account:');
|
|
267
|
+
console.log(chalk_1.default.dim(' 1. Sign out of GitHub (or use incognito)'));
|
|
268
|
+
console.log(chalk_1.default.dim(` 2. Create new account (e.g., ${currentUser}-bot)`));
|
|
269
|
+
console.log(chalk_1.default.dim(' 3. Add the bot as collaborator to your repos'));
|
|
270
|
+
console.log(chalk_1.default.dim(' 4. Create a token from the bot account'));
|
|
271
|
+
console.log(chalk_1.default.dim(' 5. Run `cis config bot-token` again\n'));
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
247
274
|
const config = getConfig();
|
|
248
275
|
config.botToken = token;
|
|
249
276
|
saveConfig(config);
|
package/dist/commands/review.js
CHANGED
|
@@ -152,6 +152,9 @@ async function reviewCommand(issueNumber) {
|
|
|
152
152
|
catch {
|
|
153
153
|
console.log(chalk_1.default.yellow('Could not fetch PR diff, Claude will review the files directly.'));
|
|
154
154
|
}
|
|
155
|
+
// Check for bot token early to include in prompt
|
|
156
|
+
const botToken = (0, config_1.getBotToken)();
|
|
157
|
+
const ghCmd = botToken ? `GH_TOKEN=\${BOT_TOKEN} gh` : 'gh';
|
|
155
158
|
// Build the review prompt
|
|
156
159
|
const prompt = `You are reviewing PR #${prNumber} for issue #${issueNumber}: ${issue.title}
|
|
157
160
|
|
|
@@ -168,7 +171,33 @@ Review the code changes in this PR. Look for:
|
|
|
168
171
|
6. Performance problems
|
|
169
172
|
|
|
170
173
|
## How to Leave Feedback
|
|
174
|
+
${botToken ? `
|
|
175
|
+
**IMPORTANT: A bot token is configured. Use this prefix for ALL gh commands:**
|
|
176
|
+
\`\`\`bash
|
|
177
|
+
GH_TOKEN=\${BOT_TOKEN} gh pr review ...
|
|
178
|
+
GH_TOKEN=\${BOT_TOKEN} gh pr comment ...
|
|
179
|
+
\`\`\`
|
|
180
|
+
The BOT_TOKEN environment variable is already set in this terminal.
|
|
171
181
|
|
|
182
|
+
You can use formal reviews (approve/request-changes):
|
|
183
|
+
|
|
184
|
+
\`\`\`bash
|
|
185
|
+
# Post suggestions as review comments
|
|
186
|
+
GH_TOKEN=\${BOT_TOKEN} gh pr review ${prNumber} --comment --body "**File: path/to/file.ts**
|
|
187
|
+
|
|
188
|
+
Description of the issue...
|
|
189
|
+
|
|
190
|
+
\\\`\\\`\\\`suggestion
|
|
191
|
+
// Your suggested fix here
|
|
192
|
+
\\\`\\\`\\\`
|
|
193
|
+
"
|
|
194
|
+
|
|
195
|
+
# Final verdict
|
|
196
|
+
GH_TOKEN=\${BOT_TOKEN} gh pr review ${prNumber} --approve --body "LGTM! Code looks good."
|
|
197
|
+
# OR
|
|
198
|
+
GH_TOKEN=\${BOT_TOKEN} gh pr review ${prNumber} --request-changes --body "Please address the issues above."
|
|
199
|
+
\`\`\`
|
|
200
|
+
` : `
|
|
172
201
|
First, check if you can post formal reviews by running these commands:
|
|
173
202
|
\`\`\`bash
|
|
174
203
|
# Get PR author
|
|
@@ -211,7 +240,7 @@ Description of the issue...
|
|
|
211
240
|
\\\`\\\`\\\`
|
|
212
241
|
"
|
|
213
242
|
\`\`\`
|
|
214
|
-
|
|
243
|
+
`}
|
|
215
244
|
The \`suggestion\` code block creates a "Commit suggestion" button on GitHub.
|
|
216
245
|
|
|
217
246
|
## PR Diff
|
|
@@ -221,9 +250,8 @@ Start by examining the diff and the changed files, then provide your review.`;
|
|
|
221
250
|
// Write prompt to a file
|
|
222
251
|
const promptFile = path.join(worktreePath, '.claude-review-prompt.txt');
|
|
223
252
|
fs.writeFileSync(promptFile, prompt);
|
|
224
|
-
//
|
|
225
|
-
const botToken =
|
|
226
|
-
const botTokenEnv = botToken ? `export GH_TOKEN="${botToken}"` : '# No bot token configured';
|
|
253
|
+
// Bot token already fetched above
|
|
254
|
+
const botTokenEnv = botToken ? `export BOT_TOKEN="${botToken}"\nexport GH_TOKEN="${botToken}"` : '# No bot token configured';
|
|
227
255
|
const botNote = botToken
|
|
228
256
|
? 'Using bot token for reviews (can approve/request changes)'
|
|
229
257
|
: 'No bot token - using your account (may have limitations on own PRs)';
|
|
@@ -420,6 +448,8 @@ async function launchReviewForPR(pr, projectRoot, projectName) {
|
|
|
420
448
|
issueBody = issue.body;
|
|
421
449
|
}
|
|
422
450
|
}
|
|
451
|
+
// Check for bot token
|
|
452
|
+
const botToken = (0, config_1.getBotToken)();
|
|
423
453
|
// Build the review prompt
|
|
424
454
|
const prompt = `You are reviewing PR #${pr.number}: ${pr.title}
|
|
425
455
|
${pr.issueNumber ? `\n## Related Issue #${pr.issueNumber}\n${issueBody}\n` : ''}
|
|
@@ -433,7 +463,33 @@ Review the code changes in this PR. Look for:
|
|
|
433
463
|
6. Performance problems
|
|
434
464
|
|
|
435
465
|
## How to Leave Feedback
|
|
466
|
+
${botToken ? `
|
|
467
|
+
**IMPORTANT: A bot token is configured. Use this prefix for ALL gh commands:**
|
|
468
|
+
\`\`\`bash
|
|
469
|
+
GH_TOKEN=\${BOT_TOKEN} gh pr review ...
|
|
470
|
+
GH_TOKEN=\${BOT_TOKEN} gh pr comment ...
|
|
471
|
+
\`\`\`
|
|
472
|
+
The BOT_TOKEN environment variable is already set in this terminal.
|
|
473
|
+
|
|
474
|
+
You can use formal reviews (approve/request-changes):
|
|
475
|
+
|
|
476
|
+
\`\`\`bash
|
|
477
|
+
# Post suggestions as review comments
|
|
478
|
+
GH_TOKEN=\${BOT_TOKEN} gh pr review ${pr.number} --comment --body "**File: path/to/file.ts**
|
|
479
|
+
|
|
480
|
+
Description of the issue...
|
|
481
|
+
|
|
482
|
+
\\\`\\\`\\\`suggestion
|
|
483
|
+
// Your suggested fix here
|
|
484
|
+
\\\`\\\`\\\`
|
|
485
|
+
"
|
|
436
486
|
|
|
487
|
+
# Final verdict
|
|
488
|
+
GH_TOKEN=\${BOT_TOKEN} gh pr review ${pr.number} --approve --body "LGTM! Code looks good."
|
|
489
|
+
# OR
|
|
490
|
+
GH_TOKEN=\${BOT_TOKEN} gh pr review ${pr.number} --request-changes --body "Please address the issues above."
|
|
491
|
+
\`\`\`
|
|
492
|
+
` : `
|
|
437
493
|
First, check if you can post formal reviews by running these commands:
|
|
438
494
|
\`\`\`bash
|
|
439
495
|
# Get PR author
|
|
@@ -476,7 +532,7 @@ Description of the issue...
|
|
|
476
532
|
\\\`\\\`\\\`
|
|
477
533
|
"
|
|
478
534
|
\`\`\`
|
|
479
|
-
|
|
535
|
+
`}
|
|
480
536
|
The \`suggestion\` code block creates a "Commit suggestion" button on GitHub.
|
|
481
537
|
|
|
482
538
|
## PR Diff
|
|
@@ -486,9 +542,7 @@ Start by examining the diff and the changed files, then provide your review.`;
|
|
|
486
542
|
// Write prompt to a file
|
|
487
543
|
const promptFile = path.join(worktreePath, '.claude-review-prompt.txt');
|
|
488
544
|
fs.writeFileSync(promptFile, prompt);
|
|
489
|
-
|
|
490
|
-
const botToken = (0, config_1.getBotToken)();
|
|
491
|
-
const botTokenEnv = botToken ? `export GH_TOKEN="${botToken}"` : '# No bot token configured';
|
|
545
|
+
const botTokenEnv = botToken ? `export BOT_TOKEN="${botToken}"\nexport GH_TOKEN="${botToken}"` : '# No bot token configured';
|
|
492
546
|
const botNote = botToken
|
|
493
547
|
? 'Using bot token for reviews (can approve/request changes)'
|
|
494
548
|
: 'No bot token - using your account (may have limitations on own PRs)';
|