Open History to see the last commit
1/**
2 * TextGeneration - Effect service contract for AI-generated Git content.
3 *
4 * Generates commit messages and pull request titles/bodies from repository
5 * context prepared by Git services.
6 *
7 * @module TextGeneration
8 */
9import { ServiceMap } from "effect";
10import type { Effect } from "effect";
11
12import type { TextGenerationError } from "../Errors.ts";
13
14export interface CommitMessageGenerationInput {
15 cwd: string;
16 branch: string | null;
17 stagedSummary: string;
18 stagedPatch: string;
19}
20
21export interface CommitMessageGenerationResult {
22 subject: string;
23 body: string;
24}
25
26export interface PrContentGenerationInput {
27 cwd: string;
28 baseBranch: string;
29 headBranch: string;
30 commitSummary: string;
31 diffSummary: string;
32 diffPatch: string;
33}
34
35export interface PrContentGenerationResult {
36 title: string;
37 body: string;
38}
39
40export interface TextGenerationService {
41 generateCommitMessage(
42 input: CommitMessageGenerationInput,
43 ): Promise<CommitMessageGenerationResult>;
44 generatePrContent(input: PrContentGenerationInput): Promise<PrContentGenerationResult>;
45}
46
47/**
48 * TextGenerationShape - Service API for commit/PR text generation.
49 */
50export interface TextGenerationShape {
51 /**
52 * Generate a commit message from staged change context.
53 */
54 readonly generateCommitMessage: (
55 input: CommitMessageGenerationInput,
56 ) => Effect.Effect<CommitMessageGenerationResult, TextGenerationError>;
57
58 /**
59 * Generate pull request title/body from branch and diff context.
60 */
61 readonly generatePrContent: (
62 input: PrContentGenerationInput,
63 ) => Effect.Effect<PrContentGenerationResult, TextGenerationError>;
64}
65
66/**
67 * TextGeneration - Service tag for commit and PR text generation.
68 */
69export class TextGeneration extends ServiceMap.Service<TextGeneration, TextGenerationShape>()(
70 "t3/git/Services/TextGeneration",
71) {}