import Foundation public protocol NotesServicing: Sendable { /// The note's text; "" when the project has none yet. func read() async -> String func write(_ text: String) async throws } /// The note is a plain `.notes.txt` in the project root, not JSON and not in `.helder/`, /// so it stays readable and editable outside Helder. public struct NotesService: NotesServicing { public static let fileName = ".notes.txt" public let root: URL public init(root: URL) { self.root = root } private var url: URL { root.appendingPathComponent(Self.fileName) } public func read() async -> String { (try? String(contentsOf: url, encoding: .utf8)) ?? "" } public func write(_ text: String) async throws { try Data(text.utf8).write(to: url, options: .atomic) } }