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

Function handleIssueComment

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

Source from the content-addressed store, hash-verified

374 source: "github",
375 content_length: prompt.length,
376 });
377
378 return {
379 outcome: "processed",
380 session_id: sessionId,
381 message_id: messageId,
382 handler_action: "auto_review",
383 };
384 }
385 );
386}
387
388export async function handleIssueComment(
389 env: Env,
390 log: Logger,
391 payload: IssueCommentPayload,
392 traceId: string
393): Promise<HandlerResult> {
394 const { issue, comment, repository: repo, sender } = payload;
395 const owner = repo.owner.login;
396 const repoName = repo.name;
397 const repositoryPath = encodeRepositoryPathSegments({ repoOwner: owner, repoName });
398 const repoFullName = `${owner}/${repoName}`.toLowerCase();
399
400 if (!issue.pull_request) {
401 log.debug("handler.not_a_pr", { trace_id: traceId, issue_number: issue.number });
402 return { outcome: "skipped", skip_reason: "not_a_pr" };
403 }
404
405 if (!containsBotMention(comment.body, env.GITHUB_BOT_USERNAME)) {
406 log.debug("handler.no_mention", {
407 trace_id: traceId,
408 issue_number: issue.number,
409 sender: sender.login,
410 });
411 return { outcome: "skipped", skip_reason: "no_mention" };
412 }
413
414 if (sender.login === env.GITHUB_BOT_USERNAME) {
415 log.debug("handler.self_comment_ignored", { trace_id: traceId });
416 return { outcome: "skipped", skip_reason: "self_comment" };
417 }
418
419 const config = await getGitHubConfig(env, repoFullName, log);
420
421 if (config.enabledRepos !== null && !config.enabledRepos.includes(repoFullName)) {
422 log.debug("handler.repo_not_enabled", { trace_id: traceId, repo: repoFullName });
423 return { outcome: "skipped", skip_reason: "repo_not_enabled" };
424 }
425
426 const gating = await resolveCallerGating(
427 env,
428 config,
429 sender.login,
430 owner,
431 repoName,
432 log,
433 traceId,

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