History

chore: effect rpc and layer based startup (#929)

Julius Marminge committed 7 months ago

Commit d8aa2f81 parent 64d6938116 files · +6676 −6648Browse files

Showing the changes to apps/server/src/git (15 of 116 files). Show all

Unified · Split

15 files
  1. apps/server/src/git/Errors.ts +0 −67
  2. apps/server/src/git/Layers/ClaudeTextGeneration.ts +1 −1
  3. apps/server/src/git/Layers/CodexTextGeneration.test.ts +1 −1
  4. apps/server/src/git/Layers/CodexTextGeneration.ts +1 −1
  5. apps/server/src/git/Layers/GitCore.test.ts +1 −1
  6. apps/server/src/git/Layers/GitCore.ts +4 −3
  7. apps/server/src/git/Layers/GitHubCli.ts +1 −1
  8. apps/server/src/git/Layers/GitManager.test.ts +1 −1
  9. apps/server/src/git/Layers/GitManager.ts +2 −2
  10. apps/server/src/git/Prompts.test.ts +1 −1
  11. apps/server/src/git/Services/GitCore.ts +1 −1
  12. apps/server/src/git/Services/GitHubCli.ts +1 −1
  13. apps/server/src/git/Services/GitManager.ts +1 −1
  14. apps/server/src/git/Services/TextGeneration.ts +1 −1
  15. apps/server/src/git/Utils.ts +1 −1
apps/server/src/git/Errors.ts+0−67
@@ -1,67 +0,0 @@
1−import { Schema } from "effect";
2−
3−/**
4− * GitCommandError - Git command execution failed.
5− */
6−export class GitCommandError extends Schema.TaggedErrorClass<GitCommandError>()("GitCommandError", {
7− operation: Schema.String,
8− command: Schema.String,
9− cwd: Schema.String,
10− detail: Schema.String,
11− cause: Schema.optional(Schema.Defect),
12−}) {
13− override get message(): string {
14− return `Git command failed in ${this.operation}: ${this.command} (${this.cwd}) - ${this.detail}`;
15− }
16−}
17−
18−/**
19− * GitHubCliError - GitHub CLI execution or authentication failed.
20− */
21−export class GitHubCliError extends Schema.TaggedErrorClass<GitHubCliError>()("GitHubCliError", {
22− operation: Schema.String,
23− detail: Schema.String,
24− cause: Schema.optional(Schema.Defect),
25−}) {
26− override get message(): string {
27− return `GitHub CLI failed in ${this.operation}: ${this.detail}`;
28− }
29−}
30−
31−/**
32− * TextGenerationError - Commit or PR text generation failed.
33− */
34−export class TextGenerationError extends Schema.TaggedErrorClass<TextGenerationError>()(
35− "TextGenerationError",
36− {
37− operation: Schema.String,
38− detail: Schema.String,
39− cause: Schema.optional(Schema.Defect),
40− },
41−) {
42− override get message(): string {
43− return `Text generation failed in ${this.operation}: ${this.detail}`;
44− }
45−}
46−
47−/**
48− * GitManagerError - Stacked Git workflow orchestration failed.
49− */
50−export class GitManagerError extends Schema.TaggedErrorClass<GitManagerError>()("GitManagerError", {
51− operation: Schema.String,
52− detail: Schema.String,
53− cause: Schema.optional(Schema.Defect),
54−}) {
55− override get message(): string {
56− return `Git manager failed in ${this.operation}: ${this.detail}`;
57− }
58−}
59−
60−/**
61− * GitManagerServiceError - Errors emitted by stacked Git workflow orchestration.
62− */
63−export type GitManagerServiceError =
64− | GitManagerError
65− | GitCommandError
66− | GitHubCliError
67− | TextGenerationError;
apps/server/src/git/Layers/ClaudeTextGeneration.ts+1−1
@@ -14,7 +14,7 @@ import { ClaudeModelSelection } from "@t3tools/contracts"; · 13 unmodified lines
1414 import { resolveApiModelId } from "@t3tools/shared/model";
1515 import { sanitizeBranchFragment, sanitizeFeatureBranchName } from "@t3tools/shared/git";
1616
17−import { TextGenerationError } from "../Errors.ts";
17+import { TextGenerationError } from "@t3tools/contracts";
1818 import { type TextGenerationShape, TextGeneration } from "../Services/TextGeneration.ts";
1919 import {
2020 buildBranchNamePrompt,
apps/server/src/git/Layers/CodexTextGeneration.test.ts+1−1
@@ -5,7 +5,7 @@ import { expect } from "vitest"; · 4 unmodified lines
55
66 import { ServerConfig } from "../../config.ts";
77 import { CodexTextGenerationLive } from "./CodexTextGeneration.ts";
8−import { TextGenerationError } from "../Errors.ts";
8+import { TextGenerationError } from "@t3tools/contracts";
99 import { TextGeneration } from "../Services/TextGeneration.ts";
1010 import { ServerSettingsService } from "../../serverSettings.ts";
1111
apps/server/src/git/Layers/CodexTextGeneration.ts+1−1
@@ -8,7 +8,7 @@ import { sanitizeBranchFragment, sanitizeFeatureBranchName } from "@t3tools/shar · 7 unmodified lines
88
99 import { resolveAttachmentPath } from "../../attachmentStore.ts";
1010 import { ServerConfig } from "../../config.ts";
11−import { TextGenerationError } from "../Errors.ts";
11+import { TextGenerationError } from "@t3tools/contracts";
1212 import {
1313 type BranchNameGenerationInput,
1414 type ThreadTitleGenerationResult,
apps/server/src/git/Layers/GitCore.test.ts+1−1
@@ -8,7 +8,7 @@ import { describe, expect, vi } from "vitest"; · 7 unmodified lines
88
99 import { GitCoreLive, makeGitCore } from "./GitCore.ts";
1010 import { GitCore, type GitCoreShape } from "../Services/GitCore.ts";
11−import { GitCommandError } from "../Errors.ts";
11+import { GitCommandError } from "@t3tools/contracts";
1212 import { type ProcessRunResult, runProcess } from "../../processRunner.ts";
1313 import { ServerConfig } from "../../config.ts";
1414
apps/server/src/git/Layers/GitCore.ts+4−3
@@ -18,7 +18,7 @@ import { · 17 unmodified lines
1818 } from "effect";
1919 import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";
2020
21−import { GitCommandError } from "../Errors.ts";
21+import { GitCommandError } from "@t3tools/contracts";
2222 import {
2323 GitCore,
2424 type ExecuteGitProgress,
@@ -1941,8 +1941,9 @@ export const makeGitCore = Effect.fn("makeGitCore")(function* (options?: { · 1916 unmodified lines
19411941 });
19421942
19431943 // Refresh upstream refs in the background so checkout remains responsive.
1944− yield* Effect.forkScoped(
1945− refreshCheckedOutBranchUpstream(input.cwd).pipe(Effect.ignoreCause({ log: true })),
1944+ yield* refreshCheckedOutBranchUpstream(input.cwd).pipe(
1945+ Effect.ignoreCause({ log: true }),
1946+ Effect.forkDetach({ startImmediately: true }),
19461947 );
19471948 },
19481949 );
apps/server/src/git/Layers/GitHubCli.ts+1−1
@@ -2,7 +2,7 @@ import { Effect, Layer, Schema } from "effect"; · 1 unmodified line
22 import { PositiveInt, TrimmedNonEmptyString } from "@t3tools/contracts";
33
44 import { runProcess } from "../../processRunner";
5−import { GitHubCliError } from "../Errors.ts";
5+import { GitHubCliError } from "@t3tools/contracts";
66 import {
77 GitHubCli,
88 type GitHubRepositoryCloneUrls,
apps/server/src/git/Layers/GitManager.test.ts+1−1
@@ -8,7 +8,7 @@ import { Effect, FileSystem, Layer, PlatformError, Scope } from "effect"; · 7 unmodified lines
88 import { expect } from "vitest";
99 import type { GitActionProgressEvent, ModelSelection } from "@t3tools/contracts";
1010
11−import { GitCommandError, GitHubCliError, TextGenerationError } from "../Errors.ts";
11+import { GitCommandError, GitHubCliError, TextGenerationError } from "@t3tools/contracts";
1212 import { type GitManagerShape } from "../Services/GitManager.ts";
1313 import {
1414 type GitHubCliShape,
apps/server/src/git/Layers/GitManager.ts+2−2
@@ -14,7 +14,7 @@ import { · 13 unmodified lines
1414 sanitizeFeatureBranchName,
1515 } from "@t3tools/shared/git";
1616
17−import { GitManagerError } from "../Errors.ts";
17+import { GitManagerError } from "@t3tools/contracts";
1818 import {
1919 GitManager,
2020 type GitActionProgressReporter,
@@ -25,7 +25,7 @@ import { GitCore } from "../Services/GitCore.ts"; · 4 unmodified lines
2525 import { GitHubCli } from "../Services/GitHubCli.ts";
2626 import { TextGeneration } from "../Services/TextGeneration.ts";
2727 import { ServerSettingsService } from "../../serverSettings.ts";
28−import type { GitManagerServiceError } from "../Errors.ts";
28+import type { GitManagerServiceError } from "@t3tools/contracts";
2929
3030 const COMMIT_TIMEOUT_MS = 10 * 60_000;
3131 const MAX_PROGRESS_TEXT_LENGTH = 500;
apps/server/src/git/Prompts.test.ts+1−1
@@ -7,7 +7,7 @@ import { · 6 unmodified lines
77 buildThreadTitlePrompt,
88 } from "./Prompts.ts";
99 import { normalizeCliError, sanitizeThreadTitle } from "./Utils.ts";
10−import { TextGenerationError } from "./Errors.ts";
10+import { TextGenerationError } from "@t3tools/contracts";
1111
1212 describe("buildCommitMessagePrompt", () => {
1313 it("includes staged patch and summary in the prompt", () => {
apps/server/src/git/Services/GitCore.ts+1−1
@@ -22,7 +22,7 @@ import type { · 21 unmodified lines
2222 GitStatusResult,
2323 } from "@t3tools/contracts";
2424
25−import type { GitCommandError } from "../Errors.ts";
25+import type { GitCommandError } from "@t3tools/contracts";
2626
2727 export interface ExecuteGitInput {
2828 readonly operation: string;
apps/server/src/git/Services/GitHubCli.ts+1−1
@@ -9,7 +9,7 @@ import { ServiceMap } from "effect"; · 8 unmodified lines
99 import type { Effect } from "effect";
1010
1111 import type { ProcessRunResult } from "../../processRunner";
12−import type { GitHubCliError } from "../Errors.ts";
12+import type { GitHubCliError } from "@t3tools/contracts";
1313
1414 export interface GitHubPullRequestSummary {
1515 readonly number: number;
apps/server/src/git/Services/GitManager.ts+1−1
@@ -19,7 +19,7 @@ import { · 18 unmodified lines
1919 } from "@t3tools/contracts";
2020 import { ServiceMap } from "effect";
2121 import type { Effect } from "effect";
22−import type { GitManagerServiceError } from "../Errors.ts";
22+import type { GitManagerServiceError } from "@t3tools/contracts";
2323
2424 export interface GitActionProgressReporter {
2525 readonly publish: (event: GitActionProgressEvent) => Effect.Effect<void, never>;
apps/server/src/git/Services/TextGeneration.ts+1−1
@@ -10,7 +10,7 @@ import { ServiceMap } from "effect"; · 9 unmodified lines
1010 import type { Effect } from "effect";
1111 import type { ChatAttachment, ModelSelection } from "@t3tools/contracts";
1212
13−import type { TextGenerationError } from "../Errors.ts";
13+import type { TextGenerationError } from "@t3tools/contracts";
1414
1515 /** Providers that support git text generation (commit messages, PR content, branch names). */
1616 export type TextGenerationProvider = "codex" | "claudeAgent";
apps/server/src/git/Utils.ts+1−1
@@ -5,7 +5,7 @@ · 4 unmodified lines
55 */
66 import { Schema } from "effect";
77
8−import { TextGenerationError } from "./Errors.ts";
8+import { TextGenerationError } from "@t3tools/contracts";
99
1010 import { existsSync } from "node:fs";
1111 import { join } from "node:path";