import Foundation extension HelderConfig { /// Folder in the project root that holds Helder's per-project state. public static let folderName = ".helder" public static let overridesFileName = "config.json" public static let defaultsFileName = "config.default.json" /// The whole `.helder` folder is machine-local state, so it ignores itself. public static let gitignoreBody = "# Helder — local, machine-specific state (do not commit).\n*\n" /// The effective config for a sparse `config.json`; nil, empty or invalid JSON yields the defaults. public static func resolved(overrides data: Data?) -> HelderConfig { guard let data, !data.isEmpty else { return .defaults } return (try? JSONDecoder().decode(HelderConfig.self, from: data)) ?? .defaults } /// Pretty JSON of every default, rewritten to `config.default.json` on each launch as documentation. public static func defaultsJSON() -> Data { let encoder = JSONEncoder() encoder.outputFormatting = [.prettyPrinted, .sortedKeys, .withoutEscapingSlashes] var data = (try? encoder.encode(HelderConfig.defaults)) ?? Data() data.append(0x0A) return data } }