@devries-cameron20 / t3code-1 / commits / 814bd67250
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

refactor(source-control): forge definitions live in shared/, not client/ (#24181)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Oct 24, 2026 at 04:24 UTC 814bd67250fdfdf4153633a3e07b4f52ec6e9b15
88 files changed +306 -237
.repos/alchemy-effect/packages/frontend-frameworks/src/core/NodeServe.ts
+1 -1
@@ -48,7 +48,7 @@ export interface NodeServeHandler {
48 export interface NodeServeEntryOptions {
49 /**
50 * JS expression resolving the on-disk client-assets directory
51 - * (typically `fileURLToPath(new URL("../client/", import.meta.url))`).
51 + * (typically `fileURLToPath(new URL("../shared/", import.meta.url))`).
52 * Omit to skip static-file serving (Next.js handles its own assets).
53 */
54 readonly clientDirExpression?: string | undefined;
.repos/alchemy-effect/packages/frontend-frameworks/src/core/test/NodeServe.test.ts
+3 -3
@@ -28,14 +28,14 @@ describe("relativeClientDirExpression", () => {
28 "/project/dist/server/serve-node.mjs",
29 "/project/dist/client",
30 ),
31 - ).toBe(`fileURLToPath(new URL("../client/", import.meta.url))`);
31 + ).toBe(`fileURLToPath(new URL("../shared/", import.meta.url))`);
32 });
33 });
34
35 describe("makeNodeServeEntrySource", () => {
36 it("listens on PORT, answers /health, serves static files, then the fetch handler", () => {
37 const source = makeNodeServeEntrySource({
38 - clientDirExpression: `fileURLToPath(new URL("../client/", import.meta.url))`,
38 + clientDirExpression: `fileURLToPath(new URL("../shared/", import.meta.url))`,
39 handler: {
40 kind: "fetch",
41 imports: `import { handler } from "./index.mjs";`,
@@ -131,7 +131,7 @@ describe("makeNodeServeEntrySource", () => {
131
132 it("does not map GET / onto public/index.html (SSR home stays on the handler)", () => {
133 const source = makeNodeServeEntrySource({
134 - clientDirExpression: `fileURLToPath(new URL("../client/", import.meta.url))`,
134 + clientDirExpression: `fileURLToPath(new URL("../shared/", import.meta.url))`,
135 handler: {
136 kind: "node",
137 imports: `import { handler } from "./index.mjs";`,
apps/server/src/assets/AssetAccess.test.ts
+2 -2
@@ -36,7 +36,7 @@ import * as NativeAppIconResolver from "./NativeAppIconResolver.ts";
36 import { symlinksSupported } from "@t3tools/shared/testing/symlinks";
37 import { fakeSourceControlDriverInstance } from "@t3tools/source-control-testing/fakeSourceControlDriver";
38 import * as BuiltInDrivers from "../sourceControl/builtInDrivers.ts";
39 -import { sourceControlClients } from "../sourceControl/sourceControlClients.ts";
39 +import { sourceControlDefinitions } from "../sourceControl/sourceControlDefinitions.ts";
40 import { sourceControlMediaResponse } from "./sourceControlMediaResponse.ts";
41 import * as HostProcess from "@t3tools/shared/HostProcess";
42
@@ -953,7 +953,7 @@ describe("AssetAccess", () => {
953 it.effect("serves a host's credentialed media through that host's driver", () => {
954 const fetched: Array<{ url: string; headers: Readonly<Record<string, string>> }> = [];
955 const url = "https://github.com/owner/repo/blob/main/docs/shot.png";
956 - const media = sourceControlClients.mediaUrl(url)!;
956 + const media = sourceControlDefinitions.mediaUrl(url)!;
957 const layerDrivers = Layer.succeed(BuiltInDrivers.SourceControlDrivers, [
958 {
959 driver: { kind: media.definition.kind, definition: media.definition },
apps/server/src/assets/AssetAccess.ts
+2 -2
@@ -64,7 +64,7 @@ import * as ProjectFaviconResolver from "../project/ProjectFaviconResolver.ts";
64 import { isWithinRoot } from "../workspace/KnownWorkspaces.ts";
65 import * as WorkspacePaths from "../workspace/WorkspacePaths.ts";
66 import * as NativeAppIconResolver from "./NativeAppIconResolver.ts";
67 -import { sourceControlClients } from "../sourceControl/sourceControlClients.ts";
67 +import { sourceControlDefinitions } from "../sourceControl/sourceControlDefinitions.ts";
68 import { extractIcnsPng } from "./icns.ts";
69 import { openMediaFile, readMediaFileHeader, type OpenMediaFile } from "./MediaFile.ts";
70 import * as HostProcess from "@t3tools/shared/HostProcess";
@@ -805,7 +805,7 @@ export const issueAssetUrl = Effect.fn("AssetAccess.issueAssetUrl")(function* (i
805 break;
806 }
807 case SOURCE_CONTROL_MEDIA_ASSET: {
808 - const media = sourceControlClients.mediaUrl(input.resource.url);
808 + const media = sourceControlDefinitions.mediaUrl(input.resource.url);
809 if (media === null) {
810 return yield* new AssetSourceControlMediaUrlValidationError({});
811 }
apps/server/src/assets/sourceControlMediaResponse.ts
+2 -2
@@ -5,7 +5,7 @@ import * as Option from "effect/Option";
5 import { HttpServerResponse } from "effect/http";
6
7 import * as BuiltInDrivers from "../sourceControl/builtInDrivers.ts";
8 -import { sourceControlClients } from "../sourceControl/sourceControlClients.ts";
8 +import { sourceControlDefinitions } from "../sourceControl/sourceControlDefinitions.ts";
9
10 const FORWARDED_REQUEST_HEADERS = ["range", "if-range"] as const;
11 const FORWARDED_RESPONSE_HEADERS = [
@@ -34,7 +34,7 @@ export const sourceControlMediaResponse = Effect.fn(
34 remainingSeconds > 0 ? `private, max-age=${remainingSeconds}` : "private, no-store",
35 "x-content-type-options": "nosniff",
36 };
37 - const media = sourceControlClients.mediaUrl(asset.url);
37 + const media = sourceControlDefinitions.mediaUrl(asset.url);
38 const drivers = yield* BuiltInDrivers.SourceControlDrivers;
39 const fetchMedia = drivers.find(({ driver }) => driver.kind === media?.definition.kind)?.instance
40 .fetchMedia;
apps/server/src/git/GitManager.ts
+16 -16
@@ -57,12 +57,12 @@ import { isSshRemoteUrl } from "@t3tools/shared/sourceControl";
57 import {
58 type ChangeRequestTerminology,
59 UNKNOWN_SOURCE_CONTROL_CLIENT,
60 -} from "@t3tools/source-control-core/client/definition";
60 +} from "@t3tools/source-control-core/shared/definition";
61 import {
62 normalizeThreadPullRequestKey,
63 threadPullRequestKeyOf,
64 } from "../sourceControl/threadPullRequests.ts";
65 -import { sourceControlClients } from "../sourceControl/sourceControlClients.ts";
65 +import { sourceControlDefinitions } from "../sourceControl/sourceControlDefinitions.ts";
66
67 import { GitManagerError, GitPullRequestMaterializationError } from "@t3tools/contracts";
68 import {
@@ -249,10 +249,10 @@ interface BranchHeadContext {
249 }
250
251 export function pullRequestRepositoryKey(value: string): string | null {
252 - const repositoryUrl = sourceControlClients.parseChangeRequestUrl(value)?.link.repositoryUrl;
252 + const repositoryUrl = sourceControlDefinitions.parseChangeRequestUrl(value)?.link.repositoryUrl;
253 return repositoryUrl === undefined
254 ? null
255 - : sourceControlClients.repositoryKeyFromRemote(repositoryUrl);
255 + : sourceControlDefinitions.repositoryKeyFromRemote(repositoryUrl);
256 }
257
258 /** Null when the host did not name the repository the head lives in. */
@@ -668,7 +668,7 @@ export const make = Effect.gen(function* () {
668 cwd: string,
669 ) {
670 return yield* sourceControlProvider(cwd).pipe(
671 - Effect.map((provider) => sourceControlClients.get(provider.kind).changeRequest),
671 + Effect.map((provider) => sourceControlDefinitions.get(provider.kind).changeRequest),
672 Effect.orElseSucceed(() => UNKNOWN_SOURCE_CONTROL_CLIENT.changeRequest),
673 );
674 });
@@ -973,7 +973,7 @@ export const make = Effect.gen(function* () {
973 number: number,
974 ) {
975 const provider = yield* sourceControlProvider(cwd);
976 - const ref = sourceControlClients.get(provider.kind).changeRequestHeadRef?.(number);
976 + const ref = sourceControlDefinitions.get(provider.kind).changeRequestHeadRef?.(number);
977 if (ref === undefined) {
978 return yield* new GitManagerError({
979 operation: "changeRequestHeadRef",
@@ -1016,9 +1016,9 @@ export const make = Effect.gen(function* () {
1016 if (
1017 remoteUrl === null ||
1018 pullRequestKey === null ||
1019 - sourceControlClients.canonicalRepositoryKey(pullRequestKey) !==
1020 - sourceControlClients.canonicalRepositoryKey(
1021 - sourceControlClients.repositoryKeyFromRemote(remoteUrl),
1019 + sourceControlDefinitions.canonicalRepositoryKey(pullRequestKey) !==
1020 + sourceControlDefinitions.canonicalRepositoryKey(
1021 + sourceControlDefinitions.repositoryKeyFromRemote(remoteUrl),
1022 )
1023 ) {
1024 return yield* cause;
@@ -1187,7 +1187,7 @@ export const make = Effect.gen(function* () {
1187 >();
1188 const noteLookupState = (pr: PullRequestInfo) =>
1189 Effect.suspend(() => {
1190 - const parsed = sourceControlClients.parseChangeRequestUrl(pr.url)?.link;
1190 + const parsed = sourceControlDefinitions.parseChangeRequestUrl(pr.url)?.link;
1191 if (parsed === undefined || parsed.number !== pr.number) return Effect.void;
1192 const key = normalizeThreadPullRequestKey(parsed);
1193 const id = threadPullRequestKeyOf(key);
@@ -1431,7 +1431,7 @@ export const make = Effect.gen(function* () {
1431 remote: { readonly remoteUrl: string | null; readonly repositoryNameWithOwner: string | null },
1432 ) {
1433 const provider =
1434 - remote.remoteUrl === null ? null : sourceControlClients.recognizeRemote(remote.remoteUrl);
1434 + remote.remoteUrl === null ? null : sourceControlDefinitions.recognizeRemote(remote.remoteUrl);
1435 if (remote.remoteUrl === null || provider === null) return true;
1436 const context = { provider, remoteName, remoteUrl: remote.remoteUrl };
1437 const handle = yield* sourceControlProviders
@@ -1458,7 +1458,7 @@ export const make = Effect.gen(function* () {
1458 (yield* readConfigValueNullable(cwd, `remote.${preferredRemoteName}.url`)) ??
1459 (yield* readConfigValueNullable(cwd, "remote.origin.url"));
1460
1461 - const provider = remoteUrl ? sourceControlClients.recognizeRemote(remoteUrl) : null;
1461 + const provider = remoteUrl ? sourceControlDefinitions.recognizeRemote(remoteUrl) : null;
1462 if (!remoteUrl || provider?.kind !== "unknown") return provider;
1463 const handle = yield* sourceControlProviders
1464 .resolveHandle({
@@ -1489,7 +1489,7 @@ export const make = Effect.gen(function* () {
1489 /^https?:\/\//iu.test(remoteUrl) &&
1490 (repositoryNameWithOwner?.split("/").length ?? 0) > 2
1491 ) {
1492 - const kind = sourceControlClients.recognizeRemote(remoteUrl)?.kind;
1492 + const kind = sourceControlDefinitions.recognizeRemote(remoteUrl)?.kind;
1493 const provider =
1494 kind === undefined
1495 ? undefined
@@ -1500,7 +1500,7 @@ export const make = Effect.gen(function* () {
1500 }
1501 return {
1502 remoteUrl,
1503 - remoteUrlKey: remoteUrl ? sourceControlClients.repositoryKeyFromRemote(remoteUrl) : null,
1503 + remoteUrlKey: remoteUrl ? sourceControlDefinitions.repositoryKeyFromRemote(remoteUrl) : null,
1504 repositoryNameWithOwner,
1505 ownerLogin: parseRepositoryOwnerLogin(repositoryNameWithOwner),
1506 };
@@ -2247,7 +2247,7 @@ export const make = Effect.gen(function* () {
2247 emit: GitActionProgressEmitter,
2248 ) {
2249 const provider = yield* sourceControlProvider(cwd);
2250 - const terms = sourceControlClients.get(provider.kind).changeRequest;
2250 + const terms = sourceControlDefinitions.get(provider.kind).changeRequest;
2251 const details = yield* gitCore.statusDetails(cwd);
2252 const branch = details.branch ?? fallbackBranch;
2253 if (!branch) {
@@ -2455,7 +2455,7 @@ export const make = Effect.gen(function* () {
2455 ? Effect.succeed(null)
2456 : readConfig(`remote.${remoteName}.url`).pipe(
2457 Effect.map((remoteUrl) =>
2458 - remoteUrl ? sourceControlClients.repositoryKeyFromRemote(remoteUrl) : null,
2458 + remoteUrl ? sourceControlDefinitions.repositoryKeyFromRemote(remoteUrl) : null,
2459 ),
2460 );
2461 const remoteName = remoteNameOverride ?? (yield* readConfig(`branch.${branch}.remote`));
apps/server/src/git/linkCreatedPullRequest.ts
+4 -4
@@ -10,7 +10,7 @@ import * as Option from "effect/Option";
10
11 import * as Orchestrator from "../orchestration-v2/Orchestrator.ts";
12 import * as ProjectService from "../project/ProjectService.ts";
13 -import { sourceControlClients } from "../sourceControl/sourceControlClients.ts";
13 +import { sourceControlDefinitions } from "../sourceControl/sourceControlDefinitions.ts";
14
15 export interface CreatedPullRequestKey {
16 readonly host: string;
@@ -27,16 +27,16 @@ export function createdPullRequestKey(
27 if ((status !== "created" && status !== "opened_existing") || number === undefined || !url) {
28 return null;
29 }
30 - const parsed = sourceControlClients.parseChangeRequestUrl(url)?.link;
30 + const parsed = sourceControlDefinitions.parseChangeRequestUrl(url)?.link;
31 if (parsed !== undefined) {
32 return { host: parsed.host, repository: parsed.repository, number: parsed.number, url };
33 }
34 const identity = project?.repositoryIdentity;
35 const kind = identity?.provider;
36 - const repository = sourceControlClients.repositorySelector(identity);
36 + const repository = sourceControlDefinitions.repositorySelector(identity);
37 if (!identity || kind === undefined || repository === null) return null;
38 return {
39 - host: sourceControlClients.changeRequestHost(identity, kind),
39 + host: sourceControlDefinitions.changeRequestHost(identity, kind),
40 repository: repository.toLowerCase(),
41 number,
42 url,
apps/server/src/mcp/toolkits/pullRequests/handlers.ts
+7 -6
@@ -15,7 +15,7 @@ import * as Orchestrator from "../../../orchestration-v2/Orchestrator.ts";
15 import * as ProjectService from "../../../project/ProjectService.ts";
16 import * as PullRequestReviewGuideService from "../../../pullRequest/PullRequestReviewGuideService.ts";
17 import { pullRequestSyncKey } from "../../../pullRequest/pullRequestSyncKey.ts";
18 -import { sourceControlClients } from "../../../sourceControl/sourceControlClients.ts";
18 +import { sourceControlDefinitions } from "../../../sourceControl/sourceControlDefinitions.ts";
19 import {
20 normalizeThreadPullRequestKey,
21 resolveThreadPullRequestChains,
@@ -62,7 +62,7 @@ function projectHostAndProvider(project: OrchestrationProjectShell | undefined):
62 const kind = identity?.provider ?? null;
63 if (!identity || kind === null) return { host: null, kind: null };
64 return {
65 - host: sourceControlClients.changeRequestHost(identity, kind),
65 + host: sourceControlDefinitions.changeRequestHost(identity, kind),
66 kind,
67 };
68 }
@@ -72,7 +72,7 @@ const resolveTarget = Effect.fn("PullRequestsToolkit.resolveTarget")(function* (
72 project: OrchestrationProjectShell | undefined,
73 ) {
74 if (input.url !== undefined) {
75 - const parsed = sourceControlClients.parseChangeRequestUrl(input.url)?.link;
75 + const parsed = sourceControlDefinitions.parseChangeRequestUrl(input.url)?.link;
76 if (parsed === undefined) {
77 return yield* new PullRequestUrlInvalidError({});
78 }
@@ -89,11 +89,11 @@ const resolveTarget = Effect.fn("PullRequestsToolkit.resolveTarget")(function* (
89 const repository = input.repository.toLowerCase();
90 // Without a URL, a public forge host says what shape its change request URLs take;
91 // any other host is taken to run the project's own forge.
92 - const kind = sourceControlClients.findByPublicHost(host)?.kind ?? projectHost.kind;
92 + const kind = sourceControlDefinitions.findByPublicHost(host)?.kind ?? projectHost.kind;
93 const url =
94 kind === null
95 ? null
96 - : sourceControlClients.get(kind).changeRequestUrl({
96 + : sourceControlDefinitions.get(kind).changeRequestUrl({
97 host,
98 repository,
99 number: input.number,
@@ -171,7 +171,8 @@ function projectForPullRequest(
171 : pullRequestSyncKey(
172 {
173 projectId: project.id,
174 - repository: sourceControlClients.repositorySelector(project.repositoryIdentity) ?? "",
174 + repository:
175 + sourceControlDefinitions.repositorySelector(project.repositoryIdentity) ?? "",
176 number: 1,
177 },
178 project.repositoryIdentity,
apps/server/src/orchestration-v2/PullRequestSyncReactor.ts
+3 -3
@@ -14,7 +14,7 @@ import {
14 threadPullRequestKeysEqual,
15 visibleThreadPullRequests,
16 } from "../sourceControl/threadPullRequests.ts";
17 -import { sourceControlClients } from "../sourceControl/sourceControlClients.ts";
17 +import { sourceControlDefinitions } from "../sourceControl/sourceControlDefinitions.ts";
18 import * as Cause from "effect/Cause";
19 import * as Clock from "effect/Clock";
20 import * as Context from "effect/Context";
@@ -44,7 +44,7 @@ const QUIET_AFTER_MS = 30 * 60 * 1_000;
44 const QUIET_SYNC_INTERVAL_MS = 5 * 60 * 1_000;
45
46 const isChangeRequestCloseCommand = (command: string) =>
47 - sourceControlClients.definitions.some(
47 + sourceControlDefinitions.definitions.some(
48 (definition) => definition.changeRequestCloseCommand?.test(command) === true,
49 );
50
@@ -60,7 +60,7 @@ interface LinkEntry {
60 /** Another layer of the stack `url` belongs to, in its host's canonical shape. */
61 function siblingChangeRequestUrl(url: string, number: number): string | null {
62 if (!Number.isSafeInteger(number) || number < 1) return null;
63 - const parsed = sourceControlClients.parseChangeRequestUrl(url);
63 + const parsed = sourceControlDefinitions.parseChangeRequestUrl(url);
64 if (parsed === null) return null;
65 const { definition, link } = parsed;
66 return definition.changeRequestUrl({
apps/server/src/orchestration-v2/ThreadPullRequestService.ts
+4 -4
@@ -25,7 +25,7 @@ import * as ProjectStore from "./ProjectStore.ts";
25 import * as PullRequestService from "../pullRequest/PullRequestService.ts";
26 import * as RepositoryIdentityResolver from "../project/RepositoryIdentityResolver.ts";
27 import { forkParked } from "../serverActivation.ts";
28 -import { sourceControlClients } from "../sourceControl/sourceControlClients.ts";
28 +import { sourceControlDefinitions } from "../sourceControl/sourceControlDefinitions.ts";
29 import * as Orchestrator from "./Orchestrator.ts";
30
31 class ThreadPullRequestServiceV2 extends Context.Service<
@@ -56,8 +56,8 @@ function pullRequestMatchesProject(
56 return (
57 pullRequest.repositoryKey !== null &&
58 project.repositoryIdentity != null &&
59 - sourceControlClients.canonicalRepositoryKey(pullRequest.repositoryKey) ===
60 - sourceControlClients.canonicalRepositoryKey(project.repositoryIdentity.canonicalKey)
59 + sourceControlDefinitions.canonicalRepositoryKey(pullRequest.repositoryKey) ===
60 + sourceControlDefinitions.canonicalRepositoryKey(project.repositoryIdentity.canonicalKey)
61 );
62 }
63
@@ -75,7 +75,7 @@ const resolveProjectForPullRequestDiscovery = Effect.fn(
75 });
76 return {
77 project: { ...project, repositoryIdentity },
78 - repository: sourceControlClients.repositorySelector(repositoryIdentity),
78 + repository: sourceControlDefinitions.repositorySelector(repositoryIdentity),
79 };
80 });
81
apps/server/src/orchestration-v2/ThreadSettlementService.ts
+3 -3
@@ -26,7 +26,7 @@ import * as ServerSettings from "../serverSettings.ts";
26 import { forkParked } from "../serverActivation.ts";
27 import * as TerminalManager from "../terminal/Manager.ts";
28 import * as ProjectStore from "./ProjectStore.ts";
29 -import { sourceControlClients } from "../sourceControl/sourceControlClients.ts";
29 +import { sourceControlDefinitions } from "../sourceControl/sourceControlDefinitions.ts";
30 import * as Orchestrator from "./Orchestrator.ts";
31 import * as ProjectionStore from "./ProjectionStore.ts";
32
@@ -61,8 +61,8 @@ function pullRequestMatchesProject(
61 return (
62 pullRequest.repositoryKey !== null &&
63 project.repositoryIdentity != null &&
64 - sourceControlClients.canonicalRepositoryKey(pullRequest.repositoryKey) ===
65 - sourceControlClients.canonicalRepositoryKey(project.repositoryIdentity.canonicalKey)
64 + sourceControlDefinitions.canonicalRepositoryKey(pullRequest.repositoryKey) ===
65 + sourceControlDefinitions.canonicalRepositoryKey(project.repositoryIdentity.canonicalKey)
66 );
67 }
68
apps/server/src/project/AgentSessionScanner.ts
+2 -2
@@ -34,7 +34,7 @@ import * as ProjectStore from "../orchestration-v2/ProjectStore.ts";
34 import { resolveCodexHomeLayout } from "../provider/Drivers/CodexHomeLayout.ts";
35 import { expandHomePath } from "@t3tools/provider-core/server/pathExpansion";
36 import * as ServerSettings from "../serverSettings.ts";
37 -import { sourceControlClients } from "../sourceControl/sourceControlClients.ts";
37 +import { sourceControlDefinitions } from "../sourceControl/sourceControlDefinitions.ts";
38 import {
39 createTranscriptJsonReader,
40 createTranscriptJsonSelector,
@@ -723,7 +723,7 @@ export const make = Effect.gen(function* () {
723 _tag: "Repository",
724 git: {
725 remoteKey:
726 - originUrl === null ? null : sourceControlClients.repositoryKeyFromRemote(originUrl),
726 + originUrl === null ? null : sourceControlDefinitions.repositoryKeyFromRemote(originUrl),
727 repository: repositoryPathFromRemoteUrl(originUrl),
728 },
729 } as const;
apps/server/src/project/RepositoryIdentityResolver.ts
+4 -4
@@ -9,7 +9,7 @@ import * as Exit from "effect/Exit";
9 import * as Layer from "effect/Layer";
10
11 import * as ProcessRunner from "../processRunner.ts";
12 -import { sourceControlClients } from "../sourceControl/sourceControlClients.ts";
12 +import { sourceControlDefinitions } from "../sourceControl/sourceControlDefinitions.ts";
13 import { explicitBareRepositoryEnv } from "../vcs/VcsProcess.ts";
14 import * as HostProcess from "@t3tools/shared/HostProcess";
15
@@ -99,7 +99,7 @@ function buildRepositoryOrigin(
99 canonicalKey: string,
100 ): RepositoryIdentity["origin"] {
101 if (!originUrl) return undefined;
102 - const originKey = sourceControlClients.repositoryKeyFromRemote(originUrl);
102 + const originKey = sourceControlDefinitions.repositoryKeyFromRemote(originUrl);
103 if (originKey === canonicalKey) return undefined;
104 const displayName = repositoryPathOf(originKey, originUrl);
105 return { canonicalKey: originKey, remoteUrl: originUrl, ...(displayName ? { displayName } : {}) };
@@ -111,8 +111,8 @@ function buildRepositoryIdentity(input: {
111 readonly originUrl: string | undefined;
112 readonly rootPath: string;
113 }): RepositoryIdentity {
114 - const canonicalKey = sourceControlClients.repositoryKeyFromRemote(input.remoteUrl);
115 - const sourceControlProvider = sourceControlClients.recognizeRemote(input.remoteUrl);
114 + const canonicalKey = sourceControlDefinitions.repositoryKeyFromRemote(input.remoteUrl);
115 + const sourceControlProvider = sourceControlDefinitions.recognizeRemote(input.remoteUrl);
116 const repositoryPath = repositoryPathOf(canonicalKey, input.remoteUrl);
117 const repositoryPathSegments = repositoryPath.split("/").filter((segment) => segment.length > 0);
118 const [owner] = repositoryPathSegments;
apps/server/src/pullRequest/PullRequestReviewGuideService.ts
+3 -3
@@ -24,7 +24,7 @@ import {
24 } from "@t3tools/contracts";
25 import type { ReviewGuideStackLayer } from "@t3tools/provider-core/server/textGeneration";
26 import { resolveProjectSettings } from "@t3tools/shared/projectSettings";
27 -import { sourceControlClients } from "../sourceControl/sourceControlClients.ts";
27 +import { sourceControlDefinitions } from "../sourceControl/sourceControlDefinitions.ts";
28
29 import * as ServerConfig from "../config.ts";
30 import * as PullRequestReviewGuides from "../persistence/PullRequestReviewGuides.ts";
@@ -104,7 +104,7 @@ const make = Effect.gen(function* () {
104 {
105 projectId: ProjectId.make("own"),
106 number: key.number,
107 - repository: sourceControlClients.repositorySelector(identity) ?? "",
107 + repository: sourceControlDefinitions.repositorySelector(identity) ?? "",
108 },
109 identity,
110 );
@@ -251,7 +251,7 @@ const make = Effect.gen(function* () {
251 ),
252 );
253 const fetchAndResolve = (ref: string) => fetch([ref]).pipe(Effect.andThen(resolveHead));
254 - const headRef = sourceControlClients.get(detail.provider).changeRequestHeadRef?.(number);
254 + const headRef = sourceControlDefinitions.get(detail.provider).changeRequestHeadRef?.(number);
255 const branchRef = `refs/heads/${branch}`;
256 const checkBranch = git.execute({
257 operation: "PullRequestReviewGuideService.checkHeadBranch",
apps/server/src/pullRequest/PullRequestService.ts
+19 -17
@@ -75,7 +75,7 @@ import {
75 type ThreadPullRequestKey,
76 } from "@t3tools/contracts";
77 import { resolveProjectSettings } from "@t3tools/shared/projectSettings";
78 -import { sourceControlClients } from "../sourceControl/sourceControlClients.ts";
78 +import { sourceControlDefinitions } from "../sourceControl/sourceControlDefinitions.ts";
79
80 import * as ProjectService from "../project/ProjectService.ts";
81 import * as ServerSettings from "../serverSettings.ts";
@@ -667,7 +667,7 @@ function sshRemoteHidesWebHost(
667 ) {
668 return (
669 identity.provider !== undefined &&
670 - sourceControlClients.find(identity.provider)?.sshRemoteHidesWebHost === true &&
670 + sourceControlDefinitions.find(identity.provider)?.sshRemoteHidesWebHost === true &&
671 isSshRemoteUrl(identity.locator.remoteUrl)
672 );
673 }
@@ -722,10 +722,10 @@ export const make = Effect.gen(function* () {
722 const identity = project.repositoryIdentity;
723 if (
724 (identity?.provider !== "unknown" && !(identity && sshRemoteHidesWebHost(identity))) ||
725 - sourceControlClients.repositorySelector(project.repositoryIdentity) === null
725 + sourceControlDefinitions.repositorySelector(project.repositoryIdentity) === null
726 )
727 continue;
728 - const host = sourceControlClients.changeRequestHost(identity, "unknown");
728 + const host = sourceControlDefinitions.changeRequestHost(identity, "unknown");
729 if (
730 filter.host !== undefined &&
731 host !== "unknown" &&
@@ -736,7 +736,7 @@ export const make = Effect.gen(function* () {
736 continue;
737 }
738 const { remoteName, remoteUrl } = identity.locator;
739 - const provider = sourceControlClients.recognizeRemote(remoteUrl);
739 + const provider = sourceControlDefinitions.recognizeRemote(remoteUrl);
740 if (provider !== null) {
741 const candidates = refinements.get(provider.baseUrl);
742 const candidate = { project, provider, remoteName, remoteUrl };
@@ -754,7 +754,7 @@ export const make = Effect.gen(function* () {
754 sourceControlProviders.resolveHandle({
755 cwd: project.workspaceRoot,
756 context: {
757 - provider: sourceControlClients.find(provider.kind)?.sshRemoteHidesWebHost
757 + provider: sourceControlDefinitions.find(provider.kind)?.sshRemoteHidesWebHost
758 ? { ...provider, kind: SourceControlProviderKind.make("unknown") }
759 : provider,
760 remoteName,
@@ -828,19 +828,21 @@ export const make = Effect.gen(function* () {
828 if (filter.projectIds !== undefined && !filter.projectIds.includes(project.id)) continue;
829 const identity = project.repositoryIdentity;
830 let kind = identity?.provider;
831 - const repository = sourceControlClients.repositorySelector(project.repositoryIdentity);
831 + const repository = sourceControlDefinitions.repositorySelector(
832 + project.repositoryIdentity,
833 + );
834 if (!identity || kind === undefined || repository === null) continue;
835 let refinedProvider: SourceControlProviderInfo | null | undefined;
836 if (kind === "unknown" || sshRemoteHidesWebHost(identity)) {
835 - const provider = sourceControlClients.recognizeRemote(identity.locator.remoteUrl);
837 + const provider = sourceControlDefinitions.recognizeRemote(identity.locator.remoteUrl);
838 refinedProvider = provider === null ? null : refinedProviders.get(provider.baseUrl);
839 kind = refinedProvider?.kind ?? kind;
840 }
841 const host =
842 refinedProvider &&
841 - sourceControlClients.find(refinedProvider.kind)?.sshRemoteHidesWebHost
843 + sourceControlDefinitions.find(refinedProvider.kind)?.sshRemoteHidesWebHost
844 ? new URL(refinedProvider.baseUrl).host.toLowerCase()
843 - : sourceControlClients.changeRequestHost(identity, kind);
845 + : sourceControlDefinitions.changeRequestHost(identity, kind);
846 if (filter.host !== undefined && host !== filter.host.toLowerCase()) {
847 continue;
848 }
@@ -869,11 +871,11 @@ export const make = Effect.gen(function* () {
871 host,
872 remote:
873 repositoryKey ??
872 - sourceControlClients.repositoryKeyFromRemote(`https://${host}/${repository}`),
874 + sourceControlDefinitions.repositoryKeyFromRemote(`https://${host}/${repository}`),
875 repositoryKey:
876 repositoryKey === null
877 ? null
876 - : sourceControlClients.canonicalRepositoryKey(repositoryKey.toLowerCase()),
878 + : sourceControlDefinitions.canonicalRepositoryKey(repositoryKey.toLowerCase()),
879 });
880 }
881 return { supported, unimplemented, viewerRoots };
@@ -905,12 +907,12 @@ export const make = Effect.gen(function* () {
907 );
908 }
909 const referenceKey = `${host}/${repository}`.toLowerCase();
908 - const repositoryKey = sourceControlClients.canonicalRepositoryKey(referenceKey);
910 + const repositoryKey = sourceControlDefinitions.canonicalRepositoryKey(referenceKey);
911 // A host that spells one repository several ways (Azure's SSH and legacy clone hosts)
912 // can differ from the browser URL's host. Compare the complete repository identity
913 // before narrowing those checkouts by host.
914 return listWorkspaceProjects(
913 - sourceControlClients.findByRepositoryKey(referenceKey) ? {} : { host },
915 + sourceControlDefinitions.findByRepositoryKey(referenceKey) ? {} : { host },
916 ).pipe(
917 Effect.flatMap(({ supported }) => {
918 const onHost = supported.filter((candidate) => candidate.host === host);
@@ -927,7 +929,7 @@ export const make = Effect.gen(function* () {
929 onHost.find((candidate) => candidate.repositoryKey === null);
930 if (route === undefined) {
931 return Effect.gen(function* () {
930 - const publicHost = sourceControlClients.findByPublicHost(host);
932 + const publicHost = sourceControlDefinitions.findByPublicHost(host);
933 const api = publicHost === undefined ? null : registry.get(publicHost.kind);
934 if (api?.readsPublicHostWithoutCheckout) {
935 const selected = yield* projects.getShell(ref.projectId).pipe(
@@ -947,7 +949,7 @@ export const make = Effect.gen(function* () {
949 api: withRateLimitBackoff(api, host, rateLimits),
950 repository,
951 host,
950 - remote: sourceControlClients.repositoryKeyFromRemote(
952 + remote: sourceControlDefinitions.repositoryKeyFromRemote(
953 `https://${host}/${repository}`,
954 ),
955 repositoryKey: null,
@@ -964,7 +966,7 @@ export const make = Effect.gen(function* () {
966 : {
967 ...route,
968 repository,
967 - remote: sourceControlClients.repositoryKeyFromRemote(
969 + remote: sourceControlDefinitions.repositoryKeyFromRemote(
970 `https://${host}/${repository}`,
971 ),
972 },
apps/server/src/pullRequest/pullRequestSyncKey.ts
+5 -3
@@ -1,5 +1,5 @@
1 import type { PullRequestRef, RepositoryIdentity, ThreadPullRequestKey } from "@t3tools/contracts";
2 -import { sourceControlClients } from "../sourceControl/sourceControlClients.ts";
2 +import { sourceControlDefinitions } from "../sourceControl/sourceControlDefinitions.ts";
3 import { normalizeThreadPullRequestKey } from "../sourceControl/threadPullRequests.ts";
4
5 export function pullRequestSyncKey(
@@ -7,11 +7,13 @@ export function pullRequestSyncKey(
7 identity?: RepositoryIdentity | null,
8 ): ThreadPullRequestKey | null {
9 const host = identity
10 - ? sourceControlClients.changeRequestHost(identity, identity.provider)
10 + ? sourceControlDefinitions.changeRequestHost(identity, identity.provider)
11 : undefined;
12 // A host whose tools select a repository by something other than its path (Azure DevOps takes
13 // the bare name) can only key such a reference through the project's own repository.
14 - const definition = identity?.provider ? sourceControlClients.find(identity.provider) : undefined;
14 + const definition = identity?.provider
15 + ? sourceControlDefinitions.find(identity.provider)
16 + : undefined;
17 if (identity && definition?.repositorySelector && !reference.repository.includes("/")) {
18 if (
19 reference.repository.toLowerCase() !==
apps/server/src/server.ts
+1 -1
@@ -60,7 +60,7 @@ import * as AcpRegistrySupport from "@t3tools/provider-acp-registry/server/AcpRe
60 import * as CheckpointDiffQuery from "./checkpointing/CheckpointDiffQuery.ts";
61 import * as CheckpointStore from "./checkpointing/CheckpointStore.ts";
62 import * as SourceControlBuiltInDrivers from "./sourceControl/builtInDrivers.ts";
63 -import { BUILT_IN_SOURCE_CONTROL_DRIVER_LIST } from "./sourceControl/sourceControlClients.ts";
63 +import { BUILT_IN_SOURCE_CONTROL_DRIVER_LIST } from "./sourceControl/sourceControlDefinitions.ts";
64 import * as TextGeneration from "./textGeneration/TextGeneration.ts";
65 import * as ProviderInstanceRegistryHydration from "./provider/ProviderInstanceRegistryHydration.ts";
66 import * as ProjectSettingsOverrideSweep from "./provider/ProjectSettingsOverrideSweep.ts";
apps/server/src/sourceControl/SourceControlProviderRegistry.ts
+3 -3
@@ -15,7 +15,7 @@ import {
15 import type {} from "@t3tools/contracts";
16
17 import * as BuiltInDrivers from "./builtInDrivers.ts";
18 -import { sourceControlClients } from "./sourceControlClients.ts";
18 +import { sourceControlDefinitions } from "./sourceControlDefinitions.ts";
19 import * as SourceControlProvider from "@t3tools/source-control-core/server/SourceControlProvider";
20 import {
21 probeSourceControlProvider,
@@ -144,7 +144,7 @@ function selectProviderContext(
144 ): SourceControlProvider.SourceControlProviderContext | null {
145 const candidates: Array<SourceControlProvider.SourceControlProviderContext> = [];
146 for (const remote of remotes) {
147 - const provider = sourceControlClients.recognizeRemote(remote.url);
147 + const provider = sourceControlDefinitions.recognizeRemote(remote.url);
148 if (provider) {
149 candidates.push({
150 provider,
@@ -337,7 +337,7 @@ export const makeWithProviders = Effect.fn("makeSourceControlProviderRegistryWit
337 if (input.url.protocol !== "https:" || input.url.username || input.url.password) {
338 return undefined;
339 }
340 - const kind = sourceControlClients.recognizeRemote(input.url.href)?.kind;
340 + const kind = sourceControlDefinitions.recognizeRemote(input.url.href)?.kind;
341 return kind ? providers.get(kind)?.resolveLink?.(input) : undefined;
342 },
343 get,
apps/server/src/sourceControl/builtInDrivers.ts
+1 -1
@@ -8,7 +8,7 @@ import * as Effect from "effect/Effect";
8 import * as Layer from "effect/Layer";
9
10 import * as ServerSourceControlHost from "./ServerSourceControlHost.ts";
11 -import { BUILT_IN_SOURCE_CONTROL_DRIVER_LIST } from "./sourceControlClients.ts";
11 +import { BUILT_IN_SOURCE_CONTROL_DRIVER_LIST } from "./sourceControlDefinitions.ts";
12
13 export interface SourceControlDriverEntry {
14 readonly driver: Pick<SourceControlDriver, "kind" | "definition">;
apps/server/src/sourceControl/sourceControlDefinitions.ts renamed
+2 -2
@@ -1,6 +1,6 @@
1 import * as AzureDevOpsDriver from "@t3tools/source-control-azure-devops/server/driver";
2 import * as BitbucketDriver from "@t3tools/source-control-bitbucket/server/driver";
3 -import { makeSourceControlClientRegistry } from "@t3tools/source-control-core/client/definition";
3 +import { makeSourceControlDefinitionRegistry } from "@t3tools/source-control-core/shared/definition";
4 import * as ForgejoDriver from "@t3tools/source-control-forgejo/server/driver";
5 import * as GitCafeDriver from "@t3tools/source-control-gitcafe/server/driver";
6 import * as GitHubDriver from "@t3tools/source-control-github/server/driver";
@@ -22,7 +22,7 @@ export const BUILT_IN_SOURCE_CONTROL_DRIVER_LIST = [
22 AzureDevOpsDriver.driver,
23 ] as const;
24
25 -export const sourceControlClients = makeSourceControlClientRegistry(
25 +export const sourceControlDefinitions = makeSourceControlDefinitionRegistry(
26 BUILT_IN_SOURCE_CONTROL_DRIVER_LIST.map((driver) => driver.definition),
27 {
28 claimChangeRequestUrlsFirst: [GitCafeDriver.driver.kind],
apps/server/src/sourceControl/sourceControlHostSecrets.ts
+2 -2
@@ -1,12 +1,12 @@
1 import { secretSettingsFields } from "@t3tools/contracts";
2
3 -import { sourceControlClients } from "./sourceControlClients.ts";
3 +import { sourceControlDefinitions } from "./sourceControlDefinitions.ts";
4
5 export const SOURCE_CONTROL_HOST_SECRET_FIELDS: ReadonlyMap<
6 string,
7 ReadonlyArray<string>
8 > = new Map(
9 - sourceControlClients.definitions.flatMap((definition) => {
9 + sourceControlDefinitions.definitions.flatMap((definition) => {
10 const fields = definition.settings ? secretSettingsFields(definition.settings) : [];
11 return fields.length > 0 ? [[definition.kind, fields] as const] : [];
12 }),
apps/server/src/sourceControl/threadPullRequests.ts
+3 -3
@@ -1,6 +1,6 @@
1 -import { makeThreadPullRequests } from "@t3tools/source-control-core/client/threadPullRequests";
1 +import { makeThreadPullRequests } from "@t3tools/source-control-core/shared/threadPullRequests";
2
3 -import { sourceControlClients } from "./sourceControlClients.ts";
3 +import { sourceControlDefinitions } from "./sourceControlDefinitions.ts";
4
5 export { visibleThreadPullRequests } from "@t3tools/shared/threadPullRequests";
6
@@ -12,4 +12,4 @@ export const {
12 resolveThreadPullRequestChains,
13 threadPullRequestsOf,
14 applyThreadPullRequestLinkUpdate,
15 -} = makeThreadPullRequests(sourceControlClients);
15 +} = makeThreadPullRequests(sourceControlDefinitions);
apps/server/src/vcs/GitVcsDriverCore.ts
+3 -3
@@ -50,7 +50,7 @@ import {
50 parseRemoteRefWithRemoteNames,
51 } from "../git/remoteRefs.ts";
52 import * as ServerConfig from "../config.ts";
53 -import { sourceControlClients } from "../sourceControl/sourceControlClients.ts";
53 +import { sourceControlDefinitions } from "../sourceControl/sourceControlDefinitions.ts";
54
55 const DEFAULT_TIMEOUT_MS = 30_000;
56 /** T3's record of the branch, named as on the host, that a branch was cut from. */
@@ -1735,7 +1735,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
1735 "ensureRemote",
1736 )(function* (input) {
1737 const preferredName = sanitizeRemoteName(input.preferredName);
1738 - const normalizedTargetUrl = sourceControlClients.repositoryKeyFromRemote(input.url);
1738 + const normalizedTargetUrl = sourceControlDefinitions.repositoryKeyFromRemote(input.url);
1739 const remoteFetchUrls = yield* runGitStdout(
1740 "GitVcsDriver.ensureRemote.listRemoteUrls",
1741 input.cwd,
@@ -1743,7 +1743,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
1743 ).pipe(Effect.map((stdout) => parseRemoteFetchUrls(stdout)));
1744
1745 for (const [remoteName, remoteUrl] of remoteFetchUrls.entries()) {
1746 - if (sourceControlClients.repositoryKeyFromRemote(remoteUrl) === normalizedTargetUrl) {
1746 + if (sourceControlDefinitions.repositoryKeyFromRemote(remoteUrl) === normalizedTargetUrl) {
1747 return remoteName;
1748 }
1749 }
apps/web/src/components/pullRequest/pullRequestLinkContextMenu.ts
+2 -2
@@ -1,6 +1,6 @@
1 import type { ContextMenuItem } from "@t3tools/contracts";
2 import {
3 - type SourceControlClientDefinition,
3 + type SourceControlDefinition,
4 UNKNOWN_SOURCE_CONTROL_CLIENT,
5 } from "@t3tools/client-runtime/source-control-clients";
6
@@ -11,7 +11,7 @@ import { toastManager } from "../ui/toast";
11
12 export type PullRequestLinkContextMenuAction = "copy-link" | "open-external";
13
14 -export const openOnHostLabel = (host: SourceControlClientDefinition): string =>
14 +export const openOnHostLabel = (host: SourceControlDefinition): string =>
15 host === UNKNOWN_SOURCE_CONTROL_CLIENT ? "Open on host" : `Open on ${host.label}`;
16
17 function pullRequestLinkContextMenuItems(
apps/web/src/components/settings/SourceControlAccountSettings.tsx
+2 -2
@@ -11,7 +11,7 @@ import { Switch } from "../ui/switch";
11 import { groupHostAccounts, nextHostAccountChoices } from "./SourceControlAccountSettings.logic";
12 import {
13 readHostCredentialSettings,
14 - type SourceControlClientDefinition,
14 + type SourceControlDefinition,
15 type SourceControlHostCredentials,
16 } from "@t3tools/client-runtime/source-control-clients";
17 import { redactedPlaceholder } from "./RedactedSensitiveText";
@@ -44,7 +44,7 @@ export function SourceControlAccountSettings({
44 onSaved,
45 }: {
46 readonly environmentId: EnvironmentId;
47 - readonly definition: SourceControlClientDefinition;
47 + readonly definition: SourceControlDefinition;
48 readonly credentials: SourceControlHostCredentials;
49 readonly auth: SourceControlProviderAuth;
50 readonly onSaved: () => void;
apps/web/src/components/settings/SourceControlHostSettings.tsx
+3 -3
@@ -1,5 +1,5 @@
1 import type { EnvironmentId } from "@t3tools/contracts";
2 -import type { SourceControlClientDefinition } from "@t3tools/client-runtime/source-control-clients";
2 +import type { SourceControlDefinition } from "@t3tools/client-runtime/source-control-clients";
3 import { useState } from "react";
4
5 import { useEnvironmentSettings } from "../../hooks/useSettings";
@@ -14,8 +14,8 @@ export function SourceControlHostSettings({
14 onSaved,
15 }: {
16 readonly environmentId: EnvironmentId;
17 - readonly definition: SourceControlClientDefinition & {
18 - readonly settings: NonNullable<SourceControlClientDefinition["settings"]>;
17 + readonly definition: SourceControlDefinition & {
18 + readonly settings: NonNullable<SourceControlDefinition["settings"]>;
19 };
20 readonly onSaved: () => void;
21 }) {
apps/web/src/components/settings/SourceControlTokenSettings.tsx
+2 -2
@@ -5,7 +5,7 @@ import { useState } from "react";
5 import { useEnvironmentSettings } from "../../hooks/useSettings";
6 import {
7 readHostCredentialSettings,
8 - type SourceControlClientDefinition,
8 + type SourceControlDefinition,
9 type SourceControlHostCredentials,
10 } from "@t3tools/client-runtime/source-control-clients";
11 import { serverEnvironment } from "../../state/server";
@@ -22,7 +22,7 @@ export function SourceControlTokenSettings({
22 onSaved,
23 }: {
24 readonly environmentId: EnvironmentId;
25 - readonly definition: SourceControlClientDefinition;
25 + readonly definition: SourceControlDefinition;
26 readonly credentials: SourceControlHostCredentials;
27 readonly onSaved: () => void;
28 }) {
apps/web/src/components/settings/settingsSearch.ts
+2 -2
@@ -6,7 +6,7 @@ import type { EnvironmentId } from "@t3tools/contracts";
6 import type { EnvironmentConnectionPhase } from "@t3tools/client-runtime/connection";
7 import {
8 sourceControlClients,
9 - type SourceControlClientDefinition,
9 + type SourceControlDefinition,
10 } from "@t3tools/client-runtime/source-control-clients";
11 import { DEFAULT_KEYBINDINGS } from "@t3tools/shared/keybindings";
12 import { commandLabel } from "./KeybindingsSettings.logic";
@@ -116,7 +116,7 @@ export function sourceControlHostSettingsSearchId(kind: string) {
116
117 /** Each host's own settings: its accounts and token, or the fields of its settings form. */
118 export function sourceControlHostSearchItems(
119 - definitions: ReadonlyArray<SourceControlClientDefinition>,
119 + definitions: ReadonlyArray<SourceControlDefinition>,
120 ): ReadonlyArray<
121 SettingsSearchItem & { readonly id: ReturnType<typeof sourceControlHostSettingsSearchId> }
122 > {
apps/web/src/sourceControlPresentation.tsx
+5 -5
@@ -3,7 +3,7 @@ import type { SourceControlProviderInfo } from "@t3tools/contracts";
3 import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
4 import type {
5 ChangeRequestTerminology,
6 - SourceControlClientDefinition,
6 + SourceControlDefinition,
7 } from "@t3tools/client-runtime/source-control-clients";
8 import { PullRequestGlyph } from "~/components/pullRequest/pullRequestIcons";
9 import { SourceControlIconArtwork } from "./components/SourceControlIconArtwork";
@@ -12,10 +12,10 @@ export type { ChangeRequestTerminology } from "@t3tools/client-runtime/source-co
12
13 type SourceControlIcon = ElementType<{ className?: string }>;
14
15 -const SOURCE_CONTROL_ICONS = new WeakMap<SourceControlClientDefinition, SourceControlIcon>();
15 +const SOURCE_CONTROL_ICONS = new WeakMap<SourceControlDefinition, SourceControlIcon>();
16
17 /** One component per definition, so a host's icon keeps its identity across renders. */
18 -export function sourceControlIcon(definition: SourceControlClientDefinition): SourceControlIcon {
18 +export function sourceControlIcon(definition: SourceControlDefinition): SourceControlIcon {
19 const artwork = definition.icon;
20 if (artwork === null) return PullRequestGlyph.pullRequest;
21 let Icon = SOURCE_CONTROL_ICONS.get(definition);
@@ -29,14 +29,14 @@ export function sourceControlIcon(definition: SourceControlClientDefinition): So
29 }
30
31 export interface SourceControlPresentation {
32 - readonly definition: SourceControlClientDefinition;
32 + readonly definition: SourceControlDefinition;
33 readonly providerName: string;
34 readonly terminology: ChangeRequestTerminology;
35 readonly Icon: SourceControlIcon;
36 }
37
38 function presentDefinition(
39 - definition: SourceControlClientDefinition,
39 + definition: SourceControlDefinition,
40 providerName: string,
41 ): SourceControlPresentation {
42 return {
docs/internals/overview.md
+1 -1
@@ -90,7 +90,7 @@ and inactivity settings without a connected client. Merge notifications invalida
90 and trigger a check. A merge outside T3, such as an agent running `gh pr merge`, sends no
91 notification, so the [PR sync reactor](../../apps/server/src/orchestration-v2/PullRequestSyncReactor.ts)
92 re-reads a thread's open links when a run that ran a merge or close command ends. Each forge's
93 -client definition names its CLI's commands in `changeRequestCloseCommand`. The guarded
93 +definition names its CLI's commands in `changeRequestCloseCommand`. The guarded
94 `thread.auto-settle` command rejects newer activity, explicit settlement overrides, and live or
95 blocked work. It records the activity timestamp for stable
96 sorting and detaches idle provider sessions. Clients render the persisted result; they do not
packages/client-runtime/src/changeRequestLinks.ts
+1 -1
@@ -4,7 +4,7 @@ import type {
4 PullRequestRef,
5 RepositoryIdentity,
6 } from "@t3tools/contracts";
7 -import type { ChangeRequestLink } from "@t3tools/source-control-core/client/definition";
7 +import type { ChangeRequestLink } from "@t3tools/source-control-core/shared/definition";
8
9 import { sourceControlClients } from "./sourceControlClients.ts";
10
packages/client-runtime/src/operations/projects.ts
+2 -2
@@ -25,7 +25,7 @@ import {
25 } from "../state/projects.ts";
26 import type { EnvironmentProject } from "../state/models.ts";
27 import { sourceControlClients } from "../sourceControlClients.ts";
28 -import type { SourceControlClientDefinition } from "../sourceControlClients.ts";
28 +import type { SourceControlDefinition } from "../sourceControlClients.ts";
29
30 export type AddProjectRemoteSource = SourceControlProviderKind | "url";
31
@@ -204,7 +204,7 @@ export function getNewProjectPathPreview(newProjectsRoot: string, name: string):
204 }
205
206 export interface NewProjectPublishTarget {
207 - readonly definition: SourceControlClientDefinition;
207 + readonly definition: SourceControlDefinition;
208 readonly owner: string | null;
209 }
210
packages/client-runtime/src/sourceControlClients.ts
+11 -11
@@ -1,10 +1,10 @@
1 -import * as AzureDevOps from "@t3tools/source-control-azure-devops/client/definition";
2 -import * as Bitbucket from "@t3tools/source-control-bitbucket/client/definition";
1 +import * as AzureDevOps from "@t3tools/source-control-azure-devops/shared/definition";
2 +import * as Bitbucket from "@t3tools/source-control-bitbucket/shared/definition";
3 import {
4 HostCredentialSettings,
5 - makeSourceControlClientRegistry,
5 + makeSourceControlDefinitionRegistry,
6 readSourceControlHostSettings,
7 -} from "@t3tools/source-control-core/client/definition";
7 +} from "@t3tools/source-control-core/shared/definition";
8 import type { ServerSettings } from "@t3tools/contracts";
9
10 export {
@@ -16,14 +16,14 @@ export {
16 type HostCredentialSettings,
17 type ParsedChangeRequestUrl,
18 type ReferenceAutolink,
19 - type SourceControlClientDefinition,
19 + type SourceControlDefinition,
20 type SourceControlHostCredentials,
21 type SourceControlIcon,
22 -} from "@t3tools/source-control-core/client/definition";
23 -import * as Forgejo from "@t3tools/source-control-forgejo/client/definition";
24 -import * as GitCafe from "@t3tools/source-control-gitcafe/client/definition";
25 -import * as GitHub from "@t3tools/source-control-github/client/definition";
26 -import * as GitLab from "@t3tools/source-control-gitlab/client/definition";
22 +} from "@t3tools/source-control-core/shared/definition";
23 +import * as Forgejo from "@t3tools/source-control-forgejo/shared/definition";
24 +import * as GitCafe from "@t3tools/source-control-gitcafe/shared/definition";
25 +import * as GitHub from "@t3tools/source-control-github/shared/definition";
26 +import * as GitLab from "@t3tools/source-control-gitlab/shared/definition";
27
28 /**
29 * GitHub comes first because a repository that has not reported its host yet reads as GitHub,
@@ -42,7 +42,7 @@ const BUILT_IN_SOURCE_CONTROL_CLIENTS = [
42 AzureDevOps.definition,
43 ];
44
45 -export const sourceControlClients = makeSourceControlClientRegistry(
45 +export const sourceControlClients = makeSourceControlDefinitionRegistry(
46 BUILT_IN_SOURCE_CONTROL_CLIENTS,
47 {
48 claimChangeRequestUrlsFirst: [GitCafe.definition.kind],
packages/client-runtime/src/threadPullRequests.ts
+2 -2
@@ -1,4 +1,4 @@
1 -import { makeThreadPullRequests } from "@t3tools/source-control-core/client/threadPullRequests";
1 +import { makeThreadPullRequests } from "@t3tools/source-control-core/shared/threadPullRequests";
2
3 import { sourceControlClients } from "./sourceControlClients.ts";
4
@@ -12,7 +12,7 @@ export {
12 type ThreadCurrentPullRequest,
13 type ThreadPullRequestBadge,
14 type ThreadPullRequestChain,
15 -} from "@t3tools/source-control-core/client/threadPullRequests";
15 +} from "@t3tools/source-control-core/shared/threadPullRequests";
16
17 export const {
18 normalizeThreadPullRequestKey,
packages/source-control-azure-devops/package.json
+3 -3
@@ -3,9 +3,9 @@
3 "private": true,
4 "type": "module",
5 "exports": {
6 - "./client/definition": {
7 - "types": "./src/client/definition.ts",
8 - "import": "./src/client/definition.ts"
6 + "./shared/definition": {
7 + "types": "./src/shared/definition.ts",
8 + "import": "./src/shared/definition.ts"
9 },
10 "./server/driver": {
11 "types": "./src/server/driver.ts",
packages/source-control-azure-devops/src/server/AzureDevOpsPullRequestProvider.ts
+1 -1
@@ -33,7 +33,7 @@ import type {
33 AzureDevOpsPullRequest,
34 AzureDevOpsRepositoryLocation,
35 } from "./azureDevOpsPullRequestJson.ts";
36 -import { definition } from "../client/definition.ts";
36 +import { definition } from "../shared/definition.ts";
37
38 /**
39 * Every file is two `az` invocations, each paying a Python interpreter's start-up, so reading them
packages/source-control-azure-devops/src/server/driver.ts
+1 -1
@@ -5,7 +5,7 @@ import {
5 import * as Effect from "effect/Effect";
6 import * as Layer from "effect/Layer";
7
8 -import { definition } from "../client/definition.ts";
8 +import { definition } from "../shared/definition.ts";
9
10 import * as AzureDevOpsCli from "./AzureDevOpsCli.ts";
11 import * as AzureDevOpsPullRequestCli from "./AzureDevOpsPullRequestCli.ts";
packages/source-control-azure-devops/src/shared/definition.test.ts renamed
+5 -5
@@ -1,9 +1,9 @@
1 import { SourceControlProviderKind } from "@t3tools/contracts";
2 -import type { ChangeRequestProjectIdentity } from "@t3tools/source-control-core/client/definition";
2 +import type { ChangeRequestProjectIdentity } from "@t3tools/source-control-core/shared/definition";
3 import {
4 - makeSourceControlClientRegistry,
4 + makeSourceControlDefinitionRegistry,
5 recognizeRemoteWith,
6 -} from "@t3tools/source-control-core/client/definition";
6 +} from "@t3tools/source-control-core/shared/definition";
7 import { describe, expect, it } from "vite-plus/test";
8
9 import { definition } from "./definition.ts";
@@ -123,7 +123,7 @@ describe("Azure DevOps remotes", () => {
123 });
124
125 describe("Azure DevOps repository keys", () => {
126 - const registry = makeSourceControlClientRegistry([definition]);
126 + const registry = makeSourceControlDefinitionRegistry([definition]);
127
128 it("gives a repository the same key over SSH as over HTTPS", () => {
129 for (const remote of [
@@ -167,7 +167,7 @@ describe("Azure DevOps repository keys", () => {
167 });
168
169 describe("Azure DevOps repository selector", () => {
170 - const registry = makeSourceControlClientRegistry([definition]);
170 + const registry = makeSourceControlDefinitionRegistry([definition]);
171
172 it("names a repository by its own name, not its project path", () => {
173 // `az repos pr list --repository` takes a name and detects the organisation and project from
packages/source-control-azure-devops/src/shared/definition.ts renamed
+3 -3
@@ -1,11 +1,11 @@
1 import { SourceControlProviderKind } from "@t3tools/contracts";
2 import {
3 changeRequestUrlBelow,
4 - defineSourceControlClient,
4 + defineSourceControl,
5 isChangeRequestAuthorityOfProject,
6 parseChangeRequestPath,
7 remoteWebOrigin,
8 -} from "@t3tools/source-control-core/client/definition";
8 +} from "@t3tools/source-control-core/shared/definition";
9 import { icon } from "./icon.ts";
10
11 // Azure DevOps Server runs on any hostname; its `_git` route identifies it.
@@ -63,7 +63,7 @@ function checkoutCommandId(args: string): string | null {
63
64 const KIND = SourceControlProviderKind.make("azure-devops");
65
66 -export const definition = defineSourceControlClient({
66 +export const definition = defineSourceControl({
67 kind: KIND,
68 label: "Azure DevOps",
69 pickerLabel: "Azure DevOps",
packages/source-control-azure-devops/src/shared/icon.ts renamed
+1 -1
@@ -1,4 +1,4 @@
1 -import type { SourceControlIcon } from "@t3tools/source-control-core/client/definition";
1 +import type { SourceControlIcon } from "@t3tools/source-control-core/shared/definition";
2
3 // Microsoft Azure DevOps mark via selfhst/icons (CC BY 4.0): https://github.com/selfhst/icons/blob/main/svg/azure-devops.svg
4 export const icon: SourceControlIcon = {
packages/source-control-bitbucket/package.json
+3 -3
@@ -3,9 +3,9 @@
3 "private": true,
4 "type": "module",
5 "exports": {
6 - "./client/definition": {
7 - "types": "./src/client/definition.ts",
8 - "import": "./src/client/definition.ts"
6 + "./shared/definition": {
7 + "types": "./src/shared/definition.ts",
8 + "import": "./src/shared/definition.ts"
9 },
10 "./server/driver": {
11 "types": "./src/server/driver.ts",
packages/source-control-bitbucket/src/server/BitbucketApi.ts
+4 -4
@@ -18,8 +18,8 @@ import {
18 import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http";
19 import { sanitizeBranchFragment } from "@t3tools/shared/git";
20 import { isSshRemoteUrl } from "@t3tools/shared/sourceControl";
21 -import { recognizeRemoteWith } from "@t3tools/source-control-core/client/definition";
22 -import { definition } from "../client/definition.ts";
21 +import { recognizeRemoteWith } from "@t3tools/source-control-core/shared/definition";
22 +import { definition } from "../shared/definition.ts";
23
24 import {
25 BitbucketPullRequestListSchema,
@@ -30,9 +30,9 @@ import {
30 import { collectUint8StreamText } from "@t3tools/provider-core/server/collectStreamText";
31 import * as SourceControlProvider from "@t3tools/source-control-core/server/SourceControlProvider";
32 import * as SourceControlHost from "@t3tools/source-control-core/server/SourceControlHost";
33 -import { readSourceControlHostSettings } from "@t3tools/source-control-core/client/definition";
33 +import { readSourceControlHostSettings } from "@t3tools/source-control-core/shared/definition";
34
35 -import * as BitbucketClient from "../client/definition.ts";
35 +import * as BitbucketClient from "../shared/definition.ts";
36 import * as SourceControlRateLimit from "@t3tools/source-control-core/server/SourceControlRateLimit";
37
38 const DEFAULT_API_BASE_URL = "https://api.bitbucket.org/2.0";
packages/source-control-bitbucket/src/server/BitbucketPullRequestProvider.ts
+1 -1
@@ -12,7 +12,7 @@ import {
12 type PullRequestProviderApi,
13 } from "@t3tools/source-control-core/server/PullRequestProvider";
14 import type { BitbucketPullRequest } from "./bitbucketPullRequestJson.ts";
15 -import { definition } from "../client/definition.ts";
15 +import { definition } from "../shared/definition.ts";
16
17 const CAPABILITIES: PullRequestCapabilities = {
18 diff: true,
packages/source-control-bitbucket/src/server/driver.ts
+1 -1
@@ -5,7 +5,7 @@ import {
5 import * as Effect from "effect/Effect";
6 import * as Layer from "effect/Layer";
7
8 -import { definition } from "../client/definition.ts";
8 +import { definition } from "../shared/definition.ts";
9
10 import * as BitbucketApi from "./BitbucketApi.ts";
11 import * as BitbucketPullRequestApi from "./BitbucketPullRequestApi.ts";
packages/source-control-bitbucket/src/shared/definition.test.ts renamed
+1 -1
@@ -1,4 +1,4 @@
1 -import { recognizeRemoteWith } from "@t3tools/source-control-core/client/definition";
1 +import { recognizeRemoteWith } from "@t3tools/source-control-core/shared/definition";
2 import { describe, expect, it } from "vite-plus/test";
3
4 import { definition } from "./definition.ts";
packages/source-control-bitbucket/src/shared/definition.ts renamed
+3 -3
@@ -7,12 +7,12 @@ import * as Effect from "effect/Effect";
7 import * as Schema from "effect/Schema";
8 import {
9 changeRequestUrlBelow,
10 - defineSourceControlClient,
10 + defineSourceControl,
11 isChangeRequestInProjectRepository,
12 isChangeRequestOnProjectHost,
13 parseChangeRequestPath,
14 projectChangeRequestHost,
15 -} from "@t3tools/source-control-core/client/definition";
15 +} from "@t3tools/source-control-core/shared/definition";
16 import { icon } from "./icon.ts";
17
18 const safeShellArgument = /^[A-Za-z0-9._/@+=,-]+$/;
@@ -63,7 +63,7 @@ export const settings = makeProviderSettingsSchema(
63 );
64 export type BitbucketSettings = typeof settings.Type;
65
66 -export const definition = defineSourceControlClient({
66 +export const definition = defineSourceControl({
67 kind: KIND,
68 label: "Bitbucket",
69 pickerLabel: "Bitbucket",
packages/source-control-bitbucket/src/shared/icon.ts renamed
+1 -1
@@ -1,4 +1,4 @@
1 -import type { SourceControlIcon } from "@t3tools/source-control-core/client/definition";
1 +import type { SourceControlIcon } from "@t3tools/source-control-core/shared/definition";
2
3 export const icon: SourceControlIcon = {
4 viewBox: "8.4 14.39 2481.29 2231.21",
packages/source-control-core/package.json
+6 -6
@@ -3,13 +3,13 @@
3 "private": true,
4 "type": "module",
5 "exports": {
6 - "./client/definition": {
7 - "types": "./src/client/definition.ts",
8 - "import": "./src/client/definition.ts"
6 + "./shared/definition": {
7 + "types": "./src/shared/definition.ts",
8 + "import": "./src/shared/definition.ts"
9 },
10 - "./client/threadPullRequests": {
11 - "types": "./src/client/threadPullRequests.ts",
12 - "import": "./src/client/threadPullRequests.ts"
10 + "./shared/threadPullRequests": {
11 + "types": "./src/shared/threadPullRequests.ts",
12 + "import": "./src/shared/threadPullRequests.ts"
13 },
14 "./server/diffFileRevisions": {
15 "types": "./src/server/diffFileRevisions.ts",
packages/source-control-core/src/server/driver.ts
+2 -2
@@ -6,7 +6,7 @@ import type { HttpClient, HttpClientError, HttpClientResponse } from "effect/htt
6 import * as Layer from "effect/Layer";
7 import type * as Scope from "effect/Scope";
8
9 -import type { SourceControlClientDefinition } from "../client/definition.ts";
9 +import type { SourceControlDefinition } from "../shared/definition.ts";
10
11 import type { SourceControlProviderDiscoverySpec } from "./discovery.ts";
12 import type { PullRequestProviderApi } from "./PullRequestProvider.ts";
@@ -49,7 +49,7 @@ export type SourceControlDriverServices =
49
50 export interface SourceControlDriver {
51 readonly kind: SourceControlProviderKind;
52 - readonly definition: SourceControlClientDefinition;
52 + readonly definition: SourceControlDefinition;
53 /**
54 * Run once per server, in a scope that lasts as long as the server. State a host shares across
55 * everything that talks to it, such as GitHub's quota reserve and rate-limit pause, lives in
packages/source-control-core/src/shared/definition.ts renamed
+24 -20
@@ -194,7 +194,11 @@ export const hostCredentialSettingsFields = {
194 export const HostCredentialSettings = Schema.Struct(hostCredentialSettingsFields);
195 export type HostCredentialSettings = typeof HostCredentialSettings.Type;
196
197 -export interface SourceControlClientDefinition {
197 +/**
198 + * What the server and every client know about a forge. It is plain data and pure functions so
199 + * one copy serves both sides; a lint rule keeps UI runtimes out of `shared/`.
200 + */
201 +export interface SourceControlDefinition {
202 readonly kind: SourceControlProviderKind;
203 readonly label: string;
204 readonly pickerLabel: string;
@@ -348,7 +352,7 @@ export function remoteWebOrigin(host: string, remoteUrl: string | undefined): st
352 return `https://${host}`;
353 }
354
351 -export function defineSourceControlClient<const Definition extends SourceControlClientDefinition>(
355 +export function defineSourceControl<const Definition extends SourceControlDefinition>(
356 definition: Definition,
357 ): Definition {
358 return definition;
@@ -448,7 +452,7 @@ export function unknownRemoteProvider(remote: GitRemoteHost): SourceControlProvi
452
453 /** What `definition` alone makes of a remote, for a host's own code that asks only about itself. */
454 export function recognizeRemoteWith(
451 - definition: Pick<SourceControlClientDefinition, "recognizeRemote">,
455 + definition: Pick<SourceControlDefinition, "recognizeRemote">,
456 remoteUrl: string,
457 ): SourceControlProviderInfo | null {
458 const remote = parseGitRemoteHost(remoteUrl);
@@ -463,7 +467,7 @@ function defaultRepositorySelector(
467 return identity.owner && identity.name ? `${identity.owner}/${identity.name}` : null;
468 }
469
466 -export const UNKNOWN_SOURCE_CONTROL_CLIENT: SourceControlClientDefinition = {
470 +export const UNKNOWN_SOURCE_CONTROL_CLIENT: SourceControlDefinition = {
471 kind: SourceControlProviderKind.make("unknown"),
472 label: "source control",
473 pickerLabel: "source control",
@@ -502,27 +506,27 @@ export const UNKNOWN_SOURCE_CONTROL_CLIENT: SourceControlClientDefinition = {
506 };
507
508 export interface ParsedChangeRequest {
505 - readonly definition: SourceControlClientDefinition;
509 + readonly definition: SourceControlDefinition;
510 readonly link: ParsedChangeRequestUrl;
511 }
512
513 export interface SourceControlMedia extends SourceControlMediaUrl {
510 - readonly definition: SourceControlClientDefinition;
514 + readonly definition: SourceControlDefinition;
515 }
516
513 -export interface SourceControlClientRegistry {
514 - readonly definitions: ReadonlyArray<SourceControlClientDefinition>;
515 - readonly get: (kind: string | null | undefined) => SourceControlClientDefinition;
516 - readonly find: (kind: string) => SourceControlClientDefinition | undefined;
517 - readonly findByPublicHost: (hostname: string) => SourceControlClientDefinition | undefined;
517 +export interface SourceControlDefinitionRegistry {
518 + readonly definitions: ReadonlyArray<SourceControlDefinition>;
519 + readonly get: (kind: string | null | undefined) => SourceControlDefinition;
520 + readonly find: (kind: string) => SourceControlDefinition | undefined;
521 + readonly findByPublicHost: (hostname: string) => SourceControlDefinition | undefined;
522 /**
523 * The host whose `publicHost` is `hostname` or a parent domain of it, such as GitHub for
524 * `gist.github.com`: which host a link is on, not one T3 can read from.
525 */
522 - readonly findByPublicDomain: (hostname: string) => SourceControlClientDefinition | undefined;
526 + readonly findByPublicDomain: (hostname: string) => SourceControlDefinition | undefined;
527 /** The first host, in registry order, that reads `url` as one of its change requests. */
528 readonly parseChangeRequestUrl: (url: string) => ParsedChangeRequest | null;
525 - readonly findByChangeRequestUrl: (url: string) => SourceControlClientDefinition | undefined;
529 + readonly findByChangeRequestUrl: (url: string) => SourceControlDefinition | undefined;
530 readonly hostLabelForChangeRequestUrl: (url: string) => string;
531 readonly isSameChangeRequest: (left: string, right: string) => boolean;
532 readonly changeRequestUrlFromReferenceAutolink: (url: string) => string | null;
@@ -535,7 +539,7 @@ export interface SourceControlClientRegistry {
539 readonly repositoryKeyFromRemote: (remoteUrl: string) => string;
540 readonly canonicalRepositoryKey: (key: string) => string;
541 /** The host that has more than one spelling of `key`, if any does. */
538 - readonly findByRepositoryKey: (key: string) => SourceControlClientDefinition | undefined;
542 + readonly findByRepositoryKey: (key: string) => SourceControlDefinition | undefined;
543 readonly repositorySelector: (
544 identity: RepositorySelectorIdentity | null | undefined,
545 ) => string | null;
@@ -557,9 +561,9 @@ function httpUrl(value: string): URL | null {
561 }
562
563 function inOrder(
560 - definitions: ReadonlyArray<SourceControlClientDefinition>,
564 + definitions: ReadonlyArray<SourceControlDefinition>,
565 firstKinds: ReadonlyArray<SourceControlProviderKind> | undefined,
562 -): ReadonlyArray<SourceControlClientDefinition> {
566 +): ReadonlyArray<SourceControlDefinition> {
567 const first = (firstKinds ?? []).flatMap(
568 (kind) => definitions.find((definition) => definition.kind === kind) ?? [],
569 );
@@ -574,14 +578,14 @@ function inOrder(
578 * goes to the first that recognises it, in `recognizeRemotesIn` order and then the rest, because
579 * one hostname can carry several hosts' labels.
580 */
577 -export function makeSourceControlClientRegistry(
578 - definitions: ReadonlyArray<SourceControlClientDefinition>,
581 +export function makeSourceControlDefinitionRegistry(
582 + definitions: ReadonlyArray<SourceControlDefinition>,
583 options?: {
584 readonly claimChangeRequestUrlsFirst?: ReadonlyArray<SourceControlProviderKind>;
585 readonly recognizeRemotesIn?: ReadonlyArray<SourceControlProviderKind>;
586 },
583 -): SourceControlClientRegistry {
584 - const byKind = new Map<string, SourceControlClientDefinition>();
587 +): SourceControlDefinitionRegistry {
588 + const byKind = new Map<string, SourceControlDefinition>();
589 for (const definition of definitions) {
590 if (byKind.has(definition.kind)) {
591 throw new Error(`Source control host '${definition.kind}' is defined more than once.`);
packages/source-control-core/src/shared/threadPullRequests.ts renamed
+2 -2
@@ -6,7 +6,7 @@ import type {
6 } from "@t3tools/contracts";
7 import { visibleThreadPullRequests } from "@t3tools/shared/threadPullRequests";
8
9 -import type { SourceControlClientRegistry } from "./definition.ts";
9 +import type { SourceControlDefinitionRegistry } from "./definition.ts";
10
11 type ThreadPullRequestKeySource = ThreadPullRequestKey & {
12 readonly authority?: string;
@@ -63,7 +63,7 @@ export type ThreadPullRequestBadge = {
63 */
64 export function makeThreadPullRequests(
65 registry: Pick<
66 - SourceControlClientRegistry,
66 + SourceControlDefinitionRegistry,
67 "parseChangeRequestUrl" | "canonicalRepositoryKey" | "findByRepositoryKey"
68 >,
69 ) {
packages/source-control-forgejo/package.json
+3 -3
@@ -3,9 +3,9 @@
3 "private": true,
4 "type": "module",
5 "exports": {
6 - "./client/definition": {
7 - "types": "./src/client/definition.ts",
8 - "import": "./src/client/definition.ts"
6 + "./shared/definition": {
7 + "types": "./src/shared/definition.ts",
8 + "import": "./src/shared/definition.ts"
9 },
10 "./server/driver": {
11 "types": "./src/server/driver.ts",
packages/source-control-forgejo/src/server/ForgejoPullRequestProvider.ts
+1 -1
@@ -34,7 +34,7 @@ import {
34 forgejoReactions,
35 } from "./forgejoPullRequestJson.ts";
36 import { ForgejoBranchStatusChecks, markRequiredForgejoChecks } from "./forgejoRequiredChecks.ts";
37 -import { definition } from "../client/definition.ts";
37 +import { definition } from "../shared/definition.ts";
38
39 const isForgejoCliError = Schema.is(ForgejoCli.ForgejoCliError);
40
packages/source-control-forgejo/src/server/driver.ts
+1 -1
@@ -4,7 +4,7 @@ import {
4 } from "@t3tools/source-control-core/server/driver";
5 import * as Effect from "effect/Effect";
6
7 -import { definition } from "../client/definition.ts";
7 +import { definition } from "../shared/definition.ts";
8
9 import * as ForgejoCli from "./ForgejoCli.ts";
10 import * as ForgejoPullRequestProvider from "./ForgejoPullRequestProvider.ts";
packages/source-control-forgejo/src/shared/definition.test.ts renamed
+2 -2
@@ -1,5 +1,5 @@
1 -import type { ChangeRequestProjectIdentity } from "@t3tools/source-control-core/client/definition";
2 -import { recognizeRemoteWith } from "@t3tools/source-control-core/client/definition";
1 +import type { ChangeRequestProjectIdentity } from "@t3tools/source-control-core/shared/definition";
2 +import { recognizeRemoteWith } from "@t3tools/source-control-core/shared/definition";
3 import { describe, expect, it } from "vite-plus/test";
4
5 import { definition } from "./definition.ts";
packages/source-control-forgejo/src/shared/definition.ts renamed
+3 -3
@@ -3,14 +3,14 @@ import {
3 changeRequestUrlBelow,
4 type ChangeRequestHostIdentity,
5 type ChangeRequestProjectIdentity,
6 - defineSourceControlClient,
6 + defineSourceControl,
7 isChangeRequestAuthorityOfProject,
8 isChangeRequestInProjectRepository,
9 isChangeRequestOnProjectHost,
10 parseChangeRequestPath,
11 projectChangeRequestHost,
12 remoteWebOrigin,
13 -} from "@t3tools/source-control-core/client/definition";
13 +} from "@t3tools/source-control-core/shared/definition";
14 import { icon } from "./icon.ts";
15
16 const CHECKOUT_COMMAND = /^tea\s+(?:pr|pulls)\s+checkout\s+(.+)$/i;
@@ -51,7 +51,7 @@ function changeRequestHost(identity: ChangeRequestHostIdentity): string {
51 return projectChangeRequestHost(identity, KIND);
52 }
53
54 -export const definition = defineSourceControlClient({
54 +export const definition = defineSourceControl({
55 kind: KIND,
56 label: "Forgejo",
57 pickerLabel: "Forgejo / Gitea",
packages/source-control-forgejo/src/shared/icon.ts renamed
+1 -1
@@ -1,4 +1,4 @@
1 -import type { SourceControlIcon } from "@t3tools/source-control-core/client/definition";
1 +import type { SourceControlIcon } from "@t3tools/source-control-core/shared/definition";
2
3 // The view box starts at -6 to move the mark 6 units in, as the published artwork's group does.
4 export const icon: SourceControlIcon = {
packages/source-control-gitcafe/package.json
+3 -3
@@ -3,9 +3,9 @@
3 "private": true,
4 "type": "module",
5 "exports": {
6 - "./client/definition": {
7 - "types": "./src/client/definition.ts",
8 - "import": "./src/client/definition.ts"
6 + "./shared/definition": {
7 + "types": "./src/shared/definition.ts",
8 + "import": "./src/shared/definition.ts"
9 },
10 "./server/driver": {
11 "types": "./src/server/driver.ts",
packages/source-control-gitcafe/src/server/GitCafeCredentials.ts
+2 -2
@@ -10,9 +10,9 @@ import * as Redacted from "effect/Redacted";
10 import * as Schema from "effect/Schema";
11 import * as HostProcess from "@t3tools/shared/HostProcess";
12 import * as SourceControlHost from "@t3tools/source-control-core/server/SourceControlHost";
13 -import { readSourceControlHostSettings } from "@t3tools/source-control-core/client/definition";
13 +import { readSourceControlHostSettings } from "@t3tools/source-control-core/shared/definition";
14
15 -import * as GitCafeClient from "../client/definition.ts";
15 +import * as GitCafeClient from "../shared/definition.ts";
16
17 const TOKEN_TTL = Duration.minutes(5);
18 const MISSING_TTL = Duration.seconds(10);
packages/source-control-gitcafe/src/server/GitCafePullRequestProvider.ts
+1 -1
@@ -20,7 +20,7 @@ import {
20 import * as GitCafeApi from "./GitCafeApi.ts";
21 import * as GitCafeHosts from "./gitCafeHosts.ts";
22 import * as Json from "./gitCafePullRequestJson.ts";
23 -import { definition } from "../client/definition.ts";
23 +import { definition } from "../shared/definition.ts";
24
25 const CAPABILITIES: PullRequestCapabilities = {
26 diff: true,
packages/source-control-gitcafe/src/server/driver.ts
+1 -1
@@ -5,7 +5,7 @@ import {
5 import * as Effect from "effect/Effect";
6 import * as Layer from "effect/Layer";
7
8 -import { definition } from "../client/definition.ts";
8 +import { definition } from "../shared/definition.ts";
9
10 import * as GitCafeApi from "./GitCafeApi.ts";
11 import * as GitCafeCredentials from "./GitCafeCredentials.ts";
packages/source-control-gitcafe/src/shared/definition.test.ts renamed
+1 -1
@@ -1,4 +1,4 @@
1 -import { recognizeRemoteWith } from "@t3tools/source-control-core/client/definition";
1 +import { recognizeRemoteWith } from "@t3tools/source-control-core/shared/definition";
2 import { describe, expect, it } from "vite-plus/test";
3
4 import { definition } from "./definition.ts";
packages/source-control-gitcafe/src/shared/definition.ts renamed
+3 -3
@@ -8,12 +8,12 @@ import * as Effect from "effect/Effect";
8 import * as Schema from "effect/Schema";
9 import {
10 changeRequestUrlBelow,
11 - defineSourceControlClient,
11 + defineSourceControl,
12 isChangeRequestInProjectRepository,
13 isChangeRequestOnProjectHost,
14 parseChangeRequestPath,
15 projectChangeRequestHost,
16 -} from "@t3tools/source-control-core/client/definition";
16 +} from "@t3tools/source-control-core/shared/definition";
17 import { icon } from "./icon.ts";
18
19 /** GitCafe has no self-hosted installs: production and staging are its only hosts. */
@@ -38,7 +38,7 @@ export const settings = makeProviderSettingsSchema({
38 });
39 export type GitCafeSettings = typeof settings.Type;
40
41 -export const definition = defineSourceControlClient({
41 +export const definition = defineSourceControl({
42 kind: KIND,
43 label: "GitCafe",
44 pickerLabel: "GitCafe",
packages/source-control-gitcafe/src/shared/icon.ts renamed
+1 -1
@@ -1,4 +1,4 @@
1 -import type { SourceControlIcon } from "@t3tools/source-control-core/client/definition";
1 +import type { SourceControlIcon } from "@t3tools/source-control-core/shared/definition";
2
3 export const icon: SourceControlIcon = {
4 viewBox: "0 0 64 64",
packages/source-control-github/package.json
+3 -3
@@ -3,9 +3,9 @@
3 "private": true,
4 "type": "module",
5 "exports": {
6 - "./client/definition": {
7 - "types": "./src/client/definition.ts",
8 - "import": "./src/client/definition.ts"
6 + "./shared/definition": {
7 + "types": "./src/shared/definition.ts",
8 + "import": "./src/shared/definition.ts"
9 },
10 "./server/driver": {
11 "types": "./src/server/driver.ts",
packages/source-control-github/src/server/GitHubCredentials.ts
+2 -2
@@ -14,10 +14,10 @@ import * as Schema from "effect/Schema";
14 import * as HostProcess from "@t3tools/shared/HostProcess";
15
16 import * as SourceControlHost from "@t3tools/source-control-core/server/SourceControlHost";
17 -import { readSourceControlHostSettings } from "@t3tools/source-control-core/client/definition";
17 +import { readSourceControlHostSettings } from "@t3tools/source-control-core/shared/definition";
18 import type { ServerSettings } from "@t3tools/contracts";
19
20 -import * as GitHubClient from "../client/definition.ts";
20 +import * as GitHubClient from "../shared/definition.ts";
21
22 /**
23 * Every gh run on the server shares this. A burst of them (a status poll across many checkouts)
packages/source-control-github/src/server/GitHubPullRequestProvider.ts
+1 -1
@@ -24,7 +24,7 @@ import type {
24 GitHubViewerAccess,
25 GitHubWorkflowRunApproval,
26 } from "./gitHubPullRequestJson.ts";
27 -import { definition } from "../client/definition.ts";
27 +import { definition } from "../shared/definition.ts";
28
29 const CAPABILITIES: PullRequestCapabilities = {
30 diff: true,
packages/source-control-github/src/server/GitHubSourceControlProvider.ts
+2 -2
@@ -61,9 +61,9 @@ import {
61 type SourceControlManagedCliDiscoverySpec,
62 } from "@t3tools/source-control-core/server/discovery";
63 import * as SourceControlHost from "@t3tools/source-control-core/server/SourceControlHost";
64 -import { readSourceControlHostSettings } from "@t3tools/source-control-core/client/definition";
64 +import { readSourceControlHostSettings } from "@t3tools/source-control-core/shared/definition";
65
66 -import * as GitHubClient from "../client/definition.ts";
66 +import * as GitHubClient from "../shared/definition.ts";
67 import {
68 PullRequestByNumber,
69 PullRequestNode,
packages/source-control-github/src/server/driver.ts
+1 -1
@@ -5,7 +5,7 @@ import {
5 import * as Effect from "effect/Effect";
6 import * as Layer from "effect/Layer";
7
8 -import { definition } from "../client/definition.ts";
8 +import { definition } from "../shared/definition.ts";
9
10 import * as GitHubMediaFetch from "./gitHubMediaFetch.ts";
11 import * as GitHubPullRequestApi from "./GitHubPullRequestApi.ts";
packages/source-control-github/src/server/gitHubAuthStatus.ts
+1 -1
@@ -1,4 +1,4 @@
1 -import type { GitHubSettings } from "../client/definition.ts";
1 +import type { GitHubSettings } from "../shared/definition.ts";
2 import * as Option from "effect/Option";
3 import * as Schema from "effect/Schema";
4
packages/source-control-github/src/server/gitHubMediaFetch.ts
+1 -1
@@ -8,7 +8,7 @@ import {
8 type HttpClientResponse,
9 } from "effect/http";
10
11 -import { GITHUB_CREDENTIALED_MEDIA_HOSTS } from "../client/gitHubMedia.ts";
11 +import { GITHUB_CREDENTIALED_MEDIA_HOSTS } from "../shared/gitHubMedia.ts";
12
13 import * as GitHubCredentials from "./GitHubCredentials.ts";
14
packages/source-control-github/src/server/gitHubRepositoryResolution.ts
+2 -2
@@ -1,7 +1,7 @@
1 import { normalizeGitRemoteUrl } from "@t3tools/shared/git";
2 import { isSshRemoteUrl } from "@t3tools/shared/sourceControl";
3 -import { parseGitRemoteHost } from "@t3tools/source-control-core/client/definition";
4 -import { definition } from "../client/definition.ts";
3 +import { parseGitRemoteHost } from "@t3tools/source-control-core/shared/definition";
4 +import { definition } from "../shared/definition.ts";
5
6 export interface GitHubRepositoryLocator {
7 readonly host: string;
packages/source-control-github/src/shared/definition.test.ts renamed
+1 -1
@@ -1,4 +1,4 @@
1 -import { recognizeRemoteWith } from "@t3tools/source-control-core/client/definition";
1 +import { recognizeRemoteWith } from "@t3tools/source-control-core/shared/definition";
2 import { describe, expect, it } from "vite-plus/test";
3
4 import { definition } from "./definition.ts";
packages/source-control-github/src/shared/definition.ts renamed
+3 -3
@@ -1,14 +1,14 @@
1 import { makeProviderSettingsSchema, SourceControlProviderKind } from "@t3tools/contracts";
2 import {
3 changeRequestUrlBelow,
4 - defineSourceControlClient,
4 + defineSourceControl,
5 hostCredentialSettingsFields,
6 isChangeRequestInProjectRepository,
7 isChangeRequestOnProjectHost,
8 parseChangeRequestPath,
9 projectChangeRequestHost,
10 remoteWebOrigin,
11 -} from "@t3tools/source-control-core/client/definition";
11 +} from "@t3tools/source-control-core/shared/definition";
12
13 import { gitHubMediaUrl } from "./gitHubMedia.ts";
14 import { icon } from "./icon.ts";
@@ -45,7 +45,7 @@ function isRepositoryPath(repository: string): boolean {
45 export const settings = makeProviderSettingsSchema(hostCredentialSettingsFields);
46 export type GitHubSettings = typeof settings.Type;
47
48 -export const definition = defineSourceControlClient({
48 +export const definition = defineSourceControl({
49 kind: KIND,
50 label: "GitHub",
51 pickerLabel: "GitHub",
packages/source-control-github/src/shared/gitHubMedia.ts renamed
+1 -1
@@ -1,4 +1,4 @@
1 -import type { SourceControlMediaUrl } from "@t3tools/source-control-core/client/definition";
1 +import type { SourceControlMediaUrl } from "@t3tools/source-control-core/shared/definition";
2
3 /**
4 * Only hosts where a credential is what decides the answer belong here. `objects.githubusercontent.com`
packages/source-control-github/src/shared/icon.ts renamed
+1 -1
@@ -1,4 +1,4 @@
1 -import type { SourceControlIcon } from "@t3tools/source-control-core/client/definition";
1 +import type { SourceControlIcon } from "@t3tools/source-control-core/shared/definition";
2
3 export const icon: SourceControlIcon = {
4 viewBox: "0 0 16 16",
packages/source-control-github/src/shared/referenceAutolinks.test.ts renamed
packages/source-control-github/src/shared/referenceAutolinks.ts renamed
+1 -1
@@ -1,4 +1,4 @@
1 -import type { ReferenceAutolink } from "@t3tools/source-control-core/client/definition";
1 +import type { ReferenceAutolink } from "@t3tools/source-control-core/shared/definition";
2
3 // GitHub's autolinked references: `#12`, `repo#12` and `owner/repo#12`; a SHA of 7 to 40
4 // characters, optionally `repo@` or `owner/repo@` qualified; `@user` and `@org/team`.
packages/source-control-gitlab/package.json
+3 -3
@@ -3,9 +3,9 @@
3 "private": true,
4 "type": "module",
5 "exports": {
6 - "./client/definition": {
7 - "types": "./src/client/definition.ts",
8 - "import": "./src/client/definition.ts"
6 + "./shared/definition": {
7 + "types": "./src/shared/definition.ts",
8 + "import": "./src/shared/definition.ts"
9 },
10 "./server/driver": {
11 "types": "./src/server/driver.ts",
packages/source-control-gitlab/src/server/GitLabPullRequestProvider.ts
+1 -1
@@ -14,7 +14,7 @@ import {
14 type ProviderChangeRequestDetail,
15 type PullRequestProviderApi,
16 } from "@t3tools/source-control-core/server/PullRequestProvider";
17 -import { definition } from "../client/definition.ts";
17 +import { definition } from "../shared/definition.ts";
18
19 const CAPABILITIES: PullRequestCapabilities = {
20 diff: true,
packages/source-control-gitlab/src/server/GitLabSourceControlProvider.test.ts
+1 -1
@@ -12,7 +12,7 @@ import * as TestSourceControlHost from "@t3tools/source-control-testing/TestSour
12 import * as GitLabCli from "./GitLabCli.ts";
13 import { parseGitLabAuthStatusHosts } from "./gitLabAuthStatus.ts";
14 import * as GitLabSourceControlProvider from "./GitLabSourceControlProvider.ts";
15 -import { definition } from "../client/definition.ts";
15 +import { definition } from "../shared/definition.ts";
16
17 function makeProvider(gitlab: Partial<GitLabCli.GitLabCli["Service"]>) {
18 return GitLabSourceControlProvider.make.pipe(
packages/source-control-gitlab/src/server/GitLabSourceControlProvider.ts
+1 -1
@@ -6,7 +6,7 @@ import { SourceControlProviderError, type ChangeRequest } from "@t3tools/contrac
6 import {
7 parseGitRemoteHost,
8 unknownRemoteProvider as unknownHostProvider,
9 -} from "@t3tools/source-control-core/client/definition";
9 +} from "@t3tools/source-control-core/shared/definition";
10
11 import * as GitLabCli from "./GitLabCli.ts";
12 import * as GitLabChangeRequestTemplate from "./gitLabChangeRequestTemplate.ts";
packages/source-control-gitlab/src/server/driver.ts
+1 -1
@@ -5,7 +5,7 @@ import {
5 import * as Effect from "effect/Effect";
6 import * as Layer from "effect/Layer";
7
8 -import { definition } from "../client/definition.ts";
8 +import { definition } from "../shared/definition.ts";
9
10 import * as GitLabCli from "./GitLabCli.ts";
11 import * as GitLabPullRequestCli from "./GitLabPullRequestCli.ts";
packages/source-control-gitlab/src/server/gitLabDiscovery.test.ts
+1 -1
@@ -1,7 +1,7 @@
1 import {
2 parseGitRemoteHost,
3 unknownRemoteProvider,
4 -} from "@t3tools/source-control-core/client/definition";
4 +} from "@t3tools/source-control-core/shared/definition";
5 import { refineUnknownRemoteProvider } from "@t3tools/source-control-core/server/discovery";
6 import { processOutput } from "@t3tools/source-control-testing/TestSourceControlHost";
7 import { assert, it } from "@effect/vitest";
packages/source-control-gitlab/src/shared/definition.test.ts renamed
+1 -1
@@ -1,4 +1,4 @@
1 -import { recognizeRemoteWith } from "@t3tools/source-control-core/client/definition";
1 +import { recognizeRemoteWith } from "@t3tools/source-control-core/shared/definition";
2 import { describe, expect, it } from "vite-plus/test";
3
4 import { definition } from "./definition.ts";
packages/source-control-gitlab/src/shared/definition.ts renamed
+3 -3
@@ -1,12 +1,12 @@
1 import { SourceControlProviderKind } from "@t3tools/contracts";
2 import {
3 changeRequestUrlBelow,
4 - defineSourceControlClient,
4 + defineSourceControl,
5 isChangeRequestInProjectRepository,
6 isChangeRequestOnProjectHost,
7 parseChangeRequestPath,
8 projectChangeRequestHost,
9 -} from "@t3tools/source-control-core/client/definition";
9 +} from "@t3tools/source-control-core/shared/definition";
10 import { icon } from "./icon.ts";
11
12 const CHECKOUT_COMMAND = /^glab\s+mr\s+checkout\s+(.+)$/i;
@@ -18,7 +18,7 @@ const CHANGE_REQUEST_PATH = /^\/([^/]+(?:\/[^/]+)+)\/-\/merge_requests\/(\d+)(?:
18
19 const KIND = SourceControlProviderKind.make("gitlab");
20
21 -export const definition = defineSourceControlClient({
21 +export const definition = defineSourceControl({
22 kind: KIND,
23 label: "GitLab",
24 pickerLabel: "GitLab",
packages/source-control-gitlab/src/shared/icon.ts renamed
+1 -1
@@ -1,4 +1,4 @@
1 -import type { SourceControlIcon } from "@t3tools/source-control-core/client/definition";
1 +import type { SourceControlIcon } from "@t3tools/source-control-core/shared/definition";
2
3 export const icon: SourceControlIcon = {
4 viewBox: "0 0 32 32",
vite.config.ts
+60
@@ -354,6 +354,66 @@ export default defineConfig({
354 files: ["apps/web/src/components/pullRequest/pullRequestIcons.tsx"],
355 rules: { "eslint/no-restricted-imports": ["error", { paths: RESTRICTED_IMPORT_PATHS }] },
356 },
357 + {
358 + // The server and every client load a forge's shared definition, so a UI runtime
359 + // imported there would break the server; client-only forge code goes in `src/client/`.
360 + files: ["packages/source-control-*/src/shared/**"],
361 + rules: {
362 + "eslint/no-restricted-imports": [
363 + "error",
364 + {
365 + paths: [...RESTRICTED_IMPORT_PATHS, RESTRICTED_PULL_REQUEST_GLYPH_IMPORTS],
366 + patterns: [
367 + {
368 + group: [
369 + "react",
370 + "react/*",
371 + "react-*",
372 + "expo",
373 + "expo-*",
374 + "lucide-react",
375 + "@t3tools/client-runtime",
376 + "@t3tools/client-runtime/*",
377 + "../client/*",
378 + "../server/*",
379 + "../../client/*",
380 + "../../server/*",
381 + "../../../client/*",
382 + "../../../server/*",
383 + "@t3tools/source-control-*/client/*",
384 + "@t3tools/source-control-*/server/*",
385 + ],
386 + message:
387 + "Shared forge definitions load on the server and every client; keep UI and server code out.",
388 + },
389 + ],
390 + },
391 + ],
392 + },
393 + },
394 + {
395 + files: ["apps/server/src/**", "packages/source-control-*/src/server/**"],
396 + rules: {
397 + "eslint/no-restricted-imports": [
398 + "error",
399 + {
400 + paths: [...RESTRICTED_IMPORT_PATHS, RESTRICTED_PULL_REQUEST_GLYPH_IMPORTS],
401 + patterns: [
402 + {
403 + group: [
404 + "@t3tools/source-control-*/client/*",
405 + "../client/*",
406 + "../../client/*",
407 + "../../../client/*",
408 + ],
409 + message:
410 + "A forge's client entry is UI-only; the server reads its `shared/definition`.",
411 + },
412 + ],
413 + },
414 + ],
415 + },
416 + },
417 {
418 files: ["apps/mobile/src/**"],
419 rules: { "t3code/no-mobile-uniwind-theme-escape-hatches": "error" },