This repository is a macOS iMessage/SMS automation tool called `imsg`. It provides a CLI and JSON-RPC interface for reading, watching, and sending messages. The architecture has three layers: a Swift CLI that parses commands and outputs NDJSON or plain text; a core library (`IMsgCore`) that reads the local Messages SQLite database and manages the bridge to Messages.app; and an injected Objective-C dylib (`IMsgHelper`) that hooks into private IMCore APIs for advanced features like typing indicators, polls, stickers, rich links, and message mutations. The tool can fall back to AppleScript automation for basic sends when the bridge is unavailable (e.g., SIP enabled). The RPC server runs over stdio, making it suitable for integration with AI agents and scripts. The codebase is well-tested with unit tests for all layers, including native Objective-C tests for the injected helper. It demonstrates deep reverse-engineering of Apple's private messaging protocols and careful handling of platform-specific quirks. The primary data flow is read-only from the local `chat.db` SQLite database for history and live updates, with write operations going through either AppleScript (via `osascript`) or the injected bridge (via UUID-keyed IPC queues). External dependencies include SQLite.swift, PhoneNumberKit, ffmpeg, afconvert, and private macOS frameworks (IMCore, CNContactStore). The build system uses SwiftPM with custom scripts for universal macOS binaries and Linux static archives. The project is actively maintained with CI, releases, and a documentation site.