(githubAdapter: GitHubInstallationLookup)
| 284 | identity.teamId, |
| 285 | platformIntegration.github_app_type ?? 'standard', |
| 286 | platformIntegration.id |
| 287 | ); |
| 288 | const url = new URL(GITHUB_LINK_PATH, APP_URL); |
| 289 | url.searchParams.set( |
| 290 | 'token', |
| 291 | createGitHubLinkToken({ |
| 292 | platformIntegrationId: platformIntegration.id, |
| 293 | installationId: identity.teamId, |
| 294 | }) |
| 295 | ); |
| 296 | |
| 297 | await thread.post({ |
| 298 | markdown: |
| 299 | 'To use Kilo from GitHub you first need to link your GitHub account to Kilo. ' + |
| 300 | `[Link your Kilo account](${url.toString()}) to continue. ` + |
| 301 | 'After linking, mention me again in this issue or pull request.', |
| 302 | }); |
| 303 | }, |
| 304 | async withAuthContext({ platformIntegration, fn }) { |
| 305 | const installationId = platformIntegration.platform_installation_id; |
| 306 | if (!installationId) throw new Error('GitHub installation is unavailable for runtime use'); |
| 307 | await assertGitHubInstallationRuntimeAuthorized( |
| 308 | installationId, |
| 309 | platformIntegration.github_app_type ?? 'standard', |
| 310 | platformIntegration.id |
| 311 | ); |
| 312 | return await fn(); |
| 313 | }, |
| 314 | async getConversationContext({ thread, triggerMessage, platformIntegration }) { |
| 315 | const coordinates = parseGitHubThreadId(thread.id); |
| 316 | if (!coordinates) return ''; |
| 317 | |
| 318 | const installationId = platformIntegration.platform_installation_id; |
| 319 | if (!installationId) return ''; |
| 320 | |
| 321 | const tokenData = await generateGitHubInstallationToken( |
| 322 | installationId, |
| 323 | platformIntegration.github_app_type ?? 'standard', |
| 324 | platformIntegration.id |
| 325 | ); |
| 326 | const octokit = new Octokit({ auth: tokenData.token }); |
| 327 | |
| 328 | const [issueResponse, issueComments, reviewThreadContext] = await Promise.all([ |
| 329 | octokit.issues.get({ |
| 330 | owner: coordinates.owner, |
| 331 | repo: coordinates.repo, |
| 332 | issue_number: coordinates.number, |
| 333 | }), |
| 334 | fetchRecentIssueComments(octokit, coordinates), |
| 335 | fetchReviewThreadContext(octokit, coordinates), |
| 336 | ]); |
| 337 | |
| 338 | const issue: GitHubIssueLike = issueResponse.data; |
| 339 | const itemType = issue.pull_request ? 'pull request' : 'issue'; |
| 340 | const itemLabel = issue.pull_request ? 'Pull request' : 'Issue'; |
| 341 | const trigger = formatTriggerMessage(triggerMessage, MAX_GITHUB_COMMENT_LENGTH); |
| 342 | const comments = issueComments |
| 343 | .filter(comment => comment.id.toString() !== triggerMessage.id) |
no outgoing calls
no test coverage detected