/** * TextGeneration - Effect service contract for AI-generated Git content. * * Generates commit messages and pull request titles/bodies from repository * context prepared by Git services. * * @module TextGeneration */ import { ServiceMap } from "effect"; import type { Effect } from "effect"; import type { ChatAttachment, ModelSelection } from "@t3tools/contracts"; import type { TextGenerationError } from "../Errors.ts"; /** Providers that support git text generation (commit messages, PR content, branch names). */ export type TextGenerationProvider = "codex" | "claudeAgent"; export interface CommitMessageGenerationInput { cwd: string; branch: string | null; stagedSummary: string; stagedPatch: string; /** When true, the model also returns a semantic branch name for the change. */ includeBranch?: boolean; /** What model and provider to use for generation. */ modelSelection: ModelSelection; } export interface CommitMessageGenerationResult { subject: string; body: string; /** Only present when `includeBranch` was set on the input. */ branch?: string | undefined; } export interface PrContentGenerationInput { cwd: string; baseBranch: string; headBranch: string; commitSummary: string; diffSummary: string; diffPatch: string; /** What model and provider to use for generation. */ modelSelection: ModelSelection; } export interface PrContentGenerationResult { title: string; body: string; } export interface BranchNameGenerationInput { cwd: string; message: string; attachments?: ReadonlyArray | undefined; /** What model and provider to use for generation. */ modelSelection: ModelSelection; } export interface BranchNameGenerationResult { branch: string; } export interface ThreadTitleGenerationInput { cwd: string; message: string; attachments?: ReadonlyArray | undefined; /** What model and provider to use for generation. */ modelSelection: ModelSelection; } export interface ThreadTitleGenerationResult { title: string; } export interface TextGenerationService { generateCommitMessage( input: CommitMessageGenerationInput, ): Promise; generatePrContent(input: PrContentGenerationInput): Promise; generateBranchName(input: BranchNameGenerationInput): Promise; generateThreadTitle(input: ThreadTitleGenerationInput): Promise; } /** * TextGenerationShape - Service API for commit/PR text generation. */ export interface TextGenerationShape { /** * Generate a commit message from staged change context. */ readonly generateCommitMessage: ( input: CommitMessageGenerationInput, ) => Effect.Effect; /** * Generate pull request title/body from branch and diff context. */ readonly generatePrContent: ( input: PrContentGenerationInput, ) => Effect.Effect; /** * Generate a concise branch name from a user message. */ readonly generateBranchName: ( input: BranchNameGenerationInput, ) => Effect.Effect; /** * Generate a concise thread title from a user's first message. */ readonly generateThreadTitle: ( input: ThreadTitleGenerationInput, ) => Effect.Effect; } /** * TextGeneration - Service tag for commit and PR text generation. */ export class TextGeneration extends ServiceMap.Service()( "t3/git/Services/TextGeneration", ) {}