/** * Strict shell-identifier shape. Used for dotenv keys we accept into * `Bun.env` — those should be referenceable as `$NAME` from POSIX shells, * so we reject anything outside `[A-Za-z_][A-Za-z0-9_]*`. */ export declare function isValidEnvName(name: string): boolean; /** * Parses simple POSIX shell environment assignments from files such as * ~/.zshrc without executing user shell code. Supports `export KEY=value` and * `KEY=value`, including single/double quoted literal values. Dynamic shell * expressions are intentionally ignored because evaluating startup files would * run arbitrary code during CLI startup. */ export declare function parseShellEnvFile(filePath: string): Record; /** * Parses a .env file synchronously and extracts key-value string pairs. * Ignores lines that are empty or start with '#'. Trims whitespace. * Allows values to be quoted with single or double quotes. * Returns an object of key-value pairs. * * The trust guards (`trustedAgentDirOverrideFor`, `trustedConfigDirName`, * `filterCredentialInheritedEnv`) decide provenance by comparing * `process.env` against this parse, so the accepted syntax must be a superset * of what Bun's own dotenv loader honors in `cwd/.env`: `export KEY=value`, * whitespace around `=` or `:`, and `#` comments after unquoted values (quotes keep * their `#`). Values that Bun would expand (`$VAR`, `${VAR}`, backticks, * command substitution) are kept as their literal text: the trust rule only * needs the parser to see the key at all, and an operator environment value * cannot equal attacker-written expansion text, so a literal parse stays * conservative. */ export declare function parseEnvFile(filePath: string): Record; /** Parse dotenv content that has already been read from a trusted file. */ export declare function parseEnvFileContent(content: string): Record; /** * What the caller's checkout declares through its dotenv files. * * `values` is the merged declaration set, later layers winning. `dynamic` holds * the keys whose surviving declaration is one Bun expands at load time, which * every provenance guard refuses outright because a value comparison cannot see * what such a declaration became. */ export interface ProjectEnvSnapshot { values: Record; dynamic: Set; } /** * Windows environment variable names are case-insensitive, so a project dotenv * line `userprofile=...` is what `process.env.USERPROFILE` resolves to. Every * provenance lookup is spelled in upper case, so the snapshot must be keyed the * same way or the declaration is invisible to the guard while still being live * in the process. POSIX names are case-sensitive and must not fold. */ export declare function canonicalEnvKey(name: string): string; /** * The layered dotenv declarations Bun overlays into `process.env` for a cwd. * * Lives in this leaf module so every consumer shares ONE notion of provenance. * `dirs.ts` resolves the config, agent and log directories from it, and * `scripts/test-preload.ts` decides test isolation from it — a second, narrower * reader (only `cwd/.env`, its own regex, its own dynamic test) is how a * `GJC_LOG_DIR` declared in `.env.local` / `.env.$NODE_ENV` came to be honored * by the preload and then rejected in production, silently routing test log * records to the operator's canonical sink. This module imports only `node:fs`, * `node:path` and the import-free `./spawn-env`, so importing it has no side * effects and cannot freeze resolver state the way importing `dirs.ts` would. * * `.env.local` is deliberately skipped when `NODE_ENV === "test"`, matching the * convention that a local override file is not part of a test run. */ export declare function projectEnvSnapshot(cwd?: string): ProjectEnvSnapshot;