AGENT SKILL

macos-test-rig

Drive remote macOS test hosts over SSH - run commands, copy files, capture the screen, launch an app and capture it, and send synthetic keys - through the `mac` script and per-host config. Use when a change must be checked or built on real macOS.

License 许可
MIT
最近更新
2026-11-10
Stars
★ 0
Forks
0

01 前言 Front Matter

name
macos-test-rig
description
Drive remote macOS test hosts over SSH - run commands, copy files, capture the screen, launch an app and capture it, and send synthetic keys - through the `mac` script and per-host config. Use when a change must be checked or built on real macOS.

02 资源文件 2

03 SKILL.md 正文

macOS test rig

Remote Macs reached over SSH, all driven through scripts/mac (relative to this file). Each host is one config file, ~/.config/macos-test-rig/hosts/NAME.env:

MAC_ADDR=192.0.2.10            # IP or hostname (required)
MAC_USER=me                    # default: local $USER
MAC_KEY=~/.ssh/id_ed25519      # default shown
MAC_NOTE="what this host is for: installed tools, display size, known grants"
MAC_VNC_PASSWORD=...           # optional: capture over Screen Sharing (port MAC_VNC_PORT, default 5900)

With MAC_VNC_PASSWORD set, shot, show and doctor capture over Screen Sharing (vncdotool on this host; the file is 0600) instead of screencapture, so they need no Screen Recording grant for sshd. Turn Screen Sharing on in System Settings and set its VNC password, or do both from a shell: sudo launchctl enable system/com.apple.screensharing && sudo launchctl bootstrap system /System/Library/LaunchDaemons/com.apple.screensharing.plist. Such captures carry a "Your screen is being observed" banner. Check the first capture: if it shows Screen Sharing's own login window instead of the desktop, the VNC session is being given a virtual display of its own. Attach it to the console instead, then restart the service with the two launchctl commands above: sudo defaults write /Library/Preferences/com.apple.RemoteManagement VNCAlwaysStartOnConsole -bool true. With that setting /dev/console can read as owned by root, so ignore the doctor's console-user warning when its capture shows the desktop. The fallback is screencapture with the Screen Recording grant for sshd-session (listed as sshd-keygen-wrapper on some versions) under Privacy & Security, Screen & System Audio Recording, in the upper list, not "System Audio Recording Only".

scripts/mac list shows the configured hosts and their notes. Choose a host by its note. If none fits the task, ask the user rather than guessing.

Start every session with

scripts/mac doctor HOST

It wakes the host and checks the OS and console user, screen capture, synthetic input, and sudo. Read the capture it saves: if it shows only wallpaper and no windows, the recording grant is missing.

Commands

Need Command
Host may be asleep mac wake HOST (a sleeping Mac accepts the login and then hangs)
Run something mac ssh HOST 'xcodebuild -version'
Copy files mac put HOST LOCAL [REMOTE], mac get HOST REMOTE LOCAL
Screenshot mac shot HOST OUT.png, then Read the PNG
Launch a GUI app and capture it mac show HOST [--settle S] OUT.png -- COMMAND ARGS
Keyboard mac key HOST 36 (Return; Escape is 53), mac key HOST 12 command (Cmd+Q), mac type HOST 'text'

Rules

  • Launch and capture in one session. Use mac show. A separate mac ssh followed by mac shot misses short-lived windows through timing skew.
  • Treat a hang as a pending consent prompt. If mac key or mac type errors or hangs, TCC is waiting for Accessibility or Automation consent at the console. Screenshot it and ask the user to click Allow.
  • Only wallpaper in captures means TCC was reset, usually by a macOS update. The user must re-grant Screen & System Audio Recording to sshd-session in System Settings.
  • Root steps belong to the user. Without passwordless sudo, stage files in /tmp and give the user the exact command to run, for example ! ssh -t USER@ADDR "sudo installer -pkg /tmp/X.pkg -target /".
  • Record what you learn in the host's MAC_NOTE, such as grants you verified or tools you installed. Project facts belong in that project's AGENTS.md.

04 同仓库更多 Skills