Skip to content

Fix assembly control: helper failed to build on current macOS SDK#272

Open
alexkroman wants to merge 1 commit into
mainfrom
fix-control-helper-build
Open

Fix assembly control: helper failed to build on current macOS SDK#272
alexkroman wants to merge 1 commit into
mainfrom
fix-control-helper-build

Conversation

@alexkroman

Copy link
Copy Markdown
Collaborator

Problem

The bundled macOS UI-control helper (aai_cli/control/macos_ui_control.swift, added in #271) called CGDisplayCreateImage, which is unavailable in current macOS SDKs (removed in favor of ScreenCaptureKit). Because helper.py compiles the helper with swiftc on first use, assembly control died with "Could not build the macOS UI-control helper" on any modern Mac (confirmed failing to compile on the macOS 26.5 SDK).

The file was also never wired into the gatescripts/check.sh only lint/compiled macos_system_audio.swift — so neither the build break nor 10 serious swiftlint --strict violations were caught.

Changes

  • screenshot() now shells out to /usr/sbin/screencapture -x -m (stable across SDK versions, identical {ok, path} PNG contract) instead of the removed CGDisplayCreateImage/NSBitmapImageRep path. Smoke-tested: captures a real PNG.
  • Fix swiftlint --strict violations: scope the CFGetTypeID-guarded force casts with a documented disable (a conditional as? to a CF type is a no-op the compiler rejects — the type-id check is the real guard); collapse handle()'s per-action guard boilerplate into a generic withArg helper (cyclomatic complexity 12 → under 10, behavior identical); fix brace placement and trailing commas.
  • Add .swiftlint.yml allowing the conventional short names x/y/ok/up/id (x/y are the JSON keys shared with helper.py and can't be renamed).
  • Wire both swift helpers into check.sh's swiftlint + compile gates so an SDK-unavailable API can't slip in unbuilt again.

Verification

  • ./scripts/check.sh: All checks passed. (3725 tests, 99.50% coverage; swiftlint 0 violations; swift compile 0 errors)
  • tests/test_control.py + tests/test_control_exec.py: 51 passed
  • No Python lines changed, so patch-coverage/mutation gates have nothing to evaluate

🤖 Generated with Claude Code

The bundled macOS UI-control helper (macos_ui_control.swift, added in #271)
called CGDisplayCreateImage, which is unavailable in current macOS SDKs
(removed in favor of ScreenCaptureKit). Since helper.py compiles the helper
with swiftc on first use, `assembly control` died with "Could not build the
macOS UI-control helper" on any modern Mac. The file was also never wired into
the gate, so neither the build break nor its swiftlint violations were caught.

- screenshot() now shells out to /usr/sbin/screencapture (stable across SDKs,
  same {ok, path} contract) instead of CGDisplayCreateImage/NSBitmapImageRep.
- Fix swiftlint --strict violations: scope the CFGetTypeID-guarded force casts
  with a documented disable, collapse handle()'s per-action guards into a
  generic withArg helper (complexity 12 -> under 10), fix brace placement and
  trailing commas.
- Add .swiftlint.yml allowing the conventional short names x/y/ok/up/id (x/y are
  the JSON keys shared with helper.py and can't be renamed).
- Wire both swift helpers into check.sh's swiftlint + compile gates so an
  SDK-unavailable API can't slip in unbuilt again.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants