MCPcopy Create free account
hub / github.com/ColeMurray/background-agents / handleReviewComment

Function handleReviewComment

packages/github-bot/src/handlers.ts:480–582  ·  view source on GitHub ↗
(
  env: Env,
  log: Logger,
  payload: ReviewCommentPayload,
  traceId: string
)

Source from the content-addressed store, hash-verified

478
479 const messageId = await sendPrompt(env, traceId, sessionId, {
480 content: prompt,
481 authorId: `github:${sender.id}`,
482 });
483 log.info("prompt.sent", {
484 ...meta,
485 session_id: sessionId,
486 message_id: messageId,
487 source: "github",
488 content_length: prompt.length,
489 });
490
491 return {
492 outcome: "processed",
493 session_id: sessionId,
494 message_id: messageId,
495 handler_action: "comment",
496 };
497 }
498 );
499}
500
501export async function handleReviewComment(
502 env: Env,
503 log: Logger,
504 payload: ReviewCommentPayload,
505 traceId: string
506): Promise<HandlerResult> {
507 const { pull_request: pr, comment, repository: repo, sender } = payload;
508 const owner = repo.owner.login;
509 const repoName = repo.name;
510 const repositoryPath = encodeRepositoryPathSegments({ repoOwner: owner, repoName });
511 const repoFullName = `${owner}/${repoName}`.toLowerCase();
512
513 if (!containsBotMention(comment.body, env.GITHUB_BOT_USERNAME)) {
514 log.debug("handler.no_mention", {
515 trace_id: traceId,
516 pull_number: pr.number,
517 sender: sender.login,
518 });
519 return { outcome: "skipped", skip_reason: "no_mention" };
520 }
521
522 if (sender.login === env.GITHUB_BOT_USERNAME) {
523 log.debug("handler.self_comment_ignored", { trace_id: traceId });
524 return { outcome: "skipped", skip_reason: "self_comment" };
525 }
526
527 const config = await getGitHubConfig(env, repoFullName, log);
528
529 if (config.enabledRepos !== null && !config.enabledRepos.includes(repoFullName)) {
530 log.debug("handler.repo_not_enabled", { trace_id: traceId, repo: repoFullName });
531 return { outcome: "skipped", skip_reason: "repo_not_enabled" };
532 }
533
534 const gating = await resolveCallerGating(
535 env,
536 config,
537 sender.login,

Callers 2

handlers.test.tsFile · 0.90
dispatchHandlerFunction · 0.90

Calls 10

getGitHubConfigFunction · 0.90
resolveAppNameFunction · 0.90
buildCommentActionPromptFunction · 0.90
resolveCallerGatingFunction · 0.85
stripMentionFunction · 0.85
fireAndForgetReactionFunction · 0.85
createSessionFunction · 0.70
sendPromptFunction · 0.70
debugMethod · 0.65
infoMethod · 0.65

Tested by

no test coverage detected