@bobmatnyc/ai-code-review
Version:
A TypeScript-based tool for automated code reviews using AI models from Google Gemini, Anthropic Claude, and OpenRouter
87 lines (86 loc) • 3.13 kB
TypeScript
/**
* @fileoverview Configuration module for managing environment variables.
*
* This module provides a centralized way to access environment variables with
* proper validation and error handling. It ensures that required variables are
* present and provides type-safe access to configuration values.
*
* Uses Zod for schema validation to ensure type safety and provide clear error messages.
*/
import { z } from 'zod';
import { CliOptions } from '../cli/argumentParser';
/**
* Zod schema for application configuration
*/
export declare const appConfigSchema: z.ZodObject<{
googleApiKey: z.ZodOptional<z.ZodString>;
openRouterApiKey: z.ZodOptional<z.ZodString>;
anthropicApiKey: z.ZodOptional<z.ZodString>;
openAIApiKey: z.ZodOptional<z.ZodString>;
selectedModel: z.ZodString;
writerModel: z.ZodOptional<z.ZodString>;
debug: z.ZodBoolean;
logLevel: z.ZodDefault<z.ZodEnum<["debug", "info", "warn", "error", "none"]>>;
contextPaths: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
outputDir: z.ZodDefault<z.ZodString>;
}, "strip", z.ZodTypeAny, {
debug: boolean;
selectedModel: string;
logLevel: "debug" | "info" | "warn" | "error" | "none";
outputDir: string;
googleApiKey?: string | undefined;
openRouterApiKey?: string | undefined;
anthropicApiKey?: string | undefined;
openAIApiKey?: string | undefined;
writerModel?: string | undefined;
contextPaths?: string[] | undefined;
}, {
debug: boolean;
selectedModel: string;
googleApiKey?: string | undefined;
openRouterApiKey?: string | undefined;
anthropicApiKey?: string | undefined;
openAIApiKey?: string | undefined;
writerModel?: string | undefined;
logLevel?: "debug" | "info" | "warn" | "error" | "none" | undefined;
contextPaths?: string[] | undefined;
outputDir?: string | undefined;
}>;
/**
* Application configuration interface
*/
export type AppConfig = z.infer<typeof appConfigSchema>;
/**
* Get the application configuration
* @param cliOptions Optional CLI options that override environment variables
* @returns Application configuration
*/
export declare function getConfig(cliOptions?: CliOptions): AppConfig;
/**
* Check if any API key is available
* @returns True if at least one API key is available
*/
export declare function hasAnyApiKey(): boolean;
/**
* Get the API key for a specific provider
* @param provider Provider name (gemini, openrouter, anthropic, openai)
* @returns API key or undefined if not available
*/
export declare function getApiKeyForProvider(provider: string): string | undefined;
/**
* Reset the configuration (mainly for testing)
*/
export declare function resetConfig(): void;
/**
* Validate that the configuration has the required API key for the selected model
* @returns Object containing validation result and error message if applicable
*/
export declare function validateConfigForSelectedModel(): {
valid: boolean;
message: string;
};
/**
* Get the path to the prompts directory
* @returns Path to the prompts directory
*/
export declare function getPromptsPath(): string;