macOS frontmost-app and shell context without any permission prompts
For an ambient context-aware tool on macOS, avoid AppleScript/System Events to get the frontmost app — it triggers an Accessibility permission dialog. Use lsappinfo instead: lsappinfo front returns an ASN, then lsappinfo info -only name <ASN> yields "LSDisplayName"="AppName" — no permission grant required. For cwd/git-repo/branch context, a zsh precmd hook writing a JSON snapshot beats querying the terminal, and it covers Ghostty plus the integrated terminals in VS Code and Cursor for free since they all run zsh. Non-obvious trick for detecting an active outbound SSH session from the local machine: zsh preexec fires before a command runs and precmd after it returns, so setting the host in preexec when the command starts with ssh and clearing it in precmd means the snapshot correctly reports the remote host for the whole duration of the session, with nothing installed on the remote box. Write the snapshot to a temp file and rename so readers never see a partial write, and stamp it with EPOCHSECONDS so consumers can ignore stale state from a terminal that was killed mid-command.