//#region src/commands/capture.d.ts /** * Execute the capture command * * Finds all .env files in the repository, parses them, and saves to storage */ declare function captureCommand(): Promise; //#endregion //#region src/commands/restore.d.ts /** * Execute the restore command * * Restores env files from storage into the repository */ declare function restoreCommand$1(): Promise; //#endregion //#region src/commands/clear.d.ts /** * Execute the clear command * * Removes the stored configuration for the current repository */ declare function clearCommand(): Promise; //#endregion //#region src/commands/create-key.d.ts interface CreateKeyOptions { /** Overwrite an existing encryption_key in envi.config.maml */ force?: boolean; } /** * Generate a per-repo encryption key and write it to envi.config.maml (or to * the legacy envi.maml if that's the file already on disk). * * Used to enable encryption-at-rest for `envi capture` / `envi restore`, and * preferred over manifest-derived keys by `envi pack` / `envi unpack`. */ declare function createKeyCommand(options?: CreateKeyOptions): Promise; //#endregion //#region src/commands/global/clear.d.ts /** * Execute the global clear command * * Removes the entire ~/.envi directory including all stored configurations */ declare function globalClearCommand(): Promise; //#endregion //#region src/commands/global/github/disable.d.ts /** * Execute the global github disable command * * Disables GitHub version control for the envi store */ declare function disableCommand(): Promise; //#endregion //#region src/commands/global/github/enable.d.ts /** * Execute the global github enable command * * Sets up GitHub version control for the envi store */ declare function enableCommand(): Promise; //#endregion //#region src/commands/global/github/restore.d.ts /** * Execute the global github restore command * * Restores the envi store from GitHub */ declare function restoreCommand(): Promise; //#endregion //#region src/lib/config.d.ts /** Global configuration structure */ interface EnviConfig { use_version_control: "github" | false; /** Manifest files to check for package name and encryption (in priority order) */ manifest_files: string[]; /** * Environment variables to redact (replace with `__envi_redacted__`) when * capturing or packing */ redacted_variables: string[]; } /** * Get the config file path * * @returns Absolute path to ~/.envi/config.maml */ declare function getConfigPath(): string; /** * Read global configuration * * @returns Configuration object */ declare function readConfig(): EnviConfig; /** * Write global configuration * * @param config - Configuration object to write */ declare function writeConfig(config: EnviConfig): void; /** * Update global configuration with partial values * * @param updates - Partial configuration to merge with existing */ declare function updateConfig(updates: Partial): void; //#endregion //#region src/lib/git.d.ts /** * Check if a directory is a git repository * * @param dir - Directory to check * @returns True if directory contains .git */ declare function isGitRepo(dir: string): boolean; /** * Initialize a git repository * * @param dir - Directory to initialize */ declare function initGitRepo(dir: string): Promise; /** * Add remote origin to git repository * * @param dir - Repository directory * @param remoteUrl - Remote URL to add */ declare function addRemote(dir: string, remoteUrl: string): Promise; /** * Commit all changes and push to remote * * @param dir - Repository directory * @param message - Commit message */ declare function commitAndPush(dir: string, message: string): Promise; /** * Create initial commit without pushing * * @param dir - Repository directory */ declare function createInitialCommit(dir: string): Promise; /** * Create initial commit and push * * @param dir - Repository directory */ declare function initialCommitAndPush(dir: string): Promise; //#endregion //#region src/lib/github-cli.d.ts /** * Check if GitHub CLI (gh) is installed * * @returns True if gh is available */ declare function isGhInstalled(): Promise; /** * Check if user is authenticated with GitHub CLI * * @returns True if authenticated */ declare function isGhAuthenticated(): Promise; /** * Get authenticated GitHub username * * @returns GitHub username */ declare function getGhUsername(): Promise; /** * Check if a GitHub repository exists for the authenticated user * * @param name - Repository name * @returns True if repository exists */ declare function repoExists(name: string): Promise; /** * Create a private GitHub repository * * @param name - Repository name * @param cwd - Working directory where the repo should be created * @returns Repository URL */ declare function createPrivateRepo(name: string, cwd: string): Promise; /** * Clone a GitHub repository * * @param name - Repository name (without username) * @param targetDir - Directory to clone into */ declare function cloneRepo(name: string, targetDir: string): Promise; //#endregion //#region src/lib/package-name-extractors.d.ts /** * Package extractor function that attempts to extract a package name from a * manifest file */ interface PackageExtractor { /** The filename to look for in the repository root */ filename: string; /** Extract package name from the file, returns null if extraction fails */ extract: (repositoryPath: string) => string | null; } /** Default list of package manifest files to check (in priority order) */ declare const DEFAULT_MANIFEST_FILES: string[]; /** Registry of all available package extractors */ declare const PACKAGE_EXTRACTORS: PackageExtractor[]; //#endregion //#region src/lib/key-file.d.ts /** * Per-repo envi config filename. * * No leading dot — meant to be visible and committed alongside source code. * Holds an optional `encryption_key`, an optional `capture_patterns` list, and * any future per-repo configuration. */ declare const KEY_FILE_NAME = "envi.config.maml"; /** * Legacy filename for the per-repo envi config. * * Kept readable so already-committed files continue to work. New files use * `KEY_FILE_NAME`. When a write targets a repo that only has the legacy file, * the legacy file is edited in place rather than silently migrating it — the * user decides when to rename and commit. */ declare const LEGACY_KEY_FILE_NAME = "envi.maml"; /** * Get the absolute path to the canonical envi config file in a repository. * * Always returns the canonical path, even if only the legacy file is on disk — * this is the path new files are written to. */ declare function getKeyFilePath(repoRoot: string): string; /** * Check whether a per-repo envi config file exists, including the legacy name. * * Note: this does not check whether `encryption_key` is set inside it; use * `readEncryptionKey` for that. */ declare function hasKeyFile(repoRoot: string): boolean; /** * Return the basename of the per-repo config file present on disk — * `envi.config.maml` when the canonical file exists, `envi.maml` when only the * legacy file does, null when neither does. * * Use this in user-facing messages so log lines name the file the user * actually has on disk instead of always the canonical constant. */ declare function findKeyFile(repoRoot: string): string | null; /** * Read the encryption key from the per-repo config file, if present. * * Reads from `envi.config.maml` (preferred) or the legacy `envi.maml`. Returns * null when no config file is present, the file can't be parsed, or no * `encryption_key` field is set. */ declare function readEncryptionKey(repoRoot: string): string | null; /** * Read additional capture patterns the user has declared for this repo. * * Patterns are merged with the built-in defaults inside `findEnvFiles` — * unknown filenames (e.g. `.flaskenv`, framework-specific or team-specific * dotenv-style secret files) become captureable without code changes. Returns an empty array when the field is * missing, malformed, or not an array. Non-string entries are filtered out so * a partly-malformed list does not poison the whole capture. */ declare function readCapturePatterns(repoRoot: string): string[]; interface WriteEncryptionKeyOptions { /** Overwrite an existing encryption_key value */ force?: boolean; } /** * Write the encryption key to the per-repo envi config file. * * - If no config file exists, creates `envi.config.maml` with a header comment * explaining what the file is for. * - If only the legacy `envi.maml` exists, edits it in place. Migration to the * new filename is left to the user so they can commit the rename. * - If a config file exists and already has an `encryption_key`, refuses * unless `force` is set, in which case the existing value is replaced in * place (preserves surrounding content and comments). * - If a config file exists without an `encryption_key`, appends the field * inside the top-level object, preserving the rest of the file. * * Returns the basename of the file that was written, so callers can surface * the actual filename in success messages instead of guessing. * * @throws Error when `force` is false and a key is already set. */ declare function writeEncryptionKey(repoRoot: string, key: string, options?: WriteEncryptionKeyOptions): string; /** * Generate a new encryption key * * Returns 32 cryptographically random bytes encoded as base64url (~43 chars, * no padding). The key is opaque and used directly as the secret for * `encrypt()` / `decrypt()` in src/utils/encryption.ts. */ declare function generateKey(): string; //#endregion //#region src/utils/parse-env-file.d.ts /** Environment variable object with comments preserved as __l_00, __l_01, etc. */ type EnvObject = Record; /** * Parse a .env file while preserving comments and empty lines * * Lines are stored as __l_00, __l_01, etc. (zero-padded, incremental) Full-line * comments starting with # and empty lines are preserved in their original * order Inline comments are stored as __i_00, __i_01, etc. right before the * value * * @param filePath - Absolute path to .env file * @returns Object with env vars and comment keys */ declare function parseEnvFile(filePath: string): EnvObject; //#endregion //#region src/lib/storage.d.ts /** * One file entry in a stored MAML. * * Either plaintext (`env`) or encrypted (`encrypted_env`, base64 ciphertext of * `JSON.stringify(env)`). The shape is per-entry so a single store can mix * encrypted and plaintext entries during a transition. */ type EnviStoreFile = { path: string; env: EnvObject; } | { path: string; encrypted_env: string; }; /** MAML file structure for storing env configurations */ interface EnviStore { __envi_version: number; metadata: { updated_from: string; updated_at: string; }; files: EnviStoreFile[]; } /** * Get the envi root directory path * * @returns Absolute path to ~/.envi/ */ declare function getEnviDir(): string; /** * Get the envi storage directory path * * @returns Absolute path to ~/.envi/store/ */ declare function getStorageDir(): string; /** * Read package name from manifest files in repository * * Checks package manifest files in priority order (additional files from config * first, then defaults). Supports: package.json, Cargo.toml, go.mod, * pyproject.toml, composer.json, pubspec.yaml, settings.gradle.kts, * settings.gradle, pom.xml * * @param repoPath - Absolute path to repository root * @returns Package name if found, null otherwise */ declare function getPackageName(repoPath: string): string | null; /** * Generate storage filename from package name or repository path * * For scoped packages like @org/name, creates @org/name.maml For unscoped * packages, creates name.maml For repos without package.json, falls back to * folder name * * @param repoPath - Absolute path to repository root * @param packageName - Optional package name (will be read if not provided) * @returns Relative path with .maml extension (may include directory) */ declare function getStorageFilename(repoPath: string, packageName?: string | null): string; interface SaveToStorageOptions { /** * If provided, encrypt each file's `env` block before writing. The same key * is used to decrypt any existing encrypted entries for the no-op * comparison. */ encryptionKey?: string | null; } /** * Save env configuration to storage * * @param repoPath - Absolute path to repository root * @param envFiles - Array of plaintext env file data * @param packageName - Optional package name (will be read if not provided) * @param options - Optional encryption settings * @returns True if file was updated, false if no changes */ declare function saveToStorage(repoPath: string, envFiles: Array<{ path: string; env: EnvObject; }>, packageName?: string | null, options?: SaveToStorageOptions): boolean; //#endregion //#region src/utils/find-env-files.d.ts interface FindEnvFilesResult { /** Paths (relative to repo root) Envi should capture */ files: string[]; /** * Paths that matched the glob but are not gitignored — either tracked or * simply not covered by any ignore rule. They are excluded from `files` * because committing them to the Envi store would shadow the * version-controlled copy or capture a file the user is about to add. */ excluded: string[]; /** * Paths that matched the glob but live inside a nested VCS root (git * worktree, submodule, nested clone, jj/hg/svn checkout). These are skipped * because nested working trees have their own independent state and must be * captured from their own directory. Surfaced separately from `excluded` so * the caller can give the user a distinct, accurate reason. */ skippedNestedVcsRoots: string[]; } interface FindEnvFilesOptions { /** * Extra capture patterns from `envi.config.maml#capture_patterns`. Bare * filenames are auto-expanded to also match nested directories; patterns * containing `/` are used verbatim. Merged with the built-in defaults. */ additionalPatterns?: string[]; } /** * Find env files Envi should capture: `.env`, `.env.*`, Cloudflare Workers' * `.dev.vars` / `.dev.vars.*` (which use the same key=value format), plus any * extra patterns the user has declared in `envi.config.maml`. * * In a git repository, only files that git considers ignored are returned in * `files`. Files that are tracked or otherwise not covered by an ignore rule * are placed in `excluded`. Files inside a nested VCS root (worktree, * submodule, nested clone) are placed in `skippedNestedVcsRoots` regardless of * gitignore status — they belong to an independent working tree. Outside a git * repository — or if `git check-ignore` fails (e.g. git binary missing) — all * matched files are returned and `excluded` is empty. * * @param repoRoot - Absolute path to repository root * @param options - Optional extra capture patterns */ declare function findEnvFiles(repoRoot: string, options?: FindEnvFilesOptions): Promise; //#endregion //#region src/utils/find-repo-root.d.ts /** * Find the repository root by traversing up the directory tree * * @param startDir - Directory to start searching from (defaults to cwd) * @returns Absolute path to repository root, or null if user declined */ declare function findRepoRoot(startDir?: string): Promise; //#endregion //#region src/utils/get-error-message.d.ts /** Extract error message from an unknown error */ declare function getErrorMessage(error: unknown): string; //#endregion export { DEFAULT_MANIFEST_FILES, type EnvObject, type EnviConfig, type EnviStore, type EnviStoreFile, KEY_FILE_NAME, LEGACY_KEY_FILE_NAME, PACKAGE_EXTRACTORS, type PackageExtractor, type WriteEncryptionKeyOptions, addRemote, captureCommand, clearCommand, cloneRepo, commitAndPush, createInitialCommit, createKeyCommand, createPrivateRepo, findEnvFiles, findKeyFile, findRepoRoot, generateKey, getConfigPath, getEnviDir, getErrorMessage, getGhUsername, getKeyFilePath, getPackageName, getStorageDir, getStorageFilename, globalClearCommand, disableCommand as globalGithubDisableCommand, enableCommand as globalGithubEnableCommand, restoreCommand as globalGithubRestoreCommand, hasKeyFile, initGitRepo, initialCommitAndPush, isGhAuthenticated, isGhInstalled, isGitRepo, parseEnvFile, readCapturePatterns, readConfig, readEncryptionKey, repoExists, restoreCommand$1 as restoreCommand, saveToStorage, updateConfig, writeConfig, writeEncryptionKey }; //# sourceMappingURL=index.d.ts.map