UNPKG

@elsikora/commitizen-plugin-commitlint-ai

Version:
39 lines (38 loc) 2.02 kB
import type { ICommitValidationResult, ICommitValidator } from '../../application/interface/commit-validator.interface'; import type { ILlmPromptContext, ILlmService } from '../../application/interface/llm-service.interface'; import type { CommitMessage } from '../../domain/entity/commit-message.entity'; import type { LLMConfiguration } from '../../domain/entity/llm-configuration.entity'; /** * Commitlint implementation of the commit validator */ export declare class CommitlintValidatorService implements ICommitValidator { private readonly LLM_SERVICES?; private llmConfiguration?; constructor(llmServices?: Array<ILlmService>); /** * Attempt to fix a commit message based on validation errors * @param {CommitMessage} message - The commit message to fix * @param {ICommitValidationResult} validationResult - The validation result containing errors * @param {ILlmPromptContext} context - Optional original context for LLM-based fixing * @returns {Promise<CommitMessage | null>} Promise resolving to the fixed commit message or null if unfixable */ fix(message: CommitMessage, validationResult: ICommitValidationResult, context?: ILlmPromptContext): Promise<CommitMessage | null>; /** * Set the LLM configuration for this validator * @param {LLMConfiguration} configuration - The LLM configuration to set */ setLLMConfiguration(configuration: LLMConfiguration): void; /** * Validate a commit message using commitlint * @param {CommitMessage} message - The commit message to validate * @returns {Promise<ICommitValidationResult>} Promise resolving to the validation result */ validate(message: CommitMessage): Promise<ICommitValidationResult>; /** * Wrap text to ensure no line exceeds the specified length * @param {string | undefined} text - The text to wrap * @param {number} maxLength - Maximum line length * @returns {string | undefined} The wrapped text */ private wrapText; }