- Make branch-name generation return a required string instead of nullable output - Propagate invalid Codex branch payloads as `TextGenerationError` instead of silently falling back - Update provider command reactor to catch generation failures, log warnings, and skip rename safely
91 lines
2.4 KiB
TypeScript
91 lines
2.4 KiB
TypeScript
/**
|
|
* 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 } from "@t3tools/contracts";
|
|
|
|
import type { TextGenerationError } from "../Errors.ts";
|
|
|
|
export interface CommitMessageGenerationInput {
|
|
cwd: string;
|
|
branch: string | null;
|
|
stagedSummary: string;
|
|
stagedPatch: string;
|
|
}
|
|
|
|
export interface CommitMessageGenerationResult {
|
|
subject: string;
|
|
body: string;
|
|
}
|
|
|
|
export interface PrContentGenerationInput {
|
|
cwd: string;
|
|
baseBranch: string;
|
|
headBranch: string;
|
|
commitSummary: string;
|
|
diffSummary: string;
|
|
diffPatch: string;
|
|
}
|
|
|
|
export interface PrContentGenerationResult {
|
|
title: string;
|
|
body: string;
|
|
}
|
|
|
|
export interface BranchNameGenerationInput {
|
|
cwd: string;
|
|
message: string;
|
|
attachments?: ReadonlyArray<ChatAttachment> | undefined;
|
|
}
|
|
|
|
export interface BranchNameGenerationResult {
|
|
branch: string;
|
|
}
|
|
|
|
export interface TextGenerationService {
|
|
generateCommitMessage(
|
|
input: CommitMessageGenerationInput,
|
|
): Promise<CommitMessageGenerationResult>;
|
|
generatePrContent(input: PrContentGenerationInput): Promise<PrContentGenerationResult>;
|
|
generateBranchName(input: BranchNameGenerationInput): Promise<BranchNameGenerationResult>;
|
|
}
|
|
|
|
/**
|
|
* 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<CommitMessageGenerationResult, TextGenerationError>;
|
|
|
|
/**
|
|
* Generate pull request title/body from branch and diff context.
|
|
*/
|
|
readonly generatePrContent: (
|
|
input: PrContentGenerationInput,
|
|
) => Effect.Effect<PrContentGenerationResult, TextGenerationError>;
|
|
|
|
/**
|
|
* Generate a concise branch name from a user message.
|
|
*/
|
|
readonly generateBranchName: (
|
|
input: BranchNameGenerationInput,
|
|
) => Effect.Effect<BranchNameGenerationResult, TextGenerationError>;
|
|
}
|
|
|
|
/**
|
|
* TextGeneration - Service tag for commit and PR text generation.
|
|
*/
|
|
export class TextGeneration extends ServiceMap.Service<TextGeneration, TextGenerationShape>()(
|
|
"t3/git/Services/TextGeneration",
|
|
) {}
|