/** * Turns a caller's `path` into a search root, for tools that accept either a * directory or a single file there. * * `path` is the one argument every caller passes, because the hook that refuses * the built-in Grep/Glob names these tools as the replacement and "where to * look" is the whole question. It was wired straight into the search root: * * cwd: options.path ?? options.cwd ?? process.cwd() * * which is right for a directory and silently wrong for a FILE. Both tools then * enumerate with a glob -- `['**\/*']` in grep, the caller's pattern in glob -- * and a glob rooted AT a file matches nothing, so a search scoped to one file * answered: * * { success: true, totalMatches: 0, filesSearched: 0 } * * indistinguishable from "the pattern is not there". A wrong answer that reports * success is worse than an error. */ export interface SearchScope { /** Directory to search from. */ cwd: string; /** * Glob patterns selecting the scoped file, for tools that take a file list. * Null when `path` named a directory or was absent. */ files: string[] | null; /** * Absolute path of the scoped file, for tools whose only filter is the * caller's own pattern and which therefore have to filter results instead. */ file: string | null; } /** * @throws {Error} when `path` names nothing that exists -- the other way to * produce a confident zero, and the one a typo produces. */ export declare function resolveSearchScope(path: string | undefined, cwd: string | undefined, fallback: string): SearchScope; /** * Narrows glob results to the scoped file, or passes them through untouched. * * Basename equality would be wrong: with the parent as the search root, a * `nested/target.ts` shares a basename with `target.ts` and would survive a * filter meant to leave exactly one file. Full resolved paths are compared. */ export declare function limitToScopedFile(paths: string[], scope: SearchScope): string[]; //# sourceMappingURL=search-scope.d.ts.map