import { type ToolInvocation, type Tree } from '@variance-authority/mcp/tools'; import type { SourceWalk } from '@variance-authority/sense'; /** * Which part of the repository an answer is allowed to come from. * * A search over names is a search over the whole checkout, and on a repository * with a hundred thousand files that is not a narrowing anybody can use. Every * product word is written somewhere in every area: `order` matches four hundred * names, the reader wanted the nine in the fulfilment service, and no ranking * over the *text* can tell those apart, because the text really does say it * four hundred times. * * What separates them is not a better score. It is a fact the caller already * holds and the search never asked for: which part of the repository they are * standing in. A start point is that fact, said as a path. * * ## It removes names, it does not prefer them * * A name declared outside the closure is not ranked low, it is not there. That * is the difference between a filter and a hint, and the reason to want the * first: a hint still hands back four hundred matches and asks the reader to * trust an order, and an answer that says *nine names, in the files this route * reaches* is one they can act on without trusting anything. * * It also makes the empty answer worth something. *Nothing here is named * `settle`* is a fact about the area, and the caller who reads it has learned * where not to look rather than that the ranking disagreed with them. * * ## The two directions ask different questions * * `from` is answered along the imports: the names in reach of a file, which is * the vocabulary available where the caller is working. `to` is answered * against them: the names declared in files that reach a destination, which is * how the callers of a thing are found when the thing is what you have. * * Said together they are two start points and not one, unioned rather than * crossed, for the same reason [`scope.ts`](https://github.com/Variance-Authority/variance-authority/blob/main/packages/mcp/src/tools/scope.ts) * gives: two entry points of one application share almost no file, so an * intersection answers nothing at exactly the moment the caller was most * specific. * * ## The rule about paths is not this module's to invent * * What a path means — three widths, anchored at the root, compared segment for * whole segment, not found rather than guessed at — belongs to * [`start-point.ts`](https://github.com/Variance-Authority/variance-authority/blob/main/packages/mcp/src/tools/start-point.ts) and is imported * from there. A second server that wrote its own would drift, and the drift * lands on the reader as `src/billing/` meaning one thing in one tool and * something else in the next. */ /** A start point, resolved against the tree, as the files it allows. */ export interface Area { /** The paths answered along the imports, as said. */ readonly from: readonly string[]; /** The paths answered against the imports, as said. */ readonly to: readonly string[]; /** Files the paths themselves named. */ readonly entries: number; /** The closure: every file in reach, entry points included. */ readonly files: ReadonlySet; /** Minimum import distance from either start point to every file in the closure. */ readonly distance: ReadonlyMap; /** Files in it whose own imports the scan could not enumerate. */ readonly unresolved: readonly string[]; /** Why it was not resolved. Absent when it was. */ readonly refused?: string; } /** A start point resolved as the walks it made, held by the addon: what reached them is counted there, never listed here. */ export interface Reach { readonly from: readonly string[]; readonly to: readonly string[]; readonly entries: number; /** The walk along the imports from `from`, and the one against them from `to`; neither when refused. */ readonly walks: { readonly from?: SourceWalk; readonly to?: SourceWalk; }; readonly refused?: string; } /** * Resolve a start point as the walks it makes, without carrying the files they * reached: the caller that only counts or filters them hands the walks back to * the addon. Refused as {@link areaOf} refuses. */ export declare function reachOf(from: string | readonly string[] | undefined, to: string | readonly string[] | undefined, tree: Tree | undefined): Reach; /** Resolve a start point, or say why it could not be. */ export declare function areaOf(from: string | readonly string[] | undefined, to: string | readonly string[] | undefined, tree: Tree | undefined): Area; /** * What the header says about a start point, before any match. * * Always printed when one was given, including — especially — when it named * nothing, because the difference between *this area holds no such name* and * *there is no such area* is the difference between asking again and asking * somewhere else, and only the tool knows which happened. */ export declare function areaLine(area: Area): string; /** {@link areaLine}, said from the counts alone: how many files the start point reached, and how many of those import what the scan could not resolve. */ export declare function reachLine(area: { readonly from: readonly string[]; readonly to: readonly string[]; readonly entries: number; readonly files: number; readonly unresolved: number; readonly refused?: string; }): string; /** What to say when a start point is missing, in the spelling of the surface that asked. */ export declare function startPointNeeded(invocation: Pick, 'shell'> | undefined): string; //# sourceMappingURL=area.d.ts.map