import type { OperationChange } from "../types/operations.js"; /** * The two index file naming conventions this command converts between. * * @category Commands */ export type IndexConvention = "readme" | "index"; /** * Configuration options for index file refactoring operations. * * Controls the target convention and the behaviour of the underlying move machinery. * * @category Commands */ export interface RefactorIndexOptions { /** Target naming convention; defaults to the opposite of the file's current convention */ to?: IndexConvention; /** Perform a dry run without making actual changes */ dryRun?: boolean; /** Enable verbose output with detailed progress information */ verbose?: boolean; /** * Root anchoring bystander discovery; an in-place rename spans one directory, so callers should * pass the project or vault root to catch bystanders above it */ discoveryRoot?: string; } /** * Result of an index file refactoring operation. * * @category Commands */ export interface RefactorIndexResult { /** Whether the operation was successful */ success: boolean; /** Absolute path of the file before the rename */ sourcePath: string; /** Absolute path the file is renamed to; absent when no target could be derived from the request */ targetPath?: string; /** Number of inbound links rewritten to the new name */ linksUpdated: number; /** Distinct files whose links were rewritten */ filesWithUpdatedLinks: string[]; /** Detailed link changes recorded by the move machinery */ changes: OperationChange[]; /** Warnings reported by the move machinery */ warnings: string[]; /** Files that failed to parse during the operation; their links could not be checked or rewritten */ parseFailures: { file: string; error: string; }[]; /** Errors that prevented the operation */ errors: string[]; } /** * Convert a README.md to index.md, or an index.md to README.md, in place. * * The file is renamed within its own directory and every markdown link in the scanned tree that * pointed at the old name is rewritten to the new one, reusing the move machinery's link * refactoring (relative-path recomputation and bystander discovery included). The file's own * content is never reformatted by this command; it reaches the new name byte-for-byte apart from * any link rewrites the shared move machinery itself performs. * * @param filePath - Path to the README.md or index.md file to convert * @param options - Configuration options for the operation * * @returns Promise resolving to the outcome of the conversion */ export declare function refactorIndex(filePath: string, options?: RefactorIndexOptions): Promise; /** * CLI-specific options for the refactor-index command. * * @category Commands */ export interface RefactorIndexCliOptions extends RefactorIndexOptions { /** Output results in JSON format */ json?: boolean; } /** * Execute the refactor-index command, converting a README.md to index.md or an index.md to * README.md in place with automatic link updates. * * This is the entry point for the CLI command. It reports the outcome in conventional or JSON form, * exits non-zero when the conversion is refused or fails, and surfaces parse failures the move * machinery encountered along the way. * * @category Commands * * @example * ```typescript await refactorIndexCommand('docs/README.md', { to: 'index' }); ```; * * @param filePath - Path to the README.md or index.md file to convert * @param options - CLI configuration options for the operation * * @throws Will exit the process with code 1 if the operation is refused or fails */ export declare function refactorIndexCommand(filePath: string, options: RefactorIndexCliOptions): Promise; //# sourceMappingURL=refactor-index.d.ts.map