/** * Configuration System for OpenCode Diff Plugin * * Manages plugin configuration loading, validation, and access. * Configuration is stored in .opencode/diff-plugin.json */ import { KeyboardAction } from './ui/keyboard-handler.js'; /** * Custom keybinding configuration */ export interface KeybindingConfig { /** The key or key combination (e.g., 'y', 'Ctrl+a', 'Shift+Enter') */ key: string; /** The action to trigger */ action: KeyboardAction; /** Optional description override */ description?: string; } /** * IDE integration configuration */ export interface IDEConfig { /** Whether IDE integration is enabled */ enabled?: boolean; /** Path to the state file for persistence */ stateFilePath?: string; } /** * VSCode-only mode configuration */ export interface VSCodeOnlyConfig { /** Whether to apply changes immediately without TUI */ applyImmediately: boolean; /** Whether to backup original files before applying changes */ backupOriginals: boolean; /** Whether to show notifications when changes are applied */ notificationOnChange: boolean; /** Maximum age in hours for pending changes before auto-cleanup */ maxPendingAgeHours: number; /** Whether to fallback to TUI if VSCode is not available */ fallbackToTuiIfVsCodeClosed: boolean; /** Maximum backup size in bytes (0 = unlimited) */ maxBackupSizeBytes: number; } /** * Plugin configuration interface */ export interface PluginConfig { /** Whether the plugin is enabled */ enabled: boolean; /** Glob patterns for files to auto-accept */ autoAccept: string[]; /** Glob patterns for files to auto-reject */ autoReject: string[]; /** Maximum file size in bytes to display diff for (0 = unlimited) */ maxFileSize: number; /** UI theme preference */ theme: 'light' | 'dark' | 'auto'; /** Whether to show line numbers in diff view */ showLineNumbers: boolean; /** Whether to show confirmation before rejecting all changes */ confirmRejectAll: boolean; /** Custom keyboard shortcuts */ keybindings: KeybindingConfig[]; /** IDE integration configuration */ ide?: IDEConfig; /** Diff viewer mode: 'tui' (terminal UI), 'vscode-only' (VSCode extension), or 'auto' (auto-detect) */ mode?: 'tui' | 'vscode-only' | 'auto'; /** VSCode-only mode configuration */ vscodeOnly?: VSCodeOnlyConfig; } /** * Default configuration values */ export declare const DEFAULT_CONFIG: PluginConfig; /** * Configuration validation error */ export declare class ConfigValidationError extends Error { readonly path: string; constructor(message: string, path: string); } /** * Configuration validation result */ interface ValidationResult { valid: boolean; errors: string[]; } /** * Configuration Manager * * Handles loading, saving, and validating plugin configuration. * Uses .opencode/diff-plugin.json as the config file. */ export declare class ConfigManager { private config; private configPath; private workspaceRoot; /** * Create a new ConfigManager * @param workspaceRoot - The workspace root directory */ constructor(workspaceRoot: string); /** * Load configuration from file or use defaults */ private load; /** * Merge loaded config with defaults */ private mergeWithDefaults; /** * Validate the current configuration */ validate(): ValidationResult; /** * Validate configuration and throw on error */ validateOrThrow(): void; /** * Save current configuration to file */ save(): void; /** * Reload configuration from file */ reload(): void; /** * Update configuration with partial values */ update(updates: Partial): void; /** * Reset configuration to defaults */ reset(): void; /** * Check if plugin is enabled */ isEnabled(): boolean; /** * Get auto-accept glob patterns */ getAutoAcceptPatterns(): string[]; /** * Get auto-reject glob patterns */ getAutoRejectPatterns(): string[]; /** * Get maximum file size in bytes */ getMaxFileSize(): number; /** * Get theme preference */ getTheme(): 'light' | 'dark' | 'auto'; /** * Check if line numbers should be shown */ shouldShowLineNumbers(): boolean; /** * Check if confirmation is required before rejecting all */ shouldConfirmRejectAll(): boolean; /** * Get custom keybindings */ getKeybindings(): KeybindingConfig[]; /** * Get the full configuration object */ getConfig(): PluginConfig; /** * Get the configuration file path */ getConfigPath(): string; /** * Get the diff viewer mode * @returns The current mode: 'tui', 'vscode-only', or 'auto' */ getMode(): 'tui' | 'vscode-only' | 'auto'; /** * Get the VSCode-only mode configuration * @returns The VSCode-only configuration object */ getVSCodeOnlyConfig(): VSCodeOnlyConfig; /** * Check if a file matches any auto-accept pattern */ shouldAutoAccept(filePath: string): boolean; /** * Check if a file matches any auto-reject pattern */ shouldAutoReject(filePath: string): boolean; /** * Check if a file exceeds the maximum file size */ isFileTooLarge(fileSize: number): boolean; /** * Match a file path against glob patterns * Supports basic glob patterns: *, ?, ** */ private matchGlobPatterns; /** * Match a file path against a single glob pattern */ private matchGlob; } export default ConfigManager; //# sourceMappingURL=config.d.ts.map