/** * Environment Variable Extractor * * Detects env vars used in a project from two complementary sources: * 1. Declaration files — .env.example, .env.local, .env (with optional comments) * 2. Source code — process.env.X (JS/TS), os.environ["X"] (Python), * os.Getenv("X") (Go), ENV["X"] (Ruby) * * Variables found in declaration files are marked hasDefault=true when the * declaration line has a non-empty value. Variables found only in source code * are marked required=true (no known default). */ import { type OversizedFileObserver } from './bounded-file-scan.js'; export interface EnvVar { /** Environment variable name, e.g. DATABASE_URL */ name: string; /** Relative path(s) where the variable was found */ files: string[]; /** True when declared in .env.example with a non-empty value */ hasDefault: boolean; /** True when used in source code without a fallback (process.env.X without ?? or ||) */ required: boolean; /** Inline comment from .env.example, if present */ description?: string; } /** * The file extensions this scan reads. Exported so a caller reporting an EMPTY inventory can say * "no in-scope language here" rather than "run analyze first" — the latter can never help a * repository written in a language the scan does not cover (change: fix-env-scope-hint). */ export declare const ENV_SOURCE_EXTENSIONS: ReadonlySet; /** * Extract all environment variables referenced or declared in the project. */ export declare function extractEnvVars(filePaths: string[], rootDir: string, onOversized?: OversizedFileObserver): Promise; /** * Return a compact summary string for LLM prompts. */ export declare function summarizeEnvVars(vars: EnvVar[]): string; /** * One environment-variable READ in source, located to a line, with a per-site * fallback verdict. The read-site refinement of {@link extractFromSource}: same * per-language patterns, but it keeps WHERE each read is and whether THAT site * has an immediate fallback — the input `analyze_env_impact` needs to map a read * to its enclosing function and classify the break as hard vs. soft. */ export interface EnvReadSite { /** Environment variable name, e.g. DATABASE_URL */ name: string; /** Repo-relative path of the file the read is in */ file: string; /** 1-based line of the read */ line: number; /** * True when no immediate fallback was detected AT THIS site (a hard break if * the var is removed). A fallback elsewhere does not clear it — per-site only. * A documented heuristic, not a guarantee. */ required: boolean; /** * Present when the variable's NAME was read from a string literal at this call site * and followed ONE HOP into a same-file helper that performs the actual read. The * mechanism is always disclosed rather than presented as a direct read * (change: follow-env-name-through-helper). */ via?: { helper: string; file: string; line: number; }; } /** * Extract every environment-variable READ site in one file, line-precise, reusing * the existing per-language patterns (no new grammar). Returns [] for a file in a * language the patterns do not cover — an honest absence, never a guessed read. * Deterministic: stable order (line, then name). */ export declare function extractEnvReadSites(source: string, relPath: string, ext: string): EnvReadSite[]; //# sourceMappingURL=env-extractor.d.ts.map