UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

50 lines • 2.8 kB
import type { ParseScope } from '../../../../shell/parse/scope.ts'; import type { MountRegistry } from '../../../mount/registry.ts'; import type { SessionState } from '../../../session/session.ts'; import { NameKind } from './types.ts'; /** * Classify the name as the layer that would run it, null if none does. * * A layer that would run a program reports one only where the name has a * file (`program`): a word only the external fallback capture takes still * runs, but is not found, as bash reports a name its * `command_not_found_handle` would take. */ export declare function classify(name: string, session: SessionState, registry: MountRegistry): NameKind | null; /** * Classify every layer holding the name, most-preferred first. * * A reserved word goes first and does not end the walk: bash prints both * lines when a function shares a keyword's name (pinned: * `function time { :; }; type -a time` prints the keyword line then the * function line). mirage's parser is looser than bash's about reserved * words as function names, so the shadow is reachable here for any of * them, and hiding it would leave `type -a` claiming a keyword while the * line runs the function. * * Duplicate kinds are dropped, since the kinds are coarser than the * layers: a program both a mount and a CLI answer for is one file. A * builtin that is a program too ends with that file's line, as bash's * `type -a echo` does after its builtin line. A file is reported only * where `program` finds one, so a layer the name runs from without a file * (the external fallback, a mount command under a shell-only builtin) * prints no line. */ export declare function classifyAll(name: string, session: SessionState, registry: MountRegistry): NameKind[]; /** * The kinds to report for one name: hide a layer, then take the top. * * Hiding is a filter over the layer list, never an edit to the session, * and it runs before the winner is picked. That order is what keeps the * winner honest: `type -f` reports the layer under a shadowing function, * where filtering afterwards would report nothing at all. */ export declare function locations(name: string, session: SessionState, registry: MountRegistry, allMode: boolean, drop?: NameKind | null): NameKind[]; /** The path of a program's file, where PATH finds it. */ export declare function programFile(name: string): string; /** Render the verbose line `command -V` and `type` print. A function's line * is followed by its body as `declare -f` prints it. `session` is needed to * read an alias's value and a function's body; every other kind renders from * the name alone. */ export declare function describe(name: string, kind: NameKind, session?: SessionState, parser?: ParseScope): string; //# sourceMappingURL=classify.d.ts.map