1import type {
2 BranchNamingOptions,
3 ChatAttachment,
4 ModelSelection,
5 ProjectId,
6 PullRequestReviewGuide,
7 TextGenerationError,
8} from "@t3tools/contracts";
9import type * as Effect from "effect/Effect";
10
11import type { TextGenerationPolicy } from "./textGenerationPolicy.ts";
12import type { ThreadTitleForkSource } from "./textGenerationPrompts.ts";
13
14export interface CommitMessageGenerationInput {
15 cwd: string;
16 branch: string | null;
17 stagedSummary: string;
18 stagedPatch: string;
19 includeBranch?: boolean;
20 policy?: TextGenerationPolicy | undefined;
21 modelSelection: ModelSelection;
22 projectId?: ProjectId | null | undefined;
23}
24
25export interface CommitMessageGenerationResult {
26 subject: string;
27 body: string;
28 branch?: string | undefined;
29}
30
31export interface PrContentGenerationInput {
32 cwd: string;
33 baseBranch: string;
34 headBranch: string;
35 commitSummary: string;
36 diffSummary: string;
37 diffPatch: string;
38 changeRequestTemplate?: string | undefined;
39 threadContext?: string | undefined;
40 policy?: TextGenerationPolicy | undefined;
41 modelSelection: ModelSelection;
42 projectId?: ProjectId | null | undefined;
43}
44
45export interface PrContentGenerationResult {
46 title: string;
47 body: string;
48}
49
50export interface BranchNameGenerationInput {
51 naming?: BranchNamingOptions | undefined;
52 cwd: string;
53 message: string;
54 attachments?: ReadonlyArray<ChatAttachment> | undefined;
55 modelSelection: ModelSelection;
56 projectId?: ProjectId | null | undefined;
57}
58
59export interface BranchNameGenerationResult {
60 branch: string;
61}
62
63export interface ThreadTitleGenerationInput {
64 linkedContext?: string | undefined;
65 cwd: string;
66 message: string;
67 projectTitle?: string | undefined;
68 previousTitle?: string | undefined;
69 forkSource?: ThreadTitleForkSource | undefined;
70 attachments?: ReadonlyArray<ChatAttachment> | undefined;
71 instructions?: string | undefined;
72 modelSelection: ModelSelection;
73 projectId?: ProjectId | null | undefined;
74}
75
76export interface ThreadTitleGenerationResult {
77 title: string;
78 needsRefinement?: boolean | undefined;
79}
80
81export interface ReviewGuideStackLayer {
82 readonly number: number;
83 readonly title: string | null;
84 readonly headSha: string | null;
85 readonly state: "open" | "closed" | "merged";
86}
87
88export interface ReviewGuideGenerationInput {
89 cwd: string;
90 number: number;
91 title: string;
92 description: string;
93 baseBranch: string;
94 baseCommit: string;
95 settledReview: string;
96 instructions?: string | undefined;
97 stack?: ReadonlyArray<ReviewGuideStackLayer> | undefined;
98 modelSelection: ModelSelection;
99 projectId?: ProjectId | null | undefined;
100}
101
102export type ReviewGuideGenerationResult = Omit<
103 PullRequestReviewGuide,
104 "headSha" | "generatedAt" | "modelSelection"
105>;
106
107export interface TranscriptionPostProcessingInput {
108 cwd: string;
109 prompt: string;
110 modelSelection: ModelSelection;
111}
112
113export interface TranscriptionPostProcessingResult {
114 transcription: string;
115}
116
117export interface ProviderTextGeneration {
118 readonly generateTranscriptionPostProcessing: (
119 input: TranscriptionPostProcessingInput,
120 ) => Effect.Effect<TranscriptionPostProcessingResult, TextGenerationError>;
121
122 readonly generateCommitMessage: (
123 input: CommitMessageGenerationInput,
124 ) => Effect.Effect<CommitMessageGenerationResult, TextGenerationError>;
125
126 readonly generatePrContent: (
127 input: PrContentGenerationInput,
128 ) => Effect.Effect<PrContentGenerationResult, TextGenerationError>;
129
130 readonly generateBranchName: (
131 input: BranchNameGenerationInput,
132 ) => Effect.Effect<BranchNameGenerationResult, TextGenerationError>;
133
134 readonly generateThreadTitle: (
135 input: ThreadTitleGenerationInput,
136 ) => Effect.Effect<ThreadTitleGenerationResult, TextGenerationError>;
137
138 readonly generateReviewGuide: (
139 input: ReviewGuideGenerationInput,
140 ) => Effect.Effect<ReviewGuideGenerationResult, TextGenerationError>;
141}