/** * Project Root Detection Engine * * Implements automatic project root detection by searching for common project markers * (.git, package.json, etc.). Falls back to error when no markers found. * * This determines the scope of indexing by finding the root directory of a project. */ /** * Project markers to search for when detecting project root. * Listed in priority order - first match wins. */ export declare const PROJECT_MARKERS: readonly [".git", "package.json", "pyproject.toml", "Cargo.toml", "go.mod"]; /** * Type for valid project markers */ export type ProjectMarker = typeof PROJECT_MARKERS[number]; /** * Marker type - determines how we check for the marker's existence */ export type MarkerType = 'directory' | 'file' | 'either'; /** * Mapping of markers to their types for proper filesystem checks. * Note: .git can be either a directory (normal repos) or a file (git worktrees) */ export declare const MARKER_TYPES: Record; /** * Result of project root detection */ export interface DetectionResult { /** Absolute path to the detected project root */ projectPath: string; /** The marker that was found (e.g., '.git', 'package.json') */ detectedBy: ProjectMarker; } /** * Check if a marker exists in a directory * * @param directory - The directory to check * @param marker - The marker to look for * @returns true if the marker exists and matches the expected type */ export declare function checkMarker(directory: string, marker: ProjectMarker): Promise; /** * Check if a path is a filesystem root * * Handles both Unix root (/) and Windows drive roots (C:\) * * @param dirPath - The path to check * @returns true if this is a filesystem root */ export declare function isFilesystemRoot(dirPath: string): boolean; /** * Search upward from a starting path to find a project root * * Checks each directory from startPath up to the filesystem root for project markers. * * @param startPath - The path to start searching from * @returns DetectionResult if found, null otherwise */ export declare function findProjectRoot(startPath: string): Promise; /** * Detect the project root from a given path or current working directory * * Searches upward from the starting path looking for project markers. * Throws PROJECT_NOT_DETECTED error if no markers are found. * * @param cwd - Starting path to search from (defaults to process.cwd()) * @returns DetectionResult with project path and the marker that was found * @throws MCPError with code PROJECT_NOT_DETECTED if no project root found * * @example * ```typescript * // Detect from current directory * const result = await detectProjectRoot(); * console.log(result.projectPath); // '/Users/dev/my-project' * console.log(result.detectedBy); // 'package.json' * * // Detect from a specific path * const result = await detectProjectRoot('/Users/dev/my-project/src/utils'); * console.log(result.projectPath); // '/Users/dev/my-project' * ``` */ export declare function detectProjectRoot(cwd?: string): Promise; /** * Check if a specific path is a project root (contains any project marker) * * Useful for validation or when you have a specific path you want to verify. * * @param directoryPath - The directory to check * @returns The marker found, or null if not a project root * * @example * ```typescript * const marker = await isProjectRoot('/Users/dev/my-project'); * if (marker) { * console.log(`Found ${marker} in directory`); * } * ``` */ export declare function isProjectRoot(directoryPath: string): Promise; //# sourceMappingURL=projectRoot.d.ts.map