import { type IssueComment, type PullRequestReviewComment } from '../github.js'; import type { Discussion } from '../gitlab.js'; import type { MergeRequestMeta, ReviewPlatform, ScmResponseInfo } from '../platform.js'; import { type PostingMode, type PostResult, type SummaryResult, type UpsertSummaryOptions } from '../posting.js'; import type { DiffRefs, GeneratedComment, ReviewComment, Side } from '../types.js'; /** * A single inline comment in a batched GitHub review, positioned against the * diff. GitHub takes one `line` plus a `side` (unlike GitLab's two-sided * position). Built by {@link buildGitHubReviewPayload}; `null` when the finding * cannot be anchored to the diff (see {@link buildGitHubComments}). */ export interface GitHubReviewCommentPayload { path: string; body: string; line: number; side: Side; } /** The `owner` and `repo` halves of a GitHub `owner/repo` slug. */ export interface GitHubRepository { owner: string; repo: string; } /** * Split a `GITHUB_REPOSITORY` slug into its `owner` and `repo` halves. GitHub * repository slugs contain exactly one `/` (neither owner nor repo may be empty * or contain a slash), so anything else is a configuration error surfaced with an * actionable hint rather than a confusing 404 from the API. */ export declare function parseGitHubRepository(slug: string): GitHubRepository; /** * Parse a pull-request number from its string form. Rejects non-integer or * non-positive values so a malformed `--pr`/`GITHUB_REF` fails fast with a hint * instead of hitting `/pulls/NaN`. */ export declare function parseGitHubPullNumber(value: string): number; /** What a {@link GitHubPlatform} needs to talk to one pull request. */ export interface GitHubPlatformOptions { /** REST API base (default `https://api.github.com`; GHE sets an `/api/v3` base). */ apiUrl?: string; token: string; owner: string; repo: string; /** Pull-request number. */ pull: number; fetchImpl?: typeof fetch; requestTimeout?: number; } /** * Resolve one reviewer finding to a GitHub review-comment payload, or `null` * when it cannot be anchored to GitHub's diff. GitHub uses a single `line` + * `side`: * - a pure added line takes the new-file line with `side: 'RIGHT'`, * - a pure removed line takes the old-file line with `side: 'LEFT'`, * - an unchanged (context) line takes the new-file line with `side: 'RIGHT'`, * regardless of the finding's side — GitHub's API prescribes RIGHT for * "unchanged lines ... shown for context", so a LEFT context comment is * doc-noncompliant and risks a 422. * * Returning `null` for an off-diff line is deliberate: GitHub answers 422 when a * review comment points at a line outside the diff, and one such comment fails * the whole batched review, so the poster drops these rather than post them. A * context line is only kept when it lies within GitHub's default 3-line hunk * context of a change — our local diff carries far more context (`--unified=20`) * than GitHub's PR diff, so a distant context line is inside our diff but off * GitHub's. */ export declare function buildGitHubReviewPayload(comment: ReviewComment, body: string, diff: string): GitHubReviewCommentPayload | null; /** * Turn parsed reviewer findings into GitHub review-comment payloads, mirroring * the GitLab `buildGeneratedComments` contract: same hunk-context fingerprints, * same dedup semantics, same comment body/footer. The payload is * `GitHubReviewCommentPayload | null` — `null` for a finding that cannot be * placed on the diff, which the poster skips. */ export declare function buildGitHubComments(comments: ReviewComment[], diff: string, refs: DiffRefs, existingFingerprints: Set): GeneratedComment[]; /** * Normalize GitHub's two comment streams into the {@link Discussion}[] shape the * platform-agnostic helpers consume unchanged: * - Inline **review comments** are threaded by `in_reply_to_id` (a reply joins * its root comment's discussion, in arrival order) so `extractPriorThreads` * sees a bot note followed by human replies, exactly like GitLab. * - Non-positional **issue comments** each become a single-note discussion; * the MR-level summary note lives here and is found via its summary marker. * * The fingerprint markers, summary marker, and reviewed-commit footer are HTML * comments that render identically on GitHub, so `extractExistingFingerprints`, * `findExistingSummaryNote`, and the reviewed-commit scan all work as-is. * * `settledCommentIds` carries the database ids of comments in settled review * threads — resolved or outdated (from the GraphQL `reviewThreads` query, since * REST omits both). Each such note gets a `resolved` flag mirroring GitLab's * per-note field: an outdated GitHub thread maps to `resolved: true` because * GitHub, unlike GitLab, does not auto-resolve a thread when its anchored line * changes, so treating outdated as resolved matches GitLab's behaviour (#133). */ export declare function normalizeGitHubDiscussions(reviewComments: PullRequestReviewComment[], issueComments: IssueComment[], settledCommentIds?: Set): Discussion[]; /** * {@link ReviewPlatform} backed by the GitHub pull-request API. Positioned * findings post as ONE batched review (`event: 'COMMENT'`) — atomic and free of * per-comment secondary rate limits — and the MR-level summary is upserted as a * single issue comment. The review core is unchanged; only target * identification, reading existing comments, and posting differ from GitLab. */ export declare class GitHubPlatform implements ReviewPlatform { private readonly client; private readonly owner; private readonly repo; private readonly pull; private last; private pullRequestPromise; private commitId; constructor(options: GitHubPlatformOptions); lastResponse(): ScmResponseInfo | undefined; private pullRequest; getMergeRequest(): Promise; getRefs(): Promise; getDiscussions(): Promise; buildComments(comments: ReviewComment[], diff: string, refs: DiffRefs, existingFingerprints: Set): GeneratedComment[]; postComments(generated: GeneratedComment[], _mode: PostingMode): Promise; updateLabels(add: string[], remove: string[]): Promise; upsertSummary(summary: string, discussions: Discussion[], options: UpsertSummaryOptions): Promise; } //# sourceMappingURL=github.d.ts.map