Skip to content

Declare which resources require Homebrew or Xcode Command Line Tools - #110

Open
kevinwang5658 wants to merge 2 commits into
mainfrom
claude/awesome-planck-n0c17x
Open

kevinwang5658 wants to merge 2 commits into
mainfrom
claude/awesome-planck-n0c17x

Conversation

@kevinwang5658

Copy link
Copy Markdown
Collaborator

Summary

Resources now declare what they need on macOS with requires: requiresOnMacOS(...) (src/utils/requires.ts). The CLI then installs Homebrew and the Xcode Command Line Tools only when a resource in the config needs them. A config with only macos-settings, alias, file, ssh-key, docker, vscode… no longer installs the Command Line Tools.

Annotations (from a scan of every resource's macOS install path)

  • xcode-tools (runs git, make, a compiler or /usr/bin/python3): homebrew, git, git-repository(ies), git-lfs, asdf-plugin, asdf-install, pyenv, rbenv, rust, macports, project-install(s), venv-project, virtualenv-project, pip, pip-sync, npm, openclaw
  • homebrew (installs with brew on macOS; homebrew brings in xcode-tools): asdf, cursor, github-cli, goenv, jenv, the JetBrains IDEs, webstorm, ollama, pgcli, syncthing, uv, virtualenv, codex-app, fnm, xcodes, plus git-lfs, pyenv, rbenv
  • action requires nothing. A script that needs the Command Line Tools declares an xcode-tools resource itself; its description says so.

Fixes found during the scan

  • nvm: installs with METHOD=script (curl). Before, it used git whenever command -v git succeeded, which on a fresh Mac is the /usr/bin/git stub. So nvm no longer needs the Command Line Tools.
  • git:
    • Its check no longer trusts the /usr/bin/git stub, which passes which git; it checks xcode-select -p.
    • When created, it skips the brew install if the Command Line Tools already provide git.
    • It doesn't try to uninstall the system git.
  • ios-simulators: needs Xcode, not the Command Line Tools. It now has a soft dependency on xcodes, and checks that the selected developer directory is Xcode.app before running xcrun, with a clear error. Its example uses xcodes.
  • codex-app: uses installViaPkgMgr / uninstallViaPkgMgr instead of calling brew directly.

Guard rail
src/utils/requires.test.ts scans resource sources. It fails if a resource uses brew or runs git without a matching requires. Exceptions are listed for resources that only use brew when it's already installed or to remove an old install.

Depends on

Test plan

  • npx vitest run src (280 passed), tsc, npm run build
  • The built plugin sends requires for all 86 resource definitions in the initialize response
  • macOS VM (integration tests not run here):
    • fresh Mac: nvm installs without a Command Line Tools dialog
    • fresh Mac: git plans auto-added xcode-tools and doesn't call brew
    • ios-simulators without Xcode.app fails with the new message
    • test/codex/codex-app.test.ts

Generated by Claude Code