/** * Config-as-code manager with hot-reload. * * Watches a JSONC config file (`~/.shroud/shroud.config.json` by default) * and merges it with the base config from `resolveConfig(pluginConfig)`. * * Priority: env vars > config file > plugin config > defaults. * * Supports: * - JSONC (JSON with // and /* comments) * - Keyed field-change callbacks (only fires when watched fields change) * - Generic reload callbacks * - Commit/rollback with 50-version history * - Dashboard read/write via setFields() */ import type { ShroudConfig } from "./types.js"; import { type ConfigIssue } from "./config.js"; /** A versioned config snapshot. */ export interface ConfigCommit { version: number; timestamp: string; description: string; config: Partial; } export declare class ConfigManager { private _configPath; private _historyPath; private _base; private _fileOverrides; private _effective; private _fieldListeners; private _reloadListeners; private _history; private _version; private _watching; constructor(configPath: string, baseConfig: ShroudConfig); /** Current effective config (merged). */ getEffective(): ShroudConfig; /** Raw overrides from the config file. */ getFileOverrides(): Partial; /** Path to the config file. */ getConfigPath(): string; /** Current version number (increments on each commit). */ getCurrentVersion(): number; /** * Register a callback that fires when any of the specified fields change. * The callback is deduplicated: even if multiple watched fields change in * one reload, the callback fires exactly once. */ onFieldChange(fields: string[], callback: () => void): void; /** Register a callback that fires on every successful reload. */ onReload(callback: (config: ShroudConfig) => void): void; startWatching(): void; stopWatching(): void; /** Merge partial config into the file and trigger reload. */ setFields(partial: Partial): { changedFields: string[]; warnings: string[]; }; /** Validate a partial config without applying it. */ validate(partial: Partial): ConfigIssue[]; commit(description: string): ConfigCommit; rollback(version: number): ConfigCommit | null; getHistory(): ConfigCommit[]; /** Generate default config file with all built-in detection rules. */ private _writeDefaultConfig; private _reload; private _loadFile; private _saveFile; private _merge; private _diff; private _loadHistory; private _saveHistory; } /** * Strip // and /* comments from JSONC text. * Handles strings correctly (doesn't strip inside quoted values). */ export declare function stripComments(jsonc: string): string;