@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
57 lines • 3 kB
TypeScript
import type { TSNodeLike } from '../types.ts';
/**
* How the line's environment-rendering commands read names.
*
* Returns `{whole, names, excluded}`: whether some command renders the
* whole environment, the names printing forms read explicitly, and the
* names every whole-environment read provably skips. Only a printing
* form selects everything: `env` on any invocation (bare it prints
* every exported name, and with arguments it hands the snapshot to the
* command it runs) unless a literal `-i`, `--ignore-environment` or
* lone `-` proves it starts empty, a bare `set`, a bare `printenv`,
* and a declaring builtin with no operands (`export`, `declare -p`).
* `printenv NAME` and `declare -p NAME` read exactly the named
* variables, and a mutating form (`export NAME=v`, `declare -x NAME`,
* `set -u`) reads nothing here, so an unavailable source cannot fail
* the write that would replace its pointer. A print target no static
* read can spell (`printenv $x`) falls back to the whole environment.
*
* Exclusions are per invocation: an assignment prefix overrides its
* name for exactly that command's environment, and `env`'s `-u`,
* `--unset` and `NAME=VALUE` words remove or override theirs
* (`envExclusions`), so `env -u TOKEN printenv TOKEN` cannot observe
* TOKEN however the whole snapshot is handed on. A print target so
* excluded is dropped rather than reported. `excluded` is the
* intersection across the node's whole-environment reads, because a
* name is skippable only when every such read skips it.
*/
export declare function envReads(node: TSNodeLike): {
whole: boolean;
names: ReadonlySet<string>;
excluded: ReadonlySet<string>;
};
/**
* Whether the line reads names no static walk can spell.
*
* Two constructs defeat `referencedNames`: an indirect expansion
* (`${!name}` reads the variable the *value* of `name` names, and the
* `${!p*}`/`${!p@}` forms enumerate by prefix), and a nameref declared
* on the line itself (`declare -n r=T; echo $r` reads T before any
* session record says so). A nameref from an earlier line is not
* opaque: the session records its target, which `deref` resolves.
*/
export declare function opaqueReads(node: TSNodeLike): boolean;
/**
* Names the program reads without a `$NAME` in the text.
*
* Tilde expansion resolves `~` and `~/...` against `$HOME` wherever a
* word expands (patterns, `=~`'s regex and redirect targets included),
* and the word scan mirrors the expansion exactly: `~user`, a mid-word
* tilde and a quoted one stay literal. `cd` reads `$HOME` bare, `$OLDPWD` for `-`
* and `$CDPATH` for a searchable relative operand; `read` splits on
* `$IFS`; `getopts` resumes from `$OPTIND` and consults `$OPTERR`.
* These join the fill plan exactly as a spelled reference does, so a
* managed `HOME` fetches for `echo ~` the way it does for `echo $HOME`.
*/
export declare function implicitReads(node: TSNodeLike): ReadonlySet<string>;
//# sourceMappingURL=env.d.ts.map