A luxe hook runs luxe-notify, which sends one JSON line over a Unix socket to a SwiftUI menu bar app. The app shows a banner, keeps a badge count and history, and brings the terminal forward when you click a banner. Notifies on approvals (PermissionRequested), question prompts (BeforeToolUse, matched to the question tool), errors, and turns that run at least --min-seconds (default 30, timed from BeforeAgentStart to AgentEnd). The menu warns when macOS has notifications blocked for the app. The app writes status.txt beside its socket for debugging. Known limits are in README.md and PLAN.md: a crowded menu bar can hide the icon, and the first test build after a change can fail with a TestingMacros error under Command Line Tools, which make test retries once.
29 lines
1.1 KiB
Swift
29 lines
1.1 KiB
Swift
import Foundation
|
|
|
|
/// Plain-text record of what the app saw, because a release build's NSLog lines are hard to read
|
|
/// back. Lives beside the socket so one folder holds everything the app owns.
|
|
enum StatusFile {
|
|
static var path: String {
|
|
(NotifySocketPathHelper.directory as NSString).appendingPathComponent("status.txt")
|
|
}
|
|
|
|
private static var lines: [String: String] = [:]
|
|
private static let lock = NSLock()
|
|
|
|
static func set(_ key: String, _ value: String) {
|
|
lock.lock()
|
|
lines[key] = value
|
|
let text = lines.sorted { $0.key < $1.key }.map { "\($0.key): \($0.value)" }.joined(separator: "\n") + "\n"
|
|
lock.unlock()
|
|
do { try text.write(toFile: path, atomically: true, encoding: .utf8) }
|
|
catch { NSLog("LuxeNotifier: cannot write status file \(path): \(error)") }
|
|
}
|
|
}
|
|
|
|
enum NotifySocketPathHelper {
|
|
static var directory: String {
|
|
let base = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)[0]
|
|
return base.appendingPathComponent("LuxeNotifier").path
|
|
}
|
|
}
|