import { CommitFooter, CommitType, ConventionalCommit } from '../models'; /** Parsed body section of a commit message. */ interface ParsedBody { /** The body text (may be multiline) */ body: string; /** Index where the body ends (start of footers or end of message) */ endIndex: number; } /** * Parses the body section of a commit message. * * The body starts after the first blank line and continues until * we encounter a footer (key: value or key #value pattern) or end of message. * * @param lines - All lines of the commit message * @param startIndex - Index to start looking for body (after header) * @returns Parsed body or undefined if no body * * @example Parsing commit body * ```typescript * const lines = [ * 'feat: add login', * '', * 'Implements OAuth flow.', * '', * 'Refs: #123' * ] * const result = parseBody(lines, 1) * // => { body: 'Implements OAuth flow.', endIndex: 4 } * ``` */ declare function parseBody(lines: string[], startIndex: number): ParsedBody | undefined; /** Parsed footer section of a commit message. */ interface ParsedFooters { /** All parsed footers */ footers: CommitFooter[]; /** Breaking change description if found */ breakingDescription?: string; } /** * Parses the footer section of a commit message. * * @param lines - All lines of the commit message * @param startIndex - Index where footers start * @returns Parsed footers * * @example Parsing commit footers * ```typescript * const lines = ['feat: add feature', '', 'Refs: #123', 'Fixes #456'] * const result = parseFooters(lines, 2) * // => { * // footers: [ * // { key: 'Refs', value: '#123', separator: ':' }, * // { key: 'Fixes', value: '456', separator: ' #' } * // ], * // breakingDescription: undefined * // } * ``` */ declare function parseFooters(lines: string[], startIndex: number): ParsedFooters; /** * Parsed conventional commit header components. */ interface ParsedHeader { /** Commit type (feat, fix, chore, etc.) */ type: CommitType; /** Scopes from parentheses (empty array when header has no scope) */ scope: readonly string[]; /** Commit subject line */ subject: string; /** Whether this is a breaking change */ breaking: boolean; } /** * Parses a conventional commit header line. * * Supports comma-separated multi-scope headers such as `feat(a,b): x` which * produce a multi-element scope array. Single-scope headers produce a * one-element array, and scopeless headers produce an empty array. * * @param line - The first line of the commit message * @returns Parsed header with type, scope array, subject, and breaking flag * * @example Parsing conventional commit headers * ```typescript * parseHeader('feat(auth): add OAuth login') * // => { type: 'feat', scope: ['auth'], subject: 'add OAuth login', breaking: false } * * parseHeader('fix!: critical security patch') * // => { type: 'fix', scope: [], subject: 'critical security patch', breaking: true } * * parseHeader('feat(versioning,questions): add searchable select') * // => { type: 'feat', scope: ['versioning', 'questions'], subject: 'add searchable select', breaking: false } * ``` */ declare function parseHeader(line: string): ParsedHeader; /** * Parses a conventional commit message. * * @param message - The complete commit message * @returns Parsed ConventionalCommit object * @throws {Error} If message exceeds maximum length * * @example Parsing a complete conventional commit message * ```typescript * parseConventionalCommit('feat(auth): add login\n\nImplements OAuth.\n\nRefs: #123') * // => { * // type: 'feat', * // scope: ['auth'], * // subject: 'add login', * // body: 'Implements OAuth.', * // footers: [{ key: 'Refs', value: '#123', separator: ':' }], * // breaking: false, * // raw: '...' * // } * ``` */ declare function parseConventionalCommit(message: string): ConventionalCommit; /** * Checks if a commit message follows conventional commit format. * * @param message - The commit message to check * @returns true if the message appears to be a conventional commit * * @example Checking if a message is a conventional commit * ```typescript * isConventionalCommit('feat(auth): add OAuth login') * // => true * * isConventionalCommit('WIP: still working on this') * // => false * * isConventionalCommit('fix: resolve bug') * // => true * ``` */ declare function isConventionalCommit(message: string): boolean; export { isConventionalCommit, parseBody, parseConventionalCommit, parseFooters, parseHeader }; export type { ParsedBody, ParsedFooters, ParsedHeader };