/** * Path validation utilities for MCP document CRUD operations. * Validates paths, prevents directory traversal, and enforces access restrictions. */ /** * Document type based on file extension. */ export type DocType = 'md' | 'jsx' | 'tsx' | 'ts' | 'json' | 'yaml' | 'other'; /** * Result of path validation. */ export interface ValidatedPath { /** Path relative to repo root */ relative: string; /** Absolute path */ absolute: string; /** Document type based on extension */ type: DocType; /** Directory portion (empty string for root) */ directory: string; /** Filename with extension */ filename: string; /** File extension including dot (e.g., '.md') */ extension: string; } /** * Options for path validation. */ export interface PathValidationOptions { /** Whether to check if path is in a writable directory (default: false) */ requireWritable?: boolean; } /** * Paths that are restricted and cannot be accessed. */ export declare const RESTRICTED_PATHS: readonly string[]; /** * Directories that allow write operations. */ export declare const WRITABLE_DIRS: readonly string[]; /** * Plan files that require confirmation before overwrite (protected, not blocked). * These files can be written, but require explicit confirmation (force: true). * Supports both legacy (plan.md) and new ({dirName}-plan.md) formats. */ export declare const PROTECTED_PLAN_FILES: readonly RegExp[]; /** * Reject path traversal in codebasePath (e.g. "../" or "..\\"). * codebasePath is otherwise trusted; this only blocks relative traversal. */ export declare function isSafeCodebasePath(path: string): boolean; /** * Get the plan file name for a plan directory (new format). * Format: {dirName}-plan.md (e.g., "0001-feature-name-plan.md") * * @param dirName - Plan directory name (e.g., "0001-feature-name") * @returns Plan file name */ export declare function getPlanFileName(dirName: string): string; /** * Find the plan file in a plan directory. * Supports both new format ({dirName}-plan.md) and legacy format (plan.md). * * @param planDir - Absolute path to the plan directory * @returns Absolute path to the plan file, or null if not found */ export declare function findPlanFile(planDir: string): string | null; /** * Check if a path is a protected plan file that requires confirmation. * * @param relativePath - Path relative to repo root * @returns True if the path matches a protected plan file pattern */ export declare function isProtectedPlanFile(relativePath: string): boolean; /** * Get document type from file path based on extension. */ export declare function getDocType(filePath: string): DocType; /** * Check if a path is writable (in allowed directories or root .md file). */ export declare function isWritablePath(relativePath: string): boolean; /** * Validate a path relative to the repository root. * * @param path - Path to validate (relative to repo root) * @param repoRoot - Absolute path to repository root * @param options - Validation options * @returns Validated path information * @throws DocumentError if validation fails */ export declare function validatePath(path: string, repoRoot: string, options?: PathValidationOptions): ValidatedPath; //# sourceMappingURL=paths.d.ts.map