Skip to content

Commit 1c8a6c8

Browse files
refactor(server): GitHub services are named for the API they call, not gh
GitHubPullRequestCli and GitHubCli have talked to GitHub's HTTP API since #16319-#16321; gh only hands over a token. Rename them to GitHubPullRequestApi and GitHubRepositoryApi (files, services, layers and the repository errors), and drop the `command: "gh"` field their errors carried, so logs no longer blame a CLI that never ran. GitLab and Azure DevOps keep their Cli names: they still run glab and az. GitHubCliMissingError/GitHubCliFailedError keep theirs too, since they are about `gh auth token`. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 26285ab commit 1c8a6c8

20 files changed

Lines changed: 410 additions & 455 deletions

‎apps/server/scripts/evaluate-thread-titles.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
} from "../src/textGeneration/ThreadTitleContext.ts";
2424
import * as ThreadTitleLinks from "../src/textGeneration/ThreadTitleLinks.ts";
2525
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";
2727
import * as GitLabCli from "../src/sourceControl/GitLabCli.ts";
2828
import * as ForgejoCli from "../src/sourceControl/ForgejoCli.ts";
2929
import * as AzureDevOpsCli from "../src/sourceControl/AzureDevOpsCli.ts";
@@ -152,7 +152,7 @@ await Effect.runPromise(
152152
SourceControlProviderRegistry.layer.pipe(
153153
Layer.provide(
154154
Layer.mergeAll(
155-
GitHubCli.layer,
155+
GitHubRepositoryApi.layer,
156156
GitLabCli.layer,
157157
ForgejoCli.layer,
158158
AzureDevOpsCli.layer,

‎apps/server/scripts/measure-pr-preview.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import * as Option from "effect/Option";
1010
import * as Schema from "effect/Schema";
1111
import { FetchHttpClient } from "effect/http";
1212

13-
import * as GitHubPullRequestCli from "../src/pullRequest/GitHubPullRequestCli.ts";
13+
import * as GitHubPullRequestApi from "../src/pullRequest/GitHubPullRequestApi.ts";
1414
import * as GitHubPullRequestProvider from "../src/pullRequest/GitHubPullRequestProvider.ts";
1515
import * as GitHubApi from "../src/sourceControl/GitHubApi.ts";
1616
import * as GitHubCredentials from "../src/sourceControl/GitHubCredentials.ts";
@@ -73,7 +73,7 @@ const measuredApi = Layer.effect(
7373
Layer.provide(NodeServices.layer),
7474
);
7575

76-
const services = GitHubPullRequestCli.layer.pipe(
76+
const services = GitHubPullRequestApi.layer.pipe(
7777
Layer.provideMerge(measuredApi),
7878
Layer.provideMerge(VcsProcess.layer),
7979
Layer.provideMerge(NodeServices.layer),

‎apps/server/src/git/GitManager.test.ts‎

Lines changed: 35 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import {
4242
} from "@t3tools/contracts";
4343
import * as DateTime from "effect/DateTime";
4444
import * as GitHubApi from "../sourceControl/GitHubApi.ts";
45-
import * as GitHubCli from "../sourceControl/GitHubCli.ts";
45+
import * as GitHubRepositoryApi from "../sourceControl/GitHubRepositoryApi.ts";
4646
import { decodeGitHubPullRequestListJson } from "../sourceControl/gitHubPullRequests.ts";
4747
import * as GitLabCli from "../sourceControl/GitLabCli.ts";
4848
import * as TextGeneration from "../textGeneration/TextGeneration.ts";
@@ -92,7 +92,7 @@ interface FakeGhScenario {
9292
headRepositoryOwnerLogin?: string | null;
9393
};
9494
repositoryCloneUrls?: Record<string, { url: string; sshUrl: string }>;
95-
failWith?: GitHubCli.GitHubCliError;
95+
failWith?: GitHubRepositoryApi.GitHubRepositoryApiError;
9696
/** Let this many gh calls succeed before failWith kicks in (default 0 = fail immediately). */
9797
failAfterCalls?: number;
9898
}
@@ -111,7 +111,9 @@ type FakeGitTextGeneration = TextGeneration.TextGeneration["Service"];
111111

112112
type FakePullRequest = NonNullable<FakeGhScenario["pullRequest"]>;
113113

114-
function normalizeFakePullRequestSummary(raw: unknown): GitHubCli.GitHubPullRequestSummary | null {
114+
function normalizeFakePullRequestSummary(
115+
raw: unknown,
116+
): GitHubRepositoryApi.GitHubPullRequestSummary | null {
115117
if (!raw || typeof raw !== "object") {
116118
return null;
117119
}
@@ -381,8 +383,8 @@ function createTextGeneration(
381383
};
382384
}
383385

384-
function createGitHubCliWithFakeGh(scenario: FakeGhScenario = {}): {
385-
service: GitHubCli.GitHubCli["Service"];
386+
function createGitHubRepositoryApiWithFakeGh(scenario: FakeGhScenario = {}): {
387+
service: GitHubRepositoryApi.GitHubRepositoryApi["Service"];
386388
ghCalls: string[];
387389
} {
388390
const prListQueue = [...(scenario.prListSequence ?? [])];
@@ -398,7 +400,7 @@ function createGitHubCliWithFakeGh(scenario: FakeGhScenario = {}): {
398400
const execute = (input: {
399401
readonly cwd: string;
400402
readonly args: ReadonlyArray<string>;
401-
}): Effect.Effect<VcsProcess.VcsProcessOutput, GitHubCli.GitHubCliError> => {
403+
}): Effect.Effect<VcsProcess.VcsProcessOutput, GitHubRepositoryApi.GitHubRepositoryApiError> => {
402404
const args = [...input.args];
403405
ghCalls.push(args.join(" "));
404406

@@ -486,10 +488,9 @@ function createGitHubCliWithFakeGh(scenario: FakeGhScenario = {}): {
486488
return fakeGhOutput("");
487489
},
488490
catch: (error) =>
489-
GitHubCli.isGitHubCliError(error)
491+
GitHubRepositoryApi.isGitHubRepositoryApiError(error)
490492
? error
491-
: new GitHubCli.GitHubCliCommandError({
492-
command: "gh",
493+
: new GitHubRepositoryApi.GitHubRepositoryCommandError({
493494
cwd: input.cwd,
494495
cause: error,
495496
}),
@@ -502,8 +503,7 @@ function createGitHubCliWithFakeGh(scenario: FakeGhScenario = {}): {
502503
const cloneUrls = scenario.repositoryCloneUrls?.[repository];
503504
if (!cloneUrls) {
504505
return Effect.fail(
505-
new GitHubCli.GitHubCliCommandError({
506-
command: "gh",
506+
new GitHubRepositoryApi.GitHubRepositoryCommandError({
507507
cwd: input.cwd,
508508
cause: new Error(`Unexpected repository lookup: ${repository}`),
509509
}),
@@ -523,8 +523,7 @@ function createGitHubCliWithFakeGh(scenario: FakeGhScenario = {}): {
523523
}
524524

525525
return Effect.fail(
526-
new GitHubCli.GitHubCliCommandError({
527-
command: "gh",
526+
new GitHubRepositoryApi.GitHubRepositoryCommandError({
528527
cwd: input.cwd,
529528
cause: new Error(`Unexpected gh command: ${args.join(" ")}`),
530529
}),
@@ -577,7 +576,9 @@ function createGitHubCliWithFakeGh(scenario: FakeGhScenario = {}): {
577576
Effect.map((raw) =>
578577
raw
579578
.map((entry) => normalizeFakePullRequestSummary(entry))
580-
.filter((entry): entry is GitHubCli.GitHubPullRequestSummary => entry !== null),
579+
.filter(
580+
(entry): entry is GitHubRepositoryApi.GitHubPullRequestSummary => entry !== null,
581+
),
581582
),
582583
),
583584
createPullRequest: (input) =>
@@ -617,7 +618,9 @@ function createGitHubCliWithFakeGh(scenario: FakeGhScenario = {}): {
617618
"number,title,url,baseRefName,headRefName,state,isDraft,mergedAt,closedAt,isCrossRepository,headRepository,headRepositoryOwner",
618619
],
619620
}).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+
),
621624
),
622625
getRepositoryCloneUrls: (input) =>
623626
execute({
@@ -626,8 +629,7 @@ function createGitHubCliWithFakeGh(scenario: FakeGhScenario = {}): {
626629
}).pipe(Effect.map((result) => JSON.parse(result.stdout))),
627630
createRepository: (input) =>
628631
Effect.fail(
629-
new GitHubCli.GitHubCliCommandError({
630-
command: "gh",
632+
new GitHubRepositoryApi.GitHubRepositoryCommandError({
631633
cwd: input.cwd,
632634
cause: new Error(`Unexpected repository create: ${input.repository}`),
633635
}),
@@ -691,7 +693,9 @@ function makeManager(input?: {
691693
ProjectionStore.ProjectionStoreV2 | ProjectStore.ProjectStoreV2
692694
>;
693695
}) {
694-
const { service: gitHubCli, ghCalls } = createGitHubCliWithFakeGh(input?.ghScenario);
696+
const { service: gitHubRepositoryApi, ghCalls } = createGitHubRepositoryApiWithFakeGh(
697+
input?.ghScenario,
698+
);
695699
const textGeneration = createTextGeneration(input?.textGeneration);
696700
const layerServerConfig = ServerConfig.layerTest(process.cwd(), {
697701
prefix: "t3-git-manager-test-",
@@ -740,7 +744,7 @@ function makeManager(input?: {
740744
),
741745
Effect.provide(
742746
Layer.merge(
743-
Layer.succeed(GitHubCli.GitHubCli, gitHubCli),
747+
Layer.succeed(GitHubRepositoryApi.GitHubRepositoryApi, gitHubRepositoryApi),
744748
Layer.mock(GitHubApi.GitHubApi)({}),
745749
),
746750
),
@@ -1296,8 +1300,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
12961300
yield* runGit(repoDir, ["push", "-u", "origin", "feature/rate-limited"]);
12971301
const { manager, ghCalls } = yield* makeManager({
12981302
ghScenario: {
1299-
failWith: new GitHubCli.GitHubCliUnavailableError({
1300-
command: "gh",
1303+
failWith: new GitHubRepositoryApi.GitHubRepositoryUnavailableError({
13011304
cwd: repoDir,
13021305
cause: new Error("rate limited"),
13031306
}),
@@ -1779,8 +1782,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
17791782

17801783
const { manager, ghCalls } = yield* makeManager({
17811784
ghScenario: {
1782-
failWith: new GitHubCli.GitHubCliUnavailableError({
1783-
command: "gh",
1785+
failWith: new GitHubRepositoryApi.GitHubRepositoryUnavailableError({
17841786
cwd: repoDir,
17851787
cause: new Error("gh is not available on PATH"),
17861788
}),
@@ -2640,8 +2642,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
26402642
},
26412643
]),
26422644
},
2643-
failWith: new GitHubCli.GitHubCliUnavailableError({
2644-
command: "gh",
2645+
failWith: new GitHubRepositoryApi.GitHubRepositoryUnavailableError({
26452646
cwd: repoDir,
26462647
cause: new Error("rate limited"),
26472648
}),
@@ -2717,8 +2718,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
27172718

27182719
const { manager } = yield* makeManager({
27192720
ghScenario: {
2720-
failWith: new GitHubCli.GitHubCliUnavailableError({
2721-
command: "gh",
2721+
failWith: new GitHubRepositoryApi.GitHubRepositoryUnavailableError({
27222722
cwd: repoDir,
27232723
cause: new Error("gh is not available on PATH"),
27242724
}),
@@ -2743,8 +2743,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
27432743
const upstreamCause = "GraphQL rate limit for user ID 51714798 and token secret-value";
27442744
const { manager } = yield* makeManager({
27452745
ghScenario: {
2746-
failWith: new GitHubCli.GitHubCliRateLimitError({
2747-
command: "gh",
2746+
failWith: new GitHubRepositoryApi.GitHubRepositoryRateLimitError({
27482747
cwd: repoDir,
27492748
cause: new Error(upstreamCause),
27502749
}),
@@ -2770,7 +2769,6 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
27702769
errorTag: "SourceControlProviderError",
27712770
provider: "github",
27722771
providerOperation: "listChangeRequests",
2773-
providerCommand: "gh",
27742772
errorDetail: "GitHub API rate limit exceeded. Requests resume when the limit resets.",
27752773
});
27762774
const loggedText = [
@@ -2801,8 +2799,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
28012799
const { manager } = yield* makeManager({
28022800
ghScenario: {
28032801
prListSequence: [JSON.stringify([existingPr])],
2804-
failWith: new GitHubCli.GitHubCliUnavailableError({
2805-
command: "gh",
2802+
failWith: new GitHubRepositoryApi.GitHubRepositoryUnavailableError({
28062803
cwd: repoDir,
28072804
cause: new Error("rate limited"),
28082805
}),
@@ -2844,8 +2841,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
28442841
const { manager } = yield* makeManager({
28452842
ghScenario: {
28462843
prListSequence: [JSON.stringify([existingPr])],
2847-
failWith: new GitHubCli.GitHubCliUnavailableError({
2848-
command: "gh",
2844+
failWith: new GitHubRepositoryApi.GitHubRepositoryUnavailableError({
28492845
cwd: repoDir,
28502846
cause: new Error("rate limited"),
28512847
}),
@@ -2892,8 +2888,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
28922888
const { manager } = yield* makeManager({
28932889
ghScenario: {
28942890
prListSequence: [JSON.stringify([existingPr])],
2895-
failWith: new GitHubCli.GitHubCliUnavailableError({
2896-
command: "gh",
2891+
failWith: new GitHubRepositoryApi.GitHubRepositoryUnavailableError({
28972892
cwd: repoDir,
28982893
cause: new Error("rate limited"),
28992894
}),
@@ -2931,8 +2926,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
29312926
const { manager } = yield* makeManager({
29322927
ghScenario: {
29332928
prListSequence: [JSON.stringify([existingPr])],
2934-
failWith: new GitHubCli.GitHubCliUnavailableError({
2935-
command: "gh",
2929+
failWith: new GitHubRepositoryApi.GitHubRepositoryUnavailableError({
29362930
cwd: repoDir,
29372931
cause: new Error("rate limited"),
29382932
}),
@@ -2973,8 +2967,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
29732967
const { manager } = yield* makeManager({
29742968
ghScenario: {
29752969
prListSequence: [JSON.stringify([existingPr])],
2976-
failWith: new GitHubCli.GitHubCliUnavailableError({
2977-
command: "gh",
2970+
failWith: new GitHubRepositoryApi.GitHubRepositoryUnavailableError({
29782971
cwd: repoDir,
29792972
cause: new Error("rate limited"),
29802973
}),
@@ -4618,8 +4611,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
46184611

46194612
const { manager } = yield* makeManager({
46204613
ghScenario: {
4621-
failWith: new GitHubCli.GitHubCliUnavailableError({
4622-
command: "gh",
4614+
failWith: new GitHubRepositoryApi.GitHubRepositoryUnavailableError({
46234615
cwd: repoDir,
46244616
cause: new Error("gh is not available on PATH"),
46254617
}),
@@ -4648,8 +4640,7 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
46484640

46494641
const { manager } = yield* makeManager({
46504642
ghScenario: {
4651-
failWith: new GitHubCli.GitHubCliAuthenticationError({
4652-
command: "gh",
4643+
failWith: new GitHubRepositoryApi.GitHubRepositoryAuthenticationError({
46534644
cwd: repoDir,
46544645
cause: new Error("gh is not authenticated"),
46554646
}),

‎apps/server/src/git/GitManager.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1286,7 +1286,7 @@ export const make = Effect.gen(function* () {
12861286
? {
12871287
provider: error.provider,
12881288
providerOperation: error.operation,
1289-
providerCommand: error.command ?? "unknown",
1289+
...(error.command === undefined ? {} : { providerCommand: error.command }),
12901290
errorDetail: error.detail,
12911291
}
12921292
: {}),

‎apps/server/src/orchestration-v2/ThreadPullRequestService.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ export const make = Effect.gen(function* () {
345345
}).pipe(Effect.tap(() => Effect.sync(() => failBackfill(group)))),
346346
),
347347
),
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
349349
// GraphQL document, instead of one `gh pr list` per branch.
350350
{ concurrency: 32, discard: true },
351351
);

0 commit comments

Comments
 (0)