@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
70 lines • 4.14 kB
TypeScript
import type { RedirectResult } from '../../../../context/session_context.ts';
import type { TSNodeLike } from '../../../../shell/types.ts';
import { type SessionState } from '../../../session/session.ts';
import type { BuiltinCall } from '../types.ts';
import type { AliasMark } from './types.ts';
/** Define or print aliases. `mark` is the read the definition sits in:
* bash expands aliases as it reads, so the commands of that read still see
* the value from before it. */
export declare function handleAlias(args: string[], session: SessionState, mark: AliasMark): RedirectResult;
/** Remove aliases: the named ones, or all under `-a`. The commands of the
* read at `mark` still see the aliases it removes. */
export declare function handleUnalias(args: string[], session: SessionState, mark: AliasMark): RedirectResult;
/**
* Keep `expand_aliases` as the read at `mark` found it, before a `shopt` in
* that read changes it: the commands of that read were expanded, or not,
* already. Mirrors Python's note_expanding.
*/
export declare function noteExpanding(session: SessionState, mark: AliasMark): void;
/**
* The alias names a command word would expand as right now. bash checks a
* word where a command starts for an alias before it checks for a reserved
* word, so one of these names is a command there even when it is spelled
* `fi` or `do`. Mirrors Python's expanding_aliases.
*/
export declare function expandingAliases(session: SessionState): ReadonlySet<string>;
/**
* The alias names a stored function's body is read with
* (`bodyAliasValues`). Mirrors Python's body_aliases.
*/
export declare function bodyAliases(session: SessionState, name: string): ReadonlySet<string>;
/**
* The aliases a stored function's body is read with, by name: the ones its
* definition saw, or the session's own for a definition that kept none (one
* restored from a stored session). Mirrors Python's body_alias_values.
*/
export declare function bodyAliasValues(session: SessionState, name: string): Map<string, string>;
/**
* The aliases a function defined by `node` keeps for its body. bash expands
* a function's aliases as it reads the definition, so the body runs them as
* they were then, whatever is defined or removed later: the aliases a use in
* the read at `mark` would expand, none while `expand_aliases` is off, and
* inside another function's body that body's own, less any alias being
* expanded where the definition stands. What is read later (`eval`,
* `source`, a trap action, `$( )`) reads the aliases as they are then.
* Mirrors Python's alias_view.
*/
export declare function aliasView(session: SessionState, node: TSNodeLike, mark: AliasMark): Record<string, string>;
/**
* The alias text a command word expands to, or null. bash expands aliases
* as it reads a command, so the word sees the aliases, and
* `expand_aliases`, as the read at `mark` found them. Null when they are
* not being expanded, when the word is no alias, or when it is guarded. In
* a function's body the aliases are the ones its definition saw
* (`aliasView`). Mirrors Python's alias_value.
*/
export declare function aliasValue(session: SessionState, name: string, mark: AliasMark, blocked: ReadonlySet<string>): string | null;
/**
* Replace alias words, preserving the rest of the command and its guards.
* Each insertion inherits the replaced word's guards and adds its name.
* A trailing blank checks the next caller word through the same loop.
*/
export declare function aliasCommandText(session: SessionState, node: TSNodeLike, head: TSNodeLike, mark: AliasMark): [string, readonly ReadonlySet<string>[]] | null;
/** The read a command at `row` of the running parse belongs to (`readRow`).
* Mirrors Python's alias_mark. */
export declare function aliasMark(session: SessionState, row: number): AliasMark;
/** The `alias` arm; the row marks the read the definition sits in. */
export declare function aliasBuiltin(call: BuiltinCall): Promise<RedirectResult>;
/** The `unalias` arm. */
export declare function unaliasBuiltin(call: BuiltinCall): Promise<RedirectResult>;
//# sourceMappingURL=alias.d.ts.map