The best way to control Claude Code, Codex and more from any computer or phone
refactor(server): GitHub services are named for the API they call, not gh (#16967)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Julius Marminge committed
Oct 7, 2026 at 17:26 UTC
08b1222d0bae670433c275ec70165c7b5048726f
20 files changed
+410
-455
apps/server/scripts/evaluate-thread-titles.ts
+2
-2
@@ -23,7 +23,7 @@ import {
23
} from "../src/textGeneration/ThreadTitleContext.ts";
24
import * as ThreadTitleLinks from "../src/textGeneration/ThreadTitleLinks.ts";
25
import * as SourceControlProviderRegistry from "../src/sourceControl/SourceControlProviderRegistry.ts";
26
-import * as GitHubCli from "../src/sourceControl/GitHubCli.ts";
26
+import * as GitHubRepositoryApi from "../src/sourceControl/GitHubRepositoryApi.ts";
27
import * as GitLabCli from "../src/sourceControl/GitLabCli.ts";
28
import * as ForgejoCli from "../src/sourceControl/ForgejoCli.ts";
29
import * as AzureDevOpsCli from "../src/sourceControl/AzureDevOpsCli.ts";
@@ -152,7 +152,7 @@ await Effect.runPromise(
152
SourceControlProviderRegistry.layer.pipe(
153
Layer.provide(
154
Layer.mergeAll(
155
- GitHubCli.layer,
155
+ GitHubRepositoryApi.layer,
156
GitLabCli.layer,
157
ForgejoCli.layer,
158
AzureDevOpsCli.layer,
apps/server/scripts/measure-pr-preview.ts
+2
-2
@@ -10,7 +10,7 @@ import * as Option from "effect/Option";
10
import * as Schema from "effect/Schema";
11
import { FetchHttpClient } from "effect/http";
12
13
-import * as GitHubPullRequestCli from "../src/pullRequest/GitHubPullRequestCli.ts";
13
+import * as GitHubPullRequestApi from "../src/pullRequest/GitHubPullRequestApi.ts";
14
import * as GitHubPullRequestProvider from "../src/pullRequest/GitHubPullRequestProvider.ts";
15
import * as GitHubApi from "../src/sourceControl/GitHubApi.ts";
16
import * as GitHubCredentials from "../src/sourceControl/GitHubCredentials.ts";
@@ -73,7 +73,7 @@ const measuredApi = Layer.effect(
73
Layer.provide(NodeServices.layer),
74
);
75
76
-const services = GitHubPullRequestCli.layer.pipe(
76
+const services = GitHubPullRequestApi.layer.pipe(
77
Layer.provideMerge(measuredApi),
78
Layer.provideMerge(VcsProcess.layer),
79
Layer.provideMerge(NodeServices.layer),
apps/server/src/git/GitManager.test.ts
+35
-44
@@ -42,7 +42,7 @@ import {
42
} from "@t3tools/contracts";
43
import * as DateTime from "effect/DateTime";
44
import * as GitHubApi from "../sourceControl/GitHubApi.ts";
45
-import * as GitHubCli from "../sourceControl/GitHubCli.ts";
45
+import * as GitHubRepositoryApi from "../sourceControl/GitHubRepositoryApi.ts";
46
import { decodeGitHubPullRequestListJson } from "../sourceControl/gitHubPullRequests.ts";
47
import * as GitLabCli from "../sourceControl/GitLabCli.ts";
48
import * as TextGeneration from "../textGeneration/TextGeneration.ts";
@@ -92,7 +92,7 @@ interface FakeGhScenario {
92
headRepositoryOwnerLogin?: string | null;
93
};
94
repositoryCloneUrls?: Record<string, { url: string; sshUrl: string }>;
95
- failWith?: GitHubCli.GitHubCliError;
95
+ failWith?: GitHubRepositoryApi.GitHubRepositoryApiError;
96
/** Let this many gh calls succeed before failWith kicks in (default 0 = fail immediately). */
97
failAfterCalls?: number;
98
}
@@ -111,7 +111,9 @@ type FakeGitTextGeneration = TextGeneration.TextGeneration["Service"];
111
112
type FakePullRequest = NonNullable<FakeGhScenario["pullRequest"]>;
113
114
-function normalizeFakePullRequestSummary(raw: unknown): GitHubCli.GitHubPullRequestSummary | null {
114
+function normalizeFakePullRequestSummary(
115
+ raw: unknown,
116
+): GitHubRepositoryApi.GitHubPullRequestSummary | null {
117
if (!raw || typeof raw !== "object") {
118
return null;
119
}
@@ -381,8 +383,8 @@ function createTextGeneration(
383
};
384
}
385
384
-function createGitHubCliWithFakeGh(scenario: FakeGhScenario = {}): {
385
- service: GitHubCli.GitHubCli["Service"];
386
+function createGitHubRepositoryApiWithFakeGh(scenario: FakeGhScenario = {}): {
387
+ service: GitHubRepositoryApi.GitHubRepositoryApi["Service"];
388
ghCalls: string[];
389
} {
390
const prListQueue = [...(scenario.prListSequence ?? [])];
@@ -398,7 +400,7 @@ function createGitHubCliWithFakeGh(scenario: FakeGhScenario = {}): {
400
const execute = (input: {
401
readonly cwd: string;
402
readonly args: ReadonlyArray<string>;
401
- }): Effect.Effect<VcsProcess.VcsProcessOutput, GitHubCli.GitHubCliError> => {
403
+ }): Effect.Effect<VcsProcess.VcsProcessOutput, GitHubRepositoryApi.GitHubRepositoryApiError> => {
404
const args = [...input.args];
405
ghCalls.push(args.join(" "));
406
@@ -486,10 +488,9 @@ function createGitHubCliWithFakeGh(scenario: FakeGhScenario = {}): {
488
return fakeGhOutput("");
489
},
490
catch: (error) =>
489
- GitHubCli.isGitHubCliError(error)
491
+ GitHubRepositoryApi.isGitHubRepositoryApiError(error)
492
? error
491
- : new GitHubCli.GitHubCliCommandError({
492
- command: "gh",
493
+ : new GitHubRepositoryApi.GitHubRepositoryCommandError({
494
cwd: input.cwd,
495
cause: error,
496
}),
@@ -502,8 +503,7 @@ function createGitHubCliWithFakeGh(scenario: FakeGhScenario = {}): {
503
const cloneUrls = scenario.repositoryCloneUrls?.[repository];
504
if (!cloneUrls) {
505
return Effect.fail(
505
- new GitHubCli.GitHubCliCommandError({
506
- command: "gh",
506
+ new GitHubRepositoryApi.GitHubRepositoryCommandError({
507
cwd: input.cwd,
508
cause: new Error(`Unexpected repository lookup: ${repository}`),
509
}),
@@ -523,8 +523,7 @@ function createGitHubCliWithFakeGh(scenario: FakeGhScenario = {}): {
523
}
524
525
return Effect.fail(
526
- new GitHubCli.GitHubCliCommandError({
527
- command: "gh",
526
+ new GitHubRepositoryApi.GitHubRepositoryCommandError({
527
cwd: input.cwd,
528
cause: new Error(`Unexpected gh command: ${args.join(" ")}`),
529
}),
@@ -577,7 +576,9 @@ function createGitHubCliWithFakeGh(scenario: FakeGhScenario = {}): {
576
Effect.map((raw) =>
577
raw
578
.map((entry) => normalizeFakePullRequestSummary(entry))
580
- .filter((entry): entry is GitHubCli.GitHubPullRequestSummary => entry !== null),
579
+ .filter(
580
+ (entry): entry is GitHubRepositoryApi.GitHubPullRequestSummary => entry !== null,
581
+ ),
582
),
583
),
584
createPullRequest: (input) =>
@@ -617,7 +618,9 @@ function createGitHubCliWithFakeGh(scenario: FakeGhScenario = {}): {
618
"number,title,url,baseRefName,headRefName,state,isDraft,mergedAt,closedAt,isCrossRepository,headRepository,headRepositoryOwner",
619
],
620
}).pipe(
620
- Effect.map((result) => JSON.parse(result.stdout) as GitHubCli.GitHubPullRequestSummary),
621
+ Effect.map(
622
+ (result) => JSON.parse(result.stdout) as GitHubRepositoryApi.GitHubPullRequestSummary,
623
+ ),
624
),
625
getRepositoryCloneUrls: (input) =>
626
execute({
@@ -626,8 +629,7 @@ function createGitHubCliWithFakeGh(scenario: FakeGhScenario = {}): {
629
}).pipe(Effect.map((result) => JSON.parse(result.stdout))),
630
createRepository: (input) =>
631
Effect.fail(
629
- new GitHubCli.GitHubCliCommandError({
630
- command: "gh",
632
+ new GitHubRepositoryApi.GitHubRepositoryCommandError({
633
cwd: input.cwd,
634
cause: new Error(`Unexpected repository create: ${input.repository}`),
635
}),
@@ -691,7 +693,9 @@ function makeManager(input?: {
693
ProjectionStore.ProjectionStoreV2 | ProjectStore.ProjectStoreV2
694
>;
695
}) {
694
- const { service: gitHubCli, ghCalls } = createGitHubCliWithFakeGh(input?.ghScenario);
696
+ const { service: gitHubRepositoryApi, ghCalls } = createGitHubRepositoryApiWithFakeGh(
697
+ input?.ghScenario,
698
+ );
699
const textGeneration = createTextGeneration(input?.textGeneration);
700
const layerServerConfig = ServerConfig.layerTest(process.cwd(), {
701
prefix: "t3-git-manager-test-",
@@ -740,7 +744,7 @@ function makeManager(input?: {
744
),
745
Effect.provide(
746
Layer.merge(
743
- Layer.succeed(GitHubCli.GitHubCli, gitHubCli),
747
+ Layer.succeed(GitHubRepositoryApi.GitHubRepositoryApi, gitHubRepositoryApi),
748
Layer.mock(GitHubApi.GitHubApi)({}),
749
),
750
),
@@ -1296,8 +1300,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
1300
yield* runGit(repoDir, ["push", "-u", "origin", "feature/rate-limited"]);
1301
const { manager, ghCalls } = yield* makeManager({
1302
ghScenario: {
1299
- failWith: new GitHubCli.GitHubCliUnavailableError({
1300
- command: "gh",
1303
+ failWith: new GitHubRepositoryApi.GitHubRepositoryUnavailableError({
1304
cwd: repoDir,
1305
cause: new Error("rate limited"),
1306
}),
@@ -1779,8 +1782,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
1782
1783
const { manager, ghCalls } = yield* makeManager({
1784
ghScenario: {
1782
- failWith: new GitHubCli.GitHubCliUnavailableError({
1783
- command: "gh",
1785
+ failWith: new GitHubRepositoryApi.GitHubRepositoryUnavailableError({
1786
cwd: repoDir,
1787
cause: new Error("gh is not available on PATH"),
1788
}),
@@ -2640,8 +2642,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
2642
},
2643
]),
2644
},
2643
- failWith: new GitHubCli.GitHubCliUnavailableError({
2644
- command: "gh",
2645
+ failWith: new GitHubRepositoryApi.GitHubRepositoryUnavailableError({
2646
cwd: repoDir,
2647
cause: new Error("rate limited"),
2648
}),
@@ -2717,8 +2718,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
2718
2719
const { manager } = yield* makeManager({
2720
ghScenario: {
2720
- failWith: new GitHubCli.GitHubCliUnavailableError({
2721
- command: "gh",
2721
+ failWith: new GitHubRepositoryApi.GitHubRepositoryUnavailableError({
2722
cwd: repoDir,
2723
cause: new Error("gh is not available on PATH"),
2724
}),
@@ -2743,8 +2743,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
2743
const upstreamCause = "GraphQL rate limit for user ID 51714798 and token secret-value";
2744
const { manager } = yield* makeManager({
2745
ghScenario: {
2746
- failWith: new GitHubCli.GitHubCliRateLimitError({
2747
- command: "gh",
2746
+ failWith: new GitHubRepositoryApi.GitHubRepositoryRateLimitError({
2747
cwd: repoDir,
2748
cause: new Error(upstreamCause),
2749
}),
@@ -2770,7 +2769,6 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
2769
errorTag: "SourceControlProviderError",
2770
provider: "github",
2771
providerOperation: "listChangeRequests",
2773
- providerCommand: "gh",
2772
errorDetail: "GitHub API rate limit exceeded. Requests resume when the limit resets.",
2773
});
2774
const loggedText = [
@@ -2801,8 +2799,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
2799
const { manager } = yield* makeManager({
2800
ghScenario: {
2801
prListSequence: [JSON.stringify([existingPr])],
2804
- failWith: new GitHubCli.GitHubCliUnavailableError({
2805
- command: "gh",
2802
+ failWith: new GitHubRepositoryApi.GitHubRepositoryUnavailableError({
2803
cwd: repoDir,
2804
cause: new Error("rate limited"),
2805
}),
@@ -2844,8 +2841,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
2841
const { manager } = yield* makeManager({
2842
ghScenario: {
2843
prListSequence: [JSON.stringify([existingPr])],
2847
- failWith: new GitHubCli.GitHubCliUnavailableError({
2848
- command: "gh",
2844
+ failWith: new GitHubRepositoryApi.GitHubRepositoryUnavailableError({
2845
cwd: repoDir,
2846
cause: new Error("rate limited"),
2847
}),
@@ -2892,8 +2888,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
2888
const { manager } = yield* makeManager({
2889
ghScenario: {
2890
prListSequence: [JSON.stringify([existingPr])],
2895
- failWith: new GitHubCli.GitHubCliUnavailableError({
2896
- command: "gh",
2891
+ failWith: new GitHubRepositoryApi.GitHubRepositoryUnavailableError({
2892
cwd: repoDir,
2893
cause: new Error("rate limited"),
2894
}),
@@ -2931,8 +2926,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
2926
const { manager } = yield* makeManager({
2927
ghScenario: {
2928
prListSequence: [JSON.stringify([existingPr])],
2934
- failWith: new GitHubCli.GitHubCliUnavailableError({
2935
- command: "gh",
2929
+ failWith: new GitHubRepositoryApi.GitHubRepositoryUnavailableError({
2930
cwd: repoDir,
2931
cause: new Error("rate limited"),
2932
}),
@@ -2973,8 +2967,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
2967
const { manager } = yield* makeManager({
2968
ghScenario: {
2969
prListSequence: [JSON.stringify([existingPr])],
2976
- failWith: new GitHubCli.GitHubCliUnavailableError({
2977
- command: "gh",
2970
+ failWith: new GitHubRepositoryApi.GitHubRepositoryUnavailableError({
2971
cwd: repoDir,
2972
cause: new Error("rate limited"),
2973
}),
@@ -4618,8 +4611,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
4611
4612
const { manager } = yield* makeManager({
4613
ghScenario: {
4621
- failWith: new GitHubCli.GitHubCliUnavailableError({
4622
- command: "gh",
4614
+ failWith: new GitHubRepositoryApi.GitHubRepositoryUnavailableError({
4615
cwd: repoDir,
4616
cause: new Error("gh is not available on PATH"),
4617
}),
@@ -4648,8 +4640,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
4640
4641
const { manager } = yield* makeManager({
4642
ghScenario: {
4651
- failWith: new GitHubCli.GitHubCliAuthenticationError({
4652
- command: "gh",
4643
+ failWith: new GitHubRepositoryApi.GitHubRepositoryAuthenticationError({
4644
cwd: repoDir,
4645
cause: new Error("gh is not authenticated"),
4646
}),
apps/server/src/git/GitManager.ts
+1
-1
@@ -1286,7 +1286,7 @@ export const make = Effect.gen(function* () {
1286
? {
1287
provider: error.provider,
1288
providerOperation: error.operation,
1289
- providerCommand: error.command ?? "unknown",
1289
+ ...(error.command === undefined ? {} : { providerCommand: error.command }),
1290
errorDetail: error.detail,
1291
}
1292
: {}),
apps/server/src/orchestration-v2/ThreadPullRequestService.ts
+1
-1
@@ -345,7 +345,7 @@ export const make = Effect.gen(function* () {
345
}).pipe(Effect.tap(() => Effect.sync(() => failBackfill(group)))),
346
),
347
),
348
- // Wide enough that a sweep's GitHub branch lookups reach GitHubCli together and share one
348
+ // Wide enough that a sweep's GitHub branch lookups reach GitHubRepositoryApi together and share one
349
// GraphQL document, instead of one `gh pr list` per branch.
350
{ concurrency: 32, discard: true },
351
);
apps/server/src/pullRequest/GitHubPullRequestApi.test.ts
renamed
+136
-136
@@ -12,13 +12,13 @@ import * as Redacted from "effect/Redacted";
12
13
import { HttpClient, HttpClientResponse } from "effect/http";
14
15
-import { AllowGitHubReserve } from "../sourceControl/GitHubCli.ts";
15
+import { AllowGitHubReserve } from "../sourceControl/GitHubRepositoryApi.ts";
16
import * as GitHubApi from "../sourceControl/GitHubApi.ts";
17
import * as GitHubCredentials from "../sourceControl/GitHubCredentials.ts";
18
import * as GitHubGraphQlBudget from "../sourceControl/githubGraphQlBudget.ts";
19
import * as SourceControlRateLimit from "../sourceControl/SourceControlRateLimit.ts";
20
import * as VcsProcess from "../vcs/VcsProcess.ts";
21
-import * as GitHubPullRequestCli from "./GitHubPullRequestCli.ts";
21
+import * as GitHubPullRequestApi from "./GitHubPullRequestApi.ts";
22
import { KnownWorkflowRuns } from "./gitHubConditionalChecks.ts";
23
24
const encodeJson = Schema.encodeSync(Schema.fromJsonString(Schema.Unknown));
@@ -96,7 +96,7 @@ const mockApi = Layer.effect(
96
);
97
98
const layer = it.layer(
99
- GitHubPullRequestCli.layer.pipe(
99
+ GitHubPullRequestApi.layer.pipe(
100
Layer.provideMerge(mockApi),
101
Layer.provideMerge(GitHubGraphQlBudget.layer),
102
Layer.provide(NodeCrypto.layer),
@@ -489,7 +489,7 @@ it.effect(
489
}),
490
),
491
);
492
- const cli = yield* GitHubPullRequestCli.make.pipe(
492
+ const cli = yield* GitHubPullRequestApi.make.pipe(
493
Effect.provide(
494
GitHubApi.layer.pipe(
495
Layer.provide(Layer.mergeAll(credentials, http)),
@@ -537,7 +537,7 @@ it.effect(
537
}),
538
);
539
540
-layer("GitHubPullRequestCli.layer", (it) => {
540
+layer("GitHubPullRequestApi.layer", (it) => {
541
it.effect("admits only one concurrent preview above the reserve and resumes after reset", () =>
542
Effect.gen(function* () {
543
const now = yield* Clock.currentTimeMillis;
@@ -569,7 +569,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
569
),
570
),
571
);
572
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
572
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
573
const input = {
574
cwd: "/w",
575
repository: "acme/web",
@@ -623,7 +623,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
623
),
624
),
625
);
626
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
626
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
627
const preview = yield* cli.getPullRequestPreview({
628
cwd: "/w",
629
repository: "acme/web",
@@ -653,7 +653,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
653
mockedExecute.mockImplementation(() =>
654
Effect.yieldNow.pipe(Effect.as(output('{"id":123,"login":"viewer"}'))),
655
);
656
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
656
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
657
const results = yield* Effect.all(
658
Array.from({ length: 4 }, () =>
659
cli.getRoutingIdentity({ cwd: "/w", host: "github.identity-flight.test" }),
@@ -683,7 +683,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
683
return output('{"id":123,"login":"viewer"}');
684
}),
685
);
686
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
686
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
687
const input = { cwd: "/w", host: "github.identity-cancel.test" };
688
const first = yield* cli.getRoutingIdentity(input).pipe(Effect.forkChild);
689
yield* Deferred.await(firstStarted);
@@ -727,7 +727,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
727
),
728
),
729
);
730
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
730
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
731
732
const reads = yield* Effect.forEach(
733
[7, 8],
@@ -795,7 +795,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
795
),
796
),
797
);
798
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
798
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
799
800
const reads = yield* Effect.forEach(
801
[7, 8],
@@ -855,7 +855,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
855
),
856
),
857
);
858
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
858
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
859
860
const read = yield* cli
861
.getPullRequestSummary({ cwd: "/w", repository: "acme/web", host: "github.com", number: 7 })
@@ -895,7 +895,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
895
),
896
),
897
);
898
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
898
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
899
900
const stack = yield* cli.getPullRequestStack({
901
cwd: "/w",
@@ -943,7 +943,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
943
),
944
),
945
);
946
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
946
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
947
const stack = yield* cli.getPullRequestStack({
948
cwd: "/w",
949
repository: "acme/web",
@@ -963,7 +963,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
963
it.effect("reads an empty stacks listing as not stacked", () =>
964
Effect.gen(function* () {
965
mockedExecute.mockReturnValueOnce(Effect.succeed(output("[]")));
966
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
966
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
967
968
const stack = yield* cli.getPullRequestStack({
969
cwd: "/w",
@@ -986,7 +986,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
986
}),
987
),
988
);
989
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
989
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
990
991
const stack = yield* cli.getPullRequestStack({
992
cwd: "/w",
@@ -1009,7 +1009,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
1009
}),
1010
),
1011
);
1012
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
1012
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1013
1014
const error = yield* Effect.flip(
1015
cli.getPullRequestStack({
@@ -1032,7 +1032,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
1032
status: 503,
1033
});
1034
mockedExecute.mockReturnValueOnce(Effect.fail(failure));
1035
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
1035
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1036
const error = yield* Effect.flip(
1037
cli.getPullRequestStack({
1038
cwd: "/w",
@@ -1048,7 +1048,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
1048
it.effect("reports a stacks answer it cannot read against the stack read", () =>
1049
Effect.gen(function* () {
1050
mockedExecute.mockReturnValueOnce(Effect.succeed(output('[{"id":42}]')));
1051
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
1051
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1052
1053
const error = yield* Effect.flip(
1054
cli.getPullRequestStack({
@@ -1068,7 +1068,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
1068
it.effect("asks for one row more than the page, to probe for a next page", () =>
1069
Effect.gen(function* () {
1070
mockedExecute.mockReturnValueOnce(Effect.succeed(output(pullRequests(3, 1))));
1071
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
1071
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1072
1073
const batch = yield* cli.listPullRequests({
1074
cwd: "/w",
@@ -1091,7 +1091,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
1091
it.effect("reports truncation from the extra row, counted before decoding", () =>
1092
Effect.gen(function* () {
1093
mockedExecute.mockReturnValueOnce(Effect.succeed(output(pullRequests(11, 1))));
1094
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
1094
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1095
1096
const batch = yield* cli.listPullRequests({
1097
cwd: "/w",
@@ -1117,7 +1117,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
1117
: emptySearch(),
1118
),
1119
);
1120
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
1120
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1121
1122
yield* cli.listPullRequests({
1123
cwd: "/w",
@@ -1143,7 +1143,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
1143
: emptySearch(),
1144
),
1145
);
1146
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
1146
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1147
1148
yield* cli.listPullRequests({
1149
cwd: "/w",
@@ -1168,7 +1168,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
1168
: emptySearch(),
1169
),
1170
);
1171
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
1171
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1172
1173
yield* cli.listPullRequests({
1174
cwd: "/w",
@@ -1189,7 +1189,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
1189
it.effect("carries every repository and every qualifier into one search", () =>
1190
Effect.gen(function* () {
1191
mockedExecute.mockReturnValue(Effect.succeed(searchPage([])));
1192
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
1192
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1193
1194
yield* cli.searchPullRequests({
1195
cwd: "/w",
@@ -1218,7 +1218,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
1218
it.effect("narrows a search to the author, and to merged on the merged tab", () =>
1219
Effect.gen(function* () {
1220
mockedExecute.mockReturnValue(Effect.succeed(searchPage([])));
1221
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
1221
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1222
1223
yield* cli.searchPullRequests({
1224
cwd: "/w",
@@ -1240,7 +1240,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
1240
it.effect("keeps a searched-for qualifier inside the phrase", () =>
1241
Effect.gen(function* () {
1242
mockedExecute.mockReturnValue(Effect.succeed(searchPage([])));
1243
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
1243
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1244
1245
yield* cli.searchPullRequests({
1246
cwd: "/w",
@@ -1263,7 +1263,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
1263
1264
it.effect("refuses to search for a repository GitHub cannot address", () =>
1265
Effect.gen(function* () {
1266
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
1266
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1267
1268
const failure = yield* Effect.flip(
1269
cli.searchPullRequests({
@@ -1295,7 +1295,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
1295
]),
1296
),
1297
);
1298
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
1298
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1299
1300
const batch = yield* cli.searchPullRequests({
1301
cwd: "/w",
@@ -1341,7 +1341,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
1341
.mockReturnValueOnce(
1342
Effect.succeed(searchPage([searchItem(1, "acme/web", "2026-07-03T00:00:00Z")], true)),
1343
);
1344
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
1344
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1345
const read = () =>
1346
cli.searchPullRequests({
1347
cwd: "/w",
@@ -1390,7 +1390,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
1390
),
1391
),
1392
);
1393
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
1393
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1394
const batch = yield* cli.listPullRequests({
1395
cwd: "/w",
1396
repository: "acme/web",
@@ -1443,7 +1443,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
1443
),
1444
),
1445
);
1446
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
1446
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1447
const batch = yield* cli.listPullRequests({
1448
cwd: "/w",
1449
repository: "acme/web",
@@ -1469,7 +1469,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
1469
mockedExecute.mockReturnValueOnce(Effect.succeed(emptySearch()));
1470
mockedExecute.mockReturnValueOnce(Effect.succeed(emptyList()));
1471
mockedExecute.mockReturnValueOnce(Effect.succeed(output(pullRequests(1, 7))));
1472
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
1472
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1473
const input = {
1474
cwd: "/w",
1475
repository: "acme/web",
@@ -1499,7 +1499,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
1499
output(encodeJson({ data: { s0: { pullRequest: { additions: 4, deletions: 1 } } } })),
1500
),
1501
);
1502
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
1502
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1503
1504
const stats = yield* cli.listPullRequestStats({
1505
cwd: "/w",
@@ -1521,7 +1521,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
1521
1522
it.effect("refuses to look up counts for a repository GitHub cannot address", () =>
1523
Effect.gen(function* () {
1524
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
1524
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1525
1526
const failure = yield* Effect.flip(
1527
cli.listPullRequestStats({
@@ -1545,7 +1545,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
1545
: emptySearch(),
1546
),
1547
);
1548
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
1548
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1549
1550
yield* cli.listPullRequests({
1551
cwd: "/w",
@@ -1575,7 +1575,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
1575
: emptySearch(),
1576
),
1577
);
1578
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
1578
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1579
1580
yield* cli.listPullRequests({
1581
cwd: "/w",
@@ -1603,7 +1603,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
1603
: emptySearch(),
1604
),
1605
);
1606
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
1606
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1607
1608
yield* cli.listPullRequests({
1609
cwd: "/w",
@@ -1641,7 +1641,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
1641
: emptySearch(),
1642
),
1643
);
1644
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
1644
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1645
1646
yield* cli.listPullRequests({
1647
cwd: "/w",
@@ -1667,7 +1667,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
1667
: emptySearch(),
1668
),
1669
);
1670
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
1670
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1671
1672
yield* cli.listPullRequests({
1673
cwd: "/w",
@@ -1701,7 +1701,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
1701
),
1702
),
1703
);
1704
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
1704
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1705
1706
const batch = yield* cli.listPullRequests({
1707
cwd: "/w",
@@ -1732,7 +1732,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
1732
mockedExecute.mockReturnValueOnce(
1733
Effect.succeed(output(listedPullRequests(1, 1, () => ({ checks: "PENDING" })))),
1734
);
1735
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
1735
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1736
1737
const batch = yield* cli.listPullRequests({
1738
cwd: "/w",
@@ -1759,7 +1759,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
1759
mockedExecute.mockReturnValueOnce(
1760
Effect.succeed(output(listedPullRequests(2, 1, (number) => ({ isDraft: number === 1 })))),
1761
);
1762
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
1762
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1763
1764
const batch = yield* cli.listPullRequests({
1765
cwd: "/w",
@@ -1784,7 +1784,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
1784
it.effect("carries the further narrowings into a batched search", () =>
1785
Effect.gen(function* () {
1786
mockedExecute.mockReturnValue(Effect.succeed(searchPage([])));
1787
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
1787
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1788
1789
yield* cli.searchPullRequests({
1790
cwd: "/w",
@@ -1813,7 +1813,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
1813
: emptySearch(),
1814
),
1815
);
1816
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
1816
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1817
1818
yield* cli.listPullRequests({
1819
cwd: "/w",
@@ -1843,7 +1843,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
1843
: emptySearch(),
1844
),
1845
);
1846
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
1846
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1847
1848
yield* cli.listPullRequests({
1849
cwd: "/w",
@@ -1873,7 +1873,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
1873
: emptySearch(),
1874
),
1875
);
1876
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
1876
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1877
1878
yield* cli.listPullRequests({
1879
cwd: "/w",
@@ -1895,7 +1895,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
1895
it.effect("carries on from the instant the last slice ended on", () =>
1896
Effect.gen(function* () {
1897
mockedExecute.mockReturnValue(Effect.succeed(output(pullRequests(3, 1))));
1898
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
1898
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1899
1900
const batch = yield* cli.listPullRequests({
1901
cwd: "/w",
@@ -1923,7 +1923,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
1923
// answer means the text matched nothing, and listing everything instead would fill the
1924
// page with rows the reader did not search for.
1925
mockedExecute.mockReturnValueOnce(Effect.succeed(emptySearch()));
1926
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
1926
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1927
1928
const batch = yield* cli.listPullRequests({
1929
cwd: "/w",
@@ -1948,7 +1948,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
1948
mockedExecute.mockReturnValueOnce(
1949
Effect.succeed(output(listedPullRequests(3, 1, () => ({ state: "CLOSED" })))),
1950
);
1951
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
1951
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1952
1953
const batch = yield* cli.listPullRequests({
1954
cwd: "/w",
@@ -1984,7 +1984,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
1984
),
1985
),
1986
);
1987
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
1987
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
1988
1989
const batch = yield* cli.listPullRequests({
1990
cwd: "/w",
@@ -2020,7 +2020,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
2020
),
2021
),
2022
);
2023
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
2023
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2024
2025
const batch = yield* cli.listPullRequests({
2026
cwd: "/w",
@@ -2064,7 +2064,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
2064
),
2065
);
2066
});
2067
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
2067
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2068
2069
const batch = yield* cli.listPullRequests({
2070
cwd: "/w",
@@ -2094,7 +2094,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
2094
: emptySearch(),
2095
),
2096
);
2097
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
2097
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2098
2099
yield* cli.listPullRequests({
2100
cwd: "/w",
@@ -2139,7 +2139,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
2139
it.effect("updates a stale branch with a merge commit unless asked to rebase", () =>
2140
Effect.gen(function* () {
2141
route(["query PullRequestActionState", actionState()]);
2142
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
2142
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2143
2144
yield* cli.runPullRequestAction({
2145
cwd: "/w",
@@ -2168,7 +2168,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
2168
it.effect("merges with the strategy it was asked for", () =>
2169
Effect.gen(function* () {
2170
route(["query PullRequestActionState", actionState()]);
2171
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
2171
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2172
2173
yield* cli.runPullRequestAction({
2174
cwd: "/w",
@@ -2199,7 +2199,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
2199
],
2200
["query PullRequestActionState", actionState()],
2201
);
2202
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
2202
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2203
yield* cli.runPullRequestAction({
2204
cwd: "/w",
2205
repository: "acme/web",
@@ -2243,7 +2243,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
2243
["query PullRequestMergeMessage", mergeMessage(body, queued)],
2244
["query PullRequestActionState", actionState({ isMergeQueueEnabled: queued })],
2245
);
2246
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
2246
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2247
yield* cli.runPullRequestAction({
2248
cwd: "/w",
2249
repository: "acme/web",
@@ -2269,7 +2269,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
2269
],
2270
["query PullRequestActionState", actionState()],
2271
);
2272
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
2272
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2273
yield* cli.runPullRequestAction({
2274
cwd: "/w",
2275
repository: "acme/web",
@@ -2294,7 +2294,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
2294
it.effect("does not fetch a message for rebase merges", () =>
2295
Effect.gen(function* () {
2296
route(["query PullRequestActionState", actionState()]);
2297
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
2297
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2298
yield* cli.runPullRequestAction({
2299
cwd: "/w",
2300
repository: "acme/web",
@@ -2317,7 +2317,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
2317
["query PullRequestMergeMessage", { data: { repository: { pullRequest: null } } }],
2318
["query PullRequestActionState", actionState()],
2319
);
2320
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
2320
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2321
const result = yield* Effect.result(
2322
cli.runPullRequestAction({
2323
cwd: "/w",
@@ -2336,7 +2336,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
2336
it.effect("arms auto-merge with the same strategy a merge would have used", () =>
2337
Effect.gen(function* () {
2338
route(["query PullRequestActionState", actionState()]);
2339
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
2339
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2340
2341
yield* cli.runPullRequestAction({
2342
cwd: "/w",
@@ -2366,7 +2366,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
2366
it.effect("merges at once when auto-merge is asked of a pull request that is ready now", () =>
2367
Effect.gen(function* () {
2368
route(["query PullRequestActionState", actionState({ mergeStateStatus: "CLEAN" })]);
2369
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
2369
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2370
2371
yield* cli.runPullRequestAction({
2372
cwd: "/w",
@@ -2387,7 +2387,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
2387
it.effect("takes auto-merge back off without naming a strategy", () =>
2388
Effect.gen(function* () {
2389
route([NODE_ID_QUERY, nodeIdAnswer("PR_7")]);
2390
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
2390
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2391
2392
yield* cli.runPullRequestAction({
2393
cwd: "/w",
@@ -2405,7 +2405,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
2405
it.effect("opens a pull request that reverts a merged pull request", () =>
2406
Effect.gen(function* () {
2407
route([NODE_ID_QUERY, nodeIdAnswer("PR_7")]);
2408
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
2408
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2409
2410
yield* cli.runPullRequestAction({
2411
cwd: "/w",
@@ -2441,7 +2441,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
2441
),
2442
),
2443
);
2444
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
2444
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2445
2446
yield* cli.runPullRequestAction({
2447
cwd: "/w",
@@ -2458,7 +2458,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
2458
it.effect("finds and approves every workflow waiting on a maintainer", () =>
2459
Effect.gen(function* () {
2460
workflowApprovalRoutes(() => crossRepositoryDetail(), heads([7]), workflowRuns([10, 11]));
2461
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
2461
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2462
2463
yield* cli.runPullRequestAction({
2464
cwd: "/w",
@@ -2490,7 +2490,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
2490
it.effect("counts revalidated runs that wait on a maintainer as GitHub reports them", () =>
2491
Effect.gen(function* () {
2492
workflowApprovalRoutes(() => crossRepositoryDetail(), heads([7]), workflowRuns([]));
2493
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
2493
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2494
2495
const runs = yield* cli
2496
.listWorkflowRunsRequiringApproval({
@@ -2532,7 +2532,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
2532
heads([7]),
2533
workflowRuns([10]),
2534
);
2535
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
2535
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2536
2537
const error = yield* Effect.flip(
2538
cli.runPullRequestAction({
@@ -2568,7 +2568,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
2568
Effect.as(output(encodeJson(workflowRuns([10])))),
2569
),
2570
);
2571
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
2571
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2572
2573
const runs = yield* cli.listWorkflowRunsRequiringApproval({
2574
cwd: "/w",
@@ -2588,7 +2588,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
2588
it.effect("refuses workflow approval when one head belongs to several pull requests", () =>
2589
Effect.gen(function* () {
2590
workflowApprovalRoutes(() => crossRepositoryDetail(), heads([7, 8]), workflowRuns([]));
2591
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
2591
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2592
2593
const error = yield* Effect.flip(
2594
cli.listWorkflowRunsRequiringApproval({
@@ -2636,7 +2636,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
2636
),
2637
),
2638
);
2639
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
2639
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2640
2641
const error = yield* Effect.flip(
2642
cli.runPullRequestAction({
@@ -2670,7 +2670,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
2670
),
2671
);
2672
});
2673
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
2673
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2674
2675
const error = yield* Effect.flip(
2676
cli.listWorkflowRunsRequiringApproval({
@@ -2701,7 +2701,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
2701
it.effect("returns a pull request to draft by converting it", () =>
2702
Effect.gen(function* () {
2703
route([NODE_ID_QUERY, nodeIdAnswer("PR_7")]);
2704
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
2704
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2705
2706
yield* cli.runPullRequestAction({
2707
cwd: "/w",
@@ -2719,7 +2719,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
2719
it.effect("sends a comment body as a variable, never inside the document", () =>
2720
Effect.gen(function* () {
2721
route([NODE_ID_QUERY, nodeIdAnswer("PR_7")]);
2722
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
2722
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2723
2724
yield* cli.commentOnPullRequest({
2725
cwd: "/w",
@@ -2743,7 +2743,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
2743
: emptySearch(),
2744
),
2745
);
2746
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
2746
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2747
2748
yield* cli.listPullRequests({
2749
cwd: "/w",
@@ -2777,7 +2777,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
2777
),
2778
),
2779
);
2780
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
2780
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2781
2782
yield* cli.listReviewThreadComments({
2783
cwd: "/w",
@@ -2794,7 +2794,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
2794
it.effect("serves a diff GitHub hands over whole in one request, with no next slice", () =>
2795
Effect.gen(function* () {
2796
mockedExecute.mockReturnValueOnce(Effect.succeed(output("diff --git a/a b/a")));
2797
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
2797
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2798
2799
const diff = yield* cli.getPullRequestDiff({
2800
cwd: "/w",
@@ -2823,7 +2823,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
2823
// GitHub answers 406 rather than a diff past 300 changed files.
2824
mockedExecute.mockReturnValueOnce(Effect.fail(diffRefused));
2825
mockedExecute.mockReturnValueOnce(Effect.succeed(output(pullRequestFiles(2, 1))));
2826
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
2826
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2827
2828
const diff = yield* cli.getPullRequestDiff({
2829
cwd: "/w",
@@ -2846,7 +2846,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
2846
Effect.gen(function* () {
2847
mockedExecute.mockReturnValueOnce(Effect.fail(diffRefused));
2848
mockedExecute.mockReturnValueOnce(Effect.succeed(output(pullRequestFiles(100, 0))));
2849
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
2849
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2850
2851
const diff = yield* cli.getPullRequestDiff({
2852
cwd: "/w",
@@ -2866,7 +2866,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
2866
Effect.gen(function* () {
2867
mockedExecute.mockReturnValueOnce(Effect.fail(diffRefused));
2868
mockedExecute.mockReturnValueOnce(Effect.succeed(output(pullRequestFiles(100, 0))));
2869
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
2869
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2870
const target = { cwd: "/w", repository: "acme/web", host: "github.com", number: 7 };
2871
2872
const first = yield* cli.getPullRequestDiff(target);
@@ -2884,7 +2884,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
2884
2885
it.effect("refuses a cursor it never handed out rather than reading it into a request", () =>
2886
Effect.gen(function* () {
2887
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
2887
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2888
2889
const error = yield* Effect.flip(
2890
cli.getPullRequestDiff({
@@ -2906,7 +2906,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
2906
mockedExecute.mockReturnValueOnce(
2907
Effect.succeed(output(`{"files":${pullRequestFiles(2, 1)}}`)),
2908
);
2909
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
2909
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2910
2911
const diff = yield* cli.getPullRequestDiff({
2912
cwd: "/w",
@@ -2933,7 +2933,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
2933
mockedExecute.mockReturnValueOnce(
2934
Effect.succeed(output(`{"files":${pullRequestFiles(100, 0)}}`)),
2935
);
2936
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
2936
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2937
const target = {
2938
cwd: "/w",
2939
repository: "acme/web",
@@ -2957,7 +2957,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
2957
2958
it.effect("refuses a commit that is not a sha rather than reading it into a request", () =>
2959
Effect.gen(function* () {
2960
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
2960
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2961
2962
const error = yield* Effect.flip(
2963
cli.getPullRequestDiff({
@@ -2980,7 +2980,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
2980
Effect.succeed(output(encodeJson({ sha: "a1b2c3d", parents: [] }))),
2981
);
2982
mockedExecute.mockReturnValueOnce(Effect.succeed(output("root contents\n")));
2983
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
2983
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
2984
2985
const contents = yield* cli.getPullRequestDiffFileContents({
2986
cwd: "/w",
@@ -3003,7 +3003,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
3003
it.effect("reports unusable diff revisions as a structured error", () =>
3004
Effect.gen(function* () {
3005
mockedExecute.mockReturnValueOnce(Effect.succeed(output("not-a-sha\tstill-not-a-sha\n")));
3006
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
3006
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3007
3008
const error = yield* Effect.flip(
3009
cli.getPullRequestDiffFileContents({
@@ -3030,7 +3030,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
3030
Effect.gen(function* () {
3031
mockedExecute.mockReturnValueOnce(Effect.succeed(output(pullRequestRefs)));
3032
mockedExecute.mockReturnValueOnce(Effect.succeed(output("partial", true)));
3033
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
3033
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3034
3035
const error = yield* Effect.flip(
3036
cli.getPullRequestDiffFileContents({
@@ -3058,7 +3058,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
3058
Effect.gen(function* () {
3059
mockedExecute.mockReturnValueOnce(Effect.succeed(output(pullRequestRefs)));
3060
mockedExecute.mockReturnValueOnce(Effect.succeed(output("binary�contents", false, true)));
3061
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
3061
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3062
3063
const error = yield* Effect.flip(
3064
cli.getPullRequestDiffFileContents({
@@ -3084,7 +3084,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
3084
Effect.gen(function* () {
3085
mockedExecute.mockReturnValueOnce(Effect.succeed(output(pullRequestRefs)));
3086
mockedExecute.mockReturnValueOnce(Effect.succeed(output("before�after")));
3087
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
3087
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3088
3089
const contents = yield* cli.getPullRequestDiffFileContents({
3090
cwd: "/w",
@@ -3103,7 +3103,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
3103
it.effect("ends the diff on a page with no files rather than asking for it again", () =>
3104
Effect.gen(function* () {
3105
mockedExecute.mockReturnValue(Effect.succeed(output("[]")));
3106
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
3106
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3107
3108
const diff = yield* cli.getPullRequestDiff({
3109
cwd: "/w",
@@ -3122,7 +3122,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
3122
Effect.gen(function* () {
3123
mockedExecute.mockReturnValueOnce(Effect.fail(diffRefused));
3124
mockedExecute.mockReturnValueOnce(Effect.succeed(output("not json")));
3125
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
3125
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3126
3127
const error = yield* Effect.flip(
3128
cli.getPullRequestDiff({
@@ -3139,7 +3139,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
3139
3140
it.effect("skips the avatar lookup when a listing named nobody", () =>
3141
Effect.gen(function* () {
3142
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
3142
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3143
3144
const avatars = yield* cli.listActorAvatars({
3145
cwd: "/w",
@@ -3172,7 +3172,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
3172
),
3173
),
3174
);
3175
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
3175
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3176
3177
const avatars = yield* cli.listActorAvatars({
3178
cwd: "/w",
@@ -3190,7 +3190,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
3190
it.effect("fails when the authenticated account has no login", () =>
3191
Effect.gen(function* () {
3192
mockedExecute.mockReturnValueOnce(Effect.succeed(output(" ")));
3193
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
3193
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3194
3195
const error = yield* Effect.flip(cli.getViewerLogin({ cwd: "/w", host: "github.com" }));
3196
@@ -3203,7 +3203,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
3203
mockedExecute.mockReturnValueOnce(
3204
Effect.succeed(output('{"id":456,"login":"enterprise-user"}')),
3205
);
3206
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
3206
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3207
3208
const login = yield* cli.getViewerLogin({ cwd: "/w", host: "github.acme.com" });
3209
@@ -3215,7 +3215,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
3215
3216
it.effect("reuses verified credentials offline and refuses an unverified replacement", () =>
3217
Effect.gen(function* () {
3218
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
3218
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3219
const input = { cwd: "/w", host: "github.identity-cache.test" };
3220
mockedCredential.mockImplementation((host) =>
3221
Effect.succeed({ token: Redacted.make("test-credential-a"), fingerprint: `${host}:a` }),
@@ -3263,7 +3263,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
3263
it.effect("sends a whole review as one request", () =>
3264
Effect.gen(function* () {
3265
mockedExecute.mockReturnValue(Effect.succeed(output("{}")));
3266
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
3266
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3267
3268
yield* cli.submitReview({
3269
cwd: "/w",
@@ -3294,7 +3294,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
3294
it.effect("sends a reply body as a variable, never inside the document", () =>
3295
Effect.gen(function* () {
3296
mockedExecute.mockReturnValue(Effect.succeed(output("{}")));
3297
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
3297
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3298
3299
yield* cli.replyToReviewThread({
3300
cwd: "/w",
@@ -3314,7 +3314,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
3314
it.effect("resolves and unresolves through the mutation each one needs", () =>
3315
Effect.gen(function* () {
3316
mockedExecute.mockReturnValue(Effect.succeed(output("{}")));
3317
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
3317
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3318
3319
yield* cli.setReviewThreadResolution({
3320
cwd: "/w",
@@ -3343,7 +3343,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
3343
it.effect("confirms a given subject belongs to the named pull request, then reacts to it", () =>
3344
Effect.gen(function* () {
3345
route([SUBJECT_SCOPE_QUERY, subjectScope("IC_1", "PR_kwDOA")]);
3346
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
3346
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3347
3348
yield* cli.setReaction({
3349
cwd: "/w",
@@ -3379,7 +3379,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
3379
),
3380
),
3381
);
3382
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
3382
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3383
3384
const error = yield* Effect.flip(
3385
cli.setReaction({
@@ -3402,7 +3402,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
3402
it.effect("looks up the pull request's own node id when no subject was given", () =>
3403
Effect.gen(function* () {
3404
route([NODE_ID_QUERY, nodeIdAnswer("PR_kwDOA")]);
3405
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
3405
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3406
3407
// Its own pull request: a node id looked up once is remembered for the life of the service.
3408
yield* cli.setReaction({
@@ -3423,7 +3423,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
3423
it.effect("takes a reaction back through the remove mutation", () =>
3424
Effect.gen(function* () {
3425
route([SUBJECT_SCOPE_QUERY, subjectScope("IC_1", "PR_kwDOA")]);
3426
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
3426
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3427
3428
yield* cli.setReaction({
3429
cwd: "/w",
@@ -3443,7 +3443,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
3443
it.effect("rewrites only the words a request named", () =>
3444
Effect.gen(function* () {
3445
route([NODE_ID_QUERY, nodeIdAnswer("PR_kwDOA")]);
3446
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
3446
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3447
const rewrite = (fields: { readonly title?: string; readonly body?: string }) =>
3448
cli.updatePullRequest({
3449
cwd: "/w",
@@ -3470,7 +3470,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
3470
it.effect("rewrites a remark through the mutation its kind needs", () =>
3471
Effect.gen(function* () {
3472
route([SUBJECT_SCOPE_QUERY, subjectScope("IC_1", "PR_kwDOA")]);
3473
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
3473
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3474
const rewrite = (kind: "issue-comment" | "review-comment") =>
3475
cli.updateComment({
3476
cwd: "/w",
@@ -3512,7 +3512,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
3512
),
3513
),
3514
);
3515
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
3515
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3516
3517
const error = yield* Effect.flip(
3518
cli.updateComment({
@@ -3537,7 +3537,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
3537
it.effect("fails the read when gh returns something unreadable", () =>
3538
Effect.gen(function* () {
3539
mockedExecute.mockReturnValueOnce(Effect.succeed(output('{"message":"not found"}')));
3540
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
3540
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3541
3542
const error = yield* Effect.flip(
3543
cli.getPullRequestDetail({
@@ -3586,7 +3586,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
3586
),
3587
),
3588
);
3589
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
3589
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3590
const input = {
3591
cwd: "/w",
3592
repository: "acme/web",
@@ -3664,7 +3664,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
3664
),
3665
),
3666
);
3667
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
3667
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3668
const detail = yield* cli.getPullRequestDetail({
3669
cwd: "/w",
3670
repository: "acme/web",
@@ -3720,7 +3720,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
3720
),
3721
),
3722
);
3723
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
3723
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3724
const detail = yield* cli.getPullRequestDetail({
3725
cwd: "/w",
3726
repository: "acme/web",
@@ -3768,7 +3768,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
3768
),
3769
),
3770
);
3771
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
3771
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3772
const error = yield* Effect.flip(
3773
cli.getPullRequestDetail({
3774
cwd: "/w",
@@ -3802,7 +3802,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
3802
),
3803
),
3804
);
3805
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
3805
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3806
const input = {
3807
cwd: "/w",
3808
repository: "acme/web",
@@ -3822,7 +3822,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
3822
Effect.gen(function* () {
3823
mockedExecute.mockReturnValueOnce(Effect.fail(diffRefused));
3824
mockedExecute.mockReturnValueOnce(Effect.succeed(output(pullRequestFiles(1, 1), true)));
3825
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
3825
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3826
3827
const error = yield* Effect.flip(
3828
cli.getPullRequestDiff({
@@ -3847,7 +3847,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
3847
Effect.succeed(output("diff --git a/a b/a\n@@ -1 +1 @@", true)),
3848
);
3849
mockedExecute.mockReturnValueOnce(Effect.succeed(output(pullRequestFiles(1, 1))));
3850
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
3850
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3851
3852
const slice = yield* cli.getPullRequestDiff({
3853
cwd: "/w",
@@ -3872,7 +3872,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
3872
mockedExecute.mockReturnValueOnce(
3873
Effect.succeed(output(reviewThreadsPage([thread("PRRT_2", "c2")], null))),
3874
);
3875
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
3875
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3876
3877
const conversation = yield* cli.listReviewThreadComments({
3878
cwd: "/w",
@@ -3902,7 +3902,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
3902
),
3903
),
3904
);
3905
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
3905
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3906
3907
const conversation = yield* cli.listReviewThreadComments({
3908
cwd: "/w",
@@ -3929,7 +3929,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
3929
),
3930
),
3931
);
3932
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
3932
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3933
3934
const conversation = yield* cli.listReviewThreadComments({
3935
cwd: "/w",
@@ -3954,7 +3954,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
3954
mockedExecute.mockReturnValueOnce(
3955
Effect.succeed(output(threadCommentsPage(["c2", "c3"], null, 3))),
3956
);
3957
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
3957
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3958
3959
const page = yield* cli.getReviewThreadComments({
3960
cwd: "/w",
@@ -3983,7 +3983,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
3983
mockedExecute.mockReturnValueOnce(
3984
Effect.succeed(output(threadCommentsPage(["foreign"], null, 1, "PR_8"))),
3985
);
3986
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
3986
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
3987
3988
const error = yield* Effect.flip(
3989
cli.getReviewThreadComments({
@@ -4021,7 +4021,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
4021
),
4022
),
4023
);
4024
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
4024
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
4025
4026
const access = yield* cli.getViewerAccess({
4027
cwd: "/w",
@@ -4069,7 +4069,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
4069
),
4070
),
4071
);
4072
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
4072
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
4073
const input = {
4074
cwd: "/w",
4075
repository: "acme/web",
@@ -4134,7 +4134,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
4134
),
4135
),
4136
);
4137
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
4137
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
4138
4139
yield* cli.getViewerAccess({
4140
cwd: "/w",
@@ -4165,7 +4165,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
4165
it.effect("asks GitHub to review, naming the collection a request is added to", () =>
4166
Effect.gen(function* () {
4167
mockedExecute.mockReturnValue(Effect.succeed(output("{}")));
4168
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
4168
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
4169
4170
yield* cli.setReviewerRequest({
4171
cwd: "/w",
@@ -4191,7 +4191,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
4191
it.effect("takes a request back by deleting from the same collection it was added to", () =>
4192
Effect.gen(function* () {
4193
mockedExecute.mockReturnValue(Effect.succeed(output("{}")));
4194
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
4194
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
4195
4196
yield* cli.setReviewerRequest({
4197
cwd: "/w",
@@ -4233,7 +4233,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
4233
),
4234
),
4235
);
4236
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
4236
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
4237
4238
const list = yield* cli.listReviewerCandidates({
4239
cwd: "/w",
@@ -4256,7 +4256,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
4256
it.effect("puts labels on by posting to the issue's own collection, all at once", () =>
4257
Effect.gen(function* () {
4258
mockedExecute.mockReturnValue(Effect.succeed(output("[]")));
4259
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
4259
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
4260
4261
yield* cli.setLabels({
4262
cwd: "/w",
@@ -4280,7 +4280,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
4280
it.effect("takes labels off one at a time, naming each in the path encoded", () =>
4281
Effect.gen(function* () {
4282
mockedExecute.mockReturnValue(Effect.succeed(output("[]")));
4283
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
4283
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
4284
4285
yield* cli.setLabels({
4286
cwd: "/w",
@@ -4329,7 +4329,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
4329
.mockReturnValueOnce(page(0, true))
4330
.mockReturnValueOnce(page(1, true))
4331
.mockReturnValueOnce(page(2, false));
4332
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
4332
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
4333
4334
const viewed = yield* cli.getPullRequestFilesViewed({
4335
cwd: "/w",
@@ -4377,7 +4377,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
4377
),
4378
),
4379
);
4380
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
4380
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
4381
4382
const viewed = yield* cli.getPullRequestFilesViewed({
4383
cwd: "/w",
@@ -4401,7 +4401,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
4401
),
4402
)
4403
.mockReturnValueOnce(Effect.succeed(output("{}")));
4404
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
4404
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
4405
4406
yield* cli.setPullRequestFilesViewed({
4407
cwd: "/w",
@@ -4428,7 +4428,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
4428
4429
it.effect("asks the host nothing when nothing was pressed", () =>
4430
Effect.gen(function* () {
4431
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
4431
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
4432
4433
yield* cli.setPullRequestFilesViewed({
4434
cwd: "/w",
@@ -4451,7 +4451,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
4451
),
4452
)
4453
.mockReturnValue(Effect.succeed(output("{}")));
4454
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
4454
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
4455
const pullRequest = { cwd: "/w", repository: "acme/web", host: "github.com", number: 24 };
4456
4457
yield* cli.setPullRequestFilesViewed({
@@ -4485,7 +4485,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
4485
),
4486
)
4487
.mockReturnValueOnce(Effect.succeed(output("{}")));
4488
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
4488
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
4489
const write = () =>
4490
cli.setPullRequestFilesViewed({
4491
cwd: "/w",
@@ -4522,7 +4522,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
4522
output(encodeJson({ data: { repository: { pullRequest: { id: `PR_${number}` } } } })),
4523
);
4524
});
4525
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
4525
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
4526
const tick = (number: number) =>
4527
cli.setPullRequestFilesViewed({
4528
cwd: "/w",
@@ -4534,7 +4534,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
4534
4535
yield* tick(HOT);
4536
// A cache's worth of cold pull requests, with the open one pressed in between each of them.
4537
- for (let filled = 0; filled < GitHubPullRequestCli.NODE_ID_CACHE_CAPACITY; filled += 1) {
4537
+ for (let filled = 0; filled < GitHubPullRequestApi.NODE_ID_CACHE_CAPACITY; filled += 1) {
4538
yield* tick(HOT + 1 + filled);
4539
yield* tick(HOT);
4540
}
apps/server/src/pullRequest/GitHubPullRequestApi.ts
renamed
+66
-93
@@ -42,7 +42,7 @@ import {
42
type PullRequestPreview,
43
} from "@t3tools/contracts";
44
45
-import { AllowGitHubReserve } from "../sourceControl/GitHubCli.ts";
45
+import { AllowGitHubReserve } from "../sourceControl/GitHubRepositoryApi.ts";
46
import * as GitHubApi from "../sourceControl/GitHubApi.ts";
47
import * as VcsProcess from "../vcs/VcsProcess.ts";
48
import * as SourceControlRateLimit from "../sourceControl/SourceControlRateLimit.ts";
@@ -138,7 +138,6 @@ import type { ProviderChangeRequestSummary, ProviderListCursor } from "./PullReq
138
export class GitHubPullRequestReadError extends Schema.TaggedError<GitHubPullRequestReadError>()(
139
"GitHubPullRequestReadError",
140
{
141
- command: Schema.Literal("gh"),
141
cwd: Schema.String,
142
operation: Schema.String,
143
cause: Schema.Defect(),
@@ -149,11 +148,10 @@ export class GitHubPullRequestReadError extends Schema.TaggedError<GitHubPullReq
148
}
149
}
150
152
-/** Not a decode failure: gh answered, the account it answered for just has no login. */
151
+/** Not a decode failure: GitHub answered, the account it answered for just has no login. */
152
export class GitHubViewerLoginUnavailableError extends Schema.TaggedError<GitHubViewerLoginUnavailableError>()(
153
"GitHubViewerLoginUnavailableError",
154
{
156
- command: Schema.Literal("gh"),
155
cwd: Schema.String,
156
},
157
) {
@@ -162,11 +160,10 @@ export class GitHubViewerLoginUnavailableError extends Schema.TaggedError<GitHub
160
}
161
}
162
165
-/** Not a decode failure: gh answered, but the pull request carried no update time. */
163
+/** Not a decode failure: GitHub answered, but the pull request carried no update time. */
164
export class GitHubPullRequestUpdatedAtUnavailableError extends Schema.TaggedError<GitHubPullRequestUpdatedAtUnavailableError>()(
165
"GitHubPullRequestUpdatedAtUnavailableError",
166
{
169
- command: Schema.Literal("gh"),
167
cwd: Schema.String,
168
repository: Schema.String,
169
number: Schema.Int,
@@ -181,7 +178,6 @@ export class GitHubPullRequestUpdatedAtUnavailableError extends Schema.TaggedErr
178
export class GitHubDiffCursorError extends Schema.TaggedError<GitHubDiffCursorError>()(
179
"GitHubDiffCursorError",
180
{
184
- command: Schema.Literal("gh"),
181
cwd: Schema.String,
182
},
183
) {
@@ -194,7 +190,6 @@ export class GitHubDiffCursorError extends Schema.TaggedError<GitHubDiffCursorEr
190
export class GitHubDiffCommitError extends Schema.TaggedError<GitHubDiffCommitError>()(
191
"GitHubDiffCommitError",
192
{
197
- command: Schema.Literal("gh"),
193
cwd: Schema.String,
194
},
195
) {
@@ -207,7 +202,6 @@ export class GitHubDiffCommitError extends Schema.TaggedError<GitHubDiffCommitEr
202
export class GitHubDiffRevisionsUnavailableError extends Schema.TaggedError<GitHubDiffRevisionsUnavailableError>()(
203
"GitHubDiffRevisionsUnavailableError",
204
{
210
- command: Schema.Literal("gh"),
205
cwd: Schema.String,
206
number: Schema.Int,
207
commit: Schema.optional(Schema.String),
@@ -224,7 +218,6 @@ export class GitHubDiffRevisionsUnavailableError extends Schema.TaggedError<GitH
218
export class GitHubDiffFileContentsUnavailableError extends Schema.TaggedError<GitHubDiffFileContentsUnavailableError>()(
219
"GitHubDiffFileContentsUnavailableError",
220
{
227
- command: Schema.Literal("gh"),
221
cwd: Schema.String,
222
path: Schema.String,
223
reason: Schema.Literals(["oversized", "binary"]),
@@ -246,7 +239,6 @@ export class GitHubDiffFileContentsUnavailableError extends Schema.TaggedError<G
239
export class GitHubRepositorySelectorError extends Schema.TaggedError<GitHubRepositorySelectorError>()(
240
"GitHubRepositorySelectorError",
241
{
249
- command: Schema.Literal("gh"),
242
cwd: Schema.String,
243
operation: Schema.String,
244
},
@@ -260,7 +252,6 @@ export class GitHubRepositorySelectorError extends Schema.TaggedError<GitHubRepo
252
export class GitHubSubjectScopeError extends Schema.TaggedError<GitHubSubjectScopeError>()(
253
"GitHubSubjectScopeError",
254
{
263
- command: Schema.Literal("gh"),
255
cwd: Schema.String,
256
operation: Schema.String,
257
},
@@ -274,7 +265,6 @@ export class GitHubSubjectScopeError extends Schema.TaggedError<GitHubSubjectSco
265
export class GitHubWorkflowApprovalRefusedError extends Schema.TaggedError<GitHubWorkflowApprovalRefusedError>()(
266
"GitHubWorkflowApprovalRefusedError",
267
{
277
- command: Schema.Literal("gh"),
268
cwd: Schema.String,
269
number: Schema.Int,
270
reason: Schema.Literals(["head-list-truncated", "head-not-unique", "run-list-truncated"]),
@@ -297,7 +287,6 @@ export class GitHubWorkflowApprovalRefusedError extends Schema.TaggedError<GitHu
287
export class GitHubWorkflowApprovalHeadUnavailableError extends Schema.TaggedError<GitHubWorkflowApprovalHeadUnavailableError>()(
288
"GitHubWorkflowApprovalHeadUnavailableError",
289
{
300
- command: Schema.Literal("gh"),
290
cwd: Schema.String,
291
number: Schema.Int,
292
},
@@ -311,7 +300,6 @@ export class GitHubWorkflowApprovalHeadUnavailableError extends Schema.TaggedErr
300
export class GitHubWorkflowApprovalHeadChangedError extends Schema.TaggedError<GitHubWorkflowApprovalHeadChangedError>()(
301
"GitHubWorkflowApprovalHeadChangedError",
302
{
314
- command: Schema.Literal("gh"),
303
cwd: Schema.String,
304
number: Schema.Int,
305
},
@@ -321,7 +309,7 @@ export class GitHubWorkflowApprovalHeadChangedError extends Schema.TaggedError<G
309
}
310
}
311
324
-export type GitHubPullRequestCliError =
312
+export type GitHubPullRequestApiError =
313
| GitHubStackActionError
314
| GitHubApi.GitHubApiError
315
| GitHubPullRequestReadError
@@ -424,7 +412,7 @@ class PullRequestSummaryRead extends Request.Class<
412
readonly number: number;
413
},
414
ProviderChangeRequestSummary,
427
- GitHubPullRequestCliError
415
+ GitHubPullRequestApiError
416
> {}
417
418
class PullRequestWatchFingerprintRead extends Request.Class<
@@ -435,7 +423,7 @@ class PullRequestWatchFingerprintRead extends Request.Class<
423
readonly number: number;
424
},
425
GitHubPullRequestWatchFingerprint | null,
438
- GitHubPullRequestCliError
426
+ GitHubPullRequestApiError
427
> {}
428
429
export interface GitHubPullRequestSearchBatch {
@@ -460,8 +448,8 @@ export interface GitHubPullRequestFilesViewed {
448
readonly truncated: boolean;
449
}
450
463
-export class GitHubPullRequestCli extends Context.Service<
464
- GitHubPullRequestCli,
451
+export class GitHubPullRequestApi extends Context.Service<
452
+ GitHubPullRequestApi,
453
{
454
readonly withVerifiedCredential: <A, E, R>(
455
input: { readonly cwd: string; readonly host: string },
@@ -470,18 +458,18 @@ export class GitHubPullRequestCli extends Context.Service<
458
readonly viewer: string;
459
readonly credentialFingerprint: string;
460
}) => Effect.Effect<A, E, R>,
473
- ) => Effect.Effect<A, E | GitHubPullRequestCliError, R>;
461
+ ) => Effect.Effect<A, E | GitHubPullRequestApiError, R>;
462
readonly getRoutingIdentity: (input: {
463
readonly cwd: string;
464
readonly host: string;
465
}) => Effect.Effect<
466
{ readonly accountId: string; readonly viewer: string },
479
- GitHubPullRequestCliError
467
+ GitHubPullRequestApiError
468
>;
469
readonly getViewerLogin: (input: {
470
readonly cwd: string;
471
readonly host: string;
484
- }) => Effect.Effect<string, GitHubPullRequestCliError>;
472
+ }) => Effect.Effect<string, GitHubPullRequestApiError>;
473
474
readonly listPullRequests: (input: {
475
readonly cwd: string;
@@ -497,7 +485,7 @@ export class GitHubPullRequestCli extends Context.Service<
485
readonly cursor?: ProviderListCursor | undefined;
486
/** Further narrowings, as qualifiers on the search and as a local pass on the fallback. */
487
readonly filters?: PullRequestListFilters | undefined;
500
- }) => Effect.Effect<GitHubPullRequestListBatch, GitHubPullRequestCliError>;
488
+ }) => Effect.Effect<GitHubPullRequestListBatch, GitHubPullRequestApiError>;
489
490
/**
491
* The same listing for a whole host in one search. `limit` is the size of the slice across
@@ -516,7 +504,7 @@ export class GitHubPullRequestCli extends Context.Service<
504
readonly query?: string | undefined;
505
readonly cursor?: ProviderListCursor | undefined;
506
readonly filters?: PullRequestListFilters | undefined;
519
- }) => Effect.Effect<GitHubPullRequestSearchBatch, GitHubPullRequestCliError>;
507
+ }) => Effect.Effect<GitHubPullRequestSearchBatch, GitHubPullRequestApiError>;
508
509
/** The line counts the search leaves out, for rows already on the page. */
510
readonly listPullRequestStats: (input: {
@@ -526,14 +514,14 @@ export class GitHubPullRequestCli extends Context.Service<
514
readonly repository: string;
515
readonly number: number;
516
}>;
529
- }) => Effect.Effect<ReadonlyArray<GitHubPullRequestStat>, GitHubPullRequestCliError>;
517
+ }) => Effect.Effect<ReadonlyArray<GitHubPullRequestStat>, GitHubPullRequestApiError>;
518
519
readonly getPullRequestSummary: (input: {
520
readonly cwd: string;
521
readonly repository: string;
522
readonly host: string;
523
readonly number: number;
536
- }) => Effect.Effect<ProviderChangeRequestSummary, GitHubPullRequestCliError>;
524
+ }) => Effect.Effect<ProviderChangeRequestSummary, GitHubPullRequestApiError>;
525
/**
526
* What a watch compares between passes, batched like summaries. Null when GitHub gave no
527
* answer for this pull request, so the watch reads it in full instead.
@@ -543,7 +531,7 @@ export class GitHubPullRequestCli extends Context.Service<
531
readonly repository: string;
532
readonly host: string;
533
readonly number: number;
546
- }) => Effect.Effect<GitHubPullRequestWatchFingerprint | null, GitHubPullRequestCliError>;
534
+ }) => Effect.Effect<GitHubPullRequestWatchFingerprint | null, GitHubPullRequestApiError>;
535
536
readonly revalidateChecks: Effect.Success<typeof makeChecksRevalidator>;
537
@@ -552,7 +540,7 @@ export class GitHubPullRequestCli extends Context.Service<
540
readonly repository: string;
541
readonly host: string;
542
readonly number: number;
555
- }) => Effect.Effect<GitHubPullRequestCore, GitHubPullRequestCliError>;
543
+ }) => Effect.Effect<GitHubPullRequestCore, GitHubPullRequestApiError>;
544
545
readonly getPullRequestPreview: (input: {
546
readonly cwd: string;
@@ -561,7 +549,7 @@ export class GitHubPullRequestCli extends Context.Service<
549
readonly number: number;
550
}) => Effect.Effect<
551
Omit<PullRequestPreview, "projectId" | "repository">,
564
- GitHubPullRequestCliError
552
+ GitHubPullRequestApiError
553
>;
554
555
readonly listWorkflowRunsRequiringApproval: (input: {
@@ -573,7 +561,7 @@ export class GitHubPullRequestCli extends Context.Service<
561
readonly headBranch: string;
562
readonly headRepositoryOwner: string;
563
readonly isCrossRepository: true;
576
- }) => Effect.Effect<ReadonlyArray<GitHubWorkflowRunApproval>, GitHubPullRequestCliError>;
564
+ }) => Effect.Effect<ReadonlyArray<GitHubWorkflowRunApproval>, GitHubPullRequestApiError>;
565
566
/**
567
* The host-native stack this pull request is in, or null when it is in none — which is also
@@ -585,14 +573,14 @@ export class GitHubPullRequestCli extends Context.Service<
573
readonly repository: string;
574
readonly host: string;
575
readonly number: number;
588
- }) => Effect.Effect<GitHubPullRequestStack | null, GitHubPullRequestCliError>;
576
+ }) => Effect.Effect<GitHubPullRequestStack | null, GitHubPullRequestApiError>;
577
578
readonly getPullRequestActivity: (input: {
579
readonly cwd: string;
580
readonly repository: string;
581
readonly host: string;
582
readonly number: number;
595
- }) => Effect.Effect<GitHubPullRequestActivity, GitHubPullRequestCliError>;
583
+ }) => Effect.Effect<GitHubPullRequestActivity, GitHubPullRequestApiError>;
584
585
readonly getPullRequestDiff: (input: {
586
readonly cwd: string;
@@ -603,7 +591,7 @@ export class GitHubPullRequestCli extends Context.Service<
591
readonly cursor?: string | undefined;
592
/** One commit's own changes, rather than everything the pull request carries. */
593
readonly commit?: string | undefined;
606
- }) => Effect.Effect<GitHubPullRequestDiffSlice, GitHubPullRequestCliError>;
594
+ }) => Effect.Effect<GitHubPullRequestDiffSlice, GitHubPullRequestApiError>;
595
596
readonly getPullRequestDiffFileContents: (input: {
597
readonly cwd: string;
@@ -616,7 +604,7 @@ export class GitHubPullRequestCli extends Context.Service<
604
readonly newPath: string;
605
}) => Effect.Effect<
606
{ readonly oldContents: string; readonly newContents: string },
619
- GitHubPullRequestCliError
607
+ GitHubPullRequestApiError
608
>;
609
610
/**
@@ -628,7 +616,7 @@ export class GitHubPullRequestCli extends Context.Service<
616
readonly repository: string;
617
readonly host: string;
618
readonly number: number;
631
- }) => Effect.Effect<GitHubPullRequestFilesViewed, GitHubPullRequestCliError>;
619
+ }) => Effect.Effect<GitHubPullRequestFilesViewed, GitHubPullRequestApiError>;
620
621
/**
622
* Clears files, or puts them back, as one request. GitHub takes a single path per mutation,
@@ -640,14 +628,14 @@ export class GitHubPullRequestCli extends Context.Service<
628
readonly host: string;
629
readonly number: number;
630
readonly files: ReadonlyArray<{ readonly path: string; readonly viewed: boolean }>;
643
- }) => Effect.Effect<void, GitHubPullRequestCliError>;
631
+ }) => Effect.Effect<void, GitHubPullRequestApiError>;
632
633
readonly listReviewThreadComments: (input: {
634
readonly cwd: string;
635
readonly repository: string;
636
readonly host: string;
637
readonly number: number;
650
- }) => Effect.Effect<GitHubReviewThreadComments, GitHubPullRequestCliError>;
638
+ }) => Effect.Effect<GitHubReviewThreadComments, GitHubPullRequestApiError>;
639
640
/** One request for a listing's authors, since no `gh` JSON field reports an avatar. */
641
readonly listActorAvatars: (input: {
@@ -655,7 +643,7 @@ export class GitHubPullRequestCli extends Context.Service<
643
readonly repository: string;
644
readonly host: string;
645
readonly ids: ReadonlyArray<string>;
658
- }) => Effect.Effect<ReadonlyMap<string, string>, GitHubPullRequestCliError>;
646
+ }) => Effect.Effect<ReadonlyMap<string, string>, GitHubPullRequestApiError>;
647
648
readonly getReviewThreadComments: (input: {
649
readonly cwd: string;
@@ -664,7 +652,7 @@ export class GitHubPullRequestCli extends Context.Service<
652
readonly number: number;
653
readonly threadId: string;
654
readonly cursor: string;
667
- }) => Effect.Effect<PullRequestThreadCommentsResult, GitHubPullRequestCliError>;
655
+ }) => Effect.Effect<PullRequestThreadCommentsResult, GitHubPullRequestApiError>;
656
657
/** The viewer's standing on its own, for deciding a write without reading the whole detail. */
658
readonly getViewerAccess: (input: {
@@ -674,7 +662,7 @@ export class GitHubPullRequestCli extends Context.Service<
662
readonly number: number;
663
/** Manual action checks may use the quota held back from automatic reads. */
664
readonly allowReserve?: boolean | undefined;
677
- }) => Effect.Effect<GitHubViewerAccess & GitHubRepositoryAccess, GitHubPullRequestCliError>;
665
+ }) => Effect.Effect<GitHubViewerAccess & GitHubRepositoryAccess, GitHubPullRequestApiError>;
666
667
/** Who this pull request may be sent to, and who it has already been sent to. */
668
readonly listReviewerCandidates: (input: {
@@ -682,7 +670,7 @@ export class GitHubPullRequestCli extends Context.Service<
670
readonly repository: string;
671
readonly host: string;
672
readonly number: number;
685
- }) => Effect.Effect<PullRequestReviewerCandidateList, GitHubPullRequestCliError>;
673
+ }) => Effect.Effect<PullRequestReviewerCandidateList, GitHubPullRequestApiError>;
674
675
readonly setReviewerRequest: (input: {
676
readonly cwd: string;
@@ -695,7 +683,7 @@ export class GitHubPullRequestCli extends Context.Service<
683
}>;
684
/** False deletes the same collection a request posts to, which takes the request back. */
685
readonly requested: boolean;
698
- }) => Effect.Effect<void, GitHubPullRequestCliError>;
686
+ }) => Effect.Effect<void, GitHubPullRequestApiError>;
687
688
/** The repository's labels, and which of them this pull request already wears. */
689
readonly listLabelCandidates: (input: {
@@ -703,7 +691,7 @@ export class GitHubPullRequestCli extends Context.Service<
691
readonly repository: string;
692
readonly host: string;
693
readonly number: number;
706
- }) => Effect.Effect<PullRequestLabelCandidateList, GitHubPullRequestCliError>;
694
+ }) => Effect.Effect<PullRequestLabelCandidateList, GitHubPullRequestApiError>;
695
696
readonly setLabels: (input: {
697
readonly cwd: string;
@@ -713,7 +701,7 @@ export class GitHubPullRequestCli extends Context.Service<
701
readonly labels: ReadonlyArray<string>;
702
/** False takes each label off; true adds each to whatever is already there. */
703
readonly applied: boolean;
716
- }) => Effect.Effect<void, GitHubPullRequestCliError>;
704
+ }) => Effect.Effect<void, GitHubPullRequestApiError>;
705
706
readonly runPullRequestAction: (input: {
707
readonly cwd: string;
@@ -726,7 +714,7 @@ export class GitHubPullRequestCli extends Context.Service<
714
readonly removeAgentCreditsOnMerge?: boolean;
715
readonly mergeMethod?: PullRequestMergeMethod;
716
readonly updateMethod?: PullRequestUpdateMethod;
729
- }) => Effect.Effect<void, GitHubPullRequestCliError>;
717
+ }) => Effect.Effect<void, GitHubPullRequestApiError>;
718
719
readonly commentOnPullRequest: (input: {
720
readonly cwd: string;
@@ -734,7 +722,7 @@ export class GitHubPullRequestCli extends Context.Service<
722
readonly host: string;
723
readonly number: number;
724
readonly body: string;
737
- }) => Effect.Effect<void, GitHubPullRequestCliError>;
725
+ }) => Effect.Effect<void, GitHubPullRequestApiError>;
726
727
readonly submitReview: (input: {
728
readonly cwd: string;
@@ -744,7 +732,7 @@ export class GitHubPullRequestCli extends Context.Service<
732
readonly verdict: PullRequestReviewVerdict;
733
readonly body: string;
734
readonly comments: ReadonlyArray<PullRequestReviewCommentDraft>;
747
- }) => Effect.Effect<void, GitHubPullRequestCliError>;
735
+ }) => Effect.Effect<void, GitHubPullRequestApiError>;
736
737
readonly replyToReviewThread: (input: {
738
readonly cwd: string;
@@ -752,7 +740,7 @@ export class GitHubPullRequestCli extends Context.Service<
740
readonly host: string;
741
readonly threadId: string;
742
readonly body: string;
755
- }) => Effect.Effect<void, GitHubPullRequestCliError>;
743
+ }) => Effect.Effect<void, GitHubPullRequestApiError>;
744
745
readonly setReviewThreadResolution: (input: {
746
readonly cwd: string;
@@ -760,7 +748,7 @@ export class GitHubPullRequestCli extends Context.Service<
748
readonly host: string;
749
readonly threadId: string;
750
readonly resolved: boolean;
763
- }) => Effect.Effect<void, GitHubPullRequestCliError>;
751
+ }) => Effect.Effect<void, GitHubPullRequestApiError>;
752
753
/**
754
* Adds a reaction to a remark, or takes it back. `subjectId` is any node GitHub calls
@@ -776,7 +764,7 @@ export class GitHubPullRequestCli extends Context.Service<
764
readonly subjectId?: string | undefined;
765
readonly content: PullRequestReactionContent;
766
readonly reacted: boolean;
779
- }) => Effect.Effect<void, GitHubPullRequestCliError>;
767
+ }) => Effect.Effect<void, GitHubPullRequestApiError>;
768
769
/** Rewrites the pull request's own words, leaving whichever of the two was not given. */
770
readonly updatePullRequest: (input: {
@@ -786,7 +774,7 @@ export class GitHubPullRequestCli extends Context.Service<
774
readonly number: number;
775
readonly title?: string | undefined;
776
readonly body?: string | undefined;
789
- }) => Effect.Effect<void, GitHubPullRequestCliError>;
777
+ }) => Effect.Effect<void, GitHubPullRequestApiError>;
778
779
/**
780
* Rewrites a remark. `commentId` is trusted to be whatever node it names, so it is confirmed
@@ -801,9 +789,9 @@ export class GitHubPullRequestCli extends Context.Service<
789
readonly commentId: string;
790
readonly kind: "issue-comment" | "review-comment";
791
readonly body: string;
804
- }) => Effect.Effect<void, GitHubPullRequestCliError>;
792
+ }) => Effect.Effect<void, GitHubPullRequestApiError>;
793
}
806
->()("t3/pullRequest/GitHubPullRequestCli") {}
794
+>()("t3/pullRequest/GitHubPullRequestApi") {}
795
796
/**
797
* The GraphQL API takes owner and name as separate arguments, so `owner/repo` is split here.
@@ -1134,10 +1122,9 @@ export const make = Effect.gen(function* () {
1122
}),
1123
),
1124
);
1137
- const captureVerifiedCredential = Effect.fn("GitHubPullRequestCli.captureVerifiedCredential")(
1125
+ const captureVerifiedCredential = Effect.fn("GitHubPullRequestApi.captureVerifiedCredential")(
1126
function* (input: { readonly cwd: string; readonly host: string }) {
1139
- const unavailable = () =>
1140
- new GitHubViewerLoginUnavailableError({ command: "gh", cwd: input.cwd });
1127
+ const unavailable = () => new GitHubViewerLoginUnavailableError({ cwd: input.cwd });
1128
const host = input.host.toLowerCase();
1129
// A missing or signed-out credential keeps its own error, so the page can say which.
1130
const { token, fingerprint: key } = yield* api.credential(host);
@@ -1183,7 +1170,7 @@ export const make = Effect.gen(function* () {
1170
);
1171
},
1172
);
1186
- const withVerifiedCredential: GitHubPullRequestCli["Service"]["withVerifiedCredential"] = (
1173
+ const withVerifiedCredential: GitHubPullRequestApi["Service"]["withVerifiedCredential"] = (
1174
input,
1175
use,
1176
) =>
@@ -1199,7 +1186,7 @@ export const make = Effect.gen(function* () {
1186
),
1187
),
1188
);
1202
- const getRoutingIdentity: GitHubPullRequestCli["Service"]["getRoutingIdentity"] = (input) =>
1189
+ const getRoutingIdentity: GitHubPullRequestApi["Service"]["getRoutingIdentity"] = (input) =>
1190
captureVerifiedCredential(input).pipe(
1191
Effect.map(({ accountId, viewer }) => ({ accountId, viewer })),
1192
);
@@ -1219,7 +1206,7 @@ export const make = Effect.gen(function* () {
1206
readonly host: string;
1207
readonly number: number;
1208
readonly operation: string;
1222
- }): Effect.Effect<string, GitHubPullRequestCliError> => {
1209
+ }): Effect.Effect<string, GitHubPullRequestApiError> => {
1210
const { owner, name } = parseRepositorySelector(input.repository);
1211
const key = `${input.host} ${owner}/${name} ${input.number}`;
1212
const held = nodeIds.get(key);
@@ -1287,7 +1274,7 @@ export const make = Effect.gen(function* () {
1274
}) => api.graphql(input).pipe(Effect.asVoid);
1275
1276
const readError = (cwd: string, operation: string, cause: unknown) =>
1290
- new GitHubPullRequestReadError({ command: "gh", cwd, operation, cause });
1277
+ new GitHubPullRequestReadError({ cwd, operation, cause });
1278
1279
/** Decodes an answer, reporting a failure against the read that made it. */
1280
const decodeWith = <A>(
@@ -1311,7 +1298,7 @@ export const make = Effect.gen(function* () {
1298
readonly variables?: Readonly<Record<string, unknown>>;
1299
readonly query: string;
1300
readonly decode: (raw: string) => Result.Result<A, unknown>;
1314
- }): Effect.Effect<A, GitHubPullRequestCliError> =>
1301
+ }): Effect.Effect<A, GitHubPullRequestApiError> =>
1302
api
1303
.graphql({
1304
host: input.host,
@@ -1329,7 +1316,7 @@ export const make = Effect.gen(function* () {
1316
readonly operation: string;
1317
readonly path: string;
1318
readonly decode: (raw: string) => Result.Result<A, unknown>;
1332
- }): Effect.Effect<A, GitHubPullRequestCliError> =>
1319
+ }): Effect.Effect<A, GitHubPullRequestApiError> =>
1320
api
1321
.rest({ host: input.host, operation: input.operation, path: input.path })
1322
.pipe(
@@ -1355,7 +1342,7 @@ export const make = Effect.gen(function* () {
1342
readonly number: number;
1343
readonly page: number;
1344
readonly commit?: string | undefined;
1358
- }): Effect.Effect<GitHubPullRequestDiffSlice, GitHubPullRequestCliError> => {
1345
+ }): Effect.Effect<GitHubPullRequestDiffSlice, GitHubPullRequestApiError> => {
1346
const { owner, name } = parseRepositorySelector(input.repository);
1347
const paging = `per_page=${DIFF_FILES_PAGE_SIZE}&page=${input.page}`;
1348
return api
@@ -1407,11 +1394,11 @@ export const make = Effect.gen(function* () {
1394
);
1395
};
1396
1410
- const getPullRequestDiffFileContents: GitHubPullRequestCli["Service"]["getPullRequestDiffFileContents"] =
1397
+ const getPullRequestDiffFileContents: GitHubPullRequestApi["Service"]["getPullRequestDiffFileContents"] =
1398
(input) =>
1399
Effect.gen(function* () {
1400
if (input.commit !== undefined && !isCommitSha(input.commit)) {
1414
- return yield* new GitHubDiffCommitError({ command: "gh", cwd: input.cwd });
1401
+ return yield* new GitHubDiffCommitError({ cwd: input.cwd });
1402
}
1403
const { owner, name } = parseRepositorySelector(input.repository);
1404
const refsResponse = yield* api.rest({
@@ -1444,7 +1431,6 @@ export const make = Effect.gen(function* () {
1431
!isCommitSha(headRef)
1432
) {
1433
return yield* new GitHubDiffRevisionsUnavailableError({
1447
- command: "gh",
1434
cwd: input.cwd,
1435
number: input.number,
1436
...(input.commit === undefined ? {} : { commit: input.commit }),
@@ -1469,7 +1455,6 @@ export const make = Effect.gen(function* () {
1455
response.truncated || response.body.includes("\0") || response.invalidUtf8
1456
? Effect.fail(
1457
new GitHubDiffFileContentsUnavailableError({
1472
- command: "gh",
1458
cwd: input.cwd,
1459
path: filePath,
1460
reason: response.truncated ? "oversized" : "binary",
@@ -1497,7 +1482,7 @@ export const make = Effect.gen(function* () {
1482
* mixing two revisions' checks.
1483
*/
1484
const readAllCheckContexts = (
1500
- input: Parameters<GitHubPullRequestCli["Service"]["getPullRequestDetail"]>[0],
1485
+ input: Parameters<GitHubPullRequestApi["Service"]["getPullRequestDetail"]>[0],
1486
allowReserve: boolean,
1487
) =>
1488
Effect.gen(function* () {
@@ -1534,7 +1519,7 @@ export const make = Effect.gen(function* () {
1519
return { headSha, contexts, truncated: after !== null };
1520
});
1521
1537
- const getPullRequestDetail: GitHubPullRequestCli["Service"]["getPullRequestDetail"] = (input) => {
1522
+ const getPullRequestDetail: GitHubPullRequestApi["Service"]["getPullRequestDetail"] = (input) => {
1523
const { owner, name } = parseRepositorySelector(input.repository);
1524
return AllowGitHubReserve.pipe(
1525
Effect.flatMap((allowReserve) =>
@@ -1659,7 +1644,7 @@ export const make = Effect.gen(function* () {
1644
return runs;
1645
});
1646
1662
- const listWorkflowRunsRequiringApproval: GitHubPullRequestCli["Service"]["listWorkflowRunsRequiringApproval"] =
1647
+ const listWorkflowRunsRequiringApproval: GitHubPullRequestApi["Service"]["listWorkflowRunsRequiringApproval"] =
1648
(input) =>
1649
Effect.all(
1650
[
@@ -1681,7 +1666,6 @@ export const make = Effect.gen(function* () {
1666
if (heads.length > workflowApprovalLimit) {
1667
return Effect.fail(
1668
new GitHubWorkflowApprovalRefusedError({
1684
- command: "gh",
1669
cwd: input.cwd,
1670
number: input.number,
1671
reason: "head-list-truncated",
@@ -1693,7 +1677,6 @@ export const make = Effect.gen(function* () {
1677
if (exactHeads.length !== 1 || exactHeads[0]?.number !== input.number) {
1678
return Effect.fail(
1679
new GitHubWorkflowApprovalRefusedError({
1696
- command: "gh",
1680
cwd: input.cwd,
1681
number: input.number,
1682
reason: "head-not-unique",
@@ -1711,7 +1694,6 @@ export const make = Effect.gen(function* () {
1694
runs.length > workflowApprovalLimit
1695
? Effect.fail(
1696
new GitHubWorkflowApprovalRefusedError({
1714
- command: "gh",
1697
cwd: input.cwd,
1698
number: input.number,
1699
reason: "run-list-truncated",
@@ -1830,7 +1812,7 @@ export const make = Effect.gen(function* () {
1812
RequestResolver.setDelay(SUMMARY_BATCH_WINDOW),
1813
RequestResolver.batchN(STAT_ALIASES_PER_REQUEST),
1814
);
1833
- const getPullRequestSummary: GitHubPullRequestCli["Service"]["getPullRequestSummary"] = (input) =>
1815
+ const getPullRequestSummary: GitHubPullRequestApi["Service"]["getPullRequestSummary"] = (input) =>
1816
Effect.request(new PullRequestSummaryRead(input), summaryResolver);
1817
1818
// Every watched pull request on a host in one read per pass. A pull request the batch has no
@@ -1884,10 +1866,10 @@ export const make = Effect.gen(function* () {
1866
RequestResolver.setDelay(SUMMARY_BATCH_WINDOW),
1867
RequestResolver.batchN(STAT_ALIASES_PER_REQUEST),
1868
);
1887
- const getPullRequestWatchFingerprint: GitHubPullRequestCli["Service"]["getPullRequestWatchFingerprint"] =
1869
+ const getPullRequestWatchFingerprint: GitHubPullRequestApi["Service"]["getPullRequestWatchFingerprint"] =
1870
(input) => Effect.request(new PullRequestWatchFingerprintRead(input), watchFingerprintResolver);
1871
1890
- return GitHubPullRequestCli.of({
1872
+ return GitHubPullRequestApi.of({
1873
withVerifiedCredential,
1874
revalidateChecks,
1875
getRoutingIdentity,
@@ -1901,7 +1883,6 @@ export const make = Effect.gen(function* () {
1883
if (query === null) {
1884
return Effect.fail(
1885
new GitHubRepositorySelectorError({
1904
- command: "gh",
1886
cwd: input.cwd,
1887
operation: "listPullRequests",
1888
}),
@@ -1913,7 +1894,7 @@ export const make = Effect.gen(function* () {
1894
page: (
1895
after: string | null,
1896
rows: number,
1916
- ) => Effect.Effect<GitHubPullRequestListPage, GitHubPullRequestCliError>,
1897
+ ) => Effect.Effect<GitHubPullRequestListPage, GitHubPullRequestApiError>,
1898
) =>
1899
Effect.gen(function* () {
1900
const items: GitHubPullRequestListItem[] = [];
@@ -1930,7 +1911,7 @@ export const make = Effect.gen(function* () {
1911
const read = (
1912
continues: boolean,
1913
requestedRows = input.limit + 1,
1933
- ): Effect.Effect<GitHubPullRequestListBatch, GitHubPullRequestCliError> =>
1914
+ ): Effect.Effect<GitHubPullRequestListBatch, GitHubPullRequestApiError> =>
1915
collect(requestedRows, (after, rows) =>
1916
continues
1917
? graphqlRead({
@@ -2047,7 +2028,6 @@ export const make = Effect.gen(function* () {
2028
if (query === null) {
2029
return Effect.fail(
2030
new GitHubRepositorySelectorError({
2050
- command: "gh",
2031
cwd: input.cwd,
2032
operation: "searchPullRequests",
2033
}),
@@ -2085,7 +2065,6 @@ export const make = Effect.gen(function* () {
2065
if (query === null) {
2066
return Effect.fail(
2067
new GitHubRepositorySelectorError({
2088
- command: "gh",
2068
cwd: input.cwd,
2069
operation: "listPullRequestStats",
2070
}),
@@ -2214,14 +2193,14 @@ export const make = Effect.gen(function* () {
2193
...(input.commit === undefined ? {} : { commit: input.commit }),
2194
});
2195
if (input.commit !== undefined && !isCommitSha(input.commit)) {
2217
- return Effect.fail(new GitHubDiffCommitError({ command: "gh", cwd: input.cwd }));
2196
+ return Effect.fail(new GitHubDiffCommitError({ cwd: input.cwd }));
2197
}
2198
// A cursor only ever comes from the files walk, so a reader carrying one is already past
2199
// the point where `gh pr diff` had anything to say.
2200
if (input.cursor !== undefined) {
2201
const page = diffCursorPage(input.cursor);
2202
return page === null
2224
- ? Effect.fail(new GitHubDiffCursorError({ command: "gh", cwd: input.cwd }))
2203
+ ? Effect.fail(new GitHubDiffCursorError({ cwd: input.cwd }))
2204
: filesPage(page);
2205
}
2206
// `gh pr diff` speaks for the whole pull request and has no way to name one commit of it.
@@ -2283,7 +2262,6 @@ export const make = Effect.gen(function* () {
2262
? Effect.succeed({ comments, nextCursor })
2263
: Effect.fail(
2264
new GitHubSubjectScopeError({
2286
- command: "gh",
2265
cwd: input.cwd,
2266
operation: "getReviewThreadComments",
2267
}),
@@ -2297,7 +2275,7 @@ export const make = Effect.gen(function* () {
2275
const { owner, name } = parseRepositorySelector(input.repository);
2276
const threadPage = (
2277
cursor: string | null,
2300
- ): Effect.Effect<GitHubReviewThreadPage, GitHubPullRequestCliError> =>
2278
+ ): Effect.Effect<GitHubReviewThreadPage, GitHubPullRequestApiError> =>
2279
graphqlRead({
2280
cwd: input.cwd,
2281
host: input.host,
@@ -2522,7 +2500,6 @@ export const make = Effect.gen(function* () {
2500
if (detail.headSha == null || detail.headRepositoryOwner == null) {
2501
return Effect.fail(
2502
new GitHubWorkflowApprovalHeadUnavailableError({
2525
- command: "gh",
2503
cwd: input.cwd,
2504
number: input.number,
2505
}),
@@ -2547,7 +2524,6 @@ export const make = Effect.gen(function* () {
2524
if (current.headSha == null || current.headRepositoryOwner == null) {
2525
return Effect.fail(
2526
new GitHubWorkflowApprovalHeadUnavailableError({
2550
- command: "gh",
2527
cwd: input.cwd,
2528
number: input.number,
2529
}),
@@ -2562,7 +2538,6 @@ export const make = Effect.gen(function* () {
2538
) {
2539
return Effect.fail(
2540
new GitHubWorkflowApprovalHeadChangedError({
2565
- command: "gh",
2541
cwd: input.cwd,
2542
number: input.number,
2543
}),
@@ -2737,7 +2712,7 @@ export const make = Effect.gen(function* () {
2712
after: string | null,
2713
collected: ReadonlyArray<PullRequestFileViewed>,
2714
pagesLeft: number,
2740
- ): Effect.Effect<GitHubPullRequestFilesViewed, GitHubPullRequestCliError> =>
2715
+ ): Effect.Effect<GitHubPullRequestFilesViewed, GitHubPullRequestApiError> =>
2716
graphqlRead({
2717
cwd: input.cwd,
2718
host: input.host,
@@ -2799,7 +2774,6 @@ export const make = Effect.gen(function* () {
2774
? Effect.succeed(givenSubjectId)
2775
: Effect.fail(
2776
new GitHubSubjectScopeError({
2802
- command: "gh",
2777
cwd: input.cwd,
2778
operation: "setReaction",
2779
}),
@@ -2850,7 +2824,6 @@ export const make = Effect.gen(function* () {
2824
? Effect.succeed(input.commentId)
2825
: Effect.fail(
2826
new GitHubSubjectScopeError({
2853
- command: "gh",
2827
cwd: input.cwd,
2828
operation: "updateComment",
2829
}),
@@ -2871,4 +2844,4 @@ export const make = Effect.gen(function* () {
2844
});
2845
});
2846
2874
-export const layer = Layer.effect(GitHubPullRequestCli, make);
2847
+export const layer = Layer.effect(GitHubPullRequestApi, make);
apps/server/src/pullRequest/GitHubPullRequestProvider.test.ts
+25
-29
@@ -7,8 +7,8 @@ import type { PullRequestReaction } from "@t3tools/contracts";
7
8
import { decodePullRequestDetailJson } from "./gitHubPullRequestJson.ts";
9
import * as GitHubApi from "../sourceControl/GitHubApi.ts";
10
-import * as GitHubCli from "../sourceControl/GitHubCli.ts";
11
-import * as GitHubPullRequestCli from "./GitHubPullRequestCli.ts";
10
+import * as GitHubRepositoryApi from "../sourceControl/GitHubRepositoryApi.ts";
11
+import * as GitHubPullRequestApi from "./GitHubPullRequestApi.ts";
12
import type { GitHubPullRequestCore } from "./gitHubPullRequestJson.ts";
13
import { gitHubViewerPermissions, loginAvatarUrl, make } from "./GitHubPullRequestProvider.ts";
14
import type { GitHubReviewThreadComments } from "./gitHubPullRequestJson.ts";
@@ -31,13 +31,12 @@ it.effect("maps credential verification failures without relabeling operation fa
31
let operations = 0;
32
const provider = yield* make.pipe(
33
Effect.provide(
34
- Layer.mock(GitHubPullRequestCli.GitHubPullRequestCli)({
34
+ Layer.mock(GitHubPullRequestApi.GitHubPullRequestApi)({
35
revalidateChecks: (_input, read) => read,
36
withVerifiedCredential: (_input, use) =>
37
verificationFails
38
? Effect.fail(
39
- new GitHubPullRequestCli.GitHubViewerLoginUnavailableError({
40
- command: "gh",
39
+ new GitHubPullRequestApi.GitHubViewerLoginUnavailableError({
40
cwd: "/w",
41
}),
42
)
@@ -76,7 +75,7 @@ it.effect("refreshes checks without permissions or comparison reads", () =>
75
);
76
const provider = yield* make.pipe(
77
Effect.provide(
79
- Layer.mock(GitHubPullRequestCli.GitHubPullRequestCli)({
78
+ Layer.mock(GitHubPullRequestApi.GitHubPullRequestApi)({
79
revalidateChecks: (_input, read) => read,
80
getPullRequestDetail: () =>
81
Effect.sync(() => {
@@ -119,7 +118,7 @@ it.effect("uses one narrow read for a linked pull request summary", () =>
118
let summaryReads = 0;
119
const provider = yield* make.pipe(
120
Effect.provide(
122
- Layer.mock(GitHubPullRequestCli.GitHubPullRequestCli)({
121
+ Layer.mock(GitHubPullRequestApi.GitHubPullRequestApi)({
122
revalidateChecks: (_input, read) => read,
123
getPullRequestSummary: () =>
124
Effect.sync(() => {
@@ -169,7 +168,7 @@ it.effect("declares host-native stacks and passes the one the CLI reads through"
168
};
169
const provider = yield* make.pipe(
170
Effect.provide(
172
- Layer.mock(GitHubPullRequestCli.GitHubPullRequestCli)({
171
+ Layer.mock(GitHubPullRequestApi.GitHubPullRequestApi)({
172
revalidateChecks: (_input, read) => read,
173
getPullRequestStack: (input) => Effect.succeed(input.number === 7 ? stack : null),
174
}),
@@ -189,12 +188,11 @@ it.effect("reports a failed stack read against its own operation", () =>
188
Effect.gen(function* () {
189
const provider = yield* make.pipe(
190
Effect.provide(
192
- Layer.mock(GitHubPullRequestCli.GitHubPullRequestCli)({
191
+ Layer.mock(GitHubPullRequestApi.GitHubPullRequestApi)({
192
revalidateChecks: (_input, read) => read,
193
getPullRequestStack: () =>
194
Effect.fail(
196
- new GitHubPullRequestCli.GitHubPullRequestReadError({
197
- command: "gh",
195
+ new GitHubPullRequestApi.GitHubPullRequestReadError({
196
cwd: "/w",
197
operation: "getPullRequestStack",
198
cause: new Error("unreadable"),
@@ -343,7 +341,7 @@ describe("gitHubViewerPermissions", () => {
341
}
342
}).pipe(
343
Effect.provide(
346
- Layer.mock(GitHubPullRequestCli.GitHubPullRequestCli)({
344
+ Layer.mock(GitHubPullRequestApi.GitHubPullRequestApi)({
345
revalidateChecks: (_input, read) => read,
346
getPullRequestDetail: () =>
347
Effect.succeed({
@@ -437,7 +435,7 @@ describe("gitHubViewerPermissions", () => {
435
]);
436
}).pipe(
437
Effect.provide(
440
- Layer.mock(GitHubPullRequestCli.GitHubPullRequestCli)({
438
+ Layer.mock(GitHubPullRequestApi.GitHubPullRequestApi)({
439
revalidateChecks: (_input, read) => read,
440
getPullRequestDetail: () =>
441
Effect.succeed({
@@ -541,7 +539,7 @@ it.effect(
539
Effect.gen(function* () {
540
const provider = yield* make.pipe(
541
Effect.provide(
544
- Layer.mock(GitHubPullRequestCli.GitHubPullRequestCli)({
542
+ Layer.mock(GitHubPullRequestApi.GitHubPullRequestApi)({
543
getPullRequestDetail: () =>
544
Effect.succeed({ ...openDetail, comparison: { behindBy: 2, viewerCanUpdate: true } }),
545
listWorkflowRunsRequiringApproval: () =>
@@ -582,7 +580,7 @@ it.effect("does not classify same-repository gates as fork workflow approvals",
580
expect(detail.checks).toEqual([]);
581
}).pipe(
582
Effect.provide(
585
- Layer.mock(GitHubPullRequestCli.GitHubPullRequestCli)({
583
+ Layer.mock(GitHubPullRequestApi.GitHubPullRequestApi)({
584
revalidateChecks: (_input, read) => read,
585
getPullRequestDetail: () => Effect.succeed({ ...openDetail, isCrossRepository: false }),
586
listWorkflowRunsRequiringApproval: () =>
@@ -621,13 +619,12 @@ it.effect("keeps an unsafe workflow approval scope visible as unknown", () =>
619
]);
620
}).pipe(
621
Effect.provide(
624
- Layer.mock(GitHubPullRequestCli.GitHubPullRequestCli)({
622
+ Layer.mock(GitHubPullRequestApi.GitHubPullRequestApi)({
623
revalidateChecks: (_input, read) => read,
624
getPullRequestDetail: () => Effect.succeed(openDetail),
625
listWorkflowRunsRequiringApproval: () =>
626
Effect.fail(
629
- new GitHubPullRequestCli.GitHubWorkflowApprovalRefusedError({
630
- command: "gh",
627
+ new GitHubPullRequestApi.GitHubWorkflowApprovalRefusedError({
628
cwd: "/w",
629
number: 7,
630
reason: "head-not-unique",
@@ -664,7 +661,7 @@ it.effect("propagates workflow discovery rate limits", () =>
661
expect(error.reason).toBe("rate-limited");
662
}).pipe(
663
Effect.provide(
667
- Layer.mock(GitHubPullRequestCli.GitHubPullRequestCli)({
664
+ Layer.mock(GitHubPullRequestApi.GitHubPullRequestApi)({
665
revalidateChecks: (_input, read) => read,
666
getPullRequestDetail: () => Effect.succeed(openDetail),
667
listWorkflowRunsRequiringApproval: () =>
@@ -713,7 +710,7 @@ describe("getViewerPermissions", () => {
710
expect(permissions.actions).not.toContain("update-branch");
711
}).pipe(
712
Effect.provide(
716
- Layer.mock(GitHubPullRequestCli.GitHubPullRequestCli)({
713
+ Layer.mock(GitHubPullRequestApi.GitHubPullRequestApi)({
714
revalidateChecks: (_input, read) => read,
715
getPullRequestDetail: () => Effect.die("Unexpected detail read"),
716
getViewerAccess: () => Effect.sync(() => (accessReads++, access)),
@@ -723,13 +720,13 @@ describe("getViewerPermissions", () => {
720
});
721
722
const layerWithDetail = (
726
- detail: Effect.Effect<GitHubPullRequestCore, GitHubPullRequestCli.GitHubPullRequestCliError>,
723
+ detail: Effect.Effect<GitHubPullRequestCore, GitHubPullRequestApi.GitHubPullRequestApiError>,
724
onDetail: (allowReserve: boolean) => void = () => {},
725
) =>
729
- Layer.mock(GitHubPullRequestCli.GitHubPullRequestCli)({
726
+ Layer.mock(GitHubPullRequestApi.GitHubPullRequestApi)({
727
revalidateChecks: (_input, read) => read,
728
getPullRequestDetail: () =>
732
- GitHubCli.AllowGitHubReserve.pipe(
729
+ GitHubRepositoryApi.AllowGitHubReserve.pipe(
730
Effect.tap((allowReserve) => Effect.sync(() => onDetail(allowReserve))),
731
Effect.flatMap(() => detail),
732
),
@@ -789,12 +786,11 @@ describe("getViewerPermissions", () => {
786
expect(permissions.actions).not.toContain("update-branch");
787
}).pipe(
788
Effect.provide(
792
- Layer.mock(GitHubPullRequestCli.GitHubPullRequestCli)({
789
+ Layer.mock(GitHubPullRequestApi.GitHubPullRequestApi)({
790
revalidateChecks: (_input, read) => read,
791
getPullRequestDetail: () =>
792
Effect.fail(
796
- new GitHubPullRequestCli.GitHubPullRequestReadError({
797
- command: "gh",
793
+ new GitHubPullRequestApi.GitHubPullRequestReadError({
794
cwd: "/w",
795
operation: "getPullRequestDetail",
796
cause: new Error("head changed"),
@@ -869,7 +865,7 @@ describe("getChangeRequest commits", () => {
865
};
866
867
const layerWith = (commits: GitHubReviewThreadComments["commits"]) =>
872
- Layer.mock(GitHubPullRequestCli.GitHubPullRequestCli)({
868
+ Layer.mock(GitHubPullRequestApi.GitHubPullRequestApi)({
869
revalidateChecks: (_input, read) => read,
870
getPullRequestActivity: () =>
871
Effect.succeed({
@@ -956,7 +952,7 @@ describe("getChangeRequestActivity dismissed reviews", () => {
952
viewer: { canUpdate: true, didAuthor: false },
953
};
954
const layerFor = (body: string) =>
959
- Layer.mock(GitHubPullRequestCli.GitHubPullRequestCli)({
955
+ Layer.mock(GitHubPullRequestApi.GitHubPullRequestApi)({
956
revalidateChecks: (_input, read) => read,
957
getPullRequestActivity: () =>
958
Effect.succeed({ author: null, comments: [dismissedReview(body)], commits: [] }),
@@ -1040,7 +1036,7 @@ describe("editing", () => {
1036
]);
1037
}).pipe(
1038
Effect.provide(
1043
- Layer.mock(GitHubPullRequestCli.GitHubPullRequestCli)({
1039
+ Layer.mock(GitHubPullRequestApi.GitHubPullRequestApi)({
1040
revalidateChecks: (_input, read) => read,
1041
updatePullRequest: (input) => Effect.sync(() => void rewrites.push(input)),
1042
updateComment: (input) => Effect.sync(() => void rewrites.push(input)),
apps/server/src/pullRequest/GitHubPullRequestProvider.ts
+6
-6
@@ -7,8 +7,8 @@ import type {
7
PullRequestViewerPermissions,
8
} from "@t3tools/contracts";
9
10
-import * as GitHubCli from "../sourceControl/GitHubCli.ts";
11
-import * as GitHubPullRequestCli from "./GitHubPullRequestCli.ts";
10
+import * as GitHubRepositoryApi from "../sourceControl/GitHubRepositoryApi.ts";
11
+import * as GitHubPullRequestApi from "./GitHubPullRequestApi.ts";
12
import {
13
PullRequestProviderError,
14
type PullRequestProviderFailure,
@@ -104,7 +104,7 @@ export function gitHubViewerPermissions(access: GitHubViewerAccess): PullRequest
104
105
/** The tags that mean GitHub is out of reach for this account, rather than one request failing. */
106
export function gitHubProviderFailure(
107
- error: GitHubPullRequestCli.GitHubPullRequestCliError,
107
+ error: GitHubPullRequestApi.GitHubPullRequestApiError,
108
): PullRequestProviderFailure {
109
switch (error._tag) {
110
case "GitHubCliMissingError":
@@ -197,9 +197,9 @@ const rendersEmpty = (body: string): boolean =>
197
body.replace(/<!--[\s\S]*?-->/g, "").trim().length === 0;
198
199
export const make = Effect.gen(function* () {
200
- const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
200
+ const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
201
202
- const fail = (operation: string) => (error: GitHubPullRequestCli.GitHubPullRequestCliError) =>
202
+ const fail = (operation: string) => (error: GitHubPullRequestApi.GitHubPullRequestApiError) =>
203
new PullRequestProviderError({
204
provider: "github",
205
operation,
@@ -526,7 +526,7 @@ export const make = Effect.gen(function* () {
526
// comparison, so one read usually answers what used to take three. When that heavier read
527
// fails, the light access read still answers, withholding only update-branch.
528
return cli.getPullRequestDetail(input).pipe(
529
- Effect.provideService(GitHubCli.AllowGitHubReserve, true),
529
+ Effect.provideService(GitHubRepositoryApi.AllowGitHubReserve, true),
530
Effect.map((pullRequest) =>
531
gitHubViewerPermissions({
532
...pullRequest.viewerAccess,
apps/server/src/pullRequest/PullRequestProviderRegistry.ts
+3
-3
@@ -16,7 +16,7 @@ import * as AzureDevOpsPullRequestCli from "./AzureDevOpsPullRequestCli.ts";
16
import * as AzureDevOpsPullRequestProvider from "./AzureDevOpsPullRequestProvider.ts";
17
import * as BitbucketPullRequestApi from "./BitbucketPullRequestApi.ts";
18
import * as BitbucketPullRequestProvider from "./BitbucketPullRequestProvider.ts";
19
-import * as GitHubPullRequestCli from "./GitHubPullRequestCli.ts";
19
+import * as GitHubPullRequestApi from "./GitHubPullRequestApi.ts";
20
import * as GitHubPullRequestProvider from "./GitHubPullRequestProvider.ts";
21
import * as GitLabPullRequestCli from "./GitLabPullRequestCli.ts";
22
import * as GitLabPullRequestProvider from "./GitLabPullRequestProvider.ts";
@@ -61,11 +61,11 @@ export const make = Effect.map(
61
62
export const layer = Layer.effect(PullRequestProviderRegistry, make).pipe(
63
Layer.provide(
64
- GitHubPullRequestCli.layer.pipe(
64
+ GitHubPullRequestApi.layer.pipe(
65
Layer.provide(
66
GitHubApi.layer.pipe(
67
Layer.provide(GitHubCredentials.layer),
68
- // The same layers GitHubCli merges, so both share one budget and one pause per host.
68
+ // The same layers GitHubRepositoryApi merges, so both share one budget and one pause per host.
69
Layer.provide(GitHubGraphQlBudget.layer),
70
Layer.provide(SourceControlRateLimit.layer),
71
),
apps/server/src/pullRequest/PullRequestService.ts
+1
-1
@@ -77,7 +77,7 @@ import {
77
import { resolveProjectSettings } from "@t3tools/shared/projectSettings";
78
import { detectSourceControlProviderFromRemoteUrl } from "@t3tools/shared/sourceControl";
79
80
-import { AllowGitHubReserve } from "../sourceControl/GitHubCli.ts";
80
+import { AllowGitHubReserve } from "../sourceControl/GitHubRepositoryApi.ts";
81
import * as ProjectService from "../project/ProjectService.ts";
82
import * as ServerSettings from "../serverSettings.ts";
83
import * as PullRequestFilesViewed from "../persistence/PullRequestFilesViewed.ts";
apps/server/src/pullRequest/gitHubConditionalChecks.ts
+2
-2
@@ -9,7 +9,7 @@ import { PositiveInt, type PullRequestChecks } from "@t3tools/contracts";
9
10
import * as GitHubApi from "../sourceControl/GitHubApi.ts";
11
import type { GitHubPullRequestDetail } from "./gitHubPullRequestJson.ts";
12
-import type { GitHubPullRequestCliError } from "./GitHubPullRequestCli.ts";
12
+import type { GitHubPullRequestApiError } from "./GitHubPullRequestApi.ts";
13
import type { ProviderRepositoryRef } from "./PullRequestProvider.ts";
14
15
const HeadSchema = Schema.Struct({
@@ -70,7 +70,7 @@ export const makeChecksRevalidator = Effect.gen(function* () {
70
Pick<GitHubPullRequestDetail, "state" | "checks" | "headSha"> & {
71
workflowApprovalsRequired?: number;
72
},
73
- GitHubPullRequestCliError
73
+ GitHubPullRequestApiError
74
>,
75
) =>
76
Effect.gen(function* () {
apps/server/src/server.ts
+3
-3
@@ -50,7 +50,7 @@ import * as CheckpointDiffQuery from "./checkpointing/CheckpointDiffQuery.ts";
50
import * as CheckpointStore from "./checkpointing/CheckpointStore.ts";
51
import * as AzureDevOpsCli from "./sourceControl/AzureDevOpsCli.ts";
52
import * as BitbucketApi from "./sourceControl/BitbucketApi.ts";
53
-import * as GitHubCli from "./sourceControl/GitHubCli.ts";
53
+import * as GitHubRepositoryApi from "./sourceControl/GitHubRepositoryApi.ts";
54
import * as GitLabCli from "./sourceControl/GitLabCli.ts";
55
import * as ForgejoCli from "./sourceControl/ForgejoCli.ts";
56
import * as TextGeneration from "./textGeneration/TextGeneration.ts";
@@ -270,7 +270,7 @@ const layerSourceControlProviderRegistry = SourceControlProviderRegistry.layer.p
270
Layer.mergeAll(
271
AzureDevOpsCli.layer,
272
BitbucketApi.layer,
273
- GitHubCli.layer,
273
+ GitHubRepositoryApi.layer,
274
GitLabCli.layer,
275
ForgejoCli.layer,
276
),
@@ -565,7 +565,7 @@ const layerRuntimeCoreDependenciesBase = Layer.mergeAll(
565
Layer.provideMerge(layerServerSettings),
566
// The asset route uses the registry's GitHub credential for private PR media.
567
Layer.provideMerge(layerSourceControlProviderRegistry),
568
- Layer.provideMerge(GitHubCli.layer),
568
+ Layer.provideMerge(GitHubRepositoryApi.layer),
569
Layer.provideMerge(layerGit),
570
Layer.provideMerge(layerVcs),
571
Layer.provideMerge(Layer.mergeAll(layerTerminal, layerPreview, layerDevice)),
apps/server/src/sourceControl/GitHubRepositoryApi.test.ts
renamed
+35
-29
@@ -11,7 +11,7 @@ import { ChildProcessSpawner } from "effect/process";
11
import * as GitVcsDriver from "../vcs/GitVcsDriver.ts";
12
import * as VcsProcess from "../vcs/VcsProcess.ts";
13
import * as GitHubApi from "./GitHubApi.ts";
14
-import * as GitHubCli from "./GitHubCli.ts";
14
+import * as GitHubRepositoryApi from "./GitHubRepositoryApi.ts";
15
import * as GitHubCredentials from "./GitHubCredentials.ts";
16
17
const encodeJson = Schema.encodeSync(Schema.fromJsonString(Schema.Unknown));
@@ -51,7 +51,7 @@ const node = (number: number, headRefName: string, owner = "acme") => ({
51
});
52
53
/**
54
- * A GitHubCli over a mocked GitHubApi, git driver and process. `remotes` is what
54
+ * A GitHubRepositoryApi over a mocked GitHubApi, git driver and process. `remotes` is what
55
* `git remote -v` prints; `git` records every driver call.
56
*/
57
function harness(input: {
@@ -92,7 +92,10 @@ function harness(input: {
92
args.args[0] === "remote" ? processOutput(input.remotes) : processOutput("", 1),
93
),
94
});
95
- const layer = Layer.effect(GitHubCli.GitHubCli, GitHubCli.make).pipe(
95
+ const layer = Layer.effect(
96
+ GitHubRepositoryApi.GitHubRepositoryApi,
97
+ GitHubRepositoryApi.make,
98
+ ).pipe(
99
Layer.provide(
100
Layer.mergeAll(
101
driver,
@@ -111,7 +114,7 @@ describe("selectGitHubBaseRepository", () => {
114
.flatMap(([name, url]) => [`${name}\t${url} (fetch)`, `${name}\t${url} (push)`])
115
.join("\n");
116
const select = (input: { remotes: string; resolved?: string }) =>
114
- GitHubCli.selectGitHubBaseRepository({ resolved: "", host: "github.com", ...input });
117
+ GitHubRepositoryApi.selectGitHubBaseRepository({ resolved: "", host: "github.com", ...input });
118
119
it("picks the repository gh reads without a prompt", () => {
120
assert.deepStrictEqual(select({ remotes: remotes(["fork", "git@github.com:me/web.git"]) }), {
@@ -175,7 +178,7 @@ describe("selectGitHubBaseRepository", () => {
178
});
179
});
180
178
-describe("GitHubCli repository resolution", () => {
181
+describe("GitHubRepositoryApi repository resolution", () => {
182
it.effect("reads the repository gh would pick from the remotes", () => {
183
const paths: string[] = [];
184
const { layer } = harness({
@@ -197,7 +200,7 @@ describe("GitHubCli repository resolution", () => {
200
},
201
});
202
return Effect.gen(function* () {
200
- const gh = yield* GitHubCli.GitHubCli;
203
+ const gh = yield* GitHubRepositoryApi.GitHubRepositoryApi;
204
assert.strictEqual(yield* gh.getDefaultBranch({ cwd: "/repo" }), "trunk");
205
assert.deepStrictEqual(paths, ["github.com repos/acme/web"]);
206
}).pipe(Effect.provide(layer));
@@ -221,16 +224,19 @@ describe("GitHubCli repository resolution", () => {
224
},
225
});
226
return Effect.gen(function* () {
224
- const gh = yield* GitHubCli.GitHubCli;
227
+ const gh = yield* GitHubRepositoryApi.GitHubRepositoryApi;
228
yield* gh.getDefaultBranch({ cwd: "/repo" });
229
// A provider's host hint for the same alias (`github` here) resolves the same way.
230
yield* gh.getDefaultBranch({ cwd: "/repo", rateLimitHost: "github" });
231
assert.deepStrictEqual(hosts, ["github.com repos/acme/web", "github.com repos/acme/web"]);
232
assert.strictEqual(
230
- GitHubCli.gitHubApiHostForRemote("git@github.example.com:a/b.git"),
233
+ GitHubRepositoryApi.gitHubApiHostForRemote("git@github.example.com:a/b.git"),
234
"github.example.com",
235
);
233
- assert.strictEqual(GitHubCli.gitHubApiHostForRemote("git@gitlab.com:a/b.git"), null);
236
+ assert.strictEqual(
237
+ GitHubRepositoryApi.gitHubApiHostForRemote("git@gitlab.com:a/b.git"),
238
+ null,
239
+ );
240
}).pipe(Effect.provide(layer));
241
});
242
@@ -240,15 +246,15 @@ describe("GitHubCli repository resolution", () => {
246
api: {},
247
});
248
return Effect.gen(function* () {
243
- const gh = yield* GitHubCli.GitHubCli;
249
+ const gh = yield* GitHubRepositoryApi.GitHubRepositoryApi;
250
const error = yield* gh.getDefaultBranch({ cwd: "/repo" }).pipe(Effect.flip);
245
- assert.strictEqual(error._tag, "GitHubCliCommandError");
251
+ assert.strictEqual(error._tag, "GitHubRepositoryCommandError");
252
assert.include(String((error.cause as Error).message), "No GitHub repository");
253
}).pipe(Effect.provide(layer));
254
});
255
});
256
251
-describe("GitHubCli.listPullRequestsByHead", () => {
257
+describe("GitHubRepositoryApi.listPullRequestsByHead", () => {
258
const remotes = remotesOutput(["origin", "git@github.com:acme/web.git"]);
259
260
it.effect("reads a background sweep's staggered heads in one GraphQL document", () => {
@@ -271,7 +277,7 @@ describe("GitHubCli.listPullRequestsByHead", () => {
277
},
278
});
279
return Effect.gen(function* () {
274
- const gh = yield* GitHubCli.GitHubCli;
280
+ const gh = yield* GitHubRepositoryApi.GitHubRepositoryApi;
281
const lookup = (headSelector: string) =>
282
gh
283
.listPullRequestsByHead({
@@ -324,7 +330,7 @@ describe("GitHubCli.listPullRequestsByHead", () => {
330
},
331
});
332
return Effect.gen(function* () {
327
- const gh = yield* GitHubCli.GitHubCli;
333
+ const gh = yield* GitHubRepositoryApi.GitHubRepositoryApi;
334
const lookups = yield* Effect.all(
335
Array.from({ length: 26 }, (_, index) =>
336
gh.listPullRequestsByHead({
@@ -368,7 +374,7 @@ describe("GitHubCli.listPullRequestsByHead", () => {
374
},
375
});
376
return Effect.gen(function* () {
371
- const gh = yield* GitHubCli.GitHubCli;
377
+ const gh = yield* GitHubRepositoryApi.GitHubRepositoryApi;
378
const open = yield* gh
379
.listOpenPullRequests({ cwd: "/repo", headSelector: "me:main", limit: 1 })
380
.pipe(Effect.forkChild);
@@ -397,24 +403,24 @@ describe("GitHubCli.listPullRequestsByHead", () => {
403
},
404
});
405
return Effect.gen(function* () {
400
- const gh = yield* GitHubCli.GitHubCli;
406
+ const gh = yield* GitHubRepositoryApi.GitHubRepositoryApi;
407
const read = (headSelector: string) =>
408
gh
409
.listPullRequestsByHead({ cwd: "/repo", headSelector, state: "open", limit: 1 })
410
.pipe(Effect.flip, Effect.forkChild);
411
const missing = yield* read("missing");
412
yield* TestClock.adjust("500 millis");
407
- assert.strictEqual((yield* Fiber.join(missing))._tag, "GitHubCliUnavailableError");
413
+ assert.strictEqual((yield* Fiber.join(missing))._tag, "GitHubRepositoryUnavailableError");
414
const limited = yield* read("limited");
415
yield* TestClock.adjust("500 millis");
416
const error = yield* Fiber.join(limited);
411
- assert.strictEqual(error._tag, "GitHubCliRateLimitError");
417
+ assert.strictEqual(error._tag, "GitHubRepositoryRateLimitError");
418
assert.propertyVal(error, "retryAt", 123);
419
}).pipe(Effect.provide(layer));
420
});
421
});
422
417
-describe("GitHubCli.getPullRequest", () => {
423
+describe("GitHubRepositoryApi.getPullRequest", () => {
424
it.effect("reads a pull request by number, and by URL on its own repository", () => {
425
const variables: Array<unknown> = [];
426
const { layer } = harness({
@@ -428,7 +434,7 @@ describe("GitHubCli.getPullRequest", () => {
434
},
435
});
436
return Effect.gen(function* () {
431
- const gh = yield* GitHubCli.GitHubCli;
437
+ const gh = yield* GitHubRepositoryApi.GitHubRepositoryApi;
438
assert.strictEqual((yield* gh.getPullRequest({ cwd: "/repo", reference: "#42" })).number, 42);
439
yield* gh.getPullRequest({
440
cwd: "/repo",
@@ -449,14 +455,14 @@ describe("GitHubCli.getPullRequest", () => {
455
},
456
});
457
return Effect.gen(function* () {
452
- const gh = yield* GitHubCli.GitHubCli;
458
+ const gh = yield* GitHubRepositoryApi.GitHubRepositoryApi;
459
const error = yield* gh.getPullRequest({ cwd: "/repo", reference: "7" }).pipe(Effect.flip);
460
assert.strictEqual(error._tag, "GitHubPullRequestNotFoundError");
461
}).pipe(Effect.provide(layer));
462
});
463
});
464
459
-describe("GitHubCli writes", () => {
465
+describe("GitHubRepositoryApi writes", () => {
466
it.effect("creates a cross-repository pull request with an owner:branch head", () => {
467
const requests: Array<GitHubApi.GitHubRestInput> = [];
468
const { layer } = harness({
@@ -476,7 +482,7 @@ describe("GitHubCli writes", () => {
482
const fs = yield* FileSystem.FileSystem;
483
const bodyFile = yield* fs.makeTempFileScoped({ suffix: ".md" });
484
yield* fs.writeFileString(bodyFile, "Body");
479
- const gh = yield* GitHubCli.GitHubCli;
485
+ const gh = yield* GitHubRepositoryApi.GitHubRepositoryApi;
486
yield* gh.createPullRequest({
487
cwd: "/repo",
488
baseBranch: "main",
@@ -515,7 +521,7 @@ describe("GitHubCli writes", () => {
521
},
522
});
523
return Effect.gen(function* () {
518
- const gh = yield* GitHubCli.GitHubCli;
524
+ const gh = yield* GitHubRepositoryApi.GitHubRepositoryApi;
525
const urls = yield* gh.createRepository({
526
cwd: "/repo",
527
repository: "acme/new",
@@ -531,7 +537,7 @@ describe("GitHubCli writes", () => {
537
});
538
});
539
534
-describe("GitHubCli.checkoutPullRequest", () => {
540
+describe("GitHubRepositoryApi.checkoutPullRequest", () => {
541
const repository = (fullName: string, defaultBranch = "main") =>
542
restResponse({
543
full_name: fullName,
@@ -551,7 +557,7 @@ describe("GitHubCli.checkoutPullRequest", () => {
557
},
558
});
559
return Effect.gen(function* () {
554
- const gh = yield* GitHubCli.GitHubCli;
560
+ const gh = yield* GitHubRepositoryApi.GitHubRepositoryApi;
561
yield* gh.checkoutPullRequest({ cwd: "/repo", reference: "5" });
562
assert.deepStrictEqual(git, [
563
[
@@ -588,7 +594,7 @@ describe("GitHubCli.checkoutPullRequest", () => {
594
},
595
});
596
return Effect.gen(function* () {
591
- const gh = yield* GitHubCli.GitHubCli;
597
+ const gh = yield* GitHubRepositoryApi.GitHubRepositoryApi;
598
yield* Effect.flip(gh.checkoutPullRequest({ cwd: "/repo", reference: "6", force: true }));
599
// Nothing touched the local branches: `main` must not be reset to the fork's commit.
600
assert.deepStrictEqual(git, []);
@@ -609,7 +615,7 @@ describe("GitHubCli.checkoutPullRequest", () => {
615
},
616
});
617
return Effect.gen(function* () {
612
- const gh = yield* GitHubCli.GitHubCli;
618
+ const gh = yield* GitHubRepositoryApi.GitHubRepositoryApi;
619
yield* gh.checkoutPullRequest({ cwd: "/repo", reference: "6", force: true });
620
assert.deepStrictEqual(git, [
621
[
@@ -632,7 +638,7 @@ describe("GitHubCli.checkoutPullRequest", () => {
638
639
it("names the local branch the way gh pr checkout does", () => {
640
const name = (headRefName: string, isCrossRepository: boolean) =>
635
- GitHubCli.pullRequestCheckoutBranchName({
641
+ GitHubRepositoryApi.pullRequestCheckoutBranchName({
642
headRefName,
643
headOwner: "someone",
644
isCrossRepository,
apps/server/src/sourceControl/GitHubRepositoryApi.ts
renamed
+68
-73
@@ -33,24 +33,23 @@ import {
33
34
export const AllowGitHubReserve = GitHubApi.AllowGitHubReserve;
35
36
-const gitHubCliFailureFields = {
37
- command: Schema.Literal("gh"),
36
+const gitHubFailureFields = {
37
cwd: Schema.String,
38
cause: Schema.Defect(),
39
} as const;
40
42
-export class GitHubCliUnavailableError extends Schema.TaggedError<GitHubCliUnavailableError>()(
43
- "GitHubCliUnavailableError",
44
- gitHubCliFailureFields,
41
+export class GitHubRepositoryUnavailableError extends Schema.TaggedError<GitHubRepositoryUnavailableError>()(
42
+ "GitHubRepositoryUnavailableError",
43
+ gitHubFailureFields,
44
) {
45
override get message(): string {
46
return "No GitHub credential on the server. Set GH_TOKEN, or install the GitHub CLI and run `gh auth login`.";
47
}
48
}
49
51
-export class GitHubCliAuthenticationError extends Schema.TaggedError<GitHubCliAuthenticationError>()(
52
- "GitHubCliAuthenticationError",
53
- gitHubCliFailureFields,
50
+export class GitHubRepositoryAuthenticationError extends Schema.TaggedError<GitHubRepositoryAuthenticationError>()(
51
+ "GitHubRepositoryAuthenticationError",
52
+ gitHubFailureFields,
53
) {
54
override get message(): string {
55
// A missing or turned-off credential already says what to do about it.
@@ -60,9 +59,9 @@ export class GitHubCliAuthenticationError extends Schema.TaggedError<GitHubCliAu
59
}
60
}
61
63
-export class GitHubCliRateLimitError extends Schema.TaggedError<GitHubCliRateLimitError>()(
64
- "GitHubCliRateLimitError",
65
- { ...gitHubCliFailureFields, retryAt: Schema.optionalKey(Schema.Finite) },
62
+export class GitHubRepositoryRateLimitError extends Schema.TaggedError<GitHubRepositoryRateLimitError>()(
63
+ "GitHubRepositoryRateLimitError",
64
+ { ...gitHubFailureFields, retryAt: Schema.optionalKey(Schema.Finite) },
65
) {
66
override get message(): string {
67
return "GitHub API rate limit exceeded. Requests resume when the limit resets.";
@@ -71,16 +70,16 @@ export class GitHubCliRateLimitError extends Schema.TaggedError<GitHubCliRateLim
70
71
export class GitHubPullRequestNotFoundError extends Schema.TaggedError<GitHubPullRequestNotFoundError>()(
72
"GitHubPullRequestNotFoundError",
74
- gitHubCliFailureFields,
73
+ gitHubFailureFields,
74
) {
75
override get message(): string {
76
return "Pull request not found. Check the PR number or URL and try again.";
77
}
78
}
79
81
-export class GitHubCliCommandError extends Schema.TaggedError<GitHubCliCommandError>()(
82
- "GitHubCliCommandError",
83
- { ...gitHubCliFailureFields, httpStatus: Schema.optional(Schema.Int) },
80
+export class GitHubRepositoryCommandError extends Schema.TaggedError<GitHubRepositoryCommandError>()(
81
+ "GitHubRepositoryCommandError",
82
+ { ...gitHubFailureFields, httpStatus: Schema.optional(Schema.Int) },
83
) {
84
override get message(): string {
85
// GitHub's own reason ("A pull request already exists…") or the failed step's, when known.
@@ -92,15 +91,14 @@ export class GitHubCliCommandError extends Schema.TaggedError<GitHubCliCommandEr
91
}
92
}
93
95
-const gitHubCliDecodeFields = {
96
- command: Schema.Literal("gh"),
94
+const gitHubDecodeFields = {
95
cwd: Schema.String,
96
cause: Schema.Defect(),
97
} as const;
98
99
export class GitHubPullRequestListDecodeError extends Schema.TaggedError<GitHubPullRequestListDecodeError>()(
100
"GitHubPullRequestListDecodeError",
103
- gitHubCliDecodeFields,
101
+ gitHubDecodeFields,
102
) {
103
override get message(): string {
104
return "GitHub returned an invalid pull request list.";
@@ -109,7 +107,7 @@ export class GitHubPullRequestListDecodeError extends Schema.TaggedError<GitHubP
107
108
export class GitHubChangeRequestListDecodeError extends Schema.TaggedError<GitHubChangeRequestListDecodeError>()(
109
"GitHubChangeRequestListDecodeError",
112
- gitHubCliDecodeFields,
110
+ gitHubDecodeFields,
111
) {
112
override get message(): string {
113
return "GitHub returned an invalid change request list.";
@@ -118,7 +116,7 @@ export class GitHubChangeRequestListDecodeError extends Schema.TaggedError<GitHu
116
117
export class GitHubPullRequestDecodeError extends Schema.TaggedError<GitHubPullRequestDecodeError>()(
118
"GitHubPullRequestDecodeError",
121
- gitHubCliDecodeFields,
119
+ gitHubDecodeFields,
120
) {
121
override get message(): string {
122
return "GitHub returned an invalid pull request.";
@@ -127,53 +125,56 @@ export class GitHubPullRequestDecodeError extends Schema.TaggedError<GitHubPullR
125
126
export class GitHubRepositoryDecodeError extends Schema.TaggedError<GitHubRepositoryDecodeError>()(
127
"GitHubRepositoryDecodeError",
130
- gitHubCliDecodeFields,
128
+ gitHubDecodeFields,
129
) {
130
override get message(): string {
131
return "GitHub returned an invalid repository.";
132
}
133
}
134
137
-export const GitHubCliError = Schema.Union([
138
- GitHubCliUnavailableError,
139
- GitHubCliAuthenticationError,
140
- GitHubCliRateLimitError,
135
+export const GitHubRepositoryApiError = Schema.Union([
136
+ GitHubRepositoryUnavailableError,
137
+ GitHubRepositoryAuthenticationError,
138
+ GitHubRepositoryRateLimitError,
139
GitHubPullRequestNotFoundError,
142
- GitHubCliCommandError,
140
+ GitHubRepositoryCommandError,
141
GitHubPullRequestListDecodeError,
142
GitHubChangeRequestListDecodeError,
143
GitHubPullRequestDecodeError,
144
GitHubRepositoryDecodeError,
145
]);
148
-export type GitHubCliError = typeof GitHubCliError.Type;
146
+export type GitHubRepositoryApiError = typeof GitHubRepositoryApiError.Type;
147
150
-export const isGitHubCliError = Schema.is(GitHubCliError);
148
+export const isGitHubRepositoryApiError = Schema.is(GitHubRepositoryApiError);
149
150
/** Maps a GitHub API failure onto the errors callers of this service already handle. */
153
-function fromGitHubApiError(cwd: string, error: GitHubApi.GitHubApiError): GitHubCliError {
154
- const context = { command: "gh" as const, cwd, cause: error };
151
+function fromGitHubApiError(
152
+ cwd: string,
153
+ error: GitHubApi.GitHubApiError,
154
+): GitHubRepositoryApiError {
155
+ const context = { cwd, cause: error };
156
switch (error._tag) {
157
case "GitHubCliMissingError":
157
- return new GitHubCliUnavailableError(context);
158
+ return new GitHubRepositoryUnavailableError(context);
159
case "GitHubNotSignedInError":
160
case "GitHubHostDisabledError":
161
case "GitHubApiAuthenticationError":
161
- return new GitHubCliAuthenticationError(context);
162
+ return new GitHubRepositoryAuthenticationError(context);
163
case "GitHubCliFailedError":
163
- return new GitHubCliCommandError(context);
164
+ return new GitHubRepositoryCommandError(context);
165
case "GitHubApiRateLimitError":
165
- return new GitHubCliRateLimitError({
166
+ return new GitHubRepositoryRateLimitError({
167
...context,
168
...(error.retryAt === undefined ? {} : { retryAt: error.retryAt }),
169
});
170
case "SourceControlRateLimitPausedError":
170
- return new GitHubCliRateLimitError({ ...context, retryAt: error.retryAt });
171
+ return new GitHubRepositoryRateLimitError({ ...context, retryAt: error.retryAt });
172
case "GitHubApiNotFoundError":
173
return new GitHubPullRequestNotFoundError(context);
174
case "GitHubApiResponseError":
174
- return new GitHubCliCommandError({ ...context, httpStatus: error.status });
175
+ return new GitHubRepositoryCommandError({ ...context, httpStatus: error.status });
176
case "GitHubApiRequestError":
176
- return new GitHubCliCommandError(context);
177
+ return new GitHubRepositoryCommandError(context);
178
}
179
}
180
@@ -208,15 +209,15 @@ export interface GitHubRepositoryCloneUrls {
209
readonly sshUrl: string;
210
}
211
211
-export class GitHubCli extends Context.Service<
212
- GitHubCli,
212
+export class GitHubRepositoryApi extends Context.Service<
213
+ GitHubRepositoryApi,
214
{
215
readonly listOpenPullRequests: (input: {
216
readonly cwd: string;
217
readonly headSelector: string;
218
readonly limit?: number;
219
readonly rateLimitHost?: string;
219
- }) => Effect.Effect<ReadonlyArray<GitHubPullRequestSummary>, GitHubCliError>;
220
+ }) => Effect.Effect<ReadonlyArray<GitHubPullRequestSummary>, GitHubRepositoryApiError>;
221
222
/**
223
* Pull requests whose head is `headSelector` (a branch, or `owner:branch` for a fork), in the
@@ -230,24 +231,24 @@ export class GitHubCli extends Context.Service<
231
readonly limit: number;
232
/** The checkout's GitHub API host. Without it, the host comes from the git remotes. */
233
readonly rateLimitHost?: string;
233
- }) => Effect.Effect<ReadonlyArray<NormalizedGitHubPullRequestRecord>, GitHubCliError>;
234
+ }) => Effect.Effect<ReadonlyArray<NormalizedGitHubPullRequestRecord>, GitHubRepositoryApiError>;
235
236
readonly getPullRequest: (input: {
237
readonly cwd: string;
238
readonly reference: string;
239
readonly rateLimitHost?: string;
239
- }) => Effect.Effect<GitHubPullRequestSummary, GitHubCliError>;
240
+ }) => Effect.Effect<GitHubPullRequestSummary, GitHubRepositoryApiError>;
241
242
readonly getRepositoryCloneUrls: (input: {
243
readonly cwd: string;
244
readonly repository: string;
244
- }) => Effect.Effect<GitHubRepositoryCloneUrls, GitHubCliError>;
245
+ }) => Effect.Effect<GitHubRepositoryCloneUrls, GitHubRepositoryApiError>;
246
247
readonly createRepository: (input: {
248
readonly cwd: string;
249
readonly repository: string;
250
readonly visibility: SourceControlRepositoryVisibility;
250
- }) => Effect.Effect<GitHubRepositoryCloneUrls, GitHubCliError>;
251
+ }) => Effect.Effect<GitHubRepositoryCloneUrls, GitHubRepositoryApiError>;
252
253
readonly createPullRequest: (input: {
254
readonly cwd: string;
@@ -255,20 +256,20 @@ export class GitHubCli extends Context.Service<
256
readonly headSelector: string;
257
readonly title: string;
258
readonly bodyFile: string;
258
- }) => Effect.Effect<void, GitHubCliError>;
259
+ }) => Effect.Effect<void, GitHubRepositoryApiError>;
260
261
readonly getDefaultBranch: (input: {
262
readonly cwd: string;
263
readonly rateLimitHost?: string;
263
- }) => Effect.Effect<string | null, GitHubCliError>;
264
+ }) => Effect.Effect<string | null, GitHubRepositoryApiError>;
265
266
readonly checkoutPullRequest: (input: {
267
readonly cwd: string;
268
readonly reference: string;
269
readonly force?: boolean;
269
- }) => Effect.Effect<void, GitHubCliError>;
270
+ }) => Effect.Effect<void, GitHubRepositoryApiError>;
271
}
271
->()("t3/sourceControl/GitHubCli") {}
272
+>()("t3/sourceControl/GitHubRepositoryApi") {}
273
274
/**
275
* The repository `gh pr list` reads in a checkout, picked the way gh picks one without a
@@ -385,7 +386,7 @@ class PullRequestsByHeadRead extends Request.Class<
386
readonly allowReserve: boolean;
387
},
388
ReadonlyArray<NormalizedGitHubPullRequestRecord>,
388
- GitHubCliError
389
+ GitHubRepositoryApiError
390
> {}
391
392
/** One aliased `pullRequests` connection per lookup, each head and state passed as a variable. */
@@ -549,7 +550,7 @@ export const make = Effect.gen(function* () {
550
551
const gitRead = (cwd: string, args: ReadonlyArray<string>) =>
552
process.run({
552
- operation: "GitHubCli.resolveRepository",
553
+ operation: "GitHubRepositoryApi.resolveRepository",
554
command: "git",
555
args,
556
cwd,
@@ -558,13 +559,13 @@ export const make = Effect.gen(function* () {
559
});
560
561
const commandFailure = (cwd: string, detail: string) =>
561
- new GitHubCliCommandError({ command: "gh", cwd, cause: new Error(detail) });
562
+ new GitHubRepositoryCommandError({ cwd, cause: new Error(detail) });
563
564
/**
565
* The repository `gh` would act on in `cwd`: GH_REPO, else the remote `gh` would pick, else
566
* the remote the caller resolved the provider from, else the best-ranked GitHub remote.
567
*/
567
- const resolveRepository = Effect.fn("GitHubCli.resolveRepository")(function* (input: {
568
+ const resolveRepository = Effect.fn("GitHubRepositoryApi.resolveRepository")(function* (input: {
569
readonly cwd: string;
570
readonly host?: string | undefined;
571
}) {
@@ -623,7 +624,7 @@ export const make = Effect.gen(function* () {
624
cwd: string,
625
input: GitHubApi.GitHubGraphQlInput,
626
decode: (raw: string) => Result.Result<A, unknown>,
626
- onDecodeFailure: (cause: unknown) => GitHubCliError,
627
+ onDecodeFailure: (cause: unknown) => GitHubRepositoryApiError,
628
) =>
629
api.graphql(input).pipe(
630
Effect.mapError((error) => fromGitHubApiError(cwd, error)),
@@ -646,7 +647,7 @@ export const make = Effect.gen(function* () {
647
Pick<PullRequestsByHeadRead, "headRefName" | "state" | "limit">
648
>;
649
readonly allowReserve: boolean;
649
- readonly onDecodeFailure: (cause: unknown) => GitHubCliError;
650
+ readonly onDecodeFailure: (cause: unknown) => GitHubRepositoryApiError;
651
}) => {
652
const query = buildPullRequestsByHeadQuery(input.lookups);
653
return graphqlJson(
@@ -668,7 +669,6 @@ export const make = Effect.gen(function* () {
669
decoded.data.repository === null
670
? Effect.fail(
671
new GitHubPullRequestNotFoundError({
671
- command: "gh",
672
cwd: input.cwd,
673
cause: new Error("The repository could not be read."),
674
}),
@@ -697,8 +697,7 @@ export const make = Effect.gen(function* () {
697
locator: { host, owner, name },
698
lookups: entries.map((entry) => entry.request),
699
allowReserve,
700
- onDecodeFailure: (cause) =>
701
- new GitHubChangeRequestListDecodeError({ command: "gh", cwd, cause }),
700
+ onDecodeFailure: (cause) => new GitHubChangeRequestListDecodeError({ cwd, cause }),
701
}).pipe(
702
Effect.map((aliases) => {
703
for (const [index, entry] of entries.entries()) {
@@ -724,7 +723,7 @@ export const make = Effect.gen(function* () {
723
RequestResolver.setDelay(BACKGROUND_HEAD_LOOKUP_BATCH_WINDOW),
724
);
725
727
- const listByHead = Effect.fn("GitHubCli.listByHead")(function* (input: {
726
+ const listByHead = Effect.fn("GitHubRepositoryApi.listByHead")(function* (input: {
727
readonly cwd: string;
728
readonly headSelector: string;
729
readonly state: PullRequestListState;
@@ -759,7 +758,7 @@ export const make = Effect.gen(function* () {
758
const toSummaries = (rows: ReadonlyArray<NormalizedGitHubPullRequestRecord>) =>
759
rows.map(pullRequestSummary);
760
762
- const readPullRequest = Effect.fn("GitHubCli.readPullRequest")(function* (input: {
761
+ const readPullRequest = Effect.fn("GitHubRepositoryApi.readPullRequest")(function* (input: {
762
readonly cwd: string;
763
readonly reference: string;
764
readonly rateLimitHost?: string | undefined;
@@ -787,7 +786,6 @@ export const make = Effect.gen(function* () {
786
}))[0];
787
if (found === undefined) {
788
return yield* new GitHubPullRequestNotFoundError({
790
- command: "gh",
789
cwd: input.cwd,
790
cause: new Error("No pull request has this head branch."),
791
});
@@ -799,7 +797,7 @@ export const make = Effect.gen(function* () {
797
? parsed.locator
798
: yield* resolveRepository({ cwd: input.cwd, host: input.rateLimitHost });
799
const decodeFailure = (cause: unknown) =>
802
- new GitHubPullRequestDecodeError({ command: "gh", cwd: input.cwd, cause });
800
+ new GitHubPullRequestDecodeError({ cwd: input.cwd, cause });
801
const decoded = yield* graphqlJson(
802
input.cwd,
803
{
@@ -815,7 +813,6 @@ export const make = Effect.gen(function* () {
813
const node = decoded.data.repository?.pullRequest;
814
if (node == null) {
815
return yield* new GitHubPullRequestNotFoundError({
818
- command: "gh",
816
cwd: input.cwd,
817
cause: new Error("The pull request does not exist."),
818
});
@@ -825,7 +822,7 @@ export const make = Effect.gen(function* () {
822
return record;
823
});
824
828
- const readRepository = Effect.fn("GitHubCli.readRepository")(function* (
825
+ const readRepository = Effect.fn("GitHubRepositoryApi.readRepository")(function* (
826
cwd: string,
827
locator: GitHubRepositoryLocator,
828
) {
@@ -838,7 +835,6 @@ export const make = Effect.gen(function* () {
835
const decoded = decodeRawRepository(response.body);
836
if (Result.isFailure(decoded)) {
837
return yield* new GitHubRepositoryDecodeError({
841
- command: "gh",
838
cwd,
839
cause: decoded.failure,
840
});
@@ -846,23 +842,23 @@ export const make = Effect.gen(function* () {
842
return decoded.success;
843
});
844
849
- const readViewerLogin = Effect.fn("GitHubCli.readViewerLogin")(function* (
845
+ const readViewerLogin = Effect.fn("GitHubRepositoryApi.readViewerLogin")(function* (
846
cwd: string,
847
host: string,
848
) {
849
const response = yield* rest(cwd, { host, operation: "getViewer", path: "user" });
850
const decoded = decodeViewerLogin(response.body);
851
if (Result.isFailure(decoded)) {
856
- return yield* new GitHubCliCommandError({ command: "gh", cwd, cause: decoded.failure });
852
+ return yield* new GitHubRepositoryCommandError({ cwd, cause: decoded.failure });
853
}
854
return decoded.success.login;
855
});
856
857
const gitFailure = (cwd: string) => (cause: unknown) =>
862
- new GitHubCliCommandError({ command: "gh", cwd, cause });
858
+ new GitHubRepositoryCommandError({ cwd, cause });
859
860
const runGit = (cwd: string, operation: string, args: ReadonlyArray<string>) =>
865
- git.execute({ operation: `GitHubCli.checkoutPullRequest.${operation}`, cwd, args });
861
+ git.execute({ operation: `GitHubRepositoryApi.checkoutPullRequest.${operation}`, cwd, args });
862
863
/**
864
* `gh pr checkout` in plain git: the head branch is fetched from the remote that holds it (a
@@ -870,8 +866,8 @@ export const make = Effect.gen(function* () {
866
* track the head. A head branch that is gone is read from the base's `refs/pull/<n>/head`.
867
* An existing branch fast-forwards, or with `force` is reset to the pull request.
868
*/
873
- const checkoutPullRequest: GitHubCli["Service"]["checkoutPullRequest"] = Effect.fn(
874
- "GitHubCli.checkoutPullRequest",
869
+ const checkoutPullRequest: GitHubRepositoryApi["Service"]["checkoutPullRequest"] = Effect.fn(
870
+ "GitHubRepositoryApi.checkoutPullRequest",
871
)(function* (input) {
872
const reference = parsePullRequestReference(input.reference);
873
const pullRequest = yield* readPullRequest({ cwd: input.cwd, reference: input.reference });
@@ -994,7 +990,7 @@ export const make = Effect.gen(function* () {
990
}).pipe(Effect.mapError(gitFailure(input.cwd)));
991
});
992
997
- return GitHubCli.of({
993
+ return GitHubRepositoryApi.of({
994
listPullRequestsByHead: (input) =>
995
AllowGitHubReserve.pipe(
996
Effect.flatMap((allowReserve) => listByHead({ ...input, allowReserve })),
@@ -1043,7 +1039,6 @@ export const make = Effect.gen(function* () {
1039
const decoded = decodeRawRepository(response.body);
1040
if (Result.isFailure(decoded)) {
1041
return yield* new GitHubRepositoryDecodeError({
1046
- command: "gh",
1042
cwd: input.cwd,
1043
cause: decoded.failure,
1044
});
@@ -1083,7 +1078,7 @@ export const make = Effect.gen(function* () {
1078
});
1079
});
1080
1086
-export const layer = Layer.effect(GitHubCli, make).pipe(
1081
+export const layer = Layer.effect(GitHubRepositoryApi, make).pipe(
1082
Layer.provideMerge(GitHubApi.layer),
1083
Layer.provideMerge(GitHubCredentials.layer),
1084
Layer.provideMerge(GitHubGraphQlBudget.layer),
apps/server/src/sourceControl/GitHubSourceControlProvider.test.ts
+14
-12
@@ -8,7 +8,7 @@ import { ChildProcessSpawner } from "effect/process";
8
9
import * as VcsProcess from "../vcs/VcsProcess.ts";
10
import * as GitHubApi from "./GitHubApi.ts";
11
-import * as GitHubCli from "./GitHubCli.ts";
11
+import * as GitHubRepositoryApi from "./GitHubRepositoryApi.ts";
12
import { parseGitHubAuthStatus } from "./gitHubAuthStatus.ts";
13
import * as GitHubSourceControlProvider from "./GitHubSourceControlProvider.ts";
14
@@ -27,12 +27,15 @@ const processResult = (
27
});
28
29
function makeProvider(
30
- github: Partial<GitHubCli.GitHubCli["Service"]>,
30
+ github: Partial<GitHubRepositoryApi.GitHubRepositoryApi["Service"]>,
31
api: Partial<GitHubApi.GitHubApi["Service"]> = {},
32
) {
33
return GitHubSourceControlProvider.make.pipe(
34
Effect.provide(
35
- Layer.merge(Layer.mock(GitHubCli.GitHubCli)(github), Layer.mock(GitHubApi.GitHubApi)(api)),
35
+ Layer.merge(
36
+ Layer.mock(GitHubRepositoryApi.GitHubRepositoryApi)(github),
37
+ Layer.mock(GitHubApi.GitHubApi)(api),
38
+ ),
39
),
40
);
41
}
@@ -87,10 +90,9 @@ it.effect("maps GitHub PR summaries into provider-neutral change requests", () =
90
}),
91
);
92
90
-it.effect("adds safe request context while retaining GitHub CLI causes", () =>
93
+it.effect("adds safe request context while retaining GitHub API causes", () =>
94
Effect.gen(function* () {
92
- const cause = new GitHubCli.GitHubPullRequestNotFoundError({
93
- command: "gh",
95
+ const cause = new GitHubRepositoryApi.GitHubPullRequestNotFoundError({
96
cwd: "/repo",
97
cause: new Error("raw upstream detail that should remain in the cause"),
98
});
@@ -109,7 +111,6 @@ it.effect("adds safe request context while retaining GitHub CLI causes", () =>
111
{
112
provider: error.provider,
113
operation: error.operation,
112
- command: error.command,
114
cwd: error.cwd,
115
reference: error.reference,
116
detail: error.detail,
@@ -117,7 +118,6 @@ it.effect("adds safe request context while retaining GitHub CLI causes", () =>
118
{
119
provider: "github",
120
operation: "getChangeRequest",
120
- command: "gh",
121
cwd: "/repo",
122
reference: "https://github.com/pingdotgg/t3code/pull/42",
123
detail: "Pull request not found. Check the PR number or URL and try again.",
@@ -130,8 +130,9 @@ it.effect("adds safe request context while retaining GitHub CLI causes", () =>
130
131
it.effect("lists change request history through the batched head lookup", () =>
132
Effect.gen(function* () {
133
- let lookup: Parameters<GitHubCli.GitHubCli["Service"]["listPullRequestsByHead"]>[0] | null =
134
- null;
133
+ let lookup:
134
+ | Parameters<GitHubRepositoryApi.GitHubRepositoryApi["Service"]["listPullRequestsByHead"]>[0]
135
+ | null = null;
136
const provider = yield* makeProvider({
137
listPullRequestsByHead: (input) => {
138
lookup = input;
@@ -183,8 +184,9 @@ it.effect("lists change request history through the batched head lookup", () =>
184
185
it.effect("creates GitHub PRs through provider-neutral input names", () =>
186
Effect.gen(function* () {
186
- let createInput: Parameters<GitHubCli.GitHubCli["Service"]["createPullRequest"]>[0] | null =
187
- null;
187
+ let createInput:
188
+ | Parameters<GitHubRepositoryApi.GitHubRepositoryApi["Service"]["createPullRequest"]>[0]
189
+ | null = null;
190
const provider = yield* makeProvider({
191
createPullRequest: (input) => {
192
createInput = input;
apps/server/src/sourceControl/GitHubSourceControlProvider.ts
+3
-11
@@ -15,7 +15,7 @@ import { HostProcessEnvironment } from "@t3tools/shared/hostProcess";
15
16
import * as ServerSettings from "../serverSettings.ts";
17
import * as GitHubApi from "./GitHubApi.ts";
18
-import * as GitHubCli from "./GitHubCli.ts";
18
+import * as GitHubRepositoryApi from "./GitHubRepositoryApi.ts";
19
import {
20
effectiveGitHubAccount,
21
findAuthenticatedGitHubAccount,
@@ -40,7 +40,7 @@ const decodeLinkSubject = Schema.decodeUnknownEffect(
40
),
41
);
42
43
-function toChangeRequest(summary: GitHubCli.GitHubPullRequestSummary): ChangeRequest {
43
+function toChangeRequest(summary: GitHubRepositoryApi.GitHubPullRequestSummary): ChangeRequest {
44
return {
45
provider: "github",
46
number: summary.number,
@@ -264,7 +264,7 @@ export const makeDiscovery = Effect.gen(function* () {
264
});
265
266
export const make = Effect.gen(function* () {
267
- const github = yield* GitHubCli.GitHubCli;
267
+ const github = yield* GitHubRepositoryApi.GitHubRepositoryApi;
268
const api = yield* GitHubApi.GitHubApi;
269
270
const listChangeRequests: SourceControlProvider.SourceControlProvider["Service"]["listChangeRequests"] =
@@ -286,7 +286,6 @@ export const make = Effect.gen(function* () {
286
new SourceControlProviderError({
287
provider: "github",
288
operation: "listChangeRequests",
289
- command: error.command,
289
cwd: input.cwd,
290
reference: SourceControlProvider.transportSafeSourceControlErrorValue(
291
input.headSelector,
@@ -325,7 +324,6 @@ export const make = Effect.gen(function* () {
324
new SourceControlProviderError({
325
provider: "github",
326
operation: "listChangeRequests",
328
- command: error.command,
327
cwd: input.cwd,
328
reference: SourceControlProvider.transportSafeSourceControlErrorValue(
329
input.headSelector,
@@ -403,7 +401,6 @@ export const make = Effect.gen(function* () {
401
new SourceControlProviderError({
402
provider: "github",
403
operation: "getChangeRequest",
406
- command: error.command,
404
cwd: input.cwd,
405
reference: SourceControlProvider.transportSafeSourceControlErrorValue(
406
input.reference,
@@ -428,7 +425,6 @@ export const make = Effect.gen(function* () {
425
new SourceControlProviderError({
426
provider: "github",
427
operation: "createChangeRequest",
431
- command: error.command,
428
cwd: input.cwd,
429
reference: SourceControlProvider.transportSafeSourceControlErrorValue(
430
input.headSelector,
@@ -445,7 +441,6 @@ export const make = Effect.gen(function* () {
441
new SourceControlProviderError({
442
provider: "github",
443
operation: "getRepositoryCloneUrls",
448
- command: error.command,
444
cwd: input.cwd,
445
repository: SourceControlProvider.transportSafeSourceControlErrorValue(
446
input.repository,
@@ -462,7 +457,6 @@ export const make = Effect.gen(function* () {
457
new SourceControlProviderError({
458
provider: "github",
459
operation: "createRepository",
465
- command: error.command,
460
cwd: input.cwd,
461
repository: SourceControlProvider.transportSafeSourceControlErrorValue(
462
input.repository,
@@ -486,7 +480,6 @@ export const make = Effect.gen(function* () {
480
new SourceControlProviderError({
481
provider: "github",
482
operation: "getDefaultBranch",
489
- command: error.command,
483
cwd: input.cwd,
484
detail: error.message,
485
cause: error,
@@ -500,7 +493,6 @@ export const make = Effect.gen(function* () {
493
new SourceControlProviderError({
494
provider: "github",
495
operation: "checkoutChangeRequest",
503
- command: error.command,
496
cwd: input.cwd,
497
reference: SourceControlProvider.transportSafeSourceControlErrorValue(
498
input.reference,
apps/server/src/sourceControl/SourceControlDiscovery.test.ts
+2
-2
@@ -18,7 +18,7 @@ import * as VcsProcess from "../vcs/VcsProcess.ts";
18
import * as AzureDevOpsCli from "./AzureDevOpsCli.ts";
19
import * as BitbucketApi from "./BitbucketApi.ts";
20
import * as GitHubApi from "./GitHubApi.ts";
21
-import * as GitHubCli from "./GitHubCli.ts";
21
+import * as GitHubRepositoryApi from "./GitHubRepositoryApi.ts";
22
import * as GitLabCli from "./GitLabCli.ts";
23
import * as ForgejoCli from "./ForgejoCli.ts";
24
import * as ForgejoSourceControlProvider from "./ForgejoSourceControlProvider.ts";
@@ -40,7 +40,7 @@ const layerSourceControlProviderRegistryTest = (input: {
40
Layer.mock(AzureDevOpsCli.AzureDevOpsCli)({}),
41
Layer.mock(BitbucketApi.BitbucketApi)(input.bitbucket),
42
ServerSettings.ServerSettingsService.layerTest(),
43
- Layer.mock(GitHubCli.GitHubCli)({}),
43
+ Layer.mock(GitHubRepositoryApi.GitHubRepositoryApi)({}),
44
Layer.mock(GitHubApi.GitHubApi)({}),
45
Layer.mock(GitLabCli.GitLabCli)({}),
46
Layer.mock(ForgejoCli.ForgejoCli)({ listLogins: () => Effect.succeed([]) }),
apps/server/src/sourceControl/SourceControlProviderRegistry.test.ts
+3
-3
@@ -15,7 +15,7 @@ import * as VcsProcess from "../vcs/VcsProcess.ts";
15
import * as AzureDevOpsCli from "./AzureDevOpsCli.ts";
16
import * as BitbucketApi from "./BitbucketApi.ts";
17
import * as GitHubApi from "./GitHubApi.ts";
18
-import * as GitHubCli from "./GitHubCli.ts";
18
+import * as GitHubRepositoryApi from "./GitHubRepositoryApi.ts";
19
import * as GitLabCli from "./GitLabCli.ts";
20
import * as ForgejoCli from "./ForgejoCli.ts";
21
import * as SourceControlProviderRegistry from "./SourceControlProviderRegistry.ts";
@@ -42,7 +42,7 @@ function makeRegistry(input: {
42
readonly url: string;
43
}>;
44
readonly process?: Partial<VcsProcess.VcsProcess["Service"]>;
45
- readonly github?: Partial<GitHubCli.GitHubCli["Service"]>;
45
+ readonly github?: Partial<GitHubRepositoryApi.GitHubRepositoryApi["Service"]>;
46
readonly githubApi?: Partial<GitHubApi.GitHubApi["Service"]>;
47
readonly gitlab?: Partial<GitLabCli.GitLabCli["Service"]>;
48
readonly resolve?: VcsDriverRegistry.VcsDriverRegistry["Service"]["resolve"];
@@ -98,7 +98,7 @@ function makeRegistry(input: {
98
Layer.mock(AzureDevOpsCli.AzureDevOpsCli)({}),
99
Layer.mock(BitbucketApi.BitbucketApi)({}),
100
ServerSettings.ServerSettingsService.layerTest(),
101
- Layer.mock(GitHubCli.GitHubCli)(input.github ?? {}),
101
+ Layer.mock(GitHubRepositoryApi.GitHubRepositoryApi)(input.github ?? {}),
102
Layer.mock(GitHubApi.GitHubApi)(input.githubApi ?? {}),
103
Layer.mock(GitLabCli.GitLabCli)(input.gitlab ?? {}),
104
Layer.mock(ForgejoCli.ForgejoCli)({ listLogins: () => Effect.succeed([]) }),
apps/server/src/ws.ts
+2
-2
@@ -229,7 +229,7 @@ import * as SourceControlDiscovery from "./sourceControl/SourceControlDiscovery.
229
import * as SourceControlRepositoryService from "./sourceControl/SourceControlRepositoryService.ts";
230
import * as AzureDevOpsCli from "./sourceControl/AzureDevOpsCli.ts";
231
import * as BitbucketApi from "./sourceControl/BitbucketApi.ts";
232
-import * as GitHubCli from "./sourceControl/GitHubCli.ts";
232
+import * as GitHubRepositoryApi from "./sourceControl/GitHubRepositoryApi.ts";
233
import * as GitLabCli from "./sourceControl/GitLabCli.ts";
234
import * as ForgejoCli from "./sourceControl/ForgejoCli.ts";
235
import * as SourceControlProviderRegistry from "./sourceControl/SourceControlProviderRegistry.ts";
@@ -3190,7 +3190,7 @@ export const layer = Layer.unwrap(
3190
Layer.mergeAll(
3191
AzureDevOpsCli.layer,
3192
BitbucketApi.layer,
3193
- GitHubCli.layer,
3193
+ GitHubRepositoryApi.layer,
3194
GitLabCli.layer,
3195
ForgejoCli.layer,
3196
),