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
This commit is contained in:
1 parent
972a6876b8
commit
8f09b8d0ab
19 files changed
+92
-98
No files matched your search
@@ -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<string>) {
|
||||
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),
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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),
|
||||
);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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),
|
||||
);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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),
|
||||
);
|
||||
}),
|
||||
|
||||
+7
-7
@@ -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(
|
||||
@@ -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());
|
||||
@@ -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<string>;
|
||||
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<VcsProcessOutput, VcsError>;
|
||||
}
|
||||
|
||||
export class VcsProcess extends Context.Service<VcsProcess, VcsProcessShape>()(
|
||||
"t3/vcs/Services/VcsProcess",
|
||||
) {}
|
||||
@@ -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<GitCoreShape, "execute"> {
|
||||
@@ -25,6 +25,4 @@ export interface VcsDriverShape extends Omit<GitCoreShape, "execute"> {
|
||||
) => Effect.Effect<ReadonlyArray<string>, VcsError>;
|
||||
}
|
||||
|
||||
export class VcsDriver extends Context.Service<VcsDriver, VcsDriverShape>()(
|
||||
"t3/vcs/Services/VcsDriver",
|
||||
) {}
|
||||
export class VcsDriver extends Context.Service<VcsDriver, VcsDriverShape>()("t3/vcs/VcsDriver") {}
|
||||
@@ -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<string>;
|
||||
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<VcsProcessOutput, VcsError>;
|
||||
}
|
||||
|
||||
export class VcsProcess extends Context.Service<VcsProcess, VcsProcessShape>()(
|
||||
"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());
|
||||
@@ -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-",
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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-",
|
||||
|
||||
@@ -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";
|
||||
|
||||
Reference in new issue
Block a user