Skip to content

Commit 331d3c5

Browse files
refactor(source-control): forge definitions live in shared/, not client/
The server imported each forge's `client/definition`, so anything client-only added there later (React, React Native, DOM) would have broken the server. The definition is what both sides know about a forge, so it now lives in `src/shared/` and is exported as `./shared/definition`. The types follow: `SourceControlDefinition`, `SourceControlDefinitionRegistry`, `defineSourceControl`, and the server's registry is `sourceControlDefinitions`. Lint keeps it that way: `shared/` may not import React, React Native, Expo, lucide, client-runtime, or a package's `client/` or `server/` code, and server code may not import any forge's `client/` entry. Client-only forge code now has an obvious home that the server can never reach. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 9d735a3 commit 331d3c5

88 files changed

Lines changed: 294 additions & 236 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.repos/alchemy-effect/packages/frontend-frameworks/src/core/NodeServe.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export interface NodeServeHandler {
4848
export interface NodeServeEntryOptions {
4949
/**
5050
* 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))`).
5252
* Omit to skip static-file serving (Next.js handles its own assets).
5353
*/
5454
readonly clientDirExpression?: string | undefined;

‎.repos/alchemy-effect/packages/frontend-frameworks/src/core/test/NodeServe.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ describe("relativeClientDirExpression", () => {
2828
"/project/dist/server/serve-node.mjs",
2929
"/project/dist/client",
3030
),
31-
).toBe(`fileURLToPath(new URL("../client/", import.meta.url))`);
31+
).toBe(`fileURLToPath(new URL("../shared/", import.meta.url))`);
3232
});
3333
});
3434

3535
describe("makeNodeServeEntrySource", () => {
3636
it("listens on PORT, answers /health, serves static files, then the fetch handler", () => {
3737
const source = makeNodeServeEntrySource({
38-
clientDirExpression: `fileURLToPath(new URL("../client/", import.meta.url))`,
38+
clientDirExpression: `fileURLToPath(new URL("../shared/", import.meta.url))`,
3939
handler: {
4040
kind: "fetch",
4141
imports: `import { handler } from "./index.mjs";`,
@@ -131,7 +131,7 @@ describe("makeNodeServeEntrySource", () => {
131131

132132
it("does not map GET / onto public/index.html (SSR home stays on the handler)", () => {
133133
const source = makeNodeServeEntrySource({
134-
clientDirExpression: `fileURLToPath(new URL("../client/", import.meta.url))`,
134+
clientDirExpression: `fileURLToPath(new URL("../shared/", import.meta.url))`,
135135
handler: {
136136
kind: "node",
137137
imports: `import { handler } from "./index.mjs";`,

‎apps/server/src/assets/AssetAccess.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import * as NativeAppIconResolver from "./NativeAppIconResolver.ts";
3636
import { symlinksSupported } from "@t3tools/shared/testing/symlinks";
3737
import { fakeSourceControlDriverInstance } from "@t3tools/source-control-testing/fakeSourceControlDriver";
3838
import * as BuiltInDrivers from "../sourceControl/builtInDrivers.ts";
39-
import { sourceControlClients } from "../sourceControl/sourceControlClients.ts";
39+
import { sourceControlDefinitions } from "../sourceControl/sourceControlDefinitions.ts";
4040
import { sourceControlMediaResponse } from "./sourceControlMediaResponse.ts";
4141
import * as HostProcess from "@t3tools/shared/HostProcess";
4242

@@ -953,7 +953,7 @@ describe("AssetAccess", () => {
953953
it.effect("serves a host's credentialed media through that host's driver", () => {
954954
const fetched: Array<{ url: string; headers: Readonly<Record<string, string>> }> = [];
955955
const url = "https://github.com/owner/repo/blob/main/docs/shot.png";
956-
const media = sourceControlClients.mediaUrl(url)!;
956+
const media = sourceControlDefinitions.mediaUrl(url)!;
957957
const layerDrivers = Layer.succeed(BuiltInDrivers.SourceControlDrivers, [
958958
{
959959
driver: { kind: media.definition.kind, definition: media.definition },

‎apps/server/src/assets/AssetAccess.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ import * as ProjectFaviconResolver from "../project/ProjectFaviconResolver.ts";
6464
import { isWithinRoot } from "../workspace/KnownWorkspaces.ts";
6565
import * as WorkspacePaths from "../workspace/WorkspacePaths.ts";
6666
import * as NativeAppIconResolver from "./NativeAppIconResolver.ts";
67-
import { sourceControlClients } from "../sourceControl/sourceControlClients.ts";
67+
import { sourceControlDefinitions } from "../sourceControl/sourceControlDefinitions.ts";
6868
import { extractIcnsPng } from "./icns.ts";
6969
import { openMediaFile, readMediaFileHeader, type OpenMediaFile } from "./MediaFile.ts";
7070
import * as HostProcess from "@t3tools/shared/HostProcess";
@@ -805,7 +805,7 @@ export const issueAssetUrl = Effect.fn("AssetAccess.issueAssetUrl")(function* (i
805805
break;
806806
}
807807
case SOURCE_CONTROL_MEDIA_ASSET: {
808-
const media = sourceControlClients.mediaUrl(input.resource.url);
808+
const media = sourceControlDefinitions.mediaUrl(input.resource.url);
809809
if (media === null) {
810810
return yield* new AssetSourceControlMediaUrlValidationError({});
811811
}

‎apps/server/src/assets/sourceControlMediaResponse.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as Option from "effect/Option";
55
import { HttpServerResponse } from "effect/http";
66

77
import * as BuiltInDrivers from "../sourceControl/builtInDrivers.ts";
8-
import { sourceControlClients } from "../sourceControl/sourceControlClients.ts";
8+
import { sourceControlDefinitions } from "../sourceControl/sourceControlDefinitions.ts";
99

1010
const FORWARDED_REQUEST_HEADERS = ["range", "if-range"] as const;
1111
const FORWARDED_RESPONSE_HEADERS = [
@@ -34,7 +34,7 @@ export const sourceControlMediaResponse = Effect.fn(
3434
remainingSeconds > 0 ? `private, max-age=${remainingSeconds}` : "private, no-store",
3535
"x-content-type-options": "nosniff",
3636
};
37-
const media = sourceControlClients.mediaUrl(asset.url);
37+
const media = sourceControlDefinitions.mediaUrl(asset.url);
3838
const drivers = yield* BuiltInDrivers.SourceControlDrivers;
3939
const fetchMedia = drivers.find(({ driver }) => driver.kind === media?.definition.kind)?.instance
4040
.fetchMedia;

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ import { isSshRemoteUrl } from "@t3tools/shared/sourceControl";
5757
import {
5858
type ChangeRequestTerminology,
5959
UNKNOWN_SOURCE_CONTROL_CLIENT,
60-
} from "@t3tools/source-control-core/client/definition";
60+
} from "@t3tools/source-control-core/shared/definition";
6161
import {
6262
normalizeThreadPullRequestKey,
6363
threadPullRequestKeyOf,
6464
} from "../sourceControl/threadPullRequests.ts";
65-
import { sourceControlClients } from "../sourceControl/sourceControlClients.ts";
65+
import { sourceControlDefinitions } from "../sourceControl/sourceControlDefinitions.ts";
6666

6767
import { GitManagerError, GitPullRequestMaterializationError } from "@t3tools/contracts";
6868
import {
@@ -249,10 +249,10 @@ interface BranchHeadContext {
249249
}
250250

251251
export function pullRequestRepositoryKey(value: string): string | null {
252-
const repositoryUrl = sourceControlClients.parseChangeRequestUrl(value)?.link.repositoryUrl;
252+
const repositoryUrl = sourceControlDefinitions.parseChangeRequestUrl(value)?.link.repositoryUrl;
253253
return repositoryUrl === undefined
254254
? null
255-
: sourceControlClients.repositoryKeyFromRemote(repositoryUrl);
255+
: sourceControlDefinitions.repositoryKeyFromRemote(repositoryUrl);
256256
}
257257

258258
/** Null when the host did not name the repository the head lives in. */
@@ -666,7 +666,7 @@ export const make = Effect.gen(function* () {
666666
const sourceControlProvider = (cwd: string) => sourceControlProviders.resolve({ cwd });
667667
const changeRequestTermsFor = (cwd: string) =>
668668
sourceControlProvider(cwd).pipe(
669-
Effect.map((provider) => sourceControlClients.get(provider.kind).changeRequest),
669+
Effect.map((provider) => sourceControlDefinitions.get(provider.kind).changeRequest),
670670
Effect.orElseSucceed(() => UNKNOWN_SOURCE_CONTROL_CLIENT.changeRequest),
671671
);
672672
const serverSettingsService = yield* ServerSettings.ServerSettingsService;
@@ -970,7 +970,7 @@ export const make = Effect.gen(function* () {
970970
number: number,
971971
) {
972972
const provider = yield* sourceControlProvider(cwd);
973-
const ref = sourceControlClients.get(provider.kind).changeRequestHeadRef?.(number);
973+
const ref = sourceControlDefinitions.get(provider.kind).changeRequestHeadRef?.(number);
974974
if (ref === undefined) {
975975
return yield* new GitManagerError({
976976
operation: "changeRequestHeadRef",
@@ -1015,9 +1015,9 @@ export const make = Effect.gen(function* () {
10151015
if (
10161016
remoteUrl === null ||
10171017
pullRequestKey === null ||
1018-
sourceControlClients.canonicalRepositoryKey(pullRequestKey) !==
1019-
sourceControlClients.canonicalRepositoryKey(
1020-
sourceControlClients.repositoryKeyFromRemote(remoteUrl),
1018+
sourceControlDefinitions.canonicalRepositoryKey(pullRequestKey) !==
1019+
sourceControlDefinitions.canonicalRepositoryKey(
1020+
sourceControlDefinitions.repositoryKeyFromRemote(remoteUrl),
10211021
)
10221022
) {
10231023
return yield* cause;
@@ -1186,7 +1186,7 @@ export const make = Effect.gen(function* () {
11861186
>();
11871187
const noteLookupState = (pr: PullRequestInfo) =>
11881188
Effect.suspend(() => {
1189-
const parsed = sourceControlClients.parseChangeRequestUrl(pr.url)?.link;
1189+
const parsed = sourceControlDefinitions.parseChangeRequestUrl(pr.url)?.link;
11901190
if (parsed === undefined || parsed.number !== pr.number) return Effect.void;
11911191
const key = normalizeThreadPullRequestKey(parsed);
11921192
const id = threadPullRequestKeyOf(key);
@@ -1430,7 +1430,7 @@ export const make = Effect.gen(function* () {
14301430
remote: { readonly remoteUrl: string | null; readonly repositoryNameWithOwner: string | null },
14311431
) {
14321432
const provider =
1433-
remote.remoteUrl === null ? null : sourceControlClients.recognizeRemote(remote.remoteUrl);
1433+
remote.remoteUrl === null ? null : sourceControlDefinitions.recognizeRemote(remote.remoteUrl);
14341434
if (remote.remoteUrl === null || provider === null) return true;
14351435
const context = { provider, remoteName, remoteUrl: remote.remoteUrl };
14361436
const handle = yield* sourceControlProviders
@@ -1457,7 +1457,7 @@ export const make = Effect.gen(function* () {
14571457
(yield* readConfigValueNullable(cwd, `remote.${preferredRemoteName}.url`)) ??
14581458
(yield* readConfigValueNullable(cwd, "remote.origin.url"));
14591459

1460-
const provider = remoteUrl ? sourceControlClients.recognizeRemote(remoteUrl) : null;
1460+
const provider = remoteUrl ? sourceControlDefinitions.recognizeRemote(remoteUrl) : null;
14611461
if (!remoteUrl || provider?.kind !== "unknown") return provider;
14621462
const handle = yield* sourceControlProviders
14631463
.resolveHandle({
@@ -1488,7 +1488,7 @@ export const make = Effect.gen(function* () {
14881488
/^https?:\/\//iu.test(remoteUrl) &&
14891489
(repositoryNameWithOwner?.split("/").length ?? 0) > 2
14901490
) {
1491-
const kind = sourceControlClients.recognizeRemote(remoteUrl)?.kind;
1491+
const kind = sourceControlDefinitions.recognizeRemote(remoteUrl)?.kind;
14921492
const provider =
14931493
kind === undefined
14941494
? undefined
@@ -1499,7 +1499,7 @@ export const make = Effect.gen(function* () {
14991499
}
15001500
return {
15011501
remoteUrl,
1502-
remoteUrlKey: remoteUrl ? sourceControlClients.repositoryKeyFromRemote(remoteUrl) : null,
1502+
remoteUrlKey: remoteUrl ? sourceControlDefinitions.repositoryKeyFromRemote(remoteUrl) : null,
15031503
repositoryNameWithOwner,
15041504
ownerLogin: parseRepositoryOwnerLogin(repositoryNameWithOwner),
15051505
};
@@ -2246,7 +2246,7 @@ export const make = Effect.gen(function* () {
22462246
emit: GitActionProgressEmitter,
22472247
) {
22482248
const provider = yield* sourceControlProvider(cwd);
2249-
const terms = sourceControlClients.get(provider.kind).changeRequest;
2249+
const terms = sourceControlDefinitions.get(provider.kind).changeRequest;
22502250
const details = yield* gitCore.statusDetails(cwd);
22512251
const branch = details.branch ?? fallbackBranch;
22522252
if (!branch) {
@@ -2454,7 +2454,7 @@ export const make = Effect.gen(function* () {
24542454
? Effect.succeed(null)
24552455
: readConfig(`remote.${remoteName}.url`).pipe(
24562456
Effect.map((remoteUrl) =>
2457-
remoteUrl ? sourceControlClients.repositoryKeyFromRemote(remoteUrl) : null,
2457+
remoteUrl ? sourceControlDefinitions.repositoryKeyFromRemote(remoteUrl) : null,
24582458
),
24592459
);
24602460
const remoteName = remoteNameOverride ?? (yield* readConfig(`branch.${branch}.remote`));

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import * as Option from "effect/Option";
1010

1111
import * as Orchestrator from "../orchestration-v2/Orchestrator.ts";
1212
import * as ProjectService from "../project/ProjectService.ts";
13-
import { sourceControlClients } from "../sourceControl/sourceControlClients.ts";
13+
import { sourceControlDefinitions } from "../sourceControl/sourceControlDefinitions.ts";
1414

1515
export interface CreatedPullRequestKey {
1616
readonly host: string;
@@ -27,16 +27,16 @@ export function createdPullRequestKey(
2727
if ((status !== "created" && status !== "opened_existing") || number === undefined || !url) {
2828
return null;
2929
}
30-
const parsed = sourceControlClients.parseChangeRequestUrl(url)?.link;
30+
const parsed = sourceControlDefinitions.parseChangeRequestUrl(url)?.link;
3131
if (parsed !== undefined) {
3232
return { host: parsed.host, repository: parsed.repository, number: parsed.number, url };
3333
}
3434
const identity = project?.repositoryIdentity;
3535
const kind = identity?.provider;
36-
const repository = sourceControlClients.repositorySelector(identity);
36+
const repository = sourceControlDefinitions.repositorySelector(identity);
3737
if (!identity || kind === undefined || repository === null) return null;
3838
return {
39-
host: sourceControlClients.changeRequestHost(identity, kind),
39+
host: sourceControlDefinitions.changeRequestHost(identity, kind),
4040
repository: repository.toLowerCase(),
4141
number,
4242
url,

‎apps/server/src/mcp/toolkits/pullRequests/handlers.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import * as Orchestrator from "../../../orchestration-v2/Orchestrator.ts";
1515
import * as ProjectService from "../../../project/ProjectService.ts";
1616
import * as PullRequestReviewGuideService from "../../../pullRequest/PullRequestReviewGuideService.ts";
1717
import { pullRequestSyncKey } from "../../../pullRequest/pullRequestSyncKey.ts";
18-
import { sourceControlClients } from "../../../sourceControl/sourceControlClients.ts";
18+
import { sourceControlDefinitions } from "../../../sourceControl/sourceControlDefinitions.ts";
1919
import {
2020
normalizeThreadPullRequestKey,
2121
resolveThreadPullRequestChains,
@@ -62,7 +62,7 @@ function projectHostAndProvider(project: OrchestrationProjectShell | undefined):
6262
const kind = identity?.provider ?? null;
6363
if (!identity || kind === null) return { host: null, kind: null };
6464
return {
65-
host: sourceControlClients.changeRequestHost(identity, kind),
65+
host: sourceControlDefinitions.changeRequestHost(identity, kind),
6666
kind,
6767
};
6868
}
@@ -72,7 +72,7 @@ const resolveTarget = Effect.fn("PullRequestsToolkit.resolveTarget")(function* (
7272
project: OrchestrationProjectShell | undefined,
7373
) {
7474
if (input.url !== undefined) {
75-
const parsed = sourceControlClients.parseChangeRequestUrl(input.url)?.link;
75+
const parsed = sourceControlDefinitions.parseChangeRequestUrl(input.url)?.link;
7676
if (parsed === undefined) {
7777
return yield* new PullRequestUrlInvalidError({});
7878
}
@@ -91,7 +91,7 @@ const resolveTarget = Effect.fn("PullRequestsToolkit.resolveTarget")(function* (
9191
const url =
9292
projectHost.kind === null
9393
? null
94-
: sourceControlClients.get(projectHost.kind).changeRequestUrl({
94+
: sourceControlDefinitions.get(projectHost.kind).changeRequestUrl({
9595
host,
9696
repository,
9797
number: input.number,
@@ -169,7 +169,8 @@ function projectForPullRequest(
169169
: pullRequestSyncKey(
170170
{
171171
projectId: project.id,
172-
repository: sourceControlClients.repositorySelector(project.repositoryIdentity) ?? "",
172+
repository:
173+
sourceControlDefinitions.repositorySelector(project.repositoryIdentity) ?? "",
173174
number: 1,
174175
},
175176
project.repositoryIdentity,

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
threadPullRequestKeysEqual,
1515
visibleThreadPullRequests,
1616
} from "../sourceControl/threadPullRequests.ts";
17-
import { sourceControlClients } from "../sourceControl/sourceControlClients.ts";
17+
import { sourceControlDefinitions } from "../sourceControl/sourceControlDefinitions.ts";
1818
import * as Cause from "effect/Cause";
1919
import * as Clock from "effect/Clock";
2020
import * as Context from "effect/Context";
@@ -44,7 +44,7 @@ const QUIET_AFTER_MS = 30 * 60 * 1_000;
4444
const QUIET_SYNC_INTERVAL_MS = 5 * 60 * 1_000;
4545

4646
const isChangeRequestCloseCommand = (command: string) =>
47-
sourceControlClients.definitions.some(
47+
sourceControlDefinitions.definitions.some(
4848
(definition) => definition.changeRequestCloseCommand?.test(command) === true,
4949
);
5050

@@ -60,7 +60,7 @@ interface LinkEntry {
6060
/** Another layer of the stack `url` belongs to, in its host's canonical shape. */
6161
function siblingChangeRequestUrl(url: string, number: number): string | null {
6262
if (!Number.isSafeInteger(number) || number < 1) return null;
63-
const parsed = sourceControlClients.parseChangeRequestUrl(url);
63+
const parsed = sourceControlDefinitions.parseChangeRequestUrl(url);
6464
if (parsed === null) return null;
6565
const { definition, link } = parsed;
6666
return definition.changeRequestUrl({

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import * as ProjectStore from "./ProjectStore.ts";
2525
import * as PullRequestService from "../pullRequest/PullRequestService.ts";
2626
import * as RepositoryIdentityResolver from "../project/RepositoryIdentityResolver.ts";
2727
import { forkParked } from "../serverActivation.ts";
28-
import { sourceControlClients } from "../sourceControl/sourceControlClients.ts";
28+
import { sourceControlDefinitions } from "../sourceControl/sourceControlDefinitions.ts";
2929
import * as Orchestrator from "./Orchestrator.ts";
3030

3131
class ThreadPullRequestServiceV2 extends Context.Service<
@@ -56,8 +56,8 @@ function pullRequestMatchesProject(
5656
return (
5757
pullRequest.repositoryKey !== null &&
5858
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)
6161
);
6262
}
6363

@@ -75,7 +75,7 @@ const resolveProjectForPullRequestDiscovery = Effect.fn(
7575
});
7676
return {
7777
project: { ...project, repositoryIdentity },
78-
repository: sourceControlClients.repositorySelector(repositoryIdentity),
78+
repository: sourceControlDefinitions.repositorySelector(repositoryIdentity),
7979
};
8080
});
8181

0 commit comments

Comments
 (0)