Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

PullRequestProvider.ts

663 lines27.6 KB

1import * as Effect from "effect/Effect";
2import * as Schema from "effect/Schema";
3import type {
4 PullRequestStackMembership,
5 PullRequestAction,
6 PullRequestStackHead,
7 PullRequestActor,
8 PullRequestBaseComparison,
9 PullRequestCapabilities,
10 PullRequestChecksState,
11 PullRequestCheck,
12 PullRequestComment,
13 PullRequestFileViewed,
14 PullRequestCommit,
15 PullRequestInvolvement,
16 PullRequestLabel,
17 PullRequestListFilters,
18 PullRequestListState,
19 PullRequestMergeCapabilities,
20 PullRequestMergeMethod,
21 PullRequestMergeability,
22 PullRequestOmittedFileStat,
23 PullRequestReaction,
24 PullRequestReactionContent,
25 PullRequestReviewCommentDraft,
26 PullRequestReviewDecision,
27 PullRequestReviewThread,
28 PullRequestThreadCommentsResult,
29 PullRequestReviewVerdict,
30 PullRequestReviewerCandidateList,
31 PullRequestReviewerKind,
32 PullRequestLabelCandidateList,
33 PullRequestState,
34 PullRequestPreview,
35 PullRequestUpdateMethod,
36 PullRequestViewerPermissions,
37 SourceControlProviderKind,
38} from "@t3tools/contracts";
39import { SourceControlProviderKind as SourceControlProviderKindSchema } from "@t3tools/contracts";
40​
41/**
42 * The one failure shape every provider reports, so the service can decide what a failure means
43 * without knowing which CLI or API produced it.
44 *
45 * `reason` is the part the service acts on: a missing or unauthenticated tool disables the
46 * provider for the whole workspace, a rate limit pauses its host, and anything else is specific
47 * to the request.
48 */
49export class PullRequestProviderError extends Schema.TaggedError<PullRequestProviderError>()(
50 "PullRequestProviderError",
51 {
52 provider: SourceControlProviderKindSchema,
53 operation: Schema.String,
54 reason: Schema.Literals(["missing-tool", "unauthenticated", "rate-limited", "failed"]),
55 detail: Schema.String,
56 retryAt: Schema.optional(Schema.Number),
57 cause: Schema.optional(Schema.Defect()),
58 },
59) {
60 override get message(): string {
61 return `${this.provider} failed in ${this.operation}: ${this.detail}`;
62 }
64​
65export interface PullRequestProviderFailure {
66 readonly reason: PullRequestProviderError["reason"];
67 readonly retryAt?: number | undefined;
69​
70/** A change request as the provider sees it, before the service attaches project context. */
71export interface ProviderChangeRequest {
72 readonly stack?: PullRequestStackMembership;
73 readonly number: number;
74 readonly title: string;
75 readonly url: string;
76 readonly author: PullRequestActor | null;
77 readonly headBranch: string;
78 readonly headRepositoryNameWithOwner?: string | null;
79 readonly baseBranch: string;
80 readonly state: PullRequestState;
81 readonly isDraft: boolean;
82 readonly mergeability: PullRequestMergeability;
83 readonly additions: number;
84 readonly deletions: number;
85 readonly createdAt: string;
86 readonly closedAt?: string | null;
87 readonly mergedAt?: string | null;
88 readonly updatedAt: string;
89 /** Accounts with a review requested. Team-level requests are excluded by each provider. */
90 readonly reviewRequestLogins: ReadonlyArray<string>;
91 readonly labels: ReadonlyArray<PullRequestLabel>;
92 /** Absent from a host that does not summarise its reviews, which is every host but GitHub. */
93 readonly reviewDecision?: PullRequestReviewDecision | null | undefined;
94 /** Absent from a host that reports no check rollup on its listings. */
95 readonly checksState?: PullRequestChecksState | null | undefined;
97​
98/** The fields needed to keep a linked thread's pull request status live. */
99export interface ProviderChangeRequestSummary {
100 readonly number: number;
101 readonly title: string;
102 readonly url: string;
103 readonly headBranch: string;
104 readonly baseBranch: string;
105 readonly state: PullRequestState;
106 /** Present when the host says an open pull request is still a draft. */
107 readonly isDraft?: boolean;
108 readonly closedAt?: string | null;
109 readonly mergedAt?: string | null;
110 readonly updatedAt: string;
111 /** Overview fields, present where the host's single read returns them at no extra cost. */
112 readonly author?: PullRequestActor | null | undefined;
113 readonly additions?: number | undefined;
114 readonly deletions?: number | undefined;
115 readonly changedFiles?: number | undefined;
116 readonly reviewDecision?: PullRequestReviewDecision | null | undefined;
117 readonly checksState?: PullRequestChecksState | null | undefined;
118 readonly mergeability?: PullRequestMergeability | undefined;
120​
121/** One layer of a host-native stack, bottom to top order is the array's. */
122export interface ProviderChangeRequestStackLayer {
123 readonly title?: string;
124 readonly isDraft?: boolean;
125 readonly headSha?: string;
126 readonly number: number;
127 readonly headBranch: string;
128 readonly state: PullRequestState;
130​
131/**
132 * A host-native stack: an ordered set of change requests the host itself merges and retargets as
133 * a unit. Only GitHub offers one today; the neutral shape lets the sync reactor and the UI stay
134 * ignorant of which host said so.
135 */
136export interface ProviderChangeRequestStack {
137 readonly id: string;
138 readonly number: number;
139 readonly url: string;
140 readonly base: string;
141 readonly layers: ReadonlyArray<ProviderChangeRequestStackLayer>;
143​
144export interface ProviderChangeRequestPage {
145 readonly items: ReadonlyArray<ProviderChangeRequest>;
146 /** True when the host has more rows than the page size asked for. */
147 readonly truncated: boolean;
148 /**
149 * Optional count-based cursor advance. Most hosts advance by the rows delivered after local
150 * de-duplication; an offset-paged host may need to count malformed raw rows it consumed too.
151 */
152 readonly cursorAdvance?: number;
153 /**
154 * This page can be carried on from, so the service may hand the caller a cursor for it. False
155 * where the host answered in an order a cursor means nothing in, which leaves a larger `limit`
156 * as the only way to the rest — what every listing did before there were cursors.
157 */
158 readonly continues: boolean;
160​
161/**
162 * Where a repository's next slice starts, as the provider that has to ask for it needs it. Built
163 * by the service out of the slice it just handed over, so the boundary that decides whether a row
164 * arrives twice or not at all is decided in one place rather than in four.
165 */
166export interface ProviderListCursor {
167 /**
168 * The instant of the oldest row already handed over, checked against a timestamp's shape before
169 * it gets here because it goes into a host's own filter. Asked for inclusively: several rows
170 * share one instant often enough — a bot that touches eight change requests writes one timestamp
171 * on all eight — and asking for strictly older would lose whichever of them the slice ended
172 * before. The service drops the ones it has already sent.
173 */
174 readonly updatedBefore: string;
175 /**
176 * How many provider rows this repository has consumed so far, for a host that carries on by
177 * counting rather than by date. Usually this is the number handed over; malformed raw rows may
178 * count too when the provider reports a `cursorAdvance`.
179 */
180 readonly delivered: number;
182​
183/** One repository's row inside an answer that spans several of them. */
184export interface ProviderBatchedChangeRequest extends ProviderChangeRequest {
185 /** Provider-native identity, exactly as it was asked for, so the caller can file the row. */
186 readonly repository: string;
188​
189/**
190 * One slice of a host read across several repositories at once, newest update first across all
191 * of them. There is no per-repository page here because the host was asked one question: the
192 * caller splits the rows by `repository` and works out where each of them carries on from the
193 * oldest row in the slice, which every repository the slice covers is now read up to.
194 */
195export interface ProviderBatchedChangeRequestPage {
196 readonly items: ReadonlyArray<ProviderBatchedChangeRequest>;
197 /** True when the host has more rows than the slice asked for, for any of the repositories. */
198 readonly truncated: boolean;
200​
201/** The line counts for one change request, which a listing may leave for a second read. */
202export interface ProviderChangeRequestStat {
203 readonly repository: string;
204 readonly number: number;
205 readonly additions: number;
206 readonly deletions: number;
208​
209export interface ProviderChangeRequestDetail extends ProviderChangeRequest {
210 readonly body: string;
211 readonly changedFiles: number;
212 readonly mergedAt: string | null;
213 readonly closedAt: string | null;
214 readonly reviewers: ReadonlyArray<PullRequestActor>;
215 readonly checks: ReadonlyArray<PullRequestCheck>;
216 readonly mergeCapabilities: PullRequestMergeCapabilities;
217 readonly viewerPermissions: PullRequestViewerPermissions;
218 /** Absent from a host that cannot compare the branch with its base, which is most of them. */
219 readonly baseComparison?: PullRequestBaseComparison;
220 readonly behindBy?: number;
221 /** Absent from a host that does not report whether it is armed to merge this on its own. */
222 readonly autoMergeEnabled?: boolean;
223 /** The strategy stored with an armed auto-merge, where the host reports it. */
224 readonly autoMergeMethod?: PullRequestMergeMethod;
225 /** Workflow runs on this head commit that still need a maintainer's approval. */
226 readonly workflowApprovalsRequired?: number;
228​
229/** The conversation-shaped half of a detail, loaded after the core can already render. */
230export interface ProviderChangeRequestActivity {
231 /** An optional richer actor, e.g. after GitHub's GraphQL read supplies an avatar. */
232 readonly author?: PullRequestActor | null;
233 /** Optional because most hosts already report their reviewer list in the core detail. */
234 readonly reviewers?: ReadonlyArray<PullRequestActor>;
235 readonly comments: ReadonlyArray<PullRequestComment>;
236 /**
237 * The host's own count of the conversation, which a bounded read can fall short of. A host
238 * that reports no count of its own answers with what it handed over, which is the same number
239 * once the read went to the end.
240 */
241 readonly commentCount: number;
242 readonly commentsTruncated: boolean;
243 readonly reviewThreads: ReadonlyArray<PullRequestReviewThread>;
244 readonly commits: ReadonlyArray<PullRequestCommit>;
245 /** The change request's own reactions, from a host that has them. */
246 readonly reactions?: ReadonlyArray<PullRequestReaction>;
248​
249export interface ProviderDiffSlice {
250 readonly patch: string;
251 /** Something in this slice could not be shown, as opposed to there being more slices. */
252 readonly truncated: boolean;
253 readonly nextCursor: string | null;
254 /** The host's own counts for the files whose hunks it withheld from this slice. */
255 readonly omittedFileStats?: ReadonlyArray<PullRequestOmittedFileStat>;
257​
258export interface ProviderDiffFileContents {
259 readonly oldContents: string;
260 readonly newContents: string;
262​
263export interface ProviderFilesViewed {
264 readonly files: ReadonlyArray<PullRequestFileViewed>;
265 /** The host has more files than were read, so the ones missing here are not "unviewed". */
266 readonly truncated: boolean;
268​
269/**
270 * What version each of the asked-for files is at, on the change request's head. Opaque strings,
271 * compared only against one another, where the empty string is the answer for a file the change
272 * request deletes rather than a gap. A path is absent only where the read could not say, so a
273 * provider converts its host's own absences on the way here.
274 *
275 * The whole path a version travels, and the three senses of null along it, are in
276 * `docs/internals/pull-request-file-revisions.md`.
277 */
278export interface ProviderFileRevisions {
279 readonly revisions: ReadonlyMap<string, string>;
280 /**
281 * Whether these are every file the change request carries rather than only the paths asked
282 * about. A host with no per-file version reads the whole change to answer for one file, and
283 * saying so is what keeps the next tick, naming a path nothing asked about before, from making
284 * it read the whole change again. False for a read cut short, which cannot speak past the cut.
285 */
286 readonly complete?: boolean;
288​
289export interface ProviderRepositoryRef {
290 readonly cwd: string;
291 /** Provider-native repository identity, e.g. `owner/repo` or `group/subgroup/project`. */
292 readonly repository: string;
293 /**
294 * The host it lives on, which `repository` deliberately leaves out — the same `owner/repo`
295 * exists on github.com and on a GitHub Enterprise install, and only the caller knows which
296 * one a project's remote points at.
297 */
298 readonly host: string;
300​
301/**
302 * One host's change requests. Implementations own their own tool and JSON shapes and hand back
303 * the neutral types above; anything a host cannot do is declared in `capabilities` rather than
304 * failing at call time.
305 */
306export interface PullRequestProviderApi {
307 readonly withVerifiedCredential?: <A, E, R>(
308 input: { readonly cwd: string; readonly host: string },
309 use: (identity: {
310 readonly accountId: string;
311 readonly viewer: string;
312 readonly credentialFingerprint: string;
313 }) => Effect.Effect<A, E, R>,
314 ) => Effect.Effect<A, E | PullRequestProviderError, R>;
315 readonly getRoutingIdentity?: (input: {
316 readonly cwd: string;
317 readonly host: string;
318 }) => Effect.Effect<
319 { readonly accountId: string; readonly viewer: string },
320 PullRequestProviderError
321 >;
322 readonly kind: SourceControlProviderKind;
323 readonly capabilities: PullRequestCapabilities;
324​
325 /** The signed-in account, which is what involvement filtering compares against. */
326 readonly getViewer: (input: {
327 readonly cwd: string;
328 readonly host?: string;
329 }) => Effect.Effect<string, PullRequestProviderError>;
330​
331 readonly listChangeRequests: (
332 input: ProviderRepositoryRef & {
333 readonly state: PullRequestListState;
334 readonly involvement: PullRequestInvolvement;
335 readonly viewer: string;
336 readonly limit: number;
337 /**
338 * Free text to narrow the listing by, as the host understands it. A host with no text
339 * filter of its own ignores it and answers with the page it would have answered with
340 * anyway — the caller narrows what it gets, so an unfiltered page is a wider answer
341 * rather than a wrong one.
342 */
343 readonly query?: string | undefined;
344 /**
345 * Where to carry on from, rather than reading this repository from its newest row. Absent
346 * asks for the first slice, which is every listing that has not been continued.
347 */
348 readonly cursor?: ProviderListCursor | undefined;
349 /**
350 * Further narrowings, which a host applies as far as it can and ignores the rest of —
351 * an unnarrowed page is a wider answer rather than a wrong one, and the caller narrows
352 * what it gets for the fields a row carries.
353 */
354 readonly filters?: PullRequestListFilters | undefined;
355 },
356 ) => Effect.Effect<ProviderChangeRequestPage, PullRequestProviderError>;
357​
358 /**
359 * The same listing for a whole host in one request, for a host that has a search across
360 * repositories. Optional: three of the four hosts here have no such API, and breaking the port
361 * for them to spare GitHub a fan-out would be paying for the fix with everyone else's clarity.
362 * The caller falls back to `listChangeRequests` per repository where this is absent, and where
363 * it fails.
364 *
365 * `limit` is the whole slice rather than a size per repository, because that is the shape of
366 * the answer: the newest `limit` rows across every repository named, which is exactly the rows
367 * a page ordered by update shows.
368 *
369 * `cursor` is one boundary for all of them, so a caller with repositories standing at different
370 * boundaries asks in groups rather than in one call.
371 */
372 readonly listChangeRequestsAcross?: (input: {
373 /** Any checkout on the host, which is what the tool is run in. */
374 readonly cwd: string;
375 readonly host: string;
376 readonly repositories: ReadonlyArray<string>;
377 readonly state: PullRequestListState;
378 readonly involvement: PullRequestInvolvement;
379 readonly viewer: string;
380 readonly limit: number;
381 readonly query?: string | undefined;
382 readonly cursor?: ProviderListCursor | undefined;
383 readonly filters?: PullRequestListFilters | undefined;
384 }) => Effect.Effect<ProviderBatchedChangeRequestPage, PullRequestProviderError>;
385​
386 /**
387 * The line counts for rows a listing has already handed over. Only implemented by a provider
388 * whose listing leaves them out — for everyone else the numbers arrived with the row, and the
389 * caller has nothing to ask for.
390 */
391 readonly listChangeRequestStats?: (input: {
392 readonly cwd: string;
393 readonly host: string;
394 readonly changeRequests: ReadonlyArray<{
395 readonly repository: string;
396 readonly number: number;
397 }>;
398 }) => Effect.Effect<ReadonlyArray<ProviderChangeRequestStat>, PullRequestProviderError>;
399​
400 readonly getChangeRequest: (
401 input: ProviderRepositoryRef & { readonly number: number },
402 ) => Effect.Effect<ProviderChangeRequestDetail, PullRequestProviderError>;
403​
404 /** Hosts without a narrow read use their existing detail response for hover cards. */
405 readonly getChangeRequestPreview?: (
406 input: ProviderRepositoryRef & { readonly number: number },
407 ) => Effect.Effect<
408 Omit<PullRequestPreview, "projectId" | "repository">,
409 PullRequestProviderError
410 >;
411​
412 /**
413 * The cheap live fields used by linked threads. Optional because a provider without a narrow
414 * endpoint can fall back to its full detail read at the service boundary.
415 */
416 readonly getChangeRequestSummary?: (
417 input: ProviderRepositoryRef & { readonly number: number },
418 ) => Effect.Effect<ProviderChangeRequestSummary, PullRequestProviderError>;
419​
420 /**
421 * The host-native stack a change request belongs to, or null when it is not stacked. Optional
422 * because most hosts have no such object; the service derives chains from base branches there.
423 */
424 readonly getChangeRequestStack?: (
425 input: ProviderRepositoryRef & { readonly includeDetails?: boolean; readonly number: number },
426 ) => Effect.Effect<ProviderChangeRequestStack | null, PullRequestProviderError>;
427​
428 /** Comments, line threads, and commits, kept off the critical path for the core detail. */
429 readonly getChangeRequestActivity: (
430 input: ProviderRepositoryRef & { readonly number: number },
431 ) => Effect.Effect<ProviderChangeRequestActivity, PullRequestProviderError>;
432​
433 /** One explicit page after a reader asks to continue an unfinished review thread. */
434 readonly getReviewThreadComments?: (
435 input: ProviderRepositoryRef & {
436 readonly number: number;
437 readonly threadId: string;
438 readonly cursor: string;
439 },
440 ) => Effect.Effect<PullRequestThreadCommentsResult, PullRequestProviderError>;
441​
442 /**
443 * The same answer `getChangeRequest` carries, on its own. Asked before anything is written, so
444 * a request that reached the server without going past the page is refused by what the host
445 * says rather than by what the client claimed — and asked freshly, because access granted or
446 * taken away since the page loaded is exactly the case this guards.
447 *
448 * Implementations read the cheapest thing that answers it, which for a host with nothing to say
449 * is no request at all.
450 */
451 readonly getViewerPermissions: (
452 input: ProviderRepositoryRef & {
453 readonly number: number;
454 /** Skip branch comparison when checking permission for an unrelated operation. */
455 readonly includeUpdateBranch?: boolean;
456 },
457 ) => Effect.Effect<PullRequestViewerPermissions, PullRequestProviderError>;
458​
459 /**
460 * One slice of the patch. Only called when `capabilities.diff` is true. A provider that can
461 * serve the whole diff at once answers with `nextCursor: null` and is done; one that pages
462 * hands back whatever it needs to find the next slice.
463 */
464 readonly getDiff: (
465 input: ProviderRepositoryRef & {
466 readonly number: number;
467 readonly cursor?: string | undefined;
468 /** One commit's own changes, rather than everything the change request carries. */
469 readonly commit?: string | undefined;
470 },
471 ) => Effect.Effect<ProviderDiffSlice, PullRequestProviderError>;
472​
473 /**
474 * Full files at the exact revisions the host used for its patch. Optional where the provider
475 * exposes no diff at all; the service refuses expansion there just as it refuses the patch.
476 */
477 readonly getDiffFileContents?: (
478 input: ProviderRepositoryRef & {
479 readonly number: number;
480 readonly commit?: string | undefined;
481 readonly changeType: "change" | "rename-pure" | "rename-changed" | "new" | "deleted";
482 readonly oldPath: string;
483 readonly newPath: string;
484 },
485 ) => Effect.Effect<ProviderDiffFileContents, PullRequestProviderError>;
486​
487 /**
488 * Which files the reader has already cleared. Only called when `capabilities.viewedFiles` is
489 * `"host"`, and read apart from the patch: this moves with every press rather than every push.
490 */
491 readonly getFilesViewed?: (
492 input: ProviderRepositoryRef & { readonly number: number },
493 ) => Effect.Effect<ProviderFilesViewed, PullRequestProviderError>;
494​
495 /**
496 * Clears files, or puts them back. Only called when `capabilities.viewedFiles` is `"host"`.
497 * A host with no bulk form is still owed one round trip for the batch rather than one per file,
498 * since the point of gathering presses is that the host is asked once.
499 */
500 readonly setFilesViewed?: (
501 input: ProviderRepositoryRef & {
502 readonly number: number;
503 readonly files: ReadonlyArray<{ readonly path: string; readonly viewed: boolean }>;
504 },
505 ) => Effect.Effect<void, PullRequestProviderError>;
506​
507 /**
508 * What version the head has of each of these files. Required of a host whose
509 * `capabilities.viewedFiles` is `"environment"`, and unused by one that keeps the marks itself:
510 * the marks live here, but only the host can say whether what a reader cleared last week is
511 * still what is in front of them. Asked for the marked paths alone, so the cost follows how
512 * much of the change request has been read rather than how large it is.
513 */
514 readonly getFileRevisions?: (
515 input: ProviderRepositoryRef & {
516 readonly number: number;
517 readonly paths: ReadonlyArray<string>;
518 },
519 ) => Effect.Effect<ProviderFileRevisions, PullRequestProviderError>;
520​
521 readonly runAction: (
522 input: ProviderRepositoryRef & {
523 readonly number: number;
524 readonly action: PullRequestAction;
525 readonly stackNumber?: number;
526 readonly expectedStackHeads?: ReadonlyArray<PullRequestStackHead>;
527 /** Meaningful for `merge` and `enable-auto-merge`; absent takes the host's own default. */
528 readonly mergeMethod?: PullRequestMergeMethod;
529 /** Only meaningful for `update-branch`; absent takes the host's own default. */
530 readonly updateMethod?: PullRequestUpdateMethod;
531 },
532 ) => Effect.Effect<void, PullRequestProviderError>;
533​
534 /**
535 * Rewrites the change request's own words. Only called when `capabilities.edit.changeRequest`
536 * is true, and never with both fields absent — the caller refuses that before it gets here,
537 * because a host asked to change nothing answers differently on each of them.
538 */
539 readonly updateChangeRequest?: (
540 input: ProviderRepositoryRef & {
541 readonly number: number;
542 readonly title?: string | undefined;
543 readonly body?: string | undefined;
544 },
545 ) => Effect.Effect<void, PullRequestProviderError>;
546​
547 readonly comment: (
548 input: ProviderRepositoryRef & { readonly number: number; readonly body: string },
549 ) => Effect.Effect<void, PullRequestProviderError>;
550​
551 /**
552 * Rewrites a remark somebody already posted. Only called when `capabilities.edit.comment` is
553 * true, with an id exactly as the conversation carried it.
554 *
555 * Whether this remark is the reader's to rewrite is the host's own answer: no read here can
556 * settle it, since access can be taken away between the conversation being read and the
557 * rewrite being sent, and a host refuses a stranger's remark with a sentence saying so.
558 */
559 readonly updateComment?: (
560 input: ProviderRepositoryRef & {
561 readonly number: number;
562 readonly commentId: string;
563 readonly kind: "issue-comment" | "review-comment";
564 readonly body: string;
565 },
566 ) => Effect.Effect<void, PullRequestProviderError>;
567​
568 /**
569 * Sends a whole review at once. Only called for a verdict the host declared in
570 * `capabilities.review.verdicts`, and with line comments only where it declared
571 * `inlineComment`.
572 */
573 readonly submitReview: (
574 input: ProviderRepositoryRef & {
575 readonly number: number;
576 readonly verdict: PullRequestReviewVerdict;
577 readonly body: string;
578 readonly comments: ReadonlyArray<PullRequestReviewCommentDraft>;
579 },
580 ) => Effect.Effect<void, PullRequestProviderError>;
581​
582 /**
583 * The people this viewer may ask for a review, with whoever has already been asked marked as
584 * such. Only called when `capabilities.reviewers.listCandidates` is true.
585 *
586 * The author is left out by each provider rather than by the caller, because only the provider
587 * knows how the host spells the same person in a candidate list and on a pull request.
588 */
589 readonly listReviewerCandidates: (
590 input: ProviderRepositoryRef & { readonly number: number },
591 ) => Effect.Effect<PullRequestReviewerCandidateList, PullRequestProviderError>;
592​
593 /**
594 * Asks for a review, or takes the request back. Only called when
595 * `capabilities.reviewers.request` is true.
596 *
597 * One call for both directions, because that is what every host does with them: GitHub posts and
598 * deletes the same collection, and GitLab and Bitbucket write the whole reviewer set either way.
599 * Asking again somebody who has already reviewed is a request like any other — which is how a
600 * re-request is made.
601 */
602 readonly setReviewerRequest: (
603 input: ProviderRepositoryRef & {
604 readonly number: number;
605 readonly reviewers: ReadonlyArray<{
606 readonly id: string;
607 readonly kind: PullRequestReviewerKind;
608 }>;
609 readonly requested: boolean;
610 },
611 ) => Effect.Effect<void, PullRequestProviderError>;
612​
613 /**
614 * The repository's labels, with the ones already on the change request marked. Present with
615 * `setLabels` only where `capabilities.labels` is true; the service refuses both without it.
616 */
617 readonly listLabelCandidates?: (
618 input: ProviderRepositoryRef & { readonly number: number },
619 ) => Effect.Effect<PullRequestLabelCandidateList, PullRequestProviderError>;
620​
621 /** Puts labels on the change request, or takes them off. One call for both directions. */
622 readonly setLabels?: (
623 input: ProviderRepositoryRef & {
624 readonly number: number;
625 readonly labels: ReadonlyArray<string>;
626 readonly applied: boolean;
627 },
628 ) => Effect.Effect<void, PullRequestProviderError>;
629​
630 /** Only called when `capabilities.review.reply` is true. */
631 readonly replyToThread: (
632 input: ProviderRepositoryRef & {
633 readonly number: number;
634 readonly threadId: string;
635 readonly body: string;
636 },
637 ) => Effect.Effect<void, PullRequestProviderError>;
638​
639 /**
640 * Adds a reaction, or takes it back. Only called when `capabilities.reactions` is true.
641 *
642 * `subjectId` is a remark's id as the conversation carried it; absent means the change request
643 * itself, whose reactions sit on its description. Whatever a host needs to address either of
644 * them is worked out here, because the id a conversation travels with is the one the reader has.
645 */
646 readonly setReaction: (
647 input: ProviderRepositoryRef & {
648 readonly number: number;
649 readonly subjectId?: string | undefined;
650 readonly content: PullRequestReactionContent;
651 readonly reacted: boolean;
652 },
653 ) => Effect.Effect<void, PullRequestProviderError>;
654​
655 /** Only called when `capabilities.review.resolve` is true. */
656 readonly setThreadResolution: (
657 input: ProviderRepositoryRef & {
658 readonly number: number;
659 readonly threadId: string;
660 readonly resolved: boolean;
661 },
662 ) => Effect.Effect<void, PullRequestProviderError>;