Skip to content

feat(bot): add GitHub adapter#3024

Open
RSO wants to merge 25 commits intomainfrom
RSO/jet-degree
Open

feat(bot): add GitHub adapter#3024
RSO wants to merge 25 commits intomainfrom
RSO/jet-degree

Conversation

@RSO
Copy link
Copy Markdown
Contributor

@RSO RSO commented May 4, 2026

Summary

  • Adds the Chat SDK GitHub adapter to the shared Kilo Bot infrastructure so GitHub issue and PR comment mentions route through the same bot flow as Slack.
  • Preserves existing GitHub App webhook behavior for PR code reviews while forwarding GitHub comment events to the bot adapter.
  • Adds GitHub platform identity handling and tests for GitHub webhook routing.

Verification

N/A (no manual verification performed).

Visual Changes

N/A

Reviewer Notes

  • GitHub comment webhooks are now double-verified: once by the existing GitHub webhook handler and once by the Chat SDK adapter using a cloned request body.
  • PR code review handling remains on the existing pull_request webhook path.

@RSO RSO force-pushed the RSO/jet-degree branch from 4506db1 to d894d74 Compare May 5, 2026 08:04
RSO added 20 commits May 5, 2026 10:43
Wrap the bot.webhooks.github call in after() with try/catch so
unhandled exceptions from the chat adapter are surfaced to Sentry
instead of being silently dropped.
Replace the manual last-page / previous-page pagination dance with a
single octokit call using sort=created&direction=desc. GitHub already
supports returning the newest comments first, so one request suffices.
The review-thread context helper previously paged through every
review comment on the pull request with no upper bound. For PRs with
thousands of review comments this produced a long cascade of API
calls on every bot mention. Cap at 500 comments (5 pages of 100) and
log when the cap is reached so we can spot pathological PRs.
Both /github/link and the bot-link branch of the GitHub App callback
were hard-coded to 'standard' credentials, so account linking would
fail for installations of the lite app. Look up the integration by
installation_id and pick credentials / exchange the OAuth code using
its stored github_app_type.
@RSO RSO marked this pull request as ready for review May 5, 2026 13:18
Comment thread apps/web/src/lib/bot.ts
const [platformIntegration, kiloUserId] = await Promise.all([
getPlatformIntegration(identity),
resolveKiloUserId(chatBot.getState(), identity),
resolveKiloUserId(chatBot.getState(), userIdentity),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: GitHub user links bypass per-installation access checks

GitHub links are now resolved with a global user-level identity, so once a GitHub account is linked through one installation, the same kiloUserId is accepted for mentions in any other GitHub installation before verifying that the Kilo user can access that integration owner. processLinkedMessage then runs with the target platformIntegration and org headers, which can let a user trigger work scoped/billed to an org they are not a Kilo member of. Please re-check org membership or user ownership for the resolved user against platformIntegration before processing the message.

@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot Bot commented May 5, 2026

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
apps/web/src/lib/bot.ts 275 GitHub user-level account links can be reused across installations without verifying access to the target integration owner.

Fix these issues in Kilo Cloud

Other Observations (not in diff)

Issues found in unchanged code that cannot receive inline comments:

File Line Issue
N/A N/A None
Files Reviewed (26 files)
  • apps/web/package.json - 0 issues
  • apps/web/src/app/api/chat/link-account/route.test.ts - 0 issues
  • apps/web/src/app/api/chat/link-account/route.ts - 0 issues
  • apps/web/src/app/api/integrations/github/callback/route.test.ts - 0 issues
  • apps/web/src/app/api/integrations/github/callback/route.ts - 0 issues
  • apps/web/src/app/api/webhooks/github/route.test.ts - 0 issues
  • apps/web/src/app/api/webhooks/github/route.ts - 0 issues
  • apps/web/src/app/github/link/route.test.ts - 0 issues
  • apps/web/src/app/github/link/route.ts - 0 issues
  • apps/web/src/lib/bot-identity.test.ts - 0 issues
  • apps/web/src/lib/bot-identity.ts - 0 issues
  • apps/web/src/lib/bot.ts - 1 issue
  • apps/web/src/lib/bot/agent-runner.ts - 0 issues
  • apps/web/src/lib/bot/constants.ts - 0 issues
  • apps/web/src/lib/bot/conversation-context.test.ts - 0 issues
  • apps/web/src/lib/bot/conversation-context.ts - 0 issues
  • apps/web/src/lib/bot/github-link-state.ts - 0 issues
  • apps/web/src/lib/bot/link-account.test.ts - 0 issues
  • apps/web/src/lib/bot/link-account.tsx - 0 issues
  • apps/web/src/lib/bot/platform-helpers.test.ts - 0 issues
  • apps/web/src/lib/bot/platform-helpers.ts - 0 issues
  • apps/web/src/lib/bot/webhook-handler.ts - 0 issues
  • apps/web/src/lib/integrations/core/constants.ts - 0 issues
  • apps/web/src/lib/integrations/platforms/github/webhook-handler.test.ts - 0 issues
  • apps/web/src/tests/setup/__mocks__/lib/integrations/platforms/github/adapter.ts - 0 issues
  • pnpm-lock.yaml - 0 issues

Reviewed by gpt-5.5-20260423 · 3,282,191 tokens

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant