claude-issue-solver 1.23.1 → 1.24.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/README.md +23 -0
- package/dist/commands/config.d.ts +8 -0
- package/dist/commands/config.js +259 -0
- package/dist/commands/review.js +79 -16
- package/dist/index.js +8 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -157,6 +157,7 @@ claude-issue --help
|
|
|
157
157
|
| `claude-issue show <number>` | - | Show full issue details |
|
|
158
158
|
| `claude-issue pr <number>` | - | Create PR for solved issue |
|
|
159
159
|
| `claude-issue review [number]` | - | Review PRs with AI suggestions |
|
|
160
|
+
| `claude-issue config` | - | Manage settings (bot token) |
|
|
160
161
|
| `claude-issue clean [number]` | `rm` | Remove worktree and branch |
|
|
161
162
|
| `claude-issue go [number]` | - | Navigate to worktree |
|
|
162
163
|
| `claude-issue init` | - | Setup wizard for requirements |
|
|
@@ -176,6 +177,11 @@ claude-issue --help
|
|
|
176
177
|
- `-a, --all` - Clean all issue worktrees (with confirmation)
|
|
177
178
|
- `-m, --merged` - Clean only worktrees with merged PRs (no confirmation)
|
|
178
179
|
|
|
180
|
+
**`config` command:**
|
|
181
|
+
- `cis config` - Show current configuration
|
|
182
|
+
- `cis config bot-token` - Set up a bot token for reviews
|
|
183
|
+
- `cis config --clear` - Clear all configuration
|
|
184
|
+
|
|
179
185
|
## How it works
|
|
180
186
|
|
|
181
187
|
1. **Fetches issue** - Gets title and description from GitHub
|
|
@@ -256,6 +262,23 @@ Branches are named `issue-{number}-{slug}` where the slug is:
|
|
|
256
262
|
- Bracket prefixes removed (e.g., `[Bug]` is stripped)
|
|
257
263
|
- Duplicate consecutive words removed (e.g., `fix-fix-bug` → `fix-bug`)
|
|
258
264
|
|
|
265
|
+
### AI Code Review
|
|
266
|
+
The `review` command lets Claude review PRs and post suggestions:
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
cis review # Select PRs to review (parallel)
|
|
270
|
+
cis review 42 # Review specific issue's PR
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Claude auto-detects whether you're reviewing your own PR or someone else's:
|
|
274
|
+
- **Your own PR**: Posts comments with suggestions (GitHub limitation)
|
|
275
|
+
- **Someone else's PR**: Can approve or request changes
|
|
276
|
+
|
|
277
|
+
**Bot Token (Optional)**: Set up a bot token to get full review capabilities on your own PRs:
|
|
278
|
+
```bash
|
|
279
|
+
cis config bot-token # Interactive setup with instructions
|
|
280
|
+
```
|
|
281
|
+
|
|
259
282
|
## Tips
|
|
260
283
|
|
|
261
284
|
- PRs are created automatically when Claude makes commits - no need to wait until the end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface Config {
|
|
2
|
+
botToken?: string;
|
|
3
|
+
}
|
|
4
|
+
export declare function getConfig(): Config;
|
|
5
|
+
export declare function saveConfig(config: Config): void;
|
|
6
|
+
export declare function getBotToken(): string | undefined;
|
|
7
|
+
export declare function configCommand(action?: string, value?: string): Promise<void>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.getConfig = getConfig;
|
|
40
|
+
exports.saveConfig = saveConfig;
|
|
41
|
+
exports.getBotToken = getBotToken;
|
|
42
|
+
exports.configCommand = configCommand;
|
|
43
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
44
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
45
|
+
const fs = __importStar(require("fs"));
|
|
46
|
+
const path = __importStar(require("path"));
|
|
47
|
+
const os = __importStar(require("os"));
|
|
48
|
+
const child_process_1 = require("child_process");
|
|
49
|
+
const CONFIG_DIR = path.join(os.homedir(), '.claude-issue-solver');
|
|
50
|
+
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
|
|
51
|
+
function getConfig() {
|
|
52
|
+
try {
|
|
53
|
+
if (fs.existsSync(CONFIG_FILE)) {
|
|
54
|
+
return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf-8'));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
// Ignore errors
|
|
59
|
+
}
|
|
60
|
+
return {};
|
|
61
|
+
}
|
|
62
|
+
function saveConfig(config) {
|
|
63
|
+
if (!fs.existsSync(CONFIG_DIR)) {
|
|
64
|
+
fs.mkdirSync(CONFIG_DIR, { recursive: true, mode: 0o700 });
|
|
65
|
+
}
|
|
66
|
+
fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2), { mode: 0o600 });
|
|
67
|
+
}
|
|
68
|
+
function getBotToken() {
|
|
69
|
+
return getConfig().botToken;
|
|
70
|
+
}
|
|
71
|
+
function validateToken(token) {
|
|
72
|
+
try {
|
|
73
|
+
const output = (0, child_process_1.execSync)('gh api user --jq .login', {
|
|
74
|
+
encoding: 'utf-8',
|
|
75
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
76
|
+
env: { ...process.env, GH_TOKEN: token },
|
|
77
|
+
});
|
|
78
|
+
return { valid: true, login: output.trim() };
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
return { valid: false, error: error.message };
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
async function configCommand(action, value) {
|
|
85
|
+
// Handle clear action
|
|
86
|
+
if (action === '--clear' || action === 'clear') {
|
|
87
|
+
if (fs.existsSync(CONFIG_FILE)) {
|
|
88
|
+
fs.unlinkSync(CONFIG_FILE);
|
|
89
|
+
console.log(chalk_1.default.green('\n✅ Configuration cleared.\n'));
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
console.log(chalk_1.default.dim('\nNo configuration to clear.\n'));
|
|
93
|
+
}
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
// Handle bot-token action
|
|
97
|
+
if (action === 'bot-token') {
|
|
98
|
+
if (value) {
|
|
99
|
+
// Direct token provided
|
|
100
|
+
console.log(chalk_1.default.dim('\nValidating token...'));
|
|
101
|
+
const result = validateToken(value);
|
|
102
|
+
if (result.valid) {
|
|
103
|
+
const config = getConfig();
|
|
104
|
+
config.botToken = value;
|
|
105
|
+
saveConfig(config);
|
|
106
|
+
console.log(chalk_1.default.green(`\n✅ Bot token saved! Authenticated as: ${result.login}\n`));
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
console.log(chalk_1.default.red('\n❌ Invalid token. Please check and try again.\n'));
|
|
110
|
+
}
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
// Interactive setup
|
|
114
|
+
await setupBotToken();
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
// Show current config
|
|
118
|
+
const config = getConfig();
|
|
119
|
+
console.log(chalk_1.default.bold('\nClaude Issue Solver Configuration\n'));
|
|
120
|
+
if (config.botToken) {
|
|
121
|
+
const result = validateToken(config.botToken);
|
|
122
|
+
if (result.valid) {
|
|
123
|
+
console.log(` Bot token: ${chalk_1.default.green('✓ Configured')} (${result.login})`);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
console.log(` Bot token: ${chalk_1.default.yellow('⚠ Invalid or expired')}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
console.log(` Bot token: ${chalk_1.default.dim('Not configured')}`);
|
|
131
|
+
}
|
|
132
|
+
console.log();
|
|
133
|
+
console.log(chalk_1.default.dim('Commands:'));
|
|
134
|
+
console.log(chalk_1.default.dim(' cis config bot-token Set up a bot token for reviews'));
|
|
135
|
+
console.log(chalk_1.default.dim(' cis config --clear Clear all configuration'));
|
|
136
|
+
console.log();
|
|
137
|
+
}
|
|
138
|
+
async function setupBotToken() {
|
|
139
|
+
console.log(chalk_1.default.bold('\n🤖 Bot Token Setup\n'));
|
|
140
|
+
console.log(`A bot token allows Claude to post formal reviews (approve/request changes)
|
|
141
|
+
on your own PRs. Without it, Claude can only post comments on your own PRs.
|
|
142
|
+
|
|
143
|
+
${chalk_1.default.bold('You have two options:')}\n`);
|
|
144
|
+
const { choice } = await inquirer_1.default.prompt([
|
|
145
|
+
{
|
|
146
|
+
type: 'list',
|
|
147
|
+
name: 'choice',
|
|
148
|
+
message: 'How would you like to set up the bot?',
|
|
149
|
+
choices: [
|
|
150
|
+
{ name: 'Use my existing account (create a token)', value: 'same-account' },
|
|
151
|
+
{ name: 'Create a separate bot account (recommended for teams)', value: 'new-account' },
|
|
152
|
+
{ name: 'I already have a token', value: 'have-token' },
|
|
153
|
+
{ name: 'Cancel', value: 'cancel' },
|
|
154
|
+
],
|
|
155
|
+
},
|
|
156
|
+
]);
|
|
157
|
+
if (choice === 'cancel') {
|
|
158
|
+
console.log(chalk_1.default.dim('\nCancelled.\n'));
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (choice === 'have-token') {
|
|
162
|
+
await promptForToken();
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (choice === 'new-account') {
|
|
166
|
+
console.log(chalk_1.default.bold('\n📝 Creating a Bot Account\n'));
|
|
167
|
+
console.log(`1. Sign out of GitHub or open an incognito window
|
|
168
|
+
2. Create a new account (e.g., ${chalk_1.default.cyan('yourname-bot')})
|
|
169
|
+
- Use email alias: ${chalk_1.default.cyan('you+bot@gmail.com')}
|
|
170
|
+
3. Add the bot as a collaborator to your repos:
|
|
171
|
+
- Repo → Settings → Collaborators → Add the bot
|
|
172
|
+
4. Log into the bot account and create a token (next step)
|
|
173
|
+
`);
|
|
174
|
+
const { ready } = await inquirer_1.default.prompt([
|
|
175
|
+
{
|
|
176
|
+
type: 'confirm',
|
|
177
|
+
name: 'ready',
|
|
178
|
+
message: 'Ready to create a token for the bot account?',
|
|
179
|
+
default: true,
|
|
180
|
+
},
|
|
181
|
+
]);
|
|
182
|
+
if (!ready) {
|
|
183
|
+
console.log(chalk_1.default.dim('\nRun `cis config bot-token` when ready.\n'));
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
// Open GitHub token page
|
|
188
|
+
console.log(chalk_1.default.bold('\n🔑 Creating a Personal Access Token\n'));
|
|
189
|
+
console.log(`I'll open GitHub's token creation page. Create a token with:
|
|
190
|
+
|
|
191
|
+
${chalk_1.default.bold('Settings:')}
|
|
192
|
+
• Token name: ${chalk_1.default.cyan('claude-issue-solver-bot')}
|
|
193
|
+
• Expiration: ${chalk_1.default.cyan('90 days')} (or your preference)
|
|
194
|
+
• Repository access: ${chalk_1.default.cyan('Only select repositories')} (pick your repos)
|
|
195
|
+
|
|
196
|
+
${chalk_1.default.bold('Permissions needed:')}
|
|
197
|
+
• ${chalk_1.default.cyan('Pull requests')}: Read and write
|
|
198
|
+
• ${chalk_1.default.cyan('Contents')}: Read (to see PR diffs)
|
|
199
|
+
`);
|
|
200
|
+
const { openBrowser } = await inquirer_1.default.prompt([
|
|
201
|
+
{
|
|
202
|
+
type: 'confirm',
|
|
203
|
+
name: 'openBrowser',
|
|
204
|
+
message: 'Open GitHub token page in browser?',
|
|
205
|
+
default: true,
|
|
206
|
+
},
|
|
207
|
+
]);
|
|
208
|
+
if (openBrowser) {
|
|
209
|
+
const tokenUrl = 'https://github.com/settings/personal-access-tokens/new';
|
|
210
|
+
try {
|
|
211
|
+
if (process.platform === 'darwin') {
|
|
212
|
+
(0, child_process_1.execSync)(`open "${tokenUrl}"`, { stdio: 'pipe' });
|
|
213
|
+
}
|
|
214
|
+
else if (process.platform === 'linux') {
|
|
215
|
+
(0, child_process_1.execSync)(`xdg-open "${tokenUrl}"`, { stdio: 'pipe' });
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
console.log(chalk_1.default.dim(`\nOpen this URL: ${tokenUrl}\n`));
|
|
219
|
+
}
|
|
220
|
+
console.log(chalk_1.default.dim('\nOpened GitHub in your browser.\n'));
|
|
221
|
+
}
|
|
222
|
+
catch {
|
|
223
|
+
console.log(chalk_1.default.dim(`\nOpen this URL: ${tokenUrl}\n`));
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
console.log(chalk_1.default.dim('\nGo to: https://github.com/settings/personal-access-tokens/new\n'));
|
|
228
|
+
}
|
|
229
|
+
await promptForToken();
|
|
230
|
+
}
|
|
231
|
+
async function promptForToken() {
|
|
232
|
+
const { token } = await inquirer_1.default.prompt([
|
|
233
|
+
{
|
|
234
|
+
type: 'password',
|
|
235
|
+
name: 'token',
|
|
236
|
+
message: 'Paste your token here:',
|
|
237
|
+
mask: '*',
|
|
238
|
+
},
|
|
239
|
+
]);
|
|
240
|
+
if (!token) {
|
|
241
|
+
console.log(chalk_1.default.dim('\nNo token provided.\n'));
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
console.log(chalk_1.default.dim('\nValidating token...'));
|
|
245
|
+
const result = validateToken(token);
|
|
246
|
+
if (result.valid) {
|
|
247
|
+
const config = getConfig();
|
|
248
|
+
config.botToken = token;
|
|
249
|
+
saveConfig(config);
|
|
250
|
+
console.log(chalk_1.default.green(`\n✅ Bot token saved!`));
|
|
251
|
+
console.log(chalk_1.default.dim(` Authenticated as: ${result.login}`));
|
|
252
|
+
console.log(chalk_1.default.dim(` Config stored in: ${CONFIG_FILE}\n`));
|
|
253
|
+
console.log(`Now when you run ${chalk_1.default.cyan('cis review')}, Claude can post formal reviews.\n`);
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
console.log(chalk_1.default.red('\n❌ Invalid token. Please check and try again.'));
|
|
257
|
+
console.log(chalk_1.default.dim(' Run `cis config bot-token` to retry.\n'));
|
|
258
|
+
}
|
|
259
|
+
}
|
package/dist/commands/review.js
CHANGED
|
@@ -47,6 +47,7 @@ const child_process_1 = require("child_process");
|
|
|
47
47
|
const github_1 = require("../utils/github");
|
|
48
48
|
const git_1 = require("../utils/git");
|
|
49
49
|
const helpers_1 = require("../utils/helpers");
|
|
50
|
+
const config_1 = require("./config");
|
|
50
51
|
async function reviewCommand(issueNumber) {
|
|
51
52
|
const spinner = (0, ora_1.default)(`Fetching issue #${issueNumber}...`).start();
|
|
52
53
|
const issue = (0, github_1.getIssue)(issueNumber);
|
|
@@ -167,10 +168,22 @@ Review the code changes in this PR. Look for:
|
|
|
167
168
|
6. Performance problems
|
|
168
169
|
|
|
169
170
|
## How to Leave Feedback
|
|
170
|
-
Use the gh CLI to post comments with suggestions. For each issue you find:
|
|
171
171
|
|
|
172
|
+
First, check if you can post formal reviews by running these commands:
|
|
172
173
|
\`\`\`bash
|
|
173
|
-
|
|
174
|
+
# Get PR author
|
|
175
|
+
PR_AUTHOR=$(gh pr view ${prNumber} --json author --jq .author.login)
|
|
176
|
+
# Get current user
|
|
177
|
+
CURRENT_USER=$(gh api user --jq .login)
|
|
178
|
+
echo "PR author: $PR_AUTHOR, Current user: $CURRENT_USER"
|
|
179
|
+
\`\`\`
|
|
180
|
+
|
|
181
|
+
### If PR author ≠ Current user (reviewing someone else's PR):
|
|
182
|
+
You can use formal reviews with approve/request-changes:
|
|
183
|
+
|
|
184
|
+
\`\`\`bash
|
|
185
|
+
# Post suggestions as review comments
|
|
186
|
+
gh pr review ${prNumber} --comment --body "**File: path/to/file.ts**
|
|
174
187
|
|
|
175
188
|
Description of the issue...
|
|
176
189
|
|
|
@@ -178,20 +191,28 @@ Description of the issue...
|
|
|
178
191
|
// Your suggested fix here
|
|
179
192
|
\\\`\\\`\\\`
|
|
180
193
|
"
|
|
194
|
+
|
|
195
|
+
# Final verdict
|
|
196
|
+
gh pr review ${prNumber} --approve --body "LGTM! Code looks good."
|
|
197
|
+
# OR
|
|
198
|
+
gh pr review ${prNumber} --request-changes --body "Please address the issues above."
|
|
181
199
|
\`\`\`
|
|
182
200
|
|
|
183
|
-
|
|
201
|
+
### If PR author = Current user (reviewing your own PR):
|
|
202
|
+
You can only post comments (GitHub doesn't allow self-review):
|
|
184
203
|
|
|
185
|
-
For a final review summary:
|
|
186
204
|
\`\`\`bash
|
|
187
|
-
gh pr comment ${prNumber} --body "
|
|
205
|
+
gh pr comment ${prNumber} --body "**File: path/to/file.ts**
|
|
188
206
|
|
|
189
|
-
|
|
190
|
-
|
|
207
|
+
Description of the issue...
|
|
208
|
+
|
|
209
|
+
\\\`\\\`\\\`suggestion
|
|
210
|
+
// Your suggested fix here
|
|
211
|
+
\\\`\\\`\\\`
|
|
191
212
|
"
|
|
192
213
|
\`\`\`
|
|
193
214
|
|
|
194
|
-
|
|
215
|
+
The \`suggestion\` code block creates a "Commit suggestion" button on GitHub.
|
|
195
216
|
|
|
196
217
|
## PR Diff
|
|
197
218
|
${diffContent ? `\n\`\`\`diff\n${diffContent.slice(0, 50000)}\n\`\`\`\n` : 'Run `gh pr diff ' + prNumber + '` to see the changes.'}
|
|
@@ -200,11 +221,20 @@ Start by examining the diff and the changed files, then provide your review.`;
|
|
|
200
221
|
// Write prompt to a file
|
|
201
222
|
const promptFile = path.join(worktreePath, '.claude-review-prompt.txt');
|
|
202
223
|
fs.writeFileSync(promptFile, prompt);
|
|
224
|
+
// Check for bot token
|
|
225
|
+
const botToken = (0, config_1.getBotToken)();
|
|
226
|
+
const botTokenEnv = botToken ? `export GH_TOKEN="${botToken}"` : '# No bot token configured';
|
|
227
|
+
const botNote = botToken
|
|
228
|
+
? 'Using bot token for reviews (can approve/request changes)'
|
|
229
|
+
: 'No bot token - using your account (may have limitations on own PRs)';
|
|
203
230
|
// Create runner script for review
|
|
204
231
|
const runnerScript = path.join(worktreePath, '.claude-review-runner.sh');
|
|
205
232
|
const runnerContent = `#!/bin/bash
|
|
206
233
|
cd "${worktreePath}"
|
|
207
234
|
|
|
235
|
+
# Set bot token if configured
|
|
236
|
+
${botTokenEnv}
|
|
237
|
+
|
|
208
238
|
# Set terminal title
|
|
209
239
|
echo -ne "\\033]0;Review PR #${prNumber}: ${issue.title.replace(/"/g, '\\"').slice(0, 50)}\\007"
|
|
210
240
|
|
|
@@ -213,6 +243,8 @@ echo "━━━━━━━━━━━━━━━━━━━━━━━━
|
|
|
213
243
|
echo ""
|
|
214
244
|
echo "Issue #${issueNumber}: ${issue.title.replace(/"/g, '\\"')}"
|
|
215
245
|
echo ""
|
|
246
|
+
echo "${botNote}"
|
|
247
|
+
echo ""
|
|
216
248
|
echo "Claude will review the PR and post suggestions."
|
|
217
249
|
echo "You can commit suggestions directly on GitHub."
|
|
218
250
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
@@ -401,10 +433,22 @@ Review the code changes in this PR. Look for:
|
|
|
401
433
|
6. Performance problems
|
|
402
434
|
|
|
403
435
|
## How to Leave Feedback
|
|
404
|
-
Use the gh CLI to post comments with suggestions. For each issue you find:
|
|
405
436
|
|
|
437
|
+
First, check if you can post formal reviews by running these commands:
|
|
406
438
|
\`\`\`bash
|
|
407
|
-
|
|
439
|
+
# Get PR author
|
|
440
|
+
PR_AUTHOR=$(gh pr view ${pr.number} --json author --jq .author.login)
|
|
441
|
+
# Get current user
|
|
442
|
+
CURRENT_USER=$(gh api user --jq .login)
|
|
443
|
+
echo "PR author: $PR_AUTHOR, Current user: $CURRENT_USER"
|
|
444
|
+
\`\`\`
|
|
445
|
+
|
|
446
|
+
### If PR author ≠ Current user (reviewing someone else's PR):
|
|
447
|
+
You can use formal reviews with approve/request-changes:
|
|
448
|
+
|
|
449
|
+
\`\`\`bash
|
|
450
|
+
# Post suggestions as review comments
|
|
451
|
+
gh pr review ${pr.number} --comment --body "**File: path/to/file.ts**
|
|
408
452
|
|
|
409
453
|
Description of the issue...
|
|
410
454
|
|
|
@@ -412,20 +456,28 @@ Description of the issue...
|
|
|
412
456
|
// Your suggested fix here
|
|
413
457
|
\\\`\\\`\\\`
|
|
414
458
|
"
|
|
459
|
+
|
|
460
|
+
# Final verdict
|
|
461
|
+
gh pr review ${pr.number} --approve --body "LGTM! Code looks good."
|
|
462
|
+
# OR
|
|
463
|
+
gh pr review ${pr.number} --request-changes --body "Please address the issues above."
|
|
415
464
|
\`\`\`
|
|
416
465
|
|
|
417
|
-
|
|
466
|
+
### If PR author = Current user (reviewing your own PR):
|
|
467
|
+
You can only post comments (GitHub doesn't allow self-review):
|
|
418
468
|
|
|
419
|
-
For a final review summary:
|
|
420
469
|
\`\`\`bash
|
|
421
|
-
gh pr comment ${pr.number} --body "
|
|
470
|
+
gh pr comment ${pr.number} --body "**File: path/to/file.ts**
|
|
422
471
|
|
|
423
|
-
|
|
424
|
-
|
|
472
|
+
Description of the issue...
|
|
473
|
+
|
|
474
|
+
\\\`\\\`\\\`suggestion
|
|
475
|
+
// Your suggested fix here
|
|
476
|
+
\\\`\\\`\\\`
|
|
425
477
|
"
|
|
426
478
|
\`\`\`
|
|
427
479
|
|
|
428
|
-
|
|
480
|
+
The \`suggestion\` code block creates a "Commit suggestion" button on GitHub.
|
|
429
481
|
|
|
430
482
|
## PR Diff
|
|
431
483
|
${diffContent ? `\n\`\`\`diff\n${diffContent.slice(0, 50000)}\n\`\`\`\n` : 'Run `gh pr diff ' + pr.number + '` to see the changes.'}
|
|
@@ -434,12 +486,21 @@ Start by examining the diff and the changed files, then provide your review.`;
|
|
|
434
486
|
// Write prompt to a file
|
|
435
487
|
const promptFile = path.join(worktreePath, '.claude-review-prompt.txt');
|
|
436
488
|
fs.writeFileSync(promptFile, prompt);
|
|
489
|
+
// Check for bot token
|
|
490
|
+
const botToken = (0, config_1.getBotToken)();
|
|
491
|
+
const botTokenEnv = botToken ? `export GH_TOKEN="${botToken}"` : '# No bot token configured';
|
|
492
|
+
const botNote = botToken
|
|
493
|
+
? 'Using bot token for reviews (can approve/request changes)'
|
|
494
|
+
: 'No bot token - using your account (may have limitations on own PRs)';
|
|
437
495
|
// Create runner script for review
|
|
438
496
|
const runnerScript = path.join(worktreePath, '.claude-review-runner.sh');
|
|
439
497
|
const escapedTitle = pr.title.replace(/"/g, '\\"').slice(0, 50);
|
|
440
498
|
const runnerContent = `#!/bin/bash
|
|
441
499
|
cd "${worktreePath}"
|
|
442
500
|
|
|
501
|
+
# Set bot token if configured
|
|
502
|
+
${botTokenEnv}
|
|
503
|
+
|
|
443
504
|
# Set terminal title
|
|
444
505
|
echo -ne "\\033]0;Review PR #${pr.number}: ${escapedTitle}\\007"
|
|
445
506
|
|
|
@@ -448,6 +509,8 @@ echo "━━━━━━━━━━━━━━━━━━━━━━━━
|
|
|
448
509
|
echo ""
|
|
449
510
|
echo "${escapedTitle}"
|
|
450
511
|
echo ""
|
|
512
|
+
echo "${botNote}"
|
|
513
|
+
echo ""
|
|
451
514
|
echo "Claude will review the PR and post suggestions."
|
|
452
515
|
echo "You can commit suggestions directly on GitHub."
|
|
453
516
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
package/dist/index.js
CHANGED
|
@@ -18,6 +18,7 @@ const new_1 = require("./commands/new");
|
|
|
18
18
|
const init_1 = require("./commands/init");
|
|
19
19
|
const show_1 = require("./commands/show");
|
|
20
20
|
const review_1 = require("./commands/review");
|
|
21
|
+
const config_1 = require("./commands/config");
|
|
21
22
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
22
23
|
const packageJson = require('../package.json');
|
|
23
24
|
const program = new commander_1.Command();
|
|
@@ -168,4 +169,11 @@ program
|
|
|
168
169
|
await (0, review_1.selectReviewCommand)();
|
|
169
170
|
}
|
|
170
171
|
});
|
|
172
|
+
// Config command - manage settings
|
|
173
|
+
program
|
|
174
|
+
.command('config [action] [value]')
|
|
175
|
+
.description('Manage configuration (bot-token, --clear)')
|
|
176
|
+
.action(async (action, value) => {
|
|
177
|
+
await (0, config_1.configCommand)(action, value);
|
|
178
|
+
});
|
|
171
179
|
program.parse();
|