import type { OperationOptions } from "../types/operations.js"; /** * Configuration options for heading refactoring operations. * * Controls how heading changes are detected and how affected links are updated. * * @category Commands */ export interface RefactorHeadingsOperationOptions extends OperationOptions { /** The original heading text to find and replace */ oldHeading: string; /** The new heading text to replace with */ newHeading: string; /** Process directories recursively */ recursive?: boolean; /** Maximum depth to traverse subdirectories */ maxDepth?: number; /** Custom slug generator function */ slugify?: (text: string) => string; /** Update cross-file references */ updateCrossReferences?: boolean; } /** * CLI-specific options for the refactor-headings command. * * @category Commands */ export interface RefactorHeadingsCliOptions extends RefactorHeadingsOperationOptions { /** Output results in JSON format */ json?: boolean; } /** * Details about a heading change operation. * * @category Commands */ interface HeadingChange { /** File containing the heading */ filePath: string; /** Line number of the heading */ line: number; /** Original heading text */ oldText: string; /** New heading text */ newText: string; /** Original slug */ oldSlug: string; /** New slug */ newSlug: string; /** Heading level */ level: number; } /** * Details about a link update operation. * * @category Commands */ interface LinkUpdate { /** File containing the link */ filePath: string; /** Line number of the link */ line?: number; /** Original link text/href */ oldLink: string; /** Updated link text/href */ newLink: string; /** Type of link updated */ linkType: "anchor" | "reference"; } /** * Result of a heading refactoring operation. * * @category Commands */ export interface RefactorHeadingsResult { /** Whether the operation completed successfully */ success: boolean; /** Number of files processed */ filesProcessed: number; /** Number of headings changed */ headingsChanged: number; /** Number of links updated */ linksUpdated: number; /** Detailed heading changes */ headingChanges: HeadingChange[]; /** Detailed link updates */ linkUpdates: LinkUpdate[]; /** Files that had processing errors */ fileErrors: { file: string; error: string; }[]; /** Processing time in milliseconds */ processingTime: number; } /** * Refactors headings in markdown files and updates all affected links. * * This command finds all instances of a specified heading and updates them to new text, while * automatically updating all anchor links and cross-file references that point to those headings. * * Features: * * - Updates heading text in place * - Automatically updates anchor links (#old-slug → #new-slug) * - Updates cross-file heading references * - Maintains link integrity across the entire project * - Supports custom slug generation * - Dry-run support for safe preview * - Comprehensive change reporting * * @example * ```typescript * // Basic heading refactoring * const result = await refactorHeadings(['docs/'], { * oldHeading: 'API Reference', * newHeading: 'API Documentation', * recursive: true * }); * * // With custom slug generation * const result = await refactorHeadings(['README.md'], { * oldHeading: 'Getting Started', * newHeading: 'Quick Start Guide', * slugify: (text) => text.toLowerCase().replace(/\s+/g, '_') * }); * ```; * * @param files - Array of file paths or glob patterns to process * @param options - Configuration options for the refactoring operation * * @returns Promise resolving to detailed results of the refactoring operation * * @group Commands */ export declare function refactorHeadings(files: string[], options: RefactorHeadingsOperationOptions): Promise; /** Command handler for the refactor-headings CLI command. */ export declare function refactorHeadingsCommand(files: string[] | undefined, options: RefactorHeadingsCliOptions): Promise; /** Formats the refactor-headings results for display. */ export declare function formatRefactorHeadingsResults(result: RefactorHeadingsResult, options: RefactorHeadingsOperationOptions): string; export {}; //# sourceMappingURL=refactor-headings.d.ts.map