claude-teammate 0.1.38 → 0.1.40
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/package.json +1 -1
- package/src/commands/worker.js +51 -47
- package/src/github.js +19 -4
package/package.json
CHANGED
package/src/commands/worker.js
CHANGED
|
@@ -362,57 +362,61 @@ export async function runWorkerCommand({ projectRoot }) {
|
|
|
362
362
|
state.lastReviewPollAt = new Date().toISOString();
|
|
363
363
|
|
|
364
364
|
try {
|
|
365
|
-
const repos = await listKnownRepos(projectRoot);
|
|
366
365
|
const processedPrs = [];
|
|
367
|
-
|
|
366
|
+
const prs = await github.listPrsNeedingReview();
|
|
367
|
+
let reviewedPrCount = prs.length;
|
|
368
|
+
|
|
369
|
+
for (const pr of prs) {
|
|
370
|
+
if (!pr.repoUrl) {
|
|
371
|
+
await logger.error("PR review skipped because repository URL is missing", {
|
|
372
|
+
pr: pr.number,
|
|
373
|
+
title: pr.title
|
|
374
|
+
});
|
|
375
|
+
reviewedPrCount -= 1;
|
|
376
|
+
continue;
|
|
377
|
+
}
|
|
368
378
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
diff,
|
|
382
|
-
repoPath,
|
|
383
|
-
pr: prDetail,
|
|
384
|
-
timeoutMs: parseOptionalInt(values.CLAUDE_TIMEOUT_MS)
|
|
385
|
-
});
|
|
379
|
+
try {
|
|
380
|
+
const repoPath = await ensureReviewRepo(pr.repoUrl, runtimePaths.reviewReposDir);
|
|
381
|
+
const prDetail = await github.fetchPullRequest(pr.repoUrl, pr.number);
|
|
382
|
+
await checkoutPullRequestBranch(repoPath, prDetail.headRef, prDetail.headRepoCloneUrl);
|
|
383
|
+
|
|
384
|
+
const diff = await github.fetchPullRequestDiff(pr.repoUrl, pr.number);
|
|
385
|
+
const result = await runClaudePrReview({
|
|
386
|
+
diff,
|
|
387
|
+
repoPath,
|
|
388
|
+
pr: prDetail,
|
|
389
|
+
timeoutMs: parseOptionalInt(values.CLAUDE_TIMEOUT_MS)
|
|
390
|
+
});
|
|
386
391
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
392
|
+
await github.createPullRequestReview(
|
|
393
|
+
pr.repoUrl,
|
|
394
|
+
pr.number,
|
|
395
|
+
result.summary,
|
|
396
|
+
result.suggestions,
|
|
397
|
+
"COMMENT"
|
|
398
|
+
);
|
|
399
|
+
|
|
400
|
+
await github.addLabelsToPullRequest(pr.repoUrl, pr.number, ["AI-reviewed"]);
|
|
401
|
+
|
|
402
|
+
processedPrs.push({
|
|
403
|
+
repoUrl: pr.repoUrl,
|
|
404
|
+
pullRequestNumber: String(pr.number),
|
|
405
|
+
pullRequestUrl: prDetail.url,
|
|
406
|
+
suggestionsCount: result.suggestions.length
|
|
407
|
+
});
|
|
403
408
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
}
|
|
409
|
+
await logger.info("PR review submitted", {
|
|
410
|
+
repo: pr.repoUrl,
|
|
411
|
+
pr: pr.number,
|
|
412
|
+
suggestions: result.suggestions.length
|
|
413
|
+
});
|
|
414
|
+
} catch (error) {
|
|
415
|
+
await logger.error("PR review failed", {
|
|
416
|
+
repo: pr.repoUrl,
|
|
417
|
+
pr: pr.number,
|
|
418
|
+
error
|
|
419
|
+
});
|
|
416
420
|
}
|
|
417
421
|
}
|
|
418
422
|
|
package/src/github.js
CHANGED
|
@@ -290,16 +290,16 @@ export function createGitHubClient(config) {
|
|
|
290
290
|
return payload.default_branch;
|
|
291
291
|
},
|
|
292
292
|
|
|
293
|
-
async listPrsNeedingReview(
|
|
294
|
-
const
|
|
295
|
-
const query = `repo:${repo.owner}/${repo.name}+is:pr+is:open+review-requested:${botLogin}+-label:AI-reviewed`;
|
|
293
|
+
async listPrsNeedingReview() {
|
|
294
|
+
const query = "is:pr+is:open+user-review-requested:@me+-label:AI-reviewed";
|
|
296
295
|
const url = new URL("https://api.github.com/search/issues");
|
|
297
296
|
url.searchParams.set("q", query);
|
|
298
297
|
url.searchParams.set("per_page", "10");
|
|
299
298
|
|
|
300
|
-
const payload = await requestGitHub(url, config, { method: "GET" }
|
|
299
|
+
const payload = await requestGitHub(url, config, { method: "GET" });
|
|
301
300
|
return Array.isArray(payload.items)
|
|
302
301
|
? payload.items.map((item) => ({
|
|
302
|
+
repoUrl: mapRepositoryApiUrlToHtmlUrl(item.repository_url),
|
|
303
303
|
number: item.number,
|
|
304
304
|
title: item.title ?? ""
|
|
305
305
|
}))
|
|
@@ -395,6 +395,21 @@ export function createGitHubClient(config) {
|
|
|
395
395
|
};
|
|
396
396
|
}
|
|
397
397
|
|
|
398
|
+
function mapRepositoryApiUrlToHtmlUrl(repositoryApiUrl) {
|
|
399
|
+
const value = String(repositoryApiUrl || "").trim();
|
|
400
|
+
|
|
401
|
+
if (!value) {
|
|
402
|
+
return "";
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
const match = value.match(/^https:\/\/api\.github\.com\/repos\/([^/]+)\/([^/]+)$/u);
|
|
406
|
+
if (!match) {
|
|
407
|
+
return value;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
return `https://github.com/${match[1]}/${match[2]}`;
|
|
411
|
+
}
|
|
412
|
+
|
|
398
413
|
function mapGitHubIssue(payload, comments = []) {
|
|
399
414
|
return {
|
|
400
415
|
number: payload.number,
|