UNPKG

@bobmatnyc/ai-code-review

Version:

A TypeScript-based tool for automated code reviews using AI models from Google Gemini, Anthropic Claude, and OpenRouter

1,232 lines (1,231 loc) 32 kB
/** * @fileoverview Centralized configuration type definitions. * * This module defines the types for configuration options used throughout the application. * It provides a type-safe way to define, access, and validate configuration settings. */ import { z } from 'zod'; /** * Environment source for a configuration value */ export type EnvSource = 'AI_CODE_REVIEW_GOOGLE_API_KEY' | 'AI_CODE_REVIEW_OPENROUTER_API_KEY' | 'AI_CODE_REVIEW_ANTHROPIC_API_KEY' | 'AI_CODE_REVIEW_OPENAI_API_KEY' | 'AI_CODE_REVIEW_MODEL' | 'AI_CODE_REVIEW_WRITER_MODEL' | 'AI_CODE_REVIEW_LOG_LEVEL' | 'AI_CODE_REVIEW_OUTPUT_DIR' | 'AI_CODE_REVIEW_CONTEXT' | 'AI_CODE_REVIEW_DIR' | 'AI_CODE_REVIEW_DEBUG' | 'CODE_REVIEW_GOOGLE_API_KEY' | 'CODE_REVIEW_OPENROUTER_API_KEY' | 'CODE_REVIEW_ANTHROPIC_API_KEY' | 'CODE_REVIEW_OPENAI_API_KEY' | 'GOOGLE_GENERATIVE_AI_KEY' | 'GOOGLE_AI_STUDIO_KEY' | 'OPENROUTER_API_KEY' | 'ANTHROPIC_API_KEY' | 'OPENAI_API_KEY' | 'cli_option' | 'default_value' | 'none'; /** * Configuration value record with its source */ export interface ConfigValue<T> { value: T; source: EnvSource; } /** * API keys configuration */ export interface ApiKeysConfig { google?: ConfigValue<string>; openRouter?: ConfigValue<string>; anthropic?: ConfigValue<string>; openai?: ConfigValue<string>; } /** * API provider types */ export type ApiProvider = 'gemini' | 'openrouter' | 'anthropic' | 'openai'; /** * API endpoint configuration */ export interface ApiEndpointsConfig { gemini: ConfigValue<string>; openRouter: ConfigValue<string>; anthropic: ConfigValue<string>; openai: ConfigValue<string>; } /** * API version configuration */ export interface ApiVersionsConfig { gemini: ConfigValue<string>; openRouter: ConfigValue<string>; anthropic: ConfigValue<string>; openai: ConfigValue<string>; } /** * Log level type */ export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'none'; /** * Paths configuration */ export interface PathsConfig { outputDir: ConfigValue<string>; promptsDir: ConfigValue<string>; templatesDir: ConfigValue<string>; contextPaths?: ConfigValue<string[]>; } /** * Rate limiting configuration */ export interface RateLimitConfig { tokensPerSecond: ConfigValue<number>; maxConcurrentRequests: ConfigValue<number>; retryDelayMs: ConfigValue<number>; maxRetries: ConfigValue<number>; } /** * Token configuration */ export interface TokenConfig { maxTokensPerRequest: ConfigValue<number>; contextWindowSize: Record<ApiProvider, ConfigValue<number>>; costPerInputToken: Record<ApiProvider, ConfigValue<number>>; costPerOutputToken: Record<ApiProvider, ConfigValue<number>>; } /** * Complete application configuration interface */ export interface ApplicationConfig { apiKeys: ApiKeysConfig; apiEndpoints: ApiEndpointsConfig; apiVersions: ApiVersionsConfig; selectedModel: ConfigValue<string>; writerModel?: ConfigValue<string>; modelProvider: ConfigValue<ApiProvider>; debug: ConfigValue<boolean>; logLevel: ConfigValue<LogLevel>; paths: PathsConfig; rateLimit: RateLimitConfig; tokens: TokenConfig; } /** * Zod schema for application configuration validation */ export declare const applicationConfigSchema: z.ZodObject<{ apiKeys: z.ZodObject<{ google: z.ZodOptional<z.ZodObject<{ value: z.ZodOptional<z.ZodString>; source: z.ZodString; }, "strip", z.ZodTypeAny, { source: string; value?: string | undefined; }, { source: string; value?: string | undefined; }>>; openRouter: z.ZodOptional<z.ZodObject<{ value: z.ZodOptional<z.ZodString>; source: z.ZodString; }, "strip", z.ZodTypeAny, { source: string; value?: string | undefined; }, { source: string; value?: string | undefined; }>>; anthropic: z.ZodOptional<z.ZodObject<{ value: z.ZodOptional<z.ZodString>; source: z.ZodString; }, "strip", z.ZodTypeAny, { source: string; value?: string | undefined; }, { source: string; value?: string | undefined; }>>; openai: z.ZodOptional<z.ZodObject<{ value: z.ZodOptional<z.ZodString>; source: z.ZodString; }, "strip", z.ZodTypeAny, { source: string; value?: string | undefined; }, { source: string; value?: string | undefined; }>>; }, "strip", z.ZodTypeAny, { google?: { source: string; value?: string | undefined; } | undefined; anthropic?: { source: string; value?: string | undefined; } | undefined; openai?: { source: string; value?: string | undefined; } | undefined; openRouter?: { source: string; value?: string | undefined; } | undefined; }, { google?: { source: string; value?: string | undefined; } | undefined; anthropic?: { source: string; value?: string | undefined; } | undefined; openai?: { source: string; value?: string | undefined; } | undefined; openRouter?: { source: string; value?: string | undefined; } | undefined; }>; apiEndpoints: z.ZodObject<{ gemini: z.ZodObject<{ value: z.ZodString; source: z.ZodString; }, "strip", z.ZodTypeAny, { value: string; source: string; }, { value: string; source: string; }>; openRouter: z.ZodObject<{ value: z.ZodString; source: z.ZodString; }, "strip", z.ZodTypeAny, { value: string; source: string; }, { value: string; source: string; }>; anthropic: z.ZodObject<{ value: z.ZodString; source: z.ZodString; }, "strip", z.ZodTypeAny, { value: string; source: string; }, { value: string; source: string; }>; openai: z.ZodObject<{ value: z.ZodString; source: z.ZodString; }, "strip", z.ZodTypeAny, { value: string; source: string; }, { value: string; source: string; }>; }, "strip", z.ZodTypeAny, { gemini: { value: string; source: string; }; anthropic: { value: string; source: string; }; openai: { value: string; source: string; }; openRouter: { value: string; source: string; }; }, { gemini: { value: string; source: string; }; anthropic: { value: string; source: string; }; openai: { value: string; source: string; }; openRouter: { value: string; source: string; }; }>; apiVersions: z.ZodObject<{ gemini: z.ZodObject<{ value: z.ZodString; source: z.ZodString; }, "strip", z.ZodTypeAny, { value: string; source: string; }, { value: string; source: string; }>; openRouter: z.ZodObject<{ value: z.ZodString; source: z.ZodString; }, "strip", z.ZodTypeAny, { value: string; source: string; }, { value: string; source: string; }>; anthropic: z.ZodObject<{ value: z.ZodString; source: z.ZodString; }, "strip", z.ZodTypeAny, { value: string; source: string; }, { value: string; source: string; }>; openai: z.ZodObject<{ value: z.ZodString; source: z.ZodString; }, "strip", z.ZodTypeAny, { value: string; source: string; }, { value: string; source: string; }>; }, "strip", z.ZodTypeAny, { gemini: { value: string; source: string; }; anthropic: { value: string; source: string; }; openai: { value: string; source: string; }; openRouter: { value: string; source: string; }; }, { gemini: { value: string; source: string; }; anthropic: { value: string; source: string; }; openai: { value: string; source: string; }; openRouter: { value: string; source: string; }; }>; selectedModel: z.ZodObject<{ value: z.ZodString; source: z.ZodString; }, "strip", z.ZodTypeAny, { value: string; source: string; }, { value: string; source: string; }>; writerModel: z.ZodOptional<z.ZodObject<{ value: z.ZodString; source: z.ZodString; }, "strip", z.ZodTypeAny, { value: string; source: string; }, { value: string; source: string; }>>; modelProvider: z.ZodObject<{ value: z.ZodEnum<["gemini", "openrouter", "anthropic", "openai"]>; source: z.ZodString; }, "strip", z.ZodTypeAny, { value: "gemini" | "openrouter" | "anthropic" | "openai"; source: string; }, { value: "gemini" | "openrouter" | "anthropic" | "openai"; source: string; }>; debug: z.ZodObject<{ value: z.ZodBoolean; source: z.ZodString; }, "strip", z.ZodTypeAny, { value: boolean; source: string; }, { value: boolean; source: string; }>; logLevel: z.ZodObject<{ value: z.ZodEnum<["debug", "info", "warn", "error", "none"]>; source: z.ZodString; }, "strip", z.ZodTypeAny, { value: "debug" | "info" | "warn" | "error" | "none"; source: string; }, { value: "debug" | "info" | "warn" | "error" | "none"; source: string; }>; paths: z.ZodObject<{ outputDir: z.ZodObject<{ value: z.ZodString; source: z.ZodString; }, "strip", z.ZodTypeAny, { value: string; source: string; }, { value: string; source: string; }>; promptsDir: z.ZodObject<{ value: z.ZodString; source: z.ZodString; }, "strip", z.ZodTypeAny, { value: string; source: string; }, { value: string; source: string; }>; templatesDir: z.ZodObject<{ value: z.ZodString; source: z.ZodString; }, "strip", z.ZodTypeAny, { value: string; source: string; }, { value: string; source: string; }>; contextPaths: z.ZodOptional<z.ZodObject<{ value: z.ZodArray<z.ZodString, "many">; source: z.ZodString; }, "strip", z.ZodTypeAny, { value: string[]; source: string; }, { value: string[]; source: string; }>>; }, "strip", z.ZodTypeAny, { outputDir: { value: string; source: string; }; promptsDir: { value: string; source: string; }; templatesDir: { value: string; source: string; }; contextPaths?: { value: string[]; source: string; } | undefined; }, { outputDir: { value: string; source: string; }; promptsDir: { value: string; source: string; }; templatesDir: { value: string; source: string; }; contextPaths?: { value: string[]; source: string; } | undefined; }>; rateLimit: z.ZodObject<{ tokensPerSecond: z.ZodObject<{ value: z.ZodNumber; source: z.ZodString; }, "strip", z.ZodTypeAny, { value: number; source: string; }, { value: number; source: string; }>; maxConcurrentRequests: z.ZodObject<{ value: z.ZodNumber; source: z.ZodString; }, "strip", z.ZodTypeAny, { value: number; source: string; }, { value: number; source: string; }>; retryDelayMs: z.ZodObject<{ value: z.ZodNumber; source: z.ZodString; }, "strip", z.ZodTypeAny, { value: number; source: string; }, { value: number; source: string; }>; maxRetries: z.ZodObject<{ value: z.ZodNumber; source: z.ZodString; }, "strip", z.ZodTypeAny, { value: number; source: string; }, { value: number; source: string; }>; }, "strip", z.ZodTypeAny, { tokensPerSecond: { value: number; source: string; }; maxConcurrentRequests: { value: number; source: string; }; retryDelayMs: { value: number; source: string; }; maxRetries: { value: number; source: string; }; }, { tokensPerSecond: { value: number; source: string; }; maxConcurrentRequests: { value: number; source: string; }; retryDelayMs: { value: number; source: string; }; maxRetries: { value: number; source: string; }; }>; tokens: z.ZodObject<{ maxTokensPerRequest: z.ZodObject<{ value: z.ZodNumber; source: z.ZodString; }, "strip", z.ZodTypeAny, { value: number; source: string; }, { value: number; source: string; }>; contextWindowSize: z.ZodObject<{ gemini: z.ZodObject<{ value: z.ZodNumber; source: z.ZodString; }, "strip", z.ZodTypeAny, { value: number; source: string; }, { value: number; source: string; }>; openrouter: z.ZodObject<{ value: z.ZodNumber; source: z.ZodString; }, "strip", z.ZodTypeAny, { value: number; source: string; }, { value: number; source: string; }>; anthropic: z.ZodObject<{ value: z.ZodNumber; source: z.ZodString; }, "strip", z.ZodTypeAny, { value: number; source: string; }, { value: number; source: string; }>; openai: z.ZodObject<{ value: z.ZodNumber; source: z.ZodString; }, "strip", z.ZodTypeAny, { value: number; source: string; }, { value: number; source: string; }>; }, "strip", z.ZodTypeAny, { gemini: { value: number; source: string; }; openrouter: { value: number; source: string; }; anthropic: { value: number; source: string; }; openai: { value: number; source: string; }; }, { gemini: { value: number; source: string; }; openrouter: { value: number; source: string; }; anthropic: { value: number; source: string; }; openai: { value: number; source: string; }; }>; costPerInputToken: z.ZodObject<{ gemini: z.ZodObject<{ value: z.ZodNumber; source: z.ZodString; }, "strip", z.ZodTypeAny, { value: number; source: string; }, { value: number; source: string; }>; openrouter: z.ZodObject<{ value: z.ZodNumber; source: z.ZodString; }, "strip", z.ZodTypeAny, { value: number; source: string; }, { value: number; source: string; }>; anthropic: z.ZodObject<{ value: z.ZodNumber; source: z.ZodString; }, "strip", z.ZodTypeAny, { value: number; source: string; }, { value: number; source: string; }>; openai: z.ZodObject<{ value: z.ZodNumber; source: z.ZodString; }, "strip", z.ZodTypeAny, { value: number; source: string; }, { value: number; source: string; }>; }, "strip", z.ZodTypeAny, { gemini: { value: number; source: string; }; openrouter: { value: number; source: string; }; anthropic: { value: number; source: string; }; openai: { value: number; source: string; }; }, { gemini: { value: number; source: string; }; openrouter: { value: number; source: string; }; anthropic: { value: number; source: string; }; openai: { value: number; source: string; }; }>; costPerOutputToken: z.ZodObject<{ gemini: z.ZodObject<{ value: z.ZodNumber; source: z.ZodString; }, "strip", z.ZodTypeAny, { value: number; source: string; }, { value: number; source: string; }>; openrouter: z.ZodObject<{ value: z.ZodNumber; source: z.ZodString; }, "strip", z.ZodTypeAny, { value: number; source: string; }, { value: number; source: string; }>; anthropic: z.ZodObject<{ value: z.ZodNumber; source: z.ZodString; }, "strip", z.ZodTypeAny, { value: number; source: string; }, { value: number; source: string; }>; openai: z.ZodObject<{ value: z.ZodNumber; source: z.ZodString; }, "strip", z.ZodTypeAny, { value: number; source: string; }, { value: number; source: string; }>; }, "strip", z.ZodTypeAny, { gemini: { value: number; source: string; }; openrouter: { value: number; source: string; }; anthropic: { value: number; source: string; }; openai: { value: number; source: string; }; }, { gemini: { value: number; source: string; }; openrouter: { value: number; source: string; }; anthropic: { value: number; source: string; }; openai: { value: number; source: string; }; }>; }, "strip", z.ZodTypeAny, { maxTokensPerRequest: { value: number; source: string; }; contextWindowSize: { gemini: { value: number; source: string; }; openrouter: { value: number; source: string; }; anthropic: { value: number; source: string; }; openai: { value: number; source: string; }; }; costPerInputToken: { gemini: { value: number; source: string; }; openrouter: { value: number; source: string; }; anthropic: { value: number; source: string; }; openai: { value: number; source: string; }; }; costPerOutputToken: { gemini: { value: number; source: string; }; openrouter: { value: number; source: string; }; anthropic: { value: number; source: string; }; openai: { value: number; source: string; }; }; }, { maxTokensPerRequest: { value: number; source: string; }; contextWindowSize: { gemini: { value: number; source: string; }; openrouter: { value: number; source: string; }; anthropic: { value: number; source: string; }; openai: { value: number; source: string; }; }; costPerInputToken: { gemini: { value: number; source: string; }; openrouter: { value: number; source: string; }; anthropic: { value: number; source: string; }; openai: { value: number; source: string; }; }; costPerOutputToken: { gemini: { value: number; source: string; }; openrouter: { value: number; source: string; }; anthropic: { value: number; source: string; }; openai: { value: number; source: string; }; }; }>; }, "strip", z.ZodTypeAny, { debug: { value: boolean; source: string; }; selectedModel: { value: string; source: string; }; logLevel: { value: "debug" | "info" | "warn" | "error" | "none"; source: string; }; rateLimit: { tokensPerSecond: { value: number; source: string; }; maxConcurrentRequests: { value: number; source: string; }; retryDelayMs: { value: number; source: string; }; maxRetries: { value: number; source: string; }; }; apiKeys: { google?: { source: string; value?: string | undefined; } | undefined; anthropic?: { source: string; value?: string | undefined; } | undefined; openai?: { source: string; value?: string | undefined; } | undefined; openRouter?: { source: string; value?: string | undefined; } | undefined; }; apiEndpoints: { gemini: { value: string; source: string; }; anthropic: { value: string; source: string; }; openai: { value: string; source: string; }; openRouter: { value: string; source: string; }; }; apiVersions: { gemini: { value: string; source: string; }; anthropic: { value: string; source: string; }; openai: { value: string; source: string; }; openRouter: { value: string; source: string; }; }; modelProvider: { value: "gemini" | "openrouter" | "anthropic" | "openai"; source: string; }; paths: { outputDir: { value: string; source: string; }; promptsDir: { value: string; source: string; }; templatesDir: { value: string; source: string; }; contextPaths?: { value: string[]; source: string; } | undefined; }; tokens: { maxTokensPerRequest: { value: number; source: string; }; contextWindowSize: { gemini: { value: number; source: string; }; openrouter: { value: number; source: string; }; anthropic: { value: number; source: string; }; openai: { value: number; source: string; }; }; costPerInputToken: { gemini: { value: number; source: string; }; openrouter: { value: number; source: string; }; anthropic: { value: number; source: string; }; openai: { value: number; source: string; }; }; costPerOutputToken: { gemini: { value: number; source: string; }; openrouter: { value: number; source: string; }; anthropic: { value: number; source: string; }; openai: { value: number; source: string; }; }; }; writerModel?: { value: string; source: string; } | undefined; }, { debug: { value: boolean; source: string; }; selectedModel: { value: string; source: string; }; logLevel: { value: "debug" | "info" | "warn" | "error" | "none"; source: string; }; rateLimit: { tokensPerSecond: { value: number; source: string; }; maxConcurrentRequests: { value: number; source: string; }; retryDelayMs: { value: number; source: string; }; maxRetries: { value: number; source: string; }; }; apiKeys: { google?: { source: string; value?: string | undefined; } | undefined; anthropic?: { source: string; value?: string | undefined; } | undefined; openai?: { source: string; value?: string | undefined; } | undefined; openRouter?: { source: string; value?: string | undefined; } | undefined; }; apiEndpoints: { gemini: { value: string; source: string; }; anthropic: { value: string; source: string; }; openai: { value: string; source: string; }; openRouter: { value: string; source: string; }; }; apiVersions: { gemini: { value: string; source: string; }; anthropic: { value: string; source: string; }; openai: { value: string; source: string; }; openRouter: { value: string; source: string; }; }; modelProvider: { value: "gemini" | "openrouter" | "anthropic" | "openai"; source: string; }; paths: { outputDir: { value: string; source: string; }; promptsDir: { value: string; source: string; }; templatesDir: { value: string; source: string; }; contextPaths?: { value: string[]; source: string; } | undefined; }; tokens: { maxTokensPerRequest: { value: number; source: string; }; contextWindowSize: { gemini: { value: number; source: string; }; openrouter: { value: number; source: string; }; anthropic: { value: number; source: string; }; openai: { value: number; source: string; }; }; costPerInputToken: { gemini: { value: number; source: string; }; openrouter: { value: number; source: string; }; anthropic: { value: number; source: string; }; openai: { value: number; source: string; }; }; costPerOutputToken: { gemini: { value: number; source: string; }; openrouter: { value: number; source: string; }; anthropic: { value: number; source: string; }; openai: { value: number; source: string; }; }; }; writerModel?: { value: string; source: string; } | undefined; }>;