$ show openclaw/casa
Casa is a deprecated Mac Catalyst iOS app that exposes local HomeKit accessory data through a loopback-only HTTP REST API on port 14663. The architecture is a SwiftUI Mac app (Casa/) paired with an embedded Swift Package CLI (CasaCLI/) that communicates with the app's local server. The core server (HomeKitServer.swift) uses Apple's Network framework (NWListener) to serve HTTP/1.1, with a custom HTTP request parser and JSON response builder. HomeKit access is gated behind an opt-in module system and requires the HomeKit entitlement. The app includes Sparkle for updates, an onboarding flow, settings persistence via UserDefaults, and a file-based rotating logger. The codebase demonstrates solid engineering practices: the HTTP server is hand-rolled without third-party dependencies, the request parser handles keep-alive and content-length correctly, the JSON envelope pattern is consistent, and the HomeKit mapping layer cleanly separates Apple's types from API DTOs. The test suite covers HTTP parsing, response encoding, schema payload generation, settings persistence, and CLI platform gating. SwiftLint is configured and CI/CD workflows exist for building and releasing. The README explicitly states deprecation and points to a successor (omarshahine/HomeClaw). The last commit was 2026-05-30, and the project uses Swift 5.0 with iOS 16.0 deployment target — both showing moderate drift. The Sparkle feed URL and public key are placeholder values in the pbxproj. The codebase is well-structured but no longer maintained.
The LLM identified 5 files worth highlighting for reuse:
A hand-rolled HTTP/1.1 server using Apple's Network framework (NWListener) with zero third-party dependencies. Implements a custom HTTP request parser (HTTPRequest.parse) supporting keep-alive, content-length enforcement, max header/body size limits, and chunked-encoding rejection. The route method uses async/await with MainActor isolation for HomeKit interop. The HTTPConnectionHandler manages per-connection lifecycle with buffered reading and backpressure. The JSON envelope pattern (requestId, ok, data, latencyMs) is consistent across all responses. This is genuinely reusable as a lightweight local-only HTTP server pattern for any Swift service that needs loopback API exposure without embedding Vapor or similar.
The JSONValue enum with Encodable conformance provides a type-safe JSON representation that avoids the Any/NSNumber casting pitfalls common in Swift. The jsonValue() function correctly handles the CFBooleanGetTypeID() edge case where NSNumber booleans need special-casing, and maps non-finite doubles to null. The HomeKitPayload enum provides a clean namespace for constructing response payloads. This pattern is reusable in any Swift project that needs to build JSON responses from mixed-type data without a full JSON framework.
A thread-safe rotating file logger with configurable max file size (1MB default) and max file count (5 default). Writes JSON-lines format entries to ~/Library/Logs/Casa/casa.log with automatic rotation. Uses a serial dispatch queue for thread safety and exposes a @Published revision counter for SwiftUI observation. The log entry model (CasaLogEntry) is Encodable with structured metadata. This is a clean, self-contained logging component reusable in any Swift application needing structured file logging without external dependencies.
A settings layer using ObservableObject with automatic UserDefaults persistence via didSet hooks. Handles default-value detection correctly by checking `defaults.object(forKey:)` rather than relying on the registered default, which avoids the common bug where bool(forKey:) returns false for both 'false' and 'not set'. Provides a test-only initializer accepting a custom UserDefaults suite for isolated testing. The pattern of guarding persistence with an isLoading flag prevents premature writes during initialization. Reusable as a template for any SwiftUI app's settings management.
Tests that exercise the HTTP request parser (method extraction, keep-alive detection), response envelope encoding (verifying HTTP status line and JSON structure), schema payload generation (writable flag, valid values, non-finite number handling), settings defaults, and persistence round-trips. Uses isolated UserDefaults suites with UUID-based names to avoid test pollution. The test for non-finite number handling (NaN, Infinity) catching is particularly thorough. These tests demonstrate how to test HTTP parsing logic and settings persistence without integration tests.