From 8f09b8d0abe521217304927cacb62770efac355b Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Thu, 30 Apr 2026 23:30:11 -0700 Subject: [PATCH] Refactor VCS layers into top-level modules - Move VcsDriver and VcsProcess out of nested service/layer paths - Update server, workspace, orchestration, and tests to use new exports - Rename layer exports to `layer` for consistency --- .../OrchestrationEngineHarness.integration.ts | 12 +++--- .../Layers/CheckpointStore.test.ts | 10 ++--- .../checkpointing/Layers/CheckpointStore.ts | 2 +- apps/server/src/git/Layers/GitManager.test.ts | 14 +++---- apps/server/src/git/Layers/GitManager.ts | 2 +- .../Layers/CheckpointReactor.test.ts | 10 ++--- .../Layers/ProviderCommandReactor.test.ts | 2 +- .../Layers/ProviderCommandReactor.ts | 2 +- apps/server/src/server.test.ts | 2 +- apps/server/src/server.ts | 14 +++---- .../src/vcs/{Layers => }/GitVcsDriver.test.ts | 14 +++---- .../src/vcs/{Layers => }/GitVcsDriver.ts | 10 ++--- apps/server/src/vcs/Services/VcsProcess.ts | 32 ---------------- .../src/vcs/{Services => }/VcsDriver.ts | 6 +-- .../server/src/vcs/{Layers => }/VcsProcess.ts | 38 ++++++++++++++++--- .../workspace/Layers/WorkspaceEntries.test.ts | 10 ++--- .../src/workspace/Layers/WorkspaceEntries.ts | 2 +- .../Layers/WorkspaceFileSystem.test.ts | 6 +-- apps/server/src/ws.ts | 2 +- 19 files changed, 92 insertions(+), 98 deletions(-) rename apps/server/src/vcs/{Layers => }/GitVcsDriver.test.ts (92%) rename apps/server/src/vcs/{Layers => }/GitVcsDriver.ts (95%) delete mode 100644 apps/server/src/vcs/Services/VcsProcess.ts rename apps/server/src/vcs/{Services => }/VcsDriver.ts (89%) rename apps/server/src/vcs/{Layers => }/VcsProcess.ts (84%) diff --git a/apps/server/integration/OrchestrationEngineHarness.integration.ts b/apps/server/integration/OrchestrationEngineHarness.integration.ts index 27c55bbffb..0792b5c19d 100644 --- a/apps/server/integration/OrchestrationEngineHarness.integration.ts +++ b/apps/server/integration/OrchestrationEngineHarness.integration.ts @@ -33,7 +33,7 @@ import { ProjectionCheckpointRepositoryLive } from "../src/persistence/Layers/Pr import { ProjectionPendingApprovalRepositoryLive } from "../src/persistence/Layers/ProjectionPendingApprovals.ts"; import { ProviderSessionRuntimeRepositoryLive } from "../src/persistence/Layers/ProviderSessionRuntime.ts"; import { makeSqlitePersistenceLive } from "../src/persistence/Layers/Sqlite.ts"; -import { VcsDriver, type VcsDriverShape } from "../src/vcs/Services/VcsDriver.ts"; +import { VcsDriver, type VcsDriverShape } from "../src/vcs/VcsDriver.ts"; import { ProjectionCheckpointRepository } from "../src/persistence/Services/ProjectionCheckpoints.ts"; import { ProjectionPendingApprovalRepository } from "../src/persistence/Services/ProjectionPendingApprovals.ts"; import { makeAdapterRegistryMock } from "../src/provider/testUtils/providerAdapterRegistryMock.ts"; @@ -76,8 +76,8 @@ import { import { deriveServerPaths, ServerConfig } from "../src/config.ts"; import { WorkspaceEntriesLive } from "../src/workspace/Layers/WorkspaceEntries.ts"; import { WorkspacePathsLive } from "../src/workspace/Layers/WorkspacePaths.ts"; -import { GitVcsDriverLive } from "../src/vcs/Layers/GitVcsDriver.ts"; -import { VcsProcessLive } from "../src/vcs/Layers/VcsProcess.ts"; +import { layer as GitVcsDriverLayer } from "../src/vcs/GitVcsDriver.ts"; +import { layer as VcsProcessLayer } from "../src/vcs/VcsProcess.ts"; function runGit(cwd: string, args: ReadonlyArray) { return execFileSync("git", args, { @@ -292,7 +292,7 @@ export const makeOrchestrationIntegrationHarness = ( Layer.provide(providerEventLoggersLayer), ); - const checkpointStoreLayer = CheckpointStoreLive.pipe(Layer.provide(GitVcsDriverLive)); + const checkpointStoreLayer = CheckpointStoreLive.pipe(Layer.provide(GitVcsDriverLayer)); const projectionSnapshotQueryLayer = OrchestrationProjectionSnapshotQueryLive; const runtimeServicesLayer = Layer.mergeAll( projectionSnapshotQueryLayer, @@ -343,12 +343,12 @@ export const makeOrchestrationIntegrationHarness = ( Layer.provideMerge( WorkspaceEntriesLive.pipe( Layer.provide(WorkspacePathsLive), - Layer.provideMerge(GitVcsDriverLive), + Layer.provideMerge(GitVcsDriverLayer), Layer.provide(NodeServices.layer), ), ), Layer.provideMerge(WorkspacePathsLive), - Layer.provideMerge(VcsProcessLive), + Layer.provideMerge(VcsProcessLayer), ); const orchestrationReactorLayer = OrchestrationReactorLive.pipe( Layer.provideMerge(runtimeIngestionLayer), diff --git a/apps/server/src/checkpointing/Layers/CheckpointStore.test.ts b/apps/server/src/checkpointing/Layers/CheckpointStore.test.ts index 0bdff6fd82..7a710c7aea 100644 --- a/apps/server/src/checkpointing/Layers/CheckpointStore.test.ts +++ b/apps/server/src/checkpointing/Layers/CheckpointStore.test.ts @@ -8,9 +8,9 @@ import { describe, expect } from "vitest"; import { checkpointRefForThreadTurn } from "../Utils.ts"; import { CheckpointStoreLive } from "./CheckpointStore.ts"; import { CheckpointStore } from "../Services/CheckpointStore.ts"; -import { GitVcsDriverLive } from "../../vcs/Layers/GitVcsDriver.ts"; -import { VcsProcessLive } from "../../vcs/Layers/VcsProcess.ts"; -import { VcsProcess } from "../../vcs/Services/VcsProcess.ts"; +import { layer as GitVcsDriverLayer } from "../../vcs/GitVcsDriver.ts"; +import { layer as VcsProcessLayer } from "../../vcs/VcsProcess.ts"; +import { VcsProcess } from "../../vcs/VcsProcess.ts"; import type { VcsError } from "@t3tools/contracts"; import { ServerConfig } from "../../config.ts"; import { ThreadId } from "@t3tools/contracts"; @@ -18,8 +18,8 @@ import { ThreadId } from "@t3tools/contracts"; const ServerConfigLayer = ServerConfig.layerTest(process.cwd(), { prefix: "t3-checkpoint-store-test-", }); -const VcsProcessTestLayer = VcsProcessLive.pipe(Layer.provide(NodeServices.layer)); -const VcsDriverTestLayer = GitVcsDriverLive.pipe(Layer.provide(VcsProcessTestLayer)); +const VcsProcessTestLayer = VcsProcessLayer.pipe(Layer.provide(NodeServices.layer)); +const VcsDriverTestLayer = GitVcsDriverLayer.pipe(Layer.provide(VcsProcessTestLayer)); const CheckpointStoreTestLayer = CheckpointStoreLive.pipe( Layer.provideMerge(VcsDriverTestLayer), Layer.provideMerge(NodeServices.layer), diff --git a/apps/server/src/checkpointing/Layers/CheckpointStore.ts b/apps/server/src/checkpointing/Layers/CheckpointStore.ts index d7b0b8b34c..41ca7785c8 100644 --- a/apps/server/src/checkpointing/Layers/CheckpointStore.ts +++ b/apps/server/src/checkpointing/Layers/CheckpointStore.ts @@ -15,7 +15,7 @@ import { Effect, Layer, FileSystem, Path } from "effect"; import { CheckpointInvariantError } from "../Errors.ts"; import { VcsProcessExitError } from "@t3tools/contracts"; -import { VcsDriver } from "../../vcs/Services/VcsDriver.ts"; +import { VcsDriver } from "../../vcs/VcsDriver.ts"; import { CheckpointStore, type CheckpointStoreShape } from "../Services/CheckpointStore.ts"; import { CheckpointRef } from "@t3tools/contracts"; diff --git a/apps/server/src/git/Layers/GitManager.test.ts b/apps/server/src/git/Layers/GitManager.test.ts index b94a771dfb..0638a9f22c 100644 --- a/apps/server/src/git/Layers/GitManager.test.ts +++ b/apps/server/src/git/Layers/GitManager.test.ts @@ -21,9 +21,9 @@ import { GitHubCli, } from "../Services/GitHubCli.ts"; import { type TextGenerationShape, TextGeneration } from "../Services/TextGeneration.ts"; -import { GitVcsDriverLive } from "../../vcs/Layers/GitVcsDriver.ts"; -import { VcsProcessLive } from "../../vcs/Layers/VcsProcess.ts"; -import { VcsDriver } from "../../vcs/Services/VcsDriver.ts"; +import { layer as GitVcsDriverLayer } from "../../vcs/GitVcsDriver.ts"; +import { layer as VcsProcessLayer } from "../../vcs/VcsProcess.ts"; +import { VcsDriver } from "../../vcs/VcsDriver.ts"; import { makeGitManager } from "./GitManager.ts"; import { ServerConfig } from "../../config.ts"; import { ServerSettingsService } from "../../serverSettings.ts"; @@ -657,8 +657,8 @@ function makeManager(input?: { const serverSettingsLayer = ServerSettingsService.layerTest(); - const vcsDriverLayer = GitVcsDriverLive.pipe( - Layer.provideMerge(VcsProcessLive), + const vcsDriverLayer = GitVcsDriverLayer.pipe( + Layer.provideMerge(VcsProcessLayer), Layer.provideMerge(NodeServices.layer), Layer.provideMerge(ServerConfigLayer), ); @@ -684,9 +684,9 @@ function makeManager(input?: { const asThreadId = (threadId: string) => threadId as ThreadId; -const GitManagerTestLayer = GitVcsDriverLive.pipe( +const GitManagerTestLayer = GitVcsDriverLayer.pipe( Layer.provide(ServerConfig.layerTest(process.cwd(), { prefix: "t3-git-manager-test-" })), - Layer.provideMerge(VcsProcessLive), + Layer.provideMerge(VcsProcessLayer), Layer.provideMerge(NodeServices.layer), ); diff --git a/apps/server/src/git/Layers/GitManager.ts b/apps/server/src/git/Layers/GitManager.ts index 349a19a59e..b6b87f8f9c 100644 --- a/apps/server/src/git/Layers/GitManager.ts +++ b/apps/server/src/git/Layers/GitManager.ts @@ -49,7 +49,7 @@ import { decodeGitHubPullRequestListJson, formatGitHubJsonDecodeError, } from "../githubPullRequests.ts"; -import { VcsDriver } from "../../vcs/Services/VcsDriver.ts"; +import { VcsDriver } from "../../vcs/VcsDriver.ts"; const COMMIT_TIMEOUT_MS = 10 * 60_000; const MAX_PROGRESS_TEXT_LENGTH = 500; diff --git a/apps/server/src/orchestration/Layers/CheckpointReactor.test.ts b/apps/server/src/orchestration/Layers/CheckpointReactor.test.ts index bc19e8c902..500f3debd3 100644 --- a/apps/server/src/orchestration/Layers/CheckpointReactor.test.ts +++ b/apps/server/src/orchestration/Layers/CheckpointReactor.test.ts @@ -25,8 +25,8 @@ import { afterEach, describe, expect, it, vi } from "vitest"; import { CheckpointStoreLive } from "../../checkpointing/Layers/CheckpointStore.ts"; import { CheckpointStore } from "../../checkpointing/Services/CheckpointStore.ts"; import { GitStatusBroadcaster } from "../../git/Services/GitStatusBroadcaster.ts"; -import { GitVcsDriverLive } from "../../vcs/Layers/GitVcsDriver.ts"; -import { VcsProcessLive } from "../../vcs/Layers/VcsProcess.ts"; +import { layer as GitVcsDriverLayer } from "../../vcs/GitVcsDriver.ts"; +import { layer as VcsProcessLayer } from "../../vcs/VcsProcess.ts"; import { RepositoryIdentityResolverLive } from "../../project/Layers/RepositoryIdentityResolver.ts"; import { CheckpointReactorLive } from "./CheckpointReactor.ts"; import { OrchestrationEngineLive } from "./OrchestrationEngine.ts"; @@ -307,15 +307,15 @@ describe("CheckpointReactor", () => { Layer.provideMerge(RuntimeReceiptBusLive), Layer.provideMerge(Layer.succeed(ProviderService, provider.service)), Layer.provideMerge(gitStatusBroadcasterLayer), - Layer.provideMerge(CheckpointStoreLive.pipe(Layer.provide(GitVcsDriverLive))), + Layer.provideMerge(CheckpointStoreLive.pipe(Layer.provide(GitVcsDriverLayer))), Layer.provideMerge( WorkspaceEntriesLive.pipe( Layer.provide(WorkspacePathsLive), - Layer.provideMerge(GitVcsDriverLive), + Layer.provideMerge(GitVcsDriverLayer), ), ), Layer.provideMerge(WorkspacePathsLive), - Layer.provideMerge(VcsProcessLive), + Layer.provideMerge(VcsProcessLayer), Layer.provideMerge(ServerConfigLayer), Layer.provideMerge(NodeServices.layer), ); diff --git a/apps/server/src/orchestration/Layers/ProviderCommandReactor.test.ts b/apps/server/src/orchestration/Layers/ProviderCommandReactor.test.ts index 0d16d3ebdd..293fa0e600 100644 --- a/apps/server/src/orchestration/Layers/ProviderCommandReactor.test.ts +++ b/apps/server/src/orchestration/Layers/ProviderCommandReactor.test.ts @@ -51,7 +51,7 @@ import { OrchestrationEngineService } from "../Services/OrchestrationEngine.ts"; import { ProviderCommandReactor } from "../Services/ProviderCommandReactor.ts"; import * as NodeServices from "@effect/platform-node/NodeServices"; import { ServerSettingsService } from "../../serverSettings.ts"; -import { VcsDriver, type VcsDriverShape } from "../../vcs/Services/VcsDriver.ts"; +import { VcsDriver, type VcsDriverShape } from "../../vcs/VcsDriver.ts"; const asProjectId = (value: string): ProjectId => ProjectId.make(value); const asApprovalRequestId = (value: string): ApprovalRequestId => ApprovalRequestId.make(value); diff --git a/apps/server/src/orchestration/Layers/ProviderCommandReactor.ts b/apps/server/src/orchestration/Layers/ProviderCommandReactor.ts index ea955553ed..89c3c9cdec 100644 --- a/apps/server/src/orchestration/Layers/ProviderCommandReactor.ts +++ b/apps/server/src/orchestration/Layers/ProviderCommandReactor.ts @@ -28,7 +28,7 @@ import { type ProviderCommandReactorShape, } from "../Services/ProviderCommandReactor.ts"; import { ServerSettingsService } from "../../serverSettings.ts"; -import { VcsDriver } from "../../vcs/Services/VcsDriver.ts"; +import { VcsDriver } from "../../vcs/VcsDriver.ts"; type ProviderIntentEvent = Extract< OrchestrationEvent, diff --git a/apps/server/src/server.test.ts b/apps/server/src/server.test.ts index 7d0066d4c6..a9d5a46c8c 100644 --- a/apps/server/src/server.test.ts +++ b/apps/server/src/server.test.ts @@ -104,7 +104,7 @@ import { import { WorkspaceEntriesLive } from "./workspace/Layers/WorkspaceEntries.ts"; import { WorkspaceFileSystemLive } from "./workspace/Layers/WorkspaceFileSystem.ts"; import { WorkspacePathsLive } from "./workspace/Layers/WorkspacePaths.ts"; -import { VcsDriver, type VcsDriverShape } from "./vcs/Services/VcsDriver.ts"; +import { VcsDriver, type VcsDriverShape } from "./vcs/VcsDriver.ts"; import { ServerSecretStoreLive } from "./auth/Layers/ServerSecretStore.ts"; import { ServerAuthLive } from "./auth/Layers/ServerAuth.ts"; diff --git a/apps/server/src/server.ts b/apps/server/src/server.ts index 66bbd68acc..114354fccd 100644 --- a/apps/server/src/server.ts +++ b/apps/server/src/server.ts @@ -46,8 +46,8 @@ import { RepositoryIdentityResolverLive } from "./project/Layers/RepositoryIdent import { WorkspaceEntriesLive } from "./workspace/Layers/WorkspaceEntries.ts"; import { WorkspaceFileSystemLive } from "./workspace/Layers/WorkspaceFileSystem.ts"; import { WorkspacePathsLive } from "./workspace/Layers/WorkspacePaths.ts"; -import { GitVcsDriverLive } from "./vcs/Layers/GitVcsDriver.ts"; -import { VcsProcessLive } from "./vcs/Layers/VcsProcess.ts"; +import { layer as GitVcsDriverLayer } from "./vcs/GitVcsDriver.ts"; +import { layer as VcsProcessLayer } from "./vcs/VcsProcess.ts"; import { ProjectSetupScriptRunnerLive } from "./project/Layers/ProjectSetupScriptRunner.ts"; import { ObservabilityLive } from "./observability/Layers/Observability.ts"; import { ServerEnvironmentLive } from "./environment/Layers/ServerEnvironment.ts"; @@ -136,7 +136,7 @@ const ReactorLayerLive = Layer.empty.pipe( const CheckpointingLayerLive = Layer.empty.pipe( Layer.provideMerge(CheckpointDiffQueryLive), - Layer.provideMerge(CheckpointStoreLive.pipe(Layer.provide(GitVcsDriverLive))), + Layer.provideMerge(CheckpointStoreLive.pipe(Layer.provide(GitVcsDriverLayer))), ); const ProviderSessionDirectoryLayerLive = ProviderSessionDirectoryLive.pipe( @@ -158,7 +158,7 @@ const PersistenceLayerLive = Layer.empty.pipe(Layer.provideMerge(SqlitePersisten const GitManagerLayerLive = GitManagerLive.pipe( Layer.provideMerge(ProjectSetupScriptRunnerLive), - Layer.provideMerge(GitVcsDriverLive), + Layer.provideMerge(GitVcsDriverLayer), Layer.provideMerge(GitHubCliLive), Layer.provideMerge(TextGenerationLive), ); @@ -166,14 +166,14 @@ const GitManagerLayerLive = GitManagerLive.pipe( const GitLayerLive = Layer.empty.pipe( Layer.provideMerge(GitManagerLayerLive), Layer.provideMerge(GitStatusBroadcasterLive.pipe(Layer.provide(GitManagerLayerLive))), - Layer.provideMerge(GitVcsDriverLive), + Layer.provideMerge(GitVcsDriverLayer), ); const TerminalLayerLive = TerminalManagerLive.pipe(Layer.provide(PtyAdapterLive)); const WorkspaceEntriesLayerLive = WorkspaceEntriesLive.pipe( Layer.provide(WorkspacePathsLive), - Layer.provideMerge(GitVcsDriverLive), + Layer.provideMerge(GitVcsDriverLayer), ); const WorkspaceFileSystemLayerLive = WorkspaceFileSystemLive.pipe( @@ -311,7 +311,7 @@ export const makeServerLayer = Layer.unwrap( Layer.provideMerge(HttpServerLive), Layer.provide(ObservabilityLive), Layer.provideMerge(FetchHttpClient.layer), - Layer.provideMerge(VcsProcessLive), + Layer.provideMerge(VcsProcessLayer), Layer.provideMerge(PlatformServicesLive), ); }), diff --git a/apps/server/src/vcs/Layers/GitVcsDriver.test.ts b/apps/server/src/vcs/GitVcsDriver.test.ts similarity index 92% rename from apps/server/src/vcs/Layers/GitVcsDriver.test.ts rename to apps/server/src/vcs/GitVcsDriver.test.ts index 454ba6bd0a..92910b21e8 100644 --- a/apps/server/src/vcs/Layers/GitVcsDriver.test.ts +++ b/apps/server/src/vcs/GitVcsDriver.test.ts @@ -3,10 +3,10 @@ import * as NodeServices from "@effect/platform-node/NodeServices"; import { Effect, Layer } from "effect"; import { describe, expect } from "vitest"; -import { ServerConfig } from "../../config.ts"; -import { VcsProcess } from "../Services/VcsProcess.ts"; -import { VcsDriver } from "../Services/VcsDriver.ts"; -import { GitVcsDriverLive } from "./GitVcsDriver.ts"; +import { ServerConfig } from "../config.ts"; +import { VcsProcess } from "./VcsProcess.ts"; +import { VcsDriver } from "./VcsDriver.ts"; +import { layer as GitVcsDriverLayer } from "./GitVcsDriver.ts"; const splitNullSeparatedPaths = (input: string): string[] => input @@ -18,7 +18,7 @@ const GitVcsDriverTestDependencies = ServerConfig.layerTest(process.cwd(), { prefix: "t3-git-vcs-driver-test-", }).pipe(Layer.provide(NodeServices.layer)); -it.layer(Layer.empty)("GitVcsDriverLive", (it) => { +it.layer(Layer.empty)("GitVcsDriverLayer", (it) => { describe("workspace helpers", () => { it.effect("filterIgnoredPaths chunks large path lists and preserves kept paths", () => Effect.gen(function* () { @@ -32,7 +32,7 @@ it.layer(Layer.empty)("GitVcsDriverLive", (it) => { ); const seenChunks: string[][] = []; - const layer = GitVcsDriverLive.pipe( + const layer = GitVcsDriverLayer.pipe( Layer.provideMerge(GitVcsDriverTestDependencies), Layer.provideMerge(NodeServices.layer), Layer.provide( @@ -81,7 +81,7 @@ it.layer(Layer.empty)("GitVcsDriverLive", (it) => { it.effect("listWorkspaceFiles disables fsmonitor and untracked cache helpers", () => Effect.gen(function* () { - const layer = GitVcsDriverLive.pipe( + const layer = GitVcsDriverLayer.pipe( Layer.provideMerge(GitVcsDriverTestDependencies), Layer.provideMerge(NodeServices.layer), Layer.provide( diff --git a/apps/server/src/vcs/Layers/GitVcsDriver.ts b/apps/server/src/vcs/GitVcsDriver.ts similarity index 95% rename from apps/server/src/vcs/Layers/GitVcsDriver.ts rename to apps/server/src/vcs/GitVcsDriver.ts index be547a4c45..b1a0728c18 100644 --- a/apps/server/src/vcs/Layers/GitVcsDriver.ts +++ b/apps/server/src/vcs/GitVcsDriver.ts @@ -1,9 +1,9 @@ import { Effect, Layer } from "effect"; import { VcsProcessExitError } from "@t3tools/contracts"; -import { makeGitCore } from "../../git/Layers/GitCore.ts"; -import { VcsDriver, type VcsDriverShape } from "../Services/VcsDriver.ts"; -import { VcsProcess, type VcsProcessShape } from "../Services/VcsProcess.ts"; +import { makeGitCore } from "../git/Layers/GitCore.ts"; +import { VcsDriver, type VcsDriverShape } from "./VcsDriver.ts"; +import { VcsProcess, type VcsProcessShape } from "./VcsProcess.ts"; const WORKSPACE_FILES_MAX_OUTPUT_BYTES = 16 * 1024 * 1024; const GIT_CHECK_IGNORE_MAX_STDIN_BYTES = 256 * 1024; @@ -91,7 +91,7 @@ const gitCommand = ( : {}), }); -export const makeGitVcsDriver = Effect.fn("makeGitVcsDriver")(function* () { +export const make = Effect.fn("makeGitVcsDriver")(function* () { const process = yield* VcsProcess; const legacyGit = yield* makeGitCore(); const capabilities = { @@ -249,4 +249,4 @@ export const makeGitVcsDriver = Effect.fn("makeGitVcsDriver")(function* () { }); }); -export const GitVcsDriverLive = Layer.effect(VcsDriver, makeGitVcsDriver()); +export const layer = Layer.effect(VcsDriver, make()); diff --git a/apps/server/src/vcs/Services/VcsProcess.ts b/apps/server/src/vcs/Services/VcsProcess.ts deleted file mode 100644 index ff29f19784..0000000000 --- a/apps/server/src/vcs/Services/VcsProcess.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { Context, type Effect } from "effect"; - -import type { VcsError } from "@t3tools/contracts"; - -export interface VcsProcessInput { - readonly operation: string; - readonly command: string; - readonly args: ReadonlyArray; - readonly cwd: string; - readonly stdin?: string; - readonly env?: NodeJS.ProcessEnv; - readonly allowNonZeroExit?: boolean; - readonly timeoutMs?: number; - readonly maxOutputBytes?: number; - readonly truncateOutputAtMaxBytes?: boolean; -} - -export interface VcsProcessOutput { - readonly exitCode: number; - readonly stdout: string; - readonly stderr: string; - readonly stdoutTruncated: boolean; - readonly stderrTruncated: boolean; -} - -export interface VcsProcessShape { - readonly run: (input: VcsProcessInput) => Effect.Effect; -} - -export class VcsProcess extends Context.Service()( - "t3/vcs/Services/VcsProcess", -) {} diff --git a/apps/server/src/vcs/Services/VcsDriver.ts b/apps/server/src/vcs/VcsDriver.ts similarity index 89% rename from apps/server/src/vcs/Services/VcsDriver.ts rename to apps/server/src/vcs/VcsDriver.ts index 1cc7c3f804..d94e0a53f6 100644 --- a/apps/server/src/vcs/Services/VcsDriver.ts +++ b/apps/server/src/vcs/VcsDriver.ts @@ -6,7 +6,7 @@ import type { VcsListWorkspaceFilesResult, VcsRepositoryIdentity, } from "@t3tools/contracts"; -import type { GitCoreShape } from "../../git/Services/GitCore.ts"; +import type { GitCoreShape } from "../git/Services/GitCore.ts"; import type { VcsProcessInput, VcsProcessOutput } from "./VcsProcess.ts"; export interface VcsDriverShape extends Omit { @@ -25,6 +25,4 @@ export interface VcsDriverShape extends Omit { ) => Effect.Effect, VcsError>; } -export class VcsDriver extends Context.Service()( - "t3/vcs/Services/VcsDriver", -) {} +export class VcsDriver extends Context.Service()("t3/vcs/VcsDriver") {} diff --git a/apps/server/src/vcs/Layers/VcsProcess.ts b/apps/server/src/vcs/VcsProcess.ts similarity index 84% rename from apps/server/src/vcs/Layers/VcsProcess.ts rename to apps/server/src/vcs/VcsProcess.ts index c406f0bdca..5196a870cd 100644 --- a/apps/server/src/vcs/Layers/VcsProcess.ts +++ b/apps/server/src/vcs/VcsProcess.ts @@ -1,13 +1,42 @@ -import { Duration, Effect, Layer, Option, PlatformError, Stream } from "effect"; +import { Duration, Context, Effect, Layer, Option, PlatformError, Stream } from "effect"; import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process"; import { VcsOutputDecodeError, + type VcsError, VcsProcessExitError, VcsProcessSpawnError, VcsProcessTimeoutError, } from "@t3tools/contracts"; -import { VcsProcess, type VcsProcessInput, type VcsProcessOutput } from "../Services/VcsProcess.ts"; + +export interface VcsProcessInput { + readonly operation: string; + readonly command: string; + readonly args: ReadonlyArray; + readonly cwd: string; + readonly stdin?: string; + readonly env?: NodeJS.ProcessEnv; + readonly allowNonZeroExit?: boolean; + readonly timeoutMs?: number; + readonly maxOutputBytes?: number; + readonly truncateOutputAtMaxBytes?: boolean; +} + +export interface VcsProcessOutput { + readonly exitCode: number; + readonly stdout: string; + readonly stderr: string; + readonly stdoutTruncated: boolean; + readonly stderrTruncated: boolean; +} + +export interface VcsProcessShape { + readonly run: (input: VcsProcessInput) => Effect.Effect; +} + +export class VcsProcess extends Context.Service()( + "t3/vcs/VcsProcess", +) {} const DEFAULT_TIMEOUT_MS = 30_000; const DEFAULT_MAX_OUTPUT_BYTES = 1_000_000; @@ -37,7 +66,6 @@ const collectOutput = Effect.fn("VcsProcess.collectOutput")(function* ( truncated = true; if (truncateOutputAtMaxBytes) { text += OUTPUT_TRUNCATED_MARKER; - return; } return; } @@ -73,7 +101,7 @@ const collectOutput = Effect.fn("VcsProcess.collectOutput")(function* ( return { text, truncated }; }); -export const makeVcsProcess = Effect.fn("makeVcsProcess")(function* () { +export const make = Effect.fn("makeVcsProcess")(function* () { const spawner = yield* ChildProcessSpawner.ChildProcessSpawner; const run = Effect.fn("VcsProcess.run")(function* (input: VcsProcessInput) { @@ -191,4 +219,4 @@ export const makeVcsProcess = Effect.fn("makeVcsProcess")(function* () { return VcsProcess.of({ run }); }); -export const VcsProcessLive = Layer.effect(VcsProcess, makeVcsProcess()); +export const layer = Layer.effect(VcsProcess, make()); diff --git a/apps/server/src/workspace/Layers/WorkspaceEntries.test.ts b/apps/server/src/workspace/Layers/WorkspaceEntries.test.ts index 61f2b9240c..87ca014a95 100644 --- a/apps/server/src/workspace/Layers/WorkspaceEntries.test.ts +++ b/apps/server/src/workspace/Layers/WorkspaceEntries.test.ts @@ -5,9 +5,9 @@ import { it, afterEach, describe, expect, vi } from "@effect/vitest"; import { Effect, FileSystem, Layer, Path, PlatformError } from "effect"; import { ServerConfig } from "../../config.ts"; -import { GitVcsDriverLive } from "../../vcs/Layers/GitVcsDriver.ts"; -import { VcsProcessLive } from "../../vcs/Layers/VcsProcess.ts"; -import { VcsProcess } from "../../vcs/Services/VcsProcess.ts"; +import { layer as GitVcsDriverLayer } from "../../vcs/GitVcsDriver.ts"; +import { layer as VcsProcessLayer } from "../../vcs/VcsProcess.ts"; +import { VcsProcess } from "../../vcs/VcsProcess.ts"; import { WorkspaceEntries } from "../Services/WorkspaceEntries.ts"; import { WorkspaceEntriesLive } from "./WorkspaceEntries.ts"; import { WorkspacePathsLive } from "./WorkspacePaths.ts"; @@ -15,8 +15,8 @@ import { WorkspacePathsLive } from "./WorkspacePaths.ts"; const TestLayer = Layer.empty.pipe( Layer.provideMerge(WorkspaceEntriesLive.pipe(Layer.provide(WorkspacePathsLive))), Layer.provideMerge(WorkspacePathsLive), - Layer.provideMerge(VcsProcessLive), - Layer.provideMerge(GitVcsDriverLive.pipe(Layer.provide(VcsProcessLive))), + Layer.provideMerge(VcsProcessLayer), + Layer.provideMerge(GitVcsDriverLayer.pipe(Layer.provide(VcsProcessLayer))), Layer.provide( ServerConfig.layerTest(process.cwd(), { prefix: "t3-workspace-entries-test-", diff --git a/apps/server/src/workspace/Layers/WorkspaceEntries.ts b/apps/server/src/workspace/Layers/WorkspaceEntries.ts index 7bb143347f..ff15c8cfc4 100644 --- a/apps/server/src/workspace/Layers/WorkspaceEntries.ts +++ b/apps/server/src/workspace/Layers/WorkspaceEntries.ts @@ -13,7 +13,7 @@ import { type RankedSearchResult, } from "@t3tools/shared/searchRanking"; -import { VcsDriver } from "../../vcs/Services/VcsDriver.ts"; +import { VcsDriver } from "../../vcs/VcsDriver.ts"; import { WorkspaceEntries, WorkspaceEntriesBrowseError, diff --git a/apps/server/src/workspace/Layers/WorkspaceFileSystem.test.ts b/apps/server/src/workspace/Layers/WorkspaceFileSystem.test.ts index 71829708c9..fd8daf6a3e 100644 --- a/apps/server/src/workspace/Layers/WorkspaceFileSystem.test.ts +++ b/apps/server/src/workspace/Layers/WorkspaceFileSystem.test.ts @@ -3,8 +3,8 @@ import { it, describe, expect } from "@effect/vitest"; import { Effect, FileSystem, Layer, Path } from "effect"; import { ServerConfig } from "../../config.ts"; -import { GitVcsDriverLive } from "../../vcs/Layers/GitVcsDriver.ts"; -import { VcsProcessLive } from "../../vcs/Layers/VcsProcess.ts"; +import { layer as GitVcsDriverLayer } from "../../vcs/GitVcsDriver.ts"; +import { layer as VcsProcessLayer } from "../../vcs/VcsProcess.ts"; import { WorkspaceEntries } from "../Services/WorkspaceEntries.ts"; import { WorkspaceFileSystem } from "../Services/WorkspaceFileSystem.ts"; import { WorkspaceEntriesLive } from "./WorkspaceEntries.ts"; @@ -20,7 +20,7 @@ const TestLayer = Layer.empty.pipe( Layer.provideMerge(ProjectLayer), Layer.provideMerge(WorkspaceEntriesLive.pipe(Layer.provide(WorkspacePathsLive))), Layer.provideMerge(WorkspacePathsLive), - Layer.provideMerge(GitVcsDriverLive.pipe(Layer.provide(VcsProcessLive))), + Layer.provideMerge(GitVcsDriverLayer.pipe(Layer.provide(VcsProcessLayer))), Layer.provide( ServerConfig.layerTest(process.cwd(), { prefix: "t3-workspace-files-test-", diff --git a/apps/server/src/ws.ts b/apps/server/src/ws.ts index da0bfad598..065706ca3f 100644 --- a/apps/server/src/ws.ts +++ b/apps/server/src/ws.ts @@ -49,7 +49,7 @@ import { TerminalManager } from "./terminal/Services/Manager.ts"; import { WorkspaceEntries } from "./workspace/Services/WorkspaceEntries.ts"; import { WorkspaceFileSystem } from "./workspace/Services/WorkspaceFileSystem.ts"; import { WorkspacePathOutsideRootError } from "./workspace/Services/WorkspacePaths.ts"; -import { VcsDriver } from "./vcs/Services/VcsDriver.ts"; +import { VcsDriver } from "./vcs/VcsDriver.ts"; import { ProjectSetupScriptRunner } from "./project/Services/ProjectSetupScriptRunner.ts"; import { RepositoryIdentityResolver } from "./project/Services/RepositoryIdentityResolver.ts"; import { ServerEnvironment } from "./environment/Services/ServerEnvironment.ts";