Skip to content

Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors

Rust

docs(macos): trim ServerLog doc comments to the companion's style

Nícolas Brandão27ff24f6cd55
diff --git a/companions/ai-memory-macos/Sources/AIMemoryMenuCore/ServerLog.swift b/companions/ai-memory-macos/Sources/AIMemoryMenuCore/ServerLog.swift
index c8ede2b9..244d36dc 100644
--- a/companions/ai-memory-macos/Sources/AIMemoryMenuCore/ServerLog.swift
+++ b/companions/ai-memory-macos/Sources/AIMemoryMenuCore/ServerLog.swift
@@ -1,19 +1,8 @@
import Foundation
-/// Reads the tail of the bundled server's log so the menu extra can show the
-/// reason the LaunchAgent exited — for example a port it cannot bind — instead
-/// of only a red status item.
-///
-/// The server writes its fatal error last, the way `anyhow` renders it:
-///
-/// Error: <context>
-///
-/// Caused by:
-/// <cause>
+/// Reads the tail of the bundled server's log so the menu extra can show why
+/// the LaunchAgent exited instead of only a red status item.
public enum ServerLog {
- /// Returns the trailing `Error:` block from `url`, or `nil` when the file
- /// is missing/unreadable or holds no `Error:` line.
- ///
/// `maxBytes` bounds the read so an unbounded log cannot be pulled into
/// memory just to show one message.
public static func recentError(at url: URL, maxBytes: Int = 64 * 1024) -> String? {
@@ -27,8 +16,6 @@ public enum ServerLog {
return extractError(from: String(decoding: data, as: UTF8.self))
}
- /// Last `Error:` line and everything after it, trimmed. Split out so a test
- /// can exercise the parsing without the filesystem.
static func extractError(from log: String) -> String? {
let lines = log.components(separatedBy: "\n")
guard let start = lines.lastIndex(where: { $0.hasPrefix("Error:") }) else {
@@ -43,14 +30,8 @@ public enum ServerLog {
/// Picks the message the menu extra shows when the server is unreachable.
public enum StartFailure {
- /// Prefers the server's own fatal log line over the transport/decode error
- /// the health poll produced: `Address already in use` explains the failure,
- /// `Could not read /admin/status` does not.
- ///
- /// Only when the agent is installed but stopped — the exit-loop the bind
- /// failure produces. While it is `.running` (or never installed) a log line
- /// left over from an earlier attempt would be misreported over the live
- /// health error.
+ /// Only when the agent is installed but stopped: a log line left over from
+ /// an earlier attempt must not be misreported over the live health error.
public static func message(health: String, launchd: LaunchdState, logURL: URL) -> String {
guard launchd == .stopped,
let logged = ServerLog.recentError(at: logURL)